clipoox-render 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/package.json +4 -3
  2. package/scripts/render-local.mjs +5160 -1446
  3. package/web/assets/FxEmbed-DbfuM8Yo.js +1 -0
  4. package/web/assets/MotionEmbed-CBQ-8Tzh.js +1 -0
  5. package/web/assets/PluginStore-OOEx0lP5.js +3 -0
  6. package/web/assets/ShotComposer-Cng515xa.js +287 -0
  7. package/web/assets/{ShotComposer-VixLbeMe.css → ShotComposer-deLi4grZ.css} +1 -1
  8. package/web/assets/TemplateEmbed-hjwM2b0o.js +2 -0
  9. package/web/assets/{TimelinePlugins-BYZ9y4m3.js → TimelinePlugins-D-NakABP.js} +4 -4
  10. package/web/assets/TimelineShotFx-D3kGhHN3.js +2 -0
  11. package/web/assets/TransitionEmbed-DR26yI3a.js +1 -0
  12. package/web/assets/{Whiteboard-BP_DvIAV.js → Whiteboard-BhxY0D0Z.js} +3 -3
  13. package/web/assets/aerial-BisYSXzG.js +2 -0
  14. package/web/assets/agentTools-CPFQeiDP.js +2 -0
  15. package/web/assets/aiInbetween-AOOM1e6p.js +2 -0
  16. package/web/assets/analyzerRun-Dtp2o7gT.js +1 -0
  17. package/web/assets/analyzerSandbox-BG_3Cea1.js +33 -0
  18. package/web/assets/api-BFN7blbw.js +3158 -0
  19. package/web/assets/auraTrack-D_gxHNVe.js +1 -0
  20. package/web/assets/breakthrough-0qFpZW-V.js +2 -0
  21. package/web/assets/{cameraPresets-CYw0OdM3.js → cameraPresets-eK3mP7qb.js} +1 -1
  22. package/web/assets/cameraTracker-BAQHuTV-.js +72 -0
  23. package/web/assets/captionLayout-CWPcbid-.js +1 -0
  24. package/web/assets/clientExport-DvpTTndR.js +1 -0
  25. package/web/assets/clientJobs-CIrYTMpn.js +2 -0
  26. package/web/assets/clientJobs-CuuUyhEy.js +1 -0
  27. package/web/assets/cutoutClean-CLYYAuXg.js +1 -0
  28. package/web/assets/depthEstimate-B7D7cGCl.js +1 -0
  29. package/web/assets/directorTools-CJD4Huqk.js +1 -0
  30. package/web/assets/distortFrames-BLt1icUb.js +2 -0
  31. package/web/assets/{distortGL-QalhICvi.js → distortGL-BA5molk-.js} +3 -3
  32. package/web/assets/draco_decoder-C32yEggz.wasm +0 -0
  33. package/web/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
  34. package/web/assets/draco_decoder-fzg4nYZr.js +34 -0
  35. package/web/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
  36. package/web/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
  37. package/web/assets/editTools-NKLsWZD1.js +1 -0
  38. package/web/assets/{engine-BedcnK45.js → engine-DioUF2mX.js} +1 -1
  39. package/web/assets/exportGlb-BOdI9cVS.js +2 -0
  40. package/web/assets/faceTracker-D7CbF-qX.js +1 -0
  41. package/web/assets/fightDirector-CYP8jxo8.js +1 -0
  42. package/web/assets/fightDrama-DIPcRKnc.js +2 -0
  43. package/web/assets/focusTool-vfabPqQ5.js +1 -0
  44. package/web/assets/{frameSink-DeM8xC8_.js → frameSink-DYs2gTzq.js} +3 -3
  45. package/web/assets/glTransitionSources.generated-DM5sRMX2.js +3695 -0
  46. package/web/assets/gltfLoader-U0Eebg7v.js +2 -0
  47. package/web/assets/{gpuCompose-CA3UmOl4.js → gpuCompose-DbnZuelB.js} +1 -1
  48. package/web/assets/gpuExport-CQ7ZhpsX.js +198 -0
  49. package/web/assets/handMatte-DIbMuqCu.js +1 -0
  50. package/web/assets/handTracker-DY_g5Xmg.js +2 -0
  51. package/web/assets/i18n-BJppIrtF.js +3 -0
  52. package/web/assets/index-BfrDwjDI.js +4247 -0
  53. package/web/assets/index-CKtv7gGE.js +9 -0
  54. package/web/assets/{index-D5oyVCRl.js → index-DxdDhmLR.js} +2 -2
  55. package/web/assets/layer-worker-DK67WH1a.js +5 -0
  56. package/web/assets/library-B6KsZUKq.js +1 -0
  57. package/web/assets/lottieLayer-C2YbiXhK.js +161 -0
  58. package/web/assets/{lottie_light_canvas-B-d7-ATe.js → lottie_light_canvas-DX9Wf-DS.js} +1 -1
  59. package/web/assets/main-B27kf5aL.css +1 -0
  60. package/web/assets/main-BKatDoGw.js +309 -0
  61. package/web/assets/mapBake-C-G7WpFM.js +1 -0
  62. package/web/assets/maskTrack-LMrwm5ub.js +1 -0
  63. package/web/assets/matteFixRun-B38CbeEt.js +1 -0
  64. package/web/assets/matteQuality-9X-jgJrH.js +1 -0
  65. package/web/assets/objectLocate-CKi3OTnL.js +1 -0
  66. package/web/assets/objectSegmenter-CziPuM61.js +1 -0
  67. package/web/assets/{objectTrack.worker-BlZkgpOX.js → objectTrack.worker-b7DJ-ub6.js} +196 -196
  68. package/web/assets/pathTracer-bqau16sX.js +2 -0
  69. package/web/assets/pendingMatte-CQb7jPg1.js +2 -0
  70. package/web/assets/personAi-CQntGDqK.js +2 -0
  71. package/web/assets/personHq-B1c0QVJT.js +2 -0
  72. package/web/assets/plateCamera-D7iLiNBy.js +1 -0
  73. package/web/assets/plateCameraMatch-BM88dx-a.js +2 -0
  74. package/web/assets/plateFollow-4iGUDTu1.js +2 -0
  75. package/web/assets/plateMatte-zTyuHHqh.js +2 -0
  76. package/web/assets/plugin-guide.en-DO_fHbzT.js +1 -0
  77. package/web/assets/plugin-guide.vi-CMJDxOhi.js +1 -0
  78. package/web/assets/pluginAutomation-DSg-sYLF.js +1 -0
  79. package/web/assets/poseTracker-DZl8l2qS.js +1 -0
  80. package/web/assets/productTools-B-jh8ukh.js +2 -0
  81. package/web/assets/remote-DJd9xWjn.js +963 -0
  82. package/web/assets/{rigTrack-urT3nDK0.js → rigTrack-XaMj1yaH.js} +1 -1
  83. package/web/assets/rotoMaskStore-DdpmT9C3.js +1 -0
  84. package/web/assets/{rotoMatte-C-2o3vv0.js → rotoMatte-i-cJTYmK.js} +1 -1
  85. package/web/assets/rotoscope-DqRSWmHR.js +1 -0
  86. package/web/assets/sceneTrack-Bbov7zET.js +1 -0
  87. package/web/assets/sceneTrack-DIPzBmMK.js +1 -0
  88. package/web/assets/{sceneTrack.worker-CT4uoTKn.js → sceneTrack.worker-Bav9h0pv.js} +180 -180
  89. package/web/assets/shot-worker-m-q77W9f.js +1 -0
  90. package/web/assets/{shotFxAgent-BFLkqs8v.js → shotFxAgent-DIMS7BGA.js} +2 -2
  91. package/web/assets/{skin-DY4QLaBI.js → skin-DrUzJE1u.js} +1 -1
  92. package/web/assets/{spark.module-DzziUgOj.js → spark.module-Y1SEI8Xz.js} +10 -10
  93. package/web/assets/spellDuel-DNnyQDVr.js +2 -0
  94. package/web/assets/store-GFMJzaWS.js +1 -0
  95. package/web/assets/surfaceLight-C--moyc9.js +1 -0
  96. package/web/assets/surfacePin-B4-1UqXD.js +2 -0
  97. package/web/assets/{textAnimators-DUZjhVGO.js → textAnimators-BVXTl8bU.js} +1 -1
  98. package/web/assets/{thumb-CS0ZuiGS.js → thumb-CTfDJgLp.js} +1 -1
  99. package/web/assets/timeline3d-Dn7PqmEe.js +2 -0
  100. package/web/assets/timeline3dExport-DCOr6ARB.js +1 -0
  101. package/web/assets/timelineComp-Dx_kED5V.js +1 -0
  102. package/web/assets/timelineOps-afzSo188.js +525 -0
  103. package/web/assets/timelineProps-eYgO6gs5.js +1 -0
  104. package/web/assets/timelineText-RKyRP988.js +1 -0
  105. package/web/assets/{titleArt-Drsrtfiv.js → titleArt-CUtA0C3I.js} +4 -4
  106. package/web/assets/{titleFrameBudget-CLZWaFHO.js → titleFrameBudget-X7HLSDre.js} +721 -704
  107. package/web/assets/titleFrames-aMG7HdVe.js +1 -0
  108. package/web/assets/{tool-DktQYmS6.js → tool-DpFjybaq.js} +1 -1
  109. package/web/assets/{tools-Co9aRDiT.js → tools-CeOU0p13.js} +1 -1
  110. package/web/assets/toonTools-DLmo37Z_.js +2 -0
  111. package/web/assets/trackAnchor-hAOtEhKO.js +1 -0
  112. package/web/assets/userFonts-1kuRjWOo.js +1 -0
  113. package/web/assets/{vfxAlpha-71tSN86T.js → vfxAlpha-DxS5-QwY.js} +2 -2
  114. package/web/assets/vfxBackground-CYpaQaTa.js +2 -0
  115. package/web/assets/videoExport-Cg4B2Nyh.js +1 -0
  116. package/web/assets/views-CUXyRb9x.js +1 -0
  117. package/web/assets/weaponDuel-nFECu9nk.js +1 -0
  118. package/web/assets/windowFrames-1wAkkWnv.js +1 -0
  119. package/web/layer-worker.html +3 -3
  120. package/web/shot-worker.html +41 -0
  121. package/web/assets/FxEmbed-BCmj9Q5C.js +0 -1
  122. package/web/assets/GLTFLoader-BHWu1lKg.js +0 -1
  123. package/web/assets/MotionEmbed-CEmbcq8Z.js +0 -1
  124. package/web/assets/PluginStore-C5hyahvG.js +0 -3
  125. package/web/assets/ShotComposer-0DUtMTVI.js +0 -287
  126. package/web/assets/TemplateEmbed-ANxSs7H5.js +0 -2
  127. package/web/assets/TimelineShotFx-q5PQwq-V.js +0 -2
  128. package/web/assets/TransitionEmbed-O6LInGWq.js +0 -1
  129. package/web/assets/aerial-CGLDKKtP.js +0 -2
  130. package/web/assets/agentTools-2Ghb80VH.js +0 -2
  131. package/web/assets/analyzerRun-DRgxrcJA.js +0 -1
  132. package/web/assets/analyzerSandbox-DuIVFnsk.js +0 -33
  133. package/web/assets/api-CJ8PdbfZ.js +0 -3168
  134. package/web/assets/auraTrack-DQw9sVU6.js +0 -1
  135. package/web/assets/breakthrough-BNj_iTDr.js +0 -2
  136. package/web/assets/captionLayout-DvDPTwO9.js +0 -1
  137. package/web/assets/clientExport-xhoXY6Dh.js +0 -1
  138. package/web/assets/depthEstimate-DEpeCojm.js +0 -1
  139. package/web/assets/directorTools-C5CpTmci.js +0 -1
  140. package/web/assets/distortFrames-Dia8O1NM.js +0 -2
  141. package/web/assets/editTools-CY_JrQfw.js +0 -1
  142. package/web/assets/exportEncode-QYsT9JBO.js +0 -1
  143. package/web/assets/exportGlb-TSj09XoV.js +0 -2
  144. package/web/assets/faceTracker-CnCWOwnJ.js +0 -1
  145. package/web/assets/fightDirector-DCI_FWTh.js +0 -1
  146. package/web/assets/fightDrama-Bg7uP_2Q.js +0 -2
  147. package/web/assets/gpuExport-D31azOQA.js +0 -198
  148. package/web/assets/handMatte-Dl-xVXFR.js +0 -1
  149. package/web/assets/handTracker-CplBsAFg.js +0 -2
  150. package/web/assets/layer-worker-DFuo32bk.js +0 -5
  151. package/web/assets/library-BufgA-Pl.js +0 -1
  152. package/web/assets/lottieLayer-DzbA3bHV.js +0 -158
  153. package/web/assets/main-Ca_CVxMz.css +0 -1
  154. package/web/assets/main-VVYiW8XD.js +0 -309
  155. package/web/assets/mapBake-BKOcEd0w.js +0 -1
  156. package/web/assets/maskTrack-CHGXtBRy.js +0 -1
  157. package/web/assets/matteFixRun-vgYrINet.js +0 -1
  158. package/web/assets/objectLocate-BJltm8Ob.js +0 -1
  159. package/web/assets/pendingMatte-BPyzzx4y.js +0 -2
  160. package/web/assets/personAi-gJu03SjU.js +0 -2
  161. package/web/assets/plateCamera-B2JvhjJw.js +0 -1
  162. package/web/assets/plateCameraMatch-ByB9nVQT.js +0 -2
  163. package/web/assets/plateFollow-C9S-l7RH.js +0 -2
  164. package/web/assets/plateMatte-J4qlNHnY.js +0 -2
  165. package/web/assets/plugin-guide.en-CGYh_9Su.js +0 -1
  166. package/web/assets/plugin-guide.vi-DMphSELb.js +0 -1
  167. package/web/assets/pluginAutomation-CkP3tA9r.js +0 -1
  168. package/web/assets/poseTracker-DGLbouqt.js +0 -1
  169. package/web/assets/productTools-CkaWF1bM.js +0 -2
  170. package/web/assets/remote-C7J0Tqhb.js +0 -1433
  171. package/web/assets/rotoMaskStore-DPziPKAN.js +0 -1
  172. package/web/assets/rotoscope-GvPFRUBg.js +0 -1
  173. package/web/assets/shot-worker-6dYkHPoL.js +0 -1
  174. package/web/assets/spellDuel-BD3m2ebA.js +0 -2
  175. package/web/assets/store-DW4E9xnW.js +0 -1
  176. package/web/assets/surfaceLight-aDSYU8Jg.js +0 -1
  177. package/web/assets/surfacePin-m83hCgGP.js +0 -2
  178. package/web/assets/timeline3d-DOw-CpZI.js +0 -2
  179. package/web/assets/timeline3dExport-BtYLU1pw.js +0 -1
  180. package/web/assets/timelineComp-B4GtoH2f.js +0 -1
  181. package/web/assets/timelineProps-D7MVutxu.js +0 -1
  182. package/web/assets/timelineText-BH09jfSM.js +0 -1
  183. package/web/assets/titleFrames-BI1DnLBn.js +0 -1
  184. package/web/assets/toonTools-CD9clJvN.js +0 -2
  185. package/web/assets/trackAnchor-sOjTtd3I.js +0 -1
  186. package/web/assets/userFonts-CwlKh9NR.js +0 -1
  187. package/web/assets/vfxBackground-Bq7lJvmZ.js +0 -2
  188. package/web/assets/videoExport-D4KbireJ.js +0 -1
  189. package/web/assets/views-ozVF4ABO.js +0 -1
  190. package/web/assets/weaponDuel-ZhX-tjGZ.js +0 -1
  191. package/web/assets/windowFrames-CpqX3kOM.js +0 -1
@@ -0,0 +1,3158 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clientExport-DvpTTndR.js","assets/titleFrameBudget-X7HLSDre.js","assets/timelineComp-Dx_kED5V.js","assets/gpuExport-CQ7ZhpsX.js","assets/glTransitionSources.generated-DM5sRMX2.js","assets/gpuCompose-DbnZuelB.js","assets/motionBlur-uAm030t9.js","assets/distortGL-BA5molk-.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/i18n-BJppIrtF.js","assets/index-CKtv7gGE.js","assets/timelineText-RKyRP988.js","assets/store-GFMJzaWS.js","assets/titleArt-CUtA0C3I.js","assets/textAnimators-BVXTl8bU.js","assets/frameSink-DYs2gTzq.js","assets/distortFrames-BLt1icUb.js","assets/timeline3dExport-DCOr6ARB.js","assets/timeline3d-Dn7PqmEe.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/titleFrames-aMG7HdVe.js","assets/lottieLayer-C2YbiXhK.js","assets/rigTrack-XaMj1yaH.js","assets/rotoMatte-i-cJTYmK.js","assets/windowFrames-1wAkkWnv.js","assets/rotoMaskStore-DdpmT9C3.js","assets/sceneTrack-Bbov7zET.js"])))=>i.map(i=>d[i]);
2
+ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn as bd,hJ as Rd,eT as Sd,eD as Fa,iF as ja,f as Cd}from"./titleFrameBudget-X7HLSDre.js";import{g as Yn,t as De}from"./i18n-BJppIrtF.js";import{r as Pd}from"./index-CKtv7gGE.js";const kd=["alpha","alpha-inverted","luma","luma-inverted","depth"],Ww=.04,Yi=.05,Gw=n=>n.mode.endsWith("-inverted"),Kw=n=>new Set(n.filter(e=>e.matte&&!e.disabled).map(e=>e.matte.source));function Od(n){const e=new Map(n.map(r=>[r.id,r])),t=new Set;for(const r of n){if(r.matte===void 0)continue;const s=r.matte;if(!s||typeof s!="object"||Object.keys(s).some(a=>!["source","mode","feather","depth"].includes(a))||!kd.includes(s.mode)||typeof s.source!="string")throw Error("Invalid track matte");if(s.mode==="depth"!=(s.depth!==void 0)||s.depth!==void 0&&!(Number.isFinite(s.depth)&&s.depth>=0&&s.depth<=1))throw Error("Invalid track matte depth");if(s.feather!==void 0&&!(Number.isFinite(s.feather)&&s.feather>=0&&s.feather<=Yi))throw Error("Invalid track matte feather");const o=e.get(s.source);if(!o||o.id===r.id||r.kind==="audio"||o.kind==="audio"||o.nullLayer||o.adjust||r.adjust||r.nullLayer)throw Error("Invalid track matte source");if(o.matte)throw Error("A matte source cannot have its own track matte");if(t.has(o.id))throw Error("A layer can be the matte of only one layer");t.add(o.id)}}const Qw=n=>+(Math.max(0,Math.min(1,n))*Yi).toFixed(5),Jw=n=>+Math.max(0,Math.min(1,(n??0)/Yi)).toFixed(4),Ba=Object.freeze([["audioFx"],["audioTools"],["duck"],["muffle"],["captionWords","captionStyle"],["captions"],["bubble"],["layout"],["effects"],["distort"],["shadow"],["glow"],["sticker"],["edge"],["enter"],["exit"],["blend"],["motionBlur"],["grade"],["key"],["face"],["colorPerson"],["depthMap"],["roto"],["planar"],["pin"],["pendingPin"],["mask"],["person","personPending"],["revealType","reveal"],["visualFadeIn","visualFadeOut","fadeInColor","fadeOutColor"],["motionKeys"],["speedRamp"],["timeRemap"],["transition"],["join"],["matte"],["seam"]]),Ru={opacity:[0,1],volume:[0,1],brightness:[0,2],contrast:[0,2],visualFadeIn:[0,4],visualFadeOut:[0,4]};function Dd(n){let e=n;for(const[t,[r,s]]of Object.entries(Ru)){const o=n[t];o===void 0||Number.isFinite(o)&&o>=r&&o<=s||(e===n&&(e={...n}),Number.isFinite(o)?e[t]=Math.min(s,Math.max(r,o)):delete e[t])}return e}const $a=n=>{try{return Id(n),null}catch(e){return String(e?.message||e)}},Nd=(n,e)=>e.some(t=>n[t]!==void 0),Hr=(n,e)=>{const t={...n};for(const r of e)delete t[r];return t};function Vd(n){let e=$a(n);if(!e)return{clip:n,dropped:[],reason:null};const t=e;let r=n;const s=[];for(let o=0,a=!0;a&&o<Ba.length;o++){a=!1;for(const u of Ba){if(!Nd(r,u))continue;const l=Hr(r,u),d=$a(l);if(!d)return s.push(...u.filter(p=>r[p]!==void 0)),{clip:l,dropped:s,reason:t};if(d!==e){s.push(...u.filter(p=>r[p]!==void 0)),r=l,e=d,a=!0;break}}}return{clip:null,dropped:s,reason:t}}function Md(n){if(!Array.isArray(n))return{clips:n,fixes:[]};const e=[],t=(a,u,l)=>e.push({clipId:a.id,label:String(a.label??"").slice(0,60),start:a.start,track:a.track,dropped:u,reason:String(l||"").slice(0,160)});let s=vd(n).map((a,u)=>{if(!a||typeof a!="object")return a;const l=n[u];l&&(JSON.stringify(l.captions)!==JSON.stringify(a.captions)||JSON.stringify(l.captionWords)!==JSON.stringify(a.captionWords))&&t(a,["captions"],"subtitle cues overlapped or ran past the clip");const d=Dd(a);d!==a&&t(a,Object.keys(Ru).filter(v=>d[v]!==a[v]),"value out of range (clamped)");const p=Vd(d);return!p.clip||!p.dropped.length?d:(t(d,p.dropped,p.reason),p.clip)});const o=new Set(s.map(a=>a?.id));s=s.map(a=>{if(!a||typeof a!="object")return a;let u=a;if(u.parentId&&(!o.has(u.parentId)||Ed(s,u.id,u.parentId))&&(t(u,["parentId"],"parent layer missing or looping"),u=Hr(u,["parentId"])),u.transition!==void 0)try{Td(u,s)}catch(l){wd(s,u)||t(u,["transition"],l?.message),u=Hr(u,["transition"])}return u});for(let a=0;a<8;a++)try{Od(s);break}catch(u){const l=s.findIndex(d=>d?.matte!==void 0);if(l<0)break;t(s[l],["matte"],u?.message),s=s.map((d,p)=>p===l?Hr(d,["matte"]):d)}return{clips:s,fixes:e}}const Ld=["mp3","wav","m4a","aac","flac","ogg","oga","opus","weba","aif","aiff"];function xd(n){if(!n)return!1;if(typeof n.type=="string"&&n.type.startsWith("audio/"))return!0;if(typeof n.type=="string"&&n.type)return!1;const e=typeof n.name=="string"?n.name.split(".").pop().toLowerCase():"";return Ld.includes(e)}let Ii=null,qa=Promise.resolve();const ns=new Set,za=()=>ns.forEach(n=>n());function Ud(n){const e=()=>new Promise(r=>{if(!ns.size)return r(!1);Ii={names:n,resolve:s=>{Ii=null,za(),r(s)}},za()}),t=qa.then(e,e);return qa=t,t}function Xw(){return Pd.useSyncExternalStore(n=>(ns.add(n),()=>{ns.delete(n)}),()=>Ii,()=>null)}const Ha="application/vnd.clipoox.export-progress";new TextEncoder;function Fd(){let n=new Uint8Array(0),e=-1,t=!1;const r=new TextDecoder;return{push(s){const o=[];if(e>=0)return s.length&&o.push({type:"data",chunk:s}),e-=s.length,o;const a=new Uint8Array(n.length+s.length);a.set(n),a.set(s,n.length);let u=0;for(;;){const l=a.indexOf(10,u);if(l<0)break;const d=r.decode(a.subarray(u,l)),p=d[0],v=d.slice(2);if(u=l+1,p==="P"){const E=Number(v);Number.isFinite(E)&&o.push({type:"progress",value:Math.max(0,Math.min(1,E))})}else if(p==="R")try{o.push({type:"review",review:JSON.parse(decodeURIComponent(v))})}catch{o.push({type:"review",review:null})}else if(p==="T")try{o.push({type:"timings",timings:JSON.parse(decodeURIComponent(v))})}catch{}else if(p==="E"){let E={};try{E=JSON.parse(v)}catch{}o.push({type:"error",error:String(E.error||"Export failed"),status:Number(E.status)||500})}else if(p==="S"){let E={};try{E=JSON.parse(decodeURIComponent(v))}catch{}typeof E.gcsUri=="string"&&(t=!0,o.push({type:"stored",gcsUri:E.gcsUri,size:Number(E.size)||0}))}else if(p==="F"){e=Number(v)||0,o.push({type:"file",size:e});const E=a.subarray(u);return E.length&&o.push({type:"data",chunk:E}),e-=E.length,n=new Uint8Array(0),o}}return n=a.slice(u),o},get complete(){return e===0||t}}}async function jd(n){let e;try{e=await n.text()}catch(t){if(n.ok)throw Wa(t);return{}}if(!e)return{};try{return JSON.parse(e)}catch(t){if(n.ok&&/^\s*([{[]|$)/.test(e))throw Wa(t);return{}}}const Wa=n=>Object.assign(Error("reply lost"),{code:"reply_lost",cause:n}),Bd=600,Yw=600,ui=n=>String(n).padStart(2,"0");function Zw(n){const e=Math.max(0,Math.round(Number(n)||0)),t=Math.floor(e/3600),r=Math.floor(e/60)%60;return t?`${t}:${ui(r)}:${ui(e%60)}`:`${r}:${ui(e%60)}`}const rs="application/vnd.clipoox.analysis-progress+json";function Su(n,e){const t=Math.max(1,Number(e)||1),r=Math.max(0,Number(n)||0);return r<=t?.9*r/t:.9+.079*(1-Math.exp(-(r-t)/t))}const $d=30;function qd(n){const e=Number(n?.duration),t=Number.isFinite(e)&&e>0?Math.min(e,Bd):$d,r={id:"fetch",seconds:2+t*.03};if(n?.mode==="music")return[r,{id:"beats",seconds:2+t*.08}];if(n?.mode==="reference")return[r,{id:"rhythm",seconds:12+t*.25}];const s=t>600?3:1,o={id:"cuts",seconds:1+t*.08},a={id:"speech",seconds:4+t*.12/s};return n?.audioOnly?[r,o,a]:[r,o,{id:"scenes",seconds:(Math.ceil(t/120)*15+t*.15)/s},a]}function eI(n,e){const t=(n||[]).map(qd),r=t.flat().reduce((l,d)=>l+d.seconds,0)||1,s=Su(e,r);let o=Math.min(r,s/.9*r)-1e-9,a=0,u=t[0]?.[0]?.id||"fetch";e:for(const[l,d]of t.entries())for(const p of d){if(a=l,u=p.id,o<p.seconds)break e;o-=p.seconds}return{fraction:s,index:a,count:t.length,stage:u}}const Ga={video:{fetch:.03,cuts:.12,scenes:.7,speech:1},audio:{fetch:.03,cuts:.12,scenes:.12,speech:1}};function tI(n,e=!1){const t=e?Ga.audio:Ga.video,r=["fetch","cuts","scenes","speech"],s=r.indexOf(n?.stage);if(s<0)return 0;const o=s?t[r[s-1]]:0,a=t[r[s]],u=Number(n.total)>0?Math.min(1,Math.max(0,Number(n.done)||0)/Number(n.total)):0,l=Math.max(1,Number(n.count)||1),d=Math.min(l-1,Math.max(0,Number(n.index)||0));return Math.min(.99,(d+o+(a-o)*u)/l)}function nI(n,e=!0){const t=Math.round(Math.max(0,Math.min(1,Number(n)||0))*100);return e?Math.min(99,t):t}const zd=()=>{};var Ka={};/**
3
+ * @license
4
+ * Copyright 2017 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */const Cu=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Hd=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const o=n[t++];e[r++]=String.fromCharCode((s&31)<<6|o&63)}else if(s>239&&s<365){const o=n[t++],a=n[t++],u=n[t++],l=((s&7)<<18|(o&63)<<12|(a&63)<<6|u&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const o=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(o&63)<<6|a&63)}}return e.join("")},Pu={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const o=n[s],a=s+1<n.length,u=a?n[s+1]:0,l=s+2<n.length,d=l?n[s+2]:0,p=o>>2,v=(o&3)<<4|u>>4;let E=(u&15)<<2|d>>6,C=d&63;l||(C=64,a||(E=64)),r.push(t[p],t[v],t[E],t[C])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Cu(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):Hd(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const o=t[n.charAt(s++)],u=s<n.length?t[n.charAt(s)]:0;++s;const d=s<n.length?t[n.charAt(s)]:64;++s;const v=s<n.length?t[n.charAt(s)]:64;if(++s,o==null||u==null||d==null||v==null)throw new Wd;const E=o<<2|u>>4;if(r.push(E),d!==64){const C=u<<4&240|d>>2;if(r.push(C),v!==64){const V=d<<6&192|v;r.push(V)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class Wd extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Gd=function(n){const e=Cu(n);return Pu.encodeByteArray(e,!0)},ss=function(n){return Gd(n).replace(/\./g,"")},ku=function(n){try{return Pu.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
18
+ * @license
19
+ * Copyright 2022 Google LLC
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ */function Kd(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
33
+ * @license
34
+ * Copyright 2022 Google LLC
35
+ *
36
+ * Licensed under the Apache License, Version 2.0 (the "License");
37
+ * you may not use this file except in compliance with the License.
38
+ * You may obtain a copy of the License at
39
+ *
40
+ * http://www.apache.org/licenses/LICENSE-2.0
41
+ *
42
+ * Unless required by applicable law or agreed to in writing, software
43
+ * distributed under the License is distributed on an "AS IS" BASIS,
44
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45
+ * See the License for the specific language governing permissions and
46
+ * limitations under the License.
47
+ */const Qd=()=>Kd().__FIREBASE_DEFAULTS__,Jd=()=>{if(typeof process>"u"||typeof Ka>"u")return;const n=Ka.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Xd=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&ku(n[1]);return e&&JSON.parse(e)},Es=()=>{try{return zd()||Qd()||Jd()||Xd()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Ou=n=>{var e,t;return(t=(e=Es())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},Yd=n=>{const e=Ou(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},Du=()=>{var n;return(n=Es())===null||n===void 0?void 0:n.config},Nu=n=>{var e;return(e=Es())===null||e===void 0?void 0:e[`_${n}`]};/**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ *
51
+ * Licensed under the Apache License, Version 2.0 (the "License");
52
+ * you may not use this file except in compliance with the License.
53
+ * You may obtain a copy of the License at
54
+ *
55
+ * http://www.apache.org/licenses/LICENSE-2.0
56
+ *
57
+ * Unless required by applicable law or agreed to in writing, software
58
+ * distributed under the License is distributed on an "AS IS" BASIS,
59
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60
+ * See the License for the specific language governing permissions and
61
+ * limitations under the License.
62
+ */class Zd{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/**
63
+ * @license
64
+ * Copyright 2025 Google LLC
65
+ *
66
+ * Licensed under the Apache License, Version 2.0 (the "License");
67
+ * you may not use this file except in compliance with the License.
68
+ * You may obtain a copy of the License at
69
+ *
70
+ * http://www.apache.org/licenses/LICENSE-2.0
71
+ *
72
+ * Unless required by applicable law or agreed to in writing, software
73
+ * distributed under the License is distributed on an "AS IS" BASIS,
74
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75
+ * See the License for the specific language governing permissions and
76
+ * limitations under the License.
77
+ */function _n(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function Vu(n){return(await fetch(n,{credentials:"include"})).ok}/**
78
+ * @license
79
+ * Copyright 2021 Google LLC
80
+ *
81
+ * Licensed under the Apache License, Version 2.0 (the "License");
82
+ * you may not use this file except in compliance with the License.
83
+ * You may obtain a copy of the License at
84
+ *
85
+ * http://www.apache.org/licenses/LICENSE-2.0
86
+ *
87
+ * Unless required by applicable law or agreed to in writing, software
88
+ * distributed under the License is distributed on an "AS IS" BASIS,
89
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
90
+ * See the License for the specific language governing permissions and
91
+ * limitations under the License.
92
+ */function ef(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,o=n.sub||n.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}}},n);return[ss(JSON.stringify(t)),ss(JSON.stringify(a)),""].join(".")}const Wn={};function tf(){const n={prod:[],emulator:[]};for(const e of Object.keys(Wn))Wn[e]?n.emulator.push(e):n.prod.push(e);return n}function nf(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Qa=!1;function Mu(n,e){if(typeof window>"u"||typeof document>"u"||!_n(window.location.host)||Wn[n]===e||Wn[n]||Qa)return;Wn[n]=e;function t(E){return`__firebase__banner__${E}`}const r="__firebase__banner",o=tf().prod.length>0;function a(){const E=document.getElementById(r);E&&E.remove()}function u(E){E.style.display="flex",E.style.background="#7faaf0",E.style.position="fixed",E.style.bottom="5px",E.style.left="5px",E.style.padding=".5em",E.style.borderRadius="5px",E.style.alignItems="center"}function l(E,C){E.setAttribute("width","24"),E.setAttribute("id",C),E.setAttribute("height","24"),E.setAttribute("viewBox","0 0 24 24"),E.setAttribute("fill","none"),E.style.marginLeft="-6px"}function d(){const E=document.createElement("span");return E.style.cursor="pointer",E.style.marginLeft="16px",E.style.fontSize="24px",E.innerHTML=" &times;",E.onclick=()=>{Qa=!0,a()},E}function p(E,C){E.setAttribute("id",C),E.innerText="Learn more",E.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",E.setAttribute("target","__blank"),E.style.paddingLeft="5px",E.style.textDecoration="underline"}function v(){const E=nf(r),C=t("text"),V=document.getElementById(C)||document.createElement("span"),M=t("learnmore"),k=document.getElementById(M)||document.createElement("a"),q=t("preprendIcon"),z=document.getElementById(q)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(E.created){const B=E.element;u(B),p(k,M);const Y=d();l(z,q),B.append(z,V,k,Y),document.body.appendChild(B)}o?(V.innerText="Preview backend disconnected.",z.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
93
+ <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
94
+ </g>
95
+ <defs>
96
+ <clipPath id="clip0_6013_33858">
97
+ <rect width="24" height="24" fill="white"/>
98
+ </clipPath>
99
+ </defs>`):(z.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
100
+ <path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
101
+ </g>
102
+ <defs>
103
+ <clipPath id="clip0_6083_34804">
104
+ <rect width="24" height="24" fill="white"/>
105
+ </clipPath>
106
+ </defs>`,V.innerText="Preview backend running in this workspace."),V.setAttribute("id",C)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",v):v()}/**
107
+ * @license
108
+ * Copyright 2017 Google LLC
109
+ *
110
+ * Licensed under the Apache License, Version 2.0 (the "License");
111
+ * you may not use this file except in compliance with the License.
112
+ * You may obtain a copy of the License at
113
+ *
114
+ * http://www.apache.org/licenses/LICENSE-2.0
115
+ *
116
+ * Unless required by applicable law or agreed to in writing, software
117
+ * distributed under the License is distributed on an "AS IS" BASIS,
118
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
+ * See the License for the specific language governing permissions and
120
+ * limitations under the License.
121
+ */function Ae(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function rf(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Ae())}function sf(){var n;const e=(n=Es())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function of(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function af(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function cf(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function uf(){const n=Ae();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function lf(){return!sf()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function hf(){try{return typeof indexedDB=="object"}catch{return!1}}function df(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var o;e(((o=s.error)===null||o===void 0?void 0:o.message)||"")}}catch(t){e(t)}})}/**
122
+ * @license
123
+ * Copyright 2017 Google LLC
124
+ *
125
+ * Licensed under the Apache License, Version 2.0 (the "License");
126
+ * you may not use this file except in compliance with the License.
127
+ * You may obtain a copy of the License at
128
+ *
129
+ * http://www.apache.org/licenses/LICENSE-2.0
130
+ *
131
+ * Unless required by applicable law or agreed to in writing, software
132
+ * distributed under the License is distributed on an "AS IS" BASIS,
133
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
+ * See the License for the specific language governing permissions and
135
+ * limitations under the License.
136
+ */const ff="FirebaseError";class st extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=ff,Object.setPrototypeOf(this,st.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,cr.prototype.create)}}class cr{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,o=this.errors[e],a=o?pf(o,r):"Error",u=`${this.serviceName}: ${a} (${s}).`;return new st(s,u,r)}}function pf(n,e){return n.replace(mf,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const mf=/\{\$([^}]+)}/g;function gf(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Bt(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const o=n[s],a=e[s];if(Ja(o)&&Ja(a)){if(!Bt(o,a))return!1}else if(o!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Ja(n){return n!==null&&typeof n=="object"}/**
137
+ * @license
138
+ * Copyright 2017 Google LLC
139
+ *
140
+ * Licensed under the Apache License, Version 2.0 (the "License");
141
+ * you may not use this file except in compliance with the License.
142
+ * You may obtain a copy of the License at
143
+ *
144
+ * http://www.apache.org/licenses/LICENSE-2.0
145
+ *
146
+ * Unless required by applicable law or agreed to in writing, software
147
+ * distributed under the License is distributed on an "AS IS" BASIS,
148
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
+ * See the License for the specific language governing permissions and
150
+ * limitations under the License.
151
+ */function ur(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function jn(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,o]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(o)}}),e}function Bn(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function _f(n,e){const t=new yf(n,e);return t.subscribe.bind(t)}class yf{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");vf(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=li),s.error===void 0&&(s.error=li),s.complete===void 0&&(s.complete=li);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),o}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function vf(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function li(){}/**
152
+ * @license
153
+ * Copyright 2021 Google LLC
154
+ *
155
+ * Licensed under the Apache License, Version 2.0 (the "License");
156
+ * you may not use this file except in compliance with the License.
157
+ * You may obtain a copy of the License at
158
+ *
159
+ * http://www.apache.org/licenses/LICENSE-2.0
160
+ *
161
+ * Unless required by applicable law or agreed to in writing, software
162
+ * distributed under the License is distributed on an "AS IS" BASIS,
163
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164
+ * See the License for the specific language governing permissions and
165
+ * limitations under the License.
166
+ */function xe(n){return n&&n._delegate?n._delegate:n}class $t{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
167
+ * @license
168
+ * Copyright 2019 Google LLC
169
+ *
170
+ * Licensed under the Apache License, Version 2.0 (the "License");
171
+ * you may not use this file except in compliance with the License.
172
+ * You may obtain a copy of the License at
173
+ *
174
+ * http://www.apache.org/licenses/LICENSE-2.0
175
+ *
176
+ * Unless required by applicable law or agreed to in writing, software
177
+ * distributed under the License is distributed on an "AS IS" BASIS,
178
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
+ * See the License for the specific language governing permissions and
180
+ * limitations under the License.
181
+ */const Mt="[DEFAULT]";/**
182
+ * @license
183
+ * Copyright 2019 Google LLC
184
+ *
185
+ * Licensed under the Apache License, Version 2.0 (the "License");
186
+ * you may not use this file except in compliance with the License.
187
+ * You may obtain a copy of the License at
188
+ *
189
+ * http://www.apache.org/licenses/LICENSE-2.0
190
+ *
191
+ * Unless required by applicable law or agreed to in writing, software
192
+ * distributed under the License is distributed on an "AS IS" BASIS,
193
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ * See the License for the specific language governing permissions and
195
+ * limitations under the License.
196
+ */class Ef{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new Zd;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const r=this.normalizeInstanceIdentifier(e?.identifier),s=(t=e?.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(o){if(s)return null;throw o}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(wf(e))try{this.getOrInitializeService({instanceIdentifier:Mt})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const o=this.getOrInitializeService({instanceIdentifier:s});r.resolve(o)}catch{}}}}clearInstance(e=Mt){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Mt){return this.instances.has(e)}getOptions(e=Mt){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[o,a]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(o);r===u&&a.resolve(s)}return s}onInit(e,t){var r;const s=this.normalizeInstanceIdentifier(t),o=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;o.add(e),this.onInitCallbacks.set(s,o);const a=this.instances.get(s);return a&&e(a,s),()=>{o.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Tf(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Mt){return this.component?this.component.multipleInstances?e:Mt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Tf(n){return n===Mt?void 0:n}function wf(n){return n.instantiationMode==="EAGER"}/**
197
+ * @license
198
+ * Copyright 2019 Google LLC
199
+ *
200
+ * Licensed under the Apache License, Version 2.0 (the "License");
201
+ * you may not use this file except in compliance with the License.
202
+ * You may obtain a copy of the License at
203
+ *
204
+ * http://www.apache.org/licenses/LICENSE-2.0
205
+ *
206
+ * Unless required by applicable law or agreed to in writing, software
207
+ * distributed under the License is distributed on an "AS IS" BASIS,
208
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ * See the License for the specific language governing permissions and
210
+ * limitations under the License.
211
+ */class If{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new Ef(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
212
+ * @license
213
+ * Copyright 2017 Google LLC
214
+ *
215
+ * Licensed under the Apache License, Version 2.0 (the "License");
216
+ * you may not use this file except in compliance with the License.
217
+ * You may obtain a copy of the License at
218
+ *
219
+ * http://www.apache.org/licenses/LICENSE-2.0
220
+ *
221
+ * Unless required by applicable law or agreed to in writing, software
222
+ * distributed under the License is distributed on an "AS IS" BASIS,
223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ * See the License for the specific language governing permissions and
225
+ * limitations under the License.
226
+ */var G;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(G||(G={}));const Af={debug:G.DEBUG,verbose:G.VERBOSE,info:G.INFO,warn:G.WARN,error:G.ERROR,silent:G.SILENT},bf=G.INFO,Rf={[G.DEBUG]:"log",[G.VERBOSE]:"log",[G.INFO]:"info",[G.WARN]:"warn",[G.ERROR]:"error"},Sf=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Rf[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Zi{constructor(e){this.name=e,this._logLevel=bf,this._logHandler=Sf,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in G))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Af[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,G.DEBUG,...e),this._logHandler(this,G.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,G.VERBOSE,...e),this._logHandler(this,G.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,G.INFO,...e),this._logHandler(this,G.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,G.WARN,...e),this._logHandler(this,G.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,G.ERROR,...e),this._logHandler(this,G.ERROR,...e)}}const Cf=(n,e)=>e.some(t=>n instanceof t);let Xa,Ya;function Pf(){return Xa||(Xa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kf(){return Ya||(Ya=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Lu=new WeakMap,Ai=new WeakMap,xu=new WeakMap,hi=new WeakMap,eo=new WeakMap;function Of(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",o),n.removeEventListener("error",a)},o=()=>{t(_t(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",o),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&Lu.set(t,n)}).catch(()=>{}),eo.set(e,n),e}function Df(n){if(Ai.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",o),n.removeEventListener("error",a),n.removeEventListener("abort",a)},o=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",o),n.addEventListener("error",a),n.addEventListener("abort",a)});Ai.set(n,e)}let bi={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Ai.get(n);if(e==="objectStoreNames")return n.objectStoreNames||xu.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return _t(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nf(n){bi=n(bi)}function Vf(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(di(this),e,...t);return xu.set(r,e.sort?e.sort():[e]),_t(r)}:kf().includes(n)?function(...e){return n.apply(di(this),e),_t(Lu.get(this))}:function(...e){return _t(n.apply(di(this),e))}}function Mf(n){return typeof n=="function"?Vf(n):(n instanceof IDBTransaction&&Df(n),Cf(n,Pf())?new Proxy(n,bi):n)}function _t(n){if(n instanceof IDBRequest)return Of(n);if(hi.has(n))return hi.get(n);const e=Mf(n);return e!==n&&(hi.set(n,e),eo.set(e,n)),e}const di=n=>eo.get(n);function Lf(n,e,{blocked:t,upgrade:r,blocking:s,terminated:o}={}){const a=indexedDB.open(n,e),u=_t(a);return r&&a.addEventListener("upgradeneeded",l=>{r(_t(a.result),l.oldVersion,l.newVersion,_t(a.transaction),l)}),t&&a.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),u.then(l=>{o&&l.addEventListener("close",()=>o()),s&&l.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),u}const xf=["get","getKey","getAll","getAllKeys","count"],Uf=["put","add","delete","clear"],fi=new Map;function Za(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(fi.get(e))return fi.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=Uf.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||xf.includes(t)))return;const o=async function(a,...u){const l=this.transaction(a,s?"readwrite":"readonly");let d=l.store;return r&&(d=d.index(u.shift())),(await Promise.all([d[t](...u),s&&l.done]))[0]};return fi.set(e,o),o}Nf(n=>({...n,get:(e,t,r)=>Za(e,t)||n.get(e,t,r),has:(e,t)=>!!Za(e,t)||n.has(e,t)}));/**
227
+ * @license
228
+ * Copyright 2019 Google LLC
229
+ *
230
+ * Licensed under the Apache License, Version 2.0 (the "License");
231
+ * you may not use this file except in compliance with the License.
232
+ * You may obtain a copy of the License at
233
+ *
234
+ * http://www.apache.org/licenses/LICENSE-2.0
235
+ *
236
+ * Unless required by applicable law or agreed to in writing, software
237
+ * distributed under the License is distributed on an "AS IS" BASIS,
238
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
+ * See the License for the specific language governing permissions and
240
+ * limitations under the License.
241
+ */class Ff{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(jf(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function jf(n){const e=n.getComponent();return e?.type==="VERSION"}const Ri="@firebase/app",ec="0.13.2";/**
242
+ * @license
243
+ * Copyright 2019 Google LLC
244
+ *
245
+ * Licensed under the Apache License, Version 2.0 (the "License");
246
+ * you may not use this file except in compliance with the License.
247
+ * You may obtain a copy of the License at
248
+ *
249
+ * http://www.apache.org/licenses/LICENSE-2.0
250
+ *
251
+ * Unless required by applicable law or agreed to in writing, software
252
+ * distributed under the License is distributed on an "AS IS" BASIS,
253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254
+ * See the License for the specific language governing permissions and
255
+ * limitations under the License.
256
+ */const et=new Zi("@firebase/app"),Bf="@firebase/app-compat",$f="@firebase/analytics-compat",qf="@firebase/analytics",zf="@firebase/app-check-compat",Hf="@firebase/app-check",Wf="@firebase/auth",Gf="@firebase/auth-compat",Kf="@firebase/database",Qf="@firebase/data-connect",Jf="@firebase/database-compat",Xf="@firebase/functions",Yf="@firebase/functions-compat",Zf="@firebase/installations",ep="@firebase/installations-compat",tp="@firebase/messaging",np="@firebase/messaging-compat",rp="@firebase/performance",sp="@firebase/performance-compat",ip="@firebase/remote-config",op="@firebase/remote-config-compat",ap="@firebase/storage",cp="@firebase/storage-compat",up="@firebase/firestore",lp="@firebase/ai",hp="@firebase/firestore-compat",dp="firebase",fp="11.10.0";/**
257
+ * @license
258
+ * Copyright 2019 Google LLC
259
+ *
260
+ * Licensed under the Apache License, Version 2.0 (the "License");
261
+ * you may not use this file except in compliance with the License.
262
+ * You may obtain a copy of the License at
263
+ *
264
+ * http://www.apache.org/licenses/LICENSE-2.0
265
+ *
266
+ * Unless required by applicable law or agreed to in writing, software
267
+ * distributed under the License is distributed on an "AS IS" BASIS,
268
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269
+ * See the License for the specific language governing permissions and
270
+ * limitations under the License.
271
+ */const Si="[DEFAULT]",pp={[Ri]:"fire-core",[Bf]:"fire-core-compat",[qf]:"fire-analytics",[$f]:"fire-analytics-compat",[Hf]:"fire-app-check",[zf]:"fire-app-check-compat",[Wf]:"fire-auth",[Gf]:"fire-auth-compat",[Kf]:"fire-rtdb",[Qf]:"fire-data-connect",[Jf]:"fire-rtdb-compat",[Xf]:"fire-fn",[Yf]:"fire-fn-compat",[Zf]:"fire-iid",[ep]:"fire-iid-compat",[tp]:"fire-fcm",[np]:"fire-fcm-compat",[rp]:"fire-perf",[sp]:"fire-perf-compat",[ip]:"fire-rc",[op]:"fire-rc-compat",[ap]:"fire-gcs",[cp]:"fire-gcs-compat",[up]:"fire-fst",[hp]:"fire-fst-compat",[lp]:"fire-vertex","fire-js":"fire-js",[dp]:"fire-js-all"};/**
272
+ * @license
273
+ * Copyright 2019 Google LLC
274
+ *
275
+ * Licensed under the Apache License, Version 2.0 (the "License");
276
+ * you may not use this file except in compliance with the License.
277
+ * You may obtain a copy of the License at
278
+ *
279
+ * http://www.apache.org/licenses/LICENSE-2.0
280
+ *
281
+ * Unless required by applicable law or agreed to in writing, software
282
+ * distributed under the License is distributed on an "AS IS" BASIS,
283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
+ * See the License for the specific language governing permissions and
285
+ * limitations under the License.
286
+ */const Zn=new Map,mp=new Map,Ci=new Map;function tc(n,e){try{n.container.addComponent(e)}catch(t){et.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function ln(n){const e=n.name;if(Ci.has(e))return et.debug(`There were multiple attempts to register component ${e}.`),!1;Ci.set(e,n);for(const t of Zn.values())tc(t,n);for(const t of mp.values())tc(t,n);return!0}function to(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function ke(n){return n==null?!1:n.settings!==void 0}/**
287
+ * @license
288
+ * Copyright 2019 Google LLC
289
+ *
290
+ * Licensed under the Apache License, Version 2.0 (the "License");
291
+ * you may not use this file except in compliance with the License.
292
+ * You may obtain a copy of the License at
293
+ *
294
+ * http://www.apache.org/licenses/LICENSE-2.0
295
+ *
296
+ * Unless required by applicable law or agreed to in writing, software
297
+ * distributed under the License is distributed on an "AS IS" BASIS,
298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
+ * See the License for the specific language governing permissions and
300
+ * limitations under the License.
301
+ */const gp={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},yt=new cr("app","Firebase",gp);/**
302
+ * @license
303
+ * Copyright 2019 Google LLC
304
+ *
305
+ * Licensed under the Apache License, Version 2.0 (the "License");
306
+ * you may not use this file except in compliance with the License.
307
+ * You may obtain a copy of the License at
308
+ *
309
+ * http://www.apache.org/licenses/LICENSE-2.0
310
+ *
311
+ * Unless required by applicable law or agreed to in writing, software
312
+ * distributed under the License is distributed on an "AS IS" BASIS,
313
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314
+ * See the License for the specific language governing permissions and
315
+ * limitations under the License.
316
+ */class _p{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new $t("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw yt.create("app-deleted",{appName:this._name})}}/**
317
+ * @license
318
+ * Copyright 2019 Google LLC
319
+ *
320
+ * Licensed under the Apache License, Version 2.0 (the "License");
321
+ * you may not use this file except in compliance with the License.
322
+ * You may obtain a copy of the License at
323
+ *
324
+ * http://www.apache.org/licenses/LICENSE-2.0
325
+ *
326
+ * Unless required by applicable law or agreed to in writing, software
327
+ * distributed under the License is distributed on an "AS IS" BASIS,
328
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329
+ * See the License for the specific language governing permissions and
330
+ * limitations under the License.
331
+ */const yn=fp;function Uu(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r=Object.assign({name:Si,automaticDataCollectionEnabled:!0},e),s=r.name;if(typeof s!="string"||!s)throw yt.create("bad-app-name",{appName:String(s)});if(t||(t=Du()),!t)throw yt.create("no-options");const o=Zn.get(s);if(o){if(Bt(t,o.options)&&Bt(r,o.config))return o;throw yt.create("duplicate-app",{appName:s})}const a=new If(s);for(const l of Ci.values())a.addComponent(l);const u=new _p(t,r,a);return Zn.set(s,u),u}function Fu(n=Si){const e=Zn.get(n);if(!e&&n===Si&&Du())return Uu();if(!e)throw yt.create("no-app",{appName:n});return e}function yp(){return Array.from(Zn.values())}function vt(n,e,t){var r;let s=(r=pp[n])!==null&&r!==void 0?r:n;t&&(s+=`-${t}`);const o=s.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const u=[`Unable to register library "${s}" with version "${e}":`];o&&u.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&a&&u.push("and"),a&&u.push(`version name "${e}" contains illegal characters (whitespace or "/")`),et.warn(u.join(" "));return}ln(new $t(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/**
332
+ * @license
333
+ * Copyright 2021 Google LLC
334
+ *
335
+ * Licensed under the Apache License, Version 2.0 (the "License");
336
+ * you may not use this file except in compliance with the License.
337
+ * You may obtain a copy of the License at
338
+ *
339
+ * http://www.apache.org/licenses/LICENSE-2.0
340
+ *
341
+ * Unless required by applicable law or agreed to in writing, software
342
+ * distributed under the License is distributed on an "AS IS" BASIS,
343
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344
+ * See the License for the specific language governing permissions and
345
+ * limitations under the License.
346
+ */const vp="firebase-heartbeat-database",Ep=1,er="firebase-heartbeat-store";let pi=null;function ju(){return pi||(pi=Lf(vp,Ep,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(er)}catch(t){console.warn(t)}}}}).catch(n=>{throw yt.create("idb-open",{originalErrorMessage:n.message})})),pi}async function Tp(n){try{const t=(await ju()).transaction(er),r=await t.objectStore(er).get(Bu(n));return await t.done,r}catch(e){if(e instanceof st)et.warn(e.message);else{const t=yt.create("idb-get",{originalErrorMessage:e?.message});et.warn(t.message)}}}async function nc(n,e){try{const r=(await ju()).transaction(er,"readwrite");await r.objectStore(er).put(e,Bu(n)),await r.done}catch(t){if(t instanceof st)et.warn(t.message);else{const r=yt.create("idb-set",{originalErrorMessage:t?.message});et.warn(r.message)}}}function Bu(n){return`${n.name}!${n.options.appId}`}/**
347
+ * @license
348
+ * Copyright 2021 Google LLC
349
+ *
350
+ * Licensed under the Apache License, Version 2.0 (the "License");
351
+ * you may not use this file except in compliance with the License.
352
+ * You may obtain a copy of the License at
353
+ *
354
+ * http://www.apache.org/licenses/LICENSE-2.0
355
+ *
356
+ * Unless required by applicable law or agreed to in writing, software
357
+ * distributed under the License is distributed on an "AS IS" BASIS,
358
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359
+ * See the License for the specific language governing permissions and
360
+ * limitations under the License.
361
+ */const wp=1024,Ip=30;class Ap{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Rp(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),o=rc();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===o||this._heartbeatsCache.heartbeats.some(a=>a.date===o))return;if(this._heartbeatsCache.heartbeats.push({date:o,agent:s}),this._heartbeatsCache.heartbeats.length>Ip){const a=Sp(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){et.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=rc(),{heartbeatsToSend:r,unsentEntries:s}=bp(this._heartbeatsCache.heartbeats),o=ss(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),o}catch(t){return et.warn(t),""}}}function rc(){return new Date().toISOString().substring(0,10)}function bp(n,e=wp){const t=[];let r=n.slice();for(const s of n){const o=t.find(a=>a.agent===s.agent);if(o){if(o.dates.push(s.date),sc(t)>e){o.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),sc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class Rp{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return hf()?df().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await Tp(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return nc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return nc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function sc(n){return ss(JSON.stringify({version:2,heartbeats:n})).length}function Sp(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}/**
362
+ * @license
363
+ * Copyright 2019 Google LLC
364
+ *
365
+ * Licensed under the Apache License, Version 2.0 (the "License");
366
+ * you may not use this file except in compliance with the License.
367
+ * You may obtain a copy of the License at
368
+ *
369
+ * http://www.apache.org/licenses/LICENSE-2.0
370
+ *
371
+ * Unless required by applicable law or agreed to in writing, software
372
+ * distributed under the License is distributed on an "AS IS" BASIS,
373
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374
+ * See the License for the specific language governing permissions and
375
+ * limitations under the License.
376
+ */function Cp(n){ln(new $t("platform-logger",e=>new Ff(e),"PRIVATE")),ln(new $t("heartbeat",e=>new Ap(e),"PRIVATE")),vt(Ri,ec,n),vt(Ri,ec,"esm2017"),vt("fire-js","")}Cp("");var Pp="firebase",kp="11.10.0";/**
377
+ * @license
378
+ * Copyright 2020 Google LLC
379
+ *
380
+ * Licensed under the Apache License, Version 2.0 (the "License");
381
+ * you may not use this file except in compliance with the License.
382
+ * You may obtain a copy of the License at
383
+ *
384
+ * http://www.apache.org/licenses/LICENSE-2.0
385
+ *
386
+ * Unless required by applicable law or agreed to in writing, software
387
+ * distributed under the License is distributed on an "AS IS" BASIS,
388
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389
+ * See the License for the specific language governing permissions and
390
+ * limitations under the License.
391
+ */vt(Pp,kp,"app");function no(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function $u(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const Op=$u,qu=new cr("auth","Firebase",$u());/**
392
+ * @license
393
+ * Copyright 2020 Google LLC
394
+ *
395
+ * Licensed under the Apache License, Version 2.0 (the "License");
396
+ * you may not use this file except in compliance with the License.
397
+ * You may obtain a copy of the License at
398
+ *
399
+ * http://www.apache.org/licenses/LICENSE-2.0
400
+ *
401
+ * Unless required by applicable law or agreed to in writing, software
402
+ * distributed under the License is distributed on an "AS IS" BASIS,
403
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404
+ * See the License for the specific language governing permissions and
405
+ * limitations under the License.
406
+ */const is=new Zi("@firebase/auth");function Dp(n,...e){is.logLevel<=G.WARN&&is.warn(`Auth (${yn}): ${n}`,...e)}function Wr(n,...e){is.logLevel<=G.ERROR&&is.error(`Auth (${yn}): ${n}`,...e)}/**
407
+ * @license
408
+ * Copyright 2020 Google LLC
409
+ *
410
+ * Licensed under the Apache License, Version 2.0 (the "License");
411
+ * you may not use this file except in compliance with the License.
412
+ * You may obtain a copy of the License at
413
+ *
414
+ * http://www.apache.org/licenses/LICENSE-2.0
415
+ *
416
+ * Unless required by applicable law or agreed to in writing, software
417
+ * distributed under the License is distributed on an "AS IS" BASIS,
418
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419
+ * See the License for the specific language governing permissions and
420
+ * limitations under the License.
421
+ */function Ne(n,...e){throw so(n,...e)}function Le(n,...e){return so(n,...e)}function ro(n,e,t){const r=Object.assign(Object.assign({},Op()),{[e]:t});return new cr("auth","Firebase",r).create(e,{appName:n.name})}function $e(n){return ro(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function zu(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&Ne(n,"argument-error"),ro(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function so(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return qu.create(n,...e)}function F(n,e,...t){if(!n)throw so(e,...t)}function Ye(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Wr(e),new Error(e)}function tt(n,e){n||Ye(e)}/**
422
+ * @license
423
+ * Copyright 2020 Google LLC
424
+ *
425
+ * Licensed under the Apache License, Version 2.0 (the "License");
426
+ * you may not use this file except in compliance with the License.
427
+ * You may obtain a copy of the License at
428
+ *
429
+ * http://www.apache.org/licenses/LICENSE-2.0
430
+ *
431
+ * Unless required by applicable law or agreed to in writing, software
432
+ * distributed under the License is distributed on an "AS IS" BASIS,
433
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434
+ * See the License for the specific language governing permissions and
435
+ * limitations under the License.
436
+ */function Pi(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function Np(){return ic()==="http:"||ic()==="https:"}function ic(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/**
437
+ * @license
438
+ * Copyright 2020 Google LLC
439
+ *
440
+ * Licensed under the Apache License, Version 2.0 (the "License");
441
+ * you may not use this file except in compliance with the License.
442
+ * You may obtain a copy of the License at
443
+ *
444
+ * http://www.apache.org/licenses/LICENSE-2.0
445
+ *
446
+ * Unless required by applicable law or agreed to in writing, software
447
+ * distributed under the License is distributed on an "AS IS" BASIS,
448
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449
+ * See the License for the specific language governing permissions and
450
+ * limitations under the License.
451
+ */function Vp(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Np()||af()||"connection"in navigator)?navigator.onLine:!0}function Mp(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
452
+ * @license
453
+ * Copyright 2020 Google LLC
454
+ *
455
+ * Licensed under the Apache License, Version 2.0 (the "License");
456
+ * you may not use this file except in compliance with the License.
457
+ * You may obtain a copy of the License at
458
+ *
459
+ * http://www.apache.org/licenses/LICENSE-2.0
460
+ *
461
+ * Unless required by applicable law or agreed to in writing, software
462
+ * distributed under the License is distributed on an "AS IS" BASIS,
463
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464
+ * See the License for the specific language governing permissions and
465
+ * limitations under the License.
466
+ */class lr{constructor(e,t){this.shortDelay=e,this.longDelay=t,tt(t>e,"Short delay should be less than long delay!"),this.isMobile=rf()||cf()}get(){return Vp()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
467
+ * @license
468
+ * Copyright 2020 Google LLC
469
+ *
470
+ * Licensed under the Apache License, Version 2.0 (the "License");
471
+ * you may not use this file except in compliance with the License.
472
+ * You may obtain a copy of the License at
473
+ *
474
+ * http://www.apache.org/licenses/LICENSE-2.0
475
+ *
476
+ * Unless required by applicable law or agreed to in writing, software
477
+ * distributed under the License is distributed on an "AS IS" BASIS,
478
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479
+ * See the License for the specific language governing permissions and
480
+ * limitations under the License.
481
+ */function io(n,e){tt(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
482
+ * @license
483
+ * Copyright 2020 Google LLC
484
+ *
485
+ * Licensed under the Apache License, Version 2.0 (the "License");
486
+ * you may not use this file except in compliance with the License.
487
+ * You may obtain a copy of the License at
488
+ *
489
+ * http://www.apache.org/licenses/LICENSE-2.0
490
+ *
491
+ * Unless required by applicable law or agreed to in writing, software
492
+ * distributed under the License is distributed on an "AS IS" BASIS,
493
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494
+ * See the License for the specific language governing permissions and
495
+ * limitations under the License.
496
+ */class Hu{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Ye("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Ye("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Ye("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
497
+ * @license
498
+ * Copyright 2020 Google LLC
499
+ *
500
+ * Licensed under the Apache License, Version 2.0 (the "License");
501
+ * you may not use this file except in compliance with the License.
502
+ * You may obtain a copy of the License at
503
+ *
504
+ * http://www.apache.org/licenses/LICENSE-2.0
505
+ *
506
+ * Unless required by applicable law or agreed to in writing, software
507
+ * distributed under the License is distributed on an "AS IS" BASIS,
508
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509
+ * See the License for the specific language governing permissions and
510
+ * limitations under the License.
511
+ */const Lp={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
512
+ * @license
513
+ * Copyright 2020 Google LLC
514
+ *
515
+ * Licensed under the Apache License, Version 2.0 (the "License");
516
+ * you may not use this file except in compliance with the License.
517
+ * You may obtain a copy of the License at
518
+ *
519
+ * http://www.apache.org/licenses/LICENSE-2.0
520
+ *
521
+ * Unless required by applicable law or agreed to in writing, software
522
+ * distributed under the License is distributed on an "AS IS" BASIS,
523
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524
+ * See the License for the specific language governing permissions and
525
+ * limitations under the License.
526
+ */const xp=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Up=new lr(3e4,6e4);function it(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function ot(n,e,t,r,s={}){return Wu(n,s,async()=>{let o={},a={};r&&(e==="GET"?a=r:o={body:JSON.stringify(r)});const u=ur(Object.assign({key:n.config.apiKey},a)).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const d=Object.assign({method:e,headers:l},o);return of()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&_n(n.emulatorConfig.host)&&(d.credentials="include"),Hu.fetch()(await Gu(n,n.config.apiHost,t,u),d)})}async function Wu(n,e,t){n._canInitEmulator=!1;const r=Object.assign(Object.assign({},Lp),e);try{const s=new jp(n),o=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await o.json();if("needConfirmation"in a)throw Fr(n,"account-exists-with-different-credential",a);if(o.ok&&!("errorMessage"in a))return a;{const u=o.ok?a.errorMessage:a.error.message,[l,d]=u.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw Fr(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw Fr(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw Fr(n,"user-disabled",a);const p=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw ro(n,p,d);Ne(n,p)}}catch(s){if(s instanceof st)throw s;Ne(n,"network-request-failed",{message:String(s)})}}async function hr(n,e,t,r,s={}){const o=await ot(n,e,t,r,s);return"mfaPendingCredential"in o&&Ne(n,"multi-factor-auth-required",{_serverResponse:o}),o}async function Gu(n,e,t,r){const s=`${e}${t}?${r}`,o=n,a=o.config.emulator?io(n.config,s):`${n.config.apiScheme}://${s}`;return xp.includes(t)&&(await o._persistenceManagerAvailable,o._getPersistenceType()==="COOKIE")?o._getPersistence()._getFinalTarget(a).toString():a}function Fp(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class jp{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Le(this.auth,"network-request-failed")),Up.get())})}}function Fr(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Le(n,e,r);return s.customData._tokenResponse=t,s}function oc(n){return n!==void 0&&n.enterprise!==void 0}class Bp{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return Fp(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function $p(n,e){return ot(n,"GET","/v2/recaptchaConfig",it(n,e))}/**
527
+ * @license
528
+ * Copyright 2020 Google LLC
529
+ *
530
+ * Licensed under the Apache License, Version 2.0 (the "License");
531
+ * you may not use this file except in compliance with the License.
532
+ * You may obtain a copy of the License at
533
+ *
534
+ * http://www.apache.org/licenses/LICENSE-2.0
535
+ *
536
+ * Unless required by applicable law or agreed to in writing, software
537
+ * distributed under the License is distributed on an "AS IS" BASIS,
538
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539
+ * See the License for the specific language governing permissions and
540
+ * limitations under the License.
541
+ */async function qp(n,e){return ot(n,"POST","/v1/accounts:delete",e)}async function os(n,e){return ot(n,"POST","/v1/accounts:lookup",e)}/**
542
+ * @license
543
+ * Copyright 2020 Google LLC
544
+ *
545
+ * Licensed under the Apache License, Version 2.0 (the "License");
546
+ * you may not use this file except in compliance with the License.
547
+ * You may obtain a copy of the License at
548
+ *
549
+ * http://www.apache.org/licenses/LICENSE-2.0
550
+ *
551
+ * Unless required by applicable law or agreed to in writing, software
552
+ * distributed under the License is distributed on an "AS IS" BASIS,
553
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554
+ * See the License for the specific language governing permissions and
555
+ * limitations under the License.
556
+ */function Gn(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function zp(n,e=!1){const t=xe(n),r=await t.getIdToken(e),s=oo(r);F(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const o=typeof s.firebase=="object"?s.firebase:void 0,a=o?.sign_in_provider;return{claims:s,token:r,authTime:Gn(mi(s.auth_time)),issuedAtTime:Gn(mi(s.iat)),expirationTime:Gn(mi(s.exp)),signInProvider:a||null,signInSecondFactor:o?.sign_in_second_factor||null}}function mi(n){return Number(n)*1e3}function oo(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return Wr("JWT malformed, contained fewer than 3 sections"),null;try{const s=ku(t);return s?JSON.parse(s):(Wr("Failed to decode base64 JWT payload"),null)}catch(s){return Wr("Caught error parsing JWT payload as JSON",s?.toString()),null}}function ac(n){const e=oo(n);return F(e,"internal-error"),F(typeof e.exp<"u","internal-error"),F(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
557
+ * @license
558
+ * Copyright 2020 Google LLC
559
+ *
560
+ * Licensed under the Apache License, Version 2.0 (the "License");
561
+ * you may not use this file except in compliance with the License.
562
+ * You may obtain a copy of the License at
563
+ *
564
+ * http://www.apache.org/licenses/LICENSE-2.0
565
+ *
566
+ * Unless required by applicable law or agreed to in writing, software
567
+ * distributed under the License is distributed on an "AS IS" BASIS,
568
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569
+ * See the License for the specific language governing permissions and
570
+ * limitations under the License.
571
+ */async function tr(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof st&&Hp(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function Hp({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
572
+ * @license
573
+ * Copyright 2020 Google LLC
574
+ *
575
+ * Licensed under the Apache License, Version 2.0 (the "License");
576
+ * you may not use this file except in compliance with the License.
577
+ * You may obtain a copy of the License at
578
+ *
579
+ * http://www.apache.org/licenses/LICENSE-2.0
580
+ *
581
+ * Unless required by applicable law or agreed to in writing, software
582
+ * distributed under the License is distributed on an "AS IS" BASIS,
583
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584
+ * See the License for the specific language governing permissions and
585
+ * limitations under the License.
586
+ */class Wp{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;const s=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
587
+ * @license
588
+ * Copyright 2020 Google LLC
589
+ *
590
+ * Licensed under the Apache License, Version 2.0 (the "License");
591
+ * you may not use this file except in compliance with the License.
592
+ * You may obtain a copy of the License at
593
+ *
594
+ * http://www.apache.org/licenses/LICENSE-2.0
595
+ *
596
+ * Unless required by applicable law or agreed to in writing, software
597
+ * distributed under the License is distributed on an "AS IS" BASIS,
598
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599
+ * See the License for the specific language governing permissions and
600
+ * limitations under the License.
601
+ */class ki{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Gn(this.lastLoginAt),this.creationTime=Gn(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
602
+ * @license
603
+ * Copyright 2019 Google LLC
604
+ *
605
+ * Licensed under the Apache License, Version 2.0 (the "License");
606
+ * you may not use this file except in compliance with the License.
607
+ * You may obtain a copy of the License at
608
+ *
609
+ * http://www.apache.org/licenses/LICENSE-2.0
610
+ *
611
+ * Unless required by applicable law or agreed to in writing, software
612
+ * distributed under the License is distributed on an "AS IS" BASIS,
613
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614
+ * See the License for the specific language governing permissions and
615
+ * limitations under the License.
616
+ */async function as(n){var e;const t=n.auth,r=await n.getIdToken(),s=await tr(n,os(t,{idToken:r}));F(s?.users.length,t,"internal-error");const o=s.users[0];n._notifyReloadListener(o);const a=!((e=o.providerUserInfo)===null||e===void 0)&&e.length?Ku(o.providerUserInfo):[],u=Kp(n.providerData,a),l=n.isAnonymous,d=!(n.email&&o.passwordHash)&&!u?.length,p=l?d:!1,v={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:u,metadata:new ki(o.createdAt,o.lastLoginAt),isAnonymous:p};Object.assign(n,v)}async function Gp(n){const e=xe(n);await as(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function Kp(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Ku(n){return n.map(e=>{var{providerId:t}=e,r=no(e,["providerId"]);return{providerId:t,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/**
617
+ * @license
618
+ * Copyright 2020 Google LLC
619
+ *
620
+ * Licensed under the Apache License, Version 2.0 (the "License");
621
+ * you may not use this file except in compliance with the License.
622
+ * You may obtain a copy of the License at
623
+ *
624
+ * http://www.apache.org/licenses/LICENSE-2.0
625
+ *
626
+ * Unless required by applicable law or agreed to in writing, software
627
+ * distributed under the License is distributed on an "AS IS" BASIS,
628
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629
+ * See the License for the specific language governing permissions and
630
+ * limitations under the License.
631
+ */async function Qp(n,e){const t=await Wu(n,{},async()=>{const r=ur({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:o}=n.config,a=await Gu(n,s,"/v1/token",`key=${o}`),u=await n._getAdditionalHeaders();u["Content-Type"]="application/x-www-form-urlencoded";const l={method:"POST",headers:u,body:r};return n.emulatorConfig&&_n(n.emulatorConfig.host)&&(l.credentials="include"),Hu.fetch()(a,l)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function Jp(n,e){return ot(n,"POST","/v2/accounts:revokeToken",it(n,e))}/**
632
+ * @license
633
+ * Copyright 2020 Google LLC
634
+ *
635
+ * Licensed under the Apache License, Version 2.0 (the "License");
636
+ * you may not use this file except in compliance with the License.
637
+ * You may obtain a copy of the License at
638
+ *
639
+ * http://www.apache.org/licenses/LICENSE-2.0
640
+ *
641
+ * Unless required by applicable law or agreed to in writing, software
642
+ * distributed under the License is distributed on an "AS IS" BASIS,
643
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
644
+ * See the License for the specific language governing permissions and
645
+ * limitations under the License.
646
+ */class nn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){F(e.idToken,"internal-error"),F(typeof e.idToken<"u","internal-error"),F(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):ac(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){F(e.length!==0,"internal-error");const t=ac(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(F(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:o}=await Qp(e,t);this.updateTokensAndExpiration(r,s,Number(o))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:o}=t,a=new nn;return r&&(F(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(F(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),o&&(F(typeof o=="number","internal-error",{appName:e}),a.expirationTime=o),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new nn,this.toJSON())}_performRefresh(){return Ye("not implemented")}}/**
647
+ * @license
648
+ * Copyright 2020 Google LLC
649
+ *
650
+ * Licensed under the Apache License, Version 2.0 (the "License");
651
+ * you may not use this file except in compliance with the License.
652
+ * You may obtain a copy of the License at
653
+ *
654
+ * http://www.apache.org/licenses/LICENSE-2.0
655
+ *
656
+ * Unless required by applicable law or agreed to in writing, software
657
+ * distributed under the License is distributed on an "AS IS" BASIS,
658
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
659
+ * See the License for the specific language governing permissions and
660
+ * limitations under the License.
661
+ */function ht(n,e){F(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Me{constructor(e){var{uid:t,auth:r,stsTokenManager:s}=e,o=no(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new Wp(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=o.displayName||null,this.email=o.email||null,this.emailVerified=o.emailVerified||!1,this.phoneNumber=o.phoneNumber||null,this.photoURL=o.photoURL||null,this.isAnonymous=o.isAnonymous||!1,this.tenantId=o.tenantId||null,this.providerData=o.providerData?[...o.providerData]:[],this.metadata=new ki(o.createdAt||void 0,o.lastLoginAt||void 0)}async getIdToken(e){const t=await tr(this,this.stsTokenManager.getToken(this.auth,e));return F(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return zp(this,e)}reload(){return Gp(this)}_assign(e){this!==e&&(F(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Me(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){F(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await as(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ke(this.auth.app))return Promise.reject($e(this.auth));const e=await this.getIdToken();return await tr(this,qp(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var r,s,o,a,u,l,d,p;const v=(r=t.displayName)!==null&&r!==void 0?r:void 0,E=(s=t.email)!==null&&s!==void 0?s:void 0,C=(o=t.phoneNumber)!==null&&o!==void 0?o:void 0,V=(a=t.photoURL)!==null&&a!==void 0?a:void 0,M=(u=t.tenantId)!==null&&u!==void 0?u:void 0,k=(l=t._redirectEventId)!==null&&l!==void 0?l:void 0,q=(d=t.createdAt)!==null&&d!==void 0?d:void 0,z=(p=t.lastLoginAt)!==null&&p!==void 0?p:void 0,{uid:B,emailVerified:Y,isAnonymous:he,providerData:P,stsTokenManager:_}=t;F(B&&_,e,"internal-error");const m=nn.fromJSON(this.name,_);F(typeof B=="string",e,"internal-error"),ht(v,e.name),ht(E,e.name),F(typeof Y=="boolean",e,"internal-error"),F(typeof he=="boolean",e,"internal-error"),ht(C,e.name),ht(V,e.name),ht(M,e.name),ht(k,e.name),ht(q,e.name),ht(z,e.name);const g=new Me({uid:B,auth:e,email:E,emailVerified:Y,displayName:v,isAnonymous:he,photoURL:V,phoneNumber:C,tenantId:M,stsTokenManager:m,createdAt:q,lastLoginAt:z});return P&&Array.isArray(P)&&(g.providerData=P.map(T=>Object.assign({},T))),k&&(g._redirectEventId=k),g}static async _fromIdTokenResponse(e,t,r=!1){const s=new nn;s.updateFromServerResponse(t);const o=new Me({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await as(o),o}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];F(s.localId!==void 0,"internal-error");const o=s.providerUserInfo!==void 0?Ku(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!o?.length,u=new nn;u.updateFromIdToken(r);const l=new Me({uid:s.localId,auth:e,stsTokenManager:u,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:o,metadata:new ki(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!o?.length};return Object.assign(l,d),l}}/**
662
+ * @license
663
+ * Copyright 2020 Google LLC
664
+ *
665
+ * Licensed under the Apache License, Version 2.0 (the "License");
666
+ * you may not use this file except in compliance with the License.
667
+ * You may obtain a copy of the License at
668
+ *
669
+ * http://www.apache.org/licenses/LICENSE-2.0
670
+ *
671
+ * Unless required by applicable law or agreed to in writing, software
672
+ * distributed under the License is distributed on an "AS IS" BASIS,
673
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
674
+ * See the License for the specific language governing permissions and
675
+ * limitations under the License.
676
+ */const cc=new Map;function Ze(n){tt(n instanceof Function,"Expected a class definition");let e=cc.get(n);return e?(tt(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,cc.set(n,e),e)}/**
677
+ * @license
678
+ * Copyright 2019 Google LLC
679
+ *
680
+ * Licensed under the Apache License, Version 2.0 (the "License");
681
+ * you may not use this file except in compliance with the License.
682
+ * You may obtain a copy of the License at
683
+ *
684
+ * http://www.apache.org/licenses/LICENSE-2.0
685
+ *
686
+ * Unless required by applicable law or agreed to in writing, software
687
+ * distributed under the License is distributed on an "AS IS" BASIS,
688
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689
+ * See the License for the specific language governing permissions and
690
+ * limitations under the License.
691
+ */class Qu{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Qu.type="NONE";const uc=Qu;/**
692
+ * @license
693
+ * Copyright 2019 Google LLC
694
+ *
695
+ * Licensed under the Apache License, Version 2.0 (the "License");
696
+ * you may not use this file except in compliance with the License.
697
+ * You may obtain a copy of the License at
698
+ *
699
+ * http://www.apache.org/licenses/LICENSE-2.0
700
+ *
701
+ * Unless required by applicable law or agreed to in writing, software
702
+ * distributed under the License is distributed on an "AS IS" BASIS,
703
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
704
+ * See the License for the specific language governing permissions and
705
+ * limitations under the License.
706
+ */function Gr(n,e,t){return`firebase:${n}:${e}:${t}`}class rn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:o}=this.auth;this.fullUserKey=Gr(this.userKey,s.apiKey,o),this.fullPersistenceKey=Gr("persistence",s.apiKey,o),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await os(this.auth,{idToken:e}).catch(()=>{});return t?Me._fromGetAccountInfoResponse(this.auth,t,e):null}return Me._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new rn(Ze(uc),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let o=s[0]||Ze(uc);const a=Gr(r,e.config.apiKey,e.name);let u=null;for(const d of t)try{const p=await d._get(a);if(p){let v;if(typeof p=="string"){const E=await os(e,{idToken:p}).catch(()=>{});if(!E)break;v=await Me._fromGetAccountInfoResponse(e,E,p)}else v=Me._fromJSON(e,p);d!==o&&(u=v),o=d;break}}catch{}const l=s.filter(d=>d._shouldAllowMigration);return!o._shouldAllowMigration||!l.length?new rn(o,e,r):(o=l[0],u&&await o._set(a,u.toJSON()),await Promise.all(t.map(async d=>{if(d!==o)try{await d._remove(a)}catch{}})),new rn(o,e,r))}}/**
707
+ * @license
708
+ * Copyright 2020 Google LLC
709
+ *
710
+ * Licensed under the Apache License, Version 2.0 (the "License");
711
+ * you may not use this file except in compliance with the License.
712
+ * You may obtain a copy of the License at
713
+ *
714
+ * http://www.apache.org/licenses/LICENSE-2.0
715
+ *
716
+ * Unless required by applicable law or agreed to in writing, software
717
+ * distributed under the License is distributed on an "AS IS" BASIS,
718
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719
+ * See the License for the specific language governing permissions and
720
+ * limitations under the License.
721
+ */function lc(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Zu(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Ju(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(tl(e))return"Blackberry";if(nl(e))return"Webos";if(Xu(e))return"Safari";if((e.includes("chrome/")||Yu(e))&&!e.includes("edge/"))return"Chrome";if(el(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function Ju(n=Ae()){return/firefox\//i.test(n)}function Xu(n=Ae()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Yu(n=Ae()){return/crios\//i.test(n)}function Zu(n=Ae()){return/iemobile/i.test(n)}function el(n=Ae()){return/android/i.test(n)}function tl(n=Ae()){return/blackberry/i.test(n)}function nl(n=Ae()){return/webos/i.test(n)}function ao(n=Ae()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function Xp(n=Ae()){var e;return ao(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function Yp(){return uf()&&document.documentMode===10}function rl(n=Ae()){return ao(n)||el(n)||nl(n)||tl(n)||/windows phone/i.test(n)||Zu(n)}/**
722
+ * @license
723
+ * Copyright 2020 Google LLC
724
+ *
725
+ * Licensed under the Apache License, Version 2.0 (the "License");
726
+ * you may not use this file except in compliance with the License.
727
+ * You may obtain a copy of the License at
728
+ *
729
+ * http://www.apache.org/licenses/LICENSE-2.0
730
+ *
731
+ * Unless required by applicable law or agreed to in writing, software
732
+ * distributed under the License is distributed on an "AS IS" BASIS,
733
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
734
+ * See the License for the specific language governing permissions and
735
+ * limitations under the License.
736
+ */function sl(n,e=[]){let t;switch(n){case"Browser":t=lc(Ae());break;case"Worker":t=`${lc(Ae())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${yn}/${r}`}/**
737
+ * @license
738
+ * Copyright 2022 Google LLC
739
+ *
740
+ * Licensed under the Apache License, Version 2.0 (the "License");
741
+ * you may not use this file except in compliance with the License.
742
+ * You may obtain a copy of the License at
743
+ *
744
+ * http://www.apache.org/licenses/LICENSE-2.0
745
+ *
746
+ * Unless required by applicable law or agreed to in writing, software
747
+ * distributed under the License is distributed on an "AS IS" BASIS,
748
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
749
+ * See the License for the specific language governing permissions and
750
+ * limitations under the License.
751
+ */class Zp{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=o=>new Promise((a,u)=>{try{const l=e(o);a(l)}catch(l){u(l)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}/**
752
+ * @license
753
+ * Copyright 2023 Google LLC
754
+ *
755
+ * Licensed under the Apache License, Version 2.0 (the "License");
756
+ * you may not use this file except in compliance with the License.
757
+ * You may obtain a copy of the License at
758
+ *
759
+ * http://www.apache.org/licenses/LICENSE-2.0
760
+ *
761
+ * Unless required by applicable law or agreed to in writing, software
762
+ * distributed under the License is distributed on an "AS IS" BASIS,
763
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764
+ * See the License for the specific language governing permissions and
765
+ * limitations under the License.
766
+ */async function em(n,e={}){return ot(n,"GET","/v2/passwordPolicy",it(n,e))}/**
767
+ * @license
768
+ * Copyright 2023 Google LLC
769
+ *
770
+ * Licensed under the Apache License, Version 2.0 (the "License");
771
+ * you may not use this file except in compliance with the License.
772
+ * You may obtain a copy of the License at
773
+ *
774
+ * http://www.apache.org/licenses/LICENSE-2.0
775
+ *
776
+ * Unless required by applicable law or agreed to in writing, software
777
+ * distributed under the License is distributed on an "AS IS" BASIS,
778
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779
+ * See the License for the specific language governing permissions and
780
+ * limitations under the License.
781
+ */const tm=6;class nm{constructor(e){var t,r,s,o;const a=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=a.minPasswordLength)!==null&&t!==void 0?t:tm,a.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=a.maxPasswordLength),a.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=a.containsLowercaseCharacter),a.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=a.containsUppercaseCharacter),a.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=a.containsNumericCharacter),a.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=a.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(s=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&s!==void 0?s:"",this.forceUpgradeOnSignin=(o=e.forceUpgradeOnSignin)!==null&&o!==void 0?o:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,r,s,o,a,u;const l={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,l),this.validatePasswordCharacterOptions(e,l),l.isValid&&(l.isValid=(t=l.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),l.isValid&&(l.isValid=(r=l.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),l.isValid&&(l.isValid=(s=l.containsLowercaseLetter)!==null&&s!==void 0?s:!0),l.isValid&&(l.isValid=(o=l.containsUppercaseLetter)!==null&&o!==void 0?o:!0),l.isValid&&(l.isValid=(a=l.containsNumericCharacter)!==null&&a!==void 0?a:!0),l.isValid&&(l.isValid=(u=l.containsNonAlphanumericCharacter)!==null&&u!==void 0?u:!0),l}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,o){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=o))}}/**
782
+ * @license
783
+ * Copyright 2020 Google LLC
784
+ *
785
+ * Licensed under the Apache License, Version 2.0 (the "License");
786
+ * you may not use this file except in compliance with the License.
787
+ * You may obtain a copy of the License at
788
+ *
789
+ * http://www.apache.org/licenses/LICENSE-2.0
790
+ *
791
+ * Unless required by applicable law or agreed to in writing, software
792
+ * distributed under the License is distributed on an "AS IS" BASIS,
793
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794
+ * See the License for the specific language governing permissions and
795
+ * limitations under the License.
796
+ */class rm{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new hc(this),this.idTokenSubscription=new hc(this),this.beforeStateQueue=new Zp(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=qu,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(o=>this._resolvePersistenceManagerAvailable=o)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ze(t)),this._initializationPromise=this.queue(async()=>{var r,s,o;if(!this._deleted&&(this.persistenceManager=await rn.create(this,e),(r=this._resolvePersistenceManagerAvailable)===null||r===void 0||r.call(this),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((o=this.currentUser)===null||o===void 0?void 0:o.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await os(this,{idToken:e}),r=await Me._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(ke(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(u,u))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,o=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,u=s?._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===u)&&l?.user&&(s=l.user,o=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(o)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return F(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await as(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=Mp()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ke(this.app))return Promise.reject($e(this));const t=e?xe(e):null;return t&&F(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&F(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ke(this.app)?Promise.reject($e(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ke(this.app)?Promise.reject($e(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ze(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await em(this),t=new nm(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new cr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await Jp(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ze(e)||this._popupRedirectResolver;F(t,this,"argument-error"),this.redirectPersistenceManager=await rn.create(this,[Ze(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const o=typeof t=="function"?t:t.next.bind(t);let a=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(F(u,this,"internal-error"),u.then(()=>{a||o(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return F(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=sl(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(t["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(t["X-Firebase-AppCheck"]=s),t}async _getAppCheckToken(){var e;if(ke(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t?.error&&Dp(`Error while retrieving App Check token: ${t.error}`),t?.token}}function Ue(n){return xe(n)}class hc{constructor(e){this.auth=e,this.observer=null,this.addObserver=_f(t=>this.observer=t)}get next(){return F(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
797
+ * @license
798
+ * Copyright 2020 Google LLC
799
+ *
800
+ * Licensed under the Apache License, Version 2.0 (the "License");
801
+ * you may not use this file except in compliance with the License.
802
+ * You may obtain a copy of the License at
803
+ *
804
+ * http://www.apache.org/licenses/LICENSE-2.0
805
+ *
806
+ * Unless required by applicable law or agreed to in writing, software
807
+ * distributed under the License is distributed on an "AS IS" BASIS,
808
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
809
+ * See the License for the specific language governing permissions and
810
+ * limitations under the License.
811
+ */let Ts={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function sm(n){Ts=n}function il(n){return Ts.loadJS(n)}function im(){return Ts.recaptchaEnterpriseScript}function om(){return Ts.gapiScript}function am(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class cm{constructor(){this.enterprise=new um}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class um{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const lm="recaptcha-enterprise",ol="NO_RECAPTCHA";class hm{constructor(e){this.type=lm,this.auth=Ue(e)}async verify(e="verify",t=!1){async function r(o){if(!t){if(o.tenantId==null&&o._agentRecaptchaConfig!=null)return o._agentRecaptchaConfig.siteKey;if(o.tenantId!=null&&o._tenantRecaptchaConfigs[o.tenantId]!==void 0)return o._tenantRecaptchaConfigs[o.tenantId].siteKey}return new Promise(async(a,u)=>{$p(o,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(l=>{if(l.recaptchaKey===void 0)u(new Error("recaptcha Enterprise site key undefined"));else{const d=new Bp(l);return o.tenantId==null?o._agentRecaptchaConfig=d:o._tenantRecaptchaConfigs[o.tenantId]=d,a(d.siteKey)}}).catch(l=>{u(l)})})}function s(o,a,u){const l=window.grecaptcha;oc(l)?l.enterprise.ready(()=>{l.enterprise.execute(o,{action:e}).then(d=>{a(d)}).catch(()=>{a(ol)})}):u(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new cm().execute("siteKey",{action:"verify"}):new Promise((o,a)=>{r(this.auth).then(u=>{if(!t&&oc(window.grecaptcha))s(u,o,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let l=im();l.length!==0&&(l+=u),il(l).then(()=>{s(u,o,a)}).catch(d=>{a(d)})}}).catch(u=>{a(u)})})}}async function dc(n,e,t,r=!1,s=!1){const o=new hm(n);let a;if(s)a=ol;else try{a=await o.verify(t)}catch{a=await o.verify(t,!0)}const u=Object.assign({},e);if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in u){const l=u.phoneEnrollmentInfo.phoneNumber,d=u.phoneEnrollmentInfo.recaptchaToken;Object.assign(u,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in u){const l=u.phoneSignInInfo.recaptchaToken;Object.assign(u,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return u}return r?Object.assign(u,{captchaResp:a}):Object.assign(u,{captchaResponse:a}),Object.assign(u,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(u,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),u}async function Oi(n,e,t,r,s){var o;if(!((o=n._getRecaptchaConfig())===null||o===void 0)&&o.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const a=await dc(n,e,t,t==="getOobCode");return r(n,a)}else return r(n,e).catch(async a=>{if(a.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const u=await dc(n,e,t,t==="getOobCode");return r(n,u)}else return Promise.reject(a)})}/**
812
+ * @license
813
+ * Copyright 2020 Google LLC
814
+ *
815
+ * Licensed under the Apache License, Version 2.0 (the "License");
816
+ * you may not use this file except in compliance with the License.
817
+ * You may obtain a copy of the License at
818
+ *
819
+ * http://www.apache.org/licenses/LICENSE-2.0
820
+ *
821
+ * Unless required by applicable law or agreed to in writing, software
822
+ * distributed under the License is distributed on an "AS IS" BASIS,
823
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824
+ * See the License for the specific language governing permissions and
825
+ * limitations under the License.
826
+ */function dm(n,e){const t=to(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),o=t.getOptions();if(Bt(o,e??{}))return s;Ne(s,"already-initialized")}return t.initialize({options:e})}function fm(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(Ze);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function pm(n,e,t){const r=Ue(n);F(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,o=al(e),{host:a,port:u}=mm(e),l=u===null?"":`:${u}`,d={url:`${o}//${a}${l}/`},p=Object.freeze({host:a,port:u,protocol:o.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){F(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),F(Bt(d,r.config.emulator)&&Bt(p,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=p,r.settings.appVerificationDisabledForTesting=!0,_n(a)?(Vu(`${o}//${a}${l}`),Mu("Auth",!0)):gm()}function al(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function mm(n){const e=al(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const o=s[1];return{host:o,port:fc(r.substr(o.length+1))}}else{const[o,a]=r.split(":");return{host:o,port:fc(a)}}}function fc(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function gm(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/**
827
+ * @license
828
+ * Copyright 2020 Google LLC
829
+ *
830
+ * Licensed under the Apache License, Version 2.0 (the "License");
831
+ * you may not use this file except in compliance with the License.
832
+ * You may obtain a copy of the License at
833
+ *
834
+ * http://www.apache.org/licenses/LICENSE-2.0
835
+ *
836
+ * Unless required by applicable law or agreed to in writing, software
837
+ * distributed under the License is distributed on an "AS IS" BASIS,
838
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839
+ * See the License for the specific language governing permissions and
840
+ * limitations under the License.
841
+ */class co{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Ye("not implemented")}_getIdTokenResponse(e){return Ye("not implemented")}_linkToIdToken(e,t){return Ye("not implemented")}_getReauthenticationResolver(e){return Ye("not implemented")}}async function _m(n,e){return ot(n,"POST","/v1/accounts:signUp",e)}/**
842
+ * @license
843
+ * Copyright 2020 Google LLC
844
+ *
845
+ * Licensed under the Apache License, Version 2.0 (the "License");
846
+ * you may not use this file except in compliance with the License.
847
+ * You may obtain a copy of the License at
848
+ *
849
+ * http://www.apache.org/licenses/LICENSE-2.0
850
+ *
851
+ * Unless required by applicable law or agreed to in writing, software
852
+ * distributed under the License is distributed on an "AS IS" BASIS,
853
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
854
+ * See the License for the specific language governing permissions and
855
+ * limitations under the License.
856
+ */async function ym(n,e){return hr(n,"POST","/v1/accounts:signInWithPassword",it(n,e))}async function vm(n,e){return ot(n,"POST","/v1/accounts:sendOobCode",it(n,e))}async function Em(n,e){return vm(n,e)}/**
857
+ * @license
858
+ * Copyright 2020 Google LLC
859
+ *
860
+ * Licensed under the Apache License, Version 2.0 (the "License");
861
+ * you may not use this file except in compliance with the License.
862
+ * You may obtain a copy of the License at
863
+ *
864
+ * http://www.apache.org/licenses/LICENSE-2.0
865
+ *
866
+ * Unless required by applicable law or agreed to in writing, software
867
+ * distributed under the License is distributed on an "AS IS" BASIS,
868
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869
+ * See the License for the specific language governing permissions and
870
+ * limitations under the License.
871
+ */async function Tm(n,e){return hr(n,"POST","/v1/accounts:signInWithEmailLink",it(n,e))}async function wm(n,e){return hr(n,"POST","/v1/accounts:signInWithEmailLink",it(n,e))}/**
872
+ * @license
873
+ * Copyright 2020 Google LLC
874
+ *
875
+ * Licensed under the Apache License, Version 2.0 (the "License");
876
+ * you may not use this file except in compliance with the License.
877
+ * You may obtain a copy of the License at
878
+ *
879
+ * http://www.apache.org/licenses/LICENSE-2.0
880
+ *
881
+ * Unless required by applicable law or agreed to in writing, software
882
+ * distributed under the License is distributed on an "AS IS" BASIS,
883
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884
+ * See the License for the specific language governing permissions and
885
+ * limitations under the License.
886
+ */class nr extends co{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new nr(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new nr(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t?.email&&t?.password){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Oi(e,t,"signInWithPassword",ym);case"emailLink":return Tm(e,{email:this._email,oobCode:this._password});default:Ne(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Oi(e,r,"signUpPassword",_m);case"emailLink":return wm(e,{idToken:t,email:this._email,oobCode:this._password});default:Ne(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
887
+ * @license
888
+ * Copyright 2020 Google LLC
889
+ *
890
+ * Licensed under the Apache License, Version 2.0 (the "License");
891
+ * you may not use this file except in compliance with the License.
892
+ * You may obtain a copy of the License at
893
+ *
894
+ * http://www.apache.org/licenses/LICENSE-2.0
895
+ *
896
+ * Unless required by applicable law or agreed to in writing, software
897
+ * distributed under the License is distributed on an "AS IS" BASIS,
898
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
899
+ * See the License for the specific language governing permissions and
900
+ * limitations under the License.
901
+ */async function sn(n,e){return hr(n,"POST","/v1/accounts:signInWithIdp",it(n,e))}/**
902
+ * @license
903
+ * Copyright 2020 Google LLC
904
+ *
905
+ * Licensed under the Apache License, Version 2.0 (the "License");
906
+ * you may not use this file except in compliance with the License.
907
+ * You may obtain a copy of the License at
908
+ *
909
+ * http://www.apache.org/licenses/LICENSE-2.0
910
+ *
911
+ * Unless required by applicable law or agreed to in writing, software
912
+ * distributed under the License is distributed on an "AS IS" BASIS,
913
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
914
+ * See the License for the specific language governing permissions and
915
+ * limitations under the License.
916
+ */const Im="http://localhost";class qt extends co{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new qt(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Ne("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s}=t,o=no(t,["providerId","signInMethod"]);if(!r||!s)return null;const a=new qt(r,s);return a.idToken=o.idToken||void 0,a.accessToken=o.accessToken||void 0,a.secret=o.secret,a.nonce=o.nonce,a.pendingToken=o.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return sn(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,sn(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,sn(e,t)}buildRequest(){const e={requestUri:Im,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=ur(t)}return e}}/**
917
+ * @license
918
+ * Copyright 2020 Google LLC
919
+ *
920
+ * Licensed under the Apache License, Version 2.0 (the "License");
921
+ * you may not use this file except in compliance with the License.
922
+ * You may obtain a copy of the License at
923
+ *
924
+ * http://www.apache.org/licenses/LICENSE-2.0
925
+ *
926
+ * Unless required by applicable law or agreed to in writing, software
927
+ * distributed under the License is distributed on an "AS IS" BASIS,
928
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
929
+ * See the License for the specific language governing permissions and
930
+ * limitations under the License.
931
+ */function Am(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function bm(n){const e=jn(Bn(n)).link,t=e?jn(Bn(e)).deep_link_id:null,r=jn(Bn(n)).deep_link_id;return(r?jn(Bn(r)).link:null)||r||t||e||n}class uo{constructor(e){var t,r,s,o,a,u;const l=jn(Bn(e)),d=(t=l.apiKey)!==null&&t!==void 0?t:null,p=(r=l.oobCode)!==null&&r!==void 0?r:null,v=Am((s=l.mode)!==null&&s!==void 0?s:null);F(d&&p&&v,"argument-error"),this.apiKey=d,this.operation=v,this.code=p,this.continueUrl=(o=l.continueUrl)!==null&&o!==void 0?o:null,this.languageCode=(a=l.lang)!==null&&a!==void 0?a:null,this.tenantId=(u=l.tenantId)!==null&&u!==void 0?u:null}static parseLink(e){const t=bm(e);try{return new uo(t)}catch{return null}}}/**
932
+ * @license
933
+ * Copyright 2020 Google LLC
934
+ *
935
+ * Licensed under the Apache License, Version 2.0 (the "License");
936
+ * you may not use this file except in compliance with the License.
937
+ * You may obtain a copy of the License at
938
+ *
939
+ * http://www.apache.org/licenses/LICENSE-2.0
940
+ *
941
+ * Unless required by applicable law or agreed to in writing, software
942
+ * distributed under the License is distributed on an "AS IS" BASIS,
943
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
944
+ * See the License for the specific language governing permissions and
945
+ * limitations under the License.
946
+ */class vn{constructor(){this.providerId=vn.PROVIDER_ID}static credential(e,t){return nr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=uo.parseLink(t);return F(r,"argument-error"),nr._fromEmailAndCode(e,r.code,r.tenantId)}}vn.PROVIDER_ID="password";vn.EMAIL_PASSWORD_SIGN_IN_METHOD="password";vn.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
947
+ * @license
948
+ * Copyright 2020 Google LLC
949
+ *
950
+ * Licensed under the Apache License, Version 2.0 (the "License");
951
+ * you may not use this file except in compliance with the License.
952
+ * You may obtain a copy of the License at
953
+ *
954
+ * http://www.apache.org/licenses/LICENSE-2.0
955
+ *
956
+ * Unless required by applicable law or agreed to in writing, software
957
+ * distributed under the License is distributed on an "AS IS" BASIS,
958
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959
+ * See the License for the specific language governing permissions and
960
+ * limitations under the License.
961
+ */class ws{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
962
+ * @license
963
+ * Copyright 2019 Google LLC
964
+ *
965
+ * Licensed under the Apache License, Version 2.0 (the "License");
966
+ * you may not use this file except in compliance with the License.
967
+ * You may obtain a copy of the License at
968
+ *
969
+ * http://www.apache.org/licenses/LICENSE-2.0
970
+ *
971
+ * Unless required by applicable law or agreed to in writing, software
972
+ * distributed under the License is distributed on an "AS IS" BASIS,
973
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
974
+ * See the License for the specific language governing permissions and
975
+ * limitations under the License.
976
+ */class dr extends ws{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
977
+ * @license
978
+ * Copyright 2020 Google LLC
979
+ *
980
+ * Licensed under the Apache License, Version 2.0 (the "License");
981
+ * you may not use this file except in compliance with the License.
982
+ * You may obtain a copy of the License at
983
+ *
984
+ * http://www.apache.org/licenses/LICENSE-2.0
985
+ *
986
+ * Unless required by applicable law or agreed to in writing, software
987
+ * distributed under the License is distributed on an "AS IS" BASIS,
988
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989
+ * See the License for the specific language governing permissions and
990
+ * limitations under the License.
991
+ */class dt extends dr{constructor(){super("facebook.com")}static credential(e){return qt._fromParams({providerId:dt.PROVIDER_ID,signInMethod:dt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return dt.credentialFromTaggedObject(e)}static credentialFromError(e){return dt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return dt.credential(e.oauthAccessToken)}catch{return null}}}dt.FACEBOOK_SIGN_IN_METHOD="facebook.com";dt.PROVIDER_ID="facebook.com";/**
992
+ * @license
993
+ * Copyright 2020 Google LLC
994
+ *
995
+ * Licensed under the Apache License, Version 2.0 (the "License");
996
+ * you may not use this file except in compliance with the License.
997
+ * You may obtain a copy of the License at
998
+ *
999
+ * http://www.apache.org/licenses/LICENSE-2.0
1000
+ *
1001
+ * Unless required by applicable law or agreed to in writing, software
1002
+ * distributed under the License is distributed on an "AS IS" BASIS,
1003
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1004
+ * See the License for the specific language governing permissions and
1005
+ * limitations under the License.
1006
+ */class Xe extends dr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return qt._fromParams({providerId:Xe.PROVIDER_ID,signInMethod:Xe.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Xe.credentialFromTaggedObject(e)}static credentialFromError(e){return Xe.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return Xe.credential(t,r)}catch{return null}}}Xe.GOOGLE_SIGN_IN_METHOD="google.com";Xe.PROVIDER_ID="google.com";/**
1007
+ * @license
1008
+ * Copyright 2020 Google LLC
1009
+ *
1010
+ * Licensed under the Apache License, Version 2.0 (the "License");
1011
+ * you may not use this file except in compliance with the License.
1012
+ * You may obtain a copy of the License at
1013
+ *
1014
+ * http://www.apache.org/licenses/LICENSE-2.0
1015
+ *
1016
+ * Unless required by applicable law or agreed to in writing, software
1017
+ * distributed under the License is distributed on an "AS IS" BASIS,
1018
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1019
+ * See the License for the specific language governing permissions and
1020
+ * limitations under the License.
1021
+ */class ft extends dr{constructor(){super("github.com")}static credential(e){return qt._fromParams({providerId:ft.PROVIDER_ID,signInMethod:ft.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ft.credentialFromTaggedObject(e)}static credentialFromError(e){return ft.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return ft.credential(e.oauthAccessToken)}catch{return null}}}ft.GITHUB_SIGN_IN_METHOD="github.com";ft.PROVIDER_ID="github.com";/**
1022
+ * @license
1023
+ * Copyright 2020 Google LLC
1024
+ *
1025
+ * Licensed under the Apache License, Version 2.0 (the "License");
1026
+ * you may not use this file except in compliance with the License.
1027
+ * You may obtain a copy of the License at
1028
+ *
1029
+ * http://www.apache.org/licenses/LICENSE-2.0
1030
+ *
1031
+ * Unless required by applicable law or agreed to in writing, software
1032
+ * distributed under the License is distributed on an "AS IS" BASIS,
1033
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1034
+ * See the License for the specific language governing permissions and
1035
+ * limitations under the License.
1036
+ */class pt extends dr{constructor(){super("twitter.com")}static credential(e,t){return qt._fromParams({providerId:pt.PROVIDER_ID,signInMethod:pt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return pt.credentialFromTaggedObject(e)}static credentialFromError(e){return pt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return pt.credential(t,r)}catch{return null}}}pt.TWITTER_SIGN_IN_METHOD="twitter.com";pt.PROVIDER_ID="twitter.com";/**
1037
+ * @license
1038
+ * Copyright 2020 Google LLC
1039
+ *
1040
+ * Licensed under the Apache License, Version 2.0 (the "License");
1041
+ * you may not use this file except in compliance with the License.
1042
+ * You may obtain a copy of the License at
1043
+ *
1044
+ * http://www.apache.org/licenses/LICENSE-2.0
1045
+ *
1046
+ * Unless required by applicable law or agreed to in writing, software
1047
+ * distributed under the License is distributed on an "AS IS" BASIS,
1048
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049
+ * See the License for the specific language governing permissions and
1050
+ * limitations under the License.
1051
+ */class zt{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const o=await Me._fromIdTokenResponse(e,r,s),a=pc(r);return new zt({user:o,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=pc(r);return new zt({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function pc(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
1052
+ * @license
1053
+ * Copyright 2020 Google LLC
1054
+ *
1055
+ * Licensed under the Apache License, Version 2.0 (the "License");
1056
+ * you may not use this file except in compliance with the License.
1057
+ * You may obtain a copy of the License at
1058
+ *
1059
+ * http://www.apache.org/licenses/LICENSE-2.0
1060
+ *
1061
+ * Unless required by applicable law or agreed to in writing, software
1062
+ * distributed under the License is distributed on an "AS IS" BASIS,
1063
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064
+ * See the License for the specific language governing permissions and
1065
+ * limitations under the License.
1066
+ */class cs extends st{constructor(e,t,r,s){var o;super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,cs.prototype),this.customData={appName:e.name,tenantId:(o=e.tenantId)!==null&&o!==void 0?o:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new cs(e,t,r,s)}}function cl(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(o=>{throw o.code==="auth/multi-factor-auth-required"?cs._fromErrorAndOperation(n,o,e,r):o})}async function Rm(n,e,t=!1){const r=await tr(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return zt._forOperation(n,"link",r)}/**
1067
+ * @license
1068
+ * Copyright 2019 Google LLC
1069
+ *
1070
+ * Licensed under the Apache License, Version 2.0 (the "License");
1071
+ * you may not use this file except in compliance with the License.
1072
+ * You may obtain a copy of the License at
1073
+ *
1074
+ * http://www.apache.org/licenses/LICENSE-2.0
1075
+ *
1076
+ * Unless required by applicable law or agreed to in writing, software
1077
+ * distributed under the License is distributed on an "AS IS" BASIS,
1078
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079
+ * See the License for the specific language governing permissions and
1080
+ * limitations under the License.
1081
+ */async function Sm(n,e,t=!1){const{auth:r}=n;if(ke(r.app))return Promise.reject($e(r));const s="reauthenticate";try{const o=await tr(n,cl(r,s,e,n),t);F(o.idToken,r,"internal-error");const a=oo(o.idToken);F(a,r,"internal-error");const{sub:u}=a;return F(n.uid===u,r,"user-mismatch"),zt._forOperation(n,s,o)}catch(o){throw o?.code==="auth/user-not-found"&&Ne(r,"user-mismatch"),o}}/**
1082
+ * @license
1083
+ * Copyright 2020 Google LLC
1084
+ *
1085
+ * Licensed under the Apache License, Version 2.0 (the "License");
1086
+ * you may not use this file except in compliance with the License.
1087
+ * You may obtain a copy of the License at
1088
+ *
1089
+ * http://www.apache.org/licenses/LICENSE-2.0
1090
+ *
1091
+ * Unless required by applicable law or agreed to in writing, software
1092
+ * distributed under the License is distributed on an "AS IS" BASIS,
1093
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094
+ * See the License for the specific language governing permissions and
1095
+ * limitations under the License.
1096
+ */async function ul(n,e,t=!1){if(ke(n.app))return Promise.reject($e(n));const r="signIn",s=await cl(n,r,e),o=await zt._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(o.user),o}async function Cm(n,e){return ul(Ue(n),e)}/**
1097
+ * @license
1098
+ * Copyright 2020 Google LLC
1099
+ *
1100
+ * Licensed under the Apache License, Version 2.0 (the "License");
1101
+ * you may not use this file except in compliance with the License.
1102
+ * You may obtain a copy of the License at
1103
+ *
1104
+ * http://www.apache.org/licenses/LICENSE-2.0
1105
+ *
1106
+ * Unless required by applicable law or agreed to in writing, software
1107
+ * distributed under the License is distributed on an "AS IS" BASIS,
1108
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109
+ * See the License for the specific language governing permissions and
1110
+ * limitations under the License.
1111
+ */async function Pm(n,e){return hr(n,"POST","/v1/accounts:signInWithCustomToken",it(n,e))}/**
1112
+ * @license
1113
+ * Copyright 2020 Google LLC
1114
+ *
1115
+ * Licensed under the Apache License, Version 2.0 (the "License");
1116
+ * you may not use this file except in compliance with the License.
1117
+ * You may obtain a copy of the License at
1118
+ *
1119
+ * http://www.apache.org/licenses/LICENSE-2.0
1120
+ *
1121
+ * Unless required by applicable law or agreed to in writing, software
1122
+ * distributed under the License is distributed on an "AS IS" BASIS,
1123
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1124
+ * See the License for the specific language governing permissions and
1125
+ * limitations under the License.
1126
+ */async function km(n,e){if(ke(n.app))return Promise.reject($e(n));const t=Ue(n),r=await Pm(t,{token:e,returnSecureToken:!0}),s=await zt._fromIdTokenResponse(t,"signIn",r);return await t._updateCurrentUser(s.user),s}/**
1127
+ * @license
1128
+ * Copyright 2020 Google LLC
1129
+ *
1130
+ * Licensed under the Apache License, Version 2.0 (the "License");
1131
+ * you may not use this file except in compliance with the License.
1132
+ * You may obtain a copy of the License at
1133
+ *
1134
+ * http://www.apache.org/licenses/LICENSE-2.0
1135
+ *
1136
+ * Unless required by applicable law or agreed to in writing, software
1137
+ * distributed under the License is distributed on an "AS IS" BASIS,
1138
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139
+ * See the License for the specific language governing permissions and
1140
+ * limitations under the License.
1141
+ */async function Om(n){const e=Ue(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function Dm(n,e,t){const r=Ue(n);await Oi(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",Em)}function Nm(n,e,t){return ke(n.app)?Promise.reject($e(n)):Cm(xe(n),vn.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Om(n),r})}function Vm(n,e,t,r){return xe(n).onIdTokenChanged(e,t,r)}function Mm(n,e,t){return xe(n).beforeAuthStateChanged(e,t)}function Lm(n,e,t,r){return xe(n).onAuthStateChanged(e,t,r)}function xm(n){return xe(n).signOut()}const us="__sak";/**
1142
+ * @license
1143
+ * Copyright 2019 Google LLC
1144
+ *
1145
+ * Licensed under the Apache License, Version 2.0 (the "License");
1146
+ * you may not use this file except in compliance with the License.
1147
+ * You may obtain a copy of the License at
1148
+ *
1149
+ * http://www.apache.org/licenses/LICENSE-2.0
1150
+ *
1151
+ * Unless required by applicable law or agreed to in writing, software
1152
+ * distributed under the License is distributed on an "AS IS" BASIS,
1153
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154
+ * See the License for the specific language governing permissions and
1155
+ * limitations under the License.
1156
+ */class ll{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(us,"1"),this.storage.removeItem(us),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1157
+ * @license
1158
+ * Copyright 2020 Google LLC
1159
+ *
1160
+ * Licensed under the Apache License, Version 2.0 (the "License");
1161
+ * you may not use this file except in compliance with the License.
1162
+ * You may obtain a copy of the License at
1163
+ *
1164
+ * http://www.apache.org/licenses/LICENSE-2.0
1165
+ *
1166
+ * Unless required by applicable law or agreed to in writing, software
1167
+ * distributed under the License is distributed on an "AS IS" BASIS,
1168
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1169
+ * See the License for the specific language governing permissions and
1170
+ * limitations under the License.
1171
+ */const Um=1e3,Fm=10;class hl extends ll{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=rl(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,u,l)=>{this.notifyListeners(a,l)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},o=this.storage.getItem(r);Yp()&&o!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,Fm):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},Um)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}hl.type="LOCAL";const jm=hl;/**
1172
+ * @license
1173
+ * Copyright 2020 Google LLC
1174
+ *
1175
+ * Licensed under the Apache License, Version 2.0 (the "License");
1176
+ * you may not use this file except in compliance with the License.
1177
+ * You may obtain a copy of the License at
1178
+ *
1179
+ * http://www.apache.org/licenses/LICENSE-2.0
1180
+ *
1181
+ * Unless required by applicable law or agreed to in writing, software
1182
+ * distributed under the License is distributed on an "AS IS" BASIS,
1183
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1184
+ * See the License for the specific language governing permissions and
1185
+ * limitations under the License.
1186
+ */class dl extends ll{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}dl.type="SESSION";const fl=dl;/**
1187
+ * @license
1188
+ * Copyright 2019 Google LLC
1189
+ *
1190
+ * Licensed under the Apache License, Version 2.0 (the "License");
1191
+ * you may not use this file except in compliance with the License.
1192
+ * You may obtain a copy of the License at
1193
+ *
1194
+ * http://www.apache.org/licenses/LICENSE-2.0
1195
+ *
1196
+ * Unless required by applicable law or agreed to in writing, software
1197
+ * distributed under the License is distributed on an "AS IS" BASIS,
1198
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1199
+ * See the License for the specific language governing permissions and
1200
+ * limitations under the License.
1201
+ */function Bm(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1202
+ * @license
1203
+ * Copyright 2019 Google LLC
1204
+ *
1205
+ * Licensed under the Apache License, Version 2.0 (the "License");
1206
+ * you may not use this file except in compliance with the License.
1207
+ * You may obtain a copy of the License at
1208
+ *
1209
+ * http://www.apache.org/licenses/LICENSE-2.0
1210
+ *
1211
+ * Unless required by applicable law or agreed to in writing, software
1212
+ * distributed under the License is distributed on an "AS IS" BASIS,
1213
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214
+ * See the License for the specific language governing permissions and
1215
+ * limitations under the License.
1216
+ */class Is{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new Is(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:o}=t.data,a=this.handlersMap[s];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const u=Array.from(a).map(async d=>d(t.origin,o)),l=await Bm(u);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:l})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Is.receivers=[];/**
1217
+ * @license
1218
+ * Copyright 2020 Google LLC
1219
+ *
1220
+ * Licensed under the Apache License, Version 2.0 (the "License");
1221
+ * you may not use this file except in compliance with the License.
1222
+ * You may obtain a copy of the License at
1223
+ *
1224
+ * http://www.apache.org/licenses/LICENSE-2.0
1225
+ *
1226
+ * Unless required by applicable law or agreed to in writing, software
1227
+ * distributed under the License is distributed on an "AS IS" BASIS,
1228
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229
+ * See the License for the specific language governing permissions and
1230
+ * limitations under the License.
1231
+ */function lo(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/**
1232
+ * @license
1233
+ * Copyright 2019 Google LLC
1234
+ *
1235
+ * Licensed under the Apache License, Version 2.0 (the "License");
1236
+ * you may not use this file except in compliance with the License.
1237
+ * You may obtain a copy of the License at
1238
+ *
1239
+ * http://www.apache.org/licenses/LICENSE-2.0
1240
+ *
1241
+ * Unless required by applicable law or agreed to in writing, software
1242
+ * distributed under the License is distributed on an "AS IS" BASIS,
1243
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244
+ * See the License for the specific language governing permissions and
1245
+ * limitations under the License.
1246
+ */class $m{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let o,a;return new Promise((u,l)=>{const d=lo("",20);s.port1.start();const p=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(v){const E=v;if(E.data.eventId===d)switch(E.data.status){case"ack":clearTimeout(p),o=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(o),u(E.data.response);break;default:clearTimeout(p),clearTimeout(o),l(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
1247
+ * @license
1248
+ * Copyright 2020 Google LLC
1249
+ *
1250
+ * Licensed under the Apache License, Version 2.0 (the "License");
1251
+ * you may not use this file except in compliance with the License.
1252
+ * You may obtain a copy of the License at
1253
+ *
1254
+ * http://www.apache.org/licenses/LICENSE-2.0
1255
+ *
1256
+ * Unless required by applicable law or agreed to in writing, software
1257
+ * distributed under the License is distributed on an "AS IS" BASIS,
1258
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1259
+ * See the License for the specific language governing permissions and
1260
+ * limitations under the License.
1261
+ */function qe(){return window}function qm(n){qe().location.href=n}/**
1262
+ * @license
1263
+ * Copyright 2020 Google LLC.
1264
+ *
1265
+ * Licensed under the Apache License, Version 2.0 (the "License");
1266
+ * you may not use this file except in compliance with the License.
1267
+ * You may obtain a copy of the License at
1268
+ *
1269
+ * http://www.apache.org/licenses/LICENSE-2.0
1270
+ *
1271
+ * Unless required by applicable law or agreed to in writing, software
1272
+ * distributed under the License is distributed on an "AS IS" BASIS,
1273
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1274
+ * See the License for the specific language governing permissions and
1275
+ * limitations under the License.
1276
+ */function pl(){return typeof qe().WorkerGlobalScope<"u"&&typeof qe().importScripts=="function"}async function zm(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function Hm(){var n;return((n=navigator?.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function Wm(){return pl()?self:null}/**
1277
+ * @license
1278
+ * Copyright 2019 Google LLC
1279
+ *
1280
+ * Licensed under the Apache License, Version 2.0 (the "License");
1281
+ * you may not use this file except in compliance with the License.
1282
+ * You may obtain a copy of the License at
1283
+ *
1284
+ * http://www.apache.org/licenses/LICENSE-2.0
1285
+ *
1286
+ * Unless required by applicable law or agreed to in writing, software
1287
+ * distributed under the License is distributed on an "AS IS" BASIS,
1288
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1289
+ * See the License for the specific language governing permissions and
1290
+ * limitations under the License.
1291
+ */const ml="firebaseLocalStorageDb",Gm=1,ls="firebaseLocalStorage",gl="fbase_key";class fr{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function As(n,e){return n.transaction([ls],e?"readwrite":"readonly").objectStore(ls)}function Km(){const n=indexedDB.deleteDatabase(ml);return new fr(n).toPromise()}function Di(){const n=indexedDB.open(ml,Gm);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(ls,{keyPath:gl})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(ls)?e(r):(r.close(),await Km(),e(await Di()))})})}async function mc(n,e,t){const r=As(n,!0).put({[gl]:e,value:t});return new fr(r).toPromise()}async function Qm(n,e){const t=As(n,!1).get(e),r=await new fr(t).toPromise();return r===void 0?null:r.value}function gc(n,e){const t=As(n,!0).delete(e);return new fr(t).toPromise()}const Jm=800,Xm=3;class _l{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await Di(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>Xm)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return pl()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Is._getInstance(Wm()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await zm(),!this.activeServiceWorker)return;this.sender=new $m(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);r&&!((e=r[0])===null||e===void 0)&&e.fulfilled&&!((t=r[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||Hm()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Di();return await mc(e,us,"1"),await gc(e,us),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>mc(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>Qm(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>gc(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const o=As(s,!1).getAll();return new fr(o).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:o}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(o)&&(this.notifyListeners(s,o),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Jm)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}}_l.type="LOCAL";const Ym=_l;new lr(3e4,6e4);/**
1292
+ * @license
1293
+ * Copyright 2021 Google LLC
1294
+ *
1295
+ * Licensed under the Apache License, Version 2.0 (the "License");
1296
+ * you may not use this file except in compliance with the License.
1297
+ * You may obtain a copy of the License at
1298
+ *
1299
+ * http://www.apache.org/licenses/LICENSE-2.0
1300
+ *
1301
+ * Unless required by applicable law or agreed to in writing, software
1302
+ * distributed under the License is distributed on an "AS IS" BASIS,
1303
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304
+ * See the License for the specific language governing permissions and
1305
+ * limitations under the License.
1306
+ */function ho(n,e){return e?Ze(e):(F(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
1307
+ * @license
1308
+ * Copyright 2019 Google LLC
1309
+ *
1310
+ * Licensed under the Apache License, Version 2.0 (the "License");
1311
+ * you may not use this file except in compliance with the License.
1312
+ * You may obtain a copy of the License at
1313
+ *
1314
+ * http://www.apache.org/licenses/LICENSE-2.0
1315
+ *
1316
+ * Unless required by applicable law or agreed to in writing, software
1317
+ * distributed under the License is distributed on an "AS IS" BASIS,
1318
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319
+ * See the License for the specific language governing permissions and
1320
+ * limitations under the License.
1321
+ */class fo extends co{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return sn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return sn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return sn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Zm(n){return ul(n.auth,new fo(n),n.bypassAuthState)}function eg(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),Sm(t,new fo(n),n.bypassAuthState)}async function tg(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),Rm(t,new fo(n),n.bypassAuthState)}/**
1322
+ * @license
1323
+ * Copyright 2020 Google LLC
1324
+ *
1325
+ * Licensed under the Apache License, Version 2.0 (the "License");
1326
+ * you may not use this file except in compliance with the License.
1327
+ * You may obtain a copy of the License at
1328
+ *
1329
+ * http://www.apache.org/licenses/LICENSE-2.0
1330
+ *
1331
+ * Unless required by applicable law or agreed to in writing, software
1332
+ * distributed under the License is distributed on an "AS IS" BASIS,
1333
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334
+ * See the License for the specific language governing permissions and
1335
+ * limitations under the License.
1336
+ */class yl{constructor(e,t,r,s,o=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=o,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:o,error:a,type:u}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:t,sessionId:r,tenantId:o||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(u)(l))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Zm;case"linkViaPopup":case"linkViaRedirect":return tg;case"reauthViaPopup":case"reauthViaRedirect":return eg;default:Ne(this.auth,"internal-error")}}resolve(e){tt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){tt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1337
+ * @license
1338
+ * Copyright 2020 Google LLC
1339
+ *
1340
+ * Licensed under the Apache License, Version 2.0 (the "License");
1341
+ * you may not use this file except in compliance with the License.
1342
+ * You may obtain a copy of the License at
1343
+ *
1344
+ * http://www.apache.org/licenses/LICENSE-2.0
1345
+ *
1346
+ * Unless required by applicable law or agreed to in writing, software
1347
+ * distributed under the License is distributed on an "AS IS" BASIS,
1348
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349
+ * See the License for the specific language governing permissions and
1350
+ * limitations under the License.
1351
+ */const ng=new lr(2e3,1e4);async function rg(n,e,t){if(ke(n.app))return Promise.reject(Le(n,"operation-not-supported-in-this-environment"));const r=Ue(n);zu(n,e,ws);const s=ho(r,t);return new Lt(r,"signInViaPopup",e,s).executeNotNull()}class Lt extends yl{constructor(e,t,r,s,o){super(e,t,s,o),this.provider=r,this.authWindow=null,this.pollId=null,Lt.currentPopupAction&&Lt.currentPopupAction.cancel(),Lt.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return F(e,this.auth,"internal-error"),e}async onExecution(){tt(this.filter.length===1,"Popup operations only handle one event");const e=lo();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Le(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(Le(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Lt.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if(!((r=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Le(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,ng.get())};e()}}Lt.currentPopupAction=null;/**
1352
+ * @license
1353
+ * Copyright 2020 Google LLC
1354
+ *
1355
+ * Licensed under the Apache License, Version 2.0 (the "License");
1356
+ * you may not use this file except in compliance with the License.
1357
+ * You may obtain a copy of the License at
1358
+ *
1359
+ * http://www.apache.org/licenses/LICENSE-2.0
1360
+ *
1361
+ * Unless required by applicable law or agreed to in writing, software
1362
+ * distributed under the License is distributed on an "AS IS" BASIS,
1363
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1364
+ * See the License for the specific language governing permissions and
1365
+ * limitations under the License.
1366
+ */const sg="pendingRedirect",Kr=new Map;class ig extends yl{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=Kr.get(this.auth._key());if(!e){try{const r=await og(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}Kr.set(this.auth._key(),e)}return this.bypassAuthState||Kr.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function og(n,e){const t=El(e),r=vl(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}async function ag(n,e){return vl(n)._set(El(e),"true")}function cg(n,e){Kr.set(n._key(),e)}function vl(n){return Ze(n._redirectPersistence)}function El(n){return Gr(sg,n.config.apiKey,n.name)}/**
1367
+ * @license
1368
+ * Copyright 2020 Google LLC
1369
+ *
1370
+ * Licensed under the Apache License, Version 2.0 (the "License");
1371
+ * you may not use this file except in compliance with the License.
1372
+ * You may obtain a copy of the License at
1373
+ *
1374
+ * http://www.apache.org/licenses/LICENSE-2.0
1375
+ *
1376
+ * Unless required by applicable law or agreed to in writing, software
1377
+ * distributed under the License is distributed on an "AS IS" BASIS,
1378
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1379
+ * See the License for the specific language governing permissions and
1380
+ * limitations under the License.
1381
+ */function ug(n,e,t){return lg(n,e,t)}async function lg(n,e,t){if(ke(n.app))return Promise.reject($e(n));const r=Ue(n);zu(n,e,ws),await r._initializationPromise;const s=ho(r,t);return await ag(s,r),s._openRedirect(r,e,"signInViaRedirect")}async function hg(n,e){return await Ue(n)._initializationPromise,Tl(n,e,!1)}async function Tl(n,e,t=!1){if(ke(n.app))return Promise.reject($e(n));const r=Ue(n),s=ho(r,e),a=await new ig(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/**
1382
+ * @license
1383
+ * Copyright 2020 Google LLC
1384
+ *
1385
+ * Licensed under the Apache License, Version 2.0 (the "License");
1386
+ * you may not use this file except in compliance with the License.
1387
+ * You may obtain a copy of the License at
1388
+ *
1389
+ * http://www.apache.org/licenses/LICENSE-2.0
1390
+ *
1391
+ * Unless required by applicable law or agreed to in writing, software
1392
+ * distributed under the License is distributed on an "AS IS" BASIS,
1393
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1394
+ * See the License for the specific language governing permissions and
1395
+ * limitations under the License.
1396
+ */const dg=600*1e3;class fg{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!pg(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!wl(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError(Le(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=dg&&this.cachedEventUids.clear(),this.cachedEventUids.has(_c(e))}saveEventToCache(e){this.cachedEventUids.add(_c(e)),this.lastProcessedEventTime=Date.now()}}function _c(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function wl({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function pg(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return wl(n);default:return!1}}/**
1397
+ * @license
1398
+ * Copyright 2020 Google LLC
1399
+ *
1400
+ * Licensed under the Apache License, Version 2.0 (the "License");
1401
+ * you may not use this file except in compliance with the License.
1402
+ * You may obtain a copy of the License at
1403
+ *
1404
+ * http://www.apache.org/licenses/LICENSE-2.0
1405
+ *
1406
+ * Unless required by applicable law or agreed to in writing, software
1407
+ * distributed under the License is distributed on an "AS IS" BASIS,
1408
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409
+ * See the License for the specific language governing permissions and
1410
+ * limitations under the License.
1411
+ */async function mg(n,e={}){return ot(n,"GET","/v1/projects",e)}/**
1412
+ * @license
1413
+ * Copyright 2020 Google LLC
1414
+ *
1415
+ * Licensed under the Apache License, Version 2.0 (the "License");
1416
+ * you may not use this file except in compliance with the License.
1417
+ * You may obtain a copy of the License at
1418
+ *
1419
+ * http://www.apache.org/licenses/LICENSE-2.0
1420
+ *
1421
+ * Unless required by applicable law or agreed to in writing, software
1422
+ * distributed under the License is distributed on an "AS IS" BASIS,
1423
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1424
+ * See the License for the specific language governing permissions and
1425
+ * limitations under the License.
1426
+ */const gg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,_g=/^https?/;async function yg(n){if(n.config.emulator)return;const{authorizedDomains:e}=await mg(n);for(const t of e)try{if(vg(t))return}catch{}Ne(n,"unauthorized-domain")}function vg(n){const e=Pi(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!_g.test(t))return!1;if(gg.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/**
1427
+ * @license
1428
+ * Copyright 2020 Google LLC.
1429
+ *
1430
+ * Licensed under the Apache License, Version 2.0 (the "License");
1431
+ * you may not use this file except in compliance with the License.
1432
+ * You may obtain a copy of the License at
1433
+ *
1434
+ * http://www.apache.org/licenses/LICENSE-2.0
1435
+ *
1436
+ * Unless required by applicable law or agreed to in writing, software
1437
+ * distributed under the License is distributed on an "AS IS" BASIS,
1438
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439
+ * See the License for the specific language governing permissions and
1440
+ * limitations under the License.
1441
+ */const Eg=new lr(3e4,6e4);function yc(){const n=qe().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function Tg(n){return new Promise((e,t)=>{var r,s,o;function a(){yc(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{yc(),t(Le(n,"network-request-failed"))},timeout:Eg.get()})}if(!((s=(r=qe().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((o=qe().gapi)===null||o===void 0)&&o.load)a();else{const u=am("iframefcb");return qe()[u]=()=>{gapi.load?a():t(Le(n,"network-request-failed"))},il(`${om()}?onload=${u}`).catch(l=>t(l))}}).catch(e=>{throw Qr=null,e})}let Qr=null;function wg(n){return Qr=Qr||Tg(n),Qr}/**
1442
+ * @license
1443
+ * Copyright 2020 Google LLC.
1444
+ *
1445
+ * Licensed under the Apache License, Version 2.0 (the "License");
1446
+ * you may not use this file except in compliance with the License.
1447
+ * You may obtain a copy of the License at
1448
+ *
1449
+ * http://www.apache.org/licenses/LICENSE-2.0
1450
+ *
1451
+ * Unless required by applicable law or agreed to in writing, software
1452
+ * distributed under the License is distributed on an "AS IS" BASIS,
1453
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1454
+ * See the License for the specific language governing permissions and
1455
+ * limitations under the License.
1456
+ */const Ig=new lr(5e3,15e3),Ag="__/auth/iframe",bg="emulator/auth/iframe",Rg={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Sg=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Cg(n){const e=n.config;F(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?io(e,bg):`https://${n.config.authDomain}/${Ag}`,r={apiKey:e.apiKey,appName:n.name,v:yn},s=Sg.get(n.config.apiHost);s&&(r.eid=s);const o=n._getFrameworks();return o.length&&(r.fw=o.join(",")),`${t}?${ur(r).slice(1)}`}async function Pg(n){const e=await wg(n),t=qe().gapi;return F(t,n,"internal-error"),e.open({where:document.body,url:Cg(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Rg,dontclear:!0},r=>new Promise(async(s,o)=>{await r.restyle({setHideOnLeave:!1});const a=Le(n,"network-request-failed"),u=qe().setTimeout(()=>{o(a)},Ig.get());function l(){qe().clearTimeout(u),s(r)}r.ping(l).then(l,()=>{o(a)})}))}/**
1457
+ * @license
1458
+ * Copyright 2020 Google LLC.
1459
+ *
1460
+ * Licensed under the Apache License, Version 2.0 (the "License");
1461
+ * you may not use this file except in compliance with the License.
1462
+ * You may obtain a copy of the License at
1463
+ *
1464
+ * http://www.apache.org/licenses/LICENSE-2.0
1465
+ *
1466
+ * Unless required by applicable law or agreed to in writing, software
1467
+ * distributed under the License is distributed on an "AS IS" BASIS,
1468
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1469
+ * See the License for the specific language governing permissions and
1470
+ * limitations under the License.
1471
+ */const kg={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Og=500,Dg=600,Ng="_blank",Vg="http://localhost";class vc{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Mg(n,e,t,r=Og,s=Dg){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const l=Object.assign(Object.assign({},kg),{width:r.toString(),height:s.toString(),top:o,left:a}),d=Ae().toLowerCase();t&&(u=Yu(d)?Ng:t),Ju(d)&&(e=e||Vg,l.scrollbars="yes");const p=Object.entries(l).reduce((E,[C,V])=>`${E}${C}=${V},`,"");if(Xp(d)&&u!=="_self")return Lg(e||"",u),new vc(null);const v=window.open(e||"",u,p);F(v,n,"popup-blocked");try{v.focus()}catch{}return new vc(v)}function Lg(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
1472
+ * @license
1473
+ * Copyright 2021 Google LLC
1474
+ *
1475
+ * Licensed under the Apache License, Version 2.0 (the "License");
1476
+ * you may not use this file except in compliance with the License.
1477
+ * You may obtain a copy of the License at
1478
+ *
1479
+ * http://www.apache.org/licenses/LICENSE-2.0
1480
+ *
1481
+ * Unless required by applicable law or agreed to in writing, software
1482
+ * distributed under the License is distributed on an "AS IS" BASIS,
1483
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1484
+ * See the License for the specific language governing permissions and
1485
+ * limitations under the License.
1486
+ */const xg="__/auth/handler",Ug="emulator/auth/handler",Fg=encodeURIComponent("fac");async function Ec(n,e,t,r,s,o){F(n.config.authDomain,n,"auth-domain-config-required"),F(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:yn,eventId:s};if(e instanceof ws){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",gf(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[p,v]of Object.entries({}))a[p]=v}if(e instanceof dr){const p=e.getScopes().filter(v=>v!=="");p.length>0&&(a.scopes=p.join(","))}n.tenantId&&(a.tid=n.tenantId);const u=a;for(const p of Object.keys(u))u[p]===void 0&&delete u[p];const l=await n._getAppCheckToken(),d=l?`#${Fg}=${encodeURIComponent(l)}`:"";return`${jg(n)}?${ur(u).slice(1)}${d}`}function jg({config:n}){return n.emulator?io(n,Ug):`https://${n.authDomain}/${xg}`}/**
1487
+ * @license
1488
+ * Copyright 2020 Google LLC
1489
+ *
1490
+ * Licensed under the Apache License, Version 2.0 (the "License");
1491
+ * you may not use this file except in compliance with the License.
1492
+ * You may obtain a copy of the License at
1493
+ *
1494
+ * http://www.apache.org/licenses/LICENSE-2.0
1495
+ *
1496
+ * Unless required by applicable law or agreed to in writing, software
1497
+ * distributed under the License is distributed on an "AS IS" BASIS,
1498
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1499
+ * See the License for the specific language governing permissions and
1500
+ * limitations under the License.
1501
+ */const gi="webStorageSupport";class Bg{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fl,this._completeRedirectFn=Tl,this._overrideRedirectResult=cg}async _openPopup(e,t,r,s){var o;tt((o=this.eventManagers[e._key()])===null||o===void 0?void 0:o.manager,"_initialize() not called before _openPopup()");const a=await Ec(e,t,r,Pi(),s);return Mg(e,a,lo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const o=await Ec(e,t,r,Pi(),s);return qm(o),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:o}=this.eventManagers[t];return s?Promise.resolve(s):(tt(o,"If manager is not set, promise should be"),o)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Pg(e),r=new fg(e);return t.register("authEvent",s=>(F(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(gi,{type:gi},s=>{var o;const a=(o=s?.[0])===null||o===void 0?void 0:o[gi];a!==void 0&&t(!!a),Ne(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=yg(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return rl()||Xu()||ao()}}const $g=Bg;var Tc="@firebase/auth",wc="1.10.8";/**
1502
+ * @license
1503
+ * Copyright 2020 Google LLC
1504
+ *
1505
+ * Licensed under the Apache License, Version 2.0 (the "License");
1506
+ * you may not use this file except in compliance with the License.
1507
+ * You may obtain a copy of the License at
1508
+ *
1509
+ * http://www.apache.org/licenses/LICENSE-2.0
1510
+ *
1511
+ * Unless required by applicable law or agreed to in writing, software
1512
+ * distributed under the License is distributed on an "AS IS" BASIS,
1513
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1514
+ * See the License for the specific language governing permissions and
1515
+ * limitations under the License.
1516
+ */class qg{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){F(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1517
+ * @license
1518
+ * Copyright 2020 Google LLC
1519
+ *
1520
+ * Licensed under the Apache License, Version 2.0 (the "License");
1521
+ * you may not use this file except in compliance with the License.
1522
+ * You may obtain a copy of the License at
1523
+ *
1524
+ * http://www.apache.org/licenses/LICENSE-2.0
1525
+ *
1526
+ * Unless required by applicable law or agreed to in writing, software
1527
+ * distributed under the License is distributed on an "AS IS" BASIS,
1528
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1529
+ * See the License for the specific language governing permissions and
1530
+ * limitations under the License.
1531
+ */function zg(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Hg(n){ln(new $t("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:a,authDomain:u}=r.options;F(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:u,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:sl(n)},d=new rm(r,s,o,l);return fm(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),ln(new $t("auth-internal",e=>{const t=Ue(e.getProvider("auth").getImmediate());return(r=>new qg(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),vt(Tc,wc,zg(n)),vt(Tc,wc,"esm2017")}/**
1532
+ * @license
1533
+ * Copyright 2021 Google LLC
1534
+ *
1535
+ * Licensed under the Apache License, Version 2.0 (the "License");
1536
+ * you may not use this file except in compliance with the License.
1537
+ * You may obtain a copy of the License at
1538
+ *
1539
+ * http://www.apache.org/licenses/LICENSE-2.0
1540
+ *
1541
+ * Unless required by applicable law or agreed to in writing, software
1542
+ * distributed under the License is distributed on an "AS IS" BASIS,
1543
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1544
+ * See the License for the specific language governing permissions and
1545
+ * limitations under the License.
1546
+ */const Wg=300,Gg=Nu("authIdTokenMaxAge")||Wg;let Ic=null;const Kg=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Gg)return;const s=t?.token;Ic!==s&&(Ic=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Qg(n=Fu()){const e=to(n,"auth");if(e.isInitialized())return e.getImmediate();const t=dm(n,{popupRedirectResolver:$g,persistence:[Ym,jm,fl]}),r=Nu("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const o=new URL(r,location.origin);if(location.origin===o.origin){const a=Kg(o.toString());Mm(t,a,()=>a(t.currentUser)),Vm(t,u=>a(u))}}const s=Ou("auth");return s&&pm(t,`http://${s}`),t}function Jg(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}sm({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const o=Le("internal-error");o.customData=s,t(o)},r.type="text/javascript",r.charset="UTF-8",Jg().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Hg("Browser");var Ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1547
+ Copyright The Closure Library Authors.
1548
+ SPDX-License-Identifier: Apache-2.0
1549
+ */var Et,Il;(function(){var n;/** @license
1550
+
1551
+ Copyright The Closure Library Authors.
1552
+ SPDX-License-Identifier: Apache-2.0
1553
+ */function e(_,m){function g(){}g.prototype=m.prototype,_.D=m.prototype,_.prototype=new g,_.prototype.constructor=_,_.C=function(T,w,A){for(var y=Array(arguments.length-2),Ge=2;Ge<arguments.length;Ge++)y[Ge-2]=arguments[Ge];return m.prototype[w].apply(T,y)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(_,m,g){g||(g=0);var T=Array(16);if(typeof m=="string")for(var w=0;16>w;++w)T[w]=m.charCodeAt(g++)|m.charCodeAt(g++)<<8|m.charCodeAt(g++)<<16|m.charCodeAt(g++)<<24;else for(w=0;16>w;++w)T[w]=m[g++]|m[g++]<<8|m[g++]<<16|m[g++]<<24;m=_.g[0],g=_.g[1],w=_.g[2];var A=_.g[3],y=m+(A^g&(w^A))+T[0]+3614090360&4294967295;m=g+(y<<7&4294967295|y>>>25),y=A+(w^m&(g^w))+T[1]+3905402710&4294967295,A=m+(y<<12&4294967295|y>>>20),y=w+(g^A&(m^g))+T[2]+606105819&4294967295,w=A+(y<<17&4294967295|y>>>15),y=g+(m^w&(A^m))+T[3]+3250441966&4294967295,g=w+(y<<22&4294967295|y>>>10),y=m+(A^g&(w^A))+T[4]+4118548399&4294967295,m=g+(y<<7&4294967295|y>>>25),y=A+(w^m&(g^w))+T[5]+1200080426&4294967295,A=m+(y<<12&4294967295|y>>>20),y=w+(g^A&(m^g))+T[6]+2821735955&4294967295,w=A+(y<<17&4294967295|y>>>15),y=g+(m^w&(A^m))+T[7]+4249261313&4294967295,g=w+(y<<22&4294967295|y>>>10),y=m+(A^g&(w^A))+T[8]+1770035416&4294967295,m=g+(y<<7&4294967295|y>>>25),y=A+(w^m&(g^w))+T[9]+2336552879&4294967295,A=m+(y<<12&4294967295|y>>>20),y=w+(g^A&(m^g))+T[10]+4294925233&4294967295,w=A+(y<<17&4294967295|y>>>15),y=g+(m^w&(A^m))+T[11]+2304563134&4294967295,g=w+(y<<22&4294967295|y>>>10),y=m+(A^g&(w^A))+T[12]+1804603682&4294967295,m=g+(y<<7&4294967295|y>>>25),y=A+(w^m&(g^w))+T[13]+4254626195&4294967295,A=m+(y<<12&4294967295|y>>>20),y=w+(g^A&(m^g))+T[14]+2792965006&4294967295,w=A+(y<<17&4294967295|y>>>15),y=g+(m^w&(A^m))+T[15]+1236535329&4294967295,g=w+(y<<22&4294967295|y>>>10),y=m+(w^A&(g^w))+T[1]+4129170786&4294967295,m=g+(y<<5&4294967295|y>>>27),y=A+(g^w&(m^g))+T[6]+3225465664&4294967295,A=m+(y<<9&4294967295|y>>>23),y=w+(m^g&(A^m))+T[11]+643717713&4294967295,w=A+(y<<14&4294967295|y>>>18),y=g+(A^m&(w^A))+T[0]+3921069994&4294967295,g=w+(y<<20&4294967295|y>>>12),y=m+(w^A&(g^w))+T[5]+3593408605&4294967295,m=g+(y<<5&4294967295|y>>>27),y=A+(g^w&(m^g))+T[10]+38016083&4294967295,A=m+(y<<9&4294967295|y>>>23),y=w+(m^g&(A^m))+T[15]+3634488961&4294967295,w=A+(y<<14&4294967295|y>>>18),y=g+(A^m&(w^A))+T[4]+3889429448&4294967295,g=w+(y<<20&4294967295|y>>>12),y=m+(w^A&(g^w))+T[9]+568446438&4294967295,m=g+(y<<5&4294967295|y>>>27),y=A+(g^w&(m^g))+T[14]+3275163606&4294967295,A=m+(y<<9&4294967295|y>>>23),y=w+(m^g&(A^m))+T[3]+4107603335&4294967295,w=A+(y<<14&4294967295|y>>>18),y=g+(A^m&(w^A))+T[8]+1163531501&4294967295,g=w+(y<<20&4294967295|y>>>12),y=m+(w^A&(g^w))+T[13]+2850285829&4294967295,m=g+(y<<5&4294967295|y>>>27),y=A+(g^w&(m^g))+T[2]+4243563512&4294967295,A=m+(y<<9&4294967295|y>>>23),y=w+(m^g&(A^m))+T[7]+1735328473&4294967295,w=A+(y<<14&4294967295|y>>>18),y=g+(A^m&(w^A))+T[12]+2368359562&4294967295,g=w+(y<<20&4294967295|y>>>12),y=m+(g^w^A)+T[5]+4294588738&4294967295,m=g+(y<<4&4294967295|y>>>28),y=A+(m^g^w)+T[8]+2272392833&4294967295,A=m+(y<<11&4294967295|y>>>21),y=w+(A^m^g)+T[11]+1839030562&4294967295,w=A+(y<<16&4294967295|y>>>16),y=g+(w^A^m)+T[14]+4259657740&4294967295,g=w+(y<<23&4294967295|y>>>9),y=m+(g^w^A)+T[1]+2763975236&4294967295,m=g+(y<<4&4294967295|y>>>28),y=A+(m^g^w)+T[4]+1272893353&4294967295,A=m+(y<<11&4294967295|y>>>21),y=w+(A^m^g)+T[7]+4139469664&4294967295,w=A+(y<<16&4294967295|y>>>16),y=g+(w^A^m)+T[10]+3200236656&4294967295,g=w+(y<<23&4294967295|y>>>9),y=m+(g^w^A)+T[13]+681279174&4294967295,m=g+(y<<4&4294967295|y>>>28),y=A+(m^g^w)+T[0]+3936430074&4294967295,A=m+(y<<11&4294967295|y>>>21),y=w+(A^m^g)+T[3]+3572445317&4294967295,w=A+(y<<16&4294967295|y>>>16),y=g+(w^A^m)+T[6]+76029189&4294967295,g=w+(y<<23&4294967295|y>>>9),y=m+(g^w^A)+T[9]+3654602809&4294967295,m=g+(y<<4&4294967295|y>>>28),y=A+(m^g^w)+T[12]+3873151461&4294967295,A=m+(y<<11&4294967295|y>>>21),y=w+(A^m^g)+T[15]+530742520&4294967295,w=A+(y<<16&4294967295|y>>>16),y=g+(w^A^m)+T[2]+3299628645&4294967295,g=w+(y<<23&4294967295|y>>>9),y=m+(w^(g|~A))+T[0]+4096336452&4294967295,m=g+(y<<6&4294967295|y>>>26),y=A+(g^(m|~w))+T[7]+1126891415&4294967295,A=m+(y<<10&4294967295|y>>>22),y=w+(m^(A|~g))+T[14]+2878612391&4294967295,w=A+(y<<15&4294967295|y>>>17),y=g+(A^(w|~m))+T[5]+4237533241&4294967295,g=w+(y<<21&4294967295|y>>>11),y=m+(w^(g|~A))+T[12]+1700485571&4294967295,m=g+(y<<6&4294967295|y>>>26),y=A+(g^(m|~w))+T[3]+2399980690&4294967295,A=m+(y<<10&4294967295|y>>>22),y=w+(m^(A|~g))+T[10]+4293915773&4294967295,w=A+(y<<15&4294967295|y>>>17),y=g+(A^(w|~m))+T[1]+2240044497&4294967295,g=w+(y<<21&4294967295|y>>>11),y=m+(w^(g|~A))+T[8]+1873313359&4294967295,m=g+(y<<6&4294967295|y>>>26),y=A+(g^(m|~w))+T[15]+4264355552&4294967295,A=m+(y<<10&4294967295|y>>>22),y=w+(m^(A|~g))+T[6]+2734768916&4294967295,w=A+(y<<15&4294967295|y>>>17),y=g+(A^(w|~m))+T[13]+1309151649&4294967295,g=w+(y<<21&4294967295|y>>>11),y=m+(w^(g|~A))+T[4]+4149444226&4294967295,m=g+(y<<6&4294967295|y>>>26),y=A+(g^(m|~w))+T[11]+3174756917&4294967295,A=m+(y<<10&4294967295|y>>>22),y=w+(m^(A|~g))+T[2]+718787259&4294967295,w=A+(y<<15&4294967295|y>>>17),y=g+(A^(w|~m))+T[9]+3951481745&4294967295,_.g[0]=_.g[0]+m&4294967295,_.g[1]=_.g[1]+(w+(y<<21&4294967295|y>>>11))&4294967295,_.g[2]=_.g[2]+w&4294967295,_.g[3]=_.g[3]+A&4294967295}r.prototype.u=function(_,m){m===void 0&&(m=_.length);for(var g=m-this.blockSize,T=this.B,w=this.h,A=0;A<m;){if(w==0)for(;A<=g;)s(this,_,A),A+=this.blockSize;if(typeof _=="string"){for(;A<m;)if(T[w++]=_.charCodeAt(A++),w==this.blockSize){s(this,T),w=0;break}}else for(;A<m;)if(T[w++]=_[A++],w==this.blockSize){s(this,T),w=0;break}}this.h=w,this.o+=m},r.prototype.v=function(){var _=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);_[0]=128;for(var m=1;m<_.length-8;++m)_[m]=0;var g=8*this.o;for(m=_.length-8;m<_.length;++m)_[m]=g&255,g/=256;for(this.u(_),_=Array(16),m=g=0;4>m;++m)for(var T=0;32>T;T+=8)_[g++]=this.g[m]>>>T&255;return _};function o(_,m){var g=u;return Object.prototype.hasOwnProperty.call(g,_)?g[_]:g[_]=m(_)}function a(_,m){this.h=m;for(var g=[],T=!0,w=_.length-1;0<=w;w--){var A=_[w]|0;T&&A==m||(g[w]=A,T=!1)}this.g=g}var u={};function l(_){return-128<=_&&128>_?o(_,function(m){return new a([m|0],0>m?-1:0)}):new a([_|0],0>_?-1:0)}function d(_){if(isNaN(_)||!isFinite(_))return v;if(0>_)return k(d(-_));for(var m=[],g=1,T=0;_>=g;T++)m[T]=_/g|0,g*=4294967296;return new a(m,0)}function p(_,m){if(_.length==0)throw Error("number format error: empty string");if(m=m||10,2>m||36<m)throw Error("radix out of range: "+m);if(_.charAt(0)=="-")return k(p(_.substring(1),m));if(0<=_.indexOf("-"))throw Error('number format error: interior "-" character');for(var g=d(Math.pow(m,8)),T=v,w=0;w<_.length;w+=8){var A=Math.min(8,_.length-w),y=parseInt(_.substring(w,w+A),m);8>A?(A=d(Math.pow(m,A)),T=T.j(A).add(d(y))):(T=T.j(g),T=T.add(d(y)))}return T}var v=l(0),E=l(1),C=l(16777216);n=a.prototype,n.m=function(){if(M(this))return-k(this).m();for(var _=0,m=1,g=0;g<this.g.length;g++){var T=this.i(g);_+=(0<=T?T:4294967296+T)*m,m*=4294967296}return _},n.toString=function(_){if(_=_||10,2>_||36<_)throw Error("radix out of range: "+_);if(V(this))return"0";if(M(this))return"-"+k(this).toString(_);for(var m=d(Math.pow(_,6)),g=this,T="";;){var w=Y(g,m).g;g=q(g,w.j(m));var A=((0<g.g.length?g.g[0]:g.h)>>>0).toString(_);if(g=w,V(g))return A+T;for(;6>A.length;)A="0"+A;T=A+T}},n.i=function(_){return 0>_?0:_<this.g.length?this.g[_]:this.h};function V(_){if(_.h!=0)return!1;for(var m=0;m<_.g.length;m++)if(_.g[m]!=0)return!1;return!0}function M(_){return _.h==-1}n.l=function(_){return _=q(this,_),M(_)?-1:V(_)?0:1};function k(_){for(var m=_.g.length,g=[],T=0;T<m;T++)g[T]=~_.g[T];return new a(g,~_.h).add(E)}n.abs=function(){return M(this)?k(this):this},n.add=function(_){for(var m=Math.max(this.g.length,_.g.length),g=[],T=0,w=0;w<=m;w++){var A=T+(this.i(w)&65535)+(_.i(w)&65535),y=(A>>>16)+(this.i(w)>>>16)+(_.i(w)>>>16);T=y>>>16,A&=65535,y&=65535,g[w]=y<<16|A}return new a(g,g[g.length-1]&-2147483648?-1:0)};function q(_,m){return _.add(k(m))}n.j=function(_){if(V(this)||V(_))return v;if(M(this))return M(_)?k(this).j(k(_)):k(k(this).j(_));if(M(_))return k(this.j(k(_)));if(0>this.l(C)&&0>_.l(C))return d(this.m()*_.m());for(var m=this.g.length+_.g.length,g=[],T=0;T<2*m;T++)g[T]=0;for(T=0;T<this.g.length;T++)for(var w=0;w<_.g.length;w++){var A=this.i(T)>>>16,y=this.i(T)&65535,Ge=_.i(w)>>>16,In=_.i(w)&65535;g[2*T+2*w]+=y*In,z(g,2*T+2*w),g[2*T+2*w+1]+=A*In,z(g,2*T+2*w+1),g[2*T+2*w+1]+=y*Ge,z(g,2*T+2*w+1),g[2*T+2*w+2]+=A*Ge,z(g,2*T+2*w+2)}for(T=0;T<m;T++)g[T]=g[2*T+1]<<16|g[2*T];for(T=m;T<2*m;T++)g[T]=0;return new a(g,0)};function z(_,m){for(;(_[m]&65535)!=_[m];)_[m+1]+=_[m]>>>16,_[m]&=65535,m++}function B(_,m){this.g=_,this.h=m}function Y(_,m){if(V(m))throw Error("division by zero");if(V(_))return new B(v,v);if(M(_))return m=Y(k(_),m),new B(k(m.g),k(m.h));if(M(m))return m=Y(_,k(m)),new B(k(m.g),m.h);if(30<_.g.length){if(M(_)||M(m))throw Error("slowDivide_ only works with positive integers.");for(var g=E,T=m;0>=T.l(_);)g=he(g),T=he(T);var w=P(g,1),A=P(T,1);for(T=P(T,2),g=P(g,2);!V(T);){var y=A.add(T);0>=y.l(_)&&(w=w.add(g),A=y),T=P(T,1),g=P(g,1)}return m=q(_,w.j(m)),new B(w,m)}for(w=v;0<=_.l(m);){for(g=Math.max(1,Math.floor(_.m()/m.m())),T=Math.ceil(Math.log(g)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),A=d(g),y=A.j(m);M(y)||0<y.l(_);)g-=T,A=d(g),y=A.j(m);V(A)&&(A=E),w=w.add(A),_=q(_,y)}return new B(w,_)}n.A=function(_){return Y(this,_).h},n.and=function(_){for(var m=Math.max(this.g.length,_.g.length),g=[],T=0;T<m;T++)g[T]=this.i(T)&_.i(T);return new a(g,this.h&_.h)},n.or=function(_){for(var m=Math.max(this.g.length,_.g.length),g=[],T=0;T<m;T++)g[T]=this.i(T)|_.i(T);return new a(g,this.h|_.h)},n.xor=function(_){for(var m=Math.max(this.g.length,_.g.length),g=[],T=0;T<m;T++)g[T]=this.i(T)^_.i(T);return new a(g,this.h^_.h)};function he(_){for(var m=_.g.length+1,g=[],T=0;T<m;T++)g[T]=_.i(T)<<1|_.i(T-1)>>>31;return new a(g,_.h)}function P(_,m){var g=m>>5;m%=32;for(var T=_.g.length-g,w=[],A=0;A<T;A++)w[A]=0<m?_.i(A+g)>>>m|_.i(A+g+1)<<32-m:_.i(A+g);return new a(w,_.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,Il=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=p,Et=a}).apply(typeof Ac<"u"?Ac:typeof self<"u"?self:typeof window<"u"?window:{});var jr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1554
+ Copyright The Closure Library Authors.
1555
+ SPDX-License-Identifier: Apache-2.0
1556
+ */var Al,$n,bl,Jr,Ni,Rl,Sl,Cl;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(i,c,h){return i==Array.prototype||i==Object.prototype||(i[c]=h.value),i};function t(i){i=[typeof globalThis=="object"&&globalThis,i,typeof window=="object"&&window,typeof self=="object"&&self,typeof jr=="object"&&jr];for(var c=0;c<i.length;++c){var h=i[c];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var r=t(this);function s(i,c){if(c)e:{var h=r;i=i.split(".");for(var f=0;f<i.length-1;f++){var I=i[f];if(!(I in h))break e;h=h[I]}i=i[i.length-1],f=h[i],c=c(f),c!=f&&c!=null&&e(h,i,{configurable:!0,writable:!0,value:c})}}function o(i,c){i instanceof String&&(i+="");var h=0,f=!1,I={next:function(){if(!f&&h<i.length){var R=h++;return{value:c(R,i[R]),done:!1}}return f=!0,{done:!0,value:void 0}}};return I[Symbol.iterator]=function(){return I},I}s("Array.prototype.values",function(i){return i||function(){return o(this,function(c,h){return h})}});/** @license
1557
+
1558
+ Copyright The Closure Library Authors.
1559
+ SPDX-License-Identifier: Apache-2.0
1560
+ */var a=a||{},u=this||self;function l(i){var c=typeof i;return c=c!="object"?c:i?Array.isArray(i)?"array":c:"null",c=="array"||c=="object"&&typeof i.length=="number"}function d(i){var c=typeof i;return c=="object"&&i!=null||c=="function"}function p(i,c,h){return i.call.apply(i.bind,arguments)}function v(i,c,h){if(!i)throw Error();if(2<arguments.length){var f=Array.prototype.slice.call(arguments,2);return function(){var I=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(I,f),i.apply(c,I)}}return function(){return i.apply(c,arguments)}}function E(i,c,h){return E=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?p:v,E.apply(null,arguments)}function C(i,c){var h=Array.prototype.slice.call(arguments,1);return function(){var f=h.slice();return f.push.apply(f,arguments),i.apply(this,f)}}function V(i,c){function h(){}h.prototype=c.prototype,i.aa=c.prototype,i.prototype=new h,i.prototype.constructor=i,i.Qb=function(f,I,R){for(var D=Array(arguments.length-2),Z=2;Z<arguments.length;Z++)D[Z-2]=arguments[Z];return c.prototype[I].apply(f,D)}}function M(i){const c=i.length;if(0<c){const h=Array(c);for(let f=0;f<c;f++)h[f]=i[f];return h}return[]}function k(i,c){for(let h=1;h<arguments.length;h++){const f=arguments[h];if(l(f)){const I=i.length||0,R=f.length||0;i.length=I+R;for(let D=0;D<R;D++)i[I+D]=f[D]}else i.push(f)}}class q{constructor(c,h){this.i=c,this.j=h,this.h=0,this.g=null}get(){let c;return 0<this.h?(this.h--,c=this.g,this.g=c.next,c.next=null):c=this.i(),c}}function z(i){return/^[\s\xa0]*$/.test(i)}function B(){var i=u.navigator;return i&&(i=i.userAgent)?i:""}function Y(i){return Y[" "](i),i}Y[" "]=function(){};var he=B().indexOf("Gecko")!=-1&&!(B().toLowerCase().indexOf("webkit")!=-1&&B().indexOf("Edge")==-1)&&!(B().indexOf("Trident")!=-1||B().indexOf("MSIE")!=-1)&&B().indexOf("Edge")==-1;function P(i,c,h){for(const f in i)c.call(h,i[f],f,i)}function _(i,c){for(const h in i)c.call(void 0,i[h],h,i)}function m(i){const c={};for(const h in i)c[h]=i[h];return c}const g="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(i,c){let h,f;for(let I=1;I<arguments.length;I++){f=arguments[I];for(h in f)i[h]=f[h];for(let R=0;R<g.length;R++)h=g[R],Object.prototype.hasOwnProperty.call(f,h)&&(i[h]=f[h])}}function w(i){var c=1;i=i.split(":");const h=[];for(;0<c&&i.length;)h.push(i.shift()),c--;return i.length&&h.push(i.join(":")),h}function A(i){u.setTimeout(()=>{throw i},0)}function y(){var i=Fs;let c=null;return i.g&&(c=i.g,i.g=i.g.next,i.g||(i.h=null),c.next=null),c}class Ge{constructor(){this.h=this.g=null}add(c,h){const f=In.get();f.set(c,h),this.h?this.h.next=f:this.g=f,this.h=f}}var In=new q(()=>new Uh,i=>i.reset());class Uh{constructor(){this.next=this.g=this.h=null}set(c,h){this.h=c,this.g=h,this.next=null}reset(){this.next=this.g=this.h=null}}let An,bn=!1,Fs=new Ge,Fo=()=>{const i=u.Promise.resolve(void 0);An=()=>{i.then(Fh)}};var Fh=()=>{for(var i;i=y();){try{i.h.call(i.g)}catch(h){A(h)}var c=In;c.j(i),100>c.h&&(c.h++,i.next=c.g,c.g=i)}bn=!1};function at(){this.s=this.s,this.C=this.C}at.prototype.s=!1,at.prototype.ma=function(){this.s||(this.s=!0,this.N())},at.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function _e(i,c){this.type=i,this.g=this.target=c,this.defaultPrevented=!1}_e.prototype.h=function(){this.defaultPrevented=!0};var jh=(function(){if(!u.addEventListener||!Object.defineProperty)return!1;var i=!1,c=Object.defineProperty({},"passive",{get:function(){i=!0}});try{const h=()=>{};u.addEventListener("test",h,c),u.removeEventListener("test",h,c)}catch{}return i})();function Rn(i,c){if(_e.call(this,i?i.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,i){var h=this.type=i.type,f=i.changedTouches&&i.changedTouches.length?i.changedTouches[0]:null;if(this.target=i.target||i.srcElement,this.g=c,c=i.relatedTarget){if(he){e:{try{Y(c.nodeName);var I=!0;break e}catch{}I=!1}I||(c=null)}}else h=="mouseover"?c=i.fromElement:h=="mouseout"&&(c=i.toElement);this.relatedTarget=c,f?(this.clientX=f.clientX!==void 0?f.clientX:f.pageX,this.clientY=f.clientY!==void 0?f.clientY:f.pageY,this.screenX=f.screenX||0,this.screenY=f.screenY||0):(this.clientX=i.clientX!==void 0?i.clientX:i.pageX,this.clientY=i.clientY!==void 0?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0),this.button=i.button,this.key=i.key||"",this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.shiftKey=i.shiftKey,this.metaKey=i.metaKey,this.pointerId=i.pointerId||0,this.pointerType=typeof i.pointerType=="string"?i.pointerType:Bh[i.pointerType]||"",this.state=i.state,this.i=i,i.defaultPrevented&&Rn.aa.h.call(this)}}V(Rn,_e);var Bh={2:"touch",3:"pen",4:"mouse"};Rn.prototype.h=function(){Rn.aa.h.call(this);var i=this.i;i.preventDefault?i.preventDefault():i.returnValue=!1};var Er="closure_listenable_"+(1e6*Math.random()|0),$h=0;function qh(i,c,h,f,I){this.listener=i,this.proxy=null,this.src=c,this.type=h,this.capture=!!f,this.ha=I,this.key=++$h,this.da=this.fa=!1}function Tr(i){i.da=!0,i.listener=null,i.proxy=null,i.src=null,i.ha=null}function wr(i){this.src=i,this.g={},this.h=0}wr.prototype.add=function(i,c,h,f,I){var R=i.toString();i=this.g[R],i||(i=this.g[R]=[],this.h++);var D=Bs(i,c,f,I);return-1<D?(c=i[D],h||(c.fa=!1)):(c=new qh(c,this.src,R,!!f,I),c.fa=h,i.push(c)),c};function js(i,c){var h=c.type;if(h in i.g){var f=i.g[h],I=Array.prototype.indexOf.call(f,c,void 0),R;(R=0<=I)&&Array.prototype.splice.call(f,I,1),R&&(Tr(c),i.g[h].length==0&&(delete i.g[h],i.h--))}}function Bs(i,c,h,f){for(var I=0;I<i.length;++I){var R=i[I];if(!R.da&&R.listener==c&&R.capture==!!h&&R.ha==f)return I}return-1}var $s="closure_lm_"+(1e6*Math.random()|0),qs={};function jo(i,c,h,f,I){if(Array.isArray(c)){for(var R=0;R<c.length;R++)jo(i,c[R],h,f,I);return null}return h=qo(h),i&&i[Er]?i.K(c,h,d(f)?!!f.capture:!1,I):zh(i,c,h,!1,f,I)}function zh(i,c,h,f,I,R){if(!c)throw Error("Invalid event type");var D=d(I)?!!I.capture:!!I,Z=Hs(i);if(Z||(i[$s]=Z=new wr(i)),h=Z.add(c,h,f,D,R),h.proxy)return h;if(f=Hh(),h.proxy=f,f.src=i,f.listener=h,i.addEventListener)jh||(I=D),I===void 0&&(I=!1),i.addEventListener(c.toString(),f,I);else if(i.attachEvent)i.attachEvent($o(c.toString()),f);else if(i.addListener&&i.removeListener)i.addListener(f);else throw Error("addEventListener and attachEvent are unavailable.");return h}function Hh(){function i(h){return c.call(i.src,i.listener,h)}const c=Wh;return i}function Bo(i,c,h,f,I){if(Array.isArray(c))for(var R=0;R<c.length;R++)Bo(i,c[R],h,f,I);else f=d(f)?!!f.capture:!!f,h=qo(h),i&&i[Er]?(i=i.i,c=String(c).toString(),c in i.g&&(R=i.g[c],h=Bs(R,h,f,I),-1<h&&(Tr(R[h]),Array.prototype.splice.call(R,h,1),R.length==0&&(delete i.g[c],i.h--)))):i&&(i=Hs(i))&&(c=i.g[c.toString()],i=-1,c&&(i=Bs(c,h,f,I)),(h=-1<i?c[i]:null)&&zs(h))}function zs(i){if(typeof i!="number"&&i&&!i.da){var c=i.src;if(c&&c[Er])js(c.i,i);else{var h=i.type,f=i.proxy;c.removeEventListener?c.removeEventListener(h,f,i.capture):c.detachEvent?c.detachEvent($o(h),f):c.addListener&&c.removeListener&&c.removeListener(f),(h=Hs(c))?(js(h,i),h.h==0&&(h.src=null,c[$s]=null)):Tr(i)}}}function $o(i){return i in qs?qs[i]:qs[i]="on"+i}function Wh(i,c){if(i.da)i=!0;else{c=new Rn(c,this);var h=i.listener,f=i.ha||i.src;i.fa&&zs(i),i=h.call(f,c)}return i}function Hs(i){return i=i[$s],i instanceof wr?i:null}var Ws="__closure_events_fn_"+(1e9*Math.random()>>>0);function qo(i){return typeof i=="function"?i:(i[Ws]||(i[Ws]=function(c){return i.handleEvent(c)}),i[Ws])}function ye(){at.call(this),this.i=new wr(this),this.M=this,this.F=null}V(ye,at),ye.prototype[Er]=!0,ye.prototype.removeEventListener=function(i,c,h,f){Bo(this,i,c,h,f)};function be(i,c){var h,f=i.F;if(f)for(h=[];f;f=f.F)h.push(f);if(i=i.M,f=c.type||c,typeof c=="string")c=new _e(c,i);else if(c instanceof _e)c.target=c.target||i;else{var I=c;c=new _e(f,i),T(c,I)}if(I=!0,h)for(var R=h.length-1;0<=R;R--){var D=c.g=h[R];I=Ir(D,f,!0,c)&&I}if(D=c.g=i,I=Ir(D,f,!0,c)&&I,I=Ir(D,f,!1,c)&&I,h)for(R=0;R<h.length;R++)D=c.g=h[R],I=Ir(D,f,!1,c)&&I}ye.prototype.N=function(){if(ye.aa.N.call(this),this.i){var i=this.i,c;for(c in i.g){for(var h=i.g[c],f=0;f<h.length;f++)Tr(h[f]);delete i.g[c],i.h--}}this.F=null},ye.prototype.K=function(i,c,h,f){return this.i.add(String(i),c,!1,h,f)},ye.prototype.L=function(i,c,h,f){return this.i.add(String(i),c,!0,h,f)};function Ir(i,c,h,f){if(c=i.i.g[String(c)],!c)return!0;c=c.concat();for(var I=!0,R=0;R<c.length;++R){var D=c[R];if(D&&!D.da&&D.capture==h){var Z=D.listener,fe=D.ha||D.src;D.fa&&js(i.i,D),I=Z.call(fe,f)!==!1&&I}}return I&&!f.defaultPrevented}function zo(i,c,h){if(typeof i=="function")h&&(i=E(i,h));else if(i&&typeof i.handleEvent=="function")i=E(i.handleEvent,i);else throw Error("Invalid listener argument");return 2147483647<Number(c)?-1:u.setTimeout(i,c||0)}function Ho(i){i.g=zo(()=>{i.g=null,i.i&&(i.i=!1,Ho(i))},i.l);const c=i.h;i.h=null,i.m.apply(null,c)}class Gh extends at{constructor(c,h){super(),this.m=c,this.l=h,this.h=null,this.i=!1,this.g=null}j(c){this.h=arguments,this.g?this.i=!0:Ho(this)}N(){super.N(),this.g&&(u.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Sn(i){at.call(this),this.h=i,this.g={}}V(Sn,at);var Wo=[];function Go(i){P(i.g,function(c,h){this.g.hasOwnProperty(h)&&zs(c)},i),i.g={}}Sn.prototype.N=function(){Sn.aa.N.call(this),Go(this)},Sn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Gs=u.JSON.stringify,Kh=u.JSON.parse,Qh=class{stringify(i){return u.JSON.stringify(i,void 0)}parse(i){return u.JSON.parse(i,void 0)}};function Ks(){}Ks.prototype.h=null;function Ko(i){return i.h||(i.h=i.i())}function Qo(){}var Cn={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Qs(){_e.call(this,"d")}V(Qs,_e);function Js(){_e.call(this,"c")}V(Js,_e);var Ot={},Jo=null;function Ar(){return Jo=Jo||new ye}Ot.La="serverreachability";function Xo(i){_e.call(this,Ot.La,i)}V(Xo,_e);function Pn(i){const c=Ar();be(c,new Xo(c))}Ot.STAT_EVENT="statevent";function Yo(i,c){_e.call(this,Ot.STAT_EVENT,i),this.stat=c}V(Yo,_e);function Re(i){const c=Ar();be(c,new Yo(c,i))}Ot.Ma="timingevent";function Zo(i,c){_e.call(this,Ot.Ma,i),this.size=c}V(Zo,_e);function kn(i,c){if(typeof i!="function")throw Error("Fn must not be null and must be a function");return u.setTimeout(function(){i()},c)}function On(){this.g=!0}On.prototype.xa=function(){this.g=!1};function Jh(i,c,h,f,I,R){i.info(function(){if(i.g)if(R)for(var D="",Z=R.split("&"),fe=0;fe<Z.length;fe++){var X=Z[fe].split("=");if(1<X.length){var ve=X[0];X=X[1];var Ee=ve.split("_");D=2<=Ee.length&&Ee[1]=="type"?D+(ve+"="+X+"&"):D+(ve+"=redacted&")}}else D=null;else D=R;return"XMLHTTP REQ ("+f+") [attempt "+I+"]: "+c+`
1561
+ `+h+`
1562
+ `+D})}function Xh(i,c,h,f,I,R,D){i.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+I+"]: "+c+`
1563
+ `+h+`
1564
+ `+R+" "+D})}function Gt(i,c,h,f){i.info(function(){return"XMLHTTP TEXT ("+c+"): "+Zh(i,h)+(f?" "+f:"")})}function Yh(i,c){i.info(function(){return"TIMEOUT: "+c})}On.prototype.info=function(){};function Zh(i,c){if(!i.g)return c;if(!c)return null;try{var h=JSON.parse(c);if(h){for(i=0;i<h.length;i++)if(Array.isArray(h[i])){var f=h[i];if(!(2>f.length)){var I=f[1];if(Array.isArray(I)&&!(1>I.length)){var R=I[0];if(R!="noop"&&R!="stop"&&R!="close")for(var D=1;D<I.length;D++)I[D]=""}}}}return Gs(h)}catch{return c}}var br={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},ea={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Xs;function Rr(){}V(Rr,Ks),Rr.prototype.g=function(){return new XMLHttpRequest},Rr.prototype.i=function(){return{}},Xs=new Rr;function ct(i,c,h,f){this.j=i,this.i=c,this.l=h,this.R=f||1,this.U=new Sn(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new ta}function ta(){this.i=null,this.g="",this.h=!1}var na={},Ys={};function Zs(i,c,h){i.L=1,i.v=kr(Ke(c)),i.m=h,i.P=!0,ra(i,null)}function ra(i,c){i.F=Date.now(),Sr(i),i.A=Ke(i.v);var h=i.A,f=i.R;Array.isArray(f)||(f=[String(f)]),_a(h.i,"t",f),i.C=0,h=i.j.J,i.h=new ta,i.g=Ma(i.j,h?c:null,!i.m),0<i.O&&(i.M=new Gh(E(i.Y,i,i.g),i.O)),c=i.U,h=i.g,f=i.ca;var I="readystatechange";Array.isArray(I)||(I&&(Wo[0]=I.toString()),I=Wo);for(var R=0;R<I.length;R++){var D=jo(h,I[R],f||c.handleEvent,!1,c.h||c);if(!D)break;c.g[D.key]=D}c=i.H?m(i.H):{},i.m?(i.u||(i.u="POST"),c["Content-Type"]="application/x-www-form-urlencoded",i.g.ea(i.A,i.u,i.m,c)):(i.u="GET",i.g.ea(i.A,i.u,null,c)),Pn(),Jh(i.i,i.u,i.A,i.l,i.R,i.m)}ct.prototype.ca=function(i){i=i.target;const c=this.M;c&&Qe(i)==3?c.j():this.Y(i)},ct.prototype.Y=function(i){try{if(i==this.g)e:{const Ee=Qe(this.g);var c=this.g.Ba();const Jt=this.g.Z();if(!(3>Ee)&&(Ee!=3||this.g&&(this.h.h||this.g.oa()||Aa(this.g)))){this.J||Ee!=4||c==7||(c==8||0>=Jt?Pn(3):Pn(2)),ei(this);var h=this.g.Z();this.X=h;t:if(sa(this)){var f=Aa(this.g);i="";var I=f.length,R=Qe(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Dt(this),Dn(this);var D="";break t}this.h.i=new u.TextDecoder}for(c=0;c<I;c++)this.h.h=!0,i+=this.h.i.decode(f[c],{stream:!(R&&c==I-1)});f.length=0,this.h.g+=i,this.C=0,D=this.h.g}else D=this.g.oa();if(this.o=h==200,Xh(this.i,this.u,this.A,this.l,this.R,Ee,h),this.o){if(this.T&&!this.K){t:{if(this.g){var Z,fe=this.g;if((Z=fe.g?fe.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!z(Z)){var X=Z;break t}}X=null}if(h=X)Gt(this.i,this.l,h,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,ti(this,h);else{this.o=!1,this.s=3,Re(12),Dt(this),Dn(this);break e}}if(this.P){h=!0;let Ve;for(;!this.J&&this.C<D.length;)if(Ve=ed(this,D),Ve==Ys){Ee==4&&(this.s=4,Re(14),h=!1),Gt(this.i,this.l,null,"[Incomplete Response]");break}else if(Ve==na){this.s=4,Re(15),Gt(this.i,this.l,D,"[Invalid Chunk]"),h=!1;break}else Gt(this.i,this.l,Ve,null),ti(this,Ve);if(sa(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ee!=4||D.length!=0||this.h.h||(this.s=1,Re(16),h=!1),this.o=this.o&&h,!h)Gt(this.i,this.l,D,"[Invalid Chunked Response]"),Dt(this),Dn(this);else if(0<D.length&&!this.W){this.W=!0;var ve=this.j;ve.g==this&&ve.ba&&!ve.M&&(ve.j.info("Great, no buffering proxy detected. Bytes received: "+D.length),ai(ve),ve.M=!0,Re(11))}}else Gt(this.i,this.l,D,null),ti(this,D);Ee==4&&Dt(this),this.o&&!this.J&&(Ee==4?Oa(this.j,this):(this.o=!1,Sr(this)))}else _d(this.g),h==400&&0<D.indexOf("Unknown SID")?(this.s=3,Re(12)):(this.s=0,Re(13)),Dt(this),Dn(this)}}}catch{}finally{}};function sa(i){return i.g?i.u=="GET"&&i.L!=2&&i.j.Ca:!1}function ed(i,c){var h=i.C,f=c.indexOf(`
1565
+ `,h);return f==-1?Ys:(h=Number(c.substring(h,f)),isNaN(h)?na:(f+=1,f+h>c.length?Ys:(c=c.slice(f,f+h),i.C=f+h,c)))}ct.prototype.cancel=function(){this.J=!0,Dt(this)};function Sr(i){i.S=Date.now()+i.I,ia(i,i.I)}function ia(i,c){if(i.B!=null)throw Error("WatchDog timer not null");i.B=kn(E(i.ba,i),c)}function ei(i){i.B&&(u.clearTimeout(i.B),i.B=null)}ct.prototype.ba=function(){this.B=null;const i=Date.now();0<=i-this.S?(Yh(this.i,this.A),this.L!=2&&(Pn(),Re(17)),Dt(this),this.s=2,Dn(this)):ia(this,this.S-i)};function Dn(i){i.j.G==0||i.J||Oa(i.j,i)}function Dt(i){ei(i);var c=i.M;c&&typeof c.ma=="function"&&c.ma(),i.M=null,Go(i.U),i.g&&(c=i.g,i.g=null,c.abort(),c.ma())}function ti(i,c){try{var h=i.j;if(h.G!=0&&(h.g==i||ni(h.h,i))){if(!i.K&&ni(h.h,i)&&h.G==3){try{var f=h.Da.g.parse(c)}catch{f=null}if(Array.isArray(f)&&f.length==3){var I=f;if(I[0]==0){e:if(!h.u){if(h.g)if(h.g.F+3e3<i.F)Lr(h),Vr(h);else break e;oi(h),Re(18)}}else h.za=I[1],0<h.za-h.T&&37500>I[2]&&h.F&&h.v==0&&!h.C&&(h.C=kn(E(h.Za,h),6e3));if(1>=ca(h.h)&&h.ca){try{h.ca()}catch{}h.ca=void 0}}else Vt(h,11)}else if((i.K||h.g==i)&&Lr(h),!z(c))for(I=h.Da.g.parse(c),c=0;c<I.length;c++){let X=I[c];if(h.T=X[0],X=X[1],h.G==2)if(X[0]=="c"){h.K=X[1],h.ia=X[2];const ve=X[3];ve!=null&&(h.la=ve,h.j.info("VER="+h.la));const Ee=X[4];Ee!=null&&(h.Aa=Ee,h.j.info("SVER="+h.Aa));const Jt=X[5];Jt!=null&&typeof Jt=="number"&&0<Jt&&(f=1.5*Jt,h.L=f,h.j.info("backChannelRequestTimeoutMs_="+f)),f=h;const Ve=i.g;if(Ve){const Ur=Ve.g?Ve.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Ur){var R=f.h;R.g||Ur.indexOf("spdy")==-1&&Ur.indexOf("quic")==-1&&Ur.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(ri(R,R.h),R.h=null))}if(f.D){const ci=Ve.g?Ve.g.getResponseHeader("X-HTTP-Session-Id"):null;ci&&(f.ya=ci,ee(f.I,f.D,ci))}}h.G=3,h.l&&h.l.ua(),h.ba&&(h.R=Date.now()-i.F,h.j.info("Handshake RTT: "+h.R+"ms")),f=h;var D=i;if(f.qa=Va(f,f.J?f.ia:null,f.W),D.K){ua(f.h,D);var Z=D,fe=f.L;fe&&(Z.I=fe),Z.B&&(ei(Z),Sr(Z)),f.g=D}else Pa(f);0<h.i.length&&Mr(h)}else X[0]!="stop"&&X[0]!="close"||Vt(h,7);else h.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Vt(h,7):ii(h):X[0]!="noop"&&h.l&&h.l.ta(X),h.v=0)}}Pn(4)}catch{}}var td=class{constructor(i,c){this.g=i,this.map=c}};function oa(i){this.l=i||10,u.PerformanceNavigationTiming?(i=u.performance.getEntriesByType("navigation"),i=0<i.length&&(i[0].nextHopProtocol=="hq"||i[0].nextHopProtocol=="h2")):i=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=i?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function aa(i){return i.h?!0:i.g?i.g.size>=i.j:!1}function ca(i){return i.h?1:i.g?i.g.size:0}function ni(i,c){return i.h?i.h==c:i.g?i.g.has(c):!1}function ri(i,c){i.g?i.g.add(c):i.h=c}function ua(i,c){i.h&&i.h==c?i.h=null:i.g&&i.g.has(c)&&i.g.delete(c)}oa.prototype.cancel=function(){if(this.i=la(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const i of this.g.values())i.cancel();this.g.clear()}};function la(i){if(i.h!=null)return i.i.concat(i.h.D);if(i.g!=null&&i.g.size!==0){let c=i.i;for(const h of i.g.values())c=c.concat(h.D);return c}return M(i.i)}function nd(i){if(i.V&&typeof i.V=="function")return i.V();if(typeof Map<"u"&&i instanceof Map||typeof Set<"u"&&i instanceof Set)return Array.from(i.values());if(typeof i=="string")return i.split("");if(l(i)){for(var c=[],h=i.length,f=0;f<h;f++)c.push(i[f]);return c}c=[],h=0;for(f in i)c[h++]=i[f];return c}function rd(i){if(i.na&&typeof i.na=="function")return i.na();if(!i.V||typeof i.V!="function"){if(typeof Map<"u"&&i instanceof Map)return Array.from(i.keys());if(!(typeof Set<"u"&&i instanceof Set)){if(l(i)||typeof i=="string"){var c=[];i=i.length;for(var h=0;h<i;h++)c.push(h);return c}c=[],h=0;for(const f in i)c[h++]=f;return c}}}function ha(i,c){if(i.forEach&&typeof i.forEach=="function")i.forEach(c,void 0);else if(l(i)||typeof i=="string")Array.prototype.forEach.call(i,c,void 0);else for(var h=rd(i),f=nd(i),I=f.length,R=0;R<I;R++)c.call(void 0,f[R],h&&h[R],i)}var da=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function sd(i,c){if(i){i=i.split("&");for(var h=0;h<i.length;h++){var f=i[h].indexOf("="),I=null;if(0<=f){var R=i[h].substring(0,f);I=i[h].substring(f+1)}else R=i[h];c(R,I?decodeURIComponent(I.replace(/\+/g," ")):"")}}}function Nt(i){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,i instanceof Nt){this.h=i.h,Cr(this,i.j),this.o=i.o,this.g=i.g,Pr(this,i.s),this.l=i.l;var c=i.i,h=new Mn;h.i=c.i,c.g&&(h.g=new Map(c.g),h.h=c.h),fa(this,h),this.m=i.m}else i&&(c=String(i).match(da))?(this.h=!1,Cr(this,c[1]||"",!0),this.o=Nn(c[2]||""),this.g=Nn(c[3]||"",!0),Pr(this,c[4]),this.l=Nn(c[5]||"",!0),fa(this,c[6]||"",!0),this.m=Nn(c[7]||"")):(this.h=!1,this.i=new Mn(null,this.h))}Nt.prototype.toString=function(){var i=[],c=this.j;c&&i.push(Vn(c,pa,!0),":");var h=this.g;return(h||c=="file")&&(i.push("//"),(c=this.o)&&i.push(Vn(c,pa,!0),"@"),i.push(encodeURIComponent(String(h)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.s,h!=null&&i.push(":",String(h))),(h=this.l)&&(this.g&&h.charAt(0)!="/"&&i.push("/"),i.push(Vn(h,h.charAt(0)=="/"?ad:od,!0))),(h=this.i.toString())&&i.push("?",h),(h=this.m)&&i.push("#",Vn(h,ud)),i.join("")};function Ke(i){return new Nt(i)}function Cr(i,c,h){i.j=h?Nn(c,!0):c,i.j&&(i.j=i.j.replace(/:$/,""))}function Pr(i,c){if(c){if(c=Number(c),isNaN(c)||0>c)throw Error("Bad port number "+c);i.s=c}else i.s=null}function fa(i,c,h){c instanceof Mn?(i.i=c,ld(i.i,i.h)):(h||(c=Vn(c,cd)),i.i=new Mn(c,i.h))}function ee(i,c,h){i.i.set(c,h)}function kr(i){return ee(i,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),i}function Nn(i,c){return i?c?decodeURI(i.replace(/%25/g,"%2525")):decodeURIComponent(i):""}function Vn(i,c,h){return typeof i=="string"?(i=encodeURI(i).replace(c,id),h&&(i=i.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),i):null}function id(i){return i=i.charCodeAt(0),"%"+(i>>4&15).toString(16)+(i&15).toString(16)}var pa=/[#\/\?@]/g,od=/[#\?:]/g,ad=/[#\?]/g,cd=/[#\?@]/g,ud=/#/g;function Mn(i,c){this.h=this.g=null,this.i=i||null,this.j=!!c}function ut(i){i.g||(i.g=new Map,i.h=0,i.i&&sd(i.i,function(c,h){i.add(decodeURIComponent(c.replace(/\+/g," ")),h)}))}n=Mn.prototype,n.add=function(i,c){ut(this),this.i=null,i=Kt(this,i);var h=this.g.get(i);return h||this.g.set(i,h=[]),h.push(c),this.h+=1,this};function ma(i,c){ut(i),c=Kt(i,c),i.g.has(c)&&(i.i=null,i.h-=i.g.get(c).length,i.g.delete(c))}function ga(i,c){return ut(i),c=Kt(i,c),i.g.has(c)}n.forEach=function(i,c){ut(this),this.g.forEach(function(h,f){h.forEach(function(I){i.call(c,I,f,this)},this)},this)},n.na=function(){ut(this);const i=Array.from(this.g.values()),c=Array.from(this.g.keys()),h=[];for(let f=0;f<c.length;f++){const I=i[f];for(let R=0;R<I.length;R++)h.push(c[f])}return h},n.V=function(i){ut(this);let c=[];if(typeof i=="string")ga(this,i)&&(c=c.concat(this.g.get(Kt(this,i))));else{i=Array.from(this.g.values());for(let h=0;h<i.length;h++)c=c.concat(i[h])}return c},n.set=function(i,c){return ut(this),this.i=null,i=Kt(this,i),ga(this,i)&&(this.h-=this.g.get(i).length),this.g.set(i,[c]),this.h+=1,this},n.get=function(i,c){return i?(i=this.V(i),0<i.length?String(i[0]):c):c};function _a(i,c,h){ma(i,c),0<h.length&&(i.i=null,i.g.set(Kt(i,c),M(h)),i.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const i=[],c=Array.from(this.g.keys());for(var h=0;h<c.length;h++){var f=c[h];const R=encodeURIComponent(String(f)),D=this.V(f);for(f=0;f<D.length;f++){var I=R;D[f]!==""&&(I+="="+encodeURIComponent(String(D[f]))),i.push(I)}}return this.i=i.join("&")};function Kt(i,c){return c=String(c),i.j&&(c=c.toLowerCase()),c}function ld(i,c){c&&!i.j&&(ut(i),i.i=null,i.g.forEach(function(h,f){var I=f.toLowerCase();f!=I&&(ma(this,f),_a(this,I,h))},i)),i.j=c}function hd(i,c){const h=new On;if(u.Image){const f=new Image;f.onload=C(lt,h,"TestLoadImage: loaded",!0,c,f),f.onerror=C(lt,h,"TestLoadImage: error",!1,c,f),f.onabort=C(lt,h,"TestLoadImage: abort",!1,c,f),f.ontimeout=C(lt,h,"TestLoadImage: timeout",!1,c,f),u.setTimeout(function(){f.ontimeout&&f.ontimeout()},1e4),f.src=i}else c(!1)}function dd(i,c){const h=new On,f=new AbortController,I=setTimeout(()=>{f.abort(),lt(h,"TestPingServer: timeout",!1,c)},1e4);fetch(i,{signal:f.signal}).then(R=>{clearTimeout(I),R.ok?lt(h,"TestPingServer: ok",!0,c):lt(h,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(I),lt(h,"TestPingServer: error",!1,c)})}function lt(i,c,h,f,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),f(h)}catch{}}function fd(){this.g=new Qh}function pd(i,c,h){const f=h||"";try{ha(i,function(I,R){let D=I;d(I)&&(D=Gs(I)),c.push(f+R+"="+encodeURIComponent(D))})}catch(I){throw c.push(f+"type="+encodeURIComponent("_badmap")),I}}function Or(i){this.l=i.Ub||null,this.j=i.eb||!1}V(Or,Ks),Or.prototype.g=function(){return new Dr(this.l,this.j)},Or.prototype.i=(function(i){return function(){return i}})({});function Dr(i,c){ye.call(this),this.D=i,this.o=c,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}V(Dr,ye),n=Dr.prototype,n.open=function(i,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=i,this.A=c,this.readyState=1,xn(this)},n.send=function(i){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const c={headers:this.u,method:this.B,credentials:this.m,cache:void 0};i&&(c.body=i),(this.D||u).fetch(new Request(this.A,c)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Ln(this)),this.readyState=0},n.Sa=function(i){if(this.g&&(this.l=i,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=i.headers,this.readyState=2,xn(this)),this.g&&(this.readyState=3,xn(this),this.g)))if(this.responseType==="arraybuffer")i.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in i){if(this.j=i.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;ya(this)}else i.text().then(this.Ra.bind(this),this.ga.bind(this))};function ya(i){i.j.read().then(i.Pa.bind(i)).catch(i.ga.bind(i))}n.Pa=function(i){if(this.g){if(this.o&&i.value)this.response.push(i.value);else if(!this.o){var c=i.value?i.value:new Uint8Array(0);(c=this.v.decode(c,{stream:!i.done}))&&(this.response=this.responseText+=c)}i.done?Ln(this):xn(this),this.readyState==3&&ya(this)}},n.Ra=function(i){this.g&&(this.response=this.responseText=i,Ln(this))},n.Qa=function(i){this.g&&(this.response=i,Ln(this))},n.ga=function(){this.g&&Ln(this)};function Ln(i){i.readyState=4,i.l=null,i.j=null,i.v=null,xn(i)}n.setRequestHeader=function(i,c){this.u.append(i,c)},n.getResponseHeader=function(i){return this.h&&this.h.get(i.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const i=[],c=this.h.entries();for(var h=c.next();!h.done;)h=h.value,i.push(h[0]+": "+h[1]),h=c.next();return i.join(`\r
1566
+ `)};function xn(i){i.onreadystatechange&&i.onreadystatechange.call(i)}Object.defineProperty(Dr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(i){this.m=i?"include":"same-origin"}});function va(i){let c="";return P(i,function(h,f){c+=f,c+=":",c+=h,c+=`\r
1567
+ `}),c}function si(i,c,h){e:{for(f in h){var f=!1;break e}f=!0}f||(h=va(h),typeof i=="string"?h!=null&&encodeURIComponent(String(h)):ee(i,c,h))}function re(i){ye.call(this),this.headers=new Map,this.o=i||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}V(re,ye);var md=/^https?$/i,gd=["POST","PUT"];n=re.prototype,n.Ha=function(i){this.J=i},n.ea=function(i,c,h,f){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+i);c=c?c.toUpperCase():"GET",this.D=i,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Xs.g(),this.v=this.o?Ko(this.o):Ko(Xs),this.g.onreadystatechange=E(this.Ea,this);try{this.B=!0,this.g.open(c,String(i),!0),this.B=!1}catch(R){Ea(this,R);return}if(i=h||"",h=new Map(this.headers),f)if(Object.getPrototypeOf(f)===Object.prototype)for(var I in f)h.set(I,f[I]);else if(typeof f.keys=="function"&&typeof f.get=="function")for(const R of f.keys())h.set(R,f.get(R));else throw Error("Unknown input type for opt_headers: "+String(f));f=Array.from(h.keys()).find(R=>R.toLowerCase()=="content-type"),I=u.FormData&&i instanceof u.FormData,!(0<=Array.prototype.indexOf.call(gd,c,void 0))||f||I||h.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,D]of h)this.g.setRequestHeader(R,D);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Ia(this),this.u=!0,this.g.send(i),this.u=!1}catch(R){Ea(this,R)}};function Ea(i,c){i.h=!1,i.g&&(i.j=!0,i.g.abort(),i.j=!1),i.l=c,i.m=5,Ta(i),Nr(i)}function Ta(i){i.A||(i.A=!0,be(i,"complete"),be(i,"error"))}n.abort=function(i){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=i||7,be(this,"complete"),be(this,"abort"),Nr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Nr(this,!0)),re.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?wa(this):this.bb())},n.bb=function(){wa(this)};function wa(i){if(i.h&&typeof a<"u"&&(!i.v[1]||Qe(i)!=4||i.Z()!=2)){if(i.u&&Qe(i)==4)zo(i.Ea,0,i);else if(be(i,"readystatechange"),Qe(i)==4){i.h=!1;try{const D=i.Z();e:switch(D){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break e;default:c=!1}var h;if(!(h=c)){var f;if(f=D===0){var I=String(i.D).match(da)[1]||null;!I&&u.self&&u.self.location&&(I=u.self.location.protocol.slice(0,-1)),f=!md.test(I?I.toLowerCase():"")}h=f}if(h)be(i,"complete"),be(i,"success");else{i.m=6;try{var R=2<Qe(i)?i.g.statusText:""}catch{R=""}i.l=R+" ["+i.Z()+"]",Ta(i)}}finally{Nr(i)}}}}function Nr(i,c){if(i.g){Ia(i);const h=i.g,f=i.v[0]?()=>{}:null;i.g=null,i.v=null,c||be(i,"ready");try{h.onreadystatechange=f}catch{}}}function Ia(i){i.I&&(u.clearTimeout(i.I),i.I=null)}n.isActive=function(){return!!this.g};function Qe(i){return i.g?i.g.readyState:0}n.Z=function(){try{return 2<Qe(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(i){if(this.g){var c=this.g.responseText;return i&&c.indexOf(i)==0&&(c=c.substring(i.length)),Kh(c)}};function Aa(i){try{if(!i.g)return null;if("response"in i.g)return i.g.response;switch(i.H){case"":case"text":return i.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in i.g)return i.g.mozResponseArrayBuffer}return null}catch{return null}}function _d(i){const c={};i=(i.g&&2<=Qe(i)&&i.g.getAllResponseHeaders()||"").split(`\r
1568
+ `);for(let f=0;f<i.length;f++){if(z(i[f]))continue;var h=w(i[f]);const I=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const R=c[I]||[];c[I]=R,R.push(h)}_(c,function(f){return f.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Un(i,c,h){return h&&h.internalChannelParams&&h.internalChannelParams[i]||c}function ba(i){this.Aa=0,this.i=[],this.j=new On,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Un("failFast",!1,i),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Un("baseRetryDelayMs",5e3,i),this.cb=Un("retryDelaySeedMs",1e4,i),this.Wa=Un("forwardChannelMaxRetries",2,i),this.wa=Un("forwardChannelRequestTimeoutMs",2e4,i),this.pa=i&&i.xmlHttpFactory||void 0,this.Xa=i&&i.Tb||void 0,this.Ca=i&&i.useFetchStreams||!1,this.L=void 0,this.J=i&&i.supportsCrossDomainXhr||!1,this.K="",this.h=new oa(i&&i.concurrentRequestLimit),this.Da=new fd,this.P=i&&i.fastHandshake||!1,this.O=i&&i.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=i&&i.Rb||!1,i&&i.xa&&this.j.xa(),i&&i.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&i&&i.detectBufferingProxy||!1,this.ja=void 0,i&&i.longPollingTimeout&&0<i.longPollingTimeout&&(this.ja=i.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=ba.prototype,n.la=8,n.G=1,n.connect=function(i,c,h,f){Re(0),this.W=i,this.H=c||{},h&&f!==void 0&&(this.H.OSID=h,this.H.OAID=f),this.F=this.X,this.I=Va(this,null,this.W),Mr(this)};function ii(i){if(Ra(i),i.G==3){var c=i.U++,h=Ke(i.I);if(ee(h,"SID",i.K),ee(h,"RID",c),ee(h,"TYPE","terminate"),Fn(i,h),c=new ct(i,i.j,c),c.L=2,c.v=kr(Ke(h)),h=!1,u.navigator&&u.navigator.sendBeacon)try{h=u.navigator.sendBeacon(c.v.toString(),"")}catch{}!h&&u.Image&&(new Image().src=c.v,h=!0),h||(c.g=Ma(c.j,null),c.g.ea(c.v)),c.F=Date.now(),Sr(c)}Na(i)}function Vr(i){i.g&&(ai(i),i.g.cancel(),i.g=null)}function Ra(i){Vr(i),i.u&&(u.clearTimeout(i.u),i.u=null),Lr(i),i.h.cancel(),i.s&&(typeof i.s=="number"&&u.clearTimeout(i.s),i.s=null)}function Mr(i){if(!aa(i.h)&&!i.s){i.s=!0;var c=i.Ga;An||Fo(),bn||(An(),bn=!0),Fs.add(c,i),i.B=0}}function yd(i,c){return ca(i.h)>=i.h.j-(i.s?1:0)?!1:i.s?(i.i=c.D.concat(i.i),!0):i.G==1||i.G==2||i.B>=(i.Va?0:i.Wa)?!1:(i.s=kn(E(i.Ga,i,c),Da(i,i.B)),i.B++,!0)}n.Ga=function(i){if(this.s)if(this.s=null,this.G==1){if(!i){this.U=Math.floor(1e5*Math.random()),i=this.U++;const I=new ct(this,this.j,i);let R=this.o;if(this.S&&(R?(R=m(R),T(R,this.S)):R=this.S),this.m!==null||this.O||(I.H=R,R=null),this.P)e:{for(var c=0,h=0;h<this.i.length;h++){t:{var f=this.i[h];if("__data__"in f.map&&(f=f.map.__data__,typeof f=="string")){f=f.length;break t}f=void 0}if(f===void 0)break;if(c+=f,4096<c){c=h;break e}if(c===4096||h===this.i.length-1){c=h+1;break e}}c=1e3}else c=1e3;c=Ca(this,I,c),h=Ke(this.I),ee(h,"RID",i),ee(h,"CVER",22),this.D&&ee(h,"X-HTTP-Session-Id",this.D),Fn(this,h),R&&(this.O?c="headers="+encodeURIComponent(String(va(R)))+"&"+c:this.m&&si(h,this.m,R)),ri(this.h,I),this.Ua&&ee(h,"TYPE","init"),this.P?(ee(h,"$req",c),ee(h,"SID","null"),I.T=!0,Zs(I,h,null)):Zs(I,h,c),this.G=2}}else this.G==3&&(i?Sa(this,i):this.i.length==0||aa(this.h)||Sa(this))};function Sa(i,c){var h;c?h=c.l:h=i.U++;const f=Ke(i.I);ee(f,"SID",i.K),ee(f,"RID",h),ee(f,"AID",i.T),Fn(i,f),i.m&&i.o&&si(f,i.m,i.o),h=new ct(i,i.j,h,i.B+1),i.m===null&&(h.H=i.o),c&&(i.i=c.D.concat(i.i)),c=Ca(i,h,1e3),h.I=Math.round(.5*i.wa)+Math.round(.5*i.wa*Math.random()),ri(i.h,h),Zs(h,f,c)}function Fn(i,c){i.H&&P(i.H,function(h,f){ee(c,f,h)}),i.l&&ha({},function(h,f){ee(c,f,h)})}function Ca(i,c,h){h=Math.min(i.i.length,h);var f=i.l?E(i.l.Na,i.l,i):null;e:{var I=i.i;let R=-1;for(;;){const D=["count="+h];R==-1?0<h?(R=I[0].g,D.push("ofs="+R)):R=0:D.push("ofs="+R);let Z=!0;for(let fe=0;fe<h;fe++){let X=I[fe].g;const ve=I[fe].map;if(X-=R,0>X)R=Math.max(0,I[fe].g-100),Z=!1;else try{pd(ve,D,"req"+X+"_")}catch{f&&f(ve)}}if(Z){f=D.join("&");break e}}}return i=i.i.splice(0,h),c.D=i,f}function Pa(i){if(!i.g&&!i.u){i.Y=1;var c=i.Fa;An||Fo(),bn||(An(),bn=!0),Fs.add(c,i),i.v=0}}function oi(i){return i.g||i.u||3<=i.v?!1:(i.Y++,i.u=kn(E(i.Fa,i),Da(i,i.v)),i.v++,!0)}n.Fa=function(){if(this.u=null,ka(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var i=2*this.R;this.j.info("BP detection timer enabled: "+i),this.A=kn(E(this.ab,this),i)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Re(10),Vr(this),ka(this))};function ai(i){i.A!=null&&(u.clearTimeout(i.A),i.A=null)}function ka(i){i.g=new ct(i,i.j,"rpc",i.Y),i.m===null&&(i.g.H=i.o),i.g.O=0;var c=Ke(i.qa);ee(c,"RID","rpc"),ee(c,"SID",i.K),ee(c,"AID",i.T),ee(c,"CI",i.F?"0":"1"),!i.F&&i.ja&&ee(c,"TO",i.ja),ee(c,"TYPE","xmlhttp"),Fn(i,c),i.m&&i.o&&si(c,i.m,i.o),i.L&&(i.g.I=i.L);var h=i.g;i=i.ia,h.L=1,h.v=kr(Ke(c)),h.m=null,h.P=!0,ra(h,i)}n.Za=function(){this.C!=null&&(this.C=null,Vr(this),oi(this),Re(19))};function Lr(i){i.C!=null&&(u.clearTimeout(i.C),i.C=null)}function Oa(i,c){var h=null;if(i.g==c){Lr(i),ai(i),i.g=null;var f=2}else if(ni(i.h,c))h=c.D,ua(i.h,c),f=1;else return;if(i.G!=0){if(c.o)if(f==1){h=c.m?c.m.length:0,c=Date.now()-c.F;var I=i.B;f=Ar(),be(f,new Zo(f,h)),Mr(i)}else Pa(i);else if(I=c.s,I==3||I==0&&0<c.X||!(f==1&&yd(i,c)||f==2&&oi(i)))switch(h&&0<h.length&&(c=i.h,c.i=c.i.concat(h)),I){case 1:Vt(i,5);break;case 4:Vt(i,10);break;case 3:Vt(i,6);break;default:Vt(i,2)}}}function Da(i,c){let h=i.Ta+Math.floor(Math.random()*i.cb);return i.isActive()||(h*=2),h*c}function Vt(i,c){if(i.j.info("Error code "+c),c==2){var h=E(i.fb,i),f=i.Xa;const I=!f;f=new Nt(f||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||Cr(f,"https"),kr(f),I?hd(f.toString(),h):dd(f.toString(),h)}else Re(2);i.G=0,i.l&&i.l.sa(c),Na(i),Ra(i)}n.fb=function(i){i?(this.j.info("Successfully pinged google.com"),Re(2)):(this.j.info("Failed to ping google.com"),Re(1))};function Na(i){if(i.G=0,i.ka=[],i.l){const c=la(i.h);(c.length!=0||i.i.length!=0)&&(k(i.ka,c),k(i.ka,i.i),i.h.i.length=0,M(i.i),i.i.length=0),i.l.ra()}}function Va(i,c,h){var f=h instanceof Nt?Ke(h):new Nt(h);if(f.g!="")c&&(f.g=c+"."+f.g),Pr(f,f.s);else{var I=u.location;f=I.protocol,c=c?c+"."+I.hostname:I.hostname,I=+I.port;var R=new Nt(null);f&&Cr(R,f),c&&(R.g=c),I&&Pr(R,I),h&&(R.l=h),f=R}return h=i.D,c=i.ya,h&&c&&ee(f,h,c),ee(f,"VER",i.la),Fn(i,f),f}function Ma(i,c,h){if(c&&!i.J)throw Error("Can't create secondary domain capable XhrIo object.");return c=i.Ca&&!i.pa?new re(new Or({eb:h})):new re(i.pa),c.Ha(i.J),c}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function La(){}n=La.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function xr(){}xr.prototype.g=function(i,c){return new Oe(i,c)};function Oe(i,c){ye.call(this),this.g=new ba(c),this.l=i,this.h=c&&c.messageUrlParams||null,i=c&&c.messageHeaders||null,c&&c.clientProtocolHeaderRequired&&(i?i["X-Client-Protocol"]="webchannel":i={"X-Client-Protocol":"webchannel"}),this.g.o=i,i=c&&c.initMessageHeaders||null,c&&c.messageContentType&&(i?i["X-WebChannel-Content-Type"]=c.messageContentType:i={"X-WebChannel-Content-Type":c.messageContentType}),c&&c.va&&(i?i["X-WebChannel-Client-Profile"]=c.va:i={"X-WebChannel-Client-Profile":c.va}),this.g.S=i,(i=c&&c.Sb)&&!z(i)&&(this.g.m=i),this.v=c&&c.supportsCrossDomainXhr||!1,this.u=c&&c.sendRawJson||!1,(c=c&&c.httpSessionIdParam)&&!z(c)&&(this.g.D=c,i=this.h,i!==null&&c in i&&(i=this.h,c in i&&delete i[c])),this.j=new Qt(this)}V(Oe,ye),Oe.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Oe.prototype.close=function(){ii(this.g)},Oe.prototype.o=function(i){var c=this.g;if(typeof i=="string"){var h={};h.__data__=i,i=h}else this.u&&(h={},h.__data__=Gs(i),i=h);c.i.push(new td(c.Ya++,i)),c.G==3&&Mr(c)},Oe.prototype.N=function(){this.g.l=null,delete this.j,ii(this.g),delete this.g,Oe.aa.N.call(this)};function xa(i){Qs.call(this),i.__headers__&&(this.headers=i.__headers__,this.statusCode=i.__status__,delete i.__headers__,delete i.__status__);var c=i.__sm__;if(c){e:{for(const h in c){i=h;break e}i=void 0}(this.i=i)&&(i=this.i,c=c!==null&&i in c?c[i]:void 0),this.data=c}else this.data=i}V(xa,Qs);function Ua(){Js.call(this),this.status=1}V(Ua,Js);function Qt(i){this.g=i}V(Qt,La),Qt.prototype.ua=function(){be(this.g,"a")},Qt.prototype.ta=function(i){be(this.g,new xa(i))},Qt.prototype.sa=function(i){be(this.g,new Ua)},Qt.prototype.ra=function(){be(this.g,"b")},xr.prototype.createWebChannel=xr.prototype.g,Oe.prototype.send=Oe.prototype.o,Oe.prototype.open=Oe.prototype.m,Oe.prototype.close=Oe.prototype.close,Cl=function(){return new xr},Sl=function(){return Ar()},Rl=Ot,Ni={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},br.NO_ERROR=0,br.TIMEOUT=8,br.HTTP_ERROR=6,Jr=br,ea.COMPLETE="complete",bl=ea,Qo.EventType=Cn,Cn.OPEN="a",Cn.CLOSE="b",Cn.ERROR="c",Cn.MESSAGE="d",ye.prototype.listen=ye.prototype.K,$n=Qo,re.prototype.listenOnce=re.prototype.L,re.prototype.getLastError=re.prototype.Ka,re.prototype.getLastErrorCode=re.prototype.Ba,re.prototype.getStatus=re.prototype.Z,re.prototype.getResponseJson=re.prototype.Oa,re.prototype.getResponseText=re.prototype.oa,re.prototype.send=re.prototype.ea,re.prototype.setWithCredentials=re.prototype.Ha,Al=re}).apply(typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{});const bc="@firebase/firestore",Rc="4.8.0";/**
1569
+ * @license
1570
+ * Copyright 2017 Google LLC
1571
+ *
1572
+ * Licensed under the Apache License, Version 2.0 (the "License");
1573
+ * you may not use this file except in compliance with the License.
1574
+ * You may obtain a copy of the License at
1575
+ *
1576
+ * http://www.apache.org/licenses/LICENSE-2.0
1577
+ *
1578
+ * Unless required by applicable law or agreed to in writing, software
1579
+ * distributed under the License is distributed on an "AS IS" BASIS,
1580
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1581
+ * See the License for the specific language governing permissions and
1582
+ * limitations under the License.
1583
+ */class we{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}we.UNAUTHENTICATED=new we(null),we.GOOGLE_CREDENTIALS=new we("google-credentials-uid"),we.FIRST_PARTY=new we("first-party-uid"),we.MOCK_USER=new we("mock-user");/**
1584
+ * @license
1585
+ * Copyright 2017 Google LLC
1586
+ *
1587
+ * Licensed under the Apache License, Version 2.0 (the "License");
1588
+ * you may not use this file except in compliance with the License.
1589
+ * You may obtain a copy of the License at
1590
+ *
1591
+ * http://www.apache.org/licenses/LICENSE-2.0
1592
+ *
1593
+ * Unless required by applicable law or agreed to in writing, software
1594
+ * distributed under the License is distributed on an "AS IS" BASIS,
1595
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1596
+ * See the License for the specific language governing permissions and
1597
+ * limitations under the License.
1598
+ */let En="11.10.0";/**
1599
+ * @license
1600
+ * Copyright 2017 Google LLC
1601
+ *
1602
+ * Licensed under the Apache License, Version 2.0 (the "License");
1603
+ * you may not use this file except in compliance with the License.
1604
+ * You may obtain a copy of the License at
1605
+ *
1606
+ * http://www.apache.org/licenses/LICENSE-2.0
1607
+ *
1608
+ * Unless required by applicable law or agreed to in writing, software
1609
+ * distributed under the License is distributed on an "AS IS" BASIS,
1610
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1611
+ * See the License for the specific language governing permissions and
1612
+ * limitations under the License.
1613
+ */const Ht=new Zi("@firebase/firestore");function Yt(){return Ht.logLevel}function L(n,...e){if(Ht.logLevel<=G.DEBUG){const t=e.map(po);Ht.debug(`Firestore (${En}): ${n}`,...t)}}function nt(n,...e){if(Ht.logLevel<=G.ERROR){const t=e.map(po);Ht.error(`Firestore (${En}): ${n}`,...t)}}function It(n,...e){if(Ht.logLevel<=G.WARN){const t=e.map(po);Ht.warn(`Firestore (${En}): ${n}`,...t)}}function po(n){if(typeof n=="string")return n;try{/**
1614
+ * @license
1615
+ * Copyright 2020 Google LLC
1616
+ *
1617
+ * Licensed under the Apache License, Version 2.0 (the "License");
1618
+ * you may not use this file except in compliance with the License.
1619
+ * You may obtain a copy of the License at
1620
+ *
1621
+ * http://www.apache.org/licenses/LICENSE-2.0
1622
+ *
1623
+ * Unless required by applicable law or agreed to in writing, software
1624
+ * distributed under the License is distributed on an "AS IS" BASIS,
1625
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1626
+ * See the License for the specific language governing permissions and
1627
+ * limitations under the License.
1628
+ */return(function(t){return JSON.stringify(t)})(n)}catch{return n}}/**
1629
+ * @license
1630
+ * Copyright 2017 Google LLC
1631
+ *
1632
+ * Licensed under the Apache License, Version 2.0 (the "License");
1633
+ * you may not use this file except in compliance with the License.
1634
+ * You may obtain a copy of the License at
1635
+ *
1636
+ * http://www.apache.org/licenses/LICENSE-2.0
1637
+ *
1638
+ * Unless required by applicable law or agreed to in writing, software
1639
+ * distributed under the License is distributed on an "AS IS" BASIS,
1640
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1641
+ * See the License for the specific language governing permissions and
1642
+ * limitations under the License.
1643
+ */function H(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,Pl(n,r,t)}function Pl(n,e,t){let r=`FIRESTORE (${En}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw nt(r),new Error(r)}function ne(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||Pl(e,s,r)}function Q(n,e){return n}/**
1644
+ * @license
1645
+ * Copyright 2017 Google LLC
1646
+ *
1647
+ * Licensed under the Apache License, Version 2.0 (the "License");
1648
+ * you may not use this file except in compliance with the License.
1649
+ * You may obtain a copy of the License at
1650
+ *
1651
+ * http://www.apache.org/licenses/LICENSE-2.0
1652
+ *
1653
+ * Unless required by applicable law or agreed to in writing, software
1654
+ * distributed under the License is distributed on an "AS IS" BASIS,
1655
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1656
+ * See the License for the specific language governing permissions and
1657
+ * limitations under the License.
1658
+ */const N={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class x extends st{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
1659
+ * @license
1660
+ * Copyright 2017 Google LLC
1661
+ *
1662
+ * Licensed under the Apache License, Version 2.0 (the "License");
1663
+ * you may not use this file except in compliance with the License.
1664
+ * You may obtain a copy of the License at
1665
+ *
1666
+ * http://www.apache.org/licenses/LICENSE-2.0
1667
+ *
1668
+ * Unless required by applicable law or agreed to in writing, software
1669
+ * distributed under the License is distributed on an "AS IS" BASIS,
1670
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1671
+ * See the License for the specific language governing permissions and
1672
+ * limitations under the License.
1673
+ */class on{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}/**
1674
+ * @license
1675
+ * Copyright 2017 Google LLC
1676
+ *
1677
+ * Licensed under the Apache License, Version 2.0 (the "License");
1678
+ * you may not use this file except in compliance with the License.
1679
+ * You may obtain a copy of the License at
1680
+ *
1681
+ * http://www.apache.org/licenses/LICENSE-2.0
1682
+ *
1683
+ * Unless required by applicable law or agreed to in writing, software
1684
+ * distributed under the License is distributed on an "AS IS" BASIS,
1685
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1686
+ * See the License for the specific language governing permissions and
1687
+ * limitations under the License.
1688
+ */class kl{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Xg{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(we.UNAUTHENTICATED)))}shutdown(){}}class Yg{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class Zg{constructor(e){this.t=e,this.currentUser=we.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ne(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let o=new on;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new on,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const l=o;e.enqueueRetryable((async()=>{await l.promise,await s(this.currentUser)}))},u=l=>{L("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((l=>u(l))),setTimeout((()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?u(l):(L("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new on)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(L("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(ne(typeof r.accessToken=="string",31837,{l:r}),new kl(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return ne(e===null||typeof e=="string",2055,{h:e}),new we(e)}}class e_{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=we.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class t_{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new e_(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(we.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Sc{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class n_{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,ke(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){ne(this.o===void 0,3512);const r=o=>{o.error!=null&&L("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const a=o.token!==this.m;return this.m=o.token,L("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(o.token):Promise.resolve()};this.o=o=>{e.enqueueRetryable((()=>r(o)))};const s=o=>{L("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((o=>s(o))),setTimeout((()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?s(o):L("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new Sc(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(ne(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new Sc(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
1689
+ * @license
1690
+ * Copyright 2020 Google LLC
1691
+ *
1692
+ * Licensed under the Apache License, Version 2.0 (the "License");
1693
+ * you may not use this file except in compliance with the License.
1694
+ * You may obtain a copy of the License at
1695
+ *
1696
+ * http://www.apache.org/licenses/LICENSE-2.0
1697
+ *
1698
+ * Unless required by applicable law or agreed to in writing, software
1699
+ * distributed under the License is distributed on an "AS IS" BASIS,
1700
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1701
+ * See the License for the specific language governing permissions and
1702
+ * limitations under the License.
1703
+ */function r_(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}/**
1704
+ * @license
1705
+ * Copyright 2023 Google LLC
1706
+ *
1707
+ * Licensed under the Apache License, Version 2.0 (the "License");
1708
+ * you may not use this file except in compliance with the License.
1709
+ * You may obtain a copy of the License at
1710
+ *
1711
+ * http://www.apache.org/licenses/LICENSE-2.0
1712
+ *
1713
+ * Unless required by applicable law or agreed to in writing, software
1714
+ * distributed under the License is distributed on an "AS IS" BASIS,
1715
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1716
+ * See the License for the specific language governing permissions and
1717
+ * limitations under the License.
1718
+ */function Ol(){return new TextEncoder}/**
1719
+ * @license
1720
+ * Copyright 2017 Google LLC
1721
+ *
1722
+ * Licensed under the Apache License, Version 2.0 (the "License");
1723
+ * you may not use this file except in compliance with the License.
1724
+ * You may obtain a copy of the License at
1725
+ *
1726
+ * http://www.apache.org/licenses/LICENSE-2.0
1727
+ *
1728
+ * Unless required by applicable law or agreed to in writing, software
1729
+ * distributed under the License is distributed on an "AS IS" BASIS,
1730
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1731
+ * See the License for the specific language governing permissions and
1732
+ * limitations under the License.
1733
+ */class mo{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=r_(40);for(let o=0;o<s.length;++o)r.length<20&&s[o]<t&&(r+=e.charAt(s[o]%62))}return r}}function W(n,e){return n<e?-1:n>e?1:0}function Vi(n,e){let t=0;for(;t<n.length&&t<e.length;){const r=n.codePointAt(t),s=e.codePointAt(t);if(r!==s){if(r<128&&s<128)return W(r,s);{const o=Ol(),a=s_(o.encode(Cc(n,t)),o.encode(Cc(e,t)));return a!==0?a:W(r,s)}}t+=r>65535?2:1}return W(n.length,e.length)}function Cc(n,e){return n.codePointAt(e)>65535?n.substring(e,e+2):n.substring(e,e+1)}function s_(n,e){for(let t=0;t<n.length&&t<e.length;++t)if(n[t]!==e[t])return W(n[t],e[t]);return W(n.length,e.length)}function hn(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}/**
1734
+ * @license
1735
+ * Copyright 2017 Google LLC
1736
+ *
1737
+ * Licensed under the Apache License, Version 2.0 (the "License");
1738
+ * you may not use this file except in compliance with the License.
1739
+ * You may obtain a copy of the License at
1740
+ *
1741
+ * http://www.apache.org/licenses/LICENSE-2.0
1742
+ *
1743
+ * Unless required by applicable law or agreed to in writing, software
1744
+ * distributed under the License is distributed on an "AS IS" BASIS,
1745
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1746
+ * See the License for the specific language governing permissions and
1747
+ * limitations under the License.
1748
+ */const Pc="__name__";class Fe{constructor(e,t,r){t===void 0?t=0:t>e.length&&H(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&H(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Fe.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Fe?e.forEach((r=>{t.push(r)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const o=Fe.compareSegments(e.get(s),t.get(s));if(o!==0)return o}return W(e.length,t.length)}static compareSegments(e,t){const r=Fe.isNumericId(e),s=Fe.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Fe.extractNumericId(e).compare(Fe.extractNumericId(t)):Vi(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Et.fromString(e.substring(4,e.length-2))}}class te extends Fe{construct(e,t,r){return new te(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new x(N.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new te(t)}static emptyPath(){return new te([])}}const i_=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Se extends Fe{construct(e,t,r){return new Se(e,t,r)}static isValidIdentifier(e){return i_.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Se.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Pc}static keyField(){return new Se([Pc])}static fromServerFormat(e){const t=[];let r="",s=0;const o=()=>{if(r.length===0)throw new x(N.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const u=e[s];if(u==="\\"){if(s+1===e.length)throw new x(N.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new x(N.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else u==="`"?(a=!a,s++):u!=="."||a?(r+=u,s++):(o(),s++)}if(o(),a)throw new x(N.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Se(t)}static emptyPath(){return new Se([])}}/**
1749
+ * @license
1750
+ * Copyright 2017 Google LLC
1751
+ *
1752
+ * Licensed under the Apache License, Version 2.0 (the "License");
1753
+ * you may not use this file except in compliance with the License.
1754
+ * You may obtain a copy of the License at
1755
+ *
1756
+ * http://www.apache.org/licenses/LICENSE-2.0
1757
+ *
1758
+ * Unless required by applicable law or agreed to in writing, software
1759
+ * distributed under the License is distributed on an "AS IS" BASIS,
1760
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761
+ * See the License for the specific language governing permissions and
1762
+ * limitations under the License.
1763
+ */class U{constructor(e){this.path=e}static fromPath(e){return new U(te.fromString(e))}static fromName(e){return new U(te.fromString(e).popFirst(5))}static empty(){return new U(te.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&te.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return te.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new U(new te(e.slice()))}}/**
1764
+ * @license
1765
+ * Copyright 2017 Google LLC
1766
+ *
1767
+ * Licensed under the Apache License, Version 2.0 (the "License");
1768
+ * you may not use this file except in compliance with the License.
1769
+ * You may obtain a copy of the License at
1770
+ *
1771
+ * http://www.apache.org/licenses/LICENSE-2.0
1772
+ *
1773
+ * Unless required by applicable law or agreed to in writing, software
1774
+ * distributed under the License is distributed on an "AS IS" BASIS,
1775
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1776
+ * See the License for the specific language governing permissions and
1777
+ * limitations under the License.
1778
+ */function o_(n,e,t){if(!t)throw new x(N.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function a_(n,e,t,r){if(e===!0&&r===!0)throw new x(N.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function kc(n){if(!U.isDocumentKey(n))throw new x(N.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function c_(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function u_(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":H(12329,{type:typeof n})}function Xr(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new x(N.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=u_(n);throw new x(N.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/**
1779
+ * @license
1780
+ * Copyright 2025 Google LLC
1781
+ *
1782
+ * Licensed under the Apache License, Version 2.0 (the "License");
1783
+ * you may not use this file except in compliance with the License.
1784
+ * You may obtain a copy of the License at
1785
+ *
1786
+ * http://www.apache.org/licenses/LICENSE-2.0
1787
+ *
1788
+ * Unless required by applicable law or agreed to in writing, software
1789
+ * distributed under the License is distributed on an "AS IS" BASIS,
1790
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791
+ * See the License for the specific language governing permissions and
1792
+ * limitations under the License.
1793
+ */function ce(n,e){const t={typeString:n};return e&&(t.value=e),t}function pr(n,e){if(!c_(n))throw new x(N.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,o="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(o!==void 0&&a!==o.value){t=`Expected '${r}' field to equal '${o.value}'`;break}}if(t)throw new x(N.INVALID_ARGUMENT,t);return!0}/**
1794
+ * @license
1795
+ * Copyright 2017 Google LLC
1796
+ *
1797
+ * Licensed under the Apache License, Version 2.0 (the "License");
1798
+ * you may not use this file except in compliance with the License.
1799
+ * You may obtain a copy of the License at
1800
+ *
1801
+ * http://www.apache.org/licenses/LICENSE-2.0
1802
+ *
1803
+ * Unless required by applicable law or agreed to in writing, software
1804
+ * distributed under the License is distributed on an "AS IS" BASIS,
1805
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1806
+ * See the License for the specific language governing permissions and
1807
+ * limitations under the License.
1808
+ */const Oc=-62135596800,Dc=1e6;class ae{static now(){return ae.fromMillis(Date.now())}static fromDate(e){return ae.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*Dc);return new ae(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new x(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new x(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Oc)throw new x(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new x(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Dc}_compareTo(e){return this.seconds===e.seconds?W(this.nanoseconds,e.nanoseconds):W(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:ae._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(pr(e,ae._jsonSchema))return new ae(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Oc;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ae._jsonSchemaVersion="firestore/timestamp/1.0",ae._jsonSchema={type:ce("string",ae._jsonSchemaVersion),seconds:ce("number"),nanoseconds:ce("number")};/**
1809
+ * @license
1810
+ * Copyright 2017 Google LLC
1811
+ *
1812
+ * Licensed under the Apache License, Version 2.0 (the "License");
1813
+ * you may not use this file except in compliance with the License.
1814
+ * You may obtain a copy of the License at
1815
+ *
1816
+ * http://www.apache.org/licenses/LICENSE-2.0
1817
+ *
1818
+ * Unless required by applicable law or agreed to in writing, software
1819
+ * distributed under the License is distributed on an "AS IS" BASIS,
1820
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821
+ * See the License for the specific language governing permissions and
1822
+ * limitations under the License.
1823
+ */class ${static fromTimestamp(e){return new $(e)}static min(){return new $(new ae(0,0))}static max(){return new $(new ae(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
1824
+ * @license
1825
+ * Copyright 2021 Google LLC
1826
+ *
1827
+ * Licensed under the Apache License, Version 2.0 (the "License");
1828
+ * you may not use this file except in compliance with the License.
1829
+ * You may obtain a copy of the License at
1830
+ *
1831
+ * http://www.apache.org/licenses/LICENSE-2.0
1832
+ *
1833
+ * Unless required by applicable law or agreed to in writing, software
1834
+ * distributed under the License is distributed on an "AS IS" BASIS,
1835
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1836
+ * See the License for the specific language governing permissions and
1837
+ * limitations under the License.
1838
+ */const rr=-1;function l_(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=$.fromTimestamp(r===1e9?new ae(t+1,0):new ae(t,r));return new At(s,U.empty(),e)}function h_(n){return new At(n.readTime,n.key,rr)}class At{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new At($.min(),U.empty(),rr)}static max(){return new At($.max(),U.empty(),rr)}}function d_(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=U.comparator(n.documentKey,e.documentKey),t!==0?t:W(n.largestBatchId,e.largestBatchId))}/**
1839
+ * @license
1840
+ * Copyright 2020 Google LLC
1841
+ *
1842
+ * Licensed under the Apache License, Version 2.0 (the "License");
1843
+ * you may not use this file except in compliance with the License.
1844
+ * You may obtain a copy of the License at
1845
+ *
1846
+ * http://www.apache.org/licenses/LICENSE-2.0
1847
+ *
1848
+ * Unless required by applicable law or agreed to in writing, software
1849
+ * distributed under the License is distributed on an "AS IS" BASIS,
1850
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1851
+ * See the License for the specific language governing permissions and
1852
+ * limitations under the License.
1853
+ */const f_="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class p_{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}/**
1854
+ * @license
1855
+ * Copyright 2017 Google LLC
1856
+ *
1857
+ * Licensed under the Apache License, Version 2.0 (the "License");
1858
+ * you may not use this file except in compliance with the License.
1859
+ * You may obtain a copy of the License at
1860
+ *
1861
+ * http://www.apache.org/licenses/LICENSE-2.0
1862
+ *
1863
+ * Unless required by applicable law or agreed to in writing, software
1864
+ * distributed under the License is distributed on an "AS IS" BASIS,
1865
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1866
+ * See the License for the specific language governing permissions and
1867
+ * limitations under the License.
1868
+ */async function bs(n){if(n.code!==N.FAILED_PRECONDITION||n.message!==f_)throw n;L("LocalStore","Unexpectedly lost primary lease")}/**
1869
+ * @license
1870
+ * Copyright 2017 Google LLC
1871
+ *
1872
+ * Licensed under the Apache License, Version 2.0 (the "License");
1873
+ * you may not use this file except in compliance with the License.
1874
+ * You may obtain a copy of the License at
1875
+ *
1876
+ * http://www.apache.org/licenses/LICENSE-2.0
1877
+ *
1878
+ * Unless required by applicable law or agreed to in writing, software
1879
+ * distributed under the License is distributed on an "AS IS" BASIS,
1880
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1881
+ * See the License for the specific language governing permissions and
1882
+ * limitations under the License.
1883
+ */class S{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&H(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new S(((r,s)=>{this.nextCallback=o=>{this.wrapSuccess(e,o).next(r,s)},this.catchCallback=o=>{this.wrapFailure(t,o).next(r,s)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof S?t:S.resolve(t)}catch(t){return S.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):S.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):S.reject(t)}static resolve(e){return new S(((t,r)=>{t(e)}))}static reject(e){return new S(((t,r)=>{r(e)}))}static waitFor(e){return new S(((t,r)=>{let s=0,o=0,a=!1;e.forEach((u=>{++s,u.next((()=>{++o,a&&o===s&&t()}),(l=>r(l)))})),a=!0,o===s&&t()}))}static or(e){let t=S.resolve(!1);for(const r of e)t=t.next((s=>s?S.resolve(s):r()));return t}static forEach(e,t){const r=[];return e.forEach(((s,o)=>{r.push(t.call(this,s,o))})),this.waitFor(r)}static mapArray(e,t){return new S(((r,s)=>{const o=e.length,a=new Array(o);let u=0;for(let l=0;l<o;l++){const d=l;t(e[d]).next((p=>{a[d]=p,++u,u===o&&r(a)}),(p=>s(p)))}}))}static doWhile(e,t){return new S(((r,s)=>{const o=()=>{e()===!0?t().next((()=>{o()}),s):r()};o()}))}}function m_(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Tn(n){return n.name==="IndexedDbTransactionError"}/**
1884
+ * @license
1885
+ * Copyright 2018 Google LLC
1886
+ *
1887
+ * Licensed under the Apache License, Version 2.0 (the "License");
1888
+ * you may not use this file except in compliance with the License.
1889
+ * You may obtain a copy of the License at
1890
+ *
1891
+ * http://www.apache.org/licenses/LICENSE-2.0
1892
+ *
1893
+ * Unless required by applicable law or agreed to in writing, software
1894
+ * distributed under the License is distributed on an "AS IS" BASIS,
1895
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1896
+ * See the License for the specific language governing permissions and
1897
+ * limitations under the License.
1898
+ */class Rs{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this._e(r),this.ae=r=>t.writeSequenceNumber(r))}_e(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ae&&this.ae(e),e}}Rs.ue=-1;/**
1899
+ * @license
1900
+ * Copyright 2017 Google LLC
1901
+ *
1902
+ * Licensed under the Apache License, Version 2.0 (the "License");
1903
+ * you may not use this file except in compliance with the License.
1904
+ * You may obtain a copy of the License at
1905
+ *
1906
+ * http://www.apache.org/licenses/LICENSE-2.0
1907
+ *
1908
+ * Unless required by applicable law or agreed to in writing, software
1909
+ * distributed under the License is distributed on an "AS IS" BASIS,
1910
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1911
+ * See the License for the specific language governing permissions and
1912
+ * limitations under the License.
1913
+ */const g_=-1;function Ss(n){return n==null}function Mi(n){return n===0&&1/n==-1/0}/**
1914
+ * @license
1915
+ * Copyright 2017 Google LLC
1916
+ *
1917
+ * Licensed under the Apache License, Version 2.0 (the "License");
1918
+ * you may not use this file except in compliance with the License.
1919
+ * You may obtain a copy of the License at
1920
+ *
1921
+ * http://www.apache.org/licenses/LICENSE-2.0
1922
+ *
1923
+ * Unless required by applicable law or agreed to in writing, software
1924
+ * distributed under the License is distributed on an "AS IS" BASIS,
1925
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1926
+ * See the License for the specific language governing permissions and
1927
+ * limitations under the License.
1928
+ */const Dl="";function __(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=Nc(e)),e=y_(n.get(t),e);return Nc(e)}function y_(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const o=n.charAt(s);switch(o){case"\0":t+="";break;case Dl:t+="";break;default:t+=o}}return t}function Nc(n){return n+Dl+""}/**
1929
+ * @license
1930
+ * Copyright 2017 Google LLC
1931
+ *
1932
+ * Licensed under the Apache License, Version 2.0 (the "License");
1933
+ * you may not use this file except in compliance with the License.
1934
+ * You may obtain a copy of the License at
1935
+ *
1936
+ * http://www.apache.org/licenses/LICENSE-2.0
1937
+ *
1938
+ * Unless required by applicable law or agreed to in writing, software
1939
+ * distributed under the License is distributed on an "AS IS" BASIS,
1940
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1941
+ * See the License for the specific language governing permissions and
1942
+ * limitations under the License.
1943
+ */function Vc(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function mr(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function v_(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
1944
+ * @license
1945
+ * Copyright 2017 Google LLC
1946
+ *
1947
+ * Licensed under the Apache License, Version 2.0 (the "License");
1948
+ * you may not use this file except in compliance with the License.
1949
+ * You may obtain a copy of the License at
1950
+ *
1951
+ * http://www.apache.org/licenses/LICENSE-2.0
1952
+ *
1953
+ * Unless required by applicable law or agreed to in writing, software
1954
+ * distributed under the License is distributed on an "AS IS" BASIS,
1955
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1956
+ * See the License for the specific language governing permissions and
1957
+ * limitations under the License.
1958
+ */class ie{constructor(e,t){this.comparator=e,this.root=t||me.EMPTY}insert(e,t){return new ie(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,me.BLACK,null,null))}remove(e){return new ie(this.comparator,this.root.remove(e,this.comparator).copy(null,null,me.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,r)=>(e(t,r),!1)))}toString(){const e=[];return this.inorderTraversal(((t,r)=>(e.push(`${t}:${r}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Br(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Br(this.root,e,this.comparator,!1)}getReverseIterator(){return new Br(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Br(this.root,e,this.comparator,!0)}}class Br{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let o=1;for(;!e.isEmpty();)if(o=t?r(e.key,t):1,t&&s&&(o*=-1),o<0)e=this.isReverse?e.left:e.right;else{if(o===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class me{constructor(e,t,r,s,o){this.key=e,this.value=t,this.color=r??me.RED,this.left=s??me.EMPTY,this.right=o??me.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,o){return new me(e??this.key,t??this.value,r??this.color,s??this.left,o??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let s=this;const o=r(e,s.key);return s=o<0?s.copy(null,null,null,s.left.insert(e,t,r),null):o===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return me.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return me.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,me.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,me.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw H(43730,{key:this.key,value:this.value});if(this.right.isRed())throw H(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw H(27949);return e+(this.isRed()?0:1)}}me.EMPTY=null,me.RED=!0,me.BLACK=!1;me.EMPTY=new class{constructor(){this.size=0}get key(){throw H(57766)}get value(){throw H(16141)}get color(){throw H(16727)}get left(){throw H(29726)}get right(){throw H(36894)}copy(e,t,r,s,o){return this}insert(e,t,r){return new me(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
1959
+ * @license
1960
+ * Copyright 2017 Google LLC
1961
+ *
1962
+ * Licensed under the Apache License, Version 2.0 (the "License");
1963
+ * you may not use this file except in compliance with the License.
1964
+ * You may obtain a copy of the License at
1965
+ *
1966
+ * http://www.apache.org/licenses/LICENSE-2.0
1967
+ *
1968
+ * Unless required by applicable law or agreed to in writing, software
1969
+ * distributed under the License is distributed on an "AS IS" BASIS,
1970
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1971
+ * See the License for the specific language governing permissions and
1972
+ * limitations under the License.
1973
+ */class le{constructor(e){this.comparator=e,this.data=new ie(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,r)=>(e(t),!1)))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Mc(this.data.getIterator())}getIteratorFrom(e){return new Mc(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((r=>{t=t.add(r)})),t}isEqual(e){if(!(e instanceof le)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,o=r.getNext().key;if(this.comparator(s,o)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new le(this.comparator);return t.data=e,t}}class Mc{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
1974
+ * @license
1975
+ * Copyright 2020 Google LLC
1976
+ *
1977
+ * Licensed under the Apache License, Version 2.0 (the "License");
1978
+ * you may not use this file except in compliance with the License.
1979
+ * You may obtain a copy of the License at
1980
+ *
1981
+ * http://www.apache.org/licenses/LICENSE-2.0
1982
+ *
1983
+ * Unless required by applicable law or agreed to in writing, software
1984
+ * distributed under the License is distributed on an "AS IS" BASIS,
1985
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1986
+ * See the License for the specific language governing permissions and
1987
+ * limitations under the License.
1988
+ */class mt{constructor(e){this.fields=e,e.sort(Se.comparator)}static empty(){return new mt([])}unionWith(e){let t=new le(Se.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new mt(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return hn(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}/**
1989
+ * @license
1990
+ * Copyright 2023 Google LLC
1991
+ *
1992
+ * Licensed under the Apache License, Version 2.0 (the "License");
1993
+ * you may not use this file except in compliance with the License.
1994
+ * You may obtain a copy of the License at
1995
+ *
1996
+ * http://www.apache.org/licenses/LICENSE-2.0
1997
+ *
1998
+ * Unless required by applicable law or agreed to in writing, software
1999
+ * distributed under the License is distributed on an "AS IS" BASIS,
2000
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2001
+ * See the License for the specific language governing permissions and
2002
+ * limitations under the License.
2003
+ */class Nl extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
2004
+ * @license
2005
+ * Copyright 2020 Google LLC
2006
+ *
2007
+ * Licensed under the Apache License, Version 2.0 (the "License");
2008
+ * you may not use this file except in compliance with the License.
2009
+ * You may obtain a copy of the License at
2010
+ *
2011
+ * http://www.apache.org/licenses/LICENSE-2.0
2012
+ *
2013
+ * Unless required by applicable law or agreed to in writing, software
2014
+ * distributed under the License is distributed on an "AS IS" BASIS,
2015
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2016
+ * See the License for the specific language governing permissions and
2017
+ * limitations under the License.
2018
+ */class ge{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(o){throw typeof DOMException<"u"&&o instanceof DOMException?new Nl("Invalid base64 string: "+o):o}})(e);return new ge(t)}static fromUint8Array(e){const t=(function(s){let o="";for(let a=0;a<s.length;++a)o+=String.fromCharCode(s[a]);return o})(e);return new ge(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(t){return btoa(t)})(this.binaryString)}toUint8Array(){return(function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return W(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}ge.EMPTY_BYTE_STRING=new ge("");const E_=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function bt(n){if(ne(!!n,39018),typeof n=="string"){let e=0;const t=E_.exec(n);if(ne(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:se(n.seconds),nanos:se(n.nanos)}}function se(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Rt(n){return typeof n=="string"?ge.fromBase64String(n):ge.fromUint8Array(n)}/**
2019
+ * @license
2020
+ * Copyright 2020 Google LLC
2021
+ *
2022
+ * Licensed under the Apache License, Version 2.0 (the "License");
2023
+ * you may not use this file except in compliance with the License.
2024
+ * You may obtain a copy of the License at
2025
+ *
2026
+ * http://www.apache.org/licenses/LICENSE-2.0
2027
+ *
2028
+ * Unless required by applicable law or agreed to in writing, software
2029
+ * distributed under the License is distributed on an "AS IS" BASIS,
2030
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2031
+ * See the License for the specific language governing permissions and
2032
+ * limitations under the License.
2033
+ */const Vl="server_timestamp",Ml="__type__",Ll="__previous_value__",xl="__local_write_time__";function go(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{})[Ml])===null||t===void 0?void 0:t.stringValue)===Vl}function Cs(n){const e=n.mapValue.fields[Ll];return go(e)?Cs(e):e}function sr(n){const e=bt(n.mapValue.fields[xl].timestampValue);return new ae(e.seconds,e.nanos)}/**
2034
+ * @license
2035
+ * Copyright 2017 Google LLC
2036
+ *
2037
+ * Licensed under the Apache License, Version 2.0 (the "License");
2038
+ * you may not use this file except in compliance with the License.
2039
+ * You may obtain a copy of the License at
2040
+ *
2041
+ * http://www.apache.org/licenses/LICENSE-2.0
2042
+ *
2043
+ * Unless required by applicable law or agreed to in writing, software
2044
+ * distributed under the License is distributed on an "AS IS" BASIS,
2045
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2046
+ * See the License for the specific language governing permissions and
2047
+ * limitations under the License.
2048
+ */class T_{constructor(e,t,r,s,o,a,u,l,d,p){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=o,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=l,this.useFetchStreams=d,this.isUsingEmulator=p}}const hs="(default)";class ir{constructor(e,t){this.projectId=e,this.database=t||hs}static empty(){return new ir("","")}get isDefaultDatabase(){return this.database===hs}isEqual(e){return e instanceof ir&&e.projectId===this.projectId&&e.database===this.database}}/**
2049
+ * @license
2050
+ * Copyright 2020 Google LLC
2051
+ *
2052
+ * Licensed under the Apache License, Version 2.0 (the "License");
2053
+ * you may not use this file except in compliance with the License.
2054
+ * You may obtain a copy of the License at
2055
+ *
2056
+ * http://www.apache.org/licenses/LICENSE-2.0
2057
+ *
2058
+ * Unless required by applicable law or agreed to in writing, software
2059
+ * distributed under the License is distributed on an "AS IS" BASIS,
2060
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2061
+ * See the License for the specific language governing permissions and
2062
+ * limitations under the License.
2063
+ */const w_="__type__",I_="__max__",$r={mapValue:{}},A_="__vector__",Li="value";function St(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?go(n)?4:R_(n)?9007199254740991:b_(n)?10:11:H(28295,{value:n})}function He(n,e){if(n===e)return!0;const t=St(n);if(t!==St(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return sr(n).isEqual(sr(e));case 3:return(function(s,o){if(typeof s.timestampValue=="string"&&typeof o.timestampValue=="string"&&s.timestampValue.length===o.timestampValue.length)return s.timestampValue===o.timestampValue;const a=bt(s.timestampValue),u=bt(o.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,o){return Rt(s.bytesValue).isEqual(Rt(o.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,o){return se(s.geoPointValue.latitude)===se(o.geoPointValue.latitude)&&se(s.geoPointValue.longitude)===se(o.geoPointValue.longitude)})(n,e);case 2:return(function(s,o){if("integerValue"in s&&"integerValue"in o)return se(s.integerValue)===se(o.integerValue);if("doubleValue"in s&&"doubleValue"in o){const a=se(s.doubleValue),u=se(o.doubleValue);return a===u?Mi(a)===Mi(u):isNaN(a)&&isNaN(u)}return!1})(n,e);case 9:return hn(n.arrayValue.values||[],e.arrayValue.values||[],He);case 10:case 11:return(function(s,o){const a=s.mapValue.fields||{},u=o.mapValue.fields||{};if(Vc(a)!==Vc(u))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(u[l]===void 0||!He(a[l],u[l])))return!1;return!0})(n,e);default:return H(52216,{left:n})}}function or(n,e){return(n.values||[]).find((t=>He(t,e)))!==void 0}function dn(n,e){if(n===e)return 0;const t=St(n),r=St(e);if(t!==r)return W(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return W(n.booleanValue,e.booleanValue);case 2:return(function(o,a){const u=se(o.integerValue||o.doubleValue),l=se(a.integerValue||a.doubleValue);return u<l?-1:u>l?1:u===l?0:isNaN(u)?isNaN(l)?0:-1:1})(n,e);case 3:return Lc(n.timestampValue,e.timestampValue);case 4:return Lc(sr(n),sr(e));case 5:return Vi(n.stringValue,e.stringValue);case 6:return(function(o,a){const u=Rt(o),l=Rt(a);return u.compareTo(l)})(n.bytesValue,e.bytesValue);case 7:return(function(o,a){const u=o.split("/"),l=a.split("/");for(let d=0;d<u.length&&d<l.length;d++){const p=W(u[d],l[d]);if(p!==0)return p}return W(u.length,l.length)})(n.referenceValue,e.referenceValue);case 8:return(function(o,a){const u=W(se(o.latitude),se(a.latitude));return u!==0?u:W(se(o.longitude),se(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return xc(n.arrayValue,e.arrayValue);case 10:return(function(o,a){var u,l,d,p;const v=o.fields||{},E=a.fields||{},C=(u=v[Li])===null||u===void 0?void 0:u.arrayValue,V=(l=E[Li])===null||l===void 0?void 0:l.arrayValue,M=W(((d=C?.values)===null||d===void 0?void 0:d.length)||0,((p=V?.values)===null||p===void 0?void 0:p.length)||0);return M!==0?M:xc(C,V)})(n.mapValue,e.mapValue);case 11:return(function(o,a){if(o===$r.mapValue&&a===$r.mapValue)return 0;if(o===$r.mapValue)return 1;if(a===$r.mapValue)return-1;const u=o.fields||{},l=Object.keys(u),d=a.fields||{},p=Object.keys(d);l.sort(),p.sort();for(let v=0;v<l.length&&v<p.length;++v){const E=Vi(l[v],p[v]);if(E!==0)return E;const C=dn(u[l[v]],d[p[v]]);if(C!==0)return C}return W(l.length,p.length)})(n.mapValue,e.mapValue);default:throw H(23264,{le:t})}}function Lc(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return W(n,e);const t=bt(n),r=bt(e),s=W(t.seconds,r.seconds);return s!==0?s:W(t.nanos,r.nanos)}function xc(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const o=dn(t[s],r[s]);if(o)return o}return W(t.length,r.length)}function fn(n){return xi(n)}function xi(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=bt(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return Rt(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return U.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const o of t.values||[])s?s=!1:r+=",",r+=xi(o);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",o=!0;for(const a of r)o?o=!1:s+=",",s+=`${a}:${xi(t.fields[a])}`;return s+"}"})(n.mapValue):H(61005,{value:n})}function Yr(n){switch(St(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Cs(n);return e?16+Yr(e):16;case 5:return 2*n.stringValue.length;case 6:return Rt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,o)=>s+Yr(o)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return mr(r.fields,((o,a)=>{s+=o.length+Yr(a)})),s})(n.mapValue);default:throw H(13486,{value:n})}}function Ui(n){return!!n&&"integerValue"in n}function _o(n){return!!n&&"arrayValue"in n}function Uc(n){return!!n&&"nullValue"in n}function Fc(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function _i(n){return!!n&&"mapValue"in n}function b_(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{})[w_])===null||t===void 0?void 0:t.stringValue)===A_}function Kn(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return mr(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=Kn(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Kn(n.arrayValue.values[t]);return e}return Object.assign({},n)}function R_(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===I_}/**
2064
+ * @license
2065
+ * Copyright 2017 Google LLC
2066
+ *
2067
+ * Licensed under the Apache License, Version 2.0 (the "License");
2068
+ * you may not use this file except in compliance with the License.
2069
+ * You may obtain a copy of the License at
2070
+ *
2071
+ * http://www.apache.org/licenses/LICENSE-2.0
2072
+ *
2073
+ * Unless required by applicable law or agreed to in writing, software
2074
+ * distributed under the License is distributed on an "AS IS" BASIS,
2075
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2076
+ * See the License for the specific language governing permissions and
2077
+ * limitations under the License.
2078
+ */class je{constructor(e){this.value=e}static empty(){return new je({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!_i(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Kn(t)}setAll(e){let t=Se.emptyPath(),r={},s=[];e.forEach(((a,u)=>{if(!t.isImmediateParentOf(u)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=u.popLast()}a?r[u.lastSegment()]=Kn(a):s.push(u.lastSegment())}));const o=this.getFieldsMap(t);this.applyChanges(o,r,s)}delete(e){const t=this.field(e.popLast());_i(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return He(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];_i(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){mr(t,((s,o)=>e[s]=o));for(const s of r)delete e[s]}clone(){return new je(Kn(this.value))}}/**
2079
+ * @license
2080
+ * Copyright 2017 Google LLC
2081
+ *
2082
+ * Licensed under the Apache License, Version 2.0 (the "License");
2083
+ * you may not use this file except in compliance with the License.
2084
+ * You may obtain a copy of the License at
2085
+ *
2086
+ * http://www.apache.org/licenses/LICENSE-2.0
2087
+ *
2088
+ * Unless required by applicable law or agreed to in writing, software
2089
+ * distributed under the License is distributed on an "AS IS" BASIS,
2090
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2091
+ * See the License for the specific language governing permissions and
2092
+ * limitations under the License.
2093
+ */class Ie{constructor(e,t,r,s,o,a,u){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=o,this.data=a,this.documentState=u}static newInvalidDocument(e){return new Ie(e,0,$.min(),$.min(),$.min(),je.empty(),0)}static newFoundDocument(e,t,r,s){return new Ie(e,1,t,$.min(),r,s,0)}static newNoDocument(e,t){return new Ie(e,2,t,$.min(),$.min(),je.empty(),0)}static newUnknownDocument(e,t){return new Ie(e,3,t,$.min(),$.min(),je.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual($.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=je.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=je.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=$.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Ie&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Ie(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
2094
+ * @license
2095
+ * Copyright 2022 Google LLC
2096
+ *
2097
+ * Licensed under the Apache License, Version 2.0 (the "License");
2098
+ * you may not use this file except in compliance with the License.
2099
+ * You may obtain a copy of the License at
2100
+ *
2101
+ * http://www.apache.org/licenses/LICENSE-2.0
2102
+ *
2103
+ * Unless required by applicable law or agreed to in writing, software
2104
+ * distributed under the License is distributed on an "AS IS" BASIS,
2105
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2106
+ * See the License for the specific language governing permissions and
2107
+ * limitations under the License.
2108
+ */class ds{constructor(e,t){this.position=e,this.inclusive=t}}function jc(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const o=e[s],a=n.position[s];if(o.field.isKeyField()?r=U.comparator(U.fromName(a.referenceValue),t.key):r=dn(a,t.data.field(o.field)),o.dir==="desc"&&(r*=-1),r!==0)break}return r}function Bc(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!He(n.position[t],e.position[t]))return!1;return!0}/**
2109
+ * @license
2110
+ * Copyright 2022 Google LLC
2111
+ *
2112
+ * Licensed under the Apache License, Version 2.0 (the "License");
2113
+ * you may not use this file except in compliance with the License.
2114
+ * You may obtain a copy of the License at
2115
+ *
2116
+ * http://www.apache.org/licenses/LICENSE-2.0
2117
+ *
2118
+ * Unless required by applicable law or agreed to in writing, software
2119
+ * distributed under the License is distributed on an "AS IS" BASIS,
2120
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121
+ * See the License for the specific language governing permissions and
2122
+ * limitations under the License.
2123
+ */class fs{constructor(e,t="asc"){this.field=e,this.dir=t}}function S_(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
2124
+ * @license
2125
+ * Copyright 2022 Google LLC
2126
+ *
2127
+ * Licensed under the Apache License, Version 2.0 (the "License");
2128
+ * you may not use this file except in compliance with the License.
2129
+ * You may obtain a copy of the License at
2130
+ *
2131
+ * http://www.apache.org/licenses/LICENSE-2.0
2132
+ *
2133
+ * Unless required by applicable law or agreed to in writing, software
2134
+ * distributed under the License is distributed on an "AS IS" BASIS,
2135
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2136
+ * See the License for the specific language governing permissions and
2137
+ * limitations under the License.
2138
+ */class Ul{}class ue extends Ul{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new P_(e,t,r):t==="array-contains"?new D_(e,r):t==="in"?new N_(e,r):t==="not-in"?new V_(e,r):t==="array-contains-any"?new M_(e,r):new ue(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new k_(e,r):new O_(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(dn(t,this.value)):t!==null&&St(this.value)===St(t)&&this.matchesComparison(dn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return H(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class We extends Ul{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new We(e,t)}matches(e){return Fl(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.he!==null||(this.he=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function Fl(n){return n.op==="and"}function jl(n){return C_(n)&&Fl(n)}function C_(n){for(const e of n.filters)if(e instanceof We)return!1;return!0}function Fi(n){if(n instanceof ue)return n.field.canonicalString()+n.op.toString()+fn(n.value);if(jl(n))return n.filters.map((e=>Fi(e))).join(",");{const e=n.filters.map((t=>Fi(t))).join(",");return`${n.op}(${e})`}}function Bl(n,e){return n instanceof ue?(function(r,s){return s instanceof ue&&r.op===s.op&&r.field.isEqual(s.field)&&He(r.value,s.value)})(n,e):n instanceof We?(function(r,s){return s instanceof We&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((o,a,u)=>o&&Bl(a,s.filters[u])),!0):!1})(n,e):void H(19439)}function $l(n){return n instanceof ue?(function(t){return`${t.field.canonicalString()} ${t.op} ${fn(t.value)}`})(n):n instanceof We?(function(t){return t.op.toString()+" {"+t.getFilters().map($l).join(" ,")+"}"})(n):"Filter"}class P_ extends ue{constructor(e,t,r){super(e,t,r),this.key=U.fromName(r.referenceValue)}matches(e){const t=U.comparator(e.key,this.key);return this.matchesComparison(t)}}class k_ extends ue{constructor(e,t){super(e,"in",t),this.keys=ql("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class O_ extends ue{constructor(e,t){super(e,"not-in",t),this.keys=ql("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function ql(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map((r=>U.fromName(r.referenceValue)))}class D_ extends ue{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return _o(t)&&or(t.arrayValue,this.value)}}class N_ extends ue{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&or(this.value.arrayValue,t)}}class V_ extends ue{constructor(e,t){super(e,"not-in",t)}matches(e){if(or(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!or(this.value.arrayValue,t)}}class M_ extends ue{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!_o(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>or(this.value.arrayValue,r)))}}/**
2139
+ * @license
2140
+ * Copyright 2019 Google LLC
2141
+ *
2142
+ * Licensed under the Apache License, Version 2.0 (the "License");
2143
+ * you may not use this file except in compliance with the License.
2144
+ * You may obtain a copy of the License at
2145
+ *
2146
+ * http://www.apache.org/licenses/LICENSE-2.0
2147
+ *
2148
+ * Unless required by applicable law or agreed to in writing, software
2149
+ * distributed under the License is distributed on an "AS IS" BASIS,
2150
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2151
+ * See the License for the specific language governing permissions and
2152
+ * limitations under the License.
2153
+ */class L_{constructor(e,t=null,r=[],s=[],o=null,a=null,u=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=o,this.startAt=a,this.endAt=u,this.Pe=null}}function $c(n,e=null,t=[],r=[],s=null,o=null,a=null){return new L_(n,e,t,r,s,o,a)}function yo(n){const e=Q(n);if(e.Pe===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>Fi(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(o){return o.field.canonicalString()+o.dir})(r))).join(","),Ss(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>fn(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>fn(r))).join(",")),e.Pe=t}return e.Pe}function vo(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!S_(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!Bl(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Bc(n.startAt,e.startAt)&&Bc(n.endAt,e.endAt)}function ji(n){return U.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
2154
+ * @license
2155
+ * Copyright 2017 Google LLC
2156
+ *
2157
+ * Licensed under the Apache License, Version 2.0 (the "License");
2158
+ * you may not use this file except in compliance with the License.
2159
+ * You may obtain a copy of the License at
2160
+ *
2161
+ * http://www.apache.org/licenses/LICENSE-2.0
2162
+ *
2163
+ * Unless required by applicable law or agreed to in writing, software
2164
+ * distributed under the License is distributed on an "AS IS" BASIS,
2165
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2166
+ * See the License for the specific language governing permissions and
2167
+ * limitations under the License.
2168
+ */class Ps{constructor(e,t=null,r=[],s=[],o=null,a="F",u=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=o,this.limitType=a,this.startAt=u,this.endAt=l,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function x_(n,e,t,r,s,o,a,u){return new Ps(n,e,t,r,s,o,a,u)}function Eo(n){return new Ps(n)}function qc(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function U_(n){return n.collectionGroup!==null}function Qn(n){const e=Q(n);if(e.Te===null){e.Te=[];const t=new Set;for(const o of e.explicitOrderBy)e.Te.push(o),t.add(o.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new le(Se.comparator);return a.filters.forEach((l=>{l.getFlattenedFilters().forEach((d=>{d.isInequality()&&(u=u.add(d.field))}))})),u})(e).forEach((o=>{t.has(o.canonicalString())||o.isKeyField()||e.Te.push(new fs(o,r))})),t.has(Se.keyField().canonicalString())||e.Te.push(new fs(Se.keyField(),r))}return e.Te}function ze(n){const e=Q(n);return e.Ie||(e.Ie=F_(e,Qn(n))),e.Ie}function F_(n,e){if(n.limitType==="F")return $c(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const o=s.dir==="desc"?"asc":"desc";return new fs(s.field,o)}));const t=n.endAt?new ds(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new ds(n.startAt.position,n.startAt.inclusive):null;return $c(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function Bi(n,e,t){return new Ps(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function ks(n,e){return vo(ze(n),ze(e))&&n.limitType===e.limitType}function zl(n){return`${yo(ze(n))}|lt:${n.limitType}`}function Zt(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>$l(s))).join(", ")}]`),Ss(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>fn(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>fn(s))).join(",")),`Target(${r})`})(ze(n))}; limitType=${n.limitType})`}function Os(n,e){return e.isFoundDocument()&&(function(r,s){const o=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(o):U.isDocumentKey(r.path)?r.path.isEqual(o):r.path.isImmediateParentOf(o)})(n,e)&&(function(r,s){for(const o of Qn(r))if(!o.field.isKeyField()&&s.data.field(o.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const o of r.filters)if(!o.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(a,u,l){const d=jc(a,u,l);return a.inclusive?d<=0:d<0})(r.startAt,Qn(r),s)||r.endAt&&!(function(a,u,l){const d=jc(a,u,l);return a.inclusive?d>=0:d>0})(r.endAt,Qn(r),s))})(n,e)}function j_(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Hl(n){return(e,t)=>{let r=!1;for(const s of Qn(n)){const o=B_(s,e,t);if(o!==0)return o;r=r||s.field.isKeyField()}return 0}}function B_(n,e,t){const r=n.field.isKeyField()?U.comparator(e.key,t.key):(function(o,a,u){const l=a.data.field(o),d=u.data.field(o);return l!==null&&d!==null?dn(l,d):H(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return H(19790,{direction:n.dir})}}/**
2169
+ * @license
2170
+ * Copyright 2017 Google LLC
2171
+ *
2172
+ * Licensed under the Apache License, Version 2.0 (the "License");
2173
+ * you may not use this file except in compliance with the License.
2174
+ * You may obtain a copy of the License at
2175
+ *
2176
+ * http://www.apache.org/licenses/LICENSE-2.0
2177
+ *
2178
+ * Unless required by applicable law or agreed to in writing, software
2179
+ * distributed under the License is distributed on an "AS IS" BASIS,
2180
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2181
+ * See the License for the specific language governing permissions and
2182
+ * limitations under the License.
2183
+ */class Wt{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,o]of r)if(this.equalsFn(s,e))return o}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let o=0;o<s.length;o++)if(this.equalsFn(s[o][0],e))return void(s[o]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){mr(this.inner,((t,r)=>{for(const[s,o]of r)e(s,o)}))}isEmpty(){return v_(this.inner)}size(){return this.innerSize}}/**
2184
+ * @license
2185
+ * Copyright 2017 Google LLC
2186
+ *
2187
+ * Licensed under the Apache License, Version 2.0 (the "License");
2188
+ * you may not use this file except in compliance with the License.
2189
+ * You may obtain a copy of the License at
2190
+ *
2191
+ * http://www.apache.org/licenses/LICENSE-2.0
2192
+ *
2193
+ * Unless required by applicable law or agreed to in writing, software
2194
+ * distributed under the License is distributed on an "AS IS" BASIS,
2195
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2196
+ * See the License for the specific language governing permissions and
2197
+ * limitations under the License.
2198
+ */const $_=new ie(U.comparator);function Ct(){return $_}const Wl=new ie(U.comparator);function qn(...n){let e=Wl;for(const t of n)e=e.insert(t.key,t);return e}function q_(n){let e=Wl;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function xt(){return Jn()}function Gl(){return Jn()}function Jn(){return new Wt((n=>n.toString()),((n,e)=>n.isEqual(e)))}const z_=new le(U.comparator);function J(...n){let e=z_;for(const t of n)e=e.add(t);return e}const H_=new le(W);function W_(){return H_}/**
2199
+ * @license
2200
+ * Copyright 2020 Google LLC
2201
+ *
2202
+ * Licensed under the Apache License, Version 2.0 (the "License");
2203
+ * you may not use this file except in compliance with the License.
2204
+ * You may obtain a copy of the License at
2205
+ *
2206
+ * http://www.apache.org/licenses/LICENSE-2.0
2207
+ *
2208
+ * Unless required by applicable law or agreed to in writing, software
2209
+ * distributed under the License is distributed on an "AS IS" BASIS,
2210
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2211
+ * See the License for the specific language governing permissions and
2212
+ * limitations under the License.
2213
+ */function G_(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Mi(e)?"-0":e}}function K_(n){return{integerValue:""+n}}/**
2214
+ * @license
2215
+ * Copyright 2018 Google LLC
2216
+ *
2217
+ * Licensed under the Apache License, Version 2.0 (the "License");
2218
+ * you may not use this file except in compliance with the License.
2219
+ * You may obtain a copy of the License at
2220
+ *
2221
+ * http://www.apache.org/licenses/LICENSE-2.0
2222
+ *
2223
+ * Unless required by applicable law or agreed to in writing, software
2224
+ * distributed under the License is distributed on an "AS IS" BASIS,
2225
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2226
+ * See the License for the specific language governing permissions and
2227
+ * limitations under the License.
2228
+ */class Ds{constructor(){this._=void 0}}function Q_(n,e,t){return n instanceof $i?(function(s,o){const a={fields:{[Ml]:{stringValue:Vl},[xl]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return o&&go(o)&&(o=Cs(o)),o&&(a.fields[Ll]=o),{mapValue:a}})(t,e):n instanceof ps?Kl(n,e):n instanceof ms?Ql(n,e):(function(s,o){const a=X_(s,o),u=zc(a)+zc(s.Ee);return Ui(a)&&Ui(s.Ee)?K_(u):G_(s.serializer,u)})(n,e)}function J_(n,e,t){return n instanceof ps?Kl(n,e):n instanceof ms?Ql(n,e):t}function X_(n,e){return n instanceof qi?(function(r){return Ui(r)||(function(o){return!!o&&"doubleValue"in o})(r)})(e)?e:{integerValue:0}:null}class $i extends Ds{}class ps extends Ds{constructor(e){super(),this.elements=e}}function Kl(n,e){const t=Jl(e);for(const r of n.elements)t.some((s=>He(s,r)))||t.push(r);return{arrayValue:{values:t}}}class ms extends Ds{constructor(e){super(),this.elements=e}}function Ql(n,e){let t=Jl(e);for(const r of n.elements)t=t.filter((s=>!He(s,r)));return{arrayValue:{values:t}}}class qi extends Ds{constructor(e,t){super(),this.serializer=e,this.Ee=t}}function zc(n){return se(n.integerValue||n.doubleValue)}function Jl(n){return _o(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function Y_(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof ps&&s instanceof ps||r instanceof ms&&s instanceof ms?hn(r.elements,s.elements,He):r instanceof qi&&s instanceof qi?He(r.Ee,s.Ee):r instanceof $i&&s instanceof $i})(n.transform,e.transform)}class Ft{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ft}static exists(e){return new Ft(void 0,e)}static updateTime(e){return new Ft(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Zr(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class To{}function Xl(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new ey(n.key,Ft.none()):new wo(n.key,n.data,Ft.none());{const t=n.data,r=je.empty();let s=new le(Se.comparator);for(let o of e.fields)if(!s.has(o)){let a=t.field(o);a===null&&o.length>1&&(o=o.popLast(),a=t.field(o)),a===null?r.delete(o):r.set(o,a),s=s.add(o)}return new Ns(n.key,r,new mt(s.toArray()),Ft.none())}}function Z_(n,e,t){n instanceof wo?(function(s,o,a){const u=s.value.clone(),l=Wc(s.fieldTransforms,o,a.transformResults);u.setAll(l),o.convertToFoundDocument(a.version,u).setHasCommittedMutations()})(n,e,t):n instanceof Ns?(function(s,o,a){if(!Zr(s.precondition,o))return void o.convertToUnknownDocument(a.version);const u=Wc(s.fieldTransforms,o,a.transformResults),l=o.data;l.setAll(Yl(s)),l.setAll(u),o.convertToFoundDocument(a.version,l).setHasCommittedMutations()})(n,e,t):(function(s,o,a){o.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function Xn(n,e,t,r){return n instanceof wo?(function(o,a,u,l){if(!Zr(o.precondition,a))return u;const d=o.value.clone(),p=Gc(o.fieldTransforms,l,a);return d.setAll(p),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null})(n,e,t,r):n instanceof Ns?(function(o,a,u,l){if(!Zr(o.precondition,a))return u;const d=Gc(o.fieldTransforms,l,a),p=a.data;return p.setAll(Yl(o)),p.setAll(d),a.convertToFoundDocument(a.version,p).setHasLocalMutations(),u===null?null:u.unionWith(o.fieldMask.fields).unionWith(o.fieldTransforms.map((v=>v.field)))})(n,e,t,r):(function(o,a,u){return Zr(o.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u})(n,e,t)}function Hc(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&hn(r,s,((o,a)=>Y_(o,a)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class wo extends To{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Ns extends To{constructor(e,t,r,s,o=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=o,this.type=1}getFieldMask(){return this.fieldMask}}function Yl(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function Wc(n,e,t){const r=new Map;ne(n.length===t.length,32656,{Ae:t.length,Re:n.length});for(let s=0;s<t.length;s++){const o=n[s],a=o.transform,u=e.data.field(o.field);r.set(o.field,J_(a,u,t[s]))}return r}function Gc(n,e,t){const r=new Map;for(const s of n){const o=s.transform,a=t.data.field(s.field);r.set(s.field,Q_(o,a,e))}return r}class ey extends To{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2229
+ * @license
2230
+ * Copyright 2017 Google LLC
2231
+ *
2232
+ * Licensed under the Apache License, Version 2.0 (the "License");
2233
+ * you may not use this file except in compliance with the License.
2234
+ * You may obtain a copy of the License at
2235
+ *
2236
+ * http://www.apache.org/licenses/LICENSE-2.0
2237
+ *
2238
+ * Unless required by applicable law or agreed to in writing, software
2239
+ * distributed under the License is distributed on an "AS IS" BASIS,
2240
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2241
+ * See the License for the specific language governing permissions and
2242
+ * limitations under the License.
2243
+ */class ty{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const o=this.mutations[s];o.key.isEqual(e.key)&&Z_(o,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=Xn(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=Xn(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=Gl();return this.mutations.forEach((s=>{const o=e.get(s.key),a=o.overlayedDocument;let u=this.applyToLocalView(a,o.mutatedFields);u=t.has(s.key)?null:u;const l=Xl(a,u);l!==null&&r.set(s.key,l),a.isValidDocument()||a.convertToNoDocument($.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),J())}isEqual(e){return this.batchId===e.batchId&&hn(this.mutations,e.mutations,((t,r)=>Hc(t,r)))&&hn(this.baseMutations,e.baseMutations,((t,r)=>Hc(t,r)))}}/**
2244
+ * @license
2245
+ * Copyright 2022 Google LLC
2246
+ *
2247
+ * Licensed under the Apache License, Version 2.0 (the "License");
2248
+ * you may not use this file except in compliance with the License.
2249
+ * You may obtain a copy of the License at
2250
+ *
2251
+ * http://www.apache.org/licenses/LICENSE-2.0
2252
+ *
2253
+ * Unless required by applicable law or agreed to in writing, software
2254
+ * distributed under the License is distributed on an "AS IS" BASIS,
2255
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2256
+ * See the License for the specific language governing permissions and
2257
+ * limitations under the License.
2258
+ */class ny{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
2259
+ largestBatchId: ${this.largestBatchId},
2260
+ mutation: ${this.mutation.toString()}
2261
+ }`}}/**
2262
+ * @license
2263
+ * Copyright 2017 Google LLC
2264
+ *
2265
+ * Licensed under the Apache License, Version 2.0 (the "License");
2266
+ * you may not use this file except in compliance with the License.
2267
+ * You may obtain a copy of the License at
2268
+ *
2269
+ * http://www.apache.org/licenses/LICENSE-2.0
2270
+ *
2271
+ * Unless required by applicable law or agreed to in writing, software
2272
+ * distributed under the License is distributed on an "AS IS" BASIS,
2273
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2274
+ * See the License for the specific language governing permissions and
2275
+ * limitations under the License.
2276
+ */class ry{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
2277
+ * @license
2278
+ * Copyright 2017 Google LLC
2279
+ *
2280
+ * Licensed under the Apache License, Version 2.0 (the "License");
2281
+ * you may not use this file except in compliance with the License.
2282
+ * You may obtain a copy of the License at
2283
+ *
2284
+ * http://www.apache.org/licenses/LICENSE-2.0
2285
+ *
2286
+ * Unless required by applicable law or agreed to in writing, software
2287
+ * distributed under the License is distributed on an "AS IS" BASIS,
2288
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2289
+ * See the License for the specific language governing permissions and
2290
+ * limitations under the License.
2291
+ */var oe,K;function Zl(n){if(n===void 0)return nt("GRPC error has no .code"),N.UNKNOWN;switch(n){case oe.OK:return N.OK;case oe.CANCELLED:return N.CANCELLED;case oe.UNKNOWN:return N.UNKNOWN;case oe.DEADLINE_EXCEEDED:return N.DEADLINE_EXCEEDED;case oe.RESOURCE_EXHAUSTED:return N.RESOURCE_EXHAUSTED;case oe.INTERNAL:return N.INTERNAL;case oe.UNAVAILABLE:return N.UNAVAILABLE;case oe.UNAUTHENTICATED:return N.UNAUTHENTICATED;case oe.INVALID_ARGUMENT:return N.INVALID_ARGUMENT;case oe.NOT_FOUND:return N.NOT_FOUND;case oe.ALREADY_EXISTS:return N.ALREADY_EXISTS;case oe.PERMISSION_DENIED:return N.PERMISSION_DENIED;case oe.FAILED_PRECONDITION:return N.FAILED_PRECONDITION;case oe.ABORTED:return N.ABORTED;case oe.OUT_OF_RANGE:return N.OUT_OF_RANGE;case oe.UNIMPLEMENTED:return N.UNIMPLEMENTED;case oe.DATA_LOSS:return N.DATA_LOSS;default:return H(39323,{code:n})}}(K=oe||(oe={}))[K.OK=0]="OK",K[K.CANCELLED=1]="CANCELLED",K[K.UNKNOWN=2]="UNKNOWN",K[K.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",K[K.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",K[K.NOT_FOUND=5]="NOT_FOUND",K[K.ALREADY_EXISTS=6]="ALREADY_EXISTS",K[K.PERMISSION_DENIED=7]="PERMISSION_DENIED",K[K.UNAUTHENTICATED=16]="UNAUTHENTICATED",K[K.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",K[K.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",K[K.ABORTED=10]="ABORTED",K[K.OUT_OF_RANGE=11]="OUT_OF_RANGE",K[K.UNIMPLEMENTED=12]="UNIMPLEMENTED",K[K.INTERNAL=13]="INTERNAL",K[K.UNAVAILABLE=14]="UNAVAILABLE",K[K.DATA_LOSS=15]="DATA_LOSS";/**
2292
+ * @license
2293
+ * Copyright 2022 Google LLC
2294
+ *
2295
+ * Licensed under the Apache License, Version 2.0 (the "License");
2296
+ * you may not use this file except in compliance with the License.
2297
+ * You may obtain a copy of the License at
2298
+ *
2299
+ * http://www.apache.org/licenses/LICENSE-2.0
2300
+ *
2301
+ * Unless required by applicable law or agreed to in writing, software
2302
+ * distributed under the License is distributed on an "AS IS" BASIS,
2303
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2304
+ * See the License for the specific language governing permissions and
2305
+ * limitations under the License.
2306
+ */const sy=new Et([4294967295,4294967295],0);function Kc(n){const e=Ol().encode(n),t=new Il;return t.update(e),new Uint8Array(t.digest())}function Qc(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),o=e.getUint32(12,!0);return[new Et([t,r],0),new Et([s,o],0)]}class Io{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new zn(`Invalid padding: ${t}`);if(r<0)throw new zn(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new zn(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new zn(`Invalid padding when bitmap length is 0: ${t}`);this.fe=8*e.length-t,this.ge=Et.fromNumber(this.fe)}pe(e,t,r){let s=e.add(t.multiply(Et.fromNumber(r)));return s.compare(sy)===1&&(s=new Et([s.getBits(0),s.getBits(1)],0)),s.modulo(this.ge).toNumber()}ye(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.fe===0)return!1;const t=Kc(e),[r,s]=Qc(t);for(let o=0;o<this.hashCount;o++){const a=this.pe(r,s,o);if(!this.ye(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,o=new Uint8Array(Math.ceil(e/8)),a=new Io(o,s,t);return r.forEach((u=>a.insert(u))),a}insert(e){if(this.fe===0)return;const t=Kc(e),[r,s]=Qc(t);for(let o=0;o<this.hashCount;o++){const a=this.pe(r,s,o);this.we(a)}}we(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class zn extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2307
+ * @license
2308
+ * Copyright 2017 Google LLC
2309
+ *
2310
+ * Licensed under the Apache License, Version 2.0 (the "License");
2311
+ * you may not use this file except in compliance with the License.
2312
+ * You may obtain a copy of the License at
2313
+ *
2314
+ * http://www.apache.org/licenses/LICENSE-2.0
2315
+ *
2316
+ * Unless required by applicable law or agreed to in writing, software
2317
+ * distributed under the License is distributed on an "AS IS" BASIS,
2318
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2319
+ * See the License for the specific language governing permissions and
2320
+ * limitations under the License.
2321
+ */class Vs{constructor(e,t,r,s,o){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=o}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,gr.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Vs($.min(),s,new ie(W),Ct(),J())}}class gr{constructor(e,t,r,s,o){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=o}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new gr(r,t,J(),J(),J())}}/**
2322
+ * @license
2323
+ * Copyright 2017 Google LLC
2324
+ *
2325
+ * Licensed under the Apache License, Version 2.0 (the "License");
2326
+ * you may not use this file except in compliance with the License.
2327
+ * You may obtain a copy of the License at
2328
+ *
2329
+ * http://www.apache.org/licenses/LICENSE-2.0
2330
+ *
2331
+ * Unless required by applicable law or agreed to in writing, software
2332
+ * distributed under the License is distributed on an "AS IS" BASIS,
2333
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2334
+ * See the License for the specific language governing permissions and
2335
+ * limitations under the License.
2336
+ */class es{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.be=s}}class eh{constructor(e,t){this.targetId=e,this.De=t}}class th{constructor(e,t,r=ge.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Jc{constructor(){this.ve=0,this.Ce=Xc(),this.Fe=ge.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return this.ve!==0}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=J(),t=J(),r=J();return this.Ce.forEach(((s,o)=>{switch(o){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:H(38017,{changeType:o})}})),new gr(this.Fe,this.Me,e,t,r)}ke(){this.xe=!1,this.Ce=Xc()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,ne(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class iy{constructor(e){this.We=e,this.Ge=new Map,this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W)}Ye(e){for(const t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(const t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,(t=>{const r=this.tt(t);switch(e.state){case 0:this.nt(t)&&r.Be(e.resumeToken);break;case 1:r.Ue(),r.Oe||r.ke(),r.Be(e.resumeToken);break;case 2:r.Ue(),r.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(r.Ke(),r.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),r.Be(e.resumeToken));break;default:H(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach(((r,s)=>{this.nt(s)&&t(s)}))}it(e){const t=e.targetId,r=e.De.count,s=this.st(t);if(s){const o=s.target;if(ji(o))if(r===0){const a=new U(o.path);this.Xe(t,a,Ie.newNoDocument(a,$.min()))}else ne(r===1,20013,{expectedCount:r});else{const a=this.ot(t);if(a!==r){const u=this._t(e),l=u?this.ut(u,e,a):1;if(l!==0){this.rt(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(t,d)}}}}}_t(e){const t=e.De.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:o=0}=t;let a,u;try{a=Rt(r).toUint8Array()}catch(l){if(l instanceof Nl)return It("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{u=new Io(a,s,o)}catch(l){return It(l instanceof zn?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return u.fe===0?null:u}ut(e,t,r){return t.De.count===r-this.ht(e,t.targetId)?0:2}ht(e,t){const r=this.We.getRemoteKeysForTarget(t);let s=0;return r.forEach((o=>{const a=this.We.lt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${o.path.canonicalString()}`;e.mightContain(u)||(this.Xe(t,o,null),s++)})),s}Pt(e){const t=new Map;this.Ge.forEach(((o,a)=>{const u=this.st(a);if(u){if(o.current&&ji(u.target)){const l=new U(u.target.path);this.Tt(l).has(a)||this.It(a,l)||this.Xe(a,l,Ie.newNoDocument(l,e))}o.Ne&&(t.set(a,o.Le()),o.ke())}}));let r=J();this.Je.forEach(((o,a)=>{let u=!0;a.forEachWhile((l=>{const d=this.st(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)})),u&&(r=r.add(o))})),this.ze.forEach(((o,a)=>a.setReadTime(e)));const s=new Vs(e,t,this.He,this.ze,r);return this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W),s}Ze(e,t){if(!this.nt(e))return;const r=this.It(e,t.key)?2:0;this.tt(e).qe(t.key,r),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,r){if(!this.nt(e))return;const s=this.tt(e);this.It(e,t)?s.qe(t,1):s.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),r&&(this.ze=this.ze.insert(t,r))}removeTarget(e){this.Ge.delete(e)}ot(e){const t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new Jc,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new le(W),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new le(W),this.je=this.je.insert(e,t)),t}nt(e){const t=this.st(e)!==null;return t||L("WatchChangeAggregator","Detected inactive target",e),t}st(e){const t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new Jc),this.We.getRemoteKeysForTarget(e).forEach((t=>{this.Xe(e,t,null)}))}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function qr(){return new ie(U.comparator)}function Xc(){return new ie(U.comparator)}const oy={asc:"ASCENDING",desc:"DESCENDING"},ay={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},cy={and:"AND",or:"OR"};class uy{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function zi(n,e){return n.useProto3Json||Ss(e)?e:{value:e}}function ly(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function hy(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function an(n){return ne(!!n,49232),$.fromTimestamp((function(t){const r=bt(t);return new ae(r.seconds,r.nanos)})(n))}function dy(n,e){return Hi(n,e).canonicalString()}function Hi(n,e){const t=(function(s){return new te(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function nh(n){const e=te.fromString(n);return ne(ah(e),10190,{key:e.toString()}),e}function yi(n,e){const t=nh(e);if(t.get(1)!==n.databaseId.projectId)throw new x(N.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new x(N.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new U(sh(t))}function rh(n,e){return dy(n.databaseId,e)}function fy(n){const e=nh(n);return e.length===4?te.emptyPath():sh(e)}function Yc(n){return new te(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function sh(n){return ne(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function py(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:H(39313,{state:d})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],o=(function(d,p){return d.useProto3Json?(ne(p===void 0||typeof p=="string",58123),ge.fromBase64String(p||"")):(ne(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),ge.fromUint8Array(p||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,u=a&&(function(d){const p=d.code===void 0?N.UNKNOWN:Zl(d.code);return new x(p,d.message||"")})(a);t=new th(r,s,o,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=yi(n,r.document.name),o=an(r.document.updateTime),a=r.document.createTime?an(r.document.createTime):$.min(),u=new je({mapValue:{fields:r.document.fields}}),l=Ie.newFoundDocument(s,o,a,u),d=r.targetIds||[],p=r.removedTargetIds||[];t=new es(d,p,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=yi(n,r.document),o=r.readTime?an(r.readTime):$.min(),a=Ie.newNoDocument(s,o),u=r.removedTargetIds||[];t=new es([],u,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=yi(n,r.document),o=r.removedTargetIds||[];t=new es([],o,s,null)}else{if(!("filter"in e))return H(11601,{At:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:o}=r,a=new ry(s,o),u=r.targetId;t=new eh(u,a)}}return t}function my(n,e){return{documents:[rh(n,e.path)]}}function gy(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=rh(n,s);const o=(function(d){if(d.length!==0)return oh(We.create(d,"and"))})(e.filters);o&&(t.structuredQuery.where=o);const a=(function(d){if(d.length!==0)return d.map((p=>(function(E){return{field:en(E.field),direction:vy(E.dir)}})(p)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const u=zi(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=(function(d){return{before:d.inclusive,values:d.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(d){return{before:!d.inclusive,values:d.position}})(e.endAt)),{Vt:t,parent:s}}function _y(n){let e=fy(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){ne(r===1,65062);const p=t.from[0];p.allDescendants?s=p.collectionId:e=e.child(p.collectionId)}let o=[];t.where&&(o=(function(v){const E=ih(v);return E instanceof We&&jl(E)?E.getFilters():[E]})(t.where));let a=[];t.orderBy&&(a=(function(v){return v.map((E=>(function(V){return new fs(tn(V.field),(function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(V.direction))})(E)))})(t.orderBy));let u=null;t.limit&&(u=(function(v){let E;return E=typeof v=="object"?v.value:v,Ss(E)?null:E})(t.limit));let l=null;t.startAt&&(l=(function(v){const E=!!v.before,C=v.values||[];return new ds(C,E)})(t.startAt));let d=null;return t.endAt&&(d=(function(v){const E=!v.before,C=v.values||[];return new ds(C,E)})(t.endAt)),x_(e,s,a,o,u,"F",l,d)}function yy(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return H(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function ih(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=tn(t.unaryFilter.field);return ue.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=tn(t.unaryFilter.field);return ue.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=tn(t.unaryFilter.field);return ue.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=tn(t.unaryFilter.field);return ue.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return H(61313);default:return H(60726)}})(n):n.fieldFilter!==void 0?(function(t){return ue.create(tn(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return H(58110);default:return H(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return We.create(t.compositeFilter.filters.map((r=>ih(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return H(1026)}})(t.compositeFilter.op))})(n):H(30097,{filter:n})}function vy(n){return oy[n]}function Ey(n){return ay[n]}function Ty(n){return cy[n]}function en(n){return{fieldPath:n.canonicalString()}}function tn(n){return Se.fromServerFormat(n.fieldPath)}function oh(n){return n instanceof ue?(function(t){if(t.op==="=="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:en(t.field),op:Ey(t.op),value:t.value}}})(n):n instanceof We?(function(t){const r=t.getFilters().map((s=>oh(s)));return r.length===1?r[0]:{compositeFilter:{op:Ty(t.op),filters:r}}})(n):H(54877,{filter:n})}function ah(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
2337
+ * @license
2338
+ * Copyright 2017 Google LLC
2339
+ *
2340
+ * Licensed under the Apache License, Version 2.0 (the "License");
2341
+ * you may not use this file except in compliance with the License.
2342
+ * You may obtain a copy of the License at
2343
+ *
2344
+ * http://www.apache.org/licenses/LICENSE-2.0
2345
+ *
2346
+ * Unless required by applicable law or agreed to in writing, software
2347
+ * distributed under the License is distributed on an "AS IS" BASIS,
2348
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2349
+ * See the License for the specific language governing permissions and
2350
+ * limitations under the License.
2351
+ */class gt{constructor(e,t,r,s,o=$.min(),a=$.min(),u=ge.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=o,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=u,this.expectedCount=l}withSequenceNumber(e){return new gt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new gt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new gt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new gt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
2352
+ * @license
2353
+ * Copyright 2017 Google LLC
2354
+ *
2355
+ * Licensed under the Apache License, Version 2.0 (the "License");
2356
+ * you may not use this file except in compliance with the License.
2357
+ * You may obtain a copy of the License at
2358
+ *
2359
+ * http://www.apache.org/licenses/LICENSE-2.0
2360
+ *
2361
+ * Unless required by applicable law or agreed to in writing, software
2362
+ * distributed under the License is distributed on an "AS IS" BASIS,
2363
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2364
+ * See the License for the specific language governing permissions and
2365
+ * limitations under the License.
2366
+ */class wy{constructor(e){this.gt=e}}function Iy(n){const e=_y({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Bi(e,e.limit,"L"):e}/**
2367
+ * @license
2368
+ * Copyright 2019 Google LLC
2369
+ *
2370
+ * Licensed under the Apache License, Version 2.0 (the "License");
2371
+ * you may not use this file except in compliance with the License.
2372
+ * You may obtain a copy of the License at
2373
+ *
2374
+ * http://www.apache.org/licenses/LICENSE-2.0
2375
+ *
2376
+ * Unless required by applicable law or agreed to in writing, software
2377
+ * distributed under the License is distributed on an "AS IS" BASIS,
2378
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2379
+ * See the License for the specific language governing permissions and
2380
+ * limitations under the License.
2381
+ */class Ay{constructor(){this.Dn=new by}addToCollectionParentIndex(e,t){return this.Dn.add(t),S.resolve()}getCollectionParents(e,t){return S.resolve(this.Dn.getEntries(t))}addFieldIndex(e,t){return S.resolve()}deleteFieldIndex(e,t){return S.resolve()}deleteAllFieldIndexes(e){return S.resolve()}createTargetIndexes(e,t){return S.resolve()}getDocumentsMatchingTarget(e,t){return S.resolve(null)}getIndexType(e,t){return S.resolve(0)}getFieldIndexes(e,t){return S.resolve([])}getNextCollectionGroupToUpdate(e){return S.resolve(null)}getMinOffset(e,t){return S.resolve(At.min())}getMinOffsetFromCollectionGroup(e,t){return S.resolve(At.min())}updateCollectionGroup(e,t,r){return S.resolve()}updateIndexEntries(e,t){return S.resolve()}}class by{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new le(te.comparator),o=!s.has(r);return this.index[t]=s.add(r),o}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new le(te.comparator)).toArray()}}/**
2382
+ * @license
2383
+ * Copyright 2018 Google LLC
2384
+ *
2385
+ * Licensed under the Apache License, Version 2.0 (the "License");
2386
+ * you may not use this file except in compliance with the License.
2387
+ * You may obtain a copy of the License at
2388
+ *
2389
+ * http://www.apache.org/licenses/LICENSE-2.0
2390
+ *
2391
+ * Unless required by applicable law or agreed to in writing, software
2392
+ * distributed under the License is distributed on an "AS IS" BASIS,
2393
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2394
+ * See the License for the specific language governing permissions and
2395
+ * limitations under the License.
2396
+ */const Zc={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},ch=41943040;class Pe{static withCacheSize(e){return new Pe(e,Pe.DEFAULT_COLLECTION_PERCENTILE,Pe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/**
2397
+ * @license
2398
+ * Copyright 2017 Google LLC
2399
+ *
2400
+ * Licensed under the Apache License, Version 2.0 (the "License");
2401
+ * you may not use this file except in compliance with the License.
2402
+ * You may obtain a copy of the License at
2403
+ *
2404
+ * http://www.apache.org/licenses/LICENSE-2.0
2405
+ *
2406
+ * Unless required by applicable law or agreed to in writing, software
2407
+ * distributed under the License is distributed on an "AS IS" BASIS,
2408
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2409
+ * See the License for the specific language governing permissions and
2410
+ * limitations under the License.
2411
+ */Pe.DEFAULT_COLLECTION_PERCENTILE=10,Pe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Pe.DEFAULT=new Pe(ch,Pe.DEFAULT_COLLECTION_PERCENTILE,Pe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Pe.DISABLED=new Pe(-1,0,0);/**
2412
+ * @license
2413
+ * Copyright 2017 Google LLC
2414
+ *
2415
+ * Licensed under the Apache License, Version 2.0 (the "License");
2416
+ * you may not use this file except in compliance with the License.
2417
+ * You may obtain a copy of the License at
2418
+ *
2419
+ * http://www.apache.org/licenses/LICENSE-2.0
2420
+ *
2421
+ * Unless required by applicable law or agreed to in writing, software
2422
+ * distributed under the License is distributed on an "AS IS" BASIS,
2423
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2424
+ * See the License for the specific language governing permissions and
2425
+ * limitations under the License.
2426
+ */class pn{constructor(e){this._r=e}next(){return this._r+=2,this._r}static ar(){return new pn(0)}static ur(){return new pn(-1)}}/**
2427
+ * @license
2428
+ * Copyright 2020 Google LLC
2429
+ *
2430
+ * Licensed under the Apache License, Version 2.0 (the "License");
2431
+ * you may not use this file except in compliance with the License.
2432
+ * You may obtain a copy of the License at
2433
+ *
2434
+ * http://www.apache.org/licenses/LICENSE-2.0
2435
+ *
2436
+ * Unless required by applicable law or agreed to in writing, software
2437
+ * distributed under the License is distributed on an "AS IS" BASIS,
2438
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2439
+ * See the License for the specific language governing permissions and
2440
+ * limitations under the License.
2441
+ */const eu="LruGarbageCollector",Ry=1048576;function tu([n,e],[t,r]){const s=W(n,t);return s===0?W(e,r):s}class Sy{constructor(e){this.Tr=e,this.buffer=new le(tu),this.Ir=0}dr(){return++this.Ir}Er(e){const t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();tu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Cy{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return this.Ar!==null}Rr(e){L(eu,`Garbage collection scheduled in ${e}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Tn(t)?L(eu,"Ignoring IndexedDB error during garbage collection: ",t):await bs(t)}await this.Rr(3e5)}))}}class Py{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.mr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return S.resolve(Rs.ue);const r=new Sy(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.gr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(L("LruGarbageCollector","Garbage collection skipped; disabled"),S.resolve(Zc)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(L("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Zc):this.pr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}pr(e,t){let r,s,o,a,u,l,d;const p=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((v=>(v>this.params.maximumSequenceNumbersToCollect?(L("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${v}`),s=this.params.maximumSequenceNumbersToCollect):s=v,a=Date.now(),this.nthSequenceNumber(e,s)))).next((v=>(r=v,u=Date.now(),this.removeTargets(e,r,t)))).next((v=>(o=v,l=Date.now(),this.removeOrphanedDocuments(e,r)))).next((v=>(d=Date.now(),Yt()<=G.DEBUG&&L("LruGarbageCollector",`LRU Garbage Collection
2442
+ Counted targets in ${a-p}ms
2443
+ Determined least recently used ${s} in `+(u-a)+`ms
2444
+ Removed ${o} targets in `+(l-u)+`ms
2445
+ Removed ${v} documents in `+(d-l)+`ms
2446
+ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:o,documentsRemoved:v}))))}}function ky(n,e){return new Py(n,e)}/**
2447
+ * @license
2448
+ * Copyright 2017 Google LLC
2449
+ *
2450
+ * Licensed under the Apache License, Version 2.0 (the "License");
2451
+ * you may not use this file except in compliance with the License.
2452
+ * You may obtain a copy of the License at
2453
+ *
2454
+ * http://www.apache.org/licenses/LICENSE-2.0
2455
+ *
2456
+ * Unless required by applicable law or agreed to in writing, software
2457
+ * distributed under the License is distributed on an "AS IS" BASIS,
2458
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2459
+ * See the License for the specific language governing permissions and
2460
+ * limitations under the License.
2461
+ */class Oy{constructor(){this.changes=new Wt((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Ie.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?S.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
2462
+ * @license
2463
+ * Copyright 2017 Google LLC
2464
+ *
2465
+ * Licensed under the Apache License, Version 2.0 (the "License");
2466
+ * you may not use this file except in compliance with the License.
2467
+ * You may obtain a copy of the License at
2468
+ *
2469
+ * http://www.apache.org/licenses/LICENSE-2.0
2470
+ *
2471
+ * Unless required by applicable law or agreed to in writing, software
2472
+ * distributed under the License is distributed on an "AS IS" BASIS,
2473
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2474
+ * See the License for the specific language governing permissions and
2475
+ * limitations under the License.
2476
+ *//**
2477
+ * @license
2478
+ * Copyright 2022 Google LLC
2479
+ *
2480
+ * Licensed under the Apache License, Version 2.0 (the "License");
2481
+ * you may not use this file except in compliance with the License.
2482
+ * You may obtain a copy of the License at
2483
+ *
2484
+ * http://www.apache.org/licenses/LICENSE-2.0
2485
+ *
2486
+ * Unless required by applicable law or agreed to in writing, software
2487
+ * distributed under the License is distributed on an "AS IS" BASIS,
2488
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2489
+ * See the License for the specific language governing permissions and
2490
+ * limitations under the License.
2491
+ */class Dy{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
2492
+ * @license
2493
+ * Copyright 2017 Google LLC
2494
+ *
2495
+ * Licensed under the Apache License, Version 2.0 (the "License");
2496
+ * you may not use this file except in compliance with the License.
2497
+ * You may obtain a copy of the License at
2498
+ *
2499
+ * http://www.apache.org/licenses/LICENSE-2.0
2500
+ *
2501
+ * Unless required by applicable law or agreed to in writing, software
2502
+ * distributed under the License is distributed on an "AS IS" BASIS,
2503
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2504
+ * See the License for the specific language governing permissions and
2505
+ * limitations under the License.
2506
+ */class Ny{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&Xn(r.mutation,s,mt.empty(),ae.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,J()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=J()){const s=xt();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((o=>{let a=qn();return o.forEach(((u,l)=>{a=a.insert(u,l.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const r=xt();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,J())))}populateOverlays(e,t,r){const s=[];return r.forEach((o=>{t.has(o)||s.push(o)})),this.documentOverlayCache.getOverlays(e,s).next((o=>{o.forEach(((a,u)=>{t.set(a,u)}))}))}computeViews(e,t,r,s){let o=Ct();const a=Jn(),u=(function(){return Jn()})();return t.forEach(((l,d)=>{const p=r.get(d.key);s.has(d.key)&&(p===void 0||p.mutation instanceof Ns)?o=o.insert(d.key,d):p!==void 0?(a.set(d.key,p.mutation.getFieldMask()),Xn(p.mutation,d,p.mutation.getFieldMask(),ae.now())):a.set(d.key,mt.empty())})),this.recalculateAndSaveOverlays(e,o).next((l=>(l.forEach(((d,p)=>a.set(d,p))),t.forEach(((d,p)=>{var v;return u.set(d,new Dy(p,(v=a.get(d))!==null&&v!==void 0?v:null))})),u)))}recalculateAndSaveOverlays(e,t){const r=Jn();let s=new ie(((a,u)=>a-u)),o=J();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>{for(const u of a)u.keys().forEach((l=>{const d=t.get(l);if(d===null)return;let p=r.get(l)||mt.empty();p=u.applyToLocalView(d,p),r.set(l,p);const v=(s.get(u.batchId)||J()).add(l);s=s.insert(u.batchId,v)}))})).next((()=>{const a=[],u=s.getReverseIterator();for(;u.hasNext();){const l=u.getNext(),d=l.key,p=l.value,v=Gl();p.forEach((E=>{if(!o.has(E)){const C=Xl(t.get(E),r.get(E));C!==null&&v.set(E,C),o=o.add(E)}})),a.push(this.documentOverlayCache.saveOverlays(e,d,v))}return S.waitFor(a)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return(function(a){return U.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0})(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):U_(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((o=>{const a=s-o.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-o.size):S.resolve(xt());let u=rr,l=o;return a.next((d=>S.forEach(d,((p,v)=>(u<v.largestBatchId&&(u=v.largestBatchId),o.get(p)?S.resolve():this.remoteDocumentCache.getEntry(e,p).next((E=>{l=l.insert(p,E)}))))).next((()=>this.populateOverlays(e,d,o))).next((()=>this.computeViews(e,l,d,J()))).next((p=>({batchId:u,changes:q_(p)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new U(t)).next((r=>{let s=qn();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const o=t.collectionGroup;let a=qn();return this.indexManager.getCollectionParents(e,o).next((u=>S.forEach(u,(l=>{const d=(function(v,E){return new Ps(E,null,v.explicitOrderBy.slice(),v.filters.slice(),v.limit,v.limitType,v.startAt,v.endAt)})(t,l.child(o));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next((p=>{p.forEach(((v,E)=>{a=a.insert(v,E)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let o;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((a=>(o=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,o,s)))).next((a=>{o.forEach(((l,d)=>{const p=d.getKey();a.get(p)===null&&(a=a.insert(p,Ie.newInvalidDocument(p)))}));let u=qn();return a.forEach(((l,d)=>{const p=o.get(l);p!==void 0&&Xn(p.mutation,d,mt.empty(),ae.now()),Os(t,d)&&(u=u.insert(l,d))})),u}))}}/**
2507
+ * @license
2508
+ * Copyright 2020 Google LLC
2509
+ *
2510
+ * Licensed under the Apache License, Version 2.0 (the "License");
2511
+ * you may not use this file except in compliance with the License.
2512
+ * You may obtain a copy of the License at
2513
+ *
2514
+ * http://www.apache.org/licenses/LICENSE-2.0
2515
+ *
2516
+ * Unless required by applicable law or agreed to in writing, software
2517
+ * distributed under the License is distributed on an "AS IS" BASIS,
2518
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2519
+ * See the License for the specific language governing permissions and
2520
+ * limitations under the License.
2521
+ */class Vy{constructor(e){this.serializer=e,this.Br=new Map,this.Lr=new Map}getBundleMetadata(e,t){return S.resolve(this.Br.get(t))}saveBundleMetadata(e,t){return this.Br.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:an(s.createTime)}})(t)),S.resolve()}getNamedQuery(e,t){return S.resolve(this.Lr.get(t))}saveNamedQuery(e,t){return this.Lr.set(t.name,(function(s){return{name:s.name,query:Iy(s.bundledQuery),readTime:an(s.readTime)}})(t)),S.resolve()}}/**
2522
+ * @license
2523
+ * Copyright 2022 Google LLC
2524
+ *
2525
+ * Licensed under the Apache License, Version 2.0 (the "License");
2526
+ * you may not use this file except in compliance with the License.
2527
+ * You may obtain a copy of the License at
2528
+ *
2529
+ * http://www.apache.org/licenses/LICENSE-2.0
2530
+ *
2531
+ * Unless required by applicable law or agreed to in writing, software
2532
+ * distributed under the License is distributed on an "AS IS" BASIS,
2533
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2534
+ * See the License for the specific language governing permissions and
2535
+ * limitations under the License.
2536
+ */class My{constructor(){this.overlays=new ie(U.comparator),this.kr=new Map}getOverlay(e,t){return S.resolve(this.overlays.get(t))}getOverlays(e,t){const r=xt();return S.forEach(t,(s=>this.getOverlay(e,s).next((o=>{o!==null&&r.set(s,o)})))).next((()=>r))}saveOverlays(e,t,r){return r.forEach(((s,o)=>{this.wt(e,t,o)})),S.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.kr.get(r);return s!==void 0&&(s.forEach((o=>this.overlays=this.overlays.remove(o))),this.kr.delete(r)),S.resolve()}getOverlaysForCollection(e,t,r){const s=xt(),o=t.length+1,a=new U(t.child("")),u=this.overlays.getIteratorFrom(a);for(;u.hasNext();){const l=u.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===o&&l.largestBatchId>r&&s.set(l.getKey(),l)}return S.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let o=new ie(((d,p)=>d-p));const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let p=o.get(d.largestBatchId);p===null&&(p=xt(),o=o.insert(d.largestBatchId,p)),p.set(d.getKey(),d)}}const u=xt(),l=o.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach(((d,p)=>u.set(d,p))),!(u.size()>=s)););return S.resolve(u)}wt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.kr.get(s.largestBatchId).delete(r.key);this.kr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new ny(t,r));let o=this.kr.get(t);o===void 0&&(o=J(),this.kr.set(t,o)),this.kr.set(t,o.add(r.key))}}/**
2537
+ * @license
2538
+ * Copyright 2024 Google LLC
2539
+ *
2540
+ * Licensed under the Apache License, Version 2.0 (the "License");
2541
+ * you may not use this file except in compliance with the License.
2542
+ * You may obtain a copy of the License at
2543
+ *
2544
+ * http://www.apache.org/licenses/LICENSE-2.0
2545
+ *
2546
+ * Unless required by applicable law or agreed to in writing, software
2547
+ * distributed under the License is distributed on an "AS IS" BASIS,
2548
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2549
+ * See the License for the specific language governing permissions and
2550
+ * limitations under the License.
2551
+ */class Ly{constructor(){this.sessionToken=ge.EMPTY_BYTE_STRING}getSessionToken(e){return S.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,S.resolve()}}/**
2552
+ * @license
2553
+ * Copyright 2017 Google LLC
2554
+ *
2555
+ * Licensed under the Apache License, Version 2.0 (the "License");
2556
+ * you may not use this file except in compliance with the License.
2557
+ * You may obtain a copy of the License at
2558
+ *
2559
+ * http://www.apache.org/licenses/LICENSE-2.0
2560
+ *
2561
+ * Unless required by applicable law or agreed to in writing, software
2562
+ * distributed under the License is distributed on an "AS IS" BASIS,
2563
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2564
+ * See the License for the specific language governing permissions and
2565
+ * limitations under the License.
2566
+ */class Ao{constructor(){this.qr=new le(de.Qr),this.$r=new le(de.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){const r=new de(e,t);this.qr=this.qr.add(r),this.$r=this.$r.add(r)}Kr(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new de(e,t))}Gr(e,t){e.forEach((r=>this.removeReference(r,t)))}zr(e){const t=new U(new te([])),r=new de(t,e),s=new de(t,e+1),o=[];return this.$r.forEachInRange([r,s],(a=>{this.Wr(a),o.push(a.key)})),o}jr(){this.qr.forEach((e=>this.Wr(e)))}Wr(e){this.qr=this.qr.delete(e),this.$r=this.$r.delete(e)}Jr(e){const t=new U(new te([])),r=new de(t,e),s=new de(t,e+1);let o=J();return this.$r.forEachInRange([r,s],(a=>{o=o.add(a.key)})),o}containsKey(e){const t=new de(e,0),r=this.qr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class de{constructor(e,t){this.key=e,this.Hr=t}static Qr(e,t){return U.comparator(e.key,t.key)||W(e.Hr,t.Hr)}static Ur(e,t){return W(e.Hr,t.Hr)||U.comparator(e.key,t.key)}}/**
2567
+ * @license
2568
+ * Copyright 2017 Google LLC
2569
+ *
2570
+ * Licensed under the Apache License, Version 2.0 (the "License");
2571
+ * you may not use this file except in compliance with the License.
2572
+ * You may obtain a copy of the License at
2573
+ *
2574
+ * http://www.apache.org/licenses/LICENSE-2.0
2575
+ *
2576
+ * Unless required by applicable law or agreed to in writing, software
2577
+ * distributed under the License is distributed on an "AS IS" BASIS,
2578
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2579
+ * See the License for the specific language governing permissions and
2580
+ * limitations under the License.
2581
+ */class xy{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.er=1,this.Yr=new le(de.Qr)}checkEmpty(e){return S.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const o=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new ty(o,t,r,s);this.mutationQueue.push(a);for(const u of s)this.Yr=this.Yr.add(new de(u.key,o)),this.indexManager.addToCollectionParentIndex(e,u.key.path.popLast());return S.resolve(a)}lookupMutationBatch(e,t){return S.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),o=s<0?0:s;return S.resolve(this.mutationQueue.length>o?this.mutationQueue[o]:null)}getHighestUnacknowledgedBatchId(){return S.resolve(this.mutationQueue.length===0?g_:this.er-1)}getAllMutationBatches(e){return S.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new de(t,0),s=new de(t,Number.POSITIVE_INFINITY),o=[];return this.Yr.forEachInRange([r,s],(a=>{const u=this.Zr(a.Hr);o.push(u)})),S.resolve(o)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new le(W);return t.forEach((s=>{const o=new de(s,0),a=new de(s,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([o,a],(u=>{r=r.add(u.Hr)}))})),S.resolve(this.ei(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let o=r;U.isDocumentKey(o)||(o=o.child(""));const a=new de(new U(o),0);let u=new le(W);return this.Yr.forEachWhile((l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(u=u.add(l.Hr)),!0)}),a),S.resolve(this.ei(u))}ei(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){ne(this.ti(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Yr;return S.forEach(t.mutations,(s=>{const o=new de(s.key,t.batchId);return r=r.delete(o),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Yr=r}))}rr(e){}containsKey(e,t){const r=new de(t,0),s=this.Yr.firstAfterOrEqual(r);return S.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,S.resolve()}ti(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
2582
+ * @license
2583
+ * Copyright 2017 Google LLC
2584
+ *
2585
+ * Licensed under the Apache License, Version 2.0 (the "License");
2586
+ * you may not use this file except in compliance with the License.
2587
+ * You may obtain a copy of the License at
2588
+ *
2589
+ * http://www.apache.org/licenses/LICENSE-2.0
2590
+ *
2591
+ * Unless required by applicable law or agreed to in writing, software
2592
+ * distributed under the License is distributed on an "AS IS" BASIS,
2593
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2594
+ * See the License for the specific language governing permissions and
2595
+ * limitations under the License.
2596
+ */class Uy{constructor(e){this.ni=e,this.docs=(function(){return new ie(U.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),o=s?s.size:0,a=this.ni(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return S.resolve(r?r.document.mutableCopy():Ie.newInvalidDocument(t))}getEntries(e,t){let r=Ct();return t.forEach((s=>{const o=this.docs.get(s);r=r.insert(s,o?o.document.mutableCopy():Ie.newInvalidDocument(s))})),S.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let o=Ct();const a=t.path,u=new U(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(u);for(;l.hasNext();){const{key:d,value:{document:p}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||d_(h_(p),r)<=0||(s.has(p.key)||Os(t,p))&&(o=o.insert(p.key,p.mutableCopy()))}return S.resolve(o)}getAllFromCollectionGroup(e,t,r,s){H(9500)}ri(e,t){return S.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new Fy(this)}getSize(e){return S.resolve(this.size)}}class Fy extends Oy{constructor(e){super(),this.Or=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Or.addEntry(e,s)):this.Or.removeEntry(r)})),S.waitFor(t)}getFromCache(e,t){return this.Or.getEntry(e,t)}getAllFromCache(e,t){return this.Or.getEntries(e,t)}}/**
2597
+ * @license
2598
+ * Copyright 2017 Google LLC
2599
+ *
2600
+ * Licensed under the Apache License, Version 2.0 (the "License");
2601
+ * you may not use this file except in compliance with the License.
2602
+ * You may obtain a copy of the License at
2603
+ *
2604
+ * http://www.apache.org/licenses/LICENSE-2.0
2605
+ *
2606
+ * Unless required by applicable law or agreed to in writing, software
2607
+ * distributed under the License is distributed on an "AS IS" BASIS,
2608
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2609
+ * See the License for the specific language governing permissions and
2610
+ * limitations under the License.
2611
+ */class jy{constructor(e){this.persistence=e,this.ii=new Wt((t=>yo(t)),vo),this.lastRemoteSnapshotVersion=$.min(),this.highestTargetId=0,this.si=0,this.oi=new Ao,this.targetCount=0,this._i=pn.ar()}forEachTarget(e,t){return this.ii.forEach(((r,s)=>t(s))),S.resolve()}getLastRemoteSnapshotVersion(e){return S.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return S.resolve(this.si)}allocateTargetId(e){return this.highestTargetId=this._i.next(),S.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.si&&(this.si=t),S.resolve()}hr(e){this.ii.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this._i=new pn(t),this.highestTargetId=t),e.sequenceNumber>this.si&&(this.si=e.sequenceNumber)}addTargetData(e,t){return this.hr(t),this.targetCount+=1,S.resolve()}updateTargetData(e,t){return this.hr(t),S.resolve()}removeTargetData(e,t){return this.ii.delete(t.target),this.oi.zr(t.targetId),this.targetCount-=1,S.resolve()}removeTargets(e,t,r){let s=0;const o=[];return this.ii.forEach(((a,u)=>{u.sequenceNumber<=t&&r.get(u.targetId)===null&&(this.ii.delete(a),o.push(this.removeMatchingKeysForTargetId(e,u.targetId)),s++)})),S.waitFor(o).next((()=>s))}getTargetCount(e){return S.resolve(this.targetCount)}getTargetData(e,t){const r=this.ii.get(t)||null;return S.resolve(r)}addMatchingKeys(e,t,r){return this.oi.Kr(t,r),S.resolve()}removeMatchingKeys(e,t,r){this.oi.Gr(t,r);const s=this.persistence.referenceDelegate,o=[];return s&&t.forEach((a=>{o.push(s.markPotentiallyOrphaned(e,a))})),S.waitFor(o)}removeMatchingKeysForTargetId(e,t){return this.oi.zr(t),S.resolve()}getMatchingKeysForTargetId(e,t){const r=this.oi.Jr(t);return S.resolve(r)}containsKey(e,t){return S.resolve(this.oi.containsKey(t))}}/**
2612
+ * @license
2613
+ * Copyright 2017 Google LLC
2614
+ *
2615
+ * Licensed under the Apache License, Version 2.0 (the "License");
2616
+ * you may not use this file except in compliance with the License.
2617
+ * You may obtain a copy of the License at
2618
+ *
2619
+ * http://www.apache.org/licenses/LICENSE-2.0
2620
+ *
2621
+ * Unless required by applicable law or agreed to in writing, software
2622
+ * distributed under the License is distributed on an "AS IS" BASIS,
2623
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2624
+ * See the License for the specific language governing permissions and
2625
+ * limitations under the License.
2626
+ */class uh{constructor(e,t){this.ai={},this.overlays={},this.ui=new Rs(0),this.ci=!1,this.ci=!0,this.li=new Ly,this.referenceDelegate=e(this),this.hi=new jy(this),this.indexManager=new Ay,this.remoteDocumentCache=(function(s){return new Uy(s)})((r=>this.referenceDelegate.Pi(r))),this.serializer=new wy(t),this.Ti=new Vy(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new My,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ai[e.toKey()];return r||(r=new xy(t,this.referenceDelegate),this.ai[e.toKey()]=r),r}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(e,t,r){L("MemoryPersistence","Starting transaction:",e);const s=new By(this.ui.next());return this.referenceDelegate.Ii(),r(s).next((o=>this.referenceDelegate.di(s).next((()=>o)))).toPromise().then((o=>(s.raiseOnCommittedEvent(),o)))}Ei(e,t){return S.or(Object.values(this.ai).map((r=>()=>r.containsKey(e,t))))}}class By extends p_{constructor(e){super(),this.currentSequenceNumber=e}}class bo{constructor(e){this.persistence=e,this.Ai=new Ao,this.Ri=null}static Vi(e){return new bo(e)}get mi(){if(this.Ri)return this.Ri;throw H(60996)}addReference(e,t,r){return this.Ai.addReference(r,t),this.mi.delete(r.toString()),S.resolve()}removeReference(e,t,r){return this.Ai.removeReference(r,t),this.mi.add(r.toString()),S.resolve()}markPotentiallyOrphaned(e,t){return this.mi.add(t.toString()),S.resolve()}removeTarget(e,t){this.Ai.zr(t.targetId).forEach((s=>this.mi.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((o=>this.mi.add(o.toString())))})).next((()=>r.removeTargetData(e,t)))}Ii(){this.Ri=new Set}di(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return S.forEach(this.mi,(r=>{const s=U.fromPath(r);return this.fi(e,s).next((o=>{o||t.removeEntry(s,$.min())}))})).next((()=>(this.Ri=null,t.apply(e))))}updateLimboDocument(e,t){return this.fi(e,t).next((r=>{r?this.mi.delete(t.toString()):this.mi.add(t.toString())}))}Pi(e){return 0}fi(e,t){return S.or([()=>S.resolve(this.Ai.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class gs{constructor(e,t){this.persistence=e,this.gi=new Wt((r=>__(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=ky(this,t)}static Vi(e,t){return new gs(e,t)}Ii(){}di(e){return S.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}mr(e){const t=this.yr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}yr(e){let t=0;return this.gr(e,(r=>{t++})).next((()=>t))}gr(e,t){return S.forEach(this.gi,((r,s)=>this.Sr(e,r,s).next((o=>o?S.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),o=s.newChangeBuffer();return s.ri(e,(a=>this.Sr(e,a,t).next((u=>{u||(r++,o.removeEntry(a,$.min()))})))).next((()=>o.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.gi.set(t,e.currentSequenceNumber),S.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),S.resolve()}removeReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),S.resolve()}updateLimboDocument(e,t){return this.gi.set(t,e.currentSequenceNumber),S.resolve()}Pi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Yr(e.data.value)),t}Sr(e,t,r){return S.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.gi.get(t);return S.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
2627
+ * @license
2628
+ * Copyright 2017 Google LLC
2629
+ *
2630
+ * Licensed under the Apache License, Version 2.0 (the "License");
2631
+ * you may not use this file except in compliance with the License.
2632
+ * You may obtain a copy of the License at
2633
+ *
2634
+ * http://www.apache.org/licenses/LICENSE-2.0
2635
+ *
2636
+ * Unless required by applicable law or agreed to in writing, software
2637
+ * distributed under the License is distributed on an "AS IS" BASIS,
2638
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2639
+ * See the License for the specific language governing permissions and
2640
+ * limitations under the License.
2641
+ */class Ro{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Is=r,this.ds=s}static Es(e,t){let r=J(),s=J();for(const o of t.docChanges)switch(o.type){case 0:r=r.add(o.doc.key);break;case 1:s=s.add(o.doc.key)}return new Ro(e,t.fromCache,r,s)}}/**
2642
+ * @license
2643
+ * Copyright 2023 Google LLC
2644
+ *
2645
+ * Licensed under the Apache License, Version 2.0 (the "License");
2646
+ * you may not use this file except in compliance with the License.
2647
+ * You may obtain a copy of the License at
2648
+ *
2649
+ * http://www.apache.org/licenses/LICENSE-2.0
2650
+ *
2651
+ * Unless required by applicable law or agreed to in writing, software
2652
+ * distributed under the License is distributed on an "AS IS" BASIS,
2653
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654
+ * See the License for the specific language governing permissions and
2655
+ * limitations under the License.
2656
+ */class $y{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
2657
+ * @license
2658
+ * Copyright 2019 Google LLC
2659
+ *
2660
+ * Licensed under the Apache License, Version 2.0 (the "License");
2661
+ * you may not use this file except in compliance with the License.
2662
+ * You may obtain a copy of the License at
2663
+ *
2664
+ * http://www.apache.org/licenses/LICENSE-2.0
2665
+ *
2666
+ * Unless required by applicable law or agreed to in writing, software
2667
+ * distributed under the License is distributed on an "AS IS" BASIS,
2668
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2669
+ * See the License for the specific language governing permissions and
2670
+ * limitations under the License.
2671
+ */class qy{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=(function(){return lf()?8:m_(Ae())>0?6:4})()}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,r,s){const o={result:null};return this.ps(e,t).next((a=>{o.result=a})).next((()=>{if(!o.result)return this.ys(e,t,s,r).next((a=>{o.result=a}))})).next((()=>{if(o.result)return;const a=new $y;return this.ws(e,t,a).next((u=>{if(o.result=u,this.Rs)return this.Ss(e,t,a,u.size)}))})).next((()=>o.result))}Ss(e,t,r,s){return r.documentReadCount<this.Vs?(Yt()<=G.DEBUG&&L("QueryEngine","SDK will not create cache indexes for query:",Zt(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),S.resolve()):(Yt()<=G.DEBUG&&L("QueryEngine","Query:",Zt(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.fs*s?(Yt()<=G.DEBUG&&L("QueryEngine","The SDK decides to create cache indexes for query:",Zt(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,ze(t))):S.resolve())}ps(e,t){if(qc(t))return S.resolve(null);let r=ze(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=Bi(t,null,"F"),r=ze(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((o=>{const a=J(...o);return this.gs.getDocuments(e,a).next((u=>this.indexManager.getMinOffset(e,r).next((l=>{const d=this.bs(t,u);return this.Ds(t,d,a,l.readTime)?this.ps(e,Bi(t,null,"F")):this.vs(e,d,t,l)}))))})))))}ys(e,t,r,s){return qc(t)||s.isEqual($.min())?S.resolve(null):this.gs.getDocuments(e,r).next((o=>{const a=this.bs(t,o);return this.Ds(t,a,r,s)?S.resolve(null):(Yt()<=G.DEBUG&&L("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Zt(t)),this.vs(e,a,t,l_(s,rr)).next((u=>u)))}))}bs(e,t){let r=new le(Hl(e));return t.forEach(((s,o)=>{Os(e,o)&&(r=r.add(o))})),r}Ds(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const o=e.limitType==="F"?t.last():t.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(s)>0)}ws(e,t,r){return Yt()<=G.DEBUG&&L("QueryEngine","Using full collection scan to execute query:",Zt(t)),this.gs.getDocumentsMatchingQuery(e,t,At.min(),r)}vs(e,t,r,s){return this.gs.getDocumentsMatchingQuery(e,r,s).next((o=>(t.forEach((a=>{o=o.insert(a.key,a)})),o)))}}/**
2672
+ * @license
2673
+ * Copyright 2020 Google LLC
2674
+ *
2675
+ * Licensed under the Apache License, Version 2.0 (the "License");
2676
+ * you may not use this file except in compliance with the License.
2677
+ * You may obtain a copy of the License at
2678
+ *
2679
+ * http://www.apache.org/licenses/LICENSE-2.0
2680
+ *
2681
+ * Unless required by applicable law or agreed to in writing, software
2682
+ * distributed under the License is distributed on an "AS IS" BASIS,
2683
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2684
+ * See the License for the specific language governing permissions and
2685
+ * limitations under the License.
2686
+ */const So="LocalStore",zy=3e8;class Hy{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.Fs=new ie(W),this.Ms=new Wt((o=>yo(o)),vo),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(r)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ny(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.Fs)))}}function Wy(n,e,t,r){return new Hy(n,e,t,r)}async function lh(n,e){const t=Q(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((o=>(s=o,t.Ns(e),t.mutationQueue.getAllMutationBatches(r)))).next((o=>{const a=[],u=[];let l=J();for(const d of s){a.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}for(const d of o){u.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}return t.localDocuments.getDocuments(r,l).next((d=>({Bs:d,removedBatchIds:a,addedBatchIds:u})))}))}))}function hh(n){const e=Q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.hi.getLastRemoteSnapshotVersion(t)))}function Gy(n,e){const t=Q(n),r=e.snapshotVersion;let s=t.Fs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(o=>{const a=t.Os.newChangeBuffer({trackRemovals:!0});s=t.Fs;const u=[];e.targetChanges.forEach(((p,v)=>{const E=s.get(v);if(!E)return;u.push(t.hi.removeMatchingKeys(o,p.removedDocuments,v).next((()=>t.hi.addMatchingKeys(o,p.addedDocuments,v))));let C=E.withSequenceNumber(o.currentSequenceNumber);e.targetMismatches.get(v)!==null?C=C.withResumeToken(ge.EMPTY_BYTE_STRING,$.min()).withLastLimboFreeSnapshotVersion($.min()):p.resumeToken.approximateByteSize()>0&&(C=C.withResumeToken(p.resumeToken,r)),s=s.insert(v,C),(function(M,k,q){return M.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-M.snapshotVersion.toMicroseconds()>=zy?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0})(E,C,p)&&u.push(t.hi.updateTargetData(o,C))}));let l=Ct(),d=J();if(e.documentUpdates.forEach((p=>{e.resolvedLimboDocuments.has(p)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(o,p))})),u.push(Ky(o,a,e.documentUpdates).next((p=>{l=p.Ls,d=p.ks}))),!r.isEqual($.min())){const p=t.hi.getLastRemoteSnapshotVersion(o).next((v=>t.hi.setTargetsMetadata(o,o.currentSequenceNumber,r)));u.push(p)}return S.waitFor(u).next((()=>a.apply(o))).next((()=>t.localDocuments.getLocalViewOfDocuments(o,l,d))).next((()=>l))})).then((o=>(t.Fs=s,o)))}function Ky(n,e,t){let r=J(),s=J();return t.forEach((o=>r=r.add(o))),e.getEntries(n,r).next((o=>{let a=Ct();return t.forEach(((u,l)=>{const d=o.get(u);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(u)),l.isNoDocument()&&l.version.isEqual($.min())?(e.removeEntry(u,l.readTime),a=a.insert(u,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(u,l)):L(So,"Ignoring outdated watch update for ",u,". Current version:",d.version," Watch version:",l.version)})),{Ls:a,ks:s}}))}function Qy(n,e){const t=Q(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.hi.getTargetData(r,e).next((o=>o?(s=o,S.resolve(s)):t.hi.allocateTargetId(r).next((a=>(s=new gt(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.hi.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.Fs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Fs=t.Fs.insert(r.targetId,r),t.Ms.set(e,r.targetId)),r}))}async function Wi(n,e,t){const r=Q(n),s=r.Fs.get(e),o=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",o,(a=>r.persistence.referenceDelegate.removeTarget(a,s)))}catch(a){if(!Tn(a))throw a;L(So,`Failed to update sequence numbers for target ${e}: ${a}`)}r.Fs=r.Fs.remove(e),r.Ms.delete(s.target)}function nu(n,e,t){const r=Q(n);let s=$.min(),o=J();return r.persistence.runTransaction("Execute query","readwrite",(a=>(function(l,d,p){const v=Q(l),E=v.Ms.get(p);return E!==void 0?S.resolve(v.Fs.get(E)):v.hi.getTargetData(d,p)})(r,a,ze(e)).next((u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,r.hi.getMatchingKeysForTargetId(a,u.targetId).next((l=>{o=l}))})).next((()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:$.min(),t?o:J()))).next((u=>(Jy(r,j_(e),u),{documents:u,qs:o})))))}function Jy(n,e,t){let r=n.xs.get(e)||$.min();t.forEach(((s,o)=>{o.readTime.compareTo(r)>0&&(r=o.readTime)})),n.xs.set(e,r)}class ru{constructor(){this.activeTargetIds=W_()}Gs(e){this.activeTargetIds=this.activeTargetIds.add(e)}zs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Xy{constructor(){this.Fo=new ru,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Fo.Gs(e),this.Mo[e]||"not-current"}updateQueryState(e,t,r){this.Mo[e]=t}removeLocalQueryTarget(e){this.Fo.zs(e)}isLocalQueryTarget(e){return this.Fo.activeTargetIds.has(e)}clearQueryState(e){delete this.Mo[e]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(e){return this.Fo.activeTargetIds.has(e)}start(){return this.Fo=new ru,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
2687
+ * @license
2688
+ * Copyright 2019 Google LLC
2689
+ *
2690
+ * Licensed under the Apache License, Version 2.0 (the "License");
2691
+ * you may not use this file except in compliance with the License.
2692
+ * You may obtain a copy of the License at
2693
+ *
2694
+ * http://www.apache.org/licenses/LICENSE-2.0
2695
+ *
2696
+ * Unless required by applicable law or agreed to in writing, software
2697
+ * distributed under the License is distributed on an "AS IS" BASIS,
2698
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2699
+ * See the License for the specific language governing permissions and
2700
+ * limitations under the License.
2701
+ */class Yy{xo(e){}shutdown(){}}/**
2702
+ * @license
2703
+ * Copyright 2019 Google LLC
2704
+ *
2705
+ * Licensed under the Apache License, Version 2.0 (the "License");
2706
+ * you may not use this file except in compliance with the License.
2707
+ * You may obtain a copy of the License at
2708
+ *
2709
+ * http://www.apache.org/licenses/LICENSE-2.0
2710
+ *
2711
+ * Unless required by applicable law or agreed to in writing, software
2712
+ * distributed under the License is distributed on an "AS IS" BASIS,
2713
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2714
+ * See the License for the specific language governing permissions and
2715
+ * limitations under the License.
2716
+ */const su="ConnectivityMonitor";class iu{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){L(su,"Network connectivity changed: AVAILABLE");for(const e of this.ko)e(0)}Lo(){L(su,"Network connectivity changed: UNAVAILABLE");for(const e of this.ko)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2717
+ * @license
2718
+ * Copyright 2023 Google LLC
2719
+ *
2720
+ * Licensed under the Apache License, Version 2.0 (the "License");
2721
+ * you may not use this file except in compliance with the License.
2722
+ * You may obtain a copy of the License at
2723
+ *
2724
+ * http://www.apache.org/licenses/LICENSE-2.0
2725
+ *
2726
+ * Unless required by applicable law or agreed to in writing, software
2727
+ * distributed under the License is distributed on an "AS IS" BASIS,
2728
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2729
+ * See the License for the specific language governing permissions and
2730
+ * limitations under the License.
2731
+ */let zr=null;function Gi(){return zr===null?zr=(function(){return 268435456+Math.round(2147483648*Math.random())})():zr++,"0x"+zr.toString(16)}/**
2732
+ * @license
2733
+ * Copyright 2020 Google LLC
2734
+ *
2735
+ * Licensed under the Apache License, Version 2.0 (the "License");
2736
+ * you may not use this file except in compliance with the License.
2737
+ * You may obtain a copy of the License at
2738
+ *
2739
+ * http://www.apache.org/licenses/LICENSE-2.0
2740
+ *
2741
+ * Unless required by applicable law or agreed to in writing, software
2742
+ * distributed under the License is distributed on an "AS IS" BASIS,
2743
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2744
+ * See the License for the specific language governing permissions and
2745
+ * limitations under the License.
2746
+ */const vi="RestConnection",Zy={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class ev{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.Ko=this.databaseId.database===hs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,o){const a=Gi(),u=this.Go(e,t.toUriEncodedString());L(vi,`Sending RPC '${e}' ${a}:`,u,r);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(l,s,o);const{host:d}=new URL(u),p=_n(d);return this.jo(e,u,l,r,p).then((v=>(L(vi,`Received RPC '${e}' ${a}: `,v),v)),(v=>{throw It(vi,`RPC '${e}' ${a} failed with error: `,v,"url: ",u,"request:",r),v}))}Jo(e,t,r,s,o,a){return this.Wo(e,t,r,s,o)}zo(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+En})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,o)=>e[o]=s)),r&&r.headers.forEach(((s,o)=>e[o]=s))}Go(e,t){const r=Zy[e];return`${this.$o}/v1/${t}:${r}`}terminate(){}}/**
2747
+ * @license
2748
+ * Copyright 2017 Google LLC
2749
+ *
2750
+ * Licensed under the Apache License, Version 2.0 (the "License");
2751
+ * you may not use this file except in compliance with the License.
2752
+ * You may obtain a copy of the License at
2753
+ *
2754
+ * http://www.apache.org/licenses/LICENSE-2.0
2755
+ *
2756
+ * Unless required by applicable law or agreed to in writing, software
2757
+ * distributed under the License is distributed on an "AS IS" BASIS,
2758
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2759
+ * See the License for the specific language governing permissions and
2760
+ * limitations under the License.
2761
+ */class tv{constructor(e){this.Ho=e.Ho,this.Yo=e.Yo}Zo(e){this.Xo=e}e_(e){this.t_=e}n_(e){this.r_=e}onMessage(e){this.i_=e}close(){this.Yo()}send(e){this.Ho(e)}s_(){this.Xo()}o_(){this.t_()}__(e){this.r_(e)}a_(e){this.i_(e)}}/**
2762
+ * @license
2763
+ * Copyright 2017 Google LLC
2764
+ *
2765
+ * Licensed under the Apache License, Version 2.0 (the "License");
2766
+ * you may not use this file except in compliance with the License.
2767
+ * You may obtain a copy of the License at
2768
+ *
2769
+ * http://www.apache.org/licenses/LICENSE-2.0
2770
+ *
2771
+ * Unless required by applicable law or agreed to in writing, software
2772
+ * distributed under the License is distributed on an "AS IS" BASIS,
2773
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2774
+ * See the License for the specific language governing permissions and
2775
+ * limitations under the License.
2776
+ */const Te="WebChannelConnection";class nv extends ev{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,r,s,o){const a=Gi();return new Promise(((u,l)=>{const d=new Al;d.setWithCredentials(!0),d.listenOnce(bl.COMPLETE,(()=>{try{switch(d.getLastErrorCode()){case Jr.NO_ERROR:const v=d.getResponseJson();L(Te,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(v)),u(v);break;case Jr.TIMEOUT:L(Te,`RPC '${e}' ${a} timed out`),l(new x(N.DEADLINE_EXCEEDED,"Request time out"));break;case Jr.HTTP_ERROR:const E=d.getStatus();if(L(Te,`RPC '${e}' ${a} failed with status:`,E,"response text:",d.getResponseText()),E>0){let C=d.getResponseJson();Array.isArray(C)&&(C=C[0]);const V=C?.error;if(V&&V.status&&V.message){const M=(function(q){const z=q.toLowerCase().replace(/_/g,"-");return Object.values(N).indexOf(z)>=0?z:N.UNKNOWN})(V.status);l(new x(M,V.message))}else l(new x(N.UNKNOWN,"Server responded with status "+d.getStatus()))}else l(new x(N.UNAVAILABLE,"Connection failed."));break;default:H(9055,{c_:e,streamId:a,l_:d.getLastErrorCode(),h_:d.getLastError()})}}finally{L(Te,`RPC '${e}' ${a} completed.`)}}));const p=JSON.stringify(s);L(Te,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",p,r,15)}))}P_(e,t,r){const s=Gi(),o=[this.$o,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=Cl(),u=Sl(),l={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(l.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(l.useFetchStreams=!0),this.zo(l.initMessageHeaders,t,r),l.encodeInitMessageHeaders=!0;const p=o.join("");L(Te,`Creating RPC '${e}' stream ${s}: ${p}`,l);const v=a.createWebChannel(p,l);this.T_(v);let E=!1,C=!1;const V=new tv({Ho:k=>{C?L(Te,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(E||(L(Te,`Opening RPC '${e}' stream ${s} transport.`),v.open(),E=!0),L(Te,`RPC '${e}' stream ${s} sending:`,k),v.send(k))},Yo:()=>v.close()}),M=(k,q,z)=>{k.listen(q,(B=>{try{z(B)}catch(Y){setTimeout((()=>{throw Y}),0)}}))};return M(v,$n.EventType.OPEN,(()=>{C||(L(Te,`RPC '${e}' stream ${s} transport opened.`),V.s_())})),M(v,$n.EventType.CLOSE,(()=>{C||(C=!0,L(Te,`RPC '${e}' stream ${s} transport closed`),V.__(),this.I_(v))})),M(v,$n.EventType.ERROR,(k=>{C||(C=!0,It(Te,`RPC '${e}' stream ${s} transport errored. Name:`,k.name,"Message:",k.message),V.__(new x(N.UNAVAILABLE,"The operation could not be completed")))})),M(v,$n.EventType.MESSAGE,(k=>{var q;if(!C){const z=k.data[0];ne(!!z,16349);const B=z,Y=B?.error||((q=B[0])===null||q===void 0?void 0:q.error);if(Y){L(Te,`RPC '${e}' stream ${s} received error:`,Y);const he=Y.status;let P=(function(g){const T=oe[g];if(T!==void 0)return Zl(T)})(he),_=Y.message;P===void 0&&(P=N.INTERNAL,_="Unknown error status: "+he+" with message "+Y.message),C=!0,V.__(new x(P,_)),v.close()}else L(Te,`RPC '${e}' stream ${s} received:`,z),V.a_(z)}})),M(u,Rl.STAT_EVENT,(k=>{k.stat===Ni.PROXY?L(Te,`RPC '${e}' stream ${s} detected buffering proxy`):k.stat===Ni.NOPROXY&&L(Te,`RPC '${e}' stream ${s} detected no buffering proxy`)})),setTimeout((()=>{V.o_()}),0),V}terminate(){this.u_.forEach((e=>e.close())),this.u_=[]}T_(e){this.u_.push(e)}I_(e){this.u_=this.u_.filter((t=>t===e))}}function Ei(){return typeof document<"u"?document:null}/**
2777
+ * @license
2778
+ * Copyright 2020 Google LLC
2779
+ *
2780
+ * Licensed under the Apache License, Version 2.0 (the "License");
2781
+ * you may not use this file except in compliance with the License.
2782
+ * You may obtain a copy of the License at
2783
+ *
2784
+ * http://www.apache.org/licenses/LICENSE-2.0
2785
+ *
2786
+ * Unless required by applicable law or agreed to in writing, software
2787
+ * distributed under the License is distributed on an "AS IS" BASIS,
2788
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2789
+ * See the License for the specific language governing permissions and
2790
+ * limitations under the License.
2791
+ */function dh(n){return new uy(n,!0)}/**
2792
+ * @license
2793
+ * Copyright 2017 Google LLC
2794
+ *
2795
+ * Licensed under the Apache License, Version 2.0 (the "License");
2796
+ * you may not use this file except in compliance with the License.
2797
+ * You may obtain a copy of the License at
2798
+ *
2799
+ * http://www.apache.org/licenses/LICENSE-2.0
2800
+ *
2801
+ * Unless required by applicable law or agreed to in writing, software
2802
+ * distributed under the License is distributed on an "AS IS" BASIS,
2803
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2804
+ * See the License for the specific language governing permissions and
2805
+ * limitations under the License.
2806
+ */class fh{constructor(e,t,r=1e3,s=1.5,o=6e4){this.Fi=e,this.timerId=t,this.d_=r,this.E_=s,this.A_=o,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();const t=Math.floor(this.R_+this.p_()),r=Math.max(0,Date.now()-this.m_),s=Math.max(0,t-r);s>0&&L("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.R_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,s,(()=>(this.m_=Date.now(),e()))),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){this.V_!==null&&(this.V_.skipDelay(),this.V_=null)}cancel(){this.V_!==null&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}/**
2807
+ * @license
2808
+ * Copyright 2017 Google LLC
2809
+ *
2810
+ * Licensed under the Apache License, Version 2.0 (the "License");
2811
+ * you may not use this file except in compliance with the License.
2812
+ * You may obtain a copy of the License at
2813
+ *
2814
+ * http://www.apache.org/licenses/LICENSE-2.0
2815
+ *
2816
+ * Unless required by applicable law or agreed to in writing, software
2817
+ * distributed under the License is distributed on an "AS IS" BASIS,
2818
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2819
+ * See the License for the specific language governing permissions and
2820
+ * limitations under the License.
2821
+ */const ou="PersistentStream";class rv{constructor(e,t,r,s,o,a,u,l){this.Fi=e,this.w_=r,this.S_=s,this.connection=o,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=l,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new fh(e,t)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.C_=0,this.state!==4?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,e!==4?this.F_.reset():t&&t.code===N.RESOURCE_EXHAUSTED?(nt(t.toString()),nt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===N.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;const e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.b_===t&&this.W_(r,s)}),(r=>{e((()=>{const s=new x(N.UNKNOWN,"Fetching auth token failed: "+r.message);return this.G_(s)}))}))}W_(e,t){const r=this.K_(this.b_);this.stream=this.z_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.e_((()=>{r((()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,(()=>(this.x_()&&(this.state=3),Promise.resolve()))),this.listener.e_())))})),this.stream.n_((s=>{r((()=>this.G_(s)))})),this.stream.onMessage((s=>{r((()=>++this.C_==1?this.j_(s):this.onNext(s)))}))}O_(){this.state=5,this.F_.g_((async()=>{this.state=0,this.start()}))}G_(e){return L(ou,`close with error: ${e}`),this.stream=null,this.close(4,e)}K_(e){return t=>{this.Fi.enqueueAndForget((()=>this.b_===e?t():(L(ou,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class sv extends rv{constructor(e,t,r,s,o,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=o}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();const t=py(this.serializer,e),r=(function(o){if(!("targetChange"in o))return $.min();const a=o.targetChange;return a.targetIds&&a.targetIds.length?$.min():a.readTime?an(a.readTime):$.min()})(e);return this.listener.J_(t,r)}H_(e){const t={};t.database=Yc(this.serializer),t.addTarget=(function(o,a){let u;const l=a.target;if(u=ji(l)?{documents:my(o,l)}:{query:gy(o,l).Vt},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=hy(o,a.resumeToken);const d=zi(o,a.expectedCount);d!==null&&(u.expectedCount=d)}else if(a.snapshotVersion.compareTo($.min())>0){u.readTime=ly(o,a.snapshotVersion.toTimestamp());const d=zi(o,a.expectedCount);d!==null&&(u.expectedCount=d)}return u})(this.serializer,e);const r=yy(this.serializer,e);r&&(t.labels=r),this.k_(t)}Y_(e){const t={};t.database=Yc(this.serializer),t.removeTarget=e,this.k_(t)}}/**
2822
+ * @license
2823
+ * Copyright 2017 Google LLC
2824
+ *
2825
+ * Licensed under the Apache License, Version 2.0 (the "License");
2826
+ * you may not use this file except in compliance with the License.
2827
+ * You may obtain a copy of the License at
2828
+ *
2829
+ * http://www.apache.org/licenses/LICENSE-2.0
2830
+ *
2831
+ * Unless required by applicable law or agreed to in writing, software
2832
+ * distributed under the License is distributed on an "AS IS" BASIS,
2833
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2834
+ * See the License for the specific language governing permissions and
2835
+ * limitations under the License.
2836
+ */class iv{}class ov extends iv{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ra=!1}ia(){if(this.ra)throw new x(N.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,a])=>this.connection.Wo(e,Hi(t,r),s,o,a))).catch((o=>{throw o.name==="FirebaseError"?(o.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new x(N.UNKNOWN,o.toString())}))}Jo(e,t,r,s,o){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,u])=>this.connection.Jo(e,Hi(t,r),s,a,u,o))).catch((a=>{throw a.name==="FirebaseError"?(a.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new x(N.UNKNOWN,a.toString())}))}terminate(){this.ra=!0,this.connection.terminate()}}class av{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){this.sa===0&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve()))))}la(e){this.state==="Online"?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,e==="Online"&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(e){const t=`Could not reach Cloud Firestore backend. ${e}
2837
+ This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this._a?(nt(t),this._a=!1):L("OnlineStateTracker",t)}ha(){this.oa!==null&&(this.oa.cancel(),this.oa=null)}}/**
2838
+ * @license
2839
+ * Copyright 2017 Google LLC
2840
+ *
2841
+ * Licensed under the Apache License, Version 2.0 (the "License");
2842
+ * you may not use this file except in compliance with the License.
2843
+ * You may obtain a copy of the License at
2844
+ *
2845
+ * http://www.apache.org/licenses/LICENSE-2.0
2846
+ *
2847
+ * Unless required by applicable law or agreed to in writing, software
2848
+ * distributed under the License is distributed on an "AS IS" BASIS,
2849
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2850
+ * See the License for the specific language governing permissions and
2851
+ * limitations under the License.
2852
+ */const mn="RemoteStore";class cv{constructor(e,t,r,s,o){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=o,this.Ea.xo((a=>{r.enqueueAndForget((async()=>{yr(this)&&(L(mn,"Restarting streams for network reachability change."),await(async function(l){const d=Q(l);d.Ia.add(4),await _r(d),d.Aa.set("Unknown"),d.Ia.delete(4),await Ms(d)})(this))}))})),this.Aa=new av(r,s)}}async function Ms(n){if(yr(n))for(const e of n.da)await e(!0)}async function _r(n){for(const e of n.da)await e(!1)}function ph(n,e){const t=Q(n);t.Ta.has(e.targetId)||(t.Ta.set(e.targetId,e),Oo(t)?ko(t):wn(t).x_()&&Po(t,e))}function Co(n,e){const t=Q(n),r=wn(t);t.Ta.delete(e),r.x_()&&mh(t,e),t.Ta.size===0&&(r.x_()?r.B_():yr(t)&&t.Aa.set("Unknown"))}function Po(n,e){if(n.Ra.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo($.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}wn(n).H_(e)}function mh(n,e){n.Ra.$e(e),wn(n).Y_(e)}function ko(n){n.Ra=new iy({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>n.Ta.get(e)||null,lt:()=>n.datastore.serializer.databaseId}),wn(n).start(),n.Aa.aa()}function Oo(n){return yr(n)&&!wn(n).M_()&&n.Ta.size>0}function yr(n){return Q(n).Ia.size===0}function gh(n){n.Ra=void 0}async function uv(n){n.Aa.set("Online")}async function lv(n){n.Ta.forEach(((e,t)=>{Po(n,e)}))}async function hv(n,e){gh(n),Oo(n)?(n.Aa.la(e),ko(n)):n.Aa.set("Unknown")}async function dv(n,e,t){if(n.Aa.set("Online"),e instanceof th&&e.state===2&&e.cause)try{await(async function(s,o){const a=o.cause;for(const u of o.targetIds)s.Ta.has(u)&&(await s.remoteSyncer.rejectListen(u,a),s.Ta.delete(u),s.Ra.removeTarget(u))})(n,e)}catch(r){L(mn,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await au(n,r)}else if(e instanceof es?n.Ra.Ye(e):e instanceof eh?n.Ra.it(e):n.Ra.et(e),!t.isEqual($.min()))try{const r=await hh(n.localStore);t.compareTo(r)>=0&&await(function(o,a){const u=o.Ra.Pt(a);return u.targetChanges.forEach(((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const p=o.Ta.get(d);p&&o.Ta.set(d,p.withResumeToken(l.resumeToken,a))}})),u.targetMismatches.forEach(((l,d)=>{const p=o.Ta.get(l);if(!p)return;o.Ta.set(l,p.withResumeToken(ge.EMPTY_BYTE_STRING,p.snapshotVersion)),mh(o,l);const v=new gt(p.target,l,d,p.sequenceNumber);Po(o,v)})),o.remoteSyncer.applyRemoteEvent(u)})(n,t)}catch(r){L(mn,"Failed to raise snapshot:",r),await au(n,r)}}async function au(n,e,t){if(!Tn(e))throw e;n.Ia.add(1),await _r(n),n.Aa.set("Offline"),t||(t=()=>hh(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{L(mn,"Retrying IndexedDB access"),await t(),n.Ia.delete(1),await Ms(n)}))}async function cu(n,e){const t=Q(n);t.asyncQueue.verifyOperationInProgress(),L(mn,"RemoteStore received new credentials");const r=yr(t);t.Ia.add(3),await _r(t),r&&t.Aa.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ia.delete(3),await Ms(t)}async function fv(n,e){const t=Q(n);e?(t.Ia.delete(2),await Ms(t)):e||(t.Ia.add(2),await _r(t),t.Aa.set("Unknown"))}function wn(n){return n.Va||(n.Va=(function(t,r,s){const o=Q(t);return o.ia(),new sv(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)})(n.datastore,n.asyncQueue,{Zo:uv.bind(null,n),e_:lv.bind(null,n),n_:hv.bind(null,n),J_:dv.bind(null,n)}),n.da.push((async e=>{e?(n.Va.N_(),Oo(n)?ko(n):n.Aa.set("Unknown")):(await n.Va.stop(),gh(n))}))),n.Va}/**
2853
+ * @license
2854
+ * Copyright 2017 Google LLC
2855
+ *
2856
+ * Licensed under the Apache License, Version 2.0 (the "License");
2857
+ * you may not use this file except in compliance with the License.
2858
+ * You may obtain a copy of the License at
2859
+ *
2860
+ * http://www.apache.org/licenses/LICENSE-2.0
2861
+ *
2862
+ * Unless required by applicable law or agreed to in writing, software
2863
+ * distributed under the License is distributed on an "AS IS" BASIS,
2864
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2865
+ * See the License for the specific language governing permissions and
2866
+ * limitations under the License.
2867
+ */class Do{constructor(e,t,r,s,o){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=o,this.deferred=new on,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,o){const a=Date.now()+r,u=new Do(e,t,a,s,o);return u.start(r),u}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new x(N.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function _h(n,e){if(nt("AsyncQueue",`${e}: ${n}`),Tn(n))return new x(N.UNAVAILABLE,`${e}: ${n}`);throw n}/**
2868
+ * @license
2869
+ * Copyright 2017 Google LLC
2870
+ *
2871
+ * Licensed under the Apache License, Version 2.0 (the "License");
2872
+ * you may not use this file except in compliance with the License.
2873
+ * You may obtain a copy of the License at
2874
+ *
2875
+ * http://www.apache.org/licenses/LICENSE-2.0
2876
+ *
2877
+ * Unless required by applicable law or agreed to in writing, software
2878
+ * distributed under the License is distributed on an "AS IS" BASIS,
2879
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2880
+ * See the License for the specific language governing permissions and
2881
+ * limitations under the License.
2882
+ */class cn{static emptySet(e){return new cn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||U.comparator(t.key,r.key):(t,r)=>U.comparator(t.key,r.key),this.keyedMap=qn(),this.sortedSet=new ie(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,r)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof cn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,o=r.getNext().key;if(!s.isEqual(o))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
2883
+ `+e.join(`
2884
+ `)+`
2885
+ )`}copy(e,t){const r=new cn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
2886
+ * @license
2887
+ * Copyright 2017 Google LLC
2888
+ *
2889
+ * Licensed under the Apache License, Version 2.0 (the "License");
2890
+ * you may not use this file except in compliance with the License.
2891
+ * You may obtain a copy of the License at
2892
+ *
2893
+ * http://www.apache.org/licenses/LICENSE-2.0
2894
+ *
2895
+ * Unless required by applicable law or agreed to in writing, software
2896
+ * distributed under the License is distributed on an "AS IS" BASIS,
2897
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2898
+ * See the License for the specific language governing permissions and
2899
+ * limitations under the License.
2900
+ */class uu{constructor(){this.fa=new ie(U.comparator)}track(e){const t=e.doc.key,r=this.fa.get(t);r?e.type!==0&&r.type===3?this.fa=this.fa.insert(t,e):e.type===3&&r.type!==1?this.fa=this.fa.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.fa=this.fa.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.fa=this.fa.remove(t):e.type===1&&r.type===2?this.fa=this.fa.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):H(63341,{At:e,ga:r}):this.fa=this.fa.insert(t,e)}pa(){const e=[];return this.fa.inorderTraversal(((t,r)=>{e.push(r)})),e}}class gn{constructor(e,t,r,s,o,a,u,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=o,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,o){const a=[];return t.forEach((u=>{a.push({type:0,doc:u})})),new gn(e,t,cn.emptySet(t),a,r,s,!0,!1,o)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ks(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
2901
+ * @license
2902
+ * Copyright 2017 Google LLC
2903
+ *
2904
+ * Licensed under the Apache License, Version 2.0 (the "License");
2905
+ * you may not use this file except in compliance with the License.
2906
+ * You may obtain a copy of the License at
2907
+ *
2908
+ * http://www.apache.org/licenses/LICENSE-2.0
2909
+ *
2910
+ * Unless required by applicable law or agreed to in writing, software
2911
+ * distributed under the License is distributed on an "AS IS" BASIS,
2912
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2913
+ * See the License for the specific language governing permissions and
2914
+ * limitations under the License.
2915
+ */class pv{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some((e=>e.ba()))}}class mv{constructor(){this.queries=lu(),this.onlineState="Unknown",this.Da=new Set}terminate(){(function(t,r){const s=Q(t),o=s.queries;s.queries=lu(),o.forEach(((a,u)=>{for(const l of u.wa)l.onError(r)}))})(this,new x(N.ABORTED,"Firestore shutting down"))}}function lu(){return new Wt((n=>zl(n)),ks)}async function gv(n,e){const t=Q(n);let r=3;const s=e.query;let o=t.queries.get(s);o?!o.Sa()&&e.ba()&&(r=2):(o=new pv,r=e.ba()?0:1);try{switch(r){case 0:o.ya=await t.onListen(s,!0);break;case 1:o.ya=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const u=_h(a,`Initialization of query '${Zt(e.query)}' failed`);return void e.onError(u)}t.queries.set(s,o),o.wa.push(e),e.va(t.onlineState),o.ya&&e.Ca(o.ya)&&No(t)}async function _v(n,e){const t=Q(n),r=e.query;let s=3;const o=t.queries.get(r);if(o){const a=o.wa.indexOf(e);a>=0&&(o.wa.splice(a,1),o.wa.length===0?s=e.ba()?0:1:!o.Sa()&&e.ba()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function yv(n,e){const t=Q(n);let r=!1;for(const s of e){const o=s.query,a=t.queries.get(o);if(a){for(const u of a.wa)u.Ca(s)&&(r=!0);a.ya=s}}r&&No(t)}function vv(n,e,t){const r=Q(n),s=r.queries.get(e);if(s)for(const o of s.wa)o.onError(t);r.queries.delete(e)}function No(n){n.Da.forEach((e=>{e.next()}))}var Ki,hu;(hu=Ki||(Ki={})).Fa="default",hu.Cache="cache";class Ev{constructor(e,t,r){this.query=e,this.Ma=t,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=r||{}}Ca(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new gn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.xa?this.Na(e)&&(this.Ma.next(e),t=!0):this.Ba(e,this.onlineState)&&(this.La(e),t=!0),this.Oa=e,t}onError(e){this.Ma.error(e)}va(e){this.onlineState=e;let t=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,e)&&(this.La(this.Oa),t=!0),t}Ba(e,t){if(!e.fromCache||!this.ba())return!0;const r=t!=="Offline";return(!this.options.ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Na(e){if(e.docChanges.length>0)return!0;const t=this.Oa&&this.Oa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}La(e){e=gn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.xa=!0,this.Ma.next(e)}ba(){return this.options.source!==Ki.Cache}}/**
2916
+ * @license
2917
+ * Copyright 2017 Google LLC
2918
+ *
2919
+ * Licensed under the Apache License, Version 2.0 (the "License");
2920
+ * you may not use this file except in compliance with the License.
2921
+ * You may obtain a copy of the License at
2922
+ *
2923
+ * http://www.apache.org/licenses/LICENSE-2.0
2924
+ *
2925
+ * Unless required by applicable law or agreed to in writing, software
2926
+ * distributed under the License is distributed on an "AS IS" BASIS,
2927
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2928
+ * See the License for the specific language governing permissions and
2929
+ * limitations under the License.
2930
+ */class yh{constructor(e){this.key=e}}class vh{constructor(e){this.key=e}}class Tv{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=J(),this.mutatedKeys=J(),this.Xa=Hl(e),this.eu=new cn(this.Xa)}get tu(){return this.Ha}nu(e,t){const r=t?t.ru:new uu,s=t?t.eu:this.eu;let o=t?t.mutatedKeys:this.mutatedKeys,a=s,u=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((p,v)=>{const E=s.get(p),C=Os(this.query,v)?v:null,V=!!E&&this.mutatedKeys.has(E.key),M=!!C&&(C.hasLocalMutations||this.mutatedKeys.has(C.key)&&C.hasCommittedMutations);let k=!1;E&&C?E.data.isEqual(C.data)?V!==M&&(r.track({type:3,doc:C}),k=!0):this.iu(E,C)||(r.track({type:2,doc:C}),k=!0,(l&&this.Xa(C,l)>0||d&&this.Xa(C,d)<0)&&(u=!0)):!E&&C?(r.track({type:0,doc:C}),k=!0):E&&!C&&(r.track({type:1,doc:E}),k=!0,(l||d)&&(u=!0)),k&&(C?(a=a.add(C),o=M?o.add(p):o.delete(p)):(a=a.delete(p),o=o.delete(p)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const p=this.query.limitType==="F"?a.last():a.first();a=a.delete(p.key),o=o.delete(p.key),r.track({type:1,doc:p})}return{eu:a,ru:r,Ds:u,mutatedKeys:o}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const o=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;const a=e.ru.pa();a.sort(((p,v)=>(function(C,V){const M=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return H(20277,{At:k})}};return M(C)-M(V)})(p.type,v.type)||this.Xa(p.doc,v.doc))),this.su(r),s=s!=null&&s;const u=t&&!s?this.ou():[],l=this.Za.size===0&&this.current&&!s?1:0,d=l!==this.Ya;return this.Ya=l,a.length!==0||d?{snapshot:new gn(this.query,e.eu,o,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),_u:u}:{_u:u}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({eu:this.eu,ru:new uu,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach((t=>this.Ha=this.Ha.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Ha=this.Ha.delete(t))),this.current=e.current)}ou(){if(!this.current)return[];const e=this.Za;this.Za=J(),this.eu.forEach((r=>{this.au(r.key)&&(this.Za=this.Za.add(r.key))}));const t=[];return e.forEach((r=>{this.Za.has(r)||t.push(new vh(r))})),this.Za.forEach((r=>{e.has(r)||t.push(new yh(r))})),t}uu(e){this.Ha=e.qs,this.Za=J();const t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return gn.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,this.Ya===0,this.hasCachedResults)}}const Vo="SyncEngine";class wv{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class Iv{constructor(e){this.key=e,this.lu=!1}}class Av{constructor(e,t,r,s,o,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=o,this.maxConcurrentLimboResolutions=a,this.hu={},this.Pu=new Wt((u=>zl(u)),ks),this.Tu=new Map,this.Iu=new Set,this.du=new ie(U.comparator),this.Eu=new Map,this.Au=new Ao,this.Ru={},this.Vu=new Map,this.mu=pn.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return this.fu===!0}}async function bv(n,e,t=!0){const r=Ah(n);let s;const o=r.Pu.get(e);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),s=o.view.cu()):s=await Eh(r,e,t,!0),s}async function Rv(n,e){const t=Ah(n);await Eh(t,e,!0,!1)}async function Eh(n,e,t,r){const s=await Qy(n.localStore,ze(e)),o=s.targetId,a=n.sharedClientState.addLocalQueryTarget(o,t);let u;return r&&(u=await Sv(n,e,o,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&ph(n.remoteStore,s),u}async function Sv(n,e,t,r,s){n.gu=(v,E,C)=>(async function(M,k,q,z){let B=k.view.nu(q);B.Ds&&(B=await nu(M.localStore,k.query,!1).then((({documents:_})=>k.view.nu(_,B))));const Y=z&&z.targetChanges.get(k.targetId),he=z&&z.targetMismatches.get(k.targetId)!=null,P=k.view.applyChanges(B,M.isPrimaryClient,Y,he);return fu(M,k.targetId,P._u),P.snapshot})(n,v,E,C);const o=await nu(n.localStore,e,!0),a=new Tv(e,o.qs),u=a.nu(o.documents),l=gr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(u,n.isPrimaryClient,l);fu(n,t,d._u);const p=new wv(e,t,a);return n.Pu.set(e,p),n.Tu.has(t)?n.Tu.get(t).push(e):n.Tu.set(t,[e]),d.snapshot}async function Cv(n,e,t){const r=Q(n),s=r.Pu.get(e),o=r.Tu.get(s.targetId);if(o.length>1)return r.Tu.set(s.targetId,o.filter((a=>!ks(a,e)))),void r.Pu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Wi(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Co(r.remoteStore,s.targetId),Qi(r,s.targetId)})).catch(bs)):(Qi(r,s.targetId),await Wi(r.localStore,s.targetId,!0))}async function Pv(n,e){const t=Q(n),r=t.Pu.get(e),s=t.Tu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Co(t.remoteStore,r.targetId))}async function Th(n,e){const t=Q(n);try{const r=await Gy(t.localStore,e);e.targetChanges.forEach(((s,o)=>{const a=t.Eu.get(o);a&&(ne(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.lu=!0:s.modifiedDocuments.size>0?ne(a.lu,14607):s.removedDocuments.size>0&&(ne(a.lu,42227),a.lu=!1))})),await Ih(t,r,e)}catch(r){await bs(r)}}function du(n,e,t){const r=Q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Pu.forEach(((o,a)=>{const u=a.view.va(e);u.snapshot&&s.push(u.snapshot)})),(function(a,u){const l=Q(a);l.onlineState=u;let d=!1;l.queries.forEach(((p,v)=>{for(const E of v.wa)E.va(u)&&(d=!0)})),d&&No(l)})(r.eventManager,e),s.length&&r.hu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function kv(n,e,t){const r=Q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Eu.get(e),o=s&&s.key;if(o){let a=new ie(U.comparator);a=a.insert(o,Ie.newNoDocument(o,$.min()));const u=J().add(o),l=new Vs($.min(),new Map,new ie(W),a,u);await Th(r,l),r.du=r.du.remove(o),r.Eu.delete(e),Mo(r)}else await Wi(r.localStore,e,!1).then((()=>Qi(r,e,t))).catch(bs)}function Qi(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Tu.get(e))n.Pu.delete(r),t&&n.hu.pu(r,t);n.Tu.delete(e),n.isPrimaryClient&&n.Au.zr(e).forEach((r=>{n.Au.containsKey(r)||wh(n,r)}))}function wh(n,e){n.Iu.delete(e.path.canonicalString());const t=n.du.get(e);t!==null&&(Co(n.remoteStore,t),n.du=n.du.remove(e),n.Eu.delete(t),Mo(n))}function fu(n,e,t){for(const r of t)r instanceof yh?(n.Au.addReference(r.key,e),Ov(n,r)):r instanceof vh?(L(Vo,"Document no longer in limbo: "+r.key),n.Au.removeReference(r.key,e),n.Au.containsKey(r.key)||wh(n,r.key)):H(19791,{yu:r})}function Ov(n,e){const t=e.key,r=t.path.canonicalString();n.du.get(t)||n.Iu.has(r)||(L(Vo,"New document in limbo: "+t),n.Iu.add(r),Mo(n))}function Mo(n){for(;n.Iu.size>0&&n.du.size<n.maxConcurrentLimboResolutions;){const e=n.Iu.values().next().value;n.Iu.delete(e);const t=new U(te.fromString(e)),r=n.mu.next();n.Eu.set(r,new Iv(t)),n.du=n.du.insert(t,r),ph(n.remoteStore,new gt(ze(Eo(t.path)),r,"TargetPurposeLimboResolution",Rs.ue))}}async function Ih(n,e,t){const r=Q(n),s=[],o=[],a=[];r.Pu.isEmpty()||(r.Pu.forEach(((u,l)=>{a.push(r.gu(l,e,t).then((d=>{var p;if((d||t)&&r.isPrimaryClient){const v=d?!d.fromCache:(p=t?.targetChanges.get(l.targetId))===null||p===void 0?void 0:p.current;r.sharedClientState.updateQueryState(l.targetId,v?"current":"not-current")}if(d){s.push(d);const v=Ro.Es(l.targetId,d);o.push(v)}})))})),await Promise.all(a),r.hu.J_(s),await(async function(l,d){const p=Q(l);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",(v=>S.forEach(d,(E=>S.forEach(E.Is,(C=>p.persistence.referenceDelegate.addReference(v,E.targetId,C))).next((()=>S.forEach(E.ds,(C=>p.persistence.referenceDelegate.removeReference(v,E.targetId,C)))))))))}catch(v){if(!Tn(v))throw v;L(So,"Failed to update sequence numbers: "+v)}for(const v of d){const E=v.targetId;if(!v.fromCache){const C=p.Fs.get(E),V=C.snapshotVersion,M=C.withLastLimboFreeSnapshotVersion(V);p.Fs=p.Fs.insert(E,M)}}})(r.localStore,o))}async function Dv(n,e){const t=Q(n);if(!t.currentUser.isEqual(e)){L(Vo,"User change. New user:",e.toKey());const r=await lh(t.localStore,e);t.currentUser=e,(function(o,a){o.Vu.forEach((u=>{u.forEach((l=>{l.reject(new x(N.CANCELLED,a))}))})),o.Vu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Ih(t,r.Bs)}}function Nv(n,e){const t=Q(n),r=t.Eu.get(e);if(r&&r.lu)return J().add(r.key);{let s=J();const o=t.Tu.get(e);if(!o)return s;for(const a of o){const u=t.Pu.get(a);s=s.unionWith(u.view.tu)}return s}}function Ah(n){const e=Q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Th.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Nv.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=kv.bind(null,e),e.hu.J_=yv.bind(null,e.eventManager),e.hu.pu=vv.bind(null,e.eventManager),e}class _s{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=dh(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){return Wy(this.persistence,new qy,e.initialUser,this.serializer)}Du(e){return new uh(bo.Vi,this.serializer)}bu(e){return new Xy}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}_s.provider={build:()=>new _s};class Vv extends _s{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){ne(this.persistence.referenceDelegate instanceof gs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Cy(r,e.asyncQueue,t)}Du(e){const t=this.cacheSizeBytes!==void 0?Pe.withCacheSize(this.cacheSizeBytes):Pe.DEFAULT;return new uh((r=>gs.Vi(r,t)),this.serializer)}}class Ji{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>du(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=Dv.bind(null,this.syncEngine),await fv(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new mv})()}createDatastore(e){const t=dh(e.databaseInfo.databaseId),r=(function(o){return new nv(o)})(e.databaseInfo);return(function(o,a,u,l){return new ov(o,a,u,l)})(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,o,a,u){return new cv(r,s,o,a,u)})(this.localStore,this.datastore,e.asyncQueue,(t=>du(this.syncEngine,t,0)),(function(){return iu.C()?new iu:new Yy})())}createSyncEngine(e,t){return(function(s,o,a,u,l,d,p){const v=new Av(s,o,a,u,l,d);return p&&(v.fu=!0),v})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await(async function(s){const o=Q(s);L(mn,"RemoteStore shutting down."),o.Ia.add(5),await _r(o),o.Ea.shutdown(),o.Aa.set("Unknown")})(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}Ji.provider={build:()=>new Ji};/**
2931
+ * @license
2932
+ * Copyright 2020 Google LLC
2933
+ *
2934
+ * Licensed under the Apache License, Version 2.0 (the "License");
2935
+ * you may not use this file except in compliance with the License.
2936
+ * You may obtain a copy of the License at
2937
+ *
2938
+ * http://www.apache.org/licenses/LICENSE-2.0
2939
+ *
2940
+ * Unless required by applicable law or agreed to in writing, software
2941
+ * distributed under the License is distributed on an "AS IS" BASIS,
2942
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2943
+ * See the License for the specific language governing permissions and
2944
+ * limitations under the License.
2945
+ *//**
2946
+ * @license
2947
+ * Copyright 2017 Google LLC
2948
+ *
2949
+ * Licensed under the Apache License, Version 2.0 (the "License");
2950
+ * you may not use this file except in compliance with the License.
2951
+ * You may obtain a copy of the License at
2952
+ *
2953
+ * http://www.apache.org/licenses/LICENSE-2.0
2954
+ *
2955
+ * Unless required by applicable law or agreed to in writing, software
2956
+ * distributed under the License is distributed on an "AS IS" BASIS,
2957
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2958
+ * See the License for the specific language governing permissions and
2959
+ * limitations under the License.
2960
+ */class Mv{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.xu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.xu(this.observer.error,e):nt("Uncaught Error in snapshot listener:",e.toString()))}Ou(){this.muted=!0}xu(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}/**
2961
+ * @license
2962
+ * Copyright 2017 Google LLC
2963
+ *
2964
+ * Licensed under the Apache License, Version 2.0 (the "License");
2965
+ * you may not use this file except in compliance with the License.
2966
+ * You may obtain a copy of the License at
2967
+ *
2968
+ * http://www.apache.org/licenses/LICENSE-2.0
2969
+ *
2970
+ * Unless required by applicable law or agreed to in writing, software
2971
+ * distributed under the License is distributed on an "AS IS" BASIS,
2972
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2973
+ * See the License for the specific language governing permissions and
2974
+ * limitations under the License.
2975
+ */const Pt="FirestoreClient";class Lv{constructor(e,t,r,s,o){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=we.UNAUTHENTICATED,this.clientId=mo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=o,this.authCredentials.start(r,(async a=>{L(Pt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(r,(a=>(L(Pt,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new on;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=_h(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function Ti(n,e){n.asyncQueue.verifyOperationInProgress(),L(Pt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await lh(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>{It("Terminating Firestore due to IndexedDb database deletion"),n.terminate().then((()=>{L("Terminating Firestore due to IndexedDb database deletion completed successfully")})).catch((s=>{It("Terminating Firestore due to IndexedDb database deletion failed",s)}))})),n._offlineComponents=e}async function pu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await xv(n);L(Pt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>cu(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>cu(e.remoteStore,s))),n._onlineComponents=e}async function xv(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){L(Pt,"Using user provided OfflineComponentProvider");try{await Ti(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===N.FAILED_PRECONDITION||s.code===N.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;It("Error using user provided cache. Falling back to memory cache: "+t),await Ti(n,new _s)}}else L(Pt,"Using default OfflineComponentProvider"),await Ti(n,new Vv(void 0));return n._offlineComponents}async function Uv(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(L(Pt,"Using user provided OnlineComponentProvider"),await pu(n,n._uninitializedComponentsProvider._online)):(L(Pt,"Using default OnlineComponentProvider"),await pu(n,new Ji))),n._onlineComponents}async function mu(n){const e=await Uv(n),t=e.eventManager;return t.onListen=bv.bind(null,e.syncEngine),t.onUnlisten=Cv.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=Rv.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=Pv.bind(null,e.syncEngine),t}/**
2976
+ * @license
2977
+ * Copyright 2023 Google LLC
2978
+ *
2979
+ * Licensed under the Apache License, Version 2.0 (the "License");
2980
+ * you may not use this file except in compliance with the License.
2981
+ * You may obtain a copy of the License at
2982
+ *
2983
+ * http://www.apache.org/licenses/LICENSE-2.0
2984
+ *
2985
+ * Unless required by applicable law or agreed to in writing, software
2986
+ * distributed under the License is distributed on an "AS IS" BASIS,
2987
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2988
+ * See the License for the specific language governing permissions and
2989
+ * limitations under the License.
2990
+ */function bh(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
2991
+ * @license
2992
+ * Copyright 2020 Google LLC
2993
+ *
2994
+ * Licensed under the Apache License, Version 2.0 (the "License");
2995
+ * you may not use this file except in compliance with the License.
2996
+ * You may obtain a copy of the License at
2997
+ *
2998
+ * http://www.apache.org/licenses/LICENSE-2.0
2999
+ *
3000
+ * Unless required by applicable law or agreed to in writing, software
3001
+ * distributed under the License is distributed on an "AS IS" BASIS,
3002
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3003
+ * See the License for the specific language governing permissions and
3004
+ * limitations under the License.
3005
+ */const gu=new Map;/**
3006
+ * @license
3007
+ * Copyright 2020 Google LLC
3008
+ *
3009
+ * Licensed under the Apache License, Version 2.0 (the "License");
3010
+ * you may not use this file except in compliance with the License.
3011
+ * You may obtain a copy of the License at
3012
+ *
3013
+ * http://www.apache.org/licenses/LICENSE-2.0
3014
+ *
3015
+ * Unless required by applicable law or agreed to in writing, software
3016
+ * distributed under the License is distributed on an "AS IS" BASIS,
3017
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3018
+ * See the License for the specific language governing permissions and
3019
+ * limitations under the License.
3020
+ */const Rh="firestore.googleapis.com",_u=!0;class yu{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new x(N.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Rh,this.ssl=_u}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:_u;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=ch;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Ry)throw new x(N.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}a_("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=bh((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),(function(o){if(o.timeoutSeconds!==void 0){if(isNaN(o.timeoutSeconds))throw new x(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (must not be NaN)`);if(o.timeoutSeconds<5)throw new x(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (minimum allowed value is 5)`);if(o.timeoutSeconds>30)throw new x(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Lo{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new yu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new x(N.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new x(N.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new yu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new Xg;switch(r.type){case"firstParty":return new t_(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new x(N.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=gu.get(t);r&&(L("ComponentProvider","Removing Datastore"),gu.delete(t),r.terminate())})(this),Promise.resolve()}}function Fv(n,e,t,r={}){var s;n=Xr(n,Lo);const o=_n(e),a=n._getSettings(),u=Object.assign(Object.assign({},a),{emulatorOptions:n._getEmulatorOptions()}),l=`${e}:${t}`;o&&(Vu(`https://${l}`),Mu("Firestore",!0)),a.host!==Rh&&a.host!==l&&It("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const d=Object.assign(Object.assign({},a),{host:l,ssl:o,emulatorOptions:r});if(!Bt(d,u)&&(n._setSettings(d),r.mockUserToken)){let p,v;if(typeof r.mockUserToken=="string")p=r.mockUserToken,v=we.MOCK_USER;else{p=ef(r.mockUserToken,(s=n._app)===null||s===void 0?void 0:s.options.projectId);const E=r.mockUserToken.sub||r.mockUserToken.user_id;if(!E)throw new x(N.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");v=new we(E)}n._authCredentials=new Yg(new kl(p,v))}}/**
3021
+ * @license
3022
+ * Copyright 2020 Google LLC
3023
+ *
3024
+ * Licensed under the Apache License, Version 2.0 (the "License");
3025
+ * you may not use this file except in compliance with the License.
3026
+ * You may obtain a copy of the License at
3027
+ *
3028
+ * http://www.apache.org/licenses/LICENSE-2.0
3029
+ *
3030
+ * Unless required by applicable law or agreed to in writing, software
3031
+ * distributed under the License is distributed on an "AS IS" BASIS,
3032
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3033
+ * See the License for the specific language governing permissions and
3034
+ * limitations under the License.
3035
+ */class Ls{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new Ls(this.firestore,e,this._query)}}class Ce{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new ar(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Ce(this.firestore,e,this._key)}toJSON(){return{type:Ce._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(pr(t,Ce._jsonSchema))return new Ce(e,r||null,new U(te.fromString(t.referencePath)))}}Ce._jsonSchemaVersion="firestore/documentReference/1.0",Ce._jsonSchema={type:ce("string",Ce._jsonSchemaVersion),referencePath:ce("string")};class ar extends Ls{constructor(e,t,r){super(e,t,Eo(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Ce(this.firestore,null,new U(e))}withConverter(e){return new ar(this.firestore,e,this._path)}}function jv(n,e,...t){if(n=xe(n),arguments.length===1&&(e=mo.newId()),o_("doc","path",e),n instanceof Lo){const r=te.fromString(e,...t);return kc(r),new Ce(n,null,new U(r))}{if(!(n instanceof Ce||n instanceof ar))throw new x(N.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(te.fromString(e,...t));return kc(r),new Ce(n.firestore,n instanceof ar?n.converter:null,new U(r))}}/**
3036
+ * @license
3037
+ * Copyright 2020 Google LLC
3038
+ *
3039
+ * Licensed under the Apache License, Version 2.0 (the "License");
3040
+ * you may not use this file except in compliance with the License.
3041
+ * You may obtain a copy of the License at
3042
+ *
3043
+ * http://www.apache.org/licenses/LICENSE-2.0
3044
+ *
3045
+ * Unless required by applicable law or agreed to in writing, software
3046
+ * distributed under the License is distributed on an "AS IS" BASIS,
3047
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3048
+ * See the License for the specific language governing permissions and
3049
+ * limitations under the License.
3050
+ */const vu="AsyncQueue";class Eu{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new fh(this,"async_queue_retry"),this.oc=()=>{const r=Ei();r&&L(vu,"Visibility state changed to "+r.visibilityState),this.F_.y_()},this._c=e;const t=Ei();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ac(),this.uc(e)}enterRestrictedMode(e){if(!this.Xu){this.Xu=!0,this.rc=e||!1;const t=Ei();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.oc)}}enqueue(e){if(this.ac(),this.Xu)return new Promise((()=>{}));const t=new on;return this.uc((()=>this.Xu&&this.rc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Zu.push(e),this.cc())))}async cc(){if(this.Zu.length!==0){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(e){if(!Tn(e))throw e;L(vu,"Operation failed with retryable error: "+e)}this.Zu.length>0&&this.F_.g_((()=>this.cc()))}}uc(e){const t=this._c.then((()=>(this.nc=!0,e().catch((r=>{throw this.tc=r,this.nc=!1,nt("INTERNAL UNHANDLED ERROR: ",Tu(r)),r})).then((r=>(this.nc=!1,r))))));return this._c=t,t}enqueueAfterDelay(e,t,r){this.ac(),this.sc.indexOf(e)>-1&&(t=0);const s=Do.createAndSchedule(this,e,t,r,(o=>this.lc(o)));return this.ec.push(s),s}ac(){this.tc&&H(47125,{hc:Tu(this.tc)})}verifyOperationInProgress(){}async Pc(){let e;do e=this._c,await e;while(e!==this._c)}Tc(e){for(const t of this.ec)if(t.timerId===e)return!0;return!1}Ic(e){return this.Pc().then((()=>{this.ec.sort(((t,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.ec)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Pc()}))}dc(e){this.sc.push(e)}lc(e){const t=this.ec.indexOf(e);this.ec.splice(t,1)}}function Tu(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
3051
+ `+n.stack),e}/**
3052
+ * @license
3053
+ * Copyright 2017 Google LLC
3054
+ *
3055
+ * Licensed under the Apache License, Version 2.0 (the "License");
3056
+ * you may not use this file except in compliance with the License.
3057
+ * You may obtain a copy of the License at
3058
+ *
3059
+ * http://www.apache.org/licenses/LICENSE-2.0
3060
+ *
3061
+ * Unless required by applicable law or agreed to in writing, software
3062
+ * distributed under the License is distributed on an "AS IS" BASIS,
3063
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3064
+ * See the License for the specific language governing permissions and
3065
+ * limitations under the License.
3066
+ */function wu(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const o of r)if(o in s&&typeof s[o]=="function")return!0;return!1})(n,["next","error","complete"])}class Xi extends Lo{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new Eu,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Eu(e),this._firestoreClient=void 0,await e}}}function Bv(n,e){const t=typeof n=="object"?n:Fu(),r=typeof n=="string"?n:hs,s=to(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const o=Yd("firestore");o&&Fv(s,...o)}return s}function $v(n){if(n._terminated)throw new x(N.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||qv(n),n._firestoreClient}function qv(n){var e,t,r;const s=n._freezeSettings(),o=(function(u,l,d,p){return new T_(u,l,d,p.host,p.ssl,p.experimentalForceLongPolling,p.experimentalAutoDetectLongPolling,bh(p.experimentalLongPollingOptions),p.useFetchStreams,p.isUsingEmulator)})(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,s);n._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),n._firestoreClient=new Lv(n._authCredentials,n._appCheckCredentials,n._queue,o,n._componentsProvider&&(function(u){const l=u?._online.build();return{_offline:u?._offline.build(l),_online:l}})(n._componentsProvider))}/**
3067
+ * @license
3068
+ * Copyright 2020 Google LLC
3069
+ *
3070
+ * Licensed under the Apache License, Version 2.0 (the "License");
3071
+ * you may not use this file except in compliance with the License.
3072
+ * You may obtain a copy of the License at
3073
+ *
3074
+ * http://www.apache.org/licenses/LICENSE-2.0
3075
+ *
3076
+ * Unless required by applicable law or agreed to in writing, software
3077
+ * distributed under the License is distributed on an "AS IS" BASIS,
3078
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3079
+ * See the License for the specific language governing permissions and
3080
+ * limitations under the License.
3081
+ */class Be{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Be(ge.fromBase64String(e))}catch(t){throw new x(N.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new Be(ge.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:Be._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(pr(e,Be._jsonSchema))return Be.fromBase64String(e.bytes)}}Be._jsonSchemaVersion="firestore/bytes/1.0",Be._jsonSchema={type:ce("string",Be._jsonSchemaVersion),bytes:ce("string")};/**
3082
+ * @license
3083
+ * Copyright 2020 Google LLC
3084
+ *
3085
+ * Licensed under the Apache License, Version 2.0 (the "License");
3086
+ * you may not use this file except in compliance with the License.
3087
+ * You may obtain a copy of the License at
3088
+ *
3089
+ * http://www.apache.org/licenses/LICENSE-2.0
3090
+ *
3091
+ * Unless required by applicable law or agreed to in writing, software
3092
+ * distributed under the License is distributed on an "AS IS" BASIS,
3093
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3094
+ * See the License for the specific language governing permissions and
3095
+ * limitations under the License.
3096
+ */class Sh{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new x(N.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Se(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
3097
+ * @license
3098
+ * Copyright 2017 Google LLC
3099
+ *
3100
+ * Licensed under the Apache License, Version 2.0 (the "License");
3101
+ * you may not use this file except in compliance with the License.
3102
+ * You may obtain a copy of the License at
3103
+ *
3104
+ * http://www.apache.org/licenses/LICENSE-2.0
3105
+ *
3106
+ * Unless required by applicable law or agreed to in writing, software
3107
+ * distributed under the License is distributed on an "AS IS" BASIS,
3108
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3109
+ * See the License for the specific language governing permissions and
3110
+ * limitations under the License.
3111
+ */class Tt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new x(N.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new x(N.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return W(this._lat,e._lat)||W(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Tt._jsonSchemaVersion}}static fromJSON(e){if(pr(e,Tt._jsonSchema))return new Tt(e.latitude,e.longitude)}}Tt._jsonSchemaVersion="firestore/geoPoint/1.0",Tt._jsonSchema={type:ce("string",Tt._jsonSchemaVersion),latitude:ce("number"),longitude:ce("number")};/**
3112
+ * @license
3113
+ * Copyright 2024 Google LLC
3114
+ *
3115
+ * Licensed under the Apache License, Version 2.0 (the "License");
3116
+ * you may not use this file except in compliance with the License.
3117
+ * You may obtain a copy of the License at
3118
+ *
3119
+ * http://www.apache.org/licenses/LICENSE-2.0
3120
+ *
3121
+ * Unless required by applicable law or agreed to in writing, software
3122
+ * distributed under the License is distributed on an "AS IS" BASIS,
3123
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3124
+ * See the License for the specific language governing permissions and
3125
+ * limitations under the License.
3126
+ */class wt{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let o=0;o<r.length;++o)if(r[o]!==s[o])return!1;return!0})(this._values,e._values)}toJSON(){return{type:wt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(pr(e,wt._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new wt(e.vectorValues);throw new x(N.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}wt._jsonSchemaVersion="firestore/vectorValue/1.0",wt._jsonSchema={type:ce("string",wt._jsonSchemaVersion),vectorValues:ce("object")};const zv=new RegExp("[~\\*/\\[\\]]");function Hv(n,e,t){if(e.search(zv)>=0)throw Iu(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n);try{return new Sh(...e.split("."))._internalPath}catch{throw Iu(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n)}}function Iu(n,e,t,r,s){let o=`Function ${e}() called with invalid data`;o+=". ";let a="";return new x(N.INVALID_ARGUMENT,o+n+a)}/**
3127
+ * @license
3128
+ * Copyright 2020 Google LLC
3129
+ *
3130
+ * Licensed under the Apache License, Version 2.0 (the "License");
3131
+ * you may not use this file except in compliance with the License.
3132
+ * You may obtain a copy of the License at
3133
+ *
3134
+ * http://www.apache.org/licenses/LICENSE-2.0
3135
+ *
3136
+ * Unless required by applicable law or agreed to in writing, software
3137
+ * distributed under the License is distributed on an "AS IS" BASIS,
3138
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3139
+ * See the License for the specific language governing permissions and
3140
+ * limitations under the License.
3141
+ */class Ch{constructor(e,t,r,s,o){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new Ce(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new Wv(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(Ph("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class Wv extends Ch{data(){return super.data()}}function Ph(n,e){return typeof e=="string"?Hv(n,e):e instanceof Sh?e._internalPath:e._delegate._internalPath}/**
3142
+ * @license
3143
+ * Copyright 2020 Google LLC
3144
+ *
3145
+ * Licensed under the Apache License, Version 2.0 (the "License");
3146
+ * you may not use this file except in compliance with the License.
3147
+ * You may obtain a copy of the License at
3148
+ *
3149
+ * http://www.apache.org/licenses/LICENSE-2.0
3150
+ *
3151
+ * Unless required by applicable law or agreed to in writing, software
3152
+ * distributed under the License is distributed on an "AS IS" BASIS,
3153
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3154
+ * See the License for the specific language governing permissions and
3155
+ * limitations under the License.
3156
+ */function Gv(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new x(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Kv{convertValue(e,t="none"){switch(St(e)){case 0:return null;case 1:return e.booleanValue;case 2:return se(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Rt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw H(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return mr(e,((s,o)=>{r[s]=this.convertValue(o,t)})),r}convertVectorValue(e){var t,r,s;const o=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[Li].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map((a=>se(a.doubleValue)));return new wt(o)}convertGeoPoint(e){return new Tt(se(e.latitude),se(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Cs(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(sr(e));default:return null}}convertTimestamp(e){const t=bt(e);return new ae(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=te.fromString(e);ne(ah(r),9688,{name:e});const s=new ir(r.get(1),r.get(3)),o=new U(r.popFirst(5));return s.isEqual(t)||nt(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),o}}class Hn{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class jt extends Ch{constructor(e,t,r,s,o,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new ts(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(Ph("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=jt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}jt._jsonSchemaVersion="firestore/documentSnapshot/1.0",jt._jsonSchema={type:ce("string",jt._jsonSchemaVersion),bundleSource:ce("string","DocumentSnapshot"),bundleName:ce("string"),bundle:ce("string")};class ts extends jt{data(e={}){return super.data(e)}}class un{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Hn(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((r=>{e.call(t,new ts(this._firestore,this._userDataWriter,r.key,r,new Hn(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new x(N.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>o||u.type!==3)).map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,p=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),p=a.indexOf(u.doc.key)),{type:Qv(u.type),doc:l,oldIndex:d,newIndex:p}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=un._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=mo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((o=>{o._document!==null&&(t.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function Qv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return H(61501,{type:n})}}un._jsonSchemaVersion="firestore/querySnapshot/1.0",un._jsonSchema={type:ce("string",un._jsonSchemaVersion),bundleSource:ce("string","QuerySnapshot"),bundleName:ce("string"),bundle:ce("string")};class kh extends Kv{constructor(e){super(),this.firestore=e}convertBytes(e){return new Be(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Ce(this.firestore,null,t)}}function Jv(n,...e){var t,r,s;n=xe(n);let o={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||wu(e[a])||(o=e[a++]);const u={includeMetadataChanges:o.includeMetadataChanges,source:o.source};if(wu(e[a])){const v=e[a];e[a]=(t=v.next)===null||t===void 0?void 0:t.bind(v),e[a+1]=(r=v.error)===null||r===void 0?void 0:r.bind(v),e[a+2]=(s=v.complete)===null||s===void 0?void 0:s.bind(v)}let l,d,p;if(n instanceof Ce)d=Xr(n.firestore,Xi),p=Eo(n._key.path),l={next:v=>{e[a]&&e[a](Xv(d,n,v))},error:e[a+1],complete:e[a+2]};else{const v=Xr(n,Ls);d=Xr(v.firestore,Xi),p=v._query;const E=new kh(d);l={next:C=>{e[a]&&e[a](new un(d,E,v,C))},error:e[a+1],complete:e[a+2]},Gv(n._query)}return(function(E,C,V,M){const k=new Mv(M),q=new Ev(C,k,V);return E.asyncQueue.enqueueAndForget((async()=>gv(await mu(E),q))),()=>{k.Ou(),E.asyncQueue.enqueueAndForget((async()=>_v(await mu(E),q)))}})($v(d),p,u,l)}function Xv(n,e,t){const r=t.docs.get(e._key),s=new kh(n);return new jt(n,s,e._key,r,new Hn(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){En=s})(yn),ln(new $t("firestore",((r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),u=new Xi(new Zg(r.getProvider("auth-internal")),new n_(a,r.getProvider("app-check-internal")),(function(d,p){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new x(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ir(d.options.projectId,p)})(a,s),a);return o=Object.assign({useFetchStreams:t},o),u._setSettings(o),u}),"PUBLIC").setMultipleInstances(!0)),vt(bc,Rc,e),vt(bc,Rc,"esm2017")})();const Yv=typeof location<"u"&&/^(localhost|127\.0\.0\.1)$/.test(location.hostname),Zv={apiKey:"AIzaSyDzUGG3LEJbx0XccOWH2xEhZcttMw_238E",authDomain:Yv?"mrcong-d8b07.firebaseapp.com":location.host,projectId:"mrcong-d8b07",storageBucket:"mrcong-d8b07.firebasestorage.app",messagingSenderId:"926811951160",appId:"1:926811951160:web:acdfdd0941e12be35d96cd"},Oh=yp()[0]||Uu(Zv),rt=Qg(Oh),eE=Bv(Oh),sI=(async()=>{if(typeof location>"u")return;const n=/[#&]t=([^&]+)/.exec(location.hash);if(n){history.replaceState(null,"",location.pathname+location.search);try{await km(rt,decodeURIComponent(n[1]))}catch(e){console.warn("[auth] sso handoff failed:",e?.code||e?.message)}}})();async function iI(){const n=new Xe;n.addScope("email"),n.addScope("profile"),n.setCustomParameters({prompt:"select_account"});try{return await rg(rt,n)}catch(e){const t=e?.code||"";if(["auth/popup-blocked","auth/popup-closed-by-user","auth/cancelled-popup-request","auth/operation-not-supported-in-this-environment"].includes(t))return await ug(rt,n),null;throw e}}const wi={code:null};hg(rt).catch(n=>{wi.code=n?.code||n?.message||"unknown",console.warn("[auth] redirect result:",wi.code),document.dispatchEvent(new CustomEvent("clipoox:auth-error",{detail:wi.code}))});const oI=(n,e)=>Nm(rt,n.trim(),e),aI=n=>Dm(rt,n.trim()),cI=()=>xm(rt),uI=n=>Lm(rt,n);async function tE(){const n=rt.currentUser;return n?n.getIdToken():null}function lI(n,e,t){return Jv(jv(eE,"users",n),r=>{!r.exists()&&!r.metadata.fromCache&&t?.();const s=r.data()||{},o=typeof s.planCredits=="number"?s.planCredits:0,a=typeof s.extraCredits=="number"?s.extraCredits:0,u=typeof s.credits=="number"?s.credits:0,l=o===0&&a===0&&!s.planExpiresAt;e({credits:l?u:Math.round((o+a)*100)/100,planCredits:o,extraCredits:a,activePlan:s.activePlan||"free",planExpiresAt:typeof s.planExpiresAt?.toMillis=="function"?s.planExpiresAt.toMillis():typeof s.planExpiresAt=="number"?s.planExpiresAt:null})},()=>e({credits:0,planCredits:0,extraCredits:0,activePlan:"free"}))}async function b(n){const e=await jd(n).catch(r=>{throw Object.assign(new Error(De("Mất kết nối khi đang chờ kết quả từ máy chủ. Hãy thử lại.")),{status:n.status,code:r?.code||"reply_lost"})}),t=n.ok&&typeof e.error=="string"&&typeof e.status=="number"&&e.status>=400;if(!n.ok||t){const r=t?e.status:n.status,s=new Error(e.error||`${n.status} ${n.statusText}`);throw s.status=r,s.code=e.code,s.data=e,s}return e}async function kt(){const n=await tE();return n?{"X-Firebase-Token":n}:{}}const j=async n=>fetch(n,{headers:await kt()}),nE=()=>j("/api/mocap/hy/status").then(n=>n.ok?n.json():null),O=async(n,e,t="POST")=>fetch(n,{method:t,headers:{"Content-Type":"application/json","Accept-Language":Yn(),...await kt()},body:JSON.stringify(n.startsWith("/api/agent")||n.startsWith("/api/shot-agent")?{...e,locale:Yn()}:e)}),rE=()=>j("/api/me").then(n=>b(n)),sE=()=>j("/api/health").then(n=>b(n)),iE=()=>j("/api/generate").then(n=>b(n)).then(n=>n.generators),oE=(n,e)=>O("/api/generate/estimate",{generator:n,inputs:e}).then(t=>b(t)),aE=(n,e,t)=>O("/api/generate",{generator:n,inputs:e,canvasId:t}).then(r=>b(r)),cE=(n,e=!1)=>{const t=new URL(`/api/jobs/${n}`,window.location.origin);return e&&t.searchParams.set("poll","1"),j(t.toString()).then(r=>b(r)).then(r=>r.job)},uE=(n,e=50)=>{const t=new URL("/api/jobs",window.location.origin);return n&&t.searchParams.set("canvasId",n),t.searchParams.set("limit",String(e)),j(t.toString()).then(r=>b(r)).then(r=>r.jobs)},lE=(n,e,t)=>O("/api/media/trim",{videoUrl:n,start:e,end:t}).then(r=>b(r)),hE=(n,e)=>O("/api/media/region-splice",{sourceUrl:n,regions:e}).then(t=>b(t)),dE=(n,e)=>O("/api/media/frame",{videoUrl:n,...e}).then(t=>b(t)),Dh=(n,e,t,r)=>O("/api/uploads/sign",{filename:n,contentType:e,kind:t,...r?{rightsConfirmed:!0}:{}}).then(s=>b(s));function fE(n){return new Promise(e=>{const t=document.createElement(n.type.startsWith("audio/")?"audio":"video"),r=URL.createObjectURL(n),s=a=>{clearTimeout(o),t.onloadedmetadata=t.onerror=null,t.removeAttribute("src"),t.load(),URL.revokeObjectURL(r),e(a)},o=setTimeout(()=>s(null),1e4);t.preload="metadata",t.onloadedmetadata=()=>s(Number.isFinite(t.duration)?t.duration:null),t.onerror=()=>s(null),t.src=r})}async function pE(n,e,t,r=!1){const s=xd(n)||t==="audio"||t==="voice";if(s&&!r&&!await Ud([n.name]))throw new Error(De("Cần xác nhận quyền sử dụng bản nhạc trước khi tải lên"));if(/^(video|audio)\//.test(n.type)&&typeof document<"u"){const a=await fE(n);if(a!==null&&a>Cd+.001)throw new Error(De("Video/âm thanh đầu vào tối đa 20 phút"))}const o=await Dh(n.name,n.type||"application/octet-stream",t,s);return await new Promise((a,u)=>{const l=new XMLHttpRequest;l.open("PUT",o.uploadUrl),Object.entries(o.headers).forEach(([d,p])=>l.setRequestHeader(d,p)),l.upload.onprogress=d=>{d.lengthComputable&&e&&e(Math.round(d.loaded/d.total*100))},l.onload=()=>l.status>=200&&l.status<300?a():u(new Error(`upload failed: ${l.status}`)),l.onerror=()=>u(new Error("upload network error")),l.send(n)}),{url:o.readUrl,gcsUri:o.gcsUri,...o.rightsConfirmed?{rightsConfirmed:o.rightsConfirmed}:{}}}const mE=(n,e,t)=>O("/api/uploads/sign",{filename:n,contentType:e,temp:t}).then(r=>b(r)),gE=()=>j("/api/uploads/temp").then(n=>b(n)),_E=n=>O("/api/uploads/temp/sign",{gcsUri:n}).then(e=>b(e)),yE=n=>O("/api/uploads/temp",n,"DELETE").then(e=>b(e));function vE(n,e,t,r){return new Promise((s,o)=>{const a=new XMLHttpRequest;a.open("PUT",n.uploadUrl),Object.entries(n.headers).forEach(([u,l])=>a.setRequestHeader(u,l)),a.upload.onprogress=u=>{u.lengthComputable&&t?.(u.loaded,u.total)},a.onload=()=>a.status>=200&&a.status<300?s():o(new Error(`upload failed: ${a.status}`)),a.onerror=()=>o(new Error("upload network error")),a.onabort=()=>o(Object.assign(new Error(De("Đã huỷ gửi tạm")),{name:"AbortError"})),r?.addEventListener("abort",()=>a.abort(),{once:!0}),a.send(e)})}const EE=n=>O("/api/uploads/model-url",{gcsUri:n}).then(e=>b(e)).then(e=>e.url),TE=n=>O("/api/plugins/asset-urls",{uris:n}).then(e=>b(e)).then(e=>e.urls),wE=n=>O("/api/outputs/sign",n).then(e=>b(e)).then(e=>e.url),IE=(n={})=>O("/api/canvases",n).then(e=>b(e)).then(e=>e.canvas),AE=n=>j(`/api/canvases/${n}`).then(e=>b(e)).then(e=>e.canvas),bE=(n,e)=>O(`/api/canvases/${n}`,e,"PUT").then(t=>b(t)),RE=(n,e)=>j(`/api/canvases/${encodeURIComponent(n)}/shot-rev/${encodeURIComponent(e)}`).then(t=>b(t)),SE=n=>j(`/api/canvases/${encodeURIComponent(n)}/timeline-rev`).then(e=>b(e)),CE=n=>j(`/api/timeline-docs/${encodeURIComponent(n)}/rev`).then(e=>b(e)),PE=n=>O(`/api/canvases/${n}`,{},"DELETE").then(e=>b(e)),kE=n=>O("/api/blender/device/approve",{userCode:n}).then(e=>b(e)),OE=()=>j("/api/blender-remote/devices").then(n=>b(n)),DE=n=>O("/api/blender-remote/missions",n).then(e=>b(e)),NE=(n=8)=>j(`/api/blender-remote/missions?limit=${n}`).then(e=>b(e)),VE=n=>j(`/api/blender-remote/missions/${encodeURIComponent(n)}`).then(e=>b(e)),ME=n=>O("/api/blender-remote/vcam/session",{deviceId:n}).then(e=>b(e)),LE=n=>O(`/api/blender-remote/missions/${encodeURIComponent(n)}/cancel`,{}).then(e=>b(e)),xE=n=>j(`/api/canvases${n?`?limit=${n}`:""}`).then(e=>b(e)).then(e=>e.canvases),UE=(n,e)=>O(`/api/canvases/${n}/archive`,{archived:e}).then(t=>b(t)),FE=n=>O(`/api/canvases/${n}/duplicate`,{}).then(e=>b(e)).then(e=>e.canvas),jE=()=>j("/api/skills").then(n=>b(n)),BE=n=>O("/api/skills",n).then(e=>b(e)).then(e=>e.skill),$E=(n,e)=>O(`/api/skills/${n}`,e,"PUT").then(t=>b(t)).then(t=>t.skill),qE=n=>O(`/api/skills/${n}`,{},"DELETE").then(e=>b(e)),zE=()=>j("/api/series").then(n=>b(n)),HE=n=>j(`/api/series/${encodeURIComponent(n)}`).then(e=>b(e)),WE=(n,e)=>O(`/api/series/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),GE=n=>j(`/api/sets/${encodeURIComponent(n)}`).then(e=>b(e)),KE=(n,e,t)=>O(`/api/sets/${encodeURIComponent(n)}`,{name:e,recipe:t},"PUT").then(r=>b(r)),QE=async n=>{const e=await j(`/api/timeline-docs/${encodeURIComponent(n)}`);return e.status===404?null:(await b(e)).timeline},JE=(n,e)=>O(`/api/timeline-docs/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),XE=async(n,e,t)=>{const r=await O(`/api/timeline-docs/${encodeURIComponent(n)}/copy`,{id:e,nodeId:t.nodeId,...t.canvasId?{canvasId:t.canvasId}:{}});return r.status===404?!1:(await b(r),!0)},YE=()=>j("/api/canvas-inbox").then(n=>b(n)),ZE=n=>O("/api/canvas-inbox/consume",{ids:n}).then(e=>b(e)),eT=(n,e,t="upload")=>j("/api/assets?"+new URLSearchParams({source:t,...n?{kind:n}:{},...e?{cursor:e}:{}})).then(r=>b(r)),tT=(n,e)=>O("/api/director/"+encodeURIComponent(n)+"/context",e,"PUT").then(t=>b(t)),nT=n=>j(`/api/director/${encodeURIComponent(n)}`).then(e=>b(e)),rT=n=>j(`/api/director-references/${encodeURIComponent(n)}`).then(e=>b(e)),sT=(n,e,t,r)=>O(`/api/director-references/${encodeURIComponent(n)}`,{gcsUri:e,label:t,role:r}).then(s=>b(s)),iT=n=>j(`/api/library${n?`?kind=${encodeURIComponent(n)}`:""}`).then(e=>b(e)).then(e=>e.assets),oT=()=>j("/api/library/usage").then(n=>b(n)),aT=n=>O("/api/library/pin",n).then(e=>b(e)),cT=n=>O(`/api/library/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),uT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),lT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}/locate-object`,e).then(t=>b(t)),hT=n=>O("/api/timeline-agent/usage",{events:n}).then(e=>b(e));async function dT(n,e,t,r){const s=`/api/timeline-agent/${encodeURIComponent(n)}/describe`;if(!r)return O(s,{items:e,locale:t}).then(v=>b(v));const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({items:e,locale:t})});if(!o.ok||!(o.headers.get("Content-Type")||"").startsWith(rs)||!o.body)return b(o);const a=o.body.pipeThrough(new TextDecoderStream).getReader();let u="",l=null;const d=v=>{if(!v.trim())return;const E=JSON.parse(v);if(E&&typeof E=="object"&&E.progress)try{r(E.progress)}catch{}else l=E};for(;;){const{value:v,done:E}=await a.read();if(E)break;u+=v;let C;for(;(C=u.indexOf(`
3157
+ `))>=0;)d(u.slice(0,C)),u=u.slice(C+1)}d(u);const p=l||{};if(typeof p.error=="string"&&typeof p.status=="number"&&p.status>=400){const v=new Error(p.error);throw v.status=p.status,v.code=p.code,v.data=p,v}if(!l)throw new Error(De("Phân tích bị ngắt giữa chừng. Hãy thử lại."));return l}async function fT(n,e,t={}){const r=await fetch(`/api/transcribe/${encodeURIComponent(n)}`,{method:"POST",signal:t.signal,headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({...e,terms:t.terms||"",locale:t.locale||Yn()})});if(!r.ok||!(r.headers.get("Content-Type")||"").startsWith(rs)||!r.body)return b(r).then(d=>d.item);const s=r.body.pipeThrough(new TextDecoderStream).getReader();let o="",a=null;const u=d=>{if(!d.trim())return;const p=JSON.parse(d);if(p&&typeof p=="object"&&p.progress)try{t.onProgress?.(p.progress)}catch{}else a=p};for(;;){const{value:d,done:p}=await s.read();if(p)break;o+=d;let v;for(;(v=o.indexOf(`
3158
+ `))>=0;)u(o.slice(0,v)),o=o.slice(v+1)}u(o);const l=a||{};if(typeof l.error=="string"&&typeof l.status=="number"&&l.status>=400){const d=new Error(l.error);throw d.status=l.status,d.code=l.code,d}if(!l.item)throw new Error(De("Chép lời bị ngắt giữa chừng. Hãy thử lại."));return l.item}const pT=(n,e,t=0)=>j(`/api/timeline-agent/plan-price?model=${encodeURIComponent(n)}&chars=${Math.round(e)}&refs=${t}`).then(r=>b(r)),mT=(n,e=!0)=>j(`/api/timeline-agent/describe-price?audioOnly=${e?1:0}${n&&n>0?`&duration=${Math.ceil(n)}`:""}`).then(t=>b(t)),gT=(n,e,t)=>O("/api/timeline/multicam/sync",{canvasId:n,items:e,...t?{main:t}:{}}).then(r=>b(r)),xs=(n,e)=>`/api/production/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,_T=(n,e)=>j(xs(n,e)).then(t=>b(t)),yT=(n,e,t)=>O(`${xs(n,e)}/quote`,{imageGenerator:t}).then(r=>b(r)),vT=(n,e,t,r)=>O(`${xs(n,e)}/${t}`,{revision:r}).then(s=>b(s)),ET=(n,e,t,r,s,o,a,u)=>O(`/api/director/${encodeURIComponent(n)}`,{input:e,requestId:t,referenceIds:r,defaults:s,...o?{skill:o.id?{id:o.id}:{title:o.title,instruction:o.instruction}}:{},...a?{model:a}:{},...u?{aspectRatio:u}:{}}).then(l=>b(l)),TT=(n,e,t,r)=>O(`${xs(n,e)}/accept`,{revision:t,totalCredits:r}).then(s=>b(s)),wT=n=>O(`/api/director/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),IT=(n,e,t,r)=>O("/api/agent",{messages:n.map(({role:s,content:o})=>({role:s,content:o})),canvas:e,model:t||void 0,defaults:r}).then(s=>b(s)),AT=()=>j("/api/agent/models").then(n=>n.json()),bT=(n="published",e)=>j("/api/model-library?"+new URLSearchParams({status:n,...e?{cursor:e}:{}})).then(t=>b(t)),RT=()=>j("/api/model-library/categories").then(n=>b(n)),ST=(n,e)=>O("/api/model-library/"+encodeURIComponent(n)+"/thumbnail",{gcsUri:e}).then(t=>b(t)),CT=n=>O("/api/model-library",n).then(e=>b(e)),PT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n),{status:e},"PATCH").then(t=>b(t)),kT=(n={})=>j("/api/asset-library?"+new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0&&e!=="").map(([e,t])=>[e,String(t)]))).then(e=>b(e)),OT=n=>j("/api/asset-library/categories"+(n?"?kind="+n:"")).then(e=>b(e)),DT=n=>j("/api/asset-library/"+encodeURIComponent(n)).then(e=>b(e)).then(e=>e.item),NT=(n="published")=>j("/api/text-templates?"+new URLSearchParams({status:n})).then(e=>b(e)),VT=()=>j("/api/brands").then(n=>b(n)),MT=()=>j("/api/fonts").then(n=>b(n)),LT=n=>O("/api/fonts",n).then(e=>b(e)),xT=n=>O("/api/fonts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),UT=(n,e)=>O("/api/brands"+(e?"/"+encodeURIComponent(e):""),n,e?"PUT":"POST").then(t=>b(t)),FT=n=>O("/api/brands/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),jT=n=>O("/api/luts",n).then(e=>b(e)),BT=()=>j("/api/luts").then(n=>b(n)),$T=n=>O("/api/luts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),qT=n=>j("/api/luts/"+encodeURIComponent(n)).then(e=>b(e)),zT=(n="published")=>j("/api/transitions?"+new URLSearchParams({status:n})).then(e=>b(e)),HT=n=>O("/api/model-library/share",n).then(e=>b(e)),WT=()=>j("/api/shot-agent").then(n=>b(n)),GT=(n,e,t)=>O("/api/shot-agent/estimate",{scene:n,messages:e,model:t}).then(r=>b(r)),KT=(n,e,t,r)=>O("/api/shot-agent",{scene:n,messages:e,requestId:t,model:r}).then(s=>b(s)),QT=n=>O("/api/shot-agent/mission/turn",n).then(e=>b(e)),JT=(n,e="build")=>O("/api/shot-agent/mission/quote",{model:n,kind:e}).then(t=>b(t)),XT=n=>O("/api/shot-agent/mission/cancel",{missionId:n}).then(e=>b(e)),YT=n=>O("/api/shot-agent/remote/poll",n).then(e=>b(e)),ZT=n=>O("/api/shot-agent/live/poll",n).then(e=>b(e)),ew=n=>O("/api/timeline-live/poll",n).then(e=>b(e)),tw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/progress`,e).then(t=>b(t)),nw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),rw=(n,e)=>O(`/api/shot-agent/live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),sw=(n,e)=>O(`/api/shot-agent/remote/missions/${encodeURIComponent(n)}/status`,e).then(t=>b(t)),iw=n=>O("/api/person-mattes",{data:n}).then(e=>b(e)).then(e=>e.ref),ow=async n=>{const e=await j(`/api/person-mattes/${n}`);return e.ok||await b(e),e.text()},aw=n=>O("/api/roto-masks",{data:n}).then(e=>b(e)).then(e=>e.ref),cw=async n=>{const e=await j(`/api/roto-masks/${n}`);return e.ok||await b(e),e.text()},uw=n=>O("/api/shot-scenes",{data:n}).then(e=>b(e)).then(e=>e.ref),lw=async n=>{const e=await j(`/api/shot-scenes/${n}`);return e.ok||await b(e),e.text()},hw=n=>O("/api/color-agent/price",n).then(e=>b(e)),dw=(n,e)=>O(`/api/color-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),fw=n=>O("/api/broll-prompt/price",n).then(e=>b(e)),pw=(n,e)=>O(`/api/broll-prompt/${encodeURIComponent(n)}`,e).then(t=>b(t)),mw=n=>O("/api/geo/hd",n).then(e=>b(e)),gw=async n=>{const e=await O("/api/geo/blender-city",n);if(!e.ok)throw await b(e),Error("Blender city failed");return{script:await e.text(),buildings:Number(e.headers.get("x-city-buildings"))||0}},_w=n=>O("/api/geo/resolve",{ops:n}).then(e=>b(e)),yw=(n,e=!0,t="vi")=>j(`/api/geo/search?${new URLSearchParams({q:n,shape:e?"1":"0",lang:t})}`).then(r=>b(r)).then(r=>r.results),vw=n=>O("/api/caption-keywords/price",{words:n}).then(e=>b(e)),Ew=(n,e,t)=>O(`/api/caption-keywords/${encodeURIComponent(n)}`,{words:e,locale:t}).then(r=>b(r)),Tw=(n,e)=>O("/api/caption-translate/price",{lines:n,target:e}).then(t=>b(t)),ww=(n,e,t)=>O(`/api/caption-translate/${encodeURIComponent(n)}`,{lines:e,target:t}).then(r=>b(r)),Iw=n=>O("/api/media-peaks",{url:n}).then(e=>b(e)),Aw=n=>O("/api/stabilize",n).then(e=>b(e)),bw=n=>O("/api/audio-tools",n).then(e=>b(e)),Rw=n=>O("/api/media/frames/sign",{count:n}).then(e=>b(e)).then(e=>e.chunks);let Sw=null;const Nh=()=>Sw??=j("/api/media/render-target").then(n=>n.ok?n.json():{}).then(n=>({url:n?.url||"",gpu:n?.gpu!==!1})).catch(()=>({url:"",gpu:!1})),vr=()=>Nh().then(n=>n.url),Vh=n=>n<=30?1:Math.min(8,Math.ceil(n/10));function Cw(n){vr().then(e=>{if(e)for(let t=0;t<Vh(n);t++)fetch(`${e}/api/health`,{cache:"no-store"}).catch(()=>{})}).catch(()=>{})}async function Pw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/media/proxy`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify({gcsUri:n})});if(s.status===429&&r<6){await xo(1e4,e);continue}const o=await b(s);return o.needed&&o.url&&o.gcsUri?{url:o.url,gcsUri:o.gcsUri,fps:Number(o.fps),width:Number(o.width),height:Number(o.height),...o.alpha===!0?{alpha:!0}:{}}:null}}let Au=null;const kw=()=>Au??=vr().then(async n=>fetch(`${n}/api/shot-inbetween`,{headers:await kt()})).then(n=>b(n)).catch(()=>(Au=null,{available:!1,maxSeconds:0}));async function Ow(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/shot-inbetween`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify(n)});if(s.status===429&&r<6){await xo(5e3,e);continue}return b(s)}}const bu=[5,10,15,20,30,30,30,30,30,30].map(n=>n*1e3),xo=(n,e)=>new Promise((t,r)=>{const s=setTimeout(t,n);e?.addEventListener("abort",()=>{clearTimeout(s),r(new DOMException("Aborted","AbortError"))},{once:!0})});function Mh(n){try{const e=n.headers.get("X-Clipoox-Review"),t=e?JSON.parse(decodeURIComponent(e)):null;return t&&Array.isArray(t.checks)&&Array.isArray(t.platforms)?t:null}catch{return null}}const Ut=.9;async function Dw(n,e){const t=Number(n.headers.get("Content-Length"))||0;if(!n.body||!t)return n.blob();const r=n.body.getReader(),s=[];let o=0;for(;;){const{done:a,value:u}=await r.read();if(a)break;s.push(u),o+=u.length,e(Math.min(1,o/t))}return new Blob(s,{type:n.headers.get("Content-Type")||"video/mp4"})}let Us=null,ys=null,vs=null;const Lh=n=>{const e=/^(\d+)\/(\d+)$/.exec(n.headers.get("X-Clipoox-Export-Quota")||"");return e?{used:+e[1],limit:+e[2]}:null};async function Nw(n,e,t,r,s){if(!n.body)throw new Error("Export failed (empty reply)");const o=n.body.getReader(),a=Fd(),u=[];let l=0,d=0,p=null,v=null,E=0;for(;;){const{done:C,value:V}=await o.read();if(C)break;for(const M of a.push(V))if(M.type==="progress")t?.(Ut*M.value);else if(M.type==="review"){const k=M.review;p=k&&Array.isArray(k.checks)&&Array.isArray(k.platforms)?k:null}else if(M.type==="timings")v=M.timings;else{if(M.type==="error")throw Object.assign(new Error(Uo(M.error)),{status:M.status});M.type==="file"?(l=M.size,E=performance.now(),e?.("download")):M.type==="stored"?(vs={gcsUri:M.gcsUri,size:M.size},l=M.size,E=performance.now()):M.type==="data"&&(u.push(M.chunk),d+=M.chunk.length,t?.(Ut+(1-Ut)*(l?Math.min(1,d/l):0)))}}if(!a.complete)throw new Error("Export interrupted — please try again");return s&&(Us={totalMs:Math.round(performance.now()-s.start),framesMs:Math.round(s.posted-s.start),renderMs:Math.round((E||performance.now())-s.posted),downloadMs:E?Math.round(performance.now()-E):0,server:v}),v&&s&&console.info("[export] timings",{server:v,browser:{frames_ms:Math.round(s.posted-s.start),request_to_file_ms:Math.round(E-s.posted),download_ms:Math.round(performance.now()-E),total_ms:Math.round(performance.now()-s.start),bytes:l}}),r?.(p),new Blob(vs?[]:u,{type:"video/mp4"})}function Uo(n){const e=/^Media exceeds (\d+) MB per export/.exec(n||"");if(e)return De("Video, ảnh và nhạc gốc trong Timeline nặng hơn {0} MB cho một lần xuất. Hãy cắt bớt hoặc bỏ các clip dài không dùng tới rồi xuất lại.",[e[1]]);const t=/^Media link missing: “(.*)” \(([\d.]+)s\)/.exec(n||"");return t?De("Lớp “{0}” (giây {1}) chưa có file media. Mở lớp đó chọn lại media, hoặc xoá lớp rồi xuất lại.",[t[1],t[2]]):/^MP4 render failed|Error opening input|Stream #\d|Input #\d|\/tmp\/canvas-/.test(n||"")?(console.warn("[export] render failed:",n),De("Không xuất được video lần này. Nếu bạn vừa sửa Timeline trong lúc xuất, hãy chờ lưu xong rồi bấm xuất lại. Nếu vẫn lỗi, hãy báo Clipoox.")):n||""}function xh(n){return n.code==="export_quota"?Object.assign(new Error(De("Bạn đã dùng hết lượt xuất video tháng này")),{planGate:{kind:"count",plan:n.plan||"free",offer:n.offer??null,seconds:0,limit:Number(n.limit)||0,used:Number(n.used)||0,resetAt:Number(n.resetAt)||0}}):n.code==="plan_required"&&n.offer?Object.assign(new Error(De("Cần nâng cấp gói để xuất video dài hơn")),{planGate:{kind:"length",plan:n.plan||"free",offer:n.offer,seconds:Number(n.seconds)||0}}):null}let Je=[];const Vw=n=>n.map(e=>e.replace(/[^A-Za-z0-9 _.:-]/g,"").slice(0,48)).filter(Boolean).slice(0,16).join(",");async function Mw(n,e,t,r,s,o,a,u){try{if(localStorage.getItem("clipoox.gpuExport")==="off")return Je=["off in this browser"],null}catch{}if(!(await Nh()).gpu)return Je=["off on the server"],null;const l=e.format||{resolution:"720p",aspectRatio:"16:9",fps:30},{clientExportCheck:d,clientExportCodes:p,softwareRetry:v,gpuErrorText:E}=await pe(async()=>{const{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}=await import("./clientExport-DvpTTndR.js");return{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}},__vite__mapDeps([0,1,2])),C=d(n,{format:l,camera:e.camera,look:e.look,encode:e.encode});if(!C.ok)return console.info("[export] server render:",C.reasons.slice(0,5).join(" · ")),Je=p(n,{format:l,camera:e.camera,look:e.look,encode:e.encode}),null;const V=await pe(()=>import("./gpuExport-CQ7ZhpsX.js"),__vite__mapDeps([3,1,4,2,5,6,7,8,9,10,11]));if(!await V.gpuExportSupported(l,e.encode))return console.info("[export] server render: no hardware video encoder here"),Je=[e.encode?.codec==="hevc"&&await V.gpuExportSupported(l)?"no hevc encoder":"no hardware encoder"],null;const M=n.reduce((k,q)=>q.disabled?k:Math.max(k,q.start+q.duration),0);{const k=await O("/api/media/client-export/check",{seconds:M,...e.aiJob?{aiJob:e.aiJob}:{}});if(k.status===402){const z=xh(await k.json().catch(()=>({})));if(z)throw z}if(!k.ok)return Je=[`plan check ${k.status}`],null;const q=(await k.json().catch(()=>null))?.hold;u.hold=typeof q=="string"?q:null}r?.("local"),s?.(0);try{let k=!1;const q=_=>V.exportOnGpu(n,{format:l,encode:e.encode,tracks:e.tracks,camera:e.camera,signal:t,onProgress:m=>s?.(m),software:_}),{blob:z,ms:B}=await q(!1).catch(_=>{if(t?.aborted||!v(_,V.gpuExportStage(),e.encode))throw _;return console.warn("[export] hardware encoder failed, again with the software encoder:",_),s?.(0),k=!0,q(!0)}),{width:Y,height:he,fps:P}=Xt(l);Us={totalMs:Math.round(performance.now()-a.start),framesMs:B.titles,renderMs:B.video+B.audio,downloadMs:0,server:{gpu:!0,...B}};{const _=await O("/api/media/client-export/done",{seconds:M,...u.hold?{hold:u.hold}:{},...k?{software:!0}:{},ms:B.total,titlesMs:B.titles,audioMs:B.audio,width:Y,height:he,fps:P,clips:n.length,...e.aiJob?{aiJob:e.aiJob}:{}}).catch(()=>null);_?.ok&&(ys=Lh(_)),u.hold=null}return o?.(null),z}catch(k){if(t?.aborted||k?.name==="AbortError")throw k;return console.warn("[export] GPU export failed, the server renders it:",k),Je=[`gpu failed: ${k?.name||"Error"} at ${V.gpuExportStage()||"start"}`,...E(k)?[`gpu error: ${E(k)}`]:[]],r?.("frames"),s?.(null),null}}async function Lw(n,e,t={},r,s,o){r?.("frames"),o?.(null);const a={start:performance.now(),posted:0};t.mode===void 0&&(Us=null,ys=null,vs=null),n=Ad(n,Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30}).fps);{const{expandComps:P}=await pe(async()=>{const{expandComps:m}=await import("./timelineComp-Dx_kED5V.js").then(g=>g.t);return{expandComps:m}},__vite__mapDeps([2,1])),_=Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30});n=P(n.filter(m=>!m.disabled),{W:_.width,H:_.height})}n=n.filter(P=>!P.disabled).map(bd);const u=Md(n);n=u.clips;const l=n.filter(P=>P.title&&!P.url&&!Rd(P));if(l.length){const P=new Map((await(await pe(async()=>{const{materializeTitles:_}=await import("./timelineText-RKyRP988.js");return{materializeTitles:_}},__vite__mapDeps([12,13,1,11,14,15,10]))).materializeTitles(l)).map(_=>[_.id,_]));n=n.map(_=>P.get(_.id)??_)}if(u.fixes.length&&s){const P=s;s=_=>P({..._??{ok:!0,checks:[],platforms:[],duration:0,ms:0},fixes:[...u.fixes,..._?.fixes??[]].slice(0,10)})}if(Je=t.breakdown?["breakdown"]:[],t.mode===void 0&&!t.breakdown){const P={hold:null},_=await Mw(n,t,e,r,o,s,a,P);if(_)return _;P.hold&&(t={...t,hold:P.hold})}t.mode===void 0&&Cw(n.reduce((P,_)=>_.disabled?P:Math.max(P,_.start+_.duration),0)),n.some(P=>P.join)&&(n=[...n,...(await pe(async()=>{const{joinDecoLayers:P}=await import("./titleFrameBudget-X7HLSDre.js").then(_=>_.nM);return{joinDecoLayers:P}},[])).joinDecoLayers(n)]);const d=new(await pe(async()=>{const{FrameSink:P}=await import("./frameSink-DYs2gTzq.js");return{FrameSink:P}},__vite__mapDeps([16,1]))).FrameSink({signal:e}),p=t.format||{resolution:"720p",aspectRatio:"16:9",fps:30};if(n.some(Sd)){const P=await(await pe(async()=>{const{distortForServer:_}=await import("./distortFrames-BLt1icUb.js");return{distortForServer:_}},__vite__mapDeps([17,1,7,8]))).distortForServer(n,p,d,e,t.tracks);n=P.clips,t={...t,tracks:P.tracks}}if(n.some(P=>P.kind==="model")&&await(await pe(async()=>{const{render3DFrames:P}=await import("./timeline3dExport-DCOr6ARB.js");return{render3DFrames:P}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(n,p,d,e,t.camera),n.some(P=>Fa(P.title)||P.shape||P.motion||P.lottie||P.card||P.geo)&&await(await pe(async()=>{const{renderTitleFrames:P}=await import("./titleFrames-aMG7HdVe.js");return{renderTitleFrames:P}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...n,...ja(n)],p,d,e,t.camera),n.some(P=>P.mask||P.person)){const P=await pe(()=>import("./rotoMatte-i-cJTYmK.js").then(_=>_.r),__vite__mapDeps([26,1,13,11]));await P.renderMatteFrames([...n,...P.maskedCopies(n)],Xt(p).fps,d,e)}{const P=await pe(()=>import("./windowFrames-1wAkkWnv.js"),__vite__mapDeps([27,1,26,13,11,10]));P.hasMovingWindows(n)&&await P.renderWindowFrames(n,Xt(p).fps,d,e)}{const{groupedLevels:P}=await pe(async()=>{const{groupedLevels:m}=await import("./timelineComp-Dx_kED5V.js").then(g=>g.t);return{groupedLevels:m}},__vite__mapDeps([2,1])),_=Xt(p);for(const m of P(n,{W:_.width,H:_.height})){if(m.some(g=>g.kind==="model")&&await(await pe(async()=>{const{render3DFrames:g}=await import("./timeline3dExport-DCOr6ARB.js");return{render3DFrames:g}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(m,p,d,e,null),m.some(g=>Fa(g.title)||g.shape||g.motion||g.lottie||g.card||g.geo)&&await(await pe(async()=>{const{renderTitleFrames:g}=await import("./titleFrames-aMG7HdVe.js");return{renderTitleFrames:g}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...m,...ja(m)],p,d,e,null),m.some(g=>g.mask||g.person)){const g=await pe(()=>import("./rotoMatte-i-cJTYmK.js").then(T=>T.r),__vite__mapDeps([26,1,13,11]));await g.renderMatteFrames([...m,...g.maskedCopies(m)],_.fps,d,e)}{const g=await pe(()=>import("./windowFrames-1wAkkWnv.js"),__vite__mapDeps([27,1,26,13,11,10]));g.hasMovingWindows(m)&&await g.renderWindowFrames(m,_.fps,d,e)}}}n.some(P=>P.mask||P.planar||P.sceneTrack)&&(n=await(await pe(async()=>{const{packMasks:P}=await import("./rotoMaskStore-DdpmT9C3.js");return{packMasks:P}},__vite__mapDeps([28,1,29,10,11]))).packMasks(n));const v=JSON.stringify({clips:n,...t,...await d.finish()}),E=await vr();r?.("render");const C=typeof CompressionStream=="function"&&v.length>256*1024,V=C?await new Response(new Blob([v]).stream().pipeThrough(new CompressionStream("gzip"))).blob():v;a.posted=performance.now();const M=!!o&&t.mode===void 0,k=async P=>fetch(P,{method:"POST",signal:e,headers:{"Content-Type":"application/json","X-Clipoox-Frames-Ms":String(Math.round(a.posted-a.start)),...t.mode===void 0&&Je.length?{"X-Clipoox-Gpu-Skip":Vw(Je)}:{},...M?{Accept:`${Ha}, video/mp4;q=0.9, */*;q=0.5`}:{},...C?{"Content-Encoding":"gzip"}:{},...await kt()},body:V}),q=n.reduce((P,_)=>Math.max(P,_.start+_.duration),0),z=performance.now();let B=!1;const Y=o?setInterval(()=>{B||o(Ut*Su((performance.now()-z)/1e3,10+q*.8))},500):null,he=P=>{B=!0,o?.(P)};try{let P;for(let _=0;;_++){try{P=await k(`${E}/api/media/timeline`)}catch(m){if(!E||e?.aborted)throw m;P=await k("/api/media/timeline")}if(P.status!==429||_>=bu.length)break;r?.("queue"),await xo(bu[_],e),r?.("render")}if(P.ok&&t.mode===void 0&&(ys=Lh(P)),P.ok&&M&&(P.headers.get("Content-Type")||"").startsWith(Ha))return await Nw(P,r,he,s,a);if(r?.("download"),!P.ok){const _=await P.json().catch(()=>({}));{const m=xh(_);if(m)throw m}throw _.clip?new Error(De("Không xuất được: clip “{0}” (giây {1}) có dữ liệu lỗi — {2}. Hãy sửa hoặc xoá clip đó rồi xuất lại.",[_.clip.label||"?",Number(_.clip.start||0).toFixed(1),_.reason||_.error||""])):new Error(_.code==="render_unavailable"?De("Máy render đang bận hoặc vừa khởi động lại, bản xuất này quá nặng để chạy dự phòng. Hãy xuất lại sau khoảng 1 phút."):Uo(_.error)||`Export failed (${P.status})`)}return s?.(Mh(P)),o?(he(Ut),await Dw(P,_=>he(Ut+(1-Ut)*_))):P.blob()}finally{Y&&clearInterval(Y)}}const xw=n=>j(`/api/motion-agent/price${n?`?chars=${n.chars}&duration=${n.duration}&kind=${n.kind}`:""}`).then(e=>b(e)),Uw=n=>O("/api/motion-agent",n).then(e=>b(e)).then(e=>{if(e.error)throw Object.assign(new Error(e.error),{status:e.status});return e}),Fw=()=>j("/api/rig-agent/price").then(n=>b(n)),jw=n=>O("/api/rig-agent",n).then(e=>b(e)),Bw=()=>{const n=navigator.userAgent,e=/(Edg|OPR|Firefox|Chrome|Version)\/(\d+)/.exec(n),t=e?(e[1]==="Edg"?"Edge":e[1]==="OPR"?"Opera":e[1]==="Version"?"Safari":e[1])+" "+e[2]:"other";return/Windows/.test(n)?`${t} Windows`:/Mac OS X/.test(n)?`${t} macOS`:/Android/.test(n)?`${t} Android`:/iPhone|iPad/.test(n)?`${t} iOS`:`${t} other`};function $w(n,e,t={}){try{const r=navigator;O("/api/client-log",{kind:n,message:String(e||"").slice(0,300),detail:{browser:Bw(),cores:r.hardwareConcurrency,memory:r.deviceMemory,...t}}).catch(()=>{})}catch{}}const hI=Object.freeze(Object.defineProperty({__proto__:null,acceptProduction:TT,addUserFont:LT,approveBlenderDevice:kE,archiveCanvas:UE,askAgent:IT,askShotAgent:KT,attachDirectorReference:sT,brollPrompt:pw,brollPromptPrice:fw,cancelRemoteMission:LE,canvasInbox:YE,captionKeywords:Ew,captionKeywordsPrice:vw,captionTranslate:ww,captionTranslatePrice:Tw,clearDirector:wT,colorAgent:dw,colorAgentPrice:hw,consumeCanvasInbox:ZE,copyTimelineDoc:XE,createCanvas:IE,createLibraryModel:CT,createRemoteMission:DE,createSkill:BE,createVcamSession:ME,deleteBrand:FT,deleteCanvas:PE,deleteLibraryAsset:cT,deleteLut:$T,deleteSkill:qE,deleteTempUploads:yE,deleteUserFont:xT,describeFootage:dT,describePrice:mT,duplicateCanvas:FE,estimate:oE,estimateShotAgent:GT,exportReviewOf:Mh,exportTimeline:Lw,extractFrame:dE,fetchHealth:sE,fetchLut:qT,freeTranscript:fT,friendlyExportError:Uo,geoSearch:yw,getAssetLibraryItem:DT,getCanvas:AE,getCanvasShotRev:RE,getCanvasTimelineRev:SE,getDirector:nT,getPersonMatte:ow,getProduction:_T,getRemoteMission:VE,getRotoMask:cw,getSeries:HE,getSet:GE,getShotScene:lw,getTimelineDoc:QE,getTimelineDocRev:CE,get lastExportQuota(){return ys},get lastExportStored(){return vs},get lastExportTimes(){return Us},libraryUsage:oT,listAgentModels:AT,listAssetLibrary:kT,listAssetLibraryCategories:OT,listAssets:eT,listBlenderDevices:OE,listBrands:VT,listCanvases:xE,listDirectorReferences:rT,listGenerators:iE,listJobs:uE,listLibrary:iT,listModelCategories:RT,listModelLibrary:bT,listMyLuts:BT,listRemoteMissions:NE,listSeries:zE,listSkills:jE,listTempUploads:gE,listTextTemplates:NT,listTransitions:zT,listUserFonts:MT,locateObject:lT,mapBlenderScript:gw,mapHd:mw,me:rE,mediaPeaks:Iw,mediaProxy:Pw,mocapRegionStatus:nE,modelReadUrl:EE,motionAgent:Uw,motionAgentPrice:xw,motionUsage:hT,multicamSync:gT,pinToLibrary:aT,pluginAssetUrls:TE,pollJob:cE,prewarmCount:Vh,processAudio:bw,productionAction:vT,publishLibraryModel:PT,putSigned:vE,quoteProduction:yT,reportClient:$w,requestTempUpload:mE,requestUpload:Dh,resolveMapPlaces:_w,rigAgent:jw,rigAgentPrice:Fw,runGenerator:aE,saveBrand:UT,saveCanvas:bE,saveLut:jT,saveModelThumbnail:ST,savePersonMatte:iw,saveProjectContext:tT,saveRotoMask:aw,saveSeries:WE,saveSet:KE,saveShotScene:uw,saveTimelineDoc:JE,sendDirector:ET,shareModelAsset:HT,shotAgentInfo:WT,shotInbetween:Ow,shotInbetweenInfo:kw,shotLivePoll:ZT,shotLiveResult:rw,shotMissionCancel:XT,shotMissionQuote:JT,shotMissionTurn:QT,shotRemotePoll:YT,shotRemoteReport:sw,signFrameChunks:Rw,signOutput:wE,signTempUpload:_E,spliceRegionsMedia:hE,stabilizeClip:Aw,timelineAgent:uT,timelineAgentPrice:pT,timelineLivePoll:ew,timelineLiveProgress:tw,timelineLiveResult:nw,trimMedia:lE,updateSkill:$E,uploadFile:pE},Symbol.toStringTag,{value:"Module"}));export{_E as $,UT as A,jE as B,$E as C,BE as D,qE as E,_T as F,vT as G,yT as H,TT as I,rT as J,sT as K,AT as L,ET as M,nT as N,wT as O,tT as P,uE as Q,Uw as R,xw as S,HT as T,iT as U,oT as V,xd as W,cT as X,bT as Y,eT as Z,DT as _,cE as a,ME as a$,mE as a0,vE as a1,gE as a2,yE as a3,BT as a4,hT as a5,Tw as a6,ww as a7,vw as a8,Ew as a9,Bd as aA,Zw as aB,ew as aC,vs as aD,nw as aE,tw as aF,CE as aG,SE as aH,kd as aI,Jw as aJ,Qw as aK,Lw as aL,Us as aM,ys as aN,Aw as aO,bw as aP,Xw as aQ,wi as aR,aI as aS,iI as aT,oI as aU,kE as aV,OE as aW,NE as aX,VE as aY,DE as aZ,LE as a_,fT as aa,nI as ab,eI as ac,tI as ad,NT as ae,yw as af,mw as ag,gw as ah,kT as ai,Su as aj,gT as ak,$w as al,Gw as am,Ww as an,Kw as ao,EE as ap,zT as aq,Pw as ar,$T as as,hw as at,dw as au,fw as av,pw as aw,pT as ax,uT as ay,Yw as az,hE as b,FE as b0,UE as b1,ln as b2,$t as b3,vt as b4,ke as b5,xe as b6,to as b7,Yd as b8,Fu as b9,KT as bA,ZT as bB,rw as bC,HE as bD,zE as bE,WE as bF,GE as bG,nE as bH,qT as bI,jT as bJ,TE as bK,aw as bL,cw as bM,_w as bN,iw as bO,Od as bP,MT as bQ,xT as bR,LT as bS,ow as bT,lT as bU,hI as bV,_n as ba,Vu as bb,Mu as bc,st as bd,yp as be,sI as bf,uI as bg,lI as bh,iE as bi,uw as bj,lw as bk,RT as bl,ST as bm,CT as bn,PT as bo,RE as bp,XT as bq,QT as br,YT as bs,sw as bt,JT as bu,KE as bv,Fw as bw,jw as bx,GT as by,WT as bz,dT as c,mT as d,oE as e,JE as f,QE as g,XE as h,AE as i,IE as j,bE as k,YE as l,ZE as m,dE as n,Ud as o,aT as p,xE as q,aE as r,wE as s,PE as t,pE as u,cI as v,tE as w,lE as x,VT as y,FT as z};