@absolutejs/absolute 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2023 +0,0 @@
1
- /**
2
- * @license Angular v21.1.5
3
- * (c) 2010-2026 Google LLC. https://angular.dev/
4
- * License: MIT
5
- */
6
-
7
- import * as i0 from '@angular/core';
8
- import { ɵRuntimeError as _RuntimeError, InjectionToken, inject, NgZone, DestroyRef, Injectable, ɵformatRuntimeError as _formatRuntimeError, ɵTracingService as _TracingService, runInInjectionContext, PendingTasks, ɵConsole as _Console, DOCUMENT, Inject, EnvironmentInjector, makeEnvironmentProviders, NgModule } from '@angular/core';
9
- import { switchMap, finalize, concatMap, filter, map } from 'rxjs/operators';
10
- import { Observable, from, of } from 'rxjs';
11
- import { XhrFactory, parseCookieValue } from './_xhr-chunk.mjs';
12
- import { PlatformLocation } from './_platform_location-chunk.mjs';
13
- class HttpHeaders {
14
- headers;
15
- normalizedNames = new Map();
16
- lazyInit;
17
- lazyUpdate = null;
18
- constructor(headers) {
19
- if (!headers) {
20
- this.headers = new Map();
21
- } else if (typeof headers === 'string') {
22
- this.lazyInit = () => {
23
- this.headers = new Map();
24
- headers.split('\n').forEach(line => {
25
- const index = line.indexOf(':');
26
- if (index > 0) {
27
- const name = line.slice(0, index);
28
- const value = line.slice(index + 1).trim();
29
- this.addHeaderEntry(name, value);
30
- }
31
- });
32
- };
33
- } else if (typeof Headers !== 'undefined' && headers instanceof Headers) {
34
- this.headers = new Map();
35
- headers.forEach((value, name) => {
36
- this.addHeaderEntry(name, value);
37
- });
38
- } else {
39
- this.lazyInit = () => {
40
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
41
- assertValidHeaders(headers);
42
- }
43
- this.headers = new Map();
44
- Object.entries(headers).forEach(([name, values]) => {
45
- this.setHeaderEntries(name, values);
46
- });
47
- };
48
- }
49
- }
50
- has(name) {
51
- this.init();
52
- return this.headers.has(name.toLowerCase());
53
- }
54
- get(name) {
55
- this.init();
56
- const values = this.headers.get(name.toLowerCase());
57
- return values && values.length > 0 ? values[0] : null;
58
- }
59
- keys() {
60
- this.init();
61
- return Array.from(this.normalizedNames.values());
62
- }
63
- getAll(name) {
64
- this.init();
65
- return this.headers.get(name.toLowerCase()) || null;
66
- }
67
- append(name, value) {
68
- return this.clone({
69
- name,
70
- op: 'a',
71
- value
72
- });
73
- }
74
- set(name, value) {
75
- return this.clone({
76
- name,
77
- op: 's',
78
- value
79
- });
80
- }
81
- delete(name, value) {
82
- return this.clone({
83
- name,
84
- op: 'd',
85
- value
86
- });
87
- }
88
- maybeSetNormalizedName(name, lcName) {
89
- if (!this.normalizedNames.has(lcName)) {
90
- this.normalizedNames.set(lcName, name);
91
- }
92
- }
93
- init() {
94
- if (this.lazyInit) {
95
- if (this.lazyInit instanceof HttpHeaders) {
96
- this.copyFrom(this.lazyInit);
97
- } else {
98
- this.lazyInit();
99
- }
100
- this.lazyInit = null;
101
- if (this.lazyUpdate) {
102
- this.lazyUpdate.forEach(update => this.applyUpdate(update));
103
- this.lazyUpdate = null;
104
- }
105
- }
106
- }
107
- copyFrom(other) {
108
- other.init();
109
- Array.from(other.headers.keys()).forEach(key => {
110
- this.headers.set(key, other.headers.get(key));
111
- this.normalizedNames.set(key, other.normalizedNames.get(key));
112
- });
113
- }
114
- clone(update) {
115
- const clone = new HttpHeaders();
116
- clone.lazyInit = Boolean(this.lazyInit) && this.lazyInit instanceof HttpHeaders ? this.lazyInit : this;
117
- clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);
118
- return clone;
119
- }
120
- applyUpdate(update) {
121
- const key = update.name.toLowerCase();
122
- switch (update.op) {
123
- case 'a':
124
- case 's':
125
- let {value} = update;
126
- if (typeof value === 'string') {
127
- value = [value];
128
- }
129
- if (value.length === 0) {
130
- return;
131
- }
132
- this.maybeSetNormalizedName(update.name, key);
133
- const base = (update.op === 'a' ? this.headers.get(key) : undefined) || [];
134
- base.push(...value);
135
- this.headers.set(key, base);
136
- break;
137
- case 'd':
138
- const toDelete = update.value;
139
- if (!toDelete) {
140
- this.headers.delete(key);
141
- this.normalizedNames.delete(key);
142
- } else {
143
- let existing = this.headers.get(key);
144
- if (!existing) {
145
- return;
146
- }
147
- existing = existing.filter(value => toDelete.indexOf(value) === -1);
148
- if (existing.length === 0) {
149
- this.headers.delete(key);
150
- this.normalizedNames.delete(key);
151
- } else {
152
- this.headers.set(key, existing);
153
- }
154
- }
155
- break;
156
- }
157
- }
158
- addHeaderEntry(name, value) {
159
- const key = name.toLowerCase();
160
- this.maybeSetNormalizedName(name, key);
161
- if (this.headers.has(key)) {
162
- this.headers.get(key).push(value);
163
- } else {
164
- this.headers.set(key, [value]);
165
- }
166
- }
167
- setHeaderEntries(name, values) {
168
- const headerValues = (Array.isArray(values) ? values : [values]).map(value => value.toString());
169
- const key = name.toLowerCase();
170
- this.headers.set(key, headerValues);
171
- this.maybeSetNormalizedName(name, key);
172
- }
173
- forEach(fn) {
174
- this.init();
175
- Array.from(this.normalizedNames.keys()).forEach(key => fn(this.normalizedNames.get(key), this.headers.get(key)));
176
- }
177
- }
178
- function assertValidHeaders(headers) {
179
- for (const [key, value] of Object.entries(headers)) {
180
- if (!(typeof value === 'string' || typeof value === 'number') && !Array.isArray(value)) {
181
- throw new Error(`Unexpected value of the \`${key}\` header provided. ` + `Expecting either a string, a number or an array, but got: \`${value}\`.`);
182
- }
183
- }
184
- }
185
- class HttpContextToken {
186
- defaultValue;
187
- constructor(defaultValue) {
188
- this.defaultValue = defaultValue;
189
- }
190
- }
191
- class HttpContext {
192
- map = new Map();
193
- set(token, value) {
194
- this.map.set(token, value);
195
- return this;
196
- }
197
- get(token) {
198
- if (!this.map.has(token)) {
199
- this.map.set(token, token.defaultValue());
200
- }
201
- return this.map.get(token);
202
- }
203
- delete(token) {
204
- this.map.delete(token);
205
- return this;
206
- }
207
- has(token) {
208
- return this.map.has(token);
209
- }
210
- keys() {
211
- return this.map.keys();
212
- }
213
- }
214
- class HttpUrlEncodingCodec {
215
- encodeKey(key) {
216
- return standardEncoding(key);
217
- }
218
- encodeValue(value) {
219
- return standardEncoding(value);
220
- }
221
- decodeKey(key) {
222
- return decodeURIComponent(key);
223
- }
224
- decodeValue(value) {
225
- return decodeURIComponent(value);
226
- }
227
- }
228
- function paramParser(rawParams, codec) {
229
- const map = new Map();
230
- if (rawParams.length > 0) {
231
- const params = rawParams.replace(/^\?/, '').split('&');
232
- params.forEach(param => {
233
- const eqIdx = param.indexOf('=');
234
- const [key, val] = eqIdx == -1 ? [codec.decodeKey(param), ''] : [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];
235
- const list = map.get(key) || [];
236
- list.push(val);
237
- map.set(key, list);
238
- });
239
- }
240
- return map;
241
- }
242
- const STANDARD_ENCODING_REGEX = /%(\d[a-f0-9])/gi;
243
- const STANDARD_ENCODING_REPLACEMENTS = {
244
- '2C': ',',
245
- '2F': '/',
246
- '3A': ':',
247
- '3B': ';',
248
- '3D': '=',
249
- '3F': '?',
250
- '24': '$',
251
- '40': '@'
252
- };
253
- function standardEncoding(v) {
254
- return encodeURIComponent(v).replace(STANDARD_ENCODING_REGEX, (s, t) => STANDARD_ENCODING_REPLACEMENTS[t] ?? s);
255
- }
256
- function valueToString(value) {
257
- return `${value}`;
258
- }
259
- class HttpParams {
260
- map;
261
- encoder;
262
- updates = null;
263
- cloneFrom = null;
264
- constructor(options = {}) {
265
- this.encoder = options.encoder || new HttpUrlEncodingCodec();
266
- if (options.fromString) {
267
- if (options.fromObject) {
268
- throw new _RuntimeError(2805, ngDevMode && 'Cannot specify both fromString and fromObject.');
269
- }
270
- this.map = paramParser(options.fromString, this.encoder);
271
- } else if (options.fromObject) {
272
- this.map = new Map();
273
- Object.keys(options.fromObject).forEach(key => {
274
- const value = options.fromObject[key];
275
- const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)];
276
- this.map.set(key, values);
277
- });
278
- } else {
279
- this.map = null;
280
- }
281
- }
282
- has(param) {
283
- this.init();
284
- return this.map.has(param);
285
- }
286
- get(param) {
287
- this.init();
288
- const res = this.map.get(param);
289
- return res ? res[0] : null;
290
- }
291
- getAll(param) {
292
- this.init();
293
- return this.map.get(param) || null;
294
- }
295
- keys() {
296
- this.init();
297
- return Array.from(this.map.keys());
298
- }
299
- append(param, value) {
300
- return this.clone({
301
- op: 'a',
302
- param,
303
- value
304
- });
305
- }
306
- appendAll(params) {
307
- const updates = [];
308
- Object.keys(params).forEach(param => {
309
- const value = params[param];
310
- if (Array.isArray(value)) {
311
- value.forEach(_value => {
312
- updates.push({
313
- op: 'a',
314
- param,
315
- value: _value
316
- });
317
- });
318
- } else {
319
- updates.push({
320
- op: 'a',
321
- param,
322
- value: value
323
- });
324
- }
325
- });
326
- return this.clone(updates);
327
- }
328
- set(param, value) {
329
- return this.clone({
330
- op: 's',
331
- param,
332
- value
333
- });
334
- }
335
- delete(param, value) {
336
- return this.clone({
337
- op: 'd',
338
- param,
339
- value
340
- });
341
- }
342
- toString() {
343
- this.init();
344
- return this.keys().map(key => {
345
- const eKey = this.encoder.encodeKey(key);
346
- return this.map.get(key).map(value => `${eKey }=${ this.encoder.encodeValue(value)}`).join('&');
347
- }).filter(param => param !== '').join('&');
348
- }
349
- clone(update) {
350
- const clone = new HttpParams({
351
- encoder: this.encoder
352
- });
353
- clone.cloneFrom = this.cloneFrom || this;
354
- clone.updates = (this.updates || []).concat(update);
355
- return clone;
356
- }
357
- init() {
358
- if (this.map === null) {
359
- this.map = new Map();
360
- }
361
- if (this.cloneFrom !== null) {
362
- this.cloneFrom.init();
363
- this.cloneFrom.keys().forEach(key => this.map.set(key, this.cloneFrom.map.get(key)));
364
- this.updates.forEach(update => {
365
- switch (update.op) {
366
- case 'a':
367
- case 's':
368
- const base = (update.op === 'a' ? this.map.get(update.param) : undefined) || [];
369
- base.push(valueToString(update.value));
370
- this.map.set(update.param, base);
371
- break;
372
- case 'd':
373
- if (update.value !== undefined) {
374
- const base = this.map.get(update.param) || [];
375
- const idx = base.indexOf(valueToString(update.value));
376
- if (idx !== -1) {
377
- base.splice(idx, 1);
378
- }
379
- if (base.length > 0) {
380
- this.map.set(update.param, base);
381
- } else {
382
- this.map.delete(update.param);
383
- }
384
- } else {
385
- this.map.delete(update.param);
386
- break;
387
- }
388
- }
389
- });
390
- this.cloneFrom = this.updates = null;
391
- }
392
- }
393
- }
394
- function mightHaveBody(method) {
395
- switch (method) {
396
- case 'DELETE':
397
- case 'GET':
398
- case 'HEAD':
399
- case 'OPTIONS':
400
- case 'JSONP':
401
- return false;
402
- default:
403
- return true;
404
- }
405
- }
406
- function isArrayBuffer(value) {
407
- return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
408
- }
409
- function isBlob(value) {
410
- return typeof Blob !== 'undefined' && value instanceof Blob;
411
- }
412
- function isFormData(value) {
413
- return typeof FormData !== 'undefined' && value instanceof FormData;
414
- }
415
- function isUrlSearchParams(value) {
416
- return typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams;
417
- }
418
- const CONTENT_TYPE_HEADER = 'Content-Type';
419
- const ACCEPT_HEADER = 'Accept';
420
- const TEXT_CONTENT_TYPE = 'text/plain';
421
- const JSON_CONTENT_TYPE = 'application/json';
422
- const ACCEPT_HEADER_VALUE = `${JSON_CONTENT_TYPE}, ${TEXT_CONTENT_TYPE}, */*`;
423
- class HttpRequest {
424
- url;
425
- body = null;
426
- headers;
427
- context;
428
- reportProgress = false;
429
- withCredentials = false;
430
- credentials;
431
- keepalive = false;
432
- cache;
433
- priority;
434
- mode;
435
- redirect;
436
- referrer;
437
- integrity;
438
- referrerPolicy;
439
- responseType = 'json';
440
- method;
441
- params;
442
- urlWithParams;
443
- transferCache;
444
- timeout;
445
- constructor(method, url, third, fourth) {
446
- this.url = url;
447
- this.method = method.toUpperCase();
448
- let options;
449
- if (mightHaveBody(this.method) || Boolean(fourth)) {
450
- this.body = third !== undefined ? third : null;
451
- options = fourth;
452
- } else {
453
- options = third;
454
- }
455
- if (options) {
456
- this.reportProgress = Boolean(options.reportProgress);
457
- this.withCredentials = Boolean(options.withCredentials);
458
- this.keepalive = Boolean(options.keepalive);
459
- if (options.responseType) {
460
- this.responseType = options.responseType;
461
- }
462
- if (options.headers) {
463
- this.headers = options.headers;
464
- }
465
- if (options.context) {
466
- this.context = options.context;
467
- }
468
- if (options.params) {
469
- this.params = options.params;
470
- }
471
- if (options.priority) {
472
- this.priority = options.priority;
473
- }
474
- if (options.cache) {
475
- this.cache = options.cache;
476
- }
477
- if (options.credentials) {
478
- this.credentials = options.credentials;
479
- }
480
- if (typeof options.timeout === 'number') {
481
- if (options.timeout < 1 || !Number.isInteger(options.timeout)) {
482
- throw new _RuntimeError(2822, ngDevMode ? '`timeout` must be a positive integer value' : '');
483
- }
484
- this.timeout = options.timeout;
485
- }
486
- if (options.mode) {
487
- this.mode = options.mode;
488
- }
489
- if (options.redirect) {
490
- this.redirect = options.redirect;
491
- }
492
- if (options.integrity) {
493
- this.integrity = options.integrity;
494
- }
495
- if (options.referrer) {
496
- this.referrer = options.referrer;
497
- }
498
- if (options.referrerPolicy) {
499
- this.referrerPolicy = options.referrerPolicy;
500
- }
501
- this.transferCache = options.transferCache;
502
- }
503
- this.headers ??= new HttpHeaders();
504
- this.context ??= new HttpContext();
505
- if (!this.params) {
506
- this.params = new HttpParams();
507
- this.urlWithParams = url;
508
- } else {
509
- const params = this.params.toString();
510
- if (params.length === 0) {
511
- this.urlWithParams = url;
512
- } else {
513
- const qIdx = url.indexOf('?');
514
- const sep = qIdx === -1 ? '?' : qIdx < url.length - 1 ? '&' : '';
515
- this.urlWithParams = url + sep + params;
516
- }
517
- }
518
- }
519
- serializeBody() {
520
- if (this.body === null) {
521
- return null;
522
- }
523
- if (typeof this.body === 'string' || isArrayBuffer(this.body) || isBlob(this.body) || isFormData(this.body) || isUrlSearchParams(this.body)) {
524
- return this.body;
525
- }
526
- if (this.body instanceof HttpParams) {
527
- return this.body.toString();
528
- }
529
- if (typeof this.body === 'object' || typeof this.body === 'boolean' || Array.isArray(this.body)) {
530
- return JSON.stringify(this.body);
531
- }
532
- return this.body.toString();
533
- }
534
- detectContentTypeHeader() {
535
- if (this.body === null) {
536
- return null;
537
- }
538
- if (isFormData(this.body)) {
539
- return null;
540
- }
541
- if (isBlob(this.body)) {
542
- return this.body.type || null;
543
- }
544
- if (isArrayBuffer(this.body)) {
545
- return null;
546
- }
547
- if (typeof this.body === 'string') {
548
- return TEXT_CONTENT_TYPE;
549
- }
550
- if (this.body instanceof HttpParams) {
551
- return 'application/x-www-form-urlencoded;charset=UTF-8';
552
- }
553
- if (typeof this.body === 'object' || typeof this.body === 'number' || typeof this.body === 'boolean') {
554
- return JSON_CONTENT_TYPE;
555
- }
556
- return null;
557
- }
558
- clone(update = {}) {
559
- const method = update.method || this.method;
560
- const url = update.url || this.url;
561
- const responseType = update.responseType || this.responseType;
562
- const keepalive = update.keepalive ?? this.keepalive;
563
- const priority = update.priority || this.priority;
564
- const cache = update.cache || this.cache;
565
- const mode = update.mode || this.mode;
566
- const redirect = update.redirect || this.redirect;
567
- const credentials = update.credentials || this.credentials;
568
- const referrer = update.referrer || this.referrer;
569
- const integrity = update.integrity || this.integrity;
570
- const referrerPolicy = update.referrerPolicy || this.referrerPolicy;
571
- const transferCache = update.transferCache ?? this.transferCache;
572
- const timeout = update.timeout ?? this.timeout;
573
- const body = update.body !== undefined ? update.body : this.body;
574
- const withCredentials = update.withCredentials ?? this.withCredentials;
575
- const reportProgress = update.reportProgress ?? this.reportProgress;
576
- let headers = update.headers || this.headers;
577
- let params = update.params || this.params;
578
- const context = update.context ?? this.context;
579
- if (update.setHeaders !== undefined) {
580
- headers = Object.keys(update.setHeaders).reduce((headers, name) => headers.set(name, update.setHeaders[name]), headers);
581
- }
582
- if (update.setParams) {
583
- params = Object.keys(update.setParams).reduce((params, param) => params.set(param, update.setParams[param]), params);
584
- }
585
- return new HttpRequest(method, url, body, {
586
- cache,
587
- context,
588
- credentials,
589
- headers,
590
- integrity,
591
- keepalive,
592
- mode,
593
- params,
594
- priority,
595
- redirect,
596
- referrer,
597
- referrerPolicy,
598
- reportProgress,
599
- responseType,
600
- timeout,
601
- transferCache,
602
- withCredentials
603
- });
604
- }
605
- }
606
- let HttpEventType;
607
- (function (HttpEventType) {
608
- HttpEventType[HttpEventType["Sent"] = 0] = "Sent";
609
- HttpEventType[HttpEventType["UploadProgress"] = 1] = "UploadProgress";
610
- HttpEventType[HttpEventType["ResponseHeader"] = 2] = "ResponseHeader";
611
- HttpEventType[HttpEventType["DownloadProgress"] = 3] = "DownloadProgress";
612
- HttpEventType[HttpEventType["Response"] = 4] = "Response";
613
- HttpEventType[HttpEventType["User"] = 5] = "User";
614
- })(HttpEventType || (HttpEventType = {}));
615
- class HttpResponseBase {
616
- headers;
617
- status;
618
- statusText;
619
- url;
620
- ok;
621
- type;
622
- redirected;
623
- responseType;
624
- constructor(init, defaultStatus = 200, defaultStatusText = 'OK') {
625
- this.headers = init.headers || new HttpHeaders();
626
- this.status = init.status !== undefined ? init.status : defaultStatus;
627
- this.statusText = init.statusText || defaultStatusText;
628
- this.url = init.url || null;
629
- this.redirected = init.redirected;
630
- this.responseType = init.responseType;
631
- this.ok = this.status >= 200 && this.status < 300;
632
- }
633
- }
634
- class HttpHeaderResponse extends HttpResponseBase {
635
- constructor(init = {}) {
636
- super(init);
637
- }
638
- type = HttpEventType.ResponseHeader;
639
- clone(update = {}) {
640
- return new HttpHeaderResponse({
641
- headers: update.headers || this.headers,
642
- status: update.status !== undefined ? update.status : this.status,
643
- statusText: update.statusText || this.statusText,
644
- url: update.url || this.url || undefined
645
- });
646
- }
647
- }
648
- class HttpResponse extends HttpResponseBase {
649
- body;
650
- constructor(init = {}) {
651
- super(init);
652
- this.body = init.body !== undefined ? init.body : null;
653
- }
654
- type = HttpEventType.Response;
655
- clone(update = {}) {
656
- return new HttpResponse({
657
- body: update.body !== undefined ? update.body : this.body,
658
- headers: update.headers || this.headers,
659
- redirected: update.redirected ?? this.redirected,
660
- responseType: update.responseType ?? this.responseType,
661
- status: update.status !== undefined ? update.status : this.status,
662
- statusText: update.statusText || this.statusText,
663
- url: update.url || this.url || undefined
664
- });
665
- }
666
- }
667
- class HttpErrorResponse extends HttpResponseBase {
668
- name = 'HttpErrorResponse';
669
- message;
670
- error;
671
- ok = false;
672
- constructor(init) {
673
- super(init, 0, 'Unknown Error');
674
- if (this.status >= 200 && this.status < 300) {
675
- this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;
676
- } else {
677
- this.message = `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${init.statusText}`;
678
- }
679
- this.error = init.error || null;
680
- }
681
- }
682
- const HTTP_STATUS_CODE_OK = 200;
683
- const HTTP_STATUS_CODE_NO_CONTENT = 204;
684
- let HttpStatusCode;
685
- (function (HttpStatusCode) {
686
- HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
687
- HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
688
- HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
689
- HttpStatusCode[HttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
690
- HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
691
- HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
692
- HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
693
- HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
694
- HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
695
- HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
696
- HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
697
- HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
698
- HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
699
- HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
700
- HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
701
- HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
702
- HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
703
- HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
704
- HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
705
- HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
706
- HttpStatusCode[HttpStatusCode["Unused"] = 306] = "Unused";
707
- HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
708
- HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
709
- HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
710
- HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
711
- HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
712
- HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
713
- HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
714
- HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
715
- HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
716
- HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
717
- HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
718
- HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
719
- HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
720
- HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
721
- HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
722
- HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
723
- HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
724
- HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
725
- HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
726
- HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
727
- HttpStatusCode[HttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
728
- HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
729
- HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
730
- HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
731
- HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
732
- HttpStatusCode[HttpStatusCode["TooEarly"] = 425] = "TooEarly";
733
- HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
734
- HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
735
- HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
736
- HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
737
- HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
738
- HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
739
- HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
740
- HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
741
- HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
742
- HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
743
- HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
744
- HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
745
- HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
746
- HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
747
- HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
748
- HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
749
- })(HttpStatusCode || (HttpStatusCode = {}));
750
- const XSSI_PREFIX$1 = /^\)\]\}',?\n/;
751
- const FETCH_BACKEND = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'FETCH_BACKEND' : '');
752
- class FetchBackend {
753
- fetchImpl = inject(FetchFactory, {
754
- optional: true
755
- })?.fetch ?? ((...args) => globalThis.fetch(...args));
756
- ngZone = inject(NgZone);
757
- destroyRef = inject(DestroyRef);
758
- handle(request) {
759
- return new Observable(observer => {
760
- const aborter = new AbortController();
761
- this.doRequest(request, aborter.signal, observer).then(noop, error => observer.error(new HttpErrorResponse({
762
- error
763
- })));
764
- let timeoutId;
765
- if (request.timeout) {
766
- timeoutId = this.ngZone.runOutsideAngular(() => setTimeout(() => {
767
- if (!aborter.signal.aborted) {
768
- aborter.abort(new DOMException('signal timed out', 'TimeoutError'));
769
- }
770
- }, request.timeout));
771
- }
772
- return () => {
773
- if (timeoutId !== undefined) {
774
- clearTimeout(timeoutId);
775
- }
776
- aborter.abort();
777
- };
778
- });
779
- }
780
- async doRequest(request, signal, observer) {
781
- const init = this.createRequestInit(request);
782
- let response;
783
- try {
784
- const fetchPromise = this.ngZone.runOutsideAngular(() => this.fetchImpl(request.urlWithParams, {
785
- signal,
786
- ...init
787
- }));
788
- silenceSuperfluousUnhandledPromiseRejection(fetchPromise);
789
- observer.next({
790
- type: HttpEventType.Sent
791
- });
792
- response = await fetchPromise;
793
- } catch (error) {
794
- observer.error(new HttpErrorResponse({
795
- error,
796
- headers: error.headers,
797
- status: error.status ?? 0,
798
- statusText: error.statusText,
799
- url: request.urlWithParams
800
- }));
801
- return;
802
- }
803
- const headers = new HttpHeaders(response.headers);
804
- const {statusText} = response;
805
- const url = response.url || request.urlWithParams;
806
- let {status} = response;
807
- let body = null;
808
- if (request.reportProgress) {
809
- observer.next(new HttpHeaderResponse({
810
- headers,
811
- status,
812
- statusText,
813
- url
814
- }));
815
- }
816
- if (response.body) {
817
- const contentLength = response.headers.get('content-length');
818
- const chunks = [];
819
- const reader = response.body.getReader();
820
- let receivedLength = 0;
821
- let decoder;
822
- let partialText;
823
- const reqZone = typeof Zone !== 'undefined' && Zone.current;
824
- let canceled = false;
825
- await this.ngZone.runOutsideAngular(async () => {
826
- while (true) {
827
- if (this.destroyRef.destroyed) {
828
- await reader.cancel();
829
- canceled = true;
830
- break;
831
- }
832
- const {
833
- done,
834
- value
835
- } = await reader.read();
836
- if (done) {
837
- break;
838
- }
839
- chunks.push(value);
840
- receivedLength += value.length;
841
- if (request.reportProgress) {
842
- partialText = request.responseType === 'text' ? (partialText ?? '') + (decoder ??= new TextDecoder()).decode(value, {
843
- stream: true
844
- }) : undefined;
845
- const reportProgress = () => observer.next({
846
- loaded: receivedLength,
847
- partialText,
848
- total: contentLength ? +contentLength : undefined,
849
- type: HttpEventType.DownloadProgress
850
- });
851
- reqZone ? reqZone.run(reportProgress) : reportProgress();
852
- }
853
- }
854
- });
855
- if (canceled) {
856
- observer.complete();
857
- return;
858
- }
859
- const chunksAll = this.concatChunks(chunks, receivedLength);
860
- try {
861
- const contentType = response.headers.get(CONTENT_TYPE_HEADER) ?? '';
862
- body = this.parseBody(request, chunksAll, contentType, status);
863
- } catch (error) {
864
- observer.error(new HttpErrorResponse({
865
- error,
866
- headers: new HttpHeaders(response.headers),
867
- status: response.status,
868
- statusText: response.statusText,
869
- url: response.url || request.urlWithParams
870
- }));
871
- return;
872
- }
873
- }
874
- if (status === 0) {
875
- status = body ? HTTP_STATUS_CODE_OK : 0;
876
- }
877
- const ok = status >= 200 && status < 300;
878
- const {redirected} = response;
879
- const responseType = response.type;
880
- if (ok) {
881
- observer.next(new HttpResponse({
882
- body,
883
- headers,
884
- redirected,
885
- responseType,
886
- status,
887
- statusText,
888
- url
889
- }));
890
- observer.complete();
891
- } else {
892
- observer.error(new HttpErrorResponse({
893
- error: body,
894
- headers,
895
- redirected,
896
- responseType,
897
- status,
898
- statusText,
899
- url
900
- }));
901
- }
902
- }
903
- parseBody(request, binContent, contentType, status) {
904
- switch (request.responseType) {
905
- case 'json':
906
- const text = new TextDecoder().decode(binContent).replace(XSSI_PREFIX$1, '');
907
- if (text === '') {
908
- return null;
909
- }
910
- try {
911
- return JSON.parse(text);
912
- } catch (e) {
913
- if (status < 200 || status >= 300) {
914
- return text;
915
- }
916
- throw e;
917
- }
918
- case 'text':
919
- return new TextDecoder().decode(binContent);
920
- case 'blob':
921
- return new Blob([binContent], {
922
- type: contentType
923
- });
924
- case 'arraybuffer':
925
- return binContent.buffer;
926
- }
927
- }
928
- createRequestInit(req) {
929
- const headers = {};
930
- let credentials;
931
- credentials = req.credentials;
932
- if (req.withCredentials) {
933
- (typeof ngDevMode === 'undefined' || ngDevMode) && warningOptionsMessage(req);
934
- credentials = 'include';
935
- }
936
- req.headers.forEach((name, values) => headers[name] = values.join(','));
937
- if (!req.headers.has(ACCEPT_HEADER)) {
938
- headers[ACCEPT_HEADER] = ACCEPT_HEADER_VALUE;
939
- }
940
- if (!req.headers.has(CONTENT_TYPE_HEADER)) {
941
- const detectedType = req.detectContentTypeHeader();
942
- if (detectedType !== null) {
943
- headers[CONTENT_TYPE_HEADER] = detectedType;
944
- }
945
- }
946
- return {
947
- body: req.serializeBody(),
948
- cache: req.cache,
949
- credentials,
950
- headers,
951
- integrity: req.integrity,
952
- keepalive: req.keepalive,
953
- method: req.method,
954
- mode: req.mode,
955
- priority: req.priority,
956
- redirect: req.redirect,
957
- referrer: req.referrer,
958
- referrerPolicy: req.referrerPolicy
959
- };
960
- }
961
- concatChunks(chunks, totalLength) {
962
- const chunksAll = new Uint8Array(totalLength);
963
- let position = 0;
964
- for (const chunk of chunks) {
965
- chunksAll.set(chunk, position);
966
- position += chunk.length;
967
- }
968
- return chunksAll;
969
- }
970
- static ɵfac = function FetchBackend_Factory(__ngFactoryType__) {
971
- return new (__ngFactoryType__ || FetchBackend)();
972
- };
973
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
974
- factory: FetchBackend.ɵfac,
975
- token: FetchBackend
976
- });
977
- }
978
- (() => {
979
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FetchBackend, [{
980
- type: Injectable
981
- }], null, null);
982
- })();
983
- class FetchFactory {}
984
- function noop() {}
985
- function warningOptionsMessage(req) {
986
- if (req.credentials && req.withCredentials) {
987
- console.warn(_formatRuntimeError(2819, `Angular detected that a \`HttpClient\` request has both \`withCredentials: true\` and \`credentials: '${req.credentials}'\` options. The \`withCredentials\` option is overriding the explicit \`credentials\` setting to 'include'. Consider removing \`withCredentials\` and using \`credentials: '${req.credentials}'\` directly for clarity.`));
988
- }
989
- }
990
- function silenceSuperfluousUnhandledPromiseRejection(promise) {
991
- promise.then(noop, noop);
992
- }
993
- const XSSI_PREFIX = /^\)\]\}',?\n/;
994
- function validateXhrCompatibility(req) {
995
- const unsupportedOptions = [{
996
- errorCode: 2813,
997
- property: 'keepalive'
998
- }, {
999
- errorCode: 2814,
1000
- property: 'cache'
1001
- }, {
1002
- errorCode: 2815,
1003
- property: 'priority'
1004
- }, {
1005
- errorCode: 2816,
1006
- property: 'mode'
1007
- }, {
1008
- errorCode: 2817,
1009
- property: 'redirect'
1010
- }, {
1011
- errorCode: 2818,
1012
- property: 'credentials'
1013
- }, {
1014
- errorCode: 2820,
1015
- property: 'integrity'
1016
- }, {
1017
- errorCode: 2821,
1018
- property: 'referrer'
1019
- }, {
1020
- errorCode: 2823,
1021
- property: 'referrerPolicy'
1022
- }];
1023
- for (const {
1024
- property,
1025
- errorCode
1026
- } of unsupportedOptions) {
1027
- if (req[property]) {
1028
- console.warn(_formatRuntimeError(errorCode, `Angular detected that a \`HttpClient\` request with the \`${property}\` option was sent using XHR, which does not support it. To use the \`${property}\` option, enable Fetch API support by passing \`withFetch()\` as an argument to \`provideHttpClient()\`.`));
1029
- }
1030
- }
1031
- }
1032
- class HttpXhrBackend {
1033
- xhrFactory;
1034
- tracingService = inject(_TracingService, {
1035
- optional: true
1036
- });
1037
- constructor(xhrFactory) {
1038
- this.xhrFactory = xhrFactory;
1039
- }
1040
- maybePropagateTrace(fn) {
1041
- return this.tracingService?.propagate ? this.tracingService.propagate(fn) : fn;
1042
- }
1043
- handle(req) {
1044
- if (req.method === 'JSONP') {
1045
- throw new _RuntimeError(-2800, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot make a JSONP request without JSONP support. To fix the problem, either add the \`withJsonpSupport()\` call (if \`provideHttpClient()\` is used) or import the \`HttpClientJsonpModule\` in the root NgModule.`);
1046
- }
1047
- ngDevMode && validateXhrCompatibility(req);
1048
- const {xhrFactory} = this;
1049
- const source = typeof ngServerMode !== 'undefined' && ngServerMode && xhrFactory.ɵloadImpl ? from(xhrFactory.ɵloadImpl()) : of(null);
1050
- return source.pipe(switchMap(() => new Observable(observer => {
1051
- const xhr = xhrFactory.build();
1052
- xhr.open(req.method, req.urlWithParams);
1053
- if (req.withCredentials) {
1054
- xhr.withCredentials = true;
1055
- }
1056
- req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(',')));
1057
- if (!req.headers.has(ACCEPT_HEADER)) {
1058
- xhr.setRequestHeader(ACCEPT_HEADER, ACCEPT_HEADER_VALUE);
1059
- }
1060
- if (!req.headers.has(CONTENT_TYPE_HEADER)) {
1061
- const detectedType = req.detectContentTypeHeader();
1062
- if (detectedType !== null) {
1063
- xhr.setRequestHeader(CONTENT_TYPE_HEADER, detectedType);
1064
- }
1065
- }
1066
- if (req.timeout) {
1067
- xhr.timeout = req.timeout;
1068
- }
1069
- if (req.responseType) {
1070
- const responseType = req.responseType.toLowerCase();
1071
- xhr.responseType = responseType !== 'json' ? responseType : 'text';
1072
- }
1073
- const reqBody = req.serializeBody();
1074
- let headerResponse = null;
1075
- const partialFromXhr = () => {
1076
- if (headerResponse !== null) {
1077
- return headerResponse;
1078
- }
1079
- const statusText = xhr.statusText || 'OK';
1080
- const headers = new HttpHeaders(xhr.getAllResponseHeaders());
1081
- const url = xhr.responseURL || req.url;
1082
- headerResponse = new HttpHeaderResponse({
1083
- headers,
1084
- status: xhr.status,
1085
- statusText,
1086
- url
1087
- });
1088
- return headerResponse;
1089
- };
1090
- const onLoad = this.maybePropagateTrace(() => {
1091
- let {
1092
- headers,
1093
- status,
1094
- statusText,
1095
- url
1096
- } = partialFromXhr();
1097
- let body = null;
1098
- if (status !== HTTP_STATUS_CODE_NO_CONTENT) {
1099
- body = typeof xhr.response === 'undefined' ? xhr.responseText : xhr.response;
1100
- }
1101
- if (status === 0) {
1102
- status = body ? HTTP_STATUS_CODE_OK : 0;
1103
- }
1104
- let ok = status >= 200 && status < 300;
1105
- if (req.responseType === 'json' && typeof body === 'string') {
1106
- const originalBody = body;
1107
- body = body.replace(XSSI_PREFIX, '');
1108
- try {
1109
- body = body !== '' ? JSON.parse(body) : null;
1110
- } catch (error) {
1111
- body = originalBody;
1112
- if (ok) {
1113
- ok = false;
1114
- body = {
1115
- error,
1116
- text: body
1117
- };
1118
- }
1119
- }
1120
- }
1121
- if (ok) {
1122
- observer.next(new HttpResponse({
1123
- body,
1124
- headers,
1125
- status,
1126
- statusText,
1127
- url: url || undefined
1128
- }));
1129
- observer.complete();
1130
- } else {
1131
- observer.error(new HttpErrorResponse({
1132
- error: body,
1133
- headers,
1134
- status,
1135
- statusText,
1136
- url: url || undefined
1137
- }));
1138
- }
1139
- });
1140
- const onError = this.maybePropagateTrace(error => {
1141
- const {
1142
- url
1143
- } = partialFromXhr();
1144
- const res = new HttpErrorResponse({
1145
- error,
1146
- status: xhr.status || 0,
1147
- statusText: xhr.statusText || 'Unknown Error',
1148
- url: url || undefined
1149
- });
1150
- observer.error(res);
1151
- });
1152
- let onTimeout = onError;
1153
- if (req.timeout) {
1154
- onTimeout = this.maybePropagateTrace(_ => {
1155
- const {
1156
- url
1157
- } = partialFromXhr();
1158
- const res = new HttpErrorResponse({
1159
- error: new DOMException('Request timed out', 'TimeoutError'),
1160
- status: xhr.status || 0,
1161
- statusText: xhr.statusText || 'Request timeout',
1162
- url: url || undefined
1163
- });
1164
- observer.error(res);
1165
- });
1166
- }
1167
- let sentHeaders = false;
1168
- const onDownProgress = this.maybePropagateTrace(event => {
1169
- if (!sentHeaders) {
1170
- observer.next(partialFromXhr());
1171
- sentHeaders = true;
1172
- }
1173
- const progressEvent = {
1174
- loaded: event.loaded,
1175
- type: HttpEventType.DownloadProgress
1176
- };
1177
- if (event.lengthComputable) {
1178
- progressEvent.total = event.total;
1179
- }
1180
- if (req.responseType === 'text' && Boolean(xhr.responseText)) {
1181
- progressEvent.partialText = xhr.responseText;
1182
- }
1183
- observer.next(progressEvent);
1184
- });
1185
- const onUpProgress = this.maybePropagateTrace(event => {
1186
- const progress = {
1187
- loaded: event.loaded,
1188
- type: HttpEventType.UploadProgress
1189
- };
1190
- if (event.lengthComputable) {
1191
- progress.total = event.total;
1192
- }
1193
- observer.next(progress);
1194
- });
1195
- xhr.addEventListener('load', onLoad);
1196
- xhr.addEventListener('error', onError);
1197
- xhr.addEventListener('timeout', onTimeout);
1198
- xhr.addEventListener('abort', onError);
1199
- if (req.reportProgress) {
1200
- xhr.addEventListener('progress', onDownProgress);
1201
- if (reqBody !== null && xhr.upload) {
1202
- xhr.upload.addEventListener('progress', onUpProgress);
1203
- }
1204
- }
1205
- xhr.send(reqBody);
1206
- observer.next({
1207
- type: HttpEventType.Sent
1208
- });
1209
- return () => {
1210
- xhr.removeEventListener('error', onError);
1211
- xhr.removeEventListener('abort', onError);
1212
- xhr.removeEventListener('load', onLoad);
1213
- xhr.removeEventListener('timeout', onTimeout);
1214
- if (req.reportProgress) {
1215
- xhr.removeEventListener('progress', onDownProgress);
1216
- if (reqBody !== null && xhr.upload) {
1217
- xhr.upload.removeEventListener('progress', onUpProgress);
1218
- }
1219
- }
1220
- if (xhr.readyState !== xhr.DONE) {
1221
- xhr.abort();
1222
- }
1223
- };
1224
- })));
1225
- }
1226
- static ɵfac = function HttpXhrBackend_Factory(__ngFactoryType__) {
1227
- return new (__ngFactoryType__ || HttpXhrBackend)(i0.ɵɵinject(XhrFactory));
1228
- };
1229
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1230
- factory: HttpXhrBackend.ɵfac,
1231
- providedIn: 'root',
1232
- token: HttpXhrBackend
1233
- });
1234
- }
1235
- (() => {
1236
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpXhrBackend, [{
1237
- args: [{
1238
- providedIn: 'root'
1239
- }],
1240
- type: Injectable
1241
- }], () => [{
1242
- type: XhrFactory
1243
- }], null);
1244
- })();
1245
- function interceptorChainEndFn(req, finalHandlerFn) {
1246
- return finalHandlerFn(req);
1247
- }
1248
- function adaptLegacyInterceptorToChain(chainTailFn, interceptor) {
1249
- return (initialRequest, finalHandlerFn) => interceptor.intercept(initialRequest, {
1250
- handle: downstreamRequest => chainTailFn(downstreamRequest, finalHandlerFn)
1251
- });
1252
- }
1253
- function chainedInterceptorFn(chainTailFn, interceptorFn, injector) {
1254
- return (initialRequest, finalHandlerFn) => runInInjectionContext(injector, () => interceptorFn(initialRequest, downstreamRequest => chainTailFn(downstreamRequest, finalHandlerFn)));
1255
- }
1256
- const HTTP_INTERCEPTORS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_INTERCEPTORS' : '');
1257
- const HTTP_INTERCEPTOR_FNS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_INTERCEPTOR_FNS' : '', {
1258
- factory: () => []
1259
- });
1260
- const HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_ROOT_INTERCEPTOR_FNS' : '');
1261
- const REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'REQUESTS_CONTRIBUTE_TO_STABILITY' : '', {
1262
- factory: () => true
1263
- });
1264
- function legacyInterceptorFnFactory() {
1265
- let chain = null;
1266
- return (req, handler) => {
1267
- if (chain === null) {
1268
- const interceptors = inject(HTTP_INTERCEPTORS, {
1269
- optional: true
1270
- }) ?? [];
1271
- chain = interceptors.reduceRight(adaptLegacyInterceptorToChain, interceptorChainEndFn);
1272
- }
1273
- const pendingTasks = inject(PendingTasks);
1274
- const contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
1275
- if (contributeToStability) {
1276
- const removeTask = pendingTasks.add();
1277
- return chain(req, handler).pipe(finalize(removeTask));
1278
- }
1279
- return chain(req, handler);
1280
-
1281
- };
1282
- }
1283
- class HttpBackend {
1284
- static ɵfac = function HttpBackend_Factory(__ngFactoryType__) {
1285
- return new (__ngFactoryType__ || HttpBackend)();
1286
- };
1287
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1288
- providedIn: 'root',
1289
- token: HttpBackend,
1290
- factory: function HttpBackend_Factory(__ngFactoryType__) {
1291
- let __ngConditionalFactory__ = null;
1292
- if (__ngFactoryType__) {
1293
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpBackend)();
1294
- } else {
1295
- __ngConditionalFactory__ = i0.ɵɵinject(HttpXhrBackend);
1296
- }
1297
- return __ngConditionalFactory__;
1298
- }
1299
- });
1300
- }
1301
- (() => {
1302
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpBackend, [{
1303
- args: [{
1304
- providedIn: 'root',
1305
- useExisting: HttpXhrBackend
1306
- }],
1307
- type: Injectable
1308
- }], null, null);
1309
- })();
1310
- let fetchBackendWarningDisplayed = false;
1311
- class HttpInterceptorHandler {
1312
- backend;
1313
- injector;
1314
- chain = null;
1315
- pendingTasks = inject(PendingTasks);
1316
- contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
1317
- constructor(backend, injector) {
1318
- this.backend = backend;
1319
- this.injector = injector;
1320
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && !fetchBackendWarningDisplayed) {
1321
- const {isTestingBackend} = this.backend;
1322
- if (typeof ngServerMode !== 'undefined' && ngServerMode && !(this.backend instanceof FetchBackend) && !isTestingBackend) {
1323
- fetchBackendWarningDisplayed = true;
1324
- injector.get(_Console).warn(_formatRuntimeError(2801, 'Angular detected that `HttpClient` is not configured ' + "to use `fetch` APIs. It's strongly recommended to " + 'enable `fetch` for applications that use Server-Side Rendering ' + 'for better performance and compatibility. ' + 'To enable `fetch`, add the `withFetch()` to the `provideHttpClient()` ' + 'call at the root of the application.'));
1325
- }
1326
- }
1327
- }
1328
- handle(initialRequest) {
1329
- if (this.chain === null) {
1330
- const dedupedInterceptorFns = Array.from(new Set([...this.injector.get(HTTP_INTERCEPTOR_FNS), ...this.injector.get(HTTP_ROOT_INTERCEPTOR_FNS, [])]));
1331
- this.chain = dedupedInterceptorFns.reduceRight((nextSequencedFn, interceptorFn) => chainedInterceptorFn(nextSequencedFn, interceptorFn, this.injector), interceptorChainEndFn);
1332
- }
1333
- if (this.contributeToStability) {
1334
- const removeTask = this.pendingTasks.add();
1335
- return this.chain(initialRequest, downstreamRequest => this.backend.handle(downstreamRequest)).pipe(finalize(removeTask));
1336
- }
1337
- return this.chain(initialRequest, downstreamRequest => this.backend.handle(downstreamRequest));
1338
-
1339
- }
1340
- static ɵfac = function HttpInterceptorHandler_Factory(__ngFactoryType__) {
1341
- return new (__ngFactoryType__ || HttpInterceptorHandler)(i0.ɵɵinject(HttpBackend), i0.ɵɵinject(i0.EnvironmentInjector));
1342
- };
1343
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1344
- factory: HttpInterceptorHandler.ɵfac,
1345
- providedIn: 'root',
1346
- token: HttpInterceptorHandler
1347
- });
1348
- }
1349
- (() => {
1350
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpInterceptorHandler, [{
1351
- args: [{
1352
- providedIn: 'root'
1353
- }],
1354
- type: Injectable
1355
- }], () => [{
1356
- type: HttpBackend
1357
- }, {
1358
- type: i0.EnvironmentInjector
1359
- }], null);
1360
- })();
1361
- class HttpHandler {
1362
- static ɵfac = function HttpHandler_Factory(__ngFactoryType__) {
1363
- return new (__ngFactoryType__ || HttpHandler)();
1364
- };
1365
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1366
- providedIn: 'root',
1367
- token: HttpHandler,
1368
- factory: function HttpHandler_Factory(__ngFactoryType__) {
1369
- let __ngConditionalFactory__ = null;
1370
- if (__ngFactoryType__) {
1371
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpHandler)();
1372
- } else {
1373
- __ngConditionalFactory__ = i0.ɵɵinject(HttpInterceptorHandler);
1374
- }
1375
- return __ngConditionalFactory__;
1376
- }
1377
- });
1378
- }
1379
- (() => {
1380
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpHandler, [{
1381
- args: [{
1382
- providedIn: 'root',
1383
- useExisting: HttpInterceptorHandler
1384
- }],
1385
- type: Injectable
1386
- }], null, null);
1387
- })();
1388
- function addBody(options, body) {
1389
- return {
1390
- body,
1391
- cache: options.cache,
1392
- context: options.context,
1393
- credentials: options.credentials,
1394
- headers: options.headers,
1395
- integrity: options.integrity,
1396
- keepalive: options.keepalive,
1397
- mode: options.mode,
1398
- observe: options.observe,
1399
- params: options.params,
1400
- priority: options.priority,
1401
- redirect: options.redirect,
1402
- referrer: options.referrer,
1403
- referrerPolicy: options.referrerPolicy,
1404
- reportProgress: options.reportProgress,
1405
- responseType: options.responseType,
1406
- timeout: options.timeout,
1407
- transferCache: options.transferCache,
1408
- withCredentials: options.withCredentials
1409
- };
1410
- }
1411
- class HttpClient {
1412
- handler;
1413
- constructor(handler) {
1414
- this.handler = handler;
1415
- }
1416
- request(first, url, options = {}) {
1417
- let req;
1418
- if (first instanceof HttpRequest) {
1419
- req = first;
1420
- } else {
1421
- let headers = undefined;
1422
- if (options.headers instanceof HttpHeaders) {
1423
- headers = options.headers;
1424
- } else {
1425
- headers = new HttpHeaders(options.headers);
1426
- }
1427
- let params = undefined;
1428
- if (options.params) {
1429
- if (options.params instanceof HttpParams) {
1430
- params = options.params;
1431
- } else {
1432
- params = new HttpParams({
1433
- fromObject: options.params
1434
- });
1435
- }
1436
- }
1437
- req = new HttpRequest(first, url, options.body !== undefined ? options.body : null, {
1438
- cache: options.cache,
1439
- context: options.context,
1440
- credentials: options.credentials,
1441
- headers,
1442
- integrity: options.integrity,
1443
- keepalive: options.keepalive,
1444
- mode: options.mode,
1445
- params,
1446
- priority: options.priority,
1447
- redirect: options.redirect,
1448
- referrer: options.referrer,
1449
- referrerPolicy: options.referrerPolicy,
1450
- reportProgress: options.reportProgress,
1451
- responseType: options.responseType || 'json',
1452
- timeout: options.timeout,
1453
- transferCache: options.transferCache,
1454
- withCredentials: options.withCredentials
1455
- });
1456
- }
1457
- const events$ = of(req).pipe(concatMap(req => this.handler.handle(req)));
1458
- if (first instanceof HttpRequest || options.observe === 'events') {
1459
- return events$;
1460
- }
1461
- const res$ = events$.pipe(filter(event => event instanceof HttpResponse));
1462
- switch (options.observe || 'body') {
1463
- case 'body':
1464
- switch (req.responseType) {
1465
- case 'arraybuffer':
1466
- return res$.pipe(map(res => {
1467
- if (res.body !== null && !(res.body instanceof ArrayBuffer)) {
1468
- throw new _RuntimeError(2806, ngDevMode && 'Response is not an ArrayBuffer.');
1469
- }
1470
- return res.body;
1471
- }));
1472
- case 'blob':
1473
- return res$.pipe(map(res => {
1474
- if (res.body !== null && !(res.body instanceof Blob)) {
1475
- throw new _RuntimeError(2807, ngDevMode && 'Response is not a Blob.');
1476
- }
1477
- return res.body;
1478
- }));
1479
- case 'text':
1480
- return res$.pipe(map(res => {
1481
- if (res.body !== null && typeof res.body !== 'string') {
1482
- throw new _RuntimeError(2808, ngDevMode && 'Response is not a string.');
1483
- }
1484
- return res.body;
1485
- }));
1486
- case 'json':
1487
- default:
1488
- return res$.pipe(map(res => res.body));
1489
- }
1490
- case 'response':
1491
- return res$;
1492
- default:
1493
- throw new _RuntimeError(2809, ngDevMode && `Unreachable: unhandled observe type ${options.observe}}`);
1494
- }
1495
- }
1496
- delete(url, options = {}) {
1497
- return this.request('DELETE', url, options);
1498
- }
1499
- get(url, options = {}) {
1500
- return this.request('GET', url, options);
1501
- }
1502
- head(url, options = {}) {
1503
- return this.request('HEAD', url, options);
1504
- }
1505
- jsonp(url, callbackParam) {
1506
- return this.request('JSONP', url, {
1507
- observe: 'body',
1508
- params: new HttpParams().append(callbackParam, 'JSONP_CALLBACK'),
1509
- responseType: 'json'
1510
- });
1511
- }
1512
- options(url, options = {}) {
1513
- return this.request('OPTIONS', url, options);
1514
- }
1515
- patch(url, body, options = {}) {
1516
- return this.request('PATCH', url, addBody(options, body));
1517
- }
1518
- post(url, body, options = {}) {
1519
- return this.request('POST', url, addBody(options, body));
1520
- }
1521
- put(url, body, options = {}) {
1522
- return this.request('PUT', url, addBody(options, body));
1523
- }
1524
- static ɵfac = function HttpClient_Factory(__ngFactoryType__) {
1525
- return new (__ngFactoryType__ || HttpClient)(i0.ɵɵinject(HttpHandler));
1526
- };
1527
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1528
- factory: HttpClient.ɵfac,
1529
- providedIn: 'root',
1530
- token: HttpClient
1531
- });
1532
- }
1533
- (() => {
1534
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpClient, [{
1535
- args: [{
1536
- providedIn: 'root'
1537
- }],
1538
- type: Injectable
1539
- }], () => [{
1540
- type: HttpHandler
1541
- }], null);
1542
- })();
1543
- let nextRequestId = 0;
1544
- let foreignDocument;
1545
- const JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
1546
- const JSONP_ERR_WRONG_METHOD = 'JSONP requests must use JSONP request method.';
1547
- const JSONP_ERR_WRONG_RESPONSE_TYPE = 'JSONP requests must use Json response type.';
1548
- const JSONP_ERR_HEADERS_NOT_SUPPORTED = 'JSONP requests do not support headers.';
1549
- class JsonpCallbackContext {}
1550
- function jsonpCallbackContext() {
1551
- if (typeof window === 'object') {
1552
- return window;
1553
- }
1554
- return {};
1555
- }
1556
- class JsonpClientBackend {
1557
- callbackMap;
1558
- document;
1559
- resolvedPromise = Promise.resolve();
1560
- constructor(callbackMap, document) {
1561
- this.callbackMap = callbackMap;
1562
- this.document = document;
1563
- }
1564
- nextCallback() {
1565
- return `ng_jsonp_callback_${nextRequestId++}`;
1566
- }
1567
- handle(req) {
1568
- if (req.method !== 'JSONP') {
1569
- throw new _RuntimeError(2810, ngDevMode && JSONP_ERR_WRONG_METHOD);
1570
- } else if (req.responseType !== 'json') {
1571
- throw new _RuntimeError(2811, ngDevMode && JSONP_ERR_WRONG_RESPONSE_TYPE);
1572
- }
1573
- if (req.headers.keys().length > 0) {
1574
- throw new _RuntimeError(2812, ngDevMode && JSONP_ERR_HEADERS_NOT_SUPPORTED);
1575
- }
1576
- return new Observable(observer => {
1577
- const callback = this.nextCallback();
1578
- const url = req.urlWithParams.replace(/=JSONP_CALLBACK(&|$)/, `=${callback}$1`);
1579
- const node = this.document.createElement('script');
1580
- node.src = url;
1581
- let body = null;
1582
- let finished = false;
1583
- this.callbackMap[callback] = data => {
1584
- delete this.callbackMap[callback];
1585
- body = data;
1586
- finished = true;
1587
- };
1588
- const cleanup = () => {
1589
- node.removeEventListener('load', onLoad);
1590
- node.removeEventListener('error', onError);
1591
- node.remove();
1592
- delete this.callbackMap[callback];
1593
- };
1594
- const onLoad = () => {
1595
- this.resolvedPromise.then(() => {
1596
- cleanup();
1597
- if (!finished) {
1598
- observer.error(new HttpErrorResponse({
1599
- error: new Error(JSONP_ERR_NO_CALLBACK),
1600
- status: 0,
1601
- statusText: 'JSONP Error',
1602
- url
1603
- }));
1604
- return;
1605
- }
1606
- observer.next(new HttpResponse({
1607
- body,
1608
- status: HTTP_STATUS_CODE_OK,
1609
- statusText: 'OK',
1610
- url
1611
- }));
1612
- observer.complete();
1613
- });
1614
- };
1615
- const onError = error => {
1616
- cleanup();
1617
- observer.error(new HttpErrorResponse({
1618
- error,
1619
- status: 0,
1620
- statusText: 'JSONP Error',
1621
- url
1622
- }));
1623
- };
1624
- node.addEventListener('load', onLoad);
1625
- node.addEventListener('error', onError);
1626
- this.document.body.appendChild(node);
1627
- observer.next({
1628
- type: HttpEventType.Sent
1629
- });
1630
- return () => {
1631
- if (!finished) {
1632
- this.removeListeners(node);
1633
- }
1634
- cleanup();
1635
- };
1636
- });
1637
- }
1638
- removeListeners(script) {
1639
- foreignDocument ??= this.document.implementation.createHTMLDocument();
1640
- foreignDocument.adoptNode(script);
1641
- }
1642
- static ɵfac = function JsonpClientBackend_Factory(__ngFactoryType__) {
1643
- return new (__ngFactoryType__ || JsonpClientBackend)(i0.ɵɵinject(JsonpCallbackContext), i0.ɵɵinject(DOCUMENT));
1644
- };
1645
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1646
- factory: JsonpClientBackend.ɵfac,
1647
- token: JsonpClientBackend
1648
- });
1649
- }
1650
- (() => {
1651
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(JsonpClientBackend, [{
1652
- type: Injectable
1653
- }], () => [{
1654
- type: JsonpCallbackContext
1655
- }, {
1656
- decorators: [{
1657
- args: [DOCUMENT],
1658
- type: Inject
1659
- }],
1660
- type: undefined
1661
- }], null);
1662
- })();
1663
- function jsonpInterceptorFn(req, next) {
1664
- if (req.method === 'JSONP') {
1665
- return inject(JsonpClientBackend).handle(req);
1666
- }
1667
- return next(req);
1668
- }
1669
- class JsonpInterceptor {
1670
- injector;
1671
- constructor(injector) {
1672
- this.injector = injector;
1673
- }
1674
- intercept(initialRequest, next) {
1675
- return runInInjectionContext(this.injector, () => jsonpInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
1676
- }
1677
- static ɵfac = function JsonpInterceptor_Factory(__ngFactoryType__) {
1678
- return new (__ngFactoryType__ || JsonpInterceptor)(i0.ɵɵinject(i0.EnvironmentInjector));
1679
- };
1680
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1681
- factory: JsonpInterceptor.ɵfac,
1682
- token: JsonpInterceptor
1683
- });
1684
- }
1685
- (() => {
1686
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(JsonpInterceptor, [{
1687
- type: Injectable
1688
- }], () => [{
1689
- type: i0.EnvironmentInjector
1690
- }], null);
1691
- })();
1692
- const XSRF_ENABLED = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'XSRF_ENABLED' : '', {
1693
- factory: () => true
1694
- });
1695
- const XSRF_DEFAULT_COOKIE_NAME = 'XSRF-TOKEN';
1696
- const XSRF_COOKIE_NAME = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'XSRF_COOKIE_NAME' : '', {
1697
- factory: () => XSRF_DEFAULT_COOKIE_NAME
1698
- });
1699
- const XSRF_DEFAULT_HEADER_NAME = 'X-XSRF-TOKEN';
1700
- const XSRF_HEADER_NAME = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'XSRF_HEADER_NAME' : '', {
1701
- factory: () => XSRF_DEFAULT_HEADER_NAME
1702
- });
1703
- class HttpXsrfCookieExtractor {
1704
- cookieName = inject(XSRF_COOKIE_NAME);
1705
- doc = inject(DOCUMENT);
1706
- lastCookieString = '';
1707
- lastToken = null;
1708
- parseCount = 0;
1709
- getToken() {
1710
- if (typeof ngServerMode !== 'undefined' && ngServerMode) {
1711
- return null;
1712
- }
1713
- const cookieString = this.doc.cookie || '';
1714
- if (cookieString !== this.lastCookieString) {
1715
- this.parseCount++;
1716
- this.lastToken = parseCookieValue(cookieString, this.cookieName);
1717
- this.lastCookieString = cookieString;
1718
- }
1719
- return this.lastToken;
1720
- }
1721
- static ɵfac = function HttpXsrfCookieExtractor_Factory(__ngFactoryType__) {
1722
- return new (__ngFactoryType__ || HttpXsrfCookieExtractor)();
1723
- };
1724
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1725
- factory: HttpXsrfCookieExtractor.ɵfac,
1726
- providedIn: 'root',
1727
- token: HttpXsrfCookieExtractor
1728
- });
1729
- }
1730
- (() => {
1731
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpXsrfCookieExtractor, [{
1732
- args: [{
1733
- providedIn: 'root'
1734
- }],
1735
- type: Injectable
1736
- }], null, null);
1737
- })();
1738
- class HttpXsrfTokenExtractor {
1739
- static ɵfac = function HttpXsrfTokenExtractor_Factory(__ngFactoryType__) {
1740
- return new (__ngFactoryType__ || HttpXsrfTokenExtractor)();
1741
- };
1742
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1743
- providedIn: 'root',
1744
- token: HttpXsrfTokenExtractor,
1745
- factory: function HttpXsrfTokenExtractor_Factory(__ngFactoryType__) {
1746
- let __ngConditionalFactory__ = null;
1747
- if (__ngFactoryType__) {
1748
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpXsrfTokenExtractor)();
1749
- } else {
1750
- __ngConditionalFactory__ = i0.ɵɵinject(HttpXsrfCookieExtractor);
1751
- }
1752
- return __ngConditionalFactory__;
1753
- }
1754
- });
1755
- }
1756
- (() => {
1757
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpXsrfTokenExtractor, [{
1758
- args: [{
1759
- providedIn: 'root',
1760
- useExisting: HttpXsrfCookieExtractor
1761
- }],
1762
- type: Injectable
1763
- }], null, null);
1764
- })();
1765
- function xsrfInterceptorFn(req, next) {
1766
- if (!inject(XSRF_ENABLED) || req.method === 'GET' || req.method === 'HEAD') {
1767
- return next(req);
1768
- }
1769
- try {
1770
- const locationHref = inject(PlatformLocation).href;
1771
- const {
1772
- origin: locationOrigin
1773
- } = new URL(locationHref);
1774
- const {
1775
- origin: requestOrigin
1776
- } = new URL(req.url, locationOrigin);
1777
- if (locationOrigin !== requestOrigin) {
1778
- return next(req);
1779
- }
1780
- } catch {
1781
- return next(req);
1782
- }
1783
- const token = inject(HttpXsrfTokenExtractor).getToken();
1784
- const headerName = inject(XSRF_HEADER_NAME);
1785
- if (token != null && !req.headers.has(headerName)) {
1786
- req = req.clone({
1787
- headers: req.headers.set(headerName, token)
1788
- });
1789
- }
1790
- return next(req);
1791
- }
1792
- class HttpXsrfInterceptor {
1793
- injector = inject(EnvironmentInjector);
1794
- intercept(initialRequest, next) {
1795
- return runInInjectionContext(this.injector, () => xsrfInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
1796
- }
1797
- static ɵfac = function HttpXsrfInterceptor_Factory(__ngFactoryType__) {
1798
- return new (__ngFactoryType__ || HttpXsrfInterceptor)();
1799
- };
1800
- static ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({
1801
- factory: HttpXsrfInterceptor.ɵfac,
1802
- token: HttpXsrfInterceptor
1803
- });
1804
- }
1805
- (() => {
1806
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpXsrfInterceptor, [{
1807
- type: Injectable
1808
- }], null, null);
1809
- })();
1810
- let HttpFeatureKind;
1811
- (function (HttpFeatureKind) {
1812
- HttpFeatureKind[HttpFeatureKind["Interceptors"] = 0] = "Interceptors";
1813
- HttpFeatureKind[HttpFeatureKind["LegacyInterceptors"] = 1] = "LegacyInterceptors";
1814
- HttpFeatureKind[HttpFeatureKind["CustomXsrfConfiguration"] = 2] = "CustomXsrfConfiguration";
1815
- HttpFeatureKind[HttpFeatureKind["NoXsrfProtection"] = 3] = "NoXsrfProtection";
1816
- HttpFeatureKind[HttpFeatureKind["JsonpSupport"] = 4] = "JsonpSupport";
1817
- HttpFeatureKind[HttpFeatureKind["RequestsMadeViaParent"] = 5] = "RequestsMadeViaParent";
1818
- HttpFeatureKind[HttpFeatureKind["Fetch"] = 6] = "Fetch";
1819
- })(HttpFeatureKind || (HttpFeatureKind = {}));
1820
- function makeHttpFeature(kind, providers) {
1821
- return {
1822
- ɵkind: kind,
1823
- ɵproviders: providers
1824
- };
1825
- }
1826
- function provideHttpClient(...features) {
1827
- if (ngDevMode) {
1828
- const featureKinds = new Set(features.map(f => f.ɵkind));
1829
- if (featureKinds.has(HttpFeatureKind.NoXsrfProtection) && featureKinds.has(HttpFeatureKind.CustomXsrfConfiguration)) {
1830
- throw new Error(ngDevMode ? `Configuration error: found both withXsrfConfiguration() and withNoXsrfProtection() in the same call to provideHttpClient(), which is a contradiction.` : '');
1831
- }
1832
- }
1833
- const providers = [HttpClient, HttpInterceptorHandler, {
1834
- provide: HttpHandler,
1835
- useExisting: HttpInterceptorHandler
1836
- }, {
1837
- provide: HttpBackend,
1838
- useFactory: () => inject(FETCH_BACKEND, {
1839
- optional: true
1840
- }) ?? inject(HttpXhrBackend)
1841
- }, {
1842
- multi: true,
1843
- provide: HTTP_INTERCEPTOR_FNS,
1844
- useValue: xsrfInterceptorFn
1845
- }];
1846
- for (const feature of features) {
1847
- providers.push(...feature.ɵproviders);
1848
- }
1849
- return makeEnvironmentProviders(providers);
1850
- }
1851
- function withInterceptors(interceptorFns) {
1852
- return makeHttpFeature(HttpFeatureKind.Interceptors, interceptorFns.map(interceptorFn => ({
1853
- multi: true,
1854
- provide: HTTP_INTERCEPTOR_FNS,
1855
- useValue: interceptorFn
1856
- })));
1857
- }
1858
- const LEGACY_INTERCEPTOR_FN = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'LEGACY_INTERCEPTOR_FN' : '');
1859
- function withInterceptorsFromDi() {
1860
- return makeHttpFeature(HttpFeatureKind.LegacyInterceptors, [{
1861
- provide: LEGACY_INTERCEPTOR_FN,
1862
- useFactory: legacyInterceptorFnFactory
1863
- }, {
1864
- multi: true,
1865
- provide: HTTP_INTERCEPTOR_FNS,
1866
- useExisting: LEGACY_INTERCEPTOR_FN
1867
- }]);
1868
- }
1869
- function withXsrfConfiguration({
1870
- cookieName,
1871
- headerName
1872
- }) {
1873
- const providers = [];
1874
- if (cookieName !== undefined) {
1875
- providers.push({
1876
- provide: XSRF_COOKIE_NAME,
1877
- useValue: cookieName
1878
- });
1879
- }
1880
- if (headerName !== undefined) {
1881
- providers.push({
1882
- provide: XSRF_HEADER_NAME,
1883
- useValue: headerName
1884
- });
1885
- }
1886
- return makeHttpFeature(HttpFeatureKind.CustomXsrfConfiguration, providers);
1887
- }
1888
- function withNoXsrfProtection() {
1889
- return makeHttpFeature(HttpFeatureKind.NoXsrfProtection, [{
1890
- provide: XSRF_ENABLED,
1891
- useValue: false
1892
- }]);
1893
- }
1894
- function withJsonpSupport() {
1895
- return makeHttpFeature(HttpFeatureKind.JsonpSupport, [JsonpClientBackend, {
1896
- provide: JsonpCallbackContext,
1897
- useFactory: jsonpCallbackContext
1898
- }, {
1899
- multi: true,
1900
- provide: HTTP_INTERCEPTOR_FNS,
1901
- useValue: jsonpInterceptorFn
1902
- }]);
1903
- }
1904
- function withRequestsMadeViaParent() {
1905
- return makeHttpFeature(HttpFeatureKind.RequestsMadeViaParent, [{
1906
- provide: HttpBackend,
1907
- useFactory: () => {
1908
- const handlerFromParent = inject(HttpHandler, {
1909
- optional: true,
1910
- skipSelf: true
1911
- });
1912
- if (ngDevMode && handlerFromParent === null) {
1913
- throw new Error('withRequestsMadeViaParent() can only be used when the parent injector also configures HttpClient');
1914
- }
1915
- return handlerFromParent;
1916
- }
1917
- }]);
1918
- }
1919
- function withFetch() {
1920
- return makeHttpFeature(HttpFeatureKind.Fetch, [FetchBackend, {
1921
- provide: FETCH_BACKEND,
1922
- useExisting: FetchBackend
1923
- }, {
1924
- provide: HttpBackend,
1925
- useExisting: FetchBackend
1926
- }]);
1927
- }
1928
- class HttpClientXsrfModule {
1929
- static disable() {
1930
- return {
1931
- ngModule: HttpClientXsrfModule,
1932
- providers: [withNoXsrfProtection().ɵproviders]
1933
- };
1934
- }
1935
- static withOptions(options = {}) {
1936
- return {
1937
- ngModule: HttpClientXsrfModule,
1938
- providers: withXsrfConfiguration(options).ɵproviders
1939
- };
1940
- }
1941
- static ɵfac = function HttpClientXsrfModule_Factory(__ngFactoryType__) {
1942
- return new (__ngFactoryType__ || HttpClientXsrfModule)();
1943
- };
1944
- static ɵmod = /* @__PURE__ */i0.ɵɵdefineNgModule({
1945
- type: HttpClientXsrfModule
1946
- });
1947
- static ɵinj = /* @__PURE__ */i0.ɵɵdefineInjector({
1948
- providers: [HttpXsrfInterceptor, {
1949
- multi: true,
1950
- provide: HTTP_INTERCEPTORS,
1951
- useExisting: HttpXsrfInterceptor
1952
- }, {
1953
- provide: HttpXsrfTokenExtractor,
1954
- useClass: HttpXsrfCookieExtractor
1955
- }, withXsrfConfiguration({
1956
- cookieName: XSRF_DEFAULT_COOKIE_NAME,
1957
- headerName: XSRF_DEFAULT_HEADER_NAME
1958
- }).ɵproviders, {
1959
- provide: XSRF_ENABLED,
1960
- useValue: true
1961
- }]
1962
- });
1963
- }
1964
- (() => {
1965
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpClientXsrfModule, [{
1966
- args: [{
1967
- providers: [HttpXsrfInterceptor, {
1968
- multi: true,
1969
- provide: HTTP_INTERCEPTORS,
1970
- useExisting: HttpXsrfInterceptor
1971
- }, {
1972
- provide: HttpXsrfTokenExtractor,
1973
- useClass: HttpXsrfCookieExtractor
1974
- }, withXsrfConfiguration({
1975
- cookieName: XSRF_DEFAULT_COOKIE_NAME,
1976
- headerName: XSRF_DEFAULT_HEADER_NAME
1977
- }).ɵproviders, {
1978
- provide: XSRF_ENABLED,
1979
- useValue: true
1980
- }]
1981
- }],
1982
- type: NgModule
1983
- }], null, null);
1984
- })();
1985
- class HttpClientModule {
1986
- static ɵfac = function HttpClientModule_Factory(__ngFactoryType__) {
1987
- return new (__ngFactoryType__ || HttpClientModule)();
1988
- };
1989
- static ɵmod = /* @__PURE__ */i0.ɵɵdefineNgModule({
1990
- type: HttpClientModule
1991
- });
1992
- static ɵinj = /* @__PURE__ */i0.ɵɵdefineInjector({
1993
- providers: [provideHttpClient(withInterceptorsFromDi())]
1994
- });
1995
- }
1996
- (() => {
1997
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpClientModule, [{
1998
- args: [{
1999
- providers: [provideHttpClient(withInterceptorsFromDi())]
2000
- }],
2001
- type: NgModule
2002
- }], null, null);
2003
- })();
2004
- class HttpClientJsonpModule {
2005
- static ɵfac = function HttpClientJsonpModule_Factory(__ngFactoryType__) {
2006
- return new (__ngFactoryType__ || HttpClientJsonpModule)();
2007
- };
2008
- static ɵmod = /* @__PURE__ */i0.ɵɵdefineNgModule({
2009
- type: HttpClientJsonpModule
2010
- });
2011
- static ɵinj = /* @__PURE__ */i0.ɵɵdefineInjector({
2012
- providers: [withJsonpSupport().ɵproviders]
2013
- });
2014
- }
2015
- (() => {
2016
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HttpClientJsonpModule, [{
2017
- args: [{
2018
- providers: [withJsonpSupport().ɵproviders]
2019
- }],
2020
- type: NgModule
2021
- }], null, null);
2022
- })();
2023
- export { FetchBackend, HTTP_INTERCEPTORS, HTTP_ROOT_INTERCEPTOR_FNS, HttpBackend, HttpClient, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContext, HttpContextToken, HttpErrorResponse, HttpEventType, HttpFeatureKind, HttpHandler, HttpHeaderResponse, HttpHeaders, HttpInterceptorHandler, HttpParams, HttpRequest, HttpResponse, HttpResponseBase, HttpStatusCode, HttpUrlEncodingCodec, HttpXhrBackend, HttpXsrfTokenExtractor, JsonpClientBackend, JsonpInterceptor, REQUESTS_CONTRIBUTE_TO_STABILITY, provideHttpClient, withFetch, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration };