@quranjs/api 3.2.1 → 3.4.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/dist/server.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { c as QuranAudio, Q as QuranChapters, C as ChapterId, g as ChapterRecitation, N as NormalizedVerseRecitation, z as Pagination, V as VerseKey, i as Chapter, j as ChapterInfo, k as ChapterInfoResponse, m as HadithReferencesByAyahResponse, r as HadithCountWithinRangeResponse, q as HadithsByAyahResponse, y as Juz, M as ChapterInfoResource, U as ChapterReciterResource, L as LanguageResource, K as RecitationStylesResource, D as RecitationInfoResource, B as RecitationResource, I as TafsirInfoResource, G as TafsirResource, F as TranslationInfoResource, E as TranslationResource, O as VerseMediaResource, w as Verse, H as HizbNumber, J as JuzNumber, P as PageNumber, R as RubNumber, d as QuranHadithReferences, b as QuranJuzs, e as QuranResources, f as QuranSearch, S as SearchResponse, a as QuranVerses } from './verses-CFFeqPDX.mjs';
2
- import { R as RawOperation } from './runtime-utils-CxjOQDsB.mjs';
3
- import { i as ServerClientConfig, A as ApiParams, O as OperationRequest, U as UserSession, l as TokenResponse, d as SearchParams } from './index-BZgqOfA4.mjs';
1
+ import { a as QuranAnswers, d as QuranAudio, Q as QuranChapters, V as VerseKey, i as AnswersByAyahResponse, k as AnswerCountWithinRangeResponse, h as AnswerQuestion, C as ChapterId, l as ChapterRecitation, N as NormalizedVerseRecitation, I as Pagination, o as Chapter, p as ChapterInfo, q as ChapterInfoResponse, s as HadithReferencesByAyahResponse, x as HadithCountWithinRangeResponse, w as HadithsByAyahResponse, G as Juz, a1 as ContentSyncResourceGroup, a7 as ContentResourceSnapshot, _ as ChapterInfoResource, a0 as ChapterReciterResource, Z as LanguageResource, Y as RecitationStylesResource, L as RecitationInfoResource, K as RecitationResource, X as TafsirInfoResource, U as TafsirResource, O as TranslationInfoResource, M as TranslationResource, $ as VerseMediaResource, a3 as ContentSyncOptions, a6 as ContentSyncResponse, E as Verse, H as HizbNumber, J as JuzNumber, P as PageNumber, R as RubNumber, e as QuranHadithReferences, c as QuranJuzs, f as QuranResources, g as QuranSearch, S as SearchResponse, b as QuranVerses } from './verses-C_LN5-Sn.mjs';
2
+ import { R as RawOperation, Q as QuranReflectPostsFacade } from './runtime-utils-CpHQzQN3.mjs';
3
+ import { i as ServerClientConfig, A as ApiParams, O as OperationRequest, U as UserSession, l as TokenResponse, d as SearchParams } from './index-BgoJducH.mjs';
4
4
 
