@gmb/bitmark-parser 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +147 -11
  2. package/dist/browser/bitmark-parser.min.js +4 -4
  3. package/dist/browser/bitmark-parser.min.js.map +1 -1
  4. package/dist/browser/cjs/index.cjs +439 -67
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +320 -17
  7. package/dist/browser/esm/index.d.ts +320 -17
  8. package/dist/browser/esm/index.js +432 -67
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +317 -29
  11. package/dist/browser/esm/worker-entry.js.map +1 -1
  12. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  13. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  15. package/dist/index.cjs +114 -38
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +315 -17
  18. package/dist/index.d.ts +315 -17
  19. package/dist/index.js +107 -38
  20. package/dist/index.js.map +1 -1
  21. package/dist/legacy.cjs +1 -1
  22. package/dist/legacy.cjs.map +1 -1
  23. package/dist/legacy.js +1 -1
  24. package/dist/legacy.js.map +1 -1
  25. package/dist/worker-entry.cjs.map +1 -1
  26. package/package.json +7 -7
  27. package/schema/bitmark.schema.json +30 -6
  28. package/wasm/bitmark_wasm.d.ts +43 -8
  29. package/wasm/bitmark_wasm.js +165 -19
  30. package/wasm/bitmark_wasm_bg.wasm +0 -0
  31. package/wasm/bitmark_wasm_bg.wasm.d.ts +4 -1
  32. package/wasm/package.json +1 -1
  33. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +43 -8
  34. package/wasm-bitmark-json/bitmark_json_wasm.js +156 -10
  35. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  36. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +4 -1
  37. package/wasm-bitmark-json/package.json +1 -1
  38. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +43 -8
  39. package/wasm-browser-full/bitmark_browser_full_wasm.js +165 -19
  40. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  41. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +4 -1
  42. package/wasm-browser-full/package.json +1 -1
package/README.md CHANGED
@@ -69,9 +69,9 @@ runtime — the API surface never changes:
69
69
 
70
70
  | Feature | Contents | Size (approx.) |
71
71
  | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
72
- | `full` (Node default) | everything: rich `info` metadata + built-in translations + the semantic `diff` | ~990 KB (~378 KB gzip) |
73
- | `browser-full` (browser default) | the same conversions and `diff`, without either | ~783 KB (~317 KB gzip) |
74
- | `bitmark-json` | bitmark ↔ JSON only: `convert`/`canonicalize`/`transform` (formats `auto`/`bitmark`/`json`, plus the `text` and `semantic-tokens` outputs), `info` (JSON only), breakscape, text fragments — no `diff` | ~563 KB (~224 KB gzip) |
72
+ | `full` (Node default) | everything: rich `info` metadata + built-in translations + the semantic `diff` | ~1025 KB (~395 KB gzip) |
73
+ | `browser-full` (browser default) | the same conversions and `diff`, without either | ~818 KB (~333 KB gzip) |
74
+ | `bitmark-json` | bitmark ↔ JSON only: `convert`/`canonicalize`/`transform` (formats `auto`/`bitmark`/`json`, plus the `text`, `semantic-tokens` and `diagnostics` outputs), the editor services, `info` (JSON only), breakscape, text fragments — no `diff` | ~599 KB (~239 KB gzip) |
75
75
 
76
76
  **The rule.** _Every build includes every feature, except the two
77
77
  browser-targeted variants, which each carry an explicit exclusion list._ That
@@ -135,8 +135,10 @@ Notes:
135
135
  the selected variant's `.wasm` is fetched (all three small JS glue modules
136
136
  are in the bundle). Overlapping `init` calls: same-feature calls coalesce; a
137
137
  different-feature call supersedes an unfinished one (last call wins); every
138
- promise resolves once the finally-active module is live. In the browser,
139
- `initSync(bytes, { feature })` instantiates from bytes you supply.
138
+ promise resolves once the finally-active module is live. `init({})` is the
139
+ same request as `init()`. In the browser, `initSync(bytes, { feature })`
140
+ instantiates from bytes you supply, and takes part in the same last-call-wins
141
+ order: an `init` still loading when `initSync` runs never swaps in afterwards.
140
142
  - **Supplying your own `.wasm`**: glue and module are a pair, so name the
141
143
  feature the bytes belong to — `init({ feature, module_or_path })`. The
142
144
  back-compat positional form `init(module_or_path)` stays on `full`, since
@@ -188,10 +190,19 @@ variant compiled out raises `UnsupportedFeatureError` before any wasm call.
188
190
 
189
191
  Convert between bitmark, JSON, and the mapped markup formats (html/xml/…).
190
192
 
193
+ A JSON input may be an array or a single value, each entry a `{ bit: {…} }`
194
+ envelope (the forward output) or a bare bit object. An entry that is not a
195
+ bit produces no bitmark: it is skipped and reported as an `unknown-bit-type`
196
+ issue naming its JSON path (`$[2] is not a bit: no "type" — skipped`) on the
197
+ warnings channel of the CLI (`--warnings`) and the daemon; the bits beside it
198
+ still convert, and a document in which nothing is a bit converts to empty
199
+ output. This `convert` returns a bare string and so cannot show the skip.
200
+ Only malformed JSON *text* throws (`invalid-json`).
201
+
191
202
  Options:
192
203
 
193
204
  - `inputFormat` — `"auto"` (default), `"bitmark"`, `"json"`, or a mapping id (`"html"`, `"xml"`, …)
194
- - `outputFormat` — `"auto"` (default: the opposite direction), `"text"` (lossy plain-text extraction; output-only), or as above
205
+ - `outputFormat` — `"auto"` (default: the opposite direction), `"text"` (lossy plain-text extraction; output-only), `"semantic-tokens"` / `"diagnostics"` / `"lex"` (output-only, bitmark input only — see their sections), or as above
195
206
  - `mode` — `"optimized"` (default) or `"full"`
196
207
  - `warnings` — include validation warnings (default: `false`)
197
208
  - `plainText` — output text as plain text (default: `false`)
@@ -244,7 +255,7 @@ Options:
244
255
  For bitmark input, output is a JSON array of entries with:
245
256
 
246
257
  - `bit` — serialized bit payload
247
- - `parser` — parser metadata, `errors` / `warnings`, and `infos` (informational notices for recoveries that are not necessarily wrong, e.g. text kept as text because it only looks like an unclosed tag). Each issue carries a stable machine-readable `code` (`"unknown-property"`, `"missing-required-tag"`, …) beside its human-readable `message`, plus `text` and `location`. **Branch on `code`** — a shipped code never changes meaning, whereas the message text is not contractual and may be reworded in any release
258
+ - `parser` — parser metadata, `errors` / `warnings`, and `infos` (informational notices for recoveries that are not necessarily wrong: text kept as text because it only looks like an unclosed tag, `unclosed-tag`, or a formatting mark with no partner, `unclosed-formatting` — in bitmark malformed markup is text, not an error). Each issue carries a stable machine-readable `code` (`"unknown-property"`, `"missing-required-tag"`, …) beside its human-readable `message`, plus `text` and `location`. **Branch on `code`** — a shipped code never changes meaning, whereas the message text is not contractual and may be reworded in any release
248
259
  - `bitmark` — source bitmark text (a convenience echo; every bit is fully described by `bit` alone)
249
260
 
250
261
  A region the parser could not read — an unknown bit type, or non-blank text
@@ -272,7 +283,13 @@ Apply a patch document to a document, bit by bit, and re-emit it.
272
283
  before the document reshapes anything; a hook's patches apply after the
273
284
  document's
274
285
  - `inputFormat`, `outputFormat`, `mode`, `pretty`, `indent`,
275
- `spacesAroundValues` — as for `convert`
286
+ `spacesAroundValues` — as for `convert`. `outputFormat` (default `"json"`)
287
+ takes every per-bit format: `"json"`, `"bitmark"`, `"text"` or a mapping id
288
+ such as `"html"` (per-bit text outputs are joined with newlines). The
289
+ whole-document outputs `"lex"`, `"semantic-tokens"` and `"diagnostics"` are
290
+ refused with an `unsupported` error in every driver — use `convert`. An
291
+ explicit `inputFormat` is honoured as given, patch or hooks or not; it is
292
+ never re-detected from the content
276
293
 
277
294
  A patch document addresses bits by their position (or id) in the input
278
295
  **before** any entry is applied, so it reads like a diff:
@@ -356,7 +373,11 @@ issue codes gained or lost, and the rendered `hunks`.
356
373
 
357
374
  #### countBits(input: string): number / splitBits(input: string): BitSlice[]
358
375
 
359
- Count or split the bits of a bitmark/JSON input without full parsing.
376
+ Count or split the bits of a bitmark/JSON input without full parsing. A JSON
377
+ input may be an array or a single value, each entry a `{ bit: {…} }` envelope
378
+ or a bare bit object (the four shapes `convert` accepts); `splitJsonBits`
379
+ always returns envelopes. An entry that is not a bit is not counted and not
380
+ returned — these calls have no warnings channel; `convert` reports the skip.
360
381
 
361
382
  #### semanticTokens(input: string, options?: SemanticTokensOptions): SemanticTokens
362
383
 
@@ -403,7 +424,7 @@ default theme colours it — paste the table into a VS Code extension's
403
424
  | `codeSigil` / `codeLanguage` / `codeBody` | `\|code:` / the language / the body | `keyword` / `type` / `string` |
404
425
  | `imageSigil` / `imageSrc` | `\|image:` / the source | `keyword` / `string` |
405
426
  | `markSigil` | a mark's open and close markers | `operator` |
406
- | `bold` / `italic` / `highlight` / `light` / `inline` | the marked text | `string` |
427
+ | `bold` / `italic` / `highlight` / `light` / `inline` | the marked text (in body text and `bitmark++` values; a string value is one literal `tagText`) | `string` |
407
428
  | `attrSigil` / `attrKey` / `attrValue` | an attr chain's `\|` and `:` / key / value | `operator` / `property` / `string` |
408
429
  | `url` | a bare URL the parser auto-linked | `string` |
409
430
  | `text` | plain body / card / footer text, and every top-level gap | (none) |
