@faith-tools/bible-sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -8
- package/dist/bible-sdk.js +1 -1
- package/dist/data/effect.js +4 -3
- package/dist/data.js +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/api-bible.js +221 -0
- package/dist/providers/fetch-bible.js +1 -1
- package/dist/providers/helloao.js +1 -1
- package/dist/providers/youversion.js +1 -1
- package/dist/{providers-D_4UrThl.js → providers-Ci0Bdu9f.js} +1 -1
- package/dist/{runtime-C-BCRjZd.js → runtime-CVlBLU4v.js} +16 -7
- package/dist/scripture-inline.js +1 -1
- package/dist/types/data-effect.d.ts +22 -0
- package/dist/types/data-helpers.d.ts +2 -2
- package/dist/types/data-types.d.ts +14 -1
- package/dist/types/data.d.ts +11 -0
- package/dist/types/providers/api-bible.d.ts +37 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Choose the surface your application needs:
|
|
|
9
9
|
- **[Bible data SDK](#bible-data-sdk):** Discover versions, books, and chapters, and retrieve Scripture with attribution and display guidance. Use async/await or native Effect v4 without a DOM.
|
|
10
10
|
- **[Browser components](#getting-started):** Display passages, choose passages and translations, or turn Bible references into Scripture cards. No framework is required.
|
|
11
11
|
|
|
12
|
-
Bible text comes from [HelloAO's Free Use Bible API](https://bible.helloao.org/docs/) by default, with no API key. The [YouVersion Platform](https://developers.youversion.com/)
|
|
12
|
+
Bible text comes from [HelloAO's Free Use Bible API](https://bible.helloao.org/docs/) by default, with no API key. The [YouVersion Platform](https://developers.youversion.com/), [fetch.bible](https://fetch.bible/), and server-only [API.Bible](https://api.bible/) are optional providers. Bible SDK is an independent community project, not affiliated with YouVersion or Life.Church.
|
|
13
13
|
|
|
14
14
|
> Bible SDK is in preview. Expect changes before 1.0.
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ Attributes (including `data-scripture-inline-ignore`), `scriptureInline()` and o
|
|
|
23
23
|
|
|
24
24
|
## Bible data SDK
|
|
25
25
|
|
|
26
|
-
The data SDK works in a browser, Node, or Bun without components, DOM access, CSS injection, or page-wide component defaults. Import `/data` for async/await, or [`/data/effect`](#native-effect-api) for native Effect programs. Both use the same Effect v4 implementation, validation, errors, and caching.
|
|
26
|
+
The data SDK works in a browser, Node, or Bun without components, DOM access, CSS injection, or page-wide component defaults. API.Bible is server-only because its API key is private. Import `/data` for async/await, or [`/data/effect`](#native-effect-api) for native Effect programs. Both use the same Effect v4 implementation, validation, errors, and caching.
|
|
27
27
|
|
|
28
28
|
Install the package. You do not need to import or directly install Effect for async/await. Effect remains a transitive runtime dependency and contributes to bundle size.
|
|
29
29
|
|
|
@@ -46,7 +46,7 @@ console.log(passage.attribution.text);
|
|
|
46
46
|
console.log(passage.instructions);
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
The example returns John 3:16–18 as `passage.text`, with separate attribution and instructions. HelloAO is the default. To use
|
|
49
|
+
The example returns John 3:16–18 as `passage.text`, with separate attribution and instructions. HelloAO is the default. To use another source, [choose a provider](#choose-a-bible-provider). See the [data reference](#data-reference) for supported passage IDs and result fields.
|
|
50
50
|
|
|
51
51
|
### Native Effect API
|
|
52
52
|
|
|
@@ -277,13 +277,14 @@ const english = versions.filter((version) => version.language === "en");
|
|
|
277
277
|
|
|
278
278
|
## Choose a Bible provider
|
|
279
279
|
|
|
280
|
-
Use HelloAO by default, or select fetch.bible or
|
|
280
|
+
Use HelloAO by default, or select fetch.bible, YouVersion, or API.Bible. All four support the same data API; API.Bible runs only on your server. Each client uses one provider; it never substitutes a translation or falls back to another source.
|
|
281
281
|
|
|
282
282
|
| Provider | Setup | Default version ID |
|
|
283
283
|
| --- | --- | --- |
|
|
284
284
|
| [HelloAO](https://bible.helloao.org/docs/) | No API key. Default provider. | `BSB` |
|
|
285
285
|
| [fetch.bible](https://fetch.bible/) | No API key. Declare your usage. | `eng_bsb` |
|
|
286
286
|
| [YouVersion](https://platform.youversion.com/) | Requires a public app key. | `3034` |
|
|
287
|
+
| [API.Bible](https://api.bible/) | Your own private key and official SDK client, server-only. | Explicitly choose an accessible edition. |
|
|
287
288
|
|
|
288
289
|
Version IDs belong to one provider: `BSB`, `eng_bsb`, and `3034` are not interchangeable. Review the selected translation's license before use. Free access and usage filters do not grant commercial, redistribution, or offline rights.
|
|
289
290
|
|
|
@@ -316,6 +317,48 @@ console.log(passage.text, passage.attribution);
|
|
|
316
317
|
|
|
317
318
|
Set `usage.commercial` to your application's actual use. The example declares noncommercial use. The `derivatives`, `attributionless`, and `limitless` filters default to `false`, `false`, and `true`. Filters are not legal permission; review each translation's terms. The adapter uses the official collection.
|
|
318
319
|
|
|
320
|
+
### API.Bible: your own server-side client
|
|
321
|
+
|
|
322
|
+
Install the [official SDK](https://api.bible/sdk) alongside Bible SDK on a Node 20+ or Bun server. This adapter uses the `node` export condition; other server runtimes need Node-compatible package resolution:
|
|
323
|
+
|
|
324
|
+
```sh
|
|
325
|
+
pnpm add @faith-tools/bible-sdk @americanbible/api-bible-sdk
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Each application supplies its own registered API.Bible account/key and applicable licenses. Bible SDK supplies adapter code, not access through a shared account. Keep the key in a server secret, never a browser bundle, `VITE_*` variable, element attribute, URL, or log. The adapter export rejects browser resolution and construction; that is not a replacement for keeping secrets out of client code.
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
// Server code only. The same provider works with /data/effect.
|
|
332
|
+
import { createBibleClient } from "@americanbible/api-bible-sdk";
|
|
333
|
+
import { createScriptureClient } from "@faith-tools/bible-sdk/data";
|
|
334
|
+
import { createApiBibleProvider } from "@faith-tools/bible-sdk/providers/api-bible";
|
|
335
|
+
|
|
336
|
+
const apiKey = process.env.API_DOT_BIBLE_API_KEY;
|
|
337
|
+
if (!apiKey) throw new Error("Set the server's API.Bible key.");
|
|
338
|
+
|
|
339
|
+
const scripture = createScriptureClient({
|
|
340
|
+
provider: createApiBibleProvider({
|
|
341
|
+
client: createBibleClient({ apiKey, retry: { maxAttempts: 1 } }),
|
|
342
|
+
defaultVersionId: "bba9f40183526463-01", // BSB; verify access for your app.
|
|
343
|
+
}),
|
|
344
|
+
});
|
|
345
|
+
const passage = await scripture.getPassage({ passageId: "JHN.3.16-18" });
|
|
346
|
+
// Your application renders text/attribution, preserves publisher metadata,
|
|
347
|
+
// and reports passage.reporting.token on each actual web display.
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Set upstream `maxAttempts: 1` so Effect owns retries and deadlines, and avoid SDK hooks/custom transports that log credentials or response bodies. Choose `defaultVersionId` from your account's `listVersions()` results, not a HelloAO or YouVersion ID. No edition is chosen automatically. Chapters exclude intro entries. Plain text preserves scriptural superscriptions and poetry, omits editorial headings and notes, and does not claim KJV numbering. Incomplete endpoint coverage fails rather than silently claiming the whole requested range; the upstream passage endpoint can limit results to 200 verses.
|
|
351
|
+
|
|
352
|
+
**Application obligations:** review the [Terms](https://api.bible/terms-and-conditions), [AUP and account agreements](https://care.api.bible/article/392-how-to-create-a-new-app), and each translation's metadata. Returned instructions are guidance, not certification of compliance.
|
|
353
|
+
|
|
354
|
+
- **Display reporting:** preserve `reporting.token` and report every actual web view to [FUMS](https://care.api.bible/article/417-understanding-fums), including cached displays. Do not report fetches/prefetches as views. The host owns device/session IDs and privacy requirements; the adapter sends no analytics automatically.
|
|
355
|
+
- **Attribution:** render `attribution.text` and links below Scripture, identify the translation, and provide the required linked copyright/about page. Preserve `publisher.copyrightHtml` and `publisher.infoHtml`; these are untrusted upstream HTML, so sanitize before rendering. Keep the visible API.Bible source link.
|
|
356
|
+
- **Caching and removal:** discovery/publisher caches refresh after 14 days. Refresh your own copies by `cache.expiresAt` (epoch milliseconds), never retain metadata/content over 30 days without refresh, and honor shorter removal/revocation deadlines. Some requests require removal within 24 hours; termination provisions can require immediate deletion. A TTL is not offline permission.
|
|
357
|
+
- **Plan and content restrictions:** Starter is noncommercial even for public-domain editions. Each app owner must accept the required account agreements, including the Statement of Orthodoxy, and check licenses, content-integrity requirements, territorial/export restrictions, and economic sanctions. Violations can lead to suspension/revocation, removal duties, audits, fees, and indemnification.
|
|
358
|
+
- **DRM and AI:** the published terms require application-level DRM restricting copying/distribution, printing over 100 verses, territory and device counts; they do not specify a universally compliant implementation. Keeping the key private does not satisfy that whole obligation. [Express Licensing guidance](https://care.api.bible/article/405-express-licensing-faqs) restricts copyrighted and Creative Commons Scripture in LLM prompts as well as training. Public-domain runtime prompts are permitted; confirm training, TTS, and exports separately.
|
|
359
|
+
|
|
360
|
+
This is a data-only adapter, not a browser-component or script-tag provider. Your application owns the backend and display/reporting integration. Do not pass this provider directly to `defineScripturePassage()` or add an API.Bible key attribute to markup.
|
|
361
|
+
|
|
319
362
|
### YouVersion: add a public app key
|
|
320
363
|
|
|
321
364
|
Get a public app key from [YouVersion Platform](https://platform.youversion.com/). Replace `YOUR_PUBLIC_APP_KEY` in this example:
|
|
@@ -394,10 +437,13 @@ Running `getPassage()` produces a Schema-validated, serializable `ScripturePassa
|
|
|
394
437
|
| Field | Meaning |
|
|
395
438
|
| --- | --- |
|
|
396
439
|
| `text` | Plain Scripture, without verse numbers, editorial headings, notes, or attribution. Meaningful breaks and wording remain. This is not a rich-text or lossless source model. |
|
|
397
|
-
| `provider`, `source` | Provider ID, source version ID, and source URL: the HelloAO chapter endpoint, fetch.bible TXT book endpoint,
|
|
440
|
+
| `provider`, `source` | Provider ID, source version ID, and source URL: the HelloAO chapter endpoint, fetch.bible TXT book endpoint, YouVersion HTTPS API base, or API.Bible website. Not a complete request log. |
|
|
398
441
|
| `requestedPassageId`, `passageId`, `reference` | Requested and resolved USFM IDs and a readable reference. |
|
|
399
442
|
| `version` | ID, title, abbreviation, available language metadata, and the source language identifier. |
|
|
400
443
|
| `attribution`, `licenses` | Attribution text, source/license URLs, and available license restrictions. Empty license metadata does not grant permission. |
|
|
444
|
+
| `publisher` | When supplied, `copyrightHtml` and `infoHtml` preserve untrusted publisher notices for your linked copyright/about page. Sanitize before rendering. |
|
|
445
|
+
| `reporting` | When supplied, `{ kind: "api-bible-fums", token }` identifies usage-reporting data. The host reports actual web displays, including cache hits. Fetching does not report views. |
|
|
446
|
+
| `cache` | When supplied, `expiresAt` is an epoch-millisecond downstream refresh deadline. It can reflect publisher metadata fetched earlier than the passage. Removal requests can override it. |
|
|
401
447
|
| `numbering` | `kjv` for the official fetch.bible collection; `unknown` when not established. |
|
|
402
448
|
| `sourceLimitations` | When supplied, documented trimming for the selected edition: `kind: "source-trimming"`, inclusive `startPassageId` and `endPassageId`, and `appliesToRequest`. Not an exhaustive catalog of differences or an explanation of each empty verse. |
|
|
403
449
|
| `display` | Text-rendering metadata: `format: "text"`, `whitespace: "pre-wrap"`, `attributionPlacement: "after-passage"`, and direction/language when known. Optional `nativeHtml` lists container attributes and stylesheets for separately requested native HTML. |
|
|
@@ -414,6 +460,7 @@ The built-in instruction codes are stable identifiers for explanatory guidance,
|
|
|
414
460
|
| `plain-text-limits` | Account for the representation's omitted rich formatting. |
|
|
415
461
|
| `fetch-bible-normalization`, `fetch-bible-license` | Check numbering, `sourceLimitations`, and the selected translation's terms. |
|
|
416
462
|
| `youversion-commercial-use`, `youversion-ai-use`, `youversion-terms` | Review paid-use disclosure, AI restrictions, and account/content agreements. |
|
|
463
|
+
| `api-bible-fums`, `api-bible-publisher`, `api-bible-cache`, `api-bible-usage`, `api-bible-ai` | Implement actual-view reporting, safe publisher notices, downstream refresh/removal, account/plan/license/DRM controls, and AI restrictions. |
|
|
417
464
|
| `fetch-bible-native-html`, `youversion-native-html` | Apply `display.nativeHtml` resources only for separately requested native HTML. |
|
|
418
465
|
|
|
419
466
|
License restriction keys remain provider-specific. Review missing or unfamiliar fields:
|
|
@@ -421,6 +468,7 @@ License restriction keys remain provider-specific. Review missing or unfamiliar
|
|
|
421
468
|
- **HelloAO:** `attribution` is `required` or `not-required`. `commercialUse` and `derivatives` are `allowed` or `not-allowed`. `copyleft` and `publicDomain` are booleans.
|
|
422
469
|
- **fetch.bible:** `forbid_commercial`, `forbid_derivatives`, `forbid_attributionless`, `forbid_limitless`, and `forbid_other` describe restrictions. `true` prohibits that use; `false` means the filter found no such restriction, not legal permission. `forbid_derivatives: "same-license"` requires share-alike. Multiple licenses are alternative filtered choices, not cumulative grants; select and follow a suitable license.
|
|
423
470
|
- **YouVersion:** No unified license restriction flags are supplied.
|
|
471
|
+
- **API.Bible:** No unified license restriction flags are supplied. Review the returned publisher notices and API.Bible account/content terms.
|
|
424
472
|
|
|
425
473
|
To render plain text in a browser:
|
|
426
474
|
|
|
@@ -439,7 +487,7 @@ An overlapping range does not establish why a particular verse is empty. Psalm r
|
|
|
439
487
|
|
|
440
488
|
### Errors, caching, and custom providers
|
|
441
489
|
|
|
442
|
-
Async methods reject with the original `ScriptureError` for expected failures. Its `code` distinguishes `invalid_reference`, `unavailable`, `unsupported`, `authentication`, `rate_limit`, `network`, `timeout`, and `invalid_response`. Upstream HTTP errors are classified when their status is available; other source failures use `network`. The original error
|
|
490
|
+
Async methods reject with the original `ScriptureError` for expected failures. Its `code` distinguishes `invalid_reference`, `unavailable`, `unsupported`, `authentication`, `rate_limit`, `network`, `timeout`, and `invalid_response`. Upstream HTTP errors are classified when their status is available; other source failures use `network`. The original error can remain in `cause`, which can contain sensitive provider diagnostics, so do not expose it to readers. API.Bible discards upstream diagnostics and response-validation causes. Programming defects are not converted to expected errors.
|
|
443
491
|
|
|
444
492
|
```ts
|
|
445
493
|
import { createScriptureClient, ScriptureError } from "@faith-tools/bible-sdk/data";
|
|
@@ -459,12 +507,13 @@ Built-in source requests retry network and rate-limit failures twice, with expon
|
|
|
459
507
|
Each client's discovery cache and each built-in adapter's payload cache have at most 256 entries, not a byte limit. Upstream response memoization is disabled; failed or malformed payloads can be downloaded again.
|
|
460
508
|
|
|
461
509
|
- HelloAO shares validated chapters. fetch.bible shares whole books and retains its collection catalog and loaded localized book-name metadata, whose size depends on the collection.
|
|
510
|
+
- API.Bible discovery and publisher metadata expire after 14 days; passage payloads are not memoized. Other built-in cache entries retain their existing lifetime until clearing/eviction. Custom data providers can set `cacheTimeToLive` to an Effect `Duration.Input` for client discovery caches. API.Bible downstream caches must honor `cache.expiresAt` and any earlier removal request.
|
|
462
511
|
- Run `client.clearCache()`, or provide its Layer to `scripture.clearCache`, to clear that client's discovery and its provider's payload caches. Shared providers share those caches. This does not invalidate other clients' discovery or the components' separate display/catalog caches.
|
|
463
512
|
- The client does not memoize passage data or YouVersion attribution. Persistent caching is not provided.
|
|
464
513
|
|
|
465
514
|
### Effect configuration and custom providers
|
|
466
515
|
|
|
467
|
-
Effects support fiber interruption and `Effect.runPromise(program, { signal })`. The simple async API does not expose an interruption option. HelloAO
|
|
516
|
+
Effects support fiber interruption and `Effect.runPromise(program, { signal })`. The simple async API does not expose an interruption option. HelloAO and API.Bible receive the transport's abort signal. YouVersion and fetch.bible SDKs do not expose transport cancellation; interruption stops waiting and ignores their late results, but does not claim to stop their underlying downloads. Components interrupt obsolete loads and use scoped listener/timer cleanup.
|
|
468
517
|
|
|
469
518
|
Named spans connect client operations, provider operations, and upstream requests to your application's Effect tracer. The SDK does not choose a telemetry backend or export content, credentials, or errors to a hosted service. Configure an Effect tracer or OTLP layer in your application.
|
|
470
519
|
|
|
@@ -527,7 +576,7 @@ Releases use [Changesets](https://github.com/changesets/changesets). Run `pnpm c
|
|
|
527
576
|
## Credits
|
|
528
577
|
|
|
529
578
|
- From [Cameron Pak](https://cameronpak.com), part of [Faith Tools Software Solutions, LLC](https://faith.tools).
|
|
530
|
-
- Default Bible text from [HelloAO's Free Use Bible API](https://bible.helloao.org/docs/), with optional [YouVersion Platform](https://developers.youversion.com/)
|
|
579
|
+
- Default Bible text from [HelloAO's Free Use Bible API](https://bible.helloao.org/docs/), with optional [YouVersion Platform](https://developers.youversion.com/), [fetch.bible](https://fetch.bible/), and server-only [API.Bible](https://api.bible/) support.
|
|
531
580
|
- References parsed by [grab-bcv](https://github.com/dpshde/grab-bcv), and links open [route.bible](https://route.bible), both by [Dylan Shade](https://github.com/dpshde).
|
|
532
581
|
- Docs styled with [Sensible UI](https://sensibleui.com).
|
|
533
582
|
|
package/dist/bible-sdk.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
`);return t.omitReference||(n=`${this.formatReference(e.book,{chapter:e.chapter.number})}
|
|
18
18
|
${n.trim()}`),n.trim()}getSimpleChapterVerseText(e,t={}){let n=``;for(let r of e.chapter.content)r.type===`verse`?(t.omitVerseNumbers||(n+=`[${r.number}] `),n+=r.text.trim()+` `):r.type===`line_break`&&(n=n.trim()+`
|
|
19
19
|
`);return t.omitReference||(n=`${this.formatReference(e.book,{chapter:e.chapter.number})}
|
|
20
|
-
${n.trim()}`),n.trim()}getWordText(e,t){let n=e.content[t.contentIndex];return typeof n==`string`?n.slice(t.start,t.end):typeof n==`object`&&n&&`text`in n?n.text.slice(t.start,t.end):``}getVerseWords(e,t){return(t.verses[e.number.toString()]??[]).map(t=>({...t,text:this.getWordText(e,t)}))}getSimpleWordText(e,t){return e.text.slice(t.start,t.end)}getSimpleVerseWords(e,t){return(t.verses[e.number.toString()]??[]).map(t=>({...t,text:this.getSimpleWordText(e,t)}))}_getJson(e,t,n,r=!0){let i=this._buildUrl(e,t),a=n?.signal;if(a?.aborted)return Promise.reject(Hy());if(!this._useCache||!r)return this._fetchJson(i,a);let o=this._responseCache.get(i);if(o)return this._waitForSharedRequest(i,o,a);let s=a?new AbortController:null;s&&this._sharedRequests.set(i,{controller:s,waiting:0});let c=this._fetchJson(i,s?.signal).catch(e=>{throw this._responseCache.get(i)===c&&this._responseCache.delete(i),e}).finally(()=>{s&&this._sharedRequests.get(i)?.controller===s&&this._sharedRequests.delete(i)});return this._responseCache.set(i,c),this._waitForSharedRequest(i,c,a)}async _fetchJson(e,t){let n=await(t?fetch(e,{signal:t}):fetch(e));if(n.status<200||n.status>=300)throw Error(`Failed request to ${e}. Status: ${n.status} ${n.statusText}`);return await n.json()}_waitForSharedRequest(e,t,n){let r=this._sharedRequests.get(e);return r&&(r.waiting+=1),n?new Promise((i,a)=>{let o=!1,s=()=>{o||(o=!0,r&&(--r.waiting,r.waiting<=0&&(this._sharedRequests.get(e)===r&&this._sharedRequests.delete(e),this._responseCache.get(e)===t&&this._responseCache.delete(e),r.controller.abort())),a(Hy()))};n.addEventListener(`abort`,s,{once:!0}),t.then(e=>{o||(o=!0,n.removeEventListener(`abort`,s),i(e))},e=>{o||(o=!0,n.removeEventListener(`abort`,s),a(e))})}):t}_buildUrl(e,t){if(/^https?:\/\//i.test(e))return e;let n=t??this.endpoint;return new URL(e,n).href}};function Hy(){let e=Error(`The operation was aborted.`);return e.name=`AbortError`,e}var Uy=R({id:ey,abbreviation:L,title:L,language:I(L),languageName:I(L)}),Wy=R({code:ey,level:Iv([`required`,`recommended`,`notice`]),appliesTo:Iv([`all`,`text`,`html`]),text:ey,urls:I(Nv(L))});R({id:ey,title:L}),R({passageId:ey,number:Zv.check(Jv(0))}),R({provider:ey,source:R({url:L,versionId:ey}),requestedPassageId:ey,passageId:ey,reference:L,text:L,version:Uy.mapFields(e=>({...e,sourceLanguage:I(L)})),attribution:R({text:ey,urls:Nv(L)}),licenses:Nv(R({name:I(L),url:L,restrictions:I(Mv(L,Fv([Av,L])))})),numbering:Iv([`kjv`,`unknown`]),sourceLimitations:I(Nv(R({kind:Tv(`source-trimming`),startPassageId:ey,endPassageId:ey,appliesToRequest:Av}))),display:R({format:Tv(`text`),whitespace:Tv(`pre-wrap`),attributionPlacement:Tv(`after-passage`),direction:I(Iv([`ltr`,`rtl`])),language:I(L),nativeHtml:I(R({containerAttributes:Mv(L,L),stylesheets:Nv(R({kind:Iv([`bible`,`font`]),href:L}))}))}),instructions:Nv(Wy)}),Ia()(`@faith-tools/scripture-inline/data/BibleSource`);var Gy=Iv([`invalid_reference`,`unavailable`,`unsupported`,`authentication`,`rate_limit`,`network`,`timeout`,`invalid_response`]),Ky=class extends hy()(`ScriptureError`,{code:Gy,message:L,cause:I(iy())}){get retryable(){return this.code===`network`||this.code===`rate_limit`}},qy=L.check(Uv(e=>{try{return new Intl.Locale(e),!0}catch{return`Invalid source language tag.`}})),Jy=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function Yy(e,t){let n=Jy(e);return/^https?:\/\//i.test(t)?`<a href="${Jy(t)}">${n}</a>`:n}var Xy=L.check(Wv(/^[1-4A-Z][A-Z0-9]{2}\.[1-9]\d*(?:\.[1-9]\d*(?:-[1-9]\d*)?)?$/)),Zy=L.check(Wv(/^[1-4A-Z][A-Z0-9]{2}$/)),Qy=ay.check(Xv(),Jv(0),Yv(2**53-1)),$y=R({book:Zy,chapter:Qy,first:I(Qy),last:I(Qy)}).check(Uv(e=>e.first===void 0||e.last>=e.first||`Range endpoints must be ascending.`)),eb=e=>new Ky({code:`invalid_reference`,message:`Use an uppercase USFM verse, ascending range, or chapter with positive safe integers. Ranges cannot cross chapters.`,cause:e}),tb=Np(function*(e){let[t,n,r]=(yield*xv(Xy)(e).pipe(gp(eb))).split(`.`),[i,a=i]=r?.split(`-`)??[];return yield*xv($y)({book:t,chapter:n,first:i,last:a}).pipe(gp(eb))}),nb=e=>xv(Zy)(e).pipe(gp(eb));function rb(e,t,n){return!e.length||t!==void 0&&(!e.includes(t)||!e.includes(n))?N(new Ky({code:`unavailable`,message:`Passage is not available in this version.`})):rp}function ib(){return[{code:`display-attribution`,level:`required`,appliesTo:`all`,text:`Display attribution.text after the passage, separately from Scripture. Preserve its wording and supplied source and license links.`},{code:`preserve-scripture`,level:`required`,appliesTo:`text`,text:`Render text as text, not HTML. Preserve wording, punctuation, meaningful line and paragraph breaks, and display.direction when supplied. Do not add notes or headings to the Scripture text.`},{code:`verify-license`,level:`required`,appliesTo:`all`,text:`Check the selected translation's license and provider terms for your intended use. Missing metadata is not permission for commercial use, redistribution, modifications, or offline storage.`},{code:`plain-text-limits`,level:`notice`,appliesTo:`text`,text:`Plain text omits verse numbers, editorial headings, notes, and rich formatting. It is not a lossless representation of the source edition.`}]}function ab(){let e=new Map,t=jp(vy(t=>np(()=>e.get(t)()),{capacity:256,requireServicesAt:`lookup`,timeToLive:e=>Kd(e)?ns:ts}));return{get(n,r){return np(()=>(e.set(n,r),xy(t,n).pipe(wp(M(()=>{e.get(n)===r&&e.delete(n)})))))},clear:Ey(t)}}var ob=e=>t=>xv(e)(t).pipe(gp(e=>new Ky({code:`invalid_response`,message:`Bible provider returned invalid data.`,cause:e}))),sb=T(`@faith-tools/scripture-inline/RequestPolicy`,{defaultValue:()=>({timeout:`15 seconds`,retries:2})}),cb=R({status:kv}),lb=R({response:cb}),ub=Sv(cb),db=Sv(lb),fb=Sv(R({code:L}));function pb(e){if(e instanceof Ky)return e;let t=ub(e),n=db(e),r=fb(e),i=t._tag===`Some`?t.value.status:n._tag===`Some`?n.value.response.status:Number(e instanceof Error?/(?:Status: |^)(\d{3})\b/.exec(e.message)?.[1]:void 0),a=r._tag===`Some`&&r.value.code===`missing_passage_attribution`?`unavailable`:e instanceof SyntaxError||e instanceof Error&&/^\$?ZodError$/.test(e.name)?`invalid_response`:i===401||i===403?`authentication`:i===429?`rate_limit`:i>=400&&i<500?`unavailable`:`network`;return new Ky({code:a,message:`Bible provider request failed (${a}).`,cause:e})}var mb=Pp(`scripture.request`)(function*(e,t,n=!0){yield*Tp({operation:e});let r=yield*sb;return yield*ep({try:t,catch:pb}).pipe(_p({times:n?r.retries:0,schedule:kf(`100 millis`),while:e=>e.retryable}),yp({duration:r.timeout,orElse:()=>N(new Ky({code:`timeout`,message:`Bible provider request timed out.`}))}))});function hb(e){return{id:e.id,defaultVersionId:e.defaultVersionId,effects:e,listVersions:()=>Ap(e.listVersions()),getPassage:(t,n)=>Ap(e.getPassageDisplay(t,n))}}function z(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function gb(e){return e&&Object.assign(yb,e),yb}var _b,vb,yb,bb=o((()=>{Object.freeze({status:`aborted`}),_b=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},vb=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},yb={}}));function xb(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Sb(e,t){return typeof t==`bigint`?t.toString():t}function Cb(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wb(e){return e==null}function Tb(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function B(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Bb)return r===void 0&&(r=Bb,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Eb(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Db(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ob(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kb(e){if(Ob(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Ob(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ab(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function jb(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function V(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Mb(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function Nb(e,t){if(!kb(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return jb(e,Db(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Eb(this,`shape`,n),n},checks:[]}))}function Pb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Fb(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ib(e){return typeof e==`string`?e:e?.message}function Lb(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Ib(e.inst?._zod.def?.error?.(e))??Ib(t?.error?.(e))??Ib(n.customError?.(e))??Ib(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Rb(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function zb(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Bb,Vb,Hb,Ub,Wb=o((()=>{Bb=Symbol(`evaluating`),Vb=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Hb=new Set([`string`,`number`,`symbol`]),Ub={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}})),Gb,Kb,qb,Jb=o((()=>{bb(),Wb(),Gb=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Sb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kb=z(`$ZodError`,Gb),qb=z(`$ZodError`,Gb,{Parent:Error})})),Yb,Xb,Zb,Qb,$b,ex,tx,nx,rx=o((()=>{bb(),Jb(),Wb(),Yb=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _b;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Lb(e,a,gb())));throw Vb(t,i?.callee),t}return o.value},Xb=Yb(qb),Zb=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Lb(e,a,gb())));throw Vb(t,i?.callee),t}return o.value},Qb=Zb(qb),$b=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _b;return a.issues.length?{success:!1,error:new(e??Kb)(a.issues.map(e=>Lb(e,i,gb())))}:{success:!0,data:a.value}},ex=$b(qb),tx=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Lb(e,i,gb())))}:{success:!0,data:a.value}},nx=tx(qb)})),ix,ax,ox,sx,cx,lx,ux,dx=o((()=>{ix=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ax=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ox=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,`${ox}`,sx=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},cx=/^-?\d+$/,lx=/^-?\d+(?:\.\d+)?/,ux=/^(?:true|false)$/i})),fx,px,mx,hx,gx,_x,vx,yx,bx,xx,Sx,Cx=o((()=>{bb(),dx(),Wb(),fx=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),px={number:`number`,bigint:`bigint`,object:`date`},mx=z(`$ZodCheckLessThan`,(e,t)=>{fx.init(e,t);let n=px[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hx=z(`$ZodCheckGreaterThan`,(e,t)=>{fx.init(e,t);let n=px[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gx=z(`$ZodCheckNumberFormat`,(e,t)=>{fx.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ub[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=cx)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),_x=z(`$ZodCheckMaxLength`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Rb(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vx=z(`$ZodCheckMinLength`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Rb(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yx=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Rb(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bx=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;fx.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xx=z(`$ZodCheckRegex`,(e,t)=>{bx.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Sx=z(`$ZodCheckOverwrite`,(e,t)=>{fx.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),wx=o((()=>{})),Tx,Ex=o((()=>{Tx={major:4,minor:1,patch:12}}));function Dx(e,t,n){e.issues.length&&t.issues.push(...Fb(n,e.issues)),t.value[n]=e.value}function Ox(e,t,n,r){e.issues.length&&t.issues.push(...Fb(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function kx(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Mb(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ax(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ox(e,n,i,t))):Ox(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function jx(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Pb(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Lb(e,r,gb())))}),t)}function Mx(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function Nx(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function Px(e){return e.value=Object.freeze(e.value),e}function Fx(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(zb(e))}}var H,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x,eS,tS,nS,rS=o((()=>{Cx(),bb(),rx(),dx(),Wb(),Ex(),H=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tx;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Pb(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new _b;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Pb(e,t))});else{if(e.issues.length===t)continue;r||=Pb(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Pb(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new _b;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new _b;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=ex(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return nx(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Ix=z(`$ZodString`,(e,t)=>{H.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??sx(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Lx=z(`$ZodStringFormat`,(e,t)=>{bx.init(e,t),Ix.init(e,t)}),Rx=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ix(e)}else t.pattern??=ix();Lx.init(e,t)}),zx=z(`$ZodURL`,(e,t)=>{Lx.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:ax.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Bx=z(`$ZodNumber`,(e,t)=>{H.init(e,t),e._zod.pattern=e._zod.bag.pattern??lx,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Vx=z(`$ZodNumber`,(e,t)=>{gx.init(e,t),Bx.init(e,t)}),Hx=z(`$ZodBoolean`,(e,t)=>{H.init(e,t),e._zod.pattern=ux,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ux=z(`$ZodUnknown`,(e,t)=>{H.init(e,t),e._zod.parse=e=>e}),Wx=z(`$ZodArray`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Dx(t,n,e))):Dx(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),Gx=z(`$ZodObject`,(e,t)=>{if(H.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Cb(()=>kx(t));B(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ob,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Ox(n,t,e,s))):Ox(n,t,e,s)}return i?Ax(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Kx=z(`$ZodUnion`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),B(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),B(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),B(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Tb(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>jx(t,i,e,a)):jx(s,i,e,a)}}),qx=z(`$ZodRecord`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!kb(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Fb(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Fb(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Lb(e,r,gb())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Fb(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Fb(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Jx=z(`$ZodEnum`,(e,t)=>{H.init(e,t);let n=xb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Hb.has(typeof e)).map(e=>typeof e==`string`?Ab(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Yx=z(`$ZodLiteral`,(e,t)=>{if(H.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ab(e):e?Ab(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),Xx=z(`$ZodTransform`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new vb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new _b;return n.value=i,n}}),Zx=z(`$ZodOptional`,(e,t)=>{H.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Tb(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Mx(t,e.value)):Mx(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Qx=z(`$ZodNullable`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Tb(e.source)}|null)$`):void 0}),B(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),$x=z(`$ZodCatch`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lb(e,n,gb()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lb(e,n,gb()))},input:e.value}),e.issues=[]),e)}}),eS=z(`$ZodPipe`,(e,t)=>{H.init(e,t),B(e._zod,`values`,()=>t.in._zod.values),B(e._zod,`optin`,()=>t.in._zod.optin),B(e._zod,`optout`,()=>t.out._zod.optout),B(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Nx(e,t.in,n)):Nx(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Nx(e,t.out,n)):Nx(r,t.out,n)}}),tS=z(`$ZodReadonly`,(e,t)=>{H.init(e,t),B(e._zod,`propValues`,()=>t.innerType._zod.propValues),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Px):Px(r)}}),nS=z(`$ZodCustom`,(e,t)=>{fx.init(e,t),H.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fx(t,n,r,e));Fx(i,n,r,e)}})})),iS=o((()=>{}));function aS(e,t){return new e({type:`string`,...V(t)})}function oS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}function sS(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}function cS(e,t){return new e({type:`number`,checks:[],...V(t)})}function lS(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}function uS(e,t){return new e({type:`boolean`,...V(t)})}function dS(e){return new e({type:`unknown`})}function fS(e,t){return new mx({check:`less_than`,...V(t),value:e,inclusive:!0})}function pS(e,t){return new hx({check:`greater_than`,...V(t),value:e,inclusive:!1})}function mS(e,t){return new hx({check:`greater_than`,...V(t),value:e,inclusive:!0})}function hS(e){return pS(0,e)}function gS(e){return mS(0,e)}function _S(e,t){return new _x({check:`max_length`,...V(t),maximum:e})}function U(e,t){return new vx({check:`min_length`,...V(t),minimum:e})}function vS(e,t){return new yx({check:`length_equals`,...V(t),length:e})}function yS(e,t){return new xx({check:`string_format`,format:`regex`,...V(t),pattern:e})}function bS(e){return new Sx({check:`overwrite`,tx:e})}function xS(){return bS(e=>e.trim())}function SS(){return bS(e=>e.toUpperCase())}function CS(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}var wS=o((()=>{Cx(),Wb()})),TS=o((()=>{})),ES=o((()=>{bb(),rx(),Jb(),rS(),Cx(),Ex(),Wb(),dx(),iS(),wx(),wS(),TS()})),DS=o((()=>{ES()}));function W(e){return aS(WS,e)}function OS(e){return oS(KS,e)}function kS(e){return sS(qS,e)}function AS(e){return cS(JS,e)}function G(e){return lS(YS,e)}function jS(e){return uS(XS,e)}function MS(){return dS(ZS)}function K(e,t){return new QS({type:`array`,element:e,...V(t)})}function NS(e){let t=e._zod.def.shape;return LS(Object.keys(t))}function q(e,t){let n={type:`object`,shape:e??{},...V(t)};return new $S(n)}function PS(e,t){return Nb(e,t)}function FS(e,t){return new eC({type:`union`,options:e,...V(t)})}function IS(e,t,n){return new tC({type:`record`,keyType:e,valueType:t,...V(n)})}function LS(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new nC({type:`enum`,entries:n,...V(t)})}function RS(e,t){return new rC({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}function zS(e){return new iC({type:`transform`,transform:e})}function J(e){return new aC({type:`optional`,innerType:e})}function Y(e){return new oC({type:`nullable`,innerType:e})}function BS(e,t){return new sC({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function VS(e,t){return new cC({type:`pipe`,in:e,out:t})}function HS(e){return new lC({type:`readonly`,innerType:e})}function US(e,t={}){return CS(uC,e,t)}var X,WS,GS,KS,qS,JS,YS,XS,ZS,QS,$S,eC,tC,nC,rC,iC,aC,oC,sC,cC,lC,uC,dC=o((()=>{ES(),DS(),X=z(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);H.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Xb(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ex(e,t,n),e.parseAsync=async(t,n)=>Qb(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>nx(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>jb(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e))}),WS=z(`ZodMiniString`,(e,t)=>{Ix.init(e,t),X.init(e,t)}),GS=z(`ZodMiniStringFormat`,(e,t)=>{Lx.init(e,t),WS.init(e,t)}),KS=z(`ZodMiniUUID`,(e,t)=>{Rx.init(e,t),GS.init(e,t)}),qS=z(`ZodMiniURL`,(e,t)=>{zx.init(e,t),GS.init(e,t)}),JS=z(`ZodMiniNumber`,(e,t)=>{Bx.init(e,t),X.init(e,t)}),YS=z(`ZodMiniNumberFormat`,(e,t)=>{Vx.init(e,t),JS.init(e,t)}),XS=z(`ZodMiniBoolean`,(e,t)=>{Hx.init(e,t),X.init(e,t)}),ZS=z(`ZodMiniUnknown`,(e,t)=>{Ux.init(e,t),X.init(e,t)}),QS=z(`ZodMiniArray`,(e,t)=>{Wx.init(e,t),X.init(e,t)}),$S=z(`ZodMiniObject`,(e,t)=>{Gx.init(e,t),X.init(e,t),B(e,`shape`,()=>t.shape)}),eC=z(`ZodMiniUnion`,(e,t)=>{Kx.init(e,t),X.init(e,t)}),tC=z(`ZodMiniRecord`,(e,t)=>{qx.init(e,t),X.init(e,t)}),nC=z(`ZodMiniEnum`,(e,t)=>{Jx.init(e,t),X.init(e,t),e.options=Object.values(t.entries)}),rC=z(`ZodMiniLiteral`,(e,t)=>{Yx.init(e,t),X.init(e,t)}),iC=z(`ZodMiniTransform`,(e,t)=>{Xx.init(e,t),X.init(e,t)}),aC=z(`ZodMiniOptional`,(e,t)=>{Zx.init(e,t),X.init(e,t)}),oC=z(`ZodMiniNullable`,(e,t)=>{Qx.init(e,t),X.init(e,t)}),sC=z(`ZodMiniCatch`,(e,t)=>{$x.init(e,t),X.init(e,t)}),cC=z(`ZodMiniPipe`,(e,t)=>{eS.init(e,t),X.init(e,t)}),lC=z(`ZodMiniReadonly`,(e,t)=>{tS.init(e,t),X.init(e,t)}),uC=z(`ZodMiniCustom`,(e,t)=>{nS.init(e,t),X.init(e,t)})})),fC=o((()=>{ES()})),pC=o((()=>{ES(),DS(),dC(),fC(),Wb(),dC()})),mC=o((()=>{pC(),pC()})),hC=o((()=>{mC()})),gC,_C,vC,yC,bC,xC=o((()=>{hC(),gC=/^[a-z]{2,3}(?:-[A-Z][a-z]{3})?$/,_C=W().check(xS(),U(1,`Language ID must be a non-empty string`),yS(gC,`Language ID must match BCP 47 format (language or language+script)`)),vC=q({id:W().check(yS(gC,`BCP 47 id limited to language or language+script`)),language:W().check(yS(/^[a-z]{2,3}$/,`ISO 639 canonical language subtag`)),script:J(Y(W().check(yS(/^[A-Z][a-z]{3}$/,`Script must match ISO 15924 format (e.g., "Latn")`)))),script_name:J(Y(W())),aliases:J(K(W())),display_names:J(IS(W(),W())),scripts:J(K(W().check(yS(/^[A-Z][a-z]{3}$/,`ISO 15924 script code`)))),variants:J(K(W())),countries:J(K(W().check(yS(/^[A-Z]{2}$/,`ISO 3166-1 alpha-2 country code`)))),text_direction:J(LS([`ltr`,`rtl`])),writing_population:J(G()),speaking_population:J(G()),default_bible_id:J(Y(G()))}),yC=W().check(xS(),vS(2,`Country code must be a 2-character ISO 3166-1 alpha-2 code`),SS()),bC=q({page_size:J(FS([G().check(hS()),RS(`*`)])),fields:J(K(NS(vC))),page_token:J(W()),country:J(yC)}).check(US(e=>e?.page_size!==`*`||e.fields&&e.fields.length>=1&&e.fields.length<=3,{error:`page_size="*" requires 1-3 fields to be specified`,path:[`page_size`,`fields`]}))})),Z,SC=o((()=>{Z={permittedVersionIds:void 0,excludedVersionIds:void 0,permittedLanguageTags:void 0}}));function CC(){return Z.permittedVersionIds!==void 0||Z.permittedLanguageTags!==void 0||(Z.excludedVersionIds?.length??0)>0}function wC(){return Z.permittedLanguageTags!==void 0}function TC(){return{permittedVersionIds:Z.permittedVersionIds,excludedVersionIds:Z.excludedVersionIds,permittedLanguageTags:Z.permittedLanguageTags}}function EC(e){if(Z.excludedVersionIds?.includes(e))return!0;let t=Z.permittedVersionIds;return t!==void 0&&!t.includes(e)}function DC(e){if(EC(e.id))return!1;let t=Z.permittedLanguageTags;return t===void 0||e.languageTag!==void 0&&t.includes(e.languageTag)}function OC(e){let t=Z.permittedLanguageTags;return t===void 0||t.includes(e)}function kC(){throw Object.assign(Error(`This app is not allowed to access this Bible version.`),{status:403})}function AC(e){if(!e)return;if(!CC())return[...e];let t=new Set(e);return t.add(`id`),wC()&&t.add(`language_tag`),[...t]}function jC(e){if(!e)return;if(!wC())return[...e];let t=new Set(e);return t.add(`id`),[...t]}function MC(e,t){return`${LC}${JSON.stringify({t:e,s:t})}`}function NC(e){if(e.startsWith(LC))try{let t=RC.safeParse(JSON.parse(e.slice(LC.length)));return t.success?t.data:void 0}catch{return}}function PC(e){if(!e)return{skip:0};let t=NC(e);return t?{pageToken:t.t??void 0,skip:t.s}:{pageToken:e,skip:0}}async function FC(e,t,n){let r=n.fieldsNeeded(),i=t.page_size;return r&&(e[`fields[]`]=r,n.isFilterActive()&&i===`*`&&r.length>3&&delete e.page_size),n.isFilterActive()?IC(n.fetchPage,n.isUsable,i,t.page_token):n.fetchPage(t.page_token)}async function IC(e,t,n,r){let i=PC(r);if(n===`*`){let n=await e(i.pageToken),r=n.data.filter(t).slice(i.skip),a=n.next_page_token;for(;a;){let n=await e(a);r.push(...n.data.filter(t)),a=n.next_page_token}return{data:r,next_page_token:null,total_size:r.length}}let a=i.pageToken,o=i.skip,s=await e(a),c=n??s.data.length,l=[],u=s;for(;;){let n=u.data.filter(t).slice(o),r=n.slice(0,c-l.length);if(l.push(...r),n.length>r.length)return{data:l,next_page_token:MC(a??null,o+r.length),total_size:s.total_size};if(o=0,l.length>=c||!u.next_page_token)return{data:l,next_page_token:u.next_page_token??null,total_size:s.total_size};a=u.next_page_token,u=await e(a)}}var LC,RC,zC=o((()=>{SC(),hC(),LC=`yv-vf1:`,RC=q({t:Y(W()),s:G().check(gS())})}));async function BC(e,t={}){if(t.page_size===`*`){let e=t.fields?.length??0;if(e<1||e>3)throw Error(VC)}let n=bC.parse(t),r={};n.country!==void 0&&(r.country=n.country),n.fields!==void 0&&(r[`fields[]`]=n.fields),n.page_size!==void 0&&(r.page_size=n.page_size);let i=jC(n.fields);return FC(r,t,{fieldsNeeded:()=>i,isFilterActive:wC,fetchPage:t=>{let n={...r};return t&&(n.page_token=t),e.get(`/v1/languages`,n)},isUsable:e=>OC(e.id)})}var VC,HC=o((()=>{xC(),zC(),VC=`page_size="*" requires 1-3 fields to be specified`}));async function UC(e,t){return _C.parse(t),e.get(`/v1/languages/${t}`)}var WC=o((()=>{xC()})),GC,KC=o((()=>{HC(),WC(),GC=class{client;constructor(e){this.client=e}async getLanguages(e={}){return BC(this.client,e)}async getLanguage(e){return UC(this.client,e)}}})),qC,JC,YC,XC,ZC,QC=o((()=>{hC(),qC=q({short_name:J(W()),long_name:J(W())}),JC=q({formatted_address:J(W()),formatted_locality:J(W()),place_id:J(W()),latitude:J(AS()),longitude:J(AS()),administrative_area_level_1:J(qC),locality:J(qC),country:J(qC)}),YC=q({id:OS(),parent_organization_id:J(Y(OS())),name:J(W()),description:J(W()),email:J(Y(W())),phone:J(Y(W())),primary_language:J(W()),website_url:J(W()),address:J(JC)}),XC=VS(W().check(xS()),OS({error:`Organization ID must be a valid UUID`})),ZC=class{client;constructor(e){this.client=e}async getOrganization(e){let t=XC.parse(e),n=await this.client.get(`/v1/organizations/${t}`);return YC.parse(n)}}}));function $C(e){return Number.isSafeInteger(e)&&e>0}function ew(e){let t=pw.exec(e);if(!t)return null;let n=t[1],r=t[2];if(n===void 0||r===void 0||!$C(Number(r)))return null;if(t[3]===void 0)return{book:n,chapter:r,verses:[]};let i=Number(t[3]);if(!$C(i))return null;if(t[4]===void 0)return{book:n,chapter:r,verses:[i]};let a=Number(t[4]);if(!$C(a)||a<i||a-i+1>mw)return null;let o=[];for(let e=i;e<=a;e+=1)o.push(e);return{book:n,chapter:r,verses:o}}function tw(e){if(Intl.Segmenter===void 0)return Array.from(e).slice(0,100).join(``);hw??=new Intl.Segmenter(void 0,{granularity:`grapheme`});let t=hw.segment(e)[Symbol.iterator](),n=0;for(let r=0;r<100;r+=1){let r=t.next();if(r.done)return e;n=r.value.index+r.value.segment.length}return e.slice(0,n)}function nw(e){return ew(e)!==null}function rw(e){return e.trim().replace(/_/g,`-`).toLowerCase()}function iw(e){let t=rw(W().check(xS(),U(1,`Language ranges must be a non-empty string`)).parse(e));return W().check(yS(_w,vw)).parse(t),t}function aw(e){let t=Array.isArray(e)?[...e]:[e];return K(W()).check(U(1,`At least one language range is required`)).parse(t),t.map(iw)}function ow(e){let t={text:e.text};return e.source==null?t:{...t,source:e.source}}function sw(e){return nw(e.reference)?{id:e.reference}:null}function cw(e){let t={verses:e.verses.map(sw).filter(e=>e!==null),didYouMean:e.did_you_mean,searchInsteadFor:e.search_instead_for??null,nextPageToken:e.next_page_token??null};return e.user_intent==null?t:{...t,userIntent:e.user_intent}}function lw(e){let t={text:e.text,subtopics:e.subtopics};return e.id===void 0?t:{...t,id:e.id}}function uw(e){return{topics:e.topics.map(lw),didYouMean:e.did_you_mean,searchInsteadFor:e.search_instead_for??null,totalSize:e.total_size}}function dw(e){return e.id.length===0||!nw(e.passage_id)?null:{id:e.id,passageId:e.passage_id}}function fw(e){let t={verses:(e.verses??[]).flatMap(e=>{let t=ww.safeParse(e);if(!t.success)return[];let n=sw(t.data);return n===null?[]:[n]}),topics:(e.topics??[]).flatMap(e=>{let t=Fw.safeParse(e);return t.success?[lw(t.data)]:[]}),images:(e.images??[]).map(e=>{let t=Lw.safeParse(e);return t.success?dw(t.data):null}).filter(e=>e!==null),didYouMean:e.did_you_mean??[],searchInsteadFor:e.search_instead_for??null};return e.user_intent==null?t:{...t,userIntent:e.user_intent}}var pw,mw,hw,gw,_w,vw,yw,bw,xw,Sw,Cw,ww,Tw,Ew,Dw,Ow,kw,Aw,jw,Mw,Nw,Pw,Fw,Iw,Lw,Rw,zw=o((()=>{hC(),pw=/^([A-Z0-9]{1,3})\.(\d+)(?:\.(\d+)(?:-(\d+))?)?$/,mw=250,gw=[`unknown`,`topical`,`text`,`reference`],_w=/^(\*|[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*)$/,vw=`Language range must be "*" or a Basic Language Range (e.g., "en", "en-US")`,yw=q({text:W(),source:J(W())}),bw=q({queries:K(yw)}),xw=q({text:W(),source:J(Y(W()))}),Sw=q({data:K(xw)}),Cw=q({id:W()}),q({verses:K(Cw),userIntent:J(W()),didYouMean:K(W()),searchInsteadFor:J(Y(W())),nextPageToken:J(Y(W()))}),ww=q({reference:W()}),Tw=q({verses:K(ww),user_intent:J(Y(W())),did_you_mean:K(W()),search_instead_for:J(Y(W())),next_page_token:J(Y(W()))}),Ew=q({id:J(Y(G())),text:W(),subtopics:K(W())}),q({topics:K(Ew),didYouMean:K(W()),searchInsteadFor:J(Y(W())),totalSize:G()}),Dw=q({id:J(Y(G())),text:W(),subtopics:K(W())}),Ow=q({topics:K(Dw),did_you_mean:K(W()),search_instead_for:J(Y(W())),total_size:G()}),kw=W().check(xS(),U(1,`Query must be between 1 and 100 characters`),US(e=>tw(e)===e,`Query must be between 1 and 100 characters`)),Aw=W().check(xS(),U(1,`Query must be a non-empty string`)),jw=q({userIntent:J(W()),pageSize:J(G().check(mS(1),fS(99))),pageToken:J(W())}),Mw=LS([`verses`,`topics`,`images`],{error:`Search field must be verses, topics, or images`}),Nw=VS(K(Mw).check(U(1,`At least one search field is required`)),zS(e=>[...new Set(e)])),Pw=q({userIntent:J(LS(gw)),fields:J(Nw)}),Fw=PS(Dw,{id:Y(G())}),Iw=q({id:W().check(U(1)),passageId:W().check(U(1))}),Lw=q({id:W(),passage_id:W()}),Rw=q({verses:J(K(MS())),topics:J(K(MS())),user_intent:J(Y(W())),did_you_mean:J(K(W())),search_instead_for:J(Y(W())),images:J(K(MS()))}),q({verses:K(Cw),topics:K(Ew),images:K(Iw),userIntent:J(W()),didYouMean:K(W()),searchInsteadFor:Y(W())})}));function Bw(e){if(e===``||e==null)return{queries:[]};let t=Sw.safeParse(e);if(!t.success)throw Error(`Unexpected search-queries API response: ${t.error.message}`);return bw.parse({queries:t.data.data.map(ow)})}async function Vw(e,t,n){let r=Aw.parse(t),i=aw(n);return Bw(await e.get(`/v1/search-queries`,{query:r,"language_ranges[]":i}))}async function Hw(e,t){let n=aw(t);return Bw(await e.get(`/v1/search-queries`,{trending:!0,"language_ranges[]":n}))}var Uw=o((()=>{zw()}));async function Ww(e,t,n){let r=kw.parse(t),i=aw(n),a=await e.get(`/v1/search-topics`,{query:r,"language_ranges[]":i}),o=Ow.safeParse(a);if(!o.success)throw Error(`Unexpected search-topics API response: ${o.error.message}`);return uw(o.data)}var Gw=o((()=>{zw()})),Kw,qw,Jw,Yw,Xw,Zw,Qw,$w,eT,tT,nT,rT,iT,aT,oT,sT,cT,lT=o((()=>{hC(),Kw=3034,qw=[`old_testament`,`new_testament`,`deuterocanon`],Jw=`GEN.EXO.LEV.NUM.DEU.JOS.JDG.RUT.1SA.2SA.1KI.2KI.1CH.2CH.EZR.NEH.EST.JOB.PSA.PRO.ECC.SNG.ISA.JER.LAM.EZK.DAN.HOS.JOL.AMO.OBA.JON.MIC.NAM.HAB.ZEP.HAG.ZEC.MAL.MAT.MRK.LUK.JHN.ACT.ROM.1CO.2CO.GAL.EPH.PHP.COL.1TH.2TH.1TI.2TI.TIT.PHM.HEB.JAS.1PE.2PE.1JN.2JN.3JN.JUD.REV.TOB.JDT.ESG.WIS.SIR.BAR.LJE.S3Y.SUS.BEL.1MA.2MA.3MA.4MA.1ES.2ES.MAN.PS2.ODA.PSS.3ES.EZA.5EZ.6EZ.DAG.PS3.2BA.LBA.JUB.ENO.1MQ.2MQ.3MQ.REP.4BA.LAO.LKA`.split(`.`),Yw={GEN:`old_testament`,EXO:`old_testament`,LEV:`old_testament`,NUM:`old_testament`,DEU:`old_testament`,JOS:`old_testament`,JDG:`old_testament`,RUT:`old_testament`,"1SA":`old_testament`,"2SA":`old_testament`,"1KI":`old_testament`,"2KI":`old_testament`,"1CH":`old_testament`,"2CH":`old_testament`,EZR:`old_testament`,NEH:`old_testament`,EST:`old_testament`,JOB:`old_testament`,PSA:`old_testament`,PRO:`old_testament`,ECC:`old_testament`,SNG:`old_testament`,ISA:`old_testament`,JER:`old_testament`,LAM:`old_testament`,EZK:`old_testament`,DAN:`old_testament`,HOS:`old_testament`,JOL:`old_testament`,AMO:`old_testament`,OBA:`old_testament`,JON:`old_testament`,MIC:`old_testament`,NAM:`old_testament`,HAB:`old_testament`,ZEP:`old_testament`,HAG:`old_testament`,ZEC:`old_testament`,MAL:`old_testament`,MAT:`new_testament`,MRK:`new_testament`,LUK:`new_testament`,JHN:`new_testament`,ACT:`new_testament`,ROM:`new_testament`,"1CO":`new_testament`,"2CO":`new_testament`,GAL:`new_testament`,EPH:`new_testament`,PHP:`new_testament`,COL:`new_testament`,"1TH":`new_testament`,"2TH":`new_testament`,"1TI":`new_testament`,"2TI":`new_testament`,TIT:`new_testament`,PHM:`new_testament`,HEB:`new_testament`,JAS:`new_testament`,"1PE":`new_testament`,"2PE":`new_testament`,"1JN":`new_testament`,"2JN":`new_testament`,"3JN":`new_testament`,JUD:`new_testament`,REV:`new_testament`,TOB:`deuterocanon`,JDT:`deuterocanon`,ESG:`deuterocanon`,WIS:`deuterocanon`,SIR:`deuterocanon`,BAR:`deuterocanon`,LJE:`deuterocanon`,S3Y:`deuterocanon`,SUS:`deuterocanon`,BEL:`deuterocanon`,"1MA":`deuterocanon`,"2MA":`deuterocanon`,"3MA":`deuterocanon`,"4MA":`deuterocanon`,"1ES":`deuterocanon`,"2ES":`deuterocanon`,MAN:`deuterocanon`,PS2:`deuterocanon`,ODA:`deuterocanon`,PSS:`deuterocanon`,"3ES":`deuterocanon`,EZA:`deuterocanon`,"5EZ":`deuterocanon`,"6EZ":`deuterocanon`,DAG:`deuterocanon`,PS3:`deuterocanon`,"2BA":`deuterocanon`,LBA:`deuterocanon`,JUB:`deuterocanon`,ENO:`deuterocanon`,"1MQ":`deuterocanon`,"2MQ":`deuterocanon`,"3MQ":`deuterocanon`,REP:`deuterocanon`,"4BA":`deuterocanon`,LAO:`deuterocanon`,LKA:`new_testament`},Xw=q({id:W(),passage_id:W(),title:W()}),Zw=G({error:`Verse must be an integer`}).check(hS(`Verse must be a positive integer`)),Qw=q({id:W(),passage_id:W(),title:W(),verses:J(K(Xw))}),$w=G({error:`Chapter must be an integer`}).check(hS(`Chapter must be a positive integer`)),eT=LS(qw),tT=q({id:W(),passage_id:W(),title:W()}),nT=W().check(vS(3)),rT=FS([...Jw.map(e=>RS(e)),nT]),q({id:rT,title:W(),full_title:W(),abbreviation:J(W()),canon:eT,intro:J(tT),chapters:J(K(Qw))}),iT=W().check(xS(),U(3,`Book ID must be exactly 3 characters`),_S(3,`Book ID must be exactly 3 characters`)),aT=q({id:G(),abbreviation:W(),promotional_content:J(Y(W())),copyright:J(Y(W())),info:J(Y(W())),publisher_url:J(Y(W())),language_tag:W(),localized_abbreviation:W(),localized_title:W(),organization_id:J(Y(W())),title:W(),books:K(rT),youversion_deep_link:kS()}),oT=G().check(hS(`Version ID must be a positive integer`)),sT=W().check(xS(),U(1,`Language ranges must be a non-empty string`)),cT=J(q({page_size:J(FS([G().check(hS()),RS(`*`)])),page_token:J(W()),fields:J(K(NS(aT))),all_available:J(jS())})).check(US(e=>e?.page_size!==`*`||e.fields&&e.fields.length>=1&&e.fields.length<=3,{error:`page_size="*" requires 1-3 fields to be specified`,path:[`page_size`,`fields`]}))}));async function uT(e,t,n,r,i={}){let a=kw.parse(t);oT.parse(n);let o=aw(r),s=Pw.parse(i),c={query:a,bible_id:n,"language_ranges[]":o};s.userIntent!==void 0&&(c.user_intent=s.userIntent),s.fields!==void 0&&(c[`fields[]`]=s.fields);let l=await e.get(`/v1/search-unified`,c),u=Rw.safeParse(l);if(!u.success)throw Error(`Unexpected search-unified API response: ${u.error.message}`);return fw(u.data)}var dT=o((()=>{zw(),lT()}));async function fT(e,t,n,r={}){let i=kw.parse(t);oT.parse(n),jw.parse(r);let a={query:i,bible_id:n};r.userIntent!==void 0&&(a.user_intent=r.userIntent),r.pageSize!==void 0&&(a.page_size=r.pageSize),r.pageToken!==void 0&&(a.page_token=r.pageToken);let o=await e.get(`/v1/search-verses`,a),s=Tw.safeParse(o);if(!s.success)throw Error(`Unexpected search-verses API response: ${s.error.message}`);return cw(s.data)}var pT=o((()=>{zw(),lT()})),mT,hT=o((()=>{Uw(),Gw(),dT(),pT(),mT=class{client;constructor(e){this.client=e}async getSuggestedQueries(e,t){return Vw(this.client,e,t)}async getTrendingQueries(e){return Hw(this.client,e)}async searchVerses(e,t,n){return fT(this.client,e,t,n)}async searchTopics(e,t){return Ww(this.client,e,t)}async searchUnified(e,t,n,r){return uT(this.client,e,t,n,r)}}}));function gT(e){if(!e.appKey.trim())throw Error(`A non-empty app key is required to build Bible stylesheet resources.`);let t=e.apiHost||`api.youversion.com`;return[{kind:`bible`,rel:`stylesheet`,href:_T},{kind:`font`,rel:`stylesheet`,href:`https://${t}/v1/fonts/1/stylesheet?app_key=${encodeURIComponent(e.appKey)}`}]}var _T,vT=o((()=>{_T=`https://cdn.youversion.com/platform/1/bible.css`}));function yT(e){return e.body?Array.from(e.body.children):[]}function bT(e){if(e.length===0)return;let t=e.map(e=>e.getAttribute(`dir`));if(t.every(e=>e===`ltr`))return`ltr`;if(t.every(e=>e===`rtl`))return`rtl`}function xT(e){let t=e.body??e.documentElement;for(let e of Array.from(t.querySelectorAll(`*`))){let t=e.tagName;if(NT.has(t))e.remove();else if(!MT.has(t))e.replaceWith(...Array.from(e.childNodes));else for(let t of Array.from(e.attributes)){let n=t.name.toLowerCase();(n.startsWith(`on`)||!PT.has(n)&&!n.startsWith(`data-`))&&e.removeAttribute(t.name)}}}function ST(e){let t=`.p, p, .d, .q, .q1, .q2, .q3, .q4, .qm, .qm1, .qm2, .qm3, .qm4, .qr, .qc, .m, .mi, .pi, .pi1, .pi2, .pi3, .pi4, .pc, .pr, .pm, .pmo, .pmc, .pmr, .li, .li1, .li2, .li3, .li4`;function n(e,t,n){let r=Array.from(t.childNodes);if(r.length===0)return;let i=e.createElement(`span`);i.className=`yv-v`,i.setAttribute(`v`,n);let a=r[0];a&&t.insertBefore(i,a),r.forEach(e=>{i.appendChild(e)})}function r(e,r,i,a){if(!i)return;let o=i.nextElementSibling;for(;o&&o!==a;)if(o.classList.contains(`yv-h`)||o.matches(`.s1, .s2, .s3, .s4, .ms, .ms1, .ms2, .ms3, .ms4, .mr, .sp, .sr, .qa, .r`))o=o.nextElementSibling;else{if(o.querySelector(`.yv-v[v]`))break;o.matches(t)&&n(e,o,r),o=o.nextElementSibling}}function i(e,t,n,i){t&&(n?t!==n&&r(e,i,t,n):r(e,i,t))}function a(e,n,r){let a=e.getAttribute(`v`);if(!a)return;let s=r[n+1],c=u(e,s);if(c.length===0)return;let l=e.closest(t),d=s?.closest(t)||null,f=e.ownerDocument;o(e,a,c),i(f,l,d,a)}function o(e,t,n){let r=e.ownerDocument.createElement(`span`);r.className=`yv-v`,r.setAttribute(`v`,t);let i=n[0];i&&e.parentNode?.insertBefore(r,i),n.forEach(e=>{r.appendChild(e)}),e.remove()}function s(e){return e.nodeType===1?e:null}function c(e,t){if(e===t)return!0;let n=s(e);return!!(t&&n?.contains(t))}function l(e){return s(e)?.classList.contains(`yv-h`)===!0}function u(e,t){let n=[],r=e.nextSibling;for(;r&&!c(r,t);)l(r)||n.push(r),r=r.nextSibling;return n}Array.from(e.querySelectorAll(`.yv-v[v]`)).forEach(a)}function CT(e){let t=0;e.querySelectorAll(`.yv-n.f`).forEach(e=>{let n=e.closest(`.yv-v[v]`)?.getAttribute(`v`);e.setAttribute(kT,n??`intro-${t++}`)})}function wT(e,t){for(let n of t){let t=n.getAttribute(kT);if(!t)continue;let r=n.previousSibling,i=n.nextSibling,a=r?.textContent??``,o=i?.textContent??``,s=a.length>0&&!/\s$/.test(a),c=o.length>0&&jT.test(o);s&&c&&n.parentNode&&n.parentNode.insertBefore(e.createTextNode(` `),n);let l=e.createElement(`span`);l.setAttribute(`data-verse-footnote`,t),l.setAttribute(`data-verse-footnote-content`,n.innerHTML),n.replaceWith(l)}}function TT(e){e.querySelectorAll(`.yv-vlbl, .va`).forEach(e=>{let t=e.textContent||``;t.endsWith(OT)||(e.textContent=t+OT)})}function ET(e){e.querySelectorAll(`table`).forEach(e=>{let t=e.querySelectorAll(`tr`);if(t.length===0)return;let n=0;t.forEach(e=>{let t=0;e.querySelectorAll(`td, th`).forEach(e=>{t+=parseInt(e.getAttribute(`colspan`)||`1`,10)}),n=Math.max(n,t)}),n>1&&t.forEach(e=>{let t=e.querySelectorAll(`td, th`);t.length===1&&parseInt(t[0].getAttribute(`colspan`)||`1`,10)<n&&t[0].setAttribute(`colspan`,n.toString())})})}function DT(e,t){let n=t.parseHtml(e);xT(n);let r=yT(n);if(r.length>0&&r.every(e=>e.hasAttribute(AT)))return TT(n),{html:t.serializeHtml(n),direction:bT(r)};ST(n),CT(n),wT(n,Array.from(n.querySelectorAll(`.yv-n.f`))),TT(n),ET(n);for(let e of yT(n))e.setAttribute(AT,``);return{html:t.serializeHtml(n),direction:bT(yT(n))}}var OT,kT,AT,jT,MT,NT,PT,FT=o((()=>{OT=`\xA0`,kT=`data-footnote-key`,AT=`data-yv-transformed`,jT=/^[^\s.,;:!?)}\]'"'»›]/,MT=new Set([`DIV`,`P`,`SPAN`,`SUP`,`SUB`,`EM`,`STRONG`,`I`,`B`,`SMALL`,`BR`,`SECTION`,`TABLE`,`THEAD`,`TBODY`,`TR`,`TD`,`TH`]),NT=new Set([`SCRIPT`,`STYLE`,`IFRAME`,`OBJECT`,`EMBED`,`SVG`,`MATH`,`FORM`,`INPUT`,`BUTTON`,`TEXTAREA`,`SELECT`,`TEMPLATE`,`LINK`,`META`,`BASE`,`NOSCRIPT`]),PT=new Set([`class`,`v`,`colspan`,`rowspan`,`dir`,`usfm`])}));function IT(e){return oT.parse(e)}function LT(e){return iT.parse(e)}function RT(e){return $w.parse(e)}async function zT(e,t){IT(t),EC(t)&&kC();let n=await e.get(`/v1/bibles/${t}`);return DC({id:n.id,languageTag:n.language_tag})||kC(),n}async function BT(e,t){EC(t)&&kC(),wC()&&await zT(e,t)}async function VT(e,t,n,r){return IT(t),LT(n),RT(r),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}`)}var HT=o((()=>{zC(),lT()})),UT=s(((e,t)=>{t.exports={}}));function WT(e,t,n){t!==void 0&&ZT.parse(t),n!==void 0&&ZT.parse(n);let r={format:e};return t!==void 0&&(r.include_headings=t),n!==void 0&&(r.include_notes=n),r}async function GT(){if(globalThis.DOMParser)return{parseHtml:e=>new globalThis.DOMParser().parseFromString(e,`text/html`),serializeHtml:e=>e.body.innerHTML};let e;try{e=await Promise.resolve().then(()=>u(UT(),1))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Server-side HTML transformation requires "jsdom". Install it as a dependency or pass transform: false to skip transformation. Original error: ${t}`,{cause:e})}return{parseHtml:t=>new e.JSDOM(`<!DOCTYPE html><html><body>${t}</body></html>`).window.document,serializeHtml:e=>e.body.innerHTML}}async function KT(e,t,n,r=`html`,i,a,o){IT(t);let s=WT(r,i,a);return await BT(e,t),YT(await JT(e,t,n,s),s.format,o)}async function qT(e,t,n,r=`html`,i,a,o){IT(t);let s=WT(r,i,a),c=await JT(e,t,n,s);return YT(XT.parse(c),s.format,o)}async function JT(e,t,n,r){return e.get(`/v1/bibles/${t}/passages/${n}`,r)}async function YT(e,t,n){if(t===`html`&&n!==!1){let t=await GT(),{html:n}=DT(e.content,t);return{...e,content:n}}return e}var XT,ZT,QT=o((()=>{FT(),HT(),hC(),XT=q({id:W(),content:W(),reference:W()}),ZT=jS()}));function $T(e){return e.copyright?.trim()?{text:e.copyright,source:`copyright`}:e.promotional_content?.trim()?{text:e.promotional_content,source:`promotionalContent`}:null}async function eE(e,t){let n=()=>qT(e,t.versionId,t.passageId,`html`,t.includeHeadings,t.includeNotes,!0);if(wC()){let r=await zT(e,t.versionId);return{passage:await n(),version:r}}EC(t.versionId)&&kC();let[r,i]=await Promise.all([n(),zT(e,t.versionId)]);return{passage:r,version:i}}async function tE(e,t){let n=nE.parse(t),r=gT(e.config),i=await eE(e,n),a=aT.parse(i.version),o=$T(a);if(!o)throw new sE(a.id);return{version:a,html:i.passage.content,attribution:o,stylesheets:r,containerAttributes:oE}}var nE,rE,iE,aE,oE,sE,cE=o((()=>{vT(),QT(),HT(),zC(),lT(),hC(),nE=q({versionId:oT,passageId:W().check(xS(),U(1,`Passage ID must be a non-empty string`)),includeHeadings:J(jS()),includeNotes:J(jS())}),rE=q({text:W().check(U(1)),source:LS([`copyright`,`promotionalContent`])}),iE=q({kind:LS([`bible`,`font`]),rel:RS(`stylesheet`),href:kS()}),aE=q({"data-yv-sdk":RS(``),"data-slot":RS(`yv-bible-renderer`)}),q({version:aT,html:W(),attribution:rE,stylesheets:K(iE),containerAttributes:aE}),oE=Object.freeze({"data-yv-sdk":``,"data-slot":`yv-bible-renderer`}),sE=class extends Error{code=`missing_passage_attribution`;versionId;constructor(e){super(`Bible version ${e} has no display attribution.`),this.name=`MissingPassageAttributionError`,this.versionId=e}}}));async function lE(e,t,n){return IT(t),await BT(e,t),e.get(`/v1/bibles/${t}/books`,{...n&&{canon:n}})}async function uE(e,t,n){return IT(t),LT(n),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}`)}async function dE(e,t,n){return IT(t),LT(n),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters`)}async function fE(e,t,n,r){return IT(t),LT(n),RT(r),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}/verses`)}async function pE(e,t,n,r,i){return IT(t),LT(n),RT(r),Zw.parse(i),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}/verses/${i}`)}async function mE(e){return e.get(`/v1/verse_of_the_days`)}async function hE(e,t){return G().check(mS(1),fS(366)).parse(t),e.get(`/v1/verse_of_the_days/${t}`)}var gE=o((()=>{HT(),lT(),hC()}));async function _E(e,t,n,r){let i=Array.isArray(t)?t:[t],a={"language_ranges[]":K(sT).check(U(1,`At least one language range is required`)).parse(i)};if(n&&(a.license_id=n),r?.page_size===`*`){let e=r.fields?.length??0;if(e<1||e>3)throw Error(`page_size="*" requires 1-3 fields to be specified`)}cT.parse(r),r?.page_size&&(a.page_size=r.page_size),r?.fields&&(a[`fields[]`]=r.fields),r?.all_available&&(a.all_available=`true`);let o=AC(r?.fields);return FC(a,r??{},{fieldsNeeded:()=>o,isFilterActive:CC,fetchPage:t=>{let n={...a};return t&&(n.page_token=t),e.get(`/v1/bibles`,n)},isUsable:e=>DC({id:e.id,languageTag:e.language_tag})})}var vE=o((()=>{zC(),lT(),hC()})),yE,bE=o((()=>{cE(),QT(),gE(),HT(),vE(),yE=class{client;constructor(e){this.client=e}async getVersions(e,t,n){return _E(this.client,e,t,n)}async getVersion(e){return zT(this.client,e)}async getBooks(e,t){return lE(this.client,e,t)}async getBook(e,t){return uE(this.client,e,t)}async getChapters(e,t){return dE(this.client,e,t)}async getChapter(e,t,n){return VT(this.client,e,t,n)}async getVerses(e,t,n){return fE(this.client,e,t,n)}async getVerse(e,t,n,r){return pE(this.client,e,t,n,r)}async getPassage(e,t,n=`html`,r,i,a){return KT(this.client,e,t,n,r,i,a)}async getPassageDisplay(e){return tE(this.client,e)}async getIndex(e){return IT(e),await BT(this.client,e),this.client.get(`/v1/bibles/${e}/index`)}async getAllVOTDs(){return mE(this.client)}async getVOTD(e){return hE(this.client,e)}}}));function xE(){return`${CE}=${TE}`}function SE(e){let t=EE.safeParse(e);return t.success?t.data.status:void 0}var CE,wE,TE,EE,DE,OE,kE=o((()=>{hC(),CE=`ReactSDK`,wE=`X-YVP-Sdk`,TE=`2.16.0`,EE=q({status:AS()}),DE=q({message:J(W()),error:J(W())}),OE=class{baseURL;timeout;defaultHeaders;config;constructor(e){this.config={...e};let t=e.apiHost||`api.youversion.com`;if(!t)throw Error(`ApiClient requires a host name. Provide an apiHost in the config.`);this.baseURL=`https://`+t,this.timeout=e.timeout||1e4,this.defaultHeaders={"Content-Type":`application/json`,"X-YVP-App-Key":this.config.appKey,"X-YVP-Installation-Id":this.config.installationId||`web-sdk-default`,[wE]:xE(),...e.additionalHeaders}}buildQueryString(e){if(!e)return``;let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{Array.isArray(n)?n.forEach(n=>t.append(e,String(n))):t.append(e,String(n))});let n=t.toString();return n?`?${n}`:``}async request(e,t={}){let n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout);try{let i=new Headers(this.defaultHeaders);new Headers(t.headers).forEach((e,t)=>{i.set(t,e)});let a=await fetch(e,{...t,signal:n.signal,headers:i});if(clearTimeout(r),!a.ok){let e=process.env.NODE_ENV===`development`,t=`HTTP error! status: ${a.status}`;try{let n=await a.text();if(n)try{let r=DE.safeParse(JSON.parse(n)),i=r.success&&(r.data.message||r.data.error)||n;t=e?i:`Request failed with status ${a.status}`}catch{e&&(t=n)}}catch(t){e&&t instanceof Error&&console.error(`Failed to read error response:`,t.message)}throw Object.assign(Error(t),{status:a.status,statusText:a.statusText})}if(a.headers.get(`content-type`)?.includes(`application/json`)){let e=await a.text();return e?JSON.parse(e):void 0}return await a.text()}catch(e){throw clearTimeout(r),e instanceof Error&&e.name===`AbortError`?Error(`Request timeout after ${this.timeout}ms`):e}}async get(e,t,n){let r=`${this.baseURL}${e}${this.buildQueryString(t)}`;return this.request(r,{method:`GET`,headers:n})}async post(e,t,n,r){let i=`${this.baseURL}${e}${this.buildQueryString(n)}`;return this.request(i,{method:`POST`,body:t?JSON.stringify(t):void 0,headers:r})}async delete(e,t,n){let r=`${this.baseURL}${e}${this.buildQueryString(t)}`;return this.request(r,{method:`DELETE`,headers:n})}}}));function AE(e){try{let t=e();if(t?.getItem instanceof Function)return t}catch{}return null}function jE(e){return AE(()=>globalThis.window?globalThis.window[e]:null)??AE(()=>globalThis[e])}function ME(){return jE(`localStorage`)}function NE(){return jE(`sessionStorage`)}function PE(e,t,n){try{return e?.setItem(t,n),e!==null}catch{return!1}}function FE(e,t){try{e?.removeItem(t)}catch{}}function IE(e){try{e?.clear()}catch{}}var LE,RE,zE,BE,VE,HE,UE,Q,WE=o((()=>{SC(),hC(),LE=q({state:W(),permissions:K(W())}),RE=q({userId:W(),permissions:K(W())}),zE=q({sub:BS(J(W()),void 0),name:BS(J(W()),void 0),profile_picture:BS(J(W()),void 0),email:BS(J(W()),void 0)}),BE=VS(FS([AS(),VS(W().check(yS(/^\d+$/)),zS(Number))]),G().check(hS())),VE=q({access_token:W(),expires_in:BE,id_token:W(),refresh_token:W(),scope:W(),token_type:W()}),HE=q({access_token:W(),expires_in:BE,refresh_token:W(),scope:W(),token_type:W()}),UE=q({name:J(W()),id:J(W()),avatar_url:J(W()),email:J(W())}),Q=class{static _appKey=null;static _installationId=null;static _apiHost=`api.youversion.com`;static _refreshTokenKey=null;static _expiryDateKey=null;static _signInPromptMessage=void 0;static _appName=void 0;static getOrSetInstallationId(){let e=ME();if(!e)return``;let t=e.getItem(`x-yvp-installation-id`);if(t)return t;let n=globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`yvp-${new Date().toISOString()}-${Math.random().toString(36).slice(2,10)}`;return PE(e,`x-yvp-installation-id`,n)?n:``}static saveAuthData(e,t,n){let r=ME(),i=!0;return e===null?FE(r,`accessToken`):i=PE(r,`accessToken`,e)&&i,t===null?FE(r,`refreshToken`):i=PE(r,`refreshToken`,t)&&i,n===null?FE(r,`expiryDate`):i=PE(r,`expiryDate`,n.toISOString())&&i,i}static saveUserInfo(e){let t=ME();return e===null?(FE(t,`userInfo`),!0):PE(t,`userInfo`,JSON.stringify(e))}static clearAuthTokens(){this.saveAuthData(null,null,null),this.saveUserInfo(null),this.clearGrantedPermissions(),this.clearDataExchangeInitiator()}static grantedPermissionsKey=`youversion-platform:granted-permissions`;static get currentUserId(){return this.storedUserInfo?.id??null}static readStoredGrants(){let e=ME()?.getItem(this.grantedPermissionsKey);if(!e)return null;try{let t=RE.safeParse(JSON.parse(e));return t.success?t.data:null}catch{return null}}static writeStoredGrants(e,t){PE(ME(),this.grantedPermissionsKey,JSON.stringify({userId:e,permissions:t}))}static get grantedPermissions(){let e=this.currentUserId;if(!e)return[];let t=this.readStoredGrants();return t?.userId===e?t.permissions:[]}static saveGrantedPermissions(e){let t=this.currentUserId;if(!t)return;let n=new Set([...this.grantedPermissions,...e]);this.writeStoredGrants(t,[...n])}static removeGrantedPermission(e){let t=this.currentUserId;if(!t)return;let n=this.grantedPermissions.filter(t=>t!==e);this.writeStoredGrants(t,n)}static clearGrantedPermissions(){FE(ME(),this.grantedPermissionsKey)}static dataExchangeInitiatorKey=`youversion-platform:data-exchange-initiator`;static saveDataExchangeInitiator(){let e=this.currentUserId;e&&PE(ME(),this.dataExchangeInitiatorKey,e)}static get dataExchangeInitiator(){return ME()?.getItem(this.dataExchangeInitiatorKey)??null}static clearDataExchangeInitiator(){FE(ME(),this.dataExchangeInitiatorKey)}static hasPermission(e){return this.grantedPermissions.includes(e)}static get accessToken(){return ME()?.getItem(`accessToken`)??null}static get refreshToken(){return ME()?.getItem(`refreshToken`)??null}static get storedUserInfo(){let e=ME()?.getItem(`userInfo`);if(!e)return null;try{let t=JSON.parse(e),n=UE.safeParse(t);return n.success?n.data:null}catch{return null}}static get tokenExpiryDate(){let e=ME()?.getItem(`expiryDate`);return e?new Date(e):null}static get appKey(){return this._appKey}static set appKey(e){this._appKey=e}static get installationId(){return this._installationId||=this.getOrSetInstallationId(),this._installationId}static set installationId(e){this._installationId=e||this.getOrSetInstallationId()}static get apiHost(){return this._apiHost}static set apiHost(e){this._apiHost=e}static get refreshTokenKey(){return this._refreshTokenKey}static set refreshTokenKey(e){this._refreshTokenKey=e}static get expiryDateKey(){return this._expiryDateKey}static set expiryDateKey(e){this._expiryDateKey=e}static get signInPromptMessage(){return this._signInPromptMessage}static set signInPromptMessage(e){this._signInPromptMessage=e}static get appName(){return this._appName}static set appName(e){this._appName=e}static get permittedVersionIds(){return Z.permittedVersionIds}static set permittedVersionIds(e){Z.permittedVersionIds=e}static get excludedVersionIds(){return Z.excludedVersionIds}static set excludedVersionIds(e){Z.excludedVersionIds=e}static get permittedLanguageTags(){return Z.permittedLanguageTags}static set permittedLanguageTags(e){Z.permittedLanguageTags=e}}}));function GE(e,t){if(e)return e;let n=Q.accessToken;if(!n)throw Error(`Authentication required. Please provide a token or sign in before ${t}.`);return n}var KE=o((()=>{WE()}));function qE(e){let t=[];for(let[n,r]of e)/^granted_permissions(\[\d*\])?$/.test(n)&&t.push(r);return YE(t)}function JE(e){return e?YE([e]):[]}function YE(e){let t=new Set;for(let n of e)for(let e of n.split(/[,\s]+/))e&&t.add(e);return[...t]}var XE=o((()=>{}));function ZE(e,t,n=Q.apiHost){let r=new URL(`https://${n}/data-exchange`);return r.searchParams.set(`token`,e),r.searchParams.set(`app_key`,t),r.searchParams.set(`x-yvp-app-key`,t),r.toString()}function QE(e){let t=new URLSearchParams(e);if(!t.has(`data_exchange_status`))return null;let n=t.get(`data_exchange_status`);return{status:n===`granted`?`granted`:n===`cancel`?`cancel`:`failure`,grantedPermissions:qE(t)}}function $E(){let e=globalThis.window;if(!e)return null;let t=QE(e.location.search);if(!t)return null;let n=Q.dataExchangeInitiator;Q.clearDataExchangeInitiator();let r=t;if(t.status===`granted`&&t.grantedPermissions.length>0){let e=Q.storedUserInfo?.id??null;n&&e&&n===e?Q.saveGrantedPermissions(t.grantedPermissions):r={status:`failure`,grantedPermissions:[]}}let i=new URL(e.location.href);for(let e of nD)i.searchParams.delete(e);return e.history.replaceState({},``,i.toString()),r}var eD,tD,nD,rD=o((()=>{KE(),XE(),WE(),hC(),q({requested_permissions:K(W())}),eD=q({token:W().check(U(1))}),tD=class{client;constructor(e){this.client=e}getAuthToken(e){return GE(e,`requesting a data exchange`)}async updateToken(e,t){let n=this.client.config.appKey;if(!n)throw Error(`App key is required to request a data exchange token.`);let r=await this.client.post(`/data-exchange/token`,{requested_permissions:e},{"app-key":n},{Authorization:`Bearer ${this.getAuthToken(t)}`}),i=eD.safeParse(r);if(!i.success)throw Error(`Unexpected data exchange token response: ${i.error.message}`);return i.data.token}},nD=[`data_exchange_status`,`granted_permissions`]}));function iD(e){return{version_id:e.bible_id,passage_id:e.passage_id,color:e.color}}var aD,oD,sD,cD,lD,uD,dD,fD=o((()=>{KE(),WE(),zC(),lT(),hC(),aD=/^[0-9a-f]{6}$/i,oD=W().check(yS(aD)),sD=W().check(xS(),U(1,`Passage ID must be a non-empty string`)),cD=W().check(yS(aD,`Color must be a 6-character hex string without #`)),lD=q({bible_id:G().check(hS()),passage_id:W(),color:oD}),uD=q({data:K(lD),next_page_token:J(Y(W()))}),q({version_id:G().check(hS()),passage_id:W(),color:oD}),q({version_id:G().check(hS()),passage_id:W(),color:oD}),q({request_id:W().check(U(1)),highlight:lD}),dD=class{client;constructor(e){this.client=e}getAuthToken(e){return GE(e,`accessing highlights`)}authHeaders(e){return{Authorization:`Bearer ${this.getAuthToken(e)}`}}validateVersionId(e){try{oT.parse(e)}catch{throw Error(`Version ID must be a positive integer`)}}validatePassageId(e){try{sD.parse(e)}catch{throw Error(`Passage ID must be a non-empty string`)}}async assertUsableVersion(e){if(EC(e)&&kC(),Q.permittedLanguageTags===void 0)return;let t=await this.client.get(`/v1/bibles/${e}`);DC({id:t.id,languageTag:t.language_tag})||kC()}validateColor(e){try{cD.parse(e)}catch{throw Error(`Color must be a 6-character hex string without #`)}}generateRequestId(){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`yvp-${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}async getHighlights(e,t){this.validateVersionId(e.version_id),this.validatePassageId(e.passage_id),await this.assertUsableVersion(e.version_id);let n=await this.client.get(`/v1/highlights`,{bible_id:e.version_id,passage_id:e.passage_id},this.authHeaders(t));if(n===``||n==null)return{data:[],next_page_token:null};let r=uD.safeParse(n);if(!r.success)throw Error(`Unexpected highlights API response: ${r.error.message}`);return{data:r.data.data.map(iD),next_page_token:r.data.next_page_token??null}}async createHighlight(e,t){this.validateVersionId(e.version_id),this.validatePassageId(e.passage_id),this.validateColor(e.color),await this.assertUsableVersion(e.version_id);let n=await this.client.post(`/v1/highlights`,{request_id:this.generateRequestId(),highlight:{bible_id:e.version_id,passage_id:e.passage_id,color:e.color.toLowerCase()}},void 0,this.authHeaders(t)),r=lD.safeParse(n);if(!r.success)throw Error(`Unexpected highlights API response: ${r.error.message}`);return iD(r.data)}async deleteHighlight(e,t,n){this.validatePassageId(e),this.validateVersionId(t.version_id),await this.assertUsableVersion(t.version_id),await this.client.delete(`/v1/highlights/${encodeURIComponent(e)}`,{bible_id:t.version_id},this.authHeaders(n))}}}));function pD(e){let t={};return e.passage_id!==void 0&&(t.passage_id=e.passage_id),e.language_ranges!==void 0&&(t[`language_ranges[]`]=[...e.language_ranges]),e.page_size!==void 0&&(t.page_size=e.page_size),e.page_token!=null&&(t.page_token=e.page_token),t}function mD(e){let t={data:e.data,next_page_token:e.next_page_token};return e.total_size==null?t:{...t,total_size:e.total_size}}var hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD=o((()=>{zw(),hC(),hD=q({id:W(),image_url:W(),passage_id:W(),attribution:W(),language_tag:W(),width:G(),height:G(),aspect_ratio:AS()}),gD=VS(J(Y(W())),zS(e=>e==null||e===``?null:e)),_D=VS(q({data:K(MS()),next_page_token:gD,total_size:J(Y(G().check(gS())))}),zS(e=>({...e,data:e.data.flatMap(e=>{let t=hD.safeParse(e);return t.success?[t.data]:[]})}))),vD=W().check(U(1,`Image ID must be a non-empty string`),US(e=>e.trim().length>0,`Image ID must be a non-empty string`)),yD=W().check(xS(),U(1,`Passage ID must be a non-empty string`)),bD=VS(W(),zS(e=>iw(e))),xD=`Page size must be an integer from 1 to 99`,SD=q({passage_id:J(yD),language_ranges:J(HS(K(bD).check(U(1,`Pass at least one language range, or omit language_ranges`)))),page_size:J(G({error:xD}).check(mS(1,xD),fS(99,xD))),page_token:J(Y(W().check(U(1,`Page token must be a non-empty string`))))}),CD=`/v1/images`,wD=class{client;constructor(e){this.client=e}async getImages(e={}){let t=SD.parse(e),n=await this.client.get(CD,pD(t));if(n===``||n==null)return{data:[],next_page_token:null};let r=_D.safeParse(n);if(!r.success)throw Error(`Unexpected images API response: ${r.error.message}`);return mD(r.data)}async getImage(e){let t=vD.parse(e),n=await this.client.get(`${CD}/${encodeURIComponent(t)}`),r=hD.safeParse(n);if(!r.success)throw Error(`Unexpected images API response: ${r.error.message}`);return r.data}}}));function ED(){zD.clear()}function DD(){BD=null}var OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD=o((()=>{XE(),WE(),OD=class{name;userId;email;avatarUrlFormat;constructor(e){let t=UE.safeParse(e);if(!t.success)throw Error(`Invalid user data provided`);this.name=t.data.name,this.userId=t.data.id,this.email=t.data.email,this.avatarUrlFormat=t.data.avatar_url}getAvatarUrl(e=200,t=200){if(!this.avatarUrlFormat)return null;let n=this.avatarUrlFormat;n.startsWith(`//`)&&(n=`https:`+n),n=n.replace(`{width}`,e.toString()),n=n.replace(`{height}`,t.toString());try{return new URL(n)}catch{return null}}get avatarUrl(){return this.getAvatarUrl()}},kD=class{static async make(e,t,n,r){let i=this.randomURLSafeString(32),a={codeVerifier:i,codeChallenge:await this.codeChallenge(i),state:this.randomURLSafeString(24),nonce:this.randomURLSafeString(24)};return{url:this.authorizeURL(e,t,a,n,r),parameters:a}}static authorizeURL(e,t,n,r,i){let a=new URL(`https://${Q.apiHost}/auth/authorize`),o=t.toString().endsWith(`/`)?t.toString().slice(0,-1):t.toString(),s=new URLSearchParams({response_type:`code`,client_id:e,redirect_uri:o,nonce:n.nonce,state:n.state,code_challenge:n.codeChallenge,code_challenge_method:`S256`}),c=Q.installationId;c&&s.set(`x-yvp-installation-id`,c);let l=this.scopeValue(r||[]);l&&s.set(`scope`,l);let u=[...i??[]].sort().join(`,`);return u&&s.set(`requested_permissions`,u),a.search=s.toString(),a}static tokenURLRequest(e,t,n){let r=Q.apiHost,i=Q.appKey,a=new URL(`https://${r}/auth/token`),o=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:n,client_id:i??``,code_verifier:t});return new Request(a,{method:`POST`,body:o,headers:{"Content-Type":`application/x-www-form-urlencoded`}})}static randomURLSafeString(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),this.base64URLEncodedString(t)}static async codeChallenge(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return this.base64URLEncodedString(new Uint8Array(n))}static base64URLEncodedString(e){return btoa(String.fromCharCode.apply(null,Array.from(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}static scopeValue(e){let t=Array.from(e).sort().join(` `);return t.split(` `).includes(`openid`)||(t+=(t===``?``:` `)+`openid`),t||null}},AD={bibles:`bibles`,highlights:`highlights`,votd:`votd`,demographics:`demographics`,bibleActivity:`bible_activity`},jD=class{accessToken;expiryDate;refreshToken;yvpUserId;name;profilePicture;email;constructor({accessToken:e,expiresIn:t,refreshToken:n,yvpUserId:r,name:i,profilePicture:a,email:o}){this.accessToken=e,this.expiryDate=t?new Date(Date.now()+t*1e3):new Date,this.refreshToken=n,this.yvpUserId=r,this.name=i,this.profilePicture=a,this.email=o}},MD=`Sign In with YouVersion requires localStorage, which is not available in this environment`,ND=`Sign In with YouVersion could not write to localStorage; the store rejected the write (its quota may be full, as it always is in Safari private browsing)`,PD=()=>{let e=ME();if(!e)throw Error(MD);return e},FD=(e,t,n)=>{if(!PE(e,t,n))throw Error(ND)},ID=`youversion-auth-pending-granted-permissions`,LD=`youversion-auth-requested-permissions`,RD=new Set([`openid`,`profile`,`email`,`offline_access`]),zD=new Map,BD=null,VD=e=>{FE(e,`youversion-auth-code-verifier`),FE(e,`youversion-auth-redirect-uri`),FE(e,`youversion-auth-state`),FE(e,ID),FE(e,LD)},HD=(e,t,n)=>{PE(e,ID,JSON.stringify({state:t,permissions:n}))},UD=(e,t)=>{let n=e?.getItem(ID);if(FE(e,ID),!n)return[];try{let e=LE.safeParse(JSON.parse(n));if(e.success&&e.data.state===t)return e.data.permissions}catch{}return[]},WD=(e,t,n)=>{FD(e,LD,JSON.stringify({state:t,permissions:n}))},GD=(e,t)=>{let n=e?.getItem(LD);if(FE(e,LD),!n)return[];try{let e=LE.safeParse(JSON.parse(n));if(e.success&&e.data.state===t)return e.data.permissions}catch{}return[]},KD=class{static async signIn(e,t,n){let r=Q.appKey;if(!r)throw Error(`YouVersionPlatformConfiguration.appKey must be set before calling signIn`);let i=PD(),a=await kD.make(r,new URL(e),t,n);FD(i,`youversion-auth-code-verifier`,a.parameters.codeVerifier),FD(i,`youversion-auth-redirect-uri`,e.toString().endsWith(`/`)?e.toString().slice(0,-1):e.toString()),FD(i,`youversion-auth-state`,a.parameters.state),FE(i,ID),FE(i,LD),Q.clearDataExchangeInitiator(),n&&n.length>0&&WD(i,a.parameters.state,n),window.location.href=a.url.toString()}static async handleAuthCallback(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`);if(!n&&!r)return null;if(r){let t=e.get(`error_description`)||r;throw Error(`OAuth authentication failed: ${t}`)}let i=PD();if(n!==i.getItem(`youversion-auth-state`))throw Error(`Invalid state parameter - possible CSRF attack`);if(!t&&n){let t=qE(e);return t.length>0&&HD(i,n,t),this.obtainLocation(window.location.href,n),null}let a=i.getItem(`youversion-auth-code-verifier`),o=i.getItem(`youversion-auth-redirect-uri`);if(!t||!a||!o)throw Error(`Missing required authentication parameters`);let s=zD.get(t);if(s)return s;let c=this.exchangeCodeForTokens(t,a,o,n,e,i);return zD.set(t,c),c}static async exchangeCodeForTokens(e,t,n,r,i,a){try{let o=kD.tokenURLRequest(e,t,n),s=await fetch(o);if(!s.ok)throw Error(`Token exchange failed: ${s.status} ${s.statusText}`);let c=await s.text(),l=VE.safeParse(JSON.parse(c));if(!l.success)throw Error(`Token exchange response was invalid: ${l.error.message}`);let u=l.data,d=r?UD(a,r):[],f=r?GD(a,r):[],p=[...new Set([...qE(i),...d,...JE(u.scope),...f])].filter(e=>!RD.has(e)),m=this.extractSignInResult(u),h=Q.saveAuthData(m.accessToken||null,m.refreshToken||null,m.expiryDate||null),ee=Q.saveUserInfo({id:m.yvpUserId,name:m.name,email:m.email,avatar_url:m.profilePicture});if(!h||!ee)throw Error(`Sign-in succeeded but the session could not be saved to browser storage`);p.length>0&&Q.saveGrantedPermissions(p),VD(a);let te=new URL(window.location.href);return te.search=``,window.history.replaceState({},``,te.toString()),m}catch(e){throw Q.clearAuthTokens(),VD(a),e}}static obtainLocation(e,t){let n=new URL(e),r=new URLSearchParams(n.search);if(r.get(`state`)!==t)throw Error(`Invalid state parameter`);let i=new URL(`https://${Q.apiHost}/auth/callback`);r.forEach((e,t)=>{i.searchParams.set(t,e)}),window.location.href=i.toString()}static extractSignInResult(e){let t=this.decodeJWT(e.id_token);return new jD({accessToken:e.access_token,expiresIn:e.expires_in,refreshToken:e.refresh_token,yvpUserId:t.sub,name:t.name,profilePicture:t.profile_picture,email:t.email})}static decodeJWT(e){let t=e.split(`.`);if(t.length!==3)return{};let n=t[1]?.replace(/-/g,`+`).replace(/_/g,`/`);for(;n&&n.length%4!=0;)n+=`=`;try{if(n){let e=atob(n),t=Uint8Array.from(e,e=>e.charCodeAt(0)),r=new TextDecoder(`utf-8`).decode(t),i=zE.safeParse(JSON.parse(r));return i.success?i.data:{}}return{}}catch(e){return process.env.NODE_ENV===`development`&&console.error(`JWT decode failed:`,e),{}}}static signOut(){Q.clearAuthTokens()}static userInfo(e){if(!e)throw Error(`Invalid access token: must be a non-empty string`);try{let t=this.decodeJWT(e);if(!t||Object.keys(t).length===0)throw Error(`Invalid JWT token: Unable to decode token payload`);return new OD({id:t.sub,name:t.name,avatar_url:t.profile_picture,email:t.email})}catch(e){throw e instanceof Error?Error(`Failed to decode user information from JWT: ${e.message}`):Error(`Failed to decode user information from JWT: Unknown error`)}}static getStoredUserInfo(){let e=Q.storedUserInfo;return e?.id?new OD(e):null}static async refreshTokens(){let e=Q.refreshToken,t=Q.appKey;if(!e)throw Error(`No refresh token available`);if(!t)throw Error(`YouVersionPlatformConfiguration.appKey must be set before refreshing tokens`);try{let n=new URL(`https://${Q.apiHost}/auth/token`),r=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:t}),i=new Request(n,{method:`POST`,body:r,headers:{"Content-Type":`application/x-www-form-urlencoded`}}),a=await fetch(i);if(!a.ok)throw Error(`Token refresh failed: ${a.status} ${a.statusText}`);let o=HE.parse(await a.json()),s=new jD({accessToken:o.access_token,expiresIn:o.expires_in,refreshToken:o.refresh_token});if(!Q.saveAuthData(s.accessToken||null,s.refreshToken||null,s.expiryDate||null))throw Error(`the rotated tokens could not be saved to browser storage`);return s}catch(e){throw e instanceof Error?Error(`Token refresh failed: ${e.message}`):Error(`Token refresh failed: Unknown error`)}}static isTokenExpired(){let e=Q.tokenExpiryDate;return!e||new Date().getTime()>=e.getTime()}static async refreshTokenIfNeeded(){if(!this.isTokenExpired())return!0;let e=BD;if(e)return e;let t=this.performTokenRefresh();BD=t;try{return await t}finally{BD===t&&(BD=null)}}static async performTokenRefresh(){try{return!!await this.refreshTokens()}catch{return Q.clearAuthTokens(),!1}}}})),JD=c({ApiClient:()=>OE,BIBLE_CONTAINER_ATTRIBUTES:()=>oE,BIBLE_CSS_STYLESHEET_URL:()=>_T,BOOK_CANON:()=>Yw,BOOK_IDS:()=>Jw,BibleClient:()=>yE,CANON_IDS:()=>qw,DEFAULT_LICENSE_FREE_BIBLE_VERSION:()=>Kw,DataExchangeClient:()=>tD,HighlightsClient:()=>dD,ImagesClient:()=>wD,LanguagesClient:()=>GC,MAX_SEARCH_QUERY_GRAPHEMES:()=>100,MemoryStorageStrategy:()=>tO,MissingPassageAttributionError:()=>sE,OrganizationsClient:()=>ZC,SDK_NAME:()=>CE,SDK_VERSION:()=>TE,SDK_VERSION_HEADER_NAME:()=>wE,SearchClient:()=>mT,SessionStorageStrategy:()=>eO,SignInWithYouVersionPermission:()=>AD,SignInWithYouVersionResult:()=>jD,UNTITLED_SERIF_FONT_ID:()=>1,YouVersionAPI:()=>nO,YouVersionAPIUsers:()=>KD,YouVersionPlatformConfiguration:()=>Q,YouVersionUserInfo:()=>OD,__resetAuthCallbackDedupeForTests:()=>ED,__resetTokenRefreshDedupeForTests:()=>DD,buildDataExchangeUrl:()=>ZE,buildSdkVersionHeaderValue:()=>xE,clampSearchText:()=>tw,clearStorage:()=>IE,collectFilteredPage:()=>IC,fieldsNeededForLanguageFilter:()=>jC,fieldsNeededForVersionFilter:()=>AC,getAdjacentChapter:()=>XD,getAllVOTDs:()=>mE,getBibleStylesheets:()=>gT,getBook:()=>uE,getBooks:()=>lE,getChapter:()=>VT,getChapters:()=>dE,getHttpStatus:()=>SE,getLanguage:()=>UC,getLanguages:()=>BC,getLocalStorage:()=>ME,getPassage:()=>KT,getPassageAttribution:()=>$T,getPassageDisplay:()=>tE,getSessionStorage:()=>NE,getSuggestedQueries:()=>Vw,getTrendingQueries:()=>Hw,getVOTD:()=>hE,getVerse:()=>pE,getVerses:()=>fE,getVersion:()=>zT,getVersionFilterSnapshot:()=>TC,getVersions:()=>_E,handleDataExchangeCallback:()=>$E,isUsableBibleVersion:()=>DC,isUsableLanguageTag:()=>OC,isValidStructuralUsfmReference:()=>nw,isVersionFilterActive:()=>CC,isVersionIdDecidablyUnusable:()=>EC,parseDataExchangeCallback:()=>QE,parseGrantedPermissions:()=>qE,parseSearchLanguageRange:()=>iw,parseUsfmReference:()=>ew,removeStorageItem:()=>FE,searchTopics:()=>Ww,searchUnified:()=>uT,searchVerses:()=>fT,setStorageItem:()=>PE,throwUnusableBibleVersion:()=>kC,transformBibleHtml:()=>DT});function YD(e){return e.toLowerCase().includes(`intro`)}function XD(e,t,n,r){if(e.length===0)return null;let i=e.findIndex(e=>e.id===t);if(i===-1)return null;let a=e[i],o=a.chapters??[];return r===`next`?ZD(e,i,a,o,n):QD(e,i,a,o,n)}function ZD(e,t,n,r,i){if(YD(i)){let e=r.find(e=>!YD(e.id));if(e)return{bookId:n.id,chapterId:e.id}}if(!YD(i)){let e=r.findIndex(e=>e.id===i);if(e!==-1&&e<r.length-1){let t=r[e+1];if(!YD(t.id))return{bookId:n.id,chapterId:t.id}}}let a=e[t+1];if(!a)return null;let o=(a.chapters??[]).find(e=>!YD(e.id));return o?{bookId:a.id,chapterId:o.id}:null}function QD(e,t,n,r,i){if(YD(i))return $D(e,t);let a=r.findIndex(e=>e.id===i);return a===-1?null:a===r.findIndex(e=>!YD(e.id))?n.intro?{bookId:n.id,chapterId:n.intro.id}:$D(e,t):a>0?{bookId:n.id,chapterId:r[a-1].id}:null}function $D(e,t){let n=e[t-1];if(!n)return null;let r=n.chapters??[];for(let e=r.length-1;e>=0;e--){let t=r[e];if(!YD(t.id))return{bookId:n.id,chapterId:t.id}}return null}var eO,tO,nO,rO=o((()=>{KC(),HC(),QC(),hT(),Uw(),Gw(),dT(),pT(),bE(),kE(),rD(),fD(),TD(),zw(),WC(),qD(),XE(),WE(),cE(),vT(),QT(),FT(),gE(),HT(),vE(),zC(),lT(),eO=class{setItem(e,t){PE(NE(),e,t)||console.warn(`SessionStorage is not available in this environment`)}getItem(e){return NE()?.getItem(e)??null}removeItem(e){FE(NE(),e)}clear(){IE(NE())}},tO=class{store=new Map;setItem(e,t){this.store.set(e,t)}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e)}clear(){this.store.clear()}},nO=class{static addStandardHeaders(e){let t=new Headers({Accept:`application/json`,"Content-Type":`application/json`,[wE]:xE()}),n=Q.appKey;n&&t.set(`X-YVP-App-Key`,n);let r=Q.installationId;return r&&t.set(`X-YVP-Installation-ID`,r),new Request(e.toString(),{headers:t})}}})),$={},iO=ob(R({books:Nv(R({id:ey,name:L,firstChapterNumber:Zv.check(Jv(0)),lastChapterNumber:Zv.check(Jv(0))}).check(Uv(e=>e.lastChapterNumber>=e.firstChapterNumber)))})),aO=R({id:ey,name:L,language:qy,shortName:I(L),languageName:I(L),languageEnglishName:I(L)}),oO=Nv(Fv([R({type:Tv(`verse`),number:Zv,content:Nv(Fv([L,R({text:L,poem:I(kv),wordsOfJesus:I(Av)}),R({noteId:kv}),R({heading:L}),R({lineBreak:Tv(!0)})]))}),R({type:Iv([`heading`,`hebrew_subtitle`]),content:Nv(Fv([L,R({text:L}),R({noteId:kv})]))}),R({type:Tv(`line_break`)})])),sO=ob(R({translation:R({id:ey,name:L,licenseUrl:L,language:qy,shortName:I(L),textDirection:I(Iv([`ltr`,`rtl`])),licenseNotice:I(Lv(L)),licenseNotes:I(Lv(L)),license:I(Lv(Mv(L,Fv([Av,L]))))}),book:R({name:L}),chapter:R({content:oO})})),cO=e=>ob(R({data:Nv(e)}));function lO(e){return{text:`${e.licenseNotice||`${e.name}. ${e.licenseUrl}`} · Source: HelloAO Free Use Bible API`,html:`${e.licenseNotice?Jy(e.licenseNotice):`${Yy(e.name,e.licenseUrl)}.`} · Source: ${Yy(`HelloAO Free Use Bible API`,`https://bible.helloao.org/docs/`)}`}}function uO(e,t){let n=t===void 0?``:`<sup class="scripture-verse-number">${t}</sup> `;return e.map(e=>{if(typeof e==`string`||`text`in e){let t=n;if(n=``,typeof e==`string`)return t+Jy(e);let r=Jy(e.text),i=e.wordsOfJesus?`<span class="scripture-jesus">${r}</span>`:r;return e.poem===void 0?t+i:`<span class="scripture-poetry" style="--indent:${e.poem}">${t}${i}</span>`}return`heading`in e?`<span class="scripture-heading">${Jy(e.heading)}</span>`:`lineBreak`in e?`<br>`:` `}).join(``)}function dO(){let e=new Vy({useCache:!1}),t=ab(),n=n=>t.get(JSON.stringify([`books`,n]),()=>mb(`helloao.books`,t=>e.getTranslationBooks(n,void 0,{signal:t})).pipe(up(iO))),r=(n,r,i)=>t.get(JSON.stringify([`chapter`,n,r,i]),()=>mb(`helloao.chapter`,t=>e.getTranslationBookChapter(n,r,i,void 0,{signal:t})).pipe(up(sO)));return hb({id:`helloao`,defaultVersionId:`BSB`,clearCache:t.clear,listBooks:Pp(`helloao.listBooks`)(function*(e){return(yield*n(e)).books.map(e=>({id:e.id,title:e.name}))}),listChapters:Pp(`helloao.listChapters`)(function*(e,t){yield*nb(t);let r=(yield*n(e)).books.find(e=>e.id===t);return r?Array.from({length:r.lastChapterNumber-r.firstChapterNumber+1},(e,n)=>{let i=r.firstChapterNumber+n;return{number:i,passageId:`${t}.${i}`}}):yield*new Ky({code:`unavailable`,message:`Book is not available in this version.`})}),getPassageData:Pp(`helloao.getPassageData`)(function*(t,n){let{book:i,chapter:a,first:o,last:s}=yield*tb(n),c=yield*r(t,i,a);yield*rb(c.chapter.content.filter(e=>e.type===`verse`).map(e=>e.number),o,s);let l=``,u=!1;for(let e of c.chapter.content)if(e.type===`verse`){if(u=o===void 0||e.number>=o&&e.number<=s,!u)continue;l&&!/\s$/.test(l)&&(l+=` `);let t;for(let[n,r]of e.content.entries()){if(typeof r==`string`||`text`in r){let i=typeof r==`string`?void 0:r.poem,a=e.content[n-1],o=a!==void 0&&typeof a!=`string`&&`noteId`in a&&t!==void 0&&i===t;t===void 0&&i===void 0||o||!l||l.endsWith(`
|
|
20
|
+
${n.trim()}`),n.trim()}getWordText(e,t){let n=e.content[t.contentIndex];return typeof n==`string`?n.slice(t.start,t.end):typeof n==`object`&&n&&`text`in n?n.text.slice(t.start,t.end):``}getVerseWords(e,t){return(t.verses[e.number.toString()]??[]).map(t=>({...t,text:this.getWordText(e,t)}))}getSimpleWordText(e,t){return e.text.slice(t.start,t.end)}getSimpleVerseWords(e,t){return(t.verses[e.number.toString()]??[]).map(t=>({...t,text:this.getSimpleWordText(e,t)}))}_getJson(e,t,n,r=!0){let i=this._buildUrl(e,t),a=n?.signal;if(a?.aborted)return Promise.reject(Hy());if(!this._useCache||!r)return this._fetchJson(i,a);let o=this._responseCache.get(i);if(o)return this._waitForSharedRequest(i,o,a);let s=a?new AbortController:null;s&&this._sharedRequests.set(i,{controller:s,waiting:0});let c=this._fetchJson(i,s?.signal).catch(e=>{throw this._responseCache.get(i)===c&&this._responseCache.delete(i),e}).finally(()=>{s&&this._sharedRequests.get(i)?.controller===s&&this._sharedRequests.delete(i)});return this._responseCache.set(i,c),this._waitForSharedRequest(i,c,a)}async _fetchJson(e,t){let n=await(t?fetch(e,{signal:t}):fetch(e));if(n.status<200||n.status>=300)throw Error(`Failed request to ${e}. Status: ${n.status} ${n.statusText}`);return await n.json()}_waitForSharedRequest(e,t,n){let r=this._sharedRequests.get(e);return r&&(r.waiting+=1),n?new Promise((i,a)=>{let o=!1,s=()=>{o||(o=!0,r&&(--r.waiting,r.waiting<=0&&(this._sharedRequests.get(e)===r&&this._sharedRequests.delete(e),this._responseCache.get(e)===t&&this._responseCache.delete(e),r.controller.abort())),a(Hy()))};n.addEventListener(`abort`,s,{once:!0}),t.then(e=>{o||(o=!0,n.removeEventListener(`abort`,s),i(e))},e=>{o||(o=!0,n.removeEventListener(`abort`,s),a(e))})}):t}_buildUrl(e,t){if(/^https?:\/\//i.test(e))return e;let n=t??this.endpoint;return new URL(e,n).href}};function Hy(){let e=Error(`The operation was aborted.`);return e.name=`AbortError`,e}var Uy=R({id:ey,abbreviation:L,title:L,language:I(L),languageName:I(L)}),Wy=R({code:ey,level:Iv([`required`,`recommended`,`notice`]),appliesTo:Iv([`all`,`text`,`html`]),text:ey,urls:I(Nv(L))});R({id:ey,title:L}),R({passageId:ey,number:Zv.check(Jv(0))}),R({provider:ey,source:R({url:L,versionId:ey}),requestedPassageId:ey,passageId:ey,reference:L,text:L,version:Uy.mapFields(e=>({...e,sourceLanguage:I(L)})),attribution:R({text:ey,urls:Nv(L)}),publisher:I(R({copyrightHtml:L,infoHtml:L})),reporting:I(R({kind:Tv(`api-bible-fums`),token:ey})),cache:I(R({expiresAt:kv})),licenses:Nv(R({name:I(L),url:L,restrictions:I(Mv(L,Fv([Av,L])))})),numbering:Iv([`kjv`,`unknown`]),sourceLimitations:I(Nv(R({kind:Tv(`source-trimming`),startPassageId:ey,endPassageId:ey,appliesToRequest:Av}))),display:R({format:Tv(`text`),whitespace:Tv(`pre-wrap`),attributionPlacement:Tv(`after-passage`),direction:I(Iv([`ltr`,`rtl`])),language:I(L),nativeHtml:I(R({containerAttributes:Mv(L,L),stylesheets:Nv(R({kind:Iv([`bible`,`font`]),href:L}))}))}),instructions:Nv(Wy)}),Ia()(`@faith-tools/scripture-inline/data/BibleSource`);var Gy=Iv([`invalid_reference`,`unavailable`,`unsupported`,`authentication`,`rate_limit`,`network`,`timeout`,`invalid_response`]),Ky=class extends hy()(`ScriptureError`,{code:Gy,message:L,cause:I(iy())}){get retryable(){return this.code===`network`||this.code===`rate_limit`}},qy=L.check(Uv(e=>{try{return new Intl.Locale(e),!0}catch{return`Invalid source language tag.`}})),Jy=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function Yy(e,t){let n=Jy(e);return/^https?:\/\//i.test(t)?`<a href="${Jy(t)}">${n}</a>`:n}var Xy=L.check(Wv(/^[1-4A-Z][A-Z0-9]{2}\.[1-9]\d*(?:\.[1-9]\d*(?:-[1-9]\d*)?)?$/)),Zy=L.check(Wv(/^[1-4A-Z][A-Z0-9]{2}$/)),Qy=ay.check(Xv(),Jv(0),Yv(2**53-1)),$y=R({book:Zy,chapter:Qy,first:I(Qy),last:I(Qy)}).check(Uv(e=>e.first===void 0||e.last>=e.first||`Range endpoints must be ascending.`)),eb=e=>new Ky({code:`invalid_reference`,message:`Use an uppercase USFM verse, ascending range, or chapter with positive safe integers. Ranges cannot cross chapters.`,cause:e}),tb=Np(function*(e){let[t,n,r]=(yield*xv(Xy)(e).pipe(gp(eb))).split(`.`),[i,a=i]=r?.split(`-`)??[];return yield*xv($y)({book:t,chapter:n,first:i,last:a}).pipe(gp(eb))}),nb=e=>xv(Zy)(e).pipe(gp(eb));function rb(e,t,n){return!e.length||t!==void 0&&(!e.includes(t)||!e.includes(n))?N(new Ky({code:`unavailable`,message:`Passage is not available in this version.`})):rp}function ib(){return[{code:`display-attribution`,level:`required`,appliesTo:`all`,text:`Display attribution.text after the passage, separately from Scripture. Preserve its wording and supplied source and license links.`},{code:`preserve-scripture`,level:`required`,appliesTo:`text`,text:`Render text as text, not HTML. Preserve wording, punctuation, meaningful line and paragraph breaks, and display.direction when supplied. Do not add notes or headings to the Scripture text.`},{code:`verify-license`,level:`required`,appliesTo:`all`,text:`Check the selected translation's license and provider terms for your intended use. Missing metadata is not permission for commercial use, redistribution, modifications, or offline storage.`},{code:`plain-text-limits`,level:`notice`,appliesTo:`text`,text:`Plain text omits verse numbers, editorial headings, notes, and rich formatting. It is not a lossless representation of the source edition.`}]}function ab(e=ns){let t=new Map,n=jp(vy(e=>np(()=>t.get(e)()),{capacity:256,requireServicesAt:`lookup`,timeToLive:t=>Kd(t)?e:ts}));return{get(e,r){return np(()=>(t.set(e,r),xy(n,e).pipe(wp(M(()=>{t.get(e)===r&&t.delete(e)})))))},clear:Ey(n)}}var ob=e=>t=>xv(e)(t).pipe(gp(e=>new Ky({code:`invalid_response`,message:`Bible provider returned invalid data.`,cause:e}))),sb=T(`@faith-tools/scripture-inline/RequestPolicy`,{defaultValue:()=>({timeout:`15 seconds`,retries:2})}),cb=R({status:kv}),lb=R({response:cb}),ub=Sv(cb),db=Sv(lb),fb=Sv(R({code:L}));function pb(e){if(e instanceof Ky)return e;let t=ub(e),n=db(e),r=fb(e),i=t._tag===`Some`?t.value.status:n._tag===`Some`?n.value.response.status:Number(e instanceof Error?/(?:Status: |^)(\d{3})\b/.exec(e.message)?.[1]:void 0),a=r._tag===`Some`&&r.value.code===`missing_passage_attribution`?`unavailable`:e instanceof SyntaxError||e instanceof Error&&/^\$?ZodError$/.test(e.name)?`invalid_response`:i===401||i===403?`authentication`:i===429?`rate_limit`:i>=400&&i<500?`unavailable`:`network`;return new Ky({code:a,message:`Bible provider request failed (${a}).`,cause:e})}var mb=Pp(`scripture.request`)(function*(e,t,n=!0){yield*Tp({operation:e});let r=yield*sb;return yield*ep({try:t,catch:pb}).pipe(_p({times:n?r.retries:0,schedule:kf(`100 millis`),while:e=>e.retryable}),yp({duration:r.timeout,orElse:()=>N(new Ky({code:`timeout`,message:`Bible provider request timed out.`}))}))});function hb(e){return{id:e.id,defaultVersionId:e.defaultVersionId,effects:e,listVersions:()=>Ap(e.listVersions()),getPassage:(t,n)=>Ap(e.getPassageDisplay(t,n))}}function z(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function gb(e){return e&&Object.assign(yb,e),yb}var _b,vb,yb,bb=o((()=>{Object.freeze({status:`aborted`}),_b=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},vb=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},yb={}}));function xb(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Sb(e,t){return typeof t==`bigint`?t.toString():t}function Cb(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wb(e){return e==null}function Tb(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function B(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Bb)return r===void 0&&(r=Bb,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Eb(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Db(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ob(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kb(e){if(Ob(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Ob(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ab(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function jb(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function V(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Mb(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function Nb(e,t){if(!kb(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return jb(e,Db(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Eb(this,`shape`,n),n},checks:[]}))}function Pb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Fb(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ib(e){return typeof e==`string`?e:e?.message}function Lb(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Ib(e.inst?._zod.def?.error?.(e))??Ib(t?.error?.(e))??Ib(n.customError?.(e))??Ib(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Rb(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function zb(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Bb,Vb,Hb,Ub,Wb=o((()=>{Bb=Symbol(`evaluating`),Vb=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Hb=new Set([`string`,`number`,`symbol`]),Ub={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}})),Gb,Kb,qb,Jb=o((()=>{bb(),Wb(),Gb=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Sb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kb=z(`$ZodError`,Gb),qb=z(`$ZodError`,Gb,{Parent:Error})})),Yb,Xb,Zb,Qb,$b,ex,tx,nx,rx=o((()=>{bb(),Jb(),Wb(),Yb=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _b;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Lb(e,a,gb())));throw Vb(t,i?.callee),t}return o.value},Xb=Yb(qb),Zb=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Lb(e,a,gb())));throw Vb(t,i?.callee),t}return o.value},Qb=Zb(qb),$b=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _b;return a.issues.length?{success:!1,error:new(e??Kb)(a.issues.map(e=>Lb(e,i,gb())))}:{success:!0,data:a.value}},ex=$b(qb),tx=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Lb(e,i,gb())))}:{success:!0,data:a.value}},nx=tx(qb)})),ix,ax,ox,sx,cx,lx,ux,dx=o((()=>{ix=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ax=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ox=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,`${ox}`,sx=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},cx=/^-?\d+$/,lx=/^-?\d+(?:\.\d+)?/,ux=/^(?:true|false)$/i})),fx,px,mx,hx,gx,_x,vx,yx,bx,xx,Sx,Cx=o((()=>{bb(),dx(),Wb(),fx=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),px={number:`number`,bigint:`bigint`,object:`date`},mx=z(`$ZodCheckLessThan`,(e,t)=>{fx.init(e,t);let n=px[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hx=z(`$ZodCheckGreaterThan`,(e,t)=>{fx.init(e,t);let n=px[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gx=z(`$ZodCheckNumberFormat`,(e,t)=>{fx.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ub[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=cx)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),_x=z(`$ZodCheckMaxLength`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Rb(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vx=z(`$ZodCheckMinLength`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Rb(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yx=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;fx.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!wb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Rb(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bx=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;fx.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xx=z(`$ZodCheckRegex`,(e,t)=>{bx.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Sx=z(`$ZodCheckOverwrite`,(e,t)=>{fx.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),wx=o((()=>{})),Tx,Ex=o((()=>{Tx={major:4,minor:1,patch:12}}));function Dx(e,t,n){e.issues.length&&t.issues.push(...Fb(n,e.issues)),t.value[n]=e.value}function Ox(e,t,n,r){e.issues.length&&t.issues.push(...Fb(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function kx(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Mb(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ax(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ox(e,n,i,t))):Ox(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function jx(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Pb(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Lb(e,r,gb())))}),t)}function Mx(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function Nx(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function Px(e){return e.value=Object.freeze(e.value),e}function Fx(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(zb(e))}}var H,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x,eS,tS,nS,rS=o((()=>{Cx(),bb(),rx(),dx(),Wb(),Ex(),H=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tx;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Pb(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new _b;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Pb(e,t))});else{if(e.issues.length===t)continue;r||=Pb(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Pb(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new _b;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new _b;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=ex(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return nx(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Ix=z(`$ZodString`,(e,t)=>{H.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??sx(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Lx=z(`$ZodStringFormat`,(e,t)=>{bx.init(e,t),Ix.init(e,t)}),Rx=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ix(e)}else t.pattern??=ix();Lx.init(e,t)}),zx=z(`$ZodURL`,(e,t)=>{Lx.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:ax.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Bx=z(`$ZodNumber`,(e,t)=>{H.init(e,t),e._zod.pattern=e._zod.bag.pattern??lx,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Vx=z(`$ZodNumber`,(e,t)=>{gx.init(e,t),Bx.init(e,t)}),Hx=z(`$ZodBoolean`,(e,t)=>{H.init(e,t),e._zod.pattern=ux,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ux=z(`$ZodUnknown`,(e,t)=>{H.init(e,t),e._zod.parse=e=>e}),Wx=z(`$ZodArray`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Dx(t,n,e))):Dx(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),Gx=z(`$ZodObject`,(e,t)=>{if(H.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Cb(()=>kx(t));B(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ob,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Ox(n,t,e,s))):Ox(n,t,e,s)}return i?Ax(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Kx=z(`$ZodUnion`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),B(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),B(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),B(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Tb(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>jx(t,i,e,a)):jx(s,i,e,a)}}),qx=z(`$ZodRecord`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!kb(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Fb(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Fb(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Lb(e,r,gb())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Fb(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Fb(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Jx=z(`$ZodEnum`,(e,t)=>{H.init(e,t);let n=xb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Hb.has(typeof e)).map(e=>typeof e==`string`?Ab(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Yx=z(`$ZodLiteral`,(e,t)=>{if(H.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ab(e):e?Ab(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),Xx=z(`$ZodTransform`,(e,t)=>{H.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new vb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new _b;return n.value=i,n}}),Zx=z(`$ZodOptional`,(e,t)=>{H.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Tb(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Mx(t,e.value)):Mx(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Qx=z(`$ZodNullable`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Tb(e.source)}|null)$`):void 0}),B(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),$x=z(`$ZodCatch`,(e,t)=>{H.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lb(e,n,gb()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Lb(e,n,gb()))},input:e.value}),e.issues=[]),e)}}),eS=z(`$ZodPipe`,(e,t)=>{H.init(e,t),B(e._zod,`values`,()=>t.in._zod.values),B(e._zod,`optin`,()=>t.in._zod.optin),B(e._zod,`optout`,()=>t.out._zod.optout),B(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Nx(e,t.in,n)):Nx(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Nx(e,t.out,n)):Nx(r,t.out,n)}}),tS=z(`$ZodReadonly`,(e,t)=>{H.init(e,t),B(e._zod,`propValues`,()=>t.innerType._zod.propValues),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Px):Px(r)}}),nS=z(`$ZodCustom`,(e,t)=>{fx.init(e,t),H.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fx(t,n,r,e));Fx(i,n,r,e)}})})),iS=o((()=>{}));function aS(e,t){return new e({type:`string`,...V(t)})}function oS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}function sS(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}function cS(e,t){return new e({type:`number`,checks:[],...V(t)})}function lS(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}function uS(e,t){return new e({type:`boolean`,...V(t)})}function dS(e){return new e({type:`unknown`})}function fS(e,t){return new mx({check:`less_than`,...V(t),value:e,inclusive:!0})}function pS(e,t){return new hx({check:`greater_than`,...V(t),value:e,inclusive:!1})}function mS(e,t){return new hx({check:`greater_than`,...V(t),value:e,inclusive:!0})}function hS(e){return pS(0,e)}function gS(e){return mS(0,e)}function _S(e,t){return new _x({check:`max_length`,...V(t),maximum:e})}function U(e,t){return new vx({check:`min_length`,...V(t),minimum:e})}function vS(e,t){return new yx({check:`length_equals`,...V(t),length:e})}function yS(e,t){return new xx({check:`string_format`,format:`regex`,...V(t),pattern:e})}function bS(e){return new Sx({check:`overwrite`,tx:e})}function xS(){return bS(e=>e.trim())}function SS(){return bS(e=>e.toUpperCase())}function CS(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}var wS=o((()=>{Cx(),Wb()})),TS=o((()=>{})),ES=o((()=>{bb(),rx(),Jb(),rS(),Cx(),Ex(),Wb(),dx(),iS(),wx(),wS(),TS()})),DS=o((()=>{ES()}));function W(e){return aS(WS,e)}function OS(e){return oS(KS,e)}function kS(e){return sS(qS,e)}function AS(e){return cS(JS,e)}function G(e){return lS(YS,e)}function jS(e){return uS(XS,e)}function MS(){return dS(ZS)}function K(e,t){return new QS({type:`array`,element:e,...V(t)})}function NS(e){let t=e._zod.def.shape;return LS(Object.keys(t))}function q(e,t){let n={type:`object`,shape:e??{},...V(t)};return new $S(n)}function PS(e,t){return Nb(e,t)}function FS(e,t){return new eC({type:`union`,options:e,...V(t)})}function IS(e,t,n){return new tC({type:`record`,keyType:e,valueType:t,...V(n)})}function LS(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new nC({type:`enum`,entries:n,...V(t)})}function RS(e,t){return new rC({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}function zS(e){return new iC({type:`transform`,transform:e})}function J(e){return new aC({type:`optional`,innerType:e})}function Y(e){return new oC({type:`nullable`,innerType:e})}function BS(e,t){return new sC({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function VS(e,t){return new cC({type:`pipe`,in:e,out:t})}function HS(e){return new lC({type:`readonly`,innerType:e})}function US(e,t={}){return CS(uC,e,t)}var X,WS,GS,KS,qS,JS,YS,XS,ZS,QS,$S,eC,tC,nC,rC,iC,aC,oC,sC,cC,lC,uC,dC=o((()=>{ES(),DS(),X=z(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);H.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Xb(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ex(e,t,n),e.parseAsync=async(t,n)=>Qb(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>nx(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>jb(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e))}),WS=z(`ZodMiniString`,(e,t)=>{Ix.init(e,t),X.init(e,t)}),GS=z(`ZodMiniStringFormat`,(e,t)=>{Lx.init(e,t),WS.init(e,t)}),KS=z(`ZodMiniUUID`,(e,t)=>{Rx.init(e,t),GS.init(e,t)}),qS=z(`ZodMiniURL`,(e,t)=>{zx.init(e,t),GS.init(e,t)}),JS=z(`ZodMiniNumber`,(e,t)=>{Bx.init(e,t),X.init(e,t)}),YS=z(`ZodMiniNumberFormat`,(e,t)=>{Vx.init(e,t),JS.init(e,t)}),XS=z(`ZodMiniBoolean`,(e,t)=>{Hx.init(e,t),X.init(e,t)}),ZS=z(`ZodMiniUnknown`,(e,t)=>{Ux.init(e,t),X.init(e,t)}),QS=z(`ZodMiniArray`,(e,t)=>{Wx.init(e,t),X.init(e,t)}),$S=z(`ZodMiniObject`,(e,t)=>{Gx.init(e,t),X.init(e,t),B(e,`shape`,()=>t.shape)}),eC=z(`ZodMiniUnion`,(e,t)=>{Kx.init(e,t),X.init(e,t)}),tC=z(`ZodMiniRecord`,(e,t)=>{qx.init(e,t),X.init(e,t)}),nC=z(`ZodMiniEnum`,(e,t)=>{Jx.init(e,t),X.init(e,t),e.options=Object.values(t.entries)}),rC=z(`ZodMiniLiteral`,(e,t)=>{Yx.init(e,t),X.init(e,t)}),iC=z(`ZodMiniTransform`,(e,t)=>{Xx.init(e,t),X.init(e,t)}),aC=z(`ZodMiniOptional`,(e,t)=>{Zx.init(e,t),X.init(e,t)}),oC=z(`ZodMiniNullable`,(e,t)=>{Qx.init(e,t),X.init(e,t)}),sC=z(`ZodMiniCatch`,(e,t)=>{$x.init(e,t),X.init(e,t)}),cC=z(`ZodMiniPipe`,(e,t)=>{eS.init(e,t),X.init(e,t)}),lC=z(`ZodMiniReadonly`,(e,t)=>{tS.init(e,t),X.init(e,t)}),uC=z(`ZodMiniCustom`,(e,t)=>{nS.init(e,t),X.init(e,t)})})),fC=o((()=>{ES()})),pC=o((()=>{ES(),DS(),dC(),fC(),Wb(),dC()})),mC=o((()=>{pC(),pC()})),hC=o((()=>{mC()})),gC,_C,vC,yC,bC,xC=o((()=>{hC(),gC=/^[a-z]{2,3}(?:-[A-Z][a-z]{3})?$/,_C=W().check(xS(),U(1,`Language ID must be a non-empty string`),yS(gC,`Language ID must match BCP 47 format (language or language+script)`)),vC=q({id:W().check(yS(gC,`BCP 47 id limited to language or language+script`)),language:W().check(yS(/^[a-z]{2,3}$/,`ISO 639 canonical language subtag`)),script:J(Y(W().check(yS(/^[A-Z][a-z]{3}$/,`Script must match ISO 15924 format (e.g., "Latn")`)))),script_name:J(Y(W())),aliases:J(K(W())),display_names:J(IS(W(),W())),scripts:J(K(W().check(yS(/^[A-Z][a-z]{3}$/,`ISO 15924 script code`)))),variants:J(K(W())),countries:J(K(W().check(yS(/^[A-Z]{2}$/,`ISO 3166-1 alpha-2 country code`)))),text_direction:J(LS([`ltr`,`rtl`])),writing_population:J(G()),speaking_population:J(G()),default_bible_id:J(Y(G()))}),yC=W().check(xS(),vS(2,`Country code must be a 2-character ISO 3166-1 alpha-2 code`),SS()),bC=q({page_size:J(FS([G().check(hS()),RS(`*`)])),fields:J(K(NS(vC))),page_token:J(W()),country:J(yC)}).check(US(e=>e?.page_size!==`*`||e.fields&&e.fields.length>=1&&e.fields.length<=3,{error:`page_size="*" requires 1-3 fields to be specified`,path:[`page_size`,`fields`]}))})),Z,SC=o((()=>{Z={permittedVersionIds:void 0,excludedVersionIds:void 0,permittedLanguageTags:void 0}}));function CC(){return Z.permittedVersionIds!==void 0||Z.permittedLanguageTags!==void 0||(Z.excludedVersionIds?.length??0)>0}function wC(){return Z.permittedLanguageTags!==void 0}function TC(){return{permittedVersionIds:Z.permittedVersionIds,excludedVersionIds:Z.excludedVersionIds,permittedLanguageTags:Z.permittedLanguageTags}}function EC(e){if(Z.excludedVersionIds?.includes(e))return!0;let t=Z.permittedVersionIds;return t!==void 0&&!t.includes(e)}function DC(e){if(EC(e.id))return!1;let t=Z.permittedLanguageTags;return t===void 0||e.languageTag!==void 0&&t.includes(e.languageTag)}function OC(e){let t=Z.permittedLanguageTags;return t===void 0||t.includes(e)}function kC(){throw Object.assign(Error(`This app is not allowed to access this Bible version.`),{status:403})}function AC(e){if(!e)return;if(!CC())return[...e];let t=new Set(e);return t.add(`id`),wC()&&t.add(`language_tag`),[...t]}function jC(e){if(!e)return;if(!wC())return[...e];let t=new Set(e);return t.add(`id`),[...t]}function MC(e,t){return`${LC}${JSON.stringify({t:e,s:t})}`}function NC(e){if(e.startsWith(LC))try{let t=RC.safeParse(JSON.parse(e.slice(LC.length)));return t.success?t.data:void 0}catch{return}}function PC(e){if(!e)return{skip:0};let t=NC(e);return t?{pageToken:t.t??void 0,skip:t.s}:{pageToken:e,skip:0}}async function FC(e,t,n){let r=n.fieldsNeeded(),i=t.page_size;return r&&(e[`fields[]`]=r,n.isFilterActive()&&i===`*`&&r.length>3&&delete e.page_size),n.isFilterActive()?IC(n.fetchPage,n.isUsable,i,t.page_token):n.fetchPage(t.page_token)}async function IC(e,t,n,r){let i=PC(r);if(n===`*`){let n=await e(i.pageToken),r=n.data.filter(t).slice(i.skip),a=n.next_page_token;for(;a;){let n=await e(a);r.push(...n.data.filter(t)),a=n.next_page_token}return{data:r,next_page_token:null,total_size:r.length}}let a=i.pageToken,o=i.skip,s=await e(a),c=n??s.data.length,l=[],u=s;for(;;){let n=u.data.filter(t).slice(o),r=n.slice(0,c-l.length);if(l.push(...r),n.length>r.length)return{data:l,next_page_token:MC(a??null,o+r.length),total_size:s.total_size};if(o=0,l.length>=c||!u.next_page_token)return{data:l,next_page_token:u.next_page_token??null,total_size:s.total_size};a=u.next_page_token,u=await e(a)}}var LC,RC,zC=o((()=>{SC(),hC(),LC=`yv-vf1:`,RC=q({t:Y(W()),s:G().check(gS())})}));async function BC(e,t={}){if(t.page_size===`*`){let e=t.fields?.length??0;if(e<1||e>3)throw Error(VC)}let n=bC.parse(t),r={};n.country!==void 0&&(r.country=n.country),n.fields!==void 0&&(r[`fields[]`]=n.fields),n.page_size!==void 0&&(r.page_size=n.page_size);let i=jC(n.fields);return FC(r,t,{fieldsNeeded:()=>i,isFilterActive:wC,fetchPage:t=>{let n={...r};return t&&(n.page_token=t),e.get(`/v1/languages`,n)},isUsable:e=>OC(e.id)})}var VC,HC=o((()=>{xC(),zC(),VC=`page_size="*" requires 1-3 fields to be specified`}));async function UC(e,t){return _C.parse(t),e.get(`/v1/languages/${t}`)}var WC=o((()=>{xC()})),GC,KC=o((()=>{HC(),WC(),GC=class{client;constructor(e){this.client=e}async getLanguages(e={}){return BC(this.client,e)}async getLanguage(e){return UC(this.client,e)}}})),qC,JC,YC,XC,ZC,QC=o((()=>{hC(),qC=q({short_name:J(W()),long_name:J(W())}),JC=q({formatted_address:J(W()),formatted_locality:J(W()),place_id:J(W()),latitude:J(AS()),longitude:J(AS()),administrative_area_level_1:J(qC),locality:J(qC),country:J(qC)}),YC=q({id:OS(),parent_organization_id:J(Y(OS())),name:J(W()),description:J(W()),email:J(Y(W())),phone:J(Y(W())),primary_language:J(W()),website_url:J(W()),address:J(JC)}),XC=VS(W().check(xS()),OS({error:`Organization ID must be a valid UUID`})),ZC=class{client;constructor(e){this.client=e}async getOrganization(e){let t=XC.parse(e),n=await this.client.get(`/v1/organizations/${t}`);return YC.parse(n)}}}));function $C(e){return Number.isSafeInteger(e)&&e>0}function ew(e){let t=pw.exec(e);if(!t)return null;let n=t[1],r=t[2];if(n===void 0||r===void 0||!$C(Number(r)))return null;if(t[3]===void 0)return{book:n,chapter:r,verses:[]};let i=Number(t[3]);if(!$C(i))return null;if(t[4]===void 0)return{book:n,chapter:r,verses:[i]};let a=Number(t[4]);if(!$C(a)||a<i||a-i+1>mw)return null;let o=[];for(let e=i;e<=a;e+=1)o.push(e);return{book:n,chapter:r,verses:o}}function tw(e){if(Intl.Segmenter===void 0)return Array.from(e).slice(0,100).join(``);hw??=new Intl.Segmenter(void 0,{granularity:`grapheme`});let t=hw.segment(e)[Symbol.iterator](),n=0;for(let r=0;r<100;r+=1){let r=t.next();if(r.done)return e;n=r.value.index+r.value.segment.length}return e.slice(0,n)}function nw(e){return ew(e)!==null}function rw(e){return e.trim().replace(/_/g,`-`).toLowerCase()}function iw(e){let t=rw(W().check(xS(),U(1,`Language ranges must be a non-empty string`)).parse(e));return W().check(yS(_w,vw)).parse(t),t}function aw(e){let t=Array.isArray(e)?[...e]:[e];return K(W()).check(U(1,`At least one language range is required`)).parse(t),t.map(iw)}function ow(e){let t={text:e.text};return e.source==null?t:{...t,source:e.source}}function sw(e){return nw(e.reference)?{id:e.reference}:null}function cw(e){let t={verses:e.verses.map(sw).filter(e=>e!==null),didYouMean:e.did_you_mean,searchInsteadFor:e.search_instead_for??null,nextPageToken:e.next_page_token??null};return e.user_intent==null?t:{...t,userIntent:e.user_intent}}function lw(e){let t={text:e.text,subtopics:e.subtopics};return e.id===void 0?t:{...t,id:e.id}}function uw(e){return{topics:e.topics.map(lw),didYouMean:e.did_you_mean,searchInsteadFor:e.search_instead_for??null,totalSize:e.total_size}}function dw(e){return e.id.length===0||!nw(e.passage_id)?null:{id:e.id,passageId:e.passage_id}}function fw(e){let t={verses:(e.verses??[]).flatMap(e=>{let t=ww.safeParse(e);if(!t.success)return[];let n=sw(t.data);return n===null?[]:[n]}),topics:(e.topics??[]).flatMap(e=>{let t=Fw.safeParse(e);return t.success?[lw(t.data)]:[]}),images:(e.images??[]).map(e=>{let t=Lw.safeParse(e);return t.success?dw(t.data):null}).filter(e=>e!==null),didYouMean:e.did_you_mean??[],searchInsteadFor:e.search_instead_for??null};return e.user_intent==null?t:{...t,userIntent:e.user_intent}}var pw,mw,hw,gw,_w,vw,yw,bw,xw,Sw,Cw,ww,Tw,Ew,Dw,Ow,kw,Aw,jw,Mw,Nw,Pw,Fw,Iw,Lw,Rw,zw=o((()=>{hC(),pw=/^([A-Z0-9]{1,3})\.(\d+)(?:\.(\d+)(?:-(\d+))?)?$/,mw=250,gw=[`unknown`,`topical`,`text`,`reference`],_w=/^(\*|[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*)$/,vw=`Language range must be "*" or a Basic Language Range (e.g., "en", "en-US")`,yw=q({text:W(),source:J(W())}),bw=q({queries:K(yw)}),xw=q({text:W(),source:J(Y(W()))}),Sw=q({data:K(xw)}),Cw=q({id:W()}),q({verses:K(Cw),userIntent:J(W()),didYouMean:K(W()),searchInsteadFor:J(Y(W())),nextPageToken:J(Y(W()))}),ww=q({reference:W()}),Tw=q({verses:K(ww),user_intent:J(Y(W())),did_you_mean:K(W()),search_instead_for:J(Y(W())),next_page_token:J(Y(W()))}),Ew=q({id:J(Y(G())),text:W(),subtopics:K(W())}),q({topics:K(Ew),didYouMean:K(W()),searchInsteadFor:J(Y(W())),totalSize:G()}),Dw=q({id:J(Y(G())),text:W(),subtopics:K(W())}),Ow=q({topics:K(Dw),did_you_mean:K(W()),search_instead_for:J(Y(W())),total_size:G()}),kw=W().check(xS(),U(1,`Query must be between 1 and 100 characters`),US(e=>tw(e)===e,`Query must be between 1 and 100 characters`)),Aw=W().check(xS(),U(1,`Query must be a non-empty string`)),jw=q({userIntent:J(W()),pageSize:J(G().check(mS(1),fS(99))),pageToken:J(W())}),Mw=LS([`verses`,`topics`,`images`],{error:`Search field must be verses, topics, or images`}),Nw=VS(K(Mw).check(U(1,`At least one search field is required`)),zS(e=>[...new Set(e)])),Pw=q({userIntent:J(LS(gw)),fields:J(Nw)}),Fw=PS(Dw,{id:Y(G())}),Iw=q({id:W().check(U(1)),passageId:W().check(U(1))}),Lw=q({id:W(),passage_id:W()}),Rw=q({verses:J(K(MS())),topics:J(K(MS())),user_intent:J(Y(W())),did_you_mean:J(K(W())),search_instead_for:J(Y(W())),images:J(K(MS()))}),q({verses:K(Cw),topics:K(Ew),images:K(Iw),userIntent:J(W()),didYouMean:K(W()),searchInsteadFor:Y(W())})}));function Bw(e){if(e===``||e==null)return{queries:[]};let t=Sw.safeParse(e);if(!t.success)throw Error(`Unexpected search-queries API response: ${t.error.message}`);return bw.parse({queries:t.data.data.map(ow)})}async function Vw(e,t,n){let r=Aw.parse(t),i=aw(n);return Bw(await e.get(`/v1/search-queries`,{query:r,"language_ranges[]":i}))}async function Hw(e,t){let n=aw(t);return Bw(await e.get(`/v1/search-queries`,{trending:!0,"language_ranges[]":n}))}var Uw=o((()=>{zw()}));async function Ww(e,t,n){let r=kw.parse(t),i=aw(n),a=await e.get(`/v1/search-topics`,{query:r,"language_ranges[]":i}),o=Ow.safeParse(a);if(!o.success)throw Error(`Unexpected search-topics API response: ${o.error.message}`);return uw(o.data)}var Gw=o((()=>{zw()})),Kw,qw,Jw,Yw,Xw,Zw,Qw,$w,eT,tT,nT,rT,iT,aT,oT,sT,cT,lT=o((()=>{hC(),Kw=3034,qw=[`old_testament`,`new_testament`,`deuterocanon`],Jw=`GEN.EXO.LEV.NUM.DEU.JOS.JDG.RUT.1SA.2SA.1KI.2KI.1CH.2CH.EZR.NEH.EST.JOB.PSA.PRO.ECC.SNG.ISA.JER.LAM.EZK.DAN.HOS.JOL.AMO.OBA.JON.MIC.NAM.HAB.ZEP.HAG.ZEC.MAL.MAT.MRK.LUK.JHN.ACT.ROM.1CO.2CO.GAL.EPH.PHP.COL.1TH.2TH.1TI.2TI.TIT.PHM.HEB.JAS.1PE.2PE.1JN.2JN.3JN.JUD.REV.TOB.JDT.ESG.WIS.SIR.BAR.LJE.S3Y.SUS.BEL.1MA.2MA.3MA.4MA.1ES.2ES.MAN.PS2.ODA.PSS.3ES.EZA.5EZ.6EZ.DAG.PS3.2BA.LBA.JUB.ENO.1MQ.2MQ.3MQ.REP.4BA.LAO.LKA`.split(`.`),Yw={GEN:`old_testament`,EXO:`old_testament`,LEV:`old_testament`,NUM:`old_testament`,DEU:`old_testament`,JOS:`old_testament`,JDG:`old_testament`,RUT:`old_testament`,"1SA":`old_testament`,"2SA":`old_testament`,"1KI":`old_testament`,"2KI":`old_testament`,"1CH":`old_testament`,"2CH":`old_testament`,EZR:`old_testament`,NEH:`old_testament`,EST:`old_testament`,JOB:`old_testament`,PSA:`old_testament`,PRO:`old_testament`,ECC:`old_testament`,SNG:`old_testament`,ISA:`old_testament`,JER:`old_testament`,LAM:`old_testament`,EZK:`old_testament`,DAN:`old_testament`,HOS:`old_testament`,JOL:`old_testament`,AMO:`old_testament`,OBA:`old_testament`,JON:`old_testament`,MIC:`old_testament`,NAM:`old_testament`,HAB:`old_testament`,ZEP:`old_testament`,HAG:`old_testament`,ZEC:`old_testament`,MAL:`old_testament`,MAT:`new_testament`,MRK:`new_testament`,LUK:`new_testament`,JHN:`new_testament`,ACT:`new_testament`,ROM:`new_testament`,"1CO":`new_testament`,"2CO":`new_testament`,GAL:`new_testament`,EPH:`new_testament`,PHP:`new_testament`,COL:`new_testament`,"1TH":`new_testament`,"2TH":`new_testament`,"1TI":`new_testament`,"2TI":`new_testament`,TIT:`new_testament`,PHM:`new_testament`,HEB:`new_testament`,JAS:`new_testament`,"1PE":`new_testament`,"2PE":`new_testament`,"1JN":`new_testament`,"2JN":`new_testament`,"3JN":`new_testament`,JUD:`new_testament`,REV:`new_testament`,TOB:`deuterocanon`,JDT:`deuterocanon`,ESG:`deuterocanon`,WIS:`deuterocanon`,SIR:`deuterocanon`,BAR:`deuterocanon`,LJE:`deuterocanon`,S3Y:`deuterocanon`,SUS:`deuterocanon`,BEL:`deuterocanon`,"1MA":`deuterocanon`,"2MA":`deuterocanon`,"3MA":`deuterocanon`,"4MA":`deuterocanon`,"1ES":`deuterocanon`,"2ES":`deuterocanon`,MAN:`deuterocanon`,PS2:`deuterocanon`,ODA:`deuterocanon`,PSS:`deuterocanon`,"3ES":`deuterocanon`,EZA:`deuterocanon`,"5EZ":`deuterocanon`,"6EZ":`deuterocanon`,DAG:`deuterocanon`,PS3:`deuterocanon`,"2BA":`deuterocanon`,LBA:`deuterocanon`,JUB:`deuterocanon`,ENO:`deuterocanon`,"1MQ":`deuterocanon`,"2MQ":`deuterocanon`,"3MQ":`deuterocanon`,REP:`deuterocanon`,"4BA":`deuterocanon`,LAO:`deuterocanon`,LKA:`new_testament`},Xw=q({id:W(),passage_id:W(),title:W()}),Zw=G({error:`Verse must be an integer`}).check(hS(`Verse must be a positive integer`)),Qw=q({id:W(),passage_id:W(),title:W(),verses:J(K(Xw))}),$w=G({error:`Chapter must be an integer`}).check(hS(`Chapter must be a positive integer`)),eT=LS(qw),tT=q({id:W(),passage_id:W(),title:W()}),nT=W().check(vS(3)),rT=FS([...Jw.map(e=>RS(e)),nT]),q({id:rT,title:W(),full_title:W(),abbreviation:J(W()),canon:eT,intro:J(tT),chapters:J(K(Qw))}),iT=W().check(xS(),U(3,`Book ID must be exactly 3 characters`),_S(3,`Book ID must be exactly 3 characters`)),aT=q({id:G(),abbreviation:W(),promotional_content:J(Y(W())),copyright:J(Y(W())),info:J(Y(W())),publisher_url:J(Y(W())),language_tag:W(),localized_abbreviation:W(),localized_title:W(),organization_id:J(Y(W())),title:W(),books:K(rT),youversion_deep_link:kS()}),oT=G().check(hS(`Version ID must be a positive integer`)),sT=W().check(xS(),U(1,`Language ranges must be a non-empty string`)),cT=J(q({page_size:J(FS([G().check(hS()),RS(`*`)])),page_token:J(W()),fields:J(K(NS(aT))),all_available:J(jS())})).check(US(e=>e?.page_size!==`*`||e.fields&&e.fields.length>=1&&e.fields.length<=3,{error:`page_size="*" requires 1-3 fields to be specified`,path:[`page_size`,`fields`]}))}));async function uT(e,t,n,r,i={}){let a=kw.parse(t);oT.parse(n);let o=aw(r),s=Pw.parse(i),c={query:a,bible_id:n,"language_ranges[]":o};s.userIntent!==void 0&&(c.user_intent=s.userIntent),s.fields!==void 0&&(c[`fields[]`]=s.fields);let l=await e.get(`/v1/search-unified`,c),u=Rw.safeParse(l);if(!u.success)throw Error(`Unexpected search-unified API response: ${u.error.message}`);return fw(u.data)}var dT=o((()=>{zw(),lT()}));async function fT(e,t,n,r={}){let i=kw.parse(t);oT.parse(n),jw.parse(r);let a={query:i,bible_id:n};r.userIntent!==void 0&&(a.user_intent=r.userIntent),r.pageSize!==void 0&&(a.page_size=r.pageSize),r.pageToken!==void 0&&(a.page_token=r.pageToken);let o=await e.get(`/v1/search-verses`,a),s=Tw.safeParse(o);if(!s.success)throw Error(`Unexpected search-verses API response: ${s.error.message}`);return cw(s.data)}var pT=o((()=>{zw(),lT()})),mT,hT=o((()=>{Uw(),Gw(),dT(),pT(),mT=class{client;constructor(e){this.client=e}async getSuggestedQueries(e,t){return Vw(this.client,e,t)}async getTrendingQueries(e){return Hw(this.client,e)}async searchVerses(e,t,n){return fT(this.client,e,t,n)}async searchTopics(e,t){return Ww(this.client,e,t)}async searchUnified(e,t,n,r){return uT(this.client,e,t,n,r)}}}));function gT(e){if(!e.appKey.trim())throw Error(`A non-empty app key is required to build Bible stylesheet resources.`);let t=e.apiHost||`api.youversion.com`;return[{kind:`bible`,rel:`stylesheet`,href:_T},{kind:`font`,rel:`stylesheet`,href:`https://${t}/v1/fonts/1/stylesheet?app_key=${encodeURIComponent(e.appKey)}`}]}var _T,vT=o((()=>{_T=`https://cdn.youversion.com/platform/1/bible.css`}));function yT(e){return e.body?Array.from(e.body.children):[]}function bT(e){if(e.length===0)return;let t=e.map(e=>e.getAttribute(`dir`));if(t.every(e=>e===`ltr`))return`ltr`;if(t.every(e=>e===`rtl`))return`rtl`}function xT(e){let t=e.body??e.documentElement;for(let e of Array.from(t.querySelectorAll(`*`))){let t=e.tagName;if(NT.has(t))e.remove();else if(!MT.has(t))e.replaceWith(...Array.from(e.childNodes));else for(let t of Array.from(e.attributes)){let n=t.name.toLowerCase();(n.startsWith(`on`)||!PT.has(n)&&!n.startsWith(`data-`))&&e.removeAttribute(t.name)}}}function ST(e){let t=`.p, p, .d, .q, .q1, .q2, .q3, .q4, .qm, .qm1, .qm2, .qm3, .qm4, .qr, .qc, .m, .mi, .pi, .pi1, .pi2, .pi3, .pi4, .pc, .pr, .pm, .pmo, .pmc, .pmr, .li, .li1, .li2, .li3, .li4`;function n(e,t,n){let r=Array.from(t.childNodes);if(r.length===0)return;let i=e.createElement(`span`);i.className=`yv-v`,i.setAttribute(`v`,n);let a=r[0];a&&t.insertBefore(i,a),r.forEach(e=>{i.appendChild(e)})}function r(e,r,i,a){if(!i)return;let o=i.nextElementSibling;for(;o&&o!==a;)if(o.classList.contains(`yv-h`)||o.matches(`.s1, .s2, .s3, .s4, .ms, .ms1, .ms2, .ms3, .ms4, .mr, .sp, .sr, .qa, .r`))o=o.nextElementSibling;else{if(o.querySelector(`.yv-v[v]`))break;o.matches(t)&&n(e,o,r),o=o.nextElementSibling}}function i(e,t,n,i){t&&(n?t!==n&&r(e,i,t,n):r(e,i,t))}function a(e,n,r){let a=e.getAttribute(`v`);if(!a)return;let s=r[n+1],c=u(e,s);if(c.length===0)return;let l=e.closest(t),d=s?.closest(t)||null,f=e.ownerDocument;o(e,a,c),i(f,l,d,a)}function o(e,t,n){let r=e.ownerDocument.createElement(`span`);r.className=`yv-v`,r.setAttribute(`v`,t);let i=n[0];i&&e.parentNode?.insertBefore(r,i),n.forEach(e=>{r.appendChild(e)}),e.remove()}function s(e){return e.nodeType===1?e:null}function c(e,t){if(e===t)return!0;let n=s(e);return!!(t&&n?.contains(t))}function l(e){return s(e)?.classList.contains(`yv-h`)===!0}function u(e,t){let n=[],r=e.nextSibling;for(;r&&!c(r,t);)l(r)||n.push(r),r=r.nextSibling;return n}Array.from(e.querySelectorAll(`.yv-v[v]`)).forEach(a)}function CT(e){let t=0;e.querySelectorAll(`.yv-n.f`).forEach(e=>{let n=e.closest(`.yv-v[v]`)?.getAttribute(`v`);e.setAttribute(kT,n??`intro-${t++}`)})}function wT(e,t){for(let n of t){let t=n.getAttribute(kT);if(!t)continue;let r=n.previousSibling,i=n.nextSibling,a=r?.textContent??``,o=i?.textContent??``,s=a.length>0&&!/\s$/.test(a),c=o.length>0&&jT.test(o);s&&c&&n.parentNode&&n.parentNode.insertBefore(e.createTextNode(` `),n);let l=e.createElement(`span`);l.setAttribute(`data-verse-footnote`,t),l.setAttribute(`data-verse-footnote-content`,n.innerHTML),n.replaceWith(l)}}function TT(e){e.querySelectorAll(`.yv-vlbl, .va`).forEach(e=>{let t=e.textContent||``;t.endsWith(OT)||(e.textContent=t+OT)})}function ET(e){e.querySelectorAll(`table`).forEach(e=>{let t=e.querySelectorAll(`tr`);if(t.length===0)return;let n=0;t.forEach(e=>{let t=0;e.querySelectorAll(`td, th`).forEach(e=>{t+=parseInt(e.getAttribute(`colspan`)||`1`,10)}),n=Math.max(n,t)}),n>1&&t.forEach(e=>{let t=e.querySelectorAll(`td, th`);t.length===1&&parseInt(t[0].getAttribute(`colspan`)||`1`,10)<n&&t[0].setAttribute(`colspan`,n.toString())})})}function DT(e,t){let n=t.parseHtml(e);xT(n);let r=yT(n);if(r.length>0&&r.every(e=>e.hasAttribute(AT)))return TT(n),{html:t.serializeHtml(n),direction:bT(r)};ST(n),CT(n),wT(n,Array.from(n.querySelectorAll(`.yv-n.f`))),TT(n),ET(n);for(let e of yT(n))e.setAttribute(AT,``);return{html:t.serializeHtml(n),direction:bT(yT(n))}}var OT,kT,AT,jT,MT,NT,PT,FT=o((()=>{OT=`\xA0`,kT=`data-footnote-key`,AT=`data-yv-transformed`,jT=/^[^\s.,;:!?)}\]'"'»›]/,MT=new Set([`DIV`,`P`,`SPAN`,`SUP`,`SUB`,`EM`,`STRONG`,`I`,`B`,`SMALL`,`BR`,`SECTION`,`TABLE`,`THEAD`,`TBODY`,`TR`,`TD`,`TH`]),NT=new Set([`SCRIPT`,`STYLE`,`IFRAME`,`OBJECT`,`EMBED`,`SVG`,`MATH`,`FORM`,`INPUT`,`BUTTON`,`TEXTAREA`,`SELECT`,`TEMPLATE`,`LINK`,`META`,`BASE`,`NOSCRIPT`]),PT=new Set([`class`,`v`,`colspan`,`rowspan`,`dir`,`usfm`])}));function IT(e){return oT.parse(e)}function LT(e){return iT.parse(e)}function RT(e){return $w.parse(e)}async function zT(e,t){IT(t),EC(t)&&kC();let n=await e.get(`/v1/bibles/${t}`);return DC({id:n.id,languageTag:n.language_tag})||kC(),n}async function BT(e,t){EC(t)&&kC(),wC()&&await zT(e,t)}async function VT(e,t,n,r){return IT(t),LT(n),RT(r),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}`)}var HT=o((()=>{zC(),lT()})),UT=s(((e,t)=>{t.exports={}}));function WT(e,t,n){t!==void 0&&ZT.parse(t),n!==void 0&&ZT.parse(n);let r={format:e};return t!==void 0&&(r.include_headings=t),n!==void 0&&(r.include_notes=n),r}async function GT(){if(globalThis.DOMParser)return{parseHtml:e=>new globalThis.DOMParser().parseFromString(e,`text/html`),serializeHtml:e=>e.body.innerHTML};let e;try{e=await Promise.resolve().then(()=>u(UT(),1))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Server-side HTML transformation requires "jsdom". Install it as a dependency or pass transform: false to skip transformation. Original error: ${t}`,{cause:e})}return{parseHtml:t=>new e.JSDOM(`<!DOCTYPE html><html><body>${t}</body></html>`).window.document,serializeHtml:e=>e.body.innerHTML}}async function KT(e,t,n,r=`html`,i,a,o){IT(t);let s=WT(r,i,a);return await BT(e,t),YT(await JT(e,t,n,s),s.format,o)}async function qT(e,t,n,r=`html`,i,a,o){IT(t);let s=WT(r,i,a),c=await JT(e,t,n,s);return YT(XT.parse(c),s.format,o)}async function JT(e,t,n,r){return e.get(`/v1/bibles/${t}/passages/${n}`,r)}async function YT(e,t,n){if(t===`html`&&n!==!1){let t=await GT(),{html:n}=DT(e.content,t);return{...e,content:n}}return e}var XT,ZT,QT=o((()=>{FT(),HT(),hC(),XT=q({id:W(),content:W(),reference:W()}),ZT=jS()}));function $T(e){return e.copyright?.trim()?{text:e.copyright,source:`copyright`}:e.promotional_content?.trim()?{text:e.promotional_content,source:`promotionalContent`}:null}async function eE(e,t){let n=()=>qT(e,t.versionId,t.passageId,`html`,t.includeHeadings,t.includeNotes,!0);if(wC()){let r=await zT(e,t.versionId);return{passage:await n(),version:r}}EC(t.versionId)&&kC();let[r,i]=await Promise.all([n(),zT(e,t.versionId)]);return{passage:r,version:i}}async function tE(e,t){let n=nE.parse(t),r=gT(e.config),i=await eE(e,n),a=aT.parse(i.version),o=$T(a);if(!o)throw new sE(a.id);return{version:a,html:i.passage.content,attribution:o,stylesheets:r,containerAttributes:oE}}var nE,rE,iE,aE,oE,sE,cE=o((()=>{vT(),QT(),HT(),zC(),lT(),hC(),nE=q({versionId:oT,passageId:W().check(xS(),U(1,`Passage ID must be a non-empty string`)),includeHeadings:J(jS()),includeNotes:J(jS())}),rE=q({text:W().check(U(1)),source:LS([`copyright`,`promotionalContent`])}),iE=q({kind:LS([`bible`,`font`]),rel:RS(`stylesheet`),href:kS()}),aE=q({"data-yv-sdk":RS(``),"data-slot":RS(`yv-bible-renderer`)}),q({version:aT,html:W(),attribution:rE,stylesheets:K(iE),containerAttributes:aE}),oE=Object.freeze({"data-yv-sdk":``,"data-slot":`yv-bible-renderer`}),sE=class extends Error{code=`missing_passage_attribution`;versionId;constructor(e){super(`Bible version ${e} has no display attribution.`),this.name=`MissingPassageAttributionError`,this.versionId=e}}}));async function lE(e,t,n){return IT(t),await BT(e,t),e.get(`/v1/bibles/${t}/books`,{...n&&{canon:n}})}async function uE(e,t,n){return IT(t),LT(n),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}`)}async function dE(e,t,n){return IT(t),LT(n),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters`)}async function fE(e,t,n,r){return IT(t),LT(n),RT(r),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}/verses`)}async function pE(e,t,n,r,i){return IT(t),LT(n),RT(r),Zw.parse(i),await BT(e,t),e.get(`/v1/bibles/${t}/books/${n}/chapters/${r}/verses/${i}`)}async function mE(e){return e.get(`/v1/verse_of_the_days`)}async function hE(e,t){return G().check(mS(1),fS(366)).parse(t),e.get(`/v1/verse_of_the_days/${t}`)}var gE=o((()=>{HT(),lT(),hC()}));async function _E(e,t,n,r){let i=Array.isArray(t)?t:[t],a={"language_ranges[]":K(sT).check(U(1,`At least one language range is required`)).parse(i)};if(n&&(a.license_id=n),r?.page_size===`*`){let e=r.fields?.length??0;if(e<1||e>3)throw Error(`page_size="*" requires 1-3 fields to be specified`)}cT.parse(r),r?.page_size&&(a.page_size=r.page_size),r?.fields&&(a[`fields[]`]=r.fields),r?.all_available&&(a.all_available=`true`);let o=AC(r?.fields);return FC(a,r??{},{fieldsNeeded:()=>o,isFilterActive:CC,fetchPage:t=>{let n={...a};return t&&(n.page_token=t),e.get(`/v1/bibles`,n)},isUsable:e=>DC({id:e.id,languageTag:e.language_tag})})}var vE=o((()=>{zC(),lT(),hC()})),yE,bE=o((()=>{cE(),QT(),gE(),HT(),vE(),yE=class{client;constructor(e){this.client=e}async getVersions(e,t,n){return _E(this.client,e,t,n)}async getVersion(e){return zT(this.client,e)}async getBooks(e,t){return lE(this.client,e,t)}async getBook(e,t){return uE(this.client,e,t)}async getChapters(e,t){return dE(this.client,e,t)}async getChapter(e,t,n){return VT(this.client,e,t,n)}async getVerses(e,t,n){return fE(this.client,e,t,n)}async getVerse(e,t,n,r){return pE(this.client,e,t,n,r)}async getPassage(e,t,n=`html`,r,i,a){return KT(this.client,e,t,n,r,i,a)}async getPassageDisplay(e){return tE(this.client,e)}async getIndex(e){return IT(e),await BT(this.client,e),this.client.get(`/v1/bibles/${e}/index`)}async getAllVOTDs(){return mE(this.client)}async getVOTD(e){return hE(this.client,e)}}}));function xE(){return`${CE}=${TE}`}function SE(e){let t=EE.safeParse(e);return t.success?t.data.status:void 0}var CE,wE,TE,EE,DE,OE,kE=o((()=>{hC(),CE=`ReactSDK`,wE=`X-YVP-Sdk`,TE=`2.16.0`,EE=q({status:AS()}),DE=q({message:J(W()),error:J(W())}),OE=class{baseURL;timeout;defaultHeaders;config;constructor(e){this.config={...e};let t=e.apiHost||`api.youversion.com`;if(!t)throw Error(`ApiClient requires a host name. Provide an apiHost in the config.`);this.baseURL=`https://`+t,this.timeout=e.timeout||1e4,this.defaultHeaders={"Content-Type":`application/json`,"X-YVP-App-Key":this.config.appKey,"X-YVP-Installation-Id":this.config.installationId||`web-sdk-default`,[wE]:xE(),...e.additionalHeaders}}buildQueryString(e){if(!e)return``;let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{Array.isArray(n)?n.forEach(n=>t.append(e,String(n))):t.append(e,String(n))});let n=t.toString();return n?`?${n}`:``}async request(e,t={}){let n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout);try{let i=new Headers(this.defaultHeaders);new Headers(t.headers).forEach((e,t)=>{i.set(t,e)});let a=await fetch(e,{...t,signal:n.signal,headers:i});if(clearTimeout(r),!a.ok){let e=process.env.NODE_ENV===`development`,t=`HTTP error! status: ${a.status}`;try{let n=await a.text();if(n)try{let r=DE.safeParse(JSON.parse(n)),i=r.success&&(r.data.message||r.data.error)||n;t=e?i:`Request failed with status ${a.status}`}catch{e&&(t=n)}}catch(t){e&&t instanceof Error&&console.error(`Failed to read error response:`,t.message)}throw Object.assign(Error(t),{status:a.status,statusText:a.statusText})}if(a.headers.get(`content-type`)?.includes(`application/json`)){let e=await a.text();return e?JSON.parse(e):void 0}return await a.text()}catch(e){throw clearTimeout(r),e instanceof Error&&e.name===`AbortError`?Error(`Request timeout after ${this.timeout}ms`):e}}async get(e,t,n){let r=`${this.baseURL}${e}${this.buildQueryString(t)}`;return this.request(r,{method:`GET`,headers:n})}async post(e,t,n,r){let i=`${this.baseURL}${e}${this.buildQueryString(n)}`;return this.request(i,{method:`POST`,body:t?JSON.stringify(t):void 0,headers:r})}async delete(e,t,n){let r=`${this.baseURL}${e}${this.buildQueryString(t)}`;return this.request(r,{method:`DELETE`,headers:n})}}}));function AE(e){try{let t=e();if(t?.getItem instanceof Function)return t}catch{}return null}function jE(e){return AE(()=>globalThis.window?globalThis.window[e]:null)??AE(()=>globalThis[e])}function ME(){return jE(`localStorage`)}function NE(){return jE(`sessionStorage`)}function PE(e,t,n){try{return e?.setItem(t,n),e!==null}catch{return!1}}function FE(e,t){try{e?.removeItem(t)}catch{}}function IE(e){try{e?.clear()}catch{}}var LE,RE,zE,BE,VE,HE,UE,Q,WE=o((()=>{SC(),hC(),LE=q({state:W(),permissions:K(W())}),RE=q({userId:W(),permissions:K(W())}),zE=q({sub:BS(J(W()),void 0),name:BS(J(W()),void 0),profile_picture:BS(J(W()),void 0),email:BS(J(W()),void 0)}),BE=VS(FS([AS(),VS(W().check(yS(/^\d+$/)),zS(Number))]),G().check(hS())),VE=q({access_token:W(),expires_in:BE,id_token:W(),refresh_token:W(),scope:W(),token_type:W()}),HE=q({access_token:W(),expires_in:BE,refresh_token:W(),scope:W(),token_type:W()}),UE=q({name:J(W()),id:J(W()),avatar_url:J(W()),email:J(W())}),Q=class{static _appKey=null;static _installationId=null;static _apiHost=`api.youversion.com`;static _refreshTokenKey=null;static _expiryDateKey=null;static _signInPromptMessage=void 0;static _appName=void 0;static getOrSetInstallationId(){let e=ME();if(!e)return``;let t=e.getItem(`x-yvp-installation-id`);if(t)return t;let n=globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`yvp-${new Date().toISOString()}-${Math.random().toString(36).slice(2,10)}`;return PE(e,`x-yvp-installation-id`,n)?n:``}static saveAuthData(e,t,n){let r=ME(),i=!0;return e===null?FE(r,`accessToken`):i=PE(r,`accessToken`,e)&&i,t===null?FE(r,`refreshToken`):i=PE(r,`refreshToken`,t)&&i,n===null?FE(r,`expiryDate`):i=PE(r,`expiryDate`,n.toISOString())&&i,i}static saveUserInfo(e){let t=ME();return e===null?(FE(t,`userInfo`),!0):PE(t,`userInfo`,JSON.stringify(e))}static clearAuthTokens(){this.saveAuthData(null,null,null),this.saveUserInfo(null),this.clearGrantedPermissions(),this.clearDataExchangeInitiator()}static grantedPermissionsKey=`youversion-platform:granted-permissions`;static get currentUserId(){return this.storedUserInfo?.id??null}static readStoredGrants(){let e=ME()?.getItem(this.grantedPermissionsKey);if(!e)return null;try{let t=RE.safeParse(JSON.parse(e));return t.success?t.data:null}catch{return null}}static writeStoredGrants(e,t){PE(ME(),this.grantedPermissionsKey,JSON.stringify({userId:e,permissions:t}))}static get grantedPermissions(){let e=this.currentUserId;if(!e)return[];let t=this.readStoredGrants();return t?.userId===e?t.permissions:[]}static saveGrantedPermissions(e){let t=this.currentUserId;if(!t)return;let n=new Set([...this.grantedPermissions,...e]);this.writeStoredGrants(t,[...n])}static removeGrantedPermission(e){let t=this.currentUserId;if(!t)return;let n=this.grantedPermissions.filter(t=>t!==e);this.writeStoredGrants(t,n)}static clearGrantedPermissions(){FE(ME(),this.grantedPermissionsKey)}static dataExchangeInitiatorKey=`youversion-platform:data-exchange-initiator`;static saveDataExchangeInitiator(){let e=this.currentUserId;e&&PE(ME(),this.dataExchangeInitiatorKey,e)}static get dataExchangeInitiator(){return ME()?.getItem(this.dataExchangeInitiatorKey)??null}static clearDataExchangeInitiator(){FE(ME(),this.dataExchangeInitiatorKey)}static hasPermission(e){return this.grantedPermissions.includes(e)}static get accessToken(){return ME()?.getItem(`accessToken`)??null}static get refreshToken(){return ME()?.getItem(`refreshToken`)??null}static get storedUserInfo(){let e=ME()?.getItem(`userInfo`);if(!e)return null;try{let t=JSON.parse(e),n=UE.safeParse(t);return n.success?n.data:null}catch{return null}}static get tokenExpiryDate(){let e=ME()?.getItem(`expiryDate`);return e?new Date(e):null}static get appKey(){return this._appKey}static set appKey(e){this._appKey=e}static get installationId(){return this._installationId||=this.getOrSetInstallationId(),this._installationId}static set installationId(e){this._installationId=e||this.getOrSetInstallationId()}static get apiHost(){return this._apiHost}static set apiHost(e){this._apiHost=e}static get refreshTokenKey(){return this._refreshTokenKey}static set refreshTokenKey(e){this._refreshTokenKey=e}static get expiryDateKey(){return this._expiryDateKey}static set expiryDateKey(e){this._expiryDateKey=e}static get signInPromptMessage(){return this._signInPromptMessage}static set signInPromptMessage(e){this._signInPromptMessage=e}static get appName(){return this._appName}static set appName(e){this._appName=e}static get permittedVersionIds(){return Z.permittedVersionIds}static set permittedVersionIds(e){Z.permittedVersionIds=e}static get excludedVersionIds(){return Z.excludedVersionIds}static set excludedVersionIds(e){Z.excludedVersionIds=e}static get permittedLanguageTags(){return Z.permittedLanguageTags}static set permittedLanguageTags(e){Z.permittedLanguageTags=e}}}));function GE(e,t){if(e)return e;let n=Q.accessToken;if(!n)throw Error(`Authentication required. Please provide a token or sign in before ${t}.`);return n}var KE=o((()=>{WE()}));function qE(e){let t=[];for(let[n,r]of e)/^granted_permissions(\[\d*\])?$/.test(n)&&t.push(r);return YE(t)}function JE(e){return e?YE([e]):[]}function YE(e){let t=new Set;for(let n of e)for(let e of n.split(/[,\s]+/))e&&t.add(e);return[...t]}var XE=o((()=>{}));function ZE(e,t,n=Q.apiHost){let r=new URL(`https://${n}/data-exchange`);return r.searchParams.set(`token`,e),r.searchParams.set(`app_key`,t),r.searchParams.set(`x-yvp-app-key`,t),r.toString()}function QE(e){let t=new URLSearchParams(e);if(!t.has(`data_exchange_status`))return null;let n=t.get(`data_exchange_status`);return{status:n===`granted`?`granted`:n===`cancel`?`cancel`:`failure`,grantedPermissions:qE(t)}}function $E(){let e=globalThis.window;if(!e)return null;let t=QE(e.location.search);if(!t)return null;let n=Q.dataExchangeInitiator;Q.clearDataExchangeInitiator();let r=t;if(t.status===`granted`&&t.grantedPermissions.length>0){let e=Q.storedUserInfo?.id??null;n&&e&&n===e?Q.saveGrantedPermissions(t.grantedPermissions):r={status:`failure`,grantedPermissions:[]}}let i=new URL(e.location.href);for(let e of nD)i.searchParams.delete(e);return e.history.replaceState({},``,i.toString()),r}var eD,tD,nD,rD=o((()=>{KE(),XE(),WE(),hC(),q({requested_permissions:K(W())}),eD=q({token:W().check(U(1))}),tD=class{client;constructor(e){this.client=e}getAuthToken(e){return GE(e,`requesting a data exchange`)}async updateToken(e,t){let n=this.client.config.appKey;if(!n)throw Error(`App key is required to request a data exchange token.`);let r=await this.client.post(`/data-exchange/token`,{requested_permissions:e},{"app-key":n},{Authorization:`Bearer ${this.getAuthToken(t)}`}),i=eD.safeParse(r);if(!i.success)throw Error(`Unexpected data exchange token response: ${i.error.message}`);return i.data.token}},nD=[`data_exchange_status`,`granted_permissions`]}));function iD(e){return{version_id:e.bible_id,passage_id:e.passage_id,color:e.color}}var aD,oD,sD,cD,lD,uD,dD,fD=o((()=>{KE(),WE(),zC(),lT(),hC(),aD=/^[0-9a-f]{6}$/i,oD=W().check(yS(aD)),sD=W().check(xS(),U(1,`Passage ID must be a non-empty string`)),cD=W().check(yS(aD,`Color must be a 6-character hex string without #`)),lD=q({bible_id:G().check(hS()),passage_id:W(),color:oD}),uD=q({data:K(lD),next_page_token:J(Y(W()))}),q({version_id:G().check(hS()),passage_id:W(),color:oD}),q({version_id:G().check(hS()),passage_id:W(),color:oD}),q({request_id:W().check(U(1)),highlight:lD}),dD=class{client;constructor(e){this.client=e}getAuthToken(e){return GE(e,`accessing highlights`)}authHeaders(e){return{Authorization:`Bearer ${this.getAuthToken(e)}`}}validateVersionId(e){try{oT.parse(e)}catch{throw Error(`Version ID must be a positive integer`)}}validatePassageId(e){try{sD.parse(e)}catch{throw Error(`Passage ID must be a non-empty string`)}}async assertUsableVersion(e){if(EC(e)&&kC(),Q.permittedLanguageTags===void 0)return;let t=await this.client.get(`/v1/bibles/${e}`);DC({id:t.id,languageTag:t.language_tag})||kC()}validateColor(e){try{cD.parse(e)}catch{throw Error(`Color must be a 6-character hex string without #`)}}generateRequestId(){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`yvp-${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}async getHighlights(e,t){this.validateVersionId(e.version_id),this.validatePassageId(e.passage_id),await this.assertUsableVersion(e.version_id);let n=await this.client.get(`/v1/highlights`,{bible_id:e.version_id,passage_id:e.passage_id},this.authHeaders(t));if(n===``||n==null)return{data:[],next_page_token:null};let r=uD.safeParse(n);if(!r.success)throw Error(`Unexpected highlights API response: ${r.error.message}`);return{data:r.data.data.map(iD),next_page_token:r.data.next_page_token??null}}async createHighlight(e,t){this.validateVersionId(e.version_id),this.validatePassageId(e.passage_id),this.validateColor(e.color),await this.assertUsableVersion(e.version_id);let n=await this.client.post(`/v1/highlights`,{request_id:this.generateRequestId(),highlight:{bible_id:e.version_id,passage_id:e.passage_id,color:e.color.toLowerCase()}},void 0,this.authHeaders(t)),r=lD.safeParse(n);if(!r.success)throw Error(`Unexpected highlights API response: ${r.error.message}`);return iD(r.data)}async deleteHighlight(e,t,n){this.validatePassageId(e),this.validateVersionId(t.version_id),await this.assertUsableVersion(t.version_id),await this.client.delete(`/v1/highlights/${encodeURIComponent(e)}`,{bible_id:t.version_id},this.authHeaders(n))}}}));function pD(e){let t={};return e.passage_id!==void 0&&(t.passage_id=e.passage_id),e.language_ranges!==void 0&&(t[`language_ranges[]`]=[...e.language_ranges]),e.page_size!==void 0&&(t.page_size=e.page_size),e.page_token!=null&&(t.page_token=e.page_token),t}function mD(e){let t={data:e.data,next_page_token:e.next_page_token};return e.total_size==null?t:{...t,total_size:e.total_size}}var hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD=o((()=>{zw(),hC(),hD=q({id:W(),image_url:W(),passage_id:W(),attribution:W(),language_tag:W(),width:G(),height:G(),aspect_ratio:AS()}),gD=VS(J(Y(W())),zS(e=>e==null||e===``?null:e)),_D=VS(q({data:K(MS()),next_page_token:gD,total_size:J(Y(G().check(gS())))}),zS(e=>({...e,data:e.data.flatMap(e=>{let t=hD.safeParse(e);return t.success?[t.data]:[]})}))),vD=W().check(U(1,`Image ID must be a non-empty string`),US(e=>e.trim().length>0,`Image ID must be a non-empty string`)),yD=W().check(xS(),U(1,`Passage ID must be a non-empty string`)),bD=VS(W(),zS(e=>iw(e))),xD=`Page size must be an integer from 1 to 99`,SD=q({passage_id:J(yD),language_ranges:J(HS(K(bD).check(U(1,`Pass at least one language range, or omit language_ranges`)))),page_size:J(G({error:xD}).check(mS(1,xD),fS(99,xD))),page_token:J(Y(W().check(U(1,`Page token must be a non-empty string`))))}),CD=`/v1/images`,wD=class{client;constructor(e){this.client=e}async getImages(e={}){let t=SD.parse(e),n=await this.client.get(CD,pD(t));if(n===``||n==null)return{data:[],next_page_token:null};let r=_D.safeParse(n);if(!r.success)throw Error(`Unexpected images API response: ${r.error.message}`);return mD(r.data)}async getImage(e){let t=vD.parse(e),n=await this.client.get(`${CD}/${encodeURIComponent(t)}`),r=hD.safeParse(n);if(!r.success)throw Error(`Unexpected images API response: ${r.error.message}`);return r.data}}}));function ED(){zD.clear()}function DD(){BD=null}var OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD=o((()=>{XE(),WE(),OD=class{name;userId;email;avatarUrlFormat;constructor(e){let t=UE.safeParse(e);if(!t.success)throw Error(`Invalid user data provided`);this.name=t.data.name,this.userId=t.data.id,this.email=t.data.email,this.avatarUrlFormat=t.data.avatar_url}getAvatarUrl(e=200,t=200){if(!this.avatarUrlFormat)return null;let n=this.avatarUrlFormat;n.startsWith(`//`)&&(n=`https:`+n),n=n.replace(`{width}`,e.toString()),n=n.replace(`{height}`,t.toString());try{return new URL(n)}catch{return null}}get avatarUrl(){return this.getAvatarUrl()}},kD=class{static async make(e,t,n,r){let i=this.randomURLSafeString(32),a={codeVerifier:i,codeChallenge:await this.codeChallenge(i),state:this.randomURLSafeString(24),nonce:this.randomURLSafeString(24)};return{url:this.authorizeURL(e,t,a,n,r),parameters:a}}static authorizeURL(e,t,n,r,i){let a=new URL(`https://${Q.apiHost}/auth/authorize`),o=t.toString().endsWith(`/`)?t.toString().slice(0,-1):t.toString(),s=new URLSearchParams({response_type:`code`,client_id:e,redirect_uri:o,nonce:n.nonce,state:n.state,code_challenge:n.codeChallenge,code_challenge_method:`S256`}),c=Q.installationId;c&&s.set(`x-yvp-installation-id`,c);let l=this.scopeValue(r||[]);l&&s.set(`scope`,l);let u=[...i??[]].sort().join(`,`);return u&&s.set(`requested_permissions`,u),a.search=s.toString(),a}static tokenURLRequest(e,t,n){let r=Q.apiHost,i=Q.appKey,a=new URL(`https://${r}/auth/token`),o=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:n,client_id:i??``,code_verifier:t});return new Request(a,{method:`POST`,body:o,headers:{"Content-Type":`application/x-www-form-urlencoded`}})}static randomURLSafeString(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),this.base64URLEncodedString(t)}static async codeChallenge(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return this.base64URLEncodedString(new Uint8Array(n))}static base64URLEncodedString(e){return btoa(String.fromCharCode.apply(null,Array.from(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}static scopeValue(e){let t=Array.from(e).sort().join(` `);return t.split(` `).includes(`openid`)||(t+=(t===``?``:` `)+`openid`),t||null}},AD={bibles:`bibles`,highlights:`highlights`,votd:`votd`,demographics:`demographics`,bibleActivity:`bible_activity`},jD=class{accessToken;expiryDate;refreshToken;yvpUserId;name;profilePicture;email;constructor({accessToken:e,expiresIn:t,refreshToken:n,yvpUserId:r,name:i,profilePicture:a,email:o}){this.accessToken=e,this.expiryDate=t?new Date(Date.now()+t*1e3):new Date,this.refreshToken=n,this.yvpUserId=r,this.name=i,this.profilePicture=a,this.email=o}},MD=`Sign In with YouVersion requires localStorage, which is not available in this environment`,ND=`Sign In with YouVersion could not write to localStorage; the store rejected the write (its quota may be full, as it always is in Safari private browsing)`,PD=()=>{let e=ME();if(!e)throw Error(MD);return e},FD=(e,t,n)=>{if(!PE(e,t,n))throw Error(ND)},ID=`youversion-auth-pending-granted-permissions`,LD=`youversion-auth-requested-permissions`,RD=new Set([`openid`,`profile`,`email`,`offline_access`]),zD=new Map,BD=null,VD=e=>{FE(e,`youversion-auth-code-verifier`),FE(e,`youversion-auth-redirect-uri`),FE(e,`youversion-auth-state`),FE(e,ID),FE(e,LD)},HD=(e,t,n)=>{PE(e,ID,JSON.stringify({state:t,permissions:n}))},UD=(e,t)=>{let n=e?.getItem(ID);if(FE(e,ID),!n)return[];try{let e=LE.safeParse(JSON.parse(n));if(e.success&&e.data.state===t)return e.data.permissions}catch{}return[]},WD=(e,t,n)=>{FD(e,LD,JSON.stringify({state:t,permissions:n}))},GD=(e,t)=>{let n=e?.getItem(LD);if(FE(e,LD),!n)return[];try{let e=LE.safeParse(JSON.parse(n));if(e.success&&e.data.state===t)return e.data.permissions}catch{}return[]},KD=class{static async signIn(e,t,n){let r=Q.appKey;if(!r)throw Error(`YouVersionPlatformConfiguration.appKey must be set before calling signIn`);let i=PD(),a=await kD.make(r,new URL(e),t,n);FD(i,`youversion-auth-code-verifier`,a.parameters.codeVerifier),FD(i,`youversion-auth-redirect-uri`,e.toString().endsWith(`/`)?e.toString().slice(0,-1):e.toString()),FD(i,`youversion-auth-state`,a.parameters.state),FE(i,ID),FE(i,LD),Q.clearDataExchangeInitiator(),n&&n.length>0&&WD(i,a.parameters.state,n),window.location.href=a.url.toString()}static async handleAuthCallback(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`);if(!n&&!r)return null;if(r){let t=e.get(`error_description`)||r;throw Error(`OAuth authentication failed: ${t}`)}let i=PD();if(n!==i.getItem(`youversion-auth-state`))throw Error(`Invalid state parameter - possible CSRF attack`);if(!t&&n){let t=qE(e);return t.length>0&&HD(i,n,t),this.obtainLocation(window.location.href,n),null}let a=i.getItem(`youversion-auth-code-verifier`),o=i.getItem(`youversion-auth-redirect-uri`);if(!t||!a||!o)throw Error(`Missing required authentication parameters`);let s=zD.get(t);if(s)return s;let c=this.exchangeCodeForTokens(t,a,o,n,e,i);return zD.set(t,c),c}static async exchangeCodeForTokens(e,t,n,r,i,a){try{let o=kD.tokenURLRequest(e,t,n),s=await fetch(o);if(!s.ok)throw Error(`Token exchange failed: ${s.status} ${s.statusText}`);let c=await s.text(),l=VE.safeParse(JSON.parse(c));if(!l.success)throw Error(`Token exchange response was invalid: ${l.error.message}`);let u=l.data,d=r?UD(a,r):[],f=r?GD(a,r):[],p=[...new Set([...qE(i),...d,...JE(u.scope),...f])].filter(e=>!RD.has(e)),m=this.extractSignInResult(u),h=Q.saveAuthData(m.accessToken||null,m.refreshToken||null,m.expiryDate||null),ee=Q.saveUserInfo({id:m.yvpUserId,name:m.name,email:m.email,avatar_url:m.profilePicture});if(!h||!ee)throw Error(`Sign-in succeeded but the session could not be saved to browser storage`);p.length>0&&Q.saveGrantedPermissions(p),VD(a);let te=new URL(window.location.href);return te.search=``,window.history.replaceState({},``,te.toString()),m}catch(e){throw Q.clearAuthTokens(),VD(a),e}}static obtainLocation(e,t){let n=new URL(e),r=new URLSearchParams(n.search);if(r.get(`state`)!==t)throw Error(`Invalid state parameter`);let i=new URL(`https://${Q.apiHost}/auth/callback`);r.forEach((e,t)=>{i.searchParams.set(t,e)}),window.location.href=i.toString()}static extractSignInResult(e){let t=this.decodeJWT(e.id_token);return new jD({accessToken:e.access_token,expiresIn:e.expires_in,refreshToken:e.refresh_token,yvpUserId:t.sub,name:t.name,profilePicture:t.profile_picture,email:t.email})}static decodeJWT(e){let t=e.split(`.`);if(t.length!==3)return{};let n=t[1]?.replace(/-/g,`+`).replace(/_/g,`/`);for(;n&&n.length%4!=0;)n+=`=`;try{if(n){let e=atob(n),t=Uint8Array.from(e,e=>e.charCodeAt(0)),r=new TextDecoder(`utf-8`).decode(t),i=zE.safeParse(JSON.parse(r));return i.success?i.data:{}}return{}}catch(e){return process.env.NODE_ENV===`development`&&console.error(`JWT decode failed:`,e),{}}}static signOut(){Q.clearAuthTokens()}static userInfo(e){if(!e)throw Error(`Invalid access token: must be a non-empty string`);try{let t=this.decodeJWT(e);if(!t||Object.keys(t).length===0)throw Error(`Invalid JWT token: Unable to decode token payload`);return new OD({id:t.sub,name:t.name,avatar_url:t.profile_picture,email:t.email})}catch(e){throw e instanceof Error?Error(`Failed to decode user information from JWT: ${e.message}`):Error(`Failed to decode user information from JWT: Unknown error`)}}static getStoredUserInfo(){let e=Q.storedUserInfo;return e?.id?new OD(e):null}static async refreshTokens(){let e=Q.refreshToken,t=Q.appKey;if(!e)throw Error(`No refresh token available`);if(!t)throw Error(`YouVersionPlatformConfiguration.appKey must be set before refreshing tokens`);try{let n=new URL(`https://${Q.apiHost}/auth/token`),r=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:t}),i=new Request(n,{method:`POST`,body:r,headers:{"Content-Type":`application/x-www-form-urlencoded`}}),a=await fetch(i);if(!a.ok)throw Error(`Token refresh failed: ${a.status} ${a.statusText}`);let o=HE.parse(await a.json()),s=new jD({accessToken:o.access_token,expiresIn:o.expires_in,refreshToken:o.refresh_token});if(!Q.saveAuthData(s.accessToken||null,s.refreshToken||null,s.expiryDate||null))throw Error(`the rotated tokens could not be saved to browser storage`);return s}catch(e){throw e instanceof Error?Error(`Token refresh failed: ${e.message}`):Error(`Token refresh failed: Unknown error`)}}static isTokenExpired(){let e=Q.tokenExpiryDate;return!e||new Date().getTime()>=e.getTime()}static async refreshTokenIfNeeded(){if(!this.isTokenExpired())return!0;let e=BD;if(e)return e;let t=this.performTokenRefresh();BD=t;try{return await t}finally{BD===t&&(BD=null)}}static async performTokenRefresh(){try{return!!await this.refreshTokens()}catch{return Q.clearAuthTokens(),!1}}}})),JD=c({ApiClient:()=>OE,BIBLE_CONTAINER_ATTRIBUTES:()=>oE,BIBLE_CSS_STYLESHEET_URL:()=>_T,BOOK_CANON:()=>Yw,BOOK_IDS:()=>Jw,BibleClient:()=>yE,CANON_IDS:()=>qw,DEFAULT_LICENSE_FREE_BIBLE_VERSION:()=>Kw,DataExchangeClient:()=>tD,HighlightsClient:()=>dD,ImagesClient:()=>wD,LanguagesClient:()=>GC,MAX_SEARCH_QUERY_GRAPHEMES:()=>100,MemoryStorageStrategy:()=>tO,MissingPassageAttributionError:()=>sE,OrganizationsClient:()=>ZC,SDK_NAME:()=>CE,SDK_VERSION:()=>TE,SDK_VERSION_HEADER_NAME:()=>wE,SearchClient:()=>mT,SessionStorageStrategy:()=>eO,SignInWithYouVersionPermission:()=>AD,SignInWithYouVersionResult:()=>jD,UNTITLED_SERIF_FONT_ID:()=>1,YouVersionAPI:()=>nO,YouVersionAPIUsers:()=>KD,YouVersionPlatformConfiguration:()=>Q,YouVersionUserInfo:()=>OD,__resetAuthCallbackDedupeForTests:()=>ED,__resetTokenRefreshDedupeForTests:()=>DD,buildDataExchangeUrl:()=>ZE,buildSdkVersionHeaderValue:()=>xE,clampSearchText:()=>tw,clearStorage:()=>IE,collectFilteredPage:()=>IC,fieldsNeededForLanguageFilter:()=>jC,fieldsNeededForVersionFilter:()=>AC,getAdjacentChapter:()=>XD,getAllVOTDs:()=>mE,getBibleStylesheets:()=>gT,getBook:()=>uE,getBooks:()=>lE,getChapter:()=>VT,getChapters:()=>dE,getHttpStatus:()=>SE,getLanguage:()=>UC,getLanguages:()=>BC,getLocalStorage:()=>ME,getPassage:()=>KT,getPassageAttribution:()=>$T,getPassageDisplay:()=>tE,getSessionStorage:()=>NE,getSuggestedQueries:()=>Vw,getTrendingQueries:()=>Hw,getVOTD:()=>hE,getVerse:()=>pE,getVerses:()=>fE,getVersion:()=>zT,getVersionFilterSnapshot:()=>TC,getVersions:()=>_E,handleDataExchangeCallback:()=>$E,isUsableBibleVersion:()=>DC,isUsableLanguageTag:()=>OC,isValidStructuralUsfmReference:()=>nw,isVersionFilterActive:()=>CC,isVersionIdDecidablyUnusable:()=>EC,parseDataExchangeCallback:()=>QE,parseGrantedPermissions:()=>qE,parseSearchLanguageRange:()=>iw,parseUsfmReference:()=>ew,removeStorageItem:()=>FE,searchTopics:()=>Ww,searchUnified:()=>uT,searchVerses:()=>fT,setStorageItem:()=>PE,throwUnusableBibleVersion:()=>kC,transformBibleHtml:()=>DT});function YD(e){return e.toLowerCase().includes(`intro`)}function XD(e,t,n,r){if(e.length===0)return null;let i=e.findIndex(e=>e.id===t);if(i===-1)return null;let a=e[i],o=a.chapters??[];return r===`next`?ZD(e,i,a,o,n):QD(e,i,a,o,n)}function ZD(e,t,n,r,i){if(YD(i)){let e=r.find(e=>!YD(e.id));if(e)return{bookId:n.id,chapterId:e.id}}if(!YD(i)){let e=r.findIndex(e=>e.id===i);if(e!==-1&&e<r.length-1){let t=r[e+1];if(!YD(t.id))return{bookId:n.id,chapterId:t.id}}}let a=e[t+1];if(!a)return null;let o=(a.chapters??[]).find(e=>!YD(e.id));return o?{bookId:a.id,chapterId:o.id}:null}function QD(e,t,n,r,i){if(YD(i))return $D(e,t);let a=r.findIndex(e=>e.id===i);return a===-1?null:a===r.findIndex(e=>!YD(e.id))?n.intro?{bookId:n.id,chapterId:n.intro.id}:$D(e,t):a>0?{bookId:n.id,chapterId:r[a-1].id}:null}function $D(e,t){let n=e[t-1];if(!n)return null;let r=n.chapters??[];for(let e=r.length-1;e>=0;e--){let t=r[e];if(!YD(t.id))return{bookId:n.id,chapterId:t.id}}return null}var eO,tO,nO,rO=o((()=>{KC(),HC(),QC(),hT(),Uw(),Gw(),dT(),pT(),bE(),kE(),rD(),fD(),TD(),zw(),WC(),qD(),XE(),WE(),cE(),vT(),QT(),FT(),gE(),HT(),vE(),zC(),lT(),eO=class{setItem(e,t){PE(NE(),e,t)||console.warn(`SessionStorage is not available in this environment`)}getItem(e){return NE()?.getItem(e)??null}removeItem(e){FE(NE(),e)}clear(){IE(NE())}},tO=class{store=new Map;setItem(e,t){this.store.set(e,t)}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e)}clear(){this.store.clear()}},nO=class{static addStandardHeaders(e){let t=new Headers({Accept:`application/json`,"Content-Type":`application/json`,[wE]:xE()}),n=Q.appKey;n&&t.set(`X-YVP-App-Key`,n);let r=Q.installationId;return r&&t.set(`X-YVP-Installation-ID`,r),new Request(e.toString(),{headers:t})}}})),$={},iO=ob(R({books:Nv(R({id:ey,name:L,firstChapterNumber:Zv.check(Jv(0)),lastChapterNumber:Zv.check(Jv(0))}).check(Uv(e=>e.lastChapterNumber>=e.firstChapterNumber)))})),aO=R({id:ey,name:L,language:qy,shortName:I(L),languageName:I(L),languageEnglishName:I(L)}),oO=Nv(Fv([R({type:Tv(`verse`),number:Zv,content:Nv(Fv([L,R({text:L,poem:I(kv),wordsOfJesus:I(Av)}),R({noteId:kv}),R({heading:L}),R({lineBreak:Tv(!0)})]))}),R({type:Iv([`heading`,`hebrew_subtitle`]),content:Nv(Fv([L,R({text:L}),R({noteId:kv})]))}),R({type:Tv(`line_break`)})])),sO=ob(R({translation:R({id:ey,name:L,licenseUrl:L,language:qy,shortName:I(L),textDirection:I(Iv([`ltr`,`rtl`])),licenseNotice:I(Lv(L)),licenseNotes:I(Lv(L)),license:I(Lv(Mv(L,Fv([Av,L]))))}),book:R({name:L}),chapter:R({content:oO})})),cO=e=>ob(R({data:Nv(e)}));function lO(e){return{text:`${e.licenseNotice||`${e.name}. ${e.licenseUrl}`} · Source: HelloAO Free Use Bible API`,html:`${e.licenseNotice?Jy(e.licenseNotice):`${Yy(e.name,e.licenseUrl)}.`} · Source: ${Yy(`HelloAO Free Use Bible API`,`https://bible.helloao.org/docs/`)}`}}function uO(e,t){let n=t===void 0?``:`<sup class="scripture-verse-number">${t}</sup> `;return e.map(e=>{if(typeof e==`string`||`text`in e){let t=n;if(n=``,typeof e==`string`)return t+Jy(e);let r=Jy(e.text),i=e.wordsOfJesus?`<span class="scripture-jesus">${r}</span>`:r;return e.poem===void 0?t+i:`<span class="scripture-poetry" style="--indent:${e.poem}">${t}${i}</span>`}return`heading`in e?`<span class="scripture-heading">${Jy(e.heading)}</span>`:`lineBreak`in e?`<br>`:` `}).join(``)}function dO(){let e=new Vy({useCache:!1}),t=ab(),n=n=>t.get(JSON.stringify([`books`,n]),()=>mb(`helloao.books`,t=>e.getTranslationBooks(n,void 0,{signal:t})).pipe(up(iO))),r=(n,r,i)=>t.get(JSON.stringify([`chapter`,n,r,i]),()=>mb(`helloao.chapter`,t=>e.getTranslationBookChapter(n,r,i,void 0,{signal:t})).pipe(up(sO)));return hb({id:`helloao`,defaultVersionId:`BSB`,clearCache:t.clear,listBooks:Pp(`helloao.listBooks`)(function*(e){return(yield*n(e)).books.map(e=>({id:e.id,title:e.name}))}),listChapters:Pp(`helloao.listChapters`)(function*(e,t){yield*nb(t);let r=(yield*n(e)).books.find(e=>e.id===t);return r?Array.from({length:r.lastChapterNumber-r.firstChapterNumber+1},(e,n)=>{let i=r.firstChapterNumber+n;return{number:i,passageId:`${t}.${i}`}}):yield*new Ky({code:`unavailable`,message:`Book is not available in this version.`})}),getPassageData:Pp(`helloao.getPassageData`)(function*(t,n){let{book:i,chapter:a,first:o,last:s}=yield*tb(n),c=yield*r(t,i,a);yield*rb(c.chapter.content.filter(e=>e.type===`verse`).map(e=>e.number),o,s);let l=``,u=!1;for(let e of c.chapter.content)if(e.type===`verse`){if(u=o===void 0||e.number>=o&&e.number<=s,!u)continue;l&&!/\s$/.test(l)&&(l+=` `);let t;for(let[n,r]of e.content.entries()){if(typeof r==`string`||`text`in r){let i=typeof r==`string`?void 0:r.poem,a=e.content[n-1],o=a!==void 0&&typeof a!=`string`&&`noteId`in a&&t!==void 0&&i===t;t===void 0&&i===void 0||o||!l||l.endsWith(`
|
|
21
21
|
`)||(l=l.trimEnd()+`
|
|
22
22
|
`),t=i}if(typeof r==`string`)l+=r;else if(`text`in r)l+=r.text;else if(`lineBreak`in r)l=l.trimEnd()+`
|
|
23
23
|
`;else if(`noteId`in r){let t=e.content.slice(n+1).find(e=>typeof e==`string`||`text`in e),r=typeof t==`string`?t:t&&`text`in t?t.text:``;l&&!/\s$/.test(l)&&r&&!/^[\s,.;:!?…\)\]”’]/.test(r)&&(l+=` `)}}}else e.type===`hebrew_subtitle`&&(o===void 0||o===1)?l+=e.content.map(e=>typeof e==`string`?e:`text`in e?e.text:`lineBreak`in e?`
|