@wildo-ai/application-creation-workbench 1.1.14 → 1.1.15

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 (179) hide show
  1. package/dist/.vite/manifest.json +552 -552
  2. package/dist/assets/{ChartEmptyState-DOlrd3QL.js → ChartEmptyState-ZXRcbrLV.js} +1 -1
  3. package/dist/assets/ChartLoadingSkeleton-BRWWLwJE.js +1 -0
  4. package/dist/assets/{ChartView-nQvehKAl.js → ChartView-B6f1J6Er.js} +2 -2
  5. package/dist/assets/ChartWidget-29BcqLsQ.js +5 -0
  6. package/dist/assets/{abnfDiagram-VCTEODGH-BOSMF_iF.js → abnfDiagram-VCTEODGH-BuQmdgCH.js} +1 -1
  7. package/dist/assets/{af-1WnNPqq-.js → af-CBNa7AYn.js} +1 -1
  8. package/dist/assets/{ar-I_OTuA6g.js → ar-RghUrw-U.js} +1 -1
  9. package/dist/assets/{architectureDiagram-5GKGNRK7-F_DICN7K.js → architectureDiagram-5GKGNRK7-BVyAQs-b.js} +1 -1
  10. package/dist/assets/badge-tone-Ci8vno_R.js +5 -0
  11. package/dist/assets/{bg-BNynXrJg.js → bg-D_WdYZi3.js} +1 -1
  12. package/dist/assets/{blockDiagram-I7D4REHJ-vdakidUW.js → blockDiagram-I7D4REHJ-R2VdOZ1H.js} +1 -1
  13. package/dist/assets/{bn-IoUqFxhs.js → bn-Do7unCCm.js} +1 -1
  14. package/dist/assets/{c4Diagram-7LVT6UL2-cnHP-5K7.js → c4Diagram-7LVT6UL2-Bslw228e.js} +1 -1
  15. package/dist/assets/{ca-CWN_9uem.js → ca-CRZTbRqC.js} +1 -1
  16. package/dist/assets/channel-DxaB-rRG.js +1 -0
  17. package/dist/assets/{chunk-4HAMMTFA-C6G-f7n3.js → chunk-4HAMMTFA-DUDg3eHK.js} +1 -1
  18. package/dist/assets/{chunk-75Z2AOVW-DiyJkf0q.js → chunk-75Z2AOVW-DaeXzHyk.js} +1 -1
  19. package/dist/assets/{chunk-DU6HZSFF-Dy7jxNH_.js → chunk-DU6HZSFF-B3UMRfg8.js} +2 -2
  20. package/dist/assets/{chunk-F27PBJKO-CkvHG7F6.js → chunk-F27PBJKO-BEX6D1-n.js} +1 -1
  21. package/dist/assets/{chunk-GMAD6QVW-DsY6Jtz4.js → chunk-GMAD6QVW-ZsbK8Hyz.js} +1 -1
  22. package/dist/assets/{chunk-GVQU2GXP-BE5D92zU.js → chunk-GVQU2GXP-CFgk1428.js} +1 -1
  23. package/dist/assets/{chunk-IMKFNOWR-CAwOIW4R.js → chunk-IMKFNOWR-Bl09s7a_.js} +1 -1
  24. package/dist/assets/{chunk-L3NEJ4N5-B1mDlHi1.js → chunk-L3NEJ4N5-zKVzE7OW.js} +1 -1
  25. package/dist/assets/{chunk-OSK3NFVY-iylVXGs0.js → chunk-OSK3NFVY-BmuNqHzQ.js} +1 -1
  26. package/dist/assets/{chunk-P2QGCYS3-CvcRZ6j9.js → chunk-P2QGCYS3-C2tydC-M.js} +1 -1
  27. package/dist/assets/{chunk-POPQ4Y6H-CNbcNXVN.js → chunk-POPQ4Y6H-DNak0l6w.js} +1 -1
  28. package/dist/assets/{chunk-PWAF6VOD-BorA01Hz.js → chunk-PWAF6VOD-D95y-mRG.js} +1 -1
  29. package/dist/assets/{chunk-SHT3W25Y-DNWg7N7_.js → chunk-SHT3W25Y-BK0XKr9M.js} +1 -1
  30. package/dist/assets/{chunk-SVP7TREG-C_gZGZzY.js → chunk-SVP7TREG-CD0633UP.js} +1 -1
  31. package/dist/assets/{chunk-TICWLB2K-CG8L7csD.js → chunk-TICWLB2K-C_TN_qXz.js} +1 -1
  32. package/dist/assets/classDiagram-ZZMXUADV-Cb5NNOFP.js +1 -0
  33. package/dist/assets/classDiagram-v2-VYDZK3BY-Cb5NNOFP.js +1 -0
  34. package/dist/assets/{cm6-editor-BrI954sl.js → cm6-editor-CsI0AZDl.js} +3 -3
  35. package/dist/assets/{code-block-IT6T5CEO-P8OONT1n.js → code-block-IT6T5CEO-rh8d07_F.js} +1 -1
  36. package/dist/assets/{context-BNM55Snb.js → context-9KbckYZi.js} +1 -1
  37. package/dist/assets/{cs-CmgNpjMj.js → cs-LJwt8LR2.js} +1 -1
  38. package/dist/assets/{cy-zQX_QEXD.js → cy-BlvpCYgb.js} +1 -1
  39. package/dist/assets/{cynefinDiagram-5FMLGOSQ-Drk0vtFB.js → cynefinDiagram-5FMLGOSQ-DxRmh9t5.js} +1 -1
  40. package/dist/assets/{da-CjOdj32R.js → da-BUvDMABw.js} +1 -1
  41. package/dist/assets/{dagre-GXQ25YYZ-CLrGf0om.js → dagre-GXQ25YYZ-w2hLzSss.js} +1 -1
  42. package/dist/assets/{de-AT-BLeHD7-g.js → de-AT-CMYX-FSX.js} +1 -1
  43. package/dist/assets/{de-CwLcXmDQ.js → de-Cg_5asH4.js} +1 -1
  44. package/dist/assets/{diagram-S7CK7UJ4-B-ZdgPTX.js → diagram-S7CK7UJ4-CNrSaCrT.js} +1 -1
  45. package/dist/assets/{diagram-UQ7AKVKN-BkKvmg4L.js → diagram-UQ7AKVKN-BEoR36FG.js} +1 -1
  46. package/dist/assets/{diagram-VSXAHHWV-HiaAFHhk.js → diagram-VSXAHHWV-Dy8S8rIp.js} +1 -1
  47. package/dist/assets/{diagram-VX7I27RA-DwkAZ58D.js → diagram-VX7I27RA-BC8Xf9f0.js} +1 -1
  48. package/dist/assets/{diagram-Z3DM3KII-D-cMFf4d.js → diagram-Z3DM3KII-CKiC1nrY.js} +1 -1
  49. package/dist/assets/{dist-BgSqI6_g.js → dist-1-HCT6qM.js} +1 -1
  50. package/dist/assets/{dist-DJ3oXpIs.js → dist-BQ8k61qr.js} +1 -1
  51. package/dist/assets/{dist-CPuGLmxI.js → dist-BYbvqYeK.js} +1 -1
  52. package/dist/assets/{dist-kKXf1Bjx.js → dist-Bi-7RiEi.js} +1 -1
  53. package/dist/assets/{dist-BHvGeTYl.js → dist-Ble3IUnd.js} +1 -1
  54. package/dist/assets/{dist-tfb1xShq.js → dist-BuE0_QYF.js} +1 -1
  55. package/dist/assets/{dist-CJxRNwMR.js → dist-C2PLdFfo.js} +1 -1
  56. package/dist/assets/{dist-Dy2TKEdf.js → dist-CSrdLN_Y.js} +1 -1
  57. package/dist/assets/{dist-7Nz9yNhS.js → dist-CY9MvaM1.js} +1 -1
  58. package/dist/assets/{dist-CE3k7Kha.js → dist-CgVofDKX.js} +1 -1
  59. package/dist/assets/{dist-CRpxTWEh.js → dist-Ciqde0Ol.js} +1 -1
  60. package/dist/assets/{dist-BCRkZyjz.js → dist-Cj_xL7Es.js} +1 -1
  61. package/dist/assets/{dist-DlNJgHFc.js → dist-D7MnPcGE.js} +1 -1
  62. package/dist/assets/{dist-5fOMJ27f.js → dist-DBEagOph.js} +1 -1
  63. package/dist/assets/{dist-BxwAVf7j.js → dist-DCP6b5Yp.js} +1 -1
  64. package/dist/assets/{dist-Cuhv1Fm_.js → dist-DChuQCpL.js} +1 -1
  65. package/dist/assets/{dist-KJ6-32V3.js → dist-DOFuKjhK.js} +1 -1
  66. package/dist/assets/{dist-OpJd06F1.js → dist-DXUYhDMM.js} +1 -1
  67. package/dist/assets/{dist-DgFx0nHw.js → dist-Dek2gQIT.js} +1 -1
  68. package/dist/assets/{dist-CstXuejQ.js → dist-ddtYIZHC.js} +1 -1
  69. package/dist/assets/{dist-CPhv_Fl3.js → dist-jCSCdtJ7.js} +1 -1
  70. package/dist/assets/{dist-CFrG-Mt_.js → dist-ngz3bapC.js} +1 -1
  71. package/dist/assets/{dist-ByMsVuIk.js → dist-ssfnxGX1.js} +1 -1
  72. package/dist/assets/{dropbox-picker-C9r5F3kM.js → dropbox-picker-YaUvIgU1.js} +1 -1
  73. package/dist/assets/{ebnfDiagram-PWID7BFC-DrvpEZ_f.js → ebnfDiagram-PWID7BFC-CBnxtxcg.js} +1 -1
  74. package/dist/assets/{el-CWW60iH9.js → el-5l_HfQh-.js} +1 -1
  75. package/dist/assets/{en-AU-BossA0Rn.js → en-AU-DIy7kJ-6.js} +1 -1
  76. package/dist/assets/{en-CA-DATw2cVB.js → en-CA-BY8gTlj5.js} +1 -1
  77. package/dist/assets/{en-GB-CUli1ZoP.js → en-GB-BGqFfEzK.js} +1 -1
  78. package/dist/assets/{erDiagram-RLTQ6QDP-aafi4jCY.js → erDiagram-RLTQ6QDP-ZW5EDEeK.js} +1 -1
  79. package/dist/assets/{es-qp1wsCMr.js → es-Bb0Mmwm4.js} +1 -1
  80. package/dist/assets/{esm-B3AZ9HP5.js → esm-CfFZhCCl.js} +1 -1
  81. package/dist/assets/esm-DDY4jF6a.js +46 -0
  82. package/dist/assets/{et-CuSdGi0t.js → et-BSa6lvqX.js} +1 -1
  83. package/dist/assets/{eu-xCnVjdHU.js → eu-9Yfh6o5v.js} +1 -1
  84. package/dist/assets/{fa-IR-DZ3ibPOw.js → fa-IR-BlqDoYrh.js} +1 -1
  85. package/dist/assets/{fi-g4XjAI_I.js → fi-Cj9cD91h.js} +1 -1
  86. package/dist/assets/flowDiagram-HODETNUW-Br3H18HF.js +1 -0
  87. package/dist/assets/{flows-actors-graph-runtime-DeTt1QCB.js → flows-actors-graph-runtime-YwzVDPst.js} +1 -1
  88. package/dist/assets/{fr-BhOuGXkV.js → fr-B0qYMnPX.js} +1 -1
  89. package/dist/assets/{fr-CA-BYF9Kaol.js → fr-CA-C2acOTEv.js} +1 -1
  90. package/dist/assets/{ganttDiagram-EL5Y4UJY-CRmnjbyh.js → ganttDiagram-EL5Y4UJY-D0NWXhSy.js} +1 -1
  91. package/dist/assets/{gitGraphDiagram-WWUBYQGX-C4ebHhmy.js → gitGraphDiagram-WWUBYQGX-C16HvgtP.js} +1 -1
  92. package/dist/assets/{gl-BLfeYzoG.js → gl-Ce_1v5yA.js} +1 -1
  93. package/dist/assets/{google-drive-picker-3-SZkSfN.js → google-drive-picker-DL6kxOGz.js} +1 -1
  94. package/dist/assets/{graph-runtime-BbbtydnB.js → graph-runtime-BDCDECWS.js} +1 -1
  95. package/dist/assets/{he-BXMp0P82.js → he-fssXNSLh.js} +1 -1
  96. package/dist/assets/{hi-BmH5--Ew.js → hi-wjit_WaO.js} +1 -1
  97. package/dist/assets/{hr-CsQDZ0KK.js → hr-CZcH_ib_.js} +1 -1
  98. package/dist/assets/{hu-DiL5YUSE.js → hu-DmApBwDg.js} +1 -1
  99. package/dist/assets/{id-1Vn21CD0.js → id-CaQxvUk5.js} +1 -1
  100. package/dist/assets/index-CZ5sv4PP.css +2 -0
  101. package/dist/assets/index-Da7nRw0z.js +202 -0
  102. package/dist/assets/{infoDiagram-27XIBGKW-CplMaWp5.js → infoDiagram-27XIBGKW-BB9zejj7.js} +1 -1
  103. package/dist/assets/{is-CByKTwFK.js → is-C7YkCQSO.js} +1 -1
  104. package/dist/assets/isSameWeek-B-QyK2gA.js +1 -0
  105. package/dist/assets/{ishikawaDiagram-5VMMS53U-BREas_JM.js → ishikawaDiagram-5VMMS53U-D0VdeBWj.js} +1 -1
  106. package/dist/assets/{it-CPNWwvi0.js → it--OaDSi8G.js} +1 -1
  107. package/dist/assets/{ja-D9Jm250G.js → ja-BZII__KN.js} +1 -1
  108. package/dist/assets/{journeyDiagram-3NMN7TZE-DWHGp6os.js → journeyDiagram-3NMN7TZE-BAlcsabK.js} +1 -1
  109. package/dist/assets/{kanban-definition-UXKFOSKX-CP-1mPST.js → kanban-definition-UXKFOSKX-DpR1bfHx.js} +1 -1
  110. package/dist/assets/katex-CHQwrTZL.js +1 -0
  111. package/dist/assets/{ko-CpsoMmES.js → ko-RpFeRS3z.js} +1 -1
  112. package/dist/assets/{line-C_Dg3XTF.js → line-sQ28MnTc.js} +1 -1
  113. package/dist/assets/{linear-DMyAYyr-.js → linear-B5bg3HtL.js} +1 -1
  114. package/dist/assets/{lt-Ckx9bY2o.js → lt-Mb4LqnAa.js} +1 -1
  115. package/dist/assets/{lv-DZt3HT5G.js → lv-D333_Qfx.js} +1 -1
  116. package/dist/assets/{markdown-stream-runtime-CMB_Qu0K.js → markdown-stream-runtime-kB8TMEpF.js} +4 -4
  117. package/dist/assets/{match-_OgMbUjy.js → match-BwzNbvxk.js} +1 -1
  118. package/dist/assets/{match-CLYNQBt4.js → match-DQpkdx9H.js} +1 -1
  119. package/dist/assets/mermaid-VLURNSYL-DUd6jtzD.js +1 -0
  120. package/dist/assets/{mermaid.core-D_DICvzX.js → mermaid.core-DY7EfcRK.js} +4 -4
  121. package/dist/assets/{mindmap-definition-YA3MSWOX-C20ANuWc.js → mindmap-definition-YA3MSWOX-DAHZInIk.js} +1 -1
  122. package/dist/assets/{ms-C7UJy830.js → ms-CLbOeyRX.js} +1 -1
  123. package/dist/assets/{mt-8KsNOVwG.js → mt-PLOofk2t.js} +1 -1
  124. package/dist/assets/{nb-C7YQIAOB.js → nb-DxwrcYvh.js} +1 -1
  125. package/dist/assets/{nl-UadnkhJV.js → nl-CzRLOR7M.js} +1 -1
  126. package/dist/assets/node-YCCWYXNI.js +2 -0
  127. package/dist/assets/{onedrive-picker-C_4mWMyM.js → onedrive-picker-B79jNUe8.js} +1 -1
  128. package/dist/assets/{pdf-viewer-By7fQHYQ.js → pdf-viewer-CslUZhU5.js} +1 -1
  129. package/dist/assets/{pegDiagram-XKGWAZYB-DVbFO1Fa.js → pegDiagram-XKGWAZYB-Dq7UThjR.js} +1 -1
  130. package/dist/assets/{pieDiagram-E7YTZNPT-DWtaagpj.js → pieDiagram-E7YTZNPT-Dl3n9rSp.js} +1 -1
  131. package/dist/assets/{pl-DaJL5jLd.js → pl-gbLhckq3.js} +1 -1
  132. package/dist/assets/{pt-BR-zn9BrDVb.js → pt-BR-R1rW_1OL.js} +1 -1
  133. package/dist/assets/{pt-BHQDKf9o.js → pt-BwcWNQjq.js} +1 -1
  134. package/dist/assets/{public-runtime-f4VjjFok.js → public-runtime-8slf2C-u.js} +1 -1
  135. package/dist/assets/{quadrantDiagram-AXDQQJYC-CJvBFA_c.js → quadrantDiagram-AXDQQJYC-_GKiRjuD.js} +1 -1
  136. package/dist/assets/{railroadDiagram-O6MQD6OU-Dygrn5Zv.js → railroadDiagram-O6MQD6OU-6CUNSmGg.js} +1 -1
  137. package/dist/assets/{requirementDiagram-BXWQKSXE-BpnohlUt.js → requirementDiagram-BXWQKSXE-BPl-usp2.js} +1 -1
  138. package/dist/assets/{ro-BdQOzb6t.js → ro-DdDjuWNa.js} +1 -1
  139. package/dist/assets/{ru-BmbP3F22.js → ru-BawxQnYH.js} +1 -1
  140. package/dist/assets/{sankeyDiagram-P5KCCOFB-Cyy3VaYL.js → sankeyDiagram-P5KCCOFB-DZKA85RO.js} +1 -1
  141. package/dist/assets/{sequenceDiagram-WJ2MYXX4-GaYcTb-c.js → sequenceDiagram-WJ2MYXX4-BJQcyiuO.js} +1 -1
  142. package/dist/assets/{sk-Deobe1dz.js → sk-MRZEZ2K_.js} +1 -1
  143. package/dist/assets/{sl-DDWo-_WQ.js → sl-BBub_-u1.js} +1 -1
  144. package/dist/assets/{stateDiagram-D77RDMKH-DGiRCD9r.js → stateDiagram-D77RDMKH-B-0Pxnb4.js} +1 -1
  145. package/dist/assets/stateDiagram-v2-MP3YSRHH-Ctzs0iNL.js +1 -0
  146. package/dist/assets/{sv-DQUMehtC.js → sv-C4z9pgWx.js} +1 -1
  147. package/dist/assets/{swimlanes-42K2YHIH-D7xJP0pw.js → swimlanes-42K2YHIH-oICSfvZv.js} +1 -1
  148. package/dist/assets/swimlanesDiagram-VR7AAH4N-Bhf7f3Wn.js +8 -0
  149. package/dist/assets/{ta-CzkRFNns.js → ta-1G1MUVAA.js} +1 -1
  150. package/dist/assets/{th-DR6hfS-t.js → th-CbVjLGeK.js} +1 -1
  151. package/dist/assets/{timeline-definition-24CTP7MA-DTJnlCQe.js → timeline-definition-24CTP7MA-DmKkaTSI.js} +1 -1
  152. package/dist/assets/{tr-ECW9jg6T.js → tr-CL1-pTfR.js} +1 -1
  153. package/dist/assets/useI18n-DcSZnYEx.js +171 -0
  154. package/dist/assets/{vennDiagram-4TSXK5OY-CFat-M74.js → vennDiagram-4TSXK5OY-CnK77vBm.js} +1 -1
  155. package/dist/assets/{vi-D2nRiUXf.js → vi-1ZMJLve8.js} +1 -1
  156. package/dist/assets/{wardleyDiagram-VM6X3IG4-h29SCI73.js → wardleyDiagram-VM6X3IG4-DkkVnAra.js} +1 -1
  157. package/dist/assets/{xychartDiagram-S5SC5T6Z-B8S8taDj.js → xychartDiagram-S5SC5T6Z-DXVlr43t.js} +1 -1
  158. package/dist/assets/{zh-CN-Cn0aI883.js → zh-CN-uOTSXSf7.js} +1 -1
  159. package/dist/assets/{zh-HK-DxBG0PaI.js → zh-HK-CNYirMD2.js} +1 -1
  160. package/dist/assets/{zh-TW-DHK1J7Rs.js → zh-TW-DB-dAf15.js} +1 -1
  161. package/dist/index.html +10 -10
  162. package/package.json +9 -9
  163. package/dist/assets/ChartLoadingSkeleton-BlVB40sh.js +0 -1
  164. package/dist/assets/ChartWidget-CZ5NXj5y.js +0 -5
  165. package/dist/assets/badge-tone-B1Pd5hFs.js +0 -5
  166. package/dist/assets/channel-Dn5Kml0R.js +0 -1
  167. package/dist/assets/classDiagram-ZZMXUADV-DZBHmNh2.js +0 -1
  168. package/dist/assets/classDiagram-v2-VYDZK3BY-DZBHmNh2.js +0 -1
  169. package/dist/assets/esm-GB9ACU6Q.js +0 -46
  170. package/dist/assets/flowDiagram-HODETNUW-RzRAndm9.js +0 -1
  171. package/dist/assets/index-Bcdys-EF.css +0 -2
  172. package/dist/assets/index-TNOEipJX.js +0 -202
  173. package/dist/assets/isSameWeek-Bf15BL-p.js +0 -1
  174. package/dist/assets/katex-Dp9rtsw4.js +0 -1
  175. package/dist/assets/mermaid-VLURNSYL-DXNPK6wv.js +0 -1
  176. package/dist/assets/node-nqfXDpgr.js +0 -2
  177. package/dist/assets/stateDiagram-v2-MP3YSRHH-CZRVHb2L.js +0 -1
  178. package/dist/assets/swimlanesDiagram-VR7AAH4N-C2KDCowk.js +0 -8
  179. package/dist/assets/useI18n-CrrUk_L3.js +0 -171
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-BWaJ3C7D.js";import{t as n}from"./react-9WV3M1gM.js";import{$ as r,$a as i,$i as a,$p as o,Aa as s,Ag as c,Ar as l,DD as u,Dt as d,EE as f,Eb as p,Eg as m,Eh as h,En as g,FS as _,Fr as v,Ft as y,Go as b,Ia as x,Ib as ee,It as te,Ja as S,Ko as ne,La as C,Lr as w,Lt as re,Lx as ie,Mr as ae,Ng as T,Nn as oe,Nr as se,Nt as ce,Nx as E,Ob as D,Od as le,PS as ue,QE as O,Qi as de,Qp as fe,R as k,Sa as pe,Tb as me,U_ as he,Up as ge,Ux as _e,W_ as ve,Wb as ye,Wp as A,Wx as be,Xa as xe,Xb as Se,Xi as Ce,Xo as we,Xp as Te,Yy as j,Za as Ee,Zi as De,_a as Oe,_t as ke,_u as Ae,an as je,ax as M,bb as Me,bt as Ne,ca as Pe,cx as Fe,dy as Ie,eD as Le,ea as Re,em as ze,eo as Be,et as Ve,fD as He,fS as Ue,ft as N,fy as We,gt as Ge,gy as Ke,ht as qe,iu as Je,jr as P,jt as Ye,k as F,kb as Xe,kr as Ze,l as Qe,lD as $e,lb as et,lt as tt,ma as nt,mm as rt,mt as it,n as at,nC as ot,nm as st,nt as ct,om as lt,ox as ut,pa as dt,pn as ft,py as pt,qT as mt,r as ht,rx as gt,ry as _t,sb as vt,t as yt,tT as bt,ta as xt,vt as St,vu as Ct,w as wt,wa as Tt,wt as Et,x as Dt,xa as Ot,xf as kt,yD as At,yo as jt,yt as Mt,zr as Nt}from"./useI18n-CrrUk_L3.js";import{Ai as Pt,Br as Ft,Cr as It,Fi as Lt,Pi as I,Si as L,Yr as R,_i as Rt,br as zt,ci as Bt,dr as z,er as B,li as V,or as Vt,sr as H}from"./public-runtime-f4VjjFok.js";import{t as Ht}from"./jsx-runtime-lTuChwRC.js";function Ut(e){return e?{needsObjectContext:e.needsObjectContext===!0,needsUserContext:e.needsUserContext===!0}:{needsObjectContext:!1,needsUserContext:!1}}function Wt(e){let t=Ut(e.enabledCondition),n=Ut(e.basicPrefixOperation);return{needsObjectContext:t.needsObjectContext||n.needsObjectContext,needsUserContext:t.needsUserContext||n.needsUserContext}}var U=e(n(),1),Gt;(function(e){e.APPLICATION=`application`,e.RESOURCE=`resource`})(Gt||={});var Kt=It(`scope`,[V({scope:R(Gt.APPLICATION)}),V({scope:R(Gt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional()})]);function qt(e){return`app.${e}`}var Jt;(function(e){e.RESOURCE=`resource`,e.COMPOSITE_VIEW=`composite-view`,e.APP_VIEW=`app-view`})(Jt||={});var Yt;(function(e){e.CHART_VIEW=`chart-view`,e.COMPOSITE_VIEW=`composite-view`,e.EXECUTION_VIEW=`execution-view`})(Yt||={});var Xt;(function(e){e.APP_SCOPE=`app-scope`,e.PARENT_CONTEXT=`parent-context`,e.URL_PARAM=`url-param`,e.FIXED_VALUE=`fixed-value`})(Xt||={});var Zt=V({hostKind:B(Jt),hostRef:L().min(1),viewKind:B(Yt),localRef:L().min(1),insertedViewRef:L().min(1)}),Qt=`::`;function $t(e){return[e.hostKind,e.viewKind,e.hostRef,e.localRef].join(Qt)}function en(e){return{...e,insertedViewRef:$t(e)}}function tn(e){if(!e)return;let[t,n,r,i,...a]=e.split(Qt);if(!(!t||!n||!r||!i||a.length>0)&&Object.values(Jt).includes(t)&&Object.values(Yt).includes(n))return{hostKind:t,hostRef:r,viewKind:n,localRef:i,insertedViewRef:e}}var nn=V({inputRef:L().min(1),source:B(Xt),contextKey:L().min(1).optional(),value:Lt().optional()}).superRefine((e,t)=>{e.source===Xt.FIXED_VALUE?e.value===void 0&&t.addIssue({code:`custom`,message:"Fixed-value inserted view bindings require `value`.",path:[`value`]}):e.contextKey||t.addIssue({code:`custom`,message:"Context-driven inserted view bindings require `contextKey`.",path:[`contextKey`]})}),rn=V({identity:Zt,contextResourceIdentifiers:Rt(L(),L()),resolvedInputs:Rt(L(),Lt()).optional()});function an(e){return qt(e)}function on(e,t){return`resources.${e}.${t}`}function sn(e,t={}){return{viewComponent:e,...t}}var cn=`composite_ctx_`;function ln(e){return e?.isAddressable===!0&&e.scope===Gt.APPLICATION}function un(e){return e?Object.entries(e).map(([e,t])=>({ref:e,translationRef:an(e),scope:Gt.APPLICATION,isAddressable:!0,operationLike:M.READ,primaryScope:D.APPLICATION,sectionRefs:t.sectionRefs,labels:t.labels,viewComponent:t.viewComponent,icon:t.icon,adjacentZoneOnEmpty:t.adjacentZoneOnEmpty,zoneContentMaxWidth:t.zoneContentMaxWidth,zoneContentFillsHeight:t.zoneContentFillsHeight})):[]}function dn(e){return e?.isAddressable===!0&&e.scope===Gt.RESOURCE}function fn(e){return e?e.scope===Gt.APPLICATION?ln(e):dn(e):!1}function pn(e,t){return en({hostKind:Jt.RESOURCE,hostRef:e,viewKind:Yt.COMPOSITE_VIEW,localRef:t.ref})}function mn(e){let{viewRef:t,compositeViews:n,registry:r}=e;if(!t)return;let i=n?.find(e=>e.ref===t);if(i)return i;let a=tn(t);if(a&&a.hostKind===Jt.RESOURCE&&a.viewKind===Yt.COMPOSITE_VIEW)return r?.resourceConfigurations[a.hostRef]?.frontendConfiguration?.compositeViews?.find(e=>e.ref===a.localRef)}function hn(e){let{viewRef:t,compositeViews:n,registry:r}=e;if(!t)return;let i=n?.find(e=>e.ref===t);if(i?.primaryScope)return i.primaryScope;let a=tn(t);if(a&&a.hostKind===Jt.RESOURCE&&a.viewKind===Yt.COMPOSITE_VIEW)return r?.resourceConfigurations[a.hostRef]?.frontendConfiguration?.compositeViews?.find(e=>e.ref===a.localRef)?.primaryScope}function gn(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t??{}))r&&n.set(`${cn}${e}`,r);let r=n.toString();return r.length>0?`/composite/${e}?${r}`:`/composite/${e}`}function _n(e){let t={};for(let[n,r]of e.entries())n.startsWith(`composite_ctx_`)&&r&&(t[n.slice(14)]=r);return Object.keys(t).length>0?t:void 0}var vn=V({ref:L().min(1),translationRef:L().min(1),isAddressable:z().default(!1),operationLike:B(M).default(M.READ),primaryScope:B(D).default(D.ORGANIZATIONS),sectionRefs:H(L()).optional(),labels:H(Vt()).optional(),viewComponent:Vt(),requiredFeatures:rt.optional(),icon:zt().optional(),adjacentZoneOnEmpty:B(Se).optional(),zoneContentMaxWidth:B(_).optional(),zoneContentFillsHeight:z().optional()}),yn=Ft(Kt,vn),bn=yn,xn=Ft(Kt,V({ref:L().min(1),trigger:c.optional(),options:T,elements:H(m),requiredFeatures:rt.optional()})),Sn=Ft(Kt,V({ref:L().min(1),isAddressable:z().default(!1),operationLike:B(M).default(M.READ),primaryScope:B(D).default(D.ORGANIZATIONS),systemRef:L().min(1),layoutPreset:L().default(`Default`),requiredFeatures:rt.optional(),icon:zt().optional()})),Cn=Ft(Kt,V({ref:L().min(1),isAddressable:z().default(!1),operationLike:B(M).default(M.READ),primaryScope:B(D).default(D.ORGANIZATIONS),componentRef:L().min(1),requiredFeatures:rt.optional(),icon:zt().optional(),labels:H(Vt()).optional()})),wn;(function(e){e.COMMAND_ONLY=`command_only`,e.OMNIBOX=`omnibox`})(wn||={});var Tn;(function(e){e.USER_INFO=`user_info`,e.ORG_SWITCHER=`org_switcher`,e.SETTINGS=`settings`,e.LOGOUT=`logout`})(Tn||={});var En;(function(e){e.AVATAR_ONLY=`avatar_only`,e.AVATAR_NAME=`avatar_name`,e.AVATAR_ORG=`avatar_org`,e.FULL=`full`})(En||={});var Dn;(function(e){e.CONTROL_ONLY=`control-only`,e.ICON_LED=`icon-led`,e.LABEL_ABOVE=`label-above`})(Dn||={});var On=V({resourceType:L(),fieldIdentifier:L(),position:Bt().optional(),dependsOn:L().optional(),persist:z().optional(),label:L().optional(),optionDisplayMode:B([f.LABEL,f.SUMMARY]).optional(),presentation:B(Dn).optional()}),kn=999;function An(e){if(!e||e.length===0)return[];let t=new Map;for(let n of e){let e=t.get(n.resourceType);e?e.push(n.fieldIdentifier):t.set(n.resourceType,[n.fieldIdentifier])}return Array.from(t.entries()).filter(([,e])=>e.length>1).map(([e,t])=>({resourceType:e,fieldIdentifiers:t}))}var jn=V({fields:H(On).optional()}),Mn=I([L(),Bt()]),Nn=V({id:L(),label:L(),icon:L().optional(),value:I([L(),Bt()]).optional()}),Pn=Nn.extend({type:R(_e.TEXT)}),Fn=Nn.extend({type:R(_e.LINK),href:L()}),In=Nn.extend({type:R(_e.BUTTON),onClick:zt(e=>typeof e==`function`)}),Ln=It(`type`,[Pn,Fn,In]),Rn=V({[E.MENUBAR]:I([z().default(!0),I([R(`FIXED`),R(`OVERLAY`)]).default(`FIXED`),H(V({breakpoint:B(mt).default(mt.MOBILE),responsivePolicy:I([R(`FIXED`),R(`OVERLAY`)]).default(`FIXED`)})),V({displayPolicy:I([R(`FIXED`),R(`OVERLAY`)]).default(`FIXED`),hostedComponents:H(dt).optional(),items:H(nt).optional(),brandHeader:z().optional(),brandMarkTheme:B(he).optional()})]).default(!0),[E.TOOLBAR]:I([z(),V({placement:I([R(`top`),R(`bottom`)]).default(`top`),compact:z().optional(),showSeparator:z().optional(),hideOnMobile:z().optional(),tools:H(x).optional()})]).default(!0),[E.HOTKEY]:I([z(),V({bindings:H(Pe).optional(),emitShortcuts:H(ie).optional()})]).default(!0),[E.NOTIFICATION_CENTER]:z().default(!0),[E.SIDEBAR]:I([z(),V({placement:I([R(ot.START),R(ot.END)]),collapsible:z().default(!0),defaultCollapsed:z().optional(),responsiveBreakpoint:B(mt).default(mt.MOBILE),responsivePolicy:B(Tt).default(Tt.BURGER),defaultSection:L().default(`main`),homeDisplayMode:B(Ot).optional(),brandMarkTheme:B(he).optional(),contentSections:H(s).optional(),hostedComponents:H(pe).optional(),width:Bt().optional(),mobileWidth:Bt().optional(),collapsedWidth:Bt().optional(),mobileCollapsedWidth:Bt().optional()})]).default(!0),[E.COMMAND_MENU]:I([z(),V({policy:B(wn).default(wn.COMMAND_ONLY),showRecent:z().default(!0),maxRecentItems:Bt().default(5),showShortcuts:z().default(!0),defaultCategory:L().optional(),openShortcut:L().optional(),commands:H(a).optional(),searchResources:H(Re).optional(),categoryOrder:H(L()).optional(),dialogWidth:L().optional()})]).default(!0),[E.QUICK_ACTION_BUTTON]:I([z(),R(`FLOATING`),V({actions:H(Oe).optional()})]).default(!0),[E.QUICK_SWITCHER]:z().default(!0),[E.CONTROL_PANEL]:I([z().default(!0),V({items:H(xt).optional()})]).default(!0),[E.STATUS_BAR]:I([z().default(!0),be,V({placement:be.optional(),showMemoryUsage:z().default(!1),showNotificationCount:z().default(!0),showConnectionStatus:z().default(!0),showConnectionStatusOnMobile:z().optional(),backgroundClassName:L().optional(),textClassName:L().optional(),showBorder:z().optional(),height:Bt().optional(),statusItems:H(Ln).optional(),style:Rt(L(),Mn).optional()})]).default(!0),[E.USER_DROPDOWN]:I([z().default(!0),V({avatarDisplay:B(En).default(En.AVATAR_ONLY),sections:H(B(Tn)).optional(),showOrgSwitcher:z().default(!0),showLogout:z().default(!0),settingsEntries:H(L()).optional()})]).default(!0),[E.NAVIGATION_CONTROL]:z().default(!0),[E.ACTIVITY_BAR]:I([z(),V({desktopRendering:De.default(Ce.VERTICAL_RAIL),mobileRendering:De.default(Ce.BOTTOM_TAB_BAR)})]).default(!1),[E.UTILITY_PANEL]:I([z(),V({items:H(C).optional(),icon:L().optional(),position:I([R(ot.START),R(ot.END)]).default(ot.END)})]).default(!1)}),zn;(function(e){e.TOP_SIDEBAR=`top_sidebar`,e.BOTTOM_SIDEBAR=`bottom_sidebar`,e.MENUBAR_RIGHT=`menubar_right`,e.MENUBAR_LEFT=`menubar_left`,e.FLOATING=`floating`})(zn||={});var Bn;(function(e){e.TOP_SIDEBAR=`top_sidebar`,e.BOTTOM_SIDEBAR=`bottom_sidebar`,e.MENUBAR_RIGHT=`menubar_right`,e.MENUBAR_LEFT=`menubar_left`,e.USER_DROPDOWN=`user_dropdown`,e.SETTINGS_DROPDOWN=`settings_dropdown`})(Bn||={});var Vn;(function(e){e.COMPACT=`compact`,e.EXPANDED=`expanded`,e.BOTH=`both`})(Vn||={});var Hn=V({resourceOperationPath:Ee.optional(),compositeViewReference:L().optional()}),Un;(function(e){e.NAVIGATE=`navigate`,e.RETRY=`retry`,e.EXTERNAL=`external`,e.SUPPORT=`support`})(Un||={});var Wn;(function(e){e.LINK=`link`,e.EMAIL=`email`,e.CHAT=`chat`})(Wn||={});var Gn;(function(e){e.PDF=`pdf`,e.LINK=`link`})(Gn||={});var Kn=V({type:B(Un),target:L().optional(),resourceOperationPath:Ee.optional(),compositeViewReference:L().optional(),icon:L().optional()}).superRefine((e,t)=>{let n=!!e.resourceOperationPath||!!e.compositeViewReference,r=typeof e.target==`string`&&e.target.length>0;e.type===Un.NAVIGATE?!r&&!n&&t.addIssue({code:`custom`,path:[`target`],message:"Navigate error-page actions require `target`, `resourceOperationPath`, or `compositeViewReference`."}):e.type===Un.RETRY?(e.target!==void 0&&t.addIssue({code:`custom`,path:[`target`],message:"Retry error-page actions do not accept `target`."}),n&&t.addIssue({code:`custom`,path:[`resourceOperationPath`],message:"Structured navigation targets are only valid for `navigate` error-page actions."})):(r||t.addIssue({code:`custom`,path:[`target`],message:`Error-page action type "${e.type}" requires a string target.`}),n&&t.addIssue({code:`custom`,path:[`resourceOperationPath`],message:"Structured navigation targets are only valid for `navigate` error-page actions."}))}),qn=V({ref:L(),target:L().optional(),resourceOperationPath:Ee.optional(),compositeViewReference:L().optional(),icon:L().optional()}).superRefine((e,t)=>{let n=!!e.resourceOperationPath||!!e.compositeViewReference;!(typeof e.target==`string`&&e.target.length>0)&&!n&&t.addIssue({code:`custom`,path:[`target`],message:"Feature-guide items require `target`, `resourceOperationPath`, or `compositeViewReference`."})}),Jn=V({type:B(Wn),target:L()}),Yn=V({primaryAction:Kn.optional(),secondaryActions:H(Kn).optional(),supportAccess:Jn.optional(),featureGuide:H(qn).optional(),leadMagnet:V({type:B(Gn),target:L()}).optional()}),Xn=V({notFound:Yn.optional(),unauthorized:Yn.optional(),forbidden:Yn.optional(),serverError:Yn.optional(),maintenance:Yn.optional()}),Zn=V({name:L().min(1),brandAssets:ve.array().optional()}),Qn;(function(e){e.HIDDEN=`hidden`,e.BRAND_HEADER=`brand_header`})(Qn||={});var $n;(function(e){e.CLIENTS=`clients`})($n||={});var er=V({navigationLayout:ye,appComponentsConfiguration:Rn,designSystemConfiguration:Ue.optional(),compositeViews:bn.array().optional(),onboardingViews:xn.array().optional(),fullCustomViews:Cn.array().optional(),flowsActorsViews:Sn.array().optional(),guidanceFlows:lt.array().optional(),homeDefinition:Hn.optional(),errorPageConfig:Xn.optional(),appModes:de.array().optional(),appScope:jn.optional(),settingsHub:zt().optional(),suppressedEngineNavigationEntries:H(B($n)).optional(),shellIdentity:Zn.optional(),publicShellIdentityMode:B(Qn).optional()}).superRefine((e,t)=>{let n=An(e.appScope?.fields??[]);for(let e of n)t.addIssue({code:`custom`,path:[`appScope`,`fields`],message:`Duplicate app-scope resourceType "${e.resourceType}" is not allowed in appScope.fields. Conflicting fieldIdentifiers: ${e.fieldIdentifiers.join(`, `)}`})}),W=Ht(),tr=`pane`,nr=V({scope:R(Gt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional(),ref:L().min(1),chartDefinition:Ae,isAddressable:z().default(!1),operationLike:B(M).default(M.READ),primaryScope:B(D).default(D.ORGANIZATIONS),inputBindings:H(nn).optional(),icon:zt().optional()});function rr(e){return!(!e||e.isAddressable!==!0)}var ir=V({identity:Zt,executionChartRef:L().min(1),chartDefinition:Ae,contextResourceIdentifiers:Rt(L(),L()),resolvedInputs:Ct.optional()}),ar=`chart_ctx_`,or=`/chart/`;function sr(e,t){return en({hostKind:Jt.RESOURCE,hostRef:e,viewKind:Yt.CHART_VIEW,localRef:t.ref})}function cr(e){return{identity:e.identity,executionChartRef:e.chartView.chartDefinition.ref,chartDefinition:e.chartView.chartDefinition,contextResourceIdentifiers:e.contextResourceIdentifiers,resolvedInputs:e.resolvedInputs}}function lr(e){let{viewRef:t,registry:n}=e,r=tn(t);if(!r||r.hostKind!==Jt.RESOURCE||r.viewKind!==Yt.CHART_VIEW)return;let i=n?.resourceConfigurations[r.hostRef]?.frontendConfiguration?.chartViews?.find(e=>e.ref===r.localRef);if(i)return{identity:r,chartView:i}}function ur(e){let t=[],n=e.resourceConfigurations??{};for(let[e,r]of Object.entries(n))fr(t,e,r?.frontendConfiguration?.chartViews);return t}function dr(e){let t=[];for(let[n,r]of Object.entries(e??{}))fr(t,n,r?.chartViews);return t}function fr(e,t,n){if(n)for(let r of n)e.push({chartDefinitionRef:r.chartDefinition.ref,resourceType:t,chartViewRef:r.ref})}function pr(e,t,n){let r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n&&r.set(`${ar}${e}`,n);for(let[e,t]of Object.entries(n??{}))t&&!e.startsWith(`chart_ctx_`)&&r.set(e,t);let i=r.toString();return i.length>0?`${or}${e}?${i}`:`${or}${e}`}function mr(e){let t={};for(let[n,r]of e.entries())n.startsWith(`chart_ctx_`)&&r&&(t[n.slice(10)]=r);return Object.keys(t).length>0?t:void 0}function hr(e){let t={};for(let[n,r]of e.entries())r&&!n.startsWith(`chart_ctx_`)&&n!==`pane`&&(t[n]=r);return Object.keys(t).length>0?t:void 0}var gr;(function(e){e.ACTION_BAR=`action_bar`,e.RECORD_NAVIGATION=`record_navigation`,e.CONTENT_CARD=`content_card`})(gr||={});var _r=V({placement:B(gr).optional(),emphasized:z().optional(),showLabel:z().optional()}),vr={placement:gr.RECORD_NAVIGATION,emphasized:!1,showLabel:!0};function yr(e){return{placement:e?.placement??vr.placement,emphasized:e?.emphasized??vr.emphasized,showLabel:e?.showLabel??vr.showLabel}}var br;(function(e){e.PARENT_RESOURCE_REQUIREMENT=`parent-resource-requirement`,e.ADDITIONAL_RESOURCE_REQUIREMENT=`additional-resource-requirement`})(br||={});var xr=V({bindingKey:L().min(1),source:B(br)}),Sr;(function(e){e.ANCHOR=`anchor`,e.PARENT_RESOURCE_REQUIREMENT=`parent-resource-requirement`,e.ADDITIONAL_RESOURCE_REQUIREMENT=`additional-resource-requirement`,e.RELATIONSHIP_PROJECTION=`relationship-projection`})(Sr||={});var Cr=V({source:R(Sr.ANCHOR)}),wr=V({source:R(Sr.PARENT_RESOURCE_REQUIREMENT),bindingKey:L().min(1)}),Tr=V({source:R(Sr.ADDITIONAL_RESOURCE_REQUIREMENT),bindingKey:L().min(1)}),Er=V({source:R(Sr.RELATIONSHIP_PROJECTION),fromParticipationRef:L().min(1),targetResourceType:Fe,foreignKeyField:L().min(1).optional()}),Dr=It(`source`,[Cr,wr,Tr,Er]),Or;(function(e){e.EMBED_LOCALLY=`embed-locally`,e.DELEGATE_TO_ROUTER=`delegate-to-router`})(Or||={});var kr=I([L().min(1),Pt([L().min(1),L().min(1)])]),Ar=V({resourceType:Fe,operation:kr,handlingMode:B(Or)}),jr=V({defaultHandlingMode:B(Or).default(Or.DELEGATE_TO_ROUTER),operationHandlingExceptions:Ar.array().optional()}),Mr=kr,Nr=V({scope:R(Gt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional(),ref:L().min(1),isAddressable:z().default(!1),primaryScope:B(D).default(D.ORGANIZATIONS),anchor:xr.optional(),navigationPolicy:jr.optional(),surfaceInOperations:H(Mr).optional(),participations:Rt(L(),Dr).optional(),viewComponent:Vt(),launcher:_r.optional(),labels:H(Vt()).optional(),requiredFeatures:rt.optional(),icon:zt().optional(),zoneContentMaxWidth:B(_).optional(),zoneContentFillsHeight:z().optional()}),Pr=`execution_ctx_`;function Fr(e,t){return{...t,viewComponent:e}}function Ir(e){return typeof e==`string`?e:`${e[0]}::${e[1]}`}function Lr(e){let t=new Map;if(!e)return t;let n=Array.isArray(e)?e.map(e=>[e.ref??``,e]):Object.entries(e);for(let[e,r]of n)if(e)for(let n of r.surfaceInOperations??[]){let r=Ir(n),i=t.get(r)??[];t.set(r,[...i,e])}return t}function Rr(e,t){let n=new Map;if(!e)return n;let r=Array.isArray(e)?e.map(e=>[e.ref??``,e]):Object.entries(e);for(let[e,i]of r){if(!e)continue;let r=Ir(i.operationLike??t),a=n.get(r)??[];n.set(r,[...a,e])}return n}function zr(e){return e?.isAddressable===!0&&e.scope===Gt.RESOURCE}function Br(e,t){return en({hostKind:Jt.RESOURCE,hostRef:e,viewKind:Yt.EXECUTION_VIEW,localRef:t.ref})}function Vr(e){let{viewRef:t,registry:n}=e;if(!t)return;let r=tn(t);if(r&&r.hostKind===Jt.RESOURCE&&r.viewKind===Yt.EXECUTION_VIEW)return n?.resourceConfigurations[r.hostRef]?.frontendConfiguration?.executionViews?.find(e=>e.ref===r.localRef)}function Hr(e){let t=String(e.operationIdentifier);return e.variantKey&&e.isOperationDefault!==!0?[t,e.variantKey]:t}function Ur(e,t){return Array.isArray(e)&&Array.isArray(t)?e[0]===t[0]&&e[1]===t[1]:!Array.isArray(e)&&!Array.isArray(t)&&e===t}function Wr(e){let t=e.viewDefinition.navigationPolicy?.defaultHandlingMode??Or.DELEGATE_TO_ROUTER,n=Hr(e.operation);return e.viewDefinition.navigationPolicy?.operationHandlingExceptions?.find(t=>t.resourceType===e.resourceType&&Ur(t.operation,n))?.handlingMode??t}function Gr(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t??{}))r&&n.set(`${Pr}${e}`,r);let r=n.toString();return r.length>0?`/execution/${e}?${r}`:`/execution/${e}`}function Kr(e){let t={};for(let[n,r]of e.entries())n.startsWith(`execution_ctx_`)&&r&&(t[n.slice(14)]=r);return Object.keys(t).length>0?t:void 0}var qr=Object.create(null);qr.open=`0`,qr.close=`1`,qr.ping=`2`,qr.pong=`3`,qr.message=`4`,qr.upgrade=`5`,qr.noop=`6`;var Jr=Object.create(null);Object.keys(qr).forEach(e=>{Jr[qr[e]]=e});var Yr={type:`error`,data:`parser error`},Xr=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Zr=typeof ArrayBuffer==`function`,Qr=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,$r=({type:e,data:t},n,r)=>Xr&&t instanceof Blob?n?r(t):ei(t,r):Zr&&(t instanceof ArrayBuffer||Qr(t))?n?r(t):ei(new Blob([t]),r):r(qr[e]+(t||``)),ei=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function ti(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ni;function ri(e,t){if(Xr&&e.data instanceof Blob)return e.data.arrayBuffer().then(ti).then(t);if(Zr&&(e.data instanceof ArrayBuffer||Qr(e.data)))return t(ti(e.data));$r(e,!1,e=>{ni||=new TextEncoder,t(ni.encode(e))})}var ii=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,ai=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)ai[ii.charCodeAt(e)]=e;var oi=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=ai[e.charCodeAt(r)],o=ai[e.charCodeAt(r+1)],s=ai[e.charCodeAt(r+2)],c=ai[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},si=typeof ArrayBuffer==`function`,ci=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:ui(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:li(e.substring(1),t)}:Jr[n]?e.length>1?{type:Jr[n],data:e.substring(1)}:{type:Jr[n]}:Yr},li=(e,t)=>si?ui(oi(e),t):{base64:!0,data:e},ui=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},di=``,fi=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{$r(e,!1,e=>{r[a]=e,++i===n&&t(r.join(di))})})},pi=(e,t)=>{let n=e.split(di),r=[];for(let e=0;e<n.length;e++){let i=ci(n[e],t);if(r.push(i),i.type===`error`)break}return r};function mi(){return new TransformStream({transform(e,t){ri(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var hi;function gi(e){return e.reduce((e,t)=>e+t.length,0)}function _i(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function vi(e,t){hi||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(gi(n)<1)break;let e=_i(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(gi(n)<2)break;let e=_i(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(gi(n)<8)break;let e=_i(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Yr);break}i=a*2**32+t.getUint32(4),r=3}else{if(gi(n)<i)break;let e=_i(n,i);s.enqueue(ci(a?e:hi.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Yr);break}}}})}function G(e){if(e)return yi(e)}function yi(e){for(var t in G.prototype)e[t]=G.prototype[t];return e}G.prototype.on=G.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},G.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},G.prototype.off=G.prototype.removeListener=G.prototype.removeAllListeners=G.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},G.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},G.prototype.emitReserved=G.prototype.emit,G.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},G.prototype.hasListeners=function(e){return!!this.listeners(e).length};var bi=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),xi=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Si=`arraybuffer`;function Ci(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var wi=xi.setTimeout,Ti=xi.clearTimeout;function Ei(e,t){t.useNativeTimers?(e.setTimeoutFn=wi.bind(xi),e.clearTimeoutFn=Ti.bind(xi)):(e.setTimeoutFn=xi.setTimeout.bind(xi),e.clearTimeoutFn=xi.clearTimeout.bind(xi))}var Di=1.33;function Oi(e){return typeof e==`string`?ki(e):Math.ceil((e.byteLength||e.size)*Di)}function ki(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Ai(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function ji(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function Mi(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Ni=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},Pi=class extends G{constructor(e){super(),this.writable=!1,Ei(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new Ni(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=ci(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=ji(e);return t.length?`?`+t:``}},Fi=class extends Pi{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){pi(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,fi(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ai()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Ii=!1;try{Ii=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Li=Ii;function Ri(){}var zi=class extends Fi{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},Bi=class e extends G{constructor(e,t,n){super(),this.createRequest=e,Ei(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=Ci(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(this._xhr!==void 0&&this._xhr!==null){if(this._xhr.onreadystatechange=Ri,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(Bi.requestsCount=0,Bi.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Vi);else if(typeof addEventListener==`function`){let e=`onpagehide`in xi?`pagehide`:`unload`;addEventListener(e,Vi,!1)}}function Vi(){for(let e in Bi.requests)Bi.requests.hasOwnProperty(e)&&Bi.requests[e].abort()}var Hi=(function(){let e=Wi({xdomain:!1});return e&&e.responseType!==null})(),Ui=class extends zi{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Hi&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Bi(Wi,this.uri(),e)}};function Wi(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Li))return new XMLHttpRequest}catch{}if(!t)try{return new xi.ActiveXObject(`Microsoft.XMLHTTP`)}catch{}}var Gi=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Ki=class extends Pi{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Gi?{}:Ci(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;$r(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&bi(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ai()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},qi=xi.WebSocket||xi.MozWebSocket,Ji={websocket:class extends Ki{createSocket(e,t,n){return Gi?new qi(e,t,n):t?new qi(e,t):new qi(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends Pi{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=vi(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=mi();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&bi(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Ui},Yi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Xi=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function Zi(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=Yi.exec(e||``),a={},o=14;for(;o--;)a[Xi[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Qi(a,a.path),a.queryKey=$i(a,a.query),a}function Qi(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function $i(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var ea=typeof addEventListener==`function`&&typeof removeEventListener==`function`,ta=[];ea&&addEventListener(`offline`,()=>{ta.forEach(e=>e())},!1);var na=class e extends G{constructor(e,t){if(super(),this.binaryType=Si,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=Zi(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=Zi(t.host).host);Ei(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=Mi(this.opts.query)),ea&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},ta.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data)}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=Oi(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,bi(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),ea&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=ta.indexOf(this._offlineEventListener);e!==-1&&ta.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};na.protocol=4;var ra=class extends na{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;na.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n){if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;na.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},ia=class extends ra{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>Ji[e]).filter(e=>!!e)),super(e,n)}};ia.protocol;function aa(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=Zi(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var oa=typeof ArrayBuffer==`function`,sa=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,ca=Object.prototype.toString,la=typeof Blob==`function`||typeof Blob<`u`&&ca.call(Blob)===`[object BlobConstructor]`,ua=typeof File==`function`||typeof File<`u`&&ca.call(File)===`[object FileConstructor]`;function da(e){return oa&&(e instanceof ArrayBuffer||sa(e))||la&&e instanceof Blob||ua&&e instanceof File}function fa(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(fa(e[t]))return!0;return!1}if(da(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return fa(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&fa(e[t]))return!0;return!1}function pa(e){let t=[],n=e.data,r=e;return r.data=ma(n,t),r.attachments=t.length,{packet:r,buffers:t}}function ma(e,t,n){if(!e)return e;if(da(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=ma(e[r],t);return n}if(typeof e==`object`&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON==`function`&&!n)return ma(e.toJSON(),t,!0);let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=ma(e[n],t));return r}return e}function ha(e,t){return e.data=ga(e.data,t),delete e.attachments,e}function ga(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=ga(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=ga(e[n],t));return e}var _a=t({Decoder:()=>ba,Encoder:()=>ya,PacketType:()=>K,isPacketValid:()=>Da,protocol:()=>5}),va=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],K;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(K||={});var ya=class{constructor(e){this.replacer=e}encode(e){return(e.type===K.EVENT||e.type===K.ACK)&&fa(e)?this.encodeAsBinary({type:e.type===K.EVENT?K.BINARY_EVENT:K.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===K.BINARY_EVENT||e.type===K.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=pa(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},ba=class e extends G{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===K.BINARY_EVENT;n||t.type===K.BINARY_ACK?(t.type=n?K.EVENT:K.ACK,this.reconstructor=new xa(t)):super.emitReserved(`decoded`,t)}else if(da(e)||e.base64){if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`)}else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(K[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===K.BINARY_EVENT||r.type===K.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!Ca(a)||a<1)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&t.charAt(n)!==`,`&&n!==t.length;);r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case K.CONNECT:return Ta(t);case K.DISCONNECT:return t===void 0;case K.CONNECT_ERROR:return typeof t==`string`||Ta(t);case K.EVENT:case K.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&va.indexOf(t[0])===-1);case K.ACK:case K.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},xa=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=ha(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Sa(e){return typeof e==`string`}var Ca=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function wa(e){return e===void 0||Ca(e)}function Ta(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ea(e,t){switch(e){case K.CONNECT:return t===void 0||Ta(t);case K.DISCONNECT:return t===void 0;case K.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&va.indexOf(t[0])===-1);case K.ACK:return Array.isArray(t);case K.CONNECT_ERROR:return typeof t==`string`||Ta(t);default:return!1}}function Da(e){return Sa(e.nsp)&&wa(e.id)&&Ea(e.type,e.data)}function Oa(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var ka=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Aa=class extends G{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[Oa(e,`open`,this.onopen.bind(this)),Oa(e,`packet`,this.onpacket.bind(this)),Oa(e,`error`,this.onerror.bind(this)),Oa(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(ka.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:K.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];(!t.pending||e)&&(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:K.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case K.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case K.EVENT:case K.BINARY_EVENT:this.onevent(e);break;case K.ACK:case K.BINARY_ACK:this.onack(e);break;case K.DISCONNECT:this.ondisconnect();break;case K.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t)}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:K.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:K.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function ja(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}ja.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},ja.prototype.reset=function(){this.attempts=0},ja.prototype.setMin=function(e){this.ms=e},ja.prototype.setMax=function(e){this.max=e},ja.prototype.setJitter=function(e){this.jitter=e};var Ma=class extends G{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,Ei(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new ja({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||_a;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new ia(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=Oa(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=Oa(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(Oa(e,`ping`,this.onping.bind(this)),Oa(e,`data`,this.ondata.bind(this)),Oa(e,`error`,this.onerror.bind(this)),Oa(e,`close`,this.onclose.bind(this)),Oa(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){bi(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Aa(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},Na={};function Pa(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=aa(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=Na[i]&&a in Na[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new Ma(r,t):(Na[i]||(Na[i]=new Ma(r,t)),c=Na[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Pa,{Manager:Ma,Socket:Aa,io:Pa,connect:Pa});function Fa(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=`${t}${`=`.repeat(n)}`,i=atob(r),a=Uint8Array.from(i,e=>e.charCodeAt(0));return new TextDecoder().decode(a)}function Ia(e){let t=e.split(`.`);if(t.length!==3)throw Error(`JWT must contain exactly three segments`);return JSON.parse(Fa(t[1]))}function La(e){if(e)try{let{exp:t}=Ia(e);return typeof t==`number`?t:void 0}catch{return}}function Ra(e,t){if(!e||!t)return t;let n=La(e),r=La(t);return n!==void 0&&r!==void 0&&n>r?e:t}var za=5,Ba=5e3,q;(function(e){e.DISCONNECTED=`disconnected`,e.CONNECTING=`connecting`,e.CONNECTED=`connected`,e.ERROR=`error`,e.RECONNECTING=`reconnecting`})(q||={});function Va(e){return Et(e)}function Ha(e){return e?Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`):``}function Ua(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.roomName!==i.roomName||r.resourceType!==i.resourceType||r.resourceId!==i.resourceId||r.scopeKey!==i.scopeKey||r.scopeId!==i.scopeId||Ha(r.contextResourceIdentifiers)!==Ha(i.contextResourceIdentifiers))return!1}return!0}function Wa(e,t){return t?e.scopeId===t||Object.values(e.contextResourceIdentifiers).includes(t):!1}function Ga(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ka(e){return e==null?{}:Ga(e)?e:{errorDetails:e}}var qa=(0,U.createContext)(void 0),Ja=Be.getLogger(),Ya=({children:e})=>{let[t,n]=(0,U.useState)(q.DISCONNECTED),[r,i]=(0,U.useState)(0),[a,s]=(0,U.useState)(null),[c,l]=(0,U.useState)([]),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)({}),p=(0,U.useRef)(null),m=(0,U.useRef)(!1),h=(0,U.useRef)(0),_=(0,U.useRef)(null),v=(0,U.useRef)(!1),y=(0,U.useRef)(0),b=(0,U.useRef)(null),x=(0,U.useRef)(0),ee=(0,U.useRef)(0),te=(0,U.useRef)(null),S=(0,U.useRef)(new Map),ne=(0,U.useRef)(new Map),C=(0,U.useRef)(new Map),w=(0,U.useRef)(0),re=(0,U.useRef)(null),ie=(0,U.useRef)(!1),ae=(0,U.useRef)(!1),T=(0,U.useCallback)(e=>{if(e.resourceId)return o(e.resourceType,e.resourceId);if(e.scopeKey&&e.scopeId)return ze(e.resourceType,e.scopeKey,e.scopeId);throw Error(`Must provide either resourceId or both scopeKey and scopeId`)},[]),oe=(0,U.useCallback)(()=>{let e=Array.from(S.current.values(),e=>({roomName:e.roomName,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers}));l(t=>Ua(t,e)?t:e)},[]),se=(0,U.useCallback)((e,t)=>{let n=C.current.get(e)??new Map;C.current.set(e,n);let r=n.get(t);if(r)return r;let i=n=>{if(e in Te){let r=st(e,n);if(`data`in r){t(r.data);return}console.warn(`Dropped invalid websocket payload at client ingress boundary`,{event:e,issues:r.error.issues})}else t(n)};return n.set(t,i),i},[]),ce=(0,U.useCallback)(e=>{for(let[t,n]of ne.current.entries())for(let r of n)e.on(t,se(t,r))},[se]),E=(0,U.useCallback)(e=>JSON.stringify({url:e.url,token:e.token??null,organizationId:e.organizationId??null,consumableToken:e.consumableToken??null}),[]),D=(0,U.useCallback)(e=>e.replace(/^ws/,`http`),[]),le=(0,U.useCallback)(async e=>{let t=`${D(e)}/health/ready`,n=Date.now(),r=0;for(console.log(`WebSocket: Waiting for API readiness...`,{healthUrl:t});;){try{let e=await Mt.get(t,{timeout:5e3,validateStatus:()=>!0});if(e.status===200&&e.data?.status===`healthy`)return console.log(`WebSocket: API is ready`,{healthUrl:t,attempts:r+1}),!0}catch{}let e=Date.now()-n;if(e>=3e4)return console.warn(`WebSocket: API readiness check timed out, proceeding with connection anyway`,{healthUrl:t,elapsedMs:e,attempts:r+1}),!1;let i=St(r,100,1e4);console.warn(`WebSocket: API not ready (attempt ${r+1}), retrying in ${i}ms...`,{healthUrl:t,elapsedMs:e}),await new Promise(e=>setTimeout(e,i)),r++}},[D]),ue=(0,U.useCallback)(e=>{p.current&&!m.current&&(h.current>=za?console.warn(`WebSocket: Suppressing token renewal (${e}) — a freshly-minted token was rejected ${h.current}× in a row; not looping the refresh endpoint`):(console.log(`WebSocket: Requesting token renewal (${e})`),m.current=!0,h.current+=1,Promise.resolve(p.current()).catch(()=>{h.current=Math.max(0,h.current-1)}).finally(()=>{m.current=!1})))},[]),O=(0,U.useCallback)(e=>{let t={auth:e=>{let{token:t,consumableToken:n,organizationId:r}=f.current,i=tt();e({...t?{token:t}:{},...n?{consumableToken:n}:{},...r?{organizationId:r}:{},...i?{clientInstanceId:i}:{},frontendServiceName:xe.loadEnvironmentConfig().frontendServiceName})},transports:[`polling`,`websocket`],reconnection:e.autoReconnect??!0,reconnectionDelay:e.reconnectInterval??1e3,reconnectionDelayMax:3e4,randomizationFactor:.5,reconnectionAttempts:e.maxReconnectAttempts??15,timeout:3e4,forceNew:!0,upgradeTimeout:1e4};e.consumableToken&&(t.extraHeaders={[kt.CONSUMABLE_TOKEN]:e.consumableToken});let r=Pa(e.url,t);u.current=r,ce(r);let a=e=>{ae.current||(ae.current=!0,Ja.warn(`WebSocket connectivity lost`,{source:`websocket`,reason:e}))};r.on(`connect`,()=>{ie.current=!1,n(q.CONNECTED),i(e=>e+1),s(null),x.current=0,ee.current=0,m.current=!1,h.current=0,te.current=new Date,ae.current&&=(Ja.info(`WebSocket connectivity restored`,{source:`websocket`}),!1),console.log(`Socket.IO connected`);for(let e of S.current.values())r.emit(A.RESOURCE_SUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers})}),r.on(`disconnect`,e=>{ie.current=!1,n(q.DISCONNECTED),console.log(`Socket.IO disconnected:`,e);let t=v.current;if(v.current=!1,e===`io server disconnect`&&t){let e=Date.now();e-y.current>=Ba&&(y.current=e,console.log(`WebSocket: Reconnecting so the server can re-derive this connection's authority`),r.connect())}else e!==`io client disconnect`&&a(e)}),r.on(A.SYSTEM_TOKEN_REFRESHED,()=>{console.log(`WebSocket: Server accepted refreshed socket auth token`),h.current=0}),r.on(A.SYSTEM_ERROR,e=>{if(e?.code===fe.AUTH_REFRESH_FAILED)console.warn(`WebSocket: Server rejected refreshed socket auth token`,e),ue(`live refresh rejected`);else if(e?.code===fe.AUTHORITY_REEVALUATION_REQUIRED)v.current=!0;else if(e?.code===fe.ORGANIZATION_SWITCH_FORBIDDEN){let t=f.current.organizationId;t&&_.current!==t&&(_.current=t,console.warn(`WebSocket: Organization switch refused; re-handshaking into the intended organization`,e),r.disconnect(),r.connect())}else if(e?.code===fe.RATE_LIMIT_EXCEEDED){let t=e.message||`Too many real-time requests. Please slow down.`,n=Ka(e.details);console.warn(`WebSocket: Rate limit exceeded`,e),s(t),g.handleError(Error(t),{source:`websocket`,riskLevel:me.MEDIUM,additionalContext:{...n,errorCode:e.code}})}}),r.on(`connect_error`,e=>{ie.current=!1,console.error(`Socket.IO connection error:`,e.message),s(e.message),(e.data?.code===ge.AUTHENTICATION_FAILED||e.message===`Authentication failed`)&&ue(`handshake rejected`),n(x.current>0?q.RECONNECTING:q.ERROR),a(`connect_error:${e.type??e.message}`)}),r.io.on(`reconnect_attempt`,e=>{x.current=e,n(q.RECONNECTING),console.log(`Socket.IO reconnection attempt ${e}`)}),r.io.on(`reconnect`,e=>{console.log(`Socket.IO reconnected after ${e} attempts`),n(q.CONNECTED),s(null),x.current=0,ee.current=0}),r.io.on(`reconnect_failed`,()=>{console.error(`Socket.IO reconnection failed`),s(`Failed to reconnect after maximum attempts`),n(q.ERROR),Ja.warn(`WebSocket reconnection gave up after maximum attempts`,{source:`websocket`,reconnectAttempts:x.current})})},[ce,ue]),de=(0,U.useCallback)(async(e,t,n)=>{await le(e.url),w.current!==t||re.current!==n?console.log(`WebSocket: Skipping stale connect attempt after readiness check`):O(e)},[le,O]),k=(0,U.useCallback)(e=>{if(!e.url){s(`WebSocket URL is not available`),n(q.ERROR),console.error(`WebSocket: Cannot connect - URL is required`);return}let r=E(e);if(re.current===r&&(ie.current||t===q.CONNECTING||t===q.CONNECTED||t===q.RECONNECTING)){console.log(`WebSocket: Reusing active connect lifecycle for identical config`);return}u.current&&=(u.current.connected&&console.log(`Disconnecting existing WebSocket connection before reconnecting`),u.current.disconnect(),u.current.removeAllListeners(),null),w.current+=1,re.current=r,ie.current=!0,d.current=e,p.current=e.onAuthenticationError??null;let i=Ra(f.current.token,e.token);i!==e.token&&console.log(`WebSocket: Keeping already-stored fresher access token over the staler connect config token`),f.current={token:i,consumableToken:e.consumableToken,organizationId:e.organizationId},n(q.CONNECTING),s(null),de(e,w.current,r).catch(e=>{console.error(`WebSocket: Connection setup failed`,e),s(`WebSocket connection setup failed`),n(q.ERROR)})},[E,de,t]),pe=(0,U.useCallback)(()=>{w.current+=1,re.current=null,ie.current=!1,x.current=0,ae.current=!1,b.current&&=(clearTimeout(b.current),null),u.current&&=(u.current.removeAllListeners(),u.current.disconnect(),null),n(q.DISCONNECTED),S.current.clear(),l([]),te.current=null,f.current={},p.current=null,m.current=!1,h.current=0},[]),he=(0,U.useCallback)(e=>{f.current={...f.current,token:e},d.current&&={...d.current,token:e};let t=u.current;t?.connected?(console.log(`WebSocket: Refreshing socket auth with renewed access token`),t.emit(A.AUTH_REFRESH,{token:e})):t&&!t.active?(console.log(`WebSocket: Reviving idle socket to reconnect with renewed access token`),t.connect()):console.log(`WebSocket: Stored renewed access token for next socket handshake`)},[]),_e=(0,U.useCallback)(()=>{if(!re.current)return;let e=u.current;e?e.connected||e.active||(x.current=0,console.log(`WebSocket: Reviving dead socket after connectivity signal`),e.connect()):d.current&&k(d.current)},[k]),ve=(0,U.useRef)(_e);ve.current=_e,(0,U.useEffect)(()=>{let e=()=>ve.current(),t=()=>{document.visibilityState===`visible`&&ve.current()};window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t);let n=15e3,r=null,i=e=>{r=setTimeout(a,e)};function a(){let e=u.current;if(!re.current||e?.connected||e?.active){ee.current=0,i(n);return}ve.current();let t=Math.max(500,St(ee.current,2e3,3e4));ee.current+=1,i(t)}return i(n),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t),r&&clearTimeout(r)}},[]);let ye=(0,U.useCallback)((e,t)=>{let n=t,r=ne.current.get(e)??new Set,i=r.has(n);return r.add(n),ne.current.set(e,r),!i&&u.current&&u.current.on(e,se(e,n)),()=>{ne.current.get(e)?.delete(n),ne.current.get(e)?.size===0&&ne.current.delete(e);let t=C.current.get(e)?.get(n);t&&(u.current?.off(e,t),C.current.get(e)?.delete(n)),C.current.get(e)?.size===0&&C.current.delete(e)}},[se]),be=(0,U.useCallback)((e,t)=>{ne.current.get(e)?.delete(t),ne.current.get(e)?.size===0&&ne.current.delete(e);let n=C.current.get(e)?.get(t);n&&(u.current?.off(e,n),C.current.get(e)?.delete(t)),C.current.get(e)?.size===0&&C.current.delete(e)},[]),Se=(0,U.useCallback)((e,t)=>{u.current?.connected?u.current.emit(e,t):console.warn(`Cannot emit: not connected`)},[]),Ce=(0,U.useCallback)(async e=>u.current?.connected?new Promise(t=>{let n=T(e),r=!1;u.current.emit(A.RESOURCE_SUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers});let i=e=>{e.roomName===n&&!r&&(r=!0,u.current.off(A.RESOURCE_SUBSCRIBED,i),t({success:e.success,editingUsers:e.editingUsers}))};u.current.on(A.RESOURCE_SUBSCRIBED,i),setTimeout(()=>{r||(r=!0,u.current?.off(A.RESOURCE_SUBSCRIBED,i),t({success:!1}))},1e4)}):(console.warn(`Cannot subscribe: not connected`),{success:!1}),[T]),we=(0,U.useCallback)(async e=>{let t=T(e),n=Va(e.contextResourceIdentifiers),r=S.current.get(t);if(r){let t=r.ownerKeys.has(e.ownerKey),i=r.ownerContexts.get(e.ownerKey),a=r.contextResourceIdentifiers,o=Ha(a)===Ha(n);if(t&&o&&u.current?.connected)return r.ownerContexts.set(e.ownerKey,n),{success:!0,editingUsers:r.editingUsers};if(r.ownerKeys.add(e.ownerKey),r.ownerContexts.set(e.ownerKey,n),r.contextResourceIdentifiers=n,u.current?.connected){let o=await Ce({resourceType:r.resourceType,resourceId:r.resourceId,scopeKey:r.scopeKey,scopeId:r.scopeId,contextResourceIdentifiers:n});return o.success?(r.editingUsers=o.editingUsers,oe(),{success:!0,editingUsers:r.editingUsers}):(t&&i?r.ownerContexts.set(e.ownerKey,i):(r.ownerKeys.delete(e.ownerKey),r.ownerContexts.delete(e.ownerKey)),r.contextResourceIdentifiers=a,oe(),o)}return oe(),{success:!0,editingUsers:r.editingUsers}}if(!u.current?.connected)return S.current.set(t,{roomName:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n,ownerKeys:new Set([e.ownerKey]),ownerContexts:new Map([[e.ownerKey,n]])}),oe(),{success:!1};let i=await Ce({...e,contextResourceIdentifiers:n});return i.success&&(S.current.set(t,{roomName:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n,ownerKeys:new Set([e.ownerKey]),ownerContexts:new Map([[e.ownerKey,n]]),editingUsers:i.editingUsers}),oe()),i},[T,Ce,oe]),j=(0,U.useCallback)(async e=>{let t=T(e);return we({...e,ownerKey:`legacy:${t}`})},[T,we]),Ee=(0,U.useCallback)(async e=>{let t=T(e),n=Va(e.contextResourceIdentifiers),r=S.current.get(t);if(r){if(r.ownerKeys.delete(e.ownerKey),r.ownerContexts.delete(e.ownerKey),r.ownerKeys.size>0){let e=r.ownerContexts.values().next().value;if(e&&(r.contextResourceIdentifiers=e,u.current?.connected)){let t=await Ce({resourceType:r.resourceType,resourceId:r.resourceId,scopeKey:r.scopeKey,scopeId:r.scopeId,contextResourceIdentifiers:e});t.success&&(r.editingUsers=t.editingUsers)}oe()}else S.current.delete(t),oe(),u.current?.connected&&u.current.emit(A.RESOURCE_UNSUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n})}},[T,oe]),De=(0,U.useCallback)(async e=>{let t=T(e);await Ee({...e,ownerKey:`legacy:${t}`})},[T,Ee]),Oe=(0,U.useCallback)((e,t)=>{f.current={...f.current,organizationId:e},d.current&&={...d.current,organizationId:e},_.current=null;let n=()=>{if(!t)return;let e=Array.from(S.current.values()).filter(e=>Wa(e,t)).flatMap(e=>Array.from(e.ownerKeys).map(t=>({ownerKey:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.ownerContexts.get(t)??e.contextResourceIdentifiers})));Promise.all(e.map(e=>Ee(e)))};u.current?.connected?(u.current.emit(A.ORGANIZATION_SWITCH,{organizationId:e,previousOrganizationId:t}),n()):(console.warn(`Organization switch recorded while not connected; the next handshake will carry it`),n())},[Ee]),ke=(0,U.useCallback)(async e=>u.current?.connected?new Promise(t=>{let n=!1;u.current.emit(A.RESOURCE_EDITING_START,{resourceType:e.resourceType,resourceId:e.resourceId,contextResourceIdentifiers:Va(e.contextResourceIdentifiers),timestamp:new Date});let r=i=>{i.resourceType===e.resourceType&&i.resourceId===e.resourceId&&!n&&(n=!0,u.current.off(A.RESOURCE_EDITING_STARTED,r),u.current.off(A.RESOURCE_EDITING_ERROR,r),t(i.success))};u.current.on(A.RESOURCE_EDITING_STARTED,r),u.current.on(A.RESOURCE_EDITING_ERROR,r),setTimeout(()=>{n||(n=!0,u.current?.off(A.RESOURCE_EDITING_STARTED,r),u.current?.off(A.RESOURCE_EDITING_ERROR,r),t(!1))},1e4)}):(console.warn(`Cannot start editing: not connected`),!1),[]),Ae=(0,U.useCallback)(e=>{u.current?.connected&&u.current.emit(A.RESOURCE_EDITING_END,{resourceType:e.resourceType,resourceId:e.resourceId,timestamp:new Date})},[]),je=(0,U.useCallback)(e=>{u.current?.connected?u.current.emit(A.RESOURCE_CUSTOM,{resourceType:e.resourceType,resourceId:e.resourceId,eventName:e.eventName,data:e.data,contextResourceIdentifiers:Va(e.contextResourceIdentifiers),includeSelf:e.includeSelf,timestamp:new Date}):console.warn(`Cannot send custom event: not connected`)},[]),M=(0,U.useCallback)(async(e,t,n)=>u.current?.connected?new Promise(r=>{let i=!1,a=setTimeout(()=>{i||(i=!0,r(0))},5e3);u.current.emit(A.BADGE_GET,{identifier:e,scope:t,scopeId:n},e=>{i||(i=!0,clearTimeout(a),r(e?.count??0))})}):0,[]),Me=(0,U.useCallback)(async(e,t)=>u.current?.connected?new Promise(n=>{let r=!1,i=setTimeout(()=>{r||(r=!0,n([]))},5e3);u.current.emit(A.BADGE_GET_ALL,{scope:e,scopeId:t},e=>{r||(r=!0,clearTimeout(i),n(e??[]))})}):[],[]),Ne=(0,U.useCallback)(()=>({status:t,url:d.current?.url||null,connectedAt:te.current}),[t]);(0,U.useEffect)(()=>()=>{pe()},[pe]);let Pe=(0,U.useMemo)(()=>({status:t,connectionCount:r,isConnected:t===q.CONNECTED,error:a,subscribedRooms:c,connect:k,disconnect:pe,refreshAuth:he,switchOrganization:Oe,on:ye,off:be,emit:Se,subscribeToResource:j,claimResourceRoom:we,unsubscribeFromResource:De,releaseResourceRoom:Ee,startEditing:ke,stopEditing:Ae,sendCustomEvent:je,getBadge:M,getAllBadges:Me,getConnectionInfo:Ne}),[t,r,a,c,k,pe,he,Oe,ye,be,Se,j,we,De,Ee,ke,Ae,je,M,Me,Ne]);return(0,W.jsx)(qa.Provider,{value:Pe,children:e})},Xa;(function(e){e.NOT_A_SUMMARY_FIELD=`not_a_summary_field`,e.BACKEND_ONLY=`backend_only`})(Xa||={});var Za=class{static objectContextCache=new Map;static getObjectContextCacheKey(e,t){return`${e}|${Object.entries(t).map(([e,t])=>`${e}:${t.parentType}:${t.parentId}`).sort().join(`|`)}`}static async fetchObjectContextForOperation(e,t,n,r,i){if(!Wt(e).needsObjectContext){let e={};for(let[t,r]of Object.entries(n))e[t]={_id:r.parentId};return{parents:e,children:{}}}if(!i){console.warn(`[OperationEnabledConditionUtils.fetchObjectContextForOperation] needsObjectContext is true but doOperation not provided. Returning IDs only.`);let e={};for(let[t,r]of Object.entries(n))e[t]={_id:r.parentId};return{parents:e,children:{}}}let a=this.getObjectContextCacheKey(t,n),o=this.objectContextCache.get(a);if(o)return o;let s=(async()=>{let e={},t={};for(let[e,i]of Object.entries(n))if(e===i.parentType){let e=r.allResourceFieldIdentifiers?.[i.parentType];e&&(t[e]=i.parentId)}else t[e]=i.parentId;for(let[a,o]of Object.entries(n)){let{parentType:n,parentId:s}=o;try{let o=r.resourceConfigurations[n];if(!o){e[a]={_id:s};continue}let c=o.operations?.find(e=>e.operationIdentifier===M.READ);if(!c){e[a]={_id:s};continue}let l=we.createOperationPathKey({resourceIdentifier:n,operationIdentifier:M.READ,variantType:p.API_CALL,isOperationDefault:c.isOperationDefault??!0,isBulkOperation:!1}),u=r.allResourceFieldIdentifiers?.[n];e[a]=await i(l,{contextualParameters:{...t,...u?{[u]:String(s)}:{}}})}catch(t){console.warn(`[OperationEnabledConditionUtils.fetchObjectContextForOperation] Failed to fetch parent ${n}:${s}`,t),e[a]={_id:s}}}return{parents:e,children:{}}})();return this.objectContextCache.set(a,s),setTimeout(()=>{this.objectContextCache.delete(a)},6e4),s}static async evaluateEnabledCondition(e){let{operation:t,currentObject:n,inputDto:r,userContext:i,initiatorIds:a,objectContext:o,resourcesRegistry:s,resourceType:c,doOperation:l,subjectDataMode:u}=e;if(!(`enabledCondition`in t)||!t.enabledCondition)return!0;let d=Ut(t.enabledCondition),f=o;if(d.needsObjectContext&&!f&&n){let e=s.resourceConfigurations[c],r={};if(e){let t=e.resourceRelationships?h(e.resourceRelationships):[];for(let e of t){if(e.resourceType1===e.resourceType2&&!e.foreignKeyField)continue;let t=e.resourceType2===c?e.resourceType1:e.resourceType2,i=_t.tryResolveRelationshipForeignKeyIdentity(e,s.allResourceFieldIdentifiers)?.fieldIdentifier;if(!i){let n=y.buildConfigurationError(vt.FRONTEND_RESOURCE_FIELD_IDENTIFIER_NOT_FOUND,{resourceType:c,parentType:t,relationship:`${e.resourceType1} → ${e.resourceType2}`,component:`operation-enabled-condition`});console.error(n.message,n.wildoError);continue}let a=n?.[i];if(a){let n=e.foreignKeyField??t;r[n]={parentType:t,parentId:String(a)}}}}f=await this.fetchObjectContextForOperation(t,c,r,s,l)}let p=u===gt.SUMMARY&&n&&!r?this.recordSummaryUnreachableReads(t,s,c,n):void 0,m=p?.subject??n,g={inputDto:r||m||{},currentObject:m||r||{},objectContext:f||{},initiatorUserContext:i,initiatorIds:a??(i?{userId:i._id}:void 0)};try{return t.enabledCondition(g)===!0}catch(e){return console.warn(`Failed to evaluate enabledCondition`,{resourceType:c,operationIdentifier:t.operationIdentifier,error:e instanceof Error?e.message:`Unknown error`}),!1}finally{p?.report()}}static reportedSummaryUnreachableReads=new Set;static recordSummaryUnreachableReads(e,t,n,r){let i=!1;try{i=xe.isDevelopment()}catch{}if(!i||typeof r!=`object`||Object.keys(r).length===0)return;let a=this.summaryUnreachableFieldNames(e,t.resourceConfigurations[n]);if(!a||a.size===0)return;let o=new Set,s=e=>{typeof e==`string`&&a.has(e)&&o.add(e)};return{subject:new Proxy(r,{get:(e,t,n)=>(s(t),Reflect.get(e,t,n)),has:(e,t)=>(s(t),Reflect.has(e,t))}),report:()=>{for(let t of o){let r=`${String(n)}::${String(e.operationIdentifier)}::${t}`;if(this.reportedSummaryUnreachableReads.has(r))continue;this.reportedSummaryUnreachableReads.add(r);let i=`[Wildo] The enabledCondition of "${String(n)}.${String(e.operationIdentifier)}" reads "${t}"`;console.warn(a.get(t)===Xa.BACKEND_ONLY?`${i}, which is .isBackendOnly() and reaches no frontend row, so the interface always judges the condition with it undefined. No declaration brings it to the interface: only the server can decide on it, so the condition the interface evaluates should not depend on it.`:`${i}, which a SUMMARY row does not carry, so on a list the condition sees it undefined on every row. Add "${t}" to the operation's enabledConditionFields so list rows carry it, or declare it .isSummaryField() if the list should also show it.`)}}}}static summaryUnreachableFieldNames(e,t){let n=e.summaryDto;if(!n)return;let r=re.getObjectLikeFieldShape(n,{commonOnly:!1}),i=y.resolveFieldShapeOfAnyVariant(t);if(!r||!i||Object.keys(r).length===0)return;let a=new Map;for(let[e,t]of Object.entries(i))e in r||a.set(e,bt(t)?Xa.BACKEND_ONLY:Xa.NOT_A_SUMMARY_FIELD);return a}static getOperationContextNeeds(e){let t=Wt(e);return{needsObjectContext:t.needsObjectContext===!0,needsUserContext:t.needsUserContext===!0}}static operationNeedsObjectContext(e){return this.getOperationContextNeeds(e).needsObjectContext}static operationNeedsUserContext(e){return this.getOperationContextNeeds(e).needsUserContext}},Qa=Za.evaluateEnabledCondition.bind(Za);Za.fetchObjectContextForOperation.bind(Za);var $a=Za.getOperationContextNeeds.bind(Za);Za.operationNeedsObjectContext.bind(Za),Za.operationNeedsUserContext.bind(Za);var eo=(0,U.createContext)(void 0),to=({children:e,resourcesRepository:t})=>{let n=t.getResourcesRegistry(),r=t.getResourcesHttpClient(),i=t.getApplicationHttpClient();(0,U.useEffect)(()=>{if(xe.isDevelopment())try{let e=ne(n.resourceConfigurations);for(let t of e){let e=t.severity===b.FAIL?`FAIL`:`WARN`;console.warn(`[required-fk-fillability:${e}] ${t.kind}: ${t.message}`)}}catch{}},[n]);let a=(0,U.useContext)(Qe)?.requestKeys,o=(0,U.useMemo)(()=>y.collectInstanceLabelSectionKeys(n),[n]);(0,U.useEffect)(()=>{a&&o.length!==0&&a(o).catch(()=>void 0)},[a,o]);let s=(0,U.useCallback)(async(e,t,n)=>{let i=typeof e==`string`?e:we.createOperationPathKey(e),a=r.getOperationDetails(i);return(a?ft(a)===M.SEARCH:we.parseOperationPathKey(i).operationIdentifier===M.SEARCH)?r.executeSearchOperation(i,t,n):r.doOperation(i,t,n)},[r]),c=(0,U.useCallback)(async e=>Za.evaluateEnabledCondition({...e,resourcesRegistry:n,doOperation:s}),[n,s]),l=(0,U.useCallback)(e=>Za.getOperationContextNeeds(e),[]),u=(0,U.useCallback)(e=>e in n.resourceConfigurations,[n]),d=(0,U.useCallback)(e=>n.resourceConfigurations[e],[n]),f=(0,U.useCallback)(()=>n,[n]),p=(0,U.useCallback)(()=>Object.keys(n.resourceConfigurations),[n]),m=(0,U.useCallback)(()=>r.getAvailableOperationPaths(),[r]),h=(0,U.useCallback)(e=>{e?(r.setAuthToken(e),i.setAuthToken(e)):(r.clearAuthToken(),i.clearAuthToken())},[r,i]),g=(0,U.useCallback)(e=>{r.setTokenRenewalHandler(e),i.setTokenRenewalHandler(e)},[r,i]),_=(0,U.useCallback)(e=>{r.setStepUpAuthHandler(e),i.setStepUpAuthHandler(e)},[r,i]),v=(0,U.useCallback)(e=>{r.setConsumableToken(e),i.setConsumableToken(e)},[r,i]),x=(0,U.useCallback)(()=>r.getReadCache(),[r]),ee=(0,U.useMemo)(()=>({registry:n,doOperation:s,evaluateOperationEnabled:c,getOperationContextNeeds:l,hasResource:u,getResourceConfiguration:d,getResourcesRegistry:f,getAvailableResourceTypes:p,getAvailableOperationPaths:m,getReadCache:x,setAuthToken:h,setTokenRenewalHandler:g,setStepUpAuthHandler:_,setConsumableToken:v}),[n,s,c,l,u,d,f,p,m,x,h,g,_,v]);return(0,W.jsx)(eo.Provider,{value:ee,children:e})},no=()=>{let e=(0,U.useContext)(eo);if(!e)throw Error(`useResourceRegistry must be used within a ResourceRegistryProvider`);return e},ro=()=>(0,U.useContext)(eo);function io(e,t){return e===void 0||e.hasResource(t)}var ao=e=>io(ro(),e),oo=()=>{let e=(0,U.useContext)(Dt);if(!e)throw Error(`useError must be used within an ErrorProvider`);return e};function so(e,t){return e===t}function co(e){return e.tComponent(e.componentType,e.key,e.params)}function lo(e){let t=e.tComponent(e.componentType,e.key,e.params);return so(t,`components.${e.componentType}.${e.key}`)?void 0:t}function uo(e,t){return(n,r)=>co({tComponent:e,componentType:t,key:n,params:r})}function fo(e){return e.tResourceHeader(e.resourceType,e.key,e.params)}function po(e){let t=e.tResourceHeader(e.resourceType,`description`,e.params);if(t!==``)return so(t,`resources.${e.resourceType}.header.description`)?void 0:t}function mo(e){return e.t(e.key,e.params)}function ho(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function go(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function _o(){return vo.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var vo={stubThis:e=>e};function yo(e){let{id:t}=e;return{...e,id:go(t),transports:e.transports}}function bo(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var J=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function xo({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new J({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new J({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new J({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new J({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bo(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new J({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new J({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var So=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Co=[`cross-platform`,`platform`];function wo(e){if(e&&!(Co.indexOf(e)<0))return e}async function To(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!_o())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:go(t.challenge),user:{...t.user,id:go(t.user.id)},excludeCredentials:t.excludeCredentials?.map(yo)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=So.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw xo({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){Eo(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=ho(e))}catch(e){Eo(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=ho(c.getAuthenticatorData())}catch(e){Eo(`getAuthenticatorData()`,e)}return{id:o,rawId:ho(s),response:{attestationObject:ho(c.attestationObject),clientDataJSON:ho(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:wo(a.authenticatorAttachment)}}function Eo(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Do(){if(!_o())return Oo.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?Oo.stubThis(new Promise(e=>e(!1))):Oo.stubThis(e.isConditionalMediationAvailable())}var Oo={stubThis:e=>e};function ko({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bo(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new J({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Ao(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!_o())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(yo));let a={...t,challenge:go(t.challenge),allowCredentials:i},o={};if(n){if(!await Do())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=So.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw ko({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=ho(u.userHandle)),{id:c,rawId:ho(l),response:{authenticatorData:ho(u.authenticatorData),clientDataJSON:ho(u.clientDataJSON),signature:ho(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:wo(s.authenticatorAttachment)}}function jo(e){return!e||e.accessToken||!e.sessionId?null:e.nextStep===pt.ONBOARDING||e.state===Je.ONBOARDING_PENDING?e.sessionId:null}function Mo(e,t){return!e.onboardingSessionId||e.accessToken?null:k(S.organizationOnboarding,t)}function No(e){return e?.wildoError?.customMessageReference===vt.AUTHENTICATION_SESSION_EXPIRED}var Y;(function(e){e.SIGNED_IN=`signed_in`,e.MFA_ENROLLMENT_REQUIRED=`mfa_enrollment_required`,e.EMAIL_VERIFICATION_PENDING=`email_verification_pending`,e.SSO_REDIRECT_REQUIRED=`sso_redirect_required`,e.MAGIC_LINK_SENT=`magic_link_sent`,e.PASSKEY_ENROLLMENT_PENDING=`passkey_enrollment_pending`,e.ORGANIZATION_ONBOARDING_REQUIRED=`organization_onboarding_required`,e.UNFINISHED=`unfinished`})(Y||={});var Po=new Set([Je.COMPLETED,Je.MFA_ENROLLMENT_GRACE]);function Fo(e){return e.accessToken&&e.state!==void 0&&Po.has(e.state)?Y.SIGNED_IN:e.ssoRedirectHint===!0?Y.SSO_REDIRECT_REQUIRED:e.state===Je.MFA_ENROLLMENT_REQUIRED?e.sessionId?Y.MFA_ENROLLMENT_REQUIRED:Y.UNFINISHED:jo(e)?Y.ORGANIZATION_ONBOARDING_REQUIRED:e.nextStep===pt.MAGIC_LINK_SENT?Y.MAGIC_LINK_SENT:e.nextStep===pt.PASSKEY_ENROLLMENT?Y.PASSKEY_ENROLLMENT_PENDING:e.state===void 0&&e.nextStep===void 0&&e.sessionId===void 0&&!e.accessToken?Y.EMAIL_VERIFICATION_PENDING:Y.UNFINISHED}function Io(){try{return globalThis.sessionStorage??void 0}catch{return}}function Lo(e){try{let t=e.getItem(it.PENDING_MFA_SESSION);if(!t)return null;let n=JSON.parse(t);return!n||typeof n.sessionId!=`string`||!n.sessionId||typeof n.email!=`string`||typeof n.rememberedAt!=`number`?null:{sessionId:n.sessionId,email:n.email,rememberedAt:n.rememberedAt}}catch{return null}}function Ro(e,t=Date.now()){let n=Io();if(!n)return;let r=Lo(n),i=r?.sessionId===e.sessionId,a={sessionId:e.sessionId,email:e.email||(i?r.email:``),rememberedAt:i?r.rememberedAt:t};try{n.setItem(it.PENDING_MFA_SESSION,JSON.stringify(a))}catch{}}function zo(e=Date.now()){let t=Io();if(!t)return null;let n=Lo(t);return!n||e-n.rememberedAt>18e5||n.rememberedAt>e?(Bo(),null):{sessionId:n.sessionId,email:n.email}}function Bo(){try{Io()?.removeItem(it.PENDING_MFA_SESSION)}catch{}}var X;(function(e){e.SURFACE=`SURFACE`,e.REFERENCE=`REFERENCE`})(X||={});var Vo={[j.NETWORK]:X.REFERENCE,[j.AUTHENTICATION]:X.SURFACE,[j.AUTHORIZATION]:X.REFERENCE,[j.VALIDATION]:X.SURFACE,[j.PAYLOAD_TOO_LARGE]:X.REFERENCE,[j.NOT_FOUND]:X.SURFACE,[j.CONFLICT]:X.REFERENCE,[j.RATE_LIMIT]:X.REFERENCE,[j.INTERNAL]:X.SURFACE,[j.DATABASE]:X.SURFACE,[j.EXTERNAL_SERVICE]:X.REFERENCE,[j.UNKNOWN]:X.SURFACE,[j.UNCAUGHT_EXCEPTION]:X.SURFACE,[j.UNHANDLED_REJECTION]:X.SURFACE,[j.BUSINESS_RULE]:X.SURFACE,[j.INFRASTRUCTURE]:X.SURFACE,[j.CONFIGURATION]:X.SURFACE,[j.FEATURE_NOT_AVAILABLE]:X.REFERENCE,[j.FEATURE_LIMIT_EXCEEDED]:X.REFERENCE,[j.INSUFFICIENT_CREDITS]:X.REFERENCE},Ho=(()=>{let e=new Map;for(let t of Object.values(le)){let n=t.defaultCustomMessageReference;e.set(n,[...e.get(n)??[],t.type])}return e})(),Uo=new Set(Object.values(j));function Wo(e,t){if(!t)return;let n=e(t);if(n&&!n.endsWith(`.${t}.msg`))return n}function Go(e,t,n){let r=`${O.RESOURCES}.${t}.operations.${n}.${$e.UNAVAILABLE_REASON}`,i=e(t,n,$e.UNAVAILABLE_REASON);return i&&i!==r?i:void 0}function Ko(e){let{tErrorMessage:t,tResourceOperation:n,resourceType:r,operationIdentifier:i,customMessageReference:a}=e;if(a===vt.SERVICE_RESOURCE_OPERATION_DISABLED&&r&&i){let e=Go(n,r,i);if(e)return e}return Wo(t,a)}function qo(e,t){if(!t)return;let n=Wo(e.tErrorMessage,t);if(n)return n;let r=`${O.ERRORS_REFUSALS}.${t}.msg`,i=e.t(r);return i&&i!==r?i:void 0}function Jo(e){return typeof e==`object`&&e?e:void 0}function Yo(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function Xo(e){let t=Jo(e);if(!t)return{};let n=Jo(t.wildoError),r=Jo(Jo(Jo(t.response)?.data)?.error);return{errorType:[n?.type,t.type,t.errorType,r?.type].find(e=>typeof e==`string`&&Uo.has(e)),customMessageReference:Yo(n?.customMessageReference)??Yo(t.customMessageReference)??Yo(r?.customMessageReference)??Yo(r?.code),userGuidance:Jo(n?.userGuidance)??Jo(t.userGuidance)??Jo(r?.userGuidance)}}var Zo=[`explanation`,`resolution`];function Qo(e,t){let n=e.userGuidance,r=n?.guidanceKey??e.customMessageReference;if(n&&r)for(let e of Zo){let i=t.tErrorGuidance(r,e,n.params);if(i)return i}}function $o(e){let t=e.userGuidance;if(t)for(let e of Zo){let n=Yo(t[e]);if(n)return n}}function es(e,t){if(!e)return;let n=Ho.get(e);if(n&&n.length!==0)return t&&n.includes(t)?t:n[0]}function ts(e,t){let{translators:n}=t,r=Xo(e),i=Qo(r,n);if(i)return i;let a=Yo(t.surfaceMessage),o=Wo(n.tErrorMessage,r.customMessageReference);if(o){let e=es(r.customMessageReference,r.errorType);if(e===void 0||Vo[e]!==X.SURFACE||a===void 0)return o}return a||(Wo(n.tErrorMessage,vt.DEFAULT)??$o(r)??n.tErrorMessage(vt.DEFAULT))}function ns(){let{tErrorMessage:e,tErrorGuidance:t}=yt(),n=(0,U.useRef)({tErrorMessage:e,tErrorGuidance:t});return n.current={tErrorMessage:e,tErrorGuidance:t},(0,U.useCallback)((e,t)=>ts(e,{translators:n.current,surfaceMessage:t}),[])}var rs=()=>{let e=(0,U.useContext)(qa);if(!e)throw Error(`useWebSocket must be used within a WebSocketProvider`);return e},Z=jt;function is(e,t){switch(t.type){case`INIT_SESSION`:return e.status===Z.IDLE?{status:Z.INITIALIZING,anonymousUserId:t.anonymousUserId,sessionToken:null}:e;case`SESSION_TOKEN_RECEIVED`:return e.status!==Z.INITIALIZING&&e.status!==Z.ACTIVE?e:{...e,status:Z.ACTIVE,sessionToken:t.sessionToken};case`RESTORE_SESSION`:return{status:Z.ACTIVE,anonymousUserId:t.anonymousUserId,sessionToken:t.sessionToken};case`START_TRANSPOSITION`:return e.status===Z.ACTIVE?{...e,status:Z.TRANSPOSING}:e;case`CLEAR`:return{status:Z.CLEARED,anonymousUserId:null,sessionToken:null};default:return e}}var as={status:Z.IDLE,anonymousUserId:null,sessionToken:null},os=(0,U.createContext)(void 0);function ss({children:e}){let{httpClient:t}=wt(),[n,r]=(0,U.useReducer)(is,as),i=(0,U.useMemo)(()=>[t,F()],[t]),a=(0,U.useCallback)((e,t)=>{i.forEach(n=>n.setAnonymousSession(e,t))},[i]),o=(0,U.useCallback)(()=>{i.forEach(e=>e.clearAnonymousSession())},[i]),s=(0,U.useCallback)(e=>{i.forEach(t=>t.updateAnonymousSessionToken(e))},[i]);(0,U.useEffect)(()=>{let e=qe(N.ANONYMOUS_USER_ID),t=qe(N.ANONYMOUS_SESSION_TOKEN);e&&t&&(r({type:`RESTORE_SESSION`,anonymousUserId:e,sessionToken:t}),a(e,t));let n=e=>{r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e})};return i.forEach(e=>e.setAnonymousSessionTokenHandler(n)),()=>{i.forEach(e=>e.setAnonymousSessionTokenHandler(null))}},[i,a]),(0,U.useEffect)(()=>{switch(n.status){case Z.INITIALIZING:n.anonymousUserId&&(ke(N.ANONYMOUS_USER_ID,n.anonymousUserId),a(n.anonymousUserId,null));break;case Z.ACTIVE:n.anonymousUserId&&n.sessionToken&&(ke(N.ANONYMOUS_USER_ID,n.anonymousUserId),ke(N.ANONYMOUS_SESSION_TOKEN,n.sessionToken),a(n.anonymousUserId,n.sessionToken));break;case Z.CLEARED:Ge(N.ANONYMOUS_USER_ID),Ge(N.ANONYMOUS_SESSION_TOKEN),o()}},[n.status,n.anonymousUserId,n.sessionToken,a,o]);let c=(0,U.useRef)(n);(0,U.useEffect)(()=>{c.current=n},[n]),(0,U.useEffect)(()=>{let e=e=>{if(e.key===N.ANONYMOUS_USER_ID){if(!e.newValue)r({type:`CLEAR`}),o();else if(e.newValue!==c.current.anonymousUserId){let t=qe(N.ANONYMOUS_SESSION_TOKEN);t&&(r({type:`RESTORE_SESSION`,anonymousUserId:e.newValue,sessionToken:t}),a(e.newValue,t))}}e.key===N.ANONYMOUS_SESSION_TOKEN&&e.newValue&&e.newValue!==c.current.sessionToken&&(r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e.newValue}),s(e.newValue))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[a,o,s]);let l=(0,U.useCallback)(()=>{if(n.anonymousUserId&&n.status!==Z.IDLE&&n.status!==Z.CLEARED)return n.anonymousUserId;let e=crypto.randomUUID();return r({type:`INIT_SESSION`,anonymousUserId:e}),a(e,null),e},[n.anonymousUserId,n.status,a]),u=(0,U.useCallback)(e=>{r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e}),s(e)},[s]),d=(0,U.useCallback)(()=>{r({type:`START_TRANSPOSITION`})},[]),f=(0,U.useCallback)(()=>{r({type:`CLEAR`})},[]),p={status:n.status,anonymousUserId:n.anonymousUserId,sessionToken:n.sessionToken,isAnonymousActive:n.status===Z.ACTIVE||n.status===Z.INITIALIZING,initAnonymousSession:l,onSessionTokenReceived:u,startTransposition:d,clearAnonymousSession:f};return(0,W.jsx)(os.Provider,{value:p,children:e})}function cs(){let e=(0,U.useContext)(os);if(!e)throw Error(`useAnonymousSession must be used within AnonymousSessionProvider`);return e}var ls={isLoading:!1,error:null,sessionId:null,accessToken:null,identification:null,sessionState:null,isRestoringSession:!1,sessionRestored:!1,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],onboardingSessionId:null,purpose:null,sessionType:null,oneOffContext:void 0,crossFrontendHandoffContext:void 0};function us(e){return e===`second`?Ie.SECOND:Ie.FIRST}var ds;(function(e){e.CONDITIONAL=`conditional`,e.MODAL=`modal`})(ds||={});var fs=class extends Error{constructor(){super(`Passkey autofill challenge expired before a passkey was picked`),this.name=`PasskeyAutofillExpiredError`}},ps=class extends Error{constructor(){super(`Passkey autofill stepped aside for a ceremony the person started`),this.name=`PasskeyAutofillSupersededError`}},ms=!1,hs=class{getAccessToken(){return qe(N.JWT_TOKEN)}getRefreshToken(){return null}storeTokens(e,t){e?ke(N.JWT_TOKEN,e):Ge(N.JWT_TOKEN),t!==null&&!ms&&(ms=!0,console.warn("[wildo-auth] PersistentSessionTokenStorage.storeTokens() received a non-null refreshToken — argument is ignored. Refresh tokens now travel via the `__wildo_refresh` HttpOnly cookie (Auth-hardening Slice A).")),Ge(N.REFRESH_TOKEN)}getOrganizationId(){return qe(N.CURRENT_ORGANIZATION_ID)}setOrganizationId(e){e?ke(N.CURRENT_ORGANIZATION_ID,e):Ge(N.CURRENT_ORGANIZATION_ID)}clear(){Ge(N.JWT_TOKEN),Ge(N.REFRESH_TOKEN),Ge(N.CURRENT_ORGANIZATION_ID)}},gs=class{_accessToken=null;_refreshToken=null;_organizationId=null;getAccessToken(){return this._accessToken}getRefreshToken(){return this._refreshToken}storeTokens(e,t){this._accessToken=e,this._refreshToken=t}getOrganizationId(){return this._organizationId}setOrganizationId(e){this._organizationId=e}clear(){this._accessToken=null,this._refreshToken=null,this._organizationId=null}},Q=Be.getLogger(),$=Q.debugByType(`AuthSessionContext`),_s=new Set([l.SESSION_ENDED,l.ACCOUNT_NOT_ACTIVE]);Q.setDebugTypeLogging(`AuthSessionContext`,!1);var vs=new Set([Je.MFA_REQUIRED,Je.MFA_ENROLLMENT_REQUIRED]),ys=(0,U.createContext)(void 0),bs=15e3;function xs(e,t){let n=globalThis.PublicKeyCredential;e&&typeof n?.signalUnknownCredential==`function`&&n.signalUnknownCredential({rpId:e,credentialId:t}).catch(()=>void 0)}var Ss=({children:e,tokenStorage:t})=>{let n=(0,U.useMemo)(()=>t??new hs,[t]),{setAuthToken:i,setTokenRenewalHandler:a,setConsumableToken:o}=no(),{handleError:s}=oo(),{tComponent:c,isReady:d}=yt({component:[u.PUBLIC_LAYOUTS_USER_AUTH,u.PUBLIC_LAYOUTS_MFA_CHALLENGE]}),f=ns(),p=(0,U.useCallback)(()=>co({tComponent:c,componentType:u.PUBLIC_LAYOUTS_MFA_CHALLENGE,key:Le.ERROR_GENERIC}),[c]),{appConfig:m}=wt(),{connect:h,disconnect:g,refreshAuth:_,switchOrganization:v}=rs(),{clearAnonymousSession:y}=cs(),b=(0,U.useRef)(!1),x=(0,U.useRef)(null),ee=(0,U.useRef)(null),te=(0,U.useRef)(0),S=(0,U.useRef)(0);(0,U.useEffect)(()=>()=>{te.current+=1},[]);let ne=(0,U.useRef)(null),[C,w]=(0,U.useState)({...ls,accessToken:n.getAccessToken()}),re=(0,U.useRef)(P.RESUMED),ie=(0,U.useRef)(l.SESSION_ENDED),ae=(0,U.useCallback)(()=>re.current,[]),T=(0,U.useCallback)(()=>ie.current,[]),se=(0,U.useRef)(!1),[ce,E]=(0,U.useState)(null),D=(0,U.useRef)(null),le=e=>{D.current=e,E(e)},ue=(0,U.useCallback)(()=>D.current,[]),O=(e,t)=>{n.storeTokens(e,null),re.current=t,de(),y()},de=()=>{se.current=!1,le(null)},fe=e=>{n.storeTokens(e,null),de(),y()},k=e=>{w(t=>({...t,isLoading:!1,error:null,sessionId:null,onboardingSessionId:e,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]}))},pe=(0,U.useCallback)(()=>{if(!m?.runtime?.endPoints?.main_backend_api)return Q.warn(`WebSocket: Cannot derive URL - appConfig.runtime.endPoints.main_backend_api not available`),null;let e=m.runtime.endPoints.main_backend_api.publicUrl;return e?e.replace(/^http/,`ws`):(Q.warn(`WebSocket: Cannot derive URL - publicUrl not available in main_backend_api config`),null)},[m]),me=(0,U.useCallback)((e,t,n)=>{if(!e){$(`WebSocket: Cannot connect - no token provided`);return}let r=pe();if(!r)$(`WebSocket: Cannot connect - URL is not available`);else try{h({url:r,token:e,organizationId:t||void 0,consumableToken:n||void 0,autoReconnect:!0,reconnectInterval:1e3,maxReconnectAttempts:15,onAuthenticationError:()=>ne.current?.()}),$(`WebSocket connection initiated`,{wsUrl:r})}catch(e){Q.warn(`Failed to connect WebSocket`,{error:e})}},[h,pe]),he=(0,U.useCallback)((e,t)=>{v(e,t)},[v]),ge=async e=>{let t=++te.current;Bo(),w(e=>({...e,isLoading:!0,error:null,identification:null,sessionId:null,sessionState:null,onboardingSessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),$(`Identifying user by email`,{email:e});try{let n=await F().identifyByEmail(e);return t===te.current&&($(`User identification successful`,{sessionId:n.sessionId}),w(e=>t===te.current?{...e,isLoading:!1,identification:n,sessionId:n.sessionId,purpose:e.purpose??Ke.LOGIN}:e)),n}catch(n){if(t!==te.current)throw n;let r=f(n);throw s(n,`Identification failed`,{email:e,message:r}),w(e=>t===te.current?{...e,isLoading:!1,error:r}:e),n}},_e=(e,t)=>{let n=e.accessToken||null;n?(O(n,P.SIGNED_IN),F().setAuthToken(n),i(n),e.success?(w(e=>({...e,isLoading:!1,accessToken:n,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):w(e=>({...e,isLoading:!1,accessToken:n,sessionId:t}))):w(n=>n.accessToken?{...n,isLoading:!1}:{...n,isLoading:!1,sessionId:e.success?null:t})},ve=async(e,t)=>{w(e=>({...e,isLoading:!0,error:null})),$(`Authenticating with password`,{email:e,sessionId:C.sessionId});try{let n=C.sessionId;if(!n){let t=Error(`No active session. Please identify user first.`);throw Q.warn(`Authentication attempted without session`,{email:e}),t}let r={sessionId:n,method:We.PASSWORD,factorLevel:Ie.FIRST,password:t},i=await F().authenticate(r),a=jo(i);return a?(k(a),i):i.requiresMFA&&!i.accessToken?(w(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:i.sessionId||n,availableMfaMethods:i.availableMFAMethods||[],availableEnrollmentMethods:i.availableEnrollmentMethods||[],enrolledSecondFactorMethods:i.enrolledSecondFactorMethods||[],usableSecondFactorMethods:i.usableSecondFactorMethods||[]})),i):($(`Authentication successful`,{success:i.success,hasAccessToken:!!i.accessToken}),_e(i,n),i)}catch(t){let n=f(t);throw s(t,`Authentication failed`,{email:e,message:n}),w(e=>({...e,isLoading:!1,error:n})),t}},ye=async e=>{w(e=>({...e,isLoading:!0,error:null})),$(`Authenticating`,{method:e.method,sessionId:e.sessionId||C.sessionId});try{let t=e.sessionId||C.sessionId;if(!t){let t=Error(`No active session. Please identify user first.`);throw Q.warn(`Authentication attempted without session`,{method:e.method}),t}let n={...e,sessionId:t},r=await F().authenticate(n),i=jo(r);return i?(k(i),r):r.requiresMFA&&!r.accessToken?(w(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:r.sessionId||t,availableMfaMethods:r.availableMFAMethods||[],availableEnrollmentMethods:r.availableEnrollmentMethods||[],enrolledSecondFactorMethods:r.enrolledSecondFactorMethods||[],usableSecondFactorMethods:r.usableSecondFactorMethods||[]})),r):($(`Authentication successful`,{success:r.success,hasAccessToken:!!r.accessToken,method:e.method}),_e(r,t),r)}catch(t){let n=f(t);throw s(t,`Authentication failed`,{method:e.method,message:n}),w(e=>({...e,isLoading:!1,error:n})),t}},A=async e=>{$(`Getting session state`,{sessionId:e});try{let t=await F().getSessionState(e);return w(e=>({...e,sessionState:t,purpose:t?.purpose??e.purpose})),$(`Session state retrieved`,{sessionId:e}),t}catch(t){throw s(t,`Failed to get session state`,{sessionId:e}),t}},be=()=>!!C.accessToken,xe=(0,U.useCallback)(async(e,t,n)=>{$(`Initiating OAuth2 login`,{providerRef:e,returnUrl:t}),w(e=>({...e,isLoading:!0,error:null}));try{let{authorizationUrl:r}=await F().getOAuth2AuthorizationUrl(e,t,void 0,n);$(`Redirecting to OAuth2 provider`,{providerRef:e,authorizationUrl:r}),window.location.href=r}catch(t){let n=f(t);throw s(t,`OAuth2 login initiation failed`,{providerRef:e,message:n}),w(e=>({...e,isLoading:!1,error:n})),t}},[s,f]),Se=(0,U.useCallback)(async e=>{$(`Handling AUTH_CODE_EXCHANGE token (OAuth2 callback or cross-frontend handoff)`,{codeLength:e.length}),w(e=>({...e,isLoading:!0,error:null}));try{let t=await F().exchangeAuthCode(e),n=jo(t);if(n){$(`Code exchange parked the federated sign-in at organization onboarding`),k(n);return}if(!(`accessToken`in t))throw Error(`The code exchange answered with neither a sign-in nor a parked onboarding session.`);let{accessToken:r,returnPath:a,sourceFrontendServiceName:o,targetServiceKey:s}=t;O(r,typeof a==`string`?P.RESUMED:P.SIGNED_IN),F().setAuthToken(r),i(r);let c=typeof a==`string`?{returnPath:a,...o!==void 0&&{sourceFrontendServiceName:o},...s!==void 0&&{targetServiceKey:s}}:void 0;$(`OAuth2 callback successful, tokens stored`,{isCrossFrontendHandoff:c!==void 0}),w(e=>({...e,isLoading:!1,accessToken:r,isRestoringSession:!0,sessionRestored:!1,sessionId:null,crossFrontendHandoffContext:c})),b.current=!0}catch(e){let t=f(e);throw s(e,`OAuth2 callback failed`,{message:t}),w(e=>({...e,isLoading:!1,error:t})),e}},[i,s,f]),Ce=(0,U.useCallback)(async(e,t)=>{$(`Handling email verification`,{tokenLength:e.length,email:t}),w(e=>({...e,isLoading:!0,error:null}));try{let n=await F().verifyEmail(e,t);n.accessToken?(O(n.accessToken,P.SIGNED_IN),F().setAuthToken(n.accessToken),i(n.accessToken),$(`Email verification successful, tokens stored`),w(e=>({...e,isLoading:!1,accessToken:n.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):jo(n)?($(`Email verification parked the registrant at organization onboarding`,{state:n.state}),k(n.sessionId)):($(`Email verification succeeded but tokens not issued — pipeline requires further steps`,{state:n.state,nextStep:n.nextStep}),w(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:n.requiresMFA??!1,mfaSessionId:n.requiresMFA?n.sessionId??null:null,availableMfaMethods:[],availableEnrollmentMethods:n.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})))}catch(e){let t=f(e);throw s(e,`Email verification failed`,{message:t}),w(e=>({...e,isLoading:!1,error:t})),e}},[i,s,f]),we=(0,U.useCallback)(async e=>{$(`Handling invitation acceptance`,{hasPassword:!!e.password,credentialMethod:e.credentialMethod}),w(e=>({...e,isLoading:!0,error:null}));try{let t=await F().acceptInvitation(e);return t.accessToken?(O(t.accessToken,P.SIGNED_IN),F().setAuthToken(t.accessToken),i(t.accessToken),$(`Invitation acceptance successful, tokens stored`),w(e=>({...e,isLoading:!1,accessToken:t.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0):($(`Invitation acceptance requires further auth steps`,{state:t.state,nextStep:t.nextStep}),w(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:t.requiresMFA??!1,mfaSessionId:t.requiresMFA?t.sessionId??null:null,availableMfaMethods:[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null}))),{passkeyRegistrationOptions:t.passkeyRegistrationOptions,signInRequired:t.nextStep===pt.SIGN_IN_REQUIRED}}catch(e){let t=f(e);throw s(e,`Invitation acceptance failed`,{message:t}),w(e=>({...e,isLoading:!1,error:t})),e}},[i,s,f]),Te=(0,U.useCallback)(async e=>{$(`Handling public registration`,{hasPassword:!!e.password});let t=await F().register(e),n=Fo(t);if(n===Y.SIGNED_IN){let e=t.accessToken;O(e,P.SIGNED_IN),F().setAuthToken(e),i(e),$(`Registration signed the registrant in, tokens stored`,{state:t.state}),w(t=>({...t,isLoading:!1,accessToken:e,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0}else n===Y.MFA_ENROLLMENT_REQUIRED?($(`Registration owes a second-factor enrollment before sign-in`,{state:t.state,nextStep:t.nextStep}),w(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:!0,mfaSessionId:t.sessionId,availableMfaMethods:[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null}))):n===Y.ORGANIZATION_ONBOARDING_REQUIRED?($(`Registration parked the registrant at organization onboarding`,{state:t.state}),k(t.sessionId)):$(`Registration answered without a session to adopt`,{outcome:n,state:t.state,nextStep:t.nextStep});return n},[i]),j=(0,U.useCallback)(async(e,t)=>{$(`Handling magic link verification`,{tokenLength:e.length,email:t}),w(e=>({...e,isLoading:!0,error:null}));try{let n=await F().magicLinkVerify(e,t),r=jo(n);return r?(k(r),n):n.requiresMFA&&!n.accessToken?(w(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:n.sessionId||null,availableMfaMethods:n.availableMFAMethods||[],availableEnrollmentMethods:n.availableEnrollmentMethods||[],enrolledSecondFactorMethods:n.enrolledSecondFactorMethods||[],usableSecondFactorMethods:n.usableSecondFactorMethods||[]})),n):(n.success&&n.accessToken?(O(n.accessToken,P.SIGNED_IN),F().setAuthToken(n.accessToken),i(n.accessToken),$(`Magic link verification successful, tokens stored`),w(e=>({...e,isLoading:!1,accessToken:n.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):w(e=>({...e,isLoading:!1})),n)}catch(e){let t=f(e);throw s(e,`Magic link verification failed`,{message:t}),w(e=>({...e,isLoading:!1,error:t})),e}},[i,s,f]),Ee=(0,U.useCallback)(async(e,t,n)=>{$(`Handling MFA verification`,{sessionId:e,method:t}),w(e=>({...e,isLoading:!0,error:null}));try{let r=F(),a=await r.authenticate({sessionId:e,method:t,factorLevel:Ie.SECOND,token:n}),o=jo(a);return o?(k(o),a):(a.success&&a.accessToken?(O(a.accessToken,P.SIGNED_IN),r.setAuthToken(a.accessToken),i(a.accessToken),$(`MFA verification successful, tokens stored`),w(e=>({...e,isLoading:!1,accessToken:a.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),b.current=!0):w(e=>({...e,isLoading:!1,error:f(null,p())})),a)}catch(e){let n=f(e,p());throw s(e,`MFA verification failed`,{method:t,message:n}),w(e=>({...e,isLoading:!1,error:n})),e}},[i,s,f,p]),De=(0,U.useCallback)((e,t)=>!t?.state||!vs.has(t.state)?!1:(w(n=>({...n,mfaRequired:!0,mfaSessionId:e,availableMfaMethods:t.availableSecondFactorMethods||[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:t.enrolledSecondFactorMethods||[],usableSecondFactorMethods:t.usableSecondFactorMethods||[]})),!0),[]),Oe=(0,U.useCallback)(e=>{let t=jo(e);if(t)return $(`Enrollment parked the registration session at organization onboarding`),k(t),!0;if(!e?.accessToken||e.state!==Je.COMPLETED)return!1;let n=F();return O(e.accessToken,P.SIGNED_IN),n.setAuthToken(e.accessToken),i(e.accessToken),$(`Enrollment completed the registration session, tokens stored`),w(t=>({...t,isLoading:!1,accessToken:e.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0,!0},[i]),ke=(0,U.useCallback)(async e=>{let t=C.onboardingSessionId;if(!t)throw Error(`No session is parked at onboarding.`);w(e=>({...e,isLoading:!0,error:null}));try{let n=F(),r=await e(t);return r.accessToken?(O(r.accessToken,P.SIGNED_IN),n.setAuthToken(r.accessToken),i(r.accessToken),$(`Onboarding completed, tokens stored`,{organizationId:r.organizationId}),w(e=>({...e,isLoading:!1,accessToken:r.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,onboardingSessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0,{signedIn:!0,pendingObligations:[]}):(w(e=>({...e,isLoading:!1})),$(`Onboarding obligation completed; the session stays parked on the rest`,{pendingObligations:r.pendingObligations}),{signedIn:!1,pendingObligations:r.pendingObligations??[]})}catch(e){throw No(e)?M():w(e=>({...e,isLoading:!1})),e}},[C.onboardingSessionId,i]),Ae=(0,U.useCallback)(e=>ke(t=>F().completeOrgOnboarding(t,e)),[ke]),je=(0,U.useCallback)((e,t)=>ke(n=>F().completeProfileOnboarding(n,e,t)),[ke]),M=()=>{te.current+=1,Bo(),w(e=>({...e,isLoading:!1,error:null,identification:null,sessionId:null,sessionState:null,onboardingSessionId:null}))},Me=(0,U.useCallback)(()=>{M()},[]),Ne=(0,U.useCallback)(async({sessionId:e,factorLevel:t,conditional:n})=>{$(`Handling passkey authentication`,{sessionId:e,factorLevel:t,conditional:n}),n||w(e=>({...e,isLoading:!0,error:null}));let r=!1,a=!1,o=t===`first`?u.PUBLIC_LAYOUTS_USER_AUTH:u.PUBLIC_LAYOUTS_MFA_CHALLENGE,l=e=>co({tComponent:c,componentType:o,key:e}),d=t===`first`?He.PASSKEY_ERROR:Le.PASSKEY_ERROR,p=t===`first`?He.PASSKEY_CANCELLED:Le.PASSKEY_CANCELLED;try{let o=F(),s=await o.passkeyAuthOptions(e),c=s.options;if(n&&S.current>0)throw new ps;let u,p=(s.expiresInSeconds??0)*1e3-bs,m=n&&p>0,h=Date.now()+p,g=()=>{a||(a=!0,So.cancelCeremony())},_=()=>{Date.now()>=h&&g()};m&&(u=setTimeout(g,p),typeof document<`u`&&document.addEventListener(`visibilitychange`,_),typeof window<`u`&&window.addEventListener(`focus`,_));let v;try{v=await Ao({optionsJSON:c,useBrowserAutofill:n})}finally{clearTimeout(u),m&&(typeof document<`u`&&document.removeEventListener(`visibilitychange`,_),typeof window<`u`&&window.removeEventListener(`focus`,_))}r=!0,n&&w(e=>({...e,isLoading:!0,error:null}));let y=await o.passkeyAuthVerify({response:v,sessionId:s.sessionId,factorLevel:us(t)});y.passkeyCredentialUnknown&&xs(c?.rpId,v.id);let x=jo(y);return x?(k(x),y):y.requiresMFA&&!y.accessToken?(w(t=>({...t,isLoading:!1,mfaRequired:!0,mfaSessionId:y.sessionId||e,availableMfaMethods:y.availableMFAMethods||[],availableEnrollmentMethods:y.availableEnrollmentMethods||[],enrolledSecondFactorMethods:y.enrolledSecondFactorMethods||[],usableSecondFactorMethods:y.usableSecondFactorMethods||[]})),y):(y.success&&y.accessToken?(O(y.accessToken,P.SIGNED_IN),o.setAuthToken(y.accessToken),i(y.accessToken),$(`Passkey authentication successful, tokens stored`),w(e=>({...e,isLoading:!1,accessToken:y.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),b.current=!0):w(e=>({...e,isLoading:!1,error:f(null,l(d))})),y)}catch(t){if(n&&!r)throw a?new fs:t;let i=t?.name===`NotAllowedError`?l(p):f(t,l(d));throw s(t,`Passkey authentication failed`,{sessionId:e,message:i}),w(e=>({...e,isLoading:!1,error:i})),t}},[i,s,c,f]),Pe=(0,U.useCallback)(async e=>{S.current+=1;try{return await Ne({...e,conditional:!1})}finally{--S.current}},[Ne]),Fe=(0,U.useCallback)((e,t=`first`)=>Pe({sessionId:e,factorLevel:t}),[Pe]),Re=(0,U.useCallback)((e=ds.MODAL)=>e===ds.CONDITIONAL?Ne({factorLevel:`first`,conditional:!0}):Pe({factorLevel:`first`}),[Ne,Pe]),ze=(0,U.useCallback)(async e=>{$(`Handling one-off token exchange`,{tokenLength:e.length}),w(e=>({...e,isLoading:!0,error:null}));try{let t=F(),{accessToken:r,consumableTokenValue:a,tokenExpiresAt:s,context:c}=await t.exchangeOneOffToken(e);O(r,P.ONE_OFF),t.setAuthToken(r),i(r),a&&(t.setConsumableToken(a),o(a)),c.organizationId&&n.setOrganizationId(c.organizationId),me(r,c.organizationId,a),te.current+=1,w({...ls,accessToken:r,sessionType:et.ONE_OFF,oneOffContext:{originTokenId:c.tokenId,tokenType:c.tokenType,consumableTokenValue:a,tokenExpiresAt:s,scopedInitiatorIds:c.targeting?.initiatorIds,applicationId:c.applicationId},sessionRestored:!0}),b.current=!0,$(`One-off token exchange successful`,{tokenType:c.tokenType})}catch(e){let t=f(e);throw s(e,`One-off token exchange failed`,{message:t}),w(e=>({...e,isLoading:!1,error:t})),e}},[n,i,o,me,s,f]),Be=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=C.mfaRequired&&!C.accessToken?C.mfaSessionId:null;e?(Ro({sessionId:e,email:C.identification?.email??``}),Be.current=e):(Be.current!==null||C.accessToken)&&(Bo(),Be.current=null)},[C.mfaRequired,C.mfaSessionId,C.accessToken,C.identification?.email]);let Ue=(0,U.useCallback)((e,t)=>{$(`Ending session`,{reason:e,revokeOnBackend:t,alreadyEnded:se.current}),te.current+=1,se.current||(se.current=!0,ie.current=e,le(_s.has(e)?e:null)),re.current=P.RESUMED,t&&F().logoutFromBackend().catch(e=>{Q.warn(`Backend logout call failed (token revocation)`,{error:e})}),x.current?.postMessage({type:`LOGOUT`,reason:ie.current}),g(),F().setConsumableToken(null),F().setAuthToken(null),o(null),i(null),n.clear(),Bo(),w(ls),b.current=!1,Q.info(`User logged out successfully`)},[g,n,i,o]),N=(0,U.useCallback)(e=>Ue(e,!0),[Ue]),Ge=(0,U.useCallback)(()=>N(l.SIGNED_OUT),[N]),qe=(0,U.useCallback)(async()=>{await F().logoutAllFromBackend(),Ue(l.SIGNED_OUT,!1)},[Ue]),Ye=(0,U.useCallback)(()=>{w(e=>e.crossFrontendHandoffContext===void 0?e:{...e,crossFrontendHandoffContext:void 0})},[]),Xe=(0,U.useCallback)(()=>{w(e=>({...e,sessionRestored:!0,isRestoringSession:!1}))},[]),Ze=(0,U.useCallback)(e=>{w(t=>({...t,isRestoringSession:e}))},[]),Qe=(0,U.useCallback)(async()=>{if(ee.current)return Q.debug(`Auth token renewal already in flight; waiting for shared result`),ee.current;let e=n.getAccessToken(),t=()=>{let t=n.getAccessToken();return t&&t!==e?(F().setAuthToken(t),i(t),w(e=>e.accessToken===t?e:{...e,accessToken:t}),_(t),Q.debug(`Auth token renewal short-circuited; adopted token rotated by another tab`),t):null},a=async()=>{Q.debug(`Auth token renewal started`);let e=await F().refreshTokens();return fe(e.accessToken),F().setAuthToken(e.accessToken),i(e.accessToken),w(t=>({...t,accessToken:e.accessToken})),x.current?.postMessage({type:`TOKEN_REFRESHED`,accessToken:e.accessToken}),Q.debug(`Auth token renewal succeeded; frontend clients updated`),_(e.accessToken),e.accessToken};ee.current=(async()=>{let e=typeof navigator<`u`?navigator.locks:void 0;return e?.request?e.request(`wildo-auth-refresh`,async()=>t()||a()):a()})().finally(()=>{ee.current=null});try{return await ee.current}catch(e){let t=r(e),n=Ve();throw t&&!n?(Q.warn(`Auth token renewal failed; refresh token was rejected and logout will follow`,{error:oe(e)?e.customMessageReference:e instanceof Error?e.message:`Unknown error`}),N(ct(e))):Q.warn(`Auth token renewal failed but session is preserved (will retry on the next request)`,{authoritative:t,devLenient:n,reason:t?`development leniency active — not logging out on an authoritative rejection`:`transient failure (backend unreachable / 5xx / timeout) — not an authoritative rejection`}),e}},[i,N,_,n]);(0,U.useEffect)(()=>{ne.current=Qe,F().setTokenRenewalHandler(Qe),a(Qe)},[Qe,a]),(0,U.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`wildo-auth-tokens`);return x.current=e,e.onmessage=e=>{let{type:t,accessToken:r}=e.data??{};if(t===`TOKEN_REFRESHED`&&r&&(Q.debug(`Auth token renewal received from another tab; frontend clients updated`),fe(r),F().setAuthToken(r),i(r),w(e=>({...e,accessToken:r})),_(r)),t===`LOGOUT`){if($(`Received logout signal from another tab`),te.current+=1,!se.current){let t=e.data?.reason,n=_s.has(t);se.current=!0,ie.current=n?t:l.SIGNED_OUT_IN_ANOTHER_TAB,le(n?t:null)}re.current=P.RESUMED,g(),n.clear(),F().setConsumableToken(null),o(null),n.storeTokens(null,null),F().setAuthToken(null),i(null),w(ls)}},()=>{e.close(),x.current=null}},[i,o,g,_,n]),(0,U.useEffect)(()=>{if(b.current)return;let e=n.getAccessToken();e?($(`Found stored access token, initializing auth state`),b.current=!0,w(t=>({...t,accessToken:e,isRestoringSession:!0})),F().setAuthToken(e),i(e)):($(`No stored access token found`),b.current=!0)},[i,n]);let $e=(0,U.useMemo)(()=>({auth:C,tokenStorage:n,identifyByEmail:ge,authenticateWithPassword:ve,authenticate:ye,getSessionState:A,isAuthenticated:be,logout:Ge,signOutEverywhere:qe,endSession:N,getSessionEstablishment:ae,getSessionEndReason:T,endedSessionReason:ce,getEndedSessionReason:ue,initiateOAuth2Login:xe,handleAuthCodeExchange:Se,handleEmailVerification:Ce,acceptInvitation:we,registerAccount:Te,handleMagicLinkVerify:j,handleMfaVerify:Ee,completeEnrollmentSession:Oe,adoptPendingMfaSession:De,completeOrganizationOnboarding:Ae,completeProfileOnboarding:je,abandonOrganizationOnboarding:Me,handlePasskeyAuth:Fe,signInWithPasskey:Re,handleOneOffTokenExchange:ze,clearCrossFrontendHandoffContext:Ye,markSessionRestored:Xe,setSessionRestoring:Ze,connectWebSocket:me,notifyOrganizationSwitch:he}),[C,n,Ge,qe,N,ae,T,ce,ue,xe,Se,Ce,we,Te,j,Ee,Oe,De,Ae,je,Me,Fe,Re,ze,Ye,Xe,Ze,me,he]);return(0,W.jsx)(ys.Provider,{value:$e,children:e})},Cs=()=>{let e=(0,U.useContext)(ys);if(!e)throw Error(`useAuthSession must be used within an AuthSessionProvider`);return e},ws=new Set(Object.values(Me).flat()),Ts=class e{static DEFAULT_PRIMARY_SCOPE=D.ORGANIZATIONS;static buildPrimaryScopeValues(e){return{organizationId:e.organizationId??null,userId:e.userId??null,applicationId:e.applicationId??null,anonymousUserId:e.anonymousUserId??null}}static buildInitiatorIds(e){let t={};return e.userId&&(t.userId=e.userId),e.organizationId&&(t.organizationId=e.organizationId),e.applicationId&&(t.applicationId=e.applicationId),e.anonymousUserId&&(t.anonymousUserId=e.anonymousUserId),Object.keys(t).length>0?t:null}static primaryScopeToContextIdentifiers(e,t){if(!e)return{};let n={[ut.ORGANIZATIONS]:e.organizationId,[ut.USERS]:e.userId,[ut.APPLICATION]:e.applicationId,[ut.ANONYMOUS_USERS]:e.anonymousUserId},r={},i=Me[t]||[];for(let e of i){let t=n[e];t&&(r[e]=t)}return r}static buildResourceOperationContextIdentifiers(t){let n=e.buildInitiatorIds({userId:t.currentUserId,organizationId:t.currentOrganizationId,applicationId:t.currentApplicationId,anonymousUserId:t.currentAnonymousUserId}),r=e.primaryScopeToContextIdentifiers(n,t.primaryScope??e.DEFAULT_PRIMARY_SCOPE),i=e.filterCustomScopeContextResourceIdentifiers(t.liveAppScopeContextResourceIdentifiers);return{...r,...i,...t.explicitContextResourceIdentifiers??{}}}static mergeContextResourceIdentifiers(...e){let t=e.reduce((e,t)=>t?{...e,...t}:e,{});return Object.keys(t).length>0?t:void 0}static filterCustomScopeContextResourceIdentifiers(e){return e?Object.fromEntries(Object.entries(e).filter(([e])=>!ws.has(e))):{}}static getAllowedViewBindingKeys(e){let t=new Set(Me[e.primaryScope]??[]),n=[...e.parentResourcesRequirements??[],...e.additionalResourceRequirements??[]];for(let e of n)t.add(e.resourceType),e.foreignKeyField&&t.add(e.foreignKeyField);return t}static scopeContextToBindingContract(e,t){if(!e)return;let n=Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)));return Object.keys(n).length>0?n:void 0}static resolveViewContextResourceIdentifiers(t){return e.mergeContextResourceIdentifiers(t.primaryScopeContext,t.customScopeContext,t.explicitContextResourceIdentifiers)}static findViewPrimaryScope(e,t){return!e||!t?null:t.find(t=>t.ref===e)?.primaryScope??null}static extractPrimaryScopeFromContent(t,n,r,i,a){switch(t.contentType){case Nt.RESOURCE_OPERATION:{let r=t.resourceContext?.resourceType;if(r&&n?.resourceConfigurations?.[r])return n.resourceConfigurations[r].resourcePrimaryScope||e.DEFAULT_PRIMARY_SCOPE;let i=t.resourceContext?.operation;return i?.resourcePrimaryScope?i.resourcePrimaryScope:e.DEFAULT_PRIMARY_SCOPE}case Nt.COMPOSITE_VIEW:return mn({viewRef:t.viewRef,compositeViews:r,registry:n})?.primaryScope??e.DEFAULT_PRIMARY_SCOPE;case Nt.CHART_VIEW:return t.viewDefinition?.primaryScope?t.viewDefinition.primaryScope:t.runtimeDescriptor||n?lr({viewRef:t.viewRef,registry:n})?.chartView.primaryScope??e.DEFAULT_PRIMARY_SCOPE:e.DEFAULT_PRIMARY_SCOPE;case Nt.FULL_CUSTOM_VIEW:return e.findViewPrimaryScope(t.viewRef,i)??e.DEFAULT_PRIMARY_SCOPE;case Nt.FLOWS_ACTORS_VIEW:return e.findViewPrimaryScope(t.viewRef,a)??e.DEFAULT_PRIMARY_SCOPE;case Nt.EXECUTION_VIEW:return Vr({viewRef:t.viewRef,registry:n})?.primaryScope??e.DEFAULT_PRIMARY_SCOPE;case Nt.CUSTOM_COMPONENT:case Nt.ENGINE_PAGE:case Nt.INLINE_CREATE:case Nt.ERROR_MODAL:return e.DEFAULT_PRIMARY_SCOPE}}static buildStorageKey(e){return`${e.appType}|${e.resourcePrimaryScope}|${e.primaryScopeValue}|${e.fieldIdentifier}`}static getPrimaryScopeValue(e,t){switch(e){case D.ORGANIZATIONS:return t.organizationId??null;case D.USER_SELF:return t.userId??null;case D.APPLICATION:return t.applicationId??null;case D.ANONYMOUS:return t.anonymousUserId??null;default:return null}}static loadAll(){let e=qe(N.SCOPE_VALUES);if(!e)return{updatedAt:new Date().toISOString(),fields:{}};try{let t=JSON.parse(e);return typeof t!=`object`||!t?{updatedAt:new Date().toISOString(),fields:{}}:t}catch{return{updatedAt:new Date().toISOString(),fields:{}}}}static saveAll(e){let t={...e,updatedAt:new Date().toISOString()};ke(N.SCOPE_VALUES,JSON.stringify(t))}static getValue(t){let n=e.loadAll(),r=e.buildStorageKey(t);return n.fields[r]??null}static setValue(t,n){let r=e.loadAll(),i=e.buildStorageKey(t);n===null?delete r.fields[i]:r.fields[i]=n,e.saveAll(r)}static clearForContext(t,n,r){let i=e.loadAll(),a=`${t}|${n}|${r}|`;for(let e of Object.keys(i.fields))e.startsWith(a)&&delete i.fields[e];e.saveAll(i)}static loadForContext(t,n,r){let i={};for(let a of r){let r=e.getPrimaryScopeValue(a.resourcePrimaryScope,n);if(!r){i[a.fieldIdentifier]=null;continue}let o=e.getValue({appType:t,resourcePrimaryScope:a.resourcePrimaryScope,primaryScopeValue:r,fieldIdentifier:a.fieldIdentifier});i[a.fieldIdentifier]=o}return i}},Es=Be.getLogger(),Ds=Es.debugByType(`AppScopeContext`);Es.setDebugTypeLogging(`AppScopeContext`,!1);var Os=(0,U.createContext)(void 0),ks=(0,U.createContext)(void 0);function As(){let e=U.useContext(ks);if(!e)throw Error(`useAppScopeInternal must be used within an AppScopeProvider`);return e}function js(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):!1}function Ms(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}function Ns(e){return Array.isArray(e)?e[0]??null:e??null}function Ps(e){if(!e)return{userId:null,applicationId:null};try{let t=Ia(e);return{userId:t.userId??null,applicationId:t.applicationId??null}}catch(e){return Es.warn(`Failed to decode access token for AppScope primary values`,{error:e}),{userId:null,applicationId:null}}}var Fs=({children:e})=>{let{emit:t,on:n}=Ne(),{registry:r,doOperation:i}=no(),{frontendConfiguration:a}=wt(),{auth:o,tokenStorage:s,notifyOrganizationSwitch:c}=Cs(),{status:l,anonymousUserId:u}=cs(),d=xe.loadEnvironmentConfig().frontendServiceName,f=()=>o.accessToken&&!o.sessionRestored?null:s.getOrganizationId(),[p,m]=(0,U.useState)(()=>f()),[g,_]=(0,U.useState)({}),[y,b]=(0,U.useState)([]),x=(0,U.useRef)({}),[S,ne]=(0,U.useState)([]),[C,re]=(0,U.useState)(!1),[ie,T]=(0,U.useState)(!0),oe=(0,U.useRef)(!1),ce=(0,U.useRef)(null),E=(0,U.useRef)(null),le=(0,U.useRef)(void 0),ue=(0,U.useMemo)(()=>Ps(o.accessToken),[o.accessToken]),O=(0,U.useMemo)(()=>Ts.buildPrimaryScopeValues({organizationId:p,userId:ue.userId,applicationId:ue.applicationId,anonymousUserId:o.accessToken?null:u}),[p,ue.userId,ue.applicationId,o.accessToken,u]),de=(0,U.useMemo)(()=>{if(o.accessToken)return o.sessionType===et.ONE_OFF?ae.AUTHENTICATED_ONE_OFF:ae.AUTHENTICATED_PERSISTENT;switch(l){case Z.INITIALIZING:return ae.ANONYMOUS_INITIALIZING;case Z.ACTIVE:return ae.ANONYMOUS_ACTIVE;case Z.TRANSPOSING:return ae.ANONYMOUS_TRANSPOSING;case Z.IDLE:case Z.CLEARED:default:return ae.UNAUTHENTICATED}},[o.accessToken,o.sessionType,l]),fe=(0,U.useMemo)(()=>({...O,...g}),[O,g]),k=(0,U.useMemo)(()=>{let e=An(a?.appScope?.fields??[]);return e.length===0?null:`Duplicate app-scope resourceType declarations are not allowed in appScope.fields. Conflicts: ${e.map(e=>`${e.resourceType} (${e.fieldIdentifiers.join(`, `)})`).join(`; `)}`},[a]),pe=(0,U.useCallback)((e,t)=>{m(n=>n===e?n:(le.current=t,s.setOrganizationId(e),n&&e&&c(e,n),e))},[c,s]),me=!!o.accessToken;(0,U.useEffect)(()=>{let e=!!o.accessToken&&!o.sessionRestored,t=!!o.accessToken;m(n=>{if(e)return null;let r=s.getOrganizationId();return t&&n||n===r?n:r})},[me,o.sessionRestored,o.sessionType,s]),(0,U.useEffect)(()=>{if(!r)return;let e=(a?.appScope?.fields??[]).map(e=>{let t=r.resourceConfigurations[e.resourceType];return t?{...e,resourcePrimaryScope:t.resourcePrimaryScope}:(Es.warn(`App scope field references unknown resource type`,{resourceType:e.resourceType,fieldIdentifier:e.fieldIdentifier}),null)}).filter(e=>e!==null).sort((e,t)=>(e.position??999)-(t.position??999));Ds(`Resolved scope fields from app config`,{count:e.length,fields:e.map(e=>e.fieldIdentifier),source:`appScope.fields`}),b(e),re(!0),T(!1)},[r,a]),(0,U.useEffect)(()=>{if(!r||y.length===0)return;let e={none:0,soft:1,hard:2},t=new Map,n=(n,r,i)=>{if(!n||!r||n===r||i===`none`)return;let a=`${n}>>${r}`,o=t.get(a);(!o||e[i]>e[o])&&t.set(a,i)},i=e=>ee(e)||y.some(t=>t.fieldIdentifier===e);for(let e of y){e.dependsOn&&n(e.dependsOn,e.fieldIdentifier,`hard`);let t=e.resourceType,a=r.resourceConfigurations[t],o=a?.resourceRelationships?h(a.resourceRelationships):[];for(let t of o){if(t.isDisabled||t.resourceType1===t.resourceType2&&!t.foreignKeyField)continue;let a=_t.tryResolveRelationshipForeignKeyIdentity(t,r.allResourceFieldIdentifiers)?.fieldIdentifier;if(!a||!i(a))continue;let o=`hard`;o=t.accessScopeStrategy===Xe.STANDALONE?`none`:t.accessScopeStrategy===Xe.OPTIONAL_CONTEXT?`soft`:`hard`,n(a,e.fieldIdentifier,o)}}let a=[];for(let[e,n]of t.entries()){let[t,r]=e.split(`>>`);a.push({parentFieldIdentifier:t,childFieldIdentifier:r,strength:n})}Ds(`Built scope dependencies`,{count:a.length}),ne(a)},[r,y]),(0,U.useEffect)(()=>{let e=E.current;E.current=O;let n=le.current;if(le.current=void 0,e)for(let r of se){let i=e[r.fieldIdentifier]??null,a=O[r.fieldIdentifier]??null;if(i===a)continue;let o=r.scopeLevel===D.ORGANIZATIONS?n:void 0;t(Ze.PRIMARY_SCOPE_CHANGED,{scopeLevel:r.scopeLevel,fieldIdentifier:r.fieldIdentifier,newValue:a,previousValue:i,...o?{initiator:o}:{}})}},[t,O]),(0,U.useEffect)(()=>{if(y.length===0)return;let e=y.filter(e=>e.persist!==!1).map(e=>({fieldIdentifier:e.fieldIdentifier,resourcePrimaryScope:e.resourcePrimaryScope})),n=new Set(y.map(e=>e.fieldIdentifier)),r=Ts.loadForContext(d,O,e);_(e=>{let i={...e},a=[];for(let t of n){let n=e[t]??null,o=r[t]??null;js(n,o)||(i[t]=o,a.push({fieldId:t,previousValue:n,nextValue:o}),Ds(`Reconciled persisted scope value`,{fieldId:t,nextValue:o}))}return a.length>0&&queueMicrotask(()=>{for(let{fieldId:e,previousValue:n,nextValue:r}of a){let i=y.find(t=>t.fieldIdentifier===e);t(Ze.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:i?.resourceType??``,newValue:r,previousValue:n,initiator:v.RESTORE})}}),a.length>0?i:e})},[y,d,O,t]);let he=(0,U.useCallback)((e,t=new Set)=>{if(t.has(e))return[];t.add(e);let n=S.filter(t=>t.parentFieldIdentifier===e&&t.strength===`hard`).map(e=>e.childFieldIdentifier),r=[];for(let e of n)r.push(e),r.push(...he(e,t));return r},[S]),ge=(0,U.useCallback)((e,n)=>{if(!oe.current){oe.current=!0;try{let r=he(e);if(r.length===0)return;Ds(`Cascading to dependent fields`,{parentFieldIdentifier:e,fieldsToClear:r,reason:n}),_(n=>{let i={...n},a=[];for(let e of r){let t=i[e];t!=null&&(i[e]=null,a.push({fieldId:e,prevValue:t}))}return a.length>0&&queueMicrotask(()=>{for(let{fieldId:n,prevValue:r}of a){let i=y.find(e=>e.fieldIdentifier===n);t(Ze.APP_SCOPE_CHANGED,{fieldIdentifier:n,resourceType:i?.resourceType??``,newValue:null,previousValue:r,initiator:v.CASCADE,cascadedFrom:e})}}),a.length>0?i:n})}finally{oe.current=!1}}},[he,y,t]);(0,U.useEffect)(()=>{if(!C||y.length===0)return;let e=JSON.stringify(fe);if(ce.current===e)return;let n=y.filter(e=>e.resourceType&&g[e.fieldIdentifier]!==null&&g[e.fieldIdentifier]!==void 0);if(n.length===0){ce.current=e;return}let a=setTimeout(async()=>{Ds(`Starting scope validation`,{fields:n.map(e=>e.fieldIdentifier)});let a={};for(let[e,t]of Object.entries(fe)){let n=Ns(t);n&&(a[e]=n)}for(let e of n){let n=g[e.fieldIdentifier],o=Ms(n),s=o.length>0?o:typeof n==`string`&&n.length>0?[n]:[];if(s.length===0)continue;let c=e.resourceType;if(r?.resourceConfigurations[c])try{let o=(r?.resourceConfigurations?.[c])?.operations?.find(e=>String(e.operationIdentifier)===M.LIST);if(!o)continue;let l=we.extractOperationPath(o),u=await i(l,{contextualParameters:a,pagination:{limit:100}});if(!u?.data||!Array.isArray(u.data))continue;let d=new Set(u.data.map(e=>String(e._id??``))),f=s.filter(e=>d.has(e)),p=Array.isArray(n)?f.length>0?f:null:f[0]??null;js(n,p)||(Ds(`Clearing invalid scope value`,{fieldIdentifier:e.fieldIdentifier,value:n,nextValue:p}),_(n=>{let r=n[e.fieldIdentifier];return js(r??null,p)?n:(queueMicrotask(()=>{t(Ze.APP_SCOPE_CHANGED,{fieldIdentifier:e.fieldIdentifier,resourceType:e.resourceType,newValue:p,previousValue:r??null,initiator:v.VALIDATION}),ge(e.fieldIdentifier,`validation_cleared`)}),{...n,[e.fieldIdentifier]:p})}))}catch(t){Es.warn(`Error validating scope field`,{fieldIdentifier:e.fieldIdentifier,error:t})}}ce.current=e,Ds(`Scope validation complete`)},500);return()=>clearTimeout(a)},[C,y,g,O,fe,r,i,t,ge]),(0,U.useEffect)(()=>n(Ze.PRIMARY_SCOPE_CHANGED,e=>{Ds(`PRIMARY_SCOPE_CHANGED received`,e);let{fieldIdentifier:t}=e;ge(t,`primary_scope_changed`)}),[n,ge]);let _e=(0,U.useCallback)((e,n,r={})=>{let{initiator:i=v.API,skipPersist:a=!1}=r;if(ee(e)){Es.warn(`Cannot set primary scope value via setScopeValue(). Use UserOrgsContext methods instead.`,{fieldIdentifier:e});return}let o=y.find(t=>t.fieldIdentifier===e);o?(Ds(`Setting scope value`,{fieldIdentifier:e,value:n,initiator:i}),_(r=>{let s=r[e]??null;return js(s,n)?r:(queueMicrotask(()=>{if(t(Ze.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:o.resourceType,newValue:n,previousValue:s,initiator:i}),ge(e,`value_changed`),!a&&o.persist!==!1){let t=Ts.getPrimaryScopeValue(o.resourcePrimaryScope,O);t&&(Ts.setValue({appType:d,resourcePrimaryScope:o.resourcePrimaryScope,primaryScopeValue:t,fieldIdentifier:e},n),Ds(`Persisted scope value`,{fieldIdentifier:e,value:n}))}}),{...r,[e]:n})})):Es.warn(`Unknown scope field`,{fieldIdentifier:e})},[y,t,ge,d,O]);(0,U.useEffect)(()=>{if(C&&y.length!==0)return n(Ze.NAVIGATION_ZONE_CHANGED,e=>{if(!w.includes(e.zone))return;let t=e.currentContent;if(!t||t.contentType!==Nt.RESOURCE_OPERATION)return;let n=t.resourceContext?.contextResourceIdentifiers;if(!n)return;let r=t.resourceContext?.resourceType,i=t.resourceContext?.operation,a=!!i&&!je(i);for(let e of y){if(!e.resourceType)continue;if(a&&r===e.resourceType){delete x.current[e.fieldIdentifier],_e(e.fieldIdentifier,null,{initiator:v.ROUTER,skipPersist:!0});continue}let t=n[e.resourceType],i=t?te.getResourceId(t):``;i?x.current[e.fieldIdentifier]=i:delete x.current[e.fieldIdentifier],i&&_e(e.fieldIdentifier,i,{initiator:v.ROUTER,skipPersist:!0})}})},[y,C,n,_e]),(0,U.useEffect)(()=>{if(C&&y.length!==0)return n(Ze.RESOURCE_COLLECTION_FILTERS_CHANGED,e=>{for(let t of y){if(!Object.prototype.hasOwnProperty.call(e.filterValues,t.fieldIdentifier))continue;let n=e.filterValues[t.fieldIdentifier],r=Array.isArray(n)?n[0]:n,i=typeof r==`string`&&r.length>0?r:null;i===null&&x.current[t.fieldIdentifier]||_e(t.fieldIdentifier,i,{initiator:v.SURFACE_FILTER,skipPersist:!0})}})},[y,C,n,_e]);let ve=(0,U.useCallback)((e={})=>{let{initiator:n=v.API}=e;Ds(`Clearing all custom scope values`,{initiator:n}),_(e=>{let r={},i=[];for(let[t,n]of Object.entries(e))n!==null&&i.push({fieldId:t,prevValue:n}),r[t]=null;return i.length>0&&queueMicrotask(()=>{for(let{fieldId:e,prevValue:r}of i){let i=y.find(t=>t.fieldIdentifier===e);t(Ze.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:i?.resourceType??``,newValue:null,previousValue:r,initiator:n})}}),i.length>0?r:e})},[y,t]),ye=(0,U.useCallback)(e=>S.filter(t=>t.parentFieldIdentifier===e).map(e=>e.childFieldIdentifier),[S]),A=(0,U.useCallback)(()=>{let e={};for(let t of se){let n=O[t.fieldIdentifier];n&&(e[t.resourceType]=n)}for(let t of y){let n=g[t.fieldIdentifier],r=Ns(n);r&&t.resourceType&&(e[t.resourceType]=r)}return e},[O,g,y]),be=(0,U.useCallback)(()=>{let e={};for(let[t,n]of Object.entries(fe))n!=null&&(!Array.isArray(n)||n.length>0)&&(e[t]=n);return e},[fe]),Se=(0,U.useMemo)(()=>({sessionMode:de,primaryScopeValues:O,customScopeValues:g,allScopeValues:fe,currentOrganizationId:O.organizationId,currentUserId:O.userId,currentApplicationId:O.applicationId,currentAnonymousUserId:O.anonymousUserId,primaryScopeFields:[...se],customScopeFields:y,setScopeValue:_e,clearCustomScopeValues:ve,dependencies:S,getDependentFields:ye,buildContextResourceIdentifiers:A,buildContextualParameters:be,isReady:C,isLoading:ie}),[de,O,g,fe,y,_e,ve,S,ye,A,be,C,ie]);if(k)throw Error(k);return(0,W.jsx)(ks.Provider,{value:{commitOrganizationScopeValue:pe},children:(0,W.jsx)(Os.Provider,{value:Se,children:e})})};function Is(){let e=(0,U.useContext)(Os);if(!e)throw Error(`useAppScope must be used within an AppScopeProvider. Ensure AppScopeProvider is included in your provider hierarchy after AuthSessionProvider and above UserOrgsProvider.`);return e}function Ls(){return(0,U.useContext)(Os)}var Rs={list:[`h-4 w-3/4`,`h-4 w-full`,`h-4 w-2/3`],detail:[`h-6 w-1/3`,`h-4 w-full`,`h-4 w-2/3`],table:[`h-8 w-full`,`h-8 w-full`,`h-8 w-full`,`h-8 w-full`],card:[`h-32 w-full`,`h-5 w-2/3`,`h-4 w-full`]};function zs(e){return e!==void 0&&e!==`reset`}function Bs(e){return e!==void 0&&e!==`reset`&&e!==`inherit`}function Vs(e){switch(e){case`sm`:return`space-y-item-xs`;case`lg`:return`space-y-card`;default:return`space-y-field`}}var Hs=8;function Us(e){return e===void 0||!Number.isFinite(e)?1:Math.min(Math.max(Math.trunc(e),1),Hs)}function Ws(e,t){return e===void 0||e===`auto`?zs(t)?t:void 0:e}function Gs(e,t,n){return e===`auto`||e===void 0&&t===void 0&&n===void 0}function Ks(e,t,n){return e&&e!==`auto`&&e!==`inherit`?e:Bs(t)?t:n}function qs({preset:e=At.DEFAULT,template:t,density:n,count:r,className:i,...a}){let o=U.useContext(d),s=o?.policy,c=at(u.LOW_LEVEL_SKELETON,`Skeleton`)(e),l=s?.skeleton?.skeletonTemplate,f=s?.skeleton?.skeletonDensity,p=o?ue[o.variant].skeleton?.skeletonDensity:void 0,m=Bs(p)?p:`md`,h=s&&Gs(t,i,a.style)?Ws(t,l):t===`auto`||t===void 0?void 0:t;if(!h||h===`inherit`)return(0,W.jsx)(c,{className:i,...a});if(h===`none`)return(0,W.jsx)(W.Fragment,{});let g=Ks(n,f,m),_=Us(r),v=Rs[h];return(0,W.jsx)(`div`,{"data-slot":`skeleton-template`,"data-skeleton-template":h,"data-skeleton-density":g,"data-skeleton-count":_,className:ce(Vs(g),i),...a,children:_===1?v.map((e,t)=>(0,W.jsx)(c,{className:e,"aria-hidden":`true`},`${h}-${t}`)):Array.from({length:_},(e,t)=>(0,W.jsx)(`div`,{className:Vs(g),children:v.map((e,t)=>(0,W.jsx)(c,{className:e,"aria-hidden":`true`},`${h}-${t}`))},`item-${t}`))})}function Js(e){switch(e){case`collapse`:case`hide`:case`render-children`:return e;default:return`placeholder`}}function Ys(e){return e===`collapse`}function Xs(e){return e===`hide`}var Zs=(0,U.forwardRef)(({preset:e=At.DEFAULT,children:t,hidden:n,style:r,respectSurfaceEmptyDisplay:i=!0,...a},o)=>{let s=Ye(),c=i?Js(s.interactiveState?.emptyDisplay):`placeholder`;if(c===`render-children`)return(0,W.jsx)(W.Fragment,{children:t??null});if(Ys(c))return null;let l=ht(u.LOW_LEVEL_EMPTY_STATE,`EmptyState`)(e);return(0,W.jsx)(l,{...a,hidden:n||Xs(c),style:Xs(c)?{...r,display:`none`}:r,ref:o})});Zs.displayName=`EmptyState`;var Qs=({height:e=400})=>{let{tComponent:t,isReady:n}=yt({component:u.HIGH_LEVEL_VIEWS_CHART});return n?(0,W.jsxs)(`div`,{role:`status`,"aria-live":`polite`,children:[(0,W.jsx)(qs,{className:`w-full rounded-lg`,style:{height:e}}),(0,W.jsx)(`span`,{className:`sr-only`,children:t(u.HIGH_LEVEL_VIEWS_CHART,`loading`)})]}):null};export{oo as $,Kt as $n,tr as $t,Xo as A,bn as An,zr as At,No as B,dn as Bn,ar as Bt,ss as C,Tn as Cn,Nr as Ct,ns as D,xn as Dn,Lr as Dt,rs as E,Sn as En,Br as Et,ts as F,on as Fn,Ir as Ft,To as G,Zt as Gn,cr as Gt,jo as H,mn as Hn,nr as Ht,Bo as I,pn as In,vr as It,co as J,Xt as Jn,dr as Jt,So as K,Yt as Kn,sr as Kt,zo as L,sn as Ln,_r as Lt,Wo as M,un as Mn,Wr as Mt,Ko as N,an as Nn,Vr as Nt,Vo as O,cn as On,Rr as Ot,qo as P,gn as Pn,Fr as Pt,mo as Q,tn as Qn,lr as Qt,Y as R,_n as Rn,gr as Rt,us as S,En as Sn,xr as St,cs as T,Cn as Tn,Gr as Tt,Ao as U,hn as Un,ir as Ut,Mo as V,fn as Vn,or as Vt,Do as W,Jt as Wn,pr as Wt,po as X,$t as Xn,hr as Xt,lo as Y,rn as Yn,mr as Yt,fo as Z,en as Zn,rr as Zt,hs as _,Dn as _n,Ar as _t,Xs as a,Kn as an,to as at,ps as b,Zn as bn,Mr as bt,Ls as c,Xn as cn,$a as ct,As as d,Jn as dn,q as dt,kn as en,Gt as er,io as et,Ts as f,Wn as fn,Ia as ft,gs as g,zn as gn,jr as gt,Ss as h,Qn as hn,Or as ht,Ys as i,$n as in,eo as it,Go as j,vn as jn,Ur as jt,X as k,yn as kn,Kr as kt,Os as l,qn as ln,qa as lt,ys as m,Vn as mn,kr as mt,Zs as n,Rn as nn,no as nt,qs as o,Un as on,Za as ot,Cs as p,Hn as pn,Pr as pt,uo as q,nn as qn,ur as qt,Js as r,wn as rn,ro as rt,Is as s,Yn as sn,Qa as st,Qs as t,er as tn,qt as tr,ao as tt,Fs as u,Gn as un,Ya as ut,ls as v,Bn as vn,Dr as vt,Z as w,An as wn,Hr as wt,ds as x,Ln as xn,br as xt,fs as y,On as yn,Sr as yt,Fo as z,ln as zn,yr as zt};