5
5
  declare const createServerClient: (config: ServerClientConfig) => {
6
+ answers: QuranAnswers;
6
7
  audio: QuranAudio;
7
8
  auth: {
8
9
  v1: {
@@ -104,6 +105,11 @@ declare const createServerClient: (config: ServerClientConfig) => {
104
105
  clearCachedTokens: () => void;
105
106
  content: {
106
107
  v4: {
108
+ answers: {
109
+ byAyah: (key: VerseKey, query?: ApiParams) => Promise<AnswersByAyahResponse>;
110
+ countWithinRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<AnswerCountWithinRangeResponse>;
111
+ get: (questionId: string | number) => Promise<AnswerQuestion>;
112
+ };
107
113
  audio: {
108
114
  chapterRecitation: {
109
115
  get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
@@ -136,6 +142,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
136
142
  };
137
143
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
138
144
  resources: {
145
+ findSnapshot: (resourceGroup: ContentSyncResourceGroup, id: string | number, query?: ApiParams) => Promise<ContentResourceSnapshot<Record<string, unknown>>>;
139
146
  chapterInfos: {
140
147
  list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
141
148
  };
@@ -163,6 +170,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
163
170
  verseMedia: {
164
171
  list: (query?: ApiParams) => Promise<VerseMediaResource>;
165
172
  };
173
+ sync: (query?: ContentSyncOptions) => Promise<ContentSyncResponse<Record<string, unknown>>>;
166
174
  };
167
175
  verses: {
168
176
  byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
@@ -175,6 +183,11 @@ declare const createServerClient: (config: ServerClientConfig) => {
175
183
  random: (query?: ApiParams) => Promise<Verse>;
176
184
  };
177
185
  };
186
+ answers: {
187
+ byAyah: (key: VerseKey, query?: ApiParams) => Promise<AnswersByAyahResponse>;
188
+ countWithinRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<AnswerCountWithinRangeResponse>;
189
+ get: (questionId: string | number) => Promise<AnswerQuestion>;
190
+ };
178
191
  audio: {
179
192
  chapterRecitation: {
180
193
  get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
@@ -207,6 +220,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
207
220
  };
208
221
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
209
222
  resources: {
223
+ findSnapshot: (resourceGroup: ContentSyncResourceGroup, id: string | number, query?: ApiParams) => Promise<ContentResourceSnapshot<Record<string, unknown>>>;
210
224
  chapterInfos: {
211
225
  list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
212
226
  };
@@ -234,6 +248,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
234
248
  verseMedia: {
235
249
  list: (query?: ApiParams) => Promise<VerseMediaResource>;
236
250
  };
251
+ sync: (query?: ContentSyncOptions) => Promise<ContentSyncResponse<Record<string, unknown>>>;
237
252
  };
238
253
  verses: {
239
254
  byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
@@ -282,9 +297,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
282
297
  comments: {
283
298
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
284
299
  };
285
- posts: {
286
- [x: string]: (request?: OperationRequest) => Promise<unknown>;
287
- };
300
+ posts: QuranReflectPostsFacade;
288
301
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
289
302
  rooms: {
290
303
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
@@ -299,9 +312,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
299
312
  comments: {
300
313
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
301
314
  };
302
- posts: {
303
- [x: string]: (request?: OperationRequest) => Promise<unknown>;
304
- };
315
+ posts: QuranReflectPostsFacade;
305
316
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
306
317
  rooms: {
307
318
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
package/dist/server.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { c as QuranAudio, Q as QuranChapters, C as ChapterId, g as ChapterRecitation, N as NormalizedVerseRecitation, z as Pagination, V as VerseKey, i as Chapter, j as ChapterInfo, k as ChapterInfoResponse, m as HadithReferencesByAyahResponse, r as HadithCountWithinRangeResponse, q as HadithsByAyahResponse, y as Juz, M as ChapterInfoResource, U as ChapterReciterResource, L as LanguageResource, K as RecitationStylesResource, D as RecitationInfoResource, B as RecitationResource, I as TafsirInfoResource, G as TafsirResource, F as TranslationInfoResource, E as TranslationResource, O as VerseMediaResource, w as Verse, H as HizbNumber, J as JuzNumber, P as PageNumber, R as RubNumber, d as QuranHadithReferences, b as QuranJuzs, e as QuranResources, f as QuranSearch, S as SearchResponse, a as QuranVerses } from './verses-B5K9Egsa.js';
2
- import { R as RawOperation } from './runtime-utils-CxjOQDsB.js';
3
- import { i as ServerClientConfig, A as ApiParams, O as OperationRequest, U as UserSession, l as TokenResponse, d as SearchParams } from './index-BZgqOfA4.js';
1
+ import { a as QuranAnswers, d as QuranAudio, Q as QuranChapters, V as VerseKey, i as AnswersByAyahResponse, k as AnswerCountWithinRangeResponse, h as AnswerQuestion, C as ChapterId, l as ChapterRecitation, N as NormalizedVerseRecitation, I as Pagination, o as Chapter, p as ChapterInfo, q as ChapterInfoResponse, s as HadithReferencesByAyahResponse, x as HadithCountWithinRangeResponse, w as HadithsByAyahResponse, G as Juz, a1 as ContentSyncResourceGroup, a7 as ContentResourceSnapshot, _ as ChapterInfoResource, a0 as ChapterReciterResource, Z as LanguageResource, Y as RecitationStylesResource, L as RecitationInfoResource, K as RecitationResource, X as TafsirInfoResource, U as TafsirResource, O as TranslationInfoResource, M as TranslationResource, $ as VerseMediaResource, a3 as ContentSyncOptions, a6 as ContentSyncResponse, E as Verse, H as HizbNumber, J as JuzNumber, P as PageNumber, R as RubNumber, e as QuranHadithReferences, c as QuranJuzs, f as QuranResources, g as QuranSearch, S as SearchResponse, b as QuranVerses } from './verses-Dw2mFuje.js';
2
+ import { R as RawOperation, Q as QuranReflectPostsFacade } from './runtime-utils-XwV859WP.js';
3
+ import { i as ServerClientConfig, A as ApiParams, O as OperationRequest, U as UserSession, l as TokenResponse, d as SearchParams } from './index-BgoJducH.js';
4
4
 
5
5
  declare const createServerClient: (config: ServerClientConfig) => {
6
+ answers: QuranAnswers;
6
7
  audio: QuranAudio;
7
8
  auth: {
8
9
  v1: {
@@ -104,6 +105,11 @@ declare const createServerClient: (config: ServerClientConfig) => {
104
105
  clearCachedTokens: () => void;
105
106
  content: {
106
107
  v4: {
108
+ answers: {
109
+ byAyah: (key: VerseKey, query?: ApiParams) => Promise<AnswersByAyahResponse>;
110
+ countWithinRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<AnswerCountWithinRangeResponse>;
111
+ get: (questionId: string | number) => Promise<AnswerQuestion>;
112
+ };
107
113
  audio: {
108
114
  chapterRecitation: {
109
115
  get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
@@ -136,6 +142,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
136
142
  };
137
143
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
138
144
  resources: {
145
+ findSnapshot: (resourceGroup: ContentSyncResourceGroup, id: string | number, query?: ApiParams) => Promise<ContentResourceSnapshot<Record<string, unknown>>>;
139
146
  chapterInfos: {
140
147
  list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
141
148
  };
@@ -163,6 +170,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
163
170
  verseMedia: {
164
171
  list: (query?: ApiParams) => Promise<VerseMediaResource>;
165
172
  };
173
+ sync: (query?: ContentSyncOptions) => Promise<ContentSyncResponse<Record<string, unknown>>>;
166
174
  };
167
175
  verses: {
168
176
  byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
@@ -175,6 +183,11 @@ declare const createServerClient: (config: ServerClientConfig) => {
175
183
  random: (query?: ApiParams) => Promise<Verse>;
176
184
  };
177
185
  };
186
+ answers: {
187
+ byAyah: (key: VerseKey, query?: ApiParams) => Promise<AnswersByAyahResponse>;
188
+ countWithinRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<AnswerCountWithinRangeResponse>;
189
+ get: (questionId: string | number) => Promise<AnswerQuestion>;
190
+ };
178
191
  audio: {
179
192
  chapterRecitation: {
180
193
  get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
@@ -207,6 +220,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
207
220
  };
208
221
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
209
222
  resources: {
223
+ findSnapshot: (resourceGroup: ContentSyncResourceGroup, id: string | number, query?: ApiParams) => Promise<ContentResourceSnapshot<Record<string, unknown>>>;
210
224
  chapterInfos: {
211
225
  list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
212
226
  };
@@ -234,6 +248,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
234
248
  verseMedia: {
235
249
  list: (query?: ApiParams) => Promise<VerseMediaResource>;
236
250
  };
251
+ sync: (query?: ContentSyncOptions) => Promise<ContentSyncResponse<Record<string, unknown>>>;
237
252
  };
238
253
  verses: {
239
254
  byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
@@ -282,9 +297,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
282
297
  comments: {
283
298
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
284
299
  };
285
- posts: {
286
- [x: string]: (request?: OperationRequest) => Promise<unknown>;
287
- };
300
+ posts: QuranReflectPostsFacade;
288
301
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
289
302
  rooms: {
290
303
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
@@ -299,9 +312,7 @@ declare const createServerClient: (config: ServerClientConfig) => {
299
312
  comments: {
300
313
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
301
314
  };
302
- posts: {
303
- [x: string]: (request?: OperationRequest) => Promise<unknown>;
304
- };
315
+ posts: QuranReflectPostsFacade;
305
316
  raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
306
317
  rooms: {
307
318
  [x: string]: (request?: OperationRequest) => Promise<unknown>;
@@ -1,3 +1,3 @@
1
- 'use strict';var de=require('humps');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var de__default=/*#__PURE__*/_interopDefault(de);var W={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},content:{v4:{operations:{audioReciterTimestamp:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/timestamp"},audioReciterLookup:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/lookup"},listChapters:{auth:"app",method:"get",path:"/chapters"},getChapter:{auth:"app",method:"get",path:"/chapters/{id}"},getChapterInfo:{auth:"app",method:"get",path:"/chapters/{id}/info"},hadithReferencesByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}"},hadithsByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}/hadiths"},hadithCountWithinRange:{auth:"app",method:"get",path:"/hadith_references/count_within_range"},listPages:{auth:"app",method:"get",path:"/pages"},getPagesLookup:{auth:"app",method:"get",path:"/pages/lookup"},getPagesPageNumber:{auth:"app",method:"get",path:"/pages/{page_number}"},versesByChapterNumber:{auth:"app",method:"get",path:"/verses/by_chapter/{chapter_number}"},versesByPageNumber:{auth:"app",method:"get",path:"/verses/by_page/{page_number}"},versesByJuzNumber:{auth:"app",method:"get",path:"/verses/by_juz/{juz_number}"},versesByHizbNumber:{auth:"app",method:"get",path:"/verses/by_hizb/{hizb_number}"},versesByRubElHizbNumber:{auth:"app",method:"get",path:"/verses/by_rub/{rub_el_hizb_number}"},versesByManzilNumber:{auth:"app",method:"get",path:"/verses/by_manzil/{manzil_number}"},versesByRukuNumber:{auth:"app",method:"get",path:"/verses/by_ruku/{ruku_number}"},versesByRange:{auth:"app",method:"get",path:"/verses/by_range"},versesByVerseKey:{auth:"app",method:"get",path:"/verses/by_key/{verse_key}"},randomVerse:{auth:"app",method:"get",path:"/verses/random"},listJuzs:{auth:"app",method:"get",path:"/juzs"},quranVersesByScript:{auth:"app",method:"get",path:"/quran/verses/{script}"},quranVersesIndopak:{auth:"app",method:"get",path:"/quran/verses/indopak"},quranVersesIndopakNastaleeq:{auth:"app",method:"get",path:"/quran/verses/indopak_nastaleeq"},quranVersesUthmaniTajweed:{auth:"app",method:"get",path:"/quran/verses/uthmani_tajweed"},quranVersesUthmani:{auth:"app",method:"get",path:"/quran/verses/uthmani"},quranVersesUthmaniSimple:{auth:"app",method:"get",path:"/quran/verses/uthmani_simple"},quranVersesImlaei:{auth:"app",method:"get",path:"/quran/verses/imlaei"},recitations:{auth:"app",method:"get",path:"/resources/recitations"},recitationAudioFiles:{auth:"app",method:"get",path:"/quran/recitations/{recitation_id}"},translation:{auth:"app",method:"get",path:"/quran/translations/{translation_id}"},chapterReciters:{auth:"app",method:"get",path:"/resources/chapter_reciters"},tafsir:{auth:"app",method:"get",path:"/quran/tafsirs/{tafsir_id}"},quranVersesCodeV1:{auth:"app",method:"get",path:"/quran/verses/code_v1"},quranVersesCodeV2:{auth:"app",method:"get",path:"/quran/verses/code_v2"},listSurahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_chapter/{chapter_number}"},listJuzRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_juz/{juz_number}"},listPageRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_page/{page_number}"},listRubElHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub/{rub_el_hizb_number}"},listHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_hizb/{hizb_number}"},listAyahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ayah/{ayah_key}"},recitationInfo:{auth:"app",method:"get",path:"/resources/recitations/{recitation_id}/info"},translationInfo:{auth:"app",method:"get",path:"/resources/translations/{translation_id}/info"},translations:{auth:"app",method:"get",path:"/resources/translations"},tafsirs:{auth:"app",method:"get",path:"/resources/tafsirs"},tafsirInfo:{auth:"app",method:"get",path:"/resources/tafsirs/{tafsir_id}/info"},recitationStyles:{auth:"app",method:"get",path:"/resources/recitation_styles"},languages:{auth:"app",method:"get",path:"/resources/languages"},chapterInfo:{auth:"app",method:"get",path:"/resources/chapter_infos"},verseMedia:{auth:"app",method:"get",path:"/resources/verse_media"},listManzilRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_manzil/{manzil_number}"},listRukuRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ruku/{ruku_number}"},listSurahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_chapter/{chapter_number}"},listPageTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_page/{page_number}"},listJuzTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_juz/{juz_number}"},listRubElHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_hizb/{hizb_number}"},listManzilTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_manzil/{manzil_number}"},listRukuTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ruku/{ruku_number}"},listAyahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ayah/{ayah_key}"},listSurahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_chapter/{chapter_number}"},listPageTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_page/{page_number}"},listJuzTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_juz/{juz_number}"},listRubElHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_hizb/{hizb_number}"},listManzilTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_manzil/{manzil_number}"},listRukuTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ruku/{ruku_number}"},listAyahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ayah/{ayah_key}"},getJuz:{auth:"app",method:"get",path:"/juzs/{id}"},listHizbs:{auth:"app",method:"get",path:"/hizbs"},getHizb:{auth:"app",method:"get",path:"/hizbs/{id}"},listRubElHizbs:{auth:"app",method:"get",path:"/rub_el_hizbs"},getRubElHizb:{auth:"app",method:"get",path:"/rub_el_hizbs/{id}"},listRukus:{auth:"app",method:"get",path:"/rukus"},getRuku:{auth:"app",method:"get",path:"/rukus/{id}"},listManzils:{auth:"app",method:"get",path:"/manzils"},getManzil:{auth:"app",method:"get",path:"/manzils/{id}"},getFootNote:{auth:"app",method:"get",path:"/foot_notes/{id}"},postsControllerFeed:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/feed"},postsControllerFindOne:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}"},postsControllerGetUserPost:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/user-posts/{id}"},postsControllerGetComments:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/all-comments"},chapterReciterAudioFiles:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}"},chapterReciterAudioFile:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}/{chapter_number}"},versesByRubElHizbNumberRubElHizb:{auth:"app",method:"get",path:"/verses/by_rub_el_hizb/{rub_el_hizb_number}"},listRubElHizbTranslationsRub:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbTafsirsRub:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbRecitationRubElHizb:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listAyahAnswers:{auth:"app",method:"get",path:"/answers/by_ayah/{ayah_key}"},getAnswerById:{auth:"app",method:"get",path:"/answers/{question_id}"},countAnswersWithinRange:{auth:"app",method:"get",path:"/answers/count_within_range"},resourcesSync:{auth:"app",method:"get",path:"/resources/sync"},resourcesSnapshot:{auth:"app",method:"get",path:"/resources/snapshots/{resource_group}/{id}"}},service:"content",version:"v4"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}},search:{v1:{operations:{searchControllerSearch:{auth:"app",method:"get",path:"/v1/search"}},service:"search",version:"v1"}}};var l=W,x=(o,e,t)=>({...t,operationName:t.operationName??e,service:t.service??o.service,tags:t.tags??[],version:t.version??o.version});var y=(o,e)=>{let t=`${o}:${e}`;if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof globalThis.btoa=="function")return globalThis.btoa(t);throw new Error("No base64 encoder available for HTTP basic auth.")},D=(o,e)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&e.set("Content-Type",o.contentType),o.body):(e.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},b=(o,e)=>{let t=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,s=o.idToken??o.id_token??e?.idToken,a=o.refreshToken??o.refresh_token??e?.refreshToken,p=o.tokenType??o.token_type??e?.tokenType,n=o.scope??e?.scope,i=t?Date.now()+t*1e3:e?.expiresAt;return {accessToken:r,expiresAt:i,idToken:s,refreshToken:a,scope:n,tokenType:p}};var Q={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},A=o=>{let e=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return e.length===0?"misc":e.map((t,r)=>{let s=t.toLowerCase();return r===0?s:s.charAt(0).toUpperCase()+s.slice(1)}).join("")},ce=o=>{let e=A(o);return e.charAt(0).toUpperCase()+e.slice(1)},R=o=>o.startsWith("{")&&o.endsWith("}"),J=o=>{let e=o.split("/").filter(Boolean);return e[0]?.match(/^v\d+$/)?e.slice(1):e},le=o=>{let e=J(o.path),t=e.at(-1),r=e.filter(p=>!R(p)),s=r.at(-1),a=r[0];return e.length===1?Q[o.method]:e.length===2&&t&&R(t)?o.method==="get"?"get":o.method==="delete"?"remove":"update":t&&!R(t)&&s?s===a?`${Q[o.method]}ById`:A(s):A(o.operationName)},f=(o,e)=>{let t={};for(let[r,s]of Object.entries(e.operations)){let a=x(e,r,s);t[r]=p=>o.requestOperation(a,p);}return t},B=(o,e)=>{let t={};for(let[r,s]of Object.entries(o.operations)){let a=x(o,r,s),p=J(a.path).filter(m=>!R(m)),n=A(p[0]??"misc"),i=le(a),h=t[n]??{},u=i;h[u]&&(u=`${i}${ce(r)}`),h[u]=e[r],t[n]=h;}return t};var{decamelize:U}=de__default.default,v=o=>o.startsWith("/")?o:`/${o}`,g=o=>o.endsWith("/")?o.slice(0,-1):o;var P=(o,e)=>o.replace(/\{([^}]+)\}/g,(t,r)=>{let s=e?.[r];if(s===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(s))}),C=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),Y=["wordFields","translationFields","fields"],Z=new Set([...Y,...Y.map(o=>U(o))]),me=new Set(["navigationalResultsNumber","versesResultsNumber"]),X=(o,e={})=>{if(!o)return "";let t=new URLSearchParams;for(let[r,s]of Object.entries(o)){if(s===void 0)continue;let a=e.preserveCase||me.has(r)?r:U(r);if(Z.has(r)||Z.has(a)){let p=Object.entries(s).filter(([,n])=>n).map(([n])=>U(n));p.length>0&&t.set(a,p.join(","));continue}typeof s=="string"?t.set(a,s):typeof s=="number"||typeof s=="boolean"?t.set(a,s.toString()):Array.isArray(s)&&t.set(a,s.join(","));}return t.size===0?"":`?${t.toString()}`};var d=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>114)};var G=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>30)};var z=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>240)};var N=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>60)};var H=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>604)};var L={1:7,2:286,3:200,4:176,5:120,6:165,7:206,8:75,9:129,10:109,11:123,12:111,13:43,14:52,15:99,16:128,17:111,18:110,19:98,20:135,21:112,22:78,23:118,24:64,25:77,26:227,27:93,28:88,29:69,30:60,31:34,32:30,33:73,34:54,35:45,36:83,37:182,38:88,39:75,40:85,41:54,42:53,43:89,44:59,45:37,46:35,47:38,48:29,49:18,50:45,51:60,52:49,53:62,54:55,55:78,56:96,57:29,58:22,59:24,60:13,61:14,62:11,63:11,64:18,65:12,66:12,67:30,68:52,69:52,70:44,71:28,72:28,73:20,74:56,75:40,76:31,77:50,78:40,79:46,80:42,81:29,82:19,83:36,84:25,85:22,86:17,87:19,88:26,89:30,90:20,91:15,92:21,93:11,94:8,95:8,96:19,97:5,98:8,99:8,100:11,101:11,102:8,103:3,104:9,105:5,106:4,107:7,108:3,109:6,110:3,111:5,112:4,113:5,114:6};var c=o=>{let[e,t]=o.trim().split(":");if(!e||!t||!d(e))return false;let r=Number(t),s=L[e];return !(!r||r<=0||r>s)};var fe="https://verses.quran.com";function ee(o){return o.map(e=>{let t=e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:`${fe}/${e.url.replace(/^\/+/,"")}`;return {...e,audioUrl:t}})}var w=class{constructor(e){this.fetcher=e;}async findAllChapterRecitations(e,t){let{audioFiles:r}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}`,t);return r}async findChapterRecitationById(e,t,r){if(!d(t))throw new Error("Invalid chapter id");let{audioFile:s}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}/${t}`,r);return s}async findVerseRecitationsByChapter(e,t,r){if(!d(e))throw new Error("Invalid chapter id");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_chapter/${e}`,r);return {...s,audioFiles:ee(s.audioFiles)}}async findVerseRecitationsByKey(e,t,r){if(!c(e))throw new Error("Invalid verse key");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_ayah/${e}`,r);return {...s,audioFiles:ee(s.audioFiles)}}};var k=class{constructor(e){this.fetcher=e;}async findAll(e){let{chapters:t}=await this.fetcher.fetch("/content/api/v4/chapters",e);return t}async findById(e,t){if(!d(e))throw new Error("Invalid chapter id");let{chapter:r}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}`,t);return r}async findInfoById(e,t){let{chapterInfo:r}=await this.findInfoResponseById(e,t);return r}async findInfoResponseById(e,t){if(!d(e))throw new Error("Invalid chapter id");return this.fetcher.fetch(`/content/api/v4/chapters/${e}/info`,t)}};var q=async(o,e={retries:3})=>{let t;for(let r=0;r<=e.retries;r++)try{return await o()}catch(s){if(t=s,r===e.retries)throw t;await new Promise(a=>setTimeout(a,Math.pow(2,r)*1e3));}throw t};var te="https://apis.quran.foundation",S={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},re={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},F={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},se={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:ve}=de__default.default,oe={content:"content",search:"search"},ye="/quran-reflect/v1/posts/",be=["/comments","/all-comments"],Re=["auth","content","quranReflect","search"],ae="User session expired. Sign in again.",Ae="invalid_grant",Pe=6e4,Ce=async o=>{try{return await o.text()}catch{return ""}},we=(o,e)=>o.status<400||o.status>=500||o.status===429?false:e.toLowerCase().includes(Ae),ke=(o,e)=>{let t=e.trim(),r=t?`: ${t}`:"";return `Token refresh failed: ${o.status} ${o.statusText}${r}`},_=class{constructor(e,t){this.mode=e;this.config=t;this.userSession=t.userSession;}appTokens=new Map;userSession;userSessionRefreshPromise=null;getFetch(){let e=this.config.fetch??globalThis.fetch;if(typeof e!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return e}clearCachedTokens(){this.appTokens.clear();}async getUserSession(){let e=await this.config.storage?.getSession?.();return e!==void 0?e:this.userSession??null}async setUserSession(e){if(!this.config.storage){this.userSession=e;return}if(!e){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(e),this.userSession=e;}buildServiceUrl(e,t,r){let s=this.isCrossServiceGatewayPath(e,t),{baseUrl:a,usesGateway:p}=this.resolveServiceBaseUrl(e,s),n=this.normalizeServicePath(e,t,p,s);return `${a}${n}${X(r,{preserveCase:e==="auth"||e==="quranReflect"})}`}async requestOperation(e,t){return this.request(e.service,P(e.path,t?.path),t?.query,{...t,auth:t?.auth==="auto"||!t?.auth?e.auth:t.auth,method:t?.method??e.method.toUpperCase(),path:void 0})}async request(e,t,r,s={}){let a=this.resolveAuthMode(e,s.auth);if(this.mode==="public"&&a==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");let p=this.buildServiceUrl(e,t,r),n=await this.getRequestUserSession(a,s),i=await this.performRequest(e,p,s,a,n?.accessToken);if(this.shouldRetryUserRequest(i,a,s,n)){let m=await this.refreshStoredUserSession();i=await this.performRequest(e,p,s,a,m.accessToken);}if(!i.ok)throw new Error(`${i.status} ${i.statusText}`);if(i.status===204)return;if(!(i.headers.get("content-type")??"").includes("application/json"))return await i.text();let u=await i.json();return ve(u)}async fetch(e,t){let r=this.resolveLegacyRoute(e);return this.request(r.service,r.path,{...this.config.defaults,...t})}async performRequest(e,t,r,s,a){let p=new Headers(r.headers),n=D(r,p);return e!=="oauth2"&&p.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(e,s,p,{...r,accessToken:a??r.accessToken},t),this.getFetch()(t,{body:n,headers:p,method:r.method??"GET"})}resolveLegacyRoute(e){let t=v(C(e));if(t.startsWith("/content/api/v4")||t.startsWith("/api/v4"))return {path:t,service:"content"};if(t==="/v1/search"||t.startsWith("/search/v1"))return {path:t,service:"search"};if(t.startsWith("/auth/v1"))return {path:t,service:"auth"};if(t.startsWith("/quran-reflect/v1"))return {path:t,service:"quranReflect"};if(t.startsWith("/oauth2")||t.startsWith("/userinfo"))return {path:t,service:"oauth2"};throw new Error(`Unsupported SDK route: ${e}`)}resolveAuthMode(e,t="auto"){return t!=="auto"?t:e==="content"||e==="search"?"app":e==="auth"||e==="quranReflect"?"user":"none"}async getRequestUserSession(e,t){if(e!=="user"||t.accessToken||this.mode!=="server")return null;let r=await this.getUserSession();if(!r?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");return this.shouldRefreshUserSession(r)?this.refreshStoredUserSession(r):r}shouldRefreshUserSession(e){return !e.refreshToken||!e.expiresAt?false:e.expiresAt<=Date.now()+Pe}shouldRetryUserRequest(e,t,r,s){return e.status!==401||t!=="user"||r.accessToken||this.mode!=="server"?false:!!s?.refreshToken}async applyAuthenticationHeaders(e,t,r,s,a){if(s.basicAuth&&r.set("Authorization",`Basic ${y(s.basicAuth.username,s.basicAuth.password)}`),s.accessToken){this.setTokenHeaders(e,r,s.accessToken);return}if(t==="none")return;if(t==="app"){let n=await this.getAppAccessToken(e,a);this.setTokenHeaders(e,r,n);return}let p=await this.getUserSession();if(!p?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(e,r,p.accessToken);}async refreshStoredUserSession(e){if(this.userSessionRefreshPromise)return this.userSessionRefreshPromise;let t=this.executeUserSessionRefresh(e);this.userSessionRefreshPromise=t;try{return await t}finally{this.userSessionRefreshPromise===t&&(this.userSessionRefreshPromise=null);}}async executeUserSessionRefresh(e){if(this.mode!=="server"||!("clientSecret"in this.config))throw new Error("Automatic session refresh requires @quranjs/api/server or a backend.");let t=this.config.clientSecret,r=e??await this.getUserSession();if(!r?.refreshToken)throw new Error(ae);let s=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??S.oauth2)}/oauth2/token`,a=new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken}),p=await q(()=>this.getFetch()(s,{body:a,headers:{Accept:"application/json",Authorization:`Basic ${y(this.config.clientId,t)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!p.ok){let h=await Ce(p);throw we(p,h)?(await this.setUserSession(null),new Error(ae)):new Error(ke(p,h))}let n=await p.json(),i=b(n,r);return await this.setUserSession(i),i}setTokenHeaders(e,t,r){if(e==="oauth2"){t.set("Authorization",`Bearer ${r}`);return}t.set("x-auth-token",r);}async getAppAccessToken(e,t){if(this.mode!=="server")throw new Error("App-authenticated APIs require @quranjs/api/server or a backend.");let r=this.resolveAppScope(e,t);if(!r)throw new Error(`No client-credentials scope is configured for ${e}.`);let s=`${e}:${r}`,a=this.appTokens.get(s);if(a&&a.expiresAt>Date.now()+3e4)return a.value;if(!("clientSecret"in this.config))throw new Error("client_secret is server-only. Use @quranjs/api/server.");let p=this.config.clientSecret,n=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??S.oauth2)}/oauth2/token`,i=new URLSearchParams({grant_type:"client_credentials",scope:r}),h=await q(()=>this.getFetch()(n,{body:i,headers:{Accept:"application/json",Authorization:`Basic ${y(this.config.clientId,p)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!h.ok)throw new Error(`Token request failed: ${h.status} ${h.statusText}`);let u=await h.json(),m={expiresAt:Date.now()+u.expires_in*1e3,value:u.access_token};return this.appTokens.set(s,m),m.value}resolveAppScope(e,t){if(e!=="content"||!t)return oe[e];let r=new URL(t).pathname;return r.startsWith(ye)?be.some(s=>r.endsWith(s))?"comment.read":"post.read":oe.content}resolveServiceBaseUrl(e,t=false){let{services:r}=this.config;if(t)return {baseUrl:g(r?.gatewayUrl??te),usesGateway:true};let s=e==="content"?r?.contentBaseUrl:e==="search"?r?.searchBaseUrl:e==="auth"?r?.authBaseUrl:e==="quranReflect"?r?.quranReflectBaseUrl:r?.oauth2BaseUrl??r?.tokenHost;return s?{baseUrl:g(s),usesGateway:false}:r?.gatewayUrl&&e!=="oauth2"?{baseUrl:g(r.gatewayUrl),usesGateway:true}:{baseUrl:S[e],usesGateway:false}}normalizeServicePath(e,t,r,s=false){let a=v(C(t));if(e==="oauth2"||s)return a;let p=a;for(let i of se[e])if(p.startsWith(i)){p=v(p.slice(i.length));break}let n=r?F[e]:re[e];return p.startsWith(n)?p:`${n}${p}`}isCrossServiceGatewayPath(e,t){let r=v(C(t)),s=Re.find(a=>this.pathMatchesPrefix(r,F[a]));return !!(s&&s!==e)}pathMatchesPrefix(e,t){return t.length>0&&(e===t||e.startsWith(`${t}/`))}};var I=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}`,t)}async findHadithsByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}/hadiths`,t)}async countWithinRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");return this.fetcher.fetch("/content/api/v4/hadith_references/count_within_range",{...r,from:e,to:t})}};var T=class{constructor(e){this.fetcher=e;}async findAll(){let{juzs:e}=await this.fetcher.fetch("/content/api/v4/juzs");return e}};var E=class{constructor(e){this.fetcher=e;}async findAllRecitations(e){let{recitations:t}=await this.fetcher.fetch("/content/api/v4/resources/recitations",e);return t}async findAllTranslations(e){let{translations:t}=await this.fetcher.fetch("/content/api/v4/resources/translations",e);return t}async findAllTafsirs(e){let{tafsirs:t}=await this.fetcher.fetch("/content/api/v4/resources/tafsirs",e);return t}async findAllLanguages(e){let{languages:t}=await this.fetcher.fetch("/content/api/v4/resources/languages",e);return t}async findRecitationInfo(e,t){let{recitationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/recitations/${e}/info`,t);return r}async findTranslationInfo(e,t){let{translationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/translations/${e}/info`,t);return r}async findTafsirInfo(e,t){let{tafsirInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/tafsirs/${e}/info`,t);return r}async findAllChapterInfos(e){let{chapterInfos:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_infos",e);return t}async findAllChapterReciters(e){let{reciters:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_reciters",e);return t}async findAllRecitationStyles(e){let{recitationStyles:t}=await this.fetcher.fetch("/content/api/v4/resources/recitation_styles",e);return t}async findVerseMedia(e){let{verseMedia:t}=await this.fetcher.fetch("/content/api/v4/resources/verse_media",e);return t}};var V=class{constructor(e){this.fetcher=e;}async search(e,t){return this.fetcher.fetch("/v1/search",{query:e,size:30,...t})}};var O=class{constructor(e){this.fetcher=e;}async findByKey(e,t){if(!c(e))throw new Error("Invalid verse key");let{verse:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_key/${e}`,{words:false,...t});return r}async findByRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");let{verses:s}=await this.fetcher.fetch("/content/api/v4/verses/by_range",{words:false,...r,from:e,to:t});return s}async findByChapter(e,t){if(!d(e))throw new Error("Invalid chapter id");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_chapter/${e}`,{words:false,...t});return r}async findByPage(e,t){if(!H(e))throw new Error("Invalid page number");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_page/${e}`,{words:false,...t});return r}async findByJuz(e,t){if(!G(e))throw new Error("Invalid juz");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_juz/${e}`,{words:false,...t});return r}async findByHizb(e,t){if(!N(e))throw new Error("Invalid hizb");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_hizb/${e}`,{words:false,...t});return r}async findByRub(e,t){if(!z(e))throw new Error("Invalid rub");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_rub/${e}`,{words:false,...t});return r}async findRandom(e){let{verse:t}=await this.fetcher.fetch("/content/api/v4/verses/random",{words:false,...e});return t}};var Se="auth.bookmarks.get(bookmarkId) is not supported because /v1/bookmarks/bookmark expects bookmark detail query parameters. Pass a query object such as { mushafId, key, type, verseNumber } or { mushafId, isReading: true }.",_e=(o,e)=>(t,r,s)=>o.request(e,P(r,s?.path),s?.query,{...s,auth:"user",method:t,path:void 0,query:void 0}),Ie=o=>{let e=f(o,l.auth.v1),t=B(l.auth.v1,e),r=_e(o,"auth");return {...t,collections:{...t.collections,addBookmark:(s,a)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:a,path:{collectionId:s}}),create:s=>r("POST","/v1/collections",{body:s}),get:(s,a)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:s},query:a}),list:s=>r("GET","/v1/collections",{query:s}),listAll:s=>r("GET","/v1/collections/all",{query:s}),remove:s=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:s}}),removeBookmark:(s,a)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:a,collectionId:s}}),update:(s,a)=>r("POST","/v1/collections/{collectionId}",{body:a,path:{collectionId:s}})},bookmarks:{...t.bookmarks,create:s=>r("POST","/v1/bookmarks",{body:s}),get:async s=>{if(typeof s=="string")throw new Error(Se);return r("GET","/v1/bookmarks/bookmark",{query:s})},list:s=>r("GET","/v1/bookmarks",{query:s}),listCollections:s=>r("GET","/v1/bookmarks/collections",{query:s}),listRange:s=>r("GET","/v1/bookmarks/ayahs-range",{query:s}),remove:s=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:s}})},goals:{...t.goals,create:s=>r("POST","/v1/goals",{body:s}),estimate:s=>r("GET","/v1/goals/estimate",{query:s}),getTodaysPlan:s=>r("GET","/v1/goals/get-todays-plan",{query:s}),remove:s=>r("DELETE","/v1/goals/{id}",{path:{id:s}}),update:(s,a)=>r("PUT","/v1/goals/{id}",{body:a,path:{id:s}})},notes:{...t.notes,create:s=>r("POST","/v1/notes",{body:s}),get:s=>r("GET","/v1/notes/{noteId}",{path:{noteId:s}}),list:s=>r("GET","/v1/notes",{query:s}),listByAttachedEntity:s=>r("GET","/v1/notes/by-attached-entity",{query:s}),listByRange:s=>r("GET","/v1/notes/by-range",{query:s}),listByVerseKey:(s,a)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:s},query:a}),publish:(s,a)=>r("POST","/v1/notes/{noteId}/publish",{body:a,path:{noteId:s}}),remove:s=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:s}}),update:(s,a)=>r("PATCH","/v1/notes/{noteId}",{body:a,path:{noteId:s}})},preferences:{...t.preferences,bulkUpdate:s=>r("POST","/v1/preferences/bulk",{body:s}),get:s=>r("GET","/v1/preferences",{query:s}),update:s=>r("POST","/v1/preferences",{body:s})},raw:e,readingSessions:{...t.readingSessions,create:s=>r("POST","/v1/reading-sessions",{body:s}),list:s=>r("GET","/v1/reading-sessions",{query:s})}}},Te=o=>{let e=f(o,l.quranReflect.v1),t=B(l.quranReflect.v1,e);return {comments:t.comments??{},posts:t.posts??{},raw:e,rooms:t.rooms??{},tags:t.tags??{},users:t.users??{}}},Ee=(o,e,t)=>{let r=f(o,l.oauth2.v1),s=async(a,p={})=>{if(p.requiresRefreshToken&&!a.get("refresh_token"))throw new Error("Missing refresh token.");let n=a.get("refresh_token")??void 0,i=p.requiresRefreshToken?await o.getUserSession():null,h=p.requiresRefreshToken&&n?{...i??{},refreshToken:n}:i,u=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",basicAuth:"clientSecret"in t?{password:t.clientSecret,username:t.clientId}:void 0,body:a,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(b(u,h)),u};return {authorizeUrl:a=>o.buildServiceUrl("oauth2","/oauth2/auth",a),exchangeCode:a=>{let p=new URLSearchParams({code:a.code,grant_type:"authorization_code",redirect_uri:a.redirectUri});return a.codeVerifier&&p.set("code_verifier",a.codeVerifier),a.scope&&p.set("scope",a.scope),s(p,{})},getUserInfo:a=>o.request("oauth2","/userinfo",void 0,{accessToken:a,auth:"user",method:"GET"}),introspect:a=>{if(!("clientSecret"in t))throw new Error("Token introspection requires @quranjs/api/server or a backend.");return o.request("oauth2","/oauth2/introspect",void 0,{auth:"none",basicAuth:{password:t.clientSecret,username:t.clientId},body:new URLSearchParams({token:a}),contentType:"application/x-www-form-urlencoded",method:"POST"})},logout:a=>o.request("oauth2","/oauth2/sessions/logout",a,{auth:"none",method:"GET"}),raw:r,refresh:async a=>{let p=await o.getUserSession(),n=new URLSearchParams({grant_type:"refresh_token",refresh_token:a??p?.refreshToken??""});return s(n,{requiresRefreshToken:true})}}},Ve=(o,e,t,r,s,a,p)=>({audio:{chapterRecitation:{get:(n,i,h)=>r.findChapterRecitationById(n,i,h),list:(n,i)=>r.findAllChapterRecitations(n,i)},verseRecitation:{byChapter:(n,i,h)=>r.findVerseRecitationsByChapter(n,i,h),byKey:(n,i,h)=>r.findVerseRecitationsByKey(n,i,h)}},chapters:{get:(n,i)=>o.findById(n,i),getInfo:(n,i)=>o.findInfoById(n,i),getInfoResponse:(n,i)=>o.findInfoResponseById(n,i),list:n=>o.findAll(n)},hadithReferences:{byAyah:(n,i)=>s.findByAyah(n,i),countWithinRange:(n,i,h)=>s.countWithinRange(n,i,h),hadithsByAyah:(n,i)=>s.findHadithsByAyah(n,i)},juzs:{list:()=>t.findAll()},raw:p,resources:{chapterInfos:{list:n=>a.findAllChapterInfos(n)},chapterReciters:{list:n=>a.findAllChapterReciters(n)},languages:{list:n=>a.findAllLanguages(n)},recitationStyles:{list:n=>a.findAllRecitationStyles(n)},recitations:{getInfo:(n,i)=>a.findRecitationInfo(n,i),list:n=>a.findAllRecitations(n)},tafsirs:{getInfo:(n,i)=>a.findTafsirInfo(n,i),list:n=>a.findAllTafsirs(n)},translations:{getInfo:(n,i)=>a.findTranslationInfo(n,i),list:n=>a.findAllTranslations(n)},verseMedia:{list:n=>a.findVerseMedia(n)}},verses:{byChapter:(n,i)=>e.findByChapter(n,i),byHizb:(n,i)=>e.findByHizb(n,i),byJuz:(n,i)=>e.findByJuz(n,i),byKey:(n,i)=>e.findByKey(n,i),byPage:(n,i)=>e.findByPage(n,i),byRange:(n,i,h)=>e.findByRange(n,i,h),byRub:(n,i)=>e.findByRub(n,i),random:n=>e.findRandom(n)}}),ne=(o,e)=>{let t=new _(o,e);t.getFetch();let r=new k(t),s=new O(t),a=new T(t),p=new w(t),n=new I(t),i=new E(t),h=new V(t),u={auth:{v1:f(t,l.auth.v1)},content:{v4:f(t,l.content.v4)},oauth2:{v1:f(t,l.oauth2.v1)},quranReflect:{v1:f(t,l.quranReflect.v1)},search:{v1:f(t,l.search.v1)}},m=Ve(r,s,a,p,n,i,u.content.v4),M=Ie(t),K=Te(t),$=Ee(t,o,e),j=({query:pe,...he})=>h.search(pe,he),ie=Object.assign(h,{query:j,raw:u.search.v1,v1:{query:j,raw:u.search.v1}});return {audio:p,auth:{...M,v1:M},chapters:r,clearCachedTokens:()=>t.clearCachedTokens(),content:{...m,v4:m},getUserSession:()=>t.getUserSession(),hadithReferences:n,juzs:a,oauth2:{...$,v1:$},quranReflect:{...K,v1:K},raw:u,resources:i,search:ie,verses:s}};var vr=o=>ne("server",{...o,defaults:{language:"ar",...o.defaults}});
2
- exports.createServerClient=vr;//# sourceMappingURL=server.min.js.map
1
+ 'use strict';var ye=require('humps');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ye__default=/*#__PURE__*/_interopDefault(ye);var D={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},content:{v4:{operations:{audioReciterTimestamp:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/timestamp"},audioReciterLookup:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/lookup"},listChapters:{auth:"app",method:"get",path:"/chapters"},getChapter:{auth:"app",method:"get",path:"/chapters/{id}"},getChapterInfo:{auth:"app",method:"get",path:"/chapters/{id}/info"},hadithReferencesByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}"},hadithsByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}/hadiths"},hadithCountWithinRange:{auth:"app",method:"get",path:"/hadith_references/count_within_range"},listPages:{auth:"app",method:"get",path:"/pages"},getPagesLookup:{auth:"app",method:"get",path:"/pages/lookup"},getPagesPageNumber:{auth:"app",method:"get",path:"/pages/{page_number}"},versesByChapterNumber:{auth:"app",method:"get",path:"/verses/by_chapter/{chapter_number}"},versesByPageNumber:{auth:"app",method:"get",path:"/verses/by_page/{page_number}"},versesByJuzNumber:{auth:"app",method:"get",path:"/verses/by_juz/{juz_number}"},versesByHizbNumber:{auth:"app",method:"get",path:"/verses/by_hizb/{hizb_number}"},versesByRubElHizbNumber:{auth:"app",method:"get",path:"/verses/by_rub/{rub_el_hizb_number}"},versesByManzilNumber:{auth:"app",method:"get",path:"/verses/by_manzil/{manzil_number}"},versesByRukuNumber:{auth:"app",method:"get",path:"/verses/by_ruku/{ruku_number}"},versesByRange:{auth:"app",method:"get",path:"/verses/by_range"},versesByVerseKey:{auth:"app",method:"get",path:"/verses/by_key/{verse_key}"},randomVerse:{auth:"app",method:"get",path:"/verses/random"},listJuzs:{auth:"app",method:"get",path:"/juzs"},quranVersesByScript:{auth:"app",method:"get",path:"/quran/verses/{script}"},quranVersesIndopak:{auth:"app",method:"get",path:"/quran/verses/indopak"},quranVersesIndopakNastaleeq:{auth:"app",method:"get",path:"/quran/verses/indopak_nastaleeq"},quranVersesUthmaniTajweed:{auth:"app",method:"get",path:"/quran/verses/uthmani_tajweed"},quranVersesUthmani:{auth:"app",method:"get",path:"/quran/verses/uthmani"},quranVersesUthmaniSimple:{auth:"app",method:"get",path:"/quran/verses/uthmani_simple"},quranVersesImlaei:{auth:"app",method:"get",path:"/quran/verses/imlaei"},recitations:{auth:"app",method:"get",path:"/resources/recitations"},recitationAudioFiles:{auth:"app",method:"get",path:"/quran/recitations/{recitation_id}"},translation:{auth:"app",method:"get",path:"/quran/translations/{translation_id}"},chapterReciters:{auth:"app",method:"get",path:"/resources/chapter_reciters"},tafsir:{auth:"app",method:"get",path:"/quran/tafsirs/{tafsir_id}"},quranVersesCodeV1:{auth:"app",method:"get",path:"/quran/verses/code_v1"},quranVersesCodeV2:{auth:"app",method:"get",path:"/quran/verses/code_v2"},listSurahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_chapter/{chapter_number}"},listJuzRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_juz/{juz_number}"},listPageRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_page/{page_number}"},listRubElHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub/{rub_el_hizb_number}"},listHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_hizb/{hizb_number}"},listAyahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ayah/{ayah_key}"},recitationInfo:{auth:"app",method:"get",path:"/resources/recitations/{recitation_id}/info"},translationInfo:{auth:"app",method:"get",path:"/resources/translations/{translation_id}/info"},translations:{auth:"app",method:"get",path:"/resources/translations"},tafsirs:{auth:"app",method:"get",path:"/resources/tafsirs"},tafsirInfo:{auth:"app",method:"get",path:"/resources/tafsirs/{tafsir_id}/info"},recitationStyles:{auth:"app",method:"get",path:"/resources/recitation_styles"},languages:{auth:"app",method:"get",path:"/resources/languages"},chapterInfo:{auth:"app",method:"get",path:"/resources/chapter_infos"},verseMedia:{auth:"app",method:"get",path:"/resources/verse_media"},listManzilRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_manzil/{manzil_number}"},listRukuRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ruku/{ruku_number}"},listSurahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_chapter/{chapter_number}"},listPageTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_page/{page_number}"},listJuzTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_juz/{juz_number}"},listRubElHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_hizb/{hizb_number}"},listManzilTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_manzil/{manzil_number}"},listRukuTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ruku/{ruku_number}"},listAyahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ayah/{ayah_key}"},listSurahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_chapter/{chapter_number}"},listPageTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_page/{page_number}"},listJuzTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_juz/{juz_number}"},listRubElHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_hizb/{hizb_number}"},listManzilTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_manzil/{manzil_number}"},listRukuTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ruku/{ruku_number}"},listAyahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ayah/{ayah_key}"},getJuz:{auth:"app",method:"get",path:"/juzs/{id}"},listHizbs:{auth:"app",method:"get",path:"/hizbs"},getHizb:{auth:"app",method:"get",path:"/hizbs/{id}"},listRubElHizbs:{auth:"app",method:"get",path:"/rub_el_hizbs"},getRubElHizb:{auth:"app",method:"get",path:"/rub_el_hizbs/{id}"},listRukus:{auth:"app",method:"get",path:"/rukus"},getRuku:{auth:"app",method:"get",path:"/rukus/{id}"},listManzils:{auth:"app",method:"get",path:"/manzils"},getManzil:{auth:"app",method:"get",path:"/manzils/{id}"},getFootNote:{auth:"app",method:"get",path:"/foot_notes/{id}"},postsControllerFeed:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/feed"},postsControllerFindOne:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}"},postsControllerGetUserPost:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/user-posts/{id}"},postsControllerGetComments:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/all-comments"},chapterReciterAudioFiles:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}"},chapterReciterAudioFile:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}/{chapter_number}"},versesByRubElHizbNumberRubElHizb:{auth:"app",method:"get",path:"/verses/by_rub_el_hizb/{rub_el_hizb_number}"},listRubElHizbTranslationsRub:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbTafsirsRub:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbRecitationRubElHizb:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listAyahAnswers:{auth:"app",method:"get",path:"/answers/by_ayah/{ayah_key}"},getAnswerById:{auth:"app",method:"get",path:"/answers/{question_id}"},countAnswersWithinRange:{auth:"app",method:"get",path:"/answers/count_within_range"},resourcesSync:{auth:"app",method:"get",path:"/resources/sync"},resourcesSnapshot:{auth:"app",method:"get",path:"/resources/snapshots/{resource_group}/{id}"}},service:"content",version:"v4"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerEdit:{auth:"user",method:"patch",path:"/v1/comments/{id}"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}},search:{v1:{operations:{searchControllerSearch:{auth:"app",method:"get",path:"/v1/search"}},service:"search",version:"v1"}}};var d=D,G=(o,e,t)=>({...t,operationName:t.operationName??e,service:t.service??o.service,tags:t.tags??[],version:t.version??o.version});var R=(o,e)=>{let t=`${o}:${e}`;if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof globalThis.btoa=="function")return globalThis.btoa(t);throw new Error("No base64 encoder available for HTTP basic auth.")},J=(o,e)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&e.set("Content-Type",o.contentType),o.body):(e.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},v=(o,e)=>{let t=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,s=o.idToken??o.id_token??e?.idToken,n=o.refreshToken??o.refresh_token??e?.refreshToken,i=o.tokenType??o.token_type??e?.tokenType,h=o.scope??e?.scope,a=t?Date.now()+t*1e3:e?.expiresAt;return {accessToken:r,expiresAt:a,idToken:s,refreshToken:n,scope:h,tokenType:i}};var Y={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},P=o=>{let e=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return e.length===0?"misc":e.map((t,r)=>{let s=t.toLowerCase();return r===0?s:s.charAt(0).toUpperCase()+s.slice(1)}).join("")},fe=o=>{let e=P(o);return e.charAt(0).toUpperCase()+e.slice(1)},b=o=>o.startsWith("{")&&o.endsWith("}"),Z=o=>{let e=o.split("/").filter(Boolean);return e[0]?.match(/^v\d+$/)?e.slice(1):e},ge=o=>{let e=Z(o.path),t=e.at(-1),r=e.filter(i=>!b(i)),s=r.at(-1),n=r[0];return e.length===1?Y[o.method]:e.length===2&&t&&b(t)?o.method==="get"?"get":o.method==="delete"?"remove":"update":t&&!b(t)&&s?s===n?`${Y[o.method]}ById`:P(s):P(o.operationName)},f=(o,e)=>{let t={};for(let[r,s]of Object.entries(e.operations)){let n=G(e,r,s);t[r]=i=>o.requestOperation(n,i);}return t},x=(o,e)=>{let t={};for(let[r,s]of Object.entries(o.operations)){let n=G(o,r,s),i=Z(n.path).filter(l=>!b(l)),h=P(i[0]??"misc"),a=ge(n),p=t[h]??{},u=a;p[u]&&(u=`${a}${fe(r)}`),p[u]=e[r],t[h]=p;}return t};var{decamelize:U}=ye__default.default,y=o=>o.startsWith("/")?o:`/${o}`,g=o=>o.endsWith("/")?o.slice(0,-1):o;var A=(o,e)=>o.replace(/\{([^}]+)\}/g,(t,r)=>{let s=e?.[r];if(s===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(s))}),C=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),X=["wordFields","translationFields","fields"],L=new Set([...X,...X.map(o=>U(o))]),Re=new Set(["navigationalResultsNumber","pageSize","versesResultsNumber"]),ee=(o,e={})=>{if(!o)return "";let t=new URLSearchParams;for(let[r,s]of Object.entries(o)){if(s===void 0)continue;let n=e.preserveCase||Re.has(r)?r:U(r);if(L.has(r)||L.has(n)){let i=Object.entries(s).filter(([,h])=>h).map(([h])=>U(h));i.length>0&&t.set(n,i.join(","));continue}typeof s=="string"?t.set(n,s):typeof s=="number"||typeof s=="boolean"?t.set(n,s.toString()):Array.isArray(s)&&t.set(n,s.join(","));}return t.size===0?"":`?${t.toString()}`};var ve=o=>!!o&&typeof o=="object"&&!Array.isArray(o),be=o=>ve(o)?typeof o.body=="string"&&typeof o.draft=="boolean"&&Array.isArray(o.references)&&Array.isArray(o.mentions):false,te=(o,e)=>({...o,create:n=>be(n)?e("POST","/v1/posts",{body:{post:n}}):e("POST","/v1/posts",n),get:(n,i)=>typeof n=="string"||typeof n=="number"?e("GET","/v1/posts/{id}",{path:{id:n},query:i}):e("GET","/v1/posts/{id}",n),update:(n,i)=>i!==void 0?e("PATCH","/v1/posts/{id}",{body:i,path:{id:n}}):e("PATCH","/v1/posts/{id}",n)});var m=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>114)};var z=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>30)};var N=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>240)};var q=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>60)};var H=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>604)};var re={1:7,2:286,3:200,4:176,5:120,6:165,7:206,8:75,9:129,10:109,11:123,12:111,13:43,14:52,15:99,16:128,17:111,18:110,19:98,20:135,21:112,22:78,23:118,24:64,25:77,26:227,27:93,28:88,29:69,30:60,31:34,32:30,33:73,34:54,35:45,36:83,37:182,38:88,39:75,40:85,41:54,42:53,43:89,44:59,45:37,46:35,47:38,48:29,49:18,50:45,51:60,52:49,53:62,54:55,55:78,56:96,57:29,58:22,59:24,60:13,61:14,62:11,63:11,64:18,65:12,66:12,67:30,68:52,69:52,70:44,71:28,72:28,73:20,74:56,75:40,76:31,77:50,78:40,79:46,80:42,81:29,82:19,83:36,84:25,85:22,86:17,87:19,88:26,89:30,90:20,91:15,92:21,93:11,94:8,95:8,96:19,97:5,98:8,99:8,100:11,101:11,102:8,103:3,104:9,105:5,106:4,107:7,108:3,109:6,110:3,111:5,112:4,113:5,114:6};var c=o=>{let[e,t]=o.trim().split(":");if(!e||!t||!m(e))return false;let r=Number(t),s=re[e];return !(!r||r<=0||r>s)};var Pe=o=>Object.fromEntries(Object.entries(o).map(([e,t])=>t.types?[e,{...t,types:Object.fromEntries(Object.entries(t.types).map(([r,s])=>[r.toUpperCase(),s]))}]:[e,t])),w=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/answers/by_ayah/${e}`,t)}async findByQuestionId(e){return this.fetcher.fetch(`/content/api/v4/answers/${e}`)}async countWithinRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");let s=await this.fetcher.fetch("/content/api/v4/answers/count_within_range",{...r,from:e,to:t});return Pe(s)}};var Ae="https://verses.quran.com";function se(o){return o.map(e=>{let t=e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:`${Ae}/${e.url.replace(/^\/+/,"")}`;return {...e,audioUrl:t}})}var S=class{constructor(e){this.fetcher=e;}async findAllChapterRecitations(e,t){let{audioFiles:r}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}`,t);return r}async findChapterRecitationById(e,t,r){if(!m(t))throw new Error("Invalid chapter id");let{audioFile:s}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}/${t}`,r);return s}async findVerseRecitationsByChapter(e,t,r){if(!m(e))throw new Error("Invalid chapter id");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_chapter/${e}`,r);return {...s,audioFiles:se(s.audioFiles)}}async findVerseRecitationsByKey(e,t,r){if(!c(e))throw new Error("Invalid verse key");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_ayah/${e}`,r);return {...s,audioFiles:se(s.audioFiles)}}};var k=class{constructor(e){this.fetcher=e;}async findAll(e){let{chapters:t}=await this.fetcher.fetch("/content/api/v4/chapters",e);return t}async findById(e,t){if(!m(e))throw new Error("Invalid chapter id");let{chapter:r}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}`,t);return r}async findInfoById(e,t){let{chapterInfo:r}=await this.findInfoResponseById(e,t);return r}async findInfoResponseById(e,t){if(!m(e))throw new Error("Invalid chapter id");return this.fetcher.fetch(`/content/api/v4/chapters/${e}/info`,t)}};var F=async(o,e={retries:3})=>{let t;for(let r=0;r<=e.retries;r++)try{return await o()}catch(s){if(t=s,r===e.retries)throw t;await new Promise(n=>setTimeout(n,Math.pow(2,r)*1e3));}throw t};var oe="https://apis.quran.foundation",_={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},ae={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},Q={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},ne={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:we}=ye__default.default,ie={content:"content",search:"search"},Se="/quran-reflect/v1/posts/",ke=["/comments","/all-comments"],_e=["auth","content","quranReflect","search"],pe="User session expired. Sign in again.",Te="invalid_grant",Ie=6e4,Ee=async o=>{try{return await o.text()}catch{return ""}},Oe=(o,e)=>o.status<400||o.status>=500||o.status===429?false:e.toLowerCase().includes(Te),Ve=(o,e)=>{let t=e.trim(),r=t?`: ${t}`:"";return `Token refresh failed: ${o.status} ${o.statusText}${r}`},T=class{constructor(e,t){this.mode=e;this.config=t;this.userSession=t.userSession;}appTokens=new Map;userSession;userSessionRefreshPromise=null;getFetch(){let e=this.config.fetch??globalThis.fetch;if(typeof e!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return e}clearCachedTokens(){this.appTokens.clear();}async getUserSession(){let e=await this.config.storage?.getSession?.();return e!==void 0?e:this.userSession??null}async setUserSession(e){if(!this.config.storage){this.userSession=e;return}if(!e){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(e),this.userSession=e;}buildServiceUrl(e,t,r){let s=this.isCrossServiceGatewayPath(e,t),{baseUrl:n,usesGateway:i}=this.resolveServiceBaseUrl(e,s),h=this.normalizeServicePath(e,t,i,s);return `${n}${h}${ee(r,{preserveCase:e==="auth"||e==="quranReflect"})}`}async requestOperation(e,t){return this.request(e.service,A(e.path,t?.path),t?.query,{...t,auth:t?.auth==="auto"||!t?.auth?e.auth:t.auth,method:t?.method??e.method.toUpperCase(),path:void 0})}async request(e,t,r,s={}){let n=this.resolveAuthMode(e,s.auth);if(this.mode==="public"&&n==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");let i=this.buildServiceUrl(e,t,r),h=await this.getRequestUserSession(n,s),a=await this.performRequest(e,i,s,n,h?.accessToken);if(this.shouldRetryUserRequest(a,n,s,h)){let l=await this.refreshStoredUserSession();a=await this.performRequest(e,i,s,n,l.accessToken);}if(!a.ok)throw new Error(`${a.status} ${a.statusText}`);if(a.status===204)return;if(!(a.headers.get("content-type")??"").includes("application/json"))return await a.text();let u=await a.json();return we(u)}async fetch(e,t){let r=this.resolveLegacyRoute(e);return this.request(r.service,r.path,{...this.config.defaults,...t})}async performRequest(e,t,r,s,n){let i=new Headers(r.headers),h=J(r,i);return e!=="oauth2"&&i.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(e,s,i,{...r,accessToken:n??r.accessToken},t),this.getFetch()(t,{body:h,headers:i,method:r.method??"GET"})}resolveLegacyRoute(e){let t=y(C(e));if(t.startsWith("/content/api/v4")||t.startsWith("/api/v4"))return {path:t,service:"content"};if(t==="/v1/search"||t.startsWith("/search/v1"))return {path:t,service:"search"};if(t.startsWith("/auth/v1"))return {path:t,service:"auth"};if(t.startsWith("/quran-reflect/v1"))return {path:t,service:"quranReflect"};if(t.startsWith("/oauth2")||t.startsWith("/userinfo"))return {path:t,service:"oauth2"};throw new Error(`Unsupported SDK route: ${e}`)}resolveAuthMode(e,t="auto"){return t!=="auto"?t:e==="content"||e==="search"?"app":e==="auth"||e==="quranReflect"?"user":"none"}async getRequestUserSession(e,t){if(e!=="user"||t.accessToken||this.mode!=="server")return null;let r=await this.getUserSession();if(!r?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");return this.shouldRefreshUserSession(r)?this.refreshStoredUserSession(r):r}shouldRefreshUserSession(e){return !e.refreshToken||!e.expiresAt?false:e.expiresAt<=Date.now()+Ie}shouldRetryUserRequest(e,t,r,s){return e.status!==401||t!=="user"||r.accessToken||this.mode!=="server"?false:!!s?.refreshToken}async applyAuthenticationHeaders(e,t,r,s,n){if(s.basicAuth&&r.set("Authorization",`Basic ${R(s.basicAuth.username,s.basicAuth.password)}`),s.accessToken){this.setTokenHeaders(e,r,s.accessToken);return}if(t==="none")return;if(t==="app"){let h=await this.getAppAccessToken(e,n);this.setTokenHeaders(e,r,h);return}let i=await this.getUserSession();if(!i?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(e,r,i.accessToken);}async refreshStoredUserSession(e){if(this.userSessionRefreshPromise)return this.userSessionRefreshPromise;let t=this.executeUserSessionRefresh(e);this.userSessionRefreshPromise=t;try{return await t}finally{this.userSessionRefreshPromise===t&&(this.userSessionRefreshPromise=null);}}async executeUserSessionRefresh(e){if(this.mode!=="server"||!("clientSecret"in this.config))throw new Error("Automatic session refresh requires @quranjs/api/server or a backend.");let t=this.config.clientSecret,r=e??await this.getUserSession();if(!r?.refreshToken)throw new Error(pe);let s=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,n=new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken}),i=await F(()=>this.getFetch()(s,{body:n,headers:{Accept:"application/json",Authorization:`Basic ${R(this.config.clientId,t)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!i.ok){let p=await Ee(i);throw Oe(i,p)?(await this.setUserSession(null),new Error(pe)):new Error(Ve(i,p))}let h=await i.json(),a=v(h,r);return await this.setUserSession(a),a}setTokenHeaders(e,t,r){if(e==="oauth2"){t.set("Authorization",`Bearer ${r}`);return}t.set("x-auth-token",r);}async getAppAccessToken(e,t){if(this.mode!=="server")throw new Error("App-authenticated APIs require @quranjs/api/server or a backend.");let r=this.resolveAppScope(e,t);if(!r)throw new Error(`No client-credentials scope is configured for ${e}.`);let s=`${e}:${r}`,n=this.appTokens.get(s);if(n&&n.expiresAt>Date.now()+3e4)return n.value;if(!("clientSecret"in this.config))throw new Error("client_secret is server-only. Use @quranjs/api/server.");let i=this.config.clientSecret,h=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,a=new URLSearchParams({grant_type:"client_credentials",scope:r}),p=await F(()=>this.getFetch()(h,{body:a,headers:{Accept:"application/json",Authorization:`Basic ${R(this.config.clientId,i)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!p.ok)throw new Error(`Token request failed: ${p.status} ${p.statusText}`);let u=await p.json(),l={expiresAt:Date.now()+u.expires_in*1e3,value:u.access_token};return this.appTokens.set(s,l),l.value}resolveAppScope(e,t){if(e!=="content"||!t)return ie[e];let r=new URL(t).pathname;return r.startsWith(Se)?ke.some(s=>r.endsWith(s))?"comment.read":"post.read":ie.content}resolveServiceBaseUrl(e,t=false){let{services:r}=this.config;if(t)return {baseUrl:g(r?.gatewayUrl??oe),usesGateway:true};let s=e==="content"?r?.contentBaseUrl:e==="search"?r?.searchBaseUrl:e==="auth"?r?.authBaseUrl:e==="quranReflect"?r?.quranReflectBaseUrl:r?.oauth2BaseUrl??r?.tokenHost;return s?{baseUrl:g(s),usesGateway:false}:r?.gatewayUrl&&e!=="oauth2"?{baseUrl:g(r.gatewayUrl),usesGateway:true}:{baseUrl:_[e],usesGateway:false}}normalizeServicePath(e,t,r,s=false){let n=y(C(t));if(e==="oauth2"||s)return n;let i=n;for(let a of ne[e])if(i.startsWith(a)){i=y(i.slice(a.length));break}let h=r?Q[e]:ae[e];return i.startsWith(h)?i:`${h}${i}`}isCrossServiceGatewayPath(e,t){let r=y(C(t)),s=_e.find(n=>this.pathMatchesPrefix(r,Q[n]));return !!(s&&s!==e)}pathMatchesPrefix(e,t){return t.length>0&&(e===t||e.startsWith(`${t}/`))}};var I=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}`,t)}async findHadithsByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}/hadiths`,t)}async countWithinRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");return this.fetcher.fetch("/content/api/v4/hadith_references/count_within_range",{...r,from:e,to:t})}};var E=class{constructor(e){this.fetcher=e;}async findAll(){let{juzs:e}=await this.fetcher.fetch("/content/api/v4/juzs");return e}};var O=class{constructor(e){this.fetcher=e;}async findAllRecitations(e){let{recitations:t}=await this.fetcher.fetch("/content/api/v4/resources/recitations",e);return t}async findAllTranslations(e){let{translations:t}=await this.fetcher.fetch("/content/api/v4/resources/translations",e);return t}async findAllTafsirs(e){let{tafsirs:t}=await this.fetcher.fetch("/content/api/v4/resources/tafsirs",e);return t}async findAllLanguages(e){let{languages:t}=await this.fetcher.fetch("/content/api/v4/resources/languages",e);return t}async findRecitationInfo(e,t){let{recitationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/recitations/${e}/info`,t);return r}async findTranslationInfo(e,t){let{translationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/translations/${e}/info`,t);return r}async findTafsirInfo(e,t){let{tafsirInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/tafsirs/${e}/info`,t);return r}async findAllChapterInfos(e){let{chapterInfos:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_infos",e);return t}async findAllChapterReciters(e){let{reciters:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_reciters",e);return t}async findAllRecitationStyles(e){let{recitationStyles:t}=await this.fetcher.fetch("/content/api/v4/resources/recitation_styles",e);return t}async findVerseMedia(e){let{verseMedia:t}=await this.fetcher.fetch("/content/api/v4/resources/verse_media",e);return t}async sync(e){return this.fetcher.fetch("/content/api/v4/resources/sync",e)}async findSnapshot(e,t,r){return this.fetcher.fetch(`/content/api/v4/resources/snapshots/${e}/${t}`,r)}};var V=class{constructor(e){this.fetcher=e;}async search(e,t){return this.fetcher.fetch("/v1/search",{query:e,size:30,...t})}};var B=class{constructor(e){this.fetcher=e;}async findByKey(e,t){if(!c(e))throw new Error("Invalid verse key");let{verse:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_key/${e}`,{words:false,...t});return r}async findByRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");let{verses:s}=await this.fetcher.fetch("/content/api/v4/verses/by_range",{words:false,...r,from:e,to:t});return s}async findByChapter(e,t){if(!m(e))throw new Error("Invalid chapter id");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_chapter/${e}`,{words:false,...t});return r}async findByPage(e,t){if(!H(e))throw new Error("Invalid page number");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_page/${e}`,{words:false,...t});return r}async findByJuz(e,t){if(!z(e))throw new Error("Invalid juz");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_juz/${e}`,{words:false,...t});return r}async findByHizb(e,t){if(!q(e))throw new Error("Invalid hizb");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_hizb/${e}`,{words:false,...t});return r}async findByRub(e,t){if(!N(e))throw new Error("Invalid rub");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_rub/${e}`,{words:false,...t});return r}async findRandom(e){let{verse:t}=await this.fetcher.fetch("/content/api/v4/verses/random",{words:false,...e});return t}};var Be="auth.bookmarks.get(bookmarkId) is not supported because /v1/bookmarks/bookmark expects bookmark detail query parameters. Pass a query object such as { mushafId, key, type, verseNumber } or { mushafId, isReading: true }.",he=(o,e)=>(t,r,s)=>o.request(e,A(r,s?.path),s?.query,{...s,auth:"user",method:t,path:void 0,query:void 0}),Ge=o=>{let e=f(o,d.auth.v1),t=x(d.auth.v1,e),r=he(o,"auth");return {...t,collections:{...t.collections,addBookmark:(s,n)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:s}}),create:s=>r("POST","/v1/collections",{body:s}),get:(s,n)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:s},query:n}),list:s=>r("GET","/v1/collections",{query:s}),listAll:s=>r("GET","/v1/collections/all",{query:s}),remove:s=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:s}}),removeBookmark:(s,n)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:s}}),update:(s,n)=>r("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:s}})},bookmarks:{...t.bookmarks,create:s=>r("POST","/v1/bookmarks",{body:s}),get:async s=>{if(typeof s=="string")throw new Error(Be);return r("GET","/v1/bookmarks/bookmark",{query:s})},list:s=>r("GET","/v1/bookmarks",{query:s}),listCollections:s=>r("GET","/v1/bookmarks/collections",{query:s}),listRange:s=>r("GET","/v1/bookmarks/ayahs-range",{query:s}),remove:s=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:s}})},goals:{...t.goals,create:s=>r("POST","/v1/goals",{body:s}),estimate:s=>r("GET","/v1/goals/estimate",{query:s}),getTodaysPlan:s=>r("GET","/v1/goals/get-todays-plan",{query:s}),remove:s=>r("DELETE","/v1/goals/{id}",{path:{id:s}}),update:(s,n)=>r("PUT","/v1/goals/{id}",{body:n,path:{id:s}})},notes:{...t.notes,create:s=>r("POST","/v1/notes",{body:s}),get:s=>r("GET","/v1/notes/{noteId}",{path:{noteId:s}}),list:s=>r("GET","/v1/notes",{query:s}),listByAttachedEntity:s=>r("GET","/v1/notes/by-attached-entity",{query:s}),listByRange:s=>r("GET","/v1/notes/by-range",{query:s}),listByVerseKey:(s,n)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:s},query:n}),publish:(s,n)=>r("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:s}}),remove:s=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:s}}),update:(s,n)=>r("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:s}})},preferences:{...t.preferences,bulkUpdate:s=>r("POST","/v1/preferences/bulk",{body:s}),get:s=>r("GET","/v1/preferences",{query:s}),update:s=>r("POST","/v1/preferences",{body:s})},raw:e,readingSessions:{...t.readingSessions,create:s=>r("POST","/v1/reading-sessions",{body:s}),list:s=>r("GET","/v1/reading-sessions",{query:s})}}},xe=o=>{let e=f(o,d.quranReflect.v1),t=x(d.quranReflect.v1,e);return {comments:t.comments??{},posts:te(t.posts??{},he(o,"quranReflect")),raw:e,rooms:t.rooms??{},tags:t.tags??{},users:t.users??{}}},Ue=(o,e,t)=>{let r=f(o,d.oauth2.v1),s=async(n,i={})=>{if(i.requiresRefreshToken&&!n.get("refresh_token"))throw new Error("Missing refresh token.");let h=n.get("refresh_token")??void 0,a=i.requiresRefreshToken?await o.getUserSession():null,p=i.requiresRefreshToken&&h?{...a??{},refreshToken:h}:a,u=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",basicAuth:"clientSecret"in t?{password:t.clientSecret,username:t.clientId}:void 0,body:n,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(v(u,p)),u};return {authorizeUrl:n=>o.buildServiceUrl("oauth2","/oauth2/auth",n),exchangeCode:n=>{let i=new URLSearchParams({code:n.code,grant_type:"authorization_code",redirect_uri:n.redirectUri});return n.codeVerifier&&i.set("code_verifier",n.codeVerifier),n.scope&&i.set("scope",n.scope),s(i,{})},getUserInfo:n=>o.request("oauth2","/userinfo",void 0,{accessToken:n,auth:"user",method:"GET"}),introspect:n=>{if(!("clientSecret"in t))throw new Error("Token introspection requires @quranjs/api/server or a backend.");return o.request("oauth2","/oauth2/introspect",void 0,{auth:"none",basicAuth:{password:t.clientSecret,username:t.clientId},body:new URLSearchParams({token:n}),contentType:"application/x-www-form-urlencoded",method:"POST"})},logout:n=>o.request("oauth2","/oauth2/sessions/logout",n,{auth:"none",method:"GET"}),raw:r,refresh:async n=>{let i=await o.getUserSession(),h=new URLSearchParams({grant_type:"refresh_token",refresh_token:n??i?.refreshToken??""});return s(h,{requiresRefreshToken:true})}}},ze=(o,e,t,r,s,n,i,h)=>({answers:{byAyah:(a,p)=>o.findByAyah(a,p),countWithinRange:(a,p,u)=>o.countWithinRange(a,p,u),get:a=>o.findByQuestionId(a)},audio:{chapterRecitation:{get:(a,p,u)=>s.findChapterRecitationById(a,p,u),list:(a,p)=>s.findAllChapterRecitations(a,p)},verseRecitation:{byChapter:(a,p,u)=>s.findVerseRecitationsByChapter(a,p,u),byKey:(a,p,u)=>s.findVerseRecitationsByKey(a,p,u)}},chapters:{get:(a,p)=>e.findById(a,p),getInfo:(a,p)=>e.findInfoById(a,p),getInfoResponse:(a,p)=>e.findInfoResponseById(a,p),list:a=>e.findAll(a)},hadithReferences:{byAyah:(a,p)=>n.findByAyah(a,p),countWithinRange:(a,p,u)=>n.countWithinRange(a,p,u),hadithsByAyah:(a,p)=>n.findHadithsByAyah(a,p)},juzs:{list:()=>r.findAll()},raw:h,resources:{findSnapshot:(a,p,u)=>i.findSnapshot(a,p,u),chapterInfos:{list:a=>i.findAllChapterInfos(a)},chapterReciters:{list:a=>i.findAllChapterReciters(a)},languages:{list:a=>i.findAllLanguages(a)},recitationStyles:{list:a=>i.findAllRecitationStyles(a)},recitations:{getInfo:(a,p)=>i.findRecitationInfo(a,p),list:a=>i.findAllRecitations(a)},tafsirs:{getInfo:(a,p)=>i.findTafsirInfo(a,p),list:a=>i.findAllTafsirs(a)},translations:{getInfo:(a,p)=>i.findTranslationInfo(a,p),list:a=>i.findAllTranslations(a)},verseMedia:{list:a=>i.findVerseMedia(a)},sync:a=>i.sync(a)},verses:{byChapter:(a,p)=>t.findByChapter(a,p),byHizb:(a,p)=>t.findByHizb(a,p),byJuz:(a,p)=>t.findByJuz(a,p),byKey:(a,p)=>t.findByKey(a,p),byPage:(a,p)=>t.findByPage(a,p),byRange:(a,p,u)=>t.findByRange(a,p,u),byRub:(a,p)=>t.findByRub(a,p),random:a=>t.findRandom(a)}}),ue=(o,e)=>{let t=new T(o,e);t.getFetch();let r=new w(t),s=new k(t),n=new B(t),i=new E(t),h=new S(t),a=new I(t),p=new O(t),u=new V(t),l={auth:{v1:f(t,d.auth.v1)},content:{v4:f(t,d.content.v4)},oauth2:{v1:f(t,d.oauth2.v1)},quranReflect:{v1:f(t,d.quranReflect.v1)},search:{v1:f(t,d.search.v1)}},M=ze(r,s,n,i,h,a,p,l.content.v4),K=Ge(t),$=xe(t),j=Ue(t,o,e),W=({query:le,...de})=>u.search(le,de),ce=Object.assign(u,{query:W,raw:l.search.v1,v1:{query:W,raw:l.search.v1}});return {answers:r,audio:h,auth:{...K,v1:K},chapters:s,clearCachedTokens:()=>t.clearCachedTokens(),content:{...M,v4:M},getUserSession:()=>t.getUserSession(),hadithReferences:a,juzs:i,oauth2:{...j,v1:j},quranReflect:{...$,v1:$},raw:l,resources:p,search:ce,verses:n}};var Er=o=>ue("server",{...o,defaults:{language:"ar",...o.defaults}});
2
+ exports.createServerClient=Er;//# sourceMappingURL=server.min.js.map
3
3
  //# sourceMappingURL=server.min.js.map