@gmb/bitmark-parser 7.6.0 → 7.7.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 (43) hide show
  1. package/README.md +54 -1
  2. package/config/bitmark.json +2 -2
  3. package/dist/browser/bitmark-parser.min.js +6 -6
  4. package/dist/browser/bitmark-parser.min.js.map +1 -1
  5. package/dist/browser/cjs/index.cjs +669 -241
  6. package/dist/browser/cjs/index.cjs.map +1 -1
  7. package/dist/browser/cjs/index.d.cts +104 -7
  8. package/dist/browser/esm/index.d.ts +104 -7
  9. package/dist/browser/esm/index.js +668 -241
  10. package/dist/browser/esm/index.js.map +1 -1
  11. package/dist/browser/esm/worker-entry.js +626 -233
  12. package/dist/browser/esm/worker-entry.js.map +1 -1
  13. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  15. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  16. package/dist/index.cjs +39 -4
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +104 -7
  19. package/dist/index.d.ts +104 -7
  20. package/dist/index.js +38 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/legacy.cjs +1 -1
  23. package/dist/legacy.cjs.map +1 -1
  24. package/dist/legacy.js +1 -1
  25. package/dist/legacy.js.map +1 -1
  26. package/dist/worker-entry.cjs.map +1 -1
  27. package/package.json +7 -7
  28. package/schema/bitmark.schema.json +1 -1
  29. package/wasm/bitmark_wasm.d.ts +65 -31
  30. package/wasm/bitmark_wasm.js +288 -122
  31. package/wasm/bitmark_wasm_bg.wasm +0 -0
  32. package/wasm/bitmark_wasm_bg.wasm.d.ts +6 -1
  33. package/wasm/package.json +1 -1
  34. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +72 -38
  35. package/wasm-bitmark-json/bitmark_json_wasm.js +301 -135
  36. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  37. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +6 -1
  38. package/wasm-bitmark-json/package.json +1 -1
  39. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +65 -31
  40. package/wasm-browser-full/bitmark_browser_full_wasm.js +288 -122
  41. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  42. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +6 -1
  43. package/wasm-browser-full/package.json +1 -1
package/README.md CHANGED
@@ -286,6 +286,48 @@ often than it may be (`|?a|?b|` — the later value wins), and
286
286
  `text-tag-value-invalid` when a value does not fit its format but is kept
287
287
  (`|symbol:…|width:wide|`).
288
288
 
289
+ #### convertWithDetails(input: string, options?: ConvertWithDetailsOptions): ConvertResult
290
+
291
+ `convert`, returning `{ output, …extras }` — the same conversion, run once,
292
+ with each extra asked for by a flag in the options. `output` is exactly what
293
+ `convert` returns, and it throws exactly as `convert` does. Future extras are
294
+ one more flag and one more field each.
295
+
296
+ - `bitSpans` — `true` adds `result.bitSpans`, where each top-level bit's text
297
+ landed in the output, for linking a source pane to an output pane bit by
298
+ bit:
299
+
300
+ ```ts
301
+ const { output, bitSpans } = convertWithDetails(source, {
302
+ inputFormat: "bitmark",
303
+ outputFormat: "html",
304
+ bitSpans: true,
305
+ });
306
+ // bitSpans = { positionEncoding: "utf-16", spans: [{ index, start, end }, …] }
307
+ for (const { index, start, end } of bitSpans!.spans) {
308
+ console.log(index, output.slice(start, end));
309
+ }
310
+ ```
311
+
312
+ - `index` is the bit's position in the **input**: its `splitBits` index for
313
+ bitmark input, its entry index in the top-level array for JSON input. An
314
+ entry that is not a bit gets no span, so the indexes can have gaps.
315
+ - `start` / `end` are **the bit's text**, tight: never the separators
316
+ between bits (`\n`, blank lines, `,`) nor the JSON array's `[` / `]`. They
317
+ are counted in `positionEncoding` — `"utf-16"` by default, so
318
+ `output.slice(start, end)` is the bit — or `"utf-8"` bytes.
319
+ - Spans are reported for the document outputs: `bitmark`, `json` (compact or
320
+ pretty), `text`, and the markup formats (`html`, `xml`, …). In `bitmark`
321
+ output they equal `splitBits(output)`'s `start` / `end`.
322
+ - A bit that writes nothing (an empty or `_error` bit in `text`) gets a
323
+ zero-width span where its text would start.
324
+ - Only top-level bits get spans. For any other output (`lex`, `ast`,
325
+ `semantic-tokens`, `diagnostics`, a mapping report) `bitSpans` is present
326
+ with `spans: []`; without the flag it is absent.
327
+
328
+ The CLI's `--bit-spans FILE` and the daemon's `convert` option
329
+ `bitSpans: true` (reply field `bitSpans`) return the same object.
330
+
289
331
  #### canonicalize(input: string, options?: CanonicalizeOptions): string
290
332
 
291
333
  Re-emit input in its own format in canonical form — the single same-format surface. `mode`: `"optimized"` (default, omit natural defaults) or `"full"` (all keys).
@@ -449,7 +491,14 @@ included so the alignment is complete — `status`
449
491
  `ops` (a patch turning the A bit into the B bit) and `revert`, the parser
450
492
  issue codes gained or lost, and the rendered `hunks`.
451
493
 
