@keeratita/heic-converter 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -134,6 +134,25 @@ const jpegBlob = await convertHeic(heicBlob, {
134
134
  });
135
135
  ```
136
136
 
137
+ #### Files you must serve
138
+
139
+ `dist/` is no longer a single file. The JS is code-split, so a hand-hosted deploy (copying files into an assets folder or a CDN, with no bundler rewriting specifiers) needs **all** of these, under the chunk names the build produced:
140
+
141
+ | File | Needed for |
142
+ | --- | --- |
143
+ | `index.mjs` / `index.js` | the entry (ESM / CJS) |
144
+ | `chunk-*.mjs` / `chunk-*.js` | the eagerly imported shared code |
145
+ | `heic-decoder-*.mjs` / `heic-decoder-*.js` | the Emscripten glue, fetched on first decode |
146
+ | `heic-decoder.wasm` (+ `.gz` / `.br`) | the decoder binary |
147
+ | `worker-*.mjs` / `worker-*.js` | `convertHeicInWorker` / `convertManyInWorker` |
148
+ | `exif-*.mjs` / `exif-*.js` | `preserveExif: true` |
149
+
150
+ - Chunk names are **content-hashed and hard-referenced by the entry**, so a partial upload — or a `dist/` mixed across releases — 404s instead of degrading quietly. Deploy the whole directory per release.
151
+ - Serve chunks as `text/javascript`. A wrong MIME type surfaces as `worker_load_failed` from the worker APIs, and as `preserveExif` silently dropping metadata (it warns once).
152
+ - `heic-decoder.wasm` and the glue chunk come from **one** `emcc` invocation and are ABI-coupled. If you host the binary separately (`locateFile`, an artifact mirror, an immutable `/assets/heic-decoder.wasm`), re-upload *and* cache-bust it together with the glue, or instantiation fails with `decoder_init_failed`.
153
+
154
+ A bundler handles all of this: the dynamic imports are literal specifiers, so your bundler rewrites and emits the chunks for you.
155
+
137
156
  #### Using a bundler (Vite, webpack, Rollup, esbuild)
138
157
 
139
158
  The main entry is a small lazy loader: the Emscripten glue ships as a dynamic-import chunk and the `.wasm` binary is **not** inlined — you must make sure `dist/heic-decoder.wasm` is served and resolvable at runtime. Bundlers that rewrite asset URLs usually handle this automatically because the glue resolves the binary relative to its own chunk. If yours doesn't, copy the binary into your assets (the `@keeratita/heic-converter/wasm` subpath export resolves to the file itself, handy as a copy source) and point the decoder at it:
@@ -153,9 +172,9 @@ Fetching a `.gz`/`.br` variant URL directly will not work — see the compressio
153
172
 
154
173
  #### Reducing the download size
155
174
 
156
- The WASM binary (~1.3 MB) dominates the payload. Everything else is small and lazy: the Emscripten glue (~70 KB) is a separate chunk fetched only on the first decode, and the main entry is ~26 KB.
175
+ The WASM binary (~794 KB, ~288 KB gzipped) dominates the payload; everything else is small and lazy. The Emscripten glue is a separate chunk fetched only on the first decode, and the Web Worker implementation and the opt-in EXIF injectors are separate chunks fetched only when you first call `convertHeicInWorker`/`convertManyInWorker` or pass `preserveExif: true`. What every consumer pays for up front is a few kilobytes of gzipped JavaScript — `test/unit/bundle.test.ts` fails the build if one of those boundaries moves or the eager budget grows, so the numbers live in the tests rather than here.
157
176
 
158
- `npm run build` also emits pre-compressed copies — `dist/heic-decoder.wasm.gz` (~421 KB) and `dist/heic-decoder.wasm.br` (~312 KB). Most static hosts and CDNs (GitHub Pages, Netlify, Vercel, Cloudflare) already compress `application/wasm` automatically when the browser sends `Accept-Encoding`; verify with:
177
+ `npm run build` also emits pre-compressed copies — `dist/heic-decoder.wasm.gz` (~288 KB) and `dist/heic-decoder.wasm.br` (~230 KB) — and verifies each one decompresses back to the binary, so a corrupt sidecar cannot reach a CDN. Most static hosts and CDNs (GitHub Pages, Netlify, Vercel, Cloudflare) already compress `application/wasm` automatically when the browser sends `Accept-Encoding`; verify with:
159
178
 
160
179
  ```bash
161
180
  curl -sI -H 'Accept-Encoding: br' https://your-site/heic-decoder.wasm | grep -i content-encoding
@@ -163,7 +182,7 @@ curl -sI -H 'Accept-Encoding: br' https://your-site/heic-decoder.wasm | grep -i
163
182
 
164
183
  If your server does not compress automatically, serve the pre-compressed files with the matching `Content-Encoding` header (nginx: `gzip_static on;` / `brotli_static on;`). Do **not** point `locateFile` at a `.br`/`.gz` URL — the browser only decompresses responses tagged with `Content-Encoding`.
165
184
 
166
- For long-lived caching, serve the WASM with `Cache-Control: public, max-age=31536000, immutable` and rename it per release (e.g. `heic-decoder-1.2.3.wasm` via `locateFile`) so clients pick up upgrades. GitHub Pages caps asset cache lifetime at 600s; put a CDN in front if that matters.
185
+ For long-lived caching, serve the WASM with `Cache-Control: public, max-age=31536000, immutable` and rename it per release (e.g. `heic-decoder-1.2.3.wasm` via `locateFile`) so clients pick up upgrades — and treat the binary and its glue chunk as one unit when you do, per the note above. GitHub Pages caps asset cache lifetime at 600s; put a CDN in front if that matters.
167
186
 
168
187
  ### 5. Node.js: Decoding Raw Pixel Data
169
188
 
@@ -475,6 +494,14 @@ Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval
475
494
  > [!NOTE]
476
495
  > `'wasm-unsafe-eval'` is a CSP Level 3 directive that allows compiling and executing WebAssembly modules without opening the security risks of general JavaScript `'unsafe-eval'`.
477
496
 
497
+ Two additions to that header are easy to miss:
498
+
499
+ - **Serving the WASM from another origin** (`locateFile` pointing at a CDN) needs that origin in `connect-src` — the glue downloads the binary with `fetch()`/`XMLHttpRequest`, so `connect-src 'self'` blocks it and you get `decoder_init_failed` blaming the binary itself:
500
+ ```http
501
+ Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; connect-src 'self' https://cdn.example.com; img-src 'self' blob: data:;
502
+ ```
503
+ - **The worker helpers** are real `Worker` scripts, so they follow `worker-src` (falling back to `script-src`). With `workerUrl` on your own origin, `worker-src 'self'` is enough; if your bundler inlines the worker as a blob URL, use `worker-src 'self' blob:`. A CSP-blocked worker surfaces as the generic `worker_failed`.
504
+
478
505
  ---
479
506
 
480
507
  ## 📖 API Reference
@@ -494,7 +521,7 @@ Converts a HEIC image file to a standard web format.
494
521
  - `scale`: `number` (Uniform scale factor, e.g. `0.5` halves the image. Takes precedence over `maxWidth`/`maxHeight`)
