@quranjs/api 2.2.0 → 3.1.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.
@@ -0,0 +1,337 @@
1
+ import { c as QuranAudio, Q as QuranChapters, C as ChapterId, f as ChapterRecitation, N as NormalizedVerseRecitation, q as Pagination, V as VerseKey, h as Chapter, i as ChapterInfo, p as Juz, y as ChapterInfoResource, B as ChapterReciterResource, L as LanguageResource, x as RecitationStylesResource, s as RecitationInfoResource, r as RecitationResource, w as TafsirInfoResource, v as TafsirResource, u as TranslationInfoResource, t as TranslationResource, z as VerseMediaResource, n as Verse, H as HizbNumber, J as JuzNumber, P as PageNumber, R as RubNumber, b as QuranJuzs, d as QuranResources, e as QuranSearch, S as SearchResponse, a as QuranVerses } from './verses-DnPcyHIi.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';
4
+
5
+ declare const createServerClient: (config: ServerClientConfig) => {
6
+ audio: QuranAudio;
7
+ auth: {
8
+ v1: {
9
+ collections: {
10
+ addBookmark: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
11
+ create: (body: Record<string, unknown>) => Promise<unknown>;
12
+ get: (collectionId: string, query?: ApiParams) => Promise<unknown>;
13
+ list: (query?: ApiParams) => Promise<unknown>;
14
+ listAll: (query?: ApiParams) => Promise<unknown>;
15
+ remove: (collectionId: string) => Promise<unknown>;
16
+ removeBookmark: (collectionId: string, bookmarkId: string) => Promise<unknown>;
17
+ update: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
18
+ };
19
+ bookmarks: {
20
+ create: (body: Record<string, unknown>) => Promise<unknown>;
21
+ get: (query?: ApiParams | string) => Promise<unknown>;
22
+ list: (query?: ApiParams) => Promise<unknown>;
23
+ listCollections: (query?: ApiParams) => Promise<unknown>;
24
+ listRange: (query?: ApiParams) => Promise<unknown>;
25
+ remove: (bookmarkId: string) => Promise<unknown>;
26
+ };
27
+ goals: {
28
+ create: (body: Record<string, unknown>) => Promise<unknown>;
29
+ estimate: (query?: ApiParams) => Promise<unknown>;
30
+ getTodaysPlan: (query?: ApiParams) => Promise<unknown>;
31
+ remove: (id: string) => Promise<unknown>;
32
+ update: (id: string, body: Record<string, unknown>) => Promise<unknown>;
33
+ };
34
+ notes: {
35
+ create: (body: Record<string, unknown>) => Promise<unknown>;
36
+ get: (noteId: string) => Promise<unknown>;
37
+ list: (query?: ApiParams) => Promise<unknown>;
38
+ listByAttachedEntity: (query?: ApiParams) => Promise<unknown>;
39
+ listByRange: (query?: ApiParams) => Promise<unknown>;
40
+ listByVerseKey: (verseKey: string, query?: ApiParams) => Promise<unknown>;
41
+ publish: (noteId: string, body?: Record<string, unknown>) => Promise<unknown>;
42
+ remove: (noteId: string) => Promise<unknown>;
43
+ update: (noteId: string, body: Record<string, unknown>) => Promise<unknown>;
44
+ };
45
+ preferences: {
46
+ bulkUpdate: (body: Record<string, unknown>) => Promise<unknown>;
47
+ get: (query?: ApiParams) => Promise<unknown>;
48
+ update: (body: Record<string, unknown>) => Promise<unknown>;
49
+ };
50
+ raw: Record<string, RawOperation>;
51
+ readingSessions: {
52
+ create: (body: Record<string, unknown>) => Promise<unknown>;
53
+ list: (query?: ApiParams) => Promise<unknown>;
54
+ };
55
+ };
56
+ collections: {
57
+ addBookmark: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
58
+ create: (body: Record<string, unknown>) => Promise<unknown>;
59
+ get: (collectionId: string, query?: ApiParams) => Promise<unknown>;
60
+ list: (query?: ApiParams) => Promise<unknown>;
61
+ listAll: (query?: ApiParams) => Promise<unknown>;
62
+ remove: (collectionId: string) => Promise<unknown>;
63
+ removeBookmark: (collectionId: string, bookmarkId: string) => Promise<unknown>;
64
+ update: (collectionId: string, body: Record<string, unknown>) => Promise<unknown>;
65
+ };
66
+ bookmarks: {
67
+ create: (body: Record<string, unknown>) => Promise<unknown>;
68
+ get: (query?: ApiParams | string) => Promise<unknown>;
69
+ list: (query?: ApiParams) => Promise<unknown>;
70
+ listCollections: (query?: ApiParams) => Promise<unknown>;
71
+ listRange: (query?: ApiParams) => Promise<unknown>;
72
+ remove: (bookmarkId: string) => Promise<unknown>;
73
+ };
74
+ goals: {
75
+ create: (body: Record<string, unknown>) => Promise<unknown>;
76
+ estimate: (query?: ApiParams) => Promise<unknown>;
77
+ getTodaysPlan: (query?: ApiParams) => Promise<unknown>;
78
+ remove: (id: string) => Promise<unknown>;
79
+ update: (id: string, body: Record<string, unknown>) => Promise<unknown>;
80
+ };
81
+ notes: {
82
+ create: (body: Record<string, unknown>) => Promise<unknown>;
83
+ get: (noteId: string) => Promise<unknown>;
84
+ list: (query?: ApiParams) => Promise<unknown>;
85
+ listByAttachedEntity: (query?: ApiParams) => Promise<unknown>;
86
+ listByRange: (query?: ApiParams) => Promise<unknown>;
87
+ listByVerseKey: (verseKey: string, query?: ApiParams) => Promise<unknown>;
88
+ publish: (noteId: string, body?: Record<string, unknown>) => Promise<unknown>;
89
+ remove: (noteId: string) => Promise<unknown>;
90
+ update: (noteId: string, body: Record<string, unknown>) => Promise<unknown>;
91
+ };
92
+ preferences: {
93
+ bulkUpdate: (body: Record<string, unknown>) => Promise<unknown>;
94
+ get: (query?: ApiParams) => Promise<unknown>;
95
+ update: (body: Record<string, unknown>) => Promise<unknown>;
96
+ };
97
+ raw: Record<string, RawOperation>;
98
+ readingSessions: {
99
+ create: (body: Record<string, unknown>) => Promise<unknown>;
100
+ list: (query?: ApiParams) => Promise<unknown>;
101
+ };
102
+ };
103
+ chapters: QuranChapters;
104
+ clearCachedTokens: () => void;
105
+ content: {
106
+ v4: {
107
+ audio: {
108
+ chapterRecitation: {
109
+ get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
110
+ list: (reciterId: string, query?: ApiParams) => Promise<ChapterRecitation[]>;
111
+ };
112
+ verseRecitation: {
113
+ byChapter: (chapterId: ChapterId, recitationId: string, query?: ApiParams) => Promise<{
114
+ audioFiles: NormalizedVerseRecitation[];
115
+ pagination: Pagination;
116
+ }>;
117
+ byKey: (verseKey: VerseKey, recitationId: string, query?: ApiParams) => Promise<{
118
+ audioFiles: NormalizedVerseRecitation[];
119
+ pagination: Pagination;
120
+ }>;
121
+ };
122
+ };
123
+ chapters: {
124
+ get: (id: ChapterId, query?: ApiParams) => Promise<Chapter>;
125
+ getInfo: (id: ChapterId, query?: ApiParams) => Promise<ChapterInfo>;
126
+ list: (query?: ApiParams) => Promise<Chapter[]>;
127
+ };
128
+ juzs: {
129
+ list: () => Promise<Juz[]>;
130
+ };
131
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
132
+ resources: {
133
+ chapterInfos: {
134
+ list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
135
+ };
136
+ chapterReciters: {
137
+ list: (query?: ApiParams) => Promise<ChapterReciterResource[]>;
138
+ };
139
+ languages: {
140
+ list: (query?: ApiParams) => Promise<LanguageResource[]>;
141
+ };
142
+ recitationStyles: {
143
+ list: (query?: ApiParams) => Promise<RecitationStylesResource>;
144
+ };
145
+ recitations: {
146
+ getInfo: (id: string, query?: ApiParams) => Promise<RecitationInfoResource>;
147
+ list: (query?: ApiParams) => Promise<RecitationResource[]>;
148
+ };
149
+ tafsirs: {
150
+ getInfo: (id: string, query?: ApiParams) => Promise<TafsirInfoResource>;
151
+ list: (query?: ApiParams) => Promise<TafsirResource[]>;
152
+ };
153
+ translations: {
154
+ getInfo: (id: string, query?: ApiParams) => Promise<TranslationInfoResource>;
155
+ list: (query?: ApiParams) => Promise<TranslationResource[]>;
156
+ };
157
+ verseMedia: {
158
+ list: (query?: ApiParams) => Promise<VerseMediaResource>;
159
+ };
160
+ };
161
+ verses: {
162
+ byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
163
+ byHizb: (id: HizbNumber, query?: ApiParams) => Promise<Verse[]>;
164
+ byJuz: (id: JuzNumber, query?: ApiParams) => Promise<Verse[]>;
165
+ byKey: (key: VerseKey, query?: ApiParams) => Promise<Verse>;
166
+ byPage: (page: PageNumber, query?: ApiParams) => Promise<Verse[]>;
167
+ byRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<Verse[]>;
168
+ byRub: (id: RubNumber, query?: ApiParams) => Promise<Verse[]>;
169
+ random: (query?: ApiParams) => Promise<Verse>;
170
+ };
171
+ };
172
+ audio: {
173
+ chapterRecitation: {
174
+ get: (reciterId: string, chapterId: ChapterId, query?: ApiParams) => Promise<ChapterRecitation>;
175
+ list: (reciterId: string, query?: ApiParams) => Promise<ChapterRecitation[]>;
176
+ };
177
+ verseRecitation: {
178
+ byChapter: (chapterId: ChapterId, recitationId: string, query?: ApiParams) => Promise<{
179
+ audioFiles: NormalizedVerseRecitation[];
180
+ pagination: Pagination;
181
+ }>;
182
+ byKey: (verseKey: VerseKey, recitationId: string, query?: ApiParams) => Promise<{
183
+ audioFiles: NormalizedVerseRecitation[];
184
+ pagination: Pagination;
185
+ }>;
186
+ };
187
+ };
188
+ chapters: {
189
+ get: (id: ChapterId, query?: ApiParams) => Promise<Chapter>;
190
+ getInfo: (id: ChapterId, query?: ApiParams) => Promise<ChapterInfo>;
191
+ list: (query?: ApiParams) => Promise<Chapter[]>;
192
+ };
193
+ juzs: {
194
+ list: () => Promise<Juz[]>;
195
+ };
196
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
197
+ resources: {
198
+ chapterInfos: {
199
+ list: (query?: ApiParams) => Promise<ChapterInfoResource[]>;
200
+ };
201
+ chapterReciters: {
202
+ list: (query?: ApiParams) => Promise<ChapterReciterResource[]>;
203
+ };
204
+ languages: {
205
+ list: (query?: ApiParams) => Promise<LanguageResource[]>;
206
+ };
207
+ recitationStyles: {
208
+ list: (query?: ApiParams) => Promise<RecitationStylesResource>;
209
+ };
210
+ recitations: {
211
+ getInfo: (id: string, query?: ApiParams) => Promise<RecitationInfoResource>;
212
+ list: (query?: ApiParams) => Promise<RecitationResource[]>;
213
+ };
214
+ tafsirs: {
215
+ getInfo: (id: string, query?: ApiParams) => Promise<TafsirInfoResource>;
216
+ list: (query?: ApiParams) => Promise<TafsirResource[]>;
217
+ };
218
+ translations: {
219
+ getInfo: (id: string, query?: ApiParams) => Promise<TranslationInfoResource>;
220
+ list: (query?: ApiParams) => Promise<TranslationResource[]>;
221
+ };
222
+ verseMedia: {
223
+ list: (query?: ApiParams) => Promise<VerseMediaResource>;
224
+ };
225
+ };
226
+ verses: {
227
+ byChapter: (id: ChapterId, query?: ApiParams) => Promise<Verse[]>;
228
+ byHizb: (id: HizbNumber, query?: ApiParams) => Promise<Verse[]>;
229
+ byJuz: (id: JuzNumber, query?: ApiParams) => Promise<Verse[]>;
230
+ byKey: (key: VerseKey, query?: ApiParams) => Promise<Verse>;
231
+ byPage: (page: PageNumber, query?: ApiParams) => Promise<Verse[]>;
232
+ byRange: (from: VerseKey, to: VerseKey, query?: ApiParams) => Promise<Verse[]>;
233
+ byRub: (id: RubNumber, query?: ApiParams) => Promise<Verse[]>;
234
+ random: (query?: ApiParams) => Promise<Verse>;
235
+ };
236
+ };
237
+ getUserSession: () => Promise<UserSession | null>;
238
+ juzs: QuranJuzs;
239
+ oauth2: {
240
+ v1: {
241
+ authorizeUrl: (query: Record<string, string | number | undefined>) => string;
242
+ exchangeCode: (params: {
243
+ code: string;
244
+ codeVerifier?: string;
245
+ redirectUri: string;
246
+ scope?: string;
247
+ }) => Promise<TokenResponse>;
248
+ getUserInfo: (accessToken?: string) => Promise<unknown>;
249
+ introspect: (token: string) => Promise<unknown>;
250
+ logout: (query?: ApiParams) => Promise<unknown>;
251
+ raw: Record<string, RawOperation>;
252
+ refresh: (refreshToken?: string) => Promise<TokenResponse>;
253
+ };
254
+ authorizeUrl: (query: Record<string, string | number | undefined>) => string;
255
+ exchangeCode: (params: {
256
+ code: string;
257
+ codeVerifier?: string;
258
+ redirectUri: string;
259
+ scope?: string;
260
+ }) => Promise<TokenResponse>;
261
+ getUserInfo: (accessToken?: string) => Promise<unknown>;
262
+ introspect: (token: string) => Promise<unknown>;
263
+ logout: (query?: ApiParams) => Promise<unknown>;
264
+ raw: Record<string, RawOperation>;
265
+ refresh: (refreshToken?: string) => Promise<TokenResponse>;
266
+ };
267
+ quranReflect: {
268
+ v1: {
269
+ comments: {
270
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
271
+ };
272
+ posts: {
273
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
274
+ };
275
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
276
+ rooms: {
277
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
278
+ };
279
+ tags: {
280
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
281
+ };
282
+ users: {
283
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
284
+ };
285
+ };
286
+ comments: {
287
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
288
+ };
289
+ posts: {
290
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
291
+ };
292
+ raw: Record<string, (request?: OperationRequest) => Promise<unknown>>;
293
+ rooms: {
294
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
295
+ };
296
+ tags: {
297
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
298
+ };
299
+ users: {
300
+ [x: string]: (request?: OperationRequest) => Promise<unknown>;
301
+ };
302
+ };
303
+ raw: {
304
+ auth: {
305
+ v1: Record<string, RawOperation>;
306
+ };
307
+ content: {
308
+ v4: Record<string, RawOperation>;
309
+ };
310
+ oauth2: {
311
+ v1: Record<string, RawOperation>;
312
+ };
313
+ quranReflect: {
314
+ v1: Record<string, RawOperation>;
315
+ };
316
+ search: {
317
+ v1: Record<string, RawOperation>;
318
+ };
319
+ };
320
+ resources: QuranResources;
321
+ search: QuranSearch & {
322
+ query: ({ query: searchQuery, ...options }: {
323
+ query: string;
324
+ } & Omit<SearchParams, "query">) => Promise<SearchResponse>;
325
+ raw: Record<string, RawOperation>;
326
+ v1: {
327
+ query: ({ query: searchQuery, ...options }: {
328
+ query: string;
329
+ } & Omit<SearchParams, "query">) => Promise<SearchResponse>;
330
+ raw: Record<string, RawOperation>;
331
+ };
332
+ };
333
+ verses: QuranVerses;
334
+ };
335
+ type ServerClient = ReturnType<typeof createServerClient>;
336
+
337
+ export { type ServerClient, createServerClient };
@@ -0,0 +1,3 @@
1
+ 'use strict';var ce=require('humps');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ce__default=/*#__PURE__*/_interopDefault(ce);var j={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"},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"}},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 c=j,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.")},K=(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,s=o.accessToken??o.access_token,r=o.idToken??o.id_token??e?.idToken,n=o.refreshToken??o.refresh_token??e?.refreshToken,a=o.tokenType??o.token_type??e?.tokenType,i=o.scope??e?.scope,p=t?Date.now()+t*1e3:e?.expiresAt;return {accessToken:s,expiresAt:p,idToken:r,refreshToken:n,scope:i,tokenType:a}};var D={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,s)=>{let r=t.toLowerCase();return s===0?r:r.charAt(0).toUpperCase()+r.slice(1)}).join("")},he=o=>{let e=A(o);return e.charAt(0).toUpperCase()+e.slice(1)},R=o=>o.startsWith("{")&&o.endsWith("}"),W=o=>{let e=o.split("/").filter(Boolean);return e[0]?.match(/^v\d+$/)?e.slice(1):e},ue=o=>{let e=W(o.path),t=e.at(-1),s=e.filter(a=>!R(a)),r=s.at(-1),n=s[0];return e.length===1?D[o.method]:e.length===2&&t&&R(t)?o.method==="get"?"get":o.method==="delete"?"remove":"update":t&&!R(t)&&r?r===n?`${D[o.method]}ById`:A(r):A(o.operationName)},m=(o,e)=>{let t={};for(let[s,r]of Object.entries(e.operations)){let n=x(e,s,r);t[s]=a=>o.requestOperation(n,a);}return t},O=(o,e)=>{let t={};for(let[s,r]of Object.entries(o.operations)){let n=x(o,s,r),a=W(n.path).filter(d=>!R(d)),i=A(a[0]??"misc"),p=ue(n),h=t[i]??{},u=p;h[u]&&(u=`${p}${he(s)}`),h[u]=e[s],t[i]=h;}return t};var{decamelize:U}=ce__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,s)=>{let r=e?.[s];if(r===void 0)throw new Error(`Missing path parameter: ${s}`);return encodeURIComponent(String(r))}),C=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),J=["wordFields","translationFields","fields"],Q=new Set([...J,...J.map(o=>U(o))]),le=new Set(["navigationalResultsNumber","versesResultsNumber"]),Y=(o,e={})=>{if(!o)return "";let t=new URLSearchParams;for(let[s,r]of Object.entries(o)){if(r===void 0)continue;let n=e.preserveCase||le.has(s)?s:U(s);if(Q.has(s)||Q.has(n)){let a=Object.entries(r).filter(([,i])=>i).map(([i])=>U(i));a.length>0&&t.set(n,a.join(","));continue}typeof r=="string"?t.set(n,r):typeof r=="number"||typeof r=="boolean"?t.set(n,r.toString()):Array.isArray(r)&&t.set(n,r.join(","));}return t.size===0?"":`?${t.toString()}`};var l=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 B=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>60)};var N=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>604)};var Z={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 f=o=>{let[e,t]=o.trim().split(":");if(!e||!t||!l(e))return false;let s=Number(t),r=Z[e];return !(!s||s<=0||s>r)};var de="https://verses.quran.com";function X(o){return o.map(e=>{let t=e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:`${de}/${e.url.replace(/^\/+/,"")}`;return {...e,audioUrl:t}})}var k=class{constructor(e){this.fetcher=e;}async findAllChapterRecitations(e,t){let{audioFiles:s}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}`,t);return s}async findChapterRecitationById(e,t,s){if(!l(t))throw new Error("Invalid chapter id");let{audioFile:r}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}/${t}`,s);return r}async findVerseRecitationsByChapter(e,t,s){if(!l(e))throw new Error("Invalid chapter id");let r=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_chapter/${e}`,s);return {...r,audioFiles:X(r.audioFiles)}}async findVerseRecitationsByKey(e,t,s){if(!f(e))throw new Error("Invalid verse key");let r=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_ayah/${e}`,s);return {...r,audioFiles:X(r.audioFiles)}}};var w=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(!l(e))throw new Error("Invalid chapter id");let{chapter:s}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}`,t);return s}async findInfoById(e,t){if(!l(e))throw new Error("Invalid chapter id");let{chapterInfo:s}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}/info`,t);return s}};var q=async(o,e={retries:3})=>{let t;for(let s=0;s<=e.retries;s++)try{return await o()}catch(r){if(t=r,s===e.retries)throw t;await new Promise(n=>setTimeout(n,Math.pow(2,s)*1e3));}throw t};var L="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"},ee={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"},te={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:fe}=ce__default.default,re={content:"content",search:"search"},ge="/quran-reflect/v1/posts/",ve=["/comments","/all-comments"],ye=["auth","content","quranReflect","search"],se="User session expired. Sign in again.",be="invalid_grant",Re=6e4,Ae=async o=>{try{return await o.text()}catch{return ""}},Pe=(o,e)=>o.status<400||o.status>=500||o.status===429?false:e.toLowerCase().includes(be),Ce=(o,e)=>{let t=e.trim(),s=t?`: ${t}`:"";return `Token refresh failed: ${o.status} ${o.statusText}${s}`},_=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,s){let r=this.isCrossServiceGatewayPath(e,t),{baseUrl:n,usesGateway:a}=this.resolveServiceBaseUrl(e,r),i=this.normalizeServicePath(e,t,a,r);return `${n}${i}${Y(s,{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,s,r={}){let n=this.resolveAuthMode(e,r.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 a=this.buildServiceUrl(e,t,s),i=await this.getRequestUserSession(n,r),p=await this.performRequest(e,a,r,n,i?.accessToken);if(this.shouldRetryUserRequest(p,n,r,i)){let d=await this.refreshStoredUserSession();p=await this.performRequest(e,a,r,n,d.accessToken);}if(!p.ok)throw new Error(`${p.status} ${p.statusText}`);if(p.status===204)return;if(!(p.headers.get("content-type")??"").includes("application/json"))return await p.text();let u=await p.json();return fe(u)}async fetch(e,t){let s=this.resolveLegacyRoute(e);return this.request(s.service,s.path,{...this.config.defaults,...t})}async performRequest(e,t,s,r,n){let a=new Headers(s.headers),i=K(s,a);return e!=="oauth2"&&a.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(e,r,a,{...s,accessToken:n??s.accessToken},t),this.getFetch()(t,{body:i,headers:a,method:s.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 s=await this.getUserSession();if(!s?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");return this.shouldRefreshUserSession(s)?this.refreshStoredUserSession(s):s}shouldRefreshUserSession(e){return !e.refreshToken||!e.expiresAt?false:e.expiresAt<=Date.now()+Re}shouldRetryUserRequest(e,t,s,r){return e.status!==401||t!=="user"||s.accessToken||this.mode!=="server"?false:!!r?.refreshToken}async applyAuthenticationHeaders(e,t,s,r,n){if(r.basicAuth&&s.set("Authorization",`Basic ${y(r.basicAuth.username,r.basicAuth.password)}`),r.accessToken){this.setTokenHeaders(e,s,r.accessToken);return}if(t==="none")return;if(t==="app"){let i=await this.getAppAccessToken(e,n);this.setTokenHeaders(e,s,i);return}let a=await this.getUserSession();if(!a?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(e,s,a.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,s=e??await this.getUserSession();if(!s?.refreshToken)throw new Error(se);let r=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??S.oauth2)}/oauth2/token`,n=new URLSearchParams({grant_type:"refresh_token",refresh_token:s.refreshToken}),a=await q(()=>this.getFetch()(r,{body:n,headers:{Accept:"application/json",Authorization:`Basic ${y(this.config.clientId,t)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!a.ok){let h=await Ae(a);throw Pe(a,h)?(await this.setUserSession(null),new Error(se)):new Error(Ce(a,h))}let i=await a.json(),p=b(i,s);return await this.setUserSession(p),p}setTokenHeaders(e,t,s){if(e==="oauth2"){t.set("Authorization",`Bearer ${s}`);return}t.set("x-auth-token",s);}async getAppAccessToken(e,t){if(this.mode!=="server")throw new Error("App-authenticated APIs require @quranjs/api/server or a backend.");let s=this.resolveAppScope(e,t);if(!s)throw new Error(`No client-credentials scope is configured for ${e}.`);let r=`${e}:${s}`,n=this.appTokens.get(r);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 a=this.config.clientSecret,i=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??S.oauth2)}/oauth2/token`,p=new URLSearchParams({grant_type:"client_credentials",scope:s}),h=await q(()=>this.getFetch()(i,{body:p,headers:{Accept:"application/json",Authorization:`Basic ${y(this.config.clientId,a)}`,"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(),d={expiresAt:Date.now()+u.expires_in*1e3,value:u.access_token};return this.appTokens.set(r,d),d.value}resolveAppScope(e,t){if(e!=="content"||!t)return re[e];let s=new URL(t).pathname;return s.startsWith(ge)?ve.some(r=>s.endsWith(r))?"comment.read":"post.read":re.content}resolveServiceBaseUrl(e,t=false){let{services:s}=this.config;if(t)return {baseUrl:g(s?.gatewayUrl??L),usesGateway:true};let r=e==="content"?s?.contentBaseUrl:e==="search"?s?.searchBaseUrl:e==="auth"?s?.authBaseUrl:e==="quranReflect"?s?.quranReflectBaseUrl:s?.oauth2BaseUrl??s?.tokenHost;return r?{baseUrl:g(r),usesGateway:false}:s?.gatewayUrl&&e!=="oauth2"?{baseUrl:g(s.gatewayUrl),usesGateway:true}:{baseUrl:S[e],usesGateway:false}}normalizeServicePath(e,t,s,r=false){let n=v(C(t));if(e==="oauth2"||r)return n;let a=n;for(let p of te[e])if(a.startsWith(p)){a=v(a.slice(p.length));break}let i=s?F[e]:ee[e];return a.startsWith(i)?a:`${i}${a}`}isCrossServiceGatewayPath(e,t){let s=v(C(t)),r=ye.find(n=>this.pathMatchesPrefix(s,F[n]));return !!(r&&r!==e)}pathMatchesPrefix(e,t){return t.length>0&&(e===t||e.startsWith(`${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 I=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:s}=await this.fetcher.fetch(`/content/api/v4/resources/recitations/${e}/info`,t);return s}async findTranslationInfo(e,t){let{translationInfo:s}=await this.fetcher.fetch(`/content/api/v4/resources/translations/${e}/info`,t);return s}async findTafsirInfo(e,t){let{tafsirInfo:s}=await this.fetcher.fetch(`/content/api/v4/resources/tafsirs/${e}/info`,t);return s}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 E=class{constructor(e){this.fetcher=e;}async search(e,t){return this.fetcher.fetch("/v1/search",{query:e,size:30,...t})}};var V=class{constructor(e){this.fetcher=e;}async findByKey(e,t){if(!f(e))throw new Error("Invalid verse key");let{verse:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_key/${e}`,{words:false,...t});return s}async findByRange(e,t,s){if(!f(e)||!f(t))throw new Error("Invalid verse key");let{verses:r}=await this.fetcher.fetch("/content/api/v4/verses/by_range",{words:false,...s,from:e,to:t});return r}async findByChapter(e,t){if(!l(e))throw new Error("Invalid chapter id");let{verses:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_chapter/${e}`,{words:false,...t});return s}async findByPage(e,t){if(!N(e))throw new Error("Invalid page number");let{verses:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_page/${e}`,{words:false,...t});return s}async findByJuz(e,t){if(!G(e))throw new Error("Invalid juz");let{verses:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_juz/${e}`,{words:false,...t});return s}async findByHizb(e,t){if(!B(e))throw new Error("Invalid hizb");let{verses:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_hizb/${e}`,{words:false,...t});return s}async findByRub(e,t){if(!z(e))throw new Error("Invalid rub");let{verses:s}=await this.fetcher.fetch(`/content/api/v4/verses/by_rub/${e}`,{words:false,...t});return s}async findRandom(e){let{verse:t}=await this.fetcher.fetch("/content/api/v4/verses/random",{words:false,...e});return t}};var ke="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 }.",we=(o,e)=>(t,s,r)=>o.request(e,P(s,r?.path),r?.query,{...r,auth:"user",method:t,path:void 0,query:void 0}),Se=o=>{let e=m(o,c.auth.v1),t=O(c.auth.v1,e),s=we(o,"auth");return {...t,collections:{...t.collections,addBookmark:(r,n)=>s("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:r}}),create:r=>s("POST","/v1/collections",{body:r}),get:(r,n)=>s("GET","/v1/collections/{collectionId}",{path:{collectionId:r},query:n}),list:r=>s("GET","/v1/collections",{query:r}),listAll:r=>s("GET","/v1/collections/all",{query:r}),remove:r=>s("DELETE","/v1/collections/{collectionId}",{path:{collectionId:r}}),removeBookmark:(r,n)=>s("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:r}}),update:(r,n)=>s("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:r}})},bookmarks:{...t.bookmarks,create:r=>s("POST","/v1/bookmarks",{body:r}),get:async r=>{if(typeof r=="string")throw new Error(ke);return s("GET","/v1/bookmarks/bookmark",{query:r})},list:r=>s("GET","/v1/bookmarks",{query:r}),listCollections:r=>s("GET","/v1/bookmarks/collections",{query:r}),listRange:r=>s("GET","/v1/bookmarks/ayahs-range",{query:r}),remove:r=>s("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:r}})},goals:{...t.goals,create:r=>s("POST","/v1/goals",{body:r}),estimate:r=>s("GET","/v1/goals/estimate",{query:r}),getTodaysPlan:r=>s("GET","/v1/goals/get-todays-plan",{query:r}),remove:r=>s("DELETE","/v1/goals/{id}",{path:{id:r}}),update:(r,n)=>s("PUT","/v1/goals/{id}",{body:n,path:{id:r}})},notes:{...t.notes,create:r=>s("POST","/v1/notes",{body:r}),get:r=>s("GET","/v1/notes/{noteId}",{path:{noteId:r}}),list:r=>s("GET","/v1/notes",{query:r}),listByAttachedEntity:r=>s("GET","/v1/notes/by-attached-entity",{query:r}),listByRange:r=>s("GET","/v1/notes/by-range",{query:r}),listByVerseKey:(r,n)=>s("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:r},query:n}),publish:(r,n)=>s("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:r}}),remove:r=>s("DELETE","/v1/notes/{noteId}",{path:{noteId:r}}),update:(r,n)=>s("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:r}})},preferences:{...t.preferences,bulkUpdate:r=>s("POST","/v1/preferences/bulk",{body:r}),get:r=>s("GET","/v1/preferences",{query:r}),update:r=>s("POST","/v1/preferences",{body:r})},raw:e,readingSessions:{...t.readingSessions,create:r=>s("POST","/v1/reading-sessions",{body:r}),list:r=>s("GET","/v1/reading-sessions",{query:r})}}},_e=o=>{let e=m(o,c.quranReflect.v1),t=O(c.quranReflect.v1,e);return {comments:t.comments??{},posts:t.posts??{},raw:e,rooms:t.rooms??{},tags:t.tags??{},users:t.users??{}}},Te=(o,e,t)=>{let s=m(o,c.oauth2.v1),r=async(n,a={})=>{if(a.requiresRefreshToken&&!n.get("refresh_token"))throw new Error("Missing refresh token.");let i=n.get("refresh_token")??void 0,p=a.requiresRefreshToken?await o.getUserSession():null,h=a.requiresRefreshToken&&i?{...p??{},refreshToken:i}:p,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(b(u,h)),u};return {authorizeUrl:n=>o.buildServiceUrl("oauth2","/oauth2/auth",n),exchangeCode:n=>{let a=new URLSearchParams({code:n.code,grant_type:"authorization_code",redirect_uri:n.redirectUri});return n.codeVerifier&&a.set("code_verifier",n.codeVerifier),n.scope&&a.set("scope",n.scope),r(a,{})},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:s,refresh:async n=>{let a=await o.getUserSession(),i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n??a?.refreshToken??""});return r(i,{requiresRefreshToken:true})}}},Ie=(o,e,t,s,r,n)=>({audio:{chapterRecitation:{get:(a,i,p)=>s.findChapterRecitationById(a,i,p),list:(a,i)=>s.findAllChapterRecitations(a,i)},verseRecitation:{byChapter:(a,i,p)=>s.findVerseRecitationsByChapter(a,i,p),byKey:(a,i,p)=>s.findVerseRecitationsByKey(a,i,p)}},chapters:{get:(a,i)=>o.findById(a,i),getInfo:(a,i)=>o.findInfoById(a,i),list:a=>o.findAll(a)},juzs:{list:()=>t.findAll()},raw:n,resources:{chapterInfos:{list:a=>r.findAllChapterInfos(a)},chapterReciters:{list:a=>r.findAllChapterReciters(a)},languages:{list:a=>r.findAllLanguages(a)},recitationStyles:{list:a=>r.findAllRecitationStyles(a)},recitations:{getInfo:(a,i)=>r.findRecitationInfo(a,i),list:a=>r.findAllRecitations(a)},tafsirs:{getInfo:(a,i)=>r.findTafsirInfo(a,i),list:a=>r.findAllTafsirs(a)},translations:{getInfo:(a,i)=>r.findTranslationInfo(a,i),list:a=>r.findAllTranslations(a)},verseMedia:{list:a=>r.findVerseMedia(a)}},verses:{byChapter:(a,i)=>e.findByChapter(a,i),byHizb:(a,i)=>e.findByHizb(a,i),byJuz:(a,i)=>e.findByJuz(a,i),byKey:(a,i)=>e.findByKey(a,i),byPage:(a,i)=>e.findByPage(a,i),byRange:(a,i,p)=>e.findByRange(a,i,p),byRub:(a,i)=>e.findByRub(a,i),random:a=>e.findRandom(a)}}),oe=(o,e)=>{let t=new _(o,e);t.getFetch();let s=new w(t),r=new V(t),n=new T(t),a=new k(t),i=new I(t),p=new E(t),h={auth:{v1:m(t,c.auth.v1)},content:{v4:m(t,c.content.v4)},oauth2:{v1:m(t,c.oauth2.v1)},quranReflect:{v1:m(t,c.quranReflect.v1)},search:{v1:m(t,c.search.v1)}},u=Ie(s,r,n,a,i,h.content.v4),d=Se(t),H=_e(t),M=Te(t,o,e),$=({query:ne,...ie})=>p.search(ne,ie),ae=Object.assign(p,{query:$,raw:h.search.v1,v1:{query:$,raw:h.search.v1}});return {audio:a,auth:{...d,v1:d},chapters:s,clearCachedTokens:()=>t.clearCachedTokens(),content:{...u,v4:u},getUserSession:()=>t.getUserSession(),juzs:n,oauth2:{...M,v1:M},quranReflect:{...H,v1:H},raw:h,resources:i,search:ae,verses:r}};var cr=o=>oe("server",{...o,defaults:{language:"ar",...o.defaults}});
2
+ exports.createServerClient=cr;//# sourceMappingURL=server.min.js.map
3
+ //# sourceMappingURL=server.min.js.map