452
- #### countBits(input: string): number / splitBits(input: string): BitSlice[]
494
+ #### countBits(input: string): number / splitBits(input: string, options?: SplitBitsOptions): BitSlice[]
495
+
496
+ `splitBits` returns one `{ index, start, end, byteStart, byteEnd, source }`
497
+ per bit. `start` / `end` locate the bit's text, `source`, counted in
498
+ `options.positionEncoding` — `"utf-16"` by default, so
499
+ `input.slice(start, end) === source` — or `"utf-8"` bytes. `byteStart` /
500
+ `byteEnd` are UTF-8 byte offsets that tile the document (each bit runs to the
501
+ next bit's start), for chunking.
453
502
 
454
503
  Count or split the bits of a bitmark/JSON input without full parsing. A JSON
455
504
  input may be an array or a single value, each entry a `{ bit: {…} }` envelope
@@ -1086,6 +1135,10 @@ bitmark convert input.bitmark --output-format semantic-tokens --tokens-layout ab
1086
1135
  # Dump the lexer token stream as JSON (debug tooling; bitmark input only)
1087
1136
  bitmark convert input.bitmark --input-format bitmark --output-format lex --pretty
1088
1137
 
1138
+ # Also write where each bit landed in the output, {positionEncoding, spans},
1139
+ # to its own file (offsets into this run's output; --position-encoding applies)
1140
+ bitmark convert input.bitmark --output-format html -o out.html --bit-spans spans.json
1141
+
1089
1142
  # Breakscape / unbreakscape text
1090
1143
  bitmark breakscape input.txt
1091
1144
  bitmark breakscape input.txt --format plainText --location tag
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "7.6.0",
3
- "label": "fnv1a64:b05a4edfe13fd984",
2
+ "version": "7.7.0",
3
+ "label": "fnv1a64:8557c377bbabcc25",
4
4
  "locales": [
5
5
  {
6
6
  "code": "it",
@@ -1,7 +1,7 @@
1
- var fe=Object.defineProperty;var yn=(t,e,r)=>e in t?fe(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var Rt=(t,e)=>{for(var r in e)fe(t,r,{get:e[r],enumerable:true});};var C=(t,e,r)=>yn(t,typeof e!="symbol"?e+"":e,r);var qt={};Rt(qt,{breakscape_text:()=>vn,canonicalize:()=>Dn,complete:()=>Pn,convert:()=>Cn,convert_text:()=>En,count_bits:()=>Wn,default:()=>Kt,diff:()=>Bn,hover:()=>jn,info:()=>In,info_text_supported:()=>On,initSync:()=>$t,is_bitmark:()=>Mn,prettify:()=>Vn,register:()=>Ln,resolve:()=>An,resolve_patch_document:()=>Sn,split_bits:()=>Jn,split_json_bits:()=>Nn,transform:()=>Rn,unbreakscape_text:()=>hn});var c,me=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&me.decode();var kt=null;function St(){return (kt===null||kt.byteLength===0)&&(kt=new Uint8Array(c.memory.buffer)),kt}function N(t,e){return t=t>>>0,me.decode(St().subarray(t,t+e))}var nt=new Array(128).fill(void 0);nt.push(void 0,null,true,false);var vt=nt.length;function wn(t){vt===nt.length&&nt.push(nt.length+1);let e=vt;return vt=nt[e],nt[e]=t,e}var T=0,Bt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},kn=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 E(t,e,r){if(r===void 0){let i=Bt.encode(t),p=e(i.length,1)>>>0;return St().subarray(p,p+i.length).set(i),T=i.length,p}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),p=kn(t,i);s+=p.written,o=r(o,n,s,1)>>>0;}return T=s,o}function be(t){return t==null}var ct=null;function h(){return (ct===null||ct.buffer.detached===true||ct.buffer.detached===void 0&&ct.buffer!==c.memory.buffer)&&(ct=new DataView(c.memory.buffer)),ct}function vn(t,e,r,n){let o,a;try{let l=c.__wbindgen_add_to_stack_pointer(-16),g=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),f=T,x=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),m=T,y=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T;var s=be(n)?0:E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),i=T;c.breakscape_text(l,g,f,x,m,y,b,s,i);var p=h().getInt32(l+0,!0),u=h().getInt32(l+4,!0);return o=p,a=u,N(p,u)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function hn(t,e,r,n){let o,a;try{let l=c.__wbindgen_add_to_stack_pointer(-16),g=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),f=T,x=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),m=T,y=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T;var s=be(n)?0:E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),i=T;c.unbreakscape_text(l,g,f,x,m,y,b,s,i);var p=h().getInt32(l+0,!0),u=h().getInt32(l+4,!0);return o=p,a=u,N(p,u)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function In(t,e,r,n,o,a,s,i,p){let u,l;try{let x=c.__wbindgen_add_to_stack_pointer(-16),m=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),y=T,b=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),w=T,k=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),v=T,O=E(p,c.__wbindgen_export_0,c.__wbindgen_export_1),A=T;c.info(x,m,y,b,w,k,v,n,o,a,s,i,O,A);var g=h().getInt32(x+0,!0),f=h().getInt32(x+4,!0);return u=g,l=f,N(g,f)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(u,l,1);}}function On(){return c.info_text_supported()!==0}function Tn(t){return nt[t]}function Fn(t){t<132||(nt[t]=vt,vt=t);}function Y(t){let e=Tn(t);return Fn(t),e}function En(t,e,r,n){let o,a;try{let f=c.__wbindgen_add_to_stack_pointer(-16),x=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),m=T,y=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T,w=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),k=T,v=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),O=T;c.convert_text(f,x,m,y,b,w,k,v,O);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),p=h().getInt32(f+8,!0),u=h().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,Y(p);return o=l,a=g,N(l,g)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Rn(t,e,r,n,o,a,s,i){let p,u;try{let b=c.__wbindgen_add_to_stack_pointer(-16),w=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),k=T,v=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),O=T,A=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),U=T,G=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),z=T,$=E(o,c.__wbindgen_export_0,c.__wbindgen_export_1),Q=T;c.transform(b,w,k,v,O,A,U,G,z,$,Q,a,s,i);var l=h().getInt32(b+0,!0),g=h().getInt32(b+4,!0),f=h().getInt32(b+8,!0),x=h().getInt32(b+12,!0),m=l,y=g;if(x)throw m=0,y=0,Y(f);return p=m,u=y,N(m,y)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(p,u,1);}}function Sn(t,e,r){let n,o;try{let g=c.__wbindgen_add_to_stack_pointer(-16),f=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),x=T,m=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),y=T,b=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),w=T;c.resolve_patch_document(g,f,x,m,y,b,w);var a=h().getInt32(g+0,!0),s=h().getInt32(g+4,!0),i=h().getInt32(g+8,!0),p=h().getInt32(g+12,!0),u=a,l=s;if(p)throw u=0,l=0,Y(i);return n=u,o=l,N(u,l)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(n,o,1);}}function Bn(t,e,r,n,o,a,s,i,p){let u,l;try{let w=c.__wbindgen_add_to_stack_pointer(-16),k=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),v=T,O=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),A=T,U=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),G=T,z=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),$=T;c.diff(w,k,v,O,A,U,G,z,$,o,a,s,i,p);var g=h().getInt32(w+0,!0),f=h().getInt32(w+4,!0),x=h().getInt32(w+8,!0),m=h().getInt32(w+12,!0),y=g,b=f;if(m)throw y=0,b=0,Y(x);return u=y,l=b,N(y,b)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(u,l,1);}}function Pn(t,e,r,n,o,a){let s,i;try{let m=c.__wbindgen_add_to_stack_pointer(-16),y=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T,w=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),k=T,v=E(a,c.__wbindgen_export_0,c.__wbindgen_export_1),O=T;c.complete(m,y,b,e,r,w,k,o,v,O);var p=h().getInt32(m+0,!0),u=h().getInt32(m+4,!0),l=h().getInt32(m+8,!0),g=h().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,Y(l);return s=f,i=x,N(f,x)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(s,i,1);}}function An(t,e,r,n,o,a,s){let i,p;try{let y=c.__wbindgen_add_to_stack_pointer(-16),b=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),w=T,k=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),v=T,O=E(a,c.__wbindgen_export_0,c.__wbindgen_export_1),A=T;c.resolve(y,b,w,e,r,k,v,o,O,A,s);var u=h().getInt32(y+0,!0),l=h().getInt32(y+4,!0),g=h().getInt32(y+8,!0),f=h().getInt32(y+12,!0),x=u,m=l;if(f)throw x=0,m=0,Y(g);return i=x,p=m,N(x,m)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(i,p,1);}}function jn(t,e,r,n){let o,a;try{let f=c.__wbindgen_add_to_stack_pointer(-16),x=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),m=T,y=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T;c.hover(f,x,m,e,r,y,b);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),p=h().getInt32(f+8,!0),u=h().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,Y(p);return o=l,a=g,N(l,g)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Ln(t,e){try{let o=c.__wbindgen_add_to_stack_pointer(-16),a=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),s=T,i=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),p=T;c.register(o,a,s,i,p);var r=h().getInt32(o+0,!0),n=h().getInt32(o+4,!0);if(n)throw Y(r)}finally{c.__wbindgen_add_to_stack_pointer(16);}}function Cn(t,e,r,n,o,a,s,i,p,u,l){let g,f;try{let v=c.__wbindgen_add_to_stack_pointer(-16),O=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),A=T,U=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),G=T,z=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),$=T,Q=E(n,c.__wbindgen_export_0,c.__wbindgen_export_1),mt=T,bt=E(u,c.__wbindgen_export_0,c.__wbindgen_export_1),xt=T,yt=E(l,c.__wbindgen_export_0,c.__wbindgen_export_1),wt=T;c.convert(v,O,A,U,G,z,$,Q,mt,o,a,s,i,p,bt,xt,yt,wt);var x=h().getInt32(v+0,!0),m=h().getInt32(v+4,!0),y=h().getInt32(v+8,!0),b=h().getInt32(v+12,!0),w=x,k=m;if(b)throw w=0,k=0,Y(y);return g=w,f=k,N(w,k)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(g,f,1);}}function Dn(t,e,r,n,o,a){let s,i;try{let m=c.__wbindgen_add_to_stack_pointer(-16),y=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),b=T,w=E(e,c.__wbindgen_export_0,c.__wbindgen_export_1),k=T,v=E(r,c.__wbindgen_export_0,c.__wbindgen_export_1),O=T;c.canonicalize(m,y,b,w,k,v,O,n,o,a);var p=h().getInt32(m+0,!0),u=h().getInt32(m+4,!0),l=h().getInt32(m+8,!0),g=h().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,Y(l);return s=f,i=x,N(f,x)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(s,i,1);}}function Wn(t){let e,r;try{let u=c.__wbindgen_add_to_stack_pointer(-16),l=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),g=T;c.count_bits(u,l,g);var n=h().getInt32(u+0,!0),o=h().getInt32(u+4,!0),a=h().getInt32(u+8,!0),s=h().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,Y(a);return e=i,r=p,N(i,p)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(e,r,1);}}function Jn(t){let e,r;try{let a=c.__wbindgen_add_to_stack_pointer(-16),s=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),i=T;c.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{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(e,r,1);}}function Mn(t){let e=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),r=T;return c.is_bitmark(e,r)!==0}function Nn(t){let e,r;try{let u=c.__wbindgen_add_to_stack_pointer(-16),l=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),g=T;c.split_json_bits(u,l,g);var n=h().getInt32(u+0,!0),o=h().getInt32(u+4,!0),a=h().getInt32(u+8,!0),s=h().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,Y(a);return e=i,r=p,N(i,p)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(e,r,1);}}function Vn(t,e){let r,n;try{let s=c.__wbindgen_add_to_stack_pointer(-16),i=E(t,c.__wbindgen_export_0,c.__wbindgen_export_1),p=T;c.prettify(s,i,p,e);var o=h().getInt32(s+0,!0),a=h().getInt32(s+4,!0);return r=o,n=a,N(o,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(r,n,1);}}async function Hn(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 xe(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(N(e,r));return wn(n)},t}function ye(t,e){return c=t.exports,we.__wbindgen_wasm_module=e,ct=null,kt=null,c}function $t(t){if(c!==void 0)return c;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=xe();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return ye(r,t)}async function we(t){if(c!==void 0)return c;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=xe();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await Hn(await t,e);return ye(r,n)}var Kt=we;var Qt={};Rt(Qt,{breakscape_text:()=>zn,canonicalize:()=>ar,complete:()=>nr,convert:()=>sr,convert_text:()=>Qn,count_bits:()=>pr,default:()=>Xt,diff:()=>er,hover:()=>or,info:()=>Kn,info_text_supported:()=>qn,initSync:()=>Yt,is_bitmark:()=>_r,prettify:()=>dr,register:()=>ir,resolve:()=>rr,resolve_patch_document:()=>tr,split_bits:()=>cr,split_json_bits:()=>ur,transform:()=>Zn,unbreakscape_text:()=>$n});var _,ke=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ke.decode();var ht=null;function Pt(){return (ht===null||ht.byteLength===0)&&(ht=new Uint8Array(_.memory.buffer)),ht}function V(t,e){return t=t>>>0,ke.decode(Pt().subarray(t,t+e))}var rt=new Array(128).fill(void 0);rt.push(void 0,null,true,false);var It=rt.length;function Un(t){It===rt.length&&rt.push(rt.length+1);let e=It;return It=rt[e],rt[e]=t,e}var F=0,At=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Gn=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 R(t,e,r){if(r===void 0){let i=At.encode(t),p=e(i.length,1)>>>0;return Pt().subarray(p,p+i.length).set(i),F=i.length,p}let n=t.length,o=e(n,1)>>>0,a=Pt(),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=Pt().subarray(o+s,o+n),p=Gn(t,i);s+=p.written,o=r(o,n,s,1)>>>0;}return F=s,o}function ve(t){return t==null}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 zn(t,e,r,n){let o,a;try{let l=_.__wbindgen_add_to_stack_pointer(-16),g=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),f=F,x=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F,y=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F;var s=ve(n)?0:R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),i=F;_.breakscape_text(l,g,f,x,m,y,b,s,i);var p=I().getInt32(l+0,!0),u=I().getInt32(l+4,!0);return o=p,a=u,V(p,u)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function $n(t,e,r,n){let o,a;try{let l=_.__wbindgen_add_to_stack_pointer(-16),g=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),f=F,x=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F,y=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F;var s=ve(n)?0:R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),i=F;_.unbreakscape_text(l,g,f,x,m,y,b,s,i);var p=I().getInt32(l+0,!0),u=I().getInt32(l+4,!0);return o=p,a=u,V(p,u)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function Kn(t,e,r,n,o,a,s,i,p){let u,l;try{let x=_.__wbindgen_add_to_stack_pointer(-16),m=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),y=F,b=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F,k=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,O=R(p,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F;_.info(x,m,y,b,w,k,v,n,o,a,s,i,O,A);var g=I().getInt32(x+0,!0),f=I().getInt32(x+4,!0);return u=g,l=f,V(g,f)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(u,l,1);}}function qn(){return _.info_text_supported()!==0}function Yn(t){return rt[t]}function Xn(t){t<132||(rt[t]=It,It=t);}function X(t){let e=Yn(t);return Xn(t),e}function Qn(t,e,r,n){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),x=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F,y=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F,w=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),O=F;_.convert_text(f,x,m,y,b,w,k,v,O);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),p=I().getInt32(f+8,!0),u=I().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,X(p);return o=l,a=g,V(l,g)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function Zn(t,e,r,n,o,a,s,i){let p,u;try{let b=_.__wbindgen_add_to_stack_pointer(-16),w=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),O=F,A=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),U=F,G=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),z=F,$=R(o,_.__wbindgen_export_0,_.__wbindgen_export_1),Q=F;_.transform(b,w,k,v,O,A,U,G,z,$,Q,a,s,i);var l=I().getInt32(b+0,!0),g=I().getInt32(b+4,!0),f=I().getInt32(b+8,!0),x=I().getInt32(b+12,!0),m=l,y=g;if(x)throw m=0,y=0,X(f);return p=m,u=y,V(m,y)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(p,u,1);}}function tr(t,e,r){let n,o;try{let g=_.__wbindgen_add_to_stack_pointer(-16),f=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),x=F,m=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),y=F,b=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F;_.resolve_patch_document(g,f,x,m,y,b,w);var a=I().getInt32(g+0,!0),s=I().getInt32(g+4,!0),i=I().getInt32(g+8,!0),p=I().getInt32(g+12,!0),u=a,l=s;if(p)throw u=0,l=0,X(i);return n=u,o=l,V(u,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,o,1);}}function er(t,e,r,n,o,a,s,i,p){let u,l;try{let w=_.__wbindgen_add_to_stack_pointer(-16),k=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,O=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F,U=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),G=F,z=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),$=F;_.diff(w,k,v,O,A,U,G,z,$,o,a,s,i,p);var g=I().getInt32(w+0,!0),f=I().getInt32(w+4,!0),x=I().getInt32(w+8,!0),m=I().getInt32(w+12,!0),y=g,b=f;if(m)throw y=0,b=0,X(x);return u=y,l=b,V(y,b)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(u,l,1);}}function nr(t,e,r,n,o,a){let s,i;try{let m=_.__wbindgen_add_to_stack_pointer(-16),y=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F,w=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=R(a,_.__wbindgen_export_0,_.__wbindgen_export_1),O=F;_.complete(m,y,b,e,r,w,k,o,v,O);var p=I().getInt32(m+0,!0),u=I().getInt32(m+4,!0),l=I().getInt32(m+8,!0),g=I().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,X(l);return s=f,i=x,V(f,x)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function rr(t,e,r,n,o,a,s){let i,p;try{let y=_.__wbindgen_add_to_stack_pointer(-16),b=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),w=F,k=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),v=F,O=R(a,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F;_.resolve(y,b,w,e,r,k,v,o,O,A,s);var u=I().getInt32(y+0,!0),l=I().getInt32(y+4,!0),g=I().getInt32(y+8,!0),f=I().getInt32(y+12,!0),x=u,m=l;if(f)throw x=0,m=0,X(g);return i=x,p=m,V(x,m)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(i,p,1);}}function or(t,e,r,n){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),x=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),m=F,y=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F;_.hover(f,x,m,e,r,y,b);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),p=I().getInt32(f+8,!0),u=I().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,X(p);return o=l,a=g,V(l,g)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function ir(t,e){try{let o=_.__wbindgen_add_to_stack_pointer(-16),a=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),s=F,i=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),p=F;_.register(o,a,s,i,p);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 sr(t,e,r,n,o,a,s,i,p,u,l){let g,f;try{let v=_.__wbindgen_add_to_stack_pointer(-16),O=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),A=F,U=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),G=F,z=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),$=F,Q=R(n,_.__wbindgen_export_0,_.__wbindgen_export_1),mt=F,bt=R(u,_.__wbindgen_export_0,_.__wbindgen_export_1),xt=F,yt=R(l,_.__wbindgen_export_0,_.__wbindgen_export_1),wt=F;_.convert(v,O,A,U,G,z,$,Q,mt,o,a,s,i,p,bt,xt,yt,wt);var x=I().getInt32(v+0,!0),m=I().getInt32(v+4,!0),y=I().getInt32(v+8,!0),b=I().getInt32(v+12,!0),w=x,k=m;if(b)throw w=0,k=0,X(y);return g=w,f=k,V(w,k)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(g,f,1);}}function ar(t,e,r,n,o,a){let s,i;try{let m=_.__wbindgen_add_to_stack_pointer(-16),y=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=F,w=R(e,_.__wbindgen_export_0,_.__wbindgen_export_1),k=F,v=R(r,_.__wbindgen_export_0,_.__wbindgen_export_1),O=F;_.canonicalize(m,y,b,w,k,v,O,n,o,a);var p=I().getInt32(m+0,!0),u=I().getInt32(m+4,!0),l=I().getInt32(m+8,!0),g=I().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,X(l);return s=f,i=x,V(f,x)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function pr(t){let e,r;try{let u=_.__wbindgen_add_to_stack_pointer(-16),l=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),g=F;_.count_bits(u,l,g);var n=I().getInt32(u+0,!0),o=I().getInt32(u+4,!0),a=I().getInt32(u+8,!0),s=I().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,X(a);return e=i,r=p,V(i,p)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(e,r,1);}}function cr(t){let e,r;try{let a=_.__wbindgen_add_to_stack_pointer(-16),s=R(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 _r(t){let e=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),r=F;return _.is_bitmark(e,r)!==0}function ur(t){let e,r;try{let u=_.__wbindgen_add_to_stack_pointer(-16),l=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),g=F;_.split_json_bits(u,l,g);var n=I().getInt32(u+0,!0),o=I().getInt32(u+4,!0),a=I().getInt32(u+8,!0),s=I().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,X(a);return e=i,r=p,V(i,p)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(e,r,1);}}function dr(t,e){let r,n;try{let s=_.__wbindgen_add_to_stack_pointer(-16),i=R(t,_.__wbindgen_export_0,_.__wbindgen_export_1),p=F;_.prettify(s,i,p,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 lr(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 he(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(V(e,r));return Un(n)},t}function Ie(t,e){return _=t.exports,Oe.__wbindgen_wasm_module=e,_t=null,ht=null,_}function Yt(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=he();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return Ie(r,t)}async function Oe(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=he();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await lr(await t,e);return Ie(r,n)}var Xt=Oe;var ee={};Rt(ee,{breakscape_text:()=>mr,canonicalize:()=>Er,complete:()=>Ir,convert:()=>Fr,convert_text:()=>jr,count_bits:()=>Rr,default:()=>te,hover:()=>Tr,info:()=>xr,initSync:()=>Zt,is_bitmark:()=>Br,prettify:()=>Ar,register:()=>kr,resolve:()=>Or,resolve_patch_document:()=>hr,split_bits:()=>Sr,split_json_bits:()=>Pr,transform:()=>vr,unbreakscape_text:()=>br});var d,Te=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Te.decode();var Ot=null;function jt(){return (Ot===null||Ot.byteLength===0)&&(Ot=new Uint8Array(d.memory.buffer)),Ot}function H(t,e){return t=t>>>0,Te.decode(jt().subarray(t,t+e))}var ot=new Array(128).fill(void 0);ot.push(void 0,null,true,false);var Tt=ot.length;function gr(t){Tt===ot.length&&ot.push(ot.length+1);let e=Tt;return Tt=ot[e],ot[e]=t,e}var B=0,Lt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},fr=typeof Lt.encodeInto=="function"?function(t,e){return Lt.encodeInto(t,e)}:function(t,e){let r=Lt.encode(t);return e.set(r),{read:t.length,written:r.length}};function P(t,e,r){if(r===void 0){let i=Lt.encode(t),p=e(i.length,1)>>>0;return jt().subarray(p,p+i.length).set(i),B=i.length,p}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),p=fr(t,i);s+=p.written,o=r(o,n,s,1)>>>0;}return B=s,o}function Fe(t){return t==null}var ut=null;function S(){return (ut===null||ut.buffer.detached===true||ut.buffer.detached===void 0&&ut.buffer!==d.memory.buffer)&&(ut=new DataView(d.memory.buffer)),ut}function mr(t,e,r,n){let o,a;try{let l=d.__wbindgen_add_to_stack_pointer(-16),g=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),f=B,x=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),m=B,y=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B;var s=Fe(n)?0:P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),i=B;d.breakscape_text(l,g,f,x,m,y,b,s,i);var p=S().getInt32(l+0,!0),u=S().getInt32(l+4,!0);return o=p,a=u,H(p,u)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(o,a,1);}}function br(t,e,r,n){let o,a;try{let l=d.__wbindgen_add_to_stack_pointer(-16),g=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),f=B,x=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),m=B,y=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B;var s=Fe(n)?0:P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),i=B;d.unbreakscape_text(l,g,f,x,m,y,b,s,i);var p=S().getInt32(l+0,!0),u=S().getInt32(l+4,!0);return o=p,a=u,H(p,u)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(o,a,1);}}function xr(t,e,r,n,o,a,s,i,p){let u,l;try{let x=d.__wbindgen_add_to_stack_pointer(-16),m=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),y=B,b=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),w=B,k=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),v=B,O=P(p,d.__wbindgen_export_0,d.__wbindgen_export_1),A=B;d.info(x,m,y,b,w,k,v,n,o,a,s,i,O,A);var g=S().getInt32(x+0,!0),f=S().getInt32(x+4,!0);return u=g,l=f,H(g,f)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(u,l,1);}}function yr(t){return ot[t]}function wr(t){t<132||(ot[t]=Tt,Tt=t);}function Z(t){let e=yr(t);return wr(t),e}function kr(t,e){try{let o=d.__wbindgen_add_to_stack_pointer(-16),a=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),s=B,i=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),p=B;d.register(o,a,s,i,p);var r=S().getInt32(o+0,!0),n=S().getInt32(o+4,!0);if(n)throw Z(r)}finally{d.__wbindgen_add_to_stack_pointer(16);}}function vr(t,e,r,n,o,a,s,i){let p,u;try{let b=d.__wbindgen_add_to_stack_pointer(-16),w=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),k=B,v=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),O=B,A=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),U=B,G=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),z=B,$=P(o,d.__wbindgen_export_0,d.__wbindgen_export_1),Q=B;d.transform(b,w,k,v,O,A,U,G,z,$,Q,a,s,i);var l=S().getInt32(b+0,!0),g=S().getInt32(b+4,!0),f=S().getInt32(b+8,!0),x=S().getInt32(b+12,!0),m=l,y=g;if(x)throw m=0,y=0,Z(f);return p=m,u=y,H(m,y)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(p,u,1);}}function hr(t,e,r){let n,o;try{let g=d.__wbindgen_add_to_stack_pointer(-16),f=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),x=B,m=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),y=B,b=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),w=B;d.resolve_patch_document(g,f,x,m,y,b,w);var a=S().getInt32(g+0,!0),s=S().getInt32(g+4,!0),i=S().getInt32(g+8,!0),p=S().getInt32(g+12,!0),u=a,l=s;if(p)throw u=0,l=0,Z(i);return n=u,o=l,H(u,l)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(n,o,1);}}function Ir(t,e,r,n,o,a){let s,i;try{let m=d.__wbindgen_add_to_stack_pointer(-16),y=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B,w=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),k=B,v=P(a,d.__wbindgen_export_0,d.__wbindgen_export_1),O=B;d.complete(m,y,b,e,r,w,k,o,v,O);var p=S().getInt32(m+0,!0),u=S().getInt32(m+4,!0),l=S().getInt32(m+8,!0),g=S().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,Z(l);return s=f,i=x,H(f,x)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(s,i,1);}}function Or(t,e,r,n,o,a,s){let i,p;try{let y=d.__wbindgen_add_to_stack_pointer(-16),b=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),w=B,k=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),v=B,O=P(a,d.__wbindgen_export_0,d.__wbindgen_export_1),A=B;d.resolve(y,b,w,e,r,k,v,o,O,A,s);var u=S().getInt32(y+0,!0),l=S().getInt32(y+4,!0),g=S().getInt32(y+8,!0),f=S().getInt32(y+12,!0),x=u,m=l;if(f)throw x=0,m=0,Z(g);return i=x,p=m,H(x,m)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(i,p,1);}}function Tr(t,e,r,n){let o,a;try{let f=d.__wbindgen_add_to_stack_pointer(-16),x=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),m=B,y=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B;d.hover(f,x,m,e,r,y,b);var s=S().getInt32(f+0,!0),i=S().getInt32(f+4,!0),p=S().getInt32(f+8,!0),u=S().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,Z(p);return o=l,a=g,H(l,g)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(o,a,1);}}function Fr(t,e,r,n,o,a,s,i,p,u,l){let g,f;try{let v=d.__wbindgen_add_to_stack_pointer(-16),O=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),A=B,U=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),G=B,z=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),$=B,Q=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),mt=B,bt=P(u,d.__wbindgen_export_0,d.__wbindgen_export_1),xt=B,yt=P(l,d.__wbindgen_export_0,d.__wbindgen_export_1),wt=B;d.convert(v,O,A,U,G,z,$,Q,mt,o,a,s,i,p,bt,xt,yt,wt);var x=S().getInt32(v+0,!0),m=S().getInt32(v+4,!0),y=S().getInt32(v+8,!0),b=S().getInt32(v+12,!0),w=x,k=m;if(b)throw w=0,k=0,Z(y);return g=w,f=k,H(w,k)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(g,f,1);}}function Er(t,e,r,n,o,a){let s,i;try{let m=d.__wbindgen_add_to_stack_pointer(-16),y=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B,w=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),k=B,v=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),O=B;d.canonicalize(m,y,b,w,k,v,O,n,o,a);var p=S().getInt32(m+0,!0),u=S().getInt32(m+4,!0),l=S().getInt32(m+8,!0),g=S().getInt32(m+12,!0),f=p,x=u;if(g)throw f=0,x=0,Z(l);return s=f,i=x,H(f,x)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(s,i,1);}}function Rr(t){let e,r;try{let u=d.__wbindgen_add_to_stack_pointer(-16),l=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),g=B;d.count_bits(u,l,g);var n=S().getInt32(u+0,!0),o=S().getInt32(u+4,!0),a=S().getInt32(u+8,!0),s=S().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,Z(a);return e=i,r=p,H(i,p)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function Sr(t){let e,r;try{let a=d.__wbindgen_add_to_stack_pointer(-16),s=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),i=B;d.split_bits(a,s,i);var n=S().getInt32(a+0,!0),o=S().getInt32(a+4,!0);return e=n,r=o,H(n,o)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function Br(t){let e=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),r=B;return d.is_bitmark(e,r)!==0}function Pr(t){let e,r;try{let u=d.__wbindgen_add_to_stack_pointer(-16),l=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),g=B;d.split_json_bits(u,l,g);var n=S().getInt32(u+0,!0),o=S().getInt32(u+4,!0),a=S().getInt32(u+8,!0),s=S().getInt32(u+12,!0),i=n,p=o;if(s)throw i=0,p=0,Z(a);return e=i,r=p,H(i,p)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(e,r,1);}}function Ar(t,e){let r,n;try{let s=d.__wbindgen_add_to_stack_pointer(-16),i=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),p=B;d.prettify(s,i,p,e);var o=S().getInt32(s+0,!0),a=S().getInt32(s+4,!0);return r=o,n=a,H(o,a)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(r,n,1);}}function jr(t,e,r,n){let o,a;try{let f=d.__wbindgen_add_to_stack_pointer(-16),x=P(t,d.__wbindgen_export_0,d.__wbindgen_export_1),m=B,y=P(e,d.__wbindgen_export_0,d.__wbindgen_export_1),b=B,w=P(r,d.__wbindgen_export_0,d.__wbindgen_export_1),k=B,v=P(n,d.__wbindgen_export_0,d.__wbindgen_export_1),O=B;d.convert_text(f,x,m,y,b,w,k,v,O);var s=S().getInt32(f+0,!0),i=S().getInt32(f+4,!0),p=S().getInt32(f+8,!0),u=S().getInt32(f+12,!0),l=s,g=i;if(u)throw l=0,g=0,Z(p);return o=l,a=g,H(l,g)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export_2(o,a,1);}}async function Lr(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 Ee(){let t={};return t.wbg={},t.wbg.__wbindgen_error_new=function(e,r){let n=new Error(H(e,r));return gr(n)},t}function Re(t,e){return d=t.exports,Se.__wbindgen_wasm_module=e,ut=null,Ot=null,d}function Zt(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=Ee();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let r=new WebAssembly.Instance(t,e);return Re(r,t)}async function Se(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=Ee();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:n}=await Lr(await t,e);return Re(r,n)}var te=Se;var Ft={version:"7.6.0"};var ne="browser-full",Dt=class extends Error{constructor(){super("wasm not initialised: call init() (or init({ feature: \u2026 })) first"),this.name="NotInitializedError";}},lt=class extends Error{constructor(e){super(e),this.name="RegisterError";}},it=class extends Error{constructor(r){let n=r.map(o=>`${o.kind} at ${o.path}: ${o.message}`);super(`${r.length} patch ${r.length===1?"entry was":"entries were"} skipped:
2
- `+n.join(`
3
- `));C(this,"diagnostics");this.name="PatchError",this.diagnostics=r;}},st=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";}},Ct,Pe,Be,Ae=new Map;function D(){if(!Ct&&Be&&Be(),!Ct)throw new Dt;return Ct}function re(t,e){for(let[r,n]of Ae)try{e.register(r,n);}catch(o){throw new lt(o instanceof Error?o.message:String(o))}Ct=e,Pe=t;}function je(t,e){Ae.set(t,e);}function et(){return Pe}function Cr(t){let e=t.trim();return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):t}function Dr(t){return t===void 0?"":typeof t=="string"?t.trim():JSON.stringify(t)}function Wr(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 oe(t,e,r){let n=r.mode??"optimized",o=r.outputFormat??"json",a=r.spacesAroundValues??1,s=r.indent??2,i=r.pretty??false,p=r.inputFormat??"auto",u=p==="bitmark"||p!=="json"&&t.is_bitmark(e),l=u?"bitmark":"json";t.transform("","bitmark",o,n,"",false,s,a);let g=Wr(t,e,u),f=g.length,x=[];for(let k=0;k<f;k++){let{view:v}=g[k];v.index=k,v.total=f;let O=r.preHook?r.preHook(v)||{}:{};x.push(O.drop?null:{patches:O.patches??[],outputFormat:O.outputFormat??o});}let m=Dr(r.patch),y;m===""?y=g.map((k,v)=>({source:v,bit:null,patch:[]})):y=JSON.parse(t.resolve_patch_document(e,l,m));let b=[],w=[];for(let k of y)if(k.source!==null){let v=x[k.source];if(!v)continue;b.push({index:k.source,source:g[k.source].source,inputFormat:l,outputFormat:v.outputFormat,mode:n,patchJson:JSON.stringify([...k.patch,...v.patches]),spacesAroundValues:a}),w.push(g[k.source].view);}else if(typeof k.bit=="string"){let v=b.length;b.push({index:v,source:k.bit,inputFormat:"bitmark",outputFormat:o,mode:n,patchJson:JSON.stringify(k.patch),spacesAroundValues:a}),w.push({format:"bitmark",index:v,total:f,source:k.bit});}else {let v=k.bit??{},O=b.length;b.push({index:O,source:JSON.stringify([{bit:v}]),inputFormat:"json",outputFormat:o,mode:n,patchJson:JSON.stringify(k.patch),spacesAroundValues:a}),w.push({format:"json",index:O,total:f,bit:v});}return {jobs:b,views:w,output:o,pretty:i,indent:s}}function Jr(t,e){let{data:r,diagnostics:n}=JSON.parse(t);return {element:e==="json"?Cr(r):r,diagnostics:n}}function Mr(t,e){return Jr(t.transform(e.source,e.inputFormat,e.outputFormat,e.mode,e.patchJson,false,2,e.spacesAroundValues),e.outputFormat)}function ie(t,e,r,n,o){if(r!=="json")return e.join(`
4
- `);let a=`[${e.join(",")}]`;return n?t.prettify(a,o):a}function Le(t,e,r){let n=oe(t,e,r),o=[],a=[];for(let s=0;s<n.jobs.length;s++){let{element:i,diagnostics:p}=Mr(t,n.jobs[s]);a.push(...p),r.postHook?.(n.views[s],i),o.push(i);}if(a.length>0)throw new it(a);return ie(t,o,n.output,n.pretty,n.indent)}async function Ce(t,e,r,n){let o=oe(t,e,r),a=await n(o.jobs,r.workers??4),s=[],i=[];for(let p=0;p<a.length;p++)s.push(a[p].element),i.push(...a[p].diagnostics),r.postHook?.(o.views[p],a[p].element);if(i.length>0)throw new it(i);return ie(t,s,o.output,o.pretty,o.indent)}var se;function De(t){se=t;}function W(){if(!se)throw new Error("legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)");return se()}function We(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,p=0,u=false,l=[],g=x=>{if(!u){u=true;for(let m of l)m.terminate();x?a(x):o(s);}},f=x=>{if(u||i>=t.length)return;let m=i++;x.post({id:m,job:t[m]});};for(let x=0;x<n;x++){let m=r(y=>{if(!u){if(!y.ok)return g(new Error(y.error??"worker job failed"));s[y.id]={element:y.element,diagnostics:y.diagnostics??[]},++p===t.length?g():f(m);}},g);l.push(m);}for(let x of l)f(x);})}function Je(t,e,r){let n=new URL("./worker-entry.js",import.meta.url);return We(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 ln={};Rt(ln,{Ast:()=>Qe,BitType:()=>Ke,BitmarkFileGenerator:()=>en,BitmarkGenerator:()=>Ze,BitmarkParser:()=>pn,BitmarkParserGenerator:()=>Ut,BitmarkParserType:()=>Xr,BitmarkStringGenerator:()=>tn,BitmarkVersion:()=>qr,BodyTextFormat:()=>to,BoundingBoxIndex:()=>Xe,Builder:()=>Ht,CardSetVersion:()=>Yr,FileWriter:()=>un,HtmlTableGenerator:()=>sn,HtmlTableParser:()=>an,InfoFormat:()=>Zr,InfoType:()=>Qr,Input:()=>zr,InputFormat:()=>Kr,JsonFileGenerator:()=>on,JsonGenerator:()=>nn,JsonParser:()=>cn,JsonStringGenerator:()=>rn,LegacyUnsupportedError:()=>gt,NodeType:()=>Ye,Output:()=>$r,ResourceBuilder:()=>Gt,StreamWriter:()=>dn,StringWriter:()=>_n,TextLocation:()=>eo,TextMarkType:()=>ze,TextNodeType:()=>$e,bitmarkTextParse:()=>Ue,isPseudoAst:()=>Ne});var gt=class extends Error{constructor(e){super(e),this.name="LegacyUnsupportedError";}};function pt(t,e){throw new gt(`'${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}function tt(t,e){throw new gt(`Option '${t}' is not supported by the @gmb/bitmark-parser legacy API`+(e?`: ${e}`:""))}var ae="bitmark v2 output is not supported (this parser is bitmark v3 only)";function pe(t){t.bitmarkVersion===2&&tt("bitmarkVersion: 2",ae);}function Jt(t){t.explicitTextFormat&&tt("bitmarkOptions.explicitTextFormat"),t.cardSetVersion===1&&tt("bitmarkOptions.cardSetVersion: 1",ae),t.debugGenerationInline&&tt("bitmarkOptions.debugGenerationInline"),t.noBreakscaping&&tt("bitmarkOptions.noBreakscaping");}function Mt(t){t.textAsPlainText&&tt("jsonOptions.textAsPlainText",ae),t.debugGenerationInline&&tt("jsonOptions.debugGenerationInline");}function dt(t){return t===true?{pretty:true,indent:2}:typeof t=="number"&&t>0?{pretty:true,indent:t}:{pretty:false,indent:2}}function Nt(t){return t===void 0||t===true?1:t===false?0:Math.max(0,Math.min(10,t))}function Vt(t){switch(t){case "text":case "latex":case "json":case "xml":return "plainText";default:return "bitmark++"}}var Me=Symbol.for("@gmb/bitmark-parser/legacy-pseudo-ast");function ft(t){let e={bits:t};return Object.defineProperty(e,Me,{value:true,enumerable:false}),e}function Ne(t){return t!==null&&typeof t=="object"&&(Me in t||Array.isArray(t.bits))}var Ve={"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"),Vr={bitType:"type",textFormat:"format",flashcards:"cards",markConfig:"marks"},Hr={"bitmark--":"bitmark++","bitmark+":"bitmark++"},Ur={bitmark:"bitmark++",text:"text",json:"json",latex:"latex",xml:"xml"},Gr=["title","subtitle","item","lead","pageNumber","marginNumber","hint","instruction","caption"],Ht=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 p=o.textFormat;p!==void 0?(i.format=Hr[p]??p,delete o.textFormat):i.format=Ur[s.bodyFormat??""]??"bitmark++",delete o.resourceType;let u=o.body;u!=null&&typeof u=="object"&&"body"in u&&(i.body=u.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],w=Ve[a];w?i[w.key]=b.filter(k=>k!==null&&typeof k=="object"&&k.type===w.resourceType):b.length>=1&&(i.resource=b[0]),delete o.resources;}let g=o.parser;delete o.parser;let f=o.extraProperties;delete o.extraProperties;for(let[b,w]of Object.entries(o))w!==void 0&&(i[Vr[b]??b]=w);if(f)for(let[b,w]of Object.entries(f))b in i||(i[b]=w);this.parseStringTexts(i);let x=n.convert(JSON.stringify([{bit:i}]),"json","json","optimized",false,2,1,false,false,"",""),y=JSON.parse(x)[0]?.bit??i;for(let[b,w]of Object.entries(i))b in y||w===false||w===""||w===null||Array.isArray(w)&&w.length===0||(y[b]=w);return g!==void 0&&Object.defineProperty(y,ce,{value:g,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,...He(i,["text","isCorrect","isHighlighted"])})):[],prefix:n.prefix??"",postfix:n.postfix??"",...He(n,["type","texts","prefix","postfix","attrs"]),attrs:{}}}parseStringTexts(e){let r=W(),n=(s,i)=>{if(s==="")return s;let p=r.convert_text(s,"textToAst","bitmark++",i);try{return JSON.parse(p)}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 Gr){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 He(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 Ft.version}convert(e,r){let n=Object.assign({},r),o=Object.assign({},n.jsonOptions),a=Object.assign({},n.bitmarkOptions);pe(n),Jt(a),Mt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:p}=this.resolveInput(e,n.inputFormat),u=n.outputFormat??(p?"json":"bitmark"),l=u==="ast"?"json":u,{pretty:g,indent:f}=dt(o.prettify),x=l==="bitmark"?dt(a.prettifyJson):{pretty:g,indent:f},m=Nt(a.spacesAroundValues),y=!o.excludeUnknownProperties,b=s.convert(i,p?"bitmark":"json",l,"optimized",x.pretty,x.indent,m,y,false,"","");if(u==="bitmark"||u==="text")return this.deliver(b,n.outputFile,n.fileOptions);if(u==="json")return n.outputFile?this.deliver(b,n.outputFile,n.fileOptions):g||o.stringify?b:JSON.parse(b);let w=ft(JSON.parse(b));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);pe(n),Jt(a),Mt(o),this.checkBrowserFileWrite(n.outputFile);let s=W(),{source:i,isBitmark:p}=this.resolveInput(e,n.inputFormat),{pretty:u,indent:l}=dt(p?a.prettifyJson:o.prettify),g=Nt(a.spacesAroundValues),f=s.canonicalize(i,p?"bitmark":"json","optimized",u,l,g);return p?this.deliver(f,n.outputFile,n.fileOptions):n.outputFile?this.deliver(f,n.outputFile,n.fileOptions):u||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}=dt(r.prettify),p=a==="pojo"?"json":a,u=n.info(o,p,r.bit??"",s,i,false,false,true,"");return a==="pojo"?JSON.parse(u):u}generateConfig(e){pt("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&&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),O=s.convert(k,v?"bitmark":"json","html","optimized",false,2,1,false,false,"","");return this.deliver(_e(O).join(`
5
- `),n.outputFile,n.fileOptions)}let u=n.tableFormat==="table"?"table":"table-extended",l=_e(i).map(k=>`<bitmark-bit data-type="${u}" data-format="bitmark++">${k}</bitmark-bit>`).join(""),g=n.outputFormat??"bitmark",{pretty:f,indent:x}=dt(o.prettify),m=Nt(a.spacesAroundValues);if(g==="html"){let k=s.convert(l,"html","html","optimized",false,2,1,false,false,"","");return this.deliver(_e(k).join(`
6
- `),n.outputFile,n.fileOptions)}let y=g==="ast"?"json":g,b=s.convert(l,"html",y,"optimized",f,x,m,false,false,"","");if(g==="bitmark"||g==="text")return this.deliver(b,n.outputFile,n.fileOptions);if(g==="json")return n.outputFile?this.deliver(b,n.outputFile,n.fileOptions):f||o.stringify?b:JSON.parse(b);let w=ft(JSON.parse(b));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 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,Vt(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,Vt(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||Vt(n.textFormat)==="bitmark++",i=n.textLocation??"body",p,u;if(typeof e=="string"?(p=this.maybeReadFile(e,n.inputFormat),u=this.parseTextAstString(p)):(p=JSON.stringify(e),u=Array.isArray(e)?e:void 0),u!==void 0){let m=s?a.convert_text(JSON.stringify(u),"astToText","bitmark++",i):a.convert_text(JSON.stringify(u),"astToPlainText","plainText",i);return this.deliver(m,n.outputFile,n.fileOptions)}let l=a.convert_text(p,"textToAst",s?"bitmark++":"plainText","body"),{pretty:g,indent:f}=dt(o.prettify),x=g?a.prettify(l,f):l;return n.outputFile?this.deliver(x,n.outputFile,n.fileOptions):g?x: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 p=o.convert_text(String(e),"textToAst","bitmark++","body");return o.convert_text(p,"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 _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 p=r.indexOf("<table",s),u=r.indexOf("</table",s);if(u===-1)break;if(p!==-1&&p<u)a++,s=p+6;else {a--;let l=r.indexOf(">",u);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 Ue(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 J(t){return (e,r,n)=>{if(!r)return;let{value:o,...a}=r,s={[t.valueField]:o??""};for(let[i,p]of Object.entries(a))p!==void 0&&(s[i]=p);return {type:t.type,[t.key]:s}}}var Ge=Object.fromEntries(Object.values(M).map(t=>[t.type,t])),Gt=class{constructor(){C(this,"imageResource",J(M.imageResource));C(this,"imageLinkResource",J(M.imageLinkResource));C(this,"audioResource",J(M.audioResource));C(this,"audioEmbedResource",J(M.audioEmbedResource));C(this,"audioLinkResource",J(M.audioLinkResource));C(this,"videoResource",J(M.videoResource));C(this,"videoEmbedResource",J(M.videoEmbedResource));C(this,"videoLinkResource",J(M.videoLinkResource));C(this,"stillImageFilmEmbedResource",J(M.stillImageFilmEmbedResource));C(this,"stillImageFilmLinkResource",J(M.stillImageFilmLinkResource));C(this,"articleResource",J(M.articleResource));C(this,"documentResource",J(M.documentResource));C(this,"documentEmbedResource",J(M.documentEmbedResource));C(this,"documentLinkResource",J(M.documentLinkResource));C(this,"documentDownloadResource",J(M.documentDownloadResource));C(this,"appLinkResource",J(M.appLinkResource));C(this,"websiteLinkResource",J(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=Ge[s.type];if(!i)continue;let p=s[i.key]??{},{[i.valueField]:u,...l}=p,g=J(i)(void 0,{value:u,...l});g&&a.push(g);}if(a.length!==0)return n?a[0]:a}resourceFromResourceDataJson(e,r,n){if(!n)return;let o=Ge[r];if(!o)return;let a=typeof n=="string"?n:void 0,s=typeof n=="object"?n:{},{url:i,src:p,body:u,...l}=s,g=i??p??u??a;return J(o)(e,{value:g,...l})}};var zr={string:"string",file:"file"},$r={bitmark:"bitmark",json:"json",ast:"ast",text:"text"},Kr={bitmark:"bitmark",bitmarkText:"bitmarkText",plainText:"plainText",html:"html"},qr={v2:2,v3:3},Yr={v1:1,v2:2},Xr={peggy:"peggy"},Qr={list:"list",deprecated:"deprecated",all:"all",bit:"bit"},Zr={text:"text",json:"json",pojo:"pojo"},to={plainText:"text",latex:"latex",json:"json",xml:"xml",bitmarkPlusPlus:"bitmark++"},eo={tag:"tag",body:"body",cardBody:"cardBody"};var ze={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"},$e={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 no(t){return t.replace(/-([a-z0-9])/gu,(e,r)=>r.toUpperCase())}var ue;function Et(){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[no(n)]=n;ue=r;}return ue}var Ke=new Proxy({},{get:(t,e)=>typeof e=="string"?Et()[e]:void 0,has:(t,e)=>typeof e=="string"&&e in Et(),ownKeys:()=>Reflect.ownKeys(Et()),getOwnPropertyDescriptor:(t,e)=>typeof e=="string"&&e in Et()?{value:Et()[e],enumerable:true,configurable:true,writable:false}:void 0});function qe(t,e){return new Proxy({},{get:(r,n)=>n===Symbol.toPrimitive||n==="toString"||n===Symbol.toStringTag?()=>`[unsupported ${t}]`:pt(t,e),has:()=>pt(t,e),ownKeys:()=>pt(t,e)})}var Ye=qe("NodeType","it names bpg's internal AST nodes; the legacy AST is bit JSON (see createAst)"),Xe=qe("BoundingBoxIndex","bpg-internal bounding-box utility");function K(t,e){return class{constructor(){pt(t,e);}}}var ro="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",Qe=K("Ast",ro),Ze=K("BitmarkGenerator",q),tn=K("BitmarkStringGenerator",q),en=K("BitmarkFileGenerator",q),nn=K("JsonGenerator",q),rn=K("JsonStringGenerator",q),on=K("JsonFileGenerator",q),sn=K("HtmlTableGenerator",q),an=K("HtmlTableParser",q),pn=K("BitmarkParser",q),cn=K("JsonParser",q),_n=K("StringWriter",q),un=K("FileWriter",q),dn=K("StreamWriter",q);var gn={Error:1,Warning:2,Information:3,Hint:4},fn={Class:7,Property:10,Value:12,Keyword:14,Snippet:15,EnumMember:20,TypeParameter:25},mn={Deprecated:1};function oo(t,e,r){return r===void 0?{path:t,op:e}:{path:t,op:e,value:r}}var io="all";function so(t,e={}){let r=D().convert(t,"bitmark","json",e.mode??"optimized",false,2,1,e.includeUnknownProperties??false,false,"","");return JSON.parse(r)}function ao(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 de(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 po(t,e={}){return JSON.parse(de(t,{inputFormat:"bitmark",outputFormat:"semantic-tokens",positionEncoding:e.positionEncoding,tokensLayout:e.tokensLayout}))}function co(t,e={}){return JSON.parse(de(t,{inputFormat:"bitmark",outputFormat:"diagnostics",positionEncoding:e.positionEncoding}))}function _o(t,e,r={}){let n=D();if(typeof n.complete!="function")throw new st("complete",et());return JSON.parse(n.complete(t,e.line,e.character,r.positionEncoding??"",r.includeDeprecated??false,r.triggerCharacter??""))}function uo(t,e,r,n={}){let o=D();if(typeof o.resolve!="function")throw new st("resolve",et());return JSON.parse(o.resolve(t,e.line,e.character,n.positionEncoding??"",n.includeDeprecated??false,r.label,r.kind))??r}function lo(t,e,r={}){let n=D();if(typeof n.hover!="function")throw new st("hover",et());return JSON.parse(n.hover(t,e.line,e.character,r.positionEncoding??""))}function go(t,e={}){return D().canonicalize(t,e.inputFormat??"auto",e.mode??"optimized",e.pretty??false,e.indent??2,e.spacesAroundValues??1)}function fo(t){return Number.parseInt(D().count_bits(t),10)}function mo(t){return JSON.parse(D().split_bits(t))}function bo(t,e={}){let r=D();if(e.preHook||e.postHook)return Le(r,t,e);let n=e.patch===void 0?"":typeof e.patch=="string"?e.patch:JSON.stringify(e.patch),{data:o,diagnostics:a}=JSON.parse(r.transform(t,e.inputFormat??"auto",e.outputFormat??"json",e.mode??"optimized",n,e.pretty??false,e.indent??2,e.spacesAroundValues??1));if(a.length>0)throw new it(a);return o}function bn(t,e,r={}){let n=D();if(typeof n.diff!="function")throw new st("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 xo(t,e,r={}){return JSON.parse(bn(t,e,{...r,outputFormat:"json"}))}function yo(t,e={}){let r=e.format??"bitmark++",n=e.location??"body",o=e.subLocation??"text";return D().breakscape_text(t,r,n,o)}function wo(t,e={}){let r=e.format??"bitmark++",n=e.location??"body",o=e.subLocation??"text";return D().unbreakscape_text(t,r,n,o)}function ko(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,p=t.full??false,u=typeof t.language=="string"?t.language:t.language?.join(",")??"",l=D();if(r!=="json"&&typeof l.info_text_supported!="function")throw new st('info (format: "text")',et());return l.info(e,r,n,o,a,s,i,p,u)}function vo(t){try{D().register(t.type,t.data);}catch(e){throw new lt(e instanceof Error?e.message:String(e))}je(t.type,t.data);}var ho="./wasm/",xn={full:{init:Kt,initSync:$t,ns:qt,wasmFile:"bitmark_wasm_bg.wasm"},"browser-full":{init:Xt,initSync:Yt,ns:Qt,wasmFile:"bitmark_browser_full_wasm_bg.wasm"},"bitmark-json":{init:te,initSync:Zt,ns:ee,wasmFile:"bitmark_json_wasm_bg.wasm"}};De(()=>D());function le(t){return t===void 0?ne:"full"}function Io(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 Oo(t){if(Io(t))return {feature:t.feature??le(t.module_or_path),module_or_path:t.module_or_path};let e=t??void 0;return {feature:le(e),module_or_path:e}}var ge=0,zt,at;async function ns(t){let{feature:e,module_or_path:r}=Oo(t);if(r===void 0){if(!at&&et()===e)return zt;if(at?.feature===e)return at.promise}let n=++ge,o=xn[e],a=r??new URL(`${ho}${o.wasmFile}?v=${Ft.version}`,import.meta.url),s=(async()=>{try{let i=await o.init({module_or_path:a});n===ge&&(re(e,o.ns),zt=i);}finally{at?.seq===n&&(at=void 0);}for(;at;)await at.promise.catch(()=>{});return zt})();return at={feature:e,seq:n,promise:s},s}function rs(t,e={}){let r=e.feature??le(t),n=xn[r],o=n.initSync({module:t});return ++ge,at=void 0,re(r,n.ns),zt=o,o}function os(){return Ft.version}function is(t,e={}){let r=D(),n=et()??ne;return Ce(r,t,e,(o,a)=>Je(o,a,n))}export{io as ALL_LANGUAGES,fn as CompletionItemKind,mn as CompletionItemTag,gn as DiagnosticSeverity,Dt as NotInitializedError,it as PatchError,lt as RegisterError,st as UnsupportedFeatureError,so as bitmarkToObjects,yo as breakscapeText,go as canonicalize,_o as complete,de as convert,fo as countBits,co as diagnostics,bn as diff,xo as diffBits,lo as hover,ko as info,ns as init,rs as initSync,ln as legacy,ao as objectsToBitmark,oo as patchEntry,vo as register,uo as resolve,po as semanticTokens,mo as splitBits,bo as transform,is as transformParallel,wo as unbreakscapeText,et as variant,os as version};//# sourceMappingURL=bitmark-parser.min.js.map
1
+ var ke=Object.defineProperty;var Rn=(e,t,n)=>t in e?ke(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var Pt=(e,t)=>{for(var n in t)ke(e,n,{get:t[n],enumerable:true});};var M=(e,t,n)=>Rn(e,typeof t!="symbol"?t+"":t,n);var ee={};Pt(ee,{ConvertDetails:()=>Lt,breakscape_text:()=>Bn,canonicalize:()=>Hn,complete:()=>Mn,convert:()=>Xn,convert_text:()=>Yn,convert_with_details:()=>Qn,count_bits:()=>Gn,default:()=>te,diff:()=>Jn,hover:()=>Vn,info:()=>An,info_text_supported:()=>jn,initSync:()=>Zt,is_bitmark:()=>$n,prettify:()=>qn,register:()=>Un,resolve:()=>Nn,resolve_patch_document:()=>Wn,split_bits:()=>zn,split_json_bits:()=>Kn,transform:()=>Dn,unbreakscape_text:()=>Pn});var _,he=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&he.decode();var kt=null;function At(){return (kt===null||kt.byteLength===0)&&(kt=new Uint8Array(_.memory.buffer)),kt}function N(e,t){return e=e>>>0,he.decode(At().subarray(e,e+t))}var rt=new Array(128).fill(void 0);rt.push(void 0,null,true,false);var ht=rt.length;function En(e){ht===rt.length&&rt.push(rt.length+1);let t=ht;return ht=rt[t],rt[t]=e,t}var O=0,jt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Sn=typeof jt.encodeInto=="function"?function(e,t){return jt.encodeInto(e,t)}:function(e,t){let n=jt.encode(e);return t.set(n),{read:e.length,written:n.length}};function E(e,t,n){if(n===void 0){let i=jt.encode(e),d=t(i.length,1)>>>0;return At().subarray(d,d+i.length).set(i),O=i.length,d}let r=e.length,o=t(r,1)>>>0,a=At(),s=0;for(;s<r;s++){let i=e.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==r){s!==0&&(e=e.slice(s)),o=n(o,r,r=s+e.length*3,1)>>>0;let i=At().subarray(o+s,o+r),d=Sn(e,i);s+=d.written,o=n(o,r,s,1)>>>0;}return O=s,o}function Ie(e){return e==null}var ct=null;function h(){return (ct===null||ct.buffer.detached===true||ct.buffer.detached===void 0&&ct.buffer!==_.memory.buffer)&&(ct=new DataView(_.memory.buffer)),ct}function Bn(e,t,n,r){let o,a;try{let g=_.__wbindgen_add_to_stack_pointer(-16),l=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),f=O,x=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=O,m=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O;var s=Ie(r)?0:E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),i=O;_.breakscape_text(g,l,f,x,b,m,w,s,i);var d=h().getInt32(g+0,!0),u=h().getInt32(g+4,!0);return o=d,a=u,N(d,u)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function Pn(e,t,n,r){let o,a;try{let g=_.__wbindgen_add_to_stack_pointer(-16),l=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),f=O,x=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),b=O,m=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O;var s=Ie(r)?0:E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),i=O;_.unbreakscape_text(g,l,f,x,b,m,w,s,i);var d=h().getInt32(g+0,!0),u=h().getInt32(g+4,!0);return o=d,a=u,N(d,u)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function An(e,t,n,r,o,a,s,i,d){let u,g;try{let x=_.__wbindgen_add_to_stack_pointer(-16),b=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),m=O,w=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),y=O,k=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),v=O,R=E(d,_.__wbindgen_export_0,_.__wbindgen_export_1),A=O;_.info(x,b,m,w,y,k,v,r,o,a,s,i,R,A);var l=h().getInt32(x+0,!0),f=h().getInt32(x+4,!0);return u=l,g=f,N(l,f)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(u,g,1);}}function jn(){return _.info_text_supported()!==0}function Ln(e){return rt[e]}function Cn(e){e<132||(rt[e]=ht,ht=e);}function Y(e){let t=Ln(e);return Cn(e),t}function Dn(e,t,n,r,o,a,s,i){let d,u;try{let w=_.__wbindgen_add_to_stack_pointer(-16),y=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),k=O,v=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),R=O,A=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),C=O,D=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),W=O,J=E(o,_.__wbindgen_export_0,_.__wbindgen_export_1),K=O;_.transform(w,y,k,v,R,A,C,D,W,J,K,a,s,i);var g=h().getInt32(w+0,!0),l=h().getInt32(w+4,!0),f=h().getInt32(w+8,!0),x=h().getInt32(w+12,!0),b=g,m=l;if(x)throw b=0,m=0,Y(f);return d=b,u=m,N(b,m)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(d,u,1);}}function Wn(e,t,n){let r,o;try{let l=_.__wbindgen_add_to_stack_pointer(-16),f=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),x=O,b=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),m=O,w=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),y=O;_.resolve_patch_document(l,f,x,b,m,w,y);var a=h().getInt32(l+0,!0),s=h().getInt32(l+4,!0),i=h().getInt32(l+8,!0),d=h().getInt32(l+12,!0),u=a,g=s;if(d)throw u=0,g=0,Y(i);return r=u,o=g,N(u,g)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(r,o,1);}}function Jn(e,t,n,r,o,a,s,i,d){let u,g;try{let y=_.__wbindgen_add_to_stack_pointer(-16),k=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),v=O,R=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),A=O,C=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),D=O,W=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),J=O;_.diff(y,k,v,R,A,C,D,W,J,o,a,s,i,d);var l=h().getInt32(y+0,!0),f=h().getInt32(y+4,!0),x=h().getInt32(y+8,!0),b=h().getInt32(y+12,!0),m=l,w=f;if(b)throw m=0,w=0,Y(x);return u=m,g=w,N(m,w)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(u,g,1);}}function Mn(e,t,n,r,o,a){let s,i;try{let b=_.__wbindgen_add_to_stack_pointer(-16),m=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O,y=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),k=O,v=E(a,_.__wbindgen_export_0,_.__wbindgen_export_1),R=O;_.complete(b,m,w,t,n,y,k,o,v,R);var d=h().getInt32(b+0,!0),u=h().getInt32(b+4,!0),g=h().getInt32(b+8,!0),l=h().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,Y(g);return s=f,i=x,N(f,x)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function Nn(e,t,n,r,o,a,s){let i,d;try{let m=_.__wbindgen_add_to_stack_pointer(-16),w=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),y=O,k=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),v=O,R=E(a,_.__wbindgen_export_0,_.__wbindgen_export_1),A=O;_.resolve(m,w,y,t,n,k,v,o,R,A,s);var u=h().getInt32(m+0,!0),g=h().getInt32(m+4,!0),l=h().getInt32(m+8,!0),f=h().getInt32(m+12,!0),x=u,b=g;if(f)throw x=0,b=0,Y(l);return i=x,d=b,N(x,b)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(i,d,1);}}function Vn(e,t,n,r){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),x=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),b=O,m=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O;_.hover(f,x,b,t,n,m,w);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),d=h().getInt32(f+8,!0),u=h().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,Y(d);return o=g,a=l,N(g,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function Un(e,t){try{let o=_.__wbindgen_add_to_stack_pointer(-16),a=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),s=O,i=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),d=O;_.register(o,a,s,i,d);var n=h().getInt32(o+0,!0),r=h().getInt32(o+4,!0);if(r)throw Y(n)}finally{_.__wbindgen_add_to_stack_pointer(16);}}function Hn(e,t,n,r,o,a){let s,i;try{let b=_.__wbindgen_add_to_stack_pointer(-16),m=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O,y=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),k=O,v=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),R=O;_.canonicalize(b,m,w,y,k,v,R,r,o,a);var d=h().getInt32(b+0,!0),u=h().getInt32(b+4,!0),g=h().getInt32(b+8,!0),l=h().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,Y(g);return s=f,i=x,N(f,x)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(s,i,1);}}function Gn(e){let t,n;try{let u=_.__wbindgen_add_to_stack_pointer(-16),g=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),l=O;_.count_bits(u,g,l);var r=h().getInt32(u+0,!0),o=h().getInt32(u+4,!0),a=h().getInt32(u+8,!0),s=h().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,Y(a);return t=i,n=d,N(i,d)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(t,n,1);}}function zn(e,t){let n,r;try{let s=_.__wbindgen_add_to_stack_pointer(-16),i=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),d=O,u=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),g=O;_.split_bits(s,i,d,u,g);var o=h().getInt32(s+0,!0),a=h().getInt32(s+4,!0);return n=o,r=a,N(o,a)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,r,1);}}function $n(e){let t=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),n=O;return _.is_bitmark(t,n)!==0}function Kn(e){let t,n;try{let u=_.__wbindgen_add_to_stack_pointer(-16),g=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),l=O;_.split_json_bits(u,g,l);var r=h().getInt32(u+0,!0),o=h().getInt32(u+4,!0),a=h().getInt32(u+8,!0),s=h().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,Y(a);return t=i,n=d,N(i,d)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(t,n,1);}}function qn(e,t){let n,r;try{let s=_.__wbindgen_add_to_stack_pointer(-16),i=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),d=O;_.prettify(s,i,d,t);var o=h().getInt32(s+0,!0),a=h().getInt32(s+4,!0);return n=o,r=a,N(o,a)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(n,r,1);}}function Yn(e,t,n,r){let o,a;try{let f=_.__wbindgen_add_to_stack_pointer(-16),x=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),b=O,m=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),w=O,y=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),k=O,v=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),R=O;_.convert_text(f,x,b,m,w,y,k,v,R);var s=h().getInt32(f+0,!0),i=h().getInt32(f+4,!0),d=h().getInt32(f+8,!0),u=h().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,Y(d);return o=g,a=l,N(g,l)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(o,a,1);}}function Xn(e,t,n,r,o,a,s,i,d,u,g){let l,f;try{let v=_.__wbindgen_add_to_stack_pointer(-16),R=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),A=O,C=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),D=O,W=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),J=O,K=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),tt=O,mt=E(u,_.__wbindgen_export_0,_.__wbindgen_export_1),wt=O,xt=E(g,_.__wbindgen_export_0,_.__wbindgen_export_1),yt=O;_.convert(v,R,A,C,D,W,J,K,tt,o,a,s,i,d,mt,wt,xt,yt);var x=h().getInt32(v+0,!0),b=h().getInt32(v+4,!0),m=h().getInt32(v+8,!0),w=h().getInt32(v+12,!0),y=x,k=b;if(w)throw y=0,k=0,Y(m);return l=y,f=k,N(y,k)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(l,f,1);}}function Qn(e,t,n,r,o,a,s,i,d,u,g,l){try{let m=_.__wbindgen_add_to_stack_pointer(-16),w=E(e,_.__wbindgen_export_0,_.__wbindgen_export_1),y=O,k=E(t,_.__wbindgen_export_0,_.__wbindgen_export_1),v=O,R=E(n,_.__wbindgen_export_0,_.__wbindgen_export_1),A=O,C=E(r,_.__wbindgen_export_0,_.__wbindgen_export_1),D=O,W=E(u,_.__wbindgen_export_0,_.__wbindgen_export_1),J=O,K=E(g,_.__wbindgen_export_0,_.__wbindgen_export_1),tt=O;_.convert_with_details(m,w,y,k,v,R,A,C,D,o,a,s,i,d,W,J,K,tt,l);var f=h().getInt32(m+0,!0),x=h().getInt32(m+4,!0),b=h().getInt32(m+8,!0);if(b)throw Y(x);return Lt.__wrap(f)}finally{_.__wbindgen_add_to_stack_pointer(16);}}var vt=null;function Zn(){return (vt===null||vt.byteLength===0)&&(vt=new Uint32Array(_.memory.buffer)),vt}function tr(e,t){return e=e>>>0,Zn().subarray(e/4,e/4+t)}var ve=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>_.__wbg_convertdetails_free(e>>>0,1)),Lt=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,ve.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,ve.unregister(this),t}free(){let t=this.__destroy_into_raw();_.__wbg_convertdetails_free(t,0);}bit_spans_encoding(){try{let r=_.__wbindgen_add_to_stack_pointer(-16);_.convertdetails_bit_spans_encoding(r,this.__wbg_ptr);var t=h().getInt32(r+0,!0),n=h().getInt32(r+4,!0);let o;return t!==0&&(o=N(t,n).slice(),_.__wbindgen_export_2(t,n*1,1)),o}finally{_.__wbindgen_add_to_stack_pointer(16);}}bit_spans(){try{let r=_.__wbindgen_add_to_stack_pointer(-16);_.convertdetails_bit_spans(r,this.__wbg_ptr);var t=h().getInt32(r+0,!0),n=h().getInt32(r+4,!0);let o;return t!==0&&(o=tr(t,n).slice(),_.__wbindgen_export_2(t,n*4,4)),o}finally{_.__wbindgen_add_to_stack_pointer(16);}}take_data(){let t,n;try{let a=_.__wbindgen_add_to_stack_pointer(-16);_.convertdetails_take_data(a,this.__wbg_ptr);var r=h().getInt32(a+0,!0),o=h().getInt32(a+4,!0);return t=r,n=o,N(r,o)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_2(t,n,1);}}};async function er(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else {let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function Oe(){let e={};return e.wbg={},e.wbg.__wbindgen_error_new=function(t,n){let r=new Error(N(t,n));return En(r)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(N(t,n))},e}function Te(e,t){return _=e.exports,Fe.__wbindgen_wasm_module=t,ct=null,vt=null,kt=null,_}function Zt(e){if(_!==void 0)return _;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Oe();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return Te(n,e)}async function Fe(e){if(_!==void 0)return _;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=new URL("bitmark_wasm_bg.wasm",import.meta.url));let t=Oe();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await er(await e,t);return Te(n,r)}var te=Fe;var oe={};Pt(oe,{ConvertDetails:()=>Wt,breakscape_text:()=>or,canonicalize:()=>mr,complete:()=>gr,convert:()=>Ir,convert_text:()=>hr,convert_with_details:()=>Or,count_bits:()=>wr,default:()=>re,diff:()=>ur,hover:()=>fr,info:()=>sr,info_text_supported:()=>ar,initSync:()=>ne,is_bitmark:()=>yr,prettify:()=>vr,register:()=>br,resolve:()=>lr,resolve_patch_document:()=>dr,split_bits:()=>xr,split_json_bits:()=>kr,transform:()=>cr,unbreakscape_text:()=>ir});var p,Ee=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Ee.decode();var It=null;function Ct(){return (It===null||It.byteLength===0)&&(It=new Uint8Array(p.memory.buffer)),It}function V(e,t){return e=e>>>0,Ee.decode(Ct().subarray(e,e+t))}var ot=new Array(128).fill(void 0);ot.push(void 0,null,true,false);var Tt=ot.length;function nr(e){Tt===ot.length&&ot.push(ot.length+1);let t=Tt;return Tt=ot[t],ot[t]=e,t}var T=0,Dt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},rr=typeof Dt.encodeInto=="function"?function(e,t){return Dt.encodeInto(e,t)}:function(e,t){let n=Dt.encode(e);return t.set(n),{read:e.length,written:n.length}};function S(e,t,n){if(n===void 0){let i=Dt.encode(e),d=t(i.length,1)>>>0;return Ct().subarray(d,d+i.length).set(i),T=i.length,d}let r=e.length,o=t(r,1)>>>0,a=Ct(),s=0;for(;s<r;s++){let i=e.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==r){s!==0&&(e=e.slice(s)),o=n(o,r,r=s+e.length*3,1)>>>0;let i=Ct().subarray(o+s,o+r),d=rr(e,i);s+=d.written,o=n(o,r,s,1)>>>0;}return T=s,o}function Se(e){return e==null}var dt=null;function I(){return (dt===null||dt.buffer.detached===true||dt.buffer.detached===void 0&&dt.buffer!==p.memory.buffer)&&(dt=new DataView(p.memory.buffer)),dt}function or(e,t,n,r){let o,a;try{let g=p.__wbindgen_add_to_stack_pointer(-16),l=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),f=T,x=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),b=T,m=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T;var s=Se(r)?0:S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),i=T;p.breakscape_text(g,l,f,x,b,m,w,s,i);var d=I().getInt32(g+0,!0),u=I().getInt32(g+4,!0);return o=d,a=u,V(d,u)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function ir(e,t,n,r){let o,a;try{let g=p.__wbindgen_add_to_stack_pointer(-16),l=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),f=T,x=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),b=T,m=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T;var s=Se(r)?0:S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),i=T;p.unbreakscape_text(g,l,f,x,b,m,w,s,i);var d=I().getInt32(g+0,!0),u=I().getInt32(g+4,!0);return o=d,a=u,V(d,u)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function sr(e,t,n,r,o,a,s,i,d){let u,g;try{let x=p.__wbindgen_add_to_stack_pointer(-16),b=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),m=T,w=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),y=T,k=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),v=T,R=S(d,p.__wbindgen_export_0,p.__wbindgen_export_1),A=T;p.info(x,b,m,w,y,k,v,r,o,a,s,i,R,A);var l=I().getInt32(x+0,!0),f=I().getInt32(x+4,!0);return u=l,g=f,V(l,f)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(u,g,1);}}function ar(){return p.info_text_supported()!==0}function _r(e){return ot[e]}function pr(e){e<132||(ot[e]=Tt,Tt=e);}function X(e){let t=_r(e);return pr(e),t}function cr(e,t,n,r,o,a,s,i){let d,u;try{let w=p.__wbindgen_add_to_stack_pointer(-16),y=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),k=T,v=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),R=T,A=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),C=T,D=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),W=T,J=S(o,p.__wbindgen_export_0,p.__wbindgen_export_1),K=T;p.transform(w,y,k,v,R,A,C,D,W,J,K,a,s,i);var g=I().getInt32(w+0,!0),l=I().getInt32(w+4,!0),f=I().getInt32(w+8,!0),x=I().getInt32(w+12,!0),b=g,m=l;if(x)throw b=0,m=0,X(f);return d=b,u=m,V(b,m)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(d,u,1);}}function dr(e,t,n){let r,o;try{let l=p.__wbindgen_add_to_stack_pointer(-16),f=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),x=T,b=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),m=T,w=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),y=T;p.resolve_patch_document(l,f,x,b,m,w,y);var a=I().getInt32(l+0,!0),s=I().getInt32(l+4,!0),i=I().getInt32(l+8,!0),d=I().getInt32(l+12,!0),u=a,g=s;if(d)throw u=0,g=0,X(i);return r=u,o=g,V(u,g)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(r,o,1);}}function ur(e,t,n,r,o,a,s,i,d){let u,g;try{let y=p.__wbindgen_add_to_stack_pointer(-16),k=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),v=T,R=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),A=T,C=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),D=T,W=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),J=T;p.diff(y,k,v,R,A,C,D,W,J,o,a,s,i,d);var l=I().getInt32(y+0,!0),f=I().getInt32(y+4,!0),x=I().getInt32(y+8,!0),b=I().getInt32(y+12,!0),m=l,w=f;if(b)throw m=0,w=0,X(x);return u=m,g=w,V(m,w)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(u,g,1);}}function gr(e,t,n,r,o,a){let s,i;try{let b=p.__wbindgen_add_to_stack_pointer(-16),m=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T,y=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),k=T,v=S(a,p.__wbindgen_export_0,p.__wbindgen_export_1),R=T;p.complete(b,m,w,t,n,y,k,o,v,R);var d=I().getInt32(b+0,!0),u=I().getInt32(b+4,!0),g=I().getInt32(b+8,!0),l=I().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,X(g);return s=f,i=x,V(f,x)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(s,i,1);}}function lr(e,t,n,r,o,a,s){let i,d;try{let m=p.__wbindgen_add_to_stack_pointer(-16),w=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),y=T,k=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),v=T,R=S(a,p.__wbindgen_export_0,p.__wbindgen_export_1),A=T;p.resolve(m,w,y,t,n,k,v,o,R,A,s);var u=I().getInt32(m+0,!0),g=I().getInt32(m+4,!0),l=I().getInt32(m+8,!0),f=I().getInt32(m+12,!0),x=u,b=g;if(f)throw x=0,b=0,X(l);return i=x,d=b,V(x,b)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(i,d,1);}}function fr(e,t,n,r){let o,a;try{let f=p.__wbindgen_add_to_stack_pointer(-16),x=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),b=T,m=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T;p.hover(f,x,b,t,n,m,w);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),d=I().getInt32(f+8,!0),u=I().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,X(d);return o=g,a=l,V(g,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function br(e,t){try{let o=p.__wbindgen_add_to_stack_pointer(-16),a=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),s=T,i=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),d=T;p.register(o,a,s,i,d);var n=I().getInt32(o+0,!0),r=I().getInt32(o+4,!0);if(r)throw X(n)}finally{p.__wbindgen_add_to_stack_pointer(16);}}function mr(e,t,n,r,o,a){let s,i;try{let b=p.__wbindgen_add_to_stack_pointer(-16),m=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T,y=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),k=T,v=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),R=T;p.canonicalize(b,m,w,y,k,v,R,r,o,a);var d=I().getInt32(b+0,!0),u=I().getInt32(b+4,!0),g=I().getInt32(b+8,!0),l=I().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,X(g);return s=f,i=x,V(f,x)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(s,i,1);}}function wr(e){let t,n;try{let u=p.__wbindgen_add_to_stack_pointer(-16),g=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),l=T;p.count_bits(u,g,l);var r=I().getInt32(u+0,!0),o=I().getInt32(u+4,!0),a=I().getInt32(u+8,!0),s=I().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,X(a);return t=i,n=d,V(i,d)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(t,n,1);}}function xr(e,t){let n,r;try{let s=p.__wbindgen_add_to_stack_pointer(-16),i=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),d=T,u=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),g=T;p.split_bits(s,i,d,u,g);var o=I().getInt32(s+0,!0),a=I().getInt32(s+4,!0);return n=o,r=a,V(o,a)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,r,1);}}function yr(e){let t=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),n=T;return p.is_bitmark(t,n)!==0}function kr(e){let t,n;try{let u=p.__wbindgen_add_to_stack_pointer(-16),g=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),l=T;p.split_json_bits(u,g,l);var r=I().getInt32(u+0,!0),o=I().getInt32(u+4,!0),a=I().getInt32(u+8,!0),s=I().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,X(a);return t=i,n=d,V(i,d)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(t,n,1);}}function vr(e,t){let n,r;try{let s=p.__wbindgen_add_to_stack_pointer(-16),i=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),d=T;p.prettify(s,i,d,t);var o=I().getInt32(s+0,!0),a=I().getInt32(s+4,!0);return n=o,r=a,V(o,a)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(n,r,1);}}function hr(e,t,n,r){let o,a;try{let f=p.__wbindgen_add_to_stack_pointer(-16),x=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),b=T,m=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),w=T,y=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),k=T,v=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),R=T;p.convert_text(f,x,b,m,w,y,k,v,R);var s=I().getInt32(f+0,!0),i=I().getInt32(f+4,!0),d=I().getInt32(f+8,!0),u=I().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,X(d);return o=g,a=l,V(g,l)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(o,a,1);}}function Ir(e,t,n,r,o,a,s,i,d,u,g){let l,f;try{let v=p.__wbindgen_add_to_stack_pointer(-16),R=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),A=T,C=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),D=T,W=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),J=T,K=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),tt=T,mt=S(u,p.__wbindgen_export_0,p.__wbindgen_export_1),wt=T,xt=S(g,p.__wbindgen_export_0,p.__wbindgen_export_1),yt=T;p.convert(v,R,A,C,D,W,J,K,tt,o,a,s,i,d,mt,wt,xt,yt);var x=I().getInt32(v+0,!0),b=I().getInt32(v+4,!0),m=I().getInt32(v+8,!0),w=I().getInt32(v+12,!0),y=x,k=b;if(w)throw y=0,k=0,X(m);return l=y,f=k,V(y,k)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(l,f,1);}}function Or(e,t,n,r,o,a,s,i,d,u,g,l){try{let m=p.__wbindgen_add_to_stack_pointer(-16),w=S(e,p.__wbindgen_export_0,p.__wbindgen_export_1),y=T,k=S(t,p.__wbindgen_export_0,p.__wbindgen_export_1),v=T,R=S(n,p.__wbindgen_export_0,p.__wbindgen_export_1),A=T,C=S(r,p.__wbindgen_export_0,p.__wbindgen_export_1),D=T,W=S(u,p.__wbindgen_export_0,p.__wbindgen_export_1),J=T,K=S(g,p.__wbindgen_export_0,p.__wbindgen_export_1),tt=T;p.convert_with_details(m,w,y,k,v,R,A,C,D,o,a,s,i,d,W,J,K,tt,l);var f=I().getInt32(m+0,!0),x=I().getInt32(m+4,!0),b=I().getInt32(m+8,!0);if(b)throw X(x);return Wt.__wrap(f)}finally{p.__wbindgen_add_to_stack_pointer(16);}}var Ot=null;function Tr(){return (Ot===null||Ot.byteLength===0)&&(Ot=new Uint32Array(p.memory.buffer)),Ot}function Fr(e,t){return e=e>>>0,Tr().subarray(e/4,e/4+t)}var Re=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>p.__wbg_convertdetails_free(e>>>0,1)),Wt=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,Re.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Re.unregister(this),t}free(){let t=this.__destroy_into_raw();p.__wbg_convertdetails_free(t,0);}bit_spans_encoding(){try{let r=p.__wbindgen_add_to_stack_pointer(-16);p.convertdetails_bit_spans_encoding(r,this.__wbg_ptr);var t=I().getInt32(r+0,!0),n=I().getInt32(r+4,!0);let o;return t!==0&&(o=V(t,n).slice(),p.__wbindgen_export_2(t,n*1,1)),o}finally{p.__wbindgen_add_to_stack_pointer(16);}}bit_spans(){try{let r=p.__wbindgen_add_to_stack_pointer(-16);p.convertdetails_bit_spans(r,this.__wbg_ptr);var t=I().getInt32(r+0,!0),n=I().getInt32(r+4,!0);let o;return t!==0&&(o=Fr(t,n).slice(),p.__wbindgen_export_2(t,n*4,4)),o}finally{p.__wbindgen_add_to_stack_pointer(16);}}take_data(){let t,n;try{let a=p.__wbindgen_add_to_stack_pointer(-16);p.convertdetails_take_data(a,this.__wbg_ptr);var r=I().getInt32(a+0,!0),o=I().getInt32(a+4,!0);return t=r,n=o,V(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_export_2(t,n,1);}}};async function Rr(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else {let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function Be(){let e={};return e.wbg={},e.wbg.__wbindgen_error_new=function(t,n){let r=new Error(V(t,n));return nr(r)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(V(t,n))},e}function Pe(e,t){return p=e.exports,Ae.__wbindgen_wasm_module=t,dt=null,Ot=null,It=null,p}function ne(e){if(p!==void 0)return p;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=Be();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return Pe(n,e)}async function Ae(e){if(p!==void 0)return p;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=new URL("bitmark_browser_full_wasm_bg.wasm",import.meta.url));let t=Be();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Rr(await e,t);return Pe(n,r)}var re=Ae;var ae={};Pt(ae,{ConvertDetails:()=>Nt,breakscape_text:()=>Br,canonicalize:()=>Nr,complete:()=>Wr,convert:()=>qr,convert_text:()=>$r,convert_with_details:()=>Yr,count_bits:()=>Vr,default:()=>se,hover:()=>Mr,info:()=>Ar,initSync:()=>ie,is_bitmark:()=>Hr,prettify:()=>zr,register:()=>Cr,resolve:()=>Jr,resolve_patch_document:()=>Dr,split_bits:()=>Ur,split_json_bits:()=>Gr,transform:()=>Kr,unbreakscape_text:()=>Pr});var c,Le=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Le.decode();var Ft=null;function Jt(){return (Ft===null||Ft.byteLength===0)&&(Ft=new Uint8Array(c.memory.buffer)),Ft}function H(e,t){return e=e>>>0,Le.decode(Jt().subarray(e,e+t))}var it=new Array(128).fill(void 0);it.push(void 0,null,true,false);var Et=it.length;function Er(e){Et===it.length&&it.push(it.length+1);let t=Et;return Et=it[t],it[t]=e,t}var B=0,Mt=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Sr=typeof Mt.encodeInto=="function"?function(e,t){return Mt.encodeInto(e,t)}:function(e,t){let n=Mt.encode(e);return t.set(n),{read:e.length,written:n.length}};function P(e,t,n){if(n===void 0){let i=Mt.encode(e),d=t(i.length,1)>>>0;return Jt().subarray(d,d+i.length).set(i),B=i.length,d}let r=e.length,o=t(r,1)>>>0,a=Jt(),s=0;for(;s<r;s++){let i=e.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==r){s!==0&&(e=e.slice(s)),o=n(o,r,r=s+e.length*3,1)>>>0;let i=Jt().subarray(o+s,o+r),d=Sr(e,i);s+=d.written,o=n(o,r,s,1)>>>0;}return B=s,o}function Ce(e){return e==null}var ut=null;function F(){return (ut===null||ut.buffer.detached===true||ut.buffer.detached===void 0&&ut.buffer!==c.memory.buffer)&&(ut=new DataView(c.memory.buffer)),ut}function Br(e,t,n,r){let o,a;try{let g=c.__wbindgen_add_to_stack_pointer(-16),l=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),f=B,x=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),b=B,m=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B;var s=Ce(r)?0:P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),i=B;c.breakscape_text(g,l,f,x,b,m,w,s,i);var d=F().getInt32(g+0,!0),u=F().getInt32(g+4,!0);return o=d,a=u,H(d,u)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Pr(e,t,n,r){let o,a;try{let g=c.__wbindgen_add_to_stack_pointer(-16),l=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),f=B,x=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),b=B,m=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B;var s=Ce(r)?0:P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),i=B;c.unbreakscape_text(g,l,f,x,b,m,w,s,i);var d=F().getInt32(g+0,!0),u=F().getInt32(g+4,!0);return o=d,a=u,H(d,u)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Ar(e,t,n,r,o,a,s,i,d){let u,g;try{let x=c.__wbindgen_add_to_stack_pointer(-16),b=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),m=B,w=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),y=B,k=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),v=B,R=P(d,c.__wbindgen_export_0,c.__wbindgen_export_1),A=B;c.info(x,b,m,w,y,k,v,r,o,a,s,i,R,A);var l=F().getInt32(x+0,!0),f=F().getInt32(x+4,!0);return u=l,g=f,H(l,f)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(u,g,1);}}function jr(e){return it[e]}function Lr(e){e<132||(it[e]=Et,Et=e);}function Z(e){let t=jr(e);return Lr(e),t}function Cr(e,t){try{let o=c.__wbindgen_add_to_stack_pointer(-16),a=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),s=B,i=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),d=B;c.register(o,a,s,i,d);var n=F().getInt32(o+0,!0),r=F().getInt32(o+4,!0);if(r)throw Z(n)}finally{c.__wbindgen_add_to_stack_pointer(16);}}function Dr(e,t,n){let r,o;try{let l=c.__wbindgen_add_to_stack_pointer(-16),f=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),x=B,b=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),m=B,w=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),y=B;c.resolve_patch_document(l,f,x,b,m,w,y);var a=F().getInt32(l+0,!0),s=F().getInt32(l+4,!0),i=F().getInt32(l+8,!0),d=F().getInt32(l+12,!0),u=a,g=s;if(d)throw u=0,g=0,Z(i);return r=u,o=g,H(u,g)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(r,o,1);}}function Wr(e,t,n,r,o,a){let s,i;try{let b=c.__wbindgen_add_to_stack_pointer(-16),m=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B,y=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),k=B,v=P(a,c.__wbindgen_export_0,c.__wbindgen_export_1),R=B;c.complete(b,m,w,t,n,y,k,o,v,R);var d=F().getInt32(b+0,!0),u=F().getInt32(b+4,!0),g=F().getInt32(b+8,!0),l=F().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,Z(g);return s=f,i=x,H(f,x)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(s,i,1);}}function Jr(e,t,n,r,o,a,s){let i,d;try{let m=c.__wbindgen_add_to_stack_pointer(-16),w=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),y=B,k=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),v=B,R=P(a,c.__wbindgen_export_0,c.__wbindgen_export_1),A=B;c.resolve(m,w,y,t,n,k,v,o,R,A,s);var u=F().getInt32(m+0,!0),g=F().getInt32(m+4,!0),l=F().getInt32(m+8,!0),f=F().getInt32(m+12,!0),x=u,b=g;if(f)throw x=0,b=0,Z(l);return i=x,d=b,H(x,b)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(i,d,1);}}function Mr(e,t,n,r){let o,a;try{let f=c.__wbindgen_add_to_stack_pointer(-16),x=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),b=B,m=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B;c.hover(f,x,b,t,n,m,w);var s=F().getInt32(f+0,!0),i=F().getInt32(f+4,!0),d=F().getInt32(f+8,!0),u=F().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,Z(d);return o=g,a=l,H(g,l)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Nr(e,t,n,r,o,a){let s,i;try{let b=c.__wbindgen_add_to_stack_pointer(-16),m=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B,y=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),k=B,v=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),R=B;c.canonicalize(b,m,w,y,k,v,R,r,o,a);var d=F().getInt32(b+0,!0),u=F().getInt32(b+4,!0),g=F().getInt32(b+8,!0),l=F().getInt32(b+12,!0),f=d,x=u;if(l)throw f=0,x=0,Z(g);return s=f,i=x,H(f,x)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(s,i,1);}}function Vr(e){let t,n;try{let u=c.__wbindgen_add_to_stack_pointer(-16),g=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),l=B;c.count_bits(u,g,l);var r=F().getInt32(u+0,!0),o=F().getInt32(u+4,!0),a=F().getInt32(u+8,!0),s=F().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,Z(a);return t=i,n=d,H(i,d)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(t,n,1);}}function Ur(e,t){let n,r;try{let s=c.__wbindgen_add_to_stack_pointer(-16),i=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),d=B,u=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),g=B;c.split_bits(s,i,d,u,g);var o=F().getInt32(s+0,!0),a=F().getInt32(s+4,!0);return n=o,r=a,H(o,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(n,r,1);}}function Hr(e){let t=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),n=B;return c.is_bitmark(t,n)!==0}function Gr(e){let t,n;try{let u=c.__wbindgen_add_to_stack_pointer(-16),g=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),l=B;c.split_json_bits(u,g,l);var r=F().getInt32(u+0,!0),o=F().getInt32(u+4,!0),a=F().getInt32(u+8,!0),s=F().getInt32(u+12,!0),i=r,d=o;if(s)throw i=0,d=0,Z(a);return t=i,n=d,H(i,d)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(t,n,1);}}function zr(e,t){let n,r;try{let s=c.__wbindgen_add_to_stack_pointer(-16),i=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),d=B;c.prettify(s,i,d,t);var o=F().getInt32(s+0,!0),a=F().getInt32(s+4,!0);return n=o,r=a,H(o,a)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(n,r,1);}}function $r(e,t,n,r){let o,a;try{let f=c.__wbindgen_add_to_stack_pointer(-16),x=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),b=B,m=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),w=B,y=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),k=B,v=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),R=B;c.convert_text(f,x,b,m,w,y,k,v,R);var s=F().getInt32(f+0,!0),i=F().getInt32(f+4,!0),d=F().getInt32(f+8,!0),u=F().getInt32(f+12,!0),g=s,l=i;if(u)throw g=0,l=0,Z(d);return o=g,a=l,H(g,l)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(o,a,1);}}function Kr(e,t,n,r,o,a,s,i){let d,u;try{let w=c.__wbindgen_add_to_stack_pointer(-16),y=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),k=B,v=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),R=B,A=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),C=B,D=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),W=B,J=P(o,c.__wbindgen_export_0,c.__wbindgen_export_1),K=B;c.transform(w,y,k,v,R,A,C,D,W,J,K,a,s,i);var g=F().getInt32(w+0,!0),l=F().getInt32(w+4,!0),f=F().getInt32(w+8,!0),x=F().getInt32(w+12,!0),b=g,m=l;if(x)throw b=0,m=0,Z(f);return d=b,u=m,H(b,m)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(d,u,1);}}function qr(e,t,n,r,o,a,s,i,d,u,g){let l,f;try{let v=c.__wbindgen_add_to_stack_pointer(-16),R=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),A=B,C=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),D=B,W=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),J=B,K=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),tt=B,mt=P(u,c.__wbindgen_export_0,c.__wbindgen_export_1),wt=B,xt=P(g,c.__wbindgen_export_0,c.__wbindgen_export_1),yt=B;c.convert(v,R,A,C,D,W,J,K,tt,o,a,s,i,d,mt,wt,xt,yt);var x=F().getInt32(v+0,!0),b=F().getInt32(v+4,!0),m=F().getInt32(v+8,!0),w=F().getInt32(v+12,!0),y=x,k=b;if(w)throw y=0,k=0,Z(m);return l=y,f=k,H(y,k)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(l,f,1);}}function Yr(e,t,n,r,o,a,s,i,d,u,g,l){try{let m=c.__wbindgen_add_to_stack_pointer(-16),w=P(e,c.__wbindgen_export_0,c.__wbindgen_export_1),y=B,k=P(t,c.__wbindgen_export_0,c.__wbindgen_export_1),v=B,R=P(n,c.__wbindgen_export_0,c.__wbindgen_export_1),A=B,C=P(r,c.__wbindgen_export_0,c.__wbindgen_export_1),D=B,W=P(u,c.__wbindgen_export_0,c.__wbindgen_export_1),J=B,K=P(g,c.__wbindgen_export_0,c.__wbindgen_export_1),tt=B;c.convert_with_details(m,w,y,k,v,R,A,C,D,o,a,s,i,d,W,J,K,tt,l);var f=F().getInt32(m+0,!0),x=F().getInt32(m+4,!0),b=F().getInt32(m+8,!0);if(b)throw Z(x);return Nt.__wrap(f)}finally{c.__wbindgen_add_to_stack_pointer(16);}}var Rt=null;function Xr(){return (Rt===null||Rt.byteLength===0)&&(Rt=new Uint32Array(c.memory.buffer)),Rt}function Qr(e,t){return e=e>>>0,Xr().subarray(e/4,e/4+t)}var je=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>c.__wbg_convertdetails_free(e>>>0,1)),Nt=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,je.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,je.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_convertdetails_free(t,0);}bit_spans_encoding(){try{let r=c.__wbindgen_add_to_stack_pointer(-16);c.convertdetails_bit_spans_encoding(r,this.__wbg_ptr);var t=F().getInt32(r+0,!0),n=F().getInt32(r+4,!0);let o;return t!==0&&(o=H(t,n).slice(),c.__wbindgen_export_2(t,n*1,1)),o}finally{c.__wbindgen_add_to_stack_pointer(16);}}bit_spans(){try{let r=c.__wbindgen_add_to_stack_pointer(-16);c.convertdetails_bit_spans(r,this.__wbg_ptr);var t=F().getInt32(r+0,!0),n=F().getInt32(r+4,!0);let o;return t!==0&&(o=Qr(t,n).slice(),c.__wbindgen_export_2(t,n*4,4)),o}finally{c.__wbindgen_add_to_stack_pointer(16);}}take_data(){let t,n;try{let a=c.__wbindgen_add_to_stack_pointer(-16);c.convertdetails_take_data(a,this.__wbg_ptr);var r=F().getInt32(a+0,!0),o=F().getInt32(a+4,!0);return t=r,n=o,H(r,o)}finally{c.__wbindgen_add_to_stack_pointer(16),c.__wbindgen_export_2(t,n,1);}}};async function Zr(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else {let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function De(){let e={};return e.wbg={},e.wbg.__wbindgen_error_new=function(t,n){let r=new Error(H(t,n));return Er(r)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(H(t,n))},e}function We(e,t){return c=e.exports,Je.__wbindgen_wasm_module=t,ut=null,Rt=null,Ft=null,c}function ie(e){if(c!==void 0)return c;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=De();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let n=new WebAssembly.Instance(e,t);return We(n,e)}async function Je(e){if(c!==void 0)return c;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=new URL("bitmark_json_wasm_bg.wasm",import.meta.url));let t=De();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Zr(await e,t);return We(n,r)}var se=Je;var St={version:"7.7.0"};var _e="browser-full",Ut=class extends Error{constructor(){super("wasm not initialised: call init() (or init({ feature: \u2026 })) first"),this.name="NotInitializedError";}},lt=class extends Error{constructor(t){super(t),this.name="RegisterError";}},st=class extends Error{constructor(n){let r=n.map(o=>`${o.kind} at ${o.path}: ${o.message}`);super(`${n.length} patch ${n.length===1?"entry was":"entries were"} skipped:
2
+ `+r.join(`
3
+ `));M(this,"diagnostics");this.name="PatchError",this.diagnostics=n;}},at=class extends Error{constructor(t,n){super(`${t} is not available in the loaded wasm module${n?` (feature: "${n}")`:""}; init({ feature: "full" }) to load it`),this.name="UnsupportedFeatureError";}},Vt,Ne,Me,Ve=new Map;function U(){if(!Vt&&Me&&Me(),!Vt)throw new Ut;return Vt}function pe(e,t){for(let[n,r]of Ve)try{t.register(n,r);}catch(o){throw new lt(o instanceof Error?o.message:String(o))}Vt=t,Ne=e;}function Ue(e,t){Ve.set(e,t);}function nt(){return Ne}function to(e){let t=e.trim();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):e}function eo(e){return e===void 0?"":typeof e=="string"?e.trim():JSON.stringify(e)}function no(e,t,n){if(n){let o=JSON.parse(e.split_bits(t,"utf-8"));return o.map(a=>({view:{format:"bitmark",index:a.index,total:o.length,source:a.source},source:a.source}))}let r=JSON.parse(e.split_json_bits(t));return r.map((o,a)=>({view:{format:"json",index:a,total:r.length,bit:o.bit??{}},source:JSON.stringify([o])}))}function ce(e,t,n){let r=n.mode??"optimized",o=n.outputFormat??"json",a=n.spacesAroundValues??1,s=n.indent??2,i=n.pretty??false,d=n.inputFormat??"auto",u=d==="bitmark"||d!=="json"&&e.is_bitmark(t),g=u?"bitmark":"json";e.transform("","bitmark",o,r,"",false,s,a);let l=no(e,t,u),f=l.length,x=[];for(let k=0;k<f;k++){let{view:v}=l[k];v.index=k,v.total=f;let R=n.preHook?n.preHook(v)||{}:{};x.push(R.drop?null:{patches:R.patches??[],outputFormat:R.outputFormat??o});}let b=eo(n.patch),m;b===""?m=l.map((k,v)=>({source:v,bit:null,patch:[]})):m=JSON.parse(e.resolve_patch_document(t,g,b));let w=[],y=[];for(let k of m)if(k.source!==null){let v=x[k.source];if(!v)continue;w.push({index:k.source,source:l[k.source].source,inputFormat:g,outputFormat:v.outputFormat,mode:r,patchJson:JSON.stringify([...k.patch,...v.patches]),spacesAroundValues:a}),y.push(l[k.source].view);}else if(typeof k.bit=="string"){let v=w.length;w.push({index:v,source:k.bit,inputFormat:"bitmark",outputFormat:o,mode:r,patchJson:JSON.stringify(k.patch),spacesAroundValues:a}),y.push({format:"bitmark",index:v,total:f,source:k.bit});}else {let v=k.bit??{},R=w.length;w.push({index:R,source:JSON.stringify([{bit:v}]),inputFormat:"json",outputFormat:o,mode:r,patchJson:JSON.stringify(k.patch),spacesAroundValues:a}),y.push({format:"json",index:R,total:f,bit:v});}return {jobs:w,views:y,output:o,pretty:i,indent:s}}function ro(e,t){let{data:n,diagnostics:r}=JSON.parse(e);return {element:t==="json"?to(n):n,diagnostics:r}}function oo(e,t){return ro(e.transform(t.source,t.inputFormat,t.outputFormat,t.mode,t.patchJson,false,2,t.spacesAroundValues),t.outputFormat)}function de(e,t,n,r,o){if(n!=="json")return t.join(`
4
+ `);let a=`[${t.join(",")}]`;return r?e.prettify(a,o):a}function He(e,t,n){let r=ce(e,t,n),o=[],a=[];for(let s=0;s<r.jobs.length;s++){let{element:i,diagnostics:d}=oo(e,r.jobs[s]);a.push(...d),n.postHook?.(r.views[s],i),o.push(i);}if(a.length>0)throw new st(a);return de(e,o,r.output,r.pretty,r.indent)}async function Ge(e,t,n,r){let o=ce(e,t,n),a=await r(o.jobs,n.workers??4),s=[],i=[];for(let d=0;d<a.length;d++)s.push(a[d].element),i.push(...a[d].diagnostics),n.postHook?.(o.views[d],a[d].element);if(i.length>0)throw new st(i);return de(e,s,o.output,o.pretty,o.indent)}var ue;function ze(e){ue=e;}function G(){if(!ue)throw new Error("legacy API not initialised: the WASM module has not been provided (browser consumers must call init() first)");return ue()}function $e(e,t,n){if(e.length===0)return Promise.resolve([]);let r=Math.max(1,Math.min(t,e.length));return new Promise((o,a)=>{let s=new Array(e.length),i=0,d=0,u=false,g=[],l=x=>{if(!u){u=true;for(let b of g)b.terminate();x?a(x):o(s);}},f=x=>{if(u||i>=e.length)return;let b=i++;x.post({id:b,job:e[b]});};for(let x=0;x<r;x++){let b=n(m=>{if(!u){if(!m.ok)return l(new Error(m.error??"worker job failed"));s[m.id]={element:m.element,diagnostics:m.diagnostics??[]},++d===e.length?l():f(b);}},l);g.push(b);}for(let x of g)f(x);})}function Ke(e,t,n){let r=new URL("./worker-entry.js",import.meta.url);return $e(e,t,(o,a)=>{let s=new Worker(r,{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:n}),terminate:()=>s.terminate()}})}var vn={};Pt(vn,{Ast:()=>_n,BitType:()=>rn,BitmarkFileGenerator:()=>dn,BitmarkGenerator:()=>pn,BitmarkParser:()=>mn,BitmarkParserGenerator:()=>Yt,BitmarkParserType:()=>bo,BitmarkStringGenerator:()=>cn,BitmarkVersion:()=>lo,BodyTextFormat:()=>xo,BoundingBoxIndex:()=>an,Builder:()=>qt,CardSetVersion:()=>fo,FileWriter:()=>yn,HtmlTableGenerator:()=>fn,HtmlTableParser:()=>bn,InfoFormat:()=>wo,InfoType:()=>mo,Input:()=>co,InputFormat:()=>go,JsonFileGenerator:()=>ln,JsonGenerator:()=>un,JsonParser:()=>wn,JsonStringGenerator:()=>gn,LegacyUnsupportedError:()=>ft,NodeType:()=>sn,Output:()=>uo,ResourceBuilder:()=>Xt,StreamWriter:()=>kn,StringWriter:()=>xn,TextLocation:()=>yo,TextMarkType:()=>en,TextNodeType:()=>nn,bitmarkTextParse:()=>Ze,isPseudoAst:()=>Ye});var ft=class extends Error{constructor(t){super(t),this.name="LegacyUnsupportedError";}};function pt(e,t){throw new ft(`'${e}' is not supported by the @gmb/bitmark-parser legacy API`+(t?`: ${t}`:""))}function et(e,t){throw new ft(`Option '${e}' is not supported by the @gmb/bitmark-parser legacy API`+(t?`: ${t}`:""))}var ge="bitmark v2 output is not supported (this parser is bitmark v3 only)";function le(e){e.bitmarkVersion===2&&et("bitmarkVersion: 2",ge);}function Gt(e){e.explicitTextFormat&&et("bitmarkOptions.explicitTextFormat"),e.cardSetVersion===1&&et("bitmarkOptions.cardSetVersion: 1",ge),e.debugGenerationInline&&et("bitmarkOptions.debugGenerationInline"),e.noBreakscaping&&et("bitmarkOptions.noBreakscaping");}function zt(e){e.textAsPlainText&&et("jsonOptions.textAsPlainText",ge),e.debugGenerationInline&&et("jsonOptions.debugGenerationInline");}function gt(e){return e===true?{pretty:true,indent:2}:typeof e=="number"&&e>0?{pretty:true,indent:e}:{pretty:false,indent:2}}function $t(e){return e===void 0||e===true?1:e===false?0:Math.max(0,Math.min(10,e))}function Kt(e){switch(e){case "text":case "latex":case "json":case "xml":return "plainText";default:return "bitmark++"}}var qe=Symbol.for("@gmb/bitmark-parser/legacy-pseudo-ast");function bt(e){let t={bits:e};return Object.defineProperty(t,qe,{value:true,enumerable:false}),t}function Ye(e){return e!==null&&typeof e=="object"&&(qe in e||Array.isArray(e.bits))}var Xe={"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 fe=Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser"),so={bitType:"type",textFormat:"format",flashcards:"cards",markConfig:"marks"},ao={"bitmark--":"bitmark++","bitmark+":"bitmark++"},_o={bitmark:"bitmark++",text:"text",json:"json",latex:"latex",xml:"xml"},po=["title","subtitle","item","lead","pageNumber","marginNumber","hint","instruction","caption"],qt=class{buildBitmark(t){let n=bt(t.bits??[]);return t.errors!==void 0&&(n.errors=t.errors),n}buildBit(t,n){let r=G(),o={...t},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 d=o.textFormat;d!==void 0?(i.format=ao[d]??d,delete o.textFormat):i.format=_o[s.bodyFormat??""]??"bitmark++",delete o.resourceType;let u=o.body;u!=null&&typeof u=="object"&&"body"in u&&(i.body=u.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 w=Array.isArray(g)?g:[g],y=Xe[a];y?i[y.key]=w.filter(k=>k!==null&&typeof k=="object"&&k.type===y.resourceType):w.length>=1&&(i.resource=w[0]),delete o.resources;}let l=o.parser;delete o.parser;let f=o.extraProperties;delete o.extraProperties;for(let[w,y]of Object.entries(o))y!==void 0&&(i[so[w]??w]=y);if(f)for(let[w,y]of Object.entries(f))w in i||(i[w]=y);this.parseStringTexts(i);let x=r.convert(JSON.stringify([{bit:i}]),"json","json","optimized",false,2,1,false,false,"",""),m=JSON.parse(x)[0]?.bit??i;for(let[w,y]of Object.entries(i))w in m||y===false||y===""||y===null||Array.isArray(y)&&y.length===0||(m[w]=y);return l!==void 0&&Object.defineProperty(m,fe,{value:l,enumerable:false}),m}buildHighlight(t,n){if(!n)return;let r={...n},o=r.attrs;return o&&Object.assign(r,o),{type:"highlight",texts:Array.isArray(r.texts)?r.texts.filter(i=>i!=null).map(i=>({text:i.text??"",isCorrect:i.isCorrect??false,isHighlighted:i.isHighlighted??false,...Qe(i,["text","isCorrect","isHighlighted"])})):[],prefix:r.prefix??"",postfix:r.postfix??"",...Qe(r,["type","texts","prefix","postfix","attrs"]),attrs:{}}}parseStringTexts(t){let n=G(),r=(s,i)=>{if(s==="")return s;let d=n.convert_text(s,"textToAst","bitmark++",i);try{return JSON.parse(d)}catch{return s}},o=t.format,a=o===void 0||o==="bitmark++"||o==="bitmark+";if(typeof t.body=="string")if(o==="json")try{t.body=JSON.parse(t.body);}catch{t.body=null;}else a&&(t.body=r(t.body,"body"));for(let s of po){let i=t[s];typeof i=="string"&&(t[s]=r(i,"tag"));}}getBitConfig(t){let n=G();if(t!==void 0)try{let r=JSON.parse(n.info("bit","json",t,!1,2,!1,!1,!0,""));if(r.error===void 0)return {bodyFormat:r.body?.format}}catch{}throw new Error(`No config found for bit: ${t}`)}};function Qe(e,t){let n={};for(let[r,o]of Object.entries(e))o!==void 0&&!t.includes(r)&&(n[r]=o);return n}var Yt=class{version(){return St.version}convert(t,n){let r=Object.assign({},n),o=Object.assign({},r.jsonOptions),a=Object.assign({},r.bitmarkOptions);le(r),Gt(a),zt(o),this.checkBrowserFileWrite(r.outputFile);let s=G(),{source:i,isBitmark:d}=this.resolveInput(t,r.inputFormat),u=r.outputFormat??(d?"json":"bitmark"),g=u==="ast"?"json":u,{pretty:l,indent:f}=gt(o.prettify),x=g==="bitmark"?gt(a.prettifyJson):{pretty:l,indent:f},b=$t(a.spacesAroundValues),m=!o.excludeUnknownProperties,w=s.convert(i,d?"bitmark":"json",g,"optimized",x.pretty,x.indent,b,m,false,"","");if(u==="bitmark"||u==="text")return this.deliver(w,r.outputFile,r.fileOptions);if(u==="json")return r.outputFile?this.deliver(w,r.outputFile,r.fileOptions):l||o.stringify?w:JSON.parse(w);let y=bt(JSON.parse(w));return r.outputFile?this.deliver(JSON.stringify(y),r.outputFile,r.fileOptions):y}upgrade(t,n){let r=Object.assign({},n),o=Object.assign({},r.jsonOptions),a=Object.assign({},r.bitmarkOptions);le(r),Gt(a),zt(o),this.checkBrowserFileWrite(r.outputFile);let s=G(),{source:i,isBitmark:d}=this.resolveInput(t,r.inputFormat),{pretty:u,indent:g}=gt(d?a.prettifyJson:o.prettify),l=$t(a.spacesAroundValues),f=s.canonicalize(i,d?"bitmark":"json","optimized",u,g,l);return d?this.deliver(f,r.outputFile,r.fileOptions):r.outputFile?this.deliver(f,r.outputFile,r.fileOptions):u||o.stringify?f:JSON.parse(f)}info(t){let n=Object.assign({},t),r=G(),o=n.type??"list",a=n.outputFormat??"text",{pretty:s,indent:i}=gt(n.prettify),d=a==="pojo"?"json":a,u=r.info(o,d,n.bit??"",s,i,false,false,true,"");return a==="pojo"?JSON.parse(u):u}generateConfig(t){pt("BitmarkParserGenerator.generateConfig","bpg-internal development tool");}convertHtmlTable(t,n){let r=Object.assign({},n),o=Object.assign({},r.jsonOptions),a=Object.assign({},r.bitmarkOptions);Gt(a),zt(o),r.keepUnknownTags&&et("keepUnknownTags"),r.noBreakscaping&&et("noBreakscaping"),this.checkBrowserFileWrite(r.outputFile);let s=G(),i=typeof t=="string"?this.maybeReadFile(t,void 0):"";if(!(r.inputFormat==="html"||r.inputFormat===void 0&&typeof t=="string"&&/<table[\s>]/iu.test(i))){let{source:k,isBitmark:v}=this.resolveInput(t,void 0),R=s.convert(k,v?"bitmark":"json","html","optimized",false,2,1,false,false,"","");return this.deliver(be(R).join(`
5
+ `),r.outputFile,r.fileOptions)}let u=r.tableFormat==="table"?"table":"table-extended",g=be(i).map(k=>`<bitmark-bit data-type="${u}" data-format="bitmark++">${k}</bitmark-bit>`).join(""),l=r.outputFormat??"bitmark",{pretty:f,indent:x}=gt(o.prettify),b=$t(a.spacesAroundValues);if(l==="html"){let k=s.convert(g,"html","html","optimized",false,2,1,false,false,"","");return this.deliver(be(k).join(`
6
+ `),r.outputFile,r.fileOptions)}let m=l==="ast"?"json":l,w=s.convert(g,"html",m,"optimized",f,x,b,false,false,"","");if(l==="bitmark"||l==="text")return this.deliver(w,r.outputFile,r.fileOptions);if(l==="json")return r.outputFile?this.deliver(w,r.outputFile,r.fileOptions):f||o.stringify?w:JSON.parse(w);let y=bt(JSON.parse(w));return r.outputFile?this.deliver(JSON.stringify(y),r.outputFile,r.fileOptions):y}createAst(t,n){let r=Object.assign({},n),o=G(),{source:a,isBitmark:s}=this.resolveInput(t,r.inputFormat),i=o.convert(a,s?"bitmark":"json","json","optimized",false,2,1,true,false,"","");return bt(JSON.parse(i))}breakscapeText(t,n){if(!t)return t;let r=Object.assign({},n);this.checkBrowserFileWrite(r.outputFile);let o=G(),a=this.maybeReadFile(t,r.inputFormat),s=o.breakscape_text(a,Kt(r.textFormat),r.textLocation??"body");return this.deliver(s,r.outputFile,r.fileOptions)}unbreakscapeText(t,n){if(!t)return t;let r=Object.assign({},n);this.checkBrowserFileWrite(r.outputFile);let o=G(),a=this.maybeReadFile(t,r.inputFormat),s=o.unbreakscape_text(a,Kt(r.textFormat),r.textLocation??"body");return this.deliver(s,r.outputFile,r.fileOptions)}convertText(t,n){let r=Object.assign({},n),o=Object.assign({},r.jsonOptions);this.checkBrowserFileWrite(r.outputFile);let a=G(),s=r.textFormat===void 0||Kt(r.textFormat)==="bitmark++",i=r.textLocation??"body",d,u;if(typeof t=="string"?(d=this.maybeReadFile(t,r.inputFormat),u=this.parseTextAstString(d)):(d=JSON.stringify(t),u=Array.isArray(t)?t:void 0),u!==void 0){let b=s?a.convert_text(JSON.stringify(u),"astToText","bitmark++",i):a.convert_text(JSON.stringify(u),"astToPlainText","plainText",i);return this.deliver(b,r.outputFile,r.fileOptions)}let g=a.convert_text(d,"textToAst",s?"bitmark++":"plainText","body"),{pretty:l,indent:f}=gt(o.prettify),x=l?a.prettify(g,f):g;return r.outputFile?this.deliver(x,r.outputFile,r.fileOptions):l?x:JSON.parse(g)}textAstToPlainText(t,n){return G().convert_text(typeof t=="string"?t:JSON.stringify(t),"astToPlainText","bitmark++","body")}extractPlainText(t,n){let r=n?.inputFormat,o=G();if(r==="plainText")return typeof t=="string"?String(t):"";if(r==="bitmarkText"){let d=o.convert_text(String(t),"textToAst","bitmark++","body");return o.convert_text(d,"astToPlainText","bitmark++","body")}if(typeof t=="string"&&this.parseTextAstString(t)===void 0&&!o.is_bitmark(t)&&!(()=>{try{return JSON.parse(t),!0}catch{return false}})())return this.extractPlainText(t,{inputFormat:"bitmarkText"});let{source:a,isBitmark:s}=this.resolveInput(t,void 0);return o.convert(a,s?"bitmark":"json","text","optimized",false,2,1,false,false,"","")}parseTextAstString(t){let n=t.trim();if(n.startsWith("["))try{let r=JSON.parse(n);if(Array.isArray(r)&&r.every(o=>o!==null&&typeof o=="object"&&"type"in o))return r}catch{}}resolveInput(t,n){if(typeof t!="string"){let a=this.jsonEntries(t);return {source:JSON.stringify(a?a.map(s=>this.toWrapperEntry(s)):t),isBitmark:false}}let r=this.maybeReadFile(t,n);if(G().is_bitmark(r))return {source:r,isBitmark:true};try{let a=JSON.parse(r),s=this.jsonEntries(a);if(s)return {source:JSON.stringify(s.map(i=>this.toWrapperEntry(i))),isBitmark:!1}}catch{return {source:r,isBitmark:true}}return {source:r,isBitmark:false}}jsonEntries(t){if(Array.isArray(t))return t;if(t!==null&&typeof t=="object"){let n=t;if(Array.isArray(n.bits))return n.bits;if("bit"in n)return [n];if(typeof n.type=="string")return [{bit:n}]}}toWrapperEntry(t){if(t!==null&&typeof t=="object"&&"bit"in t)return t;let n={bit:t},r=t?.[fe];return r!==void 0&&(n.parser=r),n}maybeReadFile(t,n){if(n==="string")return t;return t;}checkBrowserFileWrite(t){if(t&&true)throw new Error("Cannot write to file in browser environment")}deliver(t,n,r){if(!n)return t;throw new Error("Cannot write to file in browser environment");}};function be(e){let t=[],n=e.toLowerCase(),r=0;for(;;){let o=n.indexOf("<table",r);if(o===-1)break;let a=0,s=o,i=-1;for(;s<e.length;){let d=n.indexOf("<table",s),u=n.indexOf("</table",s);if(u===-1)break;if(d!==-1&&d<u)a++,s=d+6;else {a--;let g=n.indexOf(">",u);if(s=g===-1?e.length:g+1,a===0){i=s;break}}}if(i===-1)break;t.push(e.slice(o,i)),r=i;}return t}function Ze(e){let t=G().convert_text(e,"textToAst","bitmark++","body");return JSON.parse(t)}var $={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 z(e){return (t,n,r)=>{if(!n)return;let{value:o,...a}=n,s={[e.valueField]:o??""};for(let[i,d]of Object.entries(a))d!==void 0&&(s[i]=d);return {type:e.type,[e.key]:s}}}var tn=Object.fromEntries(Object.values($).map(e=>[e.type,e])),Xt=class{constructor(){M(this,"imageResource",z($.imageResource));M(this,"imageLinkResource",z($.imageLinkResource));M(this,"audioResource",z($.audioResource));M(this,"audioEmbedResource",z($.audioEmbedResource));M(this,"audioLinkResource",z($.audioLinkResource));M(this,"videoResource",z($.videoResource));M(this,"videoEmbedResource",z($.videoEmbedResource));M(this,"videoLinkResource",z($.videoLinkResource));M(this,"stillImageFilmEmbedResource",z($.stillImageFilmEmbedResource));M(this,"stillImageFilmLinkResource",z($.stillImageFilmLinkResource));M(this,"articleResource",z($.articleResource));M(this,"documentResource",z($.documentResource));M(this,"documentEmbedResource",z($.documentEmbedResource));M(this,"documentLinkResource",z($.documentLinkResource));M(this,"documentDownloadResource",z($.documentDownloadResource));M(this,"appLinkResource",z($.appLinkResource));M(this,"websiteLinkResource",z($.websiteLinkResource));}resourceFromResourceJson(t,n){if(!n)return;let r=!Array.isArray(n),o=r?[n]:n,a=[];for(let s of o){let i=tn[s.type];if(!i)continue;let d=s[i.key]??{},{[i.valueField]:u,...g}=d,l=z(i)(void 0,{value:u,...g});l&&a.push(l);}if(a.length!==0)return r?a[0]:a}resourceFromResourceDataJson(t,n,r){if(!r)return;let o=tn[n];if(!o)return;let a=typeof r=="string"?r:void 0,s=typeof r=="object"?r:{},{url:i,src:d,body:u,...g}=s,l=i??d??u??a;return z(o)(t,{value:l,...g})}};var co={string:"string",file:"file"},uo={bitmark:"bitmark",json:"json",ast:"ast",text:"text"},go={bitmark:"bitmark",bitmarkText:"bitmarkText",plainText:"plainText",html:"html"},lo={v2:2,v3:3},fo={v1:1,v2:2},bo={peggy:"peggy"},mo={list:"list",deprecated:"deprecated",all:"all",bit:"bit"},wo={text:"text",json:"json",pojo:"pojo"},xo={plainText:"text",latex:"latex",json:"json",xml:"xml",bitmarkPlusPlus:"bitmark++"},yo={tag:"tag",body:"body",cardBody:"cardBody"};var en={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"},nn={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 ko(e){return e.replace(/-([a-z0-9])/gu,(t,n)=>n.toUpperCase())}var me;function Bt(){if(!me){let e=G(),t=JSON.parse(e.info("all","json","",false,2,true,false,false,"")),n={_standard:"_standard"};for(let{name:r}of t)n[ko(r)]=r;me=n;}return me}var rn=new Proxy({},{get:(e,t)=>typeof t=="string"?Bt()[t]:void 0,has:(e,t)=>typeof t=="string"&&t in Bt(),ownKeys:()=>Reflect.ownKeys(Bt()),getOwnPropertyDescriptor:(e,t)=>typeof t=="string"&&t in Bt()?{value:Bt()[t],enumerable:true,configurable:true,writable:false}:void 0});function on(e,t){return new Proxy({},{get:(n,r)=>r===Symbol.toPrimitive||r==="toString"||r===Symbol.toStringTag?()=>`[unsupported ${e}]`:pt(e,t),has:()=>pt(e,t),ownKeys:()=>pt(e,t)})}var sn=on("NodeType","it names bpg's internal AST nodes; the legacy AST is bit JSON (see createAst)"),an=on("BoundingBoxIndex","bpg-internal bounding-box utility");function q(e,t){return class{constructor(){pt(e,t);}}}var vo="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",_n=q("Ast",vo),pn=q("BitmarkGenerator",Q),cn=q("BitmarkStringGenerator",Q),dn=q("BitmarkFileGenerator",Q),un=q("JsonGenerator",Q),gn=q("JsonStringGenerator",Q),ln=q("JsonFileGenerator",Q),fn=q("HtmlTableGenerator",Q),bn=q("HtmlTableParser",Q),mn=q("BitmarkParser",Q),wn=q("JsonParser",Q),xn=q("StringWriter",Q),yn=q("FileWriter",Q),kn=q("StreamWriter",Q);var hn={Error:1,Warning:2,Information:3,Hint:4},In={Class:7,Property:10,Value:12,Keyword:14,Snippet:15,EnumMember:20,TypeParameter:25},On={Deprecated:1};function ho(e,t,n){return n===void 0?{path:e,op:t}:{path:e,op:t,value:n}}var Io="all";function Oo(e,t={}){let n=U().convert(e,"bitmark","json",t.mode??"optimized",false,2,1,t.includeUnknownProperties??false,false,"","");return JSON.parse(n)}function To(e,t={}){let n=e.map(o=>o!==null&&typeof o=="object"&&"bit"in o&&typeof o.bit=="object"?o:{bit:o});return U().convert(JSON.stringify(n),"json","bitmark",t.mode??"optimized",false,2,1,false,false,"","")}function we(e,t={}){return U().convert(e,t.inputFormat??"auto",t.outputFormat??"auto",t.mode??"optimized",t.pretty??false,t.indent??2,t.spacesAroundValues??1,t.includeUnknownProperties??false,t.mappingReport??false,t.positionEncoding??"",t.tokensLayout??"")}function Fo(e,t={}){let n=U().convert_with_details(e,t.inputFormat??"auto",t.outputFormat??"auto",t.mode??"optimized",t.pretty??false,t.indent??2,t.spacesAroundValues??1,t.includeUnknownProperties??false,t.mappingReport??false,t.positionEncoding??"",t.tokensLayout??"",t.bitSpans??false);try{let r={output:n.take_data()},o=n.bit_spans();if(o!==void 0){let a=new Array(o.length/3);for(let s=0,i=0;i<o.length;s++,i+=3)a[s]={index:o[i],start:o[i+1],end:o[i+2]};r.bitSpans={positionEncoding:n.bit_spans_encoding(),spans:a};}return r}finally{n.free();}}function Ro(e,t={}){return JSON.parse(we(e,{inputFormat:"bitmark",outputFormat:"semantic-tokens",positionEncoding:t.positionEncoding,tokensLayout:t.tokensLayout}))}function Eo(e,t={}){return JSON.parse(we(e,{inputFormat:"bitmark",outputFormat:"diagnostics",positionEncoding:t.positionEncoding}))}function So(e,t,n={}){let r=U();if(typeof r.complete!="function")throw new at("complete",nt());return JSON.parse(r.complete(e,t.line,t.character,n.positionEncoding??"",n.includeDeprecated??false,n.triggerCharacter??""))}function Bo(e,t,n,r={}){let o=U();if(typeof o.resolve!="function")throw new at("resolve",nt());return JSON.parse(o.resolve(e,t.line,t.character,r.positionEncoding??"",r.includeDeprecated??false,n.label,n.kind))??n}function Po(e,t,n={}){let r=U();if(typeof r.hover!="function")throw new at("hover",nt());return JSON.parse(r.hover(e,t.line,t.character,n.positionEncoding??""))}function Ao(e,t={}){return U().canonicalize(e,t.inputFormat??"auto",t.mode??"optimized",t.pretty??false,t.indent??2,t.spacesAroundValues??1)}function jo(e){return Number.parseInt(U().count_bits(e),10)}function Lo(e,t={}){return JSON.parse(U().split_bits(e,t.positionEncoding??""))}function Co(e,t={}){let n=U();if(t.preHook||t.postHook)return He(n,e,t);let r=t.patch===void 0?"":typeof t.patch=="string"?t.patch:JSON.stringify(t.patch),{data:o,diagnostics:a}=JSON.parse(n.transform(e,t.inputFormat??"auto",t.outputFormat??"json",t.mode??"optimized",r,t.pretty??false,t.indent??2,t.spacesAroundValues??1));if(a.length>0)throw new st(a);return o}function Tn(e,t,n={}){let r=U();if(typeof r.diff!="function")throw new at("diff",nt());return r.diff(e,t,n.inputFormat??"auto",n.outputFormat??"bitmark",n.context??3,n.locate??false,n.similarity??.6,n.bboxTolerance??8,n.spacesAroundValues??0)}function Do(e,t,n={}){return JSON.parse(Tn(e,t,{...n,outputFormat:"json"}))}function Wo(e,t={}){let n=t.format??"bitmark++",r=t.location??"body",o=t.subLocation??"text";return U().breakscape_text(e,n,r,o)}function Jo(e,t={}){let n=t.format??"bitmark++",r=t.location??"body",o=t.subLocation??"text";return U().unbreakscape_text(e,n,r,o)}function Mo(e={}){let t=e.infoType??"list",n=e.format??"text",r=e.bit??"",o=e.pretty??false,a=e.indent??2,s=e.includeDeprecated??false,i=e.onlyDeprecated??false,d=e.full??false,u=typeof e.language=="string"?e.language:e.language?.join(",")??"",g=U();if(n!=="json"&&typeof g.info_text_supported!="function")throw new at('info (format: "text")',nt());return g.info(t,n,r,o,a,s,i,d,u)}function No(e){try{U().register(e.type,e.data);}catch(t){throw new lt(t instanceof Error?t.message:String(t))}Ue(e.type,e.data);}var Vo="./wasm/",Fn={full:{init:te,initSync:Zt,ns:ee,wasmFile:"bitmark_wasm_bg.wasm"},"browser-full":{init:re,initSync:ne,ns:oe,wasmFile:"bitmark_browser_full_wasm_bg.wasm"},"bitmark-json":{init:se,initSync:ie,ns:ae,wasmFile:"bitmark_json_wasm_bg.wasm"}};ze(()=>U());function xe(e){return e===void 0?_e:"full"}function Uo(e){if(e===null||typeof e!="object")return false;if("feature"in e||"module_or_path"in e)return true;let t=Object.getPrototypeOf(e);return (t===Object.prototype||t===null)&&Object.keys(e).length===0}function Ho(e){if(Uo(e))return {feature:e.feature??xe(e.module_or_path),module_or_path:e.module_or_path};let t=e??void 0;return {feature:xe(t),module_or_path:t}}var ye=0,Qt,_t;async function ks(e){let{feature:t,module_or_path:n}=Ho(e);if(n===void 0){if(!_t&&nt()===t)return Qt;if(_t?.feature===t)return _t.promise}let r=++ye,o=Fn[t],a=n??new URL(`${Vo}${o.wasmFile}?v=${St.version}`,import.meta.url),s=(async()=>{try{let i=await o.init({module_or_path:a});r===ye&&(pe(t,o.ns),Qt=i);}finally{_t?.seq===r&&(_t=void 0);}for(;_t;)await _t.promise.catch(()=>{});return Qt})();return _t={feature:t,seq:r,promise:s},s}function vs(e,t={}){let n=t.feature??xe(e),r=Fn[n],o=r.initSync({module:e});return ++ye,_t=void 0,pe(n,r.ns),Qt=o,o}function hs(){return St.version}function Is(e,t={}){let n=U(),r=nt()??_e;return Ge(n,e,t,(o,a)=>Ke(o,a,r))}export{Io as ALL_LANGUAGES,In as CompletionItemKind,On as CompletionItemTag,hn as DiagnosticSeverity,Ut as NotInitializedError,st as PatchError,lt as RegisterError,at as UnsupportedFeatureError,Oo as bitmarkToObjects,Wo as breakscapeText,Ao as canonicalize,So as complete,we as convert,Fo as convertWithDetails,jo as countBits,Eo as diagnostics,Tn as diff,Do as diffBits,Po as hover,Mo as info,ks as init,vs as initSync,vn as legacy,To as objectsToBitmark,ho as patchEntry,No as register,Bo as resolve,Ro as semanticTokens,Lo as splitBits,Co as transform,Is as transformParallel,Jo as unbreakscapeText,nt as variant,hs as version};//# sourceMappingURL=bitmark-parser.min.js.map
7
7
  //# sourceMappingURL=bitmark-parser.min.js.map