@@ -414,7 +435,122 @@ Modifiers, in bit order: the tag classes `property`, `resource`, `title`,
414
435
  `gap`, `mark`, `solution` (every token of a tag of that class, sigils
415
436
  included — exactly one per tag); `comment` (every token of a commented-out
416
437
  bit); `unclosed` (tokens inside a parser unclosed-mark / unclosed-tag
417
- notice). The full contract is `.zen/specs/API-SEM-semantic-tokens.tsp`.
438
+ notice); `bold`, `italic`, `highlight`, `light` (the text of an inline mark
439
+ `==…==\|…\|` whose chain carries that bare key — style it as you style the
440
+ `bold` / `italic` / `highlight` / `light` token types). The full contract is
441
+ `.zen/specs/API-SEM-semantic-tokens.tsp`.
442
+
443
+ #### diagnostics(input: string, options?: DiagnosticsOptions): Diagnostics
444
+
445
+ Every issue the JSON `parser` envelope would carry for bitmark source, as
446
+ LSP 3.17 `Diagnostic`s with editor positions — the typed form of
447
+ `convert(input, { inputFormat: "bitmark", outputFormat: "diagnostics" })`.
448
+ Parse and validate, no serialization: cheap enough for every keystroke. The
449
+ validator owns every issue, so this is exactly the envelope's set — the same
450
+ `code`s, the same spans, the same order (bit by bit) — with the envelope's
451
+ buckets as LSP severities: `errors` → 1 (`DiagnosticSeverity.Error`),
452
+ `warnings` → 2, `infos` → 3. Bitmark input only.
453
+
454
+ ```js
455
+ import { diagnostics, DiagnosticSeverity } from "@gmb/bitmark-parser";
456
+
457
+ const { positionEncoding, diagnostics: list } = diagnostics(source);
458
+ // list[i] = {
459
+ // range: { start: { line, character }, end: { line, character } }, // 0-based, UTF-16 units
460
+ // severity: 2, // DiagnosticSeverity.Warning
461
+ // code: "unknown-property", // the contract — branch on this
462
+ // source: "bitmark",
463
+ // message: "[@nope] is an unknown property …", // prose, may change
464
+ // data: { bit: 0 }, // the bit's index in the JSON array
465
+ // }
466
+ ```
467
+
468
+ Option: `positionEncoding` — `"utf-16"` (default) or `"utf-8"`, as for
469
+ `semanticTokens`; echoed in the response. The types (`Diagnostic`, `Range`,
470
+ `Position`, `DiagnosticSeverity`) are written field for field as the
471
+ protocol defines them, so a `Diagnostic` assigns to Monaco's marker input
472
+ and to `vscode-languageserver-types` without a cast, and the package keeps
473
+ its zero runtime dependencies. In every wasm variant. The contract is
474
+ `.zen/specs/API-EDT-editor-services.tsp`.
475
+
476
+ #### complete(input, position, options?) / resolve(input, position, item, options?) / hover(input, position, options?)
477
+
478
+ The editor position queries, in LSP 3.17 shapes (PLAN-196, PLAN-202). Positions are
479
+ 0-based `{ line, character }` in `positionEncoding` units — `"utf-16"` by
480
+ default, as for `semanticTokens`.
481
+
482
+ `complete` returns an LSP `CompletionList` of everything valid at the cursor:
483
+
484
+ | where the cursor is | what you get |
485
+ | --- | --- |
486
+ | a bit header's type (`[.art`) | every bit type (`kind: Class`), with its title |
487
+ | a header's `:format` / `&resource` | the body formats / the resource types this bit allows |
488
+ | a tag, or body / card / footer text | the tags valid in THAT scope — the bit body, a card variant, a chain — minus those already at their maximum, the ones the scope still requires sorted first (the first `preselect`ed) |
489
+ | a tag's value | an `enum` tag's vocabulary, a `boolean` tag's `true` / `false` |
490
+ | after a tag's `]` | that tag's chain children |
491
+ | an inline attribute chain (`==x==\|bo`) | the attribute keys, and the closed value set of one that has it |
492
+ | a line holding a prefix of one (empty, `=`, `==== f`) | the structural lines the bit's card set allows there (`====`, `--`, `++`), `==== footer ====`, `==== text ====` — each documented |
493
+ | bitmark text (body text, a `bitmark++` tag's value), after none, `=` or `==` | the inline mark `==…==\|…\|` as a snippet (`insertTextFormat: 2`); never in a string value or a plain region |
494
+
495
+ Items carry `kind`, `detail`, `tags: [1]` when deprecated, `sortText`,
496
+ `insertText`, and — in LSP's own `data` slot — the `info` record behind
497
+ them, so you can build UI from fields rather than prose. `isIncomplete` is
498
+ always `false`: every candidate for the context comes back and filtering by
499
+ the typed prefix is the editor's job. A half-typed `[@wi`, `[.art` or
500
+ `==x==\|bo` resolves as if it were closed. A header resource attachment
501
+ (`[.flashcard&image]`) is offered at the bit's level until it is there; a
502
+ tag whose label is only its sigil (`%`, `!`) leads its `detail` with its
503
+ name (`item`, `instruction`). The result adds one field beyond LSP,
504
+ `context`, saying where the query resolved.
505
+
506
+ Pass `triggerCharacter` in the options when a character opened the query
507
+ (LSP `CompletionContext.triggerCharacter`; Monaco and VS Code hand it to the
508
+ provider). A trigger that opens nothing where the cursor is — a `.` or a
509
+ `-` typed in prose — answers an empty list; `[` opens a tag anywhere, and
510
+ `=` / `-` / `+` narrow the list to the structural lines they begin. An
511
+ explicit invocation (Ctrl+Space) is never narrowed. Editors that open the
512
+ list on every letter (Monaco's `quickSuggestions`) should turn that off for
513
+ bitmark: it is prose with markup in it.
514
+
515
+ Items carry NO `documentation` (PLAN-202): a header's list is every bit type,
516
+ and its prose would be most of the bytes of every list. `resolve` is LSP's
517
+ `completionItem/resolve` — pass the same `input` and `position` you gave
518
+ `complete` plus one item as it was listed, and get that item back with its
519
+ Markdown `documentation` (a bit's title and description; a tag's format,
520
+ count, default, JSON key, chain and description in this scope; an inline
521
+ attribute's shape). Wire it to Monaco's `resolveCompletionItem` or an LSP
522
+ server's resolve handler, so only the item about to be shown is rendered.
523
+ When the list at that position no longer holds the item, the item comes
524
+ back as given.
525
+
526
+ `hover` returns an LSP `Hover` — Markdown `contents` plus the record in
527
+ `data` — for the bit type, a tag AS RESOLVED IN ITS SCOPE (the same record
528
+ `info({ infoType: "bit", full: true })` shows for it there), a tag value, a
529
+ header resource type, or an inline attribute key or value. It is `null` on
530
+ body text, dividers and whitespace.
531
+
532
+ ```js
533
+ import { complete, resolve, hover, CompletionItemKind } from "@gmb/bitmark-parser";
534
+
535
+ const list = complete("[.article]\n[@", { line: 1, character: 2 });
536
+ list.context; // { bit: "article", scope: "bit" }
537
+ list.items.filter((i) => i.kind === CompletionItemKind.Property).map((i) => i.label);
538
+
539
+ const id = list.items.find((i) => i.label === "@id");
540
+ resolve("[.article]\n[@", { line: 1, character: 2 }, id).documentation.value; // Markdown for @id here
541
+
542
+ const h = hover("[.article]\n[@id:1]", { line: 1, character: 2 });
543
+ h.contents.value; // Markdown: format, count, default, JSON key, description
544
+ h.data.tag; // the info record for @id in this bit
545
+ ```
546
+
547
+ Both need a variant built with `editor` (all three are) — otherwise they
548
+ throw `UnsupportedFeatureError`. All three read bitmark SOURCE, so a JSON
549
+ document is refused; an empty buffer, or one that is still only frontmatter,
550
+ is source being typed and is answered normally (an empty one's `complete`
551
+ offers the bit types). The CLI has the same three services under one
552
+ command: `bitmark editor diagnostics|complete|resolve|hover`. The contract is
553
+ `.zen/specs/API-EDT-editor-services.tsp`.
418
554
 
419
555
  #### The `lex` output format
420
556
 
@@ -1,5 +1,5 @@
1
- var de=Object.defineProperty;var _n=(t,e,r)=>e in t?de(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var Rt=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:true});};var J=(t,e,r)=>_n(t,typeof e!="symbol"?e+"":e,r);var Kt={};Rt(Kt,{breakscape_text:()=>fn,canonicalize:()=>In,convert:()=>On,convert_text:()=>wn,count_bits:()=>Fn,default:()=>$t,diff:()=>hn,info:()=>bn,info_text_supported:()=>mn,initSync:()=>zt,is_bitmark:()=>Sn,prettify:()=>En,register:()=>Tn,resolve_patch_document:()=>vn,split_bits:()=>Rn,split_json_bits:()=>Bn,transform:()=>kn,unbreakscape_text:()=>gn});var p,le=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&le.decode();var wt=null;function St(){return (wt===null||wt.byteLength===0)&&(wt=new Uint8Array(p.memory.buffer)),wt}function G(t,e){return t=t>>>0,le.decode(St().subarray(t,t+e))}var Q=new Array(128).fill(void 0);Q.push(void 0,null,true,false);var kt=Q.length;function dn(t){kt===Q.length&&Q.push(Q.length+1);let e=kt;return kt=Q[e],Q[e]=t,e}var O=0,Bt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},ln=typeof Bt.encodeInto=="function"?function(t,e){return Bt.encodeInto(t,e)}:function(t,e){let r=Bt.encode(t);return e.set(r),{read:t.length,written:r.length}};function R(t,e,r){if(r===void 0){let i=Bt.encode(t),c=e(i.length,1)>>>0;return St().subarray(c,c+i.length).set(i),O=i.length,c}let n=t.length,o=e(n,1)>>>0,a=St(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=St().subarray(o+s,o+n),c=ln(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return O=s,o}var st=null;function h(){return (st===null||st.buffer.detached===true||st.buffer.detached===void 0&&st.buffer!==p.memory.buffer)&&(st=new DataView(p.memory.buffer)),st}function fn(t,e,r){let n,o;try{let i=p.__wbindgen_add_to_stack_pointer(-16),c=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),_=O,l=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),f=O,g=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),m=O;p.breakscape_text(i,c,_,l,f,g,m);var a=h().getInt32(i+0,!0),s=h().getInt32(i+4,!0);return n=a,o=s,G(a,s)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,o,1);}}function gn(t,e,r){let n,o;try{let i=p.__wbindgen_add_to_stack_pointer(-16),c=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),_=O,l=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),f=O,g=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),m=O;p.unbreakscape_text(i,c,_,l,f,g,m);var a=h().getInt32(i+0,!0),s=h().getInt32(i+4,!0);return n=a,o=s,G(a,s)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,o,1);}}function bn(t,e,r,n,o,a,s,i,c){let _,l;try{let m=p.__wbindgen_add_to_stack_pointer(-16),x=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),k=O,b=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),y=O,w=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),v=O,F=R(c,p.__wbindgen_export_0,p.__wbindgen_export_1),L=O;p.info(m,x,k,b,y,w,v,n,o,a,s,i,F,L);var f=h().getInt32(m+0,!0),g=h().getInt32(m+4,!0);return _=f,l=g,G(f,g)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(_,l,1);}}function mn(){return p.info_text_supported()!==0}function yn(t){return Q[t]}function xn(t){t<132||(Q[t]=kt,kt=t);}function Z(t){let e=yn(t);return xn(t),e}function wn(t,e,r,n){let o,a;try{let g=p.__wbindgen_add_to_stack_pointer(-16),m=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O,k=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),b=O,y=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O,v=R(n,p.__wbindgen_export_0,p.__wbindgen_export_1),F=O;p.convert_text(g,m,x,k,b,y,w,v,F);var s=h().getInt32(g+0,!0),i=h().getInt32(g+4,!0),c=h().getInt32(g+8,!0),_=h().getInt32(g+12,!0),l=s,f=i;if(_)throw l=0,f=0,Z(c);return o=l,a=f,G(l,f)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function kn(t,e,r,n,o,a,s,i){let c,_;try{let b=p.__wbindgen_add_to_stack_pointer(-16),y=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O,v=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),F=O,L=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),N=O,V=R(n,p.__wbindgen_export_0,p.__wbindgen_export_1),U=O,H=R(o,p.__wbindgen_export_0,p.__wbindgen_export_1),Y=O;p.transform(b,y,w,v,F,L,N,V,U,H,Y,a,s,i);var l=h().getInt32(b+0,!0),f=h().getInt32(b+4,!0),g=h().getInt32(b+8,!0),m=h().getInt32(b+12,!0),x=l,k=f;if(m)throw x=0,k=0,Z(g);return c=x,_=k,G(x,k)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(c,_,1);}}function vn(t,e){let r,n;try{let l=p.__wbindgen_add_to_stack_pointer(-16),f=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),g=O,m=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O;p.resolve_patch_document(l,f,g,m,x);var o=h().getInt32(l+0,!0),a=h().getInt32(l+4,!0),s=h().getInt32(l+8,!0),i=h().getInt32(l+12,!0),c=o,_=a;if(i)throw c=0,_=0,Z(s);return r=c,n=_,G(c,_)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(r,n,1);}}function hn(t,e,r,n,o,a,s,i,c){let _,l;try{let y=p.__wbindgen_add_to_stack_pointer(-16),w=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),v=O,F=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),L=O,N=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),V=O,U=R(n,p.__wbindgen_export_0,p.__wbindgen_export_1),H=O;p.diff(y,w,v,F,L,N,V,U,H,o,a,s,i,c);var f=h().getInt32(y+0,!0),g=h().getInt32(y+4,!0),m=h().getInt32(y+8,!0),x=h().getInt32(y+12,!0),k=f,b=g;if(x)throw k=0,b=0,Z(m);return _=k,l=b,G(k,b)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(_,l,1);}}function Tn(t,e){try{let o=p.__wbindgen_add_to_stack_pointer(-16),a=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),s=O,i=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),c=O;p.register(o,a,s,i,c);var r=h().getInt32(o+0,!0),n=h().getInt32(o+4,!0);if(n)throw Z(r)}finally{p.__wbindgen_add_to_stack_pointer(16);}}function On(t,e,r,n,o,a,s,i,c,_,l){let f,g;try{let v=p.__wbindgen_add_to_stack_pointer(-16),F=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),L=O,N=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),V=O,U=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),H=O,Y=R(n,p.__wbindgen_export_0,p.__wbindgen_export_1),gt=O,bt=R(_,p.__wbindgen_export_0,p.__wbindgen_export_1),mt=O,yt=R(l,p.__wbindgen_export_0,p.__wbindgen_export_1),xt=O;p.convert(v,F,L,N,V,U,H,Y,gt,o,a,s,i,c,bt,mt,yt,xt);var m=h().getInt32(v+0,!0),x=h().getInt32(v+4,!0),k=h().getInt32(v+8,!0),b=h().getInt32(v+12,!0),y=m,w=x;if(b)throw y=0,w=0,Z(k);return f=y,g=w,G(y,w)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(f,g,1);}}function In(t,e,r,n,o,a){let s,i;try{let x=p.__wbindgen_add_to_stack_pointer(-16),k=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),b=O,y=R(e,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O,v=R(r,p.__wbindgen_export_0,p.__wbindgen_export_1),F=O;p.canonicalize(x,k,b,y,w,v,F,n,o,a);var c=h().getInt32(x+0,!0),_=h().getInt32(x+4,!0),l=h().getInt32(x+8,!0),f=h().getInt32(x+12,!0),g=c,m=_;if(f)throw g=0,m=0,Z(l);return s=g,i=m,G(g,m)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(s,i,1);}}function Fn(t){let e,r;try{let _=p.__wbindgen_add_to_stack_pointer(-16),l=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),f=O;p.count_bits(_,l,f);var n=h().getInt32(_+0,!0),o=h().getInt32(_+4,!0),a=h().getInt32(_+8,!0),s=h().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,Z(a);return e=i,r=c,G(i,c)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function Rn(t){let e,r;try{let a=p.__wbindgen_add_to_stack_pointer(-16),s=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),i=O;p.split_bits(a,s,i);var n=h().getInt32(a+0,!0),o=h().getInt32(a+4,!0);return e=n,r=o,G(n,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function Sn(t){let e=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),r=O;return p.is_bitmark(e,r)!==0}function Bn(t){let e,r;try{let _=p.__wbindgen_add_to_stack_pointer(-16),l=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),f=O;p.split_json_bits(_,l,f);var n=h().getInt32(_+0,!0),o=h().getInt32(_+4,!0),a=h().getInt32(_+8,!0),s=h().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,Z(a);return e=i,r=c,G(i,c)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function En(t,e){let r,n;try{let s=p.__wbindgen_add_to_stack_pointer(-16),i=R(t,p.__wbindgen_export_0,p.__wbindgen_export_1),c=O;p.prettify(s,i,c,e);var o=h().getInt32(s+0,!0),a=h().getInt32(s+4,!0);return r=o,n=a,G(o,a)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(r,n,1);}}async function An(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function fe(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(G(e,r));return dn(n)},t}function ge(t,e){return p=t.exports,be.__wbindgen_wasm_module=e,st=null,wt=null,p}function zt(t){if(p!==void 0)return p;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=fe();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return ge(r,t)}async function be(t){if(p!==void 0)return p;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_wasm_bg.wasm",import.meta.url));let e=fe();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await An(await t,e);return ge(r,n)}var $t=be;var Xt={};Rt(Xt,{breakscape_text:()=>Ln,canonicalize:()=>$n,convert:()=>zn,convert_text:()=>Nn,count_bits:()=>Kn,default:()=>Yt,diff:()=>Hn,info:()=>Cn,info_text_supported:()=>Jn,initSync:()=>qt,is_bitmark:()=>Yn,prettify:()=>Qn,register:()=>Gn,resolve_patch_document:()=>Un,split_bits:()=>qn,split_json_bits:()=>Xn,transform:()=>Vn,unbreakscape_text:()=>Wn});var u,me=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&me.decode();var vt=null;function Et(){return (vt===null||vt.byteLength===0)&&(vt=new Uint8Array(u.memory.buffer)),vt}function z(t,e){return t=t>>>0,me.decode(Et().subarray(t,t+e))}var tt=new Array(128).fill(void 0);tt.push(void 0,null,true,false);var ht=tt.length;function jn(t){ht===tt.length&&tt.push(tt.length+1);let e=ht;return ht=tt[e],tt[e]=t,e}var I=0,At=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Pn=typeof At.encodeInto=="function"?function(t,e){return At.encodeInto(t,e)}:function(t,e){let r=At.encode(t);return e.set(r),{read:t.length,written:r.length}};function S(t,e,r){if(r===void 0){let i=At.encode(t),c=e(i.length,1)>>>0;return Et().subarray(c,c+i.length).set(i),I=i.length,c}let n=t.length,o=e(n,1)>>>0,a=Et(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=Et().subarray(o+s,o+n),c=Pn(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return I=s,o}var at=null;function T(){return (at===null||at.buffer.detached===true||at.buffer.detached===void 0&&at.buffer!==u.memory.buffer)&&(at=new DataView(u.memory.buffer)),at}function Ln(t,e,r){let n,o;try{let i=u.__wbindgen_add_to_stack_pointer(-16),c=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),_=I,l=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),f=I,g=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),m=I;u.breakscape_text(i,c,_,l,f,g,m);var a=T().getInt32(i+0,!0),s=T().getInt32(i+4,!0);return n=a,o=s,z(a,s)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(n,o,1);}}function Wn(t,e,r){let n,o;try{let i=u.__wbindgen_add_to_stack_pointer(-16),c=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),_=I,l=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),f=I,g=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),m=I;u.unbreakscape_text(i,c,_,l,f,g,m);var a=T().getInt32(i+0,!0),s=T().getInt32(i+4,!0);return n=a,o=s,z(a,s)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(n,o,1);}}function Cn(t,e,r,n,o,a,s,i,c){let _,l;try{let m=u.__wbindgen_add_to_stack_pointer(-16),x=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),k=I,b=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),y=I,w=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),v=I,F=S(c,u.__wbindgen_export_0,u.__wbindgen_export_1),L=I;u.info(m,x,k,b,y,w,v,n,o,a,s,i,F,L);var f=T().getInt32(m+0,!0),g=T().getInt32(m+4,!0);return _=f,l=g,z(f,g)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(_,l,1);}}function Jn(){return u.info_text_supported()!==0}function Mn(t){return tt[t]}function Dn(t){t<132||(tt[t]=ht,ht=t);}function et(t){let e=Mn(t);return Dn(t),e}function Nn(t,e,r,n){let o,a;try{let g=u.__wbindgen_add_to_stack_pointer(-16),m=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),x=I,k=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),b=I,y=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),w=I,v=S(n,u.__wbindgen_export_0,u.__wbindgen_export_1),F=I;u.convert_text(g,m,x,k,b,y,w,v,F);var s=T().getInt32(g+0,!0),i=T().getInt32(g+4,!0),c=T().getInt32(g+8,!0),_=T().getInt32(g+12,!0),l=s,f=i;if(_)throw l=0,f=0,et(c);return o=l,a=f,z(l,f)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(o,a,1);}}function Vn(t,e,r,n,o,a,s,i){let c,_;try{let b=u.__wbindgen_add_to_stack_pointer(-16),y=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),w=I,v=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),F=I,L=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),N=I,V=S(n,u.__wbindgen_export_0,u.__wbindgen_export_1),U=I,H=S(o,u.__wbindgen_export_0,u.__wbindgen_export_1),Y=I;u.transform(b,y,w,v,F,L,N,V,U,H,Y,a,s,i);var l=T().getInt32(b+0,!0),f=T().getInt32(b+4,!0),g=T().getInt32(b+8,!0),m=T().getInt32(b+12,!0),x=l,k=f;if(m)throw x=0,k=0,et(g);return c=x,_=k,z(x,k)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(c,_,1);}}function Un(t,e){let r,n;try{let l=u.__wbindgen_add_to_stack_pointer(-16),f=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),g=I,m=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),x=I;u.resolve_patch_document(l,f,g,m,x);var o=T().getInt32(l+0,!0),a=T().getInt32(l+4,!0),s=T().getInt32(l+8,!0),i=T().getInt32(l+12,!0),c=o,_=a;if(i)throw c=0,_=0,et(s);return r=c,n=_,z(c,_)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(r,n,1);}}function Hn(t,e,r,n,o,a,s,i,c){let _,l;try{let y=u.__wbindgen_add_to_stack_pointer(-16),w=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),v=I,F=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),L=I,N=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),V=I,U=S(n,u.__wbindgen_export_0,u.__wbindgen_export_1),H=I;u.diff(y,w,v,F,L,N,V,U,H,o,a,s,i,c);var f=T().getInt32(y+0,!0),g=T().getInt32(y+4,!0),m=T().getInt32(y+8,!0),x=T().getInt32(y+12,!0),k=f,b=g;if(x)throw k=0,b=0,et(m);return _=k,l=b,z(k,b)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(_,l,1);}}function Gn(t,e){try{let o=u.__wbindgen_add_to_stack_pointer(-16),a=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),s=I,i=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),c=I;u.register(o,a,s,i,c);var r=T().getInt32(o+0,!0),n=T().getInt32(o+4,!0);if(n)throw et(r)}finally{u.__wbindgen_add_to_stack_pointer(16);}}function zn(t,e,r,n,o,a,s,i,c,_,l){let f,g;try{let v=u.__wbindgen_add_to_stack_pointer(-16),F=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),L=I,N=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),V=I,U=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),H=I,Y=S(n,u.__wbindgen_export_0,u.__wbindgen_export_1),gt=I,bt=S(_,u.__wbindgen_export_0,u.__wbindgen_export_1),mt=I,yt=S(l,u.__wbindgen_export_0,u.__wbindgen_export_1),xt=I;u.convert(v,F,L,N,V,U,H,Y,gt,o,a,s,i,c,bt,mt,yt,xt);var m=T().getInt32(v+0,!0),x=T().getInt32(v+4,!0),k=T().getInt32(v+8,!0),b=T().getInt32(v+12,!0),y=m,w=x;if(b)throw y=0,w=0,et(k);return f=y,g=w,z(y,w)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(f,g,1);}}function $n(t,e,r,n,o,a){let s,i;try{let x=u.__wbindgen_add_to_stack_pointer(-16),k=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),b=I,y=S(e,u.__wbindgen_export_0,u.__wbindgen_export_1),w=I,v=S(r,u.__wbindgen_export_0,u.__wbindgen_export_1),F=I;u.canonicalize(x,k,b,y,w,v,F,n,o,a);var c=T().getInt32(x+0,!0),_=T().getInt32(x+4,!0),l=T().getInt32(x+8,!0),f=T().getInt32(x+12,!0),g=c,m=_;if(f)throw g=0,m=0,et(l);return s=g,i=m,z(g,m)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(s,i,1);}}function Kn(t){let e,r;try{let _=u.__wbindgen_add_to_stack_pointer(-16),l=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),f=I;u.count_bits(_,l,f);var n=T().getInt32(_+0,!0),o=T().getInt32(_+4,!0),a=T().getInt32(_+8,!0),s=T().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,et(a);return e=i,r=c,z(i,c)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function qn(t){let e,r;try{let a=u.__wbindgen_add_to_stack_pointer(-16),s=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),i=I;u.split_bits(a,s,i);var n=T().getInt32(a+0,!0),o=T().getInt32(a+4,!0);return e=n,r=o,z(n,o)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function Yn(t){let e=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),r=I;return u.is_bitmark(e,r)!==0}function Xn(t){let e,r;try{let _=u.__wbindgen_add_to_stack_pointer(-16),l=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),f=I;u.split_json_bits(_,l,f);var n=T().getInt32(_+0,!0),o=T().getInt32(_+4,!0),a=T().getInt32(_+8,!0),s=T().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,et(a);return e=i,r=c,z(i,c)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function Qn(t,e){let r,n;try{let s=u.__wbindgen_add_to_stack_pointer(-16),i=S(t,u.__wbindgen_export_0,u.__wbindgen_export_1),c=I;u.prettify(s,i,c,e);var o=T().getInt32(s+0,!0),a=T().getInt32(s+4,!0);return r=o,n=a,z(o,a)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(r,n,1);}}async function Zn(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function ye(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(z(e,r));return jn(n)},t}function xe(t,e){return u=t.exports,we.__wbindgen_wasm_module=e,at=null,vt=null,u}function qt(t){if(u!==void 0)return u;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=ye();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return xe(r,t)}async function we(t){if(u!==void 0)return u;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_browser_full_wasm_bg.wasm",import.meta.url));let e=ye();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await Zn(await t,e);return xe(r,n)}var Yt=we;var te={};Rt(te,{breakscape_text:()=>nr,canonicalize:()=>_r,convert:()=>ur,convert_text:()=>mr,count_bits:()=>dr,default:()=>Zt,info:()=>or,initSync:()=>Qt,is_bitmark:()=>fr,prettify:()=>br,register:()=>ar,resolve_patch_document:()=>pr,split_bits:()=>lr,split_json_bits:()=>gr,transform:()=>cr,unbreakscape_text:()=>rr});var d,ke=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ke.decode();var Tt=null;function jt(){return (Tt===null||Tt.byteLength===0)&&(Tt=new Uint8Array(d.memory.buffer)),Tt}function K(t,e){return t=t>>>0,ke.decode(jt().subarray(t,t+e))}var nt=new Array(128).fill(void 0);nt.push(void 0,null,true,false);var Ot=nt.length;function tr(t){Ot===nt.length&&nt.push(nt.length+1);let e=Ot;return Ot=nt[e],nt[e]=t,e}var E=0,Pt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},er=typeof Pt.encodeInto=="function"?function(t,e){return Pt.encodeInto(t,e)}:function(t,e){let r=Pt.encode(t);return e.set(r),{read:t.length,written:r.length}};function A(t,e,r){if(r===void 0){let i=Pt.encode(t),c=e(i.length,1)>>>0;return jt().subarray(c,c+i.length).set(i),E=i.length,c}let n=t.length,o=e(n,1)>>>0,a=jt(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=jt().subarray(o+s,o+n),c=er(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return E=s,o}var ct=null;function B(){return (ct===null||ct.buffer.detached===true||ct.buffer.detached===void 0&&ct.buffer!==d.memory.buffer)&&(ct=new DataView(d.memory.buffer)),ct}function nr(t,e,r){let n,o;try{let i=d.__wbindgen_add_to_stack_pointer(-16),c=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),_=E,l=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),f=E,g=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),m=E;d.breakscape_text(i,c,_,l,f,g,m);var a=B().getInt32(i+0,!0),s=B().getInt32(i+4,!0);return n=a,o=s,K(a,s)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(n,o,1);}}function rr(t,e,r){let n,o;try{let i=d.__wbindgen_add_to_stack_pointer(-16),c=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),_=E,l=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),f=E,g=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),m=E;d.unbreakscape_text(i,c,_,l,f,g,m);var a=B().getInt32(i+0,!0),s=B().getInt32(i+4,!0);return n=a,o=s,K(a,s)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(n,o,1);}}function or(t,e,r,n,o,a,s,i,c){let _,l;try{let m=d.__wbindgen_add_to_stack_pointer(-16),x=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),k=E,b=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),y=E,w=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),v=E,F=A(c,d.__wbindgen_export_0,d.__wbindgen_export_1),L=E;d.info(m,x,k,b,y,w,v,n,o,a,s,i,F,L);var f=B().getInt32(m+0,!0),g=B().getInt32(m+4,!0);return _=f,l=g,K(f,g)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(_,l,1);}}function ir(t){return nt[t]}function sr(t){t<132||(nt[t]=Ot,Ot=t);}function rt(t){let e=ir(t);return sr(t),e}function ar(t,e){try{let o=d.__wbindgen_add_to_stack_pointer(-16),a=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),s=E,i=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),c=E;d.register(o,a,s,i,c);var r=B().getInt32(o+0,!0),n=B().getInt32(o+4,!0);if(n)throw rt(r)}finally{d.__wbindgen_add_to_stack_pointer(16);}}function cr(t,e,r,n,o,a,s,i){let c,_;try{let b=d.__wbindgen_add_to_stack_pointer(-16),y=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),w=E,v=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),F=E,L=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),N=E,V=A(n,d.__wbindgen_export_0,d.__wbindgen_export_1),U=E,H=A(o,d.__wbindgen_export_0,d.__wbindgen_export_1),Y=E;d.transform(b,y,w,v,F,L,N,V,U,H,Y,a,s,i);var l=B().getInt32(b+0,!0),f=B().getInt32(b+4,!0),g=B().getInt32(b+8,!0),m=B().getInt32(b+12,!0),x=l,k=f;if(m)throw x=0,k=0,rt(g);return c=x,_=k,K(x,k)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(c,_,1);}}function pr(t,e){let r,n;try{let l=d.__wbindgen_add_to_stack_pointer(-16),f=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),g=E,m=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),x=E;d.resolve_patch_document(l,f,g,m,x);var o=B().getInt32(l+0,!0),a=B().getInt32(l+4,!0),s=B().getInt32(l+8,!0),i=B().getInt32(l+12,!0),c=o,_=a;if(i)throw c=0,_=0,rt(s);return r=c,n=_,K(c,_)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(r,n,1);}}function ur(t,e,r,n,o,a,s,i,c,_,l){let f,g;try{let v=d.__wbindgen_add_to_stack_pointer(-16),F=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),L=E,N=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),V=E,U=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),H=E,Y=A(n,d.__wbindgen_export_0,d.__wbindgen_export_1),gt=E,bt=A(_,d.__wbindgen_export_0,d.__wbindgen_export_1),mt=E,yt=A(l,d.__wbindgen_export_0,d.__wbindgen_export_1),xt=E;d.convert(v,F,L,N,V,U,H,Y,gt,o,a,s,i,c,bt,mt,yt,xt);var m=B().getInt32(v+0,!0),x=B().getInt32(v+4,!0),k=B().getInt32(v+8,!0),b=B().getInt32(v+12,!0),y=m,w=x;if(b)throw y=0,w=0,rt(k);return f=y,g=w,K(y,w)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(f,g,1);}}function _r(t,e,r,n,o,a){let s,i;try{let x=d.__wbindgen_add_to_stack_pointer(-16),k=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),b=E,y=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),w=E,v=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),F=E;d.canonicalize(x,k,b,y,w,v,F,n,o,a);var c=B().getInt32(x+0,!0),_=B().getInt32(x+4,!0),l=B().getInt32(x+8,!0),f=B().getInt32(x+12,!0),g=c,m=_;if(f)throw g=0,m=0,rt(l);return s=g,i=m,K(g,m)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(s,i,1);}}function dr(t){let e,r;try{let _=d.__wbindgen_add_to_stack_pointer(-16),l=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),f=E;d.count_bits(_,l,f);var n=B().getInt32(_+0,!0),o=B().getInt32(_+4,!0),a=B().getInt32(_+8,!0),s=B().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,rt(a);return e=i,r=c,K(i,c)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function lr(t){let e,r;try{let a=d.__wbindgen_add_to_stack_pointer(-16),s=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),i=E;d.split_bits(a,s,i);var n=B().getInt32(a+0,!0),o=B().getInt32(a+4,!0);return e=n,r=o,K(n,o)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function fr(t){let e=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),r=E;return d.is_bitmark(e,r)!==0}function gr(t){let e,r;try{let _=d.__wbindgen_add_to_stack_pointer(-16),l=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),f=E;d.split_json_bits(_,l,f);var n=B().getInt32(_+0,!0),o=B().getInt32(_+4,!0),a=B().getInt32(_+8,!0),s=B().getInt32(_+12,!0),i=n,c=o;if(s)throw i=0,c=0,rt(a);return e=i,r=c,K(i,c)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function br(t,e){let r,n;try{let s=d.__wbindgen_add_to_stack_pointer(-16),i=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),c=E;d.prettify(s,i,c,e);var o=B().getInt32(s+0,!0),a=B().getInt32(s+4,!0);return r=o,n=a,K(o,a)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(r,n,1);}}function mr(t,e,r,n){let o,a;try{let g=d.__wbindgen_add_to_stack_pointer(-16),m=A(t,d.__wbindgen_export_0,d.__wbindgen_export_1),x=E,k=A(e,d.__wbindgen_export_0,d.__wbindgen_export_1),b=E,y=A(r,d.__wbindgen_export_0,d.__wbindgen_export_1),w=E,v=A(n,d.__wbindgen_export_0,d.__wbindgen_export_1),F=E;d.convert_text(g,m,x,k,b,y,w,v,F);var s=B().getInt32(g+0,!0),i=B().getInt32(g+4,!0),c=B().getInt32(g+8,!0),_=B().getInt32(g+12,!0),l=s,f=i;if(_)throw l=0,f=0,rt(c);return o=l,a=f,K(l,f)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(o,a,1);}}async function yr(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function ve(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(K(e,r));return tr(n)},t}function he(t,e){return d=t.exports,Te.__wbindgen_wasm_module=e,ct=null,Tt=null,d}function Qt(t){if(d!==void 0)return d;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=ve();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return he(r,t)}async function Te(t){if(d!==void 0)return d;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_json_wasm_bg.wasm",import.meta.url));let e=ve();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await yr(await t,e);return he(r,n)}var Zt=Te;var It={version:"7.0.0"};var ee="browser-full",Wt=class extends Error{constructor(){super("wasm not initialised: call init() (or init({ feature: \u2026 })) first"),this.name="NotInitializedError";}},_t=class extends Error{constructor(e){super(e),this.name="RegisterError";}},dt=class extends Error{constructor(e,r){super(`${e} is not available in the loaded wasm module${r?` (feature: "${r}")`:""}; init({ feature: "full" }) to load it`),this.name="UnsupportedFeatureError";}},Lt,Ie,Oe,Fe=new Map;function D(){if(!Lt&&Oe&&Oe(),!Lt)throw new Wt;return Lt}function ne(t,e){for(let[r,n]of Fe)try{e.register(r,n);}catch(o){throw new _t(o instanceof Error?o.message:String(o))}Lt=e,Ie=t;}function Re(t,e){Fe.set(t,e);}function pt(){return Ie}function xr(t){let e=t.trim();return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):t}function wr(t){return t===void 0?"":typeof t=="string"?t.trim():JSON.stringify(t)}function kr(t,e,r){if(r){let o=JSON.parse(t.split_bits(e));return o.map(a=>({view:{format:"bitmark",index:a.index,total:o.length,source:a.source},source:a.source}))}let n=JSON.parse(t.split_json_bits(e));return n.map((o,a)=>({view:{format:"json",index:a,total:n.length,bit:o.bit??{}},source:JSON.stringify([o])}))}function re(t,e,r){let n=r.mode??"optimized",o=r.outputFormat??"json",a=r.spacesAroundValues??1,s=r.indent??2,i=r.pretty??false,c=r.inputFormat??"auto",_=c==="bitmark"||c!=="json"&&t.is_bitmark(e),l=_?"bitmark":"json",f=kr(t,e,_),g=f.length,m=[];for(let w=0;w<g;w++){let{view:v}=f[w];v.index=w,v.total=g;let F=r.preHook?r.preHook(v)||{}:{};m.push(F.drop?null:{patches:F.patches??[],outputFormat:F.outputFormat??o});}let x=wr(r.patch),k;x===""?k=f.map((w,v)=>({source:v,bit:null,patch:[]})):k=JSON.parse(t.resolve_patch_document(e,x));let b=[],y=[];for(let w of k)if(w.source!==null){let v=m[w.source];if(!v)continue;b.push({index:w.source,source:f[w.source].source,inputFormat:l,outputFormat:v.outputFormat,mode:n,patchJson:JSON.stringify([...w.patch,...v.patches]),spacesAroundValues:a}),y.push(f[w.source].view);}else {let v=w.bit??{},F=b.length;b.push({index:F,source:JSON.stringify([{bit:v}]),inputFormat:"json",outputFormat:o,mode:n,patchJson:JSON.stringify(w.patch),spacesAroundValues:a}),y.push({format:"json",index:F,total:g,bit:v});}return {jobs:b,views:y,output:o,pretty:i,indent:s}}function vr(t,e){let r=t.transform(e.source,e.inputFormat,e.outputFormat,e.mode,e.patchJson,false,2,e.spacesAroundValues);return e.outputFormat==="json"?xr(r):r}function oe(t,e,r,n,o){if(r==="bitmark"||r==="text")return e.join(`
2
- `);let a=`[${e.join(",")}]`;return n?t.prettify(a,o):a}function Se(t,e,r){let n=re(t,e,r),o=[];for(let a=0;a<n.jobs.length;a++){let s=vr(t,n.jobs[a]);r.postHook?.(n.views[a],s),o.push(s);}return oe(t,o,n.output,n.pretty,n.indent)}async function Be(t,e,r,n){let o=re(t,e,r),a=await n(o.jobs,r.workers??4);for(let s=0;s<a.length;s++)r.postHook?.(o.views[s],a[s]);return oe(t,a,o.output,o.pretty,o.indent)}var ie;function Ee(t){ie=t;}function W(){if(!ie)throw new Error("legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)");return ie()}function Ae(t,e,r){if(t.length===0)return Promise.resolve([]);let n=Math.max(1,Math.min(e,t.length)),o=new URL("./worker-entry.js",import.meta.url);return new Promise((a,s)=>{let i=new Array(t.length),c=0,_=0,l=false,f=[],g=()=>{for(let k of f)k.terminate();},m=k=>{l||(l=true,g(),s(k));},x=k=>{if(l||c>=t.length)return;let b=c++;k.postMessage({id:b,job:t[b],feature:r});};for(let k=0;k<n;k++){let b=new Worker(o,{type:"module"});f.push(b),b.onmessage=y=>{let w=y.data;if(!l){if(!w.ok){m(new Error(w.error??"worker job failed"));return}if(i[w.id]=w.element,_++,_===t.length){l=true,g(),a(i);return}x(b);}},b.onerror=y=>m(new Error(y.message||"worker error"));}for(let k of f)x(k);})}var sn={};Rt(sn,{Ast:()=>Ge,BitType:()=>Ne,BitmarkFileGenerator:()=>Ke,BitmarkGenerator:()=>ze,BitmarkParser:()=>tn,BitmarkParserGenerator:()=>Ut,BitmarkParserType:()=>jr,BitmarkStringGenerator:()=>$e,BitmarkVersion:()=>Er,BodyTextFormat:()=>Wr,BoundingBoxIndex:()=>He,Builder:()=>Vt,CardSetVersion:()=>Ar,FileWriter:()=>rn,HtmlTableGenerator:()=>Qe,HtmlTableParser:()=>Ze,InfoFormat:()=>Lr,InfoType:()=>Pr,Input:()=>Rr,InputFormat:()=>Br,JsonFileGenerator:()=>Xe,JsonGenerator:()=>qe,JsonParser:()=>en,JsonStringGenerator:()=>Ye,LegacyUnsupportedError:()=>lt,NodeType:()=>Ue,Output:()=>Sr,ResourceBuilder:()=>Ht,StreamWriter:()=>on,StringWriter:()=>nn,TextLocation:()=>Cr,TextMarkType:()=>Me,TextNodeType:()=>De,bitmarkTextParse:()=>Ce,isPseudoAst:()=>Pe});var lt=class extends Error{constructor(e){super(e),this.name="LegacyUnsupportedError";}};function ot(t,e){throw new lt(`'${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}function X(t,e){throw new lt(`Option '${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}var se="bitmark v2 output is not supported (this parser is bitmark v3 only)";function ae(t){t.bitmarkVersion===2&&X("bitmarkVersion: 2",se);}function Jt(t){t.explicitTextFormat&&X("bitmarkOptions.explicitTextFormat"),t.cardSetVersion===1&&X("bitmarkOptions.cardSetVersion: 1",se),t.debugGenerationInline&&X("bitmarkOptions.debugGenerationInline"),t.noBreakscaping&&X("bitmarkOptions.noBreakscaping");}function Mt(t){t.textAsPlainText&&X("jsonOptions.textAsPlainText",se),t.debugGenerationInline&&X("jsonOptions.debugGenerationInline");}function ut(t){return t===true?{pretty:true,indent:2}:typeof t=="number"&&t>0?{pretty:true,indent:t}:{pretty:false,indent:2}}function Dt(t){return t===void 0||t===true?1:t===false?0:Math.max(0,Math.min(10,t))}function Nt(t){switch(t){case "text":case "latex":case "json":case "xml":return "plainText";default:return "bitmark++"}}var je=Symbol.for("@gmb/bitmark-parser/legacy-pseudo-ast");function ft(t){let e={bits:t};return Object.defineProperty(e,je,{value:true,enumerable:false}),e}function Pe(t){return t!==null&&typeof t=="object"&&(je in t||Array.isArray(t.bits))}var Le={"extractor-image":{key:"images",resourceType:"image"},"extractor-image-collapsible":{key:"images",resourceType:"image"},"images-logo-grave":{key:"logos",resourceType:"image"},"prototype-images":{key:"images",resourceType:"image"}};var ce=Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser"),Tr={bitType:"type",textFormat:"format",flashcards:"cards",markConfig:"marks"},Or={"bitmark--":"bitmark++","bitmark+":"bitmark++"},Ir={bitmark:"bitmark++",text:"text",json:"json",latex:"latex",xml:"xml"},Fr=["title","subtitle","item","lead","pageNumber","marginNumber","hint","instruction","caption"],Vt=class{buildBitmark(e){let r=ft(e.bits??[]);return e.errors!==void 0&&(r.errors=e.errors),r}buildBit(e,r){let n=W(),o={...e},a=o.bitType,s=this.getBitConfig(a),i={};i.type=a,o.isCommented&&(i.type="_comment",i.originalType=a),delete o.bitType,delete o.isCommented;let c=o.textFormat;c!==void 0?(i.format=Or[c]??c,delete o.textFormat):i.format=Ir[s.bodyFormat??""]??"bitmark++",delete o.resourceType;let _=o.body;_!=null&&typeof _=="object"&&"body"in _&&(i.body=_.body,delete o.body),o.example!==void 0?(i.isExample=true,i.example=o.example,delete o.example,delete o.__isDefaultExample):o.__isDefaultExample&&(i.isExample=true,delete o.__isDefaultExample);let l=o.resources;if(l!==void 0&&a!==void 0){let b=Array.isArray(l)?l:[l],y=Le[a];y?i[y.key]=b.filter(w=>w!==null&&typeof w=="object"&&w.type===y.resourceType):b.length>=1&&(i.resource=b[0]),delete o.resources;}let f=o.parser;delete o.parser;let g=o.extraProperties;delete o.extraProperties;for(let[b,y]of Object.entries(o))y!==void 0&&(i[Tr[b]??b]=y);if(g)for(let[b,y]of Object.entries(g))b in i||(i[b]=y);this.parseStringTexts(i);let m=n.convert(JSON.stringify([{bit:i}]),"json","json","optimized",false,2,1,false,false,"",""),k=JSON.parse(m)[0]?.bit??i;for(let[b,y]of Object.entries(i))b in k||y===false||y===""||y===null||Array.isArray(y)&&y.length===0||(k[b]=y);return f!==void 0&&Object.defineProperty(k,ce,{value:f,enumerable:false}),k}buildHighlight(e,r){if(!r)return;let n={...r},o=n.attrs;return o&&Object.assign(n,o),{type:"highlight",texts:Array.isArray(n.texts)?n.texts.filter(i=>i!=null).map(i=>({text:i.text??"",isCorrect:i.isCorrect??false,isHighlighted:i.isHighlighted??false,...We(i,["text","isCorrect","isHighlighted"])})):[],prefix:n.prefix??"",postfix:n.postfix??"",...We(n,["type","texts","prefix","postfix","attrs"]),attrs:{}}}parseStringTexts(e){let r=W(),n=(s,i)=>{if(s==="")return s;let c=r.convert_text(s,"textToAst","bitmark++",i);try{return JSON.parse(c)}catch{return s}},o=e.format,a=o===void 0||o==="bitmark++"||o==="bitmark+";if(typeof e.body=="string")if(o==="json")try{e.body=JSON.parse(e.body);}catch{e.body=null;}else a&&(e.body=n(e.body,"body"));for(let s of Fr){let i=e[s];typeof i=="string"&&(e[s]=n(i,"tag"));}}getBitConfig(e){let r=W();if(e!==void 0)try{let n=JSON.parse(r.info("bit","json",e,!1,2,!1,!1,!0,""));if(n.error===void 0)return {bodyFormat:n.body?.format}}catch{}throw new Error(`No config found for bit: ${e}`)}};function We(t,e){let r={};for(let[n,o]of Object.entries(t))o!==void 0&&!e.includes(n)&&(r[n]=o);return r}var Ut=class{version(){return It.version}convert(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);ae(n),Jt(a),Mt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:c}=this.resolveInput(e,n.inputFormat),_=n.outputFormat??(c?"json":"bitmark"),l=_==="ast"?"json":_,{pretty:f,indent:g}=ut(o.prettify),m=l==="bitmark"?ut(a.prettifyJson):{pretty:f,indent:g},x=Dt(a.spacesAroundValues),k=!o.excludeUnknownProperties,b=s.convert(i,c?"bitmark":"json",l,"optimized",m.pretty,m.indent,x,k,false,"","");if(_==="bitmark"||_==="text")return this.deliver(b,n.outputFile,n.fileOptions);if(_==="json")return n.outputFile?this.deliver(b,n.outputFile,n.fileOptions):f||o.stringify?b:JSON.parse(b);let y=ft(JSON.parse(b));return n.outputFile?this.deliver(JSON.stringify(y),n.outputFile,n.fileOptions):y}upgrade(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);ae(n),Jt(a),Mt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:c}=this.resolveInput(e,n.inputFormat),{pretty:_,indent:l}=ut(c?a.prettifyJson:o.prettify),f=Dt(a.spacesAroundValues),g=s.canonicalize(i,c?"bitmark":"json","optimized",_,l,f);return c?this.deliver(g,n.outputFile,n.fileOptions):n.outputFile?this.deliver(g,n.outputFile,n.fileOptions):_||o.stringify?g:JSON.parse(g)}info(e){let r=Object.assign({},e),n=W(),o=r.type??"list",a=r.outputFormat??"text",{pretty:s,indent:i}=ut(r.prettify),c=a==="pojo"?"json":a,_=n.info(o,c,r.bit??"",s,i,false,false,true,"");return a==="pojo"?JSON.parse(_):_}generateConfig(e){ot("BitmarkParserGenerator.generateConfig","bpg-internal development tool");}convertHtmlTable(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);Jt(a),Mt(o),n.keepUnknownTags&&X("keepUnknownTags"),n.noBreakscaping&&X("noBreakscaping"),this.checkBrowserFileWrite(n.outputFile);let s=W(),i=typeof e=="string"?this.maybeReadFile(e,void 0):"";if(!(n.inputFormat==="html"||n.inputFormat===void 0&&typeof e=="string"&&/<table[\s>]/iu.test(i))){let{source:w,isBitmark:v}=this.resolveInput(e,void 0),F=s.convert(w,v?"bitmark":"json","html","optimized",false,2,1,false,false,"","");return this.deliver(pe(F).join(`
3
- `),n.outputFile,n.fileOptions)}let _=n.tableFormat==="table"?"table":"table-extended",l=pe(i).map(w=>`<bitmark-bit data-type="${_}" data-format="bitmark++">${w}</bitmark-bit>`).join(""),f=n.outputFormat??"bitmark",{pretty:g,indent:m}=ut(o.prettify),x=Dt(a.spacesAroundValues);if(f==="html"){let w=s.convert(l,"html","html","optimized",false,2,1,false,false,"","");return this.deliver(pe(w).join(`
4
- `),n.outputFile,n.fileOptions)}let k=f==="ast"?"json":f,b=s.convert(l,"html",k,"optimized",g,m,x,false,false,"","");if(f==="bitmark"||f==="text")return this.deliver(b,n.outputFile,n.fileOptions);if(f==="json")return n.outputFile?this.deliver(b,n.outputFile,n.fileOptions):g||o.stringify?b:JSON.parse(b);let y=ft(JSON.parse(b));return n.outputFile?this.deliver(JSON.stringify(y),n.outputFile,n.fileOptions):y}createAst(e,r){let n=Object.assign({},r),o=W(),{source:a,isBitmark:s}=this.resolveInput(e,n.inputFormat),i=o.convert(a,s?"bitmark":"json","json","optimized",false,2,1,true,false,"","");return ft(JSON.parse(i))}breakscapeText(e,r){if(!e)return e;let n=Object.assign({},r);this.checkBrowserFileWrite(n.outputFile);let o=W(),a=this.maybeReadFile(e,n.inputFormat),s=o.breakscape_text(a,Nt(n.textFormat),n.textLocation??"body");return this.deliver(s,n.outputFile,n.fileOptions)}unbreakscapeText(e,r){if(!e)return e;let n=Object.assign({},r);this.checkBrowserFileWrite(n.outputFile);let o=W(),a=this.maybeReadFile(e,n.inputFormat),s=o.unbreakscape_text(a,Nt(n.textFormat),n.textLocation??"body");return this.deliver(s,n.outputFile,n.fileOptions)}convertText(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions);this.checkBrowserFileWrite(n.outputFile);let a=W(),s=n.textFormat===void 0||Nt(n.textFormat)==="bitmark++",i=n.textLocation??"body",c,_;if(typeof e=="string"?(c=this.maybeReadFile(e,n.inputFormat),_=this.parseTextAstString(c)):(c=JSON.stringify(e),_=Array.isArray(e)?e:void 0),_!==void 0){let x=s?a.convert_text(JSON.stringify(_),"astToText","bitmark++",i):a.convert_text(JSON.stringify(_),"astToPlainText","plainText",i);return this.deliver(x,n.outputFile,n.fileOptions)}let l=a.convert_text(c,"textToAst",s?"bitmark++":"plainText","body"),{pretty:f,indent:g}=ut(o.prettify),m=f?a.prettify(l,g):l;return n.outputFile?this.deliver(m,n.outputFile,n.fileOptions):f?m:JSON.parse(l)}textAstToPlainText(e,r){return W().convert_text(typeof e=="string"?e:JSON.stringify(e),"astToPlainText","bitmark++","body")}extractPlainText(e,r){let n=r?.inputFormat,o=W();if(n==="plainText")return typeof e=="string"?String(e):"";if(n==="bitmarkText"){let c=o.convert_text(String(e),"textToAst","bitmark++","body");return o.convert_text(c,"astToPlainText","bitmark++","body")}if(typeof e=="string"&&this.parseTextAstString(e)===void 0&&!o.is_bitmark(e)&&!(()=>{try{return JSON.parse(e),!0}catch{return false}})())return this.extractPlainText(e,{inputFormat:"bitmarkText"});let{source:a,isBitmark:s}=this.resolveInput(e,void 0);return o.convert(a,s?"bitmark":"json","text","optimized",false,2,1,false,false,"","")}parseTextAstString(e){let r=e.trim();if(r.startsWith("["))try{let n=JSON.parse(r);if(Array.isArray(n)&&n.every(o=>o!==null&&typeof o=="object"&&"type"in o))return n}catch{}}resolveInput(e,r){if(typeof e!="string"){let a=this.jsonEntries(e);return {source:JSON.stringify(a?a.map(s=>this.toWrapperEntry(s)):e),isBitmark:false}}let n=this.maybeReadFile(e,r);if(W().is_bitmark(n))return {source:n,isBitmark:true};try{let a=JSON.parse(n),s=this.jsonEntries(a);if(s)return {source:JSON.stringify(s.map(i=>this.toWrapperEntry(i))),isBitmark:!1}}catch{return {source:n,isBitmark:true}}return {source:n,isBitmark:false}}jsonEntries(e){if(Array.isArray(e))return e;if(e!==null&&typeof e=="object"){let r=e;if(Array.isArray(r.bits))return r.bits;if("bit"in r)return [r];if(typeof r.type=="string")return [{bit:r}]}}toWrapperEntry(e){if(e!==null&&typeof e=="object"&&"bit"in e)return e;let r={bit:e},n=e?.[ce];return n!==void 0&&(r.parser=n),r}maybeReadFile(e,r){if(r==="string")return e;return e;}checkBrowserFileWrite(e){if(e&&true)throw new Error("Cannot write to file in browser environment")}deliver(e,r,n){if(!r)return e;throw new Error("Cannot write to file in browser environment");}};function pe(t){let e=[],r=t.toLowerCase(),n=0;for(;;){let o=r.indexOf("<table",n);if(o===-1)break;let a=0,s=o,i=-1;for(;s<t.length;){let c=r.indexOf("<table",s),_=r.indexOf("</table",s);if(_===-1)break;if(c!==-1&&c<_)a++,s=c+6;else {a--;let l=r.indexOf(">",_);if(s=l===-1?t.length:l+1,a===0){i=s;break}}}if(i===-1)break;e.push(t.slice(o,i)),n=i;}return e}function Ce(t){let e=W().convert_text(t,"textToAst","bitmark++","body");return JSON.parse(e)}var M={imageResource:{type:"image",key:"image",valueField:"src"},imageLinkResource:{type:"image-link",key:"imageLink",valueField:"url"},audioResource:{type:"audio",key:"audio",valueField:"src"},audioEmbedResource:{type:"audio-embed",key:"audioEmbed",valueField:"src"},audioLinkResource:{type:"audio-link",key:"audioLink",valueField:"url"},videoResource:{type:"video",key:"video",valueField:"src"},videoEmbedResource:{type:"video-embed",key:"videoEmbed",valueField:"url"},videoLinkResource:{type:"video-link",key:"videoLink",valueField:"url"},stillImageFilmEmbedResource:{type:"still-image-film-embed",key:"stillImageFilmEmbed",valueField:"url"},stillImageFilmLinkResource:{type:"still-image-film-link",key:"stillImageFilmLink",valueField:"url"},articleResource:{type:"article",key:"article",valueField:"body"},documentResource:{type:"document",key:"document",valueField:"url"},documentEmbedResource:{type:"document-embed",key:"documentEmbed",valueField:"url"},documentLinkResource:{type:"document-link",key:"documentLink",valueField:"url"},documentDownloadResource:{type:"document-download",key:"documentDownload",valueField:"url"},appLinkResource:{type:"app-link",key:"appLink",valueField:"url"},websiteLinkResource:{type:"website-link",key:"websiteLink",valueField:"url"}};function C(t){return (e,r,n)=>{if(!r)return;let{value:o,...a}=r,s={[t.valueField]:o??""};for(let[i,c]of Object.entries(a))c!==void 0&&(s[i]=c);return {type:t.type,[t.key]:s}}}var Je=Object.fromEntries(Object.values(M).map(t=>[t.type,t])),Ht=class{constructor(){J(this,"imageResource",C(M.imageResource));J(this,"imageLinkResource",C(M.imageLinkResource));J(this,"audioResource",C(M.audioResource));J(this,"audioEmbedResource",C(M.audioEmbedResource));J(this,"audioLinkResource",C(M.audioLinkResource));J(this,"videoResource",C(M.videoResource));J(this,"videoEmbedResource",C(M.videoEmbedResource));J(this,"videoLinkResource",C(M.videoLinkResource));J(this,"stillImageFilmEmbedResource",C(M.stillImageFilmEmbedResource));J(this,"stillImageFilmLinkResource",C(M.stillImageFilmLinkResource));J(this,"articleResource",C(M.articleResource));J(this,"documentResource",C(M.documentResource));J(this,"documentEmbedResource",C(M.documentEmbedResource));J(this,"documentLinkResource",C(M.documentLinkResource));J(this,"documentDownloadResource",C(M.documentDownloadResource));J(this,"appLinkResource",C(M.appLinkResource));J(this,"websiteLinkResource",C(M.websiteLinkResource));}resourceFromResourceJson(e,r){if(!r)return;let n=!Array.isArray(r),o=n?[r]:r,a=[];for(let s of o){let i=Je[s.type];if(!i)continue;let c=s[i.key]??{},{[i.valueField]:_,...l}=c,f=C(i)(void 0,{value:_,...l});f&&a.push(f);}if(a.length!==0)return n?a[0]:a}resourceFromResourceDataJson(e,r,n){if(!n)return;let o=Je[r];if(!o)return;let a=typeof n=="string"?n:void 0,s=typeof n=="object"?n:{},{url:i,src:c,body:_,...l}=s,f=i??c??_??a;return C(o)(e,{value:f,...l})}};var Rr={string:"string",file:"file"},Sr={bitmark:"bitmark",json:"json",ast:"ast",text:"text"},Br={bitmark:"bitmark",bitmarkText:"bitmarkText",plainText:"plainText",html:"html"},Er={v2:2,v3:3},Ar={v1:1,v2:2},jr={peggy:"peggy"},Pr={list:"list",deprecated:"deprecated",all:"all",bit:"bit"},Lr={text:"text",json:"json",pojo:"pojo"},Wr={plainText:"text",latex:"latex",json:"json",xml:"xml",bitmarkPlusPlus:"bitmark++"},Cr={tag:"tag",body:"body"};var Me={bold:"bold",light:"light",italic:"italic",highlight:"highlight",highlightOrange:"highlightOrange",highlightYellow:"highlightYellow",highlightGreen:"highlightGreen",highlightBlue:"highlightBlue",highlightPurple:"highlightPurple",highlightPink:"highlightPink",highlightBrown:"highlightBrown",highlightBlack:"highlightBlack",highlightWhite:"highlightWhite",highlightGray:"highlightGray",strike:"strike",subscript:"subscript",superscript:"superscript",ins:"ins",del:"del",underline:"underline",doubleUnderline:"doubleUnderline",circle:"circle",languageEmRed:"languageEmRed",languageEmOrange:"languageEmOrange",languageEmYellow:"languageEmYellow",languageEmGreen:"languageEmGreen",languageEmBlue:"languageEmBlue",languageEmPurple:"languageEmPurple",languageEmPink:"languageEmPink",languageEmBrown:"languageEmBrown",languageEmBlack:"languageEmBlack",languageEmWhite:"languageEmWhite",languageEmGray:"languageEmGray",languageEm:"languageEm",userUnderline:"userUnderline",userDoubleUnderline:"userDoubleUnderline",userStrike:"userStrike",userCircle:"userCircle",userHighlight:"userHighlight",notranslate:"notranslate",link:"link",ref:"ref",xref:"xref",extref:"extref",footnote:"footnote",footnoteStar:"footnote*",symbol:"symbol",var:"var",code:"code",timer:"timer",duration:"duration",color:"color",colorPicker:"colorPicker",comment:"comment"},De={text:"text",hardBreak:"hardBreak",paragraph:"paragraph",heading:"heading",section:"section",noBulletList:"noBulletList",bulletList:"bulletList",orderedList:"orderedList",orderedListRoman:"orderedListRoman",orderedListRomanLower:"orderedListRomanLower",letteredList:"letteredList",letteredListLower:"letteredListLower",taskList:"taskList",listItem:"listItem",taskItem:"taskItem",image:"image",imageInline:"imageInline",codeBlock:"codeBlock",latex:"latex",gap:"gap",select:"select",highlight:"highlight",mark:"mark"};function Jr(t){return t.replace(/-([a-z0-9])/gu,(e,r)=>r.toUpperCase())}var ue;function Ft(){if(!ue){let t=W(),e=JSON.parse(t.info("all","json","",false,2,true,false,false,"")),r={_standard:"_standard"};for(let{name:n}of e)r[Jr(n)]=n;ue=r;}return ue}var Ne=new Proxy({},{get:(t,e)=>typeof e=="string"?Ft()[e]:void 0,has:(t,e)=>typeof e=="string"&&e in Ft(),ownKeys:()=>Reflect.ownKeys(Ft()),getOwnPropertyDescriptor:(t,e)=>typeof e=="string"&&e in Ft()?{value:Ft()[e],enumerable:true,configurable:true,writable:false}:void 0});function Ve(t,e){return new Proxy({},{get:(r,n)=>n===Symbol.toPrimitive||n==="toString"||n===Symbol.toStringTag?()=>`[unsupported ${t}]`:ot(t,e),has:()=>ot(t,e),ownKeys:()=>ot(t,e)})}var Ue=Ve("NodeType","it names bpg's internal AST nodes; the legacy AST is bit JSON (see createAst)"),He=Ve("BoundingBoxIndex","bpg-internal bounding-box utility");function $(t,e){return class{constructor(){ot(t,e);}}}var Mr="the legacy AST is bit JSON, not bpg's internal node model; walking it with bpg NodeType names would silently misbehave",q="internal class of bpg's TS implementation",Ge=$("Ast",Mr),ze=$("BitmarkGenerator",q),$e=$("BitmarkStringGenerator",q),Ke=$("BitmarkFileGenerator",q),qe=$("JsonGenerator",q),Ye=$("JsonStringGenerator",q),Xe=$("JsonFileGenerator",q),Qe=$("HtmlTableGenerator",q),Ze=$("HtmlTableParser",q),tn=$("BitmarkParser",q),en=$("JsonParser",q),nn=$("StringWriter",q),rn=$("FileWriter",q),on=$("StreamWriter",q);function Dr(t,e,r){return r===void 0?{path:t,op:e}:{path:t,op:e,value:r}}var Nr="all";function Vr(t,e={}){let r=D().convert(t,"bitmark","json",e.mode??"optimized",false,2,1,e.includeUnknownProperties??false,false,"","");return JSON.parse(r)}function Ur(t,e={}){let r=t.map(o=>o!==null&&typeof o=="object"&&"bit"in o&&typeof o.bit=="object"?o:{bit:o});return D().convert(JSON.stringify(r),"json","bitmark",e.mode??"optimized",false,2,1,false,false,"","")}function an(t,e={}){return D().convert(t,e.inputFormat??"auto",e.outputFormat??"auto",e.mode??"optimized",e.pretty??false,e.indent??2,e.spacesAroundValues??1,e.includeUnknownProperties??false,e.mappingReport??false,e.positionEncoding??"",e.tokensLayout??"")}function Hr(t,e={}){return JSON.parse(an(t,{inputFormat:"bitmark",outputFormat:"semantic-tokens",positionEncoding:e.positionEncoding,tokensLayout:e.tokensLayout}))}function Gr(t,e={}){return D().canonicalize(t,e.inputFormat??"auto",e.mode??"optimized",e.pretty??false,e.indent??2,e.spacesAroundValues??1)}function zr(t){return Number.parseInt(D().count_bits(t),10)}function $r(t){return JSON.parse(D().split_bits(t))}function Kr(t,e={}){let r=D();if(e.preHook||e.postHook)return Se(r,t,e);let n=e.patch===void 0?"":typeof e.patch=="string"?e.patch:JSON.stringify(e.patch);return r.transform(t,e.inputFormat??"auto",e.outputFormat??"json",e.mode??"optimized",n,e.pretty??false,e.indent??2,e.spacesAroundValues??1)}function cn(t,e,r={}){let n=D();if(typeof n.diff!="function")throw new dt("diff",pt());return n.diff(t,e,r.inputFormat??"auto",r.outputFormat??"bitmark",r.context??3,r.locate??false,r.similarity??.6,r.bboxTolerance??8,r.spacesAroundValues??0)}function qr(t,e,r={}){return JSON.parse(cn(t,e,{...r,outputFormat:"json"}))}function Yr(t,e={}){let r=e.format??"bitmark++",n=e.location??"body";return D().breakscape_text(t,r,n)}function Xr(t,e={}){let r=e.format??"bitmark++",n=e.location??"body";return D().unbreakscape_text(t,r,n)}function Qr(t={}){let e=t.infoType??"list",r=t.format??"text",n=t.bit??"",o=t.pretty??false,a=t.indent??2,s=t.includeDeprecated??false,i=t.onlyDeprecated??false,c=t.full??false,_=typeof t.language=="string"?t.language:t.language?.join(",")??"",l=D();if(r!=="json"&&typeof l.info_text_supported!="function")throw new dt('info (format: "text")',pt());return l.info(e,r,n,o,a,s,i,c,_)}function Zr(t){try{D().register(t.type,t.data);}catch(e){throw new _t(e instanceof Error?e.message:String(e))}Re(t.type,t.data);}var to="./wasm/",un={full:{init:$t,initSync:zt,ns:Kt,wasmFile:"bitmark_wasm_bg.wasm"},"browser-full":{init:Yt,initSync:qt,ns:Xt,wasmFile:"bitmark_browser_full_wasm_bg.wasm"},"bitmark-json":{init:Zt,initSync:Qt,ns:te,wasmFile:"bitmark_json_wasm_bg.wasm"}};Ee(()=>D());function _e(t){return t===void 0?ee:"full"}function eo(t){if(t!==null&&typeof t=="object"&&!(t instanceof URL)&&("feature"in t||"module_or_path"in t)){let r=t;return {feature:r.feature??_e(r.module_or_path),module_or_path:r.module_or_path}}let e=t??void 0;return {feature:_e(e),module_or_path:e}}var pn=0,Gt,it;async function Ti(t){let{feature:e,module_or_path:r}=eo(t);if(r===void 0){if(!it&&pt()===e)return Gt;if(it?.feature===e)return it.promise}let n=++pn,o=un[e],a=r??new URL(`${to}${o.wasmFile}?v=${It.version}`,import.meta.url),s=(async()=>{try{let i=await o.init(a);n===pn&&(ne(e,o.ns),Gt=i);}finally{it?.seq===n&&(it=void 0);}for(;it;)await it.promise.catch(()=>{});return Gt})();return it={feature:e,seq:n,promise:s},s}function Oi(t,e={}){let r=e.feature??_e(t),n=un[r],o=n.initSync(t);return ne(r,n.ns),Gt=o,o}function Ii(){return It.version}function Fi(t,e={}){let r=D(),n=pt()??ee;return Be(r,t,e,(o,a)=>Ae(o,a,n))}export{Nr as ALL_LANGUAGES,Wt as NotInitializedError,_t as RegisterError,dt as UnsupportedFeatureError,Vr as bitmarkToObjects,Yr as breakscapeText,Gr as canonicalize,an as convert,zr as countBits,cn as diff,qr as diffBits,Qr as info,Ti as init,Oi as initSync,sn as legacy,Ur as objectsToBitmark,Dr as patchEntry,Zr as register,Hr as semanticTokens,$r as splitBits,Kr as transform,Fi as transformParallel,Xr as unbreakscapeText,pt as variant,Ii as version};//# sourceMappingURL=bitmark-parser.min.js.map
1
+ var ge=Object.defineProperty;var fn=(t,e,r)=>e in t?ge(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var Rt=(t,e)=>{for(var r in e)ge(t,r,{get:e[r],enumerable:true});};var J=(t,e,r)=>fn(t,typeof e!="symbol"?e+"":e,r);var $t={};Rt($t,{breakscape_text:()=>xn,canonicalize:()=>An,complete:()=>Rn,convert:()=>Pn,convert_text:()=>In,count_bits:()=>jn,default:()=>Kt,diff:()=>Fn,hover:()=>Sn,info:()=>wn,info_text_supported:()=>kn,initSync:()=>zt,is_bitmark:()=>Cn,prettify:()=>Dn,register:()=>Bn,resolve:()=>En,resolve_patch_document:()=>On,split_bits:()=>Ln,split_json_bits:()=>Wn,transform:()=>Tn,unbreakscape_text:()=>yn});var p,fe=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&fe.decode();var wt=null;function Et(){return (wt===null||wt.byteLength===0)&&(wt=new Uint8Array(p.memory.buffer)),wt}function N(t,e){return t=t>>>0,fe.decode(Et().subarray(t,t+e))}var nt=new Array(128).fill(void 0);nt.push(void 0,null,true,false);var kt=nt.length;function mn(t){kt===nt.length&&nt.push(nt.length+1);let e=kt;return kt=nt[e],nt[e]=t,e}var O=0,St=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},bn=typeof St.encodeInto=="function"?function(t,e){return St.encodeInto(t,e)}:function(t,e){let r=St.encode(t);return e.set(r),{read:t.length,written:r.length}};function E(t,e,r){if(r===void 0){let i=St.encode(t),c=e(i.length,1)>>>0;return Et().subarray(c,c+i.length).set(i),O=i.length,c}let n=t.length,o=e(n,1)>>>0,a=Et(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=Et().subarray(o+s,o+n),c=bn(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return O=s,o}var pt=null;function h(){return (pt===null||pt.buffer.detached===true||pt.buffer.detached===void 0&&pt.buffer!==p.memory.buffer)&&(pt=new DataView(p.memory.buffer)),pt}function xn(t,e,r){let n,o;try{let i=p.__wbindgen_add_to_stack_pointer(-16),c=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),d=O,g=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),l=O,f=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),m=O;p.breakscape_text(i,c,d,g,l,f,m);var a=h().getInt32(i+0,!0),s=h().getInt32(i+4,!0);return n=a,o=s,N(a,s)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,o,1);}}function yn(t,e,r){let n,o;try{let i=p.__wbindgen_add_to_stack_pointer(-16),c=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),d=O,g=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),l=O,f=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),m=O;p.unbreakscape_text(i,c,d,g,l,f,m);var a=h().getInt32(i+0,!0),s=h().getInt32(i+4,!0);return n=a,o=s,N(a,s)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,o,1);}}function wn(t,e,r,n,o,a,s,i,c){let d,g;try{let m=p.__wbindgen_add_to_stack_pointer(-16),b=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),y=O,x=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O,k=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),v=O,T=E(c,p.__wbindgen_export_0,p.__wbindgen_export_1),A=O;p.info(m,b,y,x,w,k,v,n,o,a,s,i,T,A);var l=h().getInt32(m+0,!0),f=h().getInt32(m+4,!0);return d=l,g=f,N(l,f)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(d,g,1);}}function kn(){return p.info_text_supported()!==0}function vn(t){return nt[t]}function hn(t){t<132||(nt[t]=kt,kt=t);}function Y(t){let e=vn(t);return hn(t),e}function In(t,e,r,n){let o,a;try{let f=p.__wbindgen_add_to_stack_pointer(-16),m=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),b=O,y=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O,w=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),k=O,v=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),T=O;p.convert_text(f,m,b,y,x,w,k,v,T);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),c=h().getInt32(f+8,!0),d=h().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,Y(c);return o=g,a=l,N(g,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function Tn(t,e,r,n,o,a,s,i){let c,d;try{let x=p.__wbindgen_add_to_stack_pointer(-16),w=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),k=O,v=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),T=O,A=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),U=O,G=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),z=O,K=E(o,p.__wbindgen_export_0,p.__wbindgen_export_1),Q=O;p.transform(x,w,k,v,T,A,U,G,z,K,Q,a,s,i);var g=h().getInt32(x+0,!0),l=h().getInt32(x+4,!0),f=h().getInt32(x+8,!0),m=h().getInt32(x+12,!0),b=g,y=l;if(m)throw b=0,y=0,Y(f);return c=b,d=y,N(b,y)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(c,d,1);}}function On(t,e,r){let n,o;try{let l=p.__wbindgen_add_to_stack_pointer(-16),f=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),m=O,b=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),y=O,x=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O;p.resolve_patch_document(l,f,m,b,y,x,w);var a=h().getInt32(l+0,!0),s=h().getInt32(l+4,!0),i=h().getInt32(l+8,!0),c=h().getInt32(l+12,!0),d=a,g=s;if(c)throw d=0,g=0,Y(i);return n=d,o=g,N(d,g)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,o,1);}}function Fn(t,e,r,n,o,a,s,i,c){let d,g;try{let w=p.__wbindgen_add_to_stack_pointer(-16),k=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),v=O,T=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),A=O,U=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),G=O,z=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),K=O;p.diff(w,k,v,T,A,U,G,z,K,o,a,s,i,c);var l=h().getInt32(w+0,!0),f=h().getInt32(w+4,!0),m=h().getInt32(w+8,!0),b=h().getInt32(w+12,!0),y=l,x=f;if(b)throw y=0,x=0,Y(m);return d=y,g=x,N(y,x)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(d,g,1);}}function Rn(t,e,r,n,o,a){let s,i;try{let b=p.__wbindgen_add_to_stack_pointer(-16),y=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O,w=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),k=O,v=E(a,p.__wbindgen_export_0,p.__wbindgen_export_1),T=O;p.complete(b,y,x,e,r,w,k,o,v,T);var c=h().getInt32(b+0,!0),d=h().getInt32(b+4,!0),g=h().getInt32(b+8,!0),l=h().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,Y(g);return s=f,i=m,N(f,m)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(s,i,1);}}function En(t,e,r,n,o,a,s){let i,c;try{let y=p.__wbindgen_add_to_stack_pointer(-16),x=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),w=O,k=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),v=O,T=E(a,p.__wbindgen_export_0,p.__wbindgen_export_1),A=O;p.resolve(y,x,w,e,r,k,v,o,T,A,s);var d=h().getInt32(y+0,!0),g=h().getInt32(y+4,!0),l=h().getInt32(y+8,!0),f=h().getInt32(y+12,!0),m=d,b=g;if(f)throw m=0,b=0,Y(l);return i=m,c=b,N(m,b)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(i,c,1);}}function Sn(t,e,r,n){let o,a;try{let f=p.__wbindgen_add_to_stack_pointer(-16),m=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),b=O,y=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O;p.hover(f,m,b,e,r,y,x);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),c=h().getInt32(f+8,!0),d=h().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,Y(c);return o=g,a=l,N(g,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function Bn(t,e){try{let o=p.__wbindgen_add_to_stack_pointer(-16),a=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),s=O,i=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),c=O;p.register(o,a,s,i,c);var r=h().getInt32(o+0,!0),n=h().getInt32(o+4,!0);if(n)throw Y(r)}finally{p.__wbindgen_add_to_stack_pointer(16);}}function Pn(t,e,r,n,o,a,s,i,c,d,g){let l,f;try{let v=p.__wbindgen_add_to_stack_pointer(-16),T=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),A=O,U=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),G=O,z=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),K=O,Q=E(n,p.__wbindgen_export_0,p.__wbindgen_export_1),ft=O,mt=E(d,p.__wbindgen_export_0,p.__wbindgen_export_1),bt=O,xt=E(g,p.__wbindgen_export_0,p.__wbindgen_export_1),yt=O;p.convert(v,T,A,U,G,z,K,Q,ft,o,a,s,i,c,mt,bt,xt,yt);var m=h().getInt32(v+0,!0),b=h().getInt32(v+4,!0),y=h().getInt32(v+8,!0),x=h().getInt32(v+12,!0),w=m,k=b;if(x)throw w=0,k=0,Y(y);return l=w,f=k,N(w,k)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(l,f,1);}}function An(t,e,r,n,o,a){let s,i;try{let b=p.__wbindgen_add_to_stack_pointer(-16),y=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),x=O,w=E(e,p.__wbindgen_export_0,p.__wbindgen_export_1),k=O,v=E(r,p.__wbindgen_export_0,p.__wbindgen_export_1),T=O;p.canonicalize(b,y,x,w,k,v,T,n,o,a);var c=h().getInt32(b+0,!0),d=h().getInt32(b+4,!0),g=h().getInt32(b+8,!0),l=h().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,Y(g);return s=f,i=m,N(f,m)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(s,i,1);}}function jn(t){let e,r;try{let d=p.__wbindgen_add_to_stack_pointer(-16),g=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),l=O;p.count_bits(d,g,l);var n=h().getInt32(d+0,!0),o=h().getInt32(d+4,!0),a=h().getInt32(d+8,!0),s=h().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,Y(a);return e=i,r=c,N(i,c)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function Ln(t){let e,r;try{let a=p.__wbindgen_add_to_stack_pointer(-16),s=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),i=O;p.split_bits(a,s,i);var n=h().getInt32(a+0,!0),o=h().getInt32(a+4,!0);return e=n,r=o,N(n,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function Cn(t){let e=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),r=O;return p.is_bitmark(e,r)!==0}function Wn(t){let e,r;try{let d=p.__wbindgen_add_to_stack_pointer(-16),g=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),l=O;p.split_json_bits(d,g,l);var n=h().getInt32(d+0,!0),o=h().getInt32(d+4,!0),a=h().getInt32(d+8,!0),s=h().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,Y(a);return e=i,r=c,N(i,c)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(e,r,1);}}function Dn(t,e){let r,n;try{let s=p.__wbindgen_add_to_stack_pointer(-16),i=E(t,p.__wbindgen_export_0,p.__wbindgen_export_1),c=O;p.prettify(s,i,c,e);var o=h().getInt32(s+0,!0),a=h().getInt32(s+4,!0);return r=o,n=a,N(o,a)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(r,n,1);}}async function Jn(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function me(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(N(e,r));return mn(n)},t}function be(t,e){return p=t.exports,xe.__wbindgen_wasm_module=e,pt=null,wt=null,p}function zt(t){if(p!==void 0)return p;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=me();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return be(r,t)}async function xe(t){if(p!==void 0)return p;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_wasm_bg.wasm",import.meta.url));let e=me();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await Jn(await t,e);return be(r,n)}var Kt=xe;var Xt={};Rt(Xt,{breakscape_text:()=>Vn,canonicalize:()=>rr,complete:()=>Qn,convert:()=>nr,convert_text:()=>$n,count_bits:()=>or,default:()=>Yt,diff:()=>Xn,hover:()=>tr,info:()=>Un,info_text_supported:()=>Gn,initSync:()=>qt,is_bitmark:()=>sr,prettify:()=>pr,register:()=>er,resolve:()=>Zn,resolve_patch_document:()=>Yn,split_bits:()=>ir,split_json_bits:()=>ar,transform:()=>qn,unbreakscape_text:()=>Hn});var _,ye=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ye.decode();var vt=null;function Bt(){return (vt===null||vt.byteLength===0)&&(vt=new Uint8Array(_.memory.buffer)),vt}function V(t,e){return t=t>>>0,ye.decode(Bt().subarray(t,t+e))}var rt=new Array(128).fill(void 0);rt.push(void 0,null,true,false);var ht=rt.length;function Mn(t){ht===rt.length&&rt.push(rt.length+1);let e=ht;return ht=rt[e],rt[e]=t,e}var F=0,Pt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Nn=typeof Pt.encodeInto=="function"?function(t,e){return Pt.encodeInto(t,e)}:function(t,e){let r=Pt.encode(t);return e.set(r),{read:t.length,written:r.length}};function S(t,e,r){if(r===void 0){let i=Pt.encode(t),c=e(i.length,1)>>>0;return Bt().subarray(c,c+i.length).set(i),F=i.length,c}let n=t.length,o=e(n,1)>>>0,a=Bt(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=Bt().subarray(o+s,o+n),c=Nn(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return F=s,o}var _t=null;function I(){return (_t===null||_t.buffer.detached===true||_t.buffer.detached===void 0&&_t.buffer!==_.memory.buffer)&&(_t=new DataView(_.memory.buffer)),_t}function Vn(t,e,r){let n,o;try{let i=_.__wbindgen_add_to_stack_pointer(-16),c=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),d=F,g=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),l=F,f=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F;_.breakscape_text(i,c,d,g,l,f,m);var a=I().getInt32(i+0,!0),s=I().getInt32(i+4,!0);return n=a,o=s,V(a,s)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,o,1);}}function Hn(t,e,r){let n,o;try{let i=_.__wbindgen_add_to_stack_pointer(-16),c=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),d=F,g=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),l=F,f=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F;_.unbreakscape_text(i,c,d,g,l,f,m);var a=I().getInt32(i+0,!0),s=I().getInt32(i+4,!0);return n=a,o=s,V(a,s)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,o,1);}}function Un(t,e,r,n,o,a,s,i,c){let d,g;try{let m=_.__wbindgen_add_to_stack_pointer(-16),b=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),y=F,x=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F,k=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,T=S(c,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F;_.info(m,b,y,x,w,k,v,n,o,a,s,i,T,A);var l=I().getInt32(m+0,!0),f=I().getInt32(m+4,!0);return d=l,g=f,V(l,f)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(d,g,1);}}function Gn(){return _.info_text_supported()!==0}function zn(t){return rt[t]}function Kn(t){t<132||(rt[t]=ht,ht=t);}function X(t){let e=zn(t);return Kn(t),e}function $n(t,e,r,n){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),m=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F,y=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),x=F,w=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),T=F;_.convert_text(f,m,b,y,x,w,k,v,T);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),c=I().getInt32(f+8,!0),d=I().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,X(c);return o=g,a=l,V(g,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function qn(t,e,r,n,o,a,s,i){let c,d;try{let x=_.__wbindgen_add_to_stack_pointer(-16),w=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),T=F,A=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),U=F,G=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),z=F,K=S(o,_.__wbindgen_export_0,_.__wbindgen_export_1),Q=F;_.transform(x,w,k,v,T,A,U,G,z,K,Q,a,s,i);var g=I().getInt32(x+0,!0),l=I().getInt32(x+4,!0),f=I().getInt32(x+8,!0),m=I().getInt32(x+12,!0),b=g,y=l;if(m)throw b=0,y=0,X(f);return c=b,d=y,V(b,y)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(c,d,1);}}function Yn(t,e,r){let n,o;try{let l=_.__wbindgen_add_to_stack_pointer(-16),f=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F,b=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),y=F,x=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F;_.resolve_patch_document(l,f,m,b,y,x,w);var a=I().getInt32(l+0,!0),s=I().getInt32(l+4,!0),i=I().getInt32(l+8,!0),c=I().getInt32(l+12,!0),d=a,g=s;if(c)throw d=0,g=0,X(i);return n=d,o=g,V(d,g)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,o,1);}}function Xn(t,e,r,n,o,a,s,i,c){let d,g;try{let w=_.__wbindgen_add_to_stack_pointer(-16),k=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,T=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F,U=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),G=F,z=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),K=F;_.diff(w,k,v,T,A,U,G,z,K,o,a,s,i,c);var l=I().getInt32(w+0,!0),f=I().getInt32(w+4,!0),m=I().getInt32(w+8,!0),b=I().getInt32(w+12,!0),y=l,x=f;if(b)throw y=0,x=0,X(m);return d=y,g=x,V(y,x)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(d,g,1);}}function Qn(t,e,r,n,o,a){let s,i;try{let b=_.__wbindgen_add_to_stack_pointer(-16),y=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),x=F,w=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=S(a,_.__wbindgen_export_0,_.__wbindgen_export_1),T=F;_.complete(b,y,x,e,r,w,k,o,v,T);var c=I().getInt32(b+0,!0),d=I().getInt32(b+4,!0),g=I().getInt32(b+8,!0),l=I().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,X(g);return s=f,i=m,V(f,m)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function Zn(t,e,r,n,o,a,s){let i,c;try{let y=_.__wbindgen_add_to_stack_pointer(-16),x=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F,k=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,T=S(a,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F;_.resolve(y,x,w,e,r,k,v,o,T,A,s);var d=I().getInt32(y+0,!0),g=I().getInt32(y+4,!0),l=I().getInt32(y+8,!0),f=I().getInt32(y+12,!0),m=d,b=g;if(f)throw m=0,b=0,X(l);return i=m,c=b,V(m,b)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(i,c,1);}}function tr(t,e,r,n){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),m=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F,y=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),x=F;_.hover(f,m,b,e,r,y,x);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),c=I().getInt32(f+8,!0),d=I().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,X(c);return o=g,a=l,V(g,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function er(t,e){try{let o=_.__wbindgen_add_to_stack_pointer(-16),a=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),s=F,i=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),c=F;_.register(o,a,s,i,c);var r=I().getInt32(o+0,!0),n=I().getInt32(o+4,!0);if(n)throw X(r)}finally{_.__wbindgen_add_to_stack_pointer(16);}}function nr(t,e,r,n,o,a,s,i,c,d,g){let l,f;try{let v=_.__wbindgen_add_to_stack_pointer(-16),T=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F,U=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),G=F,z=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),K=F,Q=S(n,_.__wbindgen_export_0,_.__wbindgen_export_1),ft=F,mt=S(d,_.__wbindgen_export_0,_.__wbindgen_export_1),bt=F,xt=S(g,_.__wbindgen_export_0,_.__wbindgen_export_1),yt=F;_.convert(v,T,A,U,G,z,K,Q,ft,o,a,s,i,c,mt,bt,xt,yt);var m=I().getInt32(v+0,!0),b=I().getInt32(v+4,!0),y=I().getInt32(v+8,!0),x=I().getInt32(v+12,!0),w=m,k=b;if(x)throw w=0,k=0,X(y);return l=w,f=k,V(w,k)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(l,f,1);}}function rr(t,e,r,n,o,a){let s,i;try{let b=_.__wbindgen_add_to_stack_pointer(-16),y=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),x=F,w=S(e,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=S(r,_.__wbindgen_export_0,_.__wbindgen_export_1),T=F;_.canonicalize(b,y,x,w,k,v,T,n,o,a);var c=I().getInt32(b+0,!0),d=I().getInt32(b+4,!0),g=I().getInt32(b+8,!0),l=I().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,X(g);return s=f,i=m,V(f,m)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function or(t){let e,r;try{let d=_.__wbindgen_add_to_stack_pointer(-16),g=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),l=F;_.count_bits(d,g,l);var n=I().getInt32(d+0,!0),o=I().getInt32(d+4,!0),a=I().getInt32(d+8,!0),s=I().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,X(a);return e=i,r=c,V(i,c)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(e,r,1);}}function ir(t){let e,r;try{let a=_.__wbindgen_add_to_stack_pointer(-16),s=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),i=F;_.split_bits(a,s,i);var n=I().getInt32(a+0,!0),o=I().getInt32(a+4,!0);return e=n,r=o,V(n,o)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(e,r,1);}}function sr(t){let e=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),r=F;return _.is_bitmark(e,r)!==0}function ar(t){let e,r;try{let d=_.__wbindgen_add_to_stack_pointer(-16),g=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),l=F;_.split_json_bits(d,g,l);var n=I().getInt32(d+0,!0),o=I().getInt32(d+4,!0),a=I().getInt32(d+8,!0),s=I().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,X(a);return e=i,r=c,V(i,c)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(e,r,1);}}function pr(t,e){let r,n;try{let s=_.__wbindgen_add_to_stack_pointer(-16),i=S(t,_.__wbindgen_export_0,_.__wbindgen_export_1),c=F;_.prettify(s,i,c,e);var o=I().getInt32(s+0,!0),a=I().getInt32(s+4,!0);return r=o,n=a,V(o,a)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(r,n,1);}}async function _r(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function we(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(V(e,r));return Mn(n)},t}function ke(t,e){return _=t.exports,ve.__wbindgen_wasm_module=e,_t=null,vt=null,_}function qt(t){if(_!==void 0)return _;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=we();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return ke(r,t)}async function ve(t){if(_!==void 0)return _;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_browser_full_wasm_bg.wasm",import.meta.url));let e=we();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await _r(await t,e);return ke(r,n)}var Yt=ve;var te={};Rt(te,{breakscape_text:()=>dr,canonicalize:()=>Ir,complete:()=>wr,convert:()=>hr,convert_text:()=>Sr,count_bits:()=>Tr,default:()=>Zt,hover:()=>vr,info:()=>gr,initSync:()=>Qt,is_bitmark:()=>Fr,prettify:()=>Er,register:()=>br,resolve:()=>kr,resolve_patch_document:()=>yr,split_bits:()=>Or,split_json_bits:()=>Rr,transform:()=>xr,unbreakscape_text:()=>lr});var u,he=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&he.decode();var It=null;function At(){return (It===null||It.byteLength===0)&&(It=new Uint8Array(u.memory.buffer)),It}function H(t,e){return t=t>>>0,he.decode(At().subarray(t,t+e))}var ot=new Array(128).fill(void 0);ot.push(void 0,null,true,false);var Tt=ot.length;function cr(t){Tt===ot.length&&ot.push(ot.length+1);let e=Tt;return Tt=ot[e],ot[e]=t,e}var B=0,jt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},ur=typeof jt.encodeInto=="function"?function(t,e){return jt.encodeInto(t,e)}:function(t,e){let r=jt.encode(t);return e.set(r),{read:t.length,written:r.length}};function P(t,e,r){if(r===void 0){let i=jt.encode(t),c=e(i.length,1)>>>0;return At().subarray(c,c+i.length).set(i),B=i.length,c}let n=t.length,o=e(n,1)>>>0,a=At(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==n){s!==0&&(t=t.slice(s)),o=r(o,n,n=s+t.length*3,1)>>>0;let i=At().subarray(o+s,o+n),c=ur(t,i);s+=c.written,o=r(o,n,s,1)>>>0;}return B=s,o}var ct=null;function R(){return (ct===null||ct.buffer.detached===true||ct.buffer.detached===void 0&&ct.buffer!==u.memory.buffer)&&(ct=new DataView(u.memory.buffer)),ct}function dr(t,e,r){let n,o;try{let i=u.__wbindgen_add_to_stack_pointer(-16),c=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),d=B,g=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),l=B,f=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),m=B;u.breakscape_text(i,c,d,g,l,f,m);var a=R().getInt32(i+0,!0),s=R().getInt32(i+4,!0);return n=a,o=s,H(a,s)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(n,o,1);}}function lr(t,e,r){let n,o;try{let i=u.__wbindgen_add_to_stack_pointer(-16),c=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),d=B,g=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),l=B,f=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),m=B;u.unbreakscape_text(i,c,d,g,l,f,m);var a=R().getInt32(i+0,!0),s=R().getInt32(i+4,!0);return n=a,o=s,H(a,s)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(n,o,1);}}function gr(t,e,r,n,o,a,s,i,c){let d,g;try{let m=u.__wbindgen_add_to_stack_pointer(-16),b=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),y=B,x=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),w=B,k=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),v=B,T=P(c,u.__wbindgen_export_0,u.__wbindgen_export_1),A=B;u.info(m,b,y,x,w,k,v,n,o,a,s,i,T,A);var l=R().getInt32(m+0,!0),f=R().getInt32(m+4,!0);return d=l,g=f,H(l,f)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(d,g,1);}}function fr(t){return ot[t]}function mr(t){t<132||(ot[t]=Tt,Tt=t);}function Z(t){let e=fr(t);return mr(t),e}function br(t,e){try{let o=u.__wbindgen_add_to_stack_pointer(-16),a=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),s=B,i=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),c=B;u.register(o,a,s,i,c);var r=R().getInt32(o+0,!0),n=R().getInt32(o+4,!0);if(n)throw Z(r)}finally{u.__wbindgen_add_to_stack_pointer(16);}}function xr(t,e,r,n,o,a,s,i){let c,d;try{let x=u.__wbindgen_add_to_stack_pointer(-16),w=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),k=B,v=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),T=B,A=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),U=B,G=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),z=B,K=P(o,u.__wbindgen_export_0,u.__wbindgen_export_1),Q=B;u.transform(x,w,k,v,T,A,U,G,z,K,Q,a,s,i);var g=R().getInt32(x+0,!0),l=R().getInt32(x+4,!0),f=R().getInt32(x+8,!0),m=R().getInt32(x+12,!0),b=g,y=l;if(m)throw b=0,y=0,Z(f);return c=b,d=y,H(b,y)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(c,d,1);}}function yr(t,e,r){let n,o;try{let l=u.__wbindgen_add_to_stack_pointer(-16),f=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),m=B,b=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),y=B,x=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),w=B;u.resolve_patch_document(l,f,m,b,y,x,w);var a=R().getInt32(l+0,!0),s=R().getInt32(l+4,!0),i=R().getInt32(l+8,!0),c=R().getInt32(l+12,!0),d=a,g=s;if(c)throw d=0,g=0,Z(i);return n=d,o=g,H(d,g)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(n,o,1);}}function wr(t,e,r,n,o,a){let s,i;try{let b=u.__wbindgen_add_to_stack_pointer(-16),y=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),x=B,w=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),k=B,v=P(a,u.__wbindgen_export_0,u.__wbindgen_export_1),T=B;u.complete(b,y,x,e,r,w,k,o,v,T);var c=R().getInt32(b+0,!0),d=R().getInt32(b+4,!0),g=R().getInt32(b+8,!0),l=R().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,Z(g);return s=f,i=m,H(f,m)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(s,i,1);}}function kr(t,e,r,n,o,a,s){let i,c;try{let y=u.__wbindgen_add_to_stack_pointer(-16),x=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),w=B,k=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),v=B,T=P(a,u.__wbindgen_export_0,u.__wbindgen_export_1),A=B;u.resolve(y,x,w,e,r,k,v,o,T,A,s);var d=R().getInt32(y+0,!0),g=R().getInt32(y+4,!0),l=R().getInt32(y+8,!0),f=R().getInt32(y+12,!0),m=d,b=g;if(f)throw m=0,b=0,Z(l);return i=m,c=b,H(m,b)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(i,c,1);}}function vr(t,e,r,n){let o,a;try{let f=u.__wbindgen_add_to_stack_pointer(-16),m=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),b=B,y=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),x=B;u.hover(f,m,b,e,r,y,x);var s=R().getInt32(f+0,!0),i=R().getInt32(f+4,!0),c=R().getInt32(f+8,!0),d=R().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,Z(c);return o=g,a=l,H(g,l)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(o,a,1);}}function hr(t,e,r,n,o,a,s,i,c,d,g){let l,f;try{let v=u.__wbindgen_add_to_stack_pointer(-16),T=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),A=B,U=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),G=B,z=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),K=B,Q=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),ft=B,mt=P(d,u.__wbindgen_export_0,u.__wbindgen_export_1),bt=B,xt=P(g,u.__wbindgen_export_0,u.__wbindgen_export_1),yt=B;u.convert(v,T,A,U,G,z,K,Q,ft,o,a,s,i,c,mt,bt,xt,yt);var m=R().getInt32(v+0,!0),b=R().getInt32(v+4,!0),y=R().getInt32(v+8,!0),x=R().getInt32(v+12,!0),w=m,k=b;if(x)throw w=0,k=0,Z(y);return l=w,f=k,H(w,k)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(l,f,1);}}function Ir(t,e,r,n,o,a){let s,i;try{let b=u.__wbindgen_add_to_stack_pointer(-16),y=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),x=B,w=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),k=B,v=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),T=B;u.canonicalize(b,y,x,w,k,v,T,n,o,a);var c=R().getInt32(b+0,!0),d=R().getInt32(b+4,!0),g=R().getInt32(b+8,!0),l=R().getInt32(b+12,!0),f=c,m=d;if(l)throw f=0,m=0,Z(g);return s=f,i=m,H(f,m)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(s,i,1);}}function Tr(t){let e,r;try{let d=u.__wbindgen_add_to_stack_pointer(-16),g=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),l=B;u.count_bits(d,g,l);var n=R().getInt32(d+0,!0),o=R().getInt32(d+4,!0),a=R().getInt32(d+8,!0),s=R().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,Z(a);return e=i,r=c,H(i,c)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function Or(t){let e,r;try{let a=u.__wbindgen_add_to_stack_pointer(-16),s=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),i=B;u.split_bits(a,s,i);var n=R().getInt32(a+0,!0),o=R().getInt32(a+4,!0);return e=n,r=o,H(n,o)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function Fr(t){let e=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),r=B;return u.is_bitmark(e,r)!==0}function Rr(t){let e,r;try{let d=u.__wbindgen_add_to_stack_pointer(-16),g=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),l=B;u.split_json_bits(d,g,l);var n=R().getInt32(d+0,!0),o=R().getInt32(d+4,!0),a=R().getInt32(d+8,!0),s=R().getInt32(d+12,!0),i=n,c=o;if(s)throw i=0,c=0,Z(a);return e=i,r=c,H(i,c)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(e,r,1);}}function Er(t,e){let r,n;try{let s=u.__wbindgen_add_to_stack_pointer(-16),i=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),c=B;u.prettify(s,i,c,e);var o=R().getInt32(s+0,!0),a=R().getInt32(s+4,!0);return r=o,n=a,H(o,a)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(r,n,1);}}function Sr(t,e,r,n){let o,a;try{let f=u.__wbindgen_add_to_stack_pointer(-16),m=P(t,u.__wbindgen_export_0,u.__wbindgen_export_1),b=B,y=P(e,u.__wbindgen_export_0,u.__wbindgen_export_1),x=B,w=P(r,u.__wbindgen_export_0,u.__wbindgen_export_1),k=B,v=P(n,u.__wbindgen_export_0,u.__wbindgen_export_1),T=B;u.convert_text(f,m,b,y,x,w,k,v,T);var s=R().getInt32(f+0,!0),i=R().getInt32(f+4,!0),c=R().getInt32(f+8,!0),d=R().getInt32(f+12,!0),g=s,l=i;if(d)throw g=0,l=0,Z(c);return o=g,a=l,H(g,l)}finally{u.__wbindgen_add_to_stack_pointer(16),u.__wbindgen_export_2(o,a,1);}}async function Br(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(n){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function Ie(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(H(e,r));return cr(n)},t}function Te(t,e){return u=t.exports,Oe.__wbindgen_wasm_module=e,ct=null,It=null,u}function Qt(t){if(u!==void 0)return u;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=Ie();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return Te(r,t)}async function Oe(t){if(u!==void 0)return u;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("bitmark_json_wasm_bg.wasm",import.meta.url));let e=Ie();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await Br(await t,e);return Te(r,n)}var Zt=Oe;var Ot={version:"7.2.0"};var ee="browser-full",Ct=class extends Error{constructor(){super("wasm not initialised: call init() (or init({ feature: \u2026 })) first"),this.name="NotInitializedError";}},dt=class extends Error{constructor(e){super(e),this.name="RegisterError";}},it=class extends Error{constructor(e,r){super(`${e} is not available in the loaded wasm module${r?` (feature: "${r}")`:""}; init({ feature: "full" }) to load it`),this.name="UnsupportedFeatureError";}},Lt,Re,Fe,Ee=new Map;function C(){if(!Lt&&Fe&&Fe(),!Lt)throw new Ct;return Lt}function ne(t,e){for(let[r,n]of Ee)try{e.register(r,n);}catch(o){throw new dt(o instanceof Error?o.message:String(o))}Lt=e,Re=t;}function Se(t,e){Ee.set(t,e);}function et(){return Re}function Pr(t){let e=t.trim();return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):t}function Ar(t){return t===void 0?"":typeof t=="string"?t.trim():JSON.stringify(t)}function jr(t,e,r){if(r){let o=JSON.parse(t.split_bits(e));return o.map(a=>({view:{format:"bitmark",index:a.index,total:o.length,source:a.source},source:a.source}))}let n=JSON.parse(t.split_json_bits(e));return n.map((o,a)=>({view:{format:"json",index:a,total:n.length,bit:o.bit??{}},source:JSON.stringify([o])}))}function re(t,e,r){let n=r.mode??"optimized",o=r.outputFormat??"json",a=r.spacesAroundValues??1,s=r.indent??2,i=r.pretty??false,c=r.inputFormat??"auto",d=c==="bitmark"||c!=="json"&&t.is_bitmark(e),g=d?"bitmark":"json";t.transform("","bitmark",o,n,"",false,s,a);let l=jr(t,e,d),f=l.length,m=[];for(let k=0;k<f;k++){let{view:v}=l[k];v.index=k,v.total=f;let T=r.preHook?r.preHook(v)||{}:{};m.push(T.drop?null:{patches:T.patches??[],outputFormat:T.outputFormat??o});}let b=Ar(r.patch),y;b===""?y=l.map((k,v)=>({source:v,bit:null,patch:[]})):y=JSON.parse(t.resolve_patch_document(e,g,b));let x=[],w=[];for(let k of y)if(k.source!==null){let v=m[k.source];if(!v)continue;x.push({index:k.source,source:l[k.source].source,inputFormat:g,outputFormat:v.outputFormat,mode:n,patchJson:JSON.stringify([...k.patch,...v.patches]),spacesAroundValues:a}),w.push(l[k.source].view);}else {let v=k.bit??{},T=x.length;x.push({index:T,source:JSON.stringify([{bit:v}]),inputFormat:"json",outputFormat:o,mode:n,patchJson:JSON.stringify(k.patch),spacesAroundValues:a}),w.push({format:"json",index:T,total:f,bit:v});}return {jobs:x,views:w,output:o,pretty:i,indent:s}}function Lr(t,e){let r=t.transform(e.source,e.inputFormat,e.outputFormat,e.mode,e.patchJson,false,2,e.spacesAroundValues);return e.outputFormat==="json"?Pr(r):r}function oe(t,e,r,n,o){if(r!=="json")return e.join(`
2
+ `);let a=`[${e.join(",")}]`;return n?t.prettify(a,o):a}function Be(t,e,r){let n=re(t,e,r),o=[];for(let a=0;a<n.jobs.length;a++){let s=Lr(t,n.jobs[a]);r.postHook?.(n.views[a],s),o.push(s);}return oe(t,o,n.output,n.pretty,n.indent)}async function Pe(t,e,r,n){let o=re(t,e,r),a=await n(o.jobs,r.workers??4);for(let s=0;s<a.length;s++)r.postHook?.(o.views[s],a[s]);return oe(t,a,o.output,o.pretty,o.indent)}var ie;function Ae(t){ie=t;}function W(){if(!ie)throw new Error("legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)");return ie()}function je(t,e,r){if(t.length===0)return Promise.resolve([]);let n=Math.max(1,Math.min(e,t.length));return new Promise((o,a)=>{let s=new Array(t.length),i=0,c=0,d=false,g=[],l=m=>{if(!d){d=true;for(let b of g)b.terminate();m?a(m):o(s);}},f=m=>{if(d||i>=t.length)return;let b=i++;m.post({id:b,job:t[b]});};for(let m=0;m<n;m++){let b=r(y=>{if(!d){if(!y.ok)return l(new Error(y.error??"worker job failed"));s[y.id]=y.element,++c===t.length?l():f(b);}},l);g.push(b);}for(let m of g)f(m);})}function Le(t,e,r){let n=new URL("./worker-entry.js",import.meta.url);return je(t,e,(o,a)=>{let s=new Worker(n,{type:"module"});return s.onmessage=i=>o(i.data),s.onerror=i=>a(new Error(i.message||"worker error")),{post:i=>s.postMessage({...i,feature:r}),terminate:()=>s.terminate()}})}var _n={};Rt(_n,{Ast:()=>$e,BitType:()=>Ue,BitmarkFileGenerator:()=>Xe,BitmarkGenerator:()=>qe,BitmarkParser:()=>rn,BitmarkParserGenerator:()=>Ht,BitmarkParserType:()=>zr,BitmarkStringGenerator:()=>Ye,BitmarkVersion:()=>Ur,BodyTextFormat:()=>qr,BoundingBoxIndex:()=>Ke,Builder:()=>Vt,CardSetVersion:()=>Gr,FileWriter:()=>an,HtmlTableGenerator:()=>en,HtmlTableParser:()=>nn,InfoFormat:()=>$r,InfoType:()=>Kr,Input:()=>Nr,InputFormat:()=>Hr,JsonFileGenerator:()=>tn,JsonGenerator:()=>Qe,JsonParser:()=>on,JsonStringGenerator:()=>Ze,LegacyUnsupportedError:()=>lt,NodeType:()=>ze,Output:()=>Vr,ResourceBuilder:()=>Ut,StreamWriter:()=>pn,StringWriter:()=>sn,TextLocation:()=>Yr,TextMarkType:()=>Ve,TextNodeType:()=>He,bitmarkTextParse:()=>Me,isPseudoAst:()=>We});var lt=class extends Error{constructor(e){super(e),this.name="LegacyUnsupportedError";}};function at(t,e){throw new lt(`'${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}function tt(t,e){throw new lt(`Option '${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}var se="bitmark v2 output is not supported (this parser is bitmark v3 only)";function ae(t){t.bitmarkVersion===2&&tt("bitmarkVersion: 2",se);}function Dt(t){t.explicitTextFormat&&tt("bitmarkOptions.explicitTextFormat"),t.cardSetVersion===1&&tt("bitmarkOptions.cardSetVersion: 1",se),t.debugGenerationInline&&tt("bitmarkOptions.debugGenerationInline"),t.noBreakscaping&&tt("bitmarkOptions.noBreakscaping");}function Jt(t){t.textAsPlainText&&tt("jsonOptions.textAsPlainText",se),t.debugGenerationInline&&tt("jsonOptions.debugGenerationInline");}function ut(t){return t===true?{pretty:true,indent:2}:typeof t=="number"&&t>0?{pretty:true,indent:t}:{pretty:false,indent:2}}function Mt(t){return t===void 0||t===true?1:t===false?0:Math.max(0,Math.min(10,t))}function Nt(t){switch(t){case "text":case "latex":case "json":case "xml":return "plainText";default:return "bitmark++"}}var Ce=Symbol.for("@gmb/bitmark-parser/legacy-pseudo-ast");function gt(t){let e={bits:t};return Object.defineProperty(e,Ce,{value:true,enumerable:false}),e}function We(t){return t!==null&&typeof t=="object"&&(Ce in t||Array.isArray(t.bits))}var De={"extractor-image":{key:"images",resourceType:"image"},"extractor-image-collapsible":{key:"images",resourceType:"image"},"images-logo-grave":{key:"logos",resourceType:"image"},"prototype-images":{key:"images",resourceType:"image"}};var pe=Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser"),Wr={bitType:"type",textFormat:"format",flashcards:"cards",markConfig:"marks"},Dr={"bitmark--":"bitmark++","bitmark+":"bitmark++"},Jr={bitmark:"bitmark++",text:"text",json:"json",latex:"latex",xml:"xml"},Mr=["title","subtitle","item","lead","pageNumber","marginNumber","hint","instruction","caption"],Vt=class{buildBitmark(e){let r=gt(e.bits??[]);return e.errors!==void 0&&(r.errors=e.errors),r}buildBit(e,r){let n=W(),o={...e},a=o.bitType,s=this.getBitConfig(a),i={};i.type=a,o.isCommented&&(i.type="_comment",i.originalType=a),delete o.bitType,delete o.isCommented;let c=o.textFormat;c!==void 0?(i.format=Dr[c]??c,delete o.textFormat):i.format=Jr[s.bodyFormat??""]??"bitmark++",delete o.resourceType;let d=o.body;d!=null&&typeof d=="object"&&"body"in d&&(i.body=d.body,delete o.body),o.example!==void 0?(i.isExample=true,i.example=o.example,delete o.example,delete o.__isDefaultExample):o.__isDefaultExample&&(i.isExample=true,delete o.__isDefaultExample);let g=o.resources;if(g!==void 0&&a!==void 0){let x=Array.isArray(g)?g:[g],w=De[a];w?i[w.key]=x.filter(k=>k!==null&&typeof k=="object"&&k.type===w.resourceType):x.length>=1&&(i.resource=x[0]),delete o.resources;}let l=o.parser;delete o.parser;let f=o.extraProperties;delete o.extraProperties;for(let[x,w]of Object.entries(o))w!==void 0&&(i[Wr[x]??x]=w);if(f)for(let[x,w]of Object.entries(f))x in i||(i[x]=w);this.parseStringTexts(i);let m=n.convert(JSON.stringify([{bit:i}]),"json","json","optimized",false,2,1,false,false,"",""),y=JSON.parse(m)[0]?.bit??i;for(let[x,w]of Object.entries(i))x in y||w===false||w===""||w===null||Array.isArray(w)&&w.length===0||(y[x]=w);return l!==void 0&&Object.defineProperty(y,pe,{value:l,enumerable:false}),y}buildHighlight(e,r){if(!r)return;let n={...r},o=n.attrs;return o&&Object.assign(n,o),{type:"highlight",texts:Array.isArray(n.texts)?n.texts.filter(i=>i!=null).map(i=>({text:i.text??"",isCorrect:i.isCorrect??false,isHighlighted:i.isHighlighted??false,...Je(i,["text","isCorrect","isHighlighted"])})):[],prefix:n.prefix??"",postfix:n.postfix??"",...Je(n,["type","texts","prefix","postfix","attrs"]),attrs:{}}}parseStringTexts(e){let r=W(),n=(s,i)=>{if(s==="")return s;let c=r.convert_text(s,"textToAst","bitmark++",i);try{return JSON.parse(c)}catch{return s}},o=e.format,a=o===void 0||o==="bitmark++"||o==="bitmark+";if(typeof e.body=="string")if(o==="json")try{e.body=JSON.parse(e.body);}catch{e.body=null;}else a&&(e.body=n(e.body,"body"));for(let s of Mr){let i=e[s];typeof i=="string"&&(e[s]=n(i,"tag"));}}getBitConfig(e){let r=W();if(e!==void 0)try{let n=JSON.parse(r.info("bit","json",e,!1,2,!1,!1,!0,""));if(n.error===void 0)return {bodyFormat:n.body?.format}}catch{}throw new Error(`No config found for bit: ${e}`)}};function Je(t,e){let r={};for(let[n,o]of Object.entries(t))o!==void 0&&!e.includes(n)&&(r[n]=o);return r}var Ht=class{version(){return Ot.version}convert(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);ae(n),Dt(a),Jt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:c}=this.resolveInput(e,n.inputFormat),d=n.outputFormat??(c?"json":"bitmark"),g=d==="ast"?"json":d,{pretty:l,indent:f}=ut(o.prettify),m=g==="bitmark"?ut(a.prettifyJson):{pretty:l,indent:f},b=Mt(a.spacesAroundValues),y=!o.excludeUnknownProperties,x=s.convert(i,c?"bitmark":"json",g,"optimized",m.pretty,m.indent,b,y,false,"","");if(d==="bitmark"||d==="text")return this.deliver(x,n.outputFile,n.fileOptions);if(d==="json")return n.outputFile?this.deliver(x,n.outputFile,n.fileOptions):l||o.stringify?x:JSON.parse(x);let w=gt(JSON.parse(x));return n.outputFile?this.deliver(JSON.stringify(w),n.outputFile,n.fileOptions):w}upgrade(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);ae(n),Dt(a),Jt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:c}=this.resolveInput(e,n.inputFormat),{pretty:d,indent:g}=ut(c?a.prettifyJson:o.prettify),l=Mt(a.spacesAroundValues),f=s.canonicalize(i,c?"bitmark":"json","optimized",d,g,l);return c?this.deliver(f,n.outputFile,n.fileOptions):n.outputFile?this.deliver(f,n.outputFile,n.fileOptions):d||o.stringify?f:JSON.parse(f)}info(e){let r=Object.assign({},e),n=W(),o=r.type??"list",a=r.outputFormat??"text",{pretty:s,indent:i}=ut(r.prettify),c=a==="pojo"?"json":a,d=n.info(o,c,r.bit??"",s,i,false,false,true,"");return a==="pojo"?JSON.parse(d):d}generateConfig(e){at("BitmarkParserGenerator.generateConfig","bpg-internal development tool");}convertHtmlTable(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);Dt(a),Jt(o),n.keepUnknownTags&&tt("keepUnknownTags"),n.noBreakscaping&&tt("noBreakscaping"),this.checkBrowserFileWrite(n.outputFile);let s=W(),i=typeof e=="string"?this.maybeReadFile(e,void 0):"";if(!(n.inputFormat==="html"||n.inputFormat===void 0&&typeof e=="string"&&/<table[\s>]/iu.test(i))){let{source:k,isBitmark:v}=this.resolveInput(e,void 0),T=s.convert(k,v?"bitmark":"json","html","optimized",false,2,1,false,false,"","");return this.deliver(_e(T).join(`
3
+ `),n.outputFile,n.fileOptions)}let d=n.tableFormat==="table"?"table":"table-extended",g=_e(i).map(k=>`<bitmark-bit data-type="${d}" data-format="bitmark++">${k}</bitmark-bit>`).join(""),l=n.outputFormat??"bitmark",{pretty:f,indent:m}=ut(o.prettify),b=Mt(a.spacesAroundValues);if(l==="html"){let k=s.convert(g,"html","html","optimized",false,2,1,false,false,"","");return this.deliver(_e(k).join(`
4
+ `),n.outputFile,n.fileOptions)}let y=l==="ast"?"json":l,x=s.convert(g,"html",y,"optimized",f,m,b,false,false,"","");if(l==="bitmark"||l==="text")return this.deliver(x,n.outputFile,n.fileOptions);if(l==="json")return n.outputFile?this.deliver(x,n.outputFile,n.fileOptions):f||o.stringify?x:JSON.parse(x);let w=gt(JSON.parse(x));return n.outputFile?this.deliver(JSON.stringify(w),n.outputFile,n.fileOptions):w}createAst(e,r){let n=Object.assign({},r),o=W(),{source:a,isBitmark:s}=this.resolveInput(e,n.inputFormat),i=o.convert(a,s?"bitmark":"json","json","optimized",false,2,1,true,false,"","");return gt(JSON.parse(i))}breakscapeText(e,r){if(!e)return e;let n=Object.assign({},r);this.checkBrowserFileWrite(n.outputFile);let o=W(),a=this.maybeReadFile(e,n.inputFormat),s=o.breakscape_text(a,Nt(n.textFormat),n.textLocation??"body");return this.deliver(s,n.outputFile,n.fileOptions)}unbreakscapeText(e,r){if(!e)return e;let n=Object.assign({},r);this.checkBrowserFileWrite(n.outputFile);let o=W(),a=this.maybeReadFile(e,n.inputFormat),s=o.unbreakscape_text(a,Nt(n.textFormat),n.textLocation??"body");return this.deliver(s,n.outputFile,n.fileOptions)}convertText(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions);this.checkBrowserFileWrite(n.outputFile);let a=W(),s=n.textFormat===void 0||Nt(n.textFormat)==="bitmark++",i=n.textLocation??"body",c,d;if(typeof e=="string"?(c=this.maybeReadFile(e,n.inputFormat),d=this.parseTextAstString(c)):(c=JSON.stringify(e),d=Array.isArray(e)?e:void 0),d!==void 0){let b=s?a.convert_text(JSON.stringify(d),"astToText","bitmark++",i):a.convert_text(JSON.stringify(d),"astToPlainText","plainText",i);return this.deliver(b,n.outputFile,n.fileOptions)}let g=a.convert_text(c,"textToAst",s?"bitmark++":"plainText","body"),{pretty:l,indent:f}=ut(o.prettify),m=l?a.prettify(g,f):g;return n.outputFile?this.deliver(m,n.outputFile,n.fileOptions):l?m:JSON.parse(g)}textAstToPlainText(e,r){return W().convert_text(typeof e=="string"?e:JSON.stringify(e),"astToPlainText","bitmark++","body")}extractPlainText(e,r){let n=r?.inputFormat,o=W();if(n==="plainText")return typeof e=="string"?String(e):"";if(n==="bitmarkText"){let c=o.convert_text(String(e),"textToAst","bitmark++","body");return o.convert_text(c,"astToPlainText","bitmark++","body")}if(typeof e=="string"&&this.parseTextAstString(e)===void 0&&!o.is_bitmark(e)&&!(()=>{try{return JSON.parse(e),!0}catch{return false}})())return this.extractPlainText(e,{inputFormat:"bitmarkText"});let{source:a,isBitmark:s}=this.resolveInput(e,void 0);return o.convert(a,s?"bitmark":"json","text","optimized",false,2,1,false,false,"","")}parseTextAstString(e){let r=e.trim();if(r.startsWith("["))try{let n=JSON.parse(r);if(Array.isArray(n)&&n.every(o=>o!==null&&typeof o=="object"&&"type"in o))return n}catch{}}resolveInput(e,r){if(typeof e!="string"){let a=this.jsonEntries(e);return {source:JSON.stringify(a?a.map(s=>this.toWrapperEntry(s)):e),isBitmark:false}}let n=this.maybeReadFile(e,r);if(W().is_bitmark(n))return {source:n,isBitmark:true};try{let a=JSON.parse(n),s=this.jsonEntries(a);if(s)return {source:JSON.stringify(s.map(i=>this.toWrapperEntry(i))),isBitmark:!1}}catch{return {source:n,isBitmark:true}}return {source:n,isBitmark:false}}jsonEntries(e){if(Array.isArray(e))return e;if(e!==null&&typeof e=="object"){let r=e;if(Array.isArray(r.bits))return r.bits;if("bit"in r)return [r];if(typeof r.type=="string")return [{bit:r}]}}toWrapperEntry(e){if(e!==null&&typeof e=="object"&&"bit"in e)return e;let r={bit:e},n=e?.[pe];return n!==void 0&&(r.parser=n),r}maybeReadFile(e,r){if(r==="string")return e;return e;}checkBrowserFileWrite(e){if(e&&true)throw new Error("Cannot write to file in browser environment")}deliver(e,r,n){if(!r)return e;throw new Error("Cannot write to file in browser environment");}};function _e(t){let e=[],r=t.toLowerCase(),n=0;for(;;){let o=r.indexOf("<table",n);if(o===-1)break;let a=0,s=o,i=-1;for(;s<t.length;){let c=r.indexOf("<table",s),d=r.indexOf("</table",s);if(d===-1)break;if(c!==-1&&c<d)a++,s=c+6;else {a--;let g=r.indexOf(">",d);if(s=g===-1?t.length:g+1,a===0){i=s;break}}}if(i===-1)break;e.push(t.slice(o,i)),n=i;}return e}function Me(t){let e=W().convert_text(t,"textToAst","bitmark++","body");return JSON.parse(e)}var M={imageResource:{type:"image",key:"image",valueField:"src"},imageLinkResource:{type:"image-link",key:"imageLink",valueField:"url"},audioResource:{type:"audio",key:"audio",valueField:"src"},audioEmbedResource:{type:"audio-embed",key:"audioEmbed",valueField:"src"},audioLinkResource:{type:"audio-link",key:"audioLink",valueField:"url"},videoResource:{type:"video",key:"video",valueField:"src"},videoEmbedResource:{type:"video-embed",key:"videoEmbed",valueField:"url"},videoLinkResource:{type:"video-link",key:"videoLink",valueField:"url"},stillImageFilmEmbedResource:{type:"still-image-film-embed",key:"stillImageFilmEmbed",valueField:"url"},stillImageFilmLinkResource:{type:"still-image-film-link",key:"stillImageFilmLink",valueField:"url"},articleResource:{type:"article",key:"article",valueField:"body"},documentResource:{type:"document",key:"document",valueField:"url"},documentEmbedResource:{type:"document-embed",key:"documentEmbed",valueField:"url"},documentLinkResource:{type:"document-link",key:"documentLink",valueField:"url"},documentDownloadResource:{type:"document-download",key:"documentDownload",valueField:"url"},appLinkResource:{type:"app-link",key:"appLink",valueField:"url"},websiteLinkResource:{type:"website-link",key:"websiteLink",valueField:"url"}};function D(t){return (e,r,n)=>{if(!r)return;let{value:o,...a}=r,s={[t.valueField]:o??""};for(let[i,c]of Object.entries(a))c!==void 0&&(s[i]=c);return {type:t.type,[t.key]:s}}}var Ne=Object.fromEntries(Object.values(M).map(t=>[t.type,t])),Ut=class{constructor(){J(this,"imageResource",D(M.imageResource));J(this,"imageLinkResource",D(M.imageLinkResource));J(this,"audioResource",D(M.audioResource));J(this,"audioEmbedResource",D(M.audioEmbedResource));J(this,"audioLinkResource",D(M.audioLinkResource));J(this,"videoResource",D(M.videoResource));J(this,"videoEmbedResource",D(M.videoEmbedResource));J(this,"videoLinkResource",D(M.videoLinkResource));J(this,"stillImageFilmEmbedResource",D(M.stillImageFilmEmbedResource));J(this,"stillImageFilmLinkResource",D(M.stillImageFilmLinkResource));J(this,"articleResource",D(M.articleResource));J(this,"documentResource",D(M.documentResource));J(this,"documentEmbedResource",D(M.documentEmbedResource));J(this,"documentLinkResource",D(M.documentLinkResource));J(this,"documentDownloadResource",D(M.documentDownloadResource));J(this,"appLinkResource",D(M.appLinkResource));J(this,"websiteLinkResource",D(M.websiteLinkResource));}resourceFromResourceJson(e,r){if(!r)return;let n=!Array.isArray(r),o=n?[r]:r,a=[];for(let s of o){let i=Ne[s.type];if(!i)continue;let c=s[i.key]??{},{[i.valueField]:d,...g}=c,l=D(i)(void 0,{value:d,...g});l&&a.push(l);}if(a.length!==0)return n?a[0]:a}resourceFromResourceDataJson(e,r,n){if(!n)return;let o=Ne[r];if(!o)return;let a=typeof n=="string"?n:void 0,s=typeof n=="object"?n:{},{url:i,src:c,body:d,...g}=s,l=i??c??d??a;return D(o)(e,{value:l,...g})}};var Nr={string:"string",file:"file"},Vr={bitmark:"bitmark",json:"json",ast:"ast",text:"text"},Hr={bitmark:"bitmark",bitmarkText:"bitmarkText",plainText:"plainText",html:"html"},Ur={v2:2,v3:3},Gr={v1:1,v2:2},zr={peggy:"peggy"},Kr={list:"list",deprecated:"deprecated",all:"all",bit:"bit"},$r={text:"text",json:"json",pojo:"pojo"},qr={plainText:"text",latex:"latex",json:"json",xml:"xml",bitmarkPlusPlus:"bitmark++"},Yr={tag:"tag",body:"body"};var Ve={bold:"bold",light:"light",italic:"italic",highlight:"highlight",highlightOrange:"highlightOrange",highlightYellow:"highlightYellow",highlightGreen:"highlightGreen",highlightBlue:"highlightBlue",highlightPurple:"highlightPurple",highlightPink:"highlightPink",highlightBrown:"highlightBrown",highlightBlack:"highlightBlack",highlightWhite:"highlightWhite",highlightGray:"highlightGray",strike:"strike",subscript:"subscript",superscript:"superscript",ins:"ins",del:"del",underline:"underline",doubleUnderline:"doubleUnderline",circle:"circle",languageEmRed:"languageEmRed",languageEmOrange:"languageEmOrange",languageEmYellow:"languageEmYellow",languageEmGreen:"languageEmGreen",languageEmBlue:"languageEmBlue",languageEmPurple:"languageEmPurple",languageEmPink:"languageEmPink",languageEmBrown:"languageEmBrown",languageEmBlack:"languageEmBlack",languageEmWhite:"languageEmWhite",languageEmGray:"languageEmGray",languageEm:"languageEm",userUnderline:"userUnderline",userDoubleUnderline:"userDoubleUnderline",userStrike:"userStrike",userCircle:"userCircle",userHighlight:"userHighlight",notranslate:"notranslate",link:"link",ref:"ref",xref:"xref",extref:"extref",footnote:"footnote",footnoteStar:"footnote*",symbol:"symbol",var:"var",code:"code",timer:"timer",duration:"duration",color:"color",colorPicker:"colorPicker",comment:"comment"},He={text:"text",hardBreak:"hardBreak",paragraph:"paragraph",heading:"heading",section:"section",noBulletList:"noBulletList",bulletList:"bulletList",orderedList:"orderedList",orderedListRoman:"orderedListRoman",orderedListRomanLower:"orderedListRomanLower",letteredList:"letteredList",letteredListLower:"letteredListLower",taskList:"taskList",listItem:"listItem",taskItem:"taskItem",image:"image",imageInline:"imageInline",codeBlock:"codeBlock",latex:"latex",gap:"gap",select:"select",highlight:"highlight",mark:"mark"};function Xr(t){return t.replace(/-([a-z0-9])/gu,(e,r)=>r.toUpperCase())}var ce;function Ft(){if(!ce){let t=W(),e=JSON.parse(t.info("all","json","",false,2,true,false,false,"")),r={_standard:"_standard"};for(let{name:n}of e)r[Xr(n)]=n;ce=r;}return ce}var Ue=new Proxy({},{get:(t,e)=>typeof e=="string"?Ft()[e]:void 0,has:(t,e)=>typeof e=="string"&&e in Ft(),ownKeys:()=>Reflect.ownKeys(Ft()),getOwnPropertyDescriptor:(t,e)=>typeof e=="string"&&e in Ft()?{value:Ft()[e],enumerable:true,configurable:true,writable:false}:void 0});function Ge(t,e){return new Proxy({},{get:(r,n)=>n===Symbol.toPrimitive||n==="toString"||n===Symbol.toStringTag?()=>`[unsupported ${t}]`:at(t,e),has:()=>at(t,e),ownKeys:()=>at(t,e)})}var ze=Ge("NodeType","it names bpg's internal AST nodes; the legacy AST is bit JSON (see createAst)"),Ke=Ge("BoundingBoxIndex","bpg-internal bounding-box utility");function $(t,e){return class{constructor(){at(t,e);}}}var Qr="the legacy AST is bit JSON, not bpg's internal node model; walking it with bpg NodeType names would silently misbehave",q="internal class of bpg's TS implementation",$e=$("Ast",Qr),qe=$("BitmarkGenerator",q),Ye=$("BitmarkStringGenerator",q),Xe=$("BitmarkFileGenerator",q),Qe=$("JsonGenerator",q),Ze=$("JsonStringGenerator",q),tn=$("JsonFileGenerator",q),en=$("HtmlTableGenerator",q),nn=$("HtmlTableParser",q),rn=$("BitmarkParser",q),on=$("JsonParser",q),sn=$("StringWriter",q),an=$("FileWriter",q),pn=$("StreamWriter",q);var cn={Error:1,Warning:2,Information:3,Hint:4},un={Class:7,Property:10,Value:12,Keyword:14,Snippet:15,EnumMember:20,TypeParameter:25},dn={Deprecated:1};function Zr(t,e,r){return r===void 0?{path:t,op:e}:{path:t,op:e,value:r}}var to="all";function eo(t,e={}){let r=C().convert(t,"bitmark","json",e.mode??"optimized",false,2,1,e.includeUnknownProperties??false,false,"","");return JSON.parse(r)}function no(t,e={}){let r=t.map(o=>o!==null&&typeof o=="object"&&"bit"in o&&typeof o.bit=="object"?o:{bit:o});return C().convert(JSON.stringify(r),"json","bitmark",e.mode??"optimized",false,2,1,false,false,"","")}function ue(t,e={}){return C().convert(t,e.inputFormat??"auto",e.outputFormat??"auto",e.mode??"optimized",e.pretty??false,e.indent??2,e.spacesAroundValues??1,e.includeUnknownProperties??false,e.mappingReport??false,e.positionEncoding??"",e.tokensLayout??"")}function ro(t,e={}){return JSON.parse(ue(t,{inputFormat:"bitmark",outputFormat:"semantic-tokens",positionEncoding:e.positionEncoding,tokensLayout:e.tokensLayout}))}function oo(t,e={}){return JSON.parse(ue(t,{inputFormat:"bitmark",outputFormat:"diagnostics",positionEncoding:e.positionEncoding}))}function io(t,e,r={}){let n=C();if(typeof n.complete!="function")throw new it("complete",et());return JSON.parse(n.complete(t,e.line,e.character,r.positionEncoding??"",r.includeDeprecated??false,r.triggerCharacter??""))}function so(t,e,r,n={}){let o=C();if(typeof o.resolve!="function")throw new it("resolve",et());return JSON.parse(o.resolve(t,e.line,e.character,n.positionEncoding??"",n.includeDeprecated??false,r.label,r.kind))??r}function ao(t,e,r={}){let n=C();if(typeof n.hover!="function")throw new it("hover",et());return JSON.parse(n.hover(t,e.line,e.character,r.positionEncoding??""))}function po(t,e={}){return C().canonicalize(t,e.inputFormat??"auto",e.mode??"optimized",e.pretty??false,e.indent??2,e.spacesAroundValues??1)}function _o(t){return Number.parseInt(C().count_bits(t),10)}function co(t){return JSON.parse(C().split_bits(t))}function uo(t,e={}){let r=C();if(e.preHook||e.postHook)return Be(r,t,e);let n=e.patch===void 0?"":typeof e.patch=="string"?e.patch:JSON.stringify(e.patch);return r.transform(t,e.inputFormat??"auto",e.outputFormat??"json",e.mode??"optimized",n,e.pretty??false,e.indent??2,e.spacesAroundValues??1)}function ln(t,e,r={}){let n=C();if(typeof n.diff!="function")throw new it("diff",et());return n.diff(t,e,r.inputFormat??"auto",r.outputFormat??"bitmark",r.context??3,r.locate??false,r.similarity??.6,r.bboxTolerance??8,r.spacesAroundValues??0)}function lo(t,e,r={}){return JSON.parse(ln(t,e,{...r,outputFormat:"json"}))}function go(t,e={}){let r=e.format??"bitmark++",n=e.location??"body";return C().breakscape_text(t,r,n)}function fo(t,e={}){let r=e.format??"bitmark++",n=e.location??"body";return C().unbreakscape_text(t,r,n)}function mo(t={}){let e=t.infoType??"list",r=t.format??"text",n=t.bit??"",o=t.pretty??false,a=t.indent??2,s=t.includeDeprecated??false,i=t.onlyDeprecated??false,c=t.full??false,d=typeof t.language=="string"?t.language:t.language?.join(",")??"",g=C();if(r!=="json"&&typeof g.info_text_supported!="function")throw new it('info (format: "text")',et());return g.info(e,r,n,o,a,s,i,c,d)}function bo(t){try{C().register(t.type,t.data);}catch(e){throw new dt(e instanceof Error?e.message:String(e))}Se(t.type,t.data);}var xo="./wasm/",gn={full:{init:Kt,initSync:zt,ns:$t,wasmFile:"bitmark_wasm_bg.wasm"},"browser-full":{init:Yt,initSync:qt,ns:Xt,wasmFile:"bitmark_browser_full_wasm_bg.wasm"},"bitmark-json":{init:Zt,initSync:Qt,ns:te,wasmFile:"bitmark_json_wasm_bg.wasm"}};Ae(()=>C());function de(t){return t===void 0?ee:"full"}function yo(t){if(t===null||typeof t!="object")return false;if("feature"in t||"module_or_path"in t)return true;let e=Object.getPrototypeOf(t);return (e===Object.prototype||e===null)&&Object.keys(t).length===0}function wo(t){if(yo(t))return {feature:t.feature??de(t.module_or_path),module_or_path:t.module_or_path};let e=t??void 0;return {feature:de(e),module_or_path:e}}var le=0,Gt,st;async function $i(t){let{feature:e,module_or_path:r}=wo(t);if(r===void 0){if(!st&&et()===e)return Gt;if(st?.feature===e)return st.promise}let n=++le,o=gn[e],a=r??new URL(`${xo}${o.wasmFile}?v=${Ot.version}`,import.meta.url),s=(async()=>{try{let i=await o.init({module_or_path:a});n===le&&(ne(e,o.ns),Gt=i);}finally{st?.seq===n&&(st=void 0);}for(;st;)await st.promise.catch(()=>{});return Gt})();return st={feature:e,seq:n,promise:s},s}function qi(t,e={}){let r=e.feature??de(t),n=gn[r],o=n.initSync({module:t});return ++le,st=void 0,ne(r,n.ns),Gt=o,o}function Yi(){return Ot.version}function Xi(t,e={}){let r=C(),n=et()??ee;return Pe(r,t,e,(o,a)=>Le(o,a,n))}export{to as ALL_LANGUAGES,un as CompletionItemKind,dn as CompletionItemTag,cn as DiagnosticSeverity,Ct as NotInitializedError,dt as RegisterError,it as UnsupportedFeatureError,eo as bitmarkToObjects,go as breakscapeText,po as canonicalize,io as complete,ue as convert,_o as countBits,oo as diagnostics,ln as diff,lo as diffBits,ao as hover,mo as info,$i as init,qi as initSync,_n as legacy,no as objectsToBitmark,Zr as patchEntry,bo as register,so as resolve,ro as semanticTokens,co as splitBits,uo as transform,Xi as transformParallel,fo as unbreakscapeText,et as variant,Yi as version};//# sourceMappingURL=bitmark-parser.min.js.map
5
5
  //# sourceMappingURL=bitmark-parser.min.js.map