495
522
  - `applyOrientation`: `boolean` (Rotate/flip the output to match the source's EXIF orientation. `irot`/`imir` transforms are already applied by the decoder and never stacked. Default: `true`)
496
523
  - `crop`: `{ x?, y?, width, height }` (Cut a rectangle in post-orientation display pixels before resize. Default: none)
497
- - `preserveExif`: `boolean` (Re-inject the source EXIF block into JPEG (APP1) / PNG (`eXIf`) output. Metadata may contain GPS — opt-in. Default: `false`)
524
+ - `preserveExif`: `boolean` (Re-inject the source EXIF block into JPEG (APP1) / PNG (`eXIf`) output. Metadata may contain GPS — opt-in. Default: `false`. Fail-safe: unparsable encoder output, a malformed block, or an oversized payload returns the image without metadata rather than failing — as does a missing `dist/exif-*.mjs` chunk, which logs a one-time warning so a deployment problem is distinguishable from a file that simply had no Exif item)
498
525
  - `output`: `'blob' | 'dataUrl' | 'arrayBuffer'` (Result representation. Default: `'blob'`; see [Usage section 10](#10-output-shapes-blob-data-url-arraybuffer))
499
526
  - `signal`: `AbortSignal` (Cancel pending work; rejects with `aborted`. Default: none)
500
527
  - **Returns**: `Promise<Blob>` — or `Promise<string>` / `Promise<ArrayBuffer>` with the typed `output` overloads
@@ -572,10 +599,11 @@ All errors thrown by this library are `HeicConverterError` instances (`extends E
572
599
  | `worker_post_failed` | `convertHeicInWorker`, `convertManyInWorker` | `postMessage` threw (non-cloneable option) |
573
600
  | `worker_timeout` | `convertHeicInWorker`, `convertManyInWorker` | No result within `timeoutMs`; message includes progress/protocol diagnostics |
574
601
  | `worker_failed` | `convertHeicInWorker`, `convertManyInWorker` | Worker reported `{ type: 'result', ok: false, error }` |
575
-
576
- Option validation for **all four** conversion APIs runs on the main thread before any worker is created, so a bad option always keeps its own code. Stage errors raised *inside* a worker (decode, render, unsupported format) come back stringified under `worker_failed` — the numeric `code` does not survive the worker boundary; match on the message instead.
602
+ | `worker_load_failed` | `convertHeicInWorker`, `convertManyInWorker` | The lazily imported worker chunk (`dist/worker-*.mjs`) could not be fetched — deploy every file in `dist/` together, check your bundler emitted the chunk, and inspect `error.cause`; use `convertHeic` to convert in the current thread |
577
603
  | `batch_item_failed` | `convertMany`, `convertManyInWorker` | One or more items failed; see `itemIndex`/`itemTotal`/`failedCount`/`cause` |
578
604
 
605
+ Option validation for **all four** conversion APIs runs on the main thread before any worker is created, so a bad option keeps its own code. One ordering note: `convertHeicInWorker`/`convertManyInWorker` resolve the worker chunk before the implementation runs, so when that chunk itself cannot be fetched the rejection is `worker_load_failed` regardless of other option problems — the original failure stays on `cause`. Stage errors raised *inside* a worker (decode, render, unsupported format) come back stringified under `worker_failed` — the numeric `code` does not survive the worker boundary; match on the message instead.
606
+
579
607
  ```typescript
580
608
  import { convertHeic, type HeicConverterErrorCode } from '@keeratita/heic-converter';
581
609
 
@@ -617,7 +645,14 @@ To compile the underlying [`libheif`](https://github.com/strukturag/libheif) and
617
645
  npm run build:wasm
618
646
  ```
619
647
 
620
- See [WASM_DEPENDENCIES.md](WASM_DEPENDENCIES.md) for the pinned upstream library versions.
648
+ That rewrites **both** generated artifacts together — `src/wasm/public/heic-decoder.wasm` and `src/wasm/wrapper/heic-decoder.js` come from a single `emcc` invocation, so never replace one alone — and you must then refresh the pinned hashes or CI's verification step fails:
649
+
650
+ ```bash
651
+ npm run wasm:hashes # regenerates build-scripts/wasm-artifacts.json — commit it with the artifacts
652
+ npm run verify:wasm # confirms the committed pair matches, and scans the glue for eval/new Function
653
+ ```
654
+
655
+ Never hand-edit either generated file. See [WASM_DEPENDENCIES.md](WASM_DEPENDENCIES.md) for the pinned upstream library versions.
621
656
 
622
657
  ### Build JS & TS Typings
623
658
 
@@ -629,8 +664,12 @@ npm run build
629
664
 
630
665
  ### Run Unit Tests
631
666
 
667
+ Build first: the suites that decode real HEIC files gate on `dist/heic-decoder.wasm` (a stale `dist/` is detected and reported rather than silently passing).
668
+
632
669
  ```bash
670
+ npm run build
633
671
  npm run test
672
+ npm run typecheck # tsc over src/ *and* test/ — tests are excluded from tsconfig.json
634
673
  ```
635
674
 
636
675
  ### Run Browser E2E Tests
@@ -674,6 +713,37 @@ This script will automatically run the linter, build the TS library, run the uni
674
713
 
675
714
  ---
676
715
 
716
+ ## 🛡️ Supply Chain & Trust
717
+
718
+ | Property | Status |
719
+ | -------- | ------ |
720
+ | Runtime dependencies | **none** — the package ships no `dependencies` at all |
721
+ | Provenance | SLSA provenance attestation, from OIDC trusted publishing in `.github/workflows/publish.yml` |
722
+ | Install-time code | two dev-tree packages — `esbuild` (links its platform binary) and `fsevents` (macOS-only native addon) — pinned in an allowlist that CI enforces (`npm run check:scripts`) |
723
+ | `eval()` / `new Function()` | never generated (`-s DYNAMIC_EXECUTION=0`); CI scans the emitted glue for both |
724
+ | Decoder artifacts | committed WASM + glue pinned to SHA-256 and re-verified on every CI run (`npm run verify:wasm`) |
725
+ | Publish path | tag pushes only; the job asserts the attestation landed (`npm run verify:provenance`) |
726
+
727
+ After installing, you can verify the attestation yourself in your own project:
728
+
729
+ ```bash
730
+ npm audit signatures
731
+ ```
732
+
733
+ ### Scanner signals you will see
734
+
735
+ Automated scanners report three signals on this package. All three are expected; they are documented here rather than engineered around:
736
+
737
+ | Signal | What it actually is |
738
+ | ------ | ------------------- |
739
+ | **Network access** | The generated Emscripten glue calls `fetch()` / `XMLHttpRequest` to download `dist/heic-decoder.wasm` (~800 KB). That download is how a browser gets the decoder. Nothing else in the package touches the network — `src/` contains no `fetch`, `XMLHttpRequest`, or socket code. |
740
+ | **URL strings** | The literal `http://www.w3.org/2000/svg`, the XML namespace on the root element of SVG output. It is a format identifier and is never fetched. |
741
+ | **Minified code** | `dist/` is Terser-minified deliberately (~6% smaller gzipped, more on the glue). The published bytes come from the tagged commit through CI, with provenance attached. |
742
+
743
+ If one of these ever becomes actually exploitable rather than merely noisy, that is a bug — see [SECURITY.md](SECURITY.md).
744
+
745
+ ---
746
+
677
747
  ## 📄 License
678
748
 
679
749
  MIT © Keerati Tansawatcharoen
@@ -0,0 +1 @@
1
+ var e={QualityInvalid:e=>`Quality must be a number between 0.0 and 1.0, got: ${e}`,ApplyOrientationInvalid:e=>`applyOrientation must be a boolean, got: ${e}`,UnsupportedInputType:e=>`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${e}`,DecoderInitFailed:e=>`Failed to initialize HEIC decoder: ${e} — verify heic-decoder.wasm is served (dist/heic-decoder.wasm; see the README "Serving and Locating WASM" section / locateFile option) and that your CSP allows 'wasm-unsafe-eval'`,WorkerChunkLoadFailed:e=>`Failed to load the Web Worker implementation chunk (dist/worker-*.mjs): ${e} — deploy every file in dist/ together, or use convertHeic to convert in the current thread`,RenderEncodeFailed:(e,t)=>`Failed to render and encode image as ${e}: ${t}`,ConcurrencyInvalid:e=>`Concurrency must be a positive integer, got: ${e}`,InputsMustBeArray:"Inputs must be an array of HEIC images",OutputShapeInvalid:e=>`output must be one of 'blob', 'dataUrl', 'arrayBuffer', got: ${e}`,ReuseDecodersInvalid:e=>`reuseDecoders must be a boolean, got: ${e}`,ContinueOnErrorInvalid:e=>`continueOnError must be a boolean, got: ${e}`,PreserveExifInvalid:e=>`preserveExif must be a boolean, got: ${e}`,SignalInvalid:e=>`signal must be an AbortSignal, got: ${e}`,Aborted:"Conversion aborted (AbortSignal was aborted)",ConvertManyItemFailed:(e,t,n)=>`Conversion of item ${e} of ${t} failed: ${n}`,ConvertManyExtraFailures:(e,t)=>` (${e} of ${t} items failed in total)`,ConvertManyOtherErrors:e=>`; other errors: ${e.join(" | ")}`,BatchItemProducedNoResult:e=>`Item ${String(e)} produced no result`,BatchEndedWithoutResult:"Batch ended without a result",ScaleInvalid:e=>`Scale must be a positive finite number, got: ${e}`,MaxWidthInvalid:e=>`maxWidth must be a positive finite number, got: ${e}`,MaxHeightInvalid:e=>`maxHeight must be a positive finite number, got: ${e}`,TargetSizeTooLarge:(e,t,n)=>`Target image size ${e}x${t} exceeds the maximum supported dimension of ${n}px`,BlobToBase64Failed:"Failed to convert Blob to base64 string",BlobToBase64FailedWithCause:e=>`Failed to convert Blob to base64 string: ${e}`,CanvasToBlobFailed:e=>`Failed to convert canvas to blob (type: ${e})`,CanvasUnsupported:"Canvas is not supported in the current environment. In a browser this requires OffscreenCanvas or HTMLCanvasElement. In Node.js there is no canvas: decode raw RGBA with LibheifDecoder and encode externally (see the Node.js section of the README).",InvalidDimensions:(e,t)=>`Invalid image dimensions: ${e}x${t}. Width and height must be positive integers.`,DataLengthMismatch:(e,t,n,i)=>`Image data length mismatch. Expected ${e} bytes for ${t}x${n}, got ${i}`,ContextUnavailable:"Failed to acquire 2D rendering context from canvas",UnsupportedFormat:e=>`Unsupported output format: ${e}`,FormatUnsupported:e=>`The current environment cannot encode '${e}' — canvas encoding produced no '${e}' image (e.g. AVIF encoding is not supported in this browser). Try 'jpeg', 'png', or 'webp' instead.`,CropInvalid:(e,t)=>`crop.${e} must be ${"width"===e||"height"===e?"a positive integer":"a non-negative integer"}, got: ${t}`,CropOutOfBounds:(e,t,n,i,o,r)=>`crop ${n}x${i} at (${e}, ${t}) exceeds the ${o}x${r} image (crop coordinates are in post-orientation display pixels)`,DecoderFreedDuringDecode:"Decoder was freed before decoding completed; call initialize() again.",DecodeInputAllocFailed:e=>`Failed to allocate ${e} bytes in the WASM heap for decode input`,DecodeFailed:e=>`HEIC decoding failed (no result returned; input: ${e} bytes — is the file truncated or empty?)`,DecodeFailedWithDetail:(e,t)=>`HEIC decoding failed: ${e} (input: ${t} bytes)`,DecodeFaulted:e=>`Decoder faulted on a ${e}-byte image (out of memory, or a corrupted WebAssembly instance); retry — a faulted pooled decoder is discarded, not reused`,ProgressCallbackThrew:e=>`onProgress callback threw during decode: ${e}`},t=class extends Error{code;itemIndex;itemTotal;failedCount;constructor(e,t,n){super(t,{cause:n?.cause}),this.name="HeicConverterError",this.code=e,void 0!==n?.itemIndex&&(this.itemIndex=n.itemIndex),void 0!==n?.itemTotal&&(this.itemTotal=n.itemTotal),void 0!==n?.failedCount&&(this.failedCount=n.failedCount)}},n=["jpeg","jpg","png","svg","webp","avif"];function i(n){if(void 0!==n&&"boolean"!=typeof n)throw new t("invalid_input",e.ContinueOnErrorInvalid(n))}function o(i){const o=String(i).toLowerCase();if(!n.includes(o))throw new t("invalid_format",e.UnsupportedFormat(String(i)))}function r(n){if(!n)return;const{maxWidth:i,maxHeight:o,scale:r}=n;if(void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<=0))throw new t("invalid_resize",e.ScaleInvalid(r));if(void 0!==i&&("number"!=typeof i||!Number.isFinite(i)||i<=0))throw new t("invalid_resize",e.MaxWidthInvalid(i));if(void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<=0))throw new t("invalid_resize",e.MaxHeightInvalid(o))}function a(n){if(!n)return;const{x:i=0,y:o=0,width:r,height:a}=n;if(!Number.isInteger(r)||r<=0)throw new t("invalid_crop",e.CropInvalid("width",r));if(!Number.isInteger(a)||a<=0)throw new t("invalid_crop",e.CropInvalid("height",a));if(!Number.isInteger(i)||i<0)throw new t("invalid_crop",e.CropInvalid("x",i));if(!Number.isInteger(o)||o<0)throw new t("invalid_crop",e.CropInvalid("y",o))}function d(e,t){return Math.min(e,t)}exports.DEFAULT_QUALITY=.92,exports.HeicConverterError=t,exports.Messages=e,exports.SUPPORTED_FORMATS=n,exports.clampPercent=function(e){const t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0},exports.runBoundedBatch=async function(n,i,o,r){const a=!0===r?.continueOnError,s=r?.signal,l=new Array(n.length);let u=0,c=!1,p=0,v=null,h=-1,f=0;const m=[];let g;const b=new Promise(e=>{g=e}),w=()=>g?.();s&&!a&&s.addEventListener("abort",w,{once:!0});const y=d(i,n.length),x=Array.from({length:y},()=>(async()=>{for(;!c&&!s?.aborted||a;){const i=u;if(u+=1,i>=n.length)return;if(a&&s?.aborted){const o=new t("aborted",e.Aborted);for(let e=i;e<n.length;e++)l[e]={index:e,ok:!1,error:o};return void(u=n.length)}try{const e=await o(n[i],i);l[i]={index:i,ok:!0,result:e},p+=1}catch(e){if(f+=1,a){l[i]={index:i,ok:!1,error:e instanceof Error?e:new Error(String(e))};continue}c?m.length<2&&m.push(e instanceof Error?e.message:String(e)):(c=!0,v=e,h=i,g?.())}}})());try{if(a)return await Promise.all(x),l;if(await Promise.race([Promise.all(x),b]),p===n.length)return l.map(n=>{if(!n||!n.ok)throw new t("batch_item_failed",e.BatchItemProducedNoResult(n?.index));return n.result});if(s?.aborted)throw new t("aborted",e.Aborted);if(c){const i=v instanceof Error?v.message:String(v);let o=e.ConvertManyItemFailed(h+1,n.length,i);throw f>1&&(o+=e.ConvertManyExtraFailures(f,n.length),m.length>0&&(o+=e.ConvertManyOtherErrors(m))),new t("batch_item_failed",o,{cause:v,itemIndex:h,itemTotal:n.length,failedCount:f})}throw new t("batch_item_failed",e.BatchEndedWithoutResult)}finally{s?.removeEventListener("abort",w)}},exports.runnerCountFor=d,exports.throwIfAborted=function(n){if(n?.aborted)throw new t("aborted",e.Aborted)},exports.validateBatchOptions=function(n){i(n?.continueOnError),function(n){if(void 0!==n&&"boolean"!=typeof n)throw new t("invalid_input",e.ReuseDecodersInvalid(n))}(n?.reuseDecoders)},exports.validateConcurrency=function(n){if(!Number.isInteger(n)||n<1)throw new t("invalid_concurrency",e.ConcurrencyInvalid(n))},exports.validateContinueOnError=i,exports.validateConvertOptions=function(n){o(n?.to??"jpeg"),void 0!==n?.quality&&function(n){if("number"!=typeof n||!Number.isFinite(n)||n<0||n>1)throw new t("invalid_quality",e.QualityInvalid(n))}(n.quality),function(n){if(void 0!==n&&"boolean"!=typeof n)throw new t("invalid_input",e.ApplyOrientationInvalid(n))}(n?.applyOrientation),function(n){if(void 0!==n&&"blob"!==n&&"dataUrl"!==n&&"arrayBuffer"!==n)throw new t("invalid_input",e.OutputShapeInvalid(n))}(n?.output),function(n){if(void 0!==n&&("object"!=typeof n||null===n||"function"!=typeof n.addEventListener))throw new t("invalid_input",e.SignalInvalid(n))}(n?.signal),a(n?.crop),function(n){if(void 0!==n&&"boolean"!=typeof n)throw new t("invalid_input",e.PreserveExifInvalid(n))}(n?.preserveExif),r(void 0!==n?.maxWidth||void 0!==n?.maxHeight||void 0!==n?.scale?n:void 0)},exports.validateCrop=a,exports.validateFormat=o,exports.validateResize=r;
@@ -0,0 +1 @@
1
+ var e={QualityInvalid:e=>`Quality must be a number between 0.0 and 1.0, got: ${e}`,ApplyOrientationInvalid:e=>`applyOrientation must be a boolean, got: ${e}`,UnsupportedInputType:e=>`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${e}`,DecoderInitFailed:e=>`Failed to initialize HEIC decoder: ${e} — verify heic-decoder.wasm is served (dist/heic-decoder.wasm; see the README "Serving and Locating WASM" section / locateFile option) and that your CSP allows 'wasm-unsafe-eval'`,WorkerChunkLoadFailed:e=>`Failed to load the Web Worker implementation chunk (dist/worker-*.mjs): ${e} — deploy every file in dist/ together, or use convertHeic to convert in the current thread`,RenderEncodeFailed:(e,t)=>`Failed to render and encode image as ${e}: ${t}`,ConcurrencyInvalid:e=>`Concurrency must be a positive integer, got: ${e}`,InputsMustBeArray:"Inputs must be an array of HEIC images",OutputShapeInvalid:e=>`output must be one of 'blob', 'dataUrl', 'arrayBuffer', got: ${e}`,ReuseDecodersInvalid:e=>`reuseDecoders must be a boolean, got: ${e}`,ContinueOnErrorInvalid:e=>`continueOnError must be a boolean, got: ${e}`,PreserveExifInvalid:e=>`preserveExif must be a boolean, got: ${e}`,SignalInvalid:e=>`signal must be an AbortSignal, got: ${e}`,Aborted:"Conversion aborted (AbortSignal was aborted)",ConvertManyItemFailed:(e,t,n)=>`Conversion of item ${e} of ${t} failed: ${n}`,ConvertManyExtraFailures:(e,t)=>` (${e} of ${t} items failed in total)`,ConvertManyOtherErrors:e=>`; other errors: ${e.join(" | ")}`,BatchItemProducedNoResult:e=>`Item ${String(e)} produced no result`,BatchEndedWithoutResult:"Batch ended without a result",ScaleInvalid:e=>`Scale must be a positive finite number, got: ${e}`,MaxWidthInvalid:e=>`maxWidth must be a positive finite number, got: ${e}`,MaxHeightInvalid:e=>`maxHeight must be a positive finite number, got: ${e}`,TargetSizeTooLarge:(e,t,n)=>`Target image size ${e}x${t} exceeds the maximum supported dimension of ${n}px`,BlobToBase64Failed:"Failed to convert Blob to base64 string",BlobToBase64FailedWithCause:e=>`Failed to convert Blob to base64 string: ${e}`,CanvasToBlobFailed:e=>`Failed to convert canvas to blob (type: ${e})`,CanvasUnsupported:"Canvas is not supported in the current environment. In a browser this requires OffscreenCanvas or HTMLCanvasElement. In Node.js there is no canvas: decode raw RGBA with LibheifDecoder and encode externally (see the Node.js section of the README).",InvalidDimensions:(e,t)=>`Invalid image dimensions: ${e}x${t}. Width and height must be positive integers.`,DataLengthMismatch:(e,t,n,i)=>`Image data length mismatch. Expected ${e} bytes for ${t}x${n}, got ${i}`,ContextUnavailable:"Failed to acquire 2D rendering context from canvas",UnsupportedFormat:e=>`Unsupported output format: ${e}`,FormatUnsupported:e=>`The current environment cannot encode '${e}' — canvas encoding produced no '${e}' image (e.g. AVIF encoding is not supported in this browser). Try 'jpeg', 'png', or 'webp' instead.`,CropInvalid:(e,t)=>`crop.${e} must be ${"width"===e||"height"===e?"a positive integer":"a non-negative integer"}, got: ${t}`,CropOutOfBounds:(e,t,n,i,o,r)=>`crop ${n}x${i} at (${e}, ${t}) exceeds the ${o}x${r} image (crop coordinates are in post-orientation display pixels)`,DecoderFreedDuringDecode:"Decoder was freed before decoding completed; call initialize() again.",DecodeInputAllocFailed:e=>`Failed to allocate ${e} bytes in the WASM heap for decode input`,DecodeFailed:e=>`HEIC decoding failed (no result returned; input: ${e} bytes — is the file truncated or empty?)`,DecodeFailedWithDetail:(e,t)=>`HEIC decoding failed: ${e} (input: ${t} bytes)`,DecodeFaulted:e=>`Decoder faulted on a ${e}-byte image (out of memory, or a corrupted WebAssembly instance); retry — a faulted pooled decoder is discarded, not reused`,ProgressCallbackThrew:e=>`onProgress callback threw during decode: ${e}`};function t(e){const t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}var n=class extends Error{code;itemIndex;itemTotal;failedCount;constructor(e,t,n){super(t,{cause:n?.cause}),this.name="HeicConverterError",this.code=e,void 0!==n?.itemIndex&&(this.itemIndex=n.itemIndex),void 0!==n?.itemTotal&&(this.itemTotal=n.itemTotal),void 0!==n?.failedCount&&(this.failedCount=n.failedCount)}},i=["jpeg","jpg","png","svg","webp","avif"],o=.92;function r(t){u(t?.to??"jpeg"),void 0!==t?.quality&&function(t){if("number"!=typeof t||!Number.isFinite(t)||t<0||t>1)throw new n("invalid_quality",e.QualityInvalid(t))}(t.quality),function(t){if(void 0!==t&&"boolean"!=typeof t)throw new n("invalid_input",e.ApplyOrientationInvalid(t))}(t?.applyOrientation),function(t){if(void 0!==t&&"blob"!==t&&"dataUrl"!==t&&"arrayBuffer"!==t)throw new n("invalid_input",e.OutputShapeInvalid(t))}(t?.output),function(t){if(void 0!==t&&("object"!=typeof t||null===t||"function"!=typeof t.addEventListener))throw new n("invalid_input",e.SignalInvalid(t))}(t?.signal),f(t?.crop),function(t){if(void 0!==t&&"boolean"!=typeof t)throw new n("invalid_input",e.PreserveExifInvalid(t))}(t?.preserveExif),c(void 0!==t?.maxWidth||void 0!==t?.maxHeight||void 0!==t?.scale?t:void 0)}function a(t){s(t?.continueOnError),function(t){if(void 0!==t&&"boolean"!=typeof t)throw new n("invalid_input",e.ReuseDecodersInvalid(t))}(t?.reuseDecoders)}function d(t){if(!Number.isInteger(t)||t<1)throw new n("invalid_concurrency",e.ConcurrencyInvalid(t))}function s(t){if(void 0!==t&&"boolean"!=typeof t)throw new n("invalid_input",e.ContinueOnErrorInvalid(t))}function l(t){if(t?.aborted)throw new n("aborted",e.Aborted)}function u(t){const o=String(t).toLowerCase();if(!i.includes(o))throw new n("invalid_format",e.UnsupportedFormat(String(t)))}function c(t){if(!t)return;const{maxWidth:i,maxHeight:o,scale:r}=t;if(void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<=0))throw new n("invalid_resize",e.ScaleInvalid(r));if(void 0!==i&&("number"!=typeof i||!Number.isFinite(i)||i<=0))throw new n("invalid_resize",e.MaxWidthInvalid(i));if(void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<=0))throw new n("invalid_resize",e.MaxHeightInvalid(o))}function f(t){if(!t)return;const{x:i=0,y:o=0,width:r,height:a}=t;if(!Number.isInteger(r)||r<=0)throw new n("invalid_crop",e.CropInvalid("width",r));if(!Number.isInteger(a)||a<=0)throw new n("invalid_crop",e.CropInvalid("height",a));if(!Number.isInteger(i)||i<0)throw new n("invalid_crop",e.CropInvalid("x",i));if(!Number.isInteger(o)||o<0)throw new n("invalid_crop",e.CropInvalid("y",o))}function h(e,t){return Math.min(e,t)}async function v(t,i,o,r){const a=!0===r?.continueOnError,d=r?.signal,s=new Array(t.length);let l=0,u=!1,c=0,f=null,v=-1,p=0;const m=[];let g;const b=new Promise(e=>{g=e}),w=()=>g?.();d&&!a&&d.addEventListener("abort",w,{once:!0});const y=h(i,t.length),I=Array.from({length:y},()=>(async()=>{for(;!u&&!d?.aborted||a;){const i=l;if(l+=1,i>=t.length)return;if(a&&d?.aborted){const o=new n("aborted",e.Aborted);for(let e=i;e<t.length;e++)s[e]={index:e,ok:!1,error:o};return void(l=t.length)}try{const e=await o(t[i],i);s[i]={index:i,ok:!0,result:e},c+=1}catch(e){if(p+=1,a){s[i]={index:i,ok:!1,error:e instanceof Error?e:new Error(String(e))};continue}u?m.length<2&&m.push(e instanceof Error?e.message:String(e)):(u=!0,f=e,v=i,g?.())}}})());try{if(a)return await Promise.all(I),s;if(await Promise.race([Promise.all(I),b]),c===t.length)return s.map(t=>{if(!t||!t.ok)throw new n("batch_item_failed",e.BatchItemProducedNoResult(t?.index));return t.result});if(d?.aborted)throw new n("aborted",e.Aborted);if(u){const i=f instanceof Error?f.message:String(f);let o=e.ConvertManyItemFailed(v+1,t.length,i);throw p>1&&(o+=e.ConvertManyExtraFailures(p,t.length),m.length>0&&(o+=e.ConvertManyOtherErrors(m))),new n("batch_item_failed",o,{cause:f,itemIndex:v,itemTotal:t.length,failedCount:p})}throw new n("batch_item_failed",e.BatchEndedWithoutResult)}finally{d?.removeEventListener("abort",w)}}export{o as DEFAULT_QUALITY,n as HeicConverterError,e as Messages,i as SUPPORTED_FORMATS,t as clampPercent,v as runBoundedBatch,h as runnerCountFor,l as throwIfAborted,a as validateBatchOptions,d as validateConcurrency,s as validateContinueOnError,r as validateConvertOptions,f as validateCrop,u as validateFormat,c as validateResize};
@@ -0,0 +1 @@
1
+ var t,n=new Uint8Array([69,120,105,102,0,0]),r=new Uint8Array([137,80,78,71,13,10,26,10]);function e(t){if(t.length<n.length+8)return!1;for(let r=0;r<n.length;r++)if(t[r]!==n[r])return!1;return function(t,n){if(n+8>t.length)return!1;const r=73===t[n]&&73===t[n+1],e=77===t[n]&&77===t[n+1];return!(!r&&!e)&&42==(r?t[n+2]|t[n+3]<<8:t[n+2]<<8|t[n+3])}(t,n.length)}function u(t,n){return t[n]<<8|t[n+1]}function i(t,n){return(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0}function l(t,n,r){return t[n]===r.charCodeAt(0)&&t[n+1]===r.charCodeAt(1)&&t[n+2]===r.charCodeAt(2)&&t[n+3]===r.charCodeAt(3)}exports.injectExifIntoJpeg=function(t,n){try{if(t.length<4||255!==t[0]||216!==t[1])return t;if(!e(n))return t;const r=n.length+2;if(r>65535)return t;let i=2;for(;i<t.length;){if(i+4>t.length)return t;if(255!==t[i])return t;const n=t[i+1];if(255===n){i+=1;continue}if(!(n>=224&&n<=239||254===n))break;const r=u(t,i+2);if(r<2||i+2+r>t.length)return t;i+=2+r}const l=new Uint8Array(t.length+4+n.length);return l.set(t.subarray(0,i),0),l[i]=255,l[i+1]=225,l[i+2]=r>>8&255,l[i+3]=255&r,l.set(n,i+4),l.set(t.subarray(i),i+4+n.length),l}catch{return t}},exports.injectExifIntoPng=function(u,o){try{if(u.length<33)return u;for(let t=0;t<r.length;t++)if(u[t]!==r[t])return u;if(13!==i(u,8)||!l(u,12,"IHDR"))return u;if(!e(o))return u;const f=o.subarray(n.length);let h=33;for(;h+8<=u.length;){const t=i(u,h);if(t>u.length||h+12+t>u.length)return u;if(l(u,h+4,"IDAT")||l(u,h+4,"IEND"))break;if(l(u,h+4,"eXIf"))return u;h+=12+t}const c=new Uint8Array(12+f.length);c[0]=f.length>>>24&255,c[1]=f.length>>>16&255,c[2]=f.length>>>8&255,c[3]=255&f.length,c.set([101,88,73,102],4),c.set(f,8);const g=function(n){const r=function(){if(!t){t=new Uint32Array(256);for(let n=0;n<256;n++){let r=n;for(let t=0;t<8;t++)r=1&r?3988292384^r>>>1:r>>>1;t[n]=r>>>0}}return t}();let e=4294967295;for(let t=0;t<n.length;t++)e=r[255&(e^n[t])]^e>>>8;return(4294967295^e)>>>0}(c.subarray(4,8+f.length));c[8+f.length]=g>>>24&255,c[9+f.length]=g>>>16&255,c[10+f.length]=g>>>8&255,c[11+f.length]=255&g;const s=new Uint8Array(u.length+c.length);return s.set(u.subarray(0,h),0),s.set(c,h),s.set(u.subarray(h),h+c.length),s}catch{return u}},exports.normalizeOrientationTag=function(t){try{if(!e(t))return t;const r=n.length,u=73===t[r],i=n=>u?t[n]|t[n+1]<<8:t[n]<<8|t[n+1],l=n=>u?(t[n+3]<<24|t[n+2]<<16|t[n+1]<<8|t[n])>>>0:(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0,o=l(r+4);if(o<8||r+o+2>t.length)return t;const f=r+o,h=i(f);for(let n=0;n<h;n++){const r=f+2+12*n;if(r+12>t.length)return t;if(274!==i(r))continue;const e=i(r+2),o=l(r+4);if(3!==e||1!==o)return t;if(1==(u?t[r+8]|t[r+9]<<8:t[r+8]<<8|t[r+9]))return t;const h=t.slice();return h[r+8]=u?1:0,h[r+9]=u?0:1,h[r+10]=0,h[r+11]=0,h}return t}catch{return t}};
@@ -0,0 +1 @@
1
+ var t,n=new Uint8Array([69,120,105,102,0,0]),r=new Uint8Array([137,80,78,71,13,10,26,10]);function e(t){if(t.length<n.length+8)return!1;for(let r=0;r<n.length;r++)if(t[r]!==n[r])return!1;return function(t,n){if(n+8>t.length)return!1;const r=73===t[n]&&73===t[n+1],e=77===t[n]&&77===t[n+1];return!(!r&&!e)&&42==(r?t[n+2]|t[n+3]<<8:t[n+2]<<8|t[n+3])}(t,n.length)}function u(t,n){return t[n]<<8|t[n+1]}function l(t,n){return(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0}function f(t){try{if(!e(t))return t;const r=n.length,u=73===t[r],l=n=>u?t[n]|t[n+1]<<8:t[n]<<8|t[n+1],f=n=>u?(t[n+3]<<24|t[n+2]<<16|t[n+1]<<8|t[n])>>>0:(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0,i=f(r+4);if(i<8||r+i+2>t.length)return t;const h=r+i,o=l(h);for(let n=0;n<o;n++){const r=h+2+12*n;if(r+12>t.length)return t;if(274!==l(r))continue;const e=l(r+2),i=f(r+4);if(3!==e||1!==i)return t;if(1==(u?t[r+8]|t[r+9]<<8:t[r+8]<<8|t[r+9]))return t;const o=t.slice();return o[r+8]=u?1:0,o[r+9]=u?0:1,o[r+10]=0,o[r+11]=0,o}return t}catch{return t}}function i(t,n){try{if(t.length<4||255!==t[0]||216!==t[1])return t;if(!e(n))return t;const r=n.length+2;if(r>65535)return t;let l=2;for(;l<t.length;){if(l+4>t.length)return t;if(255!==t[l])return t;const n=t[l+1];if(255===n){l+=1;continue}if(!(n>=224&&n<=239||254===n))break;const r=u(t,l+2);if(r<2||l+2+r>t.length)return t;l+=2+r}const f=new Uint8Array(t.length+4+n.length);return f.set(t.subarray(0,l),0),f[l]=255,f[l+1]=225,f[l+2]=r>>8&255,f[l+3]=255&r,f.set(n,l+4),f.set(t.subarray(l),l+4+n.length),f}catch{return t}}function h(t,n,r){return t[n]===r.charCodeAt(0)&&t[n+1]===r.charCodeAt(1)&&t[n+2]===r.charCodeAt(2)&&t[n+3]===r.charCodeAt(3)}function o(u,f){try{if(u.length<33)return u;for(let t=0;t<r.length;t++)if(u[t]!==r[t])return u;if(13!==l(u,8)||!h(u,12,"IHDR"))return u;if(!e(f))return u;const i=f.subarray(n.length);let o=33;for(;o+8<=u.length;){const t=l(u,o);if(t>u.length||o+12+t>u.length)return u;if(h(u,o+4,"IDAT")||h(u,o+4,"IEND"))break;if(h(u,o+4,"eXIf"))return u;o+=12+t}const c=new Uint8Array(12+i.length);c[0]=i.length>>>24&255,c[1]=i.length>>>16&255,c[2]=i.length>>>8&255,c[3]=255&i.length,c.set([101,88,73,102],4),c.set(i,8);const g=function(n){const r=function(){if(!t){t=new Uint32Array(256);for(let n=0;n<256;n++){let r=n;for(let t=0;t<8;t++)r=1&r?3988292384^r>>>1:r>>>1;t[n]=r>>>0}}return t}();let e=4294967295;for(let t=0;t<n.length;t++)e=r[255&(e^n[t])]^e>>>8;return(4294967295^e)>>>0}(c.subarray(4,8+i.length));c[8+i.length]=g>>>24&255,c[9+i.length]=g>>>16&255,c[10+i.length]=g>>>8&255,c[11+i.length]=255&g;const s=new Uint8Array(u.length+c.length);return s.set(u.subarray(0,o),0),s.set(c,o),s.set(u.subarray(o),o+c.length),s}catch{return u}}export{i as injectExifIntoJpeg,o as injectExifIntoPng,f as normalizeOrientationTag};
@@ -0,0 +1 @@
1
+ var t,r=(t=import.meta.url,async function(r={}){var e,n,a=r;a.ready=new Promise((t,r)=>{e=t,n=r});var i,o,s=Object.assign({},a),u="./this.program",l="object"==typeof window,c="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";if(h){const{createRequire:t}=await(import("module"));var d=t(import.meta.url),p=d("fs"),y=d("path");f=c?y.dirname(f)+"/":d("url").fileURLToPath(new URL("./",import.meta.url)),i=(t,r)=>(t=V(t)?new URL(t):y.normalize(t),p.readFileSync(t,r?void 0:"utf8")),o=t=>{var r=i(t,!0);return r.buffer||(r=new Uint8Array(r)),r},!a.thisProgram&&process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(l||c)&&(c?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),t&&(f=t),f=f.startsWith("blob:")?"":f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1),i=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(null),r.responseText},c&&(o=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}));var v,m,g=a.print||console.log.bind(console),$=a.printErr||console.error.bind(console);Object.assign(a,s),s=null,a.arguments&&a.arguments,a.thisProgram&&(u=a.thisProgram),a.quit&&a.quit,a.wasmBinary&&(v=a.wasmBinary);var w,b,_,C,P,T,A,j,F=!1;function S(){var t=m.buffer;a.HEAP8=w=new Int8Array(t),a.HEAP16=_=new Int16Array(t),a.HEAPU8=b=new Uint8Array(t),a.HEAPU16=C=new Uint16Array(t),a.HEAP32=P=new Int32Array(t),a.HEAPU32=T=new Uint32Array(t),a.HEAPF32=A=new Float32Array(t),a.HEAPF64=j=new Float64Array(t)}var O=[],E=[],D=[];function W(t){O.unshift(t)}function R(t){D.unshift(t)}var k=0,M=null;function x(t){a.onAbort?.(t),$(t="Aborted("+t+")"),F=!0,t+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(t);throw n(r),r}var H,U,I=t=>t.startsWith("data:application/octet-stream;base64,"),V=t=>t.startsWith("file://");function Y(t){if(t==H&&v)return new Uint8Array(v);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}function L(t,r,e){return function(t){return v||!l&&!c||"function"!=typeof fetch?Promise.resolve().then(()=>Y(t)):fetch(t,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at '${t}'`;return r.arrayBuffer()}).catch(()=>Y(t))}(t).then(t=>WebAssembly.instantiate(t,r)).then(e,t=>{$(`failed to asynchronously prepare wasm: ${t}`),x(t)})}a.locateFile?I(H="heic-decoder.wasm")||(U=H,H=a.locateFile?a.locateFile(U,f):f+U):H=new URL("heic-decoder.wasm",import.meta.url).href;var z=t=>{for(;t.length>0;)t.shift()(a)};a.noExitRuntime;var B="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,G=(t,r,e)=>{for(var n=r+e,a=r;t[a]&&!(a>=n);)++a;if(a-r>16&&t.buffer&&B)return B.decode(t.subarray(r,a));for(var i="";r<a;){var o=t[r++];if(128&o){var s=63&t[r++];if(192!=(224&o)){var u=63&t[r++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&t[r++])<65536)i+=String.fromCharCode(o);else{var l=o-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&o)<<6|s)}else i+=String.fromCharCode(o)}return i},q=(t,r)=>t?G(b,t,r):"",N=[],J=0,X=0;class Z{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){T[this.ptr+4>>2]=t}get_type(){return T[this.ptr+4>>2]}set_destructor(t){T[this.ptr+8>>2]=t}get_destructor(){return T[this.ptr+8>>2]}set_caught(t){t=t?1:0,w[this.ptr+12]=t}get_caught(){return 0!=w[this.ptr+12]}set_rethrown(t){t=t?1:0,w[this.ptr+13]=t}get_rethrown(){return 0!=w[this.ptr+13]}init(t,r){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(r)}set_adjusted_ptr(t){T[this.ptr+16>>2]=t}get_adjusted_ptr(){return T[this.ptr+16>>2]}get_exception_ptr(){if(Wr(this.get_type()))return T[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var K,Q,tt,rt=t=>{var r=X;if(!r)return jr(0),0;var e=new Z(r);e.set_adjusted_ptr(r);var n=e.get_type();if(!n)return jr(0),r;for(var a in t){var i=t[a];if(0===i||i===n)break;var o=e.ptr+16;if(Dr(i,n,o))return jr(i),r}return jr(n),r},et=t=>{for(var r="",e=t;b[e];)r+=K[b[e++]];return r},nt={},at={},it={},ot=t=>{throw new Q(t)},st=t=>{throw new tt(t)},ut=(t,r,e)=>{function n(r){var n=e(r);n.length!==t.length&&st("Mismatched type converter count");for(var a=0;a<t.length;++a)lt(t[a],n[a])}t.forEach(function(t){it[t]=r});var a=new Array(r.length),i=[],o=0;r.forEach((t,r)=>{at.hasOwnProperty(t)?a[r]=at[t]:(i.push(t),nt.hasOwnProperty(t)||(nt[t]=[]),nt[t].push(()=>{a[r]=at[t],++o===i.length&&n(a)}))}),0===i.length&&n(a)};function lt(t,r,e={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(t,r,e={}){var n=r.name;if(t||ot(`type "${n}" must have a positive integer typeid pointer`),at.hasOwnProperty(t)){if(e.ignoreDuplicateRegistrations)return;ot(`Cannot register type '${n}' twice`)}if(at[t]=r,delete it[t],nt.hasOwnProperty(t)){var a=nt[t];delete nt[t],a.forEach(t=>t())}}(t,r,e)}var ct,ht=t=>{ot(t.$$.ptrType.registeredClass.name+" instance already deleted")},ft=!1,dt=t=>{},pt=t=>{t.count.value-=1,0===t.count.value&&(t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)})(t)},yt=(t,r,e)=>{if(r===e)return t;if(void 0===e.baseClass)return null;var n=yt(t,r,e.baseClass);return null===n?null:e.downcast(n)},vt={},mt=[],gt=()=>{for(;mt.length;){var t=mt.pop();t.$$.deleteScheduled=!1,t.delete()}},$t={},wt=(t,r)=>(r.ptrType&&r.ptr||st("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&st("Both smartPtrType and smartPtr must be specified"),r.count={value:1},bt(Object.create(t,{$$:{value:r,writable:!0}}))),bt=t=>"undefined"==typeof FinalizationRegistry?(bt=t=>t,t):(ft=new FinalizationRegistry(t=>{pt(t.$$)}),dt=t=>ft.unregister(t),(bt=t=>{var r=t.$$;if(r.smartPtr){var e={$$:r};ft.register(t,e,t)}return t})(t));function _t(){}var Ct=(t,r)=>Object.defineProperty(r,"name",{value:t}),Pt=(t,r,e)=>{if(void 0===t[r].overloadTable){var n=t[r];t[r]=function(...n){return t[r].overloadTable.hasOwnProperty(n.length)||ot(`Function '${e}' called with an invalid number of arguments (${n.length}) - expects one of (${t[r].overloadTable})!`),t[r].overloadTable[n.length].apply(this,n)},t[r].overloadTable=[],t[r].overloadTable[n.argCount]=n}};function Tt(t,r,e,n,a,i,o,s){this.name=t,this.constructor=r,this.instancePrototype=e,this.rawDestructor=n,this.baseClass=a,this.getActualType=i,this.upcast=o,this.downcast=s,this.pureVirtualFunctions=[]}var At=(t,r,e)=>{for(;r!==e;)r.upcast||ot(`Expected null or instance of ${e.name}, got an instance of ${r.name}`),t=r.upcast(t),r=r.baseClass;return t};function jt(t,r){if(null===r)return this.isReference&&ot(`null is not a valid ${this.name}`),0;r.$$||ot(`Cannot pass "${Jt(r)}" as a ${this.name}`),r.$$.ptr||ot(`Cannot pass deleted object as a pointer of type ${this.name}`);var e=r.$$.ptrType.registeredClass;return At(r.$$.ptr,e,this.registeredClass)}function Ft(t,r){var e;if(null===r)return this.isReference&&ot(`null is not a valid ${this.name}`),this.isSmartPointer?(e=this.rawConstructor(),null!==t&&t.push(this.rawDestructor,e),e):0;r&&r.$$||ot(`Cannot pass "${Jt(r)}" as a ${this.name}`),r.$$.ptr||ot(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&ot(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(e=At(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&ot("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?e=r.$$.smartPtr:ot(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:e=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)e=r.$$.smartPtr;else{var a=r.clone();e=this.rawShare(e,qt.toHandle(()=>a.delete())),null!==t&&t.push(this.rawDestructor,e)}break;default:ot("Unsupporting sharing policy")}return e}function St(t,r){if(null===r)return this.isReference&&ot(`null is not a valid ${this.name}`),0;r.$$||ot(`Cannot pass "${Jt(r)}" as a ${this.name}`),r.$$.ptr||ot(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&ot(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var e=r.$$.ptrType.registeredClass;return At(r.$$.ptr,e,this.registeredClass)}function Ot(t){return this.fromWireType(T[t>>2])}function Et(t,r,e,n,a,i,o,s,u,l,c){this.name=t,this.registeredClass=r,this.isReference=e,this.isConst=n,this.isSmartPointer=a,this.pointeeType=i,this.sharingPolicy=o,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,a||void 0!==r.baseClass?this.toWireType=Ft:n?(this.toWireType=jt,this.destructorFunction=null):(this.toWireType=St,this.destructorFunction=null)}var Dt,Wt,Rt=[],kt=t=>{var r=Rt[t];return r||(t>=Rt.length&&(Rt.length=t+1),Rt[t]=r=Dt.get(t)),r},Mt=(t,r)=>{var e,n,i=(t=et(t)).includes("j")?(e=t,n=r,(...t)=>((t,r,e=[])=>t.includes("j")?((t,r,e)=>(0,a["dynCall_"+t])(r,...e))(t,r,e):kt(r)(...e))(e,n,t)):kt(r);return"function"!=typeof i&&ot(`unknown function pointer with signature ${t}: ${r}`),i},xt=t=>{var r=Tr(t),e=et(r);return Pr(r),e},Ht=(t,r)=>{var e=[],n={};throw r.forEach(function t(r){n[r]||at[r]||(it[r]?it[r].forEach(t):(e.push(r),n[r]=!0))}),new Wt(`${t}: `+e.map(xt).join([", "]))},Ut=(t,r)=>{for(var e=[],n=0;n<t;n++)e.push(T[r+4*n>>2]);return e},It=t=>{for(;t.length;){var r=t.pop();t.pop()(r)}};function Vt(t,r,e,n,a,i){var o=r.length;o<2&&ot("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==r[1]&&null!==e,u=function(t){for(var r=1;r<t.length;++r)if(null!==t[r]&&void 0===t[r].destructorFunction)return!0;return!1}(r),l="void"!==r[0].name,c=o-2,h=new Array(c),f=[],d=[];return Ct(t,function(...e){var i;e.length!==c&&ot(`function ${t} called with ${e.length} arguments, expected ${c}`),d.length=0,f.length=s?2:1,f[0]=a,s&&(i=r[1].toWireType(d,this),f[1]=i);for(var o=0;o<c;++o)h[o]=r[o+2].toWireType(d,e[o]),f.push(h[o]);return function(t){if(u)It(d);else for(var e=s?1:2;e<r.length;e++){var n=1===e?i:h[e-2];null!==r[e].destructorFunction&&r[e].destructorFunction(n)}if(l)return r[0].fromWireType(t)}(n(...f))})}var Yt,Lt,zt=[],Bt=[],Gt=t=>{t>9&&0===--Bt[t+1]&&(Bt[t]=void 0,zt.push(t))},qt={toValue:t=>(t||ot("Cannot use deleted val. handle = "+t),Bt[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const r=zt.pop()||Bt.length;return Bt[r]=t,Bt[r+1]=1,r}}}},Nt={name:"emscripten::val",fromWireType:t=>{var r=qt.toValue(t);return Gt(t),r},toWireType:(t,r)=>qt.toHandle(r),argPackAdvance:8,readValueFromPointer:Ot,destructorFunction:null},Jt=t=>{if(null===t)return"null";var r=typeof t;return"object"===r||"array"===r||"function"===r?t.toString():""+t},Xt=(t,r)=>{switch(r){case 4:return function(t){return this.fromWireType(A[t>>2])};case 8:return function(t){return this.fromWireType(j[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${t}`)}},Zt=(t,r,e)=>{switch(r){case 1:return e?t=>w[t]:t=>b[t];case 2:return e?t=>_[t>>1]:t=>C[t>>1];case 4:return e?t=>P[t>>2]:t=>T[t>>2];default:throw new TypeError(`invalid integer width (${r}): ${t}`)}},Kt=(t,r,e,n)=>{if(!(n>0))return 0;for(var a=e,i=e+n-1,o=0;o<t.length;++o){var s=t.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++o)),s<=127){if(e>=i)break;r[e++]=s}else if(s<=2047){if(e+1>=i)break;r[e++]=192|s>>6,r[e++]=128|63&s}else if(s<=65535){if(e+2>=i)break;r[e++]=224|s>>12,r[e++]=128|s>>6&63,r[e++]=128|63&s}else{if(e+3>=i)break;r[e++]=240|s>>18,r[e++]=128|s>>12&63,r[e++]=128|s>>6&63,r[e++]=128|63&s}}return r[e]=0,e-a},Qt=t=>{for(var r=0,e=0;e<t.length;++e){var n=t.charCodeAt(e);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++e):r+=3}return r},tr="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,rr=(t,r)=>{for(var e=t,n=e>>1,a=n+r/2;!(n>=a)&&C[n];)++n;if((e=n<<1)-t>32&&tr)return tr.decode(b.subarray(t,e));for(var i="",o=0;!(o>=r/2);++o){var s=_[t+2*o>>1];if(0==s)break;i+=String.fromCharCode(s)}return i},er=(t,r,e)=>{if(e??=2147483647,e<2)return 0;for(var n=r,a=(e-=2)<2*t.length?e/2:t.length,i=0;i<a;++i){var o=t.charCodeAt(i);_[r>>1]=o,r+=2}return _[r>>1]=0,r-n},nr=t=>2*t.length,ar=(t,r)=>{for(var e=0,n="";!(e>=r/4);){var a=P[t+4*e>>2];if(0==a)break;if(++e,a>=65536){var i=a-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(a)}return n},ir=(t,r,e)=>{if(e??=2147483647,e<4)return 0;for(var n=r,a=n+e-4,i=0;i<t.length;++i){var o=t.charCodeAt(i);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),P[r>>2]=o,(r+=4)+4>a)break}return P[r>>2]=0,r-n},or=t=>{for(var r=0,e=0;e<t.length;++e){var n=t.charCodeAt(e);n>=55296&&n<=57343&&++e,r+=4}return r},sr=[],ur={},lr=t=>{var r=ur[t];return void 0===r?et(t):r},cr=()=>{if("object"==typeof globalThis)return globalThis;function t(t){t.$$$embind_global$$$=t;var r="object"==typeof $$$embind_global$$$&&t.$$$embind_global$$$==t;return r||delete t.$$$embind_global$$$,r}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&t(global)?$$$embind_global$$$=global:"object"==typeof self&&t(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},hr=(t,r)=>{var e=at[t];return void 0===e&&ot(`${r} has unknown type ${xt(t)}`),e},fr=Reflect.construct,dr=t=>{var r=(t-m.buffer.byteLength+65535)/65536;try{return m.grow(r),S(),1}catch(t){}},pr={},yr=()=>{if(!yr.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:u||"./this.program"};for(var r in pr)void 0===pr[r]?delete t[r]:t[r]=pr[r];var e=[];for(var r in t)e.push(`${r}=${t[r]}`);yr.strings=e}return yr.strings},vr=[null,[],[]],mr=(t,r)=>{var e=vr[t];0===r||10===r?((1===t?g:$)(G(e,0)),e.length=0):e.push(r)},gr=t=>t%4==0&&(t%100!=0||t%400==0),$r=[31,29,31,30,31,30,31,31,30,31,30,31],wr=[31,28,31,30,31,30,31,31,30,31,30,31];(()=>{for(var t=new Array(256),r=0;r<256;++r)t[r]=String.fromCharCode(r);K=t})(),Q=a.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},tt=a.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},Object.assign(_t.prototype,{isAliasOf(t){if(!(this instanceof _t))return!1;if(!(t instanceof _t))return!1;var r=this.$$.ptrType.registeredClass,e=this.$$.ptr;t.$$=t.$$;for(var n=t.$$.ptrType.registeredClass,a=t.$$.ptr;r.baseClass;)e=r.upcast(e),r=r.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return r===n&&e===a},clone(){if(this.$$.ptr||ht(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t,r=bt(Object.create(Object.getPrototypeOf(this),{$$:{value:(t=this.$$,{count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType})}}));return r.$$.count.value+=1,r.$$.deleteScheduled=!1,r},delete(){this.$$.ptr||ht(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ot("Object already scheduled for deletion"),dt(this),pt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||ht(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ot("Object already scheduled for deletion"),mt.push(this),1===mt.length&&ct&&ct(gt),this.$$.deleteScheduled=!0,this}}),a.getInheritedInstanceCount=()=>Object.keys($t).length,a.getLiveInheritedInstances=()=>{var t=[];for(var r in $t)$t.hasOwnProperty(r)&&t.push($t[r]);return t},a.flushPendingDeletes=gt,a.setDelayFunction=t=>{ct=t,mt.length&&ct&&ct(gt)},Object.assign(Et.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){this.rawDestructor?.(t)},argPackAdvance:8,readValueFromPointer:Ot,fromWireType:function(t){var r=this.getPointee(t);if(!r)return this.destructor(t),null;var e=((t,r)=>(r=((t,r)=>{for(void 0===r&&ot("ptr should not be undefined");t.baseClass;)r=t.upcast(r),t=t.baseClass;return r})(t,r),$t[r]))(this.registeredClass,r);if(void 0!==e){if(0===e.$$.count.value)return e.$$.ptr=r,e.$$.smartPtr=t,e.clone();var n=e.clone();return this.destructor(t),n}function a(){return this.isSmartPointer?wt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:t}):wt(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var i,o=this.registeredClass.getActualType(r),s=vt[o];if(!s)return a.call(this);i=this.isConst?s.constPointerType:s.pointerType;var u=yt(r,this.registeredClass,i.registeredClass);return null===u?a.call(this):this.isSmartPointer?wt(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:t}):wt(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}}),Wt=a.UnboundTypeError=(Yt=Error,(Lt=Ct("UnboundTypeError",function(t){this.name="UnboundTypeError",this.message=t;var r=new Error(t).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(Yt.prototype),Lt.prototype.constructor=Lt,Lt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},Lt),Bt.push(0,1,void 0,1,null,1,!0,1,!1,1),a.count_emval_handles=()=>Bt.length/2-5-zt.length;var br={b:(t,r,e,n)=>{x(`Assertion failed: ${q(t)}, at: `+[r?q(r):"unknown filename",e,n?q(n):"unknown function"])},o:t=>{var r=new Z(t);return r.get_caught()||(r.set_caught(!0),J--),r.set_rethrown(!1),N.push(r),Er(r.excPtr),r.get_exception_ptr()},p:()=>{Ar(0,0);var t=N.pop();Or(t.excPtr),X=0},a:()=>rt([]),g:t=>rt([t]),L:()=>{var t=N.pop();t||x("no exception to throw");var r=t.excPtr;throw t.get_rethrown()||(N.push(t),t.set_rethrown(!0),t.set_caught(!1),J++),X=r},q:(t,r,e)=>{throw new Z(t).init(r,e),J++,X=t},$:()=>J,e:t=>{throw X||(X=t),X},ba:(t,r,e)=>{},Y:(t,r,e,n,a)=>{},ia:(t,r,e,n)=>{lt(t,{name:r=et(r),fromWireType:function(t){return!!t},toWireType:function(t,r){return r?e:n},argPackAdvance:8,readValueFromPointer:function(t){return this.fromWireType(b[t])},destructorFunction:null})},T:(t,r,e,n,i,o,s,u,l,c,h,f,d)=>{h=et(h),o=Mt(i,o),u&&=Mt(s,u),c&&=Mt(l,c),d=Mt(f,d);var p=(t=>{if(void 0===t)return"_unknown";var r=(t=t.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?`_${t}`:t})(h);((t,r)=>{a.hasOwnProperty(t)?(ot(`Cannot register public name '${t}' twice`),Pt(a,t,t),a.hasOwnProperty(void 0)&&ot("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),a[t].overloadTable[void 0]=r):a[t]=r})(p,function(){Ht(`Cannot construct ${h} due to unbound types`,[n])}),ut([t,r,e],n?[n]:[],r=>{var e,i;r=r[0],i=n?(e=r.registeredClass).instancePrototype:_t.prototype;var s=Ct(h,function(...t){if(Object.getPrototypeOf(this)!==l)throw new Q("Use 'new' to construct "+h);if(void 0===f.constructor_body)throw new Q(h+" has no accessible constructor");var r=f.constructor_body[t.length];if(void 0===r)throw new Q(`Tried to invoke ctor of ${h} with invalid number of parameters (${t.length}) - expected (${Object.keys(f.constructor_body).toString()}) parameters instead!`);return r.apply(this,t)}),l=Object.create(i,{constructor:{value:s}});s.prototype=l;var f=new Tt(h,s,l,d,e,o,u,c);f.baseClass&&(f.baseClass.__derivedClasses??=[],f.baseClass.__derivedClasses.push(f));var y=new Et(h,f,!0,!1,!1),v=new Et(h+"*",f,!1,!1,!1),m=new Et(h+" const*",f,!1,!0,!1);return vt[t]={pointerType:v,constPointerType:m},((t,r)=>{a.hasOwnProperty(t)||st("Replacing nonexistent public symbol"),a[t].overloadTable,a[t]=r,a[t].argCount=void 0})(p,s),[y,v,m]})},S:(t,r,e,n,a,i)=>{var o=Ut(r,e);a=Mt(n,a),ut([],[t],t=>{var e=`constructor ${(t=t[0]).name}`;if(void 0===t.registeredClass.constructor_body&&(t.registeredClass.constructor_body=[]),void 0!==t.registeredClass.constructor_body[r-1])throw new Q(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${t.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return t.registeredClass.constructor_body[r-1]=()=>{Ht(`Cannot construct ${t.name} due to unbound types`,o)},ut([],o,n=>(n.splice(1,0,null),t.registeredClass.constructor_body[r-1]=Vt(e,n,null,a,i),[])),[]})},B:(t,r,e,n,a,i,o,s,u)=>{var l=Ut(e,n);r=(t=>{const r=(t=t.trim()).indexOf("(");return-1!==r?t.substr(0,r):t})(r=et(r)),i=Mt(a,i),ut([],[t],t=>{var n=`${(t=t[0]).name}.${r}`;function a(){Ht(`Cannot call ${n} due to unbound types`,l)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&t.registeredClass.pureVirtualFunctions.push(r);var u=t.registeredClass.instancePrototype,c=u[r];return void 0===c||void 0===c.overloadTable&&c.className!==t.name&&c.argCount===e-2?(a.argCount=e-2,a.className=t.name,u[r]=a):(Pt(u,r,n),u[r].overloadTable[e-2]=a),ut([],l,a=>{var s=Vt(n,a,t,i,o);return void 0===u[r].overloadTable?(s.argCount=e-2,u[r]=s):u[r].overloadTable[e-2]=s,[]}),[]})},ha:t=>lt(t,Nt),O:(t,r,e)=>{lt(t,{name:r=et(r),fromWireType:t=>t,toWireType:(t,r)=>r,argPackAdvance:8,readValueFromPointer:Xt(r,e),destructorFunction:null})},s:(t,r,e,n,a)=>{r=et(r);var i=t=>t;if(0===n){var o=32-8*e;i=t=>t<<o>>>o}var s=r.includes("unsigned");lt(t,{name:r,fromWireType:i,toWireType:s?function(t,r){return this.name,r>>>0}:function(t,r){return this.name,r},argPackAdvance:8,readValueFromPointer:Zt(r,e,0!==n),destructorFunction:null})},n:(t,r,e)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];function a(t){var r=T[t>>2],e=T[t+4>>2];return new n(w.buffer,e,r)}lt(t,{name:e=et(e),fromWireType:a,argPackAdvance:8,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},N:(t,r)=>{var e="std::string"===(r=et(r));lt(t,{name:r,fromWireType(t){var r,n=T[t>>2],a=t+4;if(e)for(var i=a,o=0;o<=n;++o){var s=a+o;if(o==n||0==b[s]){var u=q(i,s-i);void 0===r?r=u:(r+=String.fromCharCode(0),r+=u),i=s+1}}else{var l=new Array(n);for(o=0;o<n;++o)l[o]=String.fromCharCode(b[a+o]);r=l.join("")}return Pr(t),r},toWireType(t,r){var n;r instanceof ArrayBuffer&&(r=new Uint8Array(r));var a="string"==typeof r;a||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||ot("Cannot pass non-string to std::string"),n=e&&a?Qt(r):r.length;var i=Cr(4+n+1),o=i+4;if(T[i>>2]=n,e&&a)Kt(r,b,o,n+1);else if(a)for(var s=0;s<n;++s){var u=r.charCodeAt(s);u>255&&(Pr(o),ot("String has UTF-16 code units that do not fit in 8 bits")),b[o+s]=u}else for(s=0;s<n;++s)b[o+s]=r[s];return null!==t&&t.push(Pr,i),i},argPackAdvance:8,readValueFromPointer:Ot,destructorFunction(t){Pr(t)}})},E:(t,r,e)=>{var n,a,i,o;e=et(e),2===r?(n=rr,a=er,o=nr,i=t=>C[t>>1]):4===r&&(n=ar,a=ir,o=or,i=t=>T[t>>2]),lt(t,{name:e,fromWireType:t=>{for(var e,a=T[t>>2],o=t+4,s=0;s<=a;++s){var u=t+4+s*r;if(s==a||0==i(u)){var l=n(o,u-o);void 0===e?e=l:(e+=String.fromCharCode(0),e+=l),o=u+r}}return Pr(t),e},toWireType:(t,n)=>{"string"!=typeof n&&ot(`Cannot pass non-string to C++ string type ${e}`);var i=o(n),s=Cr(4+i+r);return T[s>>2]=i/r,a(n,s+4,i+r),null!==t&&t.push(Pr,s),s},argPackAdvance:8,readValueFromPointer:Ot,destructorFunction(t){Pr(t)}})},ja:(t,r)=>{lt(t,{isVoid:!0,name:r=et(r),argPackAdvance:0,fromWireType:()=>{},toWireType:(t,r)=>{}})},F:(t,r,e,n)=>(t=sr[t])(null,r=qt.toValue(r),e,n),P:(t,r,e,n,a)=>(t=sr[t])(r=qt.toValue(r),r[e=lr(e)],n,a),U:Gt,ma:t=>0===t?qt.toHandle(cr()):(t=lr(t),qt.toHandle(cr()[t])),x:(t,r,e)=>{var n=((t,r)=>{for(var e=new Array(t),n=0;n<t;++n)e[n]=hr(T[r+4*n>>2],"parameter "+n);return e})(t,r),a=n.shift();t--;var i,o,s=new Array(t),u=`methodCaller<(${n.map(t=>t.name).join(", ")}) => ${a.name}>`;return i=Ct(u,(r,i,o,u)=>{for(var l=0,c=0;c<t;++c)s[c]=n[c].readValueFromPointer(u+l),l+=n[c].argPackAdvance;var h=1===e?fr(i,s):i.apply(r,s);return((t,r,e)=>{var n=[],a=t.toWireType(n,e);return n.length&&(T[r>>2]=qt.toHandle(n)),a})(a,o,h)}),o=sr.length,sr.push(i),o},Q:t=>{t>9&&(Bt[t+1]+=1)},w:t=>qt.toHandle(lr(t)),la:()=>qt.toHandle({}),oa:t=>{var r=qt.toValue(t);It(r),Gt(t)},ka:(t,r,e)=>{t=qt.toValue(t),r=qt.toValue(r),e=qt.toValue(e),t[r]=e},G:(t,r)=>{var e=(t=hr(t,"_emval_take_value")).readValueFromPointer(r);return qt.toHandle(e)},C:()=>{x("")},ga:(t,r,e)=>b.copyWithin(t,r,r+e),aa:t=>{var r=b.length,e=2147483648;if((t>>>=0)>e)return!1;for(var n=(t,r)=>t+(r-t%r)%r,a=1;a<=4;a*=2){var i=r*(1+.2/a);i=Math.min(i,t+100663296);var o=Math.min(e,n(Math.max(t,i),65536));if(dr(o))return!0}return!1},ea:(t,r)=>{var e=0;return yr().forEach((n,a)=>{var i=r+e;T[t+4*a>>2]=i,((t,r)=>{for(var e=0;e<t.length;++e)w[r++]=t.charCodeAt(e);w[r]=0})(n,i),e+=n.length+1}),0},fa:(t,r)=>{var e=yr();T[t>>2]=e.length;var n=0;return e.forEach(t=>n+=t.length+1),T[r>>2]=n,0},ca:t=>52,da:(t,r,e,n)=>52,X:function(t,r,e,n,a){return 70},M:(t,r,e,n)=>{for(var a=0,i=0;i<e;i++){var o=T[r>>2],s=T[r+4>>2];r+=8;for(var u=0;u<s;u++)mr(t,b[o+u]);a+=s}return T[n>>2]=a,0},H:function(t,r,e,n){var a=Fr();try{return kt(t)(r,e,n)}catch(t){if(Sr(a),t!==t+0)throw t;Ar(1,0)}},R:function(t,r,e,n,a){var i=Fr();try{return kt(t)(r,e,n,a)}catch(t){if(Sr(i),t!==t+0)throw t;Ar(1,0)}},I:function(t,r,e,n){var a=Fr();try{return kt(t)(r,e,n)}catch(t){if(Sr(a),t!==t+0)throw t;Ar(1,0)}},m:function(t){var r=Fr();try{return kt(t)()}catch(t){if(Sr(r),t!==t+0)throw t;Ar(1,0)}},c:function(t,r){var e=Fr();try{return kt(t)(r)}catch(t){if(Sr(e),t!==t+0)throw t;Ar(1,0)}},f:function(t,r,e){var n=Fr();try{return kt(t)(r,e)}catch(t){if(Sr(n),t!==t+0)throw t;Ar(1,0)}},l:function(t,r,e,n){var a=Fr();try{return kt(t)(r,e,n)}catch(t){if(Sr(a),t!==t+0)throw t;Ar(1,0)}},j:function(t,r,e,n,a){var i=Fr();try{return kt(t)(r,e,n,a)}catch(t){if(Sr(i),t!==t+0)throw t;Ar(1,0)}},K:function(t,r,e,n,a,i){var o=Fr();try{return kt(t)(r,e,n,a,i)}catch(t){if(Sr(o),t!==t+0)throw t;Ar(1,0)}},u:function(t,r,e,n,a,i){var o=Fr();try{return kt(t)(r,e,n,a,i)}catch(t){if(Sr(o),t!==t+0)throw t;Ar(1,0)}},t:function(t,r,e,n,a,i,o){var s=Fr();try{return kt(t)(r,e,n,a,i,o)}catch(t){if(Sr(s),t!==t+0)throw t;Ar(1,0)}},J:function(t,r,e,n,a,i,o,s){var u=Fr();try{return kt(t)(r,e,n,a,i,o,s)}catch(t){if(Sr(u),t!==t+0)throw t;Ar(1,0)}},A:function(t,r,e,n,a,i,o,s,u,l,c,h){var f=Fr();try{return kt(t)(r,e,n,a,i,o,s,u,l,c,h)}catch(t){if(Sr(f),t!==t+0)throw t;Ar(1,0)}},W:function(t,r,e,n,a,i,o){var s=Fr();try{return kr(t,r,e,n,a,i,o)}catch(t){if(Sr(s),t!==t+0)throw t;Ar(1,0)}},V:function(t,r,e,n,a){var i=Fr();try{return xr(t,r,e,n,a)}catch(t){if(Sr(i),t!==t+0)throw t;Ar(1,0)}},i:function(t){var r=Fr();try{kt(t)()}catch(t){if(Sr(r),t!==t+0)throw t;Ar(1,0)}},h:function(t,r){var e=Fr();try{kt(t)(r)}catch(t){if(Sr(e),t!==t+0)throw t;Ar(1,0)}},d:function(t,r,e){var n=Fr();try{kt(t)(r,e)}catch(t){if(Sr(n),t!==t+0)throw t;Ar(1,0)}},k:function(t,r,e,n){var a=Fr();try{kt(t)(r,e,n)}catch(t){if(Sr(a),t!==t+0)throw t;Ar(1,0)}},y:function(t,r,e,n,a){var i=Fr();try{kt(t)(r,e,n,a)}catch(t){if(Sr(i),t!==t+0)throw t;Ar(1,0)}},D:function(t,r,e,n,a,i){var o=Fr();try{kt(t)(r,e,n,a,i)}catch(t){if(Sr(o),t!==t+0)throw t;Ar(1,0)}},na:function(t,r,e,n,a,i,o){var s=Fr();try{kt(t)(r,e,n,a,i,o)}catch(t){if(Sr(s),t!==t+0)throw t;Ar(1,0)}},r:function(t,r,e,n,a,i,o,s){var u=Fr();try{kt(t)(r,e,n,a,i,o,s)}catch(t){if(Sr(u),t!==t+0)throw t;Ar(1,0)}},v:function(t,r,e,n,a,i,o,s,u,l,c){var h=Fr();try{kt(t)(r,e,n,a,i,o,s,u,l,c)}catch(t){if(Sr(h),t!==t+0)throw t;Ar(1,0)}},z:function(t,r,e,n,a,i,o,s,u,l,c,h,f,d,p,y){var v=Fr();try{kt(t)(r,e,n,a,i,o,s,u,l,c,h,f,d,p,y)}catch(t){if(Sr(v),t!==t+0)throw t;Ar(1,0)}},Z:function(t,r,e,n){var a=Fr();try{Rr(t,r,e,n)}catch(t){if(Sr(a),t!==t+0)throw t;Ar(1,0)}},_:(t,r,e,n,a)=>((t,r,e,n)=>{var a=T[n+40>>2],i={tm_sec:P[n>>2],tm_min:P[n+4>>2],tm_hour:P[n+8>>2],tm_mday:P[n+12>>2],tm_mon:P[n+16>>2],tm_year:P[n+20>>2],tm_wday:P[n+24>>2],tm_yday:P[n+28>>2],tm_isdst:P[n+32>>2],tm_gmtoff:P[n+36>>2],tm_zone:a?q(a):""},o=q(e),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in s)o=o.replace(new RegExp(u,"g"),s[u]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"];function h(t,r,e){for(var n="number"==typeof t?t.toString():t||"";n.length<r;)n=e[0]+n;return n}function f(t,r){return h(t,r,"0")}function d(t,r){function e(t){return t<0?-1:t>0?1:0}var n;return 0===(n=e(t.getFullYear()-r.getFullYear()))&&0===(n=e(t.getMonth()-r.getMonth()))&&(n=e(t.getDate()-r.getDate())),n}function p(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function y(t){var r=((t,r)=>{for(var e=new Date(t.getTime());r>0;){var n=gr(e.getFullYear()),a=e.getMonth(),i=(n?$r:wr)[a];if(!(r>i-e.getDate()))return e.setDate(e.getDate()+r),e;r-=i-e.getDate()+1,e.setDate(1),a<11?e.setMonth(a+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e})(new Date(t.tm_year+1900,0,1),t.tm_yday),e=new Date(r.getFullYear(),0,4),n=new Date(r.getFullYear()+1,0,4),a=p(e),i=p(n);return d(a,r)<=0?d(i,r)<=0?r.getFullYear()+1:r.getFullYear():r.getFullYear()-1}var v={"%a":t=>l[t.tm_wday].substring(0,3),"%A":t=>l[t.tm_wday],"%b":t=>c[t.tm_mon].substring(0,3),"%B":t=>c[t.tm_mon],"%C":t=>f((t.tm_year+1900)/100|0,2),"%d":t=>f(t.tm_mday,2),"%e":t=>h(t.tm_mday,2," "),"%g":t=>y(t).toString().substring(2),"%G":y,"%H":t=>f(t.tm_hour,2),"%I":t=>{var r=t.tm_hour;return 0==r?r=12:r>12&&(r-=12),f(r,2)},"%j":t=>f(t.tm_mday+((t,r)=>{for(var e=0,n=0;n<=r;e+=t[n++]);return e})(gr(t.tm_year+1900)?$r:wr,t.tm_mon-1),3),"%m":t=>f(t.tm_mon+1,2),"%M":t=>f(t.tm_min,2),"%n":()=>"\n","%p":t=>t.tm_hour>=0&&t.tm_hour<12?"AM":"PM","%S":t=>f(t.tm_sec,2),"%t":()=>"\t","%u":t=>t.tm_wday||7,"%U":t=>{var r=t.tm_yday+7-t.tm_wday;return f(Math.floor(r/7),2)},"%V":t=>{var r=Math.floor((t.tm_yday+7-(t.tm_wday+6)%7)/7);if((t.tm_wday+371-t.tm_yday-2)%7<=2&&r++,r){if(53==r){var e=(t.tm_wday+371-t.tm_yday)%7;4==e||3==e&&gr(t.tm_year)||(r=1)}}else{r=52;var n=(t.tm_wday+7-t.tm_yday-1)%7;(4==n||5==n&&gr(t.tm_year%400-1))&&r++}return f(r,2)},"%w":t=>t.tm_wday,"%W":t=>{var r=t.tm_yday+7-(t.tm_wday+6)%7;return f(Math.floor(r/7),2)},"%y":t=>(t.tm_year+1900).toString().substring(2),"%Y":t=>t.tm_year+1900,"%z":t=>{var r=t.tm_gmtoff,e=r>=0;return r=(r=Math.abs(r)/60)/60*100+r%60,(e?"+":"-")+String("0000"+r).slice(-4)},"%Z":t=>t.tm_zone,"%%":()=>"%"};for(var u in o=o.replace(/%%/g,"\0\0"),v)o.includes(u)&&(o=o.replace(new RegExp(u,"g"),v[u](i)));o=o.replace(/\0\0/g,"%");var m,g,$,b,_,C=(g=Qt(m=o)+1,$=new Array(g),Kt(m,$,0,$.length),$);return C.length>r?0:(b=C,_=t,w.set(b,_),C.length-1)})(t,r,e,n)},_r=function(){var t,r,e,i,o={a:br};function s(t,r){var e;return _r=t.exports,m=_r.pa,S(),Dt=_r.sa,e=_r.qa,E.unshift(e),function(){if(k--,a.monitorRunDependencies?.(k),0==k&&M){var t=M;M=null,t()}}(),_r}if(k++,a.monitorRunDependencies?.(k),a.instantiateWasm)try{return a.instantiateWasm(o,s)}catch(t){$(`Module.instantiateWasm callback failed with error: ${t}`),n(t)}return(t=v,r=H,e=o,i=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||I(r)||h||"function"!=typeof fetch?L(r,e,i):fetch(r,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,e).then(i,function(t){return $(`wasm streaming compile failed: ${t}`),$("falling back to ArrayBuffer instantiation"),L(r,e,i)}))).catch(n),{}}(),Cr=a._malloc=t=>(Cr=a._malloc=_r.ra)(t),Pr=a._free=t=>(Pr=a._free=_r.ta)(t),Tr=t=>(Tr=_r.ua)(t),Ar=(t,r)=>(Ar=_r.va)(t,r),jr=t=>(jr=_r.wa)(t),Fr=()=>(Fr=_r.xa)(),Sr=t=>(Sr=_r.ya)(t),Or=t=>(Or=_r.za)(t),Er=t=>(Er=_r.Aa)(t),Dr=(t,r,e)=>(Dr=_r.Ba)(t,r,e),Wr=t=>(Wr=_r.Ca)(t),Rr=a.dynCall_vij=(t,r,e,n)=>(Rr=a.dynCall_vij=_r.Da)(t,r,e,n);a.dynCall_ji=(t,r)=>(a.dynCall_ji=_r.Ea)(t,r),a.dynCall_iij=(t,r,e,n)=>(a.dynCall_iij=_r.Fa)(t,r,e,n),a.dynCall_jijj=(t,r,e,n,i,o)=>(a.dynCall_jijj=_r.Ga)(t,r,e,n,i,o),a.dynCall_vijj=(t,r,e,n,i,o)=>(a.dynCall_vijj=_r.Ha)(t,r,e,n,i,o),a.dynCall_jiji=(t,r,e,n,i)=>(a.dynCall_jiji=_r.Ia)(t,r,e,n,i);var kr=a.dynCall_iiiiij=(t,r,e,n,i,o,s)=>(kr=a.dynCall_iiiiij=_r.Ja)(t,r,e,n,i,o,s);a.dynCall_viijii=(t,r,e,n,i,o,s)=>(a.dynCall_viijii=_r.Ka)(t,r,e,n,i,o,s);var Mr,xr=a.dynCall_jiiii=(t,r,e,n,i)=>(xr=a.dynCall_jiiii=_r.La)(t,r,e,n,i);function Hr(){function t(){Mr||(Mr=!0,a.calledRun=!0,F||(z(E),e(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),function(){if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)R(a.postRun.shift());z(D)}()))}k>0||(function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)W(a.preRun.shift());z(O)}(),k>0||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),t()},1)):t()))}if(a.dynCall_iiiiijj=(t,r,e,n,i,o,s,u,l)=>(a.dynCall_iiiiijj=_r.Ma)(t,r,e,n,i,o,s,u,l),a.dynCall_iiiiiijj=(t,r,e,n,i,o,s,u,l,c)=>(a.dynCall_iiiiiijj=_r.Na)(t,r,e,n,i,o,s,u,l,c),M=function t(){Mr||Hr(),Mr||(M=t)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return Hr(),r.ready});export{r as default};
@@ -0,0 +1 @@
1
+ var e,t="undefined"!=typeof document?document.currentScript:null,r=(e="undefined"==typeof document?require("url").pathToFileURL(__filename).href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("heic-decoder-RXDCJDOS.js",document.baseURI).href,async function(r={}){var n,a,i=r;i.ready=new Promise((e,t)=>{n=e,a=t});var o,s,u=Object.assign({},i),l="./this.program",c="object"==typeof window,h="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,d="";if(f){const{createRequire:e}=await(import("module"));var p=e("undefined"==typeof document?require("url").pathToFileURL(__filename).href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("heic-decoder-RXDCJDOS.js",document.baseURI).href),y=p("fs"),v=p("path");d=h?v.dirname(d)+"/":p("url").fileURLToPath(new URL("./","undefined"==typeof document?require("url").pathToFileURL(__filename).href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("heic-decoder-RXDCJDOS.js",document.baseURI).href)),o=(e,t)=>(e=Y(e)?new URL(e):v.normalize(e),y.readFileSync(e,t?void 0:"utf8")),s=e=>{var t=o(e,!0);return t.buffer||(t=new Uint8Array(t)),t},!i.thisProgram&&process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(c||h)&&(h?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),e&&(d=e),d=d.startsWith("blob:")?"":d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1),o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},h&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var m,g,$=i.print||console.log.bind(console),w=i.printErr||console.error.bind(console);Object.assign(i,u),u=null,i.arguments&&i.arguments,i.thisProgram&&(l=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(m=i.wasmBinary);var b,_,C,P,T,A,j,S,F=!1;function R(){var e=g.buffer;i.HEAP8=b=new Int8Array(e),i.HEAP16=C=new Int16Array(e),i.HEAPU8=_=new Uint8Array(e),i.HEAPU16=P=new Uint16Array(e),i.HEAP32=T=new Int32Array(e),i.HEAPU32=A=new Uint32Array(e),i.HEAPF32=j=new Float32Array(e),i.HEAPF64=S=new Float64Array(e)}var O=[],D=[],E=[];function U(e){O.unshift(e)}function W(e){E.unshift(e)}var k=0,I=null;function M(e){i.onAbort?.(e),w(e="Aborted("+e+")"),F=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw a(t),t}var x,H,V=e=>e.startsWith("data:application/octet-stream;base64,"),Y=e=>e.startsWith("file://");function L(e){if(e==x&&m)return new Uint8Array(m);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function q(e,t,r){return function(e){return m||!c&&!h||"function"!=typeof fetch?Promise.resolve().then(()=>L(e)):fetch(e,{credentials:"same-origin"}).then(t=>{if(!t.ok)throw`failed to load wasm binary file at '${e}'`;return t.arrayBuffer()}).catch(()=>L(e))}(e).then(e=>WebAssembly.instantiate(e,t)).then(r,e=>{w(`failed to asynchronously prepare wasm: ${e}`),M(e)})}i.locateFile?V(x="heic-decoder.wasm")||(H=x,x=i.locateFile?i.locateFile(H,d):d+H):x=new URL("heic-decoder.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("heic-decoder-RXDCJDOS.js",document.baseURI).href).href;var z=e=>{for(;e.length>0;)e.shift()(i)};i.noExitRuntime;var B="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,N=(e,t,r)=>{for(var n=t+r,a=t;e[a]&&!(a>=n);)++a;if(a-t>16&&e.buffer&&B)return B.decode(e.subarray(t,a));for(var i="";t<a;){var o=e[t++];if(128&o){var s=63&e[t++];if(192!=(224&o)){var u=63&e[t++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(o);else{var l=o-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&o)<<6|s)}else i+=String.fromCharCode(o)}return i},G=(e,t)=>e?N(_,e,t):"",J=[],X=0,Z=0;class K{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){A[this.ptr+4>>2]=e}get_type(){return A[this.ptr+4>>2]}set_destructor(e){A[this.ptr+8>>2]=e}get_destructor(){return A[this.ptr+8>>2]}set_caught(e){e=e?1:0,b[this.ptr+12]=e}get_caught(){return 0!=b[this.ptr+12]}set_rethrown(e){e=e?1:0,b[this.ptr+13]=e}get_rethrown(){return 0!=b[this.ptr+13]}init(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)}set_adjusted_ptr(e){A[this.ptr+16>>2]=e}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(Ut(this.get_type()))return A[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var Q,ee,te,re=e=>{var t=Z;if(!t)return St(0),0;var r=new K(t);r.set_adjusted_ptr(t);var n=r.get_type();if(!n)return St(0),t;for(var a in e){var i=e[a];if(0===i||i===n)break;var o=r.ptr+16;if(Et(i,n,o))return St(i),t}return St(n),t},ne=e=>{for(var t="",r=e;_[r];)t+=Q[_[r++]];return t},ae={},ie={},oe={},se=e=>{throw new ee(e)},ue=e=>{throw new te(e)},le=(e,t,r)=>{function n(t){var n=r(t);n.length!==e.length&&ue("Mismatched type converter count");for(var a=0;a<e.length;++a)ce(e[a],n[a])}e.forEach(function(e){oe[e]=t});var a=new Array(t.length),i=[],o=0;t.forEach((e,t)=>{ie.hasOwnProperty(e)?a[t]=ie[e]:(i.push(e),ae.hasOwnProperty(e)||(ae[e]=[]),ae[e].push(()=>{a[t]=ie[e],++o===i.length&&n(a)}))}),0===i.length&&n(a)};function ce(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t,r={}){var n=t.name;if(e||se(`type "${n}" must have a positive integer typeid pointer`),ie.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;se(`Cannot register type '${n}' twice`)}if(ie[e]=t,delete oe[e],ae.hasOwnProperty(e)){var a=ae[e];delete ae[e],a.forEach(e=>e())}}(e,t,r)}var he,fe=e=>{se(e.$$.ptrType.registeredClass.name+" instance already deleted")},de=!1,pe=e=>{},ye=e=>{e.count.value-=1,0===e.count.value&&(e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)})(e)},ve=(e,t,r)=>{if(t===r)return e;if(void 0===r.baseClass)return null;var n=ve(e,t,r.baseClass);return null===n?null:r.downcast(n)},me={},ge=[],$e=()=>{for(;ge.length;){var e=ge.pop();e.$$.deleteScheduled=!1,e.delete()}},we={},be=(e,t)=>(t.ptrType&&t.ptr||ue("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&ue("Both smartPtrType and smartPtr must be specified"),t.count={value:1},_e(Object.create(e,{$$:{value:t,writable:!0}}))),_e=e=>"undefined"==typeof FinalizationRegistry?(_e=e=>e,e):(de=new FinalizationRegistry(e=>{ye(e.$$)}),pe=e=>de.unregister(e),(_e=e=>{var t=e.$$;if(t.smartPtr){var r={$$:t};de.register(e,r,e)}return e})(e));function Ce(){}var Pe=(e,t)=>Object.defineProperty(t,"name",{value:e}),Te=(e,t,r)=>{if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(...n){return e[t].overloadTable.hasOwnProperty(n.length)||se(`Function '${r}' called with an invalid number of arguments (${n.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[n.length].apply(this,n)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}};function Ae(e,t,r,n,a,i,o,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=a,this.getActualType=i,this.upcast=o,this.downcast=s,this.pureVirtualFunctions=[]}var je=(e,t,r)=>{for(;t!==r;)t.upcast||se(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e};function Se(e,t){if(null===t)return this.isReference&&se(`null is not a valid ${this.name}`),0;t.$$||se(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return je(t.$$.ptr,r,this.registeredClass)}function Fe(e,t){var r;if(null===t)return this.isReference&&se(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t&&t.$$||se(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&se(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var n=t.$$.ptrType.registeredClass;if(r=je(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&se("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:se(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var a=t.clone();r=this.rawShare(r,Ge.toHandle(()=>a.delete())),null!==e&&e.push(this.rawDestructor,r)}break;default:se("Unsupporting sharing policy")}return r}function Re(e,t){if(null===t)return this.isReference&&se(`null is not a valid ${this.name}`),0;t.$$||se(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||se(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&se(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return je(t.$$.ptr,r,this.registeredClass)}function Oe(e){return this.fromWireType(A[e>>2])}function De(e,t,r,n,a,i,o,s,u,l,c){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=a,this.pointeeType=i,this.sharingPolicy=o,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,a||void 0!==t.baseClass?this.toWireType=Fe:n?(this.toWireType=Se,this.destructorFunction=null):(this.toWireType=Re,this.destructorFunction=null)}var Ee,Ue,We=[],ke=e=>{var t=We[e];return t||(e>=We.length&&(We.length=e+1),We[e]=t=Ee.get(e)),t},Ie=(e,t)=>{var r,n,a=(e=ne(e)).includes("j")?(r=e,n=t,(...e)=>((e,t,r=[])=>e.includes("j")?((e,t,r)=>(0,i["dynCall_"+e])(t,...r))(e,t,r):ke(t)(...r))(r,n,e)):ke(t);return"function"!=typeof a&&se(`unknown function pointer with signature ${e}: ${t}`),a},Me=e=>{var t=At(e),r=ne(t);return Tt(t),r},xe=(e,t)=>{var r=[],n={};throw t.forEach(function e(t){n[t]||ie[t]||(oe[t]?oe[t].forEach(e):(r.push(t),n[t]=!0))}),new Ue(`${e}: `+r.map(Me).join([", "]))},He=(e,t)=>{for(var r=[],n=0;n<e;n++)r.push(A[t+4*n>>2]);return r},Ve=e=>{for(;e.length;){var t=e.pop();e.pop()(t)}};function Ye(e,t,r,n,a,i){var o=t.length;o<2&&se("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==t[1]&&null!==r,u=function(e){for(var t=1;t<e.length;++t)if(null!==e[t]&&void 0===e[t].destructorFunction)return!0;return!1}(t),l="void"!==t[0].name,c=o-2,h=new Array(c),f=[],d=[];return Pe(e,function(...r){var i;r.length!==c&&se(`function ${e} called with ${r.length} arguments, expected ${c}`),d.length=0,f.length=s?2:1,f[0]=a,s&&(i=t[1].toWireType(d,this),f[1]=i);for(var o=0;o<c;++o)h[o]=t[o+2].toWireType(d,r[o]),f.push(h[o]);return function(e){if(u)Ve(d);else for(var r=s?1:2;r<t.length;r++){var n=1===r?i:h[r-2];null!==t[r].destructorFunction&&t[r].destructorFunction(n)}if(l)return t[0].fromWireType(e)}(n(...f))})}var Le,qe,ze=[],Be=[],Ne=e=>{e>9&&0===--Be[e+1]&&(Be[e]=void 0,ze.push(e))},Ge={toValue:e=>(e||se("Cannot use deleted val. handle = "+e),Be[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const t=ze.pop()||Be.length;return Be[t]=e,Be[t+1]=1,t}}}},Je={name:"emscripten::val",fromWireType:e=>{var t=Ge.toValue(e);return Ne(e),t},toWireType:(e,t)=>Ge.toHandle(t),argPackAdvance:8,readValueFromPointer:Oe,destructorFunction:null},Xe=e=>{if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e},Ze=(e,t)=>{switch(t){case 4:return function(e){return this.fromWireType(j[e>>2])};case 8:return function(e){return this.fromWireType(S[e>>3])};default:throw new TypeError(`invalid float width (${t}): ${e}`)}},Ke=(e,t,r)=>{switch(t){case 1:return r?e=>b[e]:e=>_[e];case 2:return r?e=>C[e>>1]:e=>P[e>>1];case 4:return r?e=>T[e>>2]:e=>A[e>>2];default:throw new TypeError(`invalid integer width (${t}): ${e}`)}},Qe=(e,t,r,n)=>{if(!(n>0))return 0;for(var a=r,i=r+n-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(r>=i)break;t[r++]=s}else if(s<=2047){if(r+1>=i)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=i)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=i)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-a},et=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t},tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,rt=(e,t)=>{for(var r=e,n=r>>1,a=n+t/2;!(n>=a)&&P[n];)++n;if((r=n<<1)-e>32&&tt)return tt.decode(_.subarray(e,r));for(var i="",o=0;!(o>=t/2);++o){var s=C[e+2*o>>1];if(0==s)break;i+=String.fromCharCode(s)}return i},nt=(e,t,r)=>{if(r??=2147483647,r<2)return 0;for(var n=t,a=(r-=2)<2*e.length?r/2:e.length,i=0;i<a;++i){var o=e.charCodeAt(i);C[t>>1]=o,t+=2}return C[t>>1]=0,t-n},at=e=>2*e.length,it=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var a=T[e+4*r>>2];if(0==a)break;if(++r,a>=65536){var i=a-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(a)}return n},ot=(e,t,r)=>{if(r??=2147483647,r<4)return 0;for(var n=t,a=n+r-4,i=0;i<e.length;++i){var o=e.charCodeAt(i);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++i)),T[t>>2]=o,(t+=4)+4>a)break}return T[t>>2]=0,t-n},st=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t},ut=[],lt={},ct=e=>{var t=lt[e];return void 0===t?ne(e):t},ht=()=>{if("object"==typeof globalThis)return globalThis;function e(e){e.$$$embind_global$$$=e;var t="object"==typeof $$$embind_global$$$&&e.$$$embind_global$$$==e;return t||delete e.$$$embind_global$$$,t}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&e(global)?$$$embind_global$$$=global:"object"==typeof self&&e(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},ft=(e,t)=>{var r=ie[e];return void 0===r&&se(`${t} has unknown type ${Me(e)}`),r},dt=Reflect.construct,pt=e=>{var t=(e-g.buffer.byteLength+65535)/65536;try{return g.grow(t),R(),1}catch(e){}},yt={},vt=()=>{if(!vt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(var t in yt)void 0===yt[t]?delete e[t]:e[t]=yt[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);vt.strings=r}return vt.strings},mt=[null,[],[]],gt=(e,t)=>{var r=mt[e];0===t||10===t?((1===e?$:w)(N(r,0)),r.length=0):r.push(t)},$t=e=>e%4==0&&(e%100!=0||e%400==0),wt=[31,29,31,30,31,30,31,31,30,31,30,31],bt=[31,28,31,30,31,30,31,31,30,31,30,31];(()=>{for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);Q=e})(),ee=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},te=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Object.assign(Ce.prototype,{isAliasOf(e){if(!(this instanceof Ce))return!1;if(!(e instanceof Ce))return!1;var t=this.$$.ptrType.registeredClass,r=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,a=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return t===n&&r===a},clone(){if(this.$$.ptr||fe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=_e(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||fe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&se("Object already scheduled for deletion"),pe(this),ye(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||fe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&se("Object already scheduled for deletion"),ge.push(this),1===ge.length&&he&&he($e),this.$$.deleteScheduled=!0,this}}),i.getInheritedInstanceCount=()=>Object.keys(we).length,i.getLiveInheritedInstances=()=>{var e=[];for(var t in we)we.hasOwnProperty(t)&&e.push(we[t]);return e},i.flushPendingDeletes=$e,i.setDelayFunction=e=>{he=e,ge.length&&he&&he($e)},Object.assign(De.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},argPackAdvance:8,readValueFromPointer:Oe,fromWireType:function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=((e,t)=>(t=((e,t)=>{for(void 0===t&&se("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t})(e,t),we[t]))(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var n=r.clone();return this.destructor(e),n}function a(){return this.isSmartPointer?be(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):be(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,o=this.registeredClass.getActualType(t),s=me[o];if(!s)return a.call(this);i=this.isConst?s.constPointerType:s.pointerType;var u=ve(t,this.registeredClass,i.registeredClass);return null===u?a.call(this):this.isSmartPointer?be(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):be(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}}),Ue=i.UnboundTypeError=(Le=Error,(qe=Pe("UnboundTypeError",function(e){this.name="UnboundTypeError",this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(Le.prototype),qe.prototype.constructor=qe,qe.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},qe),Be.push(0,1,void 0,1,null,1,!0,1,!1,1),i.count_emval_handles=()=>Be.length/2-5-ze.length;var _t={b:(e,t,r,n)=>{M(`Assertion failed: ${G(e)}, at: `+[t?G(t):"unknown filename",r,n?G(n):"unknown function"])},o:e=>{var t=new K(e);return t.get_caught()||(t.set_caught(!0),X--),t.set_rethrown(!1),J.push(t),Dt(t.excPtr),t.get_exception_ptr()},p:()=>{jt(0,0);var e=J.pop();Ot(e.excPtr),Z=0},a:()=>re([]),g:e=>re([e]),L:()=>{var e=J.pop();e||M("no exception to throw");var t=e.excPtr;throw e.get_rethrown()||(J.push(e),e.set_rethrown(!0),e.set_caught(!1),X++),Z=t},q:(e,t,r)=>{throw new K(e).init(t,r),X++,Z=e},$:()=>X,e:e=>{throw Z||(Z=e),Z},ba:(e,t,r)=>{},Y:(e,t,r,n,a)=>{},ia:(e,t,r,n)=>{ce(e,{name:t=ne(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:n},argPackAdvance:8,readValueFromPointer:function(e){return this.fromWireType(_[e])},destructorFunction:null})},T:(e,t,r,n,a,o,s,u,l,c,h,f,d)=>{h=ne(h),o=Ie(a,o),u&&=Ie(s,u),c&&=Ie(l,c),d=Ie(f,d);var p=(e=>{if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?`_${e}`:e})(h);((e,t)=>{i.hasOwnProperty(e)?(se(`Cannot register public name '${e}' twice`),Te(i,e,e),i.hasOwnProperty(void 0)&&se("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),i[e].overloadTable[void 0]=t):i[e]=t})(p,function(){xe(`Cannot construct ${h} due to unbound types`,[n])}),le([e,t,r],n?[n]:[],t=>{var r,a;t=t[0],a=n?(r=t.registeredClass).instancePrototype:Ce.prototype;var s=Pe(h,function(...e){if(Object.getPrototypeOf(this)!==l)throw new ee("Use 'new' to construct "+h);if(void 0===f.constructor_body)throw new ee(h+" has no accessible constructor");var t=f.constructor_body[e.length];if(void 0===t)throw new ee(`Tried to invoke ctor of ${h} with invalid number of parameters (${e.length}) - expected (${Object.keys(f.constructor_body).toString()}) parameters instead!`);return t.apply(this,e)}),l=Object.create(a,{constructor:{value:s}});s.prototype=l;var f=new Ae(h,s,l,d,r,o,u,c);f.baseClass&&(f.baseClass.__derivedClasses??=[],f.baseClass.__derivedClasses.push(f));var y=new De(h,f,!0,!1,!1),v=new De(h+"*",f,!1,!1,!1),m=new De(h+" const*",f,!1,!0,!1);return me[e]={pointerType:v,constPointerType:m},((e,t)=>{i.hasOwnProperty(e)||ue("Replacing nonexistent public symbol"),i[e].overloadTable,i[e]=t,i[e].argCount=void 0})(p,s),[y,v,m]})},S:(e,t,r,n,a,i)=>{var o=He(t,r);a=Ie(n,a),le([],[e],e=>{var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new ee(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{xe(`Cannot construct ${e.name} due to unbound types`,o)},le([],o,n=>(n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Ye(r,n,null,a,i),[])),[]})},B:(e,t,r,n,a,i,o,s,u)=>{var l=He(r,n);t=(e=>{const t=(e=e.trim()).indexOf("(");return-1!==t?e.substr(0,t):e})(t=ne(t)),i=Ie(a,i),le([],[e],e=>{var n=`${(e=e[0]).name}.${t}`;function a(){xe(`Cannot call ${n} due to unbound types`,l)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var u=e.registeredClass.instancePrototype,c=u[t];return void 0===c||void 0===c.overloadTable&&c.className!==e.name&&c.argCount===r-2?(a.argCount=r-2,a.className=e.name,u[t]=a):(Te(u,t,n),u[t].overloadTable[r-2]=a),le([],l,a=>{var s=Ye(n,a,e,i,o);return void 0===u[t].overloadTable?(s.argCount=r-2,u[t]=s):u[t].overloadTable[r-2]=s,[]}),[]})},ha:e=>ce(e,Je),O:(e,t,r)=>{ce(e,{name:t=ne(t),fromWireType:e=>e,toWireType:(e,t)=>t,argPackAdvance:8,readValueFromPointer:Ze(t,r),destructorFunction:null})},s:(e,t,r,n,a)=>{t=ne(t);var i=e=>e;if(0===n){var o=32-8*r;i=e=>e<<o>>>o}var s=t.includes("unsigned");ce(e,{name:t,fromWireType:i,toWireType:s?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:Ke(t,r,0!==n),destructorFunction:null})},n:(e,t,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function a(e){var t=A[e>>2],r=A[e+4>>2];return new n(b.buffer,r,t)}ce(e,{name:r=ne(r),fromWireType:a,argPackAdvance:8,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},N:(e,t)=>{var r="std::string"===(t=ne(t));ce(e,{name:t,fromWireType(e){var t,n=A[e>>2],a=e+4;if(r)for(var i=a,o=0;o<=n;++o){var s=a+o;if(o==n||0==_[s]){var u=G(i,s-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=s+1}}else{var l=new Array(n);for(o=0;o<n;++o)l[o]=String.fromCharCode(_[a+o]);t=l.join("")}return Tt(e),t},toWireType(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var a="string"==typeof t;a||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||se("Cannot pass non-string to std::string"),n=r&&a?et(t):t.length;var i=Pt(4+n+1),o=i+4;if(A[i>>2]=n,r&&a)Qe(t,_,o,n+1);else if(a)for(var s=0;s<n;++s){var u=t.charCodeAt(s);u>255&&(Tt(o),se("String has UTF-16 code units that do not fit in 8 bits")),_[o+s]=u}else for(s=0;s<n;++s)_[o+s]=t[s];return null!==e&&e.push(Tt,i),i},argPackAdvance:8,readValueFromPointer:Oe,destructorFunction(e){Tt(e)}})},E:(e,t,r)=>{var n,a,i,o;r=ne(r),2===t?(n=rt,a=nt,o=at,i=e=>P[e>>1]):4===t&&(n=it,a=ot,o=st,i=e=>A[e>>2]),ce(e,{name:r,fromWireType:e=>{for(var r,a=A[e>>2],o=e+4,s=0;s<=a;++s){var u=e+4+s*t;if(s==a||0==i(u)){var l=n(o,u-o);void 0===r?r=l:(r+=String.fromCharCode(0),r+=l),o=u+t}}return Tt(e),r},toWireType:(e,n)=>{"string"!=typeof n&&se(`Cannot pass non-string to C++ string type ${r}`);var i=o(n),s=Pt(4+i+t);return A[s>>2]=i/t,a(n,s+4,i+t),null!==e&&e.push(Tt,s),s},argPackAdvance:8,readValueFromPointer:Oe,destructorFunction(e){Tt(e)}})},ja:(e,t)=>{ce(e,{isVoid:!0,name:t=ne(t),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,t)=>{}})},F:(e,t,r,n)=>(e=ut[e])(null,t=Ge.toValue(t),r,n),P:(e,t,r,n,a)=>(e=ut[e])(t=Ge.toValue(t),t[r=ct(r)],n,a),U:Ne,ma:e=>0===e?Ge.toHandle(ht()):(e=ct(e),Ge.toHandle(ht()[e])),x:(e,t,r)=>{var n=((e,t)=>{for(var r=new Array(e),n=0;n<e;++n)r[n]=ft(A[t+4*n>>2],"parameter "+n);return r})(e,t),a=n.shift();e--;var i,o,s=new Array(e),u=`methodCaller<(${n.map(e=>e.name).join(", ")}) => ${a.name}>`;return i=Pe(u,(t,i,o,u)=>{for(var l=0,c=0;c<e;++c)s[c]=n[c].readValueFromPointer(u+l),l+=n[c].argPackAdvance;var h=1===r?dt(i,s):i.apply(t,s);return((e,t,r)=>{var n=[],a=e.toWireType(n,r);return n.length&&(A[t>>2]=Ge.toHandle(n)),a})(a,o,h)}),o=ut.length,ut.push(i),o},Q:e=>{e>9&&(Be[e+1]+=1)},w:e=>Ge.toHandle(ct(e)),la:()=>Ge.toHandle({}),oa:e=>{var t=Ge.toValue(e);Ve(t),Ne(e)},ka:(e,t,r)=>{e=Ge.toValue(e),t=Ge.toValue(t),r=Ge.toValue(r),e[t]=r},G:(e,t)=>{var r=(e=ft(e,"_emval_take_value")).readValueFromPointer(t);return Ge.toHandle(r)},C:()=>{M("")},ga:(e,t,r)=>_.copyWithin(e,t,t+r),aa:e=>{var t=_.length,r=2147483648;if((e>>>=0)>r)return!1;for(var n=(e,t)=>e+(t-e%t)%t,a=1;a<=4;a*=2){var i=t*(1+.2/a);i=Math.min(i,e+100663296);var o=Math.min(r,n(Math.max(e,i),65536));if(pt(o))return!0}return!1},ea:(e,t)=>{var r=0;return vt().forEach((n,a)=>{var i=t+r;A[e+4*a>>2]=i,((e,t)=>{for(var r=0;r<e.length;++r)b[t++]=e.charCodeAt(r);b[t]=0})(n,i),r+=n.length+1}),0},fa:(e,t)=>{var r=vt();A[e>>2]=r.length;var n=0;return r.forEach(e=>n+=e.length+1),A[t>>2]=n,0},ca:e=>52,da:(e,t,r,n)=>52,X:function(e,t,r,n,a){return 70},M:(e,t,r,n)=>{for(var a=0,i=0;i<r;i++){var o=A[t>>2],s=A[t+4>>2];t+=8;for(var u=0;u<s;u++)gt(e,_[o+u]);a+=s}return A[n>>2]=a,0},H:function(e,t,r,n){var a=Ft();try{return ke(e)(t,r,n)}catch(e){if(Rt(a),e!==e+0)throw e;jt(1,0)}},R:function(e,t,r,n,a){var i=Ft();try{return ke(e)(t,r,n,a)}catch(e){if(Rt(i),e!==e+0)throw e;jt(1,0)}},I:function(e,t,r,n){var a=Ft();try{return ke(e)(t,r,n)}catch(e){if(Rt(a),e!==e+0)throw e;jt(1,0)}},m:function(e){var t=Ft();try{return ke(e)()}catch(e){if(Rt(t),e!==e+0)throw e;jt(1,0)}},c:function(e,t){var r=Ft();try{return ke(e)(t)}catch(e){if(Rt(r),e!==e+0)throw e;jt(1,0)}},f:function(e,t,r){var n=Ft();try{return ke(e)(t,r)}catch(e){if(Rt(n),e!==e+0)throw e;jt(1,0)}},l:function(e,t,r,n){var a=Ft();try{return ke(e)(t,r,n)}catch(e){if(Rt(a),e!==e+0)throw e;jt(1,0)}},j:function(e,t,r,n,a){var i=Ft();try{return ke(e)(t,r,n,a)}catch(e){if(Rt(i),e!==e+0)throw e;jt(1,0)}},K:function(e,t,r,n,a,i){var o=Ft();try{return ke(e)(t,r,n,a,i)}catch(e){if(Rt(o),e!==e+0)throw e;jt(1,0)}},u:function(e,t,r,n,a,i){var o=Ft();try{return ke(e)(t,r,n,a,i)}catch(e){if(Rt(o),e!==e+0)throw e;jt(1,0)}},t:function(e,t,r,n,a,i,o){var s=Ft();try{return ke(e)(t,r,n,a,i,o)}catch(e){if(Rt(s),e!==e+0)throw e;jt(1,0)}},J:function(e,t,r,n,a,i,o,s){var u=Ft();try{return ke(e)(t,r,n,a,i,o,s)}catch(e){if(Rt(u),e!==e+0)throw e;jt(1,0)}},A:function(e,t,r,n,a,i,o,s,u,l,c,h){var f=Ft();try{return ke(e)(t,r,n,a,i,o,s,u,l,c,h)}catch(e){if(Rt(f),e!==e+0)throw e;jt(1,0)}},W:function(e,t,r,n,a,i,o){var s=Ft();try{return kt(e,t,r,n,a,i,o)}catch(e){if(Rt(s),e!==e+0)throw e;jt(1,0)}},V:function(e,t,r,n,a){var i=Ft();try{return Mt(e,t,r,n,a)}catch(e){if(Rt(i),e!==e+0)throw e;jt(1,0)}},i:function(e){var t=Ft();try{ke(e)()}catch(e){if(Rt(t),e!==e+0)throw e;jt(1,0)}},h:function(e,t){var r=Ft();try{ke(e)(t)}catch(e){if(Rt(r),e!==e+0)throw e;jt(1,0)}},d:function(e,t,r){var n=Ft();try{ke(e)(t,r)}catch(e){if(Rt(n),e!==e+0)throw e;jt(1,0)}},k:function(e,t,r,n){var a=Ft();try{ke(e)(t,r,n)}catch(e){if(Rt(a),e!==e+0)throw e;jt(1,0)}},y:function(e,t,r,n,a){var i=Ft();try{ke(e)(t,r,n,a)}catch(e){if(Rt(i),e!==e+0)throw e;jt(1,0)}},D:function(e,t,r,n,a,i){var o=Ft();try{ke(e)(t,r,n,a,i)}catch(e){if(Rt(o),e!==e+0)throw e;jt(1,0)}},na:function(e,t,r,n,a,i,o){var s=Ft();try{ke(e)(t,r,n,a,i,o)}catch(e){if(Rt(s),e!==e+0)throw e;jt(1,0)}},r:function(e,t,r,n,a,i,o,s){var u=Ft();try{ke(e)(t,r,n,a,i,o,s)}catch(e){if(Rt(u),e!==e+0)throw e;jt(1,0)}},v:function(e,t,r,n,a,i,o,s,u,l,c){var h=Ft();try{ke(e)(t,r,n,a,i,o,s,u,l,c)}catch(e){if(Rt(h),e!==e+0)throw e;jt(1,0)}},z:function(e,t,r,n,a,i,o,s,u,l,c,h,f,d,p,y){var v=Ft();try{ke(e)(t,r,n,a,i,o,s,u,l,c,h,f,d,p,y)}catch(e){if(Rt(v),e!==e+0)throw e;jt(1,0)}},Z:function(e,t,r,n){var a=Ft();try{Wt(e,t,r,n)}catch(e){if(Rt(a),e!==e+0)throw e;jt(1,0)}},_:(e,t,r,n,a)=>((e,t,r,n)=>{var a=A[n+40>>2],i={tm_sec:T[n>>2],tm_min:T[n+4>>2],tm_hour:T[n+8>>2],tm_mday:T[n+12>>2],tm_mon:T[n+16>>2],tm_year:T[n+20>>2],tm_wday:T[n+24>>2],tm_yday:T[n+28>>2],tm_isdst:T[n+32>>2],tm_gmtoff:T[n+36>>2],tm_zone:a?G(a):""},o=G(r),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in s)o=o.replace(new RegExp(u,"g"),s[u]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"];function h(e,t,r){for(var n="number"==typeof e?e.toString():e||"";n.length<t;)n=r[0]+n;return n}function f(e,t){return h(e,t,"0")}function d(e,t){function r(e){return e<0?-1:e>0?1:0}var n;return 0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))&&(n=r(e.getDate()-t.getDate())),n}function p(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function y(e){var t=((e,t)=>{for(var r=new Date(e.getTime());t>0;){var n=$t(r.getFullYear()),a=r.getMonth(),i=(n?wt:bt)[a];if(!(t>i-r.getDate()))return r.setDate(r.getDate()+t),r;t-=i-r.getDate()+1,r.setDate(1),a<11?r.setMonth(a+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1))}return r})(new Date(e.tm_year+1900,0,1),e.tm_yday),r=new Date(t.getFullYear(),0,4),n=new Date(t.getFullYear()+1,0,4),a=p(r),i=p(n);return d(a,t)<=0?d(i,t)<=0?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var v={"%a":e=>l[e.tm_wday].substring(0,3),"%A":e=>l[e.tm_wday],"%b":e=>c[e.tm_mon].substring(0,3),"%B":e=>c[e.tm_mon],"%C":e=>f((e.tm_year+1900)/100|0,2),"%d":e=>f(e.tm_mday,2),"%e":e=>h(e.tm_mday,2," "),"%g":e=>y(e).toString().substring(2),"%G":y,"%H":e=>f(e.tm_hour,2),"%I":e=>{var t=e.tm_hour;return 0==t?t=12:t>12&&(t-=12),f(t,2)},"%j":e=>f(e.tm_mday+((e,t)=>{for(var r=0,n=0;n<=t;r+=e[n++]);return r})($t(e.tm_year+1900)?wt:bt,e.tm_mon-1),3),"%m":e=>f(e.tm_mon+1,2),"%M":e=>f(e.tm_min,2),"%n":()=>"\n","%p":e=>e.tm_hour>=0&&e.tm_hour<12?"AM":"PM","%S":e=>f(e.tm_sec,2),"%t":()=>"\t","%u":e=>e.tm_wday||7,"%U":e=>{var t=e.tm_yday+7-e.tm_wday;return f(Math.floor(t/7),2)},"%V":e=>{var t=Math.floor((e.tm_yday+7-(e.tm_wday+6)%7)/7);if((e.tm_wday+371-e.tm_yday-2)%7<=2&&t++,t){if(53==t){var r=(e.tm_wday+371-e.tm_yday)%7;4==r||3==r&&$t(e.tm_year)||(t=1)}}else{t=52;var n=(e.tm_wday+7-e.tm_yday-1)%7;(4==n||5==n&&$t(e.tm_year%400-1))&&t++}return f(t,2)},"%w":e=>e.tm_wday,"%W":e=>{var t=e.tm_yday+7-(e.tm_wday+6)%7;return f(Math.floor(t/7),2)},"%y":e=>(e.tm_year+1900).toString().substring(2),"%Y":e=>e.tm_year+1900,"%z":e=>{var t=e.tm_gmtoff,r=t>=0;return t=(t=Math.abs(t)/60)/60*100+t%60,(r?"+":"-")+String("0000"+t).slice(-4)},"%Z":e=>e.tm_zone,"%%":()=>"%"};for(var u in o=o.replace(/%%/g,"\0\0"),v)o.includes(u)&&(o=o.replace(new RegExp(u,"g"),v[u](i)));o=o.replace(/\0\0/g,"%");var m,g,$,w,_,C=(g=et(m=o)+1,$=new Array(g),Qe(m,$,0,$.length),$);return C.length>t?0:(w=C,_=e,b.set(w,_),C.length-1)})(e,t,r,n)},Ct=function(){var e,t,r,n,o={a:_t};function s(e,t){var r;return Ct=e.exports,g=Ct.pa,R(),Ee=Ct.sa,r=Ct.qa,D.unshift(r),function(){if(k--,i.monitorRunDependencies?.(k),0==k&&I){var e=I;I=null,e()}}(),Ct}if(k++,i.monitorRunDependencies?.(k),i.instantiateWasm)try{return i.instantiateWasm(o,s)}catch(e){w(`Module.instantiateWasm callback failed with error: ${e}`),a(e)}return(e=m,t=x,r=o,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||V(t)||f||"function"!=typeof fetch?q(t,r,n):fetch(t,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,r).then(n,function(e){return w(`wasm streaming compile failed: ${e}`),w("falling back to ArrayBuffer instantiation"),q(t,r,n)}))).catch(a),{}}(),Pt=i._malloc=e=>(Pt=i._malloc=Ct.ra)(e),Tt=i._free=e=>(Tt=i._free=Ct.ta)(e),At=e=>(At=Ct.ua)(e),jt=(e,t)=>(jt=Ct.va)(e,t),St=e=>(St=Ct.wa)(e),Ft=()=>(Ft=Ct.xa)(),Rt=e=>(Rt=Ct.ya)(e),Ot=e=>(Ot=Ct.za)(e),Dt=e=>(Dt=Ct.Aa)(e),Et=(e,t,r)=>(Et=Ct.Ba)(e,t,r),Ut=e=>(Ut=Ct.Ca)(e),Wt=i.dynCall_vij=(e,t,r,n)=>(Wt=i.dynCall_vij=Ct.Da)(e,t,r,n);i.dynCall_ji=(e,t)=>(i.dynCall_ji=Ct.Ea)(e,t),i.dynCall_iij=(e,t,r,n)=>(i.dynCall_iij=Ct.Fa)(e,t,r,n),i.dynCall_jijj=(e,t,r,n,a,o)=>(i.dynCall_jijj=Ct.Ga)(e,t,r,n,a,o),i.dynCall_vijj=(e,t,r,n,a,o)=>(i.dynCall_vijj=Ct.Ha)(e,t,r,n,a,o),i.dynCall_jiji=(e,t,r,n,a)=>(i.dynCall_jiji=Ct.Ia)(e,t,r,n,a);var kt=i.dynCall_iiiiij=(e,t,r,n,a,o,s)=>(kt=i.dynCall_iiiiij=Ct.Ja)(e,t,r,n,a,o,s);i.dynCall_viijii=(e,t,r,n,a,o,s)=>(i.dynCall_viijii=Ct.Ka)(e,t,r,n,a,o,s);var It,Mt=i.dynCall_jiiii=(e,t,r,n,a)=>(Mt=i.dynCall_jiiii=Ct.La)(e,t,r,n,a);function xt(){function e(){It||(It=!0,i.calledRun=!0,F||(z(D),n(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)W(i.postRun.shift());z(E)}()))}k>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)U(i.preRun.shift());z(O)}(),k>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e()))}if(i.dynCall_iiiiijj=(e,t,r,n,a,o,s,u,l)=>(i.dynCall_iiiiijj=Ct.Ma)(e,t,r,n,a,o,s,u,l),i.dynCall_iiiiiijj=(e,t,r,n,a,o,s,u,l,c)=>(i.dynCall_iiiiiijj=Ct.Na)(e,t,r,n,a,o,s,u,l,c),I=function e(){It||xt(),It||(I=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return xt(),r.ready});module.exports=r;
Binary file
Binary file
Binary file
package/dist/index.d.mts CHANGED
@@ -346,8 +346,60 @@ interface WorkerResultMessage {
346
346
  error?: string;
347
347
  }
348
348
  /**
349
- * Converts a HEIC image inside a Web Worker so the main thread stays
350
- * responsive during the (potentially slow) WASM decode.
349
+ * Options for {@link convertManyInWorker}: the {@link convertHeicInWorker}
350
+ * worker options plus the batch semantics of `convertMany`.
351
+ */
352
+ interface WorkerBatchOptions extends Omit<WorkerConvertOptions, 'onProgress'> {
353
+ /**
354
+ * Per-item progress callback: receives the 0-based item index and its
355
+ * progress percentage (normalized 0–100). Fires only for successful items.
356
+ */
357
+ onProgress?: (index: number, percent: number) => void;
358
+ /**
359
+ * Resolve with per-item results instead of rejecting the batch on the
360
+ * first failure; all items run to completion (see
361
+ * `ConvertManyOptions.continueOnError`).
362
+ * @default false
363
+ */
364
+ continueOnError?: boolean;
365
+ }
366
+
367
+ /**
368
+ * Stable, machine-readable error codes attached to every error the library
369
+ * throws (as `HeicConverterError.code`). Codes are part of the public API:
370
+ * they are additive-only and never repurposed, so callers can branch on
371
+ * `error.code` instead of matching on message strings.
372
+ */
373
+ type HeicConverterErrorCode = 'invalid_input' | 'invalid_quality' | 'invalid_resize' | 'invalid_format' | 'invalid_crop' | 'invalid_concurrency' | 'decoder_init_failed' | 'decode_failed' | 'progress_callback_failed' | 'render_encode_failed' | 'unsupported_environment' | 'format_unsupported' | 'aborted' | 'worker_unsupported' | 'worker_load_failed' | 'worker_create_failed' | 'worker_post_failed' | 'worker_failed' | 'worker_timeout' | 'batch_item_failed';
374
+ /**
375
+ * Error thrown by all first-party code paths. Extends `Error` so existing
376
+ * `instanceof Error` / message-based handling keeps working; the `code`
377
+ * (and, for batch failures, `itemIndex`/`itemTotal`/`failedCount`) fields
378
+ * add a structured discriminator without changing message text.
379
+ */
380
+ declare class HeicConverterError extends Error {
381
+ readonly code: HeicConverterErrorCode;
382
+ /** 0-based index of the failing input. Only set on `batch_item_failed` errors. */
383
+ readonly itemIndex?: number;
384
+ /** Total number of inputs in the batch. Only set on `batch_item_failed` errors. */
385
+ readonly itemTotal?: number;
386
+ /** How many items failed overall. Only set on `batch_item_failed` errors. */
387
+ readonly failedCount?: number;
388
+ constructor(code: HeicConverterErrorCode, message: string, options?: {
389
+ cause?: unknown;
390
+ itemIndex?: number;
391
+ itemTotal?: number;
392
+ failedCount?: number;
393
+ });
394
+ }
395
+
396
+ /**
397
+ * Converts a HEIC image inside a Web Worker so the main thread stays responsive
398
+ * during the (potentially slow) WASM decode. This is the public entry point; the
399
+ * implementation lives in `src/worker.ts` and is fetched as a lazy chunk on the
400
+ * first call, so a deployment missing that chunk rejects with
401
+ * `worker_load_failed` (original failure on `cause`) rather than a raw
402
+ * module-load error.
351
403
  *
352
404
  * The worker script is user-provided and must handle the following message
353
405
  * protocol (types are exported as {@link WorkerProgressMessage} and
@@ -380,14 +432,23 @@ interface WorkerResultMessage {
380
432
  * });
381
433
  * ```
382
434
  *
383
- * Only `progress` and `result` messages are understood; any other message
384
- * type is ignored (the first unknown type is reported in the timeout
385
- * diagnostic). Use `workerType: 'module'` when the script uses ES module
386
- * imports (as in the example above); `'classic'` scripts must be
387
- * pre-bundled, since static ES imports are not supported there.
435
+ * Only `progress` and `result` messages are understood; any other message type
436
+ * is ignored (the first unknown type is reported in the timeout diagnostic).
437
+ * Use `workerType: 'module'` when the script uses ES module imports (as above);
438
+ * `'classic'` scripts must be pre-bundled, since static ES imports are not
439
+ * supported there.
388
440
  *
389
- * The `decoder` option is rejected: class instances cannot cross the
390
- * worker boundary; the worker creates its own decoder.
441
+ * Notes that are easy to trip over:
442
+ * - `decoder` is rejected — class instances cannot cross the worker boundary,
443
+ * so the worker creates its own.
444
+ * - `timeoutMs` is a per-call deadline that **includes queueing** for a free
445
+ * worker slot, not just the conversion itself.
446
+ * - An error raised *inside* the worker comes back stringified under
447
+ * `worker_failed`: the numeric `code` does not survive the boundary, so match
448
+ * on the message. Option validation happens here instead, so an invalid
449
+ * option keeps its own code.
450
+ * - Workers are pooled per `workerUrl`, so concurrent callers to the same URL
451
+ * share one bounded set rather than spawning unbounded workers.
391
452
  *
392
453
  * @param input HEIC image as a Blob, File, ArrayBuffer, or Uint8Array.
393
454
  * @param options Conversion options plus the worker script URL.
@@ -398,33 +459,16 @@ declare function convertHeicInWorker<S extends OutputShape = 'blob'>(input: Heic
398
459
  output?: S;
399
460
  }): Promise<ConvertResult<S>>;
400
461
  /**
401
- * Options for {@link convertManyInWorker}: the {@link convertHeicInWorker}
402
- * worker options plus the batch semantics of `convertMany`.
403
- */
404
- interface WorkerBatchOptions extends Omit<WorkerConvertOptions, 'onProgress'> {
405
- /**
406
- * Per-item progress callback: receives the 0-based item index and its
407
- * progress percentage (normalized 0–100). Fires only for successful items.
408
- */
409
- onProgress?: (index: number, percent: number) => void;
410
- /**
411
- * Resolve with per-item results instead of rejecting the batch on the
412
- * first failure; all items run to completion (see
413
- * `ConvertManyOptions.continueOnError`).
414
- * @default false
415
- */
416
- continueOnError?: boolean;
417
- }
418
- /**
419
- * Converts multiple HEIC images inside Web Workers, mirroring
420
- * {@link convertMany} semantics (input order, bounded concurrency,
421
- * `batch_item_failed` aggregation or `continueOnError` per-item results).
422
- * Concurrency is bounded by `maxConcurrentWorkers` (default
423
- * `navigator.hardwareConcurrency` clamped to 1–8): items queue behind the
424
- * worker semaphore, so a large batch never exhausts memory or the browser's
425
- * worker limit. Each item runs in its own worker instance via
426
- * {@link convertHeicInWorker}, which means `decoder` cannot be injected and
427
- * `workerUrl` is required.
462
+ * Converts multiple HEIC images inside Web Workers, mirroring {@link convertMany}
463
+ * semantics (input order, bounded concurrency, `batch_item_failed` aggregation
464
+ * or `continueOnError` per-item results). Concurrency is bounded by
465
+ * `maxConcurrentWorkers` (default `navigator.hardwareConcurrency` clamped to
466
+ * 1–8): items queue behind the worker semaphore, so a large batch never
467
+ * exhausts memory or the browser's worker limit. Each item runs in its own
468
+ * worker instance via {@link convertHeicInWorker}, which means `decoder` cannot
469
+ * be injected and `workerUrl` is required. See that function for the worker
470
+ * script protocol and the caveats about `timeoutMs`, the worker boundary, and
471
+ * `worker_load_failed`.
428
472
  *
429
473
  * ```ts
430
474
  * const blobs = await convertManyInWorker(heicFiles, {
@@ -435,6 +479,10 @@ interface WorkerBatchOptions extends Omit<WorkerConvertOptions, 'onProgress'> {
435
479
  * });
436
480
  * ```
437
481
  *
482
+ * Overloads must mirror `convertManyInWorker` in `src/worker.ts`: the deferred
483
+ * call below erases the union, so drift here is a public typing bug that `tsc`,
484
+ * the unit tests and the bundle guard all fail to catch.
485
+ *
438
486
  * @param inputs HEIC images as Blobs, Files, ArrayBuffers, or Uint8Arrays.
439
487
  * @param options Batch + worker conversion options (see {@link WorkerBatchOptions}).
440
488
  * @returns The converted images in input order, or per-item result entries
@@ -453,35 +501,6 @@ declare function convertManyInWorker<S extends OutputShape = 'blob'>(inputs: Hei
453
501
  continueOnError: boolean;
454
502
  }): Promise<Array<ConvertResult<S> | ConvertItemResult<ConvertResult<S>>>>;
455
503
 
456
- /**
457
- * Stable, machine-readable error codes attached to every error the library
458
- * throws (as `HeicConverterError.code`). Codes are part of the public API:
459
- * they are additive-only and never repurposed, so callers can branch on
460
- * `error.code` instead of matching on message strings.
461
- */
462
- type HeicConverterErrorCode = 'invalid_input' | 'invalid_quality' | 'invalid_resize' | 'invalid_format' | 'invalid_crop' | 'invalid_concurrency' | 'decoder_init_failed' | 'decode_failed' | 'progress_callback_failed' | 'render_encode_failed' | 'unsupported_environment' | 'format_unsupported' | 'aborted' | 'worker_unsupported' | 'worker_create_failed' | 'worker_post_failed' | 'worker_failed' | 'worker_timeout' | 'batch_item_failed';
463
- /**
464
- * Error thrown by all first-party code paths. Extends `Error` so existing
465
- * `instanceof Error` / message-based handling keeps working; the `code`
466
- * (and, for batch failures, `itemIndex`/`itemTotal`/`failedCount`) fields
467
- * add a structured discriminator without changing message text.
468
- */
469
- declare class HeicConverterError extends Error {
470
- readonly code: HeicConverterErrorCode;
471
- /** 0-based index of the failing input. Only set on `batch_item_failed` errors. */
472
- readonly itemIndex?: number;
473
- /** Total number of inputs in the batch. Only set on `batch_item_failed` errors. */
474
- readonly itemTotal?: number;
475
- /** How many items failed overall. Only set on `batch_item_failed` errors. */
476
- readonly failedCount?: number;
477
- constructor(code: HeicConverterErrorCode, message: string, options?: {
478
- cause?: unknown;
479
- itemIndex?: number;
480
- itemTotal?: number;
481
- failedCount?: number;
482
- });
483
- }
484
-
485
504
  /**
486
505
  * Releases any cached decoder resources.
487
506
  *