@angular_platform-browser.js 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453
  1. import {
  2. CommonModule,
  3. DOCUMENT,
  4. DomAdapter,
  5. PLATFORM_BROWSER_ID,
  6. XhrFactory,
  7. getDOM,
  8. isPlatformServer,
  9. parseCookieValue,
  10. setRootDomAdapter
  11. } from "./chunk-GPQCL3UH.js";
  12. import {
  13. APP_BOOTSTRAP_LISTENER,
  14. APP_ID,
  15. ApplicationModule,
  16. ApplicationRef,
  17. CSP_NONCE,
  18. Console,
  19. ENVIRONMENT_INITIALIZER,
  20. EnvironmentInjector,
  21. ErrorHandler,
  22. INJECTOR_SCOPE,
  23. Inject,
  24. Injectable,
  25. InjectionToken,
  26. Injector,
  27. NgModule,
  28. NgZone,
  29. Observable,
  30. Optional,
  31. PLATFORM_ID,
  32. PLATFORM_INITIALIZER,
  33. PendingTasksInternal,
  34. RendererFactory2,
  35. RendererStyleFlags2,
  36. ResourceImpl,
  37. ResourceStatus,
  38. RuntimeError,
  39. SecurityContext,
  40. TESTABILITY,
  41. TESTABILITY_GETTER,
  42. Testability,
  43. TestabilityRegistry,
  44. TracingService,
  45. TransferState,
  46. Version,
  47. ViewEncapsulation,
  48. XSS_SECURITY_URL,
  49. ZONELESS_ENABLED,
  50. __async,
  51. __objRest,
  52. __spreadProps,
  53. __spreadValues,
  54. _global,
  55. _sanitizeHtml,
  56. _sanitizeUrl,
  57. allowSanitizationBypassAndThrow,
  58. assertInInjectionContext,
  59. bypassSanitizationTrustHtml,
  60. bypassSanitizationTrustResourceUrl,
  61. bypassSanitizationTrustScript,
  62. bypassSanitizationTrustStyle,
  63. bypassSanitizationTrustUrl,
  64. computed,
  65. concatMap,
  66. createPlatformFactory,
  67. filter,
  68. finalize,
  69. formatRuntimeError,
  70. forwardRef,
  71. from,
  72. inject,
  73. internalCreateApplication,
  74. linkedSignal,
  75. makeEnvironmentProviders,
  76. makeStateKey,
  77. map,
  78. of,
  79. performanceMarkFeature,
  80. platformCore,
  81. runInInjectionContext,
  82. setClassMetadata,
  83. setDocument,
  84. signal,
  85. switchMap,
  86. tap,
  87. truncateMiddle,
  88. unwrapSafeValue,
  89. withDomHydration,
  90. withEventReplay,
  91. withI18nSupport,
  92. withIncrementalHydration,
  93. ɵɵdefineInjectable,
  94. ɵɵdefineInjector,
  95. ɵɵdefineNgModule,
  96. ɵɵinject
  97. } from "./chunk-3XPRMCCN.js";
  98. // node_modules/@angular/common/fesm2022/http.mjs
  99. var HttpHandler = class {
  100. };
  101. var HttpBackend = class {
  102. };
  103. var HttpHeaders = class _HttpHeaders {
  104. /**
  105. * Internal map of lowercase header names to values.
  106. */
  107. // TODO(issue/24571): remove '!'.
  108. headers;
  109. /**
  110. * Internal map of lowercased header names to the normalized
  111. * form of the name (the form seen first).
  112. */
  113. normalizedNames = /* @__PURE__ */ new Map();
  114. /**
  115. * Complete the lazy initialization of this object (needed before reading).
  116. */
  117. lazyInit;
  118. /**
  119. * Queued updates to be materialized the next initialization.
  120. */
  121. lazyUpdate = null;
  122. /** Constructs a new HTTP header object with the given values.*/
  123. constructor(headers) {
  124. if (!headers) {
  125. this.headers = /* @__PURE__ */ new Map();
  126. } else if (typeof headers === "string") {
  127. this.lazyInit = () => {
  128. this.headers = /* @__PURE__ */ new Map();
  129. headers.split("\n").forEach((line) => {
  130. const index = line.indexOf(":");
  131. if (index > 0) {
  132. const name = line.slice(0, index);
  133. const value = line.slice(index + 1).trim();
  134. this.addHeaderEntry(name, value);
  135. }
  136. });
  137. };
  138. } else if (typeof Headers !== "undefined" && headers instanceof Headers) {
  139. this.headers = /* @__PURE__ */ new Map();
  140. headers.forEach((value, name) => {
  141. this.addHeaderEntry(name, value);
  142. });
  143. } else {
  144. this.lazyInit = () => {
  145. if (typeof ngDevMode === "undefined" || ngDevMode) {
  146. assertValidHeaders(headers);
  147. }
  148. this.headers = /* @__PURE__ */ new Map();
  149. Object.entries(headers).forEach(([name, values]) => {
  150. this.setHeaderEntries(name, values);
  151. });
  152. };
  153. }
  154. }
  155. /**
  156. * Checks for existence of a given header.
  157. *
  158. * @param name The header name to check for existence.
  159. *
  160. * @returns True if the header exists, false otherwise.
  161. */
  162. has(name) {
  163. this.init();
  164. return this.headers.has(name.toLowerCase());
  165. }
  166. /**
  167. * Retrieves the first value of a given header.
  168. *
  169. * @param name The header name.
  170. *
  171. * @returns The value string if the header exists, null otherwise
  172. */
  173. get(name) {
  174. this.init();
  175. const values = this.headers.get(name.toLowerCase());
  176. return values && values.length > 0 ? values[0] : null;
  177. }
  178. /**
  179. * Retrieves the names of the headers.
  180. *
  181. * @returns A list of header names.
  182. */
  183. keys() {
  184. this.init();
  185. return Array.from(this.normalizedNames.values());
  186. }
  187. /**
  188. * Retrieves a list of values for a given header.
  189. *
  190. * @param name The header name from which to retrieve values.
  191. *
  192. * @returns A string of values if the header exists, null otherwise.
  193. */
  194. getAll(name) {
  195. this.init();
  196. return this.headers.get(name.toLowerCase()) || null;
  197. }
  198. /**
  199. * Appends a new value to the existing set of values for a header
  200. * and returns them in a clone of the original instance.
  201. *
  202. * @param name The header name for which to append the values.
  203. * @param value The value to append.
  204. *
  205. * @returns A clone of the HTTP headers object with the value appended to the given header.
  206. */
  207. append(name, value) {
  208. return this.clone({
  209. name,
  210. value,
  211. op: "a"
  212. });
  213. }
  214. /**
  215. * Sets or modifies a value for a given header in a clone of the original instance.
  216. * If the header already exists, its value is replaced with the given value
  217. * in the returned object.
  218. *
  219. * @param name The header name.
  220. * @param value The value or values to set or override for the given header.
  221. *
  222. * @returns A clone of the HTTP headers object with the newly set header value.
  223. */
  224. set(name, value) {
  225. return this.clone({
  226. name,
  227. value,
  228. op: "s"
  229. });
  230. }
  231. /**
  232. * Deletes values for a given header in a clone of the original instance.
  233. *
  234. * @param name The header name.
  235. * @param value The value or values to delete for the given header.
  236. *
  237. * @returns A clone of the HTTP headers object with the given value deleted.
  238. */
  239. delete(name, value) {
  240. return this.clone({
  241. name,
  242. value,
  243. op: "d"
  244. });
  245. }
  246. maybeSetNormalizedName(name, lcName) {
  247. if (!this.normalizedNames.has(lcName)) {
  248. this.normalizedNames.set(lcName, name);
  249. }
  250. }
  251. init() {
  252. if (!!this.lazyInit) {
  253. if (this.lazyInit instanceof _HttpHeaders) {
  254. this.copyFrom(this.lazyInit);
  255. } else {
  256. this.lazyInit();
  257. }
  258. this.lazyInit = null;
  259. if (!!this.lazyUpdate) {
  260. this.lazyUpdate.forEach((update) => this.applyUpdate(update));
  261. this.lazyUpdate = null;
  262. }
  263. }
  264. }
  265. copyFrom(other) {
  266. other.init();
  267. Array.from(other.headers.keys()).forEach((key) => {
  268. this.headers.set(key, other.headers.get(key));
  269. this.normalizedNames.set(key, other.normalizedNames.get(key));
  270. });
  271. }
  272. clone(update) {
  273. const clone = new _HttpHeaders();
  274. clone.lazyInit = !!this.lazyInit && this.lazyInit instanceof _HttpHeaders ? this.lazyInit : this;
  275. clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);
  276. return clone;
  277. }
  278. applyUpdate(update) {
  279. const key = update.name.toLowerCase();
  280. switch (update.op) {
  281. case "a":
  282. case "s":
  283. let value = update.value;
  284. if (typeof value === "string") {
  285. value = [value];
  286. }
  287. if (value.length === 0) {
  288. return;
  289. }
  290. this.maybeSetNormalizedName(update.name, key);
  291. const base = (update.op === "a" ? this.headers.get(key) : void 0) || [];
  292. base.push(...value);
  293. this.headers.set(key, base);
  294. break;
  295. case "d":
  296. const toDelete = update.value;
  297. if (!toDelete) {
  298. this.headers.delete(key);
  299. this.normalizedNames.delete(key);
  300. } else {
  301. let existing = this.headers.get(key);
  302. if (!existing) {
  303. return;
  304. }
  305. existing = existing.filter((value2) => toDelete.indexOf(value2) === -1);
  306. if (existing.length === 0) {
  307. this.headers.delete(key);
  308. this.normalizedNames.delete(key);
  309. } else {
  310. this.headers.set(key, existing);
  311. }
  312. }
  313. break;
  314. }
  315. }
  316. addHeaderEntry(name, value) {
  317. const key = name.toLowerCase();
  318. this.maybeSetNormalizedName(name, key);
  319. if (this.headers.has(key)) {
  320. this.headers.get(key).push(value);
  321. } else {
  322. this.headers.set(key, [value]);
  323. }
  324. }
  325. setHeaderEntries(name, values) {
  326. const headerValues = (Array.isArray(values) ? values : [values]).map((value) => value.toString());
  327. const key = name.toLowerCase();
  328. this.headers.set(key, headerValues);
  329. this.maybeSetNormalizedName(name, key);
  330. }
  331. /**
  332. * @internal
  333. */
  334. forEach(fn) {
  335. this.init();
  336. Array.from(this.normalizedNames.keys()).forEach((key) => fn(this.normalizedNames.get(key), this.headers.get(key)));
  337. }
  338. };
  339. function assertValidHeaders(headers) {
  340. for (const [key, value] of Object.entries(headers)) {
  341. if (!(typeof value === "string" || typeof value === "number") && !Array.isArray(value)) {
  342. throw new Error(`Unexpected value of the \`${key}\` header provided. Expecting either a string, a number or an array, but got: \`${value}\`.`);
  343. }
  344. }
  345. }
  346. var HttpUrlEncodingCodec = class {
  347. /**
  348. * Encodes a key name for a URL parameter or query-string.
  349. * @param key The key name.
  350. * @returns The encoded key name.
  351. */
  352. encodeKey(key) {
  353. return standardEncoding(key);
  354. }
  355. /**
  356. * Encodes the value of a URL parameter or query-string.
  357. * @param value The value.
  358. * @returns The encoded value.
  359. */
  360. encodeValue(value) {
  361. return standardEncoding(value);
  362. }
  363. /**
  364. * Decodes an encoded URL parameter or query-string key.
  365. * @param key The encoded key name.
  366. * @returns The decoded key name.
  367. */
  368. decodeKey(key) {
  369. return decodeURIComponent(key);
  370. }
  371. /**
  372. * Decodes an encoded URL parameter or query-string value.
  373. * @param value The encoded value.
  374. * @returns The decoded value.
  375. */
  376. decodeValue(value) {
  377. return decodeURIComponent(value);
  378. }
  379. };
  380. function paramParser(rawParams, codec) {
  381. const map2 = /* @__PURE__ */ new Map();
  382. if (rawParams.length > 0) {
  383. const params = rawParams.replace(/^\?/, "").split("&");
  384. params.forEach((param) => {
  385. const eqIdx = param.indexOf("=");
  386. const [key, val] = eqIdx == -1 ? [codec.decodeKey(param), ""] : [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];
  387. const list = map2.get(key) || [];
  388. list.push(val);
  389. map2.set(key, list);
  390. });
  391. }
  392. return map2;
  393. }
  394. var STANDARD_ENCODING_REGEX = /%(\d[a-f0-9])/gi;
  395. var STANDARD_ENCODING_REPLACEMENTS = {
  396. "40": "@",
  397. "3A": ":",
  398. "24": "$",
  399. "2C": ",",
  400. "3B": ";",
  401. "3D": "=",
  402. "3F": "?",
  403. "2F": "/"
  404. };
  405. function standardEncoding(v) {
  406. return encodeURIComponent(v).replace(STANDARD_ENCODING_REGEX, (s, t) => STANDARD_ENCODING_REPLACEMENTS[t] ?? s);
  407. }
  408. function valueToString(value) {
  409. return `${value}`;
  410. }
  411. var HttpParams = class _HttpParams {
  412. map;
  413. encoder;
  414. updates = null;
  415. cloneFrom = null;
  416. constructor(options = {}) {
  417. this.encoder = options.encoder || new HttpUrlEncodingCodec();
  418. if (options.fromString) {
  419. if (options.fromObject) {
  420. throw new RuntimeError(2805, ngDevMode && "Cannot specify both fromString and fromObject.");
  421. }
  422. this.map = paramParser(options.fromString, this.encoder);
  423. } else if (!!options.fromObject) {
  424. this.map = /* @__PURE__ */ new Map();
  425. Object.keys(options.fromObject).forEach((key) => {
  426. const value = options.fromObject[key];
  427. const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)];
  428. this.map.set(key, values);
  429. });
  430. } else {
  431. this.map = null;
  432. }
  433. }
  434. /**
  435. * Reports whether the body includes one or more values for a given parameter.
  436. * @param param The parameter name.
  437. * @returns True if the parameter has one or more values,
  438. * false if it has no value or is not present.
  439. */
  440. has(param) {
  441. this.init();
  442. return this.map.has(param);
  443. }
  444. /**
  445. * Retrieves the first value for a parameter.
  446. * @param param The parameter name.
  447. * @returns The first value of the given parameter,
  448. * or `null` if the parameter is not present.
  449. */
  450. get(param) {
  451. this.init();
  452. const res = this.map.get(param);
  453. return !!res ? res[0] : null;
  454. }
  455. /**
  456. * Retrieves all values for a parameter.
  457. * @param param The parameter name.
  458. * @returns All values in a string array,
  459. * or `null` if the parameter not present.
  460. */
  461. getAll(param) {
  462. this.init();
  463. return this.map.get(param) || null;
  464. }
  465. /**
  466. * Retrieves all the parameters for this body.
  467. * @returns The parameter names in a string array.
  468. */
  469. keys() {
  470. this.init();
  471. return Array.from(this.map.keys());
  472. }
  473. /**
  474. * Appends a new value to existing values for a parameter.
  475. * @param param The parameter name.
  476. * @param value The new value to add.
  477. * @return A new body with the appended value.
  478. */
  479. append(param, value) {
  480. return this.clone({
  481. param,
  482. value,
  483. op: "a"
  484. });
  485. }
  486. /**
  487. * Constructs a new body with appended values for the given parameter name.
  488. * @param params parameters and values
  489. * @return A new body with the new value.
  490. */
  491. appendAll(params) {
  492. const updates = [];
  493. Object.keys(params).forEach((param) => {
  494. const value = params[param];
  495. if (Array.isArray(value)) {
  496. value.forEach((_value) => {
  497. updates.push({
  498. param,
  499. value: _value,
  500. op: "a"
  501. });
  502. });
  503. } else {
  504. updates.push({
  505. param,
  506. value,
  507. op: "a"
  508. });
  509. }
  510. });
  511. return this.clone(updates);
  512. }
  513. /**
  514. * Replaces the value for a parameter.
  515. * @param param The parameter name.
  516. * @param value The new value.
  517. * @return A new body with the new value.
  518. */
  519. set(param, value) {
  520. return this.clone({
  521. param,
  522. value,
  523. op: "s"
  524. });
  525. }
  526. /**
  527. * Removes a given value or all values from a parameter.
  528. * @param param The parameter name.
  529. * @param value The value to remove, if provided.
  530. * @return A new body with the given value removed, or with all values
  531. * removed if no value is specified.
  532. */
  533. delete(param, value) {
  534. return this.clone({
  535. param,
  536. value,
  537. op: "d"
  538. });
  539. }
  540. /**
  541. * Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
  542. * separated by `&`s.
  543. */
  544. toString() {
  545. this.init();
  546. return this.keys().map((key) => {
  547. const eKey = this.encoder.encodeKey(key);
  548. return this.map.get(key).map((value) => eKey + "=" + this.encoder.encodeValue(value)).join("&");
  549. }).filter((param) => param !== "").join("&");
  550. }
  551. clone(update) {
  552. const clone = new _HttpParams({
  553. encoder: this.encoder
  554. });
  555. clone.cloneFrom = this.cloneFrom || this;
  556. clone.updates = (this.updates || []).concat(update);
  557. return clone;
  558. }
  559. init() {
  560. if (this.map === null) {
  561. this.map = /* @__PURE__ */ new Map();
  562. }
  563. if (this.cloneFrom !== null) {
  564. this.cloneFrom.init();
  565. this.cloneFrom.keys().forEach((key) => this.map.set(key, this.cloneFrom.map.get(key)));
  566. this.updates.forEach((update) => {
  567. switch (update.op) {
  568. case "a":
  569. case "s":
  570. const base = (update.op === "a" ? this.map.get(update.param) : void 0) || [];
  571. base.push(valueToString(update.value));
  572. this.map.set(update.param, base);
  573. break;
  574. case "d":
  575. if (update.value !== void 0) {
  576. let base2 = this.map.get(update.param) || [];
  577. const idx = base2.indexOf(valueToString(update.value));
  578. if (idx !== -1) {
  579. base2.splice(idx, 1);
  580. }
  581. if (base2.length > 0) {
  582. this.map.set(update.param, base2);
  583. } else {
  584. this.map.delete(update.param);
  585. }
  586. } else {
  587. this.map.delete(update.param);
  588. break;
  589. }
  590. }
  591. });
  592. this.cloneFrom = this.updates = null;
  593. }
  594. }
  595. };
  596. var HttpContext = class {
  597. map = /* @__PURE__ */ new Map();
  598. /**
  599. * Store a value in the context. If a value is already present it will be overwritten.
  600. *
  601. * @param token The reference to an instance of `HttpContextToken`.
  602. * @param value The value to store.
  603. *
  604. * @returns A reference to itself for easy chaining.
  605. */
  606. set(token, value) {
  607. this.map.set(token, value);
  608. return this;
  609. }
  610. /**
  611. * Retrieve the value associated with the given token.
  612. *
  613. * @param token The reference to an instance of `HttpContextToken`.
  614. *
  615. * @returns The stored value or default if one is defined.
  616. */
  617. get(token) {
  618. if (!this.map.has(token)) {
  619. this.map.set(token, token.defaultValue());
  620. }
  621. return this.map.get(token);
  622. }
  623. /**
  624. * Delete the value associated with the given token.
  625. *
  626. * @param token The reference to an instance of `HttpContextToken`.
  627. *
  628. * @returns A reference to itself for easy chaining.
  629. */
  630. delete(token) {
  631. this.map.delete(token);
  632. return this;
  633. }
  634. /**
  635. * Checks for existence of a given token.
  636. *
  637. * @param token The reference to an instance of `HttpContextToken`.
  638. *
  639. * @returns True if the token exists, false otherwise.
  640. */
  641. has(token) {
  642. return this.map.has(token);
  643. }
  644. /**
  645. * @returns a list of tokens currently stored in the context.
  646. */
  647. keys() {
  648. return this.map.keys();
  649. }
  650. };
  651. function mightHaveBody(method) {
  652. switch (method) {
  653. case "DELETE":
  654. case "GET":
  655. case "HEAD":
  656. case "OPTIONS":
  657. case "JSONP":
  658. return false;
  659. default:
  660. return true;
  661. }
  662. }
  663. function isArrayBuffer(value) {
  664. return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
  665. }
  666. function isBlob(value) {
  667. return typeof Blob !== "undefined" && value instanceof Blob;
  668. }
  669. function isFormData(value) {
  670. return typeof FormData !== "undefined" && value instanceof FormData;
  671. }
  672. function isUrlSearchParams(value) {
  673. return typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams;
  674. }
  675. var CONTENT_TYPE_HEADER = "Content-Type";
  676. var ACCEPT_HEADER = "Accept";
  677. var X_REQUEST_URL_HEADER = "X-Request-URL";
  678. var TEXT_CONTENT_TYPE = "text/plain";
  679. var JSON_CONTENT_TYPE = "application/json";
  680. var ACCEPT_HEADER_VALUE = `${JSON_CONTENT_TYPE}, ${TEXT_CONTENT_TYPE}, */*`;
  681. var HttpRequest = class _HttpRequest {
  682. url;
  683. /**
  684. * The request body, or `null` if one isn't set.
  685. *
  686. * Bodies are not enforced to be immutable, as they can include a reference to any
  687. * user-defined data type. However, interceptors should take care to preserve
  688. * idempotence by treating them as such.
  689. */
  690. body = null;
  691. /**
  692. * Outgoing headers for this request.
  693. */
  694. // TODO(issue/24571): remove '!'.
  695. headers;
  696. /**
  697. * Shared and mutable context that can be used by interceptors
  698. */
  699. context;
  700. /**
  701. * Whether this request should be made in a way that exposes progress events.
  702. *
  703. * Progress events are expensive (change detection runs on each event) and so
  704. * they should only be requested if the consumer intends to monitor them.
  705. *
  706. * Note: The `FetchBackend` doesn't support progress report on uploads.
  707. */
  708. reportProgress = false;
  709. /**
  710. * Whether this request should be sent with outgoing credentials (cookies).
  711. */
  712. withCredentials = false;
  713. /**
  714. * The expected response type of the server.
  715. *
  716. * This is used to parse the response appropriately before returning it to
  717. * the requestee.
  718. */
  719. responseType = "json";
  720. /**
  721. * The outgoing HTTP request method.
  722. */
  723. method;
  724. /**
  725. * Outgoing URL parameters.
  726. *
  727. * To pass a string representation of HTTP parameters in the URL-query-string format,
  728. * the `HttpParamsOptions`' `fromString` may be used. For example:
  729. *
  730. * ```ts
  731. * new HttpParams({fromString: 'angular=awesome'})
  732. * ```
  733. */
  734. // TODO(issue/24571): remove '!'.
  735. params;
  736. /**
  737. * The outgoing URL with all URL parameters set.
  738. */
  739. urlWithParams;
  740. /**
  741. * The HttpTransferCache option for the request
  742. */
  743. transferCache;
  744. constructor(method, url, third, fourth) {
  745. this.url = url;
  746. this.method = method.toUpperCase();
  747. let options;
  748. if (mightHaveBody(this.method) || !!fourth) {
  749. this.body = third !== void 0 ? third : null;
  750. options = fourth;
  751. } else {
  752. options = third;
  753. }
  754. if (options) {
  755. this.reportProgress = !!options.reportProgress;
  756. this.withCredentials = !!options.withCredentials;
  757. if (!!options.responseType) {
  758. this.responseType = options.responseType;
  759. }
  760. if (!!options.headers) {
  761. this.headers = options.headers;
  762. }
  763. if (!!options.context) {
  764. this.context = options.context;
  765. }
  766. if (!!options.params) {
  767. this.params = options.params;
  768. }
  769. this.transferCache = options.transferCache;
  770. }
  771. this.headers ??= new HttpHeaders();
  772. this.context ??= new HttpContext();
  773. if (!this.params) {
  774. this.params = new HttpParams();
  775. this.urlWithParams = url;
  776. } else {
  777. const params = this.params.toString();
  778. if (params.length === 0) {
  779. this.urlWithParams = url;
  780. } else {
  781. const qIdx = url.indexOf("?");
  782. const sep = qIdx === -1 ? "?" : qIdx < url.length - 1 ? "&" : "";
  783. this.urlWithParams = url + sep + params;
  784. }
  785. }
  786. }
  787. /**
  788. * Transform the free-form body into a serialized format suitable for
  789. * transmission to the server.
  790. */
  791. serializeBody() {
  792. if (this.body === null) {
  793. return null;
  794. }
  795. if (typeof this.body === "string" || isArrayBuffer(this.body) || isBlob(this.body) || isFormData(this.body) || isUrlSearchParams(this.body)) {
  796. return this.body;
  797. }
  798. if (this.body instanceof HttpParams) {
  799. return this.body.toString();
  800. }
  801. if (typeof this.body === "object" || typeof this.body === "boolean" || Array.isArray(this.body)) {
  802. return JSON.stringify(this.body);
  803. }
  804. return this.body.toString();
  805. }
  806. /**
  807. * Examine the body and attempt to infer an appropriate MIME type
  808. * for it.
  809. *
  810. * If no such type can be inferred, this method will return `null`.
  811. */
  812. detectContentTypeHeader() {
  813. if (this.body === null) {
  814. return null;
  815. }
  816. if (isFormData(this.body)) {
  817. return null;
  818. }
  819. if (isBlob(this.body)) {
  820. return this.body.type || null;
  821. }
  822. if (isArrayBuffer(this.body)) {
  823. return null;
  824. }
  825. if (typeof this.body === "string") {
  826. return TEXT_CONTENT_TYPE;
  827. }
  828. if (this.body instanceof HttpParams) {
  829. return "application/x-www-form-urlencoded;charset=UTF-8";
  830. }
  831. if (typeof this.body === "object" || typeof this.body === "number" || typeof this.body === "boolean") {
  832. return JSON_CONTENT_TYPE;
  833. }
  834. return null;
  835. }
  836. clone(update = {}) {
  837. const method = update.method || this.method;
  838. const url = update.url || this.url;
  839. const responseType = update.responseType || this.responseType;
  840. const transferCache = update.transferCache ?? this.transferCache;
  841. const body = update.body !== void 0 ? update.body : this.body;
  842. const withCredentials = update.withCredentials ?? this.withCredentials;
  843. const reportProgress = update.reportProgress ?? this.reportProgress;
  844. let headers = update.headers || this.headers;
  845. let params = update.params || this.params;
  846. const context = update.context ?? this.context;
  847. if (update.setHeaders !== void 0) {
  848. headers = Object.keys(update.setHeaders).reduce((headers2, name) => headers2.set(name, update.setHeaders[name]), headers);
  849. }
  850. if (update.setParams) {
  851. params = Object.keys(update.setParams).reduce((params2, param) => params2.set(param, update.setParams[param]), params);
  852. }
  853. return new _HttpRequest(method, url, body, {
  854. params,
  855. headers,
  856. context,
  857. reportProgress,
  858. responseType,
  859. withCredentials,
  860. transferCache
  861. });
  862. }
  863. };
  864. var HttpEventType;
  865. (function(HttpEventType2) {
  866. HttpEventType2[HttpEventType2["Sent"] = 0] = "Sent";
  867. HttpEventType2[HttpEventType2["UploadProgress"] = 1] = "UploadProgress";
  868. HttpEventType2[HttpEventType2["ResponseHeader"] = 2] = "ResponseHeader";
  869. HttpEventType2[HttpEventType2["DownloadProgress"] = 3] = "DownloadProgress";
  870. HttpEventType2[HttpEventType2["Response"] = 4] = "Response";
  871. HttpEventType2[HttpEventType2["User"] = 5] = "User";
  872. })(HttpEventType || (HttpEventType = {}));
  873. var HttpResponseBase = class {
  874. /**
  875. * All response headers.
  876. */
  877. headers;
  878. /**
  879. * Response status code.
  880. */
  881. status;
  882. /**
  883. * Textual description of response status code, defaults to OK.
  884. *
  885. * Do not depend on this.
  886. */
  887. statusText;
  888. /**
  889. * URL of the resource retrieved, or null if not available.
  890. */
  891. url;
  892. /**
  893. * Whether the status code falls in the 2xx range.
  894. */
  895. ok;
  896. /**
  897. * Type of the response, narrowed to either the full response or the header.
  898. */
  899. // TODO(issue/24571): remove '!'.
  900. type;
  901. /**
  902. * Super-constructor for all responses.
  903. *
  904. * The single parameter accepted is an initialization hash. Any properties
  905. * of the response passed there will override the default values.
  906. */
  907. constructor(init, defaultStatus = 200, defaultStatusText = "OK") {
  908. this.headers = init.headers || new HttpHeaders();
  909. this.status = init.status !== void 0 ? init.status : defaultStatus;
  910. this.statusText = init.statusText || defaultStatusText;
  911. this.url = init.url || null;
  912. this.ok = this.status >= 200 && this.status < 300;
  913. }
  914. };
  915. var HttpHeaderResponse = class _HttpHeaderResponse extends HttpResponseBase {
  916. /**
  917. * Create a new `HttpHeaderResponse` with the given parameters.
  918. */
  919. constructor(init = {}) {
  920. super(init);
  921. }
  922. type = HttpEventType.ResponseHeader;
  923. /**
  924. * Copy this `HttpHeaderResponse`, overriding its contents with the
  925. * given parameter hash.
  926. */
  927. clone(update = {}) {
  928. return new _HttpHeaderResponse({
  929. headers: update.headers || this.headers,
  930. status: update.status !== void 0 ? update.status : this.status,
  931. statusText: update.statusText || this.statusText,
  932. url: update.url || this.url || void 0
  933. });
  934. }
  935. };
  936. var HttpResponse = class _HttpResponse extends HttpResponseBase {
  937. /**
  938. * The response body, or `null` if one was not returned.
  939. */
  940. body;
  941. /**
  942. * Construct a new `HttpResponse`.
  943. */
  944. constructor(init = {}) {
  945. super(init);
  946. this.body = init.body !== void 0 ? init.body : null;
  947. }
  948. type = HttpEventType.Response;
  949. clone(update = {}) {
  950. return new _HttpResponse({
  951. body: update.body !== void 0 ? update.body : this.body,
  952. headers: update.headers || this.headers,
  953. status: update.status !== void 0 ? update.status : this.status,
  954. statusText: update.statusText || this.statusText,
  955. url: update.url || this.url || void 0
  956. });
  957. }
  958. };
  959. var HttpErrorResponse = class extends HttpResponseBase {
  960. name = "HttpErrorResponse";
  961. message;
  962. error;
  963. /**
  964. * Errors are never okay, even when the status code is in the 2xx success range.
  965. */
  966. ok = false;
  967. constructor(init) {
  968. super(init, 0, "Unknown Error");
  969. if (this.status >= 200 && this.status < 300) {
  970. this.message = `Http failure during parsing for ${init.url || "(unknown url)"}`;
  971. } else {
  972. this.message = `Http failure response for ${init.url || "(unknown url)"}: ${init.status} ${init.statusText}`;
  973. }
  974. this.error = init.error || null;
  975. }
  976. };
  977. var HTTP_STATUS_CODE_OK = 200;
  978. var HTTP_STATUS_CODE_NO_CONTENT = 204;
  979. var HttpStatusCode;
  980. (function(HttpStatusCode2) {
  981. HttpStatusCode2[HttpStatusCode2["Continue"] = 100] = "Continue";
  982. HttpStatusCode2[HttpStatusCode2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
  983. HttpStatusCode2[HttpStatusCode2["Processing"] = 102] = "Processing";
  984. HttpStatusCode2[HttpStatusCode2["EarlyHints"] = 103] = "EarlyHints";
  985. HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
  986. HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
  987. HttpStatusCode2[HttpStatusCode2["Accepted"] = 202] = "Accepted";
  988. HttpStatusCode2[HttpStatusCode2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
  989. HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
  990. HttpStatusCode2[HttpStatusCode2["ResetContent"] = 205] = "ResetContent";
  991. HttpStatusCode2[HttpStatusCode2["PartialContent"] = 206] = "PartialContent";
  992. HttpStatusCode2[HttpStatusCode2["MultiStatus"] = 207] = "MultiStatus";
  993. HttpStatusCode2[HttpStatusCode2["AlreadyReported"] = 208] = "AlreadyReported";
  994. HttpStatusCode2[HttpStatusCode2["ImUsed"] = 226] = "ImUsed";
  995. HttpStatusCode2[HttpStatusCode2["MultipleChoices"] = 300] = "MultipleChoices";
  996. HttpStatusCode2[HttpStatusCode2["MovedPermanently"] = 301] = "MovedPermanently";
  997. HttpStatusCode2[HttpStatusCode2["Found"] = 302] = "Found";
  998. HttpStatusCode2[HttpStatusCode2["SeeOther"] = 303] = "SeeOther";
  999. HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
  1000. HttpStatusCode2[HttpStatusCode2["UseProxy"] = 305] = "UseProxy";
  1001. HttpStatusCode2[HttpStatusCode2["Unused"] = 306] = "Unused";
  1002. HttpStatusCode2[HttpStatusCode2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
  1003. HttpStatusCode2[HttpStatusCode2["PermanentRedirect"] = 308] = "PermanentRedirect";
  1004. HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
  1005. HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
  1006. HttpStatusCode2[HttpStatusCode2["PaymentRequired"] = 402] = "PaymentRequired";
  1007. HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
  1008. HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
  1009. HttpStatusCode2[HttpStatusCode2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
  1010. HttpStatusCode2[HttpStatusCode2["NotAcceptable"] = 406] = "NotAcceptable";
  1011. HttpStatusCode2[HttpStatusCode2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
  1012. HttpStatusCode2[HttpStatusCode2["RequestTimeout"] = 408] = "RequestTimeout";
  1013. HttpStatusCode2[HttpStatusCode2["Conflict"] = 409] = "Conflict";
  1014. HttpStatusCode2[HttpStatusCode2["Gone"] = 410] = "Gone";
  1015. HttpStatusCode2[HttpStatusCode2["LengthRequired"] = 411] = "LengthRequired";
  1016. HttpStatusCode2[HttpStatusCode2["PreconditionFailed"] = 412] = "PreconditionFailed";
  1017. HttpStatusCode2[HttpStatusCode2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
  1018. HttpStatusCode2[HttpStatusCode2["UriTooLong"] = 414] = "UriTooLong";
  1019. HttpStatusCode2[HttpStatusCode2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
  1020. HttpStatusCode2[HttpStatusCode2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
  1021. HttpStatusCode2[HttpStatusCode2["ExpectationFailed"] = 417] = "ExpectationFailed";
  1022. HttpStatusCode2[HttpStatusCode2["ImATeapot"] = 418] = "ImATeapot";
  1023. HttpStatusCode2[HttpStatusCode2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
  1024. HttpStatusCode2[HttpStatusCode2["UnprocessableEntity"] = 422] = "UnprocessableEntity";
  1025. HttpStatusCode2[HttpStatusCode2["Locked"] = 423] = "Locked";
  1026. HttpStatusCode2[HttpStatusCode2["FailedDependency"] = 424] = "FailedDependency";
  1027. HttpStatusCode2[HttpStatusCode2["TooEarly"] = 425] = "TooEarly";
  1028. HttpStatusCode2[HttpStatusCode2["UpgradeRequired"] = 426] = "UpgradeRequired";
  1029. HttpStatusCode2[HttpStatusCode2["PreconditionRequired"] = 428] = "PreconditionRequired";
  1030. HttpStatusCode2[HttpStatusCode2["TooManyRequests"] = 429] = "TooManyRequests";
  1031. HttpStatusCode2[HttpStatusCode2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
  1032. HttpStatusCode2[HttpStatusCode2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
  1033. HttpStatusCode2[HttpStatusCode2["InternalServerError"] = 500] = "InternalServerError";
  1034. HttpStatusCode2[HttpStatusCode2["NotImplemented"] = 501] = "NotImplemented";
  1035. HttpStatusCode2[HttpStatusCode2["BadGateway"] = 502] = "BadGateway";
  1036. HttpStatusCode2[HttpStatusCode2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
  1037. HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
  1038. HttpStatusCode2[HttpStatusCode2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
  1039. HttpStatusCode2[HttpStatusCode2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
  1040. HttpStatusCode2[HttpStatusCode2["InsufficientStorage"] = 507] = "InsufficientStorage";
  1041. HttpStatusCode2[HttpStatusCode2["LoopDetected"] = 508] = "LoopDetected";
  1042. HttpStatusCode2[HttpStatusCode2["NotExtended"] = 510] = "NotExtended";
  1043. HttpStatusCode2[HttpStatusCode2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
  1044. })(HttpStatusCode || (HttpStatusCode = {}));
  1045. function addBody(options, body) {
  1046. return {
  1047. body,
  1048. headers: options.headers,
  1049. context: options.context,
  1050. observe: options.observe,
  1051. params: options.params,
  1052. reportProgress: options.reportProgress,
  1053. responseType: options.responseType,
  1054. withCredentials: options.withCredentials,
  1055. transferCache: options.transferCache
  1056. };
  1057. }
  1058. var HttpClient = class _HttpClient {
  1059. handler;
  1060. constructor(handler) {
  1061. this.handler = handler;
  1062. }
  1063. /**
  1064. * Constructs an observable for a generic HTTP request that, when subscribed,
  1065. * fires the request through the chain of registered interceptors and on to the
  1066. * server.
  1067. *
  1068. * You can pass an `HttpRequest` directly as the only parameter. In this case,
  1069. * the call returns an observable of the raw `HttpEvent` stream.
  1070. *
  1071. * Alternatively you can pass an HTTP method as the first parameter,
  1072. * a URL string as the second, and an options hash containing the request body as the third.
  1073. * See `addBody()`. In this case, the specified `responseType` and `observe` options determine the
  1074. * type of returned observable.
  1075. * * The `responseType` value determines how a successful response body is parsed.
  1076. * * If `responseType` is the default `json`, you can pass a type interface for the resulting
  1077. * object as a type parameter to the call.
  1078. *
  1079. * The `observe` value determines the return type, according to what you are interested in
  1080. * observing.
  1081. * * An `observe` value of events returns an observable of the raw `HttpEvent` stream, including
  1082. * progress events by default.
  1083. * * An `observe` value of response returns an observable of `HttpResponse<T>`,
  1084. * where the `T` parameter depends on the `responseType` and any optionally provided type
  1085. * parameter.
  1086. * * An `observe` value of body returns an observable of `<T>` with the same `T` body type.
  1087. *
  1088. */
  1089. request(first, url, options = {}) {
  1090. let req;
  1091. if (first instanceof HttpRequest) {
  1092. req = first;
  1093. } else {
  1094. let headers = void 0;
  1095. if (options.headers instanceof HttpHeaders) {
  1096. headers = options.headers;
  1097. } else {
  1098. headers = new HttpHeaders(options.headers);
  1099. }
  1100. let params = void 0;
  1101. if (!!options.params) {
  1102. if (options.params instanceof HttpParams) {
  1103. params = options.params;
  1104. } else {
  1105. params = new HttpParams({
  1106. fromObject: options.params
  1107. });
  1108. }
  1109. }
  1110. req = new HttpRequest(first, url, options.body !== void 0 ? options.body : null, {
  1111. headers,
  1112. context: options.context,
  1113. params,
  1114. reportProgress: options.reportProgress,
  1115. // By default, JSON is assumed to be returned for all calls.
  1116. responseType: options.responseType || "json",
  1117. withCredentials: options.withCredentials,
  1118. transferCache: options.transferCache
  1119. });
  1120. }
  1121. const events$ = of(req).pipe(concatMap((req2) => this.handler.handle(req2)));
  1122. if (first instanceof HttpRequest || options.observe === "events") {
  1123. return events$;
  1124. }
  1125. const res$ = events$.pipe(filter((event) => event instanceof HttpResponse));
  1126. switch (options.observe || "body") {
  1127. case "body":
  1128. switch (req.responseType) {
  1129. case "arraybuffer":
  1130. return res$.pipe(map((res) => {
  1131. if (res.body !== null && !(res.body instanceof ArrayBuffer)) {
  1132. throw new RuntimeError(2806, ngDevMode && "Response is not an ArrayBuffer.");
  1133. }
  1134. return res.body;
  1135. }));
  1136. case "blob":
  1137. return res$.pipe(map((res) => {
  1138. if (res.body !== null && !(res.body instanceof Blob)) {
  1139. throw new RuntimeError(2807, ngDevMode && "Response is not a Blob.");
  1140. }
  1141. return res.body;
  1142. }));
  1143. case "text":
  1144. return res$.pipe(map((res) => {
  1145. if (res.body !== null && typeof res.body !== "string") {
  1146. throw new RuntimeError(2808, ngDevMode && "Response is not a string.");
  1147. }
  1148. return res.body;
  1149. }));
  1150. case "json":
  1151. default:
  1152. return res$.pipe(map((res) => res.body));
  1153. }
  1154. case "response":
  1155. return res$;
  1156. default:
  1157. throw new RuntimeError(2809, ngDevMode && `Unreachable: unhandled observe type ${options.observe}}`);
  1158. }
  1159. }
  1160. /**
  1161. * Constructs an observable that, when subscribed, causes the configured
  1162. * `DELETE` request to execute on the server. See the individual overloads for
  1163. * details on the return type.
  1164. *
  1165. * @param url The endpoint URL.
  1166. * @param options The HTTP options to send with the request.
  1167. *
  1168. */
  1169. delete(url, options = {}) {
  1170. return this.request("DELETE", url, options);
  1171. }
  1172. /**
  1173. * Constructs an observable that, when subscribed, causes the configured
  1174. * `GET` request to execute on the server. See the individual overloads for
  1175. * details on the return type.
  1176. */
  1177. get(url, options = {}) {
  1178. return this.request("GET", url, options);
  1179. }
  1180. /**
  1181. * Constructs an observable that, when subscribed, causes the configured
  1182. * `HEAD` request to execute on the server. The `HEAD` method returns
  1183. * meta information about the resource without transferring the
  1184. * resource itself. See the individual overloads for
  1185. * details on the return type.
  1186. */
  1187. head(url, options = {}) {
  1188. return this.request("HEAD", url, options);
  1189. }
  1190. /**
  1191. * Constructs an `Observable` that, when subscribed, causes a request with the special method
  1192. * `JSONP` to be dispatched via the interceptor pipeline.
  1193. * The [JSONP pattern](https://en.wikipedia.org/wiki/JSONP) works around limitations of certain
  1194. * API endpoints that don't support newer,
  1195. * and preferable [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) protocol.
  1196. * JSONP treats the endpoint API as a JavaScript file and tricks the browser to process the
  1197. * requests even if the API endpoint is not located on the same domain (origin) as the client-side
  1198. * application making the request.
  1199. * The endpoint API must support JSONP callback for JSONP requests to work.
  1200. * The resource API returns the JSON response wrapped in a callback function.
  1201. * You can pass the callback function name as one of the query parameters.
  1202. * Note that JSONP requests can only be used with `GET` requests.
  1203. *
  1204. * @param url The resource URL.
  1205. * @param callbackParam The callback function name.
  1206. *
  1207. */
  1208. jsonp(url, callbackParam) {
  1209. return this.request("JSONP", url, {
  1210. params: new HttpParams().append(callbackParam, "JSONP_CALLBACK"),
  1211. observe: "body",
  1212. responseType: "json"
  1213. });
  1214. }
  1215. /**
  1216. * Constructs an `Observable` that, when subscribed, causes the configured
  1217. * `OPTIONS` request to execute on the server. This method allows the client
  1218. * to determine the supported HTTP methods and other capabilities of an endpoint,
  1219. * without implying a resource action. See the individual overloads for
  1220. * details on the return type.
  1221. */
  1222. options(url, options = {}) {
  1223. return this.request("OPTIONS", url, options);
  1224. }
  1225. /**
  1226. * Constructs an observable that, when subscribed, causes the configured
  1227. * `PATCH` request to execute on the server. See the individual overloads for
  1228. * details on the return type.
  1229. */
  1230. patch(url, body, options = {}) {
  1231. return this.request("PATCH", url, addBody(options, body));
  1232. }
  1233. /**
  1234. * Constructs an observable that, when subscribed, causes the configured
  1235. * `POST` request to execute on the server. The server responds with the location of
  1236. * the replaced resource. See the individual overloads for
  1237. * details on the return type.
  1238. */
  1239. post(url, body, options = {}) {
  1240. return this.request("POST", url, addBody(options, body));
  1241. }
  1242. /**
  1243. * Constructs an observable that, when subscribed, causes the configured
  1244. * `PUT` request to execute on the server. The `PUT` method replaces an existing resource
  1245. * with a new set of values.
  1246. * See the individual overloads for details on the return type.
  1247. */
  1248. put(url, body, options = {}) {
  1249. return this.request("PUT", url, addBody(options, body));
  1250. }
  1251. static ɵfac = function HttpClient_Factory(__ngFactoryType__) {
  1252. return new (__ngFactoryType__ || _HttpClient)(ɵɵinject(HttpHandler));
  1253. };
  1254. static ɵprov = ɵɵdefineInjectable({
  1255. token: _HttpClient,
  1256. factory: _HttpClient.ɵfac
  1257. });
  1258. };
  1259. (() => {
  1260. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClient, [{
  1261. type: Injectable
  1262. }], () => [{
  1263. type: HttpHandler
  1264. }], null);
  1265. })();
  1266. var XSSI_PREFIX$1 = /^\)\]\}',?\n/;
  1267. function getResponseUrl$1(response) {
  1268. if (response.url) {
  1269. return response.url;
  1270. }
  1271. const xRequestUrl = X_REQUEST_URL_HEADER.toLocaleLowerCase();
  1272. return response.headers.get(xRequestUrl);
  1273. }
  1274. var FETCH_BACKEND = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "FETCH_BACKEND" : "");
  1275. var FetchBackend = class _FetchBackend {
  1276. // We use an arrow function to always reference the current global implementation of `fetch`.
  1277. // This is helpful for cases when the global `fetch` implementation is modified by external code,
  1278. // see https://github.com/angular/angular/issues/57527.
  1279. fetchImpl = inject(FetchFactory, {
  1280. optional: true
  1281. })?.fetch ?? ((...args) => globalThis.fetch(...args));
  1282. ngZone = inject(NgZone);
  1283. handle(request) {
  1284. return new Observable((observer) => {
  1285. const aborter = new AbortController();
  1286. this.doRequest(request, aborter.signal, observer).then(noop, (error) => observer.error(new HttpErrorResponse({
  1287. error
  1288. })));
  1289. return () => aborter.abort();
  1290. });
  1291. }
  1292. doRequest(request, signal2, observer) {
  1293. return __async(this, null, function* () {
  1294. const init = this.createRequestInit(request);
  1295. let response;
  1296. try {
  1297. const fetchPromise = this.ngZone.runOutsideAngular(() => this.fetchImpl(request.urlWithParams, __spreadValues({
  1298. signal: signal2
  1299. }, init)));
  1300. silenceSuperfluousUnhandledPromiseRejection(fetchPromise);
  1301. observer.next({
  1302. type: HttpEventType.Sent
  1303. });
  1304. response = yield fetchPromise;
  1305. } catch (error) {
  1306. observer.error(new HttpErrorResponse({
  1307. error,
  1308. status: error.status ?? 0,
  1309. statusText: error.statusText,
  1310. url: request.urlWithParams,
  1311. headers: error.headers
  1312. }));
  1313. return;
  1314. }
  1315. const headers = new HttpHeaders(response.headers);
  1316. const statusText = response.statusText;
  1317. const url = getResponseUrl$1(response) ?? request.urlWithParams;
  1318. let status = response.status;
  1319. let body = null;
  1320. if (request.reportProgress) {
  1321. observer.next(new HttpHeaderResponse({
  1322. headers,
  1323. status,
  1324. statusText,
  1325. url
  1326. }));
  1327. }
  1328. if (response.body) {
  1329. const contentLength = response.headers.get("content-length");
  1330. const chunks = [];
  1331. const reader = response.body.getReader();
  1332. let receivedLength = 0;
  1333. let decoder;
  1334. let partialText;
  1335. const reqZone = typeof Zone !== "undefined" && Zone.current;
  1336. yield this.ngZone.runOutsideAngular(() => __async(this, null, function* () {
  1337. while (true) {
  1338. const {
  1339. done,
  1340. value
  1341. } = yield reader.read();
  1342. if (done) {
  1343. break;
  1344. }
  1345. chunks.push(value);
  1346. receivedLength += value.length;
  1347. if (request.reportProgress) {
  1348. partialText = request.responseType === "text" ? (partialText ?? "") + (decoder ??= new TextDecoder()).decode(value, {
  1349. stream: true
  1350. }) : void 0;
  1351. const reportProgress = () => observer.next({
  1352. type: HttpEventType.DownloadProgress,
  1353. total: contentLength ? +contentLength : void 0,
  1354. loaded: receivedLength,
  1355. partialText
  1356. });
  1357. reqZone ? reqZone.run(reportProgress) : reportProgress();
  1358. }
  1359. }
  1360. }));
  1361. const chunksAll = this.concatChunks(chunks, receivedLength);
  1362. try {
  1363. const contentType = response.headers.get(CONTENT_TYPE_HEADER) ?? "";
  1364. body = this.parseBody(request, chunksAll, contentType);
  1365. } catch (error) {
  1366. observer.error(new HttpErrorResponse({
  1367. error,
  1368. headers: new HttpHeaders(response.headers),
  1369. status: response.status,
  1370. statusText: response.statusText,
  1371. url: getResponseUrl$1(response) ?? request.urlWithParams
  1372. }));
  1373. return;
  1374. }
  1375. }
  1376. if (status === 0) {
  1377. status = body ? HTTP_STATUS_CODE_OK : 0;
  1378. }
  1379. const ok = status >= 200 && status < 300;
  1380. if (ok) {
  1381. observer.next(new HttpResponse({
  1382. body,
  1383. headers,
  1384. status,
  1385. statusText,
  1386. url
  1387. }));
  1388. observer.complete();
  1389. } else {
  1390. observer.error(new HttpErrorResponse({
  1391. error: body,
  1392. headers,
  1393. status,
  1394. statusText,
  1395. url
  1396. }));
  1397. }
  1398. });
  1399. }
  1400. parseBody(request, binContent, contentType) {
  1401. switch (request.responseType) {
  1402. case "json":
  1403. const text = new TextDecoder().decode(binContent).replace(XSSI_PREFIX$1, "");
  1404. return text === "" ? null : JSON.parse(text);
  1405. case "text":
  1406. return new TextDecoder().decode(binContent);
  1407. case "blob":
  1408. return new Blob([binContent], {
  1409. type: contentType
  1410. });
  1411. case "arraybuffer":
  1412. return binContent.buffer;
  1413. }
  1414. }
  1415. createRequestInit(req) {
  1416. const headers = {};
  1417. const credentials = req.withCredentials ? "include" : void 0;
  1418. req.headers.forEach((name, values) => headers[name] = values.join(","));
  1419. if (!req.headers.has(ACCEPT_HEADER)) {
  1420. headers[ACCEPT_HEADER] = ACCEPT_HEADER_VALUE;
  1421. }
  1422. if (!req.headers.has(CONTENT_TYPE_HEADER)) {
  1423. const detectedType = req.detectContentTypeHeader();
  1424. if (detectedType !== null) {
  1425. headers[CONTENT_TYPE_HEADER] = detectedType;
  1426. }
  1427. }
  1428. return {
  1429. body: req.serializeBody(),
  1430. method: req.method,
  1431. headers,
  1432. credentials
  1433. };
  1434. }
  1435. concatChunks(chunks, totalLength) {
  1436. const chunksAll = new Uint8Array(totalLength);
  1437. let position = 0;
  1438. for (const chunk of chunks) {
  1439. chunksAll.set(chunk, position);
  1440. position += chunk.length;
  1441. }
  1442. return chunksAll;
  1443. }
  1444. static ɵfac = function FetchBackend_Factory(__ngFactoryType__) {
  1445. return new (__ngFactoryType__ || _FetchBackend)();
  1446. };
  1447. static ɵprov = ɵɵdefineInjectable({
  1448. token: _FetchBackend,
  1449. factory: _FetchBackend.ɵfac
  1450. });
  1451. };
  1452. (() => {
  1453. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FetchBackend, [{
  1454. type: Injectable
  1455. }], null, null);
  1456. })();
  1457. var FetchFactory = class {
  1458. };
  1459. function noop() {
  1460. }
  1461. function silenceSuperfluousUnhandledPromiseRejection(promise) {
  1462. promise.then(noop, noop);
  1463. }
  1464. function interceptorChainEndFn(req, finalHandlerFn) {
  1465. return finalHandlerFn(req);
  1466. }
  1467. function adaptLegacyInterceptorToChain(chainTailFn, interceptor) {
  1468. return (initialRequest, finalHandlerFn) => interceptor.intercept(initialRequest, {
  1469. handle: (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn)
  1470. });
  1471. }
  1472. function chainedInterceptorFn(chainTailFn, interceptorFn, injector) {
  1473. return (initialRequest, finalHandlerFn) => runInInjectionContext(injector, () => interceptorFn(initialRequest, (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn)));
  1474. }
  1475. var HTTP_INTERCEPTORS = new InjectionToken(ngDevMode ? "HTTP_INTERCEPTORS" : "");
  1476. var HTTP_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? "HTTP_INTERCEPTOR_FNS" : "");
  1477. var HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? "HTTP_ROOT_INTERCEPTOR_FNS" : "");
  1478. var REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken(ngDevMode ? "REQUESTS_CONTRIBUTE_TO_STABILITY" : "", {
  1479. providedIn: "root",
  1480. factory: () => true
  1481. });
  1482. function legacyInterceptorFnFactory() {
  1483. let chain = null;
  1484. return (req, handler) => {
  1485. if (chain === null) {
  1486. const interceptors = inject(HTTP_INTERCEPTORS, {
  1487. optional: true
  1488. }) ?? [];
  1489. chain = interceptors.reduceRight(adaptLegacyInterceptorToChain, interceptorChainEndFn);
  1490. }
  1491. const pendingTasks = inject(PendingTasksInternal);
  1492. const contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
  1493. if (contributeToStability) {
  1494. const taskId = pendingTasks.add();
  1495. return chain(req, handler).pipe(finalize(() => pendingTasks.remove(taskId)));
  1496. } else {
  1497. return chain(req, handler);
  1498. }
  1499. };
  1500. }
  1501. var fetchBackendWarningDisplayed = false;
  1502. var HttpInterceptorHandler = class _HttpInterceptorHandler extends HttpHandler {
  1503. backend;
  1504. injector;
  1505. chain = null;
  1506. pendingTasks = inject(PendingTasksInternal);
  1507. contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
  1508. constructor(backend, injector) {
  1509. super();
  1510. this.backend = backend;
  1511. this.injector = injector;
  1512. if ((typeof ngDevMode === "undefined" || ngDevMode) && !fetchBackendWarningDisplayed) {
  1513. const isServer = isPlatformServer(injector.get(PLATFORM_ID));
  1514. const isTestingBackend = this.backend.isTestingBackend;
  1515. if (isServer && !(this.backend instanceof FetchBackend) && !isTestingBackend) {
  1516. fetchBackendWarningDisplayed = true;
  1517. 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."));
  1518. }
  1519. }
  1520. }
  1521. handle(initialRequest) {
  1522. if (this.chain === null) {
  1523. const dedupedInterceptorFns = Array.from(/* @__PURE__ */ new Set([...this.injector.get(HTTP_INTERCEPTOR_FNS), ...this.injector.get(HTTP_ROOT_INTERCEPTOR_FNS, [])]));
  1524. this.chain = dedupedInterceptorFns.reduceRight((nextSequencedFn, interceptorFn) => chainedInterceptorFn(nextSequencedFn, interceptorFn, this.injector), interceptorChainEndFn);
  1525. }
  1526. if (this.contributeToStability) {
  1527. const taskId = this.pendingTasks.add();
  1528. return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest)).pipe(finalize(() => this.pendingTasks.remove(taskId)));
  1529. } else {
  1530. return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest));
  1531. }
  1532. }
  1533. static ɵfac = function HttpInterceptorHandler_Factory(__ngFactoryType__) {
  1534. return new (__ngFactoryType__ || _HttpInterceptorHandler)(ɵɵinject(HttpBackend), ɵɵinject(EnvironmentInjector));
  1535. };
  1536. static ɵprov = ɵɵdefineInjectable({
  1537. token: _HttpInterceptorHandler,
  1538. factory: _HttpInterceptorHandler.ɵfac
  1539. });
  1540. };
  1541. (() => {
  1542. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpInterceptorHandler, [{
  1543. type: Injectable
  1544. }], () => [{
  1545. type: HttpBackend
  1546. }, {
  1547. type: EnvironmentInjector
  1548. }], null);
  1549. })();
  1550. var nextRequestId = 0;
  1551. var foreignDocument;
  1552. var JSONP_ERR_NO_CALLBACK = "JSONP injected script did not invoke callback.";
  1553. var JSONP_ERR_WRONG_METHOD = "JSONP requests must use JSONP request method.";
  1554. var JSONP_ERR_WRONG_RESPONSE_TYPE = "JSONP requests must use Json response type.";
  1555. var JSONP_ERR_HEADERS_NOT_SUPPORTED = "JSONP requests do not support headers.";
  1556. var JsonpCallbackContext = class {
  1557. };
  1558. function jsonpCallbackContext() {
  1559. if (typeof window === "object") {
  1560. return window;
  1561. }
  1562. return {};
  1563. }
  1564. var JsonpClientBackend = class _JsonpClientBackend {
  1565. callbackMap;
  1566. document;
  1567. /**
  1568. * A resolved promise that can be used to schedule microtasks in the event handlers.
  1569. */
  1570. resolvedPromise = Promise.resolve();
  1571. constructor(callbackMap, document2) {
  1572. this.callbackMap = callbackMap;
  1573. this.document = document2;
  1574. }
  1575. /**
  1576. * Get the name of the next callback method, by incrementing the global `nextRequestId`.
  1577. */
  1578. nextCallback() {
  1579. return `ng_jsonp_callback_${nextRequestId++}`;
  1580. }
  1581. /**
  1582. * Processes a JSONP request and returns an event stream of the results.
  1583. * @param req The request object.
  1584. * @returns An observable of the response events.
  1585. *
  1586. */
  1587. handle(req) {
  1588. if (req.method !== "JSONP") {
  1589. throw new Error(JSONP_ERR_WRONG_METHOD);
  1590. } else if (req.responseType !== "json") {
  1591. throw new Error(JSONP_ERR_WRONG_RESPONSE_TYPE);
  1592. }
  1593. if (req.headers.keys().length > 0) {
  1594. throw new Error(JSONP_ERR_HEADERS_NOT_SUPPORTED);
  1595. }
  1596. return new Observable((observer) => {
  1597. const callback = this.nextCallback();
  1598. const url = req.urlWithParams.replace(/=JSONP_CALLBACK(&|$)/, `=${callback}$1`);
  1599. const node = this.document.createElement("script");
  1600. node.src = url;
  1601. let body = null;
  1602. let finished = false;
  1603. this.callbackMap[callback] = (data) => {
  1604. delete this.callbackMap[callback];
  1605. body = data;
  1606. finished = true;
  1607. };
  1608. const cleanup = () => {
  1609. node.removeEventListener("load", onLoad);
  1610. node.removeEventListener("error", onError);
  1611. node.remove();
  1612. delete this.callbackMap[callback];
  1613. };
  1614. const onLoad = (event) => {
  1615. this.resolvedPromise.then(() => {
  1616. cleanup();
  1617. if (!finished) {
  1618. observer.error(new HttpErrorResponse({
  1619. url,
  1620. status: 0,
  1621. statusText: "JSONP Error",
  1622. error: new Error(JSONP_ERR_NO_CALLBACK)
  1623. }));
  1624. return;
  1625. }
  1626. observer.next(new HttpResponse({
  1627. body,
  1628. status: HTTP_STATUS_CODE_OK,
  1629. statusText: "OK",
  1630. url
  1631. }));
  1632. observer.complete();
  1633. });
  1634. };
  1635. const onError = (error) => {
  1636. cleanup();
  1637. observer.error(new HttpErrorResponse({
  1638. error,
  1639. status: 0,
  1640. statusText: "JSONP Error",
  1641. url
  1642. }));
  1643. };
  1644. node.addEventListener("load", onLoad);
  1645. node.addEventListener("error", onError);
  1646. this.document.body.appendChild(node);
  1647. observer.next({
  1648. type: HttpEventType.Sent
  1649. });
  1650. return () => {
  1651. if (!finished) {
  1652. this.removeListeners(node);
  1653. }
  1654. cleanup();
  1655. };
  1656. });
  1657. }
  1658. removeListeners(script) {
  1659. foreignDocument ??= this.document.implementation.createHTMLDocument();
  1660. foreignDocument.adoptNode(script);
  1661. }
  1662. static ɵfac = function JsonpClientBackend_Factory(__ngFactoryType__) {
  1663. return new (__ngFactoryType__ || _JsonpClientBackend)(ɵɵinject(JsonpCallbackContext), ɵɵinject(DOCUMENT));
  1664. };
  1665. static ɵprov = ɵɵdefineInjectable({
  1666. token: _JsonpClientBackend,
  1667. factory: _JsonpClientBackend.ɵfac
  1668. });
  1669. };
  1670. (() => {
  1671. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(JsonpClientBackend, [{
  1672. type: Injectable
  1673. }], () => [{
  1674. type: JsonpCallbackContext
  1675. }, {
  1676. type: void 0,
  1677. decorators: [{
  1678. type: Inject,
  1679. args: [DOCUMENT]
  1680. }]
  1681. }], null);
  1682. })();
  1683. function jsonpInterceptorFn(req, next) {
  1684. if (req.method === "JSONP") {
  1685. return inject(JsonpClientBackend).handle(req);
  1686. }
  1687. return next(req);
  1688. }
  1689. var JsonpInterceptor = class _JsonpInterceptor {
  1690. injector;
  1691. constructor(injector) {
  1692. this.injector = injector;
  1693. }
  1694. /**
  1695. * Identifies and handles a given JSONP request.
  1696. * @param initialRequest The outgoing request object to handle.
  1697. * @param next The next interceptor in the chain, or the backend
  1698. * if no interceptors remain in the chain.
  1699. * @returns An observable of the event stream.
  1700. */
  1701. intercept(initialRequest, next) {
  1702. return runInInjectionContext(this.injector, () => jsonpInterceptorFn(initialRequest, (downstreamRequest) => next.handle(downstreamRequest)));
  1703. }
  1704. static ɵfac = function JsonpInterceptor_Factory(__ngFactoryType__) {
  1705. return new (__ngFactoryType__ || _JsonpInterceptor)(ɵɵinject(EnvironmentInjector));
  1706. };
  1707. static ɵprov = ɵɵdefineInjectable({
  1708. token: _JsonpInterceptor,
  1709. factory: _JsonpInterceptor.ɵfac
  1710. });
  1711. };
  1712. (() => {
  1713. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(JsonpInterceptor, [{
  1714. type: Injectable
  1715. }], () => [{
  1716. type: EnvironmentInjector
  1717. }], null);
  1718. })();
  1719. var XSSI_PREFIX = /^\)\]\}',?\n/;
  1720. var X_REQUEST_URL_REGEXP = RegExp(`^${X_REQUEST_URL_HEADER}:`, "m");
  1721. function getResponseUrl(xhr) {
  1722. if ("responseURL" in xhr && xhr.responseURL) {
  1723. return xhr.responseURL;
  1724. }
  1725. if (X_REQUEST_URL_REGEXP.test(xhr.getAllResponseHeaders())) {
  1726. return xhr.getResponseHeader(X_REQUEST_URL_HEADER);
  1727. }
  1728. return null;
  1729. }
  1730. var HttpXhrBackend = class _HttpXhrBackend {
  1731. xhrFactory;
  1732. constructor(xhrFactory) {
  1733. this.xhrFactory = xhrFactory;
  1734. }
  1735. /**
  1736. * Processes a request and returns a stream of response events.
  1737. * @param req The request object.
  1738. * @returns An observable of the response events.
  1739. */
  1740. handle(req) {
  1741. if (req.method === "JSONP") {
  1742. 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.`);
  1743. }
  1744. const xhrFactory = this.xhrFactory;
  1745. const source = xhrFactory.ɵloadImpl ? from(xhrFactory.ɵloadImpl()) : of(null);
  1746. return source.pipe(switchMap(() => {
  1747. return new Observable((observer) => {
  1748. const xhr = xhrFactory.build();
  1749. xhr.open(req.method, req.urlWithParams);
  1750. if (req.withCredentials) {
  1751. xhr.withCredentials = true;
  1752. }
  1753. req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(",")));
  1754. if (!req.headers.has(ACCEPT_HEADER)) {
  1755. xhr.setRequestHeader(ACCEPT_HEADER, ACCEPT_HEADER_VALUE);
  1756. }
  1757. if (!req.headers.has(CONTENT_TYPE_HEADER)) {
  1758. const detectedType = req.detectContentTypeHeader();
  1759. if (detectedType !== null) {
  1760. xhr.setRequestHeader(CONTENT_TYPE_HEADER, detectedType);
  1761. }
  1762. }
  1763. if (req.responseType) {
  1764. const responseType = req.responseType.toLowerCase();
  1765. xhr.responseType = responseType !== "json" ? responseType : "text";
  1766. }
  1767. const reqBody = req.serializeBody();
  1768. let headerResponse = null;
  1769. const partialFromXhr = () => {
  1770. if (headerResponse !== null) {
  1771. return headerResponse;
  1772. }
  1773. const statusText = xhr.statusText || "OK";
  1774. const headers = new HttpHeaders(xhr.getAllResponseHeaders());
  1775. const url = getResponseUrl(xhr) || req.url;
  1776. headerResponse = new HttpHeaderResponse({
  1777. headers,
  1778. status: xhr.status,
  1779. statusText,
  1780. url
  1781. });
  1782. return headerResponse;
  1783. };
  1784. const onLoad = () => {
  1785. let {
  1786. headers,
  1787. status,
  1788. statusText,
  1789. url
  1790. } = partialFromXhr();
  1791. let body = null;
  1792. if (status !== HTTP_STATUS_CODE_NO_CONTENT) {
  1793. body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
  1794. }
  1795. if (status === 0) {
  1796. status = !!body ? HTTP_STATUS_CODE_OK : 0;
  1797. }
  1798. let ok = status >= 200 && status < 300;
  1799. if (req.responseType === "json" && typeof body === "string") {
  1800. const originalBody = body;
  1801. body = body.replace(XSSI_PREFIX, "");
  1802. try {
  1803. body = body !== "" ? JSON.parse(body) : null;
  1804. } catch (error) {
  1805. body = originalBody;
  1806. if (ok) {
  1807. ok = false;
  1808. body = {
  1809. error,
  1810. text: body
  1811. };
  1812. }
  1813. }
  1814. }
  1815. if (ok) {
  1816. observer.next(new HttpResponse({
  1817. body,
  1818. headers,
  1819. status,
  1820. statusText,
  1821. url: url || void 0
  1822. }));
  1823. observer.complete();
  1824. } else {
  1825. observer.error(new HttpErrorResponse({
  1826. // The error in this case is the response body (error from the server).
  1827. error: body,
  1828. headers,
  1829. status,
  1830. statusText,
  1831. url: url || void 0
  1832. }));
  1833. }
  1834. };
  1835. const onError = (error) => {
  1836. const {
  1837. url
  1838. } = partialFromXhr();
  1839. const res = new HttpErrorResponse({
  1840. error,
  1841. status: xhr.status || 0,
  1842. statusText: xhr.statusText || "Unknown Error",
  1843. url: url || void 0
  1844. });
  1845. observer.error(res);
  1846. };
  1847. let sentHeaders = false;
  1848. const onDownProgress = (event) => {
  1849. if (!sentHeaders) {
  1850. observer.next(partialFromXhr());
  1851. sentHeaders = true;
  1852. }
  1853. let progressEvent = {
  1854. type: HttpEventType.DownloadProgress,
  1855. loaded: event.loaded
  1856. };
  1857. if (event.lengthComputable) {
  1858. progressEvent.total = event.total;
  1859. }
  1860. if (req.responseType === "text" && !!xhr.responseText) {
  1861. progressEvent.partialText = xhr.responseText;
  1862. }
  1863. observer.next(progressEvent);
  1864. };
  1865. const onUpProgress = (event) => {
  1866. let progress = {
  1867. type: HttpEventType.UploadProgress,
  1868. loaded: event.loaded
  1869. };
  1870. if (event.lengthComputable) {
  1871. progress.total = event.total;
  1872. }
  1873. observer.next(progress);
  1874. };
  1875. xhr.addEventListener("load", onLoad);
  1876. xhr.addEventListener("error", onError);
  1877. xhr.addEventListener("timeout", onError);
  1878. xhr.addEventListener("abort", onError);
  1879. if (req.reportProgress) {
  1880. xhr.addEventListener("progress", onDownProgress);
  1881. if (reqBody !== null && xhr.upload) {
  1882. xhr.upload.addEventListener("progress", onUpProgress);
  1883. }
  1884. }
  1885. xhr.send(reqBody);
  1886. observer.next({
  1887. type: HttpEventType.Sent
  1888. });
  1889. return () => {
  1890. xhr.removeEventListener("error", onError);
  1891. xhr.removeEventListener("abort", onError);
  1892. xhr.removeEventListener("load", onLoad);
  1893. xhr.removeEventListener("timeout", onError);
  1894. if (req.reportProgress) {
  1895. xhr.removeEventListener("progress", onDownProgress);
  1896. if (reqBody !== null && xhr.upload) {
  1897. xhr.upload.removeEventListener("progress", onUpProgress);
  1898. }
  1899. }
  1900. if (xhr.readyState !== xhr.DONE) {
  1901. xhr.abort();
  1902. }
  1903. };
  1904. });
  1905. }));
  1906. }
  1907. static ɵfac = function HttpXhrBackend_Factory(__ngFactoryType__) {
  1908. return new (__ngFactoryType__ || _HttpXhrBackend)(ɵɵinject(XhrFactory));
  1909. };
  1910. static ɵprov = ɵɵdefineInjectable({
  1911. token: _HttpXhrBackend,
  1912. factory: _HttpXhrBackend.ɵfac
  1913. });
  1914. };
  1915. (() => {
  1916. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXhrBackend, [{
  1917. type: Injectable
  1918. }], () => [{
  1919. type: XhrFactory
  1920. }], null);
  1921. })();
  1922. var XSRF_ENABLED = new InjectionToken(ngDevMode ? "XSRF_ENABLED" : "");
  1923. var XSRF_DEFAULT_COOKIE_NAME = "XSRF-TOKEN";
  1924. var XSRF_COOKIE_NAME = new InjectionToken(ngDevMode ? "XSRF_COOKIE_NAME" : "", {
  1925. providedIn: "root",
  1926. factory: () => XSRF_DEFAULT_COOKIE_NAME
  1927. });
  1928. var XSRF_DEFAULT_HEADER_NAME = "X-XSRF-TOKEN";
  1929. var XSRF_HEADER_NAME = new InjectionToken(ngDevMode ? "XSRF_HEADER_NAME" : "", {
  1930. providedIn: "root",
  1931. factory: () => XSRF_DEFAULT_HEADER_NAME
  1932. });
  1933. var HttpXsrfTokenExtractor = class {
  1934. };
  1935. var HttpXsrfCookieExtractor = class _HttpXsrfCookieExtractor {
  1936. doc;
  1937. platform;
  1938. cookieName;
  1939. lastCookieString = "";
  1940. lastToken = null;
  1941. /**
  1942. * @internal for testing
  1943. */
  1944. parseCount = 0;
  1945. constructor(doc, platform, cookieName) {
  1946. this.doc = doc;
  1947. this.platform = platform;
  1948. this.cookieName = cookieName;
  1949. }
  1950. getToken() {
  1951. if (this.platform === "server") {
  1952. return null;
  1953. }
  1954. const cookieString = this.doc.cookie || "";
  1955. if (cookieString !== this.lastCookieString) {
  1956. this.parseCount++;
  1957. this.lastToken = parseCookieValue(cookieString, this.cookieName);
  1958. this.lastCookieString = cookieString;
  1959. }
  1960. return this.lastToken;
  1961. }
  1962. static ɵfac = function HttpXsrfCookieExtractor_Factory(__ngFactoryType__) {
  1963. return new (__ngFactoryType__ || _HttpXsrfCookieExtractor)(ɵɵinject(DOCUMENT), ɵɵinject(PLATFORM_ID), ɵɵinject(XSRF_COOKIE_NAME));
  1964. };
  1965. static ɵprov = ɵɵdefineInjectable({
  1966. token: _HttpXsrfCookieExtractor,
  1967. factory: _HttpXsrfCookieExtractor.ɵfac
  1968. });
  1969. };
  1970. (() => {
  1971. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXsrfCookieExtractor, [{
  1972. type: Injectable
  1973. }], () => [{
  1974. type: void 0,
  1975. decorators: [{
  1976. type: Inject,
  1977. args: [DOCUMENT]
  1978. }]
  1979. }, {
  1980. type: void 0,
  1981. decorators: [{
  1982. type: Inject,
  1983. args: [PLATFORM_ID]
  1984. }]
  1985. }, {
  1986. type: void 0,
  1987. decorators: [{
  1988. type: Inject,
  1989. args: [XSRF_COOKIE_NAME]
  1990. }]
  1991. }], null);
  1992. })();
  1993. function xsrfInterceptorFn(req, next) {
  1994. const lcUrl = req.url.toLowerCase();
  1995. if (!inject(XSRF_ENABLED) || req.method === "GET" || req.method === "HEAD" || lcUrl.startsWith("http://") || lcUrl.startsWith("https://")) {
  1996. return next(req);
  1997. }
  1998. const token = inject(HttpXsrfTokenExtractor).getToken();
  1999. const headerName = inject(XSRF_HEADER_NAME);
  2000. if (token != null && !req.headers.has(headerName)) {
  2001. req = req.clone({
  2002. headers: req.headers.set(headerName, token)
  2003. });
  2004. }
  2005. return next(req);
  2006. }
  2007. var HttpXsrfInterceptor = class _HttpXsrfInterceptor {
  2008. injector;
  2009. constructor(injector) {
  2010. this.injector = injector;
  2011. }
  2012. intercept(initialRequest, next) {
  2013. return runInInjectionContext(this.injector, () => xsrfInterceptorFn(initialRequest, (downstreamRequest) => next.handle(downstreamRequest)));
  2014. }
  2015. static ɵfac = function HttpXsrfInterceptor_Factory(__ngFactoryType__) {
  2016. return new (__ngFactoryType__ || _HttpXsrfInterceptor)(ɵɵinject(EnvironmentInjector));
  2017. };
  2018. static ɵprov = ɵɵdefineInjectable({
  2019. token: _HttpXsrfInterceptor,
  2020. factory: _HttpXsrfInterceptor.ɵfac
  2021. });
  2022. };
  2023. (() => {
  2024. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXsrfInterceptor, [{
  2025. type: Injectable
  2026. }], () => [{
  2027. type: EnvironmentInjector
  2028. }], null);
  2029. })();
  2030. var HttpFeatureKind;
  2031. (function(HttpFeatureKind2) {
  2032. HttpFeatureKind2[HttpFeatureKind2["Interceptors"] = 0] = "Interceptors";
  2033. HttpFeatureKind2[HttpFeatureKind2["LegacyInterceptors"] = 1] = "LegacyInterceptors";
  2034. HttpFeatureKind2[HttpFeatureKind2["CustomXsrfConfiguration"] = 2] = "CustomXsrfConfiguration";
  2035. HttpFeatureKind2[HttpFeatureKind2["NoXsrfProtection"] = 3] = "NoXsrfProtection";
  2036. HttpFeatureKind2[HttpFeatureKind2["JsonpSupport"] = 4] = "JsonpSupport";
  2037. HttpFeatureKind2[HttpFeatureKind2["RequestsMadeViaParent"] = 5] = "RequestsMadeViaParent";
  2038. HttpFeatureKind2[HttpFeatureKind2["Fetch"] = 6] = "Fetch";
  2039. })(HttpFeatureKind || (HttpFeatureKind = {}));
  2040. function makeHttpFeature(kind, providers) {
  2041. return {
  2042. ɵkind: kind,
  2043. ɵproviders: providers
  2044. };
  2045. }
  2046. function provideHttpClient(...features) {
  2047. if (ngDevMode) {
  2048. const featureKinds = new Set(features.map((f) => f.ɵkind));
  2049. if (featureKinds.has(HttpFeatureKind.NoXsrfProtection) && featureKinds.has(HttpFeatureKind.CustomXsrfConfiguration)) {
  2050. throw new Error(ngDevMode ? `Configuration error: found both withXsrfConfiguration() and withNoXsrfProtection() in the same call to provideHttpClient(), which is a contradiction.` : "");
  2051. }
  2052. }
  2053. const providers = [HttpClient, HttpXhrBackend, HttpInterceptorHandler, {
  2054. provide: HttpHandler,
  2055. useExisting: HttpInterceptorHandler
  2056. }, {
  2057. provide: HttpBackend,
  2058. useFactory: () => {
  2059. return inject(FETCH_BACKEND, {
  2060. optional: true
  2061. }) ?? inject(HttpXhrBackend);
  2062. }
  2063. }, {
  2064. provide: HTTP_INTERCEPTOR_FNS,
  2065. useValue: xsrfInterceptorFn,
  2066. multi: true
  2067. }, {
  2068. provide: XSRF_ENABLED,
  2069. useValue: true
  2070. }, {
  2071. provide: HttpXsrfTokenExtractor,
  2072. useClass: HttpXsrfCookieExtractor
  2073. }];
  2074. for (const feature of features) {
  2075. providers.push(...feature.ɵproviders);
  2076. }
  2077. return makeEnvironmentProviders(providers);
  2078. }
  2079. var LEGACY_INTERCEPTOR_FN = new InjectionToken(ngDevMode ? "LEGACY_INTERCEPTOR_FN" : "");
  2080. function withInterceptorsFromDi() {
  2081. return makeHttpFeature(HttpFeatureKind.LegacyInterceptors, [{
  2082. provide: LEGACY_INTERCEPTOR_FN,
  2083. useFactory: legacyInterceptorFnFactory
  2084. }, {
  2085. provide: HTTP_INTERCEPTOR_FNS,
  2086. useExisting: LEGACY_INTERCEPTOR_FN,
  2087. multi: true
  2088. }]);
  2089. }
  2090. function withXsrfConfiguration({
  2091. cookieName,
  2092. headerName
  2093. }) {
  2094. const providers = [];
  2095. if (cookieName !== void 0) {
  2096. providers.push({
  2097. provide: XSRF_COOKIE_NAME,
  2098. useValue: cookieName
  2099. });
  2100. }
  2101. if (headerName !== void 0) {
  2102. providers.push({
  2103. provide: XSRF_HEADER_NAME,
  2104. useValue: headerName
  2105. });
  2106. }
  2107. return makeHttpFeature(HttpFeatureKind.CustomXsrfConfiguration, providers);
  2108. }
  2109. function withNoXsrfProtection() {
  2110. return makeHttpFeature(HttpFeatureKind.NoXsrfProtection, [{
  2111. provide: XSRF_ENABLED,
  2112. useValue: false
  2113. }]);
  2114. }
  2115. function withJsonpSupport() {
  2116. return makeHttpFeature(HttpFeatureKind.JsonpSupport, [JsonpClientBackend, {
  2117. provide: JsonpCallbackContext,
  2118. useFactory: jsonpCallbackContext
  2119. }, {
  2120. provide: HTTP_INTERCEPTOR_FNS,
  2121. useValue: jsonpInterceptorFn,
  2122. multi: true
  2123. }]);
  2124. }
  2125. var HttpClientXsrfModule = class _HttpClientXsrfModule {
  2126. /**
  2127. * Disable the default XSRF protection.
  2128. */
  2129. static disable() {
  2130. return {
  2131. ngModule: _HttpClientXsrfModule,
  2132. providers: [withNoXsrfProtection().ɵproviders]
  2133. };
  2134. }
  2135. /**
  2136. * Configure XSRF protection.
  2137. * @param options An object that can specify either or both
  2138. * cookie name or header name.
  2139. * - Cookie name default is `XSRF-TOKEN`.
  2140. * - Header name default is `X-XSRF-TOKEN`.
  2141. *
  2142. */
  2143. static withOptions(options = {}) {
  2144. return {
  2145. ngModule: _HttpClientXsrfModule,
  2146. providers: withXsrfConfiguration(options).ɵproviders
  2147. };
  2148. }
  2149. static ɵfac = function HttpClientXsrfModule_Factory(__ngFactoryType__) {
  2150. return new (__ngFactoryType__ || _HttpClientXsrfModule)();
  2151. };
  2152. static ɵmod = ɵɵdefineNgModule({
  2153. type: _HttpClientXsrfModule
  2154. });
  2155. static ɵinj = ɵɵdefineInjector({
  2156. providers: [HttpXsrfInterceptor, {
  2157. provide: HTTP_INTERCEPTORS,
  2158. useExisting: HttpXsrfInterceptor,
  2159. multi: true
  2160. }, {
  2161. provide: HttpXsrfTokenExtractor,
  2162. useClass: HttpXsrfCookieExtractor
  2163. }, withXsrfConfiguration({
  2164. cookieName: XSRF_DEFAULT_COOKIE_NAME,
  2165. headerName: XSRF_DEFAULT_HEADER_NAME
  2166. }).ɵproviders, {
  2167. provide: XSRF_ENABLED,
  2168. useValue: true
  2169. }]
  2170. });
  2171. };
  2172. (() => {
  2173. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientXsrfModule, [{
  2174. type: NgModule,
  2175. args: [{
  2176. providers: [HttpXsrfInterceptor, {
  2177. provide: HTTP_INTERCEPTORS,
  2178. useExisting: HttpXsrfInterceptor,
  2179. multi: true
  2180. }, {
  2181. provide: HttpXsrfTokenExtractor,
  2182. useClass: HttpXsrfCookieExtractor
  2183. }, withXsrfConfiguration({
  2184. cookieName: XSRF_DEFAULT_COOKIE_NAME,
  2185. headerName: XSRF_DEFAULT_HEADER_NAME
  2186. }).ɵproviders, {
  2187. provide: XSRF_ENABLED,
  2188. useValue: true
  2189. }]
  2190. }]
  2191. }], null, null);
  2192. })();
  2193. var HttpClientModule = class _HttpClientModule {
  2194. static ɵfac = function HttpClientModule_Factory(__ngFactoryType__) {
  2195. return new (__ngFactoryType__ || _HttpClientModule)();
  2196. };
  2197. static ɵmod = ɵɵdefineNgModule({
  2198. type: _HttpClientModule
  2199. });
  2200. static ɵinj = ɵɵdefineInjector({
  2201. providers: [provideHttpClient(withInterceptorsFromDi())]
  2202. });
  2203. };
  2204. (() => {
  2205. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientModule, [{
  2206. type: NgModule,
  2207. args: [{
  2208. /**
  2209. * Configures the dependency injector where it is imported
  2210. * with supporting services for HTTP communications.
  2211. */
  2212. providers: [provideHttpClient(withInterceptorsFromDi())]
  2213. }]
  2214. }], null, null);
  2215. })();
  2216. var HttpClientJsonpModule = class _HttpClientJsonpModule {
  2217. static ɵfac = function HttpClientJsonpModule_Factory(__ngFactoryType__) {
  2218. return new (__ngFactoryType__ || _HttpClientJsonpModule)();
  2219. };
  2220. static ɵmod = ɵɵdefineNgModule({
  2221. type: _HttpClientJsonpModule
  2222. });
  2223. static ɵinj = ɵɵdefineInjector({
  2224. providers: [withJsonpSupport().ɵproviders]
  2225. });
  2226. };
  2227. (() => {
  2228. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientJsonpModule, [{
  2229. type: NgModule,
  2230. args: [{
  2231. providers: [withJsonpSupport().ɵproviders]
  2232. }]
  2233. }], null, null);
  2234. })();
  2235. var httpResource = (() => {
  2236. const jsonFn = makeHttpResourceFn("json");
  2237. jsonFn.arrayBuffer = makeHttpResourceFn("arraybuffer");
  2238. jsonFn.blob = makeHttpResourceFn("blob");
  2239. jsonFn.text = makeHttpResourceFn("text");
  2240. return jsonFn;
  2241. })();
  2242. function makeHttpResourceFn(responseType) {
  2243. return function httpResourceRef(request, options) {
  2244. options?.injector || assertInInjectionContext(httpResource);
  2245. const injector = options?.injector ?? inject(Injector);
  2246. return new HttpResourceImpl(injector, () => normalizeRequest(request, responseType), options?.defaultValue, options?.parse, options?.equal);
  2247. };
  2248. }
  2249. function normalizeRequest(request, responseType) {
  2250. let unwrappedRequest = typeof request === "function" ? request() : request;
  2251. if (unwrappedRequest === void 0) {
  2252. return void 0;
  2253. } else if (typeof unwrappedRequest === "string") {
  2254. unwrappedRequest = {
  2255. url: unwrappedRequest
  2256. };
  2257. }
  2258. const headers = unwrappedRequest.headers instanceof HttpHeaders ? unwrappedRequest.headers : new HttpHeaders(unwrappedRequest.headers);
  2259. const params = unwrappedRequest.params instanceof HttpParams ? unwrappedRequest.params : new HttpParams({
  2260. fromObject: unwrappedRequest.params
  2261. });
  2262. return new HttpRequest(unwrappedRequest.method ?? "GET", unwrappedRequest.url, unwrappedRequest.body ?? null, {
  2263. headers,
  2264. params,
  2265. reportProgress: unwrappedRequest.reportProgress,
  2266. withCredentials: unwrappedRequest.withCredentials,
  2267. responseType,
  2268. context: unwrappedRequest.context,
  2269. transferCache: unwrappedRequest.transferCache
  2270. });
  2271. }
  2272. var HttpResourceImpl = class extends ResourceImpl {
  2273. client;
  2274. _headers = linkedSignal({
  2275. source: this.extRequest,
  2276. computation: () => void 0
  2277. });
  2278. _progress = linkedSignal({
  2279. source: this.extRequest,
  2280. computation: () => void 0
  2281. });
  2282. _statusCode = linkedSignal({
  2283. source: this.extRequest,
  2284. computation: () => void 0
  2285. });
  2286. headers = computed(() => this.status() === ResourceStatus.Resolved || this.status() === ResourceStatus.Error ? this._headers() : void 0);
  2287. progress = this._progress.asReadonly();
  2288. statusCode = this._statusCode.asReadonly();
  2289. constructor(injector, request, defaultValue, parse, equal) {
  2290. super(request, ({
  2291. request: request2,
  2292. abortSignal
  2293. }) => {
  2294. let sub;
  2295. const onAbort = () => sub.unsubscribe();
  2296. abortSignal.addEventListener("abort", onAbort);
  2297. const stream = signal({
  2298. value: void 0
  2299. });
  2300. let resolve;
  2301. const promise = new Promise((r) => resolve = r);
  2302. const send = (value) => {
  2303. stream.set(value);
  2304. resolve?.(stream);
  2305. resolve = void 0;
  2306. };
  2307. sub = this.client.request(request2).subscribe({
  2308. next: (event) => {
  2309. switch (event.type) {
  2310. case HttpEventType.Response:
  2311. this._headers.set(event.headers);
  2312. this._statusCode.set(event.status);
  2313. try {
  2314. send({
  2315. value: parse ? parse(event.body) : event.body
  2316. });
  2317. } catch (error) {
  2318. send({
  2319. error
  2320. });
  2321. }
  2322. break;
  2323. case HttpEventType.DownloadProgress:
  2324. this._progress.set(event);
  2325. break;
  2326. }
  2327. },
  2328. error: (error) => send({
  2329. error
  2330. }),
  2331. complete: () => {
  2332. if (resolve) {
  2333. send({
  2334. error: new Error("Resource completed before producing a value")
  2335. });
  2336. }
  2337. abortSignal.removeEventListener("abort", onAbort);
  2338. }
  2339. });
  2340. return promise;
  2341. }, defaultValue, equal, injector);
  2342. this.client = injector.get(HttpClient);
  2343. }
  2344. };
  2345. var HTTP_TRANSFER_CACHE_ORIGIN_MAP = new InjectionToken(ngDevMode ? "HTTP_TRANSFER_CACHE_ORIGIN_MAP" : "");
  2346. var BODY = "b";
  2347. var HEADERS = "h";
  2348. var STATUS = "s";
  2349. var STATUS_TEXT = "st";
  2350. var REQ_URL = "u";
  2351. var RESPONSE_TYPE = "rt";
  2352. var CACHE_OPTIONS = new InjectionToken(ngDevMode ? "HTTP_TRANSFER_STATE_CACHE_OPTIONS" : "");
  2353. var ALLOWED_METHODS = ["GET", "HEAD"];
  2354. function transferCacheInterceptorFn(req, next) {
  2355. const _a = inject(CACHE_OPTIONS), {
  2356. isCacheActive
  2357. } = _a, globalOptions = __objRest(_a, [
  2358. "isCacheActive"
  2359. ]);
  2360. const {
  2361. transferCache: requestOptions,
  2362. method: requestMethod
  2363. } = req;
  2364. if (!isCacheActive || requestOptions === false || // POST requests are allowed either globally or at request level
  2365. requestMethod === "POST" && !globalOptions.includePostRequests && !requestOptions || requestMethod !== "POST" && !ALLOWED_METHODS.includes(requestMethod) || // Do not cache request that require authorization when includeRequestsWithAuthHeaders is falsey
  2366. !globalOptions.includeRequestsWithAuthHeaders && hasAuthHeaders(req) || globalOptions.filter?.(req) === false) {
  2367. return next(req);
  2368. }
  2369. const transferState = inject(TransferState);
  2370. const originMap = inject(HTTP_TRANSFER_CACHE_ORIGIN_MAP, {
  2371. optional: true
  2372. });
  2373. if (originMap) {
  2374. throw new RuntimeError(2803, ngDevMode && "Angular detected that the `HTTP_TRANSFER_CACHE_ORIGIN_MAP` token is configured and present in the client side code. Please ensure that this token is only provided in the server code of the application.");
  2375. }
  2376. const requestUrl = false ? mapRequestOriginUrl(req.url, originMap) : req.url;
  2377. const storeKey = makeCacheKey(req, requestUrl);
  2378. const response = transferState.get(storeKey, null);
  2379. let headersToInclude = globalOptions.includeHeaders;
  2380. if (typeof requestOptions === "object" && requestOptions.includeHeaders) {
  2381. headersToInclude = requestOptions.includeHeaders;
  2382. }
  2383. if (response) {
  2384. const {
  2385. [BODY]: undecodedBody,
  2386. [RESPONSE_TYPE]: responseType,
  2387. [HEADERS]: httpHeaders,
  2388. [STATUS]: status,
  2389. [STATUS_TEXT]: statusText,
  2390. [REQ_URL]: url
  2391. } = response;
  2392. let body = undecodedBody;
  2393. switch (responseType) {
  2394. case "arraybuffer":
  2395. body = new TextEncoder().encode(undecodedBody).buffer;
  2396. break;
  2397. case "blob":
  2398. body = new Blob([undecodedBody]);
  2399. break;
  2400. }
  2401. let headers = new HttpHeaders(httpHeaders);
  2402. if (typeof ngDevMode === "undefined" || ngDevMode) {
  2403. headers = appendMissingHeadersDetection(req.url, headers, headersToInclude ?? []);
  2404. }
  2405. return of(new HttpResponse({
  2406. body,
  2407. headers,
  2408. status,
  2409. statusText,
  2410. url
  2411. }));
  2412. }
  2413. return next(req).pipe(tap((event) => {
  2414. if (event instanceof HttpResponse && true && false) {
  2415. transferState.set(storeKey, {
  2416. [BODY]: event.body,
  2417. [HEADERS]: getFilteredHeaders(event.headers, headersToInclude),
  2418. [STATUS]: event.status,
  2419. [STATUS_TEXT]: event.statusText,
  2420. [REQ_URL]: requestUrl,
  2421. [RESPONSE_TYPE]: req.responseType
  2422. });
  2423. }
  2424. }));
  2425. }
  2426. function hasAuthHeaders(req) {
  2427. return req.headers.has("authorization") || req.headers.has("proxy-authorization");
  2428. }
  2429. function sortAndConcatParams(params) {
  2430. return [...params.keys()].sort().map((k) => `${k}=${params.getAll(k)}`).join("&");
  2431. }
  2432. function makeCacheKey(request, mappedRequestUrl) {
  2433. const {
  2434. params,
  2435. method,
  2436. responseType
  2437. } = request;
  2438. const encodedParams = sortAndConcatParams(params);
  2439. let serializedBody = request.serializeBody();
  2440. if (serializedBody instanceof URLSearchParams) {
  2441. serializedBody = sortAndConcatParams(serializedBody);
  2442. } else if (typeof serializedBody !== "string") {
  2443. serializedBody = "";
  2444. }
  2445. const key = [method, responseType, mappedRequestUrl, serializedBody, encodedParams].join("|");
  2446. const hash = generateHash(key);
  2447. return makeStateKey(hash);
  2448. }
  2449. function generateHash(value) {
  2450. let hash = 0;
  2451. for (const char of value) {
  2452. hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
  2453. }
  2454. hash += 2147483647 + 1;
  2455. return hash.toString();
  2456. }
  2457. function withHttpTransferCache(cacheOptions) {
  2458. return [{
  2459. provide: CACHE_OPTIONS,
  2460. useFactory: () => {
  2461. performanceMarkFeature("NgHttpTransferCache");
  2462. return __spreadValues({
  2463. isCacheActive: true
  2464. }, cacheOptions);
  2465. }
  2466. }, {
  2467. provide: HTTP_ROOT_INTERCEPTOR_FNS,
  2468. useValue: transferCacheInterceptorFn,
  2469. multi: true
  2470. }, {
  2471. provide: APP_BOOTSTRAP_LISTENER,
  2472. multi: true,
  2473. useFactory: () => {
  2474. const appRef = inject(ApplicationRef);
  2475. const cacheState = inject(CACHE_OPTIONS);
  2476. return () => {
  2477. appRef.whenStable().then(() => {
  2478. cacheState.isCacheActive = false;
  2479. });
  2480. };
  2481. }
  2482. }];
  2483. }
  2484. function appendMissingHeadersDetection(url, headers, headersToInclude) {
  2485. const warningProduced = /* @__PURE__ */ new Set();
  2486. return new Proxy(headers, {
  2487. get(target, prop) {
  2488. const value = Reflect.get(target, prop);
  2489. const methods = /* @__PURE__ */ new Set(["get", "has", "getAll"]);
  2490. if (typeof value !== "function" || !methods.has(prop)) {
  2491. return value;
  2492. }
  2493. return (headerName) => {
  2494. const key = (prop + ":" + headerName).toLowerCase();
  2495. if (!headersToInclude.includes(headerName) && !warningProduced.has(key)) {
  2496. warningProduced.add(key);
  2497. const truncatedUrl = truncateMiddle(url);
  2498. console.warn(formatRuntimeError(2802, `Angular detected that the \`${headerName}\` header is accessed, but the value of the header was not transferred from the server to the client by the HttpTransferCache. To include the value of the \`${headerName}\` header for the \`${truncatedUrl}\` request, use the \`includeHeaders\` list. The \`includeHeaders\` can be defined either on a request level by adding the \`transferCache\` parameter, or on an application level by adding the \`httpCacheTransfer.includeHeaders\` argument to the \`provideClientHydration()\` call. `));
  2499. }
  2500. return value.apply(target, [headerName]);
  2501. };
  2502. }
  2503. });
  2504. }
  2505. // node_modules/@angular/platform-browser/fesm2022/platform-browser.mjs
  2506. var GenericBrowserDomAdapter = class extends DomAdapter {
  2507. supportsDOMEvents = true;
  2508. };
  2509. var BrowserDomAdapter = class _BrowserDomAdapter extends GenericBrowserDomAdapter {
  2510. static makeCurrent() {
  2511. setRootDomAdapter(new _BrowserDomAdapter());
  2512. }
  2513. onAndCancel(el, evt, listener, options) {
  2514. el.addEventListener(evt, listener, options);
  2515. return () => {
  2516. el.removeEventListener(evt, listener, options);
  2517. };
  2518. }
  2519. dispatchEvent(el, evt) {
  2520. el.dispatchEvent(evt);
  2521. }
  2522. remove(node) {
  2523. node.remove();
  2524. }
  2525. createElement(tagName, doc) {
  2526. doc = doc || this.getDefaultDocument();
  2527. return doc.createElement(tagName);
  2528. }
  2529. createHtmlDocument() {
  2530. return document.implementation.createHTMLDocument("fakeTitle");
  2531. }
  2532. getDefaultDocument() {
  2533. return document;
  2534. }
  2535. isElementNode(node) {
  2536. return node.nodeType === Node.ELEMENT_NODE;
  2537. }
  2538. isShadowRoot(node) {
  2539. return node instanceof DocumentFragment;
  2540. }
  2541. /** @deprecated No longer being used in Ivy code. To be removed in version 14. */
  2542. getGlobalEventTarget(doc, target) {
  2543. if (target === "window") {
  2544. return window;
  2545. }
  2546. if (target === "document") {
  2547. return doc;
  2548. }
  2549. if (target === "body") {
  2550. return doc.body;
  2551. }
  2552. return null;
  2553. }
  2554. getBaseHref(doc) {
  2555. const href = getBaseElementHref();
  2556. return href == null ? null : relativePath(href);
  2557. }
  2558. resetBaseElement() {
  2559. baseElement = null;
  2560. }
  2561. getUserAgent() {
  2562. return window.navigator.userAgent;
  2563. }
  2564. getCookie(name) {
  2565. return parseCookieValue(document.cookie, name);
  2566. }
  2567. };
  2568. var baseElement = null;
  2569. function getBaseElementHref() {
  2570. baseElement = baseElement || document.querySelector("base");
  2571. return baseElement ? baseElement.getAttribute("href") : null;
  2572. }
  2573. function relativePath(url) {
  2574. return new URL(url, document.baseURI).pathname;
  2575. }
  2576. var BrowserGetTestability = class {
  2577. addToWindow(registry) {
  2578. _global["getAngularTestability"] = (elem, findInAncestors = true) => {
  2579. const testability = registry.findTestabilityInTree(elem, findInAncestors);
  2580. if (testability == null) {
  2581. throw new RuntimeError(5103, (typeof ngDevMode === "undefined" || ngDevMode) && "Could not find testability for element.");
  2582. }
  2583. return testability;
  2584. };
  2585. _global["getAllAngularTestabilities"] = () => registry.getAllTestabilities();
  2586. _global["getAllAngularRootElements"] = () => registry.getAllRootElements();
  2587. const whenAllStable = (callback) => {
  2588. const testabilities = _global["getAllAngularTestabilities"]();
  2589. let count = testabilities.length;
  2590. const decrement = function() {
  2591. count--;
  2592. if (count == 0) {
  2593. callback();
  2594. }
  2595. };
  2596. testabilities.forEach((testability) => {
  2597. testability.whenStable(decrement);
  2598. });
  2599. };
  2600. if (!_global["frameworkStabilizers"]) {
  2601. _global["frameworkStabilizers"] = [];
  2602. }
  2603. _global["frameworkStabilizers"].push(whenAllStable);
  2604. }
  2605. findTestabilityInTree(registry, elem, findInAncestors) {
  2606. if (elem == null) {
  2607. return null;
  2608. }
  2609. const t = registry.getTestability(elem);
  2610. if (t != null) {
  2611. return t;
  2612. } else if (!findInAncestors) {
  2613. return null;
  2614. }
  2615. if (getDOM().isShadowRoot(elem)) {
  2616. return this.findTestabilityInTree(registry, elem.host, true);
  2617. }
  2618. return this.findTestabilityInTree(registry, elem.parentElement, true);
  2619. }
  2620. };
  2621. var BrowserXhr = class _BrowserXhr {
  2622. build() {
  2623. return new XMLHttpRequest();
  2624. }
  2625. static ɵfac = function BrowserXhr_Factory(__ngFactoryType__) {
  2626. return new (__ngFactoryType__ || _BrowserXhr)();
  2627. };
  2628. static ɵprov = ɵɵdefineInjectable({
  2629. token: _BrowserXhr,
  2630. factory: _BrowserXhr.ɵfac
  2631. });
  2632. };
  2633. (() => {
  2634. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(BrowserXhr, [{
  2635. type: Injectable
  2636. }], null, null);
  2637. })();
  2638. var EVENT_MANAGER_PLUGINS = new InjectionToken(ngDevMode ? "EventManagerPlugins" : "");
  2639. var EventManager = class _EventManager {
  2640. _zone;
  2641. _plugins;
  2642. _eventNameToPlugin = /* @__PURE__ */ new Map();
  2643. /**
  2644. * Initializes an instance of the event-manager service.
  2645. */
  2646. constructor(plugins, _zone) {
  2647. this._zone = _zone;
  2648. plugins.forEach((plugin) => {
  2649. plugin.manager = this;
  2650. });
  2651. this._plugins = plugins.slice().reverse();
  2652. }
  2653. /**
  2654. * Registers a handler for a specific element and event.
  2655. *
  2656. * @param element The HTML element to receive event notifications.
  2657. * @param eventName The name of the event to listen for.
  2658. * @param handler A function to call when the notification occurs. Receives the
  2659. * event object as an argument.
  2660. * @param options Options that configure how the event listener is bound.
  2661. * @returns A callback function that can be used to remove the handler.
  2662. */
  2663. addEventListener(element, eventName, handler, options) {
  2664. const plugin = this._findPluginFor(eventName);
  2665. return plugin.addEventListener(element, eventName, handler, options);
  2666. }
  2667. /**
  2668. * Retrieves the compilation zone in which event listeners are registered.
  2669. */
  2670. getZone() {
  2671. return this._zone;
  2672. }
  2673. /** @internal */
  2674. _findPluginFor(eventName) {
  2675. let plugin = this._eventNameToPlugin.get(eventName);
  2676. if (plugin) {
  2677. return plugin;
  2678. }
  2679. const plugins = this._plugins;
  2680. plugin = plugins.find((plugin2) => plugin2.supports(eventName));
  2681. if (!plugin) {
  2682. throw new RuntimeError(5101, (typeof ngDevMode === "undefined" || ngDevMode) && `No event manager plugin found for event ${eventName}`);
  2683. }
  2684. this._eventNameToPlugin.set(eventName, plugin);
  2685. return plugin;
  2686. }
  2687. static ɵfac = function EventManager_Factory(__ngFactoryType__) {
  2688. return new (__ngFactoryType__ || _EventManager)(ɵɵinject(EVENT_MANAGER_PLUGINS), ɵɵinject(NgZone));
  2689. };
  2690. static ɵprov = ɵɵdefineInjectable({
  2691. token: _EventManager,
  2692. factory: _EventManager.ɵfac
  2693. });
  2694. };
  2695. (() => {
  2696. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(EventManager, [{
  2697. type: Injectable
  2698. }], () => [{
  2699. type: void 0,
  2700. decorators: [{
  2701. type: Inject,
  2702. args: [EVENT_MANAGER_PLUGINS]
  2703. }]
  2704. }, {
  2705. type: NgZone
  2706. }], null);
  2707. })();
  2708. var EventManagerPlugin = class {
  2709. _doc;
  2710. // TODO: remove (has some usage in G3)
  2711. constructor(_doc) {
  2712. this._doc = _doc;
  2713. }
  2714. // Using non-null assertion because it's set by EventManager's constructor
  2715. manager;
  2716. };
  2717. var APP_ID_ATTRIBUTE_NAME = "ng-app-id";
  2718. function removeElements(elements) {
  2719. for (const element of elements) {
  2720. element.remove();
  2721. }
  2722. }
  2723. function createStyleElement(style, doc) {
  2724. const styleElement = doc.createElement("style");
  2725. styleElement.textContent = style;
  2726. return styleElement;
  2727. }
  2728. function addServerStyles(doc, appId, inline, external) {
  2729. const elements = doc.head?.querySelectorAll(`style[${APP_ID_ATTRIBUTE_NAME}="${appId}"],link[${APP_ID_ATTRIBUTE_NAME}="${appId}"]`);
  2730. if (elements) {
  2731. for (const styleElement of elements) {
  2732. styleElement.removeAttribute(APP_ID_ATTRIBUTE_NAME);
  2733. if (styleElement instanceof HTMLLinkElement) {
  2734. external.set(styleElement.href.slice(styleElement.href.lastIndexOf("/") + 1), {
  2735. usage: 0,
  2736. elements: [styleElement]
  2737. });
  2738. } else if (styleElement.textContent) {
  2739. inline.set(styleElement.textContent, {
  2740. usage: 0,
  2741. elements: [styleElement]
  2742. });
  2743. }
  2744. }
  2745. }
  2746. }
  2747. function createLinkElement(url, doc) {
  2748. const linkElement = doc.createElement("link");
  2749. linkElement.setAttribute("rel", "stylesheet");
  2750. linkElement.setAttribute("href", url);
  2751. return linkElement;
  2752. }
  2753. var SharedStylesHost = class _SharedStylesHost {
  2754. doc;
  2755. appId;
  2756. nonce;
  2757. /**
  2758. * Provides usage information for active inline style content and associated HTML <style> elements.
  2759. * Embedded styles typically originate from the `styles` metadata of a rendered component.
  2760. */
  2761. inline = /* @__PURE__ */ new Map();
  2762. /**
  2763. * Provides usage information for active external style URLs and the associated HTML <link> elements.
  2764. * External styles typically originate from the `ɵɵExternalStylesFeature` of a rendered component.
  2765. */
  2766. external = /* @__PURE__ */ new Map();
  2767. /**
  2768. * Set of host DOM nodes that will have styles attached.
  2769. */
  2770. hosts = /* @__PURE__ */ new Set();
  2771. /**
  2772. * Whether the application code is currently executing on a server.
  2773. */
  2774. isServer;
  2775. constructor(doc, appId, nonce, platformId = {}) {
  2776. this.doc = doc;
  2777. this.appId = appId;
  2778. this.nonce = nonce;
  2779. this.isServer = isPlatformServer(platformId);
  2780. addServerStyles(doc, appId, this.inline, this.external);
  2781. this.hosts.add(doc.head);
  2782. }
  2783. /**
  2784. * Adds embedded styles to the DOM via HTML `style` elements.
  2785. * @param styles An array of style content strings.
  2786. */
  2787. addStyles(styles, urls) {
  2788. for (const value of styles) {
  2789. this.addUsage(value, this.inline, createStyleElement);
  2790. }
  2791. urls?.forEach((value) => this.addUsage(value, this.external, createLinkElement));
  2792. }
  2793. /**
  2794. * Removes embedded styles from the DOM that were added as HTML `style` elements.
  2795. * @param styles An array of style content strings.
  2796. */
  2797. removeStyles(styles, urls) {
  2798. for (const value of styles) {
  2799. this.removeUsage(value, this.inline);
  2800. }
  2801. urls?.forEach((value) => this.removeUsage(value, this.external));
  2802. }
  2803. addUsage(value, usages, creator) {
  2804. const record = usages.get(value);
  2805. if (record) {
  2806. if ((typeof ngDevMode === "undefined" || ngDevMode) && record.usage === 0) {
  2807. record.elements.forEach((element) => element.setAttribute("ng-style-reused", ""));
  2808. }
  2809. record.usage++;
  2810. } else {
  2811. usages.set(value, {
  2812. usage: 1,
  2813. elements: [...this.hosts].map((host) => this.addElement(host, creator(value, this.doc)))
  2814. });
  2815. }
  2816. }
  2817. removeUsage(value, usages) {
  2818. const record = usages.get(value);
  2819. if (record) {
  2820. record.usage--;
  2821. if (record.usage <= 0) {
  2822. removeElements(record.elements);
  2823. usages.delete(value);
  2824. }
  2825. }
  2826. }
  2827. ngOnDestroy() {
  2828. for (const [, {
  2829. elements
  2830. }] of [...this.inline, ...this.external]) {
  2831. removeElements(elements);
  2832. }
  2833. this.hosts.clear();
  2834. }
  2835. /**
  2836. * Adds a host node to the set of style hosts and adds all existing style usage to
  2837. * the newly added host node.
  2838. *
  2839. * This is currently only used for Shadow DOM encapsulation mode.
  2840. */
  2841. addHost(hostNode) {
  2842. this.hosts.add(hostNode);
  2843. for (const [style, {
  2844. elements
  2845. }] of this.inline) {
  2846. elements.push(this.addElement(hostNode, createStyleElement(style, this.doc)));
  2847. }
  2848. for (const [url, {
  2849. elements
  2850. }] of this.external) {
  2851. elements.push(this.addElement(hostNode, createLinkElement(url, this.doc)));
  2852. }
  2853. }
  2854. removeHost(hostNode) {
  2855. this.hosts.delete(hostNode);
  2856. }
  2857. addElement(host, element) {
  2858. if (this.nonce) {
  2859. element.setAttribute("nonce", this.nonce);
  2860. }
  2861. if (this.isServer) {
  2862. element.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
  2863. }
  2864. return host.appendChild(element);
  2865. }
  2866. static ɵfac = function SharedStylesHost_Factory(__ngFactoryType__) {
  2867. return new (__ngFactoryType__ || _SharedStylesHost)(ɵɵinject(DOCUMENT), ɵɵinject(APP_ID), ɵɵinject(CSP_NONCE, 8), ɵɵinject(PLATFORM_ID));
  2868. };
  2869. static ɵprov = ɵɵdefineInjectable({
  2870. token: _SharedStylesHost,
  2871. factory: _SharedStylesHost.ɵfac
  2872. });
  2873. };
  2874. (() => {
  2875. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(SharedStylesHost, [{
  2876. type: Injectable
  2877. }], () => [{
  2878. type: Document,
  2879. decorators: [{
  2880. type: Inject,
  2881. args: [DOCUMENT]
  2882. }]
  2883. }, {
  2884. type: void 0,
  2885. decorators: [{
  2886. type: Inject,
  2887. args: [APP_ID]
  2888. }]
  2889. }, {
  2890. type: void 0,
  2891. decorators: [{
  2892. type: Inject,
  2893. args: [CSP_NONCE]
  2894. }, {
  2895. type: Optional
  2896. }]
  2897. }, {
  2898. type: void 0,
  2899. decorators: [{
  2900. type: Inject,
  2901. args: [PLATFORM_ID]
  2902. }]
  2903. }], null);
  2904. })();
  2905. var NAMESPACE_URIS = {
  2906. "svg": "http://www.w3.org/2000/svg",
  2907. "xhtml": "http://www.w3.org/1999/xhtml",
  2908. "xlink": "http://www.w3.org/1999/xlink",
  2909. "xml": "http://www.w3.org/XML/1998/namespace",
  2910. "xmlns": "http://www.w3.org/2000/xmlns/",
  2911. "math": "http://www.w3.org/1998/Math/MathML"
  2912. };
  2913. var COMPONENT_REGEX = /%COMP%/g;
  2914. var SOURCEMAP_URL_REGEXP = /\/\*#\s*sourceMappingURL=(.+?)\s*\*\//;
  2915. var PROTOCOL_REGEXP = /^https?:/;
  2916. var COMPONENT_VARIABLE = "%COMP%";
  2917. var HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
  2918. var CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
  2919. var REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT = true;
  2920. var REMOVE_STYLES_ON_COMPONENT_DESTROY = new InjectionToken(ngDevMode ? "RemoveStylesOnCompDestroy" : "", {
  2921. providedIn: "root",
  2922. factory: () => REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT
  2923. });
  2924. function shimContentAttribute(componentShortId) {
  2925. return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2926. }
  2927. function shimHostAttribute(componentShortId) {
  2928. return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2929. }
  2930. function shimStylesContent(compId, styles) {
  2931. return styles.map((s) => s.replace(COMPONENT_REGEX, compId));
  2932. }
  2933. function addBaseHrefToCssSourceMap(baseHref, styles) {
  2934. if (!baseHref) {
  2935. return styles;
  2936. }
  2937. const absoluteBaseHrefUrl = new URL(baseHref, "http://localhost");
  2938. return styles.map((cssContent) => {
  2939. if (!cssContent.includes("sourceMappingURL=")) {
  2940. return cssContent;
  2941. }
  2942. return cssContent.replace(SOURCEMAP_URL_REGEXP, (_, sourceMapUrl) => {
  2943. if (sourceMapUrl[0] === "/" || sourceMapUrl.startsWith("data:") || PROTOCOL_REGEXP.test(sourceMapUrl)) {
  2944. return `/*# sourceMappingURL=${sourceMapUrl} */`;
  2945. }
  2946. const {
  2947. pathname: resolvedSourceMapUrl
  2948. } = new URL(sourceMapUrl, absoluteBaseHrefUrl);
  2949. return `/*# sourceMappingURL=${resolvedSourceMapUrl} */`;
  2950. });
  2951. });
  2952. }
  2953. var DomRendererFactory2 = class _DomRendererFactory2 {
  2954. eventManager;
  2955. sharedStylesHost;
  2956. appId;
  2957. removeStylesOnCompDestroy;
  2958. doc;
  2959. platformId;
  2960. ngZone;
  2961. nonce;
  2962. tracingService;
  2963. rendererByCompId = /* @__PURE__ */ new Map();
  2964. defaultRenderer;
  2965. platformIsServer;
  2966. constructor(eventManager, sharedStylesHost, appId, removeStylesOnCompDestroy, doc, platformId, ngZone, nonce = null, tracingService = null) {
  2967. this.eventManager = eventManager;
  2968. this.sharedStylesHost = sharedStylesHost;
  2969. this.appId = appId;
  2970. this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
  2971. this.doc = doc;
  2972. this.platformId = platformId;
  2973. this.ngZone = ngZone;
  2974. this.nonce = nonce;
  2975. this.tracingService = tracingService;
  2976. this.platformIsServer = isPlatformServer(platformId);
  2977. this.defaultRenderer = new DefaultDomRenderer2(eventManager, doc, ngZone, this.platformIsServer, this.tracingService);
  2978. }
  2979. createRenderer(element, type) {
  2980. if (!element || !type) {
  2981. return this.defaultRenderer;
  2982. }
  2983. if (this.platformIsServer && type.encapsulation === ViewEncapsulation.ShadowDom) {
  2984. type = __spreadProps(__spreadValues({}, type), {
  2985. encapsulation: ViewEncapsulation.Emulated
  2986. });
  2987. }
  2988. const renderer = this.getOrCreateRenderer(element, type);
  2989. if (renderer instanceof EmulatedEncapsulationDomRenderer2) {
  2990. renderer.applyToHost(element);
  2991. } else if (renderer instanceof NoneEncapsulationDomRenderer) {
  2992. renderer.applyStyles();
  2993. }
  2994. return renderer;
  2995. }
  2996. getOrCreateRenderer(element, type) {
  2997. const rendererByCompId = this.rendererByCompId;
  2998. let renderer = rendererByCompId.get(type.id);
  2999. if (!renderer) {
  3000. const doc = this.doc;
  3001. const ngZone = this.ngZone;
  3002. const eventManager = this.eventManager;
  3003. const sharedStylesHost = this.sharedStylesHost;
  3004. const removeStylesOnCompDestroy = this.removeStylesOnCompDestroy;
  3005. const platformIsServer = this.platformIsServer;
  3006. const tracingService = this.tracingService;
  3007. switch (type.encapsulation) {
  3008. case ViewEncapsulation.Emulated:
  3009. renderer = new EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, type, this.appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
  3010. break;
  3011. case ViewEncapsulation.ShadowDom:
  3012. return new ShadowDomRenderer(eventManager, sharedStylesHost, element, type, doc, ngZone, this.nonce, platformIsServer, tracingService);
  3013. default:
  3014. renderer = new NoneEncapsulationDomRenderer(eventManager, sharedStylesHost, type, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
  3015. break;
  3016. }
  3017. rendererByCompId.set(type.id, renderer);
  3018. }
  3019. return renderer;
  3020. }
  3021. ngOnDestroy() {
  3022. this.rendererByCompId.clear();
  3023. }
  3024. /**
  3025. * Used during HMR to clear any cached data about a component.
  3026. * @param componentId ID of the component that is being replaced.
  3027. */
  3028. componentReplaced(componentId) {
  3029. this.rendererByCompId.delete(componentId);
  3030. }
  3031. static ɵfac = function DomRendererFactory2_Factory(__ngFactoryType__) {
  3032. return new (__ngFactoryType__ || _DomRendererFactory2)(ɵɵinject(EventManager), ɵɵinject(SharedStylesHost), ɵɵinject(APP_ID), ɵɵinject(REMOVE_STYLES_ON_COMPONENT_DESTROY), ɵɵinject(DOCUMENT), ɵɵinject(PLATFORM_ID), ɵɵinject(NgZone), ɵɵinject(CSP_NONCE), ɵɵinject(TracingService, 8));
  3033. };
  3034. static ɵprov = ɵɵdefineInjectable({
  3035. token: _DomRendererFactory2,
  3036. factory: _DomRendererFactory2.ɵfac
  3037. });
  3038. };
  3039. (() => {
  3040. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DomRendererFactory2, [{
  3041. type: Injectable
  3042. }], () => [{
  3043. type: EventManager
  3044. }, {
  3045. type: SharedStylesHost
  3046. }, {
  3047. type: void 0,
  3048. decorators: [{
  3049. type: Inject,
  3050. args: [APP_ID]
  3051. }]
  3052. }, {
  3053. type: void 0,
  3054. decorators: [{
  3055. type: Inject,
  3056. args: [REMOVE_STYLES_ON_COMPONENT_DESTROY]
  3057. }]
  3058. }, {
  3059. type: Document,
  3060. decorators: [{
  3061. type: Inject,
  3062. args: [DOCUMENT]
  3063. }]
  3064. }, {
  3065. type: Object,
  3066. decorators: [{
  3067. type: Inject,
  3068. args: [PLATFORM_ID]
  3069. }]
  3070. }, {
  3071. type: NgZone
  3072. }, {
  3073. type: void 0,
  3074. decorators: [{
  3075. type: Inject,
  3076. args: [CSP_NONCE]
  3077. }]
  3078. }, {
  3079. type: TracingService,
  3080. decorators: [{
  3081. type: Inject,
  3082. args: [TracingService]
  3083. }, {
  3084. type: Optional
  3085. }]
  3086. }], null);
  3087. })();
  3088. var DefaultDomRenderer2 = class {
  3089. eventManager;
  3090. doc;
  3091. ngZone;
  3092. platformIsServer;
  3093. tracingService;
  3094. data = /* @__PURE__ */ Object.create(null);
  3095. /**
  3096. * By default this renderer throws when encountering synthetic properties
  3097. * This can be disabled for example by the AsyncAnimationRendererFactory
  3098. */
  3099. throwOnSyntheticProps = true;
  3100. constructor(eventManager, doc, ngZone, platformIsServer, tracingService) {
  3101. this.eventManager = eventManager;
  3102. this.doc = doc;
  3103. this.ngZone = ngZone;
  3104. this.platformIsServer = platformIsServer;
  3105. this.tracingService = tracingService;
  3106. }
  3107. destroy() {
  3108. }
  3109. destroyNode = null;
  3110. createElement(name, namespace) {
  3111. if (namespace) {
  3112. return this.doc.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
  3113. }
  3114. return this.doc.createElement(name);
  3115. }
  3116. createComment(value) {
  3117. return this.doc.createComment(value);
  3118. }
  3119. createText(value) {
  3120. return this.doc.createTextNode(value);
  3121. }
  3122. appendChild(parent, newChild) {
  3123. const targetParent = isTemplateNode(parent) ? parent.content : parent;
  3124. targetParent.appendChild(newChild);
  3125. }
  3126. insertBefore(parent, newChild, refChild) {
  3127. if (parent) {
  3128. const targetParent = isTemplateNode(parent) ? parent.content : parent;
  3129. targetParent.insertBefore(newChild, refChild);
  3130. }
  3131. }
  3132. removeChild(_parent, oldChild) {
  3133. oldChild.remove();
  3134. }
  3135. selectRootElement(selectorOrNode, preserveContent) {
  3136. let el = typeof selectorOrNode === "string" ? this.doc.querySelector(selectorOrNode) : selectorOrNode;
  3137. if (!el) {
  3138. throw new RuntimeError(-5104, (typeof ngDevMode === "undefined" || ngDevMode) && `The selector "${selectorOrNode}" did not match any elements`);
  3139. }
  3140. if (!preserveContent) {
  3141. el.textContent = "";
  3142. }
  3143. return el;
  3144. }
  3145. parentNode(node) {
  3146. return node.parentNode;
  3147. }
  3148. nextSibling(node) {
  3149. return node.nextSibling;
  3150. }
  3151. setAttribute(el, name, value, namespace) {
  3152. if (namespace) {
  3153. name = namespace + ":" + name;
  3154. const namespaceUri = NAMESPACE_URIS[namespace];
  3155. if (namespaceUri) {
  3156. el.setAttributeNS(namespaceUri, name, value);
  3157. } else {
  3158. el.setAttribute(name, value);
  3159. }
  3160. } else {
  3161. el.setAttribute(name, value);
  3162. }
  3163. }
  3164. removeAttribute(el, name, namespace) {
  3165. if (namespace) {
  3166. const namespaceUri = NAMESPACE_URIS[namespace];
  3167. if (namespaceUri) {
  3168. el.removeAttributeNS(namespaceUri, name);
  3169. } else {
  3170. el.removeAttribute(`${namespace}:${name}`);
  3171. }
  3172. } else {
  3173. el.removeAttribute(name);
  3174. }
  3175. }
  3176. addClass(el, name) {
  3177. el.classList.add(name);
  3178. }
  3179. removeClass(el, name) {
  3180. el.classList.remove(name);
  3181. }
  3182. setStyle(el, style, value, flags) {
  3183. if (flags & (RendererStyleFlags2.DashCase | RendererStyleFlags2.Important)) {
  3184. el.style.setProperty(style, value, flags & RendererStyleFlags2.Important ? "important" : "");
  3185. } else {
  3186. el.style[style] = value;
  3187. }
  3188. }
  3189. removeStyle(el, style, flags) {
  3190. if (flags & RendererStyleFlags2.DashCase) {
  3191. el.style.removeProperty(style);
  3192. } else {
  3193. el.style[style] = "";
  3194. }
  3195. }
  3196. setProperty(el, name, value) {
  3197. if (el == null) {
  3198. return;
  3199. }
  3200. (typeof ngDevMode === "undefined" || ngDevMode) && this.throwOnSyntheticProps && checkNoSyntheticProp(name, "property");
  3201. el[name] = value;
  3202. }
  3203. setValue(node, value) {
  3204. node.nodeValue = value;
  3205. }
  3206. listen(target, event, callback, options) {
  3207. (typeof ngDevMode === "undefined" || ngDevMode) && this.throwOnSyntheticProps && checkNoSyntheticProp(event, "listener");
  3208. if (typeof target === "string") {
  3209. target = getDOM().getGlobalEventTarget(this.doc, target);
  3210. if (!target) {
  3211. throw new RuntimeError(5102, (typeof ngDevMode === "undefined" || ngDevMode) && `Unsupported event target ${target} for event ${event}`);
  3212. }
  3213. }
  3214. let wrappedCallback = this.decoratePreventDefault(callback);
  3215. if (this.tracingService?.wrapEventListener) {
  3216. wrappedCallback = this.tracingService.wrapEventListener(target, event, wrappedCallback);
  3217. }
  3218. return this.eventManager.addEventListener(target, event, wrappedCallback, options);
  3219. }
  3220. decoratePreventDefault(eventHandler) {
  3221. return (event) => {
  3222. if (event === "__ngUnwrap__") {
  3223. return eventHandler;
  3224. }
  3225. const allowDefaultBehavior = this.platformIsServer ? this.ngZone.runGuarded(() => eventHandler(event)) : eventHandler(event);
  3226. if (allowDefaultBehavior === false) {
  3227. event.preventDefault();
  3228. }
  3229. return void 0;
  3230. };
  3231. }
  3232. };
  3233. var AT_CHARCODE = (() => "@".charCodeAt(0))();
  3234. function checkNoSyntheticProp(name, nameKind) {
  3235. if (name.charCodeAt(0) === AT_CHARCODE) {
  3236. throw new RuntimeError(5105, `Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
  3237. - Make sure \`provideAnimationsAsync()\`, \`provideAnimations()\` or \`provideNoopAnimations()\` call was added to a list of providers used to bootstrap an application.
  3238. - There is a corresponding animation configuration named \`${name}\` defined in the \`animations\` field of the \`@Component\` decorator (see https://angular.dev/api/core/Component#animations).`);
  3239. }
  3240. }
  3241. function isTemplateNode(node) {
  3242. return node.tagName === "TEMPLATE" && node.content !== void 0;
  3243. }
  3244. var ShadowDomRenderer = class extends DefaultDomRenderer2 {
  3245. sharedStylesHost;
  3246. hostEl;
  3247. shadowRoot;
  3248. constructor(eventManager, sharedStylesHost, hostEl, component, doc, ngZone, nonce, platformIsServer, tracingService) {
  3249. super(eventManager, doc, ngZone, platformIsServer, tracingService);
  3250. this.sharedStylesHost = sharedStylesHost;
  3251. this.hostEl = hostEl;
  3252. this.shadowRoot = hostEl.attachShadow({
  3253. mode: "open"
  3254. });
  3255. this.sharedStylesHost.addHost(this.shadowRoot);
  3256. let styles = component.styles;
  3257. if (ngDevMode) {
  3258. const baseHref = getDOM().getBaseHref(doc) ?? "";
  3259. styles = addBaseHrefToCssSourceMap(baseHref, styles);
  3260. }
  3261. styles = shimStylesContent(component.id, styles);
  3262. for (const style of styles) {
  3263. const styleEl = document.createElement("style");
  3264. if (nonce) {
  3265. styleEl.setAttribute("nonce", nonce);
  3266. }
  3267. styleEl.textContent = style;
  3268. this.shadowRoot.appendChild(styleEl);
  3269. }
  3270. const styleUrls = component.getExternalStyles?.();
  3271. if (styleUrls) {
  3272. for (const styleUrl of styleUrls) {
  3273. const linkEl = createLinkElement(styleUrl, doc);
  3274. if (nonce) {
  3275. linkEl.setAttribute("nonce", nonce);
  3276. }
  3277. this.shadowRoot.appendChild(linkEl);
  3278. }
  3279. }
  3280. }
  3281. nodeOrShadowRoot(node) {
  3282. return node === this.hostEl ? this.shadowRoot : node;
  3283. }
  3284. appendChild(parent, newChild) {
  3285. return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
  3286. }
  3287. insertBefore(parent, newChild, refChild) {
  3288. return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
  3289. }
  3290. removeChild(_parent, oldChild) {
  3291. return super.removeChild(null, oldChild);
  3292. }
  3293. parentNode(node) {
  3294. return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
  3295. }
  3296. destroy() {
  3297. this.sharedStylesHost.removeHost(this.shadowRoot);
  3298. }
  3299. };
  3300. var NoneEncapsulationDomRenderer = class extends DefaultDomRenderer2 {
  3301. sharedStylesHost;
  3302. removeStylesOnCompDestroy;
  3303. styles;
  3304. styleUrls;
  3305. constructor(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId) {
  3306. super(eventManager, doc, ngZone, platformIsServer, tracingService);
  3307. this.sharedStylesHost = sharedStylesHost;
  3308. this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
  3309. let styles = component.styles;
  3310. if (ngDevMode) {
  3311. const baseHref = getDOM().getBaseHref(doc) ?? "";
  3312. styles = addBaseHrefToCssSourceMap(baseHref, styles);
  3313. }
  3314. this.styles = compId ? shimStylesContent(compId, styles) : styles;
  3315. this.styleUrls = component.getExternalStyles?.(compId);
  3316. }
  3317. applyStyles() {
  3318. this.sharedStylesHost.addStyles(this.styles, this.styleUrls);
  3319. }
  3320. destroy() {
  3321. if (!this.removeStylesOnCompDestroy) {
  3322. return;
  3323. }
  3324. this.sharedStylesHost.removeStyles(this.styles, this.styleUrls);
  3325. }
  3326. };
  3327. var EmulatedEncapsulationDomRenderer2 = class extends NoneEncapsulationDomRenderer {
  3328. contentAttr;
  3329. hostAttr;
  3330. constructor(eventManager, sharedStylesHost, component, appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService) {
  3331. const compId = appId + "-" + component.id;
  3332. super(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId);
  3333. this.contentAttr = shimContentAttribute(compId);
  3334. this.hostAttr = shimHostAttribute(compId);
  3335. }
  3336. applyToHost(element) {
  3337. this.applyStyles();
  3338. this.setAttribute(element, this.hostAttr, "");
  3339. }
  3340. createElement(parent, name) {
  3341. const el = super.createElement(parent, name);
  3342. super.setAttribute(el, this.contentAttr, "");
  3343. return el;
  3344. }
  3345. };
  3346. var DomEventsPlugin = class _DomEventsPlugin extends EventManagerPlugin {
  3347. constructor(doc) {
  3348. super(doc);
  3349. }
  3350. // This plugin should come last in the list of plugins, because it accepts all
  3351. // events.
  3352. supports(eventName) {
  3353. return true;
  3354. }
  3355. addEventListener(element, eventName, handler, options) {
  3356. element.addEventListener(eventName, handler, options);
  3357. return () => this.removeEventListener(element, eventName, handler, options);
  3358. }
  3359. removeEventListener(target, eventName, callback, options) {
  3360. return target.removeEventListener(eventName, callback, options);
  3361. }
  3362. static ɵfac = function DomEventsPlugin_Factory(__ngFactoryType__) {
  3363. return new (__ngFactoryType__ || _DomEventsPlugin)(ɵɵinject(DOCUMENT));
  3364. };
  3365. static ɵprov = ɵɵdefineInjectable({
  3366. token: _DomEventsPlugin,
  3367. factory: _DomEventsPlugin.ɵfac
  3368. });
  3369. };
  3370. (() => {
  3371. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DomEventsPlugin, [{
  3372. type: Injectable
  3373. }], () => [{
  3374. type: void 0,
  3375. decorators: [{
  3376. type: Inject,
  3377. args: [DOCUMENT]
  3378. }]
  3379. }], null);
  3380. })();
  3381. var MODIFIER_KEYS = ["alt", "control", "meta", "shift"];
  3382. var _keyMap = {
  3383. "\b": "Backspace",
  3384. " ": "Tab",
  3385. "": "Delete",
  3386. "\x1B": "Escape",
  3387. "Del": "Delete",
  3388. "Esc": "Escape",
  3389. "Left": "ArrowLeft",
  3390. "Right": "ArrowRight",
  3391. "Up": "ArrowUp",
  3392. "Down": "ArrowDown",
  3393. "Menu": "ContextMenu",
  3394. "Scroll": "ScrollLock",
  3395. "Win": "OS"
  3396. };
  3397. var MODIFIER_KEY_GETTERS = {
  3398. "alt": (event) => event.altKey,
  3399. "control": (event) => event.ctrlKey,
  3400. "meta": (event) => event.metaKey,
  3401. "shift": (event) => event.shiftKey
  3402. };
  3403. var KeyEventsPlugin = class _KeyEventsPlugin extends EventManagerPlugin {
  3404. /**
  3405. * Initializes an instance of the browser plug-in.
  3406. * @param doc The document in which key events will be detected.
  3407. */
  3408. constructor(doc) {
  3409. super(doc);
  3410. }
  3411. /**
  3412. * Reports whether a named key event is supported.
  3413. * @param eventName The event name to query.
  3414. * @return True if the named key event is supported.
  3415. */
  3416. supports(eventName) {
  3417. return _KeyEventsPlugin.parseEventName(eventName) != null;
  3418. }
  3419. /**
  3420. * Registers a handler for a specific element and key event.
  3421. * @param element The HTML element to receive event notifications.
  3422. * @param eventName The name of the key event to listen for.
  3423. * @param handler A function to call when the notification occurs. Receives the
  3424. * event object as an argument.
  3425. * @returns The key event that was registered.
  3426. */
  3427. addEventListener(element, eventName, handler, options) {
  3428. const parsedEvent = _KeyEventsPlugin.parseEventName(eventName);
  3429. const outsideHandler = _KeyEventsPlugin.eventCallback(parsedEvent["fullKey"], handler, this.manager.getZone());
  3430. return this.manager.getZone().runOutsideAngular(() => {
  3431. return getDOM().onAndCancel(element, parsedEvent["domEventName"], outsideHandler, options);
  3432. });
  3433. }
  3434. /**
  3435. * Parses the user provided full keyboard event definition and normalizes it for
  3436. * later internal use. It ensures the string is all lowercase, converts special
  3437. * characters to a standard spelling, and orders all the values consistently.
  3438. *
  3439. * @param eventName The name of the key event to listen for.
  3440. * @returns an object with the full, normalized string, and the dom event name
  3441. * or null in the case when the event doesn't match a keyboard event.
  3442. */
  3443. static parseEventName(eventName) {
  3444. const parts = eventName.toLowerCase().split(".");
  3445. const domEventName = parts.shift();
  3446. if (parts.length === 0 || !(domEventName === "keydown" || domEventName === "keyup")) {
  3447. return null;
  3448. }
  3449. const key = _KeyEventsPlugin._normalizeKey(parts.pop());
  3450. let fullKey = "";
  3451. let codeIX = parts.indexOf("code");
  3452. if (codeIX > -1) {
  3453. parts.splice(codeIX, 1);
  3454. fullKey = "code.";
  3455. }
  3456. MODIFIER_KEYS.forEach((modifierName) => {
  3457. const index = parts.indexOf(modifierName);
  3458. if (index > -1) {
  3459. parts.splice(index, 1);
  3460. fullKey += modifierName + ".";
  3461. }
  3462. });
  3463. fullKey += key;
  3464. if (parts.length != 0 || key.length === 0) {
  3465. return null;
  3466. }
  3467. const result = {};
  3468. result["domEventName"] = domEventName;
  3469. result["fullKey"] = fullKey;
  3470. return result;
  3471. }
  3472. /**
  3473. * Determines whether the actual keys pressed match the configured key code string.
  3474. * The `fullKeyCode` event is normalized in the `parseEventName` method when the
  3475. * event is attached to the DOM during the `addEventListener` call. This is unseen
  3476. * by the end user and is normalized for internal consistency and parsing.
  3477. *
  3478. * @param event The keyboard event.
  3479. * @param fullKeyCode The normalized user defined expected key event string
  3480. * @returns boolean.
  3481. */
  3482. static matchEventFullKeyCode(event, fullKeyCode) {
  3483. let keycode = _keyMap[event.key] || event.key;
  3484. let key = "";
  3485. if (fullKeyCode.indexOf("code.") > -1) {
  3486. keycode = event.code;
  3487. key = "code.";
  3488. }
  3489. if (keycode == null || !keycode) return false;
  3490. keycode = keycode.toLowerCase();
  3491. if (keycode === " ") {
  3492. keycode = "space";
  3493. } else if (keycode === ".") {
  3494. keycode = "dot";
  3495. }
  3496. MODIFIER_KEYS.forEach((modifierName) => {
  3497. if (modifierName !== keycode) {
  3498. const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
  3499. if (modifierGetter(event)) {
  3500. key += modifierName + ".";
  3501. }
  3502. }
  3503. });
  3504. key += keycode;
  3505. return key === fullKeyCode;
  3506. }
  3507. /**
  3508. * Configures a handler callback for a key event.
  3509. * @param fullKey The event name that combines all simultaneous keystrokes.
  3510. * @param handler The function that responds to the key event.
  3511. * @param zone The zone in which the event occurred.
  3512. * @returns A callback function.
  3513. */
  3514. static eventCallback(fullKey, handler, zone) {
  3515. return (event) => {
  3516. if (_KeyEventsPlugin.matchEventFullKeyCode(event, fullKey)) {
  3517. zone.runGuarded(() => handler(event));
  3518. }
  3519. };
  3520. }
  3521. /** @internal */
  3522. static _normalizeKey(keyName) {
  3523. return keyName === "esc" ? "escape" : keyName;
  3524. }
  3525. static ɵfac = function KeyEventsPlugin_Factory(__ngFactoryType__) {
  3526. return new (__ngFactoryType__ || _KeyEventsPlugin)(ɵɵinject(DOCUMENT));
  3527. };
  3528. static ɵprov = ɵɵdefineInjectable({
  3529. token: _KeyEventsPlugin,
  3530. factory: _KeyEventsPlugin.ɵfac
  3531. });
  3532. };
  3533. (() => {
  3534. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(KeyEventsPlugin, [{
  3535. type: Injectable
  3536. }], () => [{
  3537. type: void 0,
  3538. decorators: [{
  3539. type: Inject,
  3540. args: [DOCUMENT]
  3541. }]
  3542. }], null);
  3543. })();
  3544. function bootstrapApplication(rootComponent, options) {
  3545. return internalCreateApplication(__spreadValues({
  3546. rootComponent
  3547. }, createProvidersConfig(options)));
  3548. }
  3549. function createApplication(options) {
  3550. return internalCreateApplication(createProvidersConfig(options));
  3551. }
  3552. function createProvidersConfig(options) {
  3553. return {
  3554. appProviders: [...BROWSER_MODULE_PROVIDERS, ...options?.providers ?? []],
  3555. platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS
  3556. };
  3557. }
  3558. function provideProtractorTestingSupport() {
  3559. return [...TESTABILITY_PROVIDERS];
  3560. }
  3561. function initDomAdapter() {
  3562. BrowserDomAdapter.makeCurrent();
  3563. }
  3564. function errorHandler() {
  3565. return new ErrorHandler();
  3566. }
  3567. function _document() {
  3568. setDocument(document);
  3569. return document;
  3570. }
  3571. var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [{
  3572. provide: PLATFORM_ID,
  3573. useValue: PLATFORM_BROWSER_ID
  3574. }, {
  3575. provide: PLATFORM_INITIALIZER,
  3576. useValue: initDomAdapter,
  3577. multi: true
  3578. }, {
  3579. provide: DOCUMENT,
  3580. useFactory: _document,
  3581. deps: []
  3582. }];
  3583. var platformBrowser = createPlatformFactory(platformCore, "browser", INTERNAL_BROWSER_PLATFORM_PROVIDERS);
  3584. var BROWSER_MODULE_PROVIDERS_MARKER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "BrowserModule Providers Marker" : "");
  3585. var TESTABILITY_PROVIDERS = [{
  3586. provide: TESTABILITY_GETTER,
  3587. useClass: BrowserGetTestability,
  3588. deps: []
  3589. }, {
  3590. provide: TESTABILITY,
  3591. useClass: Testability,
  3592. deps: [NgZone, TestabilityRegistry, TESTABILITY_GETTER]
  3593. }, {
  3594. provide: Testability,
  3595. // Also provide as `Testability` for backwards-compatibility.
  3596. useClass: Testability,
  3597. deps: [NgZone, TestabilityRegistry, TESTABILITY_GETTER]
  3598. }];
  3599. var BROWSER_MODULE_PROVIDERS = [{
  3600. provide: INJECTOR_SCOPE,
  3601. useValue: "root"
  3602. }, {
  3603. provide: ErrorHandler,
  3604. useFactory: errorHandler,
  3605. deps: []
  3606. }, {
  3607. provide: EVENT_MANAGER_PLUGINS,
  3608. useClass: DomEventsPlugin,
  3609. multi: true,
  3610. deps: [DOCUMENT]
  3611. }, {
  3612. provide: EVENT_MANAGER_PLUGINS,
  3613. useClass: KeyEventsPlugin,
  3614. multi: true,
  3615. deps: [DOCUMENT]
  3616. }, DomRendererFactory2, SharedStylesHost, EventManager, {
  3617. provide: RendererFactory2,
  3618. useExisting: DomRendererFactory2
  3619. }, {
  3620. provide: XhrFactory,
  3621. useClass: BrowserXhr,
  3622. deps: []
  3623. }, typeof ngDevMode === "undefined" || ngDevMode ? {
  3624. provide: BROWSER_MODULE_PROVIDERS_MARKER,
  3625. useValue: true
  3626. } : []];
  3627. var BrowserModule = class _BrowserModule {
  3628. constructor() {
  3629. if (typeof ngDevMode === "undefined" || ngDevMode) {
  3630. const providersAlreadyPresent = inject(BROWSER_MODULE_PROVIDERS_MARKER, {
  3631. optional: true,
  3632. skipSelf: true
  3633. });
  3634. if (providersAlreadyPresent) {
  3635. throw new RuntimeError(5100, `Providers from the \`BrowserModule\` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the \`CommonModule\` instead.`);
  3636. }
  3637. }
  3638. }
  3639. static ɵfac = function BrowserModule_Factory(__ngFactoryType__) {
  3640. return new (__ngFactoryType__ || _BrowserModule)();
  3641. };
  3642. static ɵmod = ɵɵdefineNgModule({
  3643. type: _BrowserModule,
  3644. exports: [CommonModule, ApplicationModule]
  3645. });
  3646. static ɵinj = ɵɵdefineInjector({
  3647. providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
  3648. imports: [CommonModule, ApplicationModule]
  3649. });
  3650. };
  3651. (() => {
  3652. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(BrowserModule, [{
  3653. type: NgModule,
  3654. args: [{
  3655. providers: [...BROWSER_MODULE_PROVIDERS, ...TESTABILITY_PROVIDERS],
  3656. exports: [CommonModule, ApplicationModule]
  3657. }]
  3658. }], () => [], null);
  3659. })();
  3660. var Meta = class _Meta {
  3661. _doc;
  3662. _dom;
  3663. constructor(_doc) {
  3664. this._doc = _doc;
  3665. this._dom = getDOM();
  3666. }
  3667. /**
  3668. * Retrieves or creates a specific `<meta>` tag element in the current HTML document.
  3669. * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
  3670. * values in the provided tag definition, and verifies that all other attribute values are equal.
  3671. * If an existing element is found, it is returned and is not modified in any way.
  3672. * @param tag The definition of a `<meta>` element to match or create.
  3673. * @param forceCreation True to create a new element without checking whether one already exists.
  3674. * @returns The existing element with the same attributes and values if found,
  3675. * the new element if no match is found, or `null` if the tag parameter is not defined.
  3676. */
  3677. addTag(tag, forceCreation = false) {
  3678. if (!tag) return null;
  3679. return this._getOrCreateElement(tag, forceCreation);
  3680. }
  3681. /**
  3682. * Retrieves or creates a set of `<meta>` tag elements in the current HTML document.
  3683. * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
  3684. * values in the provided tag definition, and verifies that all other attribute values are equal.
  3685. * @param tags An array of tag definitions to match or create.
  3686. * @param forceCreation True to create new elements without checking whether they already exist.
  3687. * @returns The matching elements if found, or the new elements.
  3688. */
  3689. addTags(tags, forceCreation = false) {
  3690. if (!tags) return [];
  3691. return tags.reduce((result, tag) => {
  3692. if (tag) {
  3693. result.push(this._getOrCreateElement(tag, forceCreation));
  3694. }
  3695. return result;
  3696. }, []);
  3697. }
  3698. /**
  3699. * Retrieves a `<meta>` tag element in the current HTML document.
  3700. * @param attrSelector The tag attribute and value to match against, in the format
  3701. * `"tag_attribute='value string'"`.
  3702. * @returns The matching element, if any.
  3703. */
  3704. getTag(attrSelector) {
  3705. if (!attrSelector) return null;
  3706. return this._doc.querySelector(`meta[${attrSelector}]`) || null;
  3707. }
  3708. /**
  3709. * Retrieves a set of `<meta>` tag elements in the current HTML document.
  3710. * @param attrSelector The tag attribute and value to match against, in the format
  3711. * `"tag_attribute='value string'"`.
  3712. * @returns The matching elements, if any.
  3713. */
  3714. getTags(attrSelector) {
  3715. if (!attrSelector) return [];
  3716. const list = this._doc.querySelectorAll(`meta[${attrSelector}]`);
  3717. return list ? [].slice.call(list) : [];
  3718. }
  3719. /**
  3720. * Modifies an existing `<meta>` tag element in the current HTML document.
  3721. * @param tag The tag description with which to replace the existing tag content.
  3722. * @param selector A tag attribute and value to match against, to identify
  3723. * an existing tag. A string in the format `"tag_attribute=`value string`"`.
  3724. * If not supplied, matches a tag with the same `name` or `property` attribute value as the
  3725. * replacement tag.
  3726. * @return The modified element.
  3727. */
  3728. updateTag(tag, selector) {
  3729. if (!tag) return null;
  3730. selector = selector || this._parseSelector(tag);
  3731. const meta = this.getTag(selector);
  3732. if (meta) {
  3733. return this._setMetaElementAttributes(tag, meta);
  3734. }
  3735. return this._getOrCreateElement(tag, true);
  3736. }
  3737. /**
  3738. * Removes an existing `<meta>` tag element from the current HTML document.
  3739. * @param attrSelector A tag attribute and value to match against, to identify
  3740. * an existing tag. A string in the format `"tag_attribute=`value string`"`.
  3741. */
  3742. removeTag(attrSelector) {
  3743. this.removeTagElement(this.getTag(attrSelector));
  3744. }
  3745. /**
  3746. * Removes an existing `<meta>` tag element from the current HTML document.
  3747. * @param meta The tag definition to match against to identify an existing tag.
  3748. */
  3749. removeTagElement(meta) {
  3750. if (meta) {
  3751. this._dom.remove(meta);
  3752. }
  3753. }
  3754. _getOrCreateElement(meta, forceCreation = false) {
  3755. if (!forceCreation) {
  3756. const selector = this._parseSelector(meta);
  3757. const elem = this.getTags(selector).filter((elem2) => this._containsAttributes(meta, elem2))[0];
  3758. if (elem !== void 0) return elem;
  3759. }
  3760. const element = this._dom.createElement("meta");
  3761. this._setMetaElementAttributes(meta, element);
  3762. const head = this._doc.getElementsByTagName("head")[0];
  3763. head.appendChild(element);
  3764. return element;
  3765. }
  3766. _setMetaElementAttributes(tag, el) {
  3767. Object.keys(tag).forEach((prop) => el.setAttribute(this._getMetaKeyMap(prop), tag[prop]));
  3768. return el;
  3769. }
  3770. _parseSelector(tag) {
  3771. const attr = tag.name ? "name" : "property";
  3772. return `${attr}="${tag[attr]}"`;
  3773. }
  3774. _containsAttributes(tag, elem) {
  3775. return Object.keys(tag).every((key) => elem.getAttribute(this._getMetaKeyMap(key)) === tag[key]);
  3776. }
  3777. _getMetaKeyMap(prop) {
  3778. return META_KEYS_MAP[prop] || prop;
  3779. }
  3780. static ɵfac = function Meta_Factory(__ngFactoryType__) {
  3781. return new (__ngFactoryType__ || _Meta)(ɵɵinject(DOCUMENT));
  3782. };
  3783. static ɵprov = ɵɵdefineInjectable({
  3784. token: _Meta,
  3785. factory: _Meta.ɵfac,
  3786. providedIn: "root"
  3787. });
  3788. };
  3789. (() => {
  3790. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(Meta, [{
  3791. type: Injectable,
  3792. args: [{
  3793. providedIn: "root"
  3794. }]
  3795. }], () => [{
  3796. type: void 0,
  3797. decorators: [{
  3798. type: Inject,
  3799. args: [DOCUMENT]
  3800. }]
  3801. }], null);
  3802. })();
  3803. var META_KEYS_MAP = {
  3804. httpEquiv: "http-equiv"
  3805. };
  3806. var Title = class _Title {
  3807. _doc;
  3808. constructor(_doc) {
  3809. this._doc = _doc;
  3810. }
  3811. /**
  3812. * Get the title of the current HTML document.
  3813. */
  3814. getTitle() {
  3815. return this._doc.title;
  3816. }
  3817. /**
  3818. * Set the title of the current HTML document.
  3819. * @param newTitle
  3820. */
  3821. setTitle(newTitle) {
  3822. this._doc.title = newTitle || "";
  3823. }
  3824. static ɵfac = function Title_Factory(__ngFactoryType__) {
  3825. return new (__ngFactoryType__ || _Title)(ɵɵinject(DOCUMENT));
  3826. };
  3827. static ɵprov = ɵɵdefineInjectable({
  3828. token: _Title,
  3829. factory: _Title.ɵfac,
  3830. providedIn: "root"
  3831. });
  3832. };
  3833. (() => {
  3834. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(Title, [{
  3835. type: Injectable,
  3836. args: [{
  3837. providedIn: "root"
  3838. }]
  3839. }], () => [{
  3840. type: void 0,
  3841. decorators: [{
  3842. type: Inject,
  3843. args: [DOCUMENT]
  3844. }]
  3845. }], null);
  3846. })();
  3847. function exportNgVar(name, value) {
  3848. if (typeof COMPILED === "undefined" || !COMPILED) {
  3849. const ng = _global["ng"] = _global["ng"] || {};
  3850. ng[name] = value;
  3851. }
  3852. }
  3853. var ChangeDetectionPerfRecord = class {
  3854. msPerTick;
  3855. numTicks;
  3856. constructor(msPerTick, numTicks) {
  3857. this.msPerTick = msPerTick;
  3858. this.numTicks = numTicks;
  3859. }
  3860. };
  3861. var AngularProfiler = class {
  3862. appRef;
  3863. constructor(ref) {
  3864. this.appRef = ref.injector.get(ApplicationRef);
  3865. }
  3866. // tslint:disable:no-console
  3867. /**
  3868. * Exercises change detection in a loop and then prints the average amount of
  3869. * time in milliseconds how long a single round of change detection takes for
  3870. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  3871. * of 500 milliseconds.
  3872. *
  3873. * Optionally, a user may pass a `config` parameter containing a map of
  3874. * options. Supported options are:
  3875. *
  3876. * `record` (boolean) - causes the profiler to record a CPU profile while
  3877. * it exercises the change detector. Example:
  3878. *
  3879. * ```ts
  3880. * ng.profiler.timeChangeDetection({record: true})
  3881. * ```
  3882. */
  3883. timeChangeDetection(config) {
  3884. const record = config && config["record"];
  3885. const profileName = "Change Detection";
  3886. if (record && "profile" in console && typeof console.profile === "function") {
  3887. console.profile(profileName);
  3888. }
  3889. const start = performance.now();
  3890. let numTicks = 0;
  3891. while (numTicks < 5 || performance.now() - start < 500) {
  3892. this.appRef.tick();
  3893. numTicks++;
  3894. }
  3895. const end = performance.now();
  3896. if (record && "profileEnd" in console && typeof console.profileEnd === "function") {
  3897. console.profileEnd(profileName);
  3898. }
  3899. const msPerTick = (end - start) / numTicks;
  3900. console.log(`ran ${numTicks} change detection cycles`);
  3901. console.log(`${msPerTick.toFixed(2)} ms per check`);
  3902. return new ChangeDetectionPerfRecord(msPerTick, numTicks);
  3903. }
  3904. };
  3905. var PROFILER_GLOBAL_NAME = "profiler";
  3906. function enableDebugTools(ref) {
  3907. exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
  3908. return ref;
  3909. }
  3910. function disableDebugTools() {
  3911. exportNgVar(PROFILER_GLOBAL_NAME, null);
  3912. }
  3913. var By = class {
  3914. /**
  3915. * Match all nodes.
  3916. *
  3917. * @usageNotes
  3918. * ### Example
  3919. *
  3920. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  3921. */
  3922. static all() {
  3923. return () => true;
  3924. }
  3925. /**
  3926. * Match elements by the given CSS selector.
  3927. *
  3928. * @usageNotes
  3929. * ### Example
  3930. *
  3931. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  3932. */
  3933. static css(selector) {
  3934. return (debugElement) => {
  3935. return debugElement.nativeElement != null ? elementMatches(debugElement.nativeElement, selector) : false;
  3936. };
  3937. }
  3938. /**
  3939. * Match nodes that have the given directive present.
  3940. *
  3941. * @usageNotes
  3942. * ### Example
  3943. *
  3944. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  3945. */
  3946. static directive(type) {
  3947. return (debugNode) => debugNode.providerTokens.indexOf(type) !== -1;
  3948. }
  3949. };
  3950. function elementMatches(n, selector) {
  3951. if (getDOM().isElementNode(n)) {
  3952. return n.matches && n.matches(selector) || n.msMatchesSelector && n.msMatchesSelector(selector) || n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
  3953. }
  3954. return false;
  3955. }
  3956. var EVENT_NAMES = {
  3957. // pan
  3958. "pan": true,
  3959. "panstart": true,
  3960. "panmove": true,
  3961. "panend": true,
  3962. "pancancel": true,
  3963. "panleft": true,
  3964. "panright": true,
  3965. "panup": true,
  3966. "pandown": true,
  3967. // pinch
  3968. "pinch": true,
  3969. "pinchstart": true,
  3970. "pinchmove": true,
  3971. "pinchend": true,
  3972. "pinchcancel": true,
  3973. "pinchin": true,
  3974. "pinchout": true,
  3975. // press
  3976. "press": true,
  3977. "pressup": true,
  3978. // rotate
  3979. "rotate": true,
  3980. "rotatestart": true,
  3981. "rotatemove": true,
  3982. "rotateend": true,
  3983. "rotatecancel": true,
  3984. // swipe
  3985. "swipe": true,
  3986. "swipeleft": true,
  3987. "swiperight": true,
  3988. "swipeup": true,
  3989. "swipedown": true,
  3990. // tap
  3991. "tap": true,
  3992. "doubletap": true
  3993. };
  3994. var HAMMER_GESTURE_CONFIG = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "HammerGestureConfig" : "");
  3995. var HAMMER_LOADER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "HammerLoader" : "");
  3996. var HammerGestureConfig = class _HammerGestureConfig {
  3997. /**
  3998. * A set of supported event names for gestures to be used in Angular.
  3999. * Angular supports all built-in recognizers, as listed in
  4000. * [HammerJS documentation](https://hammerjs.github.io/).
  4001. */
  4002. events = [];
  4003. /**
  4004. * Maps gesture event names to a set of configuration options
  4005. * that specify overrides to the default values for specific properties.
  4006. *
  4007. * The key is a supported event name to be configured,
  4008. * and the options object contains a set of properties, with override values
  4009. * to be applied to the named recognizer event.
  4010. * For example, to disable recognition of the rotate event, specify
  4011. * `{"rotate": {"enable": false}}`.
  4012. *
  4013. * Properties that are not present take the HammerJS default values.
  4014. * For information about which properties are supported for which events,
  4015. * and their allowed and default values, see
  4016. * [HammerJS documentation](https://hammerjs.github.io/).
  4017. *
  4018. */
  4019. overrides = {};
  4020. /**
  4021. * Properties whose default values can be overridden for a given event.
  4022. * Different sets of properties apply to different events.
  4023. * For information about which properties are supported for which events,
  4024. * and their allowed and default values, see
  4025. * [HammerJS documentation](https://hammerjs.github.io/).
  4026. */
  4027. options;
  4028. /**
  4029. * Creates a [HammerJS Manager](https://hammerjs.github.io/api/#hammermanager)
  4030. * and attaches it to a given HTML element.
  4031. * @param element The element that will recognize gestures.
  4032. * @returns A HammerJS event-manager object.
  4033. */
  4034. buildHammer(element) {
  4035. const mc = new Hammer(element, this.options);
  4036. mc.get("pinch").set({
  4037. enable: true
  4038. });
  4039. mc.get("rotate").set({
  4040. enable: true
  4041. });
  4042. for (const eventName in this.overrides) {
  4043. mc.get(eventName).set(this.overrides[eventName]);
  4044. }
  4045. return mc;
  4046. }
  4047. static ɵfac = function HammerGestureConfig_Factory(__ngFactoryType__) {
  4048. return new (__ngFactoryType__ || _HammerGestureConfig)();
  4049. };
  4050. static ɵprov = ɵɵdefineInjectable({
  4051. token: _HammerGestureConfig,
  4052. factory: _HammerGestureConfig.ɵfac
  4053. });
  4054. };
  4055. (() => {
  4056. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HammerGestureConfig, [{
  4057. type: Injectable
  4058. }], null, null);
  4059. })();
  4060. var HammerGesturesPlugin = class _HammerGesturesPlugin extends EventManagerPlugin {
  4061. _config;
  4062. _injector;
  4063. loader;
  4064. _loaderPromise = null;
  4065. constructor(doc, _config, _injector, loader) {
  4066. super(doc);
  4067. this._config = _config;
  4068. this._injector = _injector;
  4069. this.loader = loader;
  4070. }
  4071. supports(eventName) {
  4072. if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
  4073. return false;
  4074. }
  4075. if (!window.Hammer && !this.loader) {
  4076. if (typeof ngDevMode === "undefined" || ngDevMode) {
  4077. const _console = this._injector.get(Console);
  4078. _console.warn(`The "${eventName}" event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified.`);
  4079. }
  4080. return false;
  4081. }
  4082. return true;
  4083. }
  4084. addEventListener(element, eventName, handler) {
  4085. const zone = this.manager.getZone();
  4086. eventName = eventName.toLowerCase();
  4087. if (!window.Hammer && this.loader) {
  4088. this._loaderPromise = this._loaderPromise || zone.runOutsideAngular(() => this.loader());
  4089. let cancelRegistration = false;
  4090. let deregister = () => {
  4091. cancelRegistration = true;
  4092. };
  4093. zone.runOutsideAngular(() => this._loaderPromise.then(() => {
  4094. if (!window.Hammer) {
  4095. if (typeof ngDevMode === "undefined" || ngDevMode) {
  4096. const _console = this._injector.get(Console);
  4097. _console.warn(`The custom HAMMER_LOADER completed, but Hammer.JS is not present.`);
  4098. }
  4099. deregister = () => {
  4100. };
  4101. return;
  4102. }
  4103. if (!cancelRegistration) {
  4104. deregister = this.addEventListener(element, eventName, handler);
  4105. }
  4106. }).catch(() => {
  4107. if (typeof ngDevMode === "undefined" || ngDevMode) {
  4108. const _console = this._injector.get(Console);
  4109. _console.warn(`The "${eventName}" event cannot be bound because the custom Hammer.JS loader failed.`);
  4110. }
  4111. deregister = () => {
  4112. };
  4113. }));
  4114. return () => {
  4115. deregister();
  4116. };
  4117. }
  4118. return zone.runOutsideAngular(() => {
  4119. const mc = this._config.buildHammer(element);
  4120. const callback = function(eventObj) {
  4121. zone.runGuarded(function() {
  4122. handler(eventObj);
  4123. });
  4124. };
  4125. mc.on(eventName, callback);
  4126. return () => {
  4127. mc.off(eventName, callback);
  4128. if (typeof mc.destroy === "function") {
  4129. mc.destroy();
  4130. }
  4131. };
  4132. });
  4133. }
  4134. isCustomEvent(eventName) {
  4135. return this._config.events.indexOf(eventName) > -1;
  4136. }
  4137. static ɵfac = function HammerGesturesPlugin_Factory(__ngFactoryType__) {
  4138. return new (__ngFactoryType__ || _HammerGesturesPlugin)(ɵɵinject(DOCUMENT), ɵɵinject(HAMMER_GESTURE_CONFIG), ɵɵinject(Injector), ɵɵinject(HAMMER_LOADER, 8));
  4139. };
  4140. static ɵprov = ɵɵdefineInjectable({
  4141. token: _HammerGesturesPlugin,
  4142. factory: _HammerGesturesPlugin.ɵfac
  4143. });
  4144. };
  4145. (() => {
  4146. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HammerGesturesPlugin, [{
  4147. type: Injectable
  4148. }], () => [{
  4149. type: void 0,
  4150. decorators: [{
  4151. type: Inject,
  4152. args: [DOCUMENT]
  4153. }]
  4154. }, {
  4155. type: HammerGestureConfig,
  4156. decorators: [{
  4157. type: Inject,
  4158. args: [HAMMER_GESTURE_CONFIG]
  4159. }]
  4160. }, {
  4161. type: Injector
  4162. }, {
  4163. type: void 0,
  4164. decorators: [{
  4165. type: Optional
  4166. }, {
  4167. type: Inject,
  4168. args: [HAMMER_LOADER]
  4169. }]
  4170. }], null);
  4171. })();
  4172. var HammerModule = class _HammerModule {
  4173. static ɵfac = function HammerModule_Factory(__ngFactoryType__) {
  4174. return new (__ngFactoryType__ || _HammerModule)();
  4175. };
  4176. static ɵmod = ɵɵdefineNgModule({
  4177. type: _HammerModule
  4178. });
  4179. static ɵinj = ɵɵdefineInjector({
  4180. providers: [{
  4181. provide: EVENT_MANAGER_PLUGINS,
  4182. useClass: HammerGesturesPlugin,
  4183. multi: true,
  4184. deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, Injector, [new Optional(), HAMMER_LOADER]]
  4185. }, {
  4186. provide: HAMMER_GESTURE_CONFIG,
  4187. useClass: HammerGestureConfig,
  4188. deps: []
  4189. }]
  4190. });
  4191. };
  4192. (() => {
  4193. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HammerModule, [{
  4194. type: NgModule,
  4195. args: [{
  4196. providers: [{
  4197. provide: EVENT_MANAGER_PLUGINS,
  4198. useClass: HammerGesturesPlugin,
  4199. multi: true,
  4200. deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, Injector, [new Optional(), HAMMER_LOADER]]
  4201. }, {
  4202. provide: HAMMER_GESTURE_CONFIG,
  4203. useClass: HammerGestureConfig,
  4204. deps: []
  4205. }]
  4206. }]
  4207. }], null, null);
  4208. })();
  4209. var DomSanitizer = class _DomSanitizer {
  4210. static ɵfac = function DomSanitizer_Factory(__ngFactoryType__) {
  4211. return new (__ngFactoryType__ || _DomSanitizer)();
  4212. };
  4213. static ɵprov = ɵɵdefineInjectable({
  4214. token: _DomSanitizer,
  4215. factory: function DomSanitizer_Factory(__ngFactoryType__) {
  4216. let __ngConditionalFactory__ = null;
  4217. if (__ngFactoryType__) {
  4218. __ngConditionalFactory__ = new (__ngFactoryType__ || _DomSanitizer)();
  4219. } else {
  4220. __ngConditionalFactory__ = ɵɵinject(DomSanitizerImpl);
  4221. }
  4222. return __ngConditionalFactory__;
  4223. },
  4224. providedIn: "root"
  4225. });
  4226. };
  4227. (() => {
  4228. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DomSanitizer, [{
  4229. type: Injectable,
  4230. args: [{
  4231. providedIn: "root",
  4232. useExisting: forwardRef(() => DomSanitizerImpl)
  4233. }]
  4234. }], null, null);
  4235. })();
  4236. var DomSanitizerImpl = class _DomSanitizerImpl extends DomSanitizer {
  4237. _doc;
  4238. constructor(_doc) {
  4239. super();
  4240. this._doc = _doc;
  4241. }
  4242. sanitize(ctx, value) {
  4243. if (value == null) return null;
  4244. switch (ctx) {
  4245. case SecurityContext.NONE:
  4246. return value;
  4247. case SecurityContext.HTML:
  4248. if (allowSanitizationBypassAndThrow(
  4249. value,
  4250. "HTML"
  4251. /* BypassType.Html */
  4252. )) {
  4253. return unwrapSafeValue(value);
  4254. }
  4255. return _sanitizeHtml(this._doc, String(value)).toString();
  4256. case SecurityContext.STYLE:
  4257. if (allowSanitizationBypassAndThrow(
  4258. value,
  4259. "Style"
  4260. /* BypassType.Style */
  4261. )) {
  4262. return unwrapSafeValue(value);
  4263. }
  4264. return value;
  4265. case SecurityContext.SCRIPT:
  4266. if (allowSanitizationBypassAndThrow(
  4267. value,
  4268. "Script"
  4269. /* BypassType.Script */
  4270. )) {
  4271. return unwrapSafeValue(value);
  4272. }
  4273. throw new RuntimeError(5200, (typeof ngDevMode === "undefined" || ngDevMode) && "unsafe value used in a script context");
  4274. case SecurityContext.URL:
  4275. if (allowSanitizationBypassAndThrow(
  4276. value,
  4277. "URL"
  4278. /* BypassType.Url */
  4279. )) {
  4280. return unwrapSafeValue(value);
  4281. }
  4282. return _sanitizeUrl(String(value));
  4283. case SecurityContext.RESOURCE_URL:
  4284. if (allowSanitizationBypassAndThrow(
  4285. value,
  4286. "ResourceURL"
  4287. /* BypassType.ResourceUrl */
  4288. )) {
  4289. return unwrapSafeValue(value);
  4290. }
  4291. throw new RuntimeError(5201, (typeof ngDevMode === "undefined" || ngDevMode) && `unsafe value used in a resource URL context (see ${XSS_SECURITY_URL})`);
  4292. default:
  4293. throw new RuntimeError(5202, (typeof ngDevMode === "undefined" || ngDevMode) && `Unexpected SecurityContext ${ctx} (see ${XSS_SECURITY_URL})`);
  4294. }
  4295. }
  4296. bypassSecurityTrustHtml(value) {
  4297. return bypassSanitizationTrustHtml(value);
  4298. }
  4299. bypassSecurityTrustStyle(value) {
  4300. return bypassSanitizationTrustStyle(value);
  4301. }
  4302. bypassSecurityTrustScript(value) {
  4303. return bypassSanitizationTrustScript(value);
  4304. }
  4305. bypassSecurityTrustUrl(value) {
  4306. return bypassSanitizationTrustUrl(value);
  4307. }
  4308. bypassSecurityTrustResourceUrl(value) {
  4309. return bypassSanitizationTrustResourceUrl(value);
  4310. }
  4311. static ɵfac = function DomSanitizerImpl_Factory(__ngFactoryType__) {
  4312. return new (__ngFactoryType__ || _DomSanitizerImpl)(ɵɵinject(DOCUMENT));
  4313. };
  4314. static ɵprov = ɵɵdefineInjectable({
  4315. token: _DomSanitizerImpl,
  4316. factory: _DomSanitizerImpl.ɵfac,
  4317. providedIn: "root"
  4318. });
  4319. };
  4320. (() => {
  4321. (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DomSanitizerImpl, [{
  4322. type: Injectable,
  4323. args: [{
  4324. providedIn: "root"
  4325. }]
  4326. }], () => [{
  4327. type: void 0,
  4328. decorators: [{
  4329. type: Inject,
  4330. args: [DOCUMENT]
  4331. }]
  4332. }], null);
  4333. })();
  4334. var HydrationFeatureKind;
  4335. (function(HydrationFeatureKind2) {
  4336. HydrationFeatureKind2[HydrationFeatureKind2["NoHttpTransferCache"] = 0] = "NoHttpTransferCache";
  4337. HydrationFeatureKind2[HydrationFeatureKind2["HttpTransferCacheOptions"] = 1] = "HttpTransferCacheOptions";
  4338. HydrationFeatureKind2[HydrationFeatureKind2["I18nSupport"] = 2] = "I18nSupport";
  4339. HydrationFeatureKind2[HydrationFeatureKind2["EventReplay"] = 3] = "EventReplay";
  4340. HydrationFeatureKind2[HydrationFeatureKind2["IncrementalHydration"] = 4] = "IncrementalHydration";
  4341. })(HydrationFeatureKind || (HydrationFeatureKind = {}));
  4342. function hydrationFeature(ɵkind, ɵproviders = [], ɵoptions = {}) {
  4343. return {
  4344. ɵkind,
  4345. ɵproviders
  4346. };
  4347. }
  4348. function withNoHttpTransferCache() {
  4349. return hydrationFeature(HydrationFeatureKind.NoHttpTransferCache);
  4350. }
  4351. function withHttpTransferCacheOptions(options) {
  4352. return hydrationFeature(HydrationFeatureKind.HttpTransferCacheOptions, withHttpTransferCache(options));
  4353. }
  4354. function withI18nSupport2() {
  4355. return hydrationFeature(HydrationFeatureKind.I18nSupport, withI18nSupport());
  4356. }
  4357. function withEventReplay2() {
  4358. return hydrationFeature(HydrationFeatureKind.EventReplay, withEventReplay());
  4359. }
  4360. function withIncrementalHydration2() {
  4361. return hydrationFeature(HydrationFeatureKind.IncrementalHydration, withIncrementalHydration());
  4362. }
  4363. function provideZoneJsCompatibilityDetector() {
  4364. return [{
  4365. provide: ENVIRONMENT_INITIALIZER,
  4366. useValue: () => {
  4367. const ngZone = inject(NgZone);
  4368. const isZoneless = inject(ZONELESS_ENABLED);
  4369. if (!isZoneless && ngZone.constructor !== NgZone) {
  4370. const console2 = inject(Console);
  4371. const message = formatRuntimeError(-5e3, "Angular detected that hydration was enabled for an application that uses a custom or a noop Zone.js implementation. This is not yet a fully supported configuration.");
  4372. console2.warn(message);
  4373. }
  4374. },
  4375. multi: true
  4376. }];
  4377. }
  4378. function provideClientHydration(...features) {
  4379. const providers = [];
  4380. const featuresKind = /* @__PURE__ */ new Set();
  4381. const hasHttpTransferCacheOptions = featuresKind.has(HydrationFeatureKind.HttpTransferCacheOptions);
  4382. for (const {
  4383. ɵproviders,
  4384. ɵkind
  4385. } of features) {
  4386. featuresKind.add(ɵkind);
  4387. if (ɵproviders.length) {
  4388. providers.push(ɵproviders);
  4389. }
  4390. }
  4391. if (typeof ngDevMode !== "undefined" && ngDevMode && featuresKind.has(HydrationFeatureKind.NoHttpTransferCache) && hasHttpTransferCacheOptions) {
  4392. throw new Error("Configuration error: found both withHttpTransferCacheOptions() and withNoHttpTransferCache() in the same call to provideClientHydration(), which is a contradiction.");
  4393. }
  4394. return makeEnvironmentProviders([typeof ngDevMode !== "undefined" && ngDevMode ? provideZoneJsCompatibilityDetector() : [], withDomHydration(), featuresKind.has(HydrationFeatureKind.NoHttpTransferCache) || hasHttpTransferCacheOptions ? [] : withHttpTransferCache({}), providers]);
  4395. }
  4396. var VERSION = new Version("19.2.4");
  4397. export {
  4398. BrowserModule,
  4399. By,
  4400. DomSanitizer,
  4401. EVENT_MANAGER_PLUGINS,
  4402. EventManager,
  4403. EventManagerPlugin,
  4404. HAMMER_GESTURE_CONFIG,
  4405. HAMMER_LOADER,
  4406. HammerGestureConfig,
  4407. HammerModule,
  4408. HydrationFeatureKind,
  4409. Meta,
  4410. REMOVE_STYLES_ON_COMPONENT_DESTROY,
  4411. Title,
  4412. VERSION,
  4413. bootstrapApplication,
  4414. createApplication,
  4415. disableDebugTools,
  4416. enableDebugTools,
  4417. platformBrowser,
  4418. provideClientHydration,
  4419. provideProtractorTestingSupport,
  4420. withEventReplay2 as withEventReplay,
  4421. withHttpTransferCacheOptions,
  4422. withI18nSupport2 as withI18nSupport,
  4423. withIncrementalHydration2 as withIncrementalHydration,
  4424. withNoHttpTransferCache,
  4425. BrowserDomAdapter as ɵBrowserDomAdapter,
  4426. BrowserGetTestability as ɵBrowserGetTestability,
  4427. DomEventsPlugin as ɵDomEventsPlugin,
  4428. DomRendererFactory2 as ɵDomRendererFactory2,
  4429. DomSanitizerImpl as ɵDomSanitizerImpl,
  4430. HammerGesturesPlugin as ɵHammerGesturesPlugin,
  4431. KeyEventsPlugin as ɵKeyEventsPlugin,
  4432. SharedStylesHost as ɵSharedStylesHost,
  4433. getDOM as ɵgetDOM
  4434. };
  4435. /*! Bundled license information:
  4436. @angular/common/fesm2022/http.mjs:
  4437. (**
  4438. * @license Angular v19.2.4
  4439. * (c) 2010-2025 Google LLC. https://angular.io/
  4440. * License: MIT
  4441. *)
  4442. @angular/platform-browser/fesm2022/platform-browser.mjs:
  4443. (**
  4444. * @license Angular v19.2.4
  4445. * (c) 2010-2025 Google LLC. https://angular.io/
  4446. * License: MIT
  4447. *)
  4448. */
  4449. //# sourceMappingURL=@angular_platform-browser.js.map