@suveren/gateway 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/dist/control-plane/index.mjs +182 -37
  2. package/dist/mcp-server/http.mjs +355 -71
  3. package/dist/ui/assets/{index-C-lA_7Lt.js → index-CO-dj98E.js} +27 -27
  4. package/dist/ui/index.html +1 -1
  5. package/node_modules/@hap/core/README.md +3 -3
  6. package/node_modules/@hap/core/dist/index.d.mts +567 -123
  7. package/node_modules/@hap/core/dist/index.d.ts +567 -123
  8. package/node_modules/@hap/core/dist/index.js +869 -23
  9. package/node_modules/@hap/core/dist/index.mjs +829 -22
  10. package/node_modules/@hap/core/node_modules/@hpke/core/LICENSE +21 -0
  11. package/node_modules/@hap/core/node_modules/@hpke/core/README.md +263 -0
  12. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts +11 -0
  13. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts.map +1 -0
  14. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.js +6 -0
  15. package/node_modules/@hap/core/node_modules/@hpke/core/esm/package.json +3 -0
  16. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts +80 -0
  17. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts.map +1 -0
  18. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.js +167 -0
  19. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts +34 -0
  20. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts.map +1 -0
  21. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.js +56 -0
  22. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts +145 -0
  23. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts.map +1 -0
  24. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.js +326 -0
  25. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts +15 -0
  26. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts.map +1 -0
  27. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.js +68 -0
  28. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts +19 -0
  29. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts.map +1 -0
  30. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.js +62 -0
  31. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts +17 -0
  32. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts.map +1 -0
  33. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.js +1 -0
  34. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts +13 -0
  35. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
  36. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.js +1 -0
  37. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts +8 -0
  38. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts.map +1 -0
  39. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.js +1 -0
  40. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts +40 -0
  41. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts.map +1 -0
  42. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.js +1 -0
  43. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts +17 -0
  44. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts.map +1 -0
  45. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.js +1 -0
  46. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts +7 -0
  47. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts.map +1 -0
  48. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.js +1 -0
  49. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts +10 -0
  50. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts.map +1 -0
  51. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.js +1 -0
  52. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts +26 -0
  53. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts.map +1 -0
  54. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.js +112 -0
  55. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
  56. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
  57. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +214 -0
  58. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +24 -0
  59. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
  60. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +214 -0
  61. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts +38 -0
  62. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts.map +1 -0
  63. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.js +66 -0
  64. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts +38 -0
  65. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts.map +1 -0
  66. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.js +66 -0
  67. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts +5 -0
  68. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts.map +1 -0
  69. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.js +28 -0
  70. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts +236 -0
  71. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts.map +1 -0
  72. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.js +235 -0
  73. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts +6 -0
  74. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts.map +1 -0
  75. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.js +38 -0
  76. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts +11 -0
  77. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts.map +1 -0
  78. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.js +45 -0
  79. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts +2 -0
  80. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts.map +1 -0
  81. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.js +6 -0
  82. package/node_modules/@hap/core/node_modules/@hpke/core/package.json +46 -0
  83. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts +11 -0
  84. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts.map +1 -0
  85. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.js +47 -0
  86. package/node_modules/@hap/core/node_modules/@hpke/core/script/package.json +3 -0
  87. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts +80 -0
  88. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts.map +1 -0
  89. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.js +183 -0
  90. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts +34 -0
  91. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts.map +1 -0
  92. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.js +70 -0
  93. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts +145 -0
  94. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts.map +1 -0
  95. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.js +340 -0
  96. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts +15 -0
  97. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts.map +1 -0
  98. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.js +82 -0
  99. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts +19 -0
  100. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts.map +1 -0
  101. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.js +78 -0
  102. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts +17 -0
  103. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts.map +1 -0
  104. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.js +12 -0
  105. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts +13 -0
  106. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
  107. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.js +12 -0
  108. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts +8 -0
  109. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts.map +1 -0
  110. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.js +12 -0
  111. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts +40 -0
  112. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts.map +1 -0
  113. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.js +12 -0
  114. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts +17 -0
  115. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts.map +1 -0
  116. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.js +12 -0
  117. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts +7 -0
  118. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts.map +1 -0
  119. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.js +12 -0
  120. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts +10 -0
  121. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts.map +1 -0
  122. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.js +12 -0
  123. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts +26 -0
  124. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts.map +1 -0
  125. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.js +128 -0
  126. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
  127. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
  128. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +228 -0
  129. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +24 -0
  130. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
  131. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +228 -0
  132. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts +38 -0
  133. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts.map +1 -0
  134. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.js +80 -0
  135. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts +38 -0
  136. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts.map +1 -0
  137. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.js +80 -0
  138. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts +5 -0
  139. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts.map +1 -0
  140. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.js +42 -0
  141. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts +236 -0
  142. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts.map +1 -0
  143. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.js +255 -0
  144. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts +6 -0
  145. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts.map +1 -0
  146. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.js +52 -0
  147. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts +11 -0
  148. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts.map +1 -0
  149. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.js +59 -0
  150. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts +2 -0
  151. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts.map +1 -0
  152. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.js +19 -0
  153. package/node_modules/@hap/core/package.json +2 -1
  154. package/node_modules/@hap/core/src/canonicalize.ts +9 -0
  155. package/node_modules/@hap/core/src/commitment-modes.ts +21 -9
  156. package/node_modules/@hap/core/src/errors.ts +24 -8
  157. package/node_modules/@hap/core/src/gatekeeper.ts +52 -8
  158. package/node_modules/@hap/core/src/index.ts +5 -1
  159. package/node_modules/@hap/core/src/issuance.ts +250 -0
  160. package/node_modules/@hap/core/src/mandate.ts +52 -14
  161. package/node_modules/@hap/core/src/owner-signature.ts +86 -39
  162. package/node_modules/@hap/core/src/profile.ts +45 -0
  163. package/node_modules/@hap/core/src/proposal-content.ts +219 -0
  164. package/node_modules/@hap/core/src/ticket-projection.ts +167 -0
  165. package/node_modules/@hap/core/src/ticket.ts +254 -20
  166. package/node_modules/@hap/core/src/types.ts +33 -5
  167. package/node_modules/@hap/core/src/verifier-policy.ts +178 -0
  168. package/node_modules/@hap/core/src/versions.ts +50 -19
  169. package/node_modules/@hono/node-server/dist/index.cjs +31 -6
  170. package/node_modules/@hono/node-server/dist/index.mjs +31 -6
  171. package/node_modules/@hono/node-server/package.json +1 -1
  172. package/node_modules/@hpke/common/esm/package.json +5 -1
  173. package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts +2 -2
  174. package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts.map +1 -1
  175. package/node_modules/@hpke/common/esm/src/curve/montgomery.js +41 -26
  176. package/node_modules/@hpke/common/esm/src/hash/sha3.d.ts.map +1 -1
  177. package/node_modules/@hpke/common/esm/src/hash/sha3.js +0 -15
  178. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts +2 -1
  179. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts.map +1 -1
  180. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.js +12 -2
  181. package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
  182. package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.js +14 -3
  183. package/node_modules/@hpke/common/esm/src/utils/misc.d.ts +6 -0
  184. package/node_modules/@hpke/common/esm/src/utils/misc.d.ts.map +1 -1
  185. package/node_modules/@hpke/common/esm/src/utils/misc.js +43 -10
  186. package/node_modules/@hpke/common/esm/src/utils/noble.d.ts +1 -1
  187. package/node_modules/@hpke/common/esm/src/utils/noble.d.ts.map +1 -1
  188. package/node_modules/@hpke/common/esm/src/utils/noble.js +21 -10
  189. package/node_modules/@hpke/common/package.json +5 -1
  190. package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts +2 -2
  191. package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts.map +1 -1
  192. package/node_modules/@hpke/common/script/src/curve/montgomery.js +40 -25
  193. package/node_modules/@hpke/common/script/src/hash/sha3.d.ts.map +1 -1
  194. package/node_modules/@hpke/common/script/src/hash/sha3.js +0 -15
  195. package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts +2 -1
  196. package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts.map +1 -1
  197. package/node_modules/@hpke/common/script/src/kdfs/hkdf.js +12 -2
  198. package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
  199. package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.js +13 -2
  200. package/node_modules/@hpke/common/script/src/utils/misc.d.ts +6 -0
  201. package/node_modules/@hpke/common/script/src/utils/misc.d.ts.map +1 -1
  202. package/node_modules/@hpke/common/script/src/utils/misc.js +43 -9
  203. package/node_modules/@hpke/common/script/src/utils/noble.d.ts +1 -1
  204. package/node_modules/@hpke/common/script/src/utils/noble.d.ts.map +1 -1
  205. package/node_modules/@hpke/common/script/src/utils/noble.js +22 -11
  206. package/node_modules/@hpke/core/README.md +56 -56
  207. package/node_modules/@hpke/core/esm/package.json +2 -1
  208. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
  209. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
  210. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +3 -201
  211. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +3 -21
  212. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
  213. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +3 -201
  214. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
  215. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
  216. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.js +216 -0
  217. package/node_modules/@hpke/core/package.json +6 -2
  218. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
  219. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
  220. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +4 -202
  221. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +3 -21
  222. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
  223. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +4 -202
  224. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
  225. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
  226. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.js +230 -0
  227. package/node_modules/@types/node/README.md +1 -1
  228. package/node_modules/@types/node/package.json +2 -2
  229. package/node_modules/@types/node/zlib.d.ts +752 -0
  230. package/node_modules/encodeurl/README.md +14 -0
  231. package/node_modules/encodeurl/index.js +5 -10
  232. package/node_modules/encodeurl/package.json +10 -6
  233. package/node_modules/express-rate-limit/dist/index.cjs +7 -3
  234. package/node_modules/express-rate-limit/dist/index.mjs +7 -3
  235. package/node_modules/express-rate-limit/package.json +10 -10
  236. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  237. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  238. package/node_modules/hono/dist/cjs/context.js +1 -1
  239. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -5
  240. package/node_modules/hono/dist/cjs/hono-base.js +4 -10
  241. package/node_modules/hono/dist/cjs/hono.js +0 -1
  242. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
  243. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
  244. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  245. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  246. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  247. package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
  248. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  249. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  250. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  251. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  252. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
  253. package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
  254. package/node_modules/hono/dist/cjs/utils/url.js +10 -0
  255. package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
  256. package/node_modules/hono/dist/context.js +1 -1
  257. package/node_modules/hono/dist/helper/css/common.js +3 -5
  258. package/node_modules/hono/dist/hono-base.js +4 -10
  259. package/node_modules/hono/dist/hono.js +0 -1
  260. package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
  261. package/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
  262. package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  263. package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  264. package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  265. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  266. package/node_modules/hono/dist/middleware/mount/index.js +4 -4
  267. package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  268. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  269. package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  270. package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  271. package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
  272. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  273. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  274. package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  275. package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
  276. package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
  277. package/node_modules/hono/dist/utils/mount.js +34 -0
  278. package/node_modules/hono/dist/utils/url.js +10 -1
  279. package/node_modules/hono/dist/validator/validator.js +1 -1
  280. package/node_modules/hono/package.json +1 -1
  281. package/node_modules/ip-address/README.md +39 -39
  282. package/node_modules/ip-address/dist/ipv6.js +1 -1
  283. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  284. package/node_modules/ip-address/package.json +1 -1
  285. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
  286. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
  287. package/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
  288. package/node_modules/jose/dist/types/types.d.ts +8 -0
  289. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
  290. package/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
  291. package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  292. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
  293. package/node_modules/jose/package.json +1 -1
  294. package/node_modules/qs/CHANGELOG.md +29 -22
  295. package/node_modules/qs/dist/qs.js +14 -14
  296. package/node_modules/qs/eslint.config.mjs +6 -0
  297. package/node_modules/qs/lib/stringify.js +1 -1
  298. package/node_modules/qs/package.json +5 -5
  299. package/node_modules/qs/test/stringify.js +74 -0
  300. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- var Ty=Object.defineProperty;var Iy=(e,r,a)=>r in e?Ty(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var ia=(e,r,a)=>Iy(e,typeof r!="symbol"?r+"":r,a);(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var nc={exports:{}},oa={},rc={exports:{}},Xe={};/**
1
+ var Ry=Object.defineProperty;var $y=(e,r,a)=>r in e?Ry(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var ia=(e,r,a)=>$y(e,typeof r!="symbol"?r+"":r,a);(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var rc={exports:{}},oa={},sc={exports:{}},Xe={};/**
2
2
  * @license React
3
3
  * react.production.min.js
4
4
  *
@@ -6,7 +6,7 @@ var Ty=Object.defineProperty;var Iy=(e,r,a)=>r in e?Ty(e,r,{enumerable:!0,config
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Kh;function Ry(){if(Kh)return Xe;Kh=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),j=Symbol.iterator;function x(I){return I===null||typeof I!="object"?null:(I=j&&I[j]||I["@@iterator"],typeof I=="function"?I:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function k(I,D,pe){this.props=I,this.context=D,this.refs=w,this.updater=pe||S}k.prototype.isReactComponent={},k.prototype.setState=function(I,D){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,D,"setState")},k.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function C(){}C.prototype=k.prototype;function E(I,D,pe){this.props=I,this.context=D,this.refs=w,this.updater=pe||S}var $=E.prototype=new C;$.constructor=E,N($,k.prototype),$.isPureReactComponent=!0;var T=Array.isArray,F=Object.prototype.hasOwnProperty,M={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function te(I,D,pe){var de,$e={},ve=null,Y=null;if(D!=null)for(de in D.ref!==void 0&&(Y=D.ref),D.key!==void 0&&(ve=""+D.key),D)F.call(D,de)&&!B.hasOwnProperty(de)&&($e[de]=D[de]);var he=arguments.length-2;if(he===1)$e.children=pe;else if(1<he){for(var ee=Array(he),oe=0;oe<he;oe++)ee[oe]=arguments[oe+2];$e.children=ee}if(I&&I.defaultProps)for(de in he=I.defaultProps,he)$e[de]===void 0&&($e[de]=he[de]);return{$$typeof:e,type:I,key:ve,ref:Y,props:$e,_owner:M.current}}function Q(I,D){return{$$typeof:e,type:I.type,key:D,ref:I.ref,props:I.props,_owner:I._owner}}function _(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function z(I){var D={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(pe){return D[pe]})}var V=/\/+/g;function K(I,D){return typeof I=="object"&&I!==null&&I.key!=null?z(""+I.key):D.toString(36)}function le(I,D,pe,de,$e){var ve=typeof I;(ve==="undefined"||ve==="boolean")&&(I=null);var Y=!1;if(I===null)Y=!0;else switch(ve){case"string":case"number":Y=!0;break;case"object":switch(I.$$typeof){case e:case r:Y=!0}}if(Y)return Y=I,$e=$e(Y),I=de===""?"."+K(Y,0):de,T($e)?(pe="",I!=null&&(pe=I.replace(V,"$&/")+"/"),le($e,D,pe,"",function(oe){return oe})):$e!=null&&(_($e)&&($e=Q($e,pe+(!$e.key||Y&&Y.key===$e.key?"":(""+$e.key).replace(V,"$&/")+"/")+I)),D.push($e)),1;if(Y=0,de=de===""?".":de+":",T(I))for(var he=0;he<I.length;he++){ve=I[he];var ee=de+K(ve,he);Y+=le(ve,D,pe,ee,$e)}else if(ee=x(I),typeof ee=="function")for(I=ee.call(I),he=0;!(ve=I.next()).done;)ve=ve.value,ee=de+K(ve,he++),Y+=le(ve,D,pe,ee,$e);else if(ve==="object")throw D=String(I),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return Y}function me(I,D,pe){if(I==null)return I;var de=[],$e=0;return le(I,de,"","",function(ve){return D.call(pe,ve,$e++)}),de}function we(I){if(I._status===-1){var D=I._result;D=D(),D.then(function(pe){(I._status===0||I._status===-1)&&(I._status=1,I._result=pe)},function(pe){(I._status===0||I._status===-1)&&(I._status=2,I._result=pe)}),I._status===-1&&(I._status=0,I._result=D)}if(I._status===1)return I._result.default;throw I._result}var Ae={current:null},Z={transition:null},G={ReactCurrentDispatcher:Ae,ReactCurrentBatchConfig:Z,ReactCurrentOwner:M};function J(){throw Error("act(...) is not supported in production builds of React.")}return Xe.Children={map:me,forEach:function(I,D,pe){me(I,function(){D.apply(this,arguments)},pe)},count:function(I){var D=0;return me(I,function(){D++}),D},toArray:function(I){return me(I,function(D){return D})||[]},only:function(I){if(!_(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},Xe.Component=k,Xe.Fragment=a,Xe.Profiler=l,Xe.PureComponent=E,Xe.StrictMode=i,Xe.Suspense=m,Xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,Xe.act=J,Xe.cloneElement=function(I,D,pe){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var de=N({},I.props),$e=I.key,ve=I.ref,Y=I._owner;if(D!=null){if(D.ref!==void 0&&(ve=D.ref,Y=M.current),D.key!==void 0&&($e=""+D.key),I.type&&I.type.defaultProps)var he=I.type.defaultProps;for(ee in D)F.call(D,ee)&&!B.hasOwnProperty(ee)&&(de[ee]=D[ee]===void 0&&he!==void 0?he[ee]:D[ee])}var ee=arguments.length-2;if(ee===1)de.children=pe;else if(1<ee){he=Array(ee);for(var oe=0;oe<ee;oe++)he[oe]=arguments[oe+2];de.children=he}return{$$typeof:e,type:I.type,key:$e,ref:ve,props:de,_owner:Y}},Xe.createContext=function(I){return I={$$typeof:d,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:u,_context:I},I.Consumer=I},Xe.createElement=te,Xe.createFactory=function(I){var D=te.bind(null,I);return D.type=I,D},Xe.createRef=function(){return{current:null}},Xe.forwardRef=function(I){return{$$typeof:p,render:I}},Xe.isValidElement=_,Xe.lazy=function(I){return{$$typeof:v,_payload:{_status:-1,_result:I},_init:we}},Xe.memo=function(I,D){return{$$typeof:y,type:I,compare:D===void 0?null:D}},Xe.startTransition=function(I){var D=Z.transition;Z.transition={};try{I()}finally{Z.transition=D}},Xe.unstable_act=J,Xe.useCallback=function(I,D){return Ae.current.useCallback(I,D)},Xe.useContext=function(I){return Ae.current.useContext(I)},Xe.useDebugValue=function(){},Xe.useDeferredValue=function(I){return Ae.current.useDeferredValue(I)},Xe.useEffect=function(I,D){return Ae.current.useEffect(I,D)},Xe.useId=function(){return Ae.current.useId()},Xe.useImperativeHandle=function(I,D,pe){return Ae.current.useImperativeHandle(I,D,pe)},Xe.useInsertionEffect=function(I,D){return Ae.current.useInsertionEffect(I,D)},Xe.useLayoutEffect=function(I,D){return Ae.current.useLayoutEffect(I,D)},Xe.useMemo=function(I,D){return Ae.current.useMemo(I,D)},Xe.useReducer=function(I,D,pe){return Ae.current.useReducer(I,D,pe)},Xe.useRef=function(I){return Ae.current.useRef(I)},Xe.useState=function(I){return Ae.current.useState(I)},Xe.useSyncExternalStore=function(I,D,pe){return Ae.current.useSyncExternalStore(I,D,pe)},Xe.useTransition=function(){return Ae.current.useTransition()},Xe.version="18.3.1",Xe}var Gh;function Hc(){return Gh||(Gh=1,rc.exports=Ry()),rc.exports}/**
9
+ */var qh;function Py(){if(qh)return Xe;qh=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),j=Symbol.iterator;function x(I){return I===null||typeof I!="object"?null:(I=j&&I[j]||I["@@iterator"],typeof I=="function"?I:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function k(I,D,pe){this.props=I,this.context=D,this.refs=w,this.updater=pe||S}k.prototype.isReactComponent={},k.prototype.setState=function(I,D){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,D,"setState")},k.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function C(){}C.prototype=k.prototype;function E(I,D,pe){this.props=I,this.context=D,this.refs=w,this.updater=pe||S}var $=E.prototype=new C;$.constructor=E,N($,k.prototype),$.isPureReactComponent=!0;var T=Array.isArray,F=Object.prototype.hasOwnProperty,M={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function te(I,D,pe){var de,$e={},ve=null,Y=null;if(D!=null)for(de in D.ref!==void 0&&(Y=D.ref),D.key!==void 0&&(ve=""+D.key),D)F.call(D,de)&&!B.hasOwnProperty(de)&&($e[de]=D[de]);var he=arguments.length-2;if(he===1)$e.children=pe;else if(1<he){for(var ee=Array(he),oe=0;oe<he;oe++)ee[oe]=arguments[oe+2];$e.children=ee}if(I&&I.defaultProps)for(de in he=I.defaultProps,he)$e[de]===void 0&&($e[de]=he[de]);return{$$typeof:e,type:I,key:ve,ref:Y,props:$e,_owner:M.current}}function Q(I,D){return{$$typeof:e,type:I.type,key:D,ref:I.ref,props:I.props,_owner:I._owner}}function _(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function z(I){var D={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(pe){return D[pe]})}var V=/\/+/g;function K(I,D){return typeof I=="object"&&I!==null&&I.key!=null?z(""+I.key):D.toString(36)}function le(I,D,pe,de,$e){var ve=typeof I;(ve==="undefined"||ve==="boolean")&&(I=null);var Y=!1;if(I===null)Y=!0;else switch(ve){case"string":case"number":Y=!0;break;case"object":switch(I.$$typeof){case e:case r:Y=!0}}if(Y)return Y=I,$e=$e(Y),I=de===""?"."+K(Y,0):de,T($e)?(pe="",I!=null&&(pe=I.replace(V,"$&/")+"/"),le($e,D,pe,"",function(oe){return oe})):$e!=null&&(_($e)&&($e=Q($e,pe+(!$e.key||Y&&Y.key===$e.key?"":(""+$e.key).replace(V,"$&/")+"/")+I)),D.push($e)),1;if(Y=0,de=de===""?".":de+":",T(I))for(var he=0;he<I.length;he++){ve=I[he];var ee=de+K(ve,he);Y+=le(ve,D,pe,ee,$e)}else if(ee=x(I),typeof ee=="function")for(I=ee.call(I),he=0;!(ve=I.next()).done;)ve=ve.value,ee=de+K(ve,he++),Y+=le(ve,D,pe,ee,$e);else if(ve==="object")throw D=String(I),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return Y}function me(I,D,pe){if(I==null)return I;var de=[],$e=0;return le(I,de,"","",function(ve){return D.call(pe,ve,$e++)}),de}function we(I){if(I._status===-1){var D=I._result;D=D(),D.then(function(pe){(I._status===0||I._status===-1)&&(I._status=1,I._result=pe)},function(pe){(I._status===0||I._status===-1)&&(I._status=2,I._result=pe)}),I._status===-1&&(I._status=0,I._result=D)}if(I._status===1)return I._result.default;throw I._result}var Ae={current:null},Z={transition:null},G={ReactCurrentDispatcher:Ae,ReactCurrentBatchConfig:Z,ReactCurrentOwner:M};function J(){throw Error("act(...) is not supported in production builds of React.")}return Xe.Children={map:me,forEach:function(I,D,pe){me(I,function(){D.apply(this,arguments)},pe)},count:function(I){var D=0;return me(I,function(){D++}),D},toArray:function(I){return me(I,function(D){return D})||[]},only:function(I){if(!_(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},Xe.Component=k,Xe.Fragment=a,Xe.Profiler=l,Xe.PureComponent=E,Xe.StrictMode=i,Xe.Suspense=m,Xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,Xe.act=J,Xe.cloneElement=function(I,D,pe){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var de=N({},I.props),$e=I.key,ve=I.ref,Y=I._owner;if(D!=null){if(D.ref!==void 0&&(ve=D.ref,Y=M.current),D.key!==void 0&&($e=""+D.key),I.type&&I.type.defaultProps)var he=I.type.defaultProps;for(ee in D)F.call(D,ee)&&!B.hasOwnProperty(ee)&&(de[ee]=D[ee]===void 0&&he!==void 0?he[ee]:D[ee])}var ee=arguments.length-2;if(ee===1)de.children=pe;else if(1<ee){he=Array(ee);for(var oe=0;oe<ee;oe++)he[oe]=arguments[oe+2];de.children=he}return{$$typeof:e,type:I.type,key:$e,ref:ve,props:de,_owner:Y}},Xe.createContext=function(I){return I={$$typeof:d,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:u,_context:I},I.Consumer=I},Xe.createElement=te,Xe.createFactory=function(I){var D=te.bind(null,I);return D.type=I,D},Xe.createRef=function(){return{current:null}},Xe.forwardRef=function(I){return{$$typeof:p,render:I}},Xe.isValidElement=_,Xe.lazy=function(I){return{$$typeof:v,_payload:{_status:-1,_result:I},_init:we}},Xe.memo=function(I,D){return{$$typeof:y,type:I,compare:D===void 0?null:D}},Xe.startTransition=function(I){var D=Z.transition;Z.transition={};try{I()}finally{Z.transition=D}},Xe.unstable_act=J,Xe.useCallback=function(I,D){return Ae.current.useCallback(I,D)},Xe.useContext=function(I){return Ae.current.useContext(I)},Xe.useDebugValue=function(){},Xe.useDeferredValue=function(I){return Ae.current.useDeferredValue(I)},Xe.useEffect=function(I,D){return Ae.current.useEffect(I,D)},Xe.useId=function(){return Ae.current.useId()},Xe.useImperativeHandle=function(I,D,pe){return Ae.current.useImperativeHandle(I,D,pe)},Xe.useInsertionEffect=function(I,D){return Ae.current.useInsertionEffect(I,D)},Xe.useLayoutEffect=function(I,D){return Ae.current.useLayoutEffect(I,D)},Xe.useMemo=function(I,D){return Ae.current.useMemo(I,D)},Xe.useReducer=function(I,D,pe){return Ae.current.useReducer(I,D,pe)},Xe.useRef=function(I){return Ae.current.useRef(I)},Xe.useState=function(I){return Ae.current.useState(I)},Xe.useSyncExternalStore=function(I,D,pe){return Ae.current.useSyncExternalStore(I,D,pe)},Xe.useTransition=function(){return Ae.current.useTransition()},Xe.version="18.3.1",Xe}var Kh;function Hc(){return Kh||(Kh=1,sc.exports=Py()),sc.exports}/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -14,7 +14,7 @@ var Ty=Object.defineProperty;var Iy=(e,r,a)=>r in e?Ty(e,r,{enumerable:!0,config
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Yh;function $y(){if(Yh)return oa;Yh=1;var e=Hc(),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function d(p,m,y){var v,j={},x=null,S=null;y!==void 0&&(x=""+y),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(S=m.ref);for(v in m)i.call(m,v)&&!u.hasOwnProperty(v)&&(j[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)j[v]===void 0&&(j[v]=m[v]);return{$$typeof:r,type:p,key:x,ref:S,props:j,_owner:l.current}}return oa.Fragment=a,oa.jsx=d,oa.jsxs=d,oa}var Jh;function Py(){return Jh||(Jh=1,nc.exports=$y()),nc.exports}var n=Py(),f=Hc(),Ai={},sc={exports:{}},tn={},ac={exports:{}},ic={};/**
17
+ */var Gh;function _y(){if(Gh)return oa;Gh=1;var e=Hc(),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function d(p,m,y){var v,j={},x=null,S=null;y!==void 0&&(x=""+y),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(S=m.ref);for(v in m)i.call(m,v)&&!u.hasOwnProperty(v)&&(j[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)j[v]===void 0&&(j[v]=m[v]);return{$$typeof:r,type:p,key:x,ref:S,props:j,_owner:l.current}}return oa.Fragment=a,oa.jsx=d,oa.jsxs=d,oa}var Yh;function Ly(){return Yh||(Yh=1,rc.exports=_y()),rc.exports}var n=Ly(),f=Hc(),Ai={},ac={exports:{}},tn={},ic={exports:{}},oc={};/**
18
18
  * @license React
19
19
  * scheduler.production.min.js
20
20
  *
@@ -22,7 +22,7 @@ var Ty=Object.defineProperty;var Iy=(e,r,a)=>r in e?Ty(e,r,{enumerable:!0,config
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */var Qh;function _y(){return Qh||(Qh=1,(function(e){function r(Z,G){var J=Z.length;Z.push(G);e:for(;0<J;){var I=J-1>>>1,D=Z[I];if(0<l(D,G))Z[I]=G,Z[J]=D,J=I;else break e}}function a(Z){return Z.length===0?null:Z[0]}function i(Z){if(Z.length===0)return null;var G=Z[0],J=Z.pop();if(J!==G){Z[0]=J;e:for(var I=0,D=Z.length,pe=D>>>1;I<pe;){var de=2*(I+1)-1,$e=Z[de],ve=de+1,Y=Z[ve];if(0>l($e,J))ve<D&&0>l(Y,$e)?(Z[I]=Y,Z[ve]=J,I=ve):(Z[I]=$e,Z[de]=J,I=de);else if(ve<D&&0>l(Y,J))Z[I]=Y,Z[ve]=J,I=ve;else break e}}return G}function l(Z,G){var J=Z.sortIndex-G.sortIndex;return J!==0?J:Z.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],y=[],v=1,j=null,x=3,S=!1,N=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(Z){for(var G=a(y);G!==null;){if(G.callback===null)i(y);else if(G.startTime<=Z)i(y),G.sortIndex=G.expirationTime,r(m,G);else break;G=a(y)}}function T(Z){if(w=!1,$(Z),!N)if(a(m)!==null)N=!0,we(F);else{var G=a(y);G!==null&&Ae(T,G.startTime-Z)}}function F(Z,G){N=!1,w&&(w=!1,C(te),te=-1),S=!0;var J=x;try{for($(G),j=a(m);j!==null&&(!(j.expirationTime>G)||Z&&!z());){var I=j.callback;if(typeof I=="function"){j.callback=null,x=j.priorityLevel;var D=I(j.expirationTime<=G);G=e.unstable_now(),typeof D=="function"?j.callback=D:j===a(m)&&i(m),$(G)}else i(m);j=a(m)}if(j!==null)var pe=!0;else{var de=a(y);de!==null&&Ae(T,de.startTime-G),pe=!1}return pe}finally{j=null,x=J,S=!1}}var M=!1,B=null,te=-1,Q=5,_=-1;function z(){return!(e.unstable_now()-_<Q)}function V(){if(B!==null){var Z=e.unstable_now();_=Z;var G=!0;try{G=B(!0,Z)}finally{G?K():(M=!1,B=null)}}else M=!1}var K;if(typeof E=="function")K=function(){E(V)};else if(typeof MessageChannel<"u"){var le=new MessageChannel,me=le.port2;le.port1.onmessage=V,K=function(){me.postMessage(null)}}else K=function(){k(V,0)};function we(Z){B=Z,M||(M=!0,K())}function Ae(Z,G){te=k(function(){Z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){N||S||(N=!0,we(F))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return a(m)},e.unstable_next=function(Z){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var J=x;x=G;try{return Z()}finally{x=J}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,G){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var J=x;x=Z;try{return G()}finally{x=J}},e.unstable_scheduleCallback=function(Z,G,J){var I=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?I+J:I):J=I,Z){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=J+D,Z={id:v++,callback:G,priorityLevel:Z,startTime:J,expirationTime:D,sortIndex:-1},J>I?(Z.sortIndex=J,r(y,Z),a(m)===null&&Z===a(y)&&(w?(C(te),te=-1):w=!0,Ae(T,J-I))):(Z.sortIndex=D,r(m,Z),N||S||(N=!0,we(F))),Z},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(Z){var G=x;return function(){var J=x;x=G;try{return Z.apply(this,arguments)}finally{x=J}}}})(ic)),ic}var Xh;function Ly(){return Xh||(Xh=1,ac.exports=_y()),ac.exports}/**
25
+ */var Jh;function My(){return Jh||(Jh=1,(function(e){function r(Z,G){var J=Z.length;Z.push(G);e:for(;0<J;){var I=J-1>>>1,D=Z[I];if(0<l(D,G))Z[I]=G,Z[J]=D,J=I;else break e}}function a(Z){return Z.length===0?null:Z[0]}function i(Z){if(Z.length===0)return null;var G=Z[0],J=Z.pop();if(J!==G){Z[0]=J;e:for(var I=0,D=Z.length,pe=D>>>1;I<pe;){var de=2*(I+1)-1,$e=Z[de],ve=de+1,Y=Z[ve];if(0>l($e,J))ve<D&&0>l(Y,$e)?(Z[I]=Y,Z[ve]=J,I=ve):(Z[I]=$e,Z[de]=J,I=de);else if(ve<D&&0>l(Y,J))Z[I]=Y,Z[ve]=J,I=ve;else break e}}return G}function l(Z,G){var J=Z.sortIndex-G.sortIndex;return J!==0?J:Z.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],y=[],v=1,j=null,x=3,S=!1,N=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(Z){for(var G=a(y);G!==null;){if(G.callback===null)i(y);else if(G.startTime<=Z)i(y),G.sortIndex=G.expirationTime,r(m,G);else break;G=a(y)}}function T(Z){if(w=!1,$(Z),!N)if(a(m)!==null)N=!0,we(F);else{var G=a(y);G!==null&&Ae(T,G.startTime-Z)}}function F(Z,G){N=!1,w&&(w=!1,C(te),te=-1),S=!0;var J=x;try{for($(G),j=a(m);j!==null&&(!(j.expirationTime>G)||Z&&!z());){var I=j.callback;if(typeof I=="function"){j.callback=null,x=j.priorityLevel;var D=I(j.expirationTime<=G);G=e.unstable_now(),typeof D=="function"?j.callback=D:j===a(m)&&i(m),$(G)}else i(m);j=a(m)}if(j!==null)var pe=!0;else{var de=a(y);de!==null&&Ae(T,de.startTime-G),pe=!1}return pe}finally{j=null,x=J,S=!1}}var M=!1,B=null,te=-1,Q=5,_=-1;function z(){return!(e.unstable_now()-_<Q)}function V(){if(B!==null){var Z=e.unstable_now();_=Z;var G=!0;try{G=B(!0,Z)}finally{G?K():(M=!1,B=null)}}else M=!1}var K;if(typeof E=="function")K=function(){E(V)};else if(typeof MessageChannel<"u"){var le=new MessageChannel,me=le.port2;le.port1.onmessage=V,K=function(){me.postMessage(null)}}else K=function(){k(V,0)};function we(Z){B=Z,M||(M=!0,K())}function Ae(Z,G){te=k(function(){Z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){N||S||(N=!0,we(F))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return a(m)},e.unstable_next=function(Z){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var J=x;x=G;try{return Z()}finally{x=J}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,G){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var J=x;x=Z;try{return G()}finally{x=J}},e.unstable_scheduleCallback=function(Z,G,J){var I=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?I+J:I):J=I,Z){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=J+D,Z={id:v++,callback:G,priorityLevel:Z,startTime:J,expirationTime:D,sortIndex:-1},J>I?(Z.sortIndex=J,r(y,Z),a(m)===null&&Z===a(y)&&(w?(C(te),te=-1):w=!0,Ae(T,J-I))):(Z.sortIndex=D,r(m,Z),N||S||(N=!0,we(F))),Z},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(Z){var G=x;return function(){var J=x;x=G;try{return Z.apply(this,arguments)}finally{x=J}}}})(oc)),oc}var Qh;function Fy(){return Qh||(Qh=1,ic.exports=My()),ic.exports}/**
26
26
  * @license React
27
27
  * react-dom.production.min.js
28
28
  *
@@ -30,14 +30,14 @@ var Ty=Object.defineProperty;var Iy=(e,r,a)=>r in e?Ty(e,r,{enumerable:!0,config
30
30
  *
31
31
  * This source code is licensed under the MIT license found in the
32
32
  * LICENSE file in the root directory of this source tree.
33
- */var Zh;function My(){if(Zh)return tn;Zh=1;var e=Hc(),r=Ly();function a(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,l={};function u(t,s){d(t,s),d(t+"Capture",s)}function d(t,s){for(l[t]=s,t=0;t<s.length;t++)i.add(s[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},j={};function x(t){return m.call(j,t)?!0:m.call(v,t)?!1:y.test(t)?j[t]=!0:(v[t]=!0,!1)}function S(t,s,o,c){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function N(t,s,o,c){if(s===null||typeof s>"u"||S(t,s,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(t,s,o,c,h,g,b){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=c,this.attributeNamespace=h,this.mustUseProperty=o,this.propertyName=t,this.type=s,this.sanitizeURL=g,this.removeEmptyString=b}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){k[t]=new w(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];k[s]=new w(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){k[t]=new w(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){k[t]=new w(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){k[t]=new w(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){k[t]=new w(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){k[t]=new w(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){k[t]=new w(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){k[t]=new w(t,5,!1,t.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function E(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){k[t]=new w(t,1,!1,t.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){k[t]=new w(t,1,!1,t.toLowerCase(),null,!0,!0)});function $(t,s,o,c){var h=k.hasOwnProperty(s)?k[s]:null;(h!==null?h.type!==0:c||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(N(s,o,h,c)&&(o=null),c||h===null?x(s)&&(o===null?t.removeAttribute(s):t.setAttribute(s,""+o)):h.mustUseProperty?t[h.propertyName]=o===null?h.type===3?!1:"":o:(s=h.attributeName,c=h.attributeNamespace,o===null?t.removeAttribute(s):(h=h.type,o=h===3||h===4&&o===!0?"":""+o,c?t.setAttributeNS(c,s,o):t.setAttribute(s,o))))}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,F=Symbol.for("react.element"),M=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),z=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),le=Symbol.for("react.suspense_list"),me=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ae=Symbol.for("react.offscreen"),Z=Symbol.iterator;function G(t){return t===null||typeof t!="object"?null:(t=Z&&t[Z]||t["@@iterator"],typeof t=="function"?t:null)}var J=Object.assign,I;function D(t){if(I===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);I=s&&s[1]||""}return`
33
+ */var Xh;function Oy(){if(Xh)return tn;Xh=1;var e=Hc(),r=Fy();function a(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,l={};function u(t,s){d(t,s),d(t+"Capture",s)}function d(t,s){for(l[t]=s,t=0;t<s.length;t++)i.add(s[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},j={};function x(t){return m.call(j,t)?!0:m.call(v,t)?!1:y.test(t)?j[t]=!0:(v[t]=!0,!1)}function S(t,s,o,c){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function N(t,s,o,c){if(s===null||typeof s>"u"||S(t,s,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(t,s,o,c,h,g,b){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=c,this.attributeNamespace=h,this.mustUseProperty=o,this.propertyName=t,this.type=s,this.sanitizeURL=g,this.removeEmptyString=b}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){k[t]=new w(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];k[s]=new w(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){k[t]=new w(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){k[t]=new w(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){k[t]=new w(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){k[t]=new w(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){k[t]=new w(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){k[t]=new w(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){k[t]=new w(t,5,!1,t.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function E(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(C,E);k[s]=new w(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){k[t]=new w(t,1,!1,t.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){k[t]=new w(t,1,!1,t.toLowerCase(),null,!0,!0)});function $(t,s,o,c){var h=k.hasOwnProperty(s)?k[s]:null;(h!==null?h.type!==0:c||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(N(s,o,h,c)&&(o=null),c||h===null?x(s)&&(o===null?t.removeAttribute(s):t.setAttribute(s,""+o)):h.mustUseProperty?t[h.propertyName]=o===null?h.type===3?!1:"":o:(s=h.attributeName,c=h.attributeNamespace,o===null?t.removeAttribute(s):(h=h.type,o=h===3||h===4&&o===!0?"":""+o,c?t.setAttributeNS(c,s,o):t.setAttribute(s,o))))}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,F=Symbol.for("react.element"),M=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),z=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),le=Symbol.for("react.suspense_list"),me=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ae=Symbol.for("react.offscreen"),Z=Symbol.iterator;function G(t){return t===null||typeof t!="object"?null:(t=Z&&t[Z]||t["@@iterator"],typeof t=="function"?t:null)}var J=Object.assign,I;function D(t){if(I===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);I=s&&s[1]||""}return`
34
34
  `+I+t}var pe=!1;function de(t,s){if(!t||pe)return"";pe=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(q){var c=q}Reflect.construct(t,[],s)}else{try{s.call()}catch(q){c=q}t.call(s.prototype)}else{try{throw Error()}catch(q){c=q}t()}}catch(q){if(q&&c&&typeof q.stack=="string"){for(var h=q.stack.split(`
35
35
  `),g=c.stack.split(`
36
36
  `),b=h.length-1,A=g.length-1;1<=b&&0<=A&&h[b]!==g[A];)A--;for(;1<=b&&0<=A;b--,A--)if(h[b]!==g[A]){if(b!==1||A!==1)do if(b--,A--,0>A||h[b]!==g[A]){var R=`
37
- `+h[b].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=b&&0<=A);break}}}finally{pe=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?D(t):""}function $e(t){switch(t.tag){case 5:return D(t.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return t=de(t.type,!1),t;case 11:return t=de(t.type.render,!1),t;case 1:return t=de(t.type,!0),t;default:return""}}function ve(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case B:return"Fragment";case M:return"Portal";case Q:return"Profiler";case te:return"StrictMode";case K:return"Suspense";case le:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case z:return(t.displayName||"Context")+".Consumer";case _:return(t._context.displayName||"Context")+".Provider";case V:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case me:return s=t.displayName||null,s!==null?s:ve(t.type)||"Memo";case we:s=t._payload,t=t._init;try{return ve(t(s))}catch{}}return null}function Y(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(s);case 8:return s===te?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function he(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ee(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function oe(t){var s=ee(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),c=""+t[s];if(!t.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var h=o.get,g=o.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return h.call(this)},set:function(b){c=""+b,g.call(this,b)}}),Object.defineProperty(t,s,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(b){c=""+b},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function Oe(t){t._valueTracker||(t._valueTracker=oe(t))}function Fe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var o=s.getValue(),c="";return t&&(c=ee(t)?t.checked?"true":"false":t.value),t=c,t!==o?(s.setValue(t),!0):!1}function se(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Te(t,s){var o=s.checked;return J({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function _e(t,s){var o=s.defaultValue==null?"":s.defaultValue,c=s.checked!=null?s.checked:s.defaultChecked;o=he(s.value!=null?s.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Ve(t,s){s=s.checked,s!=null&&$(t,"checked",s,!1)}function Ge(t,s){Ve(t,s);var o=he(s.value),c=s.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?nt(t,s.type,o):s.hasOwnProperty("defaultValue")&&nt(t,s.type,he(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function ct(t,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var c=s.type;if(!(c!=="submit"&&c!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,o||s===t.value||(t.value=s),t.defaultValue=s}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function nt(t,s,o){(s!=="number"||se(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var Je=Array.isArray;function Be(t,s,o,c){if(t=t.options,s){s={};for(var h=0;h<o.length;h++)s["$"+o[h]]=!0;for(o=0;o<t.length;o++)h=s.hasOwnProperty("$"+t[o].value),t[o].selected!==h&&(t[o].selected=h),h&&c&&(t[o].defaultSelected=!0)}else{for(o=""+he(o),s=null,h=0;h<t.length;h++){if(t[h].value===o){t[h].selected=!0,c&&(t[h].defaultSelected=!0);return}s!==null||t[h].disabled||(s=t[h])}s!==null&&(s.selected=!0)}}function dt(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(a(91));return J({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function et(t,s){var o=s.value;if(o==null){if(o=s.children,s=s.defaultValue,o!=null){if(s!=null)throw Error(a(92));if(Je(o)){if(1<o.length)throw Error(a(93));o=o[0]}s=o}s==null&&(s=""),o=s}t._wrapperState={initialValue:he(o)}}function De(t,s){var o=he(s.value),c=he(s.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),s.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function Ie(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function We(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qe(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?We(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var ut,ye=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,o,c,h){MSApp.execUnsafeLocalFunction(function(){return t(s,o,c,h)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(ut=ut||document.createElement("div"),ut.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=ut.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function ze(t,s){if(s){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=s;return}}t.textContent=s}var Ye={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tt=["Webkit","ms","Moz","O"];Object.keys(Ye).forEach(function(t){tt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),Ye[s]=Ye[t]})});function st(t,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Ye.hasOwnProperty(t)&&Ye[t]?(""+s).trim():s+"px"}function ht(t,s){t=t.style;for(var o in s)if(s.hasOwnProperty(o)){var c=o.indexOf("--")===0,h=st(o,s[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,h):t[o]=h}}var jt=J({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qe(t,s){if(s){if(jt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(a(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(a(61))}if(s.style!=null&&typeof s.style!="object")throw Error(a(62))}}function H(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ge=null;function be(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var X=null,Ne=null,ke=null;function ue(t){if(t=Vs(t)){if(typeof X!="function")throw Error(a(280));var s=t.stateNode;s&&(s=Wa(s),X(t.stateNode,t.type,s))}}function He(t){Ne?ke?ke.push(t):ke=[t]:Ne=t}function kt(){if(Ne){var t=Ne,s=ke;if(ke=Ne=null,ue(t),s)for(t=0;t<s.length;t++)ue(s[t])}}function ne(t,s){return t(s)}function xe(){}var U=!1;function ie(t,s,o){if(U)return t(s,o);U=!0;try{return ne(t,s,o)}finally{U=!1,(Ne!==null||ke!==null)&&(xe(),kt())}}function Ee(t,s){var o=t.stateNode;if(o===null)return null;var c=Wa(o);if(c===null)return null;o=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(a(231,s,typeof o));return o}var it=!1;if(p)try{var ot={};Object.defineProperty(ot,"passive",{get:function(){it=!0}}),window.addEventListener("test",ot,ot),window.removeEventListener("test",ot,ot)}catch{it=!1}function zn(t,s,o,c,h,g,b,A,R){var q=Array.prototype.slice.call(arguments,3);try{s.apply(o,q)}catch(ae){this.onError(ae)}}var rn=!1,sn=null,Yt=!1,br=null,wo={onError:function(t){rn=!0,sn=t}};function ja(t,s,o,c,h,g,b,A,R){rn=!1,sn=null,zn.apply(wo,arguments)}function wa(t,s,o,c,h,g,b,A,R){if(ja.apply(this,arguments),rn){if(rn){var q=sn;rn=!1,sn=null}else throw Error(a(198));Yt||(Yt=!0,br=q)}}function Tn(t){var s=t,o=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(o=s.return),t=s.return;while(t)}return s.tag===3?o:null}function Cs(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function ba(t){if(Tn(t)!==t)throw Error(a(188))}function Wr(t){var s=t.alternate;if(!s){if(s=Tn(t),s===null)throw Error(a(188));return s!==t?null:t}for(var o=t,c=s;;){var h=o.return;if(h===null)break;var g=h.alternate;if(g===null){if(c=h.return,c!==null){o=c;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===o)return ba(h),t;if(g===c)return ba(h),s;g=g.sibling}throw Error(a(188))}if(o.return!==c.return)o=h,c=g;else{for(var b=!1,A=h.child;A;){if(A===o){b=!0,o=h,c=g;break}if(A===c){b=!0,c=h,o=g;break}A=A.sibling}if(!b){for(A=g.child;A;){if(A===o){b=!0,o=g,c=h;break}if(A===c){b=!0,c=g,o=h;break}A=A.sibling}if(!b)throw Error(a(189))}}if(o.alternate!==c)throw Error(a(190))}if(o.tag!==3)throw Error(a(188));return o.stateNode.current===o?t:s}function In(t){return t=Wr(t),t!==null?xu(t):null}function xu(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=xu(t);if(s!==null)return s;t=t.sibling}return null}var ju=r.unstable_scheduleCallback,wu=r.unstable_cancelCallback,Dg=r.unstable_shouldYield,Bg=r.unstable_requestPaint,Ct=r.unstable_now,Ug=r.unstable_getCurrentPriorityLevel,bo=r.unstable_ImmediatePriority,bu=r.unstable_UserBlockingPriority,ka=r.unstable_NormalPriority,Wg=r.unstable_LowPriority,ku=r.unstable_IdlePriority,Sa=null,Rn=null;function Hg(t){if(Rn&&typeof Rn.onCommitFiberRoot=="function")try{Rn.onCommitFiberRoot(Sa,t,void 0,(t.current.flags&128)===128)}catch{}}var xn=Math.clz32?Math.clz32:Kg,Vg=Math.log,qg=Math.LN2;function Kg(t){return t>>>=0,t===0?32:31-(Vg(t)/qg|0)|0}var Na=64,Ca=4194304;function Es(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ea(t,s){var o=t.pendingLanes;if(o===0)return 0;var c=0,h=t.suspendedLanes,g=t.pingedLanes,b=o&268435455;if(b!==0){var A=b&~h;A!==0?c=Es(A):(g&=b,g!==0&&(c=Es(g)))}else b=o&~h,b!==0?c=Es(b):g!==0&&(c=Es(g));if(c===0)return 0;if(s!==0&&s!==c&&(s&h)===0&&(h=c&-c,g=s&-s,h>=g||h===16&&(g&4194240)!==0))return s;if((c&4)!==0&&(c|=o&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=c;0<s;)o=31-xn(s),h=1<<o,c|=t[o],s&=~h;return c}function Gg(t,s){switch(t){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Yg(t,s){for(var o=t.suspendedLanes,c=t.pingedLanes,h=t.expirationTimes,g=t.pendingLanes;0<g;){var b=31-xn(g),A=1<<b,R=h[b];R===-1?((A&o)===0||(A&c)!==0)&&(h[b]=Gg(A,s)):R<=s&&(t.expiredLanes|=A),g&=~A}}function ko(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Su(){var t=Na;return Na<<=1,(Na&4194240)===0&&(Na=64),t}function So(t){for(var s=[],o=0;31>o;o++)s.push(t);return s}function As(t,s,o){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-xn(s),t[s]=o}function Jg(t,s){var o=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var h=31-xn(o),g=1<<h;s[h]=0,c[h]=-1,t[h]=-1,o&=~g}}function No(t,s){var o=t.entangledLanes|=s;for(t=t.entanglements;o;){var c=31-xn(o),h=1<<c;h&s|t[c]&s&&(t[c]|=s),o&=~h}}var lt=0;function Nu(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var Cu,Co,Eu,Au,Tu,Eo=!1,Aa=[],Zn=null,er=null,tr=null,Ts=new Map,Is=new Map,nr=[],Qg="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Iu(t,s){switch(t){case"focusin":case"focusout":Zn=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":Ts.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Is.delete(s.pointerId)}}function Rs(t,s,o,c,h,g){return t===null||t.nativeEvent!==g?(t={blockedOn:s,domEventName:o,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},s!==null&&(s=Vs(s),s!==null&&Co(s)),t):(t.eventSystemFlags|=c,s=t.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),t)}function Xg(t,s,o,c,h){switch(s){case"focusin":return Zn=Rs(Zn,t,s,o,c,h),!0;case"dragenter":return er=Rs(er,t,s,o,c,h),!0;case"mouseover":return tr=Rs(tr,t,s,o,c,h),!0;case"pointerover":var g=h.pointerId;return Ts.set(g,Rs(Ts.get(g)||null,t,s,o,c,h)),!0;case"gotpointercapture":return g=h.pointerId,Is.set(g,Rs(Is.get(g)||null,t,s,o,c,h)),!0}return!1}function Ru(t){var s=kr(t.target);if(s!==null){var o=Tn(s);if(o!==null){if(s=o.tag,s===13){if(s=Cs(o),s!==null){t.blockedOn=s,Tu(t.priority,function(){Eu(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ta(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var o=To(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);ge=c,o.target.dispatchEvent(c),ge=null}else return s=Vs(o),s!==null&&Co(s),t.blockedOn=o,!1;s.shift()}return!0}function $u(t,s,o){Ta(t)&&o.delete(s)}function Zg(){Eo=!1,Zn!==null&&Ta(Zn)&&(Zn=null),er!==null&&Ta(er)&&(er=null),tr!==null&&Ta(tr)&&(tr=null),Ts.forEach($u),Is.forEach($u)}function $s(t,s){t.blockedOn===s&&(t.blockedOn=null,Eo||(Eo=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Zg)))}function Ps(t){function s(h){return $s(h,t)}if(0<Aa.length){$s(Aa[0],t);for(var o=1;o<Aa.length;o++){var c=Aa[o];c.blockedOn===t&&(c.blockedOn=null)}}for(Zn!==null&&$s(Zn,t),er!==null&&$s(er,t),tr!==null&&$s(tr,t),Ts.forEach(s),Is.forEach(s),o=0;o<nr.length;o++)c=nr[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<nr.length&&(o=nr[0],o.blockedOn===null);)Ru(o),o.blockedOn===null&&nr.shift()}var Hr=T.ReactCurrentBatchConfig,Ia=!0;function ev(t,s,o,c){var h=lt,g=Hr.transition;Hr.transition=null;try{lt=1,Ao(t,s,o,c)}finally{lt=h,Hr.transition=g}}function tv(t,s,o,c){var h=lt,g=Hr.transition;Hr.transition=null;try{lt=4,Ao(t,s,o,c)}finally{lt=h,Hr.transition=g}}function Ao(t,s,o,c){if(Ia){var h=To(t,s,o,c);if(h===null)qo(t,s,c,Ra,o),Iu(t,c);else if(Xg(h,t,s,o,c))c.stopPropagation();else if(Iu(t,c),s&4&&-1<Qg.indexOf(t)){for(;h!==null;){var g=Vs(h);if(g!==null&&Cu(g),g=To(t,s,o,c),g===null&&qo(t,s,c,Ra,o),g===h)break;h=g}h!==null&&c.stopPropagation()}else qo(t,s,c,null,o)}}var Ra=null;function To(t,s,o,c){if(Ra=null,t=be(c),t=kr(t),t!==null)if(s=Tn(t),s===null)t=null;else if(o=s.tag,o===13){if(t=Cs(s),t!==null)return t;t=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return Ra=t,null}function Pu(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ug()){case bo:return 1;case bu:return 4;case ka:case Wg:return 16;case ku:return 536870912;default:return 16}default:return 16}}var rr=null,Io=null,$a=null;function _u(){if($a)return $a;var t,s=Io,o=s.length,c,h="value"in rr?rr.value:rr.textContent,g=h.length;for(t=0;t<o&&s[t]===h[t];t++);var b=o-t;for(c=1;c<=b&&s[o-c]===h[g-c];c++);return $a=h.slice(t,1<c?1-c:void 0)}function Pa(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function _a(){return!0}function Lu(){return!1}function an(t){function s(o,c,h,g,b){this._reactName=o,this._targetInst=h,this.type=c,this.nativeEvent=g,this.target=b,this.currentTarget=null;for(var A in t)t.hasOwnProperty(A)&&(o=t[A],this[A]=o?o(g):g[A]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?_a:Lu,this.isPropagationStopped=Lu,this}return J(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=_a)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=_a)},persist:function(){},isPersistent:_a}),s}var Vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ro=an(Vr),_s=J({},Vr,{view:0,detail:0}),nv=an(_s),$o,Po,Ls,La=J({},_s,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lo,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ls&&(Ls&&t.type==="mousemove"?($o=t.screenX-Ls.screenX,Po=t.screenY-Ls.screenY):Po=$o=0,Ls=t),$o)},movementY:function(t){return"movementY"in t?t.movementY:Po}}),Mu=an(La),rv=J({},La,{dataTransfer:0}),sv=an(rv),av=J({},_s,{relatedTarget:0}),_o=an(av),iv=J({},Vr,{animationName:0,elapsedTime:0,pseudoElement:0}),ov=an(iv),lv=J({},Vr,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),cv=an(lv),uv=J({},Vr,{data:0}),Fu=an(uv),dv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mv(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=fv[t])?!!s[t]:!1}function Lo(){return mv}var pv=J({},_s,{key:function(t){if(t.key){var s=dv[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=Pa(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?hv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lo,charCode:function(t){return t.type==="keypress"?Pa(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Pa(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),gv=an(pv),vv=J({},La,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ou=an(vv),yv=J({},_s,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lo}),xv=an(yv),jv=J({},Vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),wv=an(jv),bv=J({},La,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),kv=an(bv),Sv=[9,13,27,32],Mo=p&&"CompositionEvent"in window,Ms=null;p&&"documentMode"in document&&(Ms=document.documentMode);var Nv=p&&"TextEvent"in window&&!Ms,zu=p&&(!Mo||Ms&&8<Ms&&11>=Ms),Du=" ",Bu=!1;function Uu(t,s){switch(t){case"keyup":return Sv.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var qr=!1;function Cv(t,s){switch(t){case"compositionend":return Wu(s);case"keypress":return s.which!==32?null:(Bu=!0,Du);case"textInput":return t=s.data,t===Du&&Bu?null:t;default:return null}}function Ev(t,s){if(qr)return t==="compositionend"||!Mo&&Uu(t,s)?(t=_u(),$a=Io=rr=null,qr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return zu&&s.locale!=="ko"?null:s.data;default:return null}}var Av={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hu(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!Av[t.type]:s==="textarea"}function Vu(t,s,o,c){He(c),s=Da(s,"onChange"),0<s.length&&(o=new Ro("onChange","change",null,o,c),t.push({event:o,listeners:s}))}var Fs=null,Os=null;function Tv(t){cd(t,0)}function Ma(t){var s=Qr(t);if(Fe(s))return t}function Iv(t,s){if(t==="change")return s}var qu=!1;if(p){var Fo;if(p){var Oo="oninput"in document;if(!Oo){var Ku=document.createElement("div");Ku.setAttribute("oninput","return;"),Oo=typeof Ku.oninput=="function"}Fo=Oo}else Fo=!1;qu=Fo&&(!document.documentMode||9<document.documentMode)}function Gu(){Fs&&(Fs.detachEvent("onpropertychange",Yu),Os=Fs=null)}function Yu(t){if(t.propertyName==="value"&&Ma(Os)){var s=[];Vu(s,Os,t,be(t)),ie(Tv,s)}}function Rv(t,s,o){t==="focusin"?(Gu(),Fs=s,Os=o,Fs.attachEvent("onpropertychange",Yu)):t==="focusout"&&Gu()}function $v(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Ma(Os)}function Pv(t,s){if(t==="click")return Ma(s)}function _v(t,s){if(t==="input"||t==="change")return Ma(s)}function Lv(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var jn=typeof Object.is=="function"?Object.is:Lv;function zs(t,s){if(jn(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var o=Object.keys(t),c=Object.keys(s);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var h=o[c];if(!m.call(s,h)||!jn(t[h],s[h]))return!1}return!0}function Ju(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Qu(t,s){var o=Ju(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=s&&c>=s)return{node:o,offset:s-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Ju(o)}}function Xu(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?Xu(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function Zu(){for(var t=window,s=se();s instanceof t.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)t=s.contentWindow;else break;s=se(t.document)}return s}function zo(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function Mv(t){var s=Zu(),o=t.focusedElem,c=t.selectionRange;if(s!==o&&o&&o.ownerDocument&&Xu(o.ownerDocument.documentElement,o)){if(c!==null&&zo(o)){if(s=c.start,t=c.end,t===void 0&&(t=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(t,o.value.length);else if(t=(s=o.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var h=o.textContent.length,g=Math.min(c.start,h);c=c.end===void 0?g:Math.min(c.end,h),!t.extend&&g>c&&(h=c,c=g,g=h),h=Qu(o,g);var b=Qu(o,c);h&&b&&(t.rangeCount!==1||t.anchorNode!==h.node||t.anchorOffset!==h.offset||t.focusNode!==b.node||t.focusOffset!==b.offset)&&(s=s.createRange(),s.setStart(h.node,h.offset),t.removeAllRanges(),g>c?(t.addRange(s),t.extend(b.node,b.offset)):(s.setEnd(b.node,b.offset),t.addRange(s)))}}for(s=[],t=o;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<s.length;o++)t=s[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Fv=p&&"documentMode"in document&&11>=document.documentMode,Kr=null,Do=null,Ds=null,Bo=!1;function ed(t,s,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Bo||Kr==null||Kr!==se(c)||(c=Kr,"selectionStart"in c&&zo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Ds&&zs(Ds,c)||(Ds=c,c=Da(Do,"onSelect"),0<c.length&&(s=new Ro("onSelect","select",null,s,o),t.push({event:s,listeners:c}),s.target=Kr)))}function Fa(t,s){var o={};return o[t.toLowerCase()]=s.toLowerCase(),o["Webkit"+t]="webkit"+s,o["Moz"+t]="moz"+s,o}var Gr={animationend:Fa("Animation","AnimationEnd"),animationiteration:Fa("Animation","AnimationIteration"),animationstart:Fa("Animation","AnimationStart"),transitionend:Fa("Transition","TransitionEnd")},Uo={},td={};p&&(td=document.createElement("div").style,"AnimationEvent"in window||(delete Gr.animationend.animation,delete Gr.animationiteration.animation,delete Gr.animationstart.animation),"TransitionEvent"in window||delete Gr.transitionend.transition);function Oa(t){if(Uo[t])return Uo[t];if(!Gr[t])return t;var s=Gr[t],o;for(o in s)if(s.hasOwnProperty(o)&&o in td)return Uo[t]=s[o];return t}var nd=Oa("animationend"),rd=Oa("animationiteration"),sd=Oa("animationstart"),ad=Oa("transitionend"),id=new Map,od="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function sr(t,s){id.set(t,s),u(s,[t])}for(var Wo=0;Wo<od.length;Wo++){var Ho=od[Wo],Ov=Ho.toLowerCase(),zv=Ho[0].toUpperCase()+Ho.slice(1);sr(Ov,"on"+zv)}sr(nd,"onAnimationEnd"),sr(rd,"onAnimationIteration"),sr(sd,"onAnimationStart"),sr("dblclick","onDoubleClick"),sr("focusin","onFocus"),sr("focusout","onBlur"),sr(ad,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Dv=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bs));function ld(t,s,o){var c=t.type||"unknown-event";t.currentTarget=o,wa(c,s,void 0,t),t.currentTarget=null}function cd(t,s){s=(s&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],h=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var b=c.length-1;0<=b;b--){var A=c[b],R=A.instance,q=A.currentTarget;if(A=A.listener,R!==g&&h.isPropagationStopped())break e;ld(h,A,q),g=R}else for(b=0;b<c.length;b++){if(A=c[b],R=A.instance,q=A.currentTarget,A=A.listener,R!==g&&h.isPropagationStopped())break e;ld(h,A,q),g=R}}}if(Yt)throw t=br,Yt=!1,br=null,t}function gt(t,s){var o=s[Xo];o===void 0&&(o=s[Xo]=new Set);var c=t+"__bubble";o.has(c)||(ud(s,t,2,!1),o.add(c))}function Vo(t,s,o){var c=0;s&&(c|=4),ud(o,t,c,s)}var za="_reactListening"+Math.random().toString(36).slice(2);function Us(t){if(!t[za]){t[za]=!0,i.forEach(function(o){o!=="selectionchange"&&(Dv.has(o)||Vo(o,!1,t),Vo(o,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[za]||(s[za]=!0,Vo("selectionchange",!1,s))}}function ud(t,s,o,c){switch(Pu(s)){case 1:var h=ev;break;case 4:h=tv;break;default:h=Ao}o=h.bind(null,s,o,t),h=void 0,!it||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),c?h!==void 0?t.addEventListener(s,o,{capture:!0,passive:h}):t.addEventListener(s,o,!0):h!==void 0?t.addEventListener(s,o,{passive:h}):t.addEventListener(s,o,!1)}function qo(t,s,o,c,h){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var A=c.stateNode.containerInfo;if(A===h||A.nodeType===8&&A.parentNode===h)break;if(b===4)for(b=c.return;b!==null;){var R=b.tag;if((R===3||R===4)&&(R=b.stateNode.containerInfo,R===h||R.nodeType===8&&R.parentNode===h))return;b=b.return}for(;A!==null;){if(b=kr(A),b===null)return;if(R=b.tag,R===5||R===6){c=g=b;continue e}A=A.parentNode}}c=c.return}ie(function(){var q=g,ae=be(o),ce=[];e:{var re=id.get(t);if(re!==void 0){var je=Ro,Ce=t;switch(t){case"keypress":if(Pa(o)===0)break e;case"keydown":case"keyup":je=gv;break;case"focusin":Ce="focus",je=_o;break;case"focusout":Ce="blur",je=_o;break;case"beforeblur":case"afterblur":je=_o;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=Mu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=sv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=xv;break;case nd:case rd:case sd:je=ov;break;case ad:je=wv;break;case"scroll":je=nv;break;case"wheel":je=kv;break;case"copy":case"cut":case"paste":je=cv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Ou}var Re=(s&4)!==0,Et=!Re&&t==="scroll",O=Re?re!==null?re+"Capture":null:re;Re=[];for(var L=q,W;L!==null;){W=L;var fe=W.stateNode;if(W.tag===5&&fe!==null&&(W=fe,O!==null&&(fe=Ee(L,O),fe!=null&&Re.push(Ws(L,fe,W)))),Et)break;L=L.return}0<Re.length&&(re=new je(re,Ce,null,o,ae),ce.push({event:re,listeners:Re}))}}if((s&7)===0){e:{if(re=t==="mouseover"||t==="pointerover",je=t==="mouseout"||t==="pointerout",re&&o!==ge&&(Ce=o.relatedTarget||o.fromElement)&&(kr(Ce)||Ce[Dn]))break e;if((je||re)&&(re=ae.window===ae?ae:(re=ae.ownerDocument)?re.defaultView||re.parentWindow:window,je?(Ce=o.relatedTarget||o.toElement,je=q,Ce=Ce?kr(Ce):null,Ce!==null&&(Et=Tn(Ce),Ce!==Et||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(je=null,Ce=q),je!==Ce)){if(Re=Mu,fe="onMouseLeave",O="onMouseEnter",L="mouse",(t==="pointerout"||t==="pointerover")&&(Re=Ou,fe="onPointerLeave",O="onPointerEnter",L="pointer"),Et=je==null?re:Qr(je),W=Ce==null?re:Qr(Ce),re=new Re(fe,L+"leave",je,o,ae),re.target=Et,re.relatedTarget=W,fe=null,kr(ae)===q&&(Re=new Re(O,L+"enter",Ce,o,ae),Re.target=W,Re.relatedTarget=Et,fe=Re),Et=fe,je&&Ce)t:{for(Re=je,O=Ce,L=0,W=Re;W;W=Yr(W))L++;for(W=0,fe=O;fe;fe=Yr(fe))W++;for(;0<L-W;)Re=Yr(Re),L--;for(;0<W-L;)O=Yr(O),W--;for(;L--;){if(Re===O||O!==null&&Re===O.alternate)break t;Re=Yr(Re),O=Yr(O)}Re=null}else Re=null;je!==null&&dd(ce,re,je,Re,!1),Ce!==null&&Et!==null&&dd(ce,Et,Ce,Re,!0)}}e:{if(re=q?Qr(q):window,je=re.nodeName&&re.nodeName.toLowerCase(),je==="select"||je==="input"&&re.type==="file")var Pe=Iv;else if(Hu(re))if(qu)Pe=_v;else{Pe=$v;var Le=Rv}else(je=re.nodeName)&&je.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Pe=Pv);if(Pe&&(Pe=Pe(t,q))){Vu(ce,Pe,o,ae);break e}Le&&Le(t,re,q),t==="focusout"&&(Le=re._wrapperState)&&Le.controlled&&re.type==="number"&&nt(re,"number",re.value)}switch(Le=q?Qr(q):window,t){case"focusin":(Hu(Le)||Le.contentEditable==="true")&&(Kr=Le,Do=q,Ds=null);break;case"focusout":Ds=Do=Kr=null;break;case"mousedown":Bo=!0;break;case"contextmenu":case"mouseup":case"dragend":Bo=!1,ed(ce,o,ae);break;case"selectionchange":if(Fv)break;case"keydown":case"keyup":ed(ce,o,ae)}var Me;if(Mo)e:{switch(t){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else qr?Uu(t,o)&&(Ue="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(Ue="onCompositionStart");Ue&&(zu&&o.locale!=="ko"&&(qr||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&qr&&(Me=_u()):(rr=ae,Io="value"in rr?rr.value:rr.textContent,qr=!0)),Le=Da(q,Ue),0<Le.length&&(Ue=new Fu(Ue,t,null,o,ae),ce.push({event:Ue,listeners:Le}),Me?Ue.data=Me:(Me=Wu(o),Me!==null&&(Ue.data=Me)))),(Me=Nv?Cv(t,o):Ev(t,o))&&(q=Da(q,"onBeforeInput"),0<q.length&&(ae=new Fu("onBeforeInput","beforeinput",null,o,ae),ce.push({event:ae,listeners:q}),ae.data=Me))}cd(ce,s)})}function Ws(t,s,o){return{instance:t,listener:s,currentTarget:o}}function Da(t,s){for(var o=s+"Capture",c=[];t!==null;){var h=t,g=h.stateNode;h.tag===5&&g!==null&&(h=g,g=Ee(t,o),g!=null&&c.unshift(Ws(t,g,h)),g=Ee(t,s),g!=null&&c.push(Ws(t,g,h))),t=t.return}return c}function Yr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function dd(t,s,o,c,h){for(var g=s._reactName,b=[];o!==null&&o!==c;){var A=o,R=A.alternate,q=A.stateNode;if(R!==null&&R===c)break;A.tag===5&&q!==null&&(A=q,h?(R=Ee(o,g),R!=null&&b.unshift(Ws(o,R,A))):h||(R=Ee(o,g),R!=null&&b.push(Ws(o,R,A)))),o=o.return}b.length!==0&&t.push({event:s,listeners:b})}var Bv=/\r\n?/g,Uv=/\u0000|\uFFFD/g;function hd(t){return(typeof t=="string"?t:""+t).replace(Bv,`
38
- `).replace(Uv,"")}function Ba(t,s,o){if(s=hd(s),hd(t)!==s&&o)throw Error(a(425))}function Ua(){}var Ko=null,Go=null;function Yo(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Jo=typeof setTimeout=="function"?setTimeout:void 0,Wv=typeof clearTimeout=="function"?clearTimeout:void 0,fd=typeof Promise=="function"?Promise:void 0,Hv=typeof queueMicrotask=="function"?queueMicrotask:typeof fd<"u"?function(t){return fd.resolve(null).then(t).catch(Vv)}:Jo;function Vv(t){setTimeout(function(){throw t})}function Qo(t,s){var o=s,c=0;do{var h=o.nextSibling;if(t.removeChild(o),h&&h.nodeType===8)if(o=h.data,o==="/$"){if(c===0){t.removeChild(h),Ps(s);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=h}while(o);Ps(s)}function ar(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function md(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(s===0)return t;s--}else o==="/$"&&s++}t=t.previousSibling}return null}var Jr=Math.random().toString(36).slice(2),$n="__reactFiber$"+Jr,Hs="__reactProps$"+Jr,Dn="__reactContainer$"+Jr,Xo="__reactEvents$"+Jr,qv="__reactListeners$"+Jr,Kv="__reactHandles$"+Jr;function kr(t){var s=t[$n];if(s)return s;for(var o=t.parentNode;o;){if(s=o[Dn]||o[$n]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(t=md(t);t!==null;){if(o=t[$n])return o;t=md(t)}return s}t=o,o=t.parentNode}return null}function Vs(t){return t=t[$n]||t[Dn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Qr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Wa(t){return t[Hs]||null}var Zo=[],Xr=-1;function ir(t){return{current:t}}function vt(t){0>Xr||(t.current=Zo[Xr],Zo[Xr]=null,Xr--)}function ft(t,s){Xr++,Zo[Xr]=t.current,t.current=s}var or={},Dt=ir(or),Jt=ir(!1),Sr=or;function Zr(t,s){var o=t.type.contextTypes;if(!o)return or;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===s)return c.__reactInternalMemoizedMaskedChildContext;var h={},g;for(g in o)h[g]=s[g];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=h),h}function Qt(t){return t=t.childContextTypes,t!=null}function Ha(){vt(Jt),vt(Dt)}function pd(t,s,o){if(Dt.current!==or)throw Error(a(168));ft(Dt,s),ft(Jt,o)}function gd(t,s,o){var c=t.stateNode;if(s=s.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var h in c)if(!(h in s))throw Error(a(108,Y(t)||"Unknown",h));return J({},o,c)}function Va(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||or,Sr=Dt.current,ft(Dt,t),ft(Jt,Jt.current),!0}function vd(t,s,o){var c=t.stateNode;if(!c)throw Error(a(169));o?(t=gd(t,s,Sr),c.__reactInternalMemoizedMergedChildContext=t,vt(Jt),vt(Dt),ft(Dt,t)):vt(Jt),ft(Jt,o)}var Bn=null,qa=!1,el=!1;function yd(t){Bn===null?Bn=[t]:Bn.push(t)}function Gv(t){qa=!0,yd(t)}function lr(){if(!el&&Bn!==null){el=!0;var t=0,s=lt;try{var o=Bn;for(lt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}Bn=null,qa=!1}catch(h){throw Bn!==null&&(Bn=Bn.slice(t+1)),ju(bo,lr),h}finally{lt=s,el=!1}}return null}var es=[],ts=0,Ka=null,Ga=0,dn=[],hn=0,Nr=null,Un=1,Wn="";function Cr(t,s){es[ts++]=Ga,es[ts++]=Ka,Ka=t,Ga=s}function xd(t,s,o){dn[hn++]=Un,dn[hn++]=Wn,dn[hn++]=Nr,Nr=t;var c=Un;t=Wn;var h=32-xn(c)-1;c&=~(1<<h),o+=1;var g=32-xn(s)+h;if(30<g){var b=h-h%5;g=(c&(1<<b)-1).toString(32),c>>=b,h-=b,Un=1<<32-xn(s)+h|o<<h|c,Wn=g+t}else Un=1<<g|o<<h|c,Wn=t}function tl(t){t.return!==null&&(Cr(t,1),xd(t,1,0))}function nl(t){for(;t===Ka;)Ka=es[--ts],es[ts]=null,Ga=es[--ts],es[ts]=null;for(;t===Nr;)Nr=dn[--hn],dn[hn]=null,Wn=dn[--hn],dn[hn]=null,Un=dn[--hn],dn[hn]=null}var on=null,ln=null,yt=!1,wn=null;function jd(t,s){var o=gn(5,null,null,0);o.elementType="DELETED",o.stateNode=s,o.return=t,s=t.deletions,s===null?(t.deletions=[o],t.flags|=16):s.push(o)}function wd(t,s){switch(t.tag){case 5:var o=t.type;return s=s.nodeType!==1||o.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,on=t,ln=ar(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,on=t,ln=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(o=Nr!==null?{id:Un,overflow:Wn}:null,t.memoizedState={dehydrated:s,treeContext:o,retryLane:1073741824},o=gn(18,null,null,0),o.stateNode=s,o.return=t,t.child=o,on=t,ln=null,!0):!1;default:return!1}}function rl(t){return(t.mode&1)!==0&&(t.flags&128)===0}function sl(t){if(yt){var s=ln;if(s){var o=s;if(!wd(t,s)){if(rl(t))throw Error(a(418));s=ar(o.nextSibling);var c=on;s&&wd(t,s)?jd(c,o):(t.flags=t.flags&-4097|2,yt=!1,on=t)}}else{if(rl(t))throw Error(a(418));t.flags=t.flags&-4097|2,yt=!1,on=t}}}function bd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;on=t}function Ya(t){if(t!==on)return!1;if(!yt)return bd(t),yt=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!Yo(t.type,t.memoizedProps)),s&&(s=ln)){if(rl(t))throw kd(),Error(a(418));for(;s;)jd(t,s),s=ar(s.nextSibling)}if(bd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(s===0){ln=ar(t.nextSibling);break e}s--}else o!=="$"&&o!=="$!"&&o!=="$?"||s++}t=t.nextSibling}ln=null}}else ln=on?ar(t.stateNode.nextSibling):null;return!0}function kd(){for(var t=ln;t;)t=ar(t.nextSibling)}function ns(){ln=on=null,yt=!1}function al(t){wn===null?wn=[t]:wn.push(t)}var Yv=T.ReactCurrentBatchConfig;function qs(t,s,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(a(309));var c=o.stateNode}if(!c)throw Error(a(147,t));var h=c,g=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===g?s.ref:(s=function(b){var A=h.refs;b===null?delete A[g]:A[g]=b},s._stringRef=g,s)}if(typeof t!="string")throw Error(a(284));if(!o._owner)throw Error(a(290,t))}return t}function Ja(t,s){throw t=Object.prototype.toString.call(s),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function Sd(t){var s=t._init;return s(t._payload)}function Nd(t){function s(O,L){if(t){var W=O.deletions;W===null?(O.deletions=[L],O.flags|=16):W.push(L)}}function o(O,L){if(!t)return null;for(;L!==null;)s(O,L),L=L.sibling;return null}function c(O,L){for(O=new Map;L!==null;)L.key!==null?O.set(L.key,L):O.set(L.index,L),L=L.sibling;return O}function h(O,L){return O=gr(O,L),O.index=0,O.sibling=null,O}function g(O,L,W){return O.index=W,t?(W=O.alternate,W!==null?(W=W.index,W<L?(O.flags|=2,L):W):(O.flags|=2,L)):(O.flags|=1048576,L)}function b(O){return t&&O.alternate===null&&(O.flags|=2),O}function A(O,L,W,fe){return L===null||L.tag!==6?(L=Jl(W,O.mode,fe),L.return=O,L):(L=h(L,W),L.return=O,L)}function R(O,L,W,fe){var Pe=W.type;return Pe===B?ae(O,L,W.props.children,fe,W.key):L!==null&&(L.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===we&&Sd(Pe)===L.type)?(fe=h(L,W.props),fe.ref=qs(O,L,W),fe.return=O,fe):(fe=ji(W.type,W.key,W.props,null,O.mode,fe),fe.ref=qs(O,L,W),fe.return=O,fe)}function q(O,L,W,fe){return L===null||L.tag!==4||L.stateNode.containerInfo!==W.containerInfo||L.stateNode.implementation!==W.implementation?(L=Ql(W,O.mode,fe),L.return=O,L):(L=h(L,W.children||[]),L.return=O,L)}function ae(O,L,W,fe,Pe){return L===null||L.tag!==7?(L=_r(W,O.mode,fe,Pe),L.return=O,L):(L=h(L,W),L.return=O,L)}function ce(O,L,W){if(typeof L=="string"&&L!==""||typeof L=="number")return L=Jl(""+L,O.mode,W),L.return=O,L;if(typeof L=="object"&&L!==null){switch(L.$$typeof){case F:return W=ji(L.type,L.key,L.props,null,O.mode,W),W.ref=qs(O,null,L),W.return=O,W;case M:return L=Ql(L,O.mode,W),L.return=O,L;case we:var fe=L._init;return ce(O,fe(L._payload),W)}if(Je(L)||G(L))return L=_r(L,O.mode,W,null),L.return=O,L;Ja(O,L)}return null}function re(O,L,W,fe){var Pe=L!==null?L.key:null;if(typeof W=="string"&&W!==""||typeof W=="number")return Pe!==null?null:A(O,L,""+W,fe);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case F:return W.key===Pe?R(O,L,W,fe):null;case M:return W.key===Pe?q(O,L,W,fe):null;case we:return Pe=W._init,re(O,L,Pe(W._payload),fe)}if(Je(W)||G(W))return Pe!==null?null:ae(O,L,W,fe,null);Ja(O,W)}return null}function je(O,L,W,fe,Pe){if(typeof fe=="string"&&fe!==""||typeof fe=="number")return O=O.get(W)||null,A(L,O,""+fe,Pe);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case F:return O=O.get(fe.key===null?W:fe.key)||null,R(L,O,fe,Pe);case M:return O=O.get(fe.key===null?W:fe.key)||null,q(L,O,fe,Pe);case we:var Le=fe._init;return je(O,L,W,Le(fe._payload),Pe)}if(Je(fe)||G(fe))return O=O.get(W)||null,ae(L,O,fe,Pe,null);Ja(L,fe)}return null}function Ce(O,L,W,fe){for(var Pe=null,Le=null,Me=L,Ue=L=0,Lt=null;Me!==null&&Ue<W.length;Ue++){Me.index>Ue?(Lt=Me,Me=null):Lt=Me.sibling;var at=re(O,Me,W[Ue],fe);if(at===null){Me===null&&(Me=Lt);break}t&&Me&&at.alternate===null&&s(O,Me),L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at,Me=Lt}if(Ue===W.length)return o(O,Me),yt&&Cr(O,Ue),Pe;if(Me===null){for(;Ue<W.length;Ue++)Me=ce(O,W[Ue],fe),Me!==null&&(L=g(Me,L,Ue),Le===null?Pe=Me:Le.sibling=Me,Le=Me);return yt&&Cr(O,Ue),Pe}for(Me=c(O,Me);Ue<W.length;Ue++)Lt=je(Me,O,Ue,W[Ue],fe),Lt!==null&&(t&&Lt.alternate!==null&&Me.delete(Lt.key===null?Ue:Lt.key),L=g(Lt,L,Ue),Le===null?Pe=Lt:Le.sibling=Lt,Le=Lt);return t&&Me.forEach(function(vr){return s(O,vr)}),yt&&Cr(O,Ue),Pe}function Re(O,L,W,fe){var Pe=G(W);if(typeof Pe!="function")throw Error(a(150));if(W=Pe.call(W),W==null)throw Error(a(151));for(var Le=Pe=null,Me=L,Ue=L=0,Lt=null,at=W.next();Me!==null&&!at.done;Ue++,at=W.next()){Me.index>Ue?(Lt=Me,Me=null):Lt=Me.sibling;var vr=re(O,Me,at.value,fe);if(vr===null){Me===null&&(Me=Lt);break}t&&Me&&vr.alternate===null&&s(O,Me),L=g(vr,L,Ue),Le===null?Pe=vr:Le.sibling=vr,Le=vr,Me=Lt}if(at.done)return o(O,Me),yt&&Cr(O,Ue),Pe;if(Me===null){for(;!at.done;Ue++,at=W.next())at=ce(O,at.value,fe),at!==null&&(L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at);return yt&&Cr(O,Ue),Pe}for(Me=c(O,Me);!at.done;Ue++,at=W.next())at=je(Me,O,Ue,at.value,fe),at!==null&&(t&&at.alternate!==null&&Me.delete(at.key===null?Ue:at.key),L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at);return t&&Me.forEach(function(Ay){return s(O,Ay)}),yt&&Cr(O,Ue),Pe}function Et(O,L,W,fe){if(typeof W=="object"&&W!==null&&W.type===B&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case F:e:{for(var Pe=W.key,Le=L;Le!==null;){if(Le.key===Pe){if(Pe=W.type,Pe===B){if(Le.tag===7){o(O,Le.sibling),L=h(Le,W.props.children),L.return=O,O=L;break e}}else if(Le.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===we&&Sd(Pe)===Le.type){o(O,Le.sibling),L=h(Le,W.props),L.ref=qs(O,Le,W),L.return=O,O=L;break e}o(O,Le);break}else s(O,Le);Le=Le.sibling}W.type===B?(L=_r(W.props.children,O.mode,fe,W.key),L.return=O,O=L):(fe=ji(W.type,W.key,W.props,null,O.mode,fe),fe.ref=qs(O,L,W),fe.return=O,O=fe)}return b(O);case M:e:{for(Le=W.key;L!==null;){if(L.key===Le)if(L.tag===4&&L.stateNode.containerInfo===W.containerInfo&&L.stateNode.implementation===W.implementation){o(O,L.sibling),L=h(L,W.children||[]),L.return=O,O=L;break e}else{o(O,L);break}else s(O,L);L=L.sibling}L=Ql(W,O.mode,fe),L.return=O,O=L}return b(O);case we:return Le=W._init,Et(O,L,Le(W._payload),fe)}if(Je(W))return Ce(O,L,W,fe);if(G(W))return Re(O,L,W,fe);Ja(O,W)}return typeof W=="string"&&W!==""||typeof W=="number"?(W=""+W,L!==null&&L.tag===6?(o(O,L.sibling),L=h(L,W),L.return=O,O=L):(o(O,L),L=Jl(W,O.mode,fe),L.return=O,O=L),b(O)):o(O,L)}return Et}var rs=Nd(!0),Cd=Nd(!1),Qa=ir(null),Xa=null,ss=null,il=null;function ol(){il=ss=Xa=null}function ll(t){var s=Qa.current;vt(Qa),t._currentValue=s}function cl(t,s,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),t===o)break;t=t.return}}function as(t,s){Xa=t,il=ss=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(Xt=!0),t.firstContext=null)}function fn(t){var s=t._currentValue;if(il!==t)if(t={context:t,memoizedValue:s,next:null},ss===null){if(Xa===null)throw Error(a(308));ss=t,Xa.dependencies={lanes:0,firstContext:t}}else ss=ss.next=t;return s}var Er=null;function ul(t){Er===null?Er=[t]:Er.push(t)}function Ed(t,s,o,c){var h=s.interleaved;return h===null?(o.next=o,ul(s)):(o.next=h.next,h.next=o),s.interleaved=o,Hn(t,c)}function Hn(t,s){t.lanes|=s;var o=t.alternate;for(o!==null&&(o.lanes|=s),o=t,t=t.return;t!==null;)t.childLanes|=s,o=t.alternate,o!==null&&(o.childLanes|=s),o=t,t=t.return;return o.tag===3?o.stateNode:null}var cr=!1;function dl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ad(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Vn(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function ur(t,s,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(rt&2)!==0){var h=c.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),c.pending=s,Hn(t,o)}return h=c.interleaved,h===null?(s.next=s,ul(c)):(s.next=h.next,h.next=s),c.interleaved=s,Hn(t,o)}function Za(t,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,No(t,o)}}function Td(t,s){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var h=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var b={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};g===null?h=g=b:g=g.next=b,o=o.next}while(o!==null);g===null?h=g=s:g=g.next=s}else h=g=s;o={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:g,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=s:t.next=s,o.lastBaseUpdate=s}function ei(t,s,o,c){var h=t.updateQueue;cr=!1;var g=h.firstBaseUpdate,b=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var R=A,q=R.next;R.next=null,b===null?g=q:b.next=q,b=R;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,A=ae.lastBaseUpdate,A!==b&&(A===null?ae.firstBaseUpdate=q:A.next=q,ae.lastBaseUpdate=R))}if(g!==null){var ce=h.baseState;b=0,ae=q=R=null,A=g;do{var re=A.lane,je=A.eventTime;if((c&re)===re){ae!==null&&(ae=ae.next={eventTime:je,lane:0,tag:A.tag,payload:A.payload,callback:A.callback,next:null});e:{var Ce=t,Re=A;switch(re=s,je=o,Re.tag){case 1:if(Ce=Re.payload,typeof Ce=="function"){ce=Ce.call(je,ce,re);break e}ce=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Re.payload,re=typeof Ce=="function"?Ce.call(je,ce,re):Ce,re==null)break e;ce=J({},ce,re);break e;case 2:cr=!0}}A.callback!==null&&A.lane!==0&&(t.flags|=64,re=h.effects,re===null?h.effects=[A]:re.push(A))}else je={eventTime:je,lane:re,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ae===null?(q=ae=je,R=ce):ae=ae.next=je,b|=re;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;re=A,A=re.next,re.next=null,h.lastBaseUpdate=re,h.shared.pending=null}}while(!0);if(ae===null&&(R=ce),h.baseState=R,h.firstBaseUpdate=q,h.lastBaseUpdate=ae,s=h.shared.interleaved,s!==null){h=s;do b|=h.lane,h=h.next;while(h!==s)}else g===null&&(h.shared.lanes=0);Ir|=b,t.lanes=b,t.memoizedState=ce}}function Id(t,s,o){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var c=t[s],h=c.callback;if(h!==null){if(c.callback=null,c=o,typeof h!="function")throw Error(a(191,h));h.call(c)}}}var Ks={},Pn=ir(Ks),Gs=ir(Ks),Ys=ir(Ks);function Ar(t){if(t===Ks)throw Error(a(174));return t}function hl(t,s){switch(ft(Ys,s),ft(Gs,t),ft(Pn,Ks),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Qe(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=Qe(s,t)}vt(Pn),ft(Pn,s)}function is(){vt(Pn),vt(Gs),vt(Ys)}function Rd(t){Ar(Ys.current);var s=Ar(Pn.current),o=Qe(s,t.type);s!==o&&(ft(Gs,t),ft(Pn,o))}function fl(t){Gs.current===t&&(vt(Pn),vt(Gs))}var wt=ir(0);function ti(t){for(var s=t;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var ml=[];function pl(){for(var t=0;t<ml.length;t++)ml[t]._workInProgressVersionPrimary=null;ml.length=0}var ni=T.ReactCurrentDispatcher,gl=T.ReactCurrentBatchConfig,Tr=0,bt=null,It=null,Pt=null,ri=!1,Js=!1,Qs=0,Jv=0;function Bt(){throw Error(a(321))}function vl(t,s){if(s===null)return!1;for(var o=0;o<s.length&&o<t.length;o++)if(!jn(t[o],s[o]))return!1;return!0}function yl(t,s,o,c,h,g){if(Tr=g,bt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,ni.current=t===null||t.memoizedState===null?ey:ty,t=o(c,h),Js){g=0;do{if(Js=!1,Qs=0,25<=g)throw Error(a(301));g+=1,Pt=It=null,s.updateQueue=null,ni.current=ny,t=o(c,h)}while(Js)}if(ni.current=ii,s=It!==null&&It.next!==null,Tr=0,Pt=It=bt=null,ri=!1,s)throw Error(a(300));return t}function xl(){var t=Qs!==0;return Qs=0,t}function _n(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pt===null?bt.memoizedState=Pt=t:Pt=Pt.next=t,Pt}function mn(){if(It===null){var t=bt.alternate;t=t!==null?t.memoizedState:null}else t=It.next;var s=Pt===null?bt.memoizedState:Pt.next;if(s!==null)Pt=s,It=t;else{if(t===null)throw Error(a(310));It=t,t={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},Pt===null?bt.memoizedState=Pt=t:Pt=Pt.next=t}return Pt}function Xs(t,s){return typeof s=="function"?s(t):s}function jl(t){var s=mn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=It,h=c.baseQueue,g=o.pending;if(g!==null){if(h!==null){var b=h.next;h.next=g.next,g.next=b}c.baseQueue=h=g,o.pending=null}if(h!==null){g=h.next,c=c.baseState;var A=b=null,R=null,q=g;do{var ae=q.lane;if((Tr&ae)===ae)R!==null&&(R=R.next={lane:0,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),c=q.hasEagerState?q.eagerState:t(c,q.action);else{var ce={lane:ae,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null};R===null?(A=R=ce,b=c):R=R.next=ce,bt.lanes|=ae,Ir|=ae}q=q.next}while(q!==null&&q!==g);R===null?b=c:R.next=A,jn(c,s.memoizedState)||(Xt=!0),s.memoizedState=c,s.baseState=b,s.baseQueue=R,o.lastRenderedState=c}if(t=o.interleaved,t!==null){h=t;do g=h.lane,bt.lanes|=g,Ir|=g,h=h.next;while(h!==t)}else h===null&&(o.lanes=0);return[s.memoizedState,o.dispatch]}function wl(t){var s=mn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=o.dispatch,h=o.pending,g=s.memoizedState;if(h!==null){o.pending=null;var b=h=h.next;do g=t(g,b.action),b=b.next;while(b!==h);jn(g,s.memoizedState)||(Xt=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),o.lastRenderedState=g}return[g,c]}function $d(){}function Pd(t,s){var o=bt,c=mn(),h=s(),g=!jn(c.memoizedState,h);if(g&&(c.memoizedState=h,Xt=!0),c=c.queue,bl(Md.bind(null,o,c,t),[t]),c.getSnapshot!==s||g||Pt!==null&&Pt.memoizedState.tag&1){if(o.flags|=2048,Zs(9,Ld.bind(null,o,c,h,s),void 0,null),_t===null)throw Error(a(349));(Tr&30)!==0||_d(o,s,h)}return h}function _d(t,s,o){t.flags|=16384,t={getSnapshot:s,value:o},s=bt.updateQueue,s===null?(s={lastEffect:null,stores:null},bt.updateQueue=s,s.stores=[t]):(o=s.stores,o===null?s.stores=[t]:o.push(t))}function Ld(t,s,o,c){s.value=o,s.getSnapshot=c,Fd(s)&&Od(t)}function Md(t,s,o){return o(function(){Fd(s)&&Od(t)})}function Fd(t){var s=t.getSnapshot;t=t.value;try{var o=s();return!jn(t,o)}catch{return!0}}function Od(t){var s=Hn(t,1);s!==null&&Nn(s,t,1,-1)}function zd(t){var s=_n();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Xs,lastRenderedState:t},s.queue=t,t=t.dispatch=Zv.bind(null,bt,t),[s.memoizedState,t]}function Zs(t,s,o,c){return t={tag:t,create:s,destroy:o,deps:c,next:null},s=bt.updateQueue,s===null?(s={lastEffect:null,stores:null},bt.updateQueue=s,s.lastEffect=t.next=t):(o=s.lastEffect,o===null?s.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,s.lastEffect=t)),t}function Dd(){return mn().memoizedState}function si(t,s,o,c){var h=_n();bt.flags|=t,h.memoizedState=Zs(1|s,o,void 0,c===void 0?null:c)}function ai(t,s,o,c){var h=mn();c=c===void 0?null:c;var g=void 0;if(It!==null){var b=It.memoizedState;if(g=b.destroy,c!==null&&vl(c,b.deps)){h.memoizedState=Zs(s,o,g,c);return}}bt.flags|=t,h.memoizedState=Zs(1|s,o,g,c)}function Bd(t,s){return si(8390656,8,t,s)}function bl(t,s){return ai(2048,8,t,s)}function Ud(t,s){return ai(4,2,t,s)}function Wd(t,s){return ai(4,4,t,s)}function Hd(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function Vd(t,s,o){return o=o!=null?o.concat([t]):null,ai(4,4,Hd.bind(null,s,t),o)}function kl(){}function qd(t,s){var o=mn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&vl(s,c[1])?c[0]:(o.memoizedState=[t,s],t)}function Kd(t,s){var o=mn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&vl(s,c[1])?c[0]:(t=t(),o.memoizedState=[t,s],t)}function Gd(t,s,o){return(Tr&21)===0?(t.baseState&&(t.baseState=!1,Xt=!0),t.memoizedState=o):(jn(o,s)||(o=Su(),bt.lanes|=o,Ir|=o,t.baseState=!0),s)}function Qv(t,s){var o=lt;lt=o!==0&&4>o?o:4,t(!0);var c=gl.transition;gl.transition={};try{t(!1),s()}finally{lt=o,gl.transition=c}}function Yd(){return mn().memoizedState}function Xv(t,s,o){var c=mr(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Jd(t))Qd(s,o);else if(o=Ed(t,s,o,c),o!==null){var h=Kt();Nn(o,t,c,h),Xd(o,s,c)}}function Zv(t,s,o){var c=mr(t),h={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Jd(t))Qd(s,h);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var b=s.lastRenderedState,A=g(b,o);if(h.hasEagerState=!0,h.eagerState=A,jn(A,b)){var R=s.interleaved;R===null?(h.next=h,ul(s)):(h.next=R.next,R.next=h),s.interleaved=h;return}}catch{}finally{}o=Ed(t,s,h,c),o!==null&&(h=Kt(),Nn(o,t,c,h),Xd(o,s,c))}}function Jd(t){var s=t.alternate;return t===bt||s!==null&&s===bt}function Qd(t,s){Js=ri=!0;var o=t.pending;o===null?s.next=s:(s.next=o.next,o.next=s),t.pending=s}function Xd(t,s,o){if((o&4194240)!==0){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,No(t,o)}}var ii={readContext:fn,useCallback:Bt,useContext:Bt,useEffect:Bt,useImperativeHandle:Bt,useInsertionEffect:Bt,useLayoutEffect:Bt,useMemo:Bt,useReducer:Bt,useRef:Bt,useState:Bt,useDebugValue:Bt,useDeferredValue:Bt,useTransition:Bt,useMutableSource:Bt,useSyncExternalStore:Bt,useId:Bt,unstable_isNewReconciler:!1},ey={readContext:fn,useCallback:function(t,s){return _n().memoizedState=[t,s===void 0?null:s],t},useContext:fn,useEffect:Bd,useImperativeHandle:function(t,s,o){return o=o!=null?o.concat([t]):null,si(4194308,4,Hd.bind(null,s,t),o)},useLayoutEffect:function(t,s){return si(4194308,4,t,s)},useInsertionEffect:function(t,s){return si(4,2,t,s)},useMemo:function(t,s){var o=_n();return s=s===void 0?null:s,t=t(),o.memoizedState=[t,s],t},useReducer:function(t,s,o){var c=_n();return s=o!==void 0?o(s):s,c.memoizedState=c.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},c.queue=t,t=t.dispatch=Xv.bind(null,bt,t),[c.memoizedState,t]},useRef:function(t){var s=_n();return t={current:t},s.memoizedState=t},useState:zd,useDebugValue:kl,useDeferredValue:function(t){return _n().memoizedState=t},useTransition:function(){var t=zd(!1),s=t[0];return t=Qv.bind(null,t[1]),_n().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,o){var c=bt,h=_n();if(yt){if(o===void 0)throw Error(a(407));o=o()}else{if(o=s(),_t===null)throw Error(a(349));(Tr&30)!==0||_d(c,s,o)}h.memoizedState=o;var g={value:o,getSnapshot:s};return h.queue=g,Bd(Md.bind(null,c,g,t),[t]),c.flags|=2048,Zs(9,Ld.bind(null,c,g,o,s),void 0,null),o},useId:function(){var t=_n(),s=_t.identifierPrefix;if(yt){var o=Wn,c=Un;o=(c&~(1<<32-xn(c)-1)).toString(32)+o,s=":"+s+"R"+o,o=Qs++,0<o&&(s+="H"+o.toString(32)),s+=":"}else o=Jv++,s=":"+s+"r"+o.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},ty={readContext:fn,useCallback:qd,useContext:fn,useEffect:bl,useImperativeHandle:Vd,useInsertionEffect:Ud,useLayoutEffect:Wd,useMemo:Kd,useReducer:jl,useRef:Dd,useState:function(){return jl(Xs)},useDebugValue:kl,useDeferredValue:function(t){var s=mn();return Gd(s,It.memoizedState,t)},useTransition:function(){var t=jl(Xs)[0],s=mn().memoizedState;return[t,s]},useMutableSource:$d,useSyncExternalStore:Pd,useId:Yd,unstable_isNewReconciler:!1},ny={readContext:fn,useCallback:qd,useContext:fn,useEffect:bl,useImperativeHandle:Vd,useInsertionEffect:Ud,useLayoutEffect:Wd,useMemo:Kd,useReducer:wl,useRef:Dd,useState:function(){return wl(Xs)},useDebugValue:kl,useDeferredValue:function(t){var s=mn();return It===null?s.memoizedState=t:Gd(s,It.memoizedState,t)},useTransition:function(){var t=wl(Xs)[0],s=mn().memoizedState;return[t,s]},useMutableSource:$d,useSyncExternalStore:Pd,useId:Yd,unstable_isNewReconciler:!1};function bn(t,s){if(t&&t.defaultProps){s=J({},s),t=t.defaultProps;for(var o in t)s[o]===void 0&&(s[o]=t[o]);return s}return s}function Sl(t,s,o,c){s=t.memoizedState,o=o(c,s),o=o==null?s:J({},s,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var oi={isMounted:function(t){return(t=t._reactInternals)?Tn(t)===t:!1},enqueueSetState:function(t,s,o){t=t._reactInternals;var c=Kt(),h=mr(t),g=Vn(c,h);g.payload=s,o!=null&&(g.callback=o),s=ur(t,g,h),s!==null&&(Nn(s,t,h,c),Za(s,t,h))},enqueueReplaceState:function(t,s,o){t=t._reactInternals;var c=Kt(),h=mr(t),g=Vn(c,h);g.tag=1,g.payload=s,o!=null&&(g.callback=o),s=ur(t,g,h),s!==null&&(Nn(s,t,h,c),Za(s,t,h))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var o=Kt(),c=mr(t),h=Vn(o,c);h.tag=2,s!=null&&(h.callback=s),s=ur(t,h,c),s!==null&&(Nn(s,t,c,o),Za(s,t,c))}};function Zd(t,s,o,c,h,g,b){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,b):s.prototype&&s.prototype.isPureReactComponent?!zs(o,c)||!zs(h,g):!0}function eh(t,s,o){var c=!1,h=or,g=s.contextType;return typeof g=="object"&&g!==null?g=fn(g):(h=Qt(s)?Sr:Dt.current,c=s.contextTypes,g=(c=c!=null)?Zr(t,h):or),s=new s(o,g),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=oi,t.stateNode=s,s._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=h,t.__reactInternalMemoizedMaskedChildContext=g),s}function th(t,s,o,c){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,c),s.state!==t&&oi.enqueueReplaceState(s,s.state,null)}function Nl(t,s,o,c){var h=t.stateNode;h.props=o,h.state=t.memoizedState,h.refs={},dl(t);var g=s.contextType;typeof g=="object"&&g!==null?h.context=fn(g):(g=Qt(s)?Sr:Dt.current,h.context=Zr(t,g)),h.state=t.memoizedState,g=s.getDerivedStateFromProps,typeof g=="function"&&(Sl(t,s,g,o),h.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(s=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),s!==h.state&&oi.enqueueReplaceState(h,h.state,null),ei(t,o,h,c),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308)}function os(t,s){try{var o="",c=s;do o+=$e(c),c=c.return;while(c);var h=o}catch(g){h=`
37
+ `+h[b].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=b&&0<=A);break}}}finally{pe=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?D(t):""}function $e(t){switch(t.tag){case 5:return D(t.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return t=de(t.type,!1),t;case 11:return t=de(t.type.render,!1),t;case 1:return t=de(t.type,!0),t;default:return""}}function ve(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case B:return"Fragment";case M:return"Portal";case Q:return"Profiler";case te:return"StrictMode";case K:return"Suspense";case le:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case z:return(t.displayName||"Context")+".Consumer";case _:return(t._context.displayName||"Context")+".Provider";case V:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case me:return s=t.displayName||null,s!==null?s:ve(t.type)||"Memo";case we:s=t._payload,t=t._init;try{return ve(t(s))}catch{}}return null}function Y(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(s);case 8:return s===te?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function he(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ee(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function oe(t){var s=ee(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),c=""+t[s];if(!t.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var h=o.get,g=o.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return h.call(this)},set:function(b){c=""+b,g.call(this,b)}}),Object.defineProperty(t,s,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(b){c=""+b},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function Oe(t){t._valueTracker||(t._valueTracker=oe(t))}function Fe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var o=s.getValue(),c="";return t&&(c=ee(t)?t.checked?"true":"false":t.value),t=c,t!==o?(s.setValue(t),!0):!1}function se(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Te(t,s){var o=s.checked;return J({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function _e(t,s){var o=s.defaultValue==null?"":s.defaultValue,c=s.checked!=null?s.checked:s.defaultChecked;o=he(s.value!=null?s.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Ve(t,s){s=s.checked,s!=null&&$(t,"checked",s,!1)}function Ge(t,s){Ve(t,s);var o=he(s.value),c=s.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?nt(t,s.type,o):s.hasOwnProperty("defaultValue")&&nt(t,s.type,he(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function ct(t,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var c=s.type;if(!(c!=="submit"&&c!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,o||s===t.value||(t.value=s),t.defaultValue=s}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function nt(t,s,o){(s!=="number"||se(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var Je=Array.isArray;function Be(t,s,o,c){if(t=t.options,s){s={};for(var h=0;h<o.length;h++)s["$"+o[h]]=!0;for(o=0;o<t.length;o++)h=s.hasOwnProperty("$"+t[o].value),t[o].selected!==h&&(t[o].selected=h),h&&c&&(t[o].defaultSelected=!0)}else{for(o=""+he(o),s=null,h=0;h<t.length;h++){if(t[h].value===o){t[h].selected=!0,c&&(t[h].defaultSelected=!0);return}s!==null||t[h].disabled||(s=t[h])}s!==null&&(s.selected=!0)}}function dt(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(a(91));return J({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function et(t,s){var o=s.value;if(o==null){if(o=s.children,s=s.defaultValue,o!=null){if(s!=null)throw Error(a(92));if(Je(o)){if(1<o.length)throw Error(a(93));o=o[0]}s=o}s==null&&(s=""),o=s}t._wrapperState={initialValue:he(o)}}function De(t,s){var o=he(s.value),c=he(s.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),s.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function Ie(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function We(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qe(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?We(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var ut,ye=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,o,c,h){MSApp.execUnsafeLocalFunction(function(){return t(s,o,c,h)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(ut=ut||document.createElement("div"),ut.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=ut.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function ze(t,s){if(s){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=s;return}}t.textContent=s}var Ye={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tt=["Webkit","ms","Moz","O"];Object.keys(Ye).forEach(function(t){tt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),Ye[s]=Ye[t]})});function st(t,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Ye.hasOwnProperty(t)&&Ye[t]?(""+s).trim():s+"px"}function ht(t,s){t=t.style;for(var o in s)if(s.hasOwnProperty(o)){var c=o.indexOf("--")===0,h=st(o,s[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,h):t[o]=h}}var jt=J({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qe(t,s){if(s){if(jt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(a(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(a(61))}if(s.style!=null&&typeof s.style!="object")throw Error(a(62))}}function H(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ge=null;function be(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var X=null,Ne=null,ke=null;function ue(t){if(t=Vs(t)){if(typeof X!="function")throw Error(a(280));var s=t.stateNode;s&&(s=Wa(s),X(t.stateNode,t.type,s))}}function He(t){Ne?ke?ke.push(t):ke=[t]:Ne=t}function kt(){if(Ne){var t=Ne,s=ke;if(ke=Ne=null,ue(t),s)for(t=0;t<s.length;t++)ue(s[t])}}function ne(t,s){return t(s)}function xe(){}var U=!1;function ie(t,s,o){if(U)return t(s,o);U=!0;try{return ne(t,s,o)}finally{U=!1,(Ne!==null||ke!==null)&&(xe(),kt())}}function Ee(t,s){var o=t.stateNode;if(o===null)return null;var c=Wa(o);if(c===null)return null;o=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(a(231,s,typeof o));return o}var it=!1;if(p)try{var ot={};Object.defineProperty(ot,"passive",{get:function(){it=!0}}),window.addEventListener("test",ot,ot),window.removeEventListener("test",ot,ot)}catch{it=!1}function zn(t,s,o,c,h,g,b,A,R){var q=Array.prototype.slice.call(arguments,3);try{s.apply(o,q)}catch(ae){this.onError(ae)}}var rn=!1,sn=null,Yt=!1,br=null,bo={onError:function(t){rn=!0,sn=t}};function ja(t,s,o,c,h,g,b,A,R){rn=!1,sn=null,zn.apply(bo,arguments)}function wa(t,s,o,c,h,g,b,A,R){if(ja.apply(this,arguments),rn){if(rn){var q=sn;rn=!1,sn=null}else throw Error(a(198));Yt||(Yt=!0,br=q)}}function Tn(t){var s=t,o=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(o=s.return),t=s.return;while(t)}return s.tag===3?o:null}function Cs(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function ba(t){if(Tn(t)!==t)throw Error(a(188))}function Wr(t){var s=t.alternate;if(!s){if(s=Tn(t),s===null)throw Error(a(188));return s!==t?null:t}for(var o=t,c=s;;){var h=o.return;if(h===null)break;var g=h.alternate;if(g===null){if(c=h.return,c!==null){o=c;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===o)return ba(h),t;if(g===c)return ba(h),s;g=g.sibling}throw Error(a(188))}if(o.return!==c.return)o=h,c=g;else{for(var b=!1,A=h.child;A;){if(A===o){b=!0,o=h,c=g;break}if(A===c){b=!0,c=h,o=g;break}A=A.sibling}if(!b){for(A=g.child;A;){if(A===o){b=!0,o=g,c=h;break}if(A===c){b=!0,c=g,o=h;break}A=A.sibling}if(!b)throw Error(a(189))}}if(o.alternate!==c)throw Error(a(190))}if(o.tag!==3)throw Error(a(188));return o.stateNode.current===o?t:s}function In(t){return t=Wr(t),t!==null?yu(t):null}function yu(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=yu(t);if(s!==null)return s;t=t.sibling}return null}var xu=r.unstable_scheduleCallback,ju=r.unstable_cancelCallback,Ug=r.unstable_shouldYield,Wg=r.unstable_requestPaint,Ct=r.unstable_now,Hg=r.unstable_getCurrentPriorityLevel,ko=r.unstable_ImmediatePriority,wu=r.unstable_UserBlockingPriority,ka=r.unstable_NormalPriority,Vg=r.unstable_LowPriority,bu=r.unstable_IdlePriority,Sa=null,Rn=null;function qg(t){if(Rn&&typeof Rn.onCommitFiberRoot=="function")try{Rn.onCommitFiberRoot(Sa,t,void 0,(t.current.flags&128)===128)}catch{}}var xn=Math.clz32?Math.clz32:Yg,Kg=Math.log,Gg=Math.LN2;function Yg(t){return t>>>=0,t===0?32:31-(Kg(t)/Gg|0)|0}var Na=64,Ca=4194304;function Es(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ea(t,s){var o=t.pendingLanes;if(o===0)return 0;var c=0,h=t.suspendedLanes,g=t.pingedLanes,b=o&268435455;if(b!==0){var A=b&~h;A!==0?c=Es(A):(g&=b,g!==0&&(c=Es(g)))}else b=o&~h,b!==0?c=Es(b):g!==0&&(c=Es(g));if(c===0)return 0;if(s!==0&&s!==c&&(s&h)===0&&(h=c&-c,g=s&-s,h>=g||h===16&&(g&4194240)!==0))return s;if((c&4)!==0&&(c|=o&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=c;0<s;)o=31-xn(s),h=1<<o,c|=t[o],s&=~h;return c}function Jg(t,s){switch(t){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Qg(t,s){for(var o=t.suspendedLanes,c=t.pingedLanes,h=t.expirationTimes,g=t.pendingLanes;0<g;){var b=31-xn(g),A=1<<b,R=h[b];R===-1?((A&o)===0||(A&c)!==0)&&(h[b]=Jg(A,s)):R<=s&&(t.expiredLanes|=A),g&=~A}}function So(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function ku(){var t=Na;return Na<<=1,(Na&4194240)===0&&(Na=64),t}function No(t){for(var s=[],o=0;31>o;o++)s.push(t);return s}function As(t,s,o){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-xn(s),t[s]=o}function Xg(t,s){var o=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var h=31-xn(o),g=1<<h;s[h]=0,c[h]=-1,t[h]=-1,o&=~g}}function Co(t,s){var o=t.entangledLanes|=s;for(t=t.entanglements;o;){var c=31-xn(o),h=1<<c;h&s|t[c]&s&&(t[c]|=s),o&=~h}}var lt=0;function Su(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var Nu,Eo,Cu,Eu,Au,Ao=!1,Aa=[],Zn=null,er=null,tr=null,Ts=new Map,Is=new Map,nr=[],Zg="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Tu(t,s){switch(t){case"focusin":case"focusout":Zn=null;break;case"dragenter":case"dragleave":er=null;break;case"mouseover":case"mouseout":tr=null;break;case"pointerover":case"pointerout":Ts.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Is.delete(s.pointerId)}}function Rs(t,s,o,c,h,g){return t===null||t.nativeEvent!==g?(t={blockedOn:s,domEventName:o,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},s!==null&&(s=Vs(s),s!==null&&Eo(s)),t):(t.eventSystemFlags|=c,s=t.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),t)}function ev(t,s,o,c,h){switch(s){case"focusin":return Zn=Rs(Zn,t,s,o,c,h),!0;case"dragenter":return er=Rs(er,t,s,o,c,h),!0;case"mouseover":return tr=Rs(tr,t,s,o,c,h),!0;case"pointerover":var g=h.pointerId;return Ts.set(g,Rs(Ts.get(g)||null,t,s,o,c,h)),!0;case"gotpointercapture":return g=h.pointerId,Is.set(g,Rs(Is.get(g)||null,t,s,o,c,h)),!0}return!1}function Iu(t){var s=kr(t.target);if(s!==null){var o=Tn(s);if(o!==null){if(s=o.tag,s===13){if(s=Cs(o),s!==null){t.blockedOn=s,Au(t.priority,function(){Cu(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ta(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var o=Io(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);ge=c,o.target.dispatchEvent(c),ge=null}else return s=Vs(o),s!==null&&Eo(s),t.blockedOn=o,!1;s.shift()}return!0}function Ru(t,s,o){Ta(t)&&o.delete(s)}function tv(){Ao=!1,Zn!==null&&Ta(Zn)&&(Zn=null),er!==null&&Ta(er)&&(er=null),tr!==null&&Ta(tr)&&(tr=null),Ts.forEach(Ru),Is.forEach(Ru)}function $s(t,s){t.blockedOn===s&&(t.blockedOn=null,Ao||(Ao=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,tv)))}function Ps(t){function s(h){return $s(h,t)}if(0<Aa.length){$s(Aa[0],t);for(var o=1;o<Aa.length;o++){var c=Aa[o];c.blockedOn===t&&(c.blockedOn=null)}}for(Zn!==null&&$s(Zn,t),er!==null&&$s(er,t),tr!==null&&$s(tr,t),Ts.forEach(s),Is.forEach(s),o=0;o<nr.length;o++)c=nr[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<nr.length&&(o=nr[0],o.blockedOn===null);)Iu(o),o.blockedOn===null&&nr.shift()}var Hr=T.ReactCurrentBatchConfig,Ia=!0;function nv(t,s,o,c){var h=lt,g=Hr.transition;Hr.transition=null;try{lt=1,To(t,s,o,c)}finally{lt=h,Hr.transition=g}}function rv(t,s,o,c){var h=lt,g=Hr.transition;Hr.transition=null;try{lt=4,To(t,s,o,c)}finally{lt=h,Hr.transition=g}}function To(t,s,o,c){if(Ia){var h=Io(t,s,o,c);if(h===null)Ko(t,s,c,Ra,o),Tu(t,c);else if(ev(h,t,s,o,c))c.stopPropagation();else if(Tu(t,c),s&4&&-1<Zg.indexOf(t)){for(;h!==null;){var g=Vs(h);if(g!==null&&Nu(g),g=Io(t,s,o,c),g===null&&Ko(t,s,c,Ra,o),g===h)break;h=g}h!==null&&c.stopPropagation()}else Ko(t,s,c,null,o)}}var Ra=null;function Io(t,s,o,c){if(Ra=null,t=be(c),t=kr(t),t!==null)if(s=Tn(t),s===null)t=null;else if(o=s.tag,o===13){if(t=Cs(s),t!==null)return t;t=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return Ra=t,null}function $u(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Hg()){case ko:return 1;case wu:return 4;case ka:case Vg:return 16;case bu:return 536870912;default:return 16}default:return 16}}var rr=null,Ro=null,$a=null;function Pu(){if($a)return $a;var t,s=Ro,o=s.length,c,h="value"in rr?rr.value:rr.textContent,g=h.length;for(t=0;t<o&&s[t]===h[t];t++);var b=o-t;for(c=1;c<=b&&s[o-c]===h[g-c];c++);return $a=h.slice(t,1<c?1-c:void 0)}function Pa(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function _a(){return!0}function _u(){return!1}function an(t){function s(o,c,h,g,b){this._reactName=o,this._targetInst=h,this.type=c,this.nativeEvent=g,this.target=b,this.currentTarget=null;for(var A in t)t.hasOwnProperty(A)&&(o=t[A],this[A]=o?o(g):g[A]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?_a:_u,this.isPropagationStopped=_u,this}return J(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=_a)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=_a)},persist:function(){},isPersistent:_a}),s}var Vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$o=an(Vr),_s=J({},Vr,{view:0,detail:0}),sv=an(_s),Po,_o,Ls,La=J({},_s,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mo,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ls&&(Ls&&t.type==="mousemove"?(Po=t.screenX-Ls.screenX,_o=t.screenY-Ls.screenY):_o=Po=0,Ls=t),Po)},movementY:function(t){return"movementY"in t?t.movementY:_o}}),Lu=an(La),av=J({},La,{dataTransfer:0}),iv=an(av),ov=J({},_s,{relatedTarget:0}),Lo=an(ov),lv=J({},Vr,{animationName:0,elapsedTime:0,pseudoElement:0}),cv=an(lv),uv=J({},Vr,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),dv=an(uv),hv=J({},Vr,{data:0}),Mu=an(hv),fv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},pv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gv(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=pv[t])?!!s[t]:!1}function Mo(){return gv}var vv=J({},_s,{key:function(t){if(t.key){var s=fv[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=Pa(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?mv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mo,charCode:function(t){return t.type==="keypress"?Pa(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Pa(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),yv=an(vv),xv=J({},La,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fu=an(xv),jv=J({},_s,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mo}),wv=an(jv),bv=J({},Vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),kv=an(bv),Sv=J({},La,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Nv=an(Sv),Cv=[9,13,27,32],Fo=p&&"CompositionEvent"in window,Ms=null;p&&"documentMode"in document&&(Ms=document.documentMode);var Ev=p&&"TextEvent"in window&&!Ms,Ou=p&&(!Fo||Ms&&8<Ms&&11>=Ms),zu=" ",Du=!1;function Bu(t,s){switch(t){case"keyup":return Cv.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var qr=!1;function Av(t,s){switch(t){case"compositionend":return Uu(s);case"keypress":return s.which!==32?null:(Du=!0,zu);case"textInput":return t=s.data,t===zu&&Du?null:t;default:return null}}function Tv(t,s){if(qr)return t==="compositionend"||!Fo&&Bu(t,s)?(t=Pu(),$a=Ro=rr=null,qr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Ou&&s.locale!=="ko"?null:s.data;default:return null}}var Iv={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wu(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!Iv[t.type]:s==="textarea"}function Hu(t,s,o,c){He(c),s=Da(s,"onChange"),0<s.length&&(o=new $o("onChange","change",null,o,c),t.push({event:o,listeners:s}))}var Fs=null,Os=null;function Rv(t){ld(t,0)}function Ma(t){var s=Qr(t);if(Fe(s))return t}function $v(t,s){if(t==="change")return s}var Vu=!1;if(p){var Oo;if(p){var zo="oninput"in document;if(!zo){var qu=document.createElement("div");qu.setAttribute("oninput","return;"),zo=typeof qu.oninput=="function"}Oo=zo}else Oo=!1;Vu=Oo&&(!document.documentMode||9<document.documentMode)}function Ku(){Fs&&(Fs.detachEvent("onpropertychange",Gu),Os=Fs=null)}function Gu(t){if(t.propertyName==="value"&&Ma(Os)){var s=[];Hu(s,Os,t,be(t)),ie(Rv,s)}}function Pv(t,s,o){t==="focusin"?(Ku(),Fs=s,Os=o,Fs.attachEvent("onpropertychange",Gu)):t==="focusout"&&Ku()}function _v(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Ma(Os)}function Lv(t,s){if(t==="click")return Ma(s)}function Mv(t,s){if(t==="input"||t==="change")return Ma(s)}function Fv(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var jn=typeof Object.is=="function"?Object.is:Fv;function zs(t,s){if(jn(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var o=Object.keys(t),c=Object.keys(s);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var h=o[c];if(!m.call(s,h)||!jn(t[h],s[h]))return!1}return!0}function Yu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Ju(t,s){var o=Yu(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=s&&c>=s)return{node:o,offset:s-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Yu(o)}}function Qu(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?Qu(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function Xu(){for(var t=window,s=se();s instanceof t.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)t=s.contentWindow;else break;s=se(t.document)}return s}function Do(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function Ov(t){var s=Xu(),o=t.focusedElem,c=t.selectionRange;if(s!==o&&o&&o.ownerDocument&&Qu(o.ownerDocument.documentElement,o)){if(c!==null&&Do(o)){if(s=c.start,t=c.end,t===void 0&&(t=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(t,o.value.length);else if(t=(s=o.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var h=o.textContent.length,g=Math.min(c.start,h);c=c.end===void 0?g:Math.min(c.end,h),!t.extend&&g>c&&(h=c,c=g,g=h),h=Ju(o,g);var b=Ju(o,c);h&&b&&(t.rangeCount!==1||t.anchorNode!==h.node||t.anchorOffset!==h.offset||t.focusNode!==b.node||t.focusOffset!==b.offset)&&(s=s.createRange(),s.setStart(h.node,h.offset),t.removeAllRanges(),g>c?(t.addRange(s),t.extend(b.node,b.offset)):(s.setEnd(b.node,b.offset),t.addRange(s)))}}for(s=[],t=o;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<s.length;o++)t=s[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var zv=p&&"documentMode"in document&&11>=document.documentMode,Kr=null,Bo=null,Ds=null,Uo=!1;function Zu(t,s,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Uo||Kr==null||Kr!==se(c)||(c=Kr,"selectionStart"in c&&Do(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Ds&&zs(Ds,c)||(Ds=c,c=Da(Bo,"onSelect"),0<c.length&&(s=new $o("onSelect","select",null,s,o),t.push({event:s,listeners:c}),s.target=Kr)))}function Fa(t,s){var o={};return o[t.toLowerCase()]=s.toLowerCase(),o["Webkit"+t]="webkit"+s,o["Moz"+t]="moz"+s,o}var Gr={animationend:Fa("Animation","AnimationEnd"),animationiteration:Fa("Animation","AnimationIteration"),animationstart:Fa("Animation","AnimationStart"),transitionend:Fa("Transition","TransitionEnd")},Wo={},ed={};p&&(ed=document.createElement("div").style,"AnimationEvent"in window||(delete Gr.animationend.animation,delete Gr.animationiteration.animation,delete Gr.animationstart.animation),"TransitionEvent"in window||delete Gr.transitionend.transition);function Oa(t){if(Wo[t])return Wo[t];if(!Gr[t])return t;var s=Gr[t],o;for(o in s)if(s.hasOwnProperty(o)&&o in ed)return Wo[t]=s[o];return t}var td=Oa("animationend"),nd=Oa("animationiteration"),rd=Oa("animationstart"),sd=Oa("transitionend"),ad=new Map,id="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function sr(t,s){ad.set(t,s),u(s,[t])}for(var Ho=0;Ho<id.length;Ho++){var Vo=id[Ho],Dv=Vo.toLowerCase(),Bv=Vo[0].toUpperCase()+Vo.slice(1);sr(Dv,"on"+Bv)}sr(td,"onAnimationEnd"),sr(nd,"onAnimationIteration"),sr(rd,"onAnimationStart"),sr("dblclick","onDoubleClick"),sr("focusin","onFocus"),sr("focusout","onBlur"),sr(sd,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Uv=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bs));function od(t,s,o){var c=t.type||"unknown-event";t.currentTarget=o,wa(c,s,void 0,t),t.currentTarget=null}function ld(t,s){s=(s&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],h=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var b=c.length-1;0<=b;b--){var A=c[b],R=A.instance,q=A.currentTarget;if(A=A.listener,R!==g&&h.isPropagationStopped())break e;od(h,A,q),g=R}else for(b=0;b<c.length;b++){if(A=c[b],R=A.instance,q=A.currentTarget,A=A.listener,R!==g&&h.isPropagationStopped())break e;od(h,A,q),g=R}}}if(Yt)throw t=br,Yt=!1,br=null,t}function gt(t,s){var o=s[Zo];o===void 0&&(o=s[Zo]=new Set);var c=t+"__bubble";o.has(c)||(cd(s,t,2,!1),o.add(c))}function qo(t,s,o){var c=0;s&&(c|=4),cd(o,t,c,s)}var za="_reactListening"+Math.random().toString(36).slice(2);function Us(t){if(!t[za]){t[za]=!0,i.forEach(function(o){o!=="selectionchange"&&(Uv.has(o)||qo(o,!1,t),qo(o,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[za]||(s[za]=!0,qo("selectionchange",!1,s))}}function cd(t,s,o,c){switch($u(s)){case 1:var h=nv;break;case 4:h=rv;break;default:h=To}o=h.bind(null,s,o,t),h=void 0,!it||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),c?h!==void 0?t.addEventListener(s,o,{capture:!0,passive:h}):t.addEventListener(s,o,!0):h!==void 0?t.addEventListener(s,o,{passive:h}):t.addEventListener(s,o,!1)}function Ko(t,s,o,c,h){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var b=c.tag;if(b===3||b===4){var A=c.stateNode.containerInfo;if(A===h||A.nodeType===8&&A.parentNode===h)break;if(b===4)for(b=c.return;b!==null;){var R=b.tag;if((R===3||R===4)&&(R=b.stateNode.containerInfo,R===h||R.nodeType===8&&R.parentNode===h))return;b=b.return}for(;A!==null;){if(b=kr(A),b===null)return;if(R=b.tag,R===5||R===6){c=g=b;continue e}A=A.parentNode}}c=c.return}ie(function(){var q=g,ae=be(o),ce=[];e:{var re=ad.get(t);if(re!==void 0){var je=$o,Ce=t;switch(t){case"keypress":if(Pa(o)===0)break e;case"keydown":case"keyup":je=yv;break;case"focusin":Ce="focus",je=Lo;break;case"focusout":Ce="blur",je=Lo;break;case"beforeblur":case"afterblur":je=Lo;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=Lu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=iv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=wv;break;case td:case nd:case rd:je=cv;break;case sd:je=kv;break;case"scroll":je=sv;break;case"wheel":je=Nv;break;case"copy":case"cut":case"paste":je=dv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Fu}var Re=(s&4)!==0,Et=!Re&&t==="scroll",O=Re?re!==null?re+"Capture":null:re;Re=[];for(var L=q,W;L!==null;){W=L;var fe=W.stateNode;if(W.tag===5&&fe!==null&&(W=fe,O!==null&&(fe=Ee(L,O),fe!=null&&Re.push(Ws(L,fe,W)))),Et)break;L=L.return}0<Re.length&&(re=new je(re,Ce,null,o,ae),ce.push({event:re,listeners:Re}))}}if((s&7)===0){e:{if(re=t==="mouseover"||t==="pointerover",je=t==="mouseout"||t==="pointerout",re&&o!==ge&&(Ce=o.relatedTarget||o.fromElement)&&(kr(Ce)||Ce[Dn]))break e;if((je||re)&&(re=ae.window===ae?ae:(re=ae.ownerDocument)?re.defaultView||re.parentWindow:window,je?(Ce=o.relatedTarget||o.toElement,je=q,Ce=Ce?kr(Ce):null,Ce!==null&&(Et=Tn(Ce),Ce!==Et||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(je=null,Ce=q),je!==Ce)){if(Re=Lu,fe="onMouseLeave",O="onMouseEnter",L="mouse",(t==="pointerout"||t==="pointerover")&&(Re=Fu,fe="onPointerLeave",O="onPointerEnter",L="pointer"),Et=je==null?re:Qr(je),W=Ce==null?re:Qr(Ce),re=new Re(fe,L+"leave",je,o,ae),re.target=Et,re.relatedTarget=W,fe=null,kr(ae)===q&&(Re=new Re(O,L+"enter",Ce,o,ae),Re.target=W,Re.relatedTarget=Et,fe=Re),Et=fe,je&&Ce)t:{for(Re=je,O=Ce,L=0,W=Re;W;W=Yr(W))L++;for(W=0,fe=O;fe;fe=Yr(fe))W++;for(;0<L-W;)Re=Yr(Re),L--;for(;0<W-L;)O=Yr(O),W--;for(;L--;){if(Re===O||O!==null&&Re===O.alternate)break t;Re=Yr(Re),O=Yr(O)}Re=null}else Re=null;je!==null&&ud(ce,re,je,Re,!1),Ce!==null&&Et!==null&&ud(ce,Et,Ce,Re,!0)}}e:{if(re=q?Qr(q):window,je=re.nodeName&&re.nodeName.toLowerCase(),je==="select"||je==="input"&&re.type==="file")var Pe=$v;else if(Wu(re))if(Vu)Pe=Mv;else{Pe=_v;var Le=Pv}else(je=re.nodeName)&&je.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Pe=Lv);if(Pe&&(Pe=Pe(t,q))){Hu(ce,Pe,o,ae);break e}Le&&Le(t,re,q),t==="focusout"&&(Le=re._wrapperState)&&Le.controlled&&re.type==="number"&&nt(re,"number",re.value)}switch(Le=q?Qr(q):window,t){case"focusin":(Wu(Le)||Le.contentEditable==="true")&&(Kr=Le,Bo=q,Ds=null);break;case"focusout":Ds=Bo=Kr=null;break;case"mousedown":Uo=!0;break;case"contextmenu":case"mouseup":case"dragend":Uo=!1,Zu(ce,o,ae);break;case"selectionchange":if(zv)break;case"keydown":case"keyup":Zu(ce,o,ae)}var Me;if(Fo)e:{switch(t){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else qr?Bu(t,o)&&(Ue="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(Ue="onCompositionStart");Ue&&(Ou&&o.locale!=="ko"&&(qr||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&qr&&(Me=Pu()):(rr=ae,Ro="value"in rr?rr.value:rr.textContent,qr=!0)),Le=Da(q,Ue),0<Le.length&&(Ue=new Mu(Ue,t,null,o,ae),ce.push({event:Ue,listeners:Le}),Me?Ue.data=Me:(Me=Uu(o),Me!==null&&(Ue.data=Me)))),(Me=Ev?Av(t,o):Tv(t,o))&&(q=Da(q,"onBeforeInput"),0<q.length&&(ae=new Mu("onBeforeInput","beforeinput",null,o,ae),ce.push({event:ae,listeners:q}),ae.data=Me))}ld(ce,s)})}function Ws(t,s,o){return{instance:t,listener:s,currentTarget:o}}function Da(t,s){for(var o=s+"Capture",c=[];t!==null;){var h=t,g=h.stateNode;h.tag===5&&g!==null&&(h=g,g=Ee(t,o),g!=null&&c.unshift(Ws(t,g,h)),g=Ee(t,s),g!=null&&c.push(Ws(t,g,h))),t=t.return}return c}function Yr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function ud(t,s,o,c,h){for(var g=s._reactName,b=[];o!==null&&o!==c;){var A=o,R=A.alternate,q=A.stateNode;if(R!==null&&R===c)break;A.tag===5&&q!==null&&(A=q,h?(R=Ee(o,g),R!=null&&b.unshift(Ws(o,R,A))):h||(R=Ee(o,g),R!=null&&b.push(Ws(o,R,A)))),o=o.return}b.length!==0&&t.push({event:s,listeners:b})}var Wv=/\r\n?/g,Hv=/\u0000|\uFFFD/g;function dd(t){return(typeof t=="string"?t:""+t).replace(Wv,`
38
+ `).replace(Hv,"")}function Ba(t,s,o){if(s=dd(s),dd(t)!==s&&o)throw Error(a(425))}function Ua(){}var Go=null,Yo=null;function Jo(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Qo=typeof setTimeout=="function"?setTimeout:void 0,Vv=typeof clearTimeout=="function"?clearTimeout:void 0,hd=typeof Promise=="function"?Promise:void 0,qv=typeof queueMicrotask=="function"?queueMicrotask:typeof hd<"u"?function(t){return hd.resolve(null).then(t).catch(Kv)}:Qo;function Kv(t){setTimeout(function(){throw t})}function Xo(t,s){var o=s,c=0;do{var h=o.nextSibling;if(t.removeChild(o),h&&h.nodeType===8)if(o=h.data,o==="/$"){if(c===0){t.removeChild(h),Ps(s);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=h}while(o);Ps(s)}function ar(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function fd(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(s===0)return t;s--}else o==="/$"&&s++}t=t.previousSibling}return null}var Jr=Math.random().toString(36).slice(2),$n="__reactFiber$"+Jr,Hs="__reactProps$"+Jr,Dn="__reactContainer$"+Jr,Zo="__reactEvents$"+Jr,Gv="__reactListeners$"+Jr,Yv="__reactHandles$"+Jr;function kr(t){var s=t[$n];if(s)return s;for(var o=t.parentNode;o;){if(s=o[Dn]||o[$n]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(t=fd(t);t!==null;){if(o=t[$n])return o;t=fd(t)}return s}t=o,o=t.parentNode}return null}function Vs(t){return t=t[$n]||t[Dn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Qr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Wa(t){return t[Hs]||null}var el=[],Xr=-1;function ir(t){return{current:t}}function vt(t){0>Xr||(t.current=el[Xr],el[Xr]=null,Xr--)}function ft(t,s){Xr++,el[Xr]=t.current,t.current=s}var or={},Dt=ir(or),Jt=ir(!1),Sr=or;function Zr(t,s){var o=t.type.contextTypes;if(!o)return or;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===s)return c.__reactInternalMemoizedMaskedChildContext;var h={},g;for(g in o)h[g]=s[g];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=h),h}function Qt(t){return t=t.childContextTypes,t!=null}function Ha(){vt(Jt),vt(Dt)}function md(t,s,o){if(Dt.current!==or)throw Error(a(168));ft(Dt,s),ft(Jt,o)}function pd(t,s,o){var c=t.stateNode;if(s=s.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var h in c)if(!(h in s))throw Error(a(108,Y(t)||"Unknown",h));return J({},o,c)}function Va(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||or,Sr=Dt.current,ft(Dt,t),ft(Jt,Jt.current),!0}function gd(t,s,o){var c=t.stateNode;if(!c)throw Error(a(169));o?(t=pd(t,s,Sr),c.__reactInternalMemoizedMergedChildContext=t,vt(Jt),vt(Dt),ft(Dt,t)):vt(Jt),ft(Jt,o)}var Bn=null,qa=!1,tl=!1;function vd(t){Bn===null?Bn=[t]:Bn.push(t)}function Jv(t){qa=!0,vd(t)}function lr(){if(!tl&&Bn!==null){tl=!0;var t=0,s=lt;try{var o=Bn;for(lt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}Bn=null,qa=!1}catch(h){throw Bn!==null&&(Bn=Bn.slice(t+1)),xu(ko,lr),h}finally{lt=s,tl=!1}}return null}var es=[],ts=0,Ka=null,Ga=0,dn=[],hn=0,Nr=null,Un=1,Wn="";function Cr(t,s){es[ts++]=Ga,es[ts++]=Ka,Ka=t,Ga=s}function yd(t,s,o){dn[hn++]=Un,dn[hn++]=Wn,dn[hn++]=Nr,Nr=t;var c=Un;t=Wn;var h=32-xn(c)-1;c&=~(1<<h),o+=1;var g=32-xn(s)+h;if(30<g){var b=h-h%5;g=(c&(1<<b)-1).toString(32),c>>=b,h-=b,Un=1<<32-xn(s)+h|o<<h|c,Wn=g+t}else Un=1<<g|o<<h|c,Wn=t}function nl(t){t.return!==null&&(Cr(t,1),yd(t,1,0))}function rl(t){for(;t===Ka;)Ka=es[--ts],es[ts]=null,Ga=es[--ts],es[ts]=null;for(;t===Nr;)Nr=dn[--hn],dn[hn]=null,Wn=dn[--hn],dn[hn]=null,Un=dn[--hn],dn[hn]=null}var on=null,ln=null,yt=!1,wn=null;function xd(t,s){var o=gn(5,null,null,0);o.elementType="DELETED",o.stateNode=s,o.return=t,s=t.deletions,s===null?(t.deletions=[o],t.flags|=16):s.push(o)}function jd(t,s){switch(t.tag){case 5:var o=t.type;return s=s.nodeType!==1||o.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,on=t,ln=ar(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,on=t,ln=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(o=Nr!==null?{id:Un,overflow:Wn}:null,t.memoizedState={dehydrated:s,treeContext:o,retryLane:1073741824},o=gn(18,null,null,0),o.stateNode=s,o.return=t,t.child=o,on=t,ln=null,!0):!1;default:return!1}}function sl(t){return(t.mode&1)!==0&&(t.flags&128)===0}function al(t){if(yt){var s=ln;if(s){var o=s;if(!jd(t,s)){if(sl(t))throw Error(a(418));s=ar(o.nextSibling);var c=on;s&&jd(t,s)?xd(c,o):(t.flags=t.flags&-4097|2,yt=!1,on=t)}}else{if(sl(t))throw Error(a(418));t.flags=t.flags&-4097|2,yt=!1,on=t}}}function wd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;on=t}function Ya(t){if(t!==on)return!1;if(!yt)return wd(t),yt=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!Jo(t.type,t.memoizedProps)),s&&(s=ln)){if(sl(t))throw bd(),Error(a(418));for(;s;)xd(t,s),s=ar(s.nextSibling)}if(wd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(s===0){ln=ar(t.nextSibling);break e}s--}else o!=="$"&&o!=="$!"&&o!=="$?"||s++}t=t.nextSibling}ln=null}}else ln=on?ar(t.stateNode.nextSibling):null;return!0}function bd(){for(var t=ln;t;)t=ar(t.nextSibling)}function ns(){ln=on=null,yt=!1}function il(t){wn===null?wn=[t]:wn.push(t)}var Qv=T.ReactCurrentBatchConfig;function qs(t,s,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(a(309));var c=o.stateNode}if(!c)throw Error(a(147,t));var h=c,g=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===g?s.ref:(s=function(b){var A=h.refs;b===null?delete A[g]:A[g]=b},s._stringRef=g,s)}if(typeof t!="string")throw Error(a(284));if(!o._owner)throw Error(a(290,t))}return t}function Ja(t,s){throw t=Object.prototype.toString.call(s),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function kd(t){var s=t._init;return s(t._payload)}function Sd(t){function s(O,L){if(t){var W=O.deletions;W===null?(O.deletions=[L],O.flags|=16):W.push(L)}}function o(O,L){if(!t)return null;for(;L!==null;)s(O,L),L=L.sibling;return null}function c(O,L){for(O=new Map;L!==null;)L.key!==null?O.set(L.key,L):O.set(L.index,L),L=L.sibling;return O}function h(O,L){return O=gr(O,L),O.index=0,O.sibling=null,O}function g(O,L,W){return O.index=W,t?(W=O.alternate,W!==null?(W=W.index,W<L?(O.flags|=2,L):W):(O.flags|=2,L)):(O.flags|=1048576,L)}function b(O){return t&&O.alternate===null&&(O.flags|=2),O}function A(O,L,W,fe){return L===null||L.tag!==6?(L=Ql(W,O.mode,fe),L.return=O,L):(L=h(L,W),L.return=O,L)}function R(O,L,W,fe){var Pe=W.type;return Pe===B?ae(O,L,W.props.children,fe,W.key):L!==null&&(L.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===we&&kd(Pe)===L.type)?(fe=h(L,W.props),fe.ref=qs(O,L,W),fe.return=O,fe):(fe=ji(W.type,W.key,W.props,null,O.mode,fe),fe.ref=qs(O,L,W),fe.return=O,fe)}function q(O,L,W,fe){return L===null||L.tag!==4||L.stateNode.containerInfo!==W.containerInfo||L.stateNode.implementation!==W.implementation?(L=Xl(W,O.mode,fe),L.return=O,L):(L=h(L,W.children||[]),L.return=O,L)}function ae(O,L,W,fe,Pe){return L===null||L.tag!==7?(L=_r(W,O.mode,fe,Pe),L.return=O,L):(L=h(L,W),L.return=O,L)}function ce(O,L,W){if(typeof L=="string"&&L!==""||typeof L=="number")return L=Ql(""+L,O.mode,W),L.return=O,L;if(typeof L=="object"&&L!==null){switch(L.$$typeof){case F:return W=ji(L.type,L.key,L.props,null,O.mode,W),W.ref=qs(O,null,L),W.return=O,W;case M:return L=Xl(L,O.mode,W),L.return=O,L;case we:var fe=L._init;return ce(O,fe(L._payload),W)}if(Je(L)||G(L))return L=_r(L,O.mode,W,null),L.return=O,L;Ja(O,L)}return null}function re(O,L,W,fe){var Pe=L!==null?L.key:null;if(typeof W=="string"&&W!==""||typeof W=="number")return Pe!==null?null:A(O,L,""+W,fe);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case F:return W.key===Pe?R(O,L,W,fe):null;case M:return W.key===Pe?q(O,L,W,fe):null;case we:return Pe=W._init,re(O,L,Pe(W._payload),fe)}if(Je(W)||G(W))return Pe!==null?null:ae(O,L,W,fe,null);Ja(O,W)}return null}function je(O,L,W,fe,Pe){if(typeof fe=="string"&&fe!==""||typeof fe=="number")return O=O.get(W)||null,A(L,O,""+fe,Pe);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case F:return O=O.get(fe.key===null?W:fe.key)||null,R(L,O,fe,Pe);case M:return O=O.get(fe.key===null?W:fe.key)||null,q(L,O,fe,Pe);case we:var Le=fe._init;return je(O,L,W,Le(fe._payload),Pe)}if(Je(fe)||G(fe))return O=O.get(W)||null,ae(L,O,fe,Pe,null);Ja(L,fe)}return null}function Ce(O,L,W,fe){for(var Pe=null,Le=null,Me=L,Ue=L=0,Lt=null;Me!==null&&Ue<W.length;Ue++){Me.index>Ue?(Lt=Me,Me=null):Lt=Me.sibling;var at=re(O,Me,W[Ue],fe);if(at===null){Me===null&&(Me=Lt);break}t&&Me&&at.alternate===null&&s(O,Me),L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at,Me=Lt}if(Ue===W.length)return o(O,Me),yt&&Cr(O,Ue),Pe;if(Me===null){for(;Ue<W.length;Ue++)Me=ce(O,W[Ue],fe),Me!==null&&(L=g(Me,L,Ue),Le===null?Pe=Me:Le.sibling=Me,Le=Me);return yt&&Cr(O,Ue),Pe}for(Me=c(O,Me);Ue<W.length;Ue++)Lt=je(Me,O,Ue,W[Ue],fe),Lt!==null&&(t&&Lt.alternate!==null&&Me.delete(Lt.key===null?Ue:Lt.key),L=g(Lt,L,Ue),Le===null?Pe=Lt:Le.sibling=Lt,Le=Lt);return t&&Me.forEach(function(vr){return s(O,vr)}),yt&&Cr(O,Ue),Pe}function Re(O,L,W,fe){var Pe=G(W);if(typeof Pe!="function")throw Error(a(150));if(W=Pe.call(W),W==null)throw Error(a(151));for(var Le=Pe=null,Me=L,Ue=L=0,Lt=null,at=W.next();Me!==null&&!at.done;Ue++,at=W.next()){Me.index>Ue?(Lt=Me,Me=null):Lt=Me.sibling;var vr=re(O,Me,at.value,fe);if(vr===null){Me===null&&(Me=Lt);break}t&&Me&&vr.alternate===null&&s(O,Me),L=g(vr,L,Ue),Le===null?Pe=vr:Le.sibling=vr,Le=vr,Me=Lt}if(at.done)return o(O,Me),yt&&Cr(O,Ue),Pe;if(Me===null){for(;!at.done;Ue++,at=W.next())at=ce(O,at.value,fe),at!==null&&(L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at);return yt&&Cr(O,Ue),Pe}for(Me=c(O,Me);!at.done;Ue++,at=W.next())at=je(Me,O,Ue,at.value,fe),at!==null&&(t&&at.alternate!==null&&Me.delete(at.key===null?Ue:at.key),L=g(at,L,Ue),Le===null?Pe=at:Le.sibling=at,Le=at);return t&&Me.forEach(function(Iy){return s(O,Iy)}),yt&&Cr(O,Ue),Pe}function Et(O,L,W,fe){if(typeof W=="object"&&W!==null&&W.type===B&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case F:e:{for(var Pe=W.key,Le=L;Le!==null;){if(Le.key===Pe){if(Pe=W.type,Pe===B){if(Le.tag===7){o(O,Le.sibling),L=h(Le,W.props.children),L.return=O,O=L;break e}}else if(Le.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===we&&kd(Pe)===Le.type){o(O,Le.sibling),L=h(Le,W.props),L.ref=qs(O,Le,W),L.return=O,O=L;break e}o(O,Le);break}else s(O,Le);Le=Le.sibling}W.type===B?(L=_r(W.props.children,O.mode,fe,W.key),L.return=O,O=L):(fe=ji(W.type,W.key,W.props,null,O.mode,fe),fe.ref=qs(O,L,W),fe.return=O,O=fe)}return b(O);case M:e:{for(Le=W.key;L!==null;){if(L.key===Le)if(L.tag===4&&L.stateNode.containerInfo===W.containerInfo&&L.stateNode.implementation===W.implementation){o(O,L.sibling),L=h(L,W.children||[]),L.return=O,O=L;break e}else{o(O,L);break}else s(O,L);L=L.sibling}L=Xl(W,O.mode,fe),L.return=O,O=L}return b(O);case we:return Le=W._init,Et(O,L,Le(W._payload),fe)}if(Je(W))return Ce(O,L,W,fe);if(G(W))return Re(O,L,W,fe);Ja(O,W)}return typeof W=="string"&&W!==""||typeof W=="number"?(W=""+W,L!==null&&L.tag===6?(o(O,L.sibling),L=h(L,W),L.return=O,O=L):(o(O,L),L=Ql(W,O.mode,fe),L.return=O,O=L),b(O)):o(O,L)}return Et}var rs=Sd(!0),Nd=Sd(!1),Qa=ir(null),Xa=null,ss=null,ol=null;function ll(){ol=ss=Xa=null}function cl(t){var s=Qa.current;vt(Qa),t._currentValue=s}function ul(t,s,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),t===o)break;t=t.return}}function as(t,s){Xa=t,ol=ss=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(Xt=!0),t.firstContext=null)}function fn(t){var s=t._currentValue;if(ol!==t)if(t={context:t,memoizedValue:s,next:null},ss===null){if(Xa===null)throw Error(a(308));ss=t,Xa.dependencies={lanes:0,firstContext:t}}else ss=ss.next=t;return s}var Er=null;function dl(t){Er===null?Er=[t]:Er.push(t)}function Cd(t,s,o,c){var h=s.interleaved;return h===null?(o.next=o,dl(s)):(o.next=h.next,h.next=o),s.interleaved=o,Hn(t,c)}function Hn(t,s){t.lanes|=s;var o=t.alternate;for(o!==null&&(o.lanes|=s),o=t,t=t.return;t!==null;)t.childLanes|=s,o=t.alternate,o!==null&&(o.childLanes|=s),o=t,t=t.return;return o.tag===3?o.stateNode:null}var cr=!1;function hl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Vn(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function ur(t,s,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(rt&2)!==0){var h=c.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),c.pending=s,Hn(t,o)}return h=c.interleaved,h===null?(s.next=s,dl(c)):(s.next=h.next,h.next=s),c.interleaved=s,Hn(t,o)}function Za(t,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,Co(t,o)}}function Ad(t,s){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var h=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var b={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};g===null?h=g=b:g=g.next=b,o=o.next}while(o!==null);g===null?h=g=s:g=g.next=s}else h=g=s;o={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:g,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=s:t.next=s,o.lastBaseUpdate=s}function ei(t,s,o,c){var h=t.updateQueue;cr=!1;var g=h.firstBaseUpdate,b=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var R=A,q=R.next;R.next=null,b===null?g=q:b.next=q,b=R;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,A=ae.lastBaseUpdate,A!==b&&(A===null?ae.firstBaseUpdate=q:A.next=q,ae.lastBaseUpdate=R))}if(g!==null){var ce=h.baseState;b=0,ae=q=R=null,A=g;do{var re=A.lane,je=A.eventTime;if((c&re)===re){ae!==null&&(ae=ae.next={eventTime:je,lane:0,tag:A.tag,payload:A.payload,callback:A.callback,next:null});e:{var Ce=t,Re=A;switch(re=s,je=o,Re.tag){case 1:if(Ce=Re.payload,typeof Ce=="function"){ce=Ce.call(je,ce,re);break e}ce=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Re.payload,re=typeof Ce=="function"?Ce.call(je,ce,re):Ce,re==null)break e;ce=J({},ce,re);break e;case 2:cr=!0}}A.callback!==null&&A.lane!==0&&(t.flags|=64,re=h.effects,re===null?h.effects=[A]:re.push(A))}else je={eventTime:je,lane:re,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ae===null?(q=ae=je,R=ce):ae=ae.next=je,b|=re;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;re=A,A=re.next,re.next=null,h.lastBaseUpdate=re,h.shared.pending=null}}while(!0);if(ae===null&&(R=ce),h.baseState=R,h.firstBaseUpdate=q,h.lastBaseUpdate=ae,s=h.shared.interleaved,s!==null){h=s;do b|=h.lane,h=h.next;while(h!==s)}else g===null&&(h.shared.lanes=0);Ir|=b,t.lanes=b,t.memoizedState=ce}}function Td(t,s,o){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var c=t[s],h=c.callback;if(h!==null){if(c.callback=null,c=o,typeof h!="function")throw Error(a(191,h));h.call(c)}}}var Ks={},Pn=ir(Ks),Gs=ir(Ks),Ys=ir(Ks);function Ar(t){if(t===Ks)throw Error(a(174));return t}function fl(t,s){switch(ft(Ys,s),ft(Gs,t),ft(Pn,Ks),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Qe(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=Qe(s,t)}vt(Pn),ft(Pn,s)}function is(){vt(Pn),vt(Gs),vt(Ys)}function Id(t){Ar(Ys.current);var s=Ar(Pn.current),o=Qe(s,t.type);s!==o&&(ft(Gs,t),ft(Pn,o))}function ml(t){Gs.current===t&&(vt(Pn),vt(Gs))}var wt=ir(0);function ti(t){for(var s=t;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var pl=[];function gl(){for(var t=0;t<pl.length;t++)pl[t]._workInProgressVersionPrimary=null;pl.length=0}var ni=T.ReactCurrentDispatcher,vl=T.ReactCurrentBatchConfig,Tr=0,bt=null,It=null,Pt=null,ri=!1,Js=!1,Qs=0,Xv=0;function Bt(){throw Error(a(321))}function yl(t,s){if(s===null)return!1;for(var o=0;o<s.length&&o<t.length;o++)if(!jn(t[o],s[o]))return!1;return!0}function xl(t,s,o,c,h,g){if(Tr=g,bt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,ni.current=t===null||t.memoizedState===null?ny:ry,t=o(c,h),Js){g=0;do{if(Js=!1,Qs=0,25<=g)throw Error(a(301));g+=1,Pt=It=null,s.updateQueue=null,ni.current=sy,t=o(c,h)}while(Js)}if(ni.current=ii,s=It!==null&&It.next!==null,Tr=0,Pt=It=bt=null,ri=!1,s)throw Error(a(300));return t}function jl(){var t=Qs!==0;return Qs=0,t}function _n(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pt===null?bt.memoizedState=Pt=t:Pt=Pt.next=t,Pt}function mn(){if(It===null){var t=bt.alternate;t=t!==null?t.memoizedState:null}else t=It.next;var s=Pt===null?bt.memoizedState:Pt.next;if(s!==null)Pt=s,It=t;else{if(t===null)throw Error(a(310));It=t,t={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},Pt===null?bt.memoizedState=Pt=t:Pt=Pt.next=t}return Pt}function Xs(t,s){return typeof s=="function"?s(t):s}function wl(t){var s=mn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=It,h=c.baseQueue,g=o.pending;if(g!==null){if(h!==null){var b=h.next;h.next=g.next,g.next=b}c.baseQueue=h=g,o.pending=null}if(h!==null){g=h.next,c=c.baseState;var A=b=null,R=null,q=g;do{var ae=q.lane;if((Tr&ae)===ae)R!==null&&(R=R.next={lane:0,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),c=q.hasEagerState?q.eagerState:t(c,q.action);else{var ce={lane:ae,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null};R===null?(A=R=ce,b=c):R=R.next=ce,bt.lanes|=ae,Ir|=ae}q=q.next}while(q!==null&&q!==g);R===null?b=c:R.next=A,jn(c,s.memoizedState)||(Xt=!0),s.memoizedState=c,s.baseState=b,s.baseQueue=R,o.lastRenderedState=c}if(t=o.interleaved,t!==null){h=t;do g=h.lane,bt.lanes|=g,Ir|=g,h=h.next;while(h!==t)}else h===null&&(o.lanes=0);return[s.memoizedState,o.dispatch]}function bl(t){var s=mn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=o.dispatch,h=o.pending,g=s.memoizedState;if(h!==null){o.pending=null;var b=h=h.next;do g=t(g,b.action),b=b.next;while(b!==h);jn(g,s.memoizedState)||(Xt=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),o.lastRenderedState=g}return[g,c]}function Rd(){}function $d(t,s){var o=bt,c=mn(),h=s(),g=!jn(c.memoizedState,h);if(g&&(c.memoizedState=h,Xt=!0),c=c.queue,kl(Ld.bind(null,o,c,t),[t]),c.getSnapshot!==s||g||Pt!==null&&Pt.memoizedState.tag&1){if(o.flags|=2048,Zs(9,_d.bind(null,o,c,h,s),void 0,null),_t===null)throw Error(a(349));(Tr&30)!==0||Pd(o,s,h)}return h}function Pd(t,s,o){t.flags|=16384,t={getSnapshot:s,value:o},s=bt.updateQueue,s===null?(s={lastEffect:null,stores:null},bt.updateQueue=s,s.stores=[t]):(o=s.stores,o===null?s.stores=[t]:o.push(t))}function _d(t,s,o,c){s.value=o,s.getSnapshot=c,Md(s)&&Fd(t)}function Ld(t,s,o){return o(function(){Md(s)&&Fd(t)})}function Md(t){var s=t.getSnapshot;t=t.value;try{var o=s();return!jn(t,o)}catch{return!0}}function Fd(t){var s=Hn(t,1);s!==null&&Nn(s,t,1,-1)}function Od(t){var s=_n();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Xs,lastRenderedState:t},s.queue=t,t=t.dispatch=ty.bind(null,bt,t),[s.memoizedState,t]}function Zs(t,s,o,c){return t={tag:t,create:s,destroy:o,deps:c,next:null},s=bt.updateQueue,s===null?(s={lastEffect:null,stores:null},bt.updateQueue=s,s.lastEffect=t.next=t):(o=s.lastEffect,o===null?s.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,s.lastEffect=t)),t}function zd(){return mn().memoizedState}function si(t,s,o,c){var h=_n();bt.flags|=t,h.memoizedState=Zs(1|s,o,void 0,c===void 0?null:c)}function ai(t,s,o,c){var h=mn();c=c===void 0?null:c;var g=void 0;if(It!==null){var b=It.memoizedState;if(g=b.destroy,c!==null&&yl(c,b.deps)){h.memoizedState=Zs(s,o,g,c);return}}bt.flags|=t,h.memoizedState=Zs(1|s,o,g,c)}function Dd(t,s){return si(8390656,8,t,s)}function kl(t,s){return ai(2048,8,t,s)}function Bd(t,s){return ai(4,2,t,s)}function Ud(t,s){return ai(4,4,t,s)}function Wd(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function Hd(t,s,o){return o=o!=null?o.concat([t]):null,ai(4,4,Wd.bind(null,s,t),o)}function Sl(){}function Vd(t,s){var o=mn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&yl(s,c[1])?c[0]:(o.memoizedState=[t,s],t)}function qd(t,s){var o=mn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&yl(s,c[1])?c[0]:(t=t(),o.memoizedState=[t,s],t)}function Kd(t,s,o){return(Tr&21)===0?(t.baseState&&(t.baseState=!1,Xt=!0),t.memoizedState=o):(jn(o,s)||(o=ku(),bt.lanes|=o,Ir|=o,t.baseState=!0),s)}function Zv(t,s){var o=lt;lt=o!==0&&4>o?o:4,t(!0);var c=vl.transition;vl.transition={};try{t(!1),s()}finally{lt=o,vl.transition=c}}function Gd(){return mn().memoizedState}function ey(t,s,o){var c=mr(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Yd(t))Jd(s,o);else if(o=Cd(t,s,o,c),o!==null){var h=Kt();Nn(o,t,c,h),Qd(o,s,c)}}function ty(t,s,o){var c=mr(t),h={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Yd(t))Jd(s,h);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var b=s.lastRenderedState,A=g(b,o);if(h.hasEagerState=!0,h.eagerState=A,jn(A,b)){var R=s.interleaved;R===null?(h.next=h,dl(s)):(h.next=R.next,R.next=h),s.interleaved=h;return}}catch{}finally{}o=Cd(t,s,h,c),o!==null&&(h=Kt(),Nn(o,t,c,h),Qd(o,s,c))}}function Yd(t){var s=t.alternate;return t===bt||s!==null&&s===bt}function Jd(t,s){Js=ri=!0;var o=t.pending;o===null?s.next=s:(s.next=o.next,o.next=s),t.pending=s}function Qd(t,s,o){if((o&4194240)!==0){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,Co(t,o)}}var ii={readContext:fn,useCallback:Bt,useContext:Bt,useEffect:Bt,useImperativeHandle:Bt,useInsertionEffect:Bt,useLayoutEffect:Bt,useMemo:Bt,useReducer:Bt,useRef:Bt,useState:Bt,useDebugValue:Bt,useDeferredValue:Bt,useTransition:Bt,useMutableSource:Bt,useSyncExternalStore:Bt,useId:Bt,unstable_isNewReconciler:!1},ny={readContext:fn,useCallback:function(t,s){return _n().memoizedState=[t,s===void 0?null:s],t},useContext:fn,useEffect:Dd,useImperativeHandle:function(t,s,o){return o=o!=null?o.concat([t]):null,si(4194308,4,Wd.bind(null,s,t),o)},useLayoutEffect:function(t,s){return si(4194308,4,t,s)},useInsertionEffect:function(t,s){return si(4,2,t,s)},useMemo:function(t,s){var o=_n();return s=s===void 0?null:s,t=t(),o.memoizedState=[t,s],t},useReducer:function(t,s,o){var c=_n();return s=o!==void 0?o(s):s,c.memoizedState=c.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},c.queue=t,t=t.dispatch=ey.bind(null,bt,t),[c.memoizedState,t]},useRef:function(t){var s=_n();return t={current:t},s.memoizedState=t},useState:Od,useDebugValue:Sl,useDeferredValue:function(t){return _n().memoizedState=t},useTransition:function(){var t=Od(!1),s=t[0];return t=Zv.bind(null,t[1]),_n().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,o){var c=bt,h=_n();if(yt){if(o===void 0)throw Error(a(407));o=o()}else{if(o=s(),_t===null)throw Error(a(349));(Tr&30)!==0||Pd(c,s,o)}h.memoizedState=o;var g={value:o,getSnapshot:s};return h.queue=g,Dd(Ld.bind(null,c,g,t),[t]),c.flags|=2048,Zs(9,_d.bind(null,c,g,o,s),void 0,null),o},useId:function(){var t=_n(),s=_t.identifierPrefix;if(yt){var o=Wn,c=Un;o=(c&~(1<<32-xn(c)-1)).toString(32)+o,s=":"+s+"R"+o,o=Qs++,0<o&&(s+="H"+o.toString(32)),s+=":"}else o=Xv++,s=":"+s+"r"+o.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},ry={readContext:fn,useCallback:Vd,useContext:fn,useEffect:kl,useImperativeHandle:Hd,useInsertionEffect:Bd,useLayoutEffect:Ud,useMemo:qd,useReducer:wl,useRef:zd,useState:function(){return wl(Xs)},useDebugValue:Sl,useDeferredValue:function(t){var s=mn();return Kd(s,It.memoizedState,t)},useTransition:function(){var t=wl(Xs)[0],s=mn().memoizedState;return[t,s]},useMutableSource:Rd,useSyncExternalStore:$d,useId:Gd,unstable_isNewReconciler:!1},sy={readContext:fn,useCallback:Vd,useContext:fn,useEffect:kl,useImperativeHandle:Hd,useInsertionEffect:Bd,useLayoutEffect:Ud,useMemo:qd,useReducer:bl,useRef:zd,useState:function(){return bl(Xs)},useDebugValue:Sl,useDeferredValue:function(t){var s=mn();return It===null?s.memoizedState=t:Kd(s,It.memoizedState,t)},useTransition:function(){var t=bl(Xs)[0],s=mn().memoizedState;return[t,s]},useMutableSource:Rd,useSyncExternalStore:$d,useId:Gd,unstable_isNewReconciler:!1};function bn(t,s){if(t&&t.defaultProps){s=J({},s),t=t.defaultProps;for(var o in t)s[o]===void 0&&(s[o]=t[o]);return s}return s}function Nl(t,s,o,c){s=t.memoizedState,o=o(c,s),o=o==null?s:J({},s,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var oi={isMounted:function(t){return(t=t._reactInternals)?Tn(t)===t:!1},enqueueSetState:function(t,s,o){t=t._reactInternals;var c=Kt(),h=mr(t),g=Vn(c,h);g.payload=s,o!=null&&(g.callback=o),s=ur(t,g,h),s!==null&&(Nn(s,t,h,c),Za(s,t,h))},enqueueReplaceState:function(t,s,o){t=t._reactInternals;var c=Kt(),h=mr(t),g=Vn(c,h);g.tag=1,g.payload=s,o!=null&&(g.callback=o),s=ur(t,g,h),s!==null&&(Nn(s,t,h,c),Za(s,t,h))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var o=Kt(),c=mr(t),h=Vn(o,c);h.tag=2,s!=null&&(h.callback=s),s=ur(t,h,c),s!==null&&(Nn(s,t,c,o),Za(s,t,c))}};function Xd(t,s,o,c,h,g,b){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,b):s.prototype&&s.prototype.isPureReactComponent?!zs(o,c)||!zs(h,g):!0}function Zd(t,s,o){var c=!1,h=or,g=s.contextType;return typeof g=="object"&&g!==null?g=fn(g):(h=Qt(s)?Sr:Dt.current,c=s.contextTypes,g=(c=c!=null)?Zr(t,h):or),s=new s(o,g),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=oi,t.stateNode=s,s._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=h,t.__reactInternalMemoizedMaskedChildContext=g),s}function eh(t,s,o,c){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,c),s.state!==t&&oi.enqueueReplaceState(s,s.state,null)}function Cl(t,s,o,c){var h=t.stateNode;h.props=o,h.state=t.memoizedState,h.refs={},hl(t);var g=s.contextType;typeof g=="object"&&g!==null?h.context=fn(g):(g=Qt(s)?Sr:Dt.current,h.context=Zr(t,g)),h.state=t.memoizedState,g=s.getDerivedStateFromProps,typeof g=="function"&&(Nl(t,s,g,o),h.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(s=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),s!==h.state&&oi.enqueueReplaceState(h,h.state,null),ei(t,o,h,c),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308)}function os(t,s){try{var o="",c=s;do o+=$e(c),c=c.return;while(c);var h=o}catch(g){h=`
39
39
  Error generating stack: `+g.message+`
40
- `+g.stack}return{value:t,source:s,stack:h,digest:null}}function Cl(t,s,o){return{value:t,source:null,stack:o??null,digest:s??null}}function El(t,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var ry=typeof WeakMap=="function"?WeakMap:Map;function nh(t,s,o){o=Vn(-1,o),o.tag=3,o.payload={element:null};var c=s.value;return o.callback=function(){mi||(mi=!0,Ul=c),El(t,s)},o}function rh(t,s,o){o=Vn(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var h=s.value;o.payload=function(){return c(h)},o.callback=function(){El(t,s)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(o.callback=function(){El(t,s),typeof c!="function"&&(hr===null?hr=new Set([this]):hr.add(this));var b=s.stack;this.componentDidCatch(s.value,{componentStack:b!==null?b:""})}),o}function sh(t,s,o){var c=t.pingCache;if(c===null){c=t.pingCache=new ry;var h=new Set;c.set(s,h)}else h=c.get(s),h===void 0&&(h=new Set,c.set(s,h));h.has(o)||(h.add(o),t=vy.bind(null,t,s,o),s.then(t,t))}function ah(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function ih(t,s,o,c,h){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=Vn(-1,1),s.tag=2,ur(o,s,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=h,t)}var sy=T.ReactCurrentOwner,Xt=!1;function qt(t,s,o,c){s.child=t===null?Cd(s,null,o,c):rs(s,t.child,o,c)}function oh(t,s,o,c,h){o=o.render;var g=s.ref;return as(s,h),c=yl(t,s,o,c,g,h),o=xl(),t!==null&&!Xt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~h,qn(t,s,h)):(yt&&o&&tl(s),s.flags|=1,qt(t,s,c,h),s.child)}function lh(t,s,o,c,h){if(t===null){var g=o.type;return typeof g=="function"&&!Yl(g)&&g.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=g,ch(t,s,g,c,h)):(t=ji(o.type,null,c,s,s.mode,h),t.ref=s.ref,t.return=s,s.child=t)}if(g=t.child,(t.lanes&h)===0){var b=g.memoizedProps;if(o=o.compare,o=o!==null?o:zs,o(b,c)&&t.ref===s.ref)return qn(t,s,h)}return s.flags|=1,t=gr(g,c),t.ref=s.ref,t.return=s,s.child=t}function ch(t,s,o,c,h){if(t!==null){var g=t.memoizedProps;if(zs(g,c)&&t.ref===s.ref)if(Xt=!1,s.pendingProps=c=g,(t.lanes&h)!==0)(t.flags&131072)!==0&&(Xt=!0);else return s.lanes=t.lanes,qn(t,s,h)}return Al(t,s,o,c,h)}function uh(t,s,o){var c=s.pendingProps,h=c.children,g=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},ft(cs,cn),cn|=o;else{if((o&1073741824)===0)return t=g!==null?g.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,ft(cs,cn),cn|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:o,ft(cs,cn),cn|=c}else g!==null?(c=g.baseLanes|o,s.memoizedState=null):c=o,ft(cs,cn),cn|=c;return qt(t,s,h,o),s.child}function dh(t,s){var o=s.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Al(t,s,o,c,h){var g=Qt(o)?Sr:Dt.current;return g=Zr(s,g),as(s,h),o=yl(t,s,o,c,g,h),c=xl(),t!==null&&!Xt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~h,qn(t,s,h)):(yt&&c&&tl(s),s.flags|=1,qt(t,s,o,h),s.child)}function hh(t,s,o,c,h){if(Qt(o)){var g=!0;Va(s)}else g=!1;if(as(s,h),s.stateNode===null)ci(t,s),eh(s,o,c),Nl(s,o,c,h),c=!0;else if(t===null){var b=s.stateNode,A=s.memoizedProps;b.props=A;var R=b.context,q=o.contextType;typeof q=="object"&&q!==null?q=fn(q):(q=Qt(o)?Sr:Dt.current,q=Zr(s,q));var ae=o.getDerivedStateFromProps,ce=typeof ae=="function"||typeof b.getSnapshotBeforeUpdate=="function";ce||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(A!==c||R!==q)&&th(s,b,c,q),cr=!1;var re=s.memoizedState;b.state=re,ei(s,c,b,h),R=s.memoizedState,A!==c||re!==R||Jt.current||cr?(typeof ae=="function"&&(Sl(s,o,ae,c),R=s.memoizedState),(A=cr||Zd(s,o,A,c,re,R,q))?(ce||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(s.flags|=4194308)):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=R),b.props=c,b.state=R,b.context=q,c=A):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{b=s.stateNode,Ad(t,s),A=s.memoizedProps,q=s.type===s.elementType?A:bn(s.type,A),b.props=q,ce=s.pendingProps,re=b.context,R=o.contextType,typeof R=="object"&&R!==null?R=fn(R):(R=Qt(o)?Sr:Dt.current,R=Zr(s,R));var je=o.getDerivedStateFromProps;(ae=typeof je=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(A!==ce||re!==R)&&th(s,b,c,R),cr=!1,re=s.memoizedState,b.state=re,ei(s,c,b,h);var Ce=s.memoizedState;A!==ce||re!==Ce||Jt.current||cr?(typeof je=="function"&&(Sl(s,o,je,c),Ce=s.memoizedState),(q=cr||Zd(s,o,q,c,re,Ce,R)||!1)?(ae||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(c,Ce,R),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(c,Ce,R)),typeof b.componentDidUpdate=="function"&&(s.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof b.componentDidUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=Ce),b.props=c,b.state=Ce,b.context=R,c=q):(typeof b.componentDidUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=1024),c=!1)}return Tl(t,s,o,c,g,h)}function Tl(t,s,o,c,h,g){dh(t,s);var b=(s.flags&128)!==0;if(!c&&!b)return h&&vd(s,o,!1),qn(t,s,g);c=s.stateNode,sy.current=s;var A=b&&typeof o.getDerivedStateFromError!="function"?null:c.render();return s.flags|=1,t!==null&&b?(s.child=rs(s,t.child,null,g),s.child=rs(s,null,A,g)):qt(t,s,A,g),s.memoizedState=c.state,h&&vd(s,o,!0),s.child}function fh(t){var s=t.stateNode;s.pendingContext?pd(t,s.pendingContext,s.pendingContext!==s.context):s.context&&pd(t,s.context,!1),hl(t,s.containerInfo)}function mh(t,s,o,c,h){return ns(),al(h),s.flags|=256,qt(t,s,o,c),s.child}var Il={dehydrated:null,treeContext:null,retryLane:0};function Rl(t){return{baseLanes:t,cachePool:null,transitions:null}}function ph(t,s,o){var c=s.pendingProps,h=wt.current,g=!1,b=(s.flags&128)!==0,A;if((A=b)||(A=t!==null&&t.memoizedState===null?!1:(h&2)!==0),A?(g=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(h|=1),ft(wt,h&1),t===null)return sl(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(b=c.children,t=c.fallback,g?(c=s.mode,g=s.child,b={mode:"hidden",children:b},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=b):g=wi(b,c,0,null),t=_r(t,c,o,null),g.return=s,t.return=s,g.sibling=t,s.child=g,s.child.memoizedState=Rl(o),s.memoizedState=Il,t):$l(s,b));if(h=t.memoizedState,h!==null&&(A=h.dehydrated,A!==null))return ay(t,s,b,c,A,h,o);if(g){g=c.fallback,b=s.mode,h=t.child,A=h.sibling;var R={mode:"hidden",children:c.children};return(b&1)===0&&s.child!==h?(c=s.child,c.childLanes=0,c.pendingProps=R,s.deletions=null):(c=gr(h,R),c.subtreeFlags=h.subtreeFlags&14680064),A!==null?g=gr(A,g):(g=_r(g,b,o,null),g.flags|=2),g.return=s,c.return=s,c.sibling=g,s.child=c,c=g,g=s.child,b=t.child.memoizedState,b=b===null?Rl(o):{baseLanes:b.baseLanes|o,cachePool:null,transitions:b.transitions},g.memoizedState=b,g.childLanes=t.childLanes&~o,s.memoizedState=Il,c}return g=t.child,t=g.sibling,c=gr(g,{mode:"visible",children:c.children}),(s.mode&1)===0&&(c.lanes=o),c.return=s,c.sibling=null,t!==null&&(o=s.deletions,o===null?(s.deletions=[t],s.flags|=16):o.push(t)),s.child=c,s.memoizedState=null,c}function $l(t,s){return s=wi({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function li(t,s,o,c){return c!==null&&al(c),rs(s,t.child,null,o),t=$l(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function ay(t,s,o,c,h,g,b){if(o)return s.flags&256?(s.flags&=-257,c=Cl(Error(a(422))),li(t,s,b,c)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(g=c.fallback,h=s.mode,c=wi({mode:"visible",children:c.children},h,0,null),g=_r(g,h,b,null),g.flags|=2,c.return=s,g.return=s,c.sibling=g,s.child=c,(s.mode&1)!==0&&rs(s,t.child,null,b),s.child.memoizedState=Rl(b),s.memoizedState=Il,g);if((s.mode&1)===0)return li(t,s,b,null);if(h.data==="$!"){if(c=h.nextSibling&&h.nextSibling.dataset,c)var A=c.dgst;return c=A,g=Error(a(419)),c=Cl(g,c,void 0),li(t,s,b,c)}if(A=(b&t.childLanes)!==0,Xt||A){if(c=_t,c!==null){switch(b&-b){case 4:h=2;break;case 16:h=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:h=32;break;case 536870912:h=268435456;break;default:h=0}h=(h&(c.suspendedLanes|b))!==0?0:h,h!==0&&h!==g.retryLane&&(g.retryLane=h,Hn(t,h),Nn(c,t,h,-1))}return Gl(),c=Cl(Error(a(421))),li(t,s,b,c)}return h.data==="$?"?(s.flags|=128,s.child=t.child,s=yy.bind(null,t),h._reactRetry=s,null):(t=g.treeContext,ln=ar(h.nextSibling),on=s,yt=!0,wn=null,t!==null&&(dn[hn++]=Un,dn[hn++]=Wn,dn[hn++]=Nr,Un=t.id,Wn=t.overflow,Nr=s),s=$l(s,c.children),s.flags|=4096,s)}function gh(t,s,o){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s),cl(t.return,s,o)}function Pl(t,s,o,c,h){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:h}:(g.isBackwards=s,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=o,g.tailMode=h)}function vh(t,s,o){var c=s.pendingProps,h=c.revealOrder,g=c.tail;if(qt(t,s,c.children,o),c=wt.current,(c&2)!==0)c=c&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&gh(t,o,s);else if(t.tag===19)gh(t,o,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(ft(wt,c),(s.mode&1)===0)s.memoizedState=null;else switch(h){case"forwards":for(o=s.child,h=null;o!==null;)t=o.alternate,t!==null&&ti(t)===null&&(h=o),o=o.sibling;o=h,o===null?(h=s.child,s.child=null):(h=o.sibling,o.sibling=null),Pl(s,!1,h,o,g);break;case"backwards":for(o=null,h=s.child,s.child=null;h!==null;){if(t=h.alternate,t!==null&&ti(t)===null){s.child=h;break}t=h.sibling,h.sibling=o,o=h,h=t}Pl(s,!0,o,null,g);break;case"together":Pl(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function ci(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function qn(t,s,o){if(t!==null&&(s.dependencies=t.dependencies),Ir|=s.lanes,(o&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(a(153));if(s.child!==null){for(t=s.child,o=gr(t,t.pendingProps),s.child=o,o.return=s;t.sibling!==null;)t=t.sibling,o=o.sibling=gr(t,t.pendingProps),o.return=s;o.sibling=null}return s.child}function iy(t,s,o){switch(s.tag){case 3:fh(s),ns();break;case 5:Rd(s);break;case 1:Qt(s.type)&&Va(s);break;case 4:hl(s,s.stateNode.containerInfo);break;case 10:var c=s.type._context,h=s.memoizedProps.value;ft(Qa,c._currentValue),c._currentValue=h;break;case 13:if(c=s.memoizedState,c!==null)return c.dehydrated!==null?(ft(wt,wt.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?ph(t,s,o):(ft(wt,wt.current&1),t=qn(t,s,o),t!==null?t.sibling:null);ft(wt,wt.current&1);break;case 19:if(c=(o&s.childLanes)!==0,(t.flags&128)!==0){if(c)return vh(t,s,o);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),ft(wt,wt.current),c)break;return null;case 22:case 23:return s.lanes=0,uh(t,s,o)}return qn(t,s,o)}var yh,_l,xh,jh;yh=function(t,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},_l=function(){},xh=function(t,s,o,c){var h=t.memoizedProps;if(h!==c){t=s.stateNode,Ar(Pn.current);var g=null;switch(o){case"input":h=Te(t,h),c=Te(t,c),g=[];break;case"select":h=J({},h,{value:void 0}),c=J({},c,{value:void 0}),g=[];break;case"textarea":h=dt(t,h),c=dt(t,c),g=[];break;default:typeof h.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Ua)}qe(o,c);var b;o=null;for(q in h)if(!c.hasOwnProperty(q)&&h.hasOwnProperty(q)&&h[q]!=null)if(q==="style"){var A=h[q];for(b in A)A.hasOwnProperty(b)&&(o||(o={}),o[b]="")}else q!=="dangerouslySetInnerHTML"&&q!=="children"&&q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&q!=="autoFocus"&&(l.hasOwnProperty(q)?g||(g=[]):(g=g||[]).push(q,null));for(q in c){var R=c[q];if(A=h!=null?h[q]:void 0,c.hasOwnProperty(q)&&R!==A&&(R!=null||A!=null))if(q==="style")if(A){for(b in A)!A.hasOwnProperty(b)||R&&R.hasOwnProperty(b)||(o||(o={}),o[b]="");for(b in R)R.hasOwnProperty(b)&&A[b]!==R[b]&&(o||(o={}),o[b]=R[b])}else o||(g||(g=[]),g.push(q,o)),o=R;else q==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,A=A?A.__html:void 0,R!=null&&A!==R&&(g=g||[]).push(q,R)):q==="children"?typeof R!="string"&&typeof R!="number"||(g=g||[]).push(q,""+R):q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&(l.hasOwnProperty(q)?(R!=null&&q==="onScroll"&&gt("scroll",t),g||A===R||(g=[])):(g=g||[]).push(q,R))}o&&(g=g||[]).push("style",o);var q=g;(s.updateQueue=q)&&(s.flags|=4)}},jh=function(t,s,o,c){o!==c&&(s.flags|=4)};function ea(t,s){if(!yt)switch(t.tailMode){case"hidden":s=t.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Ut(t){var s=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(s)for(var h=t.child;h!==null;)o|=h.lanes|h.childLanes,c|=h.subtreeFlags&14680064,c|=h.flags&14680064,h.return=t,h=h.sibling;else for(h=t.child;h!==null;)o|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=t,h=h.sibling;return t.subtreeFlags|=c,t.childLanes=o,s}function oy(t,s,o){var c=s.pendingProps;switch(nl(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ut(s),null;case 1:return Qt(s.type)&&Ha(),Ut(s),null;case 3:return c=s.stateNode,is(),vt(Jt),vt(Dt),pl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ya(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,wn!==null&&(Vl(wn),wn=null))),_l(t,s),Ut(s),null;case 5:fl(s);var h=Ar(Ys.current);if(o=s.type,t!==null&&s.stateNode!=null)xh(t,s,o,c,h),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!c){if(s.stateNode===null)throw Error(a(166));return Ut(s),null}if(t=Ar(Pn.current),Ya(s)){c=s.stateNode,o=s.type;var g=s.memoizedProps;switch(c[$n]=s,c[Hs]=g,t=(s.mode&1)!==0,o){case"dialog":gt("cancel",c),gt("close",c);break;case"iframe":case"object":case"embed":gt("load",c);break;case"video":case"audio":for(h=0;h<Bs.length;h++)gt(Bs[h],c);break;case"source":gt("error",c);break;case"img":case"image":case"link":gt("error",c),gt("load",c);break;case"details":gt("toggle",c);break;case"input":_e(c,g),gt("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},gt("invalid",c);break;case"textarea":et(c,g),gt("invalid",c)}qe(o,g),h=null;for(var b in g)if(g.hasOwnProperty(b)){var A=g[b];b==="children"?typeof A=="string"?c.textContent!==A&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,A,t),h=["children",A]):typeof A=="number"&&c.textContent!==""+A&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,A,t),h=["children",""+A]):l.hasOwnProperty(b)&&A!=null&&b==="onScroll"&&gt("scroll",c)}switch(o){case"input":Oe(c),ct(c,g,!0);break;case"textarea":Oe(c),Ie(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=Ua)}c=h,s.updateQueue=c,c!==null&&(s.flags|=4)}else{b=h.nodeType===9?h:h.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=We(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=b.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=b.createElement(o,{is:c.is}):(t=b.createElement(o),o==="select"&&(b=t,c.multiple?b.multiple=!0:c.size&&(b.size=c.size))):t=b.createElementNS(t,o),t[$n]=s,t[Hs]=c,yh(t,s,!1,!1),s.stateNode=t;e:{switch(b=H(o,c),o){case"dialog":gt("cancel",t),gt("close",t),h=c;break;case"iframe":case"object":case"embed":gt("load",t),h=c;break;case"video":case"audio":for(h=0;h<Bs.length;h++)gt(Bs[h],t);h=c;break;case"source":gt("error",t),h=c;break;case"img":case"image":case"link":gt("error",t),gt("load",t),h=c;break;case"details":gt("toggle",t),h=c;break;case"input":_e(t,c),h=Te(t,c),gt("invalid",t);break;case"option":h=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},h=J({},c,{value:void 0}),gt("invalid",t);break;case"textarea":et(t,c),h=dt(t,c),gt("invalid",t);break;default:h=c}qe(o,h),A=h;for(g in A)if(A.hasOwnProperty(g)){var R=A[g];g==="style"?ht(t,R):g==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&ye(t,R)):g==="children"?typeof R=="string"?(o!=="textarea"||R!=="")&&ze(t,R):typeof R=="number"&&ze(t,""+R):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(l.hasOwnProperty(g)?R!=null&&g==="onScroll"&&gt("scroll",t):R!=null&&$(t,g,R,b))}switch(o){case"input":Oe(t),ct(t,c,!1);break;case"textarea":Oe(t),Ie(t);break;case"option":c.value!=null&&t.setAttribute("value",""+he(c.value));break;case"select":t.multiple=!!c.multiple,g=c.value,g!=null?Be(t,!!c.multiple,g,!1):c.defaultValue!=null&&Be(t,!!c.multiple,c.defaultValue,!0);break;default:typeof h.onClick=="function"&&(t.onclick=Ua)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Ut(s),null;case 6:if(t&&s.stateNode!=null)jh(t,s,t.memoizedProps,c);else{if(typeof c!="string"&&s.stateNode===null)throw Error(a(166));if(o=Ar(Ys.current),Ar(Pn.current),Ya(s)){if(c=s.stateNode,o=s.memoizedProps,c[$n]=s,(g=c.nodeValue!==o)&&(t=on,t!==null))switch(t.tag){case 3:Ba(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ba(c.nodeValue,o,(t.mode&1)!==0)}g&&(s.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[$n]=s,s.stateNode=c}return Ut(s),null;case 13:if(vt(wt),c=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(yt&&ln!==null&&(s.mode&1)!==0&&(s.flags&128)===0)kd(),ns(),s.flags|=98560,g=!1;else if(g=Ya(s),c!==null&&c.dehydrated!==null){if(t===null){if(!g)throw Error(a(318));if(g=s.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(a(317));g[$n]=s}else ns(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Ut(s),g=!1}else wn!==null&&(Vl(wn),wn=null),g=!0;if(!g)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=o,s):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(wt.current&1)!==0?Rt===0&&(Rt=3):Gl())),s.updateQueue!==null&&(s.flags|=4),Ut(s),null);case 4:return is(),_l(t,s),t===null&&Us(s.stateNode.containerInfo),Ut(s),null;case 10:return ll(s.type._context),Ut(s),null;case 17:return Qt(s.type)&&Ha(),Ut(s),null;case 19:if(vt(wt),g=s.memoizedState,g===null)return Ut(s),null;if(c=(s.flags&128)!==0,b=g.rendering,b===null)if(c)ea(g,!1);else{if(Rt!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(b=ti(t),b!==null){for(s.flags|=128,ea(g,!1),c=b.updateQueue,c!==null&&(s.updateQueue=c,s.flags|=4),s.subtreeFlags=0,c=o,o=s.child;o!==null;)g=o,t=c,g.flags&=14680066,b=g.alternate,b===null?(g.childLanes=0,g.lanes=t,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=b.childLanes,g.lanes=b.lanes,g.child=b.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=b.memoizedProps,g.memoizedState=b.memoizedState,g.updateQueue=b.updateQueue,g.type=b.type,t=b.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return ft(wt,wt.current&1|2),s.child}t=t.sibling}g.tail!==null&&Ct()>us&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304)}else{if(!c)if(t=ti(b),t!==null){if(s.flags|=128,c=!0,o=t.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),ea(g,!0),g.tail===null&&g.tailMode==="hidden"&&!b.alternate&&!yt)return Ut(s),null}else 2*Ct()-g.renderingStartTime>us&&o!==1073741824&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304);g.isBackwards?(b.sibling=s.child,s.child=b):(o=g.last,o!==null?o.sibling=b:s.child=b,g.last=b)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=Ct(),s.sibling=null,o=wt.current,ft(wt,c?o&1|2:o&1),s):(Ut(s),null);case 22:case 23:return Kl(),c=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(s.flags|=8192),c&&(s.mode&1)!==0?(cn&1073741824)!==0&&(Ut(s),s.subtreeFlags&6&&(s.flags|=8192)):Ut(s),null;case 24:return null;case 25:return null}throw Error(a(156,s.tag))}function ly(t,s){switch(nl(s),s.tag){case 1:return Qt(s.type)&&Ha(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return is(),vt(Jt),vt(Dt),pl(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return fl(s),null;case 13:if(vt(wt),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(a(340));ns()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return vt(wt),null;case 4:return is(),null;case 10:return ll(s.type._context),null;case 22:case 23:return Kl(),null;case 24:return null;default:return null}}var ui=!1,Wt=!1,cy=typeof WeakSet=="function"?WeakSet:Set,Se=null;function ls(t,s){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){St(t,s,c)}else o.current=null}function Ll(t,s,o){try{o()}catch(c){St(t,s,c)}}var wh=!1;function uy(t,s){if(Ko=Ia,t=Zu(),zo(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var h=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var b=0,A=-1,R=-1,q=0,ae=0,ce=t,re=null;t:for(;;){for(var je;ce!==o||h!==0&&ce.nodeType!==3||(A=b+h),ce!==g||c!==0&&ce.nodeType!==3||(R=b+c),ce.nodeType===3&&(b+=ce.nodeValue.length),(je=ce.firstChild)!==null;)re=ce,ce=je;for(;;){if(ce===t)break t;if(re===o&&++q===h&&(A=b),re===g&&++ae===c&&(R=b),(je=ce.nextSibling)!==null)break;ce=re,re=ce.parentNode}ce=je}o=A===-1||R===-1?null:{start:A,end:R}}else o=null}o=o||{start:0,end:0}}else o=null;for(Go={focusedElem:t,selectionRange:o},Ia=!1,Se=s;Se!==null;)if(s=Se,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Se=t;else for(;Se!==null;){s=Se;try{var Ce=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Re=Ce.memoizedProps,Et=Ce.memoizedState,O=s.stateNode,L=O.getSnapshotBeforeUpdate(s.elementType===s.type?Re:bn(s.type,Re),Et);O.__reactInternalSnapshotBeforeUpdate=L}break;case 3:var W=s.stateNode.containerInfo;W.nodeType===1?W.textContent="":W.nodeType===9&&W.documentElement&&W.removeChild(W.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(fe){St(s,s.return,fe)}if(t=s.sibling,t!==null){t.return=s.return,Se=t;break}Se=s.return}return Ce=wh,wh=!1,Ce}function ta(t,s,o){var c=s.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var h=c=c.next;do{if((h.tag&t)===t){var g=h.destroy;h.destroy=void 0,g!==void 0&&Ll(s,o,g)}h=h.next}while(h!==c)}}function di(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==s)}}function Ml(t){var s=t.ref;if(s!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof s=="function"?s(t):s.current=t}}function bh(t){var s=t.alternate;s!==null&&(t.alternate=null,bh(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[$n],delete s[Hs],delete s[Xo],delete s[qv],delete s[Kv])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function kh(t){return t.tag===5||t.tag===3||t.tag===4}function Sh(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||kh(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Fl(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(t,s):o.insertBefore(t,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(t,o)):(s=o,s.appendChild(t)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ua));else if(c!==4&&(t=t.child,t!==null))for(Fl(t,s,o),t=t.sibling;t!==null;)Fl(t,s,o),t=t.sibling}function Ol(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.insertBefore(t,s):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Ol(t,s,o),t=t.sibling;t!==null;)Ol(t,s,o),t=t.sibling}var Ft=null,kn=!1;function dr(t,s,o){for(o=o.child;o!==null;)Nh(t,s,o),o=o.sibling}function Nh(t,s,o){if(Rn&&typeof Rn.onCommitFiberUnmount=="function")try{Rn.onCommitFiberUnmount(Sa,o)}catch{}switch(o.tag){case 5:Wt||ls(o,s);case 6:var c=Ft,h=kn;Ft=null,dr(t,s,o),Ft=c,kn=h,Ft!==null&&(kn?(t=Ft,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):Ft.removeChild(o.stateNode));break;case 18:Ft!==null&&(kn?(t=Ft,o=o.stateNode,t.nodeType===8?Qo(t.parentNode,o):t.nodeType===1&&Qo(t,o),Ps(t)):Qo(Ft,o.stateNode));break;case 4:c=Ft,h=kn,Ft=o.stateNode.containerInfo,kn=!0,dr(t,s,o),Ft=c,kn=h;break;case 0:case 11:case 14:case 15:if(!Wt&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){h=c=c.next;do{var g=h,b=g.destroy;g=g.tag,b!==void 0&&((g&2)!==0||(g&4)!==0)&&Ll(o,s,b),h=h.next}while(h!==c)}dr(t,s,o);break;case 1:if(!Wt&&(ls(o,s),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(A){St(o,s,A)}dr(t,s,o);break;case 21:dr(t,s,o);break;case 22:o.mode&1?(Wt=(c=Wt)||o.memoizedState!==null,dr(t,s,o),Wt=c):dr(t,s,o);break;default:dr(t,s,o)}}function Ch(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new cy),s.forEach(function(c){var h=xy.bind(null,t,c);o.has(c)||(o.add(c),c.then(h,h))})}}function Sn(t,s){var o=s.deletions;if(o!==null)for(var c=0;c<o.length;c++){var h=o[c];try{var g=t,b=s,A=b;e:for(;A!==null;){switch(A.tag){case 5:Ft=A.stateNode,kn=!1;break e;case 3:Ft=A.stateNode.containerInfo,kn=!0;break e;case 4:Ft=A.stateNode.containerInfo,kn=!0;break e}A=A.return}if(Ft===null)throw Error(a(160));Nh(g,b,h),Ft=null,kn=!1;var R=h.alternate;R!==null&&(R.return=null),h.return=null}catch(q){St(h,s,q)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Eh(s,t),s=s.sibling}function Eh(t,s){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Sn(s,t),Ln(t),c&4){try{ta(3,t,t.return),di(3,t)}catch(Re){St(t,t.return,Re)}try{ta(5,t,t.return)}catch(Re){St(t,t.return,Re)}}break;case 1:Sn(s,t),Ln(t),c&512&&o!==null&&ls(o,o.return);break;case 5:if(Sn(s,t),Ln(t),c&512&&o!==null&&ls(o,o.return),t.flags&32){var h=t.stateNode;try{ze(h,"")}catch(Re){St(t,t.return,Re)}}if(c&4&&(h=t.stateNode,h!=null)){var g=t.memoizedProps,b=o!==null?o.memoizedProps:g,A=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{A==="input"&&g.type==="radio"&&g.name!=null&&Ve(h,g),H(A,b);var q=H(A,g);for(b=0;b<R.length;b+=2){var ae=R[b],ce=R[b+1];ae==="style"?ht(h,ce):ae==="dangerouslySetInnerHTML"?ye(h,ce):ae==="children"?ze(h,ce):$(h,ae,ce,q)}switch(A){case"input":Ge(h,g);break;case"textarea":De(h,g);break;case"select":var re=h._wrapperState.wasMultiple;h._wrapperState.wasMultiple=!!g.multiple;var je=g.value;je!=null?Be(h,!!g.multiple,je,!1):re!==!!g.multiple&&(g.defaultValue!=null?Be(h,!!g.multiple,g.defaultValue,!0):Be(h,!!g.multiple,g.multiple?[]:"",!1))}h[Hs]=g}catch(Re){St(t,t.return,Re)}}break;case 6:if(Sn(s,t),Ln(t),c&4){if(t.stateNode===null)throw Error(a(162));h=t.stateNode,g=t.memoizedProps;try{h.nodeValue=g}catch(Re){St(t,t.return,Re)}}break;case 3:if(Sn(s,t),Ln(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Ps(s.containerInfo)}catch(Re){St(t,t.return,Re)}break;case 4:Sn(s,t),Ln(t);break;case 13:Sn(s,t),Ln(t),h=t.child,h.flags&8192&&(g=h.memoizedState!==null,h.stateNode.isHidden=g,!g||h.alternate!==null&&h.alternate.memoizedState!==null||(Bl=Ct())),c&4&&Ch(t);break;case 22:if(ae=o!==null&&o.memoizedState!==null,t.mode&1?(Wt=(q=Wt)||ae,Sn(s,t),Wt=q):Sn(s,t),Ln(t),c&8192){if(q=t.memoizedState!==null,(t.stateNode.isHidden=q)&&!ae&&(t.mode&1)!==0)for(Se=t,ae=t.child;ae!==null;){for(ce=Se=ae;Se!==null;){switch(re=Se,je=re.child,re.tag){case 0:case 11:case 14:case 15:ta(4,re,re.return);break;case 1:ls(re,re.return);var Ce=re.stateNode;if(typeof Ce.componentWillUnmount=="function"){c=re,o=re.return;try{s=c,Ce.props=s.memoizedProps,Ce.state=s.memoizedState,Ce.componentWillUnmount()}catch(Re){St(c,o,Re)}}break;case 5:ls(re,re.return);break;case 22:if(re.memoizedState!==null){Ih(ce);continue}}je!==null?(je.return=re,Se=je):Ih(ce)}ae=ae.sibling}e:for(ae=null,ce=t;;){if(ce.tag===5){if(ae===null){ae=ce;try{h=ce.stateNode,q?(g=h.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(A=ce.stateNode,R=ce.memoizedProps.style,b=R!=null&&R.hasOwnProperty("display")?R.display:null,A.style.display=st("display",b))}catch(Re){St(t,t.return,Re)}}}else if(ce.tag===6){if(ae===null)try{ce.stateNode.nodeValue=q?"":ce.memoizedProps}catch(Re){St(t,t.return,Re)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===t)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===t)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===t)break e;ae===ce&&(ae=null),ce=ce.return}ae===ce&&(ae=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:Sn(s,t),Ln(t),c&4&&Ch(t);break;case 21:break;default:Sn(s,t),Ln(t)}}function Ln(t){var s=t.flags;if(s&2){try{e:{for(var o=t.return;o!==null;){if(kh(o)){var c=o;break e}o=o.return}throw Error(a(160))}switch(c.tag){case 5:var h=c.stateNode;c.flags&32&&(ze(h,""),c.flags&=-33);var g=Sh(t);Ol(t,g,h);break;case 3:case 4:var b=c.stateNode.containerInfo,A=Sh(t);Fl(t,A,b);break;default:throw Error(a(161))}}catch(R){St(t,t.return,R)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function dy(t,s,o){Se=t,Ah(t)}function Ah(t,s,o){for(var c=(t.mode&1)!==0;Se!==null;){var h=Se,g=h.child;if(h.tag===22&&c){var b=h.memoizedState!==null||ui;if(!b){var A=h.alternate,R=A!==null&&A.memoizedState!==null||Wt;A=ui;var q=Wt;if(ui=b,(Wt=R)&&!q)for(Se=h;Se!==null;)b=Se,R=b.child,b.tag===22&&b.memoizedState!==null?Rh(h):R!==null?(R.return=b,Se=R):Rh(h);for(;g!==null;)Se=g,Ah(g),g=g.sibling;Se=h,ui=A,Wt=q}Th(t)}else(h.subtreeFlags&8772)!==0&&g!==null?(g.return=h,Se=g):Th(t)}}function Th(t){for(;Se!==null;){var s=Se;if((s.flags&8772)!==0){var o=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:Wt||di(5,s);break;case 1:var c=s.stateNode;if(s.flags&4&&!Wt)if(o===null)c.componentDidMount();else{var h=s.elementType===s.type?o.memoizedProps:bn(s.type,o.memoizedProps);c.componentDidUpdate(h,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=s.updateQueue;g!==null&&Id(s,g,c);break;case 3:var b=s.updateQueue;if(b!==null){if(o=null,s.child!==null)switch(s.child.tag){case 5:o=s.child.stateNode;break;case 1:o=s.child.stateNode}Id(s,b,o)}break;case 5:var A=s.stateNode;if(o===null&&s.flags&4){o=A;var R=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&o.focus();break;case"img":R.src&&(o.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var q=s.alternate;if(q!==null){var ae=q.memoizedState;if(ae!==null){var ce=ae.dehydrated;ce!==null&&Ps(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Wt||s.flags&512&&Ml(s)}catch(re){St(s,s.return,re)}}if(s===t){Se=null;break}if(o=s.sibling,o!==null){o.return=s.return,Se=o;break}Se=s.return}}function Ih(t){for(;Se!==null;){var s=Se;if(s===t){Se=null;break}var o=s.sibling;if(o!==null){o.return=s.return,Se=o;break}Se=s.return}}function Rh(t){for(;Se!==null;){var s=Se;try{switch(s.tag){case 0:case 11:case 15:var o=s.return;try{di(4,s)}catch(R){St(s,o,R)}break;case 1:var c=s.stateNode;if(typeof c.componentDidMount=="function"){var h=s.return;try{c.componentDidMount()}catch(R){St(s,h,R)}}var g=s.return;try{Ml(s)}catch(R){St(s,g,R)}break;case 5:var b=s.return;try{Ml(s)}catch(R){St(s,b,R)}}}catch(R){St(s,s.return,R)}if(s===t){Se=null;break}var A=s.sibling;if(A!==null){A.return=s.return,Se=A;break}Se=s.return}}var hy=Math.ceil,hi=T.ReactCurrentDispatcher,zl=T.ReactCurrentOwner,pn=T.ReactCurrentBatchConfig,rt=0,_t=null,Tt=null,Ot=0,cn=0,cs=ir(0),Rt=0,na=null,Ir=0,fi=0,Dl=0,ra=null,Zt=null,Bl=0,us=1/0,Kn=null,mi=!1,Ul=null,hr=null,pi=!1,fr=null,gi=0,sa=0,Wl=null,vi=-1,yi=0;function Kt(){return(rt&6)!==0?Ct():vi!==-1?vi:vi=Ct()}function mr(t){return(t.mode&1)===0?1:(rt&2)!==0&&Ot!==0?Ot&-Ot:Yv.transition!==null?(yi===0&&(yi=Su()),yi):(t=lt,t!==0||(t=window.event,t=t===void 0?16:Pu(t.type)),t)}function Nn(t,s,o,c){if(50<sa)throw sa=0,Wl=null,Error(a(185));As(t,o,c),((rt&2)===0||t!==_t)&&(t===_t&&((rt&2)===0&&(fi|=o),Rt===4&&pr(t,Ot)),en(t,c),o===1&&rt===0&&(s.mode&1)===0&&(us=Ct()+500,qa&&lr()))}function en(t,s){var o=t.callbackNode;Yg(t,s);var c=Ea(t,t===_t?Ot:0);if(c===0)o!==null&&wu(o),t.callbackNode=null,t.callbackPriority=0;else if(s=c&-c,t.callbackPriority!==s){if(o!=null&&wu(o),s===1)t.tag===0?Gv(Ph.bind(null,t)):yd(Ph.bind(null,t)),Hv(function(){(rt&6)===0&&lr()}),o=null;else{switch(Nu(c)){case 1:o=bo;break;case 4:o=bu;break;case 16:o=ka;break;case 536870912:o=ku;break;default:o=ka}o=Bh(o,$h.bind(null,t))}t.callbackPriority=s,t.callbackNode=o}}function $h(t,s){if(vi=-1,yi=0,(rt&6)!==0)throw Error(a(327));var o=t.callbackNode;if(ds()&&t.callbackNode!==o)return null;var c=Ea(t,t===_t?Ot:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||s)s=xi(t,c);else{s=c;var h=rt;rt|=2;var g=Lh();(_t!==t||Ot!==s)&&(Kn=null,us=Ct()+500,$r(t,s));do try{py();break}catch(A){_h(t,A)}while(!0);ol(),hi.current=g,rt=h,Tt!==null?s=0:(_t=null,Ot=0,s=Rt)}if(s!==0){if(s===2&&(h=ko(t),h!==0&&(c=h,s=Hl(t,h))),s===1)throw o=na,$r(t,0),pr(t,c),en(t,Ct()),o;if(s===6)pr(t,c);else{if(h=t.current.alternate,(c&30)===0&&!fy(h)&&(s=xi(t,c),s===2&&(g=ko(t),g!==0&&(c=g,s=Hl(t,g))),s===1))throw o=na,$r(t,0),pr(t,c),en(t,Ct()),o;switch(t.finishedWork=h,t.finishedLanes=c,s){case 0:case 1:throw Error(a(345));case 2:Pr(t,Zt,Kn);break;case 3:if(pr(t,c),(c&130023424)===c&&(s=Bl+500-Ct(),10<s)){if(Ea(t,0)!==0)break;if(h=t.suspendedLanes,(h&c)!==c){Kt(),t.pingedLanes|=t.suspendedLanes&h;break}t.timeoutHandle=Jo(Pr.bind(null,t,Zt,Kn),s);break}Pr(t,Zt,Kn);break;case 4:if(pr(t,c),(c&4194240)===c)break;for(s=t.eventTimes,h=-1;0<c;){var b=31-xn(c);g=1<<b,b=s[b],b>h&&(h=b),c&=~g}if(c=h,c=Ct()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*hy(c/1960))-c,10<c){t.timeoutHandle=Jo(Pr.bind(null,t,Zt,Kn),c);break}Pr(t,Zt,Kn);break;case 5:Pr(t,Zt,Kn);break;default:throw Error(a(329))}}}return en(t,Ct()),t.callbackNode===o?$h.bind(null,t):null}function Hl(t,s){var o=ra;return t.current.memoizedState.isDehydrated&&($r(t,s).flags|=256),t=xi(t,s),t!==2&&(s=Zt,Zt=o,s!==null&&Vl(s)),t}function Vl(t){Zt===null?Zt=t:Zt.push.apply(Zt,t)}function fy(t){for(var s=t;;){if(s.flags&16384){var o=s.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var h=o[c],g=h.getSnapshot;h=h.value;try{if(!jn(g(),h))return!1}catch{return!1}}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function pr(t,s){for(s&=~Dl,s&=~fi,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var o=31-xn(s),c=1<<o;t[o]=-1,s&=~c}}function Ph(t){if((rt&6)!==0)throw Error(a(327));ds();var s=Ea(t,0);if((s&1)===0)return en(t,Ct()),null;var o=xi(t,s);if(t.tag!==0&&o===2){var c=ko(t);c!==0&&(s=c,o=Hl(t,c))}if(o===1)throw o=na,$r(t,0),pr(t,s),en(t,Ct()),o;if(o===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,Pr(t,Zt,Kn),en(t,Ct()),null}function ql(t,s){var o=rt;rt|=1;try{return t(s)}finally{rt=o,rt===0&&(us=Ct()+500,qa&&lr())}}function Rr(t){fr!==null&&fr.tag===0&&(rt&6)===0&&ds();var s=rt;rt|=1;var o=pn.transition,c=lt;try{if(pn.transition=null,lt=1,t)return t()}finally{lt=c,pn.transition=o,rt=s,(rt&6)===0&&lr()}}function Kl(){cn=cs.current,vt(cs)}function $r(t,s){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,Wv(o)),Tt!==null)for(o=Tt.return;o!==null;){var c=o;switch(nl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ha();break;case 3:is(),vt(Jt),vt(Dt),pl();break;case 5:fl(c);break;case 4:is();break;case 13:vt(wt);break;case 19:vt(wt);break;case 10:ll(c.type._context);break;case 22:case 23:Kl()}o=o.return}if(_t=t,Tt=t=gr(t.current,null),Ot=cn=s,Rt=0,na=null,Dl=fi=Ir=0,Zt=ra=null,Er!==null){for(s=0;s<Er.length;s++)if(o=Er[s],c=o.interleaved,c!==null){o.interleaved=null;var h=c.next,g=o.pending;if(g!==null){var b=g.next;g.next=h,c.next=b}o.pending=c}Er=null}return t}function _h(t,s){do{var o=Tt;try{if(ol(),ni.current=ii,ri){for(var c=bt.memoizedState;c!==null;){var h=c.queue;h!==null&&(h.pending=null),c=c.next}ri=!1}if(Tr=0,Pt=It=bt=null,Js=!1,Qs=0,zl.current=null,o===null||o.return===null){Rt=1,na=s,Tt=null;break}e:{var g=t,b=o.return,A=o,R=s;if(s=Ot,A.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var q=R,ae=A,ce=ae.tag;if((ae.mode&1)===0&&(ce===0||ce===11||ce===15)){var re=ae.alternate;re?(ae.updateQueue=re.updateQueue,ae.memoizedState=re.memoizedState,ae.lanes=re.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var je=ah(b);if(je!==null){je.flags&=-257,ih(je,b,A,g,s),je.mode&1&&sh(g,q,s),s=je,R=q;var Ce=s.updateQueue;if(Ce===null){var Re=new Set;Re.add(R),s.updateQueue=Re}else Ce.add(R);break e}else{if((s&1)===0){sh(g,q,s),Gl();break e}R=Error(a(426))}}else if(yt&&A.mode&1){var Et=ah(b);if(Et!==null){(Et.flags&65536)===0&&(Et.flags|=256),ih(Et,b,A,g,s),al(os(R,A));break e}}g=R=os(R,A),Rt!==4&&(Rt=2),ra===null?ra=[g]:ra.push(g),g=b;do{switch(g.tag){case 3:g.flags|=65536,s&=-s,g.lanes|=s;var O=nh(g,R,s);Td(g,O);break e;case 1:A=R;var L=g.type,W=g.stateNode;if((g.flags&128)===0&&(typeof L.getDerivedStateFromError=="function"||W!==null&&typeof W.componentDidCatch=="function"&&(hr===null||!hr.has(W)))){g.flags|=65536,s&=-s,g.lanes|=s;var fe=rh(g,A,s);Td(g,fe);break e}}g=g.return}while(g!==null)}Fh(o)}catch(Pe){s=Pe,Tt===o&&o!==null&&(Tt=o=o.return);continue}break}while(!0)}function Lh(){var t=hi.current;return hi.current=ii,t===null?ii:t}function Gl(){(Rt===0||Rt===3||Rt===2)&&(Rt=4),_t===null||(Ir&268435455)===0&&(fi&268435455)===0||pr(_t,Ot)}function xi(t,s){var o=rt;rt|=2;var c=Lh();(_t!==t||Ot!==s)&&(Kn=null,$r(t,s));do try{my();break}catch(h){_h(t,h)}while(!0);if(ol(),rt=o,hi.current=c,Tt!==null)throw Error(a(261));return _t=null,Ot=0,Rt}function my(){for(;Tt!==null;)Mh(Tt)}function py(){for(;Tt!==null&&!Dg();)Mh(Tt)}function Mh(t){var s=Dh(t.alternate,t,cn);t.memoizedProps=t.pendingProps,s===null?Fh(t):Tt=s,zl.current=null}function Fh(t){var s=t;do{var o=s.alternate;if(t=s.return,(s.flags&32768)===0){if(o=oy(o,s,cn),o!==null){Tt=o;return}}else{if(o=ly(o,s),o!==null){o.flags&=32767,Tt=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Rt=6,Tt=null;return}}if(s=s.sibling,s!==null){Tt=s;return}Tt=s=t}while(s!==null);Rt===0&&(Rt=5)}function Pr(t,s,o){var c=lt,h=pn.transition;try{pn.transition=null,lt=1,gy(t,s,o,c)}finally{pn.transition=h,lt=c}return null}function gy(t,s,o,c){do ds();while(fr!==null);if((rt&6)!==0)throw Error(a(327));o=t.finishedWork;var h=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var g=o.lanes|o.childLanes;if(Jg(t,g),t===_t&&(Tt=_t=null,Ot=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||pi||(pi=!0,Bh(ka,function(){return ds(),null})),g=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||g){g=pn.transition,pn.transition=null;var b=lt;lt=1;var A=rt;rt|=4,zl.current=null,uy(t,o),Eh(o,t),Mv(Go),Ia=!!Ko,Go=Ko=null,t.current=o,dy(o),Bg(),rt=A,lt=b,pn.transition=g}else t.current=o;if(pi&&(pi=!1,fr=t,gi=h),g=t.pendingLanes,g===0&&(hr=null),Hg(o.stateNode),en(t,Ct()),s!==null)for(c=t.onRecoverableError,o=0;o<s.length;o++)h=s[o],c(h.value,{componentStack:h.stack,digest:h.digest});if(mi)throw mi=!1,t=Ul,Ul=null,t;return(gi&1)!==0&&t.tag!==0&&ds(),g=t.pendingLanes,(g&1)!==0?t===Wl?sa++:(sa=0,Wl=t):sa=0,lr(),null}function ds(){if(fr!==null){var t=Nu(gi),s=pn.transition,o=lt;try{if(pn.transition=null,lt=16>t?16:t,fr===null)var c=!1;else{if(t=fr,fr=null,gi=0,(rt&6)!==0)throw Error(a(331));var h=rt;for(rt|=4,Se=t.current;Se!==null;){var g=Se,b=g.child;if((Se.flags&16)!==0){var A=g.deletions;if(A!==null){for(var R=0;R<A.length;R++){var q=A[R];for(Se=q;Se!==null;){var ae=Se;switch(ae.tag){case 0:case 11:case 15:ta(8,ae,g)}var ce=ae.child;if(ce!==null)ce.return=ae,Se=ce;else for(;Se!==null;){ae=Se;var re=ae.sibling,je=ae.return;if(bh(ae),ae===q){Se=null;break}if(re!==null){re.return=je,Se=re;break}Se=je}}}var Ce=g.alternate;if(Ce!==null){var Re=Ce.child;if(Re!==null){Ce.child=null;do{var Et=Re.sibling;Re.sibling=null,Re=Et}while(Re!==null)}}Se=g}}if((g.subtreeFlags&2064)!==0&&b!==null)b.return=g,Se=b;else e:for(;Se!==null;){if(g=Se,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:ta(9,g,g.return)}var O=g.sibling;if(O!==null){O.return=g.return,Se=O;break e}Se=g.return}}var L=t.current;for(Se=L;Se!==null;){b=Se;var W=b.child;if((b.subtreeFlags&2064)!==0&&W!==null)W.return=b,Se=W;else e:for(b=L;Se!==null;){if(A=Se,(A.flags&2048)!==0)try{switch(A.tag){case 0:case 11:case 15:di(9,A)}}catch(Pe){St(A,A.return,Pe)}if(A===b){Se=null;break e}var fe=A.sibling;if(fe!==null){fe.return=A.return,Se=fe;break e}Se=A.return}}if(rt=h,lr(),Rn&&typeof Rn.onPostCommitFiberRoot=="function")try{Rn.onPostCommitFiberRoot(Sa,t)}catch{}c=!0}return c}finally{lt=o,pn.transition=s}}return!1}function Oh(t,s,o){s=os(o,s),s=nh(t,s,1),t=ur(t,s,1),s=Kt(),t!==null&&(As(t,1,s),en(t,s))}function St(t,s,o){if(t.tag===3)Oh(t,t,o);else for(;s!==null;){if(s.tag===3){Oh(s,t,o);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(hr===null||!hr.has(c))){t=os(o,t),t=rh(s,t,1),s=ur(s,t,1),t=Kt(),s!==null&&(As(s,1,t),en(s,t));break}}s=s.return}}function vy(t,s,o){var c=t.pingCache;c!==null&&c.delete(s),s=Kt(),t.pingedLanes|=t.suspendedLanes&o,_t===t&&(Ot&o)===o&&(Rt===4||Rt===3&&(Ot&130023424)===Ot&&500>Ct()-Bl?$r(t,0):Dl|=o),en(t,s)}function zh(t,s){s===0&&((t.mode&1)===0?s=1:(s=Ca,Ca<<=1,(Ca&130023424)===0&&(Ca=4194304)));var o=Kt();t=Hn(t,s),t!==null&&(As(t,s,o),en(t,o))}function yy(t){var s=t.memoizedState,o=0;s!==null&&(o=s.retryLane),zh(t,o)}function xy(t,s){var o=0;switch(t.tag){case 13:var c=t.stateNode,h=t.memoizedState;h!==null&&(o=h.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(s),zh(t,o)}var Dh;Dh=function(t,s,o){if(t!==null)if(t.memoizedProps!==s.pendingProps||Jt.current)Xt=!0;else{if((t.lanes&o)===0&&(s.flags&128)===0)return Xt=!1,iy(t,s,o);Xt=(t.flags&131072)!==0}else Xt=!1,yt&&(s.flags&1048576)!==0&&xd(s,Ga,s.index);switch(s.lanes=0,s.tag){case 2:var c=s.type;ci(t,s),t=s.pendingProps;var h=Zr(s,Dt.current);as(s,o),h=yl(null,s,c,t,h,o);var g=xl();return s.flags|=1,typeof h=="object"&&h!==null&&typeof h.render=="function"&&h.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Qt(c)?(g=!0,Va(s)):g=!1,s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,dl(s),h.updater=oi,s.stateNode=h,h._reactInternals=s,Nl(s,c,t,o),s=Tl(null,s,c,!0,g,o)):(s.tag=0,yt&&g&&tl(s),qt(null,s,h,o),s=s.child),s;case 16:c=s.elementType;e:{switch(ci(t,s),t=s.pendingProps,h=c._init,c=h(c._payload),s.type=c,h=s.tag=wy(c),t=bn(c,t),h){case 0:s=Al(null,s,c,t,o);break e;case 1:s=hh(null,s,c,t,o);break e;case 11:s=oh(null,s,c,t,o);break e;case 14:s=lh(null,s,c,bn(c.type,t),o);break e}throw Error(a(306,c,""))}return s;case 0:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),Al(t,s,c,h,o);case 1:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),hh(t,s,c,h,o);case 3:e:{if(fh(s),t===null)throw Error(a(387));c=s.pendingProps,g=s.memoizedState,h=g.element,Ad(t,s),ei(s,c,null,o);var b=s.memoizedState;if(c=b.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:b.cache,pendingSuspenseBoundaries:b.pendingSuspenseBoundaries,transitions:b.transitions},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){h=os(Error(a(423)),s),s=mh(t,s,c,o,h);break e}else if(c!==h){h=os(Error(a(424)),s),s=mh(t,s,c,o,h);break e}else for(ln=ar(s.stateNode.containerInfo.firstChild),on=s,yt=!0,wn=null,o=Cd(s,null,c,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ns(),c===h){s=qn(t,s,o);break e}qt(t,s,c,o)}s=s.child}return s;case 5:return Rd(s),t===null&&sl(s),c=s.type,h=s.pendingProps,g=t!==null?t.memoizedProps:null,b=h.children,Yo(c,h)?b=null:g!==null&&Yo(c,g)&&(s.flags|=32),dh(t,s),qt(t,s,b,o),s.child;case 6:return t===null&&sl(s),null;case 13:return ph(t,s,o);case 4:return hl(s,s.stateNode.containerInfo),c=s.pendingProps,t===null?s.child=rs(s,null,c,o):qt(t,s,c,o),s.child;case 11:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),oh(t,s,c,h,o);case 7:return qt(t,s,s.pendingProps,o),s.child;case 8:return qt(t,s,s.pendingProps.children,o),s.child;case 12:return qt(t,s,s.pendingProps.children,o),s.child;case 10:e:{if(c=s.type._context,h=s.pendingProps,g=s.memoizedProps,b=h.value,ft(Qa,c._currentValue),c._currentValue=b,g!==null)if(jn(g.value,b)){if(g.children===h.children&&!Jt.current){s=qn(t,s,o);break e}}else for(g=s.child,g!==null&&(g.return=s);g!==null;){var A=g.dependencies;if(A!==null){b=g.child;for(var R=A.firstContext;R!==null;){if(R.context===c){if(g.tag===1){R=Vn(-1,o&-o),R.tag=2;var q=g.updateQueue;if(q!==null){q=q.shared;var ae=q.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),q.pending=R}}g.lanes|=o,R=g.alternate,R!==null&&(R.lanes|=o),cl(g.return,o,s),A.lanes|=o;break}R=R.next}}else if(g.tag===10)b=g.type===s.type?null:g.child;else if(g.tag===18){if(b=g.return,b===null)throw Error(a(341));b.lanes|=o,A=b.alternate,A!==null&&(A.lanes|=o),cl(b,o,s),b=g.sibling}else b=g.child;if(b!==null)b.return=g;else for(b=g;b!==null;){if(b===s){b=null;break}if(g=b.sibling,g!==null){g.return=b.return,b=g;break}b=b.return}g=b}qt(t,s,h.children,o),s=s.child}return s;case 9:return h=s.type,c=s.pendingProps.children,as(s,o),h=fn(h),c=c(h),s.flags|=1,qt(t,s,c,o),s.child;case 14:return c=s.type,h=bn(c,s.pendingProps),h=bn(c.type,h),lh(t,s,c,h,o);case 15:return ch(t,s,s.type,s.pendingProps,o);case 17:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),ci(t,s),s.tag=1,Qt(c)?(t=!0,Va(s)):t=!1,as(s,o),eh(s,c,h),Nl(s,c,h,o),Tl(null,s,c,!0,t,o);case 19:return vh(t,s,o);case 22:return uh(t,s,o)}throw Error(a(156,s.tag))};function Bh(t,s){return ju(t,s)}function jy(t,s,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gn(t,s,o,c){return new jy(t,s,o,c)}function Yl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function wy(t){if(typeof t=="function")return Yl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===V)return 11;if(t===me)return 14}return 2}function gr(t,s){var o=t.alternate;return o===null?(o=gn(t.tag,s,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=s,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,s=t.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function ji(t,s,o,c,h,g){var b=2;if(c=t,typeof t=="function")Yl(t)&&(b=1);else if(typeof t=="string")b=5;else e:switch(t){case B:return _r(o.children,h,g,s);case te:b=8,h|=8;break;case Q:return t=gn(12,o,s,h|2),t.elementType=Q,t.lanes=g,t;case K:return t=gn(13,o,s,h),t.elementType=K,t.lanes=g,t;case le:return t=gn(19,o,s,h),t.elementType=le,t.lanes=g,t;case Ae:return wi(o,h,g,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:b=10;break e;case z:b=9;break e;case V:b=11;break e;case me:b=14;break e;case we:b=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return s=gn(b,o,s,h),s.elementType=t,s.type=c,s.lanes=g,s}function _r(t,s,o,c){return t=gn(7,t,c,s),t.lanes=o,t}function wi(t,s,o,c){return t=gn(22,t,c,s),t.elementType=Ae,t.lanes=o,t.stateNode={isHidden:!1},t}function Jl(t,s,o){return t=gn(6,t,null,s),t.lanes=o,t}function Ql(t,s,o){return s=gn(4,t.children!==null?t.children:[],t.key,s),s.lanes=o,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function by(t,s,o,c,h){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=So(0),this.expirationTimes=So(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=So(0),this.identifierPrefix=c,this.onRecoverableError=h,this.mutableSourceEagerHydrationData=null}function Xl(t,s,o,c,h,g,b,A,R){return t=new by(t,s,o,A,R),s===1?(s=1,g===!0&&(s|=8)):s=0,g=gn(3,null,null,s),t.current=g,g.stateNode=t,g.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},dl(g),t}function ky(t,s,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:c==null?null:""+c,children:t,containerInfo:s,implementation:o}}function Uh(t){if(!t)return or;t=t._reactInternals;e:{if(Tn(t)!==t||t.tag!==1)throw Error(a(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(Qt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(a(171))}if(t.tag===1){var o=t.type;if(Qt(o))return gd(t,o,s)}return s}function Wh(t,s,o,c,h,g,b,A,R){return t=Xl(o,c,!0,t,h,g,b,A,R),t.context=Uh(null),o=t.current,c=Kt(),h=mr(o),g=Vn(c,h),g.callback=s??null,ur(o,g,h),t.current.lanes=h,As(t,h,c),en(t,c),t}function bi(t,s,o,c){var h=s.current,g=Kt(),b=mr(h);return o=Uh(o),s.context===null?s.context=o:s.pendingContext=o,s=Vn(g,b),s.payload={element:t},c=c===void 0?null:c,c!==null&&(s.callback=c),t=ur(h,s,b),t!==null&&(Nn(t,h,b,g),Za(t,h,b)),b}function ki(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Hh(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<s?o:s}}function Zl(t,s){Hh(t,s),(t=t.alternate)&&Hh(t,s)}function Sy(){return null}var Vh=typeof reportError=="function"?reportError:function(t){console.error(t)};function ec(t){this._internalRoot=t}Si.prototype.render=ec.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(a(409));bi(t,s,null,null)},Si.prototype.unmount=ec.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;Rr(function(){bi(null,t,null,null)}),s[Dn]=null}};function Si(t){this._internalRoot=t}Si.prototype.unstable_scheduleHydration=function(t){if(t){var s=Au();t={blockedOn:null,target:t,priority:s};for(var o=0;o<nr.length&&s!==0&&s<nr[o].priority;o++);nr.splice(o,0,t),o===0&&Ru(t)}};function tc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Ni(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function qh(){}function Ny(t,s,o,c,h){if(h){if(typeof c=="function"){var g=c;c=function(){var q=ki(b);g.call(q)}}var b=Wh(s,c,t,0,null,!1,!1,"",qh);return t._reactRootContainer=b,t[Dn]=b.current,Us(t.nodeType===8?t.parentNode:t),Rr(),b}for(;h=t.lastChild;)t.removeChild(h);if(typeof c=="function"){var A=c;c=function(){var q=ki(R);A.call(q)}}var R=Xl(t,0,!1,null,null,!1,!1,"",qh);return t._reactRootContainer=R,t[Dn]=R.current,Us(t.nodeType===8?t.parentNode:t),Rr(function(){bi(s,R,o,c)}),R}function Ci(t,s,o,c,h){var g=o._reactRootContainer;if(g){var b=g;if(typeof h=="function"){var A=h;h=function(){var R=ki(b);A.call(R)}}bi(s,b,t,h)}else b=Ny(o,s,t,h,c);return ki(b)}Cu=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var o=Es(s.pendingLanes);o!==0&&(No(s,o|1),en(s,Ct()),(rt&6)===0&&(us=Ct()+500,lr()))}break;case 13:Rr(function(){var c=Hn(t,1);if(c!==null){var h=Kt();Nn(c,t,1,h)}}),Zl(t,1)}},Co=function(t){if(t.tag===13){var s=Hn(t,134217728);if(s!==null){var o=Kt();Nn(s,t,134217728,o)}Zl(t,134217728)}},Eu=function(t){if(t.tag===13){var s=mr(t),o=Hn(t,s);if(o!==null){var c=Kt();Nn(o,t,s,c)}Zl(t,s)}},Au=function(){return lt},Tu=function(t,s){var o=lt;try{return lt=t,s()}finally{lt=o}},X=function(t,s,o){switch(s){case"input":if(Ge(t,o),s=o.name,o.type==="radio"&&s!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<o.length;s++){var c=o[s];if(c!==t&&c.form===t.form){var h=Wa(c);if(!h)throw Error(a(90));Fe(c),Ge(c,h)}}}break;case"textarea":De(t,o);break;case"select":s=o.value,s!=null&&Be(t,!!o.multiple,s,!1)}},ne=ql,xe=Rr;var Cy={usingClientEntryPoint:!1,Events:[Vs,Qr,Wa,He,kt,ql]},aa={findFiberByHostInstance:kr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ey={bundleType:aa.bundleType,version:aa.version,rendererPackageName:aa.rendererPackageName,rendererConfig:aa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=In(t),t===null?null:t.stateNode},findFiberByHostInstance:aa.findFiberByHostInstance||Sy,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ei=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ei.isDisabled&&Ei.supportsFiber)try{Sa=Ei.inject(Ey),Rn=Ei}catch{}}return tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Cy,tn.createPortal=function(t,s){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!tc(s))throw Error(a(200));return ky(t,s,null,o)},tn.createRoot=function(t,s){if(!tc(t))throw Error(a(299));var o=!1,c="",h=Vh;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onRecoverableError!==void 0&&(h=s.onRecoverableError)),s=Xl(t,1,!1,null,null,o,!1,c,h),t[Dn]=s.current,Us(t.nodeType===8?t.parentNode:t),new ec(s)},tn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=In(s),t=t===null?null:t.stateNode,t},tn.flushSync=function(t){return Rr(t)},tn.hydrate=function(t,s,o){if(!Ni(s))throw Error(a(200));return Ci(null,t,s,!0,o)},tn.hydrateRoot=function(t,s,o){if(!tc(t))throw Error(a(405));var c=o!=null&&o.hydratedSources||null,h=!1,g="",b=Vh;if(o!=null&&(o.unstable_strictMode===!0&&(h=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(b=o.onRecoverableError)),s=Wh(s,null,t,1,o??null,h,!1,g,b),t[Dn]=s.current,Us(t),c)for(t=0;t<c.length;t++)o=c[t],h=o._getVersion,h=h(o._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[o,h]:s.mutableSourceEagerHydrationData.push(o,h);return new Si(s)},tn.render=function(t,s,o){if(!Ni(s))throw Error(a(200));return Ci(null,t,s,!1,o)},tn.unmountComponentAtNode=function(t){if(!Ni(t))throw Error(a(40));return t._reactRootContainer?(Rr(function(){Ci(null,null,t,!1,function(){t._reactRootContainer=null,t[Dn]=null})}),!0):!1},tn.unstable_batchedUpdates=ql,tn.unstable_renderSubtreeIntoContainer=function(t,s,o,c){if(!Ni(o))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return Ci(t,s,o,!1,c)},tn.version="18.3.1-next-f1338f8080-20240426",tn}var ef;function wm(){if(ef)return sc.exports;ef=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),sc.exports=My(),sc.exports}var tf;function Fy(){if(tf)return Ai;tf=1;var e=wm();return Ai.createRoot=e.createRoot,Ai.hydrateRoot=e.hydrateRoot,Ai}var Oy=Fy();/**
40
+ `+g.stack}return{value:t,source:s,stack:h,digest:null}}function El(t,s,o){return{value:t,source:null,stack:o??null,digest:s??null}}function Al(t,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var ay=typeof WeakMap=="function"?WeakMap:Map;function th(t,s,o){o=Vn(-1,o),o.tag=3,o.payload={element:null};var c=s.value;return o.callback=function(){mi||(mi=!0,Wl=c),Al(t,s)},o}function nh(t,s,o){o=Vn(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var h=s.value;o.payload=function(){return c(h)},o.callback=function(){Al(t,s)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(o.callback=function(){Al(t,s),typeof c!="function"&&(hr===null?hr=new Set([this]):hr.add(this));var b=s.stack;this.componentDidCatch(s.value,{componentStack:b!==null?b:""})}),o}function rh(t,s,o){var c=t.pingCache;if(c===null){c=t.pingCache=new ay;var h=new Set;c.set(s,h)}else h=c.get(s),h===void 0&&(h=new Set,c.set(s,h));h.has(o)||(h.add(o),t=xy.bind(null,t,s,o),s.then(t,t))}function sh(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function ah(t,s,o,c,h){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=Vn(-1,1),s.tag=2,ur(o,s,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=h,t)}var iy=T.ReactCurrentOwner,Xt=!1;function qt(t,s,o,c){s.child=t===null?Nd(s,null,o,c):rs(s,t.child,o,c)}function ih(t,s,o,c,h){o=o.render;var g=s.ref;return as(s,h),c=xl(t,s,o,c,g,h),o=jl(),t!==null&&!Xt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~h,qn(t,s,h)):(yt&&o&&nl(s),s.flags|=1,qt(t,s,c,h),s.child)}function oh(t,s,o,c,h){if(t===null){var g=o.type;return typeof g=="function"&&!Jl(g)&&g.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=g,lh(t,s,g,c,h)):(t=ji(o.type,null,c,s,s.mode,h),t.ref=s.ref,t.return=s,s.child=t)}if(g=t.child,(t.lanes&h)===0){var b=g.memoizedProps;if(o=o.compare,o=o!==null?o:zs,o(b,c)&&t.ref===s.ref)return qn(t,s,h)}return s.flags|=1,t=gr(g,c),t.ref=s.ref,t.return=s,s.child=t}function lh(t,s,o,c,h){if(t!==null){var g=t.memoizedProps;if(zs(g,c)&&t.ref===s.ref)if(Xt=!1,s.pendingProps=c=g,(t.lanes&h)!==0)(t.flags&131072)!==0&&(Xt=!0);else return s.lanes=t.lanes,qn(t,s,h)}return Tl(t,s,o,c,h)}function ch(t,s,o){var c=s.pendingProps,h=c.children,g=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},ft(cs,cn),cn|=o;else{if((o&1073741824)===0)return t=g!==null?g.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,ft(cs,cn),cn|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:o,ft(cs,cn),cn|=c}else g!==null?(c=g.baseLanes|o,s.memoizedState=null):c=o,ft(cs,cn),cn|=c;return qt(t,s,h,o),s.child}function uh(t,s){var o=s.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Tl(t,s,o,c,h){var g=Qt(o)?Sr:Dt.current;return g=Zr(s,g),as(s,h),o=xl(t,s,o,c,g,h),c=jl(),t!==null&&!Xt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~h,qn(t,s,h)):(yt&&c&&nl(s),s.flags|=1,qt(t,s,o,h),s.child)}function dh(t,s,o,c,h){if(Qt(o)){var g=!0;Va(s)}else g=!1;if(as(s,h),s.stateNode===null)ci(t,s),Zd(s,o,c),Cl(s,o,c,h),c=!0;else if(t===null){var b=s.stateNode,A=s.memoizedProps;b.props=A;var R=b.context,q=o.contextType;typeof q=="object"&&q!==null?q=fn(q):(q=Qt(o)?Sr:Dt.current,q=Zr(s,q));var ae=o.getDerivedStateFromProps,ce=typeof ae=="function"||typeof b.getSnapshotBeforeUpdate=="function";ce||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(A!==c||R!==q)&&eh(s,b,c,q),cr=!1;var re=s.memoizedState;b.state=re,ei(s,c,b,h),R=s.memoizedState,A!==c||re!==R||Jt.current||cr?(typeof ae=="function"&&(Nl(s,o,ae,c),R=s.memoizedState),(A=cr||Xd(s,o,A,c,re,R,q))?(ce||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(s.flags|=4194308)):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=R),b.props=c,b.state=R,b.context=q,c=A):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{b=s.stateNode,Ed(t,s),A=s.memoizedProps,q=s.type===s.elementType?A:bn(s.type,A),b.props=q,ce=s.pendingProps,re=b.context,R=o.contextType,typeof R=="object"&&R!==null?R=fn(R):(R=Qt(o)?Sr:Dt.current,R=Zr(s,R));var je=o.getDerivedStateFromProps;(ae=typeof je=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(A!==ce||re!==R)&&eh(s,b,c,R),cr=!1,re=s.memoizedState,b.state=re,ei(s,c,b,h);var Ce=s.memoizedState;A!==ce||re!==Ce||Jt.current||cr?(typeof je=="function"&&(Nl(s,o,je,c),Ce=s.memoizedState),(q=cr||Xd(s,o,q,c,re,Ce,R)||!1)?(ae||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(c,Ce,R),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(c,Ce,R)),typeof b.componentDidUpdate=="function"&&(s.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof b.componentDidUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=Ce),b.props=c,b.state=Ce,b.context=R,c=q):(typeof b.componentDidUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||A===t.memoizedProps&&re===t.memoizedState||(s.flags|=1024),c=!1)}return Il(t,s,o,c,g,h)}function Il(t,s,o,c,h,g){uh(t,s);var b=(s.flags&128)!==0;if(!c&&!b)return h&&gd(s,o,!1),qn(t,s,g);c=s.stateNode,iy.current=s;var A=b&&typeof o.getDerivedStateFromError!="function"?null:c.render();return s.flags|=1,t!==null&&b?(s.child=rs(s,t.child,null,g),s.child=rs(s,null,A,g)):qt(t,s,A,g),s.memoizedState=c.state,h&&gd(s,o,!0),s.child}function hh(t){var s=t.stateNode;s.pendingContext?md(t,s.pendingContext,s.pendingContext!==s.context):s.context&&md(t,s.context,!1),fl(t,s.containerInfo)}function fh(t,s,o,c,h){return ns(),il(h),s.flags|=256,qt(t,s,o,c),s.child}var Rl={dehydrated:null,treeContext:null,retryLane:0};function $l(t){return{baseLanes:t,cachePool:null,transitions:null}}function mh(t,s,o){var c=s.pendingProps,h=wt.current,g=!1,b=(s.flags&128)!==0,A;if((A=b)||(A=t!==null&&t.memoizedState===null?!1:(h&2)!==0),A?(g=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(h|=1),ft(wt,h&1),t===null)return al(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(b=c.children,t=c.fallback,g?(c=s.mode,g=s.child,b={mode:"hidden",children:b},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=b):g=wi(b,c,0,null),t=_r(t,c,o,null),g.return=s,t.return=s,g.sibling=t,s.child=g,s.child.memoizedState=$l(o),s.memoizedState=Rl,t):Pl(s,b));if(h=t.memoizedState,h!==null&&(A=h.dehydrated,A!==null))return oy(t,s,b,c,A,h,o);if(g){g=c.fallback,b=s.mode,h=t.child,A=h.sibling;var R={mode:"hidden",children:c.children};return(b&1)===0&&s.child!==h?(c=s.child,c.childLanes=0,c.pendingProps=R,s.deletions=null):(c=gr(h,R),c.subtreeFlags=h.subtreeFlags&14680064),A!==null?g=gr(A,g):(g=_r(g,b,o,null),g.flags|=2),g.return=s,c.return=s,c.sibling=g,s.child=c,c=g,g=s.child,b=t.child.memoizedState,b=b===null?$l(o):{baseLanes:b.baseLanes|o,cachePool:null,transitions:b.transitions},g.memoizedState=b,g.childLanes=t.childLanes&~o,s.memoizedState=Rl,c}return g=t.child,t=g.sibling,c=gr(g,{mode:"visible",children:c.children}),(s.mode&1)===0&&(c.lanes=o),c.return=s,c.sibling=null,t!==null&&(o=s.deletions,o===null?(s.deletions=[t],s.flags|=16):o.push(t)),s.child=c,s.memoizedState=null,c}function Pl(t,s){return s=wi({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function li(t,s,o,c){return c!==null&&il(c),rs(s,t.child,null,o),t=Pl(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function oy(t,s,o,c,h,g,b){if(o)return s.flags&256?(s.flags&=-257,c=El(Error(a(422))),li(t,s,b,c)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(g=c.fallback,h=s.mode,c=wi({mode:"visible",children:c.children},h,0,null),g=_r(g,h,b,null),g.flags|=2,c.return=s,g.return=s,c.sibling=g,s.child=c,(s.mode&1)!==0&&rs(s,t.child,null,b),s.child.memoizedState=$l(b),s.memoizedState=Rl,g);if((s.mode&1)===0)return li(t,s,b,null);if(h.data==="$!"){if(c=h.nextSibling&&h.nextSibling.dataset,c)var A=c.dgst;return c=A,g=Error(a(419)),c=El(g,c,void 0),li(t,s,b,c)}if(A=(b&t.childLanes)!==0,Xt||A){if(c=_t,c!==null){switch(b&-b){case 4:h=2;break;case 16:h=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:h=32;break;case 536870912:h=268435456;break;default:h=0}h=(h&(c.suspendedLanes|b))!==0?0:h,h!==0&&h!==g.retryLane&&(g.retryLane=h,Hn(t,h),Nn(c,t,h,-1))}return Yl(),c=El(Error(a(421))),li(t,s,b,c)}return h.data==="$?"?(s.flags|=128,s.child=t.child,s=jy.bind(null,t),h._reactRetry=s,null):(t=g.treeContext,ln=ar(h.nextSibling),on=s,yt=!0,wn=null,t!==null&&(dn[hn++]=Un,dn[hn++]=Wn,dn[hn++]=Nr,Un=t.id,Wn=t.overflow,Nr=s),s=Pl(s,c.children),s.flags|=4096,s)}function ph(t,s,o){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s),ul(t.return,s,o)}function _l(t,s,o,c,h){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:h}:(g.isBackwards=s,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=o,g.tailMode=h)}function gh(t,s,o){var c=s.pendingProps,h=c.revealOrder,g=c.tail;if(qt(t,s,c.children,o),c=wt.current,(c&2)!==0)c=c&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&ph(t,o,s);else if(t.tag===19)ph(t,o,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(ft(wt,c),(s.mode&1)===0)s.memoizedState=null;else switch(h){case"forwards":for(o=s.child,h=null;o!==null;)t=o.alternate,t!==null&&ti(t)===null&&(h=o),o=o.sibling;o=h,o===null?(h=s.child,s.child=null):(h=o.sibling,o.sibling=null),_l(s,!1,h,o,g);break;case"backwards":for(o=null,h=s.child,s.child=null;h!==null;){if(t=h.alternate,t!==null&&ti(t)===null){s.child=h;break}t=h.sibling,h.sibling=o,o=h,h=t}_l(s,!0,o,null,g);break;case"together":_l(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function ci(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function qn(t,s,o){if(t!==null&&(s.dependencies=t.dependencies),Ir|=s.lanes,(o&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(a(153));if(s.child!==null){for(t=s.child,o=gr(t,t.pendingProps),s.child=o,o.return=s;t.sibling!==null;)t=t.sibling,o=o.sibling=gr(t,t.pendingProps),o.return=s;o.sibling=null}return s.child}function ly(t,s,o){switch(s.tag){case 3:hh(s),ns();break;case 5:Id(s);break;case 1:Qt(s.type)&&Va(s);break;case 4:fl(s,s.stateNode.containerInfo);break;case 10:var c=s.type._context,h=s.memoizedProps.value;ft(Qa,c._currentValue),c._currentValue=h;break;case 13:if(c=s.memoizedState,c!==null)return c.dehydrated!==null?(ft(wt,wt.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?mh(t,s,o):(ft(wt,wt.current&1),t=qn(t,s,o),t!==null?t.sibling:null);ft(wt,wt.current&1);break;case 19:if(c=(o&s.childLanes)!==0,(t.flags&128)!==0){if(c)return gh(t,s,o);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),ft(wt,wt.current),c)break;return null;case 22:case 23:return s.lanes=0,ch(t,s,o)}return qn(t,s,o)}var vh,Ll,yh,xh;vh=function(t,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ll=function(){},yh=function(t,s,o,c){var h=t.memoizedProps;if(h!==c){t=s.stateNode,Ar(Pn.current);var g=null;switch(o){case"input":h=Te(t,h),c=Te(t,c),g=[];break;case"select":h=J({},h,{value:void 0}),c=J({},c,{value:void 0}),g=[];break;case"textarea":h=dt(t,h),c=dt(t,c),g=[];break;default:typeof h.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Ua)}qe(o,c);var b;o=null;for(q in h)if(!c.hasOwnProperty(q)&&h.hasOwnProperty(q)&&h[q]!=null)if(q==="style"){var A=h[q];for(b in A)A.hasOwnProperty(b)&&(o||(o={}),o[b]="")}else q!=="dangerouslySetInnerHTML"&&q!=="children"&&q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&q!=="autoFocus"&&(l.hasOwnProperty(q)?g||(g=[]):(g=g||[]).push(q,null));for(q in c){var R=c[q];if(A=h!=null?h[q]:void 0,c.hasOwnProperty(q)&&R!==A&&(R!=null||A!=null))if(q==="style")if(A){for(b in A)!A.hasOwnProperty(b)||R&&R.hasOwnProperty(b)||(o||(o={}),o[b]="");for(b in R)R.hasOwnProperty(b)&&A[b]!==R[b]&&(o||(o={}),o[b]=R[b])}else o||(g||(g=[]),g.push(q,o)),o=R;else q==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,A=A?A.__html:void 0,R!=null&&A!==R&&(g=g||[]).push(q,R)):q==="children"?typeof R!="string"&&typeof R!="number"||(g=g||[]).push(q,""+R):q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&(l.hasOwnProperty(q)?(R!=null&&q==="onScroll"&&gt("scroll",t),g||A===R||(g=[])):(g=g||[]).push(q,R))}o&&(g=g||[]).push("style",o);var q=g;(s.updateQueue=q)&&(s.flags|=4)}},xh=function(t,s,o,c){o!==c&&(s.flags|=4)};function ea(t,s){if(!yt)switch(t.tailMode){case"hidden":s=t.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Ut(t){var s=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(s)for(var h=t.child;h!==null;)o|=h.lanes|h.childLanes,c|=h.subtreeFlags&14680064,c|=h.flags&14680064,h.return=t,h=h.sibling;else for(h=t.child;h!==null;)o|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=t,h=h.sibling;return t.subtreeFlags|=c,t.childLanes=o,s}function cy(t,s,o){var c=s.pendingProps;switch(rl(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ut(s),null;case 1:return Qt(s.type)&&Ha(),Ut(s),null;case 3:return c=s.stateNode,is(),vt(Jt),vt(Dt),gl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ya(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,wn!==null&&(ql(wn),wn=null))),Ll(t,s),Ut(s),null;case 5:ml(s);var h=Ar(Ys.current);if(o=s.type,t!==null&&s.stateNode!=null)yh(t,s,o,c,h),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!c){if(s.stateNode===null)throw Error(a(166));return Ut(s),null}if(t=Ar(Pn.current),Ya(s)){c=s.stateNode,o=s.type;var g=s.memoizedProps;switch(c[$n]=s,c[Hs]=g,t=(s.mode&1)!==0,o){case"dialog":gt("cancel",c),gt("close",c);break;case"iframe":case"object":case"embed":gt("load",c);break;case"video":case"audio":for(h=0;h<Bs.length;h++)gt(Bs[h],c);break;case"source":gt("error",c);break;case"img":case"image":case"link":gt("error",c),gt("load",c);break;case"details":gt("toggle",c);break;case"input":_e(c,g),gt("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},gt("invalid",c);break;case"textarea":et(c,g),gt("invalid",c)}qe(o,g),h=null;for(var b in g)if(g.hasOwnProperty(b)){var A=g[b];b==="children"?typeof A=="string"?c.textContent!==A&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,A,t),h=["children",A]):typeof A=="number"&&c.textContent!==""+A&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,A,t),h=["children",""+A]):l.hasOwnProperty(b)&&A!=null&&b==="onScroll"&&gt("scroll",c)}switch(o){case"input":Oe(c),ct(c,g,!0);break;case"textarea":Oe(c),Ie(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=Ua)}c=h,s.updateQueue=c,c!==null&&(s.flags|=4)}else{b=h.nodeType===9?h:h.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=We(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=b.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=b.createElement(o,{is:c.is}):(t=b.createElement(o),o==="select"&&(b=t,c.multiple?b.multiple=!0:c.size&&(b.size=c.size))):t=b.createElementNS(t,o),t[$n]=s,t[Hs]=c,vh(t,s,!1,!1),s.stateNode=t;e:{switch(b=H(o,c),o){case"dialog":gt("cancel",t),gt("close",t),h=c;break;case"iframe":case"object":case"embed":gt("load",t),h=c;break;case"video":case"audio":for(h=0;h<Bs.length;h++)gt(Bs[h],t);h=c;break;case"source":gt("error",t),h=c;break;case"img":case"image":case"link":gt("error",t),gt("load",t),h=c;break;case"details":gt("toggle",t),h=c;break;case"input":_e(t,c),h=Te(t,c),gt("invalid",t);break;case"option":h=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},h=J({},c,{value:void 0}),gt("invalid",t);break;case"textarea":et(t,c),h=dt(t,c),gt("invalid",t);break;default:h=c}qe(o,h),A=h;for(g in A)if(A.hasOwnProperty(g)){var R=A[g];g==="style"?ht(t,R):g==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&ye(t,R)):g==="children"?typeof R=="string"?(o!=="textarea"||R!=="")&&ze(t,R):typeof R=="number"&&ze(t,""+R):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(l.hasOwnProperty(g)?R!=null&&g==="onScroll"&&gt("scroll",t):R!=null&&$(t,g,R,b))}switch(o){case"input":Oe(t),ct(t,c,!1);break;case"textarea":Oe(t),Ie(t);break;case"option":c.value!=null&&t.setAttribute("value",""+he(c.value));break;case"select":t.multiple=!!c.multiple,g=c.value,g!=null?Be(t,!!c.multiple,g,!1):c.defaultValue!=null&&Be(t,!!c.multiple,c.defaultValue,!0);break;default:typeof h.onClick=="function"&&(t.onclick=Ua)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Ut(s),null;case 6:if(t&&s.stateNode!=null)xh(t,s,t.memoizedProps,c);else{if(typeof c!="string"&&s.stateNode===null)throw Error(a(166));if(o=Ar(Ys.current),Ar(Pn.current),Ya(s)){if(c=s.stateNode,o=s.memoizedProps,c[$n]=s,(g=c.nodeValue!==o)&&(t=on,t!==null))switch(t.tag){case 3:Ba(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ba(c.nodeValue,o,(t.mode&1)!==0)}g&&(s.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[$n]=s,s.stateNode=c}return Ut(s),null;case 13:if(vt(wt),c=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(yt&&ln!==null&&(s.mode&1)!==0&&(s.flags&128)===0)bd(),ns(),s.flags|=98560,g=!1;else if(g=Ya(s),c!==null&&c.dehydrated!==null){if(t===null){if(!g)throw Error(a(318));if(g=s.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(a(317));g[$n]=s}else ns(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Ut(s),g=!1}else wn!==null&&(ql(wn),wn=null),g=!0;if(!g)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=o,s):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(wt.current&1)!==0?Rt===0&&(Rt=3):Yl())),s.updateQueue!==null&&(s.flags|=4),Ut(s),null);case 4:return is(),Ll(t,s),t===null&&Us(s.stateNode.containerInfo),Ut(s),null;case 10:return cl(s.type._context),Ut(s),null;case 17:return Qt(s.type)&&Ha(),Ut(s),null;case 19:if(vt(wt),g=s.memoizedState,g===null)return Ut(s),null;if(c=(s.flags&128)!==0,b=g.rendering,b===null)if(c)ea(g,!1);else{if(Rt!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(b=ti(t),b!==null){for(s.flags|=128,ea(g,!1),c=b.updateQueue,c!==null&&(s.updateQueue=c,s.flags|=4),s.subtreeFlags=0,c=o,o=s.child;o!==null;)g=o,t=c,g.flags&=14680066,b=g.alternate,b===null?(g.childLanes=0,g.lanes=t,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=b.childLanes,g.lanes=b.lanes,g.child=b.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=b.memoizedProps,g.memoizedState=b.memoizedState,g.updateQueue=b.updateQueue,g.type=b.type,t=b.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return ft(wt,wt.current&1|2),s.child}t=t.sibling}g.tail!==null&&Ct()>us&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304)}else{if(!c)if(t=ti(b),t!==null){if(s.flags|=128,c=!0,o=t.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),ea(g,!0),g.tail===null&&g.tailMode==="hidden"&&!b.alternate&&!yt)return Ut(s),null}else 2*Ct()-g.renderingStartTime>us&&o!==1073741824&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304);g.isBackwards?(b.sibling=s.child,s.child=b):(o=g.last,o!==null?o.sibling=b:s.child=b,g.last=b)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=Ct(),s.sibling=null,o=wt.current,ft(wt,c?o&1|2:o&1),s):(Ut(s),null);case 22:case 23:return Gl(),c=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(s.flags|=8192),c&&(s.mode&1)!==0?(cn&1073741824)!==0&&(Ut(s),s.subtreeFlags&6&&(s.flags|=8192)):Ut(s),null;case 24:return null;case 25:return null}throw Error(a(156,s.tag))}function uy(t,s){switch(rl(s),s.tag){case 1:return Qt(s.type)&&Ha(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return is(),vt(Jt),vt(Dt),gl(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return ml(s),null;case 13:if(vt(wt),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(a(340));ns()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return vt(wt),null;case 4:return is(),null;case 10:return cl(s.type._context),null;case 22:case 23:return Gl(),null;case 24:return null;default:return null}}var ui=!1,Wt=!1,dy=typeof WeakSet=="function"?WeakSet:Set,Se=null;function ls(t,s){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){St(t,s,c)}else o.current=null}function Ml(t,s,o){try{o()}catch(c){St(t,s,c)}}var jh=!1;function hy(t,s){if(Go=Ia,t=Xu(),Do(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var h=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var b=0,A=-1,R=-1,q=0,ae=0,ce=t,re=null;t:for(;;){for(var je;ce!==o||h!==0&&ce.nodeType!==3||(A=b+h),ce!==g||c!==0&&ce.nodeType!==3||(R=b+c),ce.nodeType===3&&(b+=ce.nodeValue.length),(je=ce.firstChild)!==null;)re=ce,ce=je;for(;;){if(ce===t)break t;if(re===o&&++q===h&&(A=b),re===g&&++ae===c&&(R=b),(je=ce.nextSibling)!==null)break;ce=re,re=ce.parentNode}ce=je}o=A===-1||R===-1?null:{start:A,end:R}}else o=null}o=o||{start:0,end:0}}else o=null;for(Yo={focusedElem:t,selectionRange:o},Ia=!1,Se=s;Se!==null;)if(s=Se,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Se=t;else for(;Se!==null;){s=Se;try{var Ce=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Re=Ce.memoizedProps,Et=Ce.memoizedState,O=s.stateNode,L=O.getSnapshotBeforeUpdate(s.elementType===s.type?Re:bn(s.type,Re),Et);O.__reactInternalSnapshotBeforeUpdate=L}break;case 3:var W=s.stateNode.containerInfo;W.nodeType===1?W.textContent="":W.nodeType===9&&W.documentElement&&W.removeChild(W.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(fe){St(s,s.return,fe)}if(t=s.sibling,t!==null){t.return=s.return,Se=t;break}Se=s.return}return Ce=jh,jh=!1,Ce}function ta(t,s,o){var c=s.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var h=c=c.next;do{if((h.tag&t)===t){var g=h.destroy;h.destroy=void 0,g!==void 0&&Ml(s,o,g)}h=h.next}while(h!==c)}}function di(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==s)}}function Fl(t){var s=t.ref;if(s!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof s=="function"?s(t):s.current=t}}function wh(t){var s=t.alternate;s!==null&&(t.alternate=null,wh(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[$n],delete s[Hs],delete s[Zo],delete s[Gv],delete s[Yv])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function bh(t){return t.tag===5||t.tag===3||t.tag===4}function kh(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||bh(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ol(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(t,s):o.insertBefore(t,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(t,o)):(s=o,s.appendChild(t)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ua));else if(c!==4&&(t=t.child,t!==null))for(Ol(t,s,o),t=t.sibling;t!==null;)Ol(t,s,o),t=t.sibling}function zl(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.insertBefore(t,s):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(zl(t,s,o),t=t.sibling;t!==null;)zl(t,s,o),t=t.sibling}var Ft=null,kn=!1;function dr(t,s,o){for(o=o.child;o!==null;)Sh(t,s,o),o=o.sibling}function Sh(t,s,o){if(Rn&&typeof Rn.onCommitFiberUnmount=="function")try{Rn.onCommitFiberUnmount(Sa,o)}catch{}switch(o.tag){case 5:Wt||ls(o,s);case 6:var c=Ft,h=kn;Ft=null,dr(t,s,o),Ft=c,kn=h,Ft!==null&&(kn?(t=Ft,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):Ft.removeChild(o.stateNode));break;case 18:Ft!==null&&(kn?(t=Ft,o=o.stateNode,t.nodeType===8?Xo(t.parentNode,o):t.nodeType===1&&Xo(t,o),Ps(t)):Xo(Ft,o.stateNode));break;case 4:c=Ft,h=kn,Ft=o.stateNode.containerInfo,kn=!0,dr(t,s,o),Ft=c,kn=h;break;case 0:case 11:case 14:case 15:if(!Wt&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){h=c=c.next;do{var g=h,b=g.destroy;g=g.tag,b!==void 0&&((g&2)!==0||(g&4)!==0)&&Ml(o,s,b),h=h.next}while(h!==c)}dr(t,s,o);break;case 1:if(!Wt&&(ls(o,s),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(A){St(o,s,A)}dr(t,s,o);break;case 21:dr(t,s,o);break;case 22:o.mode&1?(Wt=(c=Wt)||o.memoizedState!==null,dr(t,s,o),Wt=c):dr(t,s,o);break;default:dr(t,s,o)}}function Nh(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new dy),s.forEach(function(c){var h=wy.bind(null,t,c);o.has(c)||(o.add(c),c.then(h,h))})}}function Sn(t,s){var o=s.deletions;if(o!==null)for(var c=0;c<o.length;c++){var h=o[c];try{var g=t,b=s,A=b;e:for(;A!==null;){switch(A.tag){case 5:Ft=A.stateNode,kn=!1;break e;case 3:Ft=A.stateNode.containerInfo,kn=!0;break e;case 4:Ft=A.stateNode.containerInfo,kn=!0;break e}A=A.return}if(Ft===null)throw Error(a(160));Sh(g,b,h),Ft=null,kn=!1;var R=h.alternate;R!==null&&(R.return=null),h.return=null}catch(q){St(h,s,q)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Ch(s,t),s=s.sibling}function Ch(t,s){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Sn(s,t),Ln(t),c&4){try{ta(3,t,t.return),di(3,t)}catch(Re){St(t,t.return,Re)}try{ta(5,t,t.return)}catch(Re){St(t,t.return,Re)}}break;case 1:Sn(s,t),Ln(t),c&512&&o!==null&&ls(o,o.return);break;case 5:if(Sn(s,t),Ln(t),c&512&&o!==null&&ls(o,o.return),t.flags&32){var h=t.stateNode;try{ze(h,"")}catch(Re){St(t,t.return,Re)}}if(c&4&&(h=t.stateNode,h!=null)){var g=t.memoizedProps,b=o!==null?o.memoizedProps:g,A=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{A==="input"&&g.type==="radio"&&g.name!=null&&Ve(h,g),H(A,b);var q=H(A,g);for(b=0;b<R.length;b+=2){var ae=R[b],ce=R[b+1];ae==="style"?ht(h,ce):ae==="dangerouslySetInnerHTML"?ye(h,ce):ae==="children"?ze(h,ce):$(h,ae,ce,q)}switch(A){case"input":Ge(h,g);break;case"textarea":De(h,g);break;case"select":var re=h._wrapperState.wasMultiple;h._wrapperState.wasMultiple=!!g.multiple;var je=g.value;je!=null?Be(h,!!g.multiple,je,!1):re!==!!g.multiple&&(g.defaultValue!=null?Be(h,!!g.multiple,g.defaultValue,!0):Be(h,!!g.multiple,g.multiple?[]:"",!1))}h[Hs]=g}catch(Re){St(t,t.return,Re)}}break;case 6:if(Sn(s,t),Ln(t),c&4){if(t.stateNode===null)throw Error(a(162));h=t.stateNode,g=t.memoizedProps;try{h.nodeValue=g}catch(Re){St(t,t.return,Re)}}break;case 3:if(Sn(s,t),Ln(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Ps(s.containerInfo)}catch(Re){St(t,t.return,Re)}break;case 4:Sn(s,t),Ln(t);break;case 13:Sn(s,t),Ln(t),h=t.child,h.flags&8192&&(g=h.memoizedState!==null,h.stateNode.isHidden=g,!g||h.alternate!==null&&h.alternate.memoizedState!==null||(Ul=Ct())),c&4&&Nh(t);break;case 22:if(ae=o!==null&&o.memoizedState!==null,t.mode&1?(Wt=(q=Wt)||ae,Sn(s,t),Wt=q):Sn(s,t),Ln(t),c&8192){if(q=t.memoizedState!==null,(t.stateNode.isHidden=q)&&!ae&&(t.mode&1)!==0)for(Se=t,ae=t.child;ae!==null;){for(ce=Se=ae;Se!==null;){switch(re=Se,je=re.child,re.tag){case 0:case 11:case 14:case 15:ta(4,re,re.return);break;case 1:ls(re,re.return);var Ce=re.stateNode;if(typeof Ce.componentWillUnmount=="function"){c=re,o=re.return;try{s=c,Ce.props=s.memoizedProps,Ce.state=s.memoizedState,Ce.componentWillUnmount()}catch(Re){St(c,o,Re)}}break;case 5:ls(re,re.return);break;case 22:if(re.memoizedState!==null){Th(ce);continue}}je!==null?(je.return=re,Se=je):Th(ce)}ae=ae.sibling}e:for(ae=null,ce=t;;){if(ce.tag===5){if(ae===null){ae=ce;try{h=ce.stateNode,q?(g=h.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(A=ce.stateNode,R=ce.memoizedProps.style,b=R!=null&&R.hasOwnProperty("display")?R.display:null,A.style.display=st("display",b))}catch(Re){St(t,t.return,Re)}}}else if(ce.tag===6){if(ae===null)try{ce.stateNode.nodeValue=q?"":ce.memoizedProps}catch(Re){St(t,t.return,Re)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===t)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===t)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===t)break e;ae===ce&&(ae=null),ce=ce.return}ae===ce&&(ae=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:Sn(s,t),Ln(t),c&4&&Nh(t);break;case 21:break;default:Sn(s,t),Ln(t)}}function Ln(t){var s=t.flags;if(s&2){try{e:{for(var o=t.return;o!==null;){if(bh(o)){var c=o;break e}o=o.return}throw Error(a(160))}switch(c.tag){case 5:var h=c.stateNode;c.flags&32&&(ze(h,""),c.flags&=-33);var g=kh(t);zl(t,g,h);break;case 3:case 4:var b=c.stateNode.containerInfo,A=kh(t);Ol(t,A,b);break;default:throw Error(a(161))}}catch(R){St(t,t.return,R)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function fy(t,s,o){Se=t,Eh(t)}function Eh(t,s,o){for(var c=(t.mode&1)!==0;Se!==null;){var h=Se,g=h.child;if(h.tag===22&&c){var b=h.memoizedState!==null||ui;if(!b){var A=h.alternate,R=A!==null&&A.memoizedState!==null||Wt;A=ui;var q=Wt;if(ui=b,(Wt=R)&&!q)for(Se=h;Se!==null;)b=Se,R=b.child,b.tag===22&&b.memoizedState!==null?Ih(h):R!==null?(R.return=b,Se=R):Ih(h);for(;g!==null;)Se=g,Eh(g),g=g.sibling;Se=h,ui=A,Wt=q}Ah(t)}else(h.subtreeFlags&8772)!==0&&g!==null?(g.return=h,Se=g):Ah(t)}}function Ah(t){for(;Se!==null;){var s=Se;if((s.flags&8772)!==0){var o=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:Wt||di(5,s);break;case 1:var c=s.stateNode;if(s.flags&4&&!Wt)if(o===null)c.componentDidMount();else{var h=s.elementType===s.type?o.memoizedProps:bn(s.type,o.memoizedProps);c.componentDidUpdate(h,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=s.updateQueue;g!==null&&Td(s,g,c);break;case 3:var b=s.updateQueue;if(b!==null){if(o=null,s.child!==null)switch(s.child.tag){case 5:o=s.child.stateNode;break;case 1:o=s.child.stateNode}Td(s,b,o)}break;case 5:var A=s.stateNode;if(o===null&&s.flags&4){o=A;var R=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&o.focus();break;case"img":R.src&&(o.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var q=s.alternate;if(q!==null){var ae=q.memoizedState;if(ae!==null){var ce=ae.dehydrated;ce!==null&&Ps(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Wt||s.flags&512&&Fl(s)}catch(re){St(s,s.return,re)}}if(s===t){Se=null;break}if(o=s.sibling,o!==null){o.return=s.return,Se=o;break}Se=s.return}}function Th(t){for(;Se!==null;){var s=Se;if(s===t){Se=null;break}var o=s.sibling;if(o!==null){o.return=s.return,Se=o;break}Se=s.return}}function Ih(t){for(;Se!==null;){var s=Se;try{switch(s.tag){case 0:case 11:case 15:var o=s.return;try{di(4,s)}catch(R){St(s,o,R)}break;case 1:var c=s.stateNode;if(typeof c.componentDidMount=="function"){var h=s.return;try{c.componentDidMount()}catch(R){St(s,h,R)}}var g=s.return;try{Fl(s)}catch(R){St(s,g,R)}break;case 5:var b=s.return;try{Fl(s)}catch(R){St(s,b,R)}}}catch(R){St(s,s.return,R)}if(s===t){Se=null;break}var A=s.sibling;if(A!==null){A.return=s.return,Se=A;break}Se=s.return}}var my=Math.ceil,hi=T.ReactCurrentDispatcher,Dl=T.ReactCurrentOwner,pn=T.ReactCurrentBatchConfig,rt=0,_t=null,Tt=null,Ot=0,cn=0,cs=ir(0),Rt=0,na=null,Ir=0,fi=0,Bl=0,ra=null,Zt=null,Ul=0,us=1/0,Kn=null,mi=!1,Wl=null,hr=null,pi=!1,fr=null,gi=0,sa=0,Hl=null,vi=-1,yi=0;function Kt(){return(rt&6)!==0?Ct():vi!==-1?vi:vi=Ct()}function mr(t){return(t.mode&1)===0?1:(rt&2)!==0&&Ot!==0?Ot&-Ot:Qv.transition!==null?(yi===0&&(yi=ku()),yi):(t=lt,t!==0||(t=window.event,t=t===void 0?16:$u(t.type)),t)}function Nn(t,s,o,c){if(50<sa)throw sa=0,Hl=null,Error(a(185));As(t,o,c),((rt&2)===0||t!==_t)&&(t===_t&&((rt&2)===0&&(fi|=o),Rt===4&&pr(t,Ot)),en(t,c),o===1&&rt===0&&(s.mode&1)===0&&(us=Ct()+500,qa&&lr()))}function en(t,s){var o=t.callbackNode;Qg(t,s);var c=Ea(t,t===_t?Ot:0);if(c===0)o!==null&&ju(o),t.callbackNode=null,t.callbackPriority=0;else if(s=c&-c,t.callbackPriority!==s){if(o!=null&&ju(o),s===1)t.tag===0?Jv($h.bind(null,t)):vd($h.bind(null,t)),qv(function(){(rt&6)===0&&lr()}),o=null;else{switch(Su(c)){case 1:o=ko;break;case 4:o=wu;break;case 16:o=ka;break;case 536870912:o=bu;break;default:o=ka}o=Dh(o,Rh.bind(null,t))}t.callbackPriority=s,t.callbackNode=o}}function Rh(t,s){if(vi=-1,yi=0,(rt&6)!==0)throw Error(a(327));var o=t.callbackNode;if(ds()&&t.callbackNode!==o)return null;var c=Ea(t,t===_t?Ot:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||s)s=xi(t,c);else{s=c;var h=rt;rt|=2;var g=_h();(_t!==t||Ot!==s)&&(Kn=null,us=Ct()+500,$r(t,s));do try{vy();break}catch(A){Ph(t,A)}while(!0);ll(),hi.current=g,rt=h,Tt!==null?s=0:(_t=null,Ot=0,s=Rt)}if(s!==0){if(s===2&&(h=So(t),h!==0&&(c=h,s=Vl(t,h))),s===1)throw o=na,$r(t,0),pr(t,c),en(t,Ct()),o;if(s===6)pr(t,c);else{if(h=t.current.alternate,(c&30)===0&&!py(h)&&(s=xi(t,c),s===2&&(g=So(t),g!==0&&(c=g,s=Vl(t,g))),s===1))throw o=na,$r(t,0),pr(t,c),en(t,Ct()),o;switch(t.finishedWork=h,t.finishedLanes=c,s){case 0:case 1:throw Error(a(345));case 2:Pr(t,Zt,Kn);break;case 3:if(pr(t,c),(c&130023424)===c&&(s=Ul+500-Ct(),10<s)){if(Ea(t,0)!==0)break;if(h=t.suspendedLanes,(h&c)!==c){Kt(),t.pingedLanes|=t.suspendedLanes&h;break}t.timeoutHandle=Qo(Pr.bind(null,t,Zt,Kn),s);break}Pr(t,Zt,Kn);break;case 4:if(pr(t,c),(c&4194240)===c)break;for(s=t.eventTimes,h=-1;0<c;){var b=31-xn(c);g=1<<b,b=s[b],b>h&&(h=b),c&=~g}if(c=h,c=Ct()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*my(c/1960))-c,10<c){t.timeoutHandle=Qo(Pr.bind(null,t,Zt,Kn),c);break}Pr(t,Zt,Kn);break;case 5:Pr(t,Zt,Kn);break;default:throw Error(a(329))}}}return en(t,Ct()),t.callbackNode===o?Rh.bind(null,t):null}function Vl(t,s){var o=ra;return t.current.memoizedState.isDehydrated&&($r(t,s).flags|=256),t=xi(t,s),t!==2&&(s=Zt,Zt=o,s!==null&&ql(s)),t}function ql(t){Zt===null?Zt=t:Zt.push.apply(Zt,t)}function py(t){for(var s=t;;){if(s.flags&16384){var o=s.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var h=o[c],g=h.getSnapshot;h=h.value;try{if(!jn(g(),h))return!1}catch{return!1}}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function pr(t,s){for(s&=~Bl,s&=~fi,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var o=31-xn(s),c=1<<o;t[o]=-1,s&=~c}}function $h(t){if((rt&6)!==0)throw Error(a(327));ds();var s=Ea(t,0);if((s&1)===0)return en(t,Ct()),null;var o=xi(t,s);if(t.tag!==0&&o===2){var c=So(t);c!==0&&(s=c,o=Vl(t,c))}if(o===1)throw o=na,$r(t,0),pr(t,s),en(t,Ct()),o;if(o===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,Pr(t,Zt,Kn),en(t,Ct()),null}function Kl(t,s){var o=rt;rt|=1;try{return t(s)}finally{rt=o,rt===0&&(us=Ct()+500,qa&&lr())}}function Rr(t){fr!==null&&fr.tag===0&&(rt&6)===0&&ds();var s=rt;rt|=1;var o=pn.transition,c=lt;try{if(pn.transition=null,lt=1,t)return t()}finally{lt=c,pn.transition=o,rt=s,(rt&6)===0&&lr()}}function Gl(){cn=cs.current,vt(cs)}function $r(t,s){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,Vv(o)),Tt!==null)for(o=Tt.return;o!==null;){var c=o;switch(rl(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ha();break;case 3:is(),vt(Jt),vt(Dt),gl();break;case 5:ml(c);break;case 4:is();break;case 13:vt(wt);break;case 19:vt(wt);break;case 10:cl(c.type._context);break;case 22:case 23:Gl()}o=o.return}if(_t=t,Tt=t=gr(t.current,null),Ot=cn=s,Rt=0,na=null,Bl=fi=Ir=0,Zt=ra=null,Er!==null){for(s=0;s<Er.length;s++)if(o=Er[s],c=o.interleaved,c!==null){o.interleaved=null;var h=c.next,g=o.pending;if(g!==null){var b=g.next;g.next=h,c.next=b}o.pending=c}Er=null}return t}function Ph(t,s){do{var o=Tt;try{if(ll(),ni.current=ii,ri){for(var c=bt.memoizedState;c!==null;){var h=c.queue;h!==null&&(h.pending=null),c=c.next}ri=!1}if(Tr=0,Pt=It=bt=null,Js=!1,Qs=0,Dl.current=null,o===null||o.return===null){Rt=1,na=s,Tt=null;break}e:{var g=t,b=o.return,A=o,R=s;if(s=Ot,A.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var q=R,ae=A,ce=ae.tag;if((ae.mode&1)===0&&(ce===0||ce===11||ce===15)){var re=ae.alternate;re?(ae.updateQueue=re.updateQueue,ae.memoizedState=re.memoizedState,ae.lanes=re.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var je=sh(b);if(je!==null){je.flags&=-257,ah(je,b,A,g,s),je.mode&1&&rh(g,q,s),s=je,R=q;var Ce=s.updateQueue;if(Ce===null){var Re=new Set;Re.add(R),s.updateQueue=Re}else Ce.add(R);break e}else{if((s&1)===0){rh(g,q,s),Yl();break e}R=Error(a(426))}}else if(yt&&A.mode&1){var Et=sh(b);if(Et!==null){(Et.flags&65536)===0&&(Et.flags|=256),ah(Et,b,A,g,s),il(os(R,A));break e}}g=R=os(R,A),Rt!==4&&(Rt=2),ra===null?ra=[g]:ra.push(g),g=b;do{switch(g.tag){case 3:g.flags|=65536,s&=-s,g.lanes|=s;var O=th(g,R,s);Ad(g,O);break e;case 1:A=R;var L=g.type,W=g.stateNode;if((g.flags&128)===0&&(typeof L.getDerivedStateFromError=="function"||W!==null&&typeof W.componentDidCatch=="function"&&(hr===null||!hr.has(W)))){g.flags|=65536,s&=-s,g.lanes|=s;var fe=nh(g,A,s);Ad(g,fe);break e}}g=g.return}while(g!==null)}Mh(o)}catch(Pe){s=Pe,Tt===o&&o!==null&&(Tt=o=o.return);continue}break}while(!0)}function _h(){var t=hi.current;return hi.current=ii,t===null?ii:t}function Yl(){(Rt===0||Rt===3||Rt===2)&&(Rt=4),_t===null||(Ir&268435455)===0&&(fi&268435455)===0||pr(_t,Ot)}function xi(t,s){var o=rt;rt|=2;var c=_h();(_t!==t||Ot!==s)&&(Kn=null,$r(t,s));do try{gy();break}catch(h){Ph(t,h)}while(!0);if(ll(),rt=o,hi.current=c,Tt!==null)throw Error(a(261));return _t=null,Ot=0,Rt}function gy(){for(;Tt!==null;)Lh(Tt)}function vy(){for(;Tt!==null&&!Ug();)Lh(Tt)}function Lh(t){var s=zh(t.alternate,t,cn);t.memoizedProps=t.pendingProps,s===null?Mh(t):Tt=s,Dl.current=null}function Mh(t){var s=t;do{var o=s.alternate;if(t=s.return,(s.flags&32768)===0){if(o=cy(o,s,cn),o!==null){Tt=o;return}}else{if(o=uy(o,s),o!==null){o.flags&=32767,Tt=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Rt=6,Tt=null;return}}if(s=s.sibling,s!==null){Tt=s;return}Tt=s=t}while(s!==null);Rt===0&&(Rt=5)}function Pr(t,s,o){var c=lt,h=pn.transition;try{pn.transition=null,lt=1,yy(t,s,o,c)}finally{pn.transition=h,lt=c}return null}function yy(t,s,o,c){do ds();while(fr!==null);if((rt&6)!==0)throw Error(a(327));o=t.finishedWork;var h=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var g=o.lanes|o.childLanes;if(Xg(t,g),t===_t&&(Tt=_t=null,Ot=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||pi||(pi=!0,Dh(ka,function(){return ds(),null})),g=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||g){g=pn.transition,pn.transition=null;var b=lt;lt=1;var A=rt;rt|=4,Dl.current=null,hy(t,o),Ch(o,t),Ov(Yo),Ia=!!Go,Yo=Go=null,t.current=o,fy(o),Wg(),rt=A,lt=b,pn.transition=g}else t.current=o;if(pi&&(pi=!1,fr=t,gi=h),g=t.pendingLanes,g===0&&(hr=null),qg(o.stateNode),en(t,Ct()),s!==null)for(c=t.onRecoverableError,o=0;o<s.length;o++)h=s[o],c(h.value,{componentStack:h.stack,digest:h.digest});if(mi)throw mi=!1,t=Wl,Wl=null,t;return(gi&1)!==0&&t.tag!==0&&ds(),g=t.pendingLanes,(g&1)!==0?t===Hl?sa++:(sa=0,Hl=t):sa=0,lr(),null}function ds(){if(fr!==null){var t=Su(gi),s=pn.transition,o=lt;try{if(pn.transition=null,lt=16>t?16:t,fr===null)var c=!1;else{if(t=fr,fr=null,gi=0,(rt&6)!==0)throw Error(a(331));var h=rt;for(rt|=4,Se=t.current;Se!==null;){var g=Se,b=g.child;if((Se.flags&16)!==0){var A=g.deletions;if(A!==null){for(var R=0;R<A.length;R++){var q=A[R];for(Se=q;Se!==null;){var ae=Se;switch(ae.tag){case 0:case 11:case 15:ta(8,ae,g)}var ce=ae.child;if(ce!==null)ce.return=ae,Se=ce;else for(;Se!==null;){ae=Se;var re=ae.sibling,je=ae.return;if(wh(ae),ae===q){Se=null;break}if(re!==null){re.return=je,Se=re;break}Se=je}}}var Ce=g.alternate;if(Ce!==null){var Re=Ce.child;if(Re!==null){Ce.child=null;do{var Et=Re.sibling;Re.sibling=null,Re=Et}while(Re!==null)}}Se=g}}if((g.subtreeFlags&2064)!==0&&b!==null)b.return=g,Se=b;else e:for(;Se!==null;){if(g=Se,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:ta(9,g,g.return)}var O=g.sibling;if(O!==null){O.return=g.return,Se=O;break e}Se=g.return}}var L=t.current;for(Se=L;Se!==null;){b=Se;var W=b.child;if((b.subtreeFlags&2064)!==0&&W!==null)W.return=b,Se=W;else e:for(b=L;Se!==null;){if(A=Se,(A.flags&2048)!==0)try{switch(A.tag){case 0:case 11:case 15:di(9,A)}}catch(Pe){St(A,A.return,Pe)}if(A===b){Se=null;break e}var fe=A.sibling;if(fe!==null){fe.return=A.return,Se=fe;break e}Se=A.return}}if(rt=h,lr(),Rn&&typeof Rn.onPostCommitFiberRoot=="function")try{Rn.onPostCommitFiberRoot(Sa,t)}catch{}c=!0}return c}finally{lt=o,pn.transition=s}}return!1}function Fh(t,s,o){s=os(o,s),s=th(t,s,1),t=ur(t,s,1),s=Kt(),t!==null&&(As(t,1,s),en(t,s))}function St(t,s,o){if(t.tag===3)Fh(t,t,o);else for(;s!==null;){if(s.tag===3){Fh(s,t,o);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(hr===null||!hr.has(c))){t=os(o,t),t=nh(s,t,1),s=ur(s,t,1),t=Kt(),s!==null&&(As(s,1,t),en(s,t));break}}s=s.return}}function xy(t,s,o){var c=t.pingCache;c!==null&&c.delete(s),s=Kt(),t.pingedLanes|=t.suspendedLanes&o,_t===t&&(Ot&o)===o&&(Rt===4||Rt===3&&(Ot&130023424)===Ot&&500>Ct()-Ul?$r(t,0):Bl|=o),en(t,s)}function Oh(t,s){s===0&&((t.mode&1)===0?s=1:(s=Ca,Ca<<=1,(Ca&130023424)===0&&(Ca=4194304)));var o=Kt();t=Hn(t,s),t!==null&&(As(t,s,o),en(t,o))}function jy(t){var s=t.memoizedState,o=0;s!==null&&(o=s.retryLane),Oh(t,o)}function wy(t,s){var o=0;switch(t.tag){case 13:var c=t.stateNode,h=t.memoizedState;h!==null&&(o=h.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(s),Oh(t,o)}var zh;zh=function(t,s,o){if(t!==null)if(t.memoizedProps!==s.pendingProps||Jt.current)Xt=!0;else{if((t.lanes&o)===0&&(s.flags&128)===0)return Xt=!1,ly(t,s,o);Xt=(t.flags&131072)!==0}else Xt=!1,yt&&(s.flags&1048576)!==0&&yd(s,Ga,s.index);switch(s.lanes=0,s.tag){case 2:var c=s.type;ci(t,s),t=s.pendingProps;var h=Zr(s,Dt.current);as(s,o),h=xl(null,s,c,t,h,o);var g=jl();return s.flags|=1,typeof h=="object"&&h!==null&&typeof h.render=="function"&&h.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Qt(c)?(g=!0,Va(s)):g=!1,s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,hl(s),h.updater=oi,s.stateNode=h,h._reactInternals=s,Cl(s,c,t,o),s=Il(null,s,c,!0,g,o)):(s.tag=0,yt&&g&&nl(s),qt(null,s,h,o),s=s.child),s;case 16:c=s.elementType;e:{switch(ci(t,s),t=s.pendingProps,h=c._init,c=h(c._payload),s.type=c,h=s.tag=ky(c),t=bn(c,t),h){case 0:s=Tl(null,s,c,t,o);break e;case 1:s=dh(null,s,c,t,o);break e;case 11:s=ih(null,s,c,t,o);break e;case 14:s=oh(null,s,c,bn(c.type,t),o);break e}throw Error(a(306,c,""))}return s;case 0:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),Tl(t,s,c,h,o);case 1:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),dh(t,s,c,h,o);case 3:e:{if(hh(s),t===null)throw Error(a(387));c=s.pendingProps,g=s.memoizedState,h=g.element,Ed(t,s),ei(s,c,null,o);var b=s.memoizedState;if(c=b.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:b.cache,pendingSuspenseBoundaries:b.pendingSuspenseBoundaries,transitions:b.transitions},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){h=os(Error(a(423)),s),s=fh(t,s,c,o,h);break e}else if(c!==h){h=os(Error(a(424)),s),s=fh(t,s,c,o,h);break e}else for(ln=ar(s.stateNode.containerInfo.firstChild),on=s,yt=!0,wn=null,o=Nd(s,null,c,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ns(),c===h){s=qn(t,s,o);break e}qt(t,s,c,o)}s=s.child}return s;case 5:return Id(s),t===null&&al(s),c=s.type,h=s.pendingProps,g=t!==null?t.memoizedProps:null,b=h.children,Jo(c,h)?b=null:g!==null&&Jo(c,g)&&(s.flags|=32),uh(t,s),qt(t,s,b,o),s.child;case 6:return t===null&&al(s),null;case 13:return mh(t,s,o);case 4:return fl(s,s.stateNode.containerInfo),c=s.pendingProps,t===null?s.child=rs(s,null,c,o):qt(t,s,c,o),s.child;case 11:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),ih(t,s,c,h,o);case 7:return qt(t,s,s.pendingProps,o),s.child;case 8:return qt(t,s,s.pendingProps.children,o),s.child;case 12:return qt(t,s,s.pendingProps.children,o),s.child;case 10:e:{if(c=s.type._context,h=s.pendingProps,g=s.memoizedProps,b=h.value,ft(Qa,c._currentValue),c._currentValue=b,g!==null)if(jn(g.value,b)){if(g.children===h.children&&!Jt.current){s=qn(t,s,o);break e}}else for(g=s.child,g!==null&&(g.return=s);g!==null;){var A=g.dependencies;if(A!==null){b=g.child;for(var R=A.firstContext;R!==null;){if(R.context===c){if(g.tag===1){R=Vn(-1,o&-o),R.tag=2;var q=g.updateQueue;if(q!==null){q=q.shared;var ae=q.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),q.pending=R}}g.lanes|=o,R=g.alternate,R!==null&&(R.lanes|=o),ul(g.return,o,s),A.lanes|=o;break}R=R.next}}else if(g.tag===10)b=g.type===s.type?null:g.child;else if(g.tag===18){if(b=g.return,b===null)throw Error(a(341));b.lanes|=o,A=b.alternate,A!==null&&(A.lanes|=o),ul(b,o,s),b=g.sibling}else b=g.child;if(b!==null)b.return=g;else for(b=g;b!==null;){if(b===s){b=null;break}if(g=b.sibling,g!==null){g.return=b.return,b=g;break}b=b.return}g=b}qt(t,s,h.children,o),s=s.child}return s;case 9:return h=s.type,c=s.pendingProps.children,as(s,o),h=fn(h),c=c(h),s.flags|=1,qt(t,s,c,o),s.child;case 14:return c=s.type,h=bn(c,s.pendingProps),h=bn(c.type,h),oh(t,s,c,h,o);case 15:return lh(t,s,s.type,s.pendingProps,o);case 17:return c=s.type,h=s.pendingProps,h=s.elementType===c?h:bn(c,h),ci(t,s),s.tag=1,Qt(c)?(t=!0,Va(s)):t=!1,as(s,o),Zd(s,c,h),Cl(s,c,h,o),Il(null,s,c,!0,t,o);case 19:return gh(t,s,o);case 22:return ch(t,s,o)}throw Error(a(156,s.tag))};function Dh(t,s){return xu(t,s)}function by(t,s,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gn(t,s,o,c){return new by(t,s,o,c)}function Jl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function ky(t){if(typeof t=="function")return Jl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===V)return 11;if(t===me)return 14}return 2}function gr(t,s){var o=t.alternate;return o===null?(o=gn(t.tag,s,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=s,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,s=t.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function ji(t,s,o,c,h,g){var b=2;if(c=t,typeof t=="function")Jl(t)&&(b=1);else if(typeof t=="string")b=5;else e:switch(t){case B:return _r(o.children,h,g,s);case te:b=8,h|=8;break;case Q:return t=gn(12,o,s,h|2),t.elementType=Q,t.lanes=g,t;case K:return t=gn(13,o,s,h),t.elementType=K,t.lanes=g,t;case le:return t=gn(19,o,s,h),t.elementType=le,t.lanes=g,t;case Ae:return wi(o,h,g,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:b=10;break e;case z:b=9;break e;case V:b=11;break e;case me:b=14;break e;case we:b=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return s=gn(b,o,s,h),s.elementType=t,s.type=c,s.lanes=g,s}function _r(t,s,o,c){return t=gn(7,t,c,s),t.lanes=o,t}function wi(t,s,o,c){return t=gn(22,t,c,s),t.elementType=Ae,t.lanes=o,t.stateNode={isHidden:!1},t}function Ql(t,s,o){return t=gn(6,t,null,s),t.lanes=o,t}function Xl(t,s,o){return s=gn(4,t.children!==null?t.children:[],t.key,s),s.lanes=o,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Sy(t,s,o,c,h){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=No(0),this.expirationTimes=No(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=No(0),this.identifierPrefix=c,this.onRecoverableError=h,this.mutableSourceEagerHydrationData=null}function Zl(t,s,o,c,h,g,b,A,R){return t=new Sy(t,s,o,A,R),s===1?(s=1,g===!0&&(s|=8)):s=0,g=gn(3,null,null,s),t.current=g,g.stateNode=t,g.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},hl(g),t}function Ny(t,s,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:c==null?null:""+c,children:t,containerInfo:s,implementation:o}}function Bh(t){if(!t)return or;t=t._reactInternals;e:{if(Tn(t)!==t||t.tag!==1)throw Error(a(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(Qt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(a(171))}if(t.tag===1){var o=t.type;if(Qt(o))return pd(t,o,s)}return s}function Uh(t,s,o,c,h,g,b,A,R){return t=Zl(o,c,!0,t,h,g,b,A,R),t.context=Bh(null),o=t.current,c=Kt(),h=mr(o),g=Vn(c,h),g.callback=s??null,ur(o,g,h),t.current.lanes=h,As(t,h,c),en(t,c),t}function bi(t,s,o,c){var h=s.current,g=Kt(),b=mr(h);return o=Bh(o),s.context===null?s.context=o:s.pendingContext=o,s=Vn(g,b),s.payload={element:t},c=c===void 0?null:c,c!==null&&(s.callback=c),t=ur(h,s,b),t!==null&&(Nn(t,h,b,g),Za(t,h,b)),b}function ki(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Wh(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<s?o:s}}function ec(t,s){Wh(t,s),(t=t.alternate)&&Wh(t,s)}function Cy(){return null}var Hh=typeof reportError=="function"?reportError:function(t){console.error(t)};function tc(t){this._internalRoot=t}Si.prototype.render=tc.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(a(409));bi(t,s,null,null)},Si.prototype.unmount=tc.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;Rr(function(){bi(null,t,null,null)}),s[Dn]=null}};function Si(t){this._internalRoot=t}Si.prototype.unstable_scheduleHydration=function(t){if(t){var s=Eu();t={blockedOn:null,target:t,priority:s};for(var o=0;o<nr.length&&s!==0&&s<nr[o].priority;o++);nr.splice(o,0,t),o===0&&Iu(t)}};function nc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Ni(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Vh(){}function Ey(t,s,o,c,h){if(h){if(typeof c=="function"){var g=c;c=function(){var q=ki(b);g.call(q)}}var b=Uh(s,c,t,0,null,!1,!1,"",Vh);return t._reactRootContainer=b,t[Dn]=b.current,Us(t.nodeType===8?t.parentNode:t),Rr(),b}for(;h=t.lastChild;)t.removeChild(h);if(typeof c=="function"){var A=c;c=function(){var q=ki(R);A.call(q)}}var R=Zl(t,0,!1,null,null,!1,!1,"",Vh);return t._reactRootContainer=R,t[Dn]=R.current,Us(t.nodeType===8?t.parentNode:t),Rr(function(){bi(s,R,o,c)}),R}function Ci(t,s,o,c,h){var g=o._reactRootContainer;if(g){var b=g;if(typeof h=="function"){var A=h;h=function(){var R=ki(b);A.call(R)}}bi(s,b,t,h)}else b=Ey(o,s,t,h,c);return ki(b)}Nu=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var o=Es(s.pendingLanes);o!==0&&(Co(s,o|1),en(s,Ct()),(rt&6)===0&&(us=Ct()+500,lr()))}break;case 13:Rr(function(){var c=Hn(t,1);if(c!==null){var h=Kt();Nn(c,t,1,h)}}),ec(t,1)}},Eo=function(t){if(t.tag===13){var s=Hn(t,134217728);if(s!==null){var o=Kt();Nn(s,t,134217728,o)}ec(t,134217728)}},Cu=function(t){if(t.tag===13){var s=mr(t),o=Hn(t,s);if(o!==null){var c=Kt();Nn(o,t,s,c)}ec(t,s)}},Eu=function(){return lt},Au=function(t,s){var o=lt;try{return lt=t,s()}finally{lt=o}},X=function(t,s,o){switch(s){case"input":if(Ge(t,o),s=o.name,o.type==="radio"&&s!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<o.length;s++){var c=o[s];if(c!==t&&c.form===t.form){var h=Wa(c);if(!h)throw Error(a(90));Fe(c),Ge(c,h)}}}break;case"textarea":De(t,o);break;case"select":s=o.value,s!=null&&Be(t,!!o.multiple,s,!1)}},ne=Kl,xe=Rr;var Ay={usingClientEntryPoint:!1,Events:[Vs,Qr,Wa,He,kt,Kl]},aa={findFiberByHostInstance:kr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ty={bundleType:aa.bundleType,version:aa.version,rendererPackageName:aa.rendererPackageName,rendererConfig:aa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=In(t),t===null?null:t.stateNode},findFiberByHostInstance:aa.findFiberByHostInstance||Cy,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ei=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ei.isDisabled&&Ei.supportsFiber)try{Sa=Ei.inject(Ty),Rn=Ei}catch{}}return tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ay,tn.createPortal=function(t,s){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!nc(s))throw Error(a(200));return Ny(t,s,null,o)},tn.createRoot=function(t,s){if(!nc(t))throw Error(a(299));var o=!1,c="",h=Hh;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onRecoverableError!==void 0&&(h=s.onRecoverableError)),s=Zl(t,1,!1,null,null,o,!1,c,h),t[Dn]=s.current,Us(t.nodeType===8?t.parentNode:t),new tc(s)},tn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=In(s),t=t===null?null:t.stateNode,t},tn.flushSync=function(t){return Rr(t)},tn.hydrate=function(t,s,o){if(!Ni(s))throw Error(a(200));return Ci(null,t,s,!0,o)},tn.hydrateRoot=function(t,s,o){if(!nc(t))throw Error(a(405));var c=o!=null&&o.hydratedSources||null,h=!1,g="",b=Hh;if(o!=null&&(o.unstable_strictMode===!0&&(h=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(b=o.onRecoverableError)),s=Uh(s,null,t,1,o??null,h,!1,g,b),t[Dn]=s.current,Us(t),c)for(t=0;t<c.length;t++)o=c[t],h=o._getVersion,h=h(o._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[o,h]:s.mutableSourceEagerHydrationData.push(o,h);return new Si(s)},tn.render=function(t,s,o){if(!Ni(s))throw Error(a(200));return Ci(null,t,s,!1,o)},tn.unmountComponentAtNode=function(t){if(!Ni(t))throw Error(a(40));return t._reactRootContainer?(Rr(function(){Ci(null,null,t,!1,function(){t._reactRootContainer=null,t[Dn]=null})}),!0):!1},tn.unstable_batchedUpdates=Kl,tn.unstable_renderSubtreeIntoContainer=function(t,s,o,c){if(!Ni(o))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return Ci(t,s,o,!1,c)},tn.version="18.3.1-next-f1338f8080-20240426",tn}var Zh;function jm(){if(Zh)return ac.exports;Zh=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),ac.exports=Oy(),ac.exports}var ef;function zy(){if(ef)return Ai;ef=1;var e=jm();return Ai.createRoot=e.createRoot,Ai.hydrateRoot=e.hydrateRoot,Ai}var Dy=zy();/**
41
41
  * react-router v7.18.4
42
42
  *
43
43
  * Copyright (c) Remix Software Inc.
@@ -46,15 +46,15 @@ Error generating stack: `+g.message+`
46
46
  * LICENSE.md file in the root directory of this source tree.
47
47
  *
48
48
  * @license MIT
49
- */var Vc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,bm=/^[\\/]{2}/;function zy(e,r){return r+e.replace(/\\/g,"/")}var nf="popstate";function rf(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Dy(e={}){function r(i,l){var y;let u=(y=l.state)==null?void 0:y.masked,{pathname:d,search:p,hash:m}=u||i.location;return Sc("",{pathname:d,search:p,hash:m},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function a(i,l){return typeof l=="string"?l:zr(l)}return Uy(r,a,null,e)}function xt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function vn(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function By(){return Math.random().toString(36).substring(2,10)}function sf(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Sc(e,r,a=null,i,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?ws(r):r,state:a,key:r&&r.key||i||By(),mask:l}}function zr({pathname:e="/",search:r="",hash:a=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function ws(e){let r={};if(e){let a=e.indexOf("#");a>=0&&(r.hash=e.substring(a),e=e.substring(0,a));let i=e.indexOf("?");i>=0&&(r.search=e.substring(i),e=e.substring(0,i)),e&&(r.pathname=e)}return r}function Uy(e,r,a,i={}){let{window:l=document.defaultView,v5Compat:u=!1}=i,d=l.history,p="POP",m=null,y=v();y==null&&(y=0,d.replaceState({...d.state,idx:y},""));function v(){return(d.state||{idx:null}).idx}function j(){p="POP";let k=v(),C=k==null?null:k-y;y=k,m&&m({action:p,location:w.location,delta:C})}function x(k,C){p="PUSH";let E=rf(k)?k:Sc(w.location,k,C);y=v()+1;let $=sf(E,y),T=w.createHref(E.mask||E);try{d.pushState($,"",T)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;l.location.assign(T)}u&&m&&m({action:p,location:w.location,delta:1})}function S(k,C){p="REPLACE";let E=rf(k)?k:Sc(w.location,k,C);y=v();let $=sf(E,y),T=w.createHref(E.mask||E);d.replaceState($,"",T),u&&m&&m({action:p,location:w.location,delta:0})}function N(k){return Wy(l,k)}let w={get action(){return p},get location(){return e(l,d)},listen(k){if(m)throw new Error("A history only accepts one active listener");return l.addEventListener(nf,j),m=k,()=>{l.removeEventListener(nf,j),m=null}},createHref(k){return r(l,k)},createURL:N,encodeLocation(k){let C=N(k);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:x,replace:S,go(k){return d.go(k)}};return w}function Wy(e,r,a=!1){let i="http://localhost";e&&(i=e.location.origin!=="null"?e.location.origin:e.location.href),xt(i,"No window.location.(origin|href) available to create URL");let l=typeof r=="string"?r:zr(r);return l=l.replace(/ $/,"%20"),!a&&bm.test(l)&&(l=i+l),new URL(l,i)}function km(e,r,a="/"){return Hy(e,r,a,!1)}function Hy(e,r,a,i,l){let u=typeof r=="string"?ws(r):r,d=Yn(u.pathname||"/",a);if(d==null)return null;let p=Vy(e),m=null,y=nx(d);for(let v=0;m==null&&v<p.length;++v)m=tx(p[v],y,i);return m}function Vy(e){let r=Sm(e);return qy(r),r}function Sm(e,r=[],a=[],i="",l=!1){let u=(d,p,m=l,y)=>{let v={relativePath:y===void 0?d.path||"":y,caseSensitive:d.caseSensitive===!0,childrenIndex:p,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(i)&&m)return;xt(v.relativePath.startsWith(i),`Absolute route path "${v.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(i.length)}let j=Cn([i,v.relativePath]),x=a.concat(v);d.children&&d.children.length>0&&(xt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${j}".`),Sm(d.children,r,x,j,m)),!(d.path==null&&!d.index)&&r.push({path:j,score:Zy(j,d.index),routesMeta:x.map((S,N)=>{let[w,k]=Em(S.relativePath,S.caseSensitive,N===x.length-1);return{...S,matcher:w,compiledParams:k}})})};return e.forEach((d,p)=>{var m;if(d.path===""||!((m=d.path)!=null&&m.includes("?")))u(d,p);else for(let y of Nm(d.path))u(d,p,!0,y)}),r}function Nm(e){let r=e.split("/");if(r.length===0)return[];let[a,...i]=r,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(i.length===0)return l?[u,""]:[u];let d=Nm(i.join("/")),p=[];return p.push(...d.map(m=>m===""?u:[u,m].join("/"))),l&&p.push(...d),p.map(m=>e.startsWith("/")&&m===""?"/":m)}function qy(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:ex(r.routesMeta.map(i=>i.childrenIndex),a.routesMeta.map(i=>i.childrenIndex)))}var Ky=/^:[\w-]+$/,Gy=3,Yy=2,Jy=1,Qy=10,Xy=-2,af=e=>e==="*";function Zy(e,r){let a=e.split("/"),i=a.length;return a.some(af)&&(i+=Xy),r&&(i+=Yy),a.filter(l=>!af(l)).reduce((l,u)=>l+(Ky.test(u)?Gy:u===""?Jy:Qy),i)}function ex(e,r){return e.length===r.length&&e.slice(0,-1).every((i,l)=>i===r[l])?e[e.length-1]-r[r.length-1]:0}function tx(e,r,a=!1){let{routesMeta:i}=e,l={},u="/",d=[];for(let p=0;p<i.length;++p){let m=i[p],y=p===i.length-1,v=u==="/"?r:r.slice(u.length)||"/",j={path:m.relativePath,caseSensitive:m.caseSensitive,end:y},x=m.matcher&&m.compiledParams?Cm(j,v,m.matcher,m.compiledParams):Hi(j,v),S=m.route;if(!x&&y&&a&&!i[i.length-1].route.index&&(x=Hi({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},v)),!x)return null;Object.assign(l,x.params),d.push({params:l,pathname:Cn([u,x.pathname]),pathnameBase:ax(Cn([u,x.pathnameBase])),route:S}),x.pathnameBase!=="/"&&(u=Cn([u,x.pathnameBase]))}return d}function Hi(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,i]=Em(e.path,e.caseSensitive,e.end);return Cm(e,r,a,i)}function Cm(e,r,a,i){let l=r.match(a);if(!l)return null;let u=l[0],d=gs(u,1),p=l.slice(1);return{params:i.reduce((y,{paramName:v,isOptional:j},x)=>{if(v==="*"){let N=p[x]||"";d=gs(u.slice(0,u.length-N.length),1)}const S=p[x];return j&&!S?y[v]=void 0:y[v]=(S||"").replace(/%2F/g,"/"),y},{}),pathname:u,pathnameBase:d,pattern:e}}function Em(e,r=!1,a=!0){vn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let i=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,p,m,y,v)=>{if(i.push({paramName:p,isOptional:m!=null}),m){let j=v.charAt(y+d.length);return j&&j!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(i.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,r?void 0:"i"),i]}function nx(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return vn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function Yn(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let a=r.endsWith("/")?r.length-1:r.length,i=e.charAt(a);return i&&i!=="/"?null:e.slice(a)||"/"}function rx(e,r="/"){let{pathname:a,search:i="",hash:l=""}=typeof e=="string"?ws(e):e,u;return a?(a=Am(a),a.startsWith("/")||a.startsWith("\\")?u=of(a.substring(1),"/"):u=of(a,r)):u=r,{pathname:u,search:ix(i),hash:ox(l)}}function of(e,r){let a=gs(r).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function oc(e,r,a,i){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function sx(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function qc(e){let r=sx(e);return r.map((a,i)=>i===r.length-1?a.pathname:a.pathnameBase)}function uo(e,r,a,i=!1){let l;typeof e=="string"?l=ws(e):(l={...e},xt(!l.pathname||!l.pathname.includes("?"),oc("?","pathname","search",l)),xt(!l.pathname||!l.pathname.includes("#"),oc("#","pathname","hash",l)),xt(!l.search||!l.search.includes("#"),oc("#","search","hash",l)));let u=e===""||l.pathname==="",d=u?"/":l.pathname,p;if(d==null)p=a;else{let j=r.length-1;if(!i&&d.startsWith("..")){let x=d.split("/");for(;x[0]==="..";)x.shift(),j-=1;l.pathname=x.join("/")}p=j>=0?r[j]:"/"}let m=rx(l,p),y=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&a.endsWith("/");return!m.pathname.endsWith("/")&&(y||v)&&(m.pathname+="/"),m}var Am=e=>e.replace(/[\\/]{2,}/g,"/"),Cn=e=>Am(e.join("/"));function gs(e,r=0){let a=e.length;for(;a>r&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var ax=e=>gs(e).replace(/^\/*/,"/"),ix=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ox=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,lx=class{constructor(e,r,a,i=!1){this.status=e,this.statusText=r||"",this.internal=i,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function cx(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ux(e){let r=e.map(a=>a.route.path).filter(Boolean);return Cn(r)||"/"}var Tm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Im(e,r){let a=e;if(typeof a!="string"||!Vc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let i=a,l=!1;if(Tm)try{let u=new URL(window.location.href),d=bm.test(a)?new URL(zy(a,u.protocol)):new URL(a),p=Yn(d.pathname,r);d.origin===u.origin&&p!=null?a=p+d.search+d.hash:l=!0}catch{vn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var lf=new URL("http://localhost");function Kc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),lf)}catch{return lf}}function lc(e,r){return e.origin===r.origin&&(e.origin!=="null"||e.protocol===r.protocol&&e.host===r.host)}function dx(e,r){if(e.startsWith("//"))return!0;let a=r.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?r.host===""||e.slice(a.length).startsWith("//"):!1}function Gc(e,r,a,i){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(r,a),d=l!=null&&!lc(l,a),p=!lc(u,a);if(i==="reject"){if(d||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!dx(e,l)||!lc(l,u)))throw new Error("External navigation is not allowed")}var Rm=["POST","PUT","PATCH","DELETE"];new Set(Rm);var hx=["GET",...Rm];new Set(hx);var fx=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function mx(e){try{return fx.includes(new URL(e).protocol)}catch{return!1}}var bs=f.createContext(null);bs.displayName="DataRouter";var ho=f.createContext(null);ho.displayName="DataRouterState";var $m=f.createContext(!1);function px(){return f.useContext($m)}var Pm=f.createContext({isTransitioning:!1});Pm.displayName="ViewTransition";var gx=f.createContext(new Map);gx.displayName="Fetchers";var vx=f.createContext(null);vx.displayName="Await";var un=f.createContext(null);un.displayName="Navigation";var pa=f.createContext(null);pa.displayName="Location";var An=f.createContext({outlet:null,matches:[],isDataRoute:!1});An.displayName="Route";var Yc=f.createContext(null);Yc.displayName="RouteError";var _m="REACT_ROUTER_ERROR",yx="REDIRECT",xx="ROUTE_ERROR_RESPONSE";function jx(e){if(e.startsWith(`${_m}:${yx}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function wx(e){if(e.startsWith(`${_m}:${xx}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new lx(r.status,r.statusText,r.data)}catch{}}function bx(e,{relative:r}={}){xt(ks(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:i}=f.useContext(un),{hash:l,pathname:u,search:d}=ga(e,{relative:r}),p=u;return a!=="/"&&(p=u==="/"?a:Cn([a,u])),i.createHref({pathname:p,search:d,hash:l})}function ks(){return f.useContext(pa)!=null}function nn(){return xt(ks(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(pa).location}var Lm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Mm(e){f.useContext(un).static||f.useLayoutEffect(e)}function yn(){let{isDataRoute:e}=f.useContext(An);return e?Fx():kx()}function kx(){xt(ks(),"useNavigate() may be used only in the context of a <Router> component.");let e=f.useContext(bs),{basename:r,navigator:a}=f.useContext(un),{matches:i}=f.useContext(An),{pathname:l}=nn(),u=JSON.stringify(qc(i)),d=f.useRef(!1);return Mm(()=>{d.current=!0}),f.useCallback((m,y={})=>{if(vn(d.current,Lm),!d.current)return;if(typeof m=="number"){a.go(m);return}let v=uo(m,JSON.parse(u),l,y.relative==="path");e==null&&r!=="/"&&(v.pathname=v.pathname==="/"?r:Cn([r,v.pathname])),Gc(typeof m=="string"?m:zr(m),a.createHref(v),Kc(a),"reject"),(y.replace?a.replace:a.push)(v,y.state,y)},[r,a,u,l,e])}var Sx=f.createContext(null);function Nx(e){let r=f.useContext(An).outlet;return f.useMemo(()=>r&&f.createElement(Sx.Provider,{value:e},r),[r,e])}function ga(e,{relative:r}={}){let{matches:a}=f.useContext(An),{pathname:i}=nn(),l=JSON.stringify(qc(a));return f.useMemo(()=>uo(e,JSON.parse(l),i,r==="path"),[e,l,i,r])}function Cx(e,r){return Fm(e,r)}function Fm(e,r,a){var k;xt(ks(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=f.useContext(un),{matches:l}=f.useContext(An),u=l[l.length-1],d=u?u.params:{},p=u?u.pathname:"/",m=u?u.pathnameBase:"/",y=u&&u.route;{let C=y&&y.path||"";zm(p,!y||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
49
+ */var Vc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,wm=/^[\\/]{2}/;function By(e,r){return r+e.replace(/\\/g,"/")}var tf="popstate";function nf(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Uy(e={}){function r(i,l){var y;let u=(y=l.state)==null?void 0:y.masked,{pathname:d,search:p,hash:m}=u||i.location;return Nc("",{pathname:d,search:p,hash:m},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function a(i,l){return typeof l=="string"?l:zr(l)}return Hy(r,a,null,e)}function xt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function vn(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Wy(){return Math.random().toString(36).substring(2,10)}function rf(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Nc(e,r,a=null,i,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?ws(r):r,state:a,key:r&&r.key||i||Wy(),mask:l}}function zr({pathname:e="/",search:r="",hash:a=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function ws(e){let r={};if(e){let a=e.indexOf("#");a>=0&&(r.hash=e.substring(a),e=e.substring(0,a));let i=e.indexOf("?");i>=0&&(r.search=e.substring(i),e=e.substring(0,i)),e&&(r.pathname=e)}return r}function Hy(e,r,a,i={}){let{window:l=document.defaultView,v5Compat:u=!1}=i,d=l.history,p="POP",m=null,y=v();y==null&&(y=0,d.replaceState({...d.state,idx:y},""));function v(){return(d.state||{idx:null}).idx}function j(){p="POP";let k=v(),C=k==null?null:k-y;y=k,m&&m({action:p,location:w.location,delta:C})}function x(k,C){p="PUSH";let E=nf(k)?k:Nc(w.location,k,C);y=v()+1;let $=rf(E,y),T=w.createHref(E.mask||E);try{d.pushState($,"",T)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;l.location.assign(T)}u&&m&&m({action:p,location:w.location,delta:1})}function S(k,C){p="REPLACE";let E=nf(k)?k:Nc(w.location,k,C);y=v();let $=rf(E,y),T=w.createHref(E.mask||E);d.replaceState($,"",T),u&&m&&m({action:p,location:w.location,delta:0})}function N(k){return Vy(l,k)}let w={get action(){return p},get location(){return e(l,d)},listen(k){if(m)throw new Error("A history only accepts one active listener");return l.addEventListener(tf,j),m=k,()=>{l.removeEventListener(tf,j),m=null}},createHref(k){return r(l,k)},createURL:N,encodeLocation(k){let C=N(k);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:x,replace:S,go(k){return d.go(k)}};return w}function Vy(e,r,a=!1){let i="http://localhost";e&&(i=e.location.origin!=="null"?e.location.origin:e.location.href),xt(i,"No window.location.(origin|href) available to create URL");let l=typeof r=="string"?r:zr(r);return l=l.replace(/ $/,"%20"),!a&&wm.test(l)&&(l=i+l),new URL(l,i)}function bm(e,r,a="/"){return qy(e,r,a,!1)}function qy(e,r,a,i,l){let u=typeof r=="string"?ws(r):r,d=Yn(u.pathname||"/",a);if(d==null)return null;let p=Ky(e),m=null,y=sx(d);for(let v=0;m==null&&v<p.length;++v)m=rx(p[v],y,i);return m}function Ky(e){let r=km(e);return Gy(r),r}function km(e,r=[],a=[],i="",l=!1){let u=(d,p,m=l,y)=>{let v={relativePath:y===void 0?d.path||"":y,caseSensitive:d.caseSensitive===!0,childrenIndex:p,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(i)&&m)return;xt(v.relativePath.startsWith(i),`Absolute route path "${v.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(i.length)}let j=Cn([i,v.relativePath]),x=a.concat(v);d.children&&d.children.length>0&&(xt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${j}".`),km(d.children,r,x,j,m)),!(d.path==null&&!d.index)&&r.push({path:j,score:tx(j,d.index),routesMeta:x.map((S,N)=>{let[w,k]=Cm(S.relativePath,S.caseSensitive,N===x.length-1);return{...S,matcher:w,compiledParams:k}})})};return e.forEach((d,p)=>{var m;if(d.path===""||!((m=d.path)!=null&&m.includes("?")))u(d,p);else for(let y of Sm(d.path))u(d,p,!0,y)}),r}function Sm(e){let r=e.split("/");if(r.length===0)return[];let[a,...i]=r,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(i.length===0)return l?[u,""]:[u];let d=Sm(i.join("/")),p=[];return p.push(...d.map(m=>m===""?u:[u,m].join("/"))),l&&p.push(...d),p.map(m=>e.startsWith("/")&&m===""?"/":m)}function Gy(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:nx(r.routesMeta.map(i=>i.childrenIndex),a.routesMeta.map(i=>i.childrenIndex)))}var Yy=/^:[\w-]+$/,Jy=3,Qy=2,Xy=1,Zy=10,ex=-2,sf=e=>e==="*";function tx(e,r){let a=e.split("/"),i=a.length;return a.some(sf)&&(i+=ex),r&&(i+=Qy),a.filter(l=>!sf(l)).reduce((l,u)=>l+(Yy.test(u)?Jy:u===""?Xy:Zy),i)}function nx(e,r){return e.length===r.length&&e.slice(0,-1).every((i,l)=>i===r[l])?e[e.length-1]-r[r.length-1]:0}function rx(e,r,a=!1){let{routesMeta:i}=e,l={},u="/",d=[];for(let p=0;p<i.length;++p){let m=i[p],y=p===i.length-1,v=u==="/"?r:r.slice(u.length)||"/",j={path:m.relativePath,caseSensitive:m.caseSensitive,end:y},x=m.matcher&&m.compiledParams?Nm(j,v,m.matcher,m.compiledParams):Hi(j,v),S=m.route;if(!x&&y&&a&&!i[i.length-1].route.index&&(x=Hi({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},v)),!x)return null;Object.assign(l,x.params),d.push({params:l,pathname:Cn([u,x.pathname]),pathnameBase:ox(Cn([u,x.pathnameBase])),route:S}),x.pathnameBase!=="/"&&(u=Cn([u,x.pathnameBase]))}return d}function Hi(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,i]=Cm(e.path,e.caseSensitive,e.end);return Nm(e,r,a,i)}function Nm(e,r,a,i){let l=r.match(a);if(!l)return null;let u=l[0],d=gs(u,1),p=l.slice(1);return{params:i.reduce((y,{paramName:v,isOptional:j},x)=>{if(v==="*"){let N=p[x]||"";d=gs(u.slice(0,u.length-N.length),1)}const S=p[x];return j&&!S?y[v]=void 0:y[v]=(S||"").replace(/%2F/g,"/"),y},{}),pathname:u,pathnameBase:d,pattern:e}}function Cm(e,r=!1,a=!0){vn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let i=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,p,m,y,v)=>{if(i.push({paramName:p,isOptional:m!=null}),m){let j=v.charAt(y+d.length);return j&&j!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(i.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,r?void 0:"i"),i]}function sx(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return vn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function Yn(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let a=r.endsWith("/")?r.length-1:r.length,i=e.charAt(a);return i&&i!=="/"?null:e.slice(a)||"/"}function ax(e,r="/"){let{pathname:a,search:i="",hash:l=""}=typeof e=="string"?ws(e):e,u;return a?(a=Em(a),a.startsWith("/")||a.startsWith("\\")?u=af(a.substring(1),"/"):u=af(a,r)):u=r,{pathname:u,search:lx(i),hash:cx(l)}}function af(e,r){let a=gs(r).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function lc(e,r,a,i){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ix(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function qc(e){let r=ix(e);return r.map((a,i)=>i===r.length-1?a.pathname:a.pathnameBase)}function uo(e,r,a,i=!1){let l;typeof e=="string"?l=ws(e):(l={...e},xt(!l.pathname||!l.pathname.includes("?"),lc("?","pathname","search",l)),xt(!l.pathname||!l.pathname.includes("#"),lc("#","pathname","hash",l)),xt(!l.search||!l.search.includes("#"),lc("#","search","hash",l)));let u=e===""||l.pathname==="",d=u?"/":l.pathname,p;if(d==null)p=a;else{let j=r.length-1;if(!i&&d.startsWith("..")){let x=d.split("/");for(;x[0]==="..";)x.shift(),j-=1;l.pathname=x.join("/")}p=j>=0?r[j]:"/"}let m=ax(l,p),y=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&a.endsWith("/");return!m.pathname.endsWith("/")&&(y||v)&&(m.pathname+="/"),m}var Em=e=>e.replace(/[\\/]{2,}/g,"/"),Cn=e=>Em(e.join("/"));function gs(e,r=0){let a=e.length;for(;a>r&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var ox=e=>gs(e).replace(/^\/*/,"/"),lx=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,cx=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ux=class{constructor(e,r,a,i=!1){this.status=e,this.statusText=r||"",this.internal=i,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function dx(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function hx(e){let r=e.map(a=>a.route.path).filter(Boolean);return Cn(r)||"/"}var Am=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Tm(e,r){let a=e;if(typeof a!="string"||!Vc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let i=a,l=!1;if(Am)try{let u=new URL(window.location.href),d=wm.test(a)?new URL(By(a,u.protocol)):new URL(a),p=Yn(d.pathname,r);d.origin===u.origin&&p!=null?a=p+d.search+d.hash:l=!0}catch{vn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var of=new URL("http://localhost");function Kc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),of)}catch{return of}}function cc(e,r){return e.origin===r.origin&&(e.origin!=="null"||e.protocol===r.protocol&&e.host===r.host)}function fx(e,r){if(e.startsWith("//"))return!0;let a=r.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?r.host===""||e.slice(a.length).startsWith("//"):!1}function Gc(e,r,a,i){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(r,a),d=l!=null&&!cc(l,a),p=!cc(u,a);if(i==="reject"){if(d||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!fx(e,l)||!cc(l,u)))throw new Error("External navigation is not allowed")}var Im=["POST","PUT","PATCH","DELETE"];new Set(Im);var mx=["GET",...Im];new Set(mx);var px=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function gx(e){try{return px.includes(new URL(e).protocol)}catch{return!1}}var bs=f.createContext(null);bs.displayName="DataRouter";var ho=f.createContext(null);ho.displayName="DataRouterState";var Rm=f.createContext(!1);function vx(){return f.useContext(Rm)}var $m=f.createContext({isTransitioning:!1});$m.displayName="ViewTransition";var yx=f.createContext(new Map);yx.displayName="Fetchers";var xx=f.createContext(null);xx.displayName="Await";var un=f.createContext(null);un.displayName="Navigation";var pa=f.createContext(null);pa.displayName="Location";var An=f.createContext({outlet:null,matches:[],isDataRoute:!1});An.displayName="Route";var Yc=f.createContext(null);Yc.displayName="RouteError";var Pm="REACT_ROUTER_ERROR",jx="REDIRECT",wx="ROUTE_ERROR_RESPONSE";function bx(e){if(e.startsWith(`${Pm}:${jx}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function kx(e){if(e.startsWith(`${Pm}:${wx}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new ux(r.status,r.statusText,r.data)}catch{}}function Sx(e,{relative:r}={}){xt(ks(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:i}=f.useContext(un),{hash:l,pathname:u,search:d}=ga(e,{relative:r}),p=u;return a!=="/"&&(p=u==="/"?a:Cn([a,u])),i.createHref({pathname:p,search:d,hash:l})}function ks(){return f.useContext(pa)!=null}function nn(){return xt(ks(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(pa).location}var _m="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lm(e){f.useContext(un).static||f.useLayoutEffect(e)}function yn(){let{isDataRoute:e}=f.useContext(An);return e?zx():Nx()}function Nx(){xt(ks(),"useNavigate() may be used only in the context of a <Router> component.");let e=f.useContext(bs),{basename:r,navigator:a}=f.useContext(un),{matches:i}=f.useContext(An),{pathname:l}=nn(),u=JSON.stringify(qc(i)),d=f.useRef(!1);return Lm(()=>{d.current=!0}),f.useCallback((m,y={})=>{if(vn(d.current,_m),!d.current)return;if(typeof m=="number"){a.go(m);return}let v=uo(m,JSON.parse(u),l,y.relative==="path");e==null&&r!=="/"&&(v.pathname=v.pathname==="/"?r:Cn([r,v.pathname])),Gc(typeof m=="string"?m:zr(m),a.createHref(v),Kc(a),"reject"),(y.replace?a.replace:a.push)(v,y.state,y)},[r,a,u,l,e])}var Cx=f.createContext(null);function Ex(e){let r=f.useContext(An).outlet;return f.useMemo(()=>r&&f.createElement(Cx.Provider,{value:e},r),[r,e])}function ga(e,{relative:r}={}){let{matches:a}=f.useContext(An),{pathname:i}=nn(),l=JSON.stringify(qc(a));return f.useMemo(()=>uo(e,JSON.parse(l),i,r==="path"),[e,l,i,r])}function Ax(e,r){return Mm(e,r)}function Mm(e,r,a){var k;xt(ks(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=f.useContext(un),{matches:l}=f.useContext(An),u=l[l.length-1],d=u?u.params:{},p=u?u.pathname:"/",m=u?u.pathnameBase:"/",y=u&&u.route;{let C=y&&y.path||"";Om(p,!y||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
50
 
51
- Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let v=nn(),j;if(r){let C=typeof r=="string"?ws(r):r;xt(m==="/"||((k=C.pathname)==null?void 0:k.startsWith(m)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${C.pathname}" was given in the \`location\` prop.`),j=C}else j=v;let x=j.pathname||"/",S=x;if(m!=="/"){let C=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let N=a&&a.state.matches.length?a.state.matches.map(C=>Object.assign(C,{route:a.manifest[C.route.id]||C.route})):km(e,{pathname:S});vn(y||N!=null,`No routes matched location "${j.pathname}${j.search}${j.hash}" `),vn(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${j.pathname}${j.search}${j.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=Rx(N&&N.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:Cn([m,i.encodeLocation?i.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?m:Cn([m,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),l,a);return r&&w?f.createElement(pa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...j},navigationType:"POP"}},w):w}function Ex(){let e=Mx(),r=cx(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,i="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",e),d=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:u},"ErrorBoundary")," or"," ",f.createElement("code",{style:u},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},r),a?f.createElement("pre",{style:l},a):null,d)}var Ax=f.createElement(Ex,null),Om=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=wx(e.digest);a&&(e=a)}let r=e!==void 0?f.createElement(An.Provider,{value:this.props.routeContext},f.createElement(Yc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?f.createElement(Tx,{error:e},r):r}};Om.contextType=$m;var cc=new WeakMap;function Tx({children:e,error:r}){let{basename:a,navigator:i}=f.useContext(un);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let l=jx(r.digest);if(l){let u=cc.get(r);if(u)throw u;let d=Im(l.location,a),p=d.absoluteURL||d.to;if(Gc(l.location,p,Kc(i),"allow-explicit"),mx(p))throw new Error("Invalid redirect location");if(Tm&&!cc.get(r))if(d.isExternal||l.reloadDocument)window.location.href=p;else{const m=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:l.replace}));throw cc.set(r,m),m}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function Ix({routeContext:e,match:r,children:a}){let i=f.useContext(bs);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),f.createElement(An.Provider,{value:e},a)}function Rx(e,r=[],a){let i=a==null?void 0:a.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(r.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let l=e,u=i==null?void 0:i.errors;if(u!=null){let v=l.findIndex(j=>j.route.id&&(u==null?void 0:u[j.route.id])!==void 0);xt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,v+1))}let d=!1,p=-1;if(a&&i){d=i.renderFallback;for(let v=0;v<l.length;v++){let j=l[v];if((j.route.HydrateFallback||j.route.hydrateFallbackElement)&&(p=v),j.route.id){let{loaderData:x,errors:S}=i,N=j.route.loader&&!x.hasOwnProperty(j.route.id)&&(!S||S[j.route.id]===void 0);if(j.route.lazy||N){a.isStatic&&(d=!0),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let m=a==null?void 0:a.onError,y=i&&m?(v,j)=>{var x,S;m(v,{location:i.location,params:((S=(x=i.matches)==null?void 0:x[0])==null?void 0:S.params)??{},pattern:ux(i.matches),errorInfo:j})}:void 0;return l.reduceRight((v,j,x)=>{let S,N=!1,w=null,k=null;i&&(S=u&&j.route.id?u[j.route.id]:void 0,w=j.route.errorElement||Ax,d&&(p<0&&x===0?(zm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,k=null):p===x&&(N=!0,k=j.route.hydrateFallbackElement||null)));let C=r.concat(l.slice(0,x+1)),E=()=>{let $;return S?$=w:N?$=k:j.route.Component?$=f.createElement(j.route.Component,null):j.route.element?$=j.route.element:$=v,f.createElement(Ix,{match:j,routeContext:{outlet:v,matches:C,isDataRoute:i!=null},children:$})};return i&&(j.route.ErrorBoundary||j.route.errorElement||x===0)?f.createElement(Om,{location:i.location,revalidation:i.revalidation,component:w,error:S,children:E(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:y}):E()},null)}function Jc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $x(e){let r=f.useContext(bs);return xt(r,Jc(e)),r}function Px(e){let r=f.useContext(ho);return xt(r,Jc(e)),r}function _x(e){let r=f.useContext(An);return xt(r,Jc(e)),r}function Qc(e){let r=_x(e),a=r.matches[r.matches.length-1];return xt(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Lx(){return Qc("useRouteId")}function Mx(){var i;let e=f.useContext(Yc),r=Px("useRouteError"),a=Qc("useRouteError");return e!==void 0?e:(i=r.errors)==null?void 0:i[a]}function Fx(){let{router:e}=$x("useNavigate"),r=Qc("useNavigate"),a=f.useRef(!1);return Mm(()=>{a.current=!0}),f.useCallback(async(l,u={})=>{vn(a.current,Lm),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:r,...u}))},[e,r])}var cf={};function zm(e,r,a){!r&&!cf[e]&&(cf[e]=!0,vn(!1,a))}f.memo(Ox);function Ox({routes:e,manifest:r,future:a,state:i,isStatic:l,onError:u}){return Fm(e,void 0,{manifest:r,state:i,isStatic:l,onError:u})}function Gn({to:e,replace:r,state:a,relative:i}){xt(ks(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=f.useContext(un);vn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=f.useContext(An),{pathname:p}=nn(),m=yn(),y=uo(e,qc(d),p,i==="path");Gc(typeof e=="string"?e:zr(e),u.createHref(y),Kc(u),"reject");let v=JSON.stringify(y);return f.useEffect(()=>{m(JSON.parse(v),{replace:r,state:a,relative:i})},[m,v,i,r,a]),null}function zx(e){return Nx(e.context)}function mt(e){xt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Dx({basename:e="/",children:r=null,location:a,navigationType:i="POP",navigator:l,static:u=!1,useTransitions:d}){xt(!ks(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=e.replace(/^\/*/,"/"),m=f.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:d,future:{}}),[p,l,u,d]);typeof a=="string"&&(a=ws(a));let{pathname:y="/",search:v="",hash:j="",state:x=null,key:S="default",mask:N}=a,w=f.useMemo(()=>{let k=Yn(y,p);return k==null?null:{location:{pathname:k,search:v,hash:j,state:x,key:S,mask:N},navigationType:i}},[p,y,v,j,x,S,i,N]);return vn(w!=null,`<Router basename="${p}"> is not able to match the URL "${y}${v}${j}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:f.createElement(un.Provider,{value:m},f.createElement(pa.Provider,{children:r,value:w}))}function Bx({children:e,location:r}){return Cx(Nc(e),r)}function Nc(e,r=[]){let a=[];return f.Children.forEach(e,(i,l)=>{if(!f.isValidElement(i))return;let u=[...r,l];if(i.type===f.Fragment){a.push.apply(a,Nc(i.props.children,u));return}xt(i.type===mt,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xt(!i.props.index||!i.props.children,"An index route cannot have child routes.");let d={id:i.props.id||u.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(d.children=Nc(i.props.children,u)),a.push(d)}),a}var Oi="get",zi="application/x-www-form-urlencoded";function fo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Ux(e){return fo(e)&&e.tagName.toLowerCase()==="button"}function Wx(e){return fo(e)&&e.tagName.toLowerCase()==="form"}function Hx(e){return fo(e)&&e.tagName.toLowerCase()==="input"}function Vx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function qx(e,r){return e.button===0&&(!r||r==="_self")&&!Vx(e)}function Cc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,a)=>{let i=e[a];return r.concat(Array.isArray(i)?i.map(l=>[a,l]):[[a,i]])},[]))}function Kx(e,r){let a=Cc(e);return r&&r.forEach((i,l)=>{a.has(l)||r.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ti=null;function Gx(){if(Ti===null)try{new FormData(document.createElement("form"),0),Ti=!1}catch{Ti=!0}return Ti}var Yx=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function uc(e){return e!=null&&!Yx.has(e)?(vn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${zi}"`),null):e}function Jx(e,r){let a,i,l,u,d;if(Wx(e)){let p=e.getAttribute("action");i=p?Yn(p,r):null,a=e.getAttribute("method")||Oi,l=uc(e.getAttribute("enctype"))||zi,u=new FormData(e)}else if(Ux(e)||Hx(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=e.getAttribute("formaction")||p.getAttribute("action");if(i=m?Yn(m,r):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||Oi,l=uc(e.getAttribute("formenctype"))||uc(p.getAttribute("enctype"))||zi,u=new FormData(p,e),!Gx()){let{name:y,type:v,value:j}=e;if(v==="image"){let x=y?`${y}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else y&&u.append(y,j)}}else{if(fo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Oi,i=null,l=zi,d=e}return u&&l==="text/plain"&&(d=u,u=void 0),{action:i,method:a.toLowerCase(),encType:l,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xc(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Dm(e,r,a,i){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${i}`:l.pathname=`${l.pathname}.${i}`:l.pathname==="/"?l.pathname=`_root.${i}`:r&&Yn(l.pathname,r)==="/"?l.pathname=`${gs(r)}/_root.${i}`:l.pathname=`${gs(l.pathname)}.${i}`,l}async function Qx(e,r){if(e.id in r)return r[e.id];try{let a=await import(e.module);return r[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Xx(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Zx(e,r,a){let i=await Promise.all(e.map(async l=>{let u=r.routes[l.route.id];if(u){let d=await Qx(u,a);return d.links?d.links():[]}return[]}));return rj(i.flat(1).filter(Xx).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function uf(e,r,a,i,l,u){let d=(m,y)=>a[y]?m.route.id!==a[y].route.id:!0,p=(m,y)=>{var v;return a[y].pathname!==m.pathname||((v=a[y].route.path)==null?void 0:v.endsWith("*"))&&a[y].params["*"]!==m.params["*"]};return u==="assets"?r.filter((m,y)=>d(m,y)||p(m,y)):u==="data"?r.filter((m,y)=>{var j;let v=i.routes[m.route.id];if(!v||!v.hasLoader)return!1;if(d(m,y)||p(m,y))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((j=a[0])==null?void 0:j.params)||{},nextUrl:new URL(e,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function ej(e,r,{includeHydrateFallback:a}={}){return tj(e.map(i=>{let l=r.routes[i.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function tj(e){return[...new Set(e)]}function nj(e){let r={},a=Object.keys(e).sort();for(let i of a)r[i]=e[i];return r}function rj(e,r){let a=new Set;return new Set(r),e.reduce((i,l)=>{let u=JSON.stringify(nj(l));return a.has(u)||(a.add(u),i.push({key:u,link:l})),i},[])}function Zc(){let e=f.useContext(bs);return Xc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function sj(){let e=f.useContext(ho);return Xc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var eu=f.createContext(void 0);eu.displayName="FrameworkContext";function mo(){let e=f.useContext(eu);return Xc(e,"You must render this element inside a <HydratedRouter> element"),e}function aj(e,r){let a=f.useContext(eu),[i,l]=f.useState(!1),[u,d]=f.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:y,onMouseLeave:v,onTouchStart:j}=r,x=f.useRef(null);f.useEffect(()=>{if(e==="render"&&d(!0),e==="viewport"){let w=C=>{C.forEach(E=>{d(E.isIntersecting)})},k=new IntersectionObserver(w,{threshold:.5});return x.current&&k.observe(x.current),()=>{k.disconnect()}}},[e]),f.useEffect(()=>{if(i){let w=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(w)}}},[i]);let S=()=>{l(!0)},N=()=>{l(!1),d(!1)};return a?e!=="intent"?[u,x,{}]:[u,x,{onFocus:la(p,S),onBlur:la(m,N),onMouseEnter:la(y,S),onMouseLeave:la(v,N),onTouchStart:la(j,S)}]:[!1,x,{}]}function la(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function ij({page:e,...r}){let a=px(),{nonce:i}=mo(),{router:l}=Zc(),u=f.useMemo(()=>km(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(r.nonce==null&&i&&(r={...r,nonce:i}),a?f.createElement(lj,{page:e,matches:u,...r}):f.createElement(cj,{page:e,matches:u,...r})):null}function oj(e){let{manifest:r,routeModules:a}=mo(),[i,l]=f.useState([]);return f.useEffect(()=>{let u=!1;return Zx(e,r,a).then(d=>{u||l(d)}),()=>{u=!0}},[e,r,a]),i}function lj({page:e,matches:r,...a}){let i=nn(),{future:l}=mo(),{basename:u}=Zc(),d=f.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let p=Dm(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),m=!1,y=[];for(let v of r)typeof v.route.shouldRevalidate=="function"?m=!0:y.push(v.route.id);return m&&y.length>0&&p.searchParams.set("_routes",y.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,i,r]);return f.createElement(f.Fragment,null,d.map(p=>f.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function cj({page:e,matches:r,...a}){let i=nn(),{future:l,manifest:u,routeModules:d}=mo(),{basename:p}=Zc(),{loaderData:m,matches:y}=sj(),v=f.useMemo(()=>uf(e,r,y,u,i,"data"),[e,r,y,u,i]),j=f.useMemo(()=>uf(e,r,y,u,i,"assets"),[e,r,y,u,i]),x=f.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let w=new Set,k=!1;if(r.forEach(E=>{var T;let $=u.routes[E.route.id];!$||!$.hasLoader||(!v.some(F=>F.route.id===E.route.id)&&E.route.id in m&&((T=d[E.route.id])!=null&&T.shouldRevalidate)||$.hasClientLoader?k=!0:w.add(E.route.id))}),w.size===0)return[];let C=Dm(e,p,l.v8_trailingSlashAwareDataRequests,"data");return k&&w.size>0&&C.searchParams.set("_routes",r.filter(E=>w.has(E.route.id)).map(E=>E.route.id).join(",")),[C.pathname+C.search]},[p,l.v8_trailingSlashAwareDataRequests,m,i,u,v,r,e,d]),S=f.useMemo(()=>ej(j,u),[j,u]),N=oj(j);return f.createElement(f.Fragment,null,x.map(w=>f.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...a})),S.map(w=>f.createElement("link",{key:w,rel:"modulepreload",href:w,...a})),N.map(({key:w,link:k})=>f.createElement("link",{key:w,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function uj(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var dj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{dj&&(window.__reactRouterVersion="7.18.4")}catch{}function hj({basename:e,children:r,useTransitions:a,window:i}){let l=f.useRef();l.current==null&&(l.current=Dy({window:i,v5Compat:!0}));let u=l.current,[d,p]=f.useState({action:u.action,location:u.location}),m=f.useCallback(y=>{a===!1?p(y):f.startTransition(()=>p(y))},[a]);return f.useLayoutEffect(()=>u.listen(m),[u,m]),f.createElement(Dx,{basename:e,children:r,location:d.location,navigationType:d.action,navigator:u,useTransitions:a})}var pt=f.forwardRef(function({onClick:r,discover:a="render",prefetch:i="none",relative:l,reloadDocument:u,replace:d,mask:p,state:m,target:y,to:v,preventScrollReset:j,viewTransition:x,defaultShouldRevalidate:S,...N},w){let{basename:k,navigator:C,useTransitions:E}=f.useContext(un),$=typeof v=="string"&&Vc.test(v),T=Im(v,k);v=T.to;let F=bx(v,{relative:l}),M=nn(),B=null;if(p){let me=uo(p,[],M.mask?M.mask.pathname:"/",!0);k!=="/"&&(me.pathname=me.pathname==="/"?k:Cn([k,me.pathname])),B=C.createHref(me)}let[te,Q,_]=aj(i,N),z=pj(v,{replace:d,mask:p,state:m,target:y,preventScrollReset:j,relative:l,viewTransition:x,defaultShouldRevalidate:S,useTransitions:E});function V(me){r&&r(me),me.defaultPrevented||z(me)}let K=!(T.isExternal||u),le=f.createElement("a",{...N,..._,href:(K?B:void 0)||T.absoluteURL||F,onClick:K?V:r,ref:uj(w,Q),target:y,"data-discover":!$&&a==="render"?"true":void 0});return te&&!$?f.createElement(f.Fragment,null,le,f.createElement(ij,{page:F})):le});pt.displayName="Link";var tu=f.forwardRef(function({"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:u,to:d,viewTransition:p,children:m,...y},v){let j=ga(d,{relative:y.relative}),x=nn(),S=f.useContext(ho),{navigator:N,basename:w}=f.useContext(un),k=S!=null&&jj(j)&&p===!0,C=N.encodeLocation?N.encodeLocation(j).pathname:j.pathname,E=x.pathname,$=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;a||(E=E.toLowerCase(),$=$?$.toLowerCase():null,C=C.toLowerCase()),$&&w&&($=Yn($,w)||$);const T=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let F=E===C||!l&&E.startsWith(C)&&E.charAt(T)==="/",M=$!=null&&($===C||!l&&$.startsWith(C)&&$.charAt(C.length)==="/"),B={isActive:F,isPending:M,isTransitioning:k},te=F?r:void 0,Q;typeof i=="function"?Q=i(B):Q=[i,F?"active":null,M?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(B):u;return f.createElement(pt,{...y,"aria-current":te,className:Q,ref:v,style:_,to:d,viewTransition:p},typeof m=="function"?m(B):m)});tu.displayName="NavLink";var fj=f.forwardRef(({discover:e="render",fetcherKey:r,navigate:a,reloadDocument:i,replace:l,state:u,method:d=Oi,action:p,onSubmit:m,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:x,...S},N)=>{let{useTransitions:w}=f.useContext(un),k=yj(),C=xj(p,{relative:y}),E=d.toLowerCase()==="get"?"get":"post",$=typeof p=="string"&&Vc.test(p),T=F=>{if(m&&m(F),F.defaultPrevented)return;F.preventDefault();let M=F.nativeEvent.submitter,B=(M==null?void 0:M.getAttribute("formmethod"))||d,te=()=>k(M||F.currentTarget,{fetcherKey:r,method:B,navigate:a,replace:l,state:u,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:x});w&&a!==!1?f.startTransition(()=>te()):te()};return f.createElement("form",{ref:N,method:E,action:C,onSubmit:i?m:T,...S,"data-discover":!$&&e==="render"?"true":void 0})});fj.displayName="Form";function mj(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bm(e){let r=f.useContext(bs);return xt(r,mj(e)),r}function pj(e,{target:r,replace:a,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y}={}){let v=yn(),j=nn(),x=ga(e,{relative:d});return f.useCallback(S=>{if(qx(S,r)){S.preventDefault();let N=a!==void 0?a:zr(j)===zr(x),w=()=>v(e,{replace:N,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m});y?f.startTransition(()=>w()):w()}},[j,v,x,a,i,l,r,e,u,d,p,m,y])}function Ss(e){vn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let r=f.useRef(Cc(e)),a=f.useRef(!1),i=nn(),l=f.useMemo(()=>Kx(i.search,a.current?null:r.current),[i.search]),u=yn(),d=f.useCallback((p,m)=>{const y=Cc(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+y,m)},[u,l]);return[l,d]}var gj=0,vj=()=>`__${String(++gj)}__`;function yj(){let{router:e}=Bm("useSubmit"),{basename:r}=f.useContext(un),a=Lx(),i=e.fetch,l=e.navigate;return f.useCallback(async(u,d={})=>{let{action:p,method:m,encType:y,formData:v,body:j}=Jx(u,r);if(d.navigate===!1){let x=d.fetcherKey||vj();await i(x,a,d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:j,formMethod:d.method||m,formEncType:d.encType||y,flushSync:d.flushSync})}else await l(d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:j,formMethod:d.method||m,formEncType:d.encType||y,replace:d.replace,state:d.state,fromRouteId:a,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,l,r,a])}function xj(e,{relative:r}={}){let{basename:a}=f.useContext(un),i=f.useContext(An);xt(i,"useFormAction must be used inside a RouteContext");let[l]=i.matches.slice(-1),u={...ga(e||".",{relative:r})},d=nn();if(e==null){u.search=d.search;let p=new URLSearchParams(u.search),m=p.getAll("index");if(m.some(v=>v==="")){p.delete("index"),m.filter(j=>j).forEach(j=>p.append("index",j));let v=p.toString();u.search=v?`?${v}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:Cn([a,u.pathname])),zr(u)}function jj(e,{relative:r}={}){let a=f.useContext(Pm);xt(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Bm("useViewTransitionState"),l=ga(e,{relative:r});if(!a.isTransitioning)return!1;let u=Yn(a.currentLocation.pathname,i)||a.currentLocation.pathname,d=Yn(a.nextLocation.pathname,i)||a.nextLocation.pathname;return Hi(l.pathname,d)!=null||Hi(l.pathname,u)!=null}var wj=wm();const Fr="owner";function bj(e){const r=e||Fr;return r===Fr?[Fr]:[r,Fr]}function kj(e){const r=new Map;for(const a of e)for(const i of a)r.has(i.id)||r.set(i.id,i);return[...r.values()].sort((a,i)=>i.createdAt-a.createdAt)}function Sj(e,r){const a=r||Fr,i=(e==null?void 0:e.pendingDomains)??[];return i.includes(a)?a:i.includes(Fr)?Fr:a}function Nj(e){const r=Array.isArray(e)?e.map(i=>i==null?void 0:i.expiresAt).filter(i=>typeof i=="number"):[];if(r.length===0)return{earliest_expiry:null,remaining_seconds:null};const a=Math.min(...r);return{earliest_expiry:new Date(a*1e3).toISOString(),remaining_seconds:Math.max(0,a-Math.floor(Date.now()/1e3))}}class Um extends Error{constructor(a){super("different_account");ia(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Wm(e){return e.grantors??e.approvers}function Cj(e){return e.approvals??1}function Ze(e,r){const a=e??{},i=Array.isArray(a.errors)?a.errors[0]:void 0;return i!=null&&i.message?i.code?`${i.message} (${i.code})`:i.message:i!=null&&i.code?i.code:a.error||a.detail||r}function Ej(e){const r=e==null?void 0:e.pubkeys;return!r||typeof r!="object"||Array.isArray(r)?[]:Object.entries(r).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,i])=>({userId:a,publicKey:i}))}class Aj{constructor(){ia(this,"apiKey",null)}setApiKey(r){this.apiKey=r}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(r,a){return globalThis.fetch(r,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(r,a={}){const i=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":r,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(i.status===409){const u=await i.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Um(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!i.ok){const u=await i.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ze(u,`Login failed: ${i.status}`))}return(await i.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const r=await this.fetch("/api/groups");if(!r.ok)throw new Error(`Failed to fetch groups: ${r.status}`);const a=await r.json();return a.groups??a}async listProfiles(){const r=await this.fetch("/api/profiles");if(!r.ok)throw new Error(`Failed to fetch profiles: ${r.status}`);return(await r.json()).profiles}async getProfile(r){const a=await this.fetch(`/api/profiles/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(r){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Signing failed: ${a.status}`))}return a.json()}async getPending(r){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const i=await a.json();return i.pending??i}async getMyAttestations(r){const a=r?`?status=${encodeURIComponent(r)}`:"",i=await this.fetch(`/api/mandates/mine${a}`);if(!i.ok)throw new Error(`Failed to fetch attestations: ${i.status}`);return((await i.json()).mandates??[]).map(u=>({authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(d=>!(u.attestedDomains??[]).includes(d)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",...Nj(u.mandates??u.attestations)}))}async getDenials(r){const a=new URLSearchParams;r!=null&&r.since&&a.set("since",String(r.since)),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${i}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(r){const a=new URLSearchParams;r!=null&&r.date&&a.set("date",r.date),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const r=await this.fetch("/api/evidence-export"),a=await r.json();if(!r.ok)throw new Error(Ze(a,`Export failed (${r.status})`));const i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:i}}async getLocalAuthorizations(){const r=await this.fetch("/api/evidence/authorizations");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(r){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const r=await this.fetch("/api/evidence/headlines");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const r=await this.fetch("/api/report");if(!r.ok){const a=await r.json().catch(()=>({error:`Report unavailable (${r.status})`}));throw new Error(Ze(a,`Report unavailable (${r.status})`))}return r.json()}async saveReport(r){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:r})});if(!a.ok){const i=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(Ze(i,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const r=await this.fetch("/api/report/recheck",{method:"POST"});if(!r.ok){const a=await r.json().catch(()=>({error:`Recheck failed (${r.status})`}));throw new Error(Ze(a,`Recheck failed (${r.status})`))}return r.json()}async exportReportWithProof(){var l;const r=await this.fetch("/api/report/export");if(!r.ok){const u=await r.json().catch(()=>({error:`Export failed (${r.status})`}));throw new Error(Ze(u,`Export failed (${r.status})`))}const a=await r.text(),i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:i}}async revokeAttestation(r,a){const i=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to revoke"}));throw new Error(Ze(l,`Revoke failed: ${i.status}`))}}async getAttestations(r){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const i=await a.json();return{...i,attestations:i.mandates??i.attestations??[]}}async getGroupById(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(r){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:r})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(u,`Create group failed: ${a.status}`))}const i=await a.json(),l=i.group||i;return{id:l.id,name:l.name,myDomains:l.myDomains||[],isAdmin:!0,ended:i.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const r=await this.fetch("/api/groups/create/preview");if(!r.ok){const a=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(a,`Failed to preview team creation: ${r.status}`))}return r.json()}async getJoinPreview(r){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(r)}`);if(!a.ok){const i=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(Ze(i,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(r){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:r})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(l,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const r=await this.fetch("/api/groups/join",{method:"DELETE"});if(r.status===404)return!1;if(!r.ok){const i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Withdraw failed: ${r.status}`))}return(await r.json()).withdrawn===!0}async inviteToGroup(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/invite`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const r=await this.fetch("/api/groups/me");if(!r.ok)return{group:null,membership:null,pendingRequest:null};const a=await r.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const r=await this.fetch("/api/users");return r.ok?(await r.json()).users??[]:[]}async setPubkey(r){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(Ze(i,`setPubkey failed: ${a.status}`))}}async getPubkey(r){const a=await this.fetch(`/api/users/${encodeURIComponent(r)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/leave`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(Ze(i,`Leave failed: ${a.status}`))}}async getVaultStatus(){const r=await this.fetch("/vault/status");if(!r.ok)throw new Error(`Failed to fetch vault status: ${r.status}`);return r.json()}async getGatewaySettings(){const r=await this.fetch("/api/gateway-settings");if(!r.ok)throw new Error(`Failed to load settings: ${r.status}`);return r.json()}async setGatewaySettings(r){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const r=await this.fetch("/api/archived-mandates");if(!r.ok)throw new Error(`Failed to load archived mandates: ${r.status}`);return(await r.json()).archived}async setMandateArchived(r,a){const i=await this.fetch(`/api/archived-mandates/${encodeURIComponent(r)}`,{method:a?"PUT":"DELETE"});if(!i.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${i.status}`);return(await i.json()).archived}async getLastSeenBlockedAt(){const r=await this.fetch("/api/blocked-seen");if(!r.ok)throw new Error(`Failed to load last-seen: ${r.status}`);return(await r.json()).lastSeenBlockedAt}async markBlockedSeen(r=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const r=await this.fetch("/api/report-seen");if(!r.ok)throw new Error(`Failed to load last-seen report: ${r.status}`);return(await r.json()).lastSeenReportAt}async markReportSeen(r=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const r=await this.fetch("/api/tickets-seen");if(!r.ok)throw new Error(`Failed to load last-seen tickets: ${r.status}`);return(await r.json()).lastSeenTicketsAt}async markTicketsSeen(r=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(r){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(r,a){const i=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to save credential: ${i.status}`)}async testCredential(r){const a=await this.fetch(`/vault/test/${encodeURIComponent(r)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(r){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ze(i,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(r){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ze(i,"AI request failed")}}return a.json()}async aiTest(r){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(r){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const r=await this.fetch("/mcp/health");if(!r.ok)throw new Error(`MCP server unreachable: ${r.status}`);return r.json()}async getAgentContact(){const r=await this.fetch("/mcp/agent-contact");if(!r.ok)throw new Error(`Failed to fetch agent contact: ${r.status}`);return r.json()}async getMcpIntegrations(){const r=await this.fetch("/mcp/integrations");if(!r.ok)throw new Error(`Failed to fetch integrations: ${r.status}`);return r.json()}async getOAuthHealth(r){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(r)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const r=await this.fetch("/mcp/integrations/manifests");if(!r.ok)throw new Error(`Failed to fetch manifests: ${r.status}`);return r.json()}async getLabelManifests(){const{manifests:r,builtins:a}=await this.getIntegrationManifests();return[...r??[],...a??[]]}async discoverScopeField(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/discover/${encodeURIComponent(a)}`);if(!i.ok){const l=await i.json().catch(()=>({error:`Discovery failed: ${i.status}`}));throw new Error(Ze(l,`Discovery failed: ${i.status}`))}return i.json()}async activateIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}/activate`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ze(i,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!i.ok){const l=await i.json().catch(()=>({error:`HTTP ${i.status}`}));throw new Error(Ze(l,`HTTP ${i.status}`))}}async getTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`);if(i.status===404||!i.ok)return null;const l=await i.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(r,a,i){const l=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(Ze(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(r,a){const i=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:r,recipients:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ze(l,`encryptIntent failed: ${i.status}`))}return i.json()}async getToolDisplay(){const r=await this.fetch("/tool-display");if(!r.ok)return{};const a=await r.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return i.ok?Ej(await i.json()):[]}async deleteTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(Ze(l,`deleteTeamProfileConfig failed: ${i.status}`))}}async getIdentityDisclosure(){const r=await this.fetch("/api/users/me/identity-disclosure");if(!r.ok)throw new Error(`Failed to read identity setting: ${r.status}`);return r.json()}async setIdentityDisclosure(r){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:r})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(r,a="pending"){const i=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(r)}${i}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(r,a="pending"){const i=await Promise.all(bj(r).map(l=>this.getProposals(l,a)));return kj(i)}async resolveProposal(r,a,i,l){const{noteEncrypted:u,contentHash:d,shownHash:p,note:m,...y}=l??{},v=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:i,...y,...u?{note_encrypted:u}:m?{note:m}:{},...d?{content_hash:d}:{},...p?{shown_hash:p}:{}})});if(!v.ok){const j=await v.json().catch(()=>({error:"Failed"}));throw new Error(Ze(j,`Failed: ${v.status}`))}return v.json()}async getProposal(r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(r)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ze(l,`getProposal failed: ${a.status}`))}const i=await a.json();return i.proposal??i}async getProposalsForApprover(){const r=await this.fetch("/api/proposals?approver=me");if(!r.ok)throw new Error(`Failed to fetch approver proposals: ${r.status}`);return(await r.json()).proposals??[]}async approveProposal(r,a,i){const l={};a&&(l.content_hash=a),i&&(l.shown_hash=i);const u=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const d=await u.json().catch(()=>({error:"Failed"}));throw new Error(Ze(d,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(r,a,i,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:p,note:m,...y}=a??{};u={...y,...p?{note_encrypted:p}:m?{note:m}:{}}}i&&(u.content_hash=i),l&&(u.shown_hash=l);const d=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!d.ok){const p=await d.json().catch(()=>({error:"Failed"}));throw new Error(Ze(p,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalsCreatedByMe(){const r=await this.fetch("/api/proposals?creator=me");if(r.status===400)return null;if(!r.ok)throw new Error(`Failed to fetch my proposals: ${r.status}`);return(await r.json()).proposals??[]}async withdrawProposal(r,a,i,l){const{noteEncrypted:u,note:d}=a??{},p={...u?{note_encrypted:u}:d?{note:d}:{}};i&&(p.content_hash=i),l&&(p.shown_hash=l);const m=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!m.ok){const y=await m.json().catch(()=>({error:"Failed"}));throw new Error(Ze(y,`withdrawProposal failed: ${m.status}`))}return m.json()}async getProposalPreview(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to store the shown snapshot: ${i.status}`);return i.json()}async getShownSnapshot(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getProposalAttachmentPreview(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getReceiptAttachmentPreview(r,a){const i=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getAttestationIntent(r){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(r){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ze(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(r){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ze(i,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(r,a){const i=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:r,recipientUserIds:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ze(l,`encryptProposalNote failed: ${i.status}`))}return i.json()}async storeApprovedIntent(r,a){const i=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:r,intent:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed"}));throw new Error(Ze(l,`storeApprovedIntent failed: ${i.status}`))}}async listTeamAuthorizations(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var p,m;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(y=>!(l.attestedDomains??l.attested_domains??[]).includes(y)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(y=>y.expiresAt))*1e3).toISOString():null,remaining_seconds:(m=l.mandates)!=null&&m.length?Math.max(0,Math.min(...l.mandates.map(y=>y.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(r){const a=new URLSearchParams;r!=null&&r.before&&a.set("before",r.before),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(r,a){const i=new URLSearchParams;a!=null&&a.before&&i.set("before",a.before),a!=null&&a.profile&&i.set("profile",a.profile),a!=null&&a.limit&&i.set("limit",String(a.limit));const l=i.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const d=await u.json();return{receipts:d.tickets??[],nextBefore:d.nextBefore??null}}async getThread(r){const a=r.sinceDays??7,i=r.status??"pending",l=await this.getMyProposals(r.domain,i);let u=[];if(i==="all"){const d=[],p=new Date;for(let y=0;y<a;y++){const v=new Date(p);v.setUTCDate(p.getUTCDate()-y),d.push(v.toISOString().slice(0,10))}u=(await Promise.all(d.map(y=>this.getMyReceipts({date:y,profile:r.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const r=await this.fetch("/autostart");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async setAutostart(r){const a=await this.fetch("/autostart",{method:r?"POST":"DELETE"});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.message||`HTTP ${a.status}`)}}async getAsPairing(){const r=await this.fetch("/as-pairing");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getSkippedCommitments(){const r=await this.fetch("/skipped-commitments");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getMyPendingProposals(){const r=await this.fetch("/my-pending-proposals");return r.ok?(await r.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(r){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const r=await this.fetch("/resync-gates",{method:"POST"});if(!r.ok)throw new Error(`Failed to resync gates: ${r.status}`)}async getEnrichedAuthorizations(){const r=await this.fetch("/active-authorizations");if(!r.ok)throw new Error(`Failed to fetch authorizations: ${r.status}`);return(await r.json()).authorizations??[]}async pushGateContent(r){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(Ze(i,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const r=await this.fetch("/agent-brief/context");if(!r.ok)throw new Error(`Failed to fetch agent context: ${r.status}`);return(await r.json()).content}async saveAgentContext(r){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(Ze(i,`Save failed: ${a.status}`))}}async aiChat(r){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:Ze(i,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const r=await this.fetch("/ai-prompts");if(!r.ok)throw new Error(`Failed to load AI prompts: ${r.status}`);return r.json()}async setAIPrompt(r,a){const i=await this.fetch(`/ai-prompts/${r}`,{method:"PUT",body:JSON.stringify({value:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Save failed"}));throw new Error(Ze(l,`Save failed: ${i.status}`))}}}const P=new Aj,Hm=f.createContext(null);function Tj({children:e}){const[r,a]=f.useState(null),[i,l]=f.useState("personal"),[u,d]=f.useState(null),[p,m]=f.useState(""),[y,v]=f.useState(null),[j,x]=f.useState(null),[S,N]=f.useState(null),[w,k]=f.useState(!1),[C,E]=f.useState(""),$=f.useRef(!1),T=f.useRef(null),F=f.useCallback(async()=>{if($.current)try{const z=await P.getMyTeam();if(N(z.pendingRequest),z.group&&z.membership){const{group:V,membership:K}=z;v(V),x(K),l("team"),d(V);const le=T.current??K.domains[0]??"owner";m(le)}else v(null),x(null),l("personal")}catch{}},[]);f.useEffect(()=>{const z=()=>{document.visibilityState==="visible"&&F()};return document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[F]),f.useEffect(()=>{fetch("/health").then(z=>z.json()).then(z=>{var V;((V=z.session)==null?void 0:V.lockedReason)==="as-url-changed"&&E(`Authority Server changed to ${z.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const M=f.useCallback(async(z,V={})=>{k(!0),E("");try{P.setApiKey(z),$.current=!0;const K=await P.login(z,V);a(K),T.current=K.id;const le=await P.getGroups(),me=le.find(we=>we.isPersonal)??le[0]??null;d(me),m("owner"),await F()}catch(K){throw P.clearApiKey(),$.current=!1,E(K instanceof Error?K.message:"Login failed"),K}finally{k(!1)}},[F]),B=f.useCallback(async()=>{await P.logout(),P.clearApiKey(),$.current=!1,T.current=null,a(null),d(null),m(""),v(null),x(null),N(null),l("personal"),E("")},[]),te=f.useCallback(z=>{P.clearApiKey(),$.current=!1,T.current=null,a(null),d(null),m(""),v(null),x(null),N(null),l("personal"),E(z??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Q=f.useCallback(()=>E(""),[]),_=f.useCallback((z,V)=>{d(z),m(V)},[]);return n.jsx(Hm.Provider,{value:{user:r,mode:i,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:y,activeMembership:j,pendingRequest:S,isLoading:w,error:C,login:M,logout:B,clearError:Q,handleSessionLocked:te,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:_,refreshGroups:F},children:e})}function Nt(){const e=f.useContext(Hm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Ij={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},Rj=Object.keys(Ij),Vm=f.createContext(null);function $j({children:e}){const{user:r}=Nt(),a=f.useRef(null),[i,l]=f.useState(!1),u=f.useRef(new Map),d=f.useCallback((p,m)=>{const y=u.current;return y.has(p)||y.set(p,new Set),y.get(p).add(m),()=>{var v;(v=y.get(p))==null||v.delete(m)}},[]);return f.useEffect(()=>{if(!r){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=P.getApiKey();if(!p)return;const m=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=m,m.onopen=()=>l(!0),m.onerror=()=>l(!1);for(const y of Rj)m.addEventListener(y,v=>{let j;try{j=JSON.parse(v.data)}catch{j=null}const x=u.current.get(y);if(x)for(const S of x)try{S(j)}catch(N){console.error(`[EventSource] handler for "${y}" threw:`,N)}});return()=>{m.close(),a.current=null,l(!1)}},[r]),n.jsx(Vm.Provider,{value:{connected:i,addListener:d},children:e})}function Ke(e,r){const a=f.useContext(Vm);if(!a)return;const{addListener:i}=a;f.useEffect(()=>i(e,r),[e,r,i])}const fa="suveren-theme",df="hap-theme";function Ii(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const r=localStorage.getItem(df);r!==null&&localStorage.getItem(fa)===null&&localStorage.setItem(fa,r),r!==null&&localStorage.removeItem(df)})();function qm(){const[e,r]=f.useState(()=>{const u=localStorage.getItem(fa);return u==="light"||u==="dark"?u:"system"}),[a,i]=f.useState(()=>Ii(e));f.useEffect(()=>{const u=document.documentElement,d=Ii(e);u.setAttribute("data-theme",d),e==="system"?localStorage.removeItem(fa):localStorage.setItem(fa,e),i(Ii(e))},[e]),f.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>i(Ii("system"));return u.addEventListener("change",d),()=>u.removeEventListener("change",d)},[e]);const l=f.useCallback(()=>{r(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const Pj=300*1e3,_j=2e3;function nu(){const[e,r]=f.useState(!1),[a,i]=f.useState("docker"),[l,u]=f.useState(""),[d,p]=f.useState(null),[m,y]=f.useState(!1),[v,j]=f.useState(!1),[x,S]=f.useState(!1),N=f.useRef(null);return f.useEffect(()=>{let w=!1;const k=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(T=>T.json()).then(T=>{w||(T.installMethod&&i(T.installMethod),typeof T.latestVersion<"u"&&p(T.latestVersion),T.updateAvailable&&r(!0),T.version&&(u(T.version),N.current===null?N.current=T.version:T.version!==N.current&&T.version!=="dev"&&y(!0)))}).catch(()=>{})};k(!0);const C=setInterval(()=>k(!1),x?_j:Pj),E=()=>{document.visibilityState==="visible"&&k(!1)};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",E),()=>{w=!0,clearInterval(C),document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",E)}},[x]),{updateAvailable:e&&!v,installMethod:a,version:l,latestVersion:d,serverRestarted:m,startFastPolling:()=>S(!0),dismiss:()=>j(!0)}}function Lj(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Mj(){const[e,r]=f.useState({managed:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(Lj(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function Fj({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Oj(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const hf={system:"◑",light:"☀",dark:"☾"};function ru({onMenuToggle:e}){const{user:r,logout:a,mode:i,activeTeam:l}=Nt(),{theme:u,toggle:d}=qm(),{version:p,updateAvailable:m,latestVersion:y}=nu(),{managed:v}=Mj(),j=Oj(p),x=i==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(Fj,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),j&&n.jsxs("span",{className:"gw-version",title:m&&y?`Running v${j} — v${y} is available`:"Running gateway version","data-stale":m?"true":void 0,children:["v",j,m&&y?` → ${y}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:r?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":v?"true":void 0,title:v?`${x} — set by your IT`:x,children:[x,v&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:r.name})}),n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:hf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:hf[u]})}),r&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function su(e,r){var a;if((a=r==null?void 0:r.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Km(e){return e==="expired"||e==="revoked"}function Gm(e,r){var a;return!!((a=r==null?void 0:r.archivedSet)!=null&&a.has(e.authorization_id))&&Km(su(e,r))}function Vi(e,r){return Gm(e,r)?"archived":su(e,r)}function Ym(e,r){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const i of e)a[Vi(i,r)].push(i);return a}function zj(e,r){return r==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ht(e,r,a){const i=f.useRef(e);i.current=e,f.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",d=()=>{u()&&i.current()},p=()=>{l===null&&(l=setInterval(d,r))},m=()=>{l!==null&&(clearInterval(l),l=null)},y=()=>{u()?(i.current(),p()):m()};return u()&&(i.current(),p()),document.addEventListener("visibilitychange",y),()=>{m(),document.removeEventListener("visibilitychange",y)}},[r,a])}function au(){const[e,r]=f.useState(!1);return f.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(d.simulation===!0)}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function Dj(e,r){const a=e.simulation;return a?(((r==null?void 0:r[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function qi(e){return!!(e!=null&&e.simulation)}function Bj(e,r){return Jm(e,e.modeLabels,r)}function Uj(e,r){return Jm(e,e.modeNotes,r)}function Jm(e,r,a){const i=e.simulation;if(!r||!i)return;const l=((a==null?void 0:a[i.field])??"").trim().toLowerCase()||i.default.trim().toLowerCase(),u=r[l];if(u===void 0)return;if(typeof u=="string")return u;const d=e.adapterField,p=d?((a==null?void 0:a[d])??"").trim().toLowerCase():"";return p?u[p]:void 0}function Ki(e,r){var a;return r&&(!qi(e.manifest)||((a=e.integration)==null?void 0:a.paused)==="simulation")}function Wj(e,r=!1){var i;const a=[];for(const l of e)Ki(l,r)||(l.state==="error"?a.push({label:"Integration error",detail:(i=l.integration)!=null&&i.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(qi(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function Hj(e){const r=e.filter(a=>a.state==="paused");return r.length===0?null:{count:r.length,namesText:r.map(a=>a.manifest.name).join(", ")}}const Qm=f.createContext(null),Vj=3e4,qj=5e3,Kj=3e5;function Gj(e,r,a){return r===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function Yj({children:e}){const[r,a]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),i=f.useRef(null),l=f.useCallback(async()=>{let v=!1;const[j,x]=await Promise.all([P.getIntegrationManifests().catch(()=>(v=!0,{manifests:[]})),P.getMcpHealth().catch(()=>null)]);a(N=>({...N,manifests:j.manifests,integrations:(x==null?void 0:x.integrations)??N.integrations,activeSessions:(x==null?void 0:x.activeSessions)??N.activeSessions,mcpServerUp:!!x,manifestsError:v,fetchCount:N.fetchCount+1}));const S=j.manifests.filter(N=>N.oauth);if(S.length>0){const N=await Promise.all(S.map(async w=>[w.id,await P.getOAuthHealth(w.id)]));a(w=>({...w,authHealth:Object.fromEntries(N)}))}},[]),u=r.fetchCount>0&&r.manifests.some(v=>{const j=r.integrations.find(x=>x.id===v.id);return j&&!j.running&&!j.paused});Ke("integration-changed",l),Ht(l,u?qj:Kj);const d=f.useMemo(()=>{const v=new Map(r.integrations.map(S=>[S.id,S])),j=Date.now();u&&i.current===null?i.current=j:u||(i.current=null);const x=i.current!==null&&j-i.current<Vj;return r.manifests.map(S=>{const N=v.get(S.id),w=Gj(N,r.fetchCount,x),k=r.authHealth[S.id];return{id:S.id,manifest:S,integration:N,state:w,authStatus:k==null?void 0:k.status,authAccount:k==null?void 0:k.account,authError:k==null?void 0:k.error}})},[r,u]),p=au(),m=f.useMemo(()=>d.filter(v=>!Ki(v,p)&&(v.state==="not-running"||v.state==="error"||v.authStatus==="failed")).length,[d,p]),y={loading:r.fetchCount===0,mcpServerUp:r.mcpServerUp,manifestsError:r.manifestsError,entries:d,attentionCount:m,activeSessions:r.activeSessions,refresh:l};return n.jsx(Qm.Provider,{value:y,children:e})}function iu(){const e=f.useContext(Qm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const ff=40;function Vt(e,r){const a=e.lastIndexOf("/"),i=a>=0?e.slice(a+1):e,l=i.indexOf("@"),u=l>=0?i.slice(0,l):i;return r?r.slice(0,ff):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,ff)}function En(e){const r=e.lastIndexOf("/"),a=r>=0?e.slice(r+1):e,i=a.indexOf("@");return(i>=0?a.slice(0,i):a).toLowerCase()}function jr(e,r){const a=En(e),i=Jn(e),l=Vt(e,r==null?void 0:r.name);return{icon:i,name:l,testSetup:a==="delegation"}}function po(e){return e.startsWith("setup__")}const Jj={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup",invoicing:"invoicing","master-data":"masterData"};function Jn(e){return Jj[En(e)]??"unknown"}function mf(e){const r=e.indexOf("@");return r>=0?e.slice(r+1):""}function Qn(e,r){const a=En(e),i=r.filter(l=>En(l.id)===a).sort((l,u)=>mf(u.id).localeCompare(mf(l.id),void 0,{numeric:!0}))[0];return Vt(e,i==null?void 0:i.name)}function Ec(e,r){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==r.trim().toLowerCase():!1}function Xm(e){return e&&e.trim()?e.trim():null}function Zm(e,r){return r===null||En(e)===r}let dc=null;function ep(){return dc||(dc=P.listProfiles().catch(()=>[])),dc}function On(){const[e,r]=f.useState([]);return f.useEffect(()=>{let a=!0;return ep().then(i=>{a&&r(i)}),()=>{a=!1}},[]),e}function Qj(e){const r=On();return Qn(e,r)}const Xj={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),invoicing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2-1.3-2 1.3-2-1.3-2 1.3-2-1.3L6 21z"}),n.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),masterData:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.5 7.5h15a1.5 1.5 0 0 1 1.5 1.5v9.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18.5V9a1.5 1.5 0 0 1 1.5-1.5z"}),n.jsx("path",{d:"M6 7.5V5h6v2.5M7 12h10M7 16h6"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function Dr({icon:e,className:r}){return n.jsx("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Xj[e]})}function go(){return n.jsxs("svg",{className:"ob-i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]})}function tp(){return n.jsx("svg",{className:"ob-i ob-chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function At({tag:e,parts:r,className:a,profileId:i}){return n.jsxs("div",{className:`ob-type${a?` ${a}`:""}`,children:[e&&n.jsx("span",{className:"ob-tag",children:e}),r.filter(Boolean).map((l,u)=>n.jsxs("span",{className:u===0&&i?"ob-area":void 0,children:[u===0&&i&&n.jsx(Dr,{icon:Jn(i)}),l]},u))]})}function Gt({title:e,summary:r,children:a,open:i,testId:l,attrs:u,onToggle:d}){return n.jsxs("details",{className:"ob-fold","data-testid":l,...u,open:i,onToggle:d?p=>d(p.currentTarget.open):void 0,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:e}),r!=null&&n.jsx("span",{className:"one",children:r}),n.jsx(tp,{})]}),n.jsx("div",{className:"ob-fold-body",children:a})]})}function va(){const e=f.useRef(null);return f.useCallback(r=>{var i;if((i=e.current)==null||i.call(e),e.current=null,!r)return;const a=l=>{var d;const u=l.target;!u.open||!((d=u.classList)!=null&&d.contains("ob-fold"))||r.querySelectorAll("details.ob-fold[open]").forEach(p=>{p!==u&&(p.open=!1)})};r.addEventListener("toggle",a,!0),e.current=()=>r.removeEventListener("toggle",a,!0)},[])}const Zj={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},vs=e=>Zj[e]??e,ew={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function tw(e){return(e&&ew[e])??{chip:"Blocked",sev:"info"}}function nw(e){const r=vs(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",r]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",r," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",r," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",r," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",r," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function rw(e,r){const a=Math.max(0,(r-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const i=Math.floor(a/86400);return i===1?"Yesterday":`${i} days ago`}const sw=5,aw=1440*60*1e3,iw=7;function ow(e,r){const a=r-iw*aw;return{recent:e.filter(i=>i.ts>=a),all:e}}function lw(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=On(),p=f.useCallback(()=>{P.getDenials({limit:200}).then(({records:x})=>{r(x),i(!1)}).catch(()=>i(!0)),P.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(f.useEffect(()=>{p()},[p]),Ht(p,12e4),Ke("denial-recorded",p),f.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",p),()=>window.removeEventListener("suveren:blocked-seen-changed",p)),[p]),a||e===null||l===null)return null;const{all:m}=ow(e,Date.now()),y=m.filter(x=>x.ts>l);if(y.length===0)return null;const v=y.slice(0,sw),j=(x,S)=>{const N=x.profile?Qn(x.profile,d):vs(x.integrationId),w=tw(x.reason);return n.jsxs(pt,{className:"ob-card dash-row",to:"/blocked","data-testid":"dash-blocked",children:[n.jsx(At,{tag:"Blocked",className:"obj-line",profileId:x.profile??void 0,parts:[N,`via ${vs(x.integrationId)}`,op(x.ts,Date.now())]}),n.jsx("span",{className:"ob-title",children:x.reason?nw(x):lp(x)}),n.jsxs("span",{className:"ob-one ob-check-x",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",n.jsx("b",{children:cp(x)})," ",n.jsx("span",{className:"ob-quiet-inline",children:x.reason?w.chip:ip(x).sentence})]})]},`${x.ts}-${S}`)};return n.jsxs("section",{className:"dash-sec","aria-label":"Blocked — new since you looked","data-testid":"dash-blocked-sec",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Blocked — new since you looked"}),n.jsx("span",{className:"pill-count",children:y.length})]}),n.jsx("div",{className:"dash-rows",children:v.map(j)}),y.length>v.length&&n.jsx(pt,{className:"ob-btn dash-btn",to:"/blocked",children:"All blocked"})]})}function vo(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const np=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function zt(e){const r=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return r.charAt(0).toUpperCase()+r.slice(1)}function Fn(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function cw(e){const{integrationId:r,toolName:a}=Fn(e);return r?`${r} · ${a}`:a}function wr(e,r){const a=r==null?void 0:r.find(i=>i.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function uw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
52
- `)||e.length>120)?"markdown":"text"}function rp(e,r){var d,p;const a=(r==null?void 0:r.approvalView)??{},i=((d=r==null?void 0:r.inputSchema)==null?void 0:d.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(i),...Object.keys(e)])],u=[];for(const m of l){if(!(m in e)||np.has(m)||m===(r==null?void 0:r.aiTextArg))continue;const y=e[m],v=a[m]??{},j=v.kind??uw(y),x={key:m,label:v.label??zt(m),kind:j,value:y,hint:(p=i[m])==null?void 0:p.description};j==="money"&&v.currencyArg&&typeof e[v.currencyArg]=="string"&&(x.currency=e[v.currencyArg]),j==="profile"&&typeof y=="string"&&(x.profileRef=y),(j==="profile-limits"||j==="profile-scope")&&v.profileArg&&typeof e[v.profileArg]=="string"&&(x.profileRef=e[v.profileArg]),u.push(x)}return u}function pf(e,r){const a=r==null?void 0:r.aiTextArg;if(!a)return;const i=e[a];return typeof i=="string"&&i.length>0?i:void 0}function gf(e,r){var i,l;const a=(l=(i=r==null?void 0:r.scopeSchema)==null?void 0:i.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function sp(e,r,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const i=a==="limits"?r==null?void 0:r.boundsSchema:r==null?void 0:r.scopeSchema,l=(i==null?void 0:i.fields)??{},u=[...new Set([...(i==null?void 0:i.keyOrder)??[],...Object.keys(e)])],d=[];for(const p of u){if(p==="profile"||!(p in e))continue;const m=e[p],y=l[p],v=vo(y==null?void 0:y.unit),j=Array.isArray(m)?m.join(", "):String(m);d.push({key:p,label:(y==null?void 0:y.displayName)??zt(p),value:v?`${j} ${v}`:j,hint:y==null?void 0:y.description,unknown:r?!y:void 0})}return d}function ya(e){return e.kind??"read"}function dw(e,r){var u,d,p,m;if(!r)return"";if(!e)return r;const a=(d=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:d[r];if(a!=null&&a.displayName)return a.displayName;const i=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((m=i[r])!=null&&m.displayName)return i[r].displayName;const l=Object.values(i).find(y=>y.boundType&&"of"in y.boundType&&y.boundType.of===r);return l!=null&&l.displayName?l.displayName:r}const hw={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",check:"Blocked — a check failed",read:"Read blocked"},fw={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",check:"Nothing ran and no approval was asked for. The check reads the system's own data — correct the request or that data.",read:"Nothing was read."};function mw(e){const r=e.includes("_")?e.replace(/_/g," "):e;return r.charAt(0).toLowerCase()+r.slice(1)}function vf(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function pw(e,r){const a=ya(e),i=vf(e.value),l=vf(e.limit);switch(a){case"bound":return i&&l?`${r||"Value"} ${i} is above the limit ${l}.`:e.detail;case"scope":return i?`"${i}" is not within your mandate's ${r?mw(r):"scope"}.`:e.detail;case"cumulative":return i&&l?`${i} of ${l} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function ap(e,r){if(e.mandateId){const a=r==null?void 0:r[e.mandateId];if(a)return a}return e.mandateTitle}function gw(e,r){const a=ap(e,r);if(a){const i=[{text:` · mandate "${a}"`}];return e.mandateId&&i.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),i}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function vw(e,r){const a=ya(e),i=vs(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${i} · ${e.tool}`},...gw(e,r),{text:` · ${l}${u}`}]}function ip(e,r,a){const i=ya(e),l=dw(r,e.field);return{title:hw[i],sentence:pw(e,l),sourceLine:vw(e,a),whatYouCanDo:fw[i]}}function yw(e,r){const a=new Date(r);return a.setHours(0,0,0,0),e.filter(i=>i.ts>=a.getTime()).length}function xw(e,r){return e.filter(a=>a.ts>r).length}const jw=1440*60*1e3;function op(e,r){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),i=new Date(r);i.setHours(0,0,0,0);const l=i.getTime();return e>=l?`Today · ${a}`:e>=l-jw?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function lp(e){var i;const r=zt(Fn(e.tool).toolName),a=(i=e.target)==null?void 0:i.trim();return a?`${r} · ${a}`:r}const ww={bound:"Above your limit:",scope:"Outside your mandate:",cumulative:"Limit reached:",simulation:"Simulation mode:",not_authorized:"Not authorized:",check:"A check failed:",read:"Read blocked:"};function cp(e){return ww[ya(e)]}function bw(e){return e.who==="authority-server"?"Refused by the Authority Server before anything ran.":"Refused by this gateway before anything ran."}function up(e,r){return!!e&&e.savedAt*1e3>r}function kw(e){const r=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=r?r[1].replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function Sw(e){var r,a;return{verified:((a=(r=e.proof)==null?void 0:r.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(i=>i.status==="unverifiable").length}}const yf=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),xf=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Gi(e,r){const a=e==null?void 0:e.window;return a?{text:`Covers ${yf(a.start,r)} → ${yf(a.end,r)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${xf(a.start,r)} to ${xf(a.end,r)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function dp(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((r-e*1e3)/864e5);if(new Date(r).toDateString()===i.toDateString())return`today ${l}`;const p=`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}function hp(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function ys(e,r){var m,y,v;const{integrationId:a,toolName:i}=hp(e.action),l=r.find(j=>j.id===a),u=(y=(m=l==null?void 0:l.toolGating)==null?void 0:m.overrides)==null?void 0:y[i];if(u!=null&&u.actionLabel)return u.actionLabel;const d=Vt(e.profileId),p=(v=e.executionContext)==null?void 0:v.action_type;return typeof p=="string"&&p?`${d} · ${p}`:`${d} · ${i}`}function Nw(e,r){var l;const a=(l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields;if(!a)return"";const i=[];for(const[u,d]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(d??"").trim();p&&i.push(p.split(",").map(m=>m.trim()).filter(Boolean).join(", "))}return i.join(" · ")}function Cw(e,r){var l,u;if(!e)return"";const a=((l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields)??{},i=[];for(const[d,p]of Object.entries(e)){if(d==="action_type")continue;const m=String(p??"").trim();if(!m)continue;const y=((u=a[d])==null?void 0:u.displayName)??d;i.push(`${y} ${m.split(",").map(v=>v.trim()).filter(Boolean).join(", ")}`)}return i.join(" · ")}function jf(e){return e.appliesTo}function fp(e,r,a,i){var y,v,j;const l=(y=a==null?void 0:a.boundsSchema)==null?void 0:y.fields;if(!l||!r)return;const u=e.actionType??(typeof((v=e.executionContext)==null?void 0:v.action_type)=="string"?e.executionContext.action_type:void 0),d=Object.entries(l).filter(([x,S])=>{if(!(x in r))return!1;const N=S.boundType;if(!N||N.kind!=="cumulative_sum"&&N.kind!=="cumulative_count"||N.window!==i)return!1;const w=jf(S);return!w||!u||w.includes(u)}),m=(u?d.find(([,x])=>{var S;return(S=jf(x))==null?void 0:S.includes(u)}):void 0)??(d.length===1?d[0]:void 0);return m?{key:m[0],isAmount:((j=m[1].boundType)==null?void 0:j.kind)==="cumulative_sum"}:void 0}function ou(e,r,a,i){var p;const l=(p=e.cumulativeState)==null?void 0:p[i];if(!l)return null;const u=fp(e,r,a,i),d=u?Number(r==null?void 0:r[u.key]):NaN;return u&&Number.isFinite(d)?{used:u.isAmount?l.amount:l.count,limit:d}:{count:l.count}}function Ew(e,r,a){const i=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:d}of i){const p=ou(e,r,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${d}`:`${p.count} ${p.count===1?"call":"calls"} ${d}`)}return l.join(" · ")}function Aw(e,r,a){var u;const i=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!r||!i)return[];const l=[];for(const[d,p]of Object.entries(i)){const m=p.boundType;if(!m||m.kind!=="per_transaction")continue;const y=m.of;if(!(y in e)||!(d in r))continue;const v=Number(e[y]),j=Number(r[d]);if(!Number.isFinite(v)||!Number.isFinite(j))continue;const x=vo(p.unit),S=p.displayName??zt(y),N=w=>x?`${w.toLocaleString()} ${x}`:w.toLocaleString();l.push({key:d,label:S,ok:v<=j,valueText:N(v),limitText:N(j)})}return l}function Yi(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Tw(e){const r=Vt(e),a=e.split("@")[1];return a?`${r}@${a}`:r}const Iw=["automatic","approved","all"];function Rw(e){return e==="automatic"||e==="approved"?e:"all"}function Ji(e,r){return r==="all"?!0:r==="approved"?Yi(e):!Yi(e)}function Br(e,r){return Qn(e,r)}function yo(e,r){return wr(hp(e).integrationId,r)}function mp(e,r){const a=Math.max(0,Math.floor((r-e)/1e3));if(a<60)return"just now";const i=Math.floor(a/60);if(i<60)return`${i} min`;const l=Math.floor(i/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}const $w=24*3600;function pp(e,r,a){const i=e-Math.floor(r/1e3);return i<=0||i>$w?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function lu(e){return e.replace(/-/g,"").slice(0,8)}function Pw(e,r){const a=new Date(e),i=new Date(r);return a.getFullYear()===i.getFullYear()&&a.getMonth()===i.getMonth()&&a.getDate()===i.getDate()}function Ur(e,r){return Pw(e*1e3,r)}function Qi(e,r){return e.timestamp*1e3>r}function _w(e,r){var l;const a=new Map;for(const u of e){if(Yi(u))continue;const d=ys(u,r.manifests),m=`${u.authorizationId??u.profileId}|${u.action}`;let y=a.get(m);y||(y={key:m,area:Br(u.profileId,r.catalog),system:yo(u.action,r.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=r.titles)==null?void 0:l[u.authorizationId]:void 0,label:d,count:0,newCount:0,latestSec:0,tickets:[]},a.set(m,y)),y.count+=1,Qi(u,r.lastSeenMs)&&(y.newCount+=1),y.latestSec=Math.max(y.latestSec,u.timestamp),y.tickets.push(u)}const i=[...a.values()];for(const u of i)u.tickets.sort((d,p)=>p.timestamp-d.timestamp);return i.sort((u,d)=>+(d.newCount>0)-+(u.newCount>0)||d.latestSec-u.latestSec)}function Lw(e,r){var l,u,d,p,m;const a=new Map;for(const y of e){if(!y.authorizationId||!Ur(y.timestamp,r.nowMs))continue;const v=a.get(y.authorizationId);(!v||y.timestamp>v.timestamp||y.timestamp===v.timestamp&&(((u=(l=y.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=v.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&a.set(y.authorizationId,y)}const i=[];for(const[y,v]of a){const j=ou(v,r.boundsOf(y)??v.limits,r.profileOf(v.profileId),"daily"),x={authorizationId:y,area:Br(v.profileId,r.catalog),system:yo(v.action,r.manifests),profileId:v.profileId,mandateTitle:(m=r.titles)==null?void 0:m[y]};j&&"limit"in j?i.push({...x,used:j.used,limit:j.limit,ratio:j.limit>0?j.used/j.limit:0}):i.push({...x,used:j?j.count:1,ratio:0})}return i.sort((y,v)=>v.ratio-y.ratio||y.area.localeCompare(v.area))}function Mw(e){return e.ratio>=.8}function ma(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Ur(e,r)?`today ${l}`:`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}function Fw(e,r){return e==="approve"?r?"Signing":"Approving":e==="reject"?"Rejecting":"Sending"}function Ow(e,r){return e==="approve"?r?"Signed":"Approved":e==="reject"?"Rejected":"Sent back to the AI"}function zw(e,r){return r!=null&&r.detail?r.detail:e==="approve"&&(r!=null&&r.ticketId)?`Ticket ${lu(r.ticketId)}`:"Recorded"}function gp(e){if(!e||typeof e!="object")return;const r=e,a=r.id??r.receiptId??r.ticketId;return typeof a=="string"&&a.length>0?a:void 0}function Dw(e,r){const a=e.indexOf(r),i=e.filter(l=>l!==r);return i.length===0?null:a<0?i[0]:i[Math.min(a,i.length-1)]}function Bw(e,r){if(!r)return null;const a=e.indexOf(r);return a<0?null:`${a+1} of ${e.length}`}function Uw(e,r){const a=Bw(e,r);return a?`Next · ${a}`:null}const Ww=[{id:"me",label:"For me"},{id:"others",label:"Others"},{id:"all",label:"All"}];function Hw(e){return e==="ArrowLeft"?"prev":e==="ArrowRight"?"next":e==="Escape"?"list":null}const Ac="suveren:approvals-changed";function wf(e=typeof window<"u"?window:void 0){e==null||e.dispatchEvent(new Event(Ac))}const Vw={dashboard:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"13.5",y:"13.5",width:"7",height:"7",rx:"1.4"})]}),approvals:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 13.5 6.2 5h11.6l2.2 8.5V19H4z"}),n.jsx("path",{d:"M4 13.5h5l1 2.2h4l1-2.2h5"})]}),mandates:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4"}),n.jsx("path",{d:"M9 12h7M8.8 17c1.2-2 2.2 1 3.4-.8s1.6-.2 3 .1"})]}),tickets:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 8a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2a2 2 0 0 0 0 4v2a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-2a2 2 0 0 0 0-4z"}),n.jsx("path",{d:"M14.5 7.5v9",strokeDasharray:"1.8 2"})]}),reports:n.jsx("path",{d:"M4 20h16M7 20v-6M12 20V5M17 20v-9"}),blocked:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),n.jsx("path",{d:"M6 6l12 12"})]}),team:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),brief:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 3.5h14v17H5z"}),n.jsx("path",{d:"M8.5 8.5h7M8.5 12h7M8.5 15.5h4"})]}),integrations:n.jsx("path",{d:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4"}),settings:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h9M17 7h3M4 17h3M11 17h9"}),n.jsx("circle",{cx:"15",cy:"7",r:"2"}),n.jsx("circle",{cx:"9",cy:"17",r:"2"})]})};function Tc({name:e}){return n.jsx("svg",{className:"nav-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Vw[e]})}const qw=[{to:"/",icon:"dashboard",label:"Dashboard",group:"top"},{to:"/approvals",icon:"approvals",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"mandates",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"tickets",label:"Tickets",group:"core"},{to:"/reports",icon:"reports",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"team",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"brief",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"integrations",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"settings",label:"Settings",statusKey:"assistant",group:"setup"}];function Kw(){const{activeDomain:e}=Nt(),[r,a]=f.useState({}),i=f.useCallback(async()=>{try{const[l,u,d,p,m,y,v,j,x,S]=await Promise.all([P.getCredential("ai-config").catch(()=>null),P.getMyAttestations().catch(()=>null),P.getMyProposals(e).catch(()=>null),P.getProposalsForApprover().catch(()=>null),P.getAgentContext().catch(()=>""),P.getArchivedMandates().catch(()=>[]),P.getDenials({limit:200}).catch(()=>null),P.getLastSeenBlockedAt().catch(()=>0),P.getReport().catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),N={};if(l&&!l.configured&&(N.assistant=1),u){const E=Ym(u,{archivedSet:new Set(y)}).expired.length;E>0&&(N.authorizations=E)}const w=(d==null?void 0:d.length)??0,k=(p==null?void 0:p.length)??0,C=w+k;if(C>0&&(N.proposals=C),(!m||!m.trim())&&(N.brief=1),v){const E=xw(v.records,j);E>0&&(N.blocked=E)}up(x==null?void 0:x.report,S)&&(N.report=1),a(N)}catch{}},[e]);return Ke("attestation-changed",i),Ke("proposal-added",i),Ke("proposal-resolved",i),Ke("proposal-approved",i),Ke("proposal-rejected",i),Ke("team-membership-changed",i),Ke("denial-recorded",i),Ke("report-written",i),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",i),()=>window.removeEventListener("suveren:archived-changed",i)),[i]),f.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",i),window.addEventListener("suveren:report-seen-changed",i),window.addEventListener(Ac,i),()=>{window.removeEventListener(Ac,i),window.removeEventListener("suveren:blocked-seen-changed",i),window.removeEventListener("suveren:report-seen-changed",i)}),[i]),Ht(i,3e5,e),r}const Gw={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"var(--elevation-2)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function Yw(){const{mode:e,activeTeam:r}=Nt(),a=Kw(),{attentionCount:i}=iu(),l={...a};i>0&&(l.integrations=i);const u=qw.filter(v=>!v.teamOnly||e==="team"),d=f.useRef(null),[p,m]=f.useState(null),y=nn();return f.useEffect(()=>{if(d.current===null){d.current=e;return}d.current!==e&&(e==="team"&&r?m(`You are now acting in team context — ${r.name}`):e==="personal"&&m("You have left the team — back to personal context"),d.current=e)},[e,r]),f.useEffect(()=>{m(null)},[y.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(v=>{const j=u.filter(x=>(x.group??"setup")===v);return j.length===0?null:n.jsxs("div",{className:`sidebar-${v}`,children:[v==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),v==="setup"&&n.jsxs("span",{className:`sidebar-setup-rail${j.some(x=>y.pathname.startsWith(x.to))?" is-active":""}`,"aria-hidden":"true",children:[n.jsx(Tc,{name:"settings"}),j.some(x=>x.statusKey&&l[x.statusKey])&&n.jsx("span",{className:"nav-dot"})]}),n.jsx("ul",{className:"sidebar-nav",children:j.map(x=>{const S=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(tu,{to:x.to,end:x.to==="/",className:({isActive:N})=>`sidebar-item${N?" active":""}`,children:[n.jsx("span",{className:"icon",children:n.jsx(Tc,{name:x.icon})}),n.jsx("span",{className:"sidebar-label",children:x.label}),S?x.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${x.statusKey}`,children:"New"}):n.jsx("span",{className:`nav-count${x.quietCount||v==="setup"?" nav-count-setup":""}`,"data-testid":`nav-count-${x.statusKey}`,title:x.statusKey==="authorizations"?"Expired mandates":void 0,children:S}):null]})},x.to)})})]},v)}),p&&n.jsx("div",{style:Gw,role:"status","aria-live":"polite",children:p})]})}const hc="suveren:updatedTo";function Jw(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Qw="Updates for this gateway come from your company's IT — no action needed here.";function Xw(e){return e==="managed"?"update-banner is-managed":"update-banner"}const Zw="Download the new installer and run it. Your settings and mandates stay.";function e0(e){const r="https://github.com/suverenai/suveren-gateway/releases";return e?`${r}/tag/v${e}`:`${r}/latest`}function t0(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const r=document.activeElement;if(r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)){const a=r.value;if(a&&a.trim())return!0}return!1}function vp(){const{updateAvailable:e,installMethod:r,version:a,latestVersion:i,serverRestarted:l,startFastPolling:u,dismiss:d}=nu(),[p,m]=f.useState(!1),[y,v]=f.useState(!1),[j,x]=f.useState(()=>{try{const $=sessionStorage.getItem(hc);if($)return sessionStorage.removeItem(hc),$}catch{}return null}),S=Jw(r),N=f.useRef(null),w=$=>{try{sessionStorage.setItem(hc,$||i||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!j)return;const $=setTimeout(()=>x(null),6e3);return()=>clearTimeout($)},[j]),f.useEffect(()=>{if(!p||!l)return;const $=()=>t0()?!1:(w(a),!0);if($())return;const T=setInterval($,1500);return()=>clearInterval(T)},[p,l,a]),f.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const k=e&&!p&&!j||!!j&&!p;f.useEffect(()=>{if(!k){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const $=()=>{var M;const F=((M=N.current)==null?void 0:M.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${F}px`)};$();const T=new ResizeObserver($);return N.current&&T.observe(N.current),()=>{T.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[k]);const C=()=>{m(!0),u()},E=async()=>{if(S)try{await navigator.clipboard.writeText(S),v(!0),setTimeout(()=>v(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[j&&!p&&n.jsx("div",{ref:N,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",j&&j!=="✓"?` — ${j} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>x(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!p&&!j&&n.jsxs("div",{ref:N,className:Xw(r),role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"update-banner-row",children:[n.jsx("span",{className:"update-banner-text",children:r==="msi"&&i?`Update available — version ${i}.`:"Update available."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r==="msi"&&n.jsx("a",{className:"btn btn-sm btn-secondary",href:e0(i),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),r!=="managed"&&r!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:C,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:d,"aria-label":"Dismiss",children:"×"})]})]}),r==="managed"&&n.jsx("p",{className:"update-banner-hint",children:Qw}),r==="msi"&&n.jsx("p",{className:"update-banner-hint",children:Zw})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:S}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:E,children:y?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>w(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>m(!1),children:"Cancel"})]})]})})]})}function yp(){const e=au(),r=f.useRef(null);return f.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=r.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const i=new ResizeObserver(a);return r.current&&i.observe(r.current),()=>{i.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:r,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const n0={system:"◑",light:"☀",dark:"☾"},r0=[{to:"/",icon:"dashboard",label:"Dashboard"},{to:"/approvals",icon:"approvals",label:"Approvals"},{to:"/mandates",icon:"mandates",label:"Mandates"},{to:"/tickets",icon:"tickets",label:"Tickets"},{to:"/reports",icon:"reports",label:"Reports"},{to:"/blocked",icon:"blocked",label:"Blocked"},{to:"/team",icon:"team",label:"Team"},{to:"/agent-brief",icon:"brief",label:"Agent Brief"},{to:"/integrations",icon:"integrations",label:"Integrations"},{to:"/settings",icon:"settings",label:"Settings"}];function s0({open:e,onClose:r}){const{user:a,activeGroup:i,activeDomain:l,logout:u}=Nt(),{theme:d,toggle:p}=qm(),m=nn();return f.useEffect(()=>{r()},[m.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:r}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:i?`${i.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:r0.map(y=>n.jsxs(tu,{to:y.to,end:y.to==="/",className:({isActive:v})=>`mobile-menu-item${v?" active":""}`,onClick:r,children:[n.jsx("span",{className:"icon",children:n.jsx(Tc,{name:y.icon})}),y.label]},y.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:n0[d]}),"Theme: ",d]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),r()},children:"Logout"})]})]})]}):null}function xp(e){return e.status==="pending"}function a0(e,r){return e.filter(xp).length+r.length}const Lr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],i0=500;function jp(){const{user:e,domain:r}=Nt(),[a,i]=f.useState(0),l=f.useRef(null),u=f.useCallback(async()=>{if(!e){i(0);return}try{const[p,m]=await Promise.all([P.getMyProposals(r).catch(()=>[]),P.getProposalsForApprover().catch(()=>[])]);i(a0(p,m))}catch{i(0)}},[e,r]),d=f.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},i0)},[u]);return f.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Ke(Lr[0],d),Ke(Lr[1],d),Ke(Lr[2],d),Ke(Lr[3],d),Ke(Lr[4],d),Ke(Lr[5],d),Ke(Lr[6],d),a}const bf="Suveren",o0="/favicon.svg",l0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ri={x1:74.54,y1:22.74,x2:94.46,y2:34.24},c0=14,u0="#f59e0b";function d0(e){const r=cu(e);return r>0?`(${r}) ${bf}`:bf}function cu(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function h0(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
53
- <path class="m" d="${l0}"/>
51
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let v=nn(),j;if(r){let C=typeof r=="string"?ws(r):r;xt(m==="/"||((k=C.pathname)==null?void 0:k.startsWith(m)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${C.pathname}" was given in the \`location\` prop.`),j=C}else j=v;let x=j.pathname||"/",S=x;if(m!=="/"){let C=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let N=a&&a.state.matches.length?a.state.matches.map(C=>Object.assign(C,{route:a.manifest[C.route.id]||C.route})):bm(e,{pathname:S});vn(y||N!=null,`No routes matched location "${j.pathname}${j.search}${j.hash}" `),vn(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${j.pathname}${j.search}${j.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=Px(N&&N.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:Cn([m,i.encodeLocation?i.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?m:Cn([m,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),l,a);return r&&w?f.createElement(pa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...j},navigationType:"POP"}},w):w}function Tx(){let e=Ox(),r=dx(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,i="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",e),d=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:u},"ErrorBoundary")," or"," ",f.createElement("code",{style:u},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},r),a?f.createElement("pre",{style:l},a):null,d)}var Ix=f.createElement(Tx,null),Fm=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=kx(e.digest);a&&(e=a)}let r=e!==void 0?f.createElement(An.Provider,{value:this.props.routeContext},f.createElement(Yc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?f.createElement(Rx,{error:e},r):r}};Fm.contextType=Rm;var uc=new WeakMap;function Rx({children:e,error:r}){let{basename:a,navigator:i}=f.useContext(un);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let l=bx(r.digest);if(l){let u=uc.get(r);if(u)throw u;let d=Tm(l.location,a),p=d.absoluteURL||d.to;if(Gc(l.location,p,Kc(i),"allow-explicit"),gx(p))throw new Error("Invalid redirect location");if(Am&&!uc.get(r))if(d.isExternal||l.reloadDocument)window.location.href=p;else{const m=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:l.replace}));throw uc.set(r,m),m}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function $x({routeContext:e,match:r,children:a}){let i=f.useContext(bs);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),f.createElement(An.Provider,{value:e},a)}function Px(e,r=[],a){let i=a==null?void 0:a.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(r.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let l=e,u=i==null?void 0:i.errors;if(u!=null){let v=l.findIndex(j=>j.route.id&&(u==null?void 0:u[j.route.id])!==void 0);xt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,v+1))}let d=!1,p=-1;if(a&&i){d=i.renderFallback;for(let v=0;v<l.length;v++){let j=l[v];if((j.route.HydrateFallback||j.route.hydrateFallbackElement)&&(p=v),j.route.id){let{loaderData:x,errors:S}=i,N=j.route.loader&&!x.hasOwnProperty(j.route.id)&&(!S||S[j.route.id]===void 0);if(j.route.lazy||N){a.isStatic&&(d=!0),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let m=a==null?void 0:a.onError,y=i&&m?(v,j)=>{var x,S;m(v,{location:i.location,params:((S=(x=i.matches)==null?void 0:x[0])==null?void 0:S.params)??{},pattern:hx(i.matches),errorInfo:j})}:void 0;return l.reduceRight((v,j,x)=>{let S,N=!1,w=null,k=null;i&&(S=u&&j.route.id?u[j.route.id]:void 0,w=j.route.errorElement||Ix,d&&(p<0&&x===0?(Om("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,k=null):p===x&&(N=!0,k=j.route.hydrateFallbackElement||null)));let C=r.concat(l.slice(0,x+1)),E=()=>{let $;return S?$=w:N?$=k:j.route.Component?$=f.createElement(j.route.Component,null):j.route.element?$=j.route.element:$=v,f.createElement($x,{match:j,routeContext:{outlet:v,matches:C,isDataRoute:i!=null},children:$})};return i&&(j.route.ErrorBoundary||j.route.errorElement||x===0)?f.createElement(Fm,{location:i.location,revalidation:i.revalidation,component:w,error:S,children:E(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:y}):E()},null)}function Jc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function _x(e){let r=f.useContext(bs);return xt(r,Jc(e)),r}function Lx(e){let r=f.useContext(ho);return xt(r,Jc(e)),r}function Mx(e){let r=f.useContext(An);return xt(r,Jc(e)),r}function Qc(e){let r=Mx(e),a=r.matches[r.matches.length-1];return xt(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Fx(){return Qc("useRouteId")}function Ox(){var i;let e=f.useContext(Yc),r=Lx("useRouteError"),a=Qc("useRouteError");return e!==void 0?e:(i=r.errors)==null?void 0:i[a]}function zx(){let{router:e}=_x("useNavigate"),r=Qc("useNavigate"),a=f.useRef(!1);return Lm(()=>{a.current=!0}),f.useCallback(async(l,u={})=>{vn(a.current,_m),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:r,...u}))},[e,r])}var lf={};function Om(e,r,a){!r&&!lf[e]&&(lf[e]=!0,vn(!1,a))}f.memo(Dx);function Dx({routes:e,manifest:r,future:a,state:i,isStatic:l,onError:u}){return Mm(e,void 0,{manifest:r,state:i,isStatic:l,onError:u})}function Gn({to:e,replace:r,state:a,relative:i}){xt(ks(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=f.useContext(un);vn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=f.useContext(An),{pathname:p}=nn(),m=yn(),y=uo(e,qc(d),p,i==="path");Gc(typeof e=="string"?e:zr(e),u.createHref(y),Kc(u),"reject");let v=JSON.stringify(y);return f.useEffect(()=>{m(JSON.parse(v),{replace:r,state:a,relative:i})},[m,v,i,r,a]),null}function Bx(e){return Ex(e.context)}function mt(e){xt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ux({basename:e="/",children:r=null,location:a,navigationType:i="POP",navigator:l,static:u=!1,useTransitions:d}){xt(!ks(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=e.replace(/^\/*/,"/"),m=f.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:d,future:{}}),[p,l,u,d]);typeof a=="string"&&(a=ws(a));let{pathname:y="/",search:v="",hash:j="",state:x=null,key:S="default",mask:N}=a,w=f.useMemo(()=>{let k=Yn(y,p);return k==null?null:{location:{pathname:k,search:v,hash:j,state:x,key:S,mask:N},navigationType:i}},[p,y,v,j,x,S,i,N]);return vn(w!=null,`<Router basename="${p}"> is not able to match the URL "${y}${v}${j}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:f.createElement(un.Provider,{value:m},f.createElement(pa.Provider,{children:r,value:w}))}function Wx({children:e,location:r}){return Ax(Cc(e),r)}function Cc(e,r=[]){let a=[];return f.Children.forEach(e,(i,l)=>{if(!f.isValidElement(i))return;let u=[...r,l];if(i.type===f.Fragment){a.push.apply(a,Cc(i.props.children,u));return}xt(i.type===mt,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xt(!i.props.index||!i.props.children,"An index route cannot have child routes.");let d={id:i.props.id||u.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(d.children=Cc(i.props.children,u)),a.push(d)}),a}var Oi="get",zi="application/x-www-form-urlencoded";function fo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Hx(e){return fo(e)&&e.tagName.toLowerCase()==="button"}function Vx(e){return fo(e)&&e.tagName.toLowerCase()==="form"}function qx(e){return fo(e)&&e.tagName.toLowerCase()==="input"}function Kx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Gx(e,r){return e.button===0&&(!r||r==="_self")&&!Kx(e)}function Ec(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,a)=>{let i=e[a];return r.concat(Array.isArray(i)?i.map(l=>[a,l]):[[a,i]])},[]))}function Yx(e,r){let a=Ec(e);return r&&r.forEach((i,l)=>{a.has(l)||r.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ti=null;function Jx(){if(Ti===null)try{new FormData(document.createElement("form"),0),Ti=!1}catch{Ti=!0}return Ti}var Qx=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function dc(e){return e!=null&&!Qx.has(e)?(vn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${zi}"`),null):e}function Xx(e,r){let a,i,l,u,d;if(Vx(e)){let p=e.getAttribute("action");i=p?Yn(p,r):null,a=e.getAttribute("method")||Oi,l=dc(e.getAttribute("enctype"))||zi,u=new FormData(e)}else if(Hx(e)||qx(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=e.getAttribute("formaction")||p.getAttribute("action");if(i=m?Yn(m,r):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||Oi,l=dc(e.getAttribute("formenctype"))||dc(p.getAttribute("enctype"))||zi,u=new FormData(p,e),!Jx()){let{name:y,type:v,value:j}=e;if(v==="image"){let x=y?`${y}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else y&&u.append(y,j)}}else{if(fo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Oi,i=null,l=zi,d=e}return u&&l==="text/plain"&&(d=u,u=void 0),{action:i,method:a.toLowerCase(),encType:l,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xc(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function zm(e,r,a,i){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${i}`:l.pathname=`${l.pathname}.${i}`:l.pathname==="/"?l.pathname=`_root.${i}`:r&&Yn(l.pathname,r)==="/"?l.pathname=`${gs(r)}/_root.${i}`:l.pathname=`${gs(l.pathname)}.${i}`,l}async function Zx(e,r){if(e.id in r)return r[e.id];try{let a=await import(e.module);return r[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function ej(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function tj(e,r,a){let i=await Promise.all(e.map(async l=>{let u=r.routes[l.route.id];if(u){let d=await Zx(u,a);return d.links?d.links():[]}return[]}));return aj(i.flat(1).filter(ej).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function cf(e,r,a,i,l,u){let d=(m,y)=>a[y]?m.route.id!==a[y].route.id:!0,p=(m,y)=>{var v;return a[y].pathname!==m.pathname||((v=a[y].route.path)==null?void 0:v.endsWith("*"))&&a[y].params["*"]!==m.params["*"]};return u==="assets"?r.filter((m,y)=>d(m,y)||p(m,y)):u==="data"?r.filter((m,y)=>{var j;let v=i.routes[m.route.id];if(!v||!v.hasLoader)return!1;if(d(m,y)||p(m,y))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((j=a[0])==null?void 0:j.params)||{},nextUrl:new URL(e,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function nj(e,r,{includeHydrateFallback:a}={}){return rj(e.map(i=>{let l=r.routes[i.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function rj(e){return[...new Set(e)]}function sj(e){let r={},a=Object.keys(e).sort();for(let i of a)r[i]=e[i];return r}function aj(e,r){let a=new Set;return new Set(r),e.reduce((i,l)=>{let u=JSON.stringify(sj(l));return a.has(u)||(a.add(u),i.push({key:u,link:l})),i},[])}function Zc(){let e=f.useContext(bs);return Xc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ij(){let e=f.useContext(ho);return Xc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var eu=f.createContext(void 0);eu.displayName="FrameworkContext";function mo(){let e=f.useContext(eu);return Xc(e,"You must render this element inside a <HydratedRouter> element"),e}function oj(e,r){let a=f.useContext(eu),[i,l]=f.useState(!1),[u,d]=f.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:y,onMouseLeave:v,onTouchStart:j}=r,x=f.useRef(null);f.useEffect(()=>{if(e==="render"&&d(!0),e==="viewport"){let w=C=>{C.forEach(E=>{d(E.isIntersecting)})},k=new IntersectionObserver(w,{threshold:.5});return x.current&&k.observe(x.current),()=>{k.disconnect()}}},[e]),f.useEffect(()=>{if(i){let w=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(w)}}},[i]);let S=()=>{l(!0)},N=()=>{l(!1),d(!1)};return a?e!=="intent"?[u,x,{}]:[u,x,{onFocus:la(p,S),onBlur:la(m,N),onMouseEnter:la(y,S),onMouseLeave:la(v,N),onTouchStart:la(j,S)}]:[!1,x,{}]}function la(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function lj({page:e,...r}){let a=vx(),{nonce:i}=mo(),{router:l}=Zc(),u=f.useMemo(()=>bm(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(r.nonce==null&&i&&(r={...r,nonce:i}),a?f.createElement(uj,{page:e,matches:u,...r}):f.createElement(dj,{page:e,matches:u,...r})):null}function cj(e){let{manifest:r,routeModules:a}=mo(),[i,l]=f.useState([]);return f.useEffect(()=>{let u=!1;return tj(e,r,a).then(d=>{u||l(d)}),()=>{u=!0}},[e,r,a]),i}function uj({page:e,matches:r,...a}){let i=nn(),{future:l}=mo(),{basename:u}=Zc(),d=f.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let p=zm(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),m=!1,y=[];for(let v of r)typeof v.route.shouldRevalidate=="function"?m=!0:y.push(v.route.id);return m&&y.length>0&&p.searchParams.set("_routes",y.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,i,r]);return f.createElement(f.Fragment,null,d.map(p=>f.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function dj({page:e,matches:r,...a}){let i=nn(),{future:l,manifest:u,routeModules:d}=mo(),{basename:p}=Zc(),{loaderData:m,matches:y}=ij(),v=f.useMemo(()=>cf(e,r,y,u,i,"data"),[e,r,y,u,i]),j=f.useMemo(()=>cf(e,r,y,u,i,"assets"),[e,r,y,u,i]),x=f.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let w=new Set,k=!1;if(r.forEach(E=>{var T;let $=u.routes[E.route.id];!$||!$.hasLoader||(!v.some(F=>F.route.id===E.route.id)&&E.route.id in m&&((T=d[E.route.id])!=null&&T.shouldRevalidate)||$.hasClientLoader?k=!0:w.add(E.route.id))}),w.size===0)return[];let C=zm(e,p,l.v8_trailingSlashAwareDataRequests,"data");return k&&w.size>0&&C.searchParams.set("_routes",r.filter(E=>w.has(E.route.id)).map(E=>E.route.id).join(",")),[C.pathname+C.search]},[p,l.v8_trailingSlashAwareDataRequests,m,i,u,v,r,e,d]),S=f.useMemo(()=>nj(j,u),[j,u]),N=cj(j);return f.createElement(f.Fragment,null,x.map(w=>f.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...a})),S.map(w=>f.createElement("link",{key:w,rel:"modulepreload",href:w,...a})),N.map(({key:w,link:k})=>f.createElement("link",{key:w,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function hj(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var fj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{fj&&(window.__reactRouterVersion="7.18.4")}catch{}function mj({basename:e,children:r,useTransitions:a,window:i}){let l=f.useRef();l.current==null&&(l.current=Uy({window:i,v5Compat:!0}));let u=l.current,[d,p]=f.useState({action:u.action,location:u.location}),m=f.useCallback(y=>{a===!1?p(y):f.startTransition(()=>p(y))},[a]);return f.useLayoutEffect(()=>u.listen(m),[u,m]),f.createElement(Ux,{basename:e,children:r,location:d.location,navigationType:d.action,navigator:u,useTransitions:a})}var pt=f.forwardRef(function({onClick:r,discover:a="render",prefetch:i="none",relative:l,reloadDocument:u,replace:d,mask:p,state:m,target:y,to:v,preventScrollReset:j,viewTransition:x,defaultShouldRevalidate:S,...N},w){let{basename:k,navigator:C,useTransitions:E}=f.useContext(un),$=typeof v=="string"&&Vc.test(v),T=Tm(v,k);v=T.to;let F=Sx(v,{relative:l}),M=nn(),B=null;if(p){let me=uo(p,[],M.mask?M.mask.pathname:"/",!0);k!=="/"&&(me.pathname=me.pathname==="/"?k:Cn([k,me.pathname])),B=C.createHref(me)}let[te,Q,_]=oj(i,N),z=vj(v,{replace:d,mask:p,state:m,target:y,preventScrollReset:j,relative:l,viewTransition:x,defaultShouldRevalidate:S,useTransitions:E});function V(me){r&&r(me),me.defaultPrevented||z(me)}let K=!(T.isExternal||u),le=f.createElement("a",{...N,..._,href:(K?B:void 0)||T.absoluteURL||F,onClick:K?V:r,ref:hj(w,Q),target:y,"data-discover":!$&&a==="render"?"true":void 0});return te&&!$?f.createElement(f.Fragment,null,le,f.createElement(lj,{page:F})):le});pt.displayName="Link";var tu=f.forwardRef(function({"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:u,to:d,viewTransition:p,children:m,...y},v){let j=ga(d,{relative:y.relative}),x=nn(),S=f.useContext(ho),{navigator:N,basename:w}=f.useContext(un),k=S!=null&&bj(j)&&p===!0,C=N.encodeLocation?N.encodeLocation(j).pathname:j.pathname,E=x.pathname,$=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;a||(E=E.toLowerCase(),$=$?$.toLowerCase():null,C=C.toLowerCase()),$&&w&&($=Yn($,w)||$);const T=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let F=E===C||!l&&E.startsWith(C)&&E.charAt(T)==="/",M=$!=null&&($===C||!l&&$.startsWith(C)&&$.charAt(C.length)==="/"),B={isActive:F,isPending:M,isTransitioning:k},te=F?r:void 0,Q;typeof i=="function"?Q=i(B):Q=[i,F?"active":null,M?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(B):u;return f.createElement(pt,{...y,"aria-current":te,className:Q,ref:v,style:_,to:d,viewTransition:p},typeof m=="function"?m(B):m)});tu.displayName="NavLink";var pj=f.forwardRef(({discover:e="render",fetcherKey:r,navigate:a,reloadDocument:i,replace:l,state:u,method:d=Oi,action:p,onSubmit:m,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:x,...S},N)=>{let{useTransitions:w}=f.useContext(un),k=jj(),C=wj(p,{relative:y}),E=d.toLowerCase()==="get"?"get":"post",$=typeof p=="string"&&Vc.test(p),T=F=>{if(m&&m(F),F.defaultPrevented)return;F.preventDefault();let M=F.nativeEvent.submitter,B=(M==null?void 0:M.getAttribute("formmethod"))||d,te=()=>k(M||F.currentTarget,{fetcherKey:r,method:B,navigate:a,replace:l,state:u,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:x});w&&a!==!1?f.startTransition(()=>te()):te()};return f.createElement("form",{ref:N,method:E,action:C,onSubmit:i?m:T,...S,"data-discover":!$&&e==="render"?"true":void 0})});pj.displayName="Form";function gj(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Dm(e){let r=f.useContext(bs);return xt(r,gj(e)),r}function vj(e,{target:r,replace:a,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y}={}){let v=yn(),j=nn(),x=ga(e,{relative:d});return f.useCallback(S=>{if(Gx(S,r)){S.preventDefault();let N=a!==void 0?a:zr(j)===zr(x),w=()=>v(e,{replace:N,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m});y?f.startTransition(()=>w()):w()}},[j,v,x,a,i,l,r,e,u,d,p,m,y])}function Ss(e){vn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let r=f.useRef(Ec(e)),a=f.useRef(!1),i=nn(),l=f.useMemo(()=>Yx(i.search,a.current?null:r.current),[i.search]),u=yn(),d=f.useCallback((p,m)=>{const y=Ec(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+y,m)},[u,l]);return[l,d]}var yj=0,xj=()=>`__${String(++yj)}__`;function jj(){let{router:e}=Dm("useSubmit"),{basename:r}=f.useContext(un),a=Fx(),i=e.fetch,l=e.navigate;return f.useCallback(async(u,d={})=>{let{action:p,method:m,encType:y,formData:v,body:j}=Xx(u,r);if(d.navigate===!1){let x=d.fetcherKey||xj();await i(x,a,d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:j,formMethod:d.method||m,formEncType:d.encType||y,flushSync:d.flushSync})}else await l(d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:j,formMethod:d.method||m,formEncType:d.encType||y,replace:d.replace,state:d.state,fromRouteId:a,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,l,r,a])}function wj(e,{relative:r}={}){let{basename:a}=f.useContext(un),i=f.useContext(An);xt(i,"useFormAction must be used inside a RouteContext");let[l]=i.matches.slice(-1),u={...ga(e||".",{relative:r})},d=nn();if(e==null){u.search=d.search;let p=new URLSearchParams(u.search),m=p.getAll("index");if(m.some(v=>v==="")){p.delete("index"),m.filter(j=>j).forEach(j=>p.append("index",j));let v=p.toString();u.search=v?`?${v}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:Cn([a,u.pathname])),zr(u)}function bj(e,{relative:r}={}){let a=f.useContext($m);xt(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Dm("useViewTransitionState"),l=ga(e,{relative:r});if(!a.isTransitioning)return!1;let u=Yn(a.currentLocation.pathname,i)||a.currentLocation.pathname,d=Yn(a.nextLocation.pathname,i)||a.nextLocation.pathname;return Hi(l.pathname,d)!=null||Hi(l.pathname,u)!=null}var kj=jm();const Fr="owner";function Sj(e){const r=e||Fr;return r===Fr?[Fr]:[r,Fr]}function Nj(e){const r=new Map;for(const a of e)for(const i of a)r.has(i.id)||r.set(i.id,i);return[...r.values()].sort((a,i)=>i.createdAt-a.createdAt)}function Cj(e,r){const a=r||Fr,i=(e==null?void 0:e.pendingDomains)??[];return i.includes(a)?a:i.includes(Fr)?Fr:a}const Bm=["0.8","0.7"];function Ej(e){const r=Array.isArray(e)?e.map(i=>i==null?void 0:i.expiresAt).filter(i=>typeof i=="number"):[];if(r.length===0)return{earliest_expiry:null,remaining_seconds:null};const a=Math.min(...r);return{earliest_expiry:new Date(a*1e3).toISOString(),remaining_seconds:Math.max(0,a-Math.floor(Date.now()/1e3))}}class Um extends Error{constructor(a){super("different_account");ia(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Wm(e){return e.grantors??e.approvers}function Aj(e){return e.approvals??1}function Ze(e,r){const a=e??{},i=Array.isArray(a.errors)?a.errors[0]:void 0;return i!=null&&i.message?i.code?`${i.message} (${i.code})`:i.message:i!=null&&i.code?i.code:a.error||a.detail||r}function Tj(e){const r=e==null?void 0:e.pubkeys;return!r||typeof r!="object"||Array.isArray(r)?[]:Object.entries(r).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,i])=>({userId:a,publicKey:i}))}class Ij{constructor(){ia(this,"apiKey",null)}setApiKey(r){this.apiKey=r}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(r,a){return globalThis.fetch(r,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(r,a={}){const i=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":r,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(i.status===409){const u=await i.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Um(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!i.ok){const u=await i.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ze(u,`Login failed: ${i.status}`))}return(await i.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const r=await this.fetch("/api/groups");if(!r.ok)throw new Error(`Failed to fetch groups: ${r.status}`);const a=await r.json();return a.groups??a}async listProfiles(){const r=await this.fetch("/api/profiles");if(!r.ok)throw new Error(`Failed to fetch profiles: ${r.status}`);return(await r.json()).profiles}async getProfile(r){const a=await this.fetch(`/api/profiles/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(r){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Signing failed: ${a.status}`))}return a.json()}async getPending(r){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const i=await a.json();return i.pending??i}async getMyAttestations(r){const a=r?`?status=${encodeURIComponent(r)}`:"",i=await this.fetch(`/api/mandates/mine${a}`);if(!i.ok)throw new Error(`Failed to fetch attestations: ${i.status}`);return((await i.json()).mandates??[]).map(u=>({authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(d=>!(u.attestedDomains??[]).includes(d)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",...Ej(u.mandates??u.attestations)}))}async getDenials(r){const a=new URLSearchParams;r!=null&&r.since&&a.set("since",String(r.since)),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${i}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(r){const a=new URLSearchParams;r!=null&&r.date&&a.set("date",r.date),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const r=await this.fetch("/api/evidence-export"),a=await r.json();if(!r.ok)throw new Error(Ze(a,`Export failed (${r.status})`));const i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:i}}async getLocalAuthorizations(){const r=await this.fetch("/api/evidence/authorizations");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(r){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const r=await this.fetch("/api/evidence/headlines");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const r=await this.fetch("/api/report");if(!r.ok){const a=await r.json().catch(()=>({error:`Report unavailable (${r.status})`}));throw new Error(Ze(a,`Report unavailable (${r.status})`))}return r.json()}async saveReport(r){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:r})});if(!a.ok){const i=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(Ze(i,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const r=await this.fetch("/api/report/recheck",{method:"POST"});if(!r.ok){const a=await r.json().catch(()=>({error:`Recheck failed (${r.status})`}));throw new Error(Ze(a,`Recheck failed (${r.status})`))}return r.json()}async exportReportWithProof(){var l;const r=await this.fetch("/api/report/export");if(!r.ok){const u=await r.json().catch(()=>({error:`Export failed (${r.status})`}));throw new Error(Ze(u,`Export failed (${r.status})`))}const a=await r.text(),i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:i}}async revokeAttestation(r,a){const i=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to revoke"}));throw new Error(Ze(l,`Revoke failed: ${i.status}`))}}async getAttestations(r){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const i=await a.json();return{...i,attestations:i.mandates??i.attestations??[]}}async getGroupById(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(r){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:r})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(u,`Create group failed: ${a.status}`))}const i=await a.json(),l=i.group||i;return{id:l.id,name:l.name,myDomains:l.myDomains||[],isAdmin:!0,ended:i.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const r=await this.fetch("/api/groups/create/preview");if(!r.ok){const a=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(a,`Failed to preview team creation: ${r.status}`))}return r.json()}async getJoinPreview(r){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(r)}`);if(!a.ok){const i=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(Ze(i,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(r){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:r})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(l,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const r=await this.fetch("/api/groups/join",{method:"DELETE"});if(r.status===404)return!1;if(!r.ok){const i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Withdraw failed: ${r.status}`))}return(await r.json()).withdrawn===!0}async inviteToGroup(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/invite`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ze(i,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const r=await this.fetch("/api/groups/me");if(!r.ok)return{group:null,membership:null,pendingRequest:null};const a=await r.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const r=await this.fetch("/api/users");return r.ok?(await r.json()).users??[]:[]}async setPubkey(r){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(Ze(i,`setPubkey failed: ${a.status}`))}}async getPubkey(r){const a=await this.fetch(`/api/users/${encodeURIComponent(r)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/leave`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(Ze(i,`Leave failed: ${a.status}`))}}async getVaultStatus(){const r=await this.fetch("/vault/status");if(!r.ok)throw new Error(`Failed to fetch vault status: ${r.status}`);return r.json()}async getGatewaySettings(){const r=await this.fetch("/api/gateway-settings");if(!r.ok)throw new Error(`Failed to load settings: ${r.status}`);return r.json()}async setGatewaySettings(r){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const r=await this.fetch("/api/archived-mandates");if(!r.ok)throw new Error(`Failed to load archived mandates: ${r.status}`);return(await r.json()).archived}async setMandateArchived(r,a){const i=await this.fetch(`/api/archived-mandates/${encodeURIComponent(r)}`,{method:a?"PUT":"DELETE"});if(!i.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${i.status}`);return(await i.json()).archived}async getLastSeenBlockedAt(){const r=await this.fetch("/api/blocked-seen");if(!r.ok)throw new Error(`Failed to load last-seen: ${r.status}`);return(await r.json()).lastSeenBlockedAt}async markBlockedSeen(r=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const r=await this.fetch("/api/report-seen");if(!r.ok)throw new Error(`Failed to load last-seen report: ${r.status}`);return(await r.json()).lastSeenReportAt}async markReportSeen(r=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const r=await this.fetch("/api/tickets-seen");if(!r.ok)throw new Error(`Failed to load last-seen tickets: ${r.status}`);return(await r.json()).lastSeenTicketsAt}async markTicketsSeen(r=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(r){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(r,a){const i=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to save credential: ${i.status}`)}async testCredential(r){const a=await this.fetch(`/vault/test/${encodeURIComponent(r)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(r){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ze(i,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(r){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ze(i,"AI request failed")}}return a.json()}async aiTest(r){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(r){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const r=await this.fetch("/mcp/health");if(!r.ok)throw new Error(`MCP server unreachable: ${r.status}`);return r.json()}async getAgentContact(){const r=await this.fetch("/mcp/agent-contact");if(!r.ok)throw new Error(`Failed to fetch agent contact: ${r.status}`);return r.json()}async getMcpIntegrations(){const r=await this.fetch("/mcp/integrations");if(!r.ok)throw new Error(`Failed to fetch integrations: ${r.status}`);return r.json()}async getOAuthHealth(r){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(r)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const r=await this.fetch("/mcp/integrations/manifests");if(!r.ok)throw new Error(`Failed to fetch manifests: ${r.status}`);return r.json()}async getLabelManifests(){const{manifests:r,builtins:a}=await this.getIntegrationManifests();return[...r??[],...a??[]]}async discoverScopeField(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/discover/${encodeURIComponent(a)}`);if(!i.ok){const l=await i.json().catch(()=>({error:`Discovery failed: ${i.status}`}));throw new Error(Ze(l,`Discovery failed: ${i.status}`))}return i.json()}async activateIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}/activate`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ze(i,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!i.ok){const l=await i.json().catch(()=>({error:`HTTP ${i.status}`}));throw new Error(Ze(l,`HTTP ${i.status}`))}}async getTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`);if(i.status===404||!i.ok)return null;const l=await i.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(r,a,i){const l=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(Ze(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(r,a){const i=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:r,recipients:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ze(l,`encryptIntent failed: ${i.status}`))}return i.json()}async getToolDisplay(){const r=await this.fetch("/tool-display");if(!r.ok)return{};const a=await r.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return i.ok?Tj(await i.json()):[]}async deleteTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(Ze(l,`deleteTeamProfileConfig failed: ${i.status}`))}}async getIdentityDisclosure(){const r=await this.fetch("/api/users/me/identity-disclosure");if(!r.ok)throw new Error(`Failed to read identity setting: ${r.status}`);return r.json()}async setIdentityDisclosure(r){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:r})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(r,a="pending"){const i=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(r)}${i}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(r,a="pending"){const i=await Promise.all(Sj(r).map(l=>this.getProposals(l,a)));return Nj(i)}async resolveProposal(r,a,i,l){const{noteEncrypted:u,contentHash:d,shownHash:p,note:m,...y}=l??{},v=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:i,...y,...u?{note_encrypted:u}:m?{note:m}:{},...d?{content_hash:d,proposalContentHash:d}:{},...p?{shown_hash:p}:{}})});if(!v.ok){const j=await v.json().catch(()=>({error:"Failed"}));throw new Error(Ze(j,`Failed: ${v.status}`))}return v.json()}async getProposal(r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(r)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ze(l,`getProposal failed: ${a.status}`))}const i=await a.json();return i.proposal??i}async getProposalsForApprover(){const r=await this.fetch("/api/proposals?approver=me");if(!r.ok)throw new Error(`Failed to fetch approver proposals: ${r.status}`);return(await r.json()).proposals??[]}async approveProposal(r,a,i){const l={};a&&(l.content_hash=a,l.proposalContentHash=a),i&&(l.shown_hash=i);const u=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const d=await u.json().catch(()=>({error:"Failed"}));throw new Error(Ze(d,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(r,a,i,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:p,note:m,...y}=a??{};u={...y,...p?{note_encrypted:p}:m?{note:m}:{}}}i&&(u.content_hash=i,u.proposalContentHash=i),l&&(u.shown_hash=l);const d=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!d.ok){const p=await d.json().catch(()=>({error:"Failed"}));throw new Error(Ze(p,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalsCreatedByMe(){const r=await this.fetch("/api/proposals?creator=me");if(r.status===400)return null;if(!r.ok)throw new Error(`Failed to fetch my proposals: ${r.status}`);return(await r.json()).proposals??[]}async withdrawProposal(r,a,i,l){const{noteEncrypted:u,note:d}=a??{},p={...u?{note_encrypted:u}:d?{note:d}:{}};i&&(p.content_hash=i,p.proposalContentHash=i),l&&(p.shown_hash=l);const m=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!m.ok){const y=await m.json().catch(()=>({error:"Failed"}));throw new Error(Ze(y,`withdrawProposal failed: ${m.status}`))}return m.json()}async getProposalPreview(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to store the shown snapshot: ${i.status}`);return i.json()}async getShownSnapshot(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getProposalAttachmentPreview(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getReceiptAttachmentPreview(r,a){const i=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getAttestationIntent(r){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(r){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ze(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(r){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ze(i,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(r,a){const i=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:r,recipientUserIds:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ze(l,`encryptProposalNote failed: ${i.status}`))}return i.json()}async storeApprovedIntent(r,a){const i=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:r,intent:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed"}));throw new Error(Ze(l,`storeApprovedIntent failed: ${i.status}`))}}async listTeamAuthorizations(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var p,m;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(y=>!(l.attestedDomains??l.attested_domains??[]).includes(y)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(y=>y.expiresAt))*1e3).toISOString():null,remaining_seconds:(m=l.mandates)!=null&&m.length?Math.max(0,Math.min(...l.mandates.map(y=>y.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(r){const a=new URLSearchParams;r!=null&&r.before&&a.set("before",r.before),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(r,a){const i=new URLSearchParams;a!=null&&a.before&&i.set("before",a.before),a!=null&&a.profile&&i.set("profile",a.profile),a!=null&&a.limit&&i.set("limit",String(a.limit));const l=i.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const d=await u.json();return{receipts:d.tickets??[],nextBefore:d.nextBefore??null}}async getThread(r){const a=r.sinceDays??7,i=r.status??"pending",l=await this.getMyProposals(r.domain,i);let u=[];if(i==="all"){const d=[],p=new Date;for(let y=0;y<a;y++){const v=new Date(p);v.setUTCDate(p.getUTCDate()-y),d.push(v.toISOString().slice(0,10))}u=(await Promise.all(d.map(y=>this.getMyReceipts({date:y,profile:r.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const r=await this.fetch("/autostart");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async setAutostart(r){const a=await this.fetch("/autostart",{method:r?"POST":"DELETE"});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.message||`HTTP ${a.status}`)}}async getAsPairing(){const r=await this.fetch("/as-pairing");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getSkippedCommitments(){const r=await this.fetch("/skipped-commitments");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getMyPendingProposals(){const r=await this.fetch("/my-pending-proposals");return r.ok?(await r.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(r){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const r=await this.fetch("/resync-gates",{method:"POST"});if(!r.ok)throw new Error(`Failed to resync gates: ${r.status}`)}async getEnrichedAuthorizations(){const r=await this.fetch("/active-authorizations");if(!r.ok)throw new Error(`Failed to fetch authorizations: ${r.status}`);return(await r.json()).authorizations??[]}async pushGateContent(r){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(Ze(i,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const r=await this.fetch("/agent-brief/context");if(!r.ok)throw new Error(`Failed to fetch agent context: ${r.status}`);return(await r.json()).content}async saveAgentContext(r){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(Ze(i,`Save failed: ${a.status}`))}}async aiChat(r){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:Ze(i,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const r=await this.fetch("/ai-prompts");if(!r.ok)throw new Error(`Failed to load AI prompts: ${r.status}`);return r.json()}async setAIPrompt(r,a){const i=await this.fetch(`/ai-prompts/${r}`,{method:"PUT",body:JSON.stringify({value:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Save failed"}));throw new Error(Ze(l,`Save failed: ${i.status}`))}}}const P=new Ij,Hm=f.createContext(null);function Rj({children:e}){const[r,a]=f.useState(null),[i,l]=f.useState("personal"),[u,d]=f.useState(null),[p,m]=f.useState(""),[y,v]=f.useState(null),[j,x]=f.useState(null),[S,N]=f.useState(null),[w,k]=f.useState(!1),[C,E]=f.useState(""),$=f.useRef(!1),T=f.useRef(null),F=f.useCallback(async()=>{if($.current)try{const z=await P.getMyTeam();if(N(z.pendingRequest),z.group&&z.membership){const{group:V,membership:K}=z;v(V),x(K),l("team"),d(V);const le=T.current??K.domains[0]??"owner";m(le)}else v(null),x(null),l("personal")}catch{}},[]);f.useEffect(()=>{const z=()=>{document.visibilityState==="visible"&&F()};return document.addEventListener("visibilitychange",z),()=>document.removeEventListener("visibilitychange",z)},[F]),f.useEffect(()=>{fetch("/health").then(z=>z.json()).then(z=>{var V;((V=z.session)==null?void 0:V.lockedReason)==="as-url-changed"&&E(`Authority Server changed to ${z.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const M=f.useCallback(async(z,V={})=>{k(!0),E("");try{P.setApiKey(z),$.current=!0;const K=await P.login(z,V);a(K),T.current=K.id;const le=await P.getGroups(),me=le.find(we=>we.isPersonal)??le[0]??null;d(me),m("owner"),await F()}catch(K){throw P.clearApiKey(),$.current=!1,E(K instanceof Error?K.message:"Login failed"),K}finally{k(!1)}},[F]),B=f.useCallback(async()=>{await P.logout(),P.clearApiKey(),$.current=!1,T.current=null,a(null),d(null),m(""),v(null),x(null),N(null),l("personal"),E("")},[]),te=f.useCallback(z=>{P.clearApiKey(),$.current=!1,T.current=null,a(null),d(null),m(""),v(null),x(null),N(null),l("personal"),E(z??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Q=f.useCallback(()=>E(""),[]),_=f.useCallback((z,V)=>{d(z),m(V)},[]);return n.jsx(Hm.Provider,{value:{user:r,mode:i,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:y,activeMembership:j,pendingRequest:S,isLoading:w,error:C,login:M,logout:B,clearError:Q,handleSessionLocked:te,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:_,refreshGroups:F},children:e})}function Nt(){const e=f.useContext(Hm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const $j={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},Pj=Object.keys($j),Vm=f.createContext(null);function _j({children:e}){const{user:r}=Nt(),a=f.useRef(null),[i,l]=f.useState(!1),u=f.useRef(new Map),d=f.useCallback((p,m)=>{const y=u.current;return y.has(p)||y.set(p,new Set),y.get(p).add(m),()=>{var v;(v=y.get(p))==null||v.delete(m)}},[]);return f.useEffect(()=>{if(!r){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=P.getApiKey();if(!p)return;const m=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=m,m.onopen=()=>l(!0),m.onerror=()=>l(!1);for(const y of Pj)m.addEventListener(y,v=>{let j;try{j=JSON.parse(v.data)}catch{j=null}const x=u.current.get(y);if(x)for(const S of x)try{S(j)}catch(N){console.error(`[EventSource] handler for "${y}" threw:`,N)}});return()=>{m.close(),a.current=null,l(!1)}},[r]),n.jsx(Vm.Provider,{value:{connected:i,addListener:d},children:e})}function Ke(e,r){const a=f.useContext(Vm);if(!a)return;const{addListener:i}=a;f.useEffect(()=>i(e,r),[e,r,i])}const fa="suveren-theme",uf="hap-theme";function Ii(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const r=localStorage.getItem(uf);r!==null&&localStorage.getItem(fa)===null&&localStorage.setItem(fa,r),r!==null&&localStorage.removeItem(uf)})();function qm(){const[e,r]=f.useState(()=>{const u=localStorage.getItem(fa);return u==="light"||u==="dark"?u:"system"}),[a,i]=f.useState(()=>Ii(e));f.useEffect(()=>{const u=document.documentElement,d=Ii(e);u.setAttribute("data-theme",d),e==="system"?localStorage.removeItem(fa):localStorage.setItem(fa,e),i(Ii(e))},[e]),f.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>i(Ii("system"));return u.addEventListener("change",d),()=>u.removeEventListener("change",d)},[e]);const l=f.useCallback(()=>{r(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const Lj=300*1e3,Mj=2e3;function nu(){const[e,r]=f.useState(!1),[a,i]=f.useState("docker"),[l,u]=f.useState(""),[d,p]=f.useState(null),[m,y]=f.useState(!1),[v,j]=f.useState(!1),[x,S]=f.useState(!1),N=f.useRef(null);return f.useEffect(()=>{let w=!1;const k=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(T=>T.json()).then(T=>{w||(T.installMethod&&i(T.installMethod),typeof T.latestVersion<"u"&&p(T.latestVersion),T.updateAvailable&&r(!0),T.version&&(u(T.version),N.current===null?N.current=T.version:T.version!==N.current&&T.version!=="dev"&&y(!0)))}).catch(()=>{})};k(!0);const C=setInterval(()=>k(!1),x?Mj:Lj),E=()=>{document.visibilityState==="visible"&&k(!1)};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",E),()=>{w=!0,clearInterval(C),document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",E)}},[x]),{updateAvailable:e&&!v,installMethod:a,version:l,latestVersion:d,serverRestarted:m,startFastPolling:()=>S(!0),dismiss:()=>j(!0)}}function Fj(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Oj(){const[e,r]=f.useState({managed:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(Fj(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function zj({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Dj(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const df={system:"◑",light:"☀",dark:"☾"};function ru({onMenuToggle:e}){const{user:r,logout:a,mode:i,activeTeam:l}=Nt(),{theme:u,toggle:d}=qm(),{version:p,updateAvailable:m,latestVersion:y}=nu(),{managed:v}=Oj(),j=Dj(p),x=i==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(zj,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),j&&n.jsxs("span",{className:"gw-version",title:m&&y?`Running v${j} — v${y} is available`:"Running gateway version","data-stale":m?"true":void 0,children:["v",j,m&&y?` → ${y}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:r?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":v?"true":void 0,title:v?`${x} — set by your IT`:x,children:[x,v&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:r.name})}),n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:df[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:df[u]})}),r&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function su(e,r){var a;if((a=r==null?void 0:r.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Km(e){return e==="expired"||e==="revoked"}function Gm(e,r){var a;return!!((a=r==null?void 0:r.archivedSet)!=null&&a.has(e.authorization_id))&&Km(su(e,r))}function Vi(e,r){return Gm(e,r)?"archived":su(e,r)}function Ym(e,r){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const i of e)a[Vi(i,r)].push(i);return a}function Bj(e,r){return r==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ht(e,r,a){const i=f.useRef(e);i.current=e,f.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",d=()=>{u()&&i.current()},p=()=>{l===null&&(l=setInterval(d,r))},m=()=>{l!==null&&(clearInterval(l),l=null)},y=()=>{u()?(i.current(),p()):m()};return u()&&(i.current(),p()),document.addEventListener("visibilitychange",y),()=>{m(),document.removeEventListener("visibilitychange",y)}},[r,a])}function au(){const[e,r]=f.useState(!1);return f.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(d.simulation===!0)}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function Uj(e,r){const a=e.simulation;return a?(((r==null?void 0:r[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function qi(e){return!!(e!=null&&e.simulation)}function Wj(e,r){return Jm(e,e.modeLabels,r)}function Hj(e,r){return Jm(e,e.modeNotes,r)}function Jm(e,r,a){const i=e.simulation;if(!r||!i)return;const l=((a==null?void 0:a[i.field])??"").trim().toLowerCase()||i.default.trim().toLowerCase(),u=r[l];if(u===void 0)return;if(typeof u=="string")return u;const d=e.adapterField,p=d?((a==null?void 0:a[d])??"").trim().toLowerCase():"";return p?u[p]:void 0}function Ki(e,r){var a;return r&&(!qi(e.manifest)||((a=e.integration)==null?void 0:a.paused)==="simulation")}function Vj(e,r=!1){var i;const a=[];for(const l of e)Ki(l,r)||(l.state==="error"?a.push({label:"Integration error",detail:(i=l.integration)!=null&&i.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(qi(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function qj(e){const r=e.filter(a=>a.state==="paused");return r.length===0?null:{count:r.length,namesText:r.map(a=>a.manifest.name).join(", ")}}const Qm=f.createContext(null),Kj=3e4,Gj=5e3,Yj=3e5;function Jj(e,r,a){return r===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function Qj({children:e}){const[r,a]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),i=f.useRef(null),l=f.useCallback(async()=>{let v=!1;const[j,x]=await Promise.all([P.getIntegrationManifests().catch(()=>(v=!0,{manifests:[]})),P.getMcpHealth().catch(()=>null)]);a(N=>({...N,manifests:j.manifests,integrations:(x==null?void 0:x.integrations)??N.integrations,activeSessions:(x==null?void 0:x.activeSessions)??N.activeSessions,mcpServerUp:!!x,manifestsError:v,fetchCount:N.fetchCount+1}));const S=j.manifests.filter(N=>N.oauth);if(S.length>0){const N=await Promise.all(S.map(async w=>[w.id,await P.getOAuthHealth(w.id)]));a(w=>({...w,authHealth:Object.fromEntries(N)}))}},[]),u=r.fetchCount>0&&r.manifests.some(v=>{const j=r.integrations.find(x=>x.id===v.id);return j&&!j.running&&!j.paused});Ke("integration-changed",l),Ht(l,u?Gj:Yj);const d=f.useMemo(()=>{const v=new Map(r.integrations.map(S=>[S.id,S])),j=Date.now();u&&i.current===null?i.current=j:u||(i.current=null);const x=i.current!==null&&j-i.current<Kj;return r.manifests.map(S=>{const N=v.get(S.id),w=Jj(N,r.fetchCount,x),k=r.authHealth[S.id];return{id:S.id,manifest:S,integration:N,state:w,authStatus:k==null?void 0:k.status,authAccount:k==null?void 0:k.account,authError:k==null?void 0:k.error}})},[r,u]),p=au(),m=f.useMemo(()=>d.filter(v=>!Ki(v,p)&&(v.state==="not-running"||v.state==="error"||v.authStatus==="failed")).length,[d,p]),y={loading:r.fetchCount===0,mcpServerUp:r.mcpServerUp,manifestsError:r.manifestsError,entries:d,attentionCount:m,activeSessions:r.activeSessions,refresh:l};return n.jsx(Qm.Provider,{value:y,children:e})}function iu(){const e=f.useContext(Qm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const hf=40;function Vt(e,r){const a=e.lastIndexOf("/"),i=a>=0?e.slice(a+1):e,l=i.indexOf("@"),u=l>=0?i.slice(0,l):i;return r?r.slice(0,hf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,hf)}function En(e){const r=e.lastIndexOf("/"),a=r>=0?e.slice(r+1):e,i=a.indexOf("@");return(i>=0?a.slice(0,i):a).toLowerCase()}function jr(e,r){const a=En(e),i=Jn(e),l=Vt(e,r==null?void 0:r.name);return{icon:i,name:l,testSetup:a==="delegation"}}function po(e){return e.startsWith("setup__")}const Xj={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup",invoicing:"invoicing","master-data":"masterData"};function Jn(e){return Xj[En(e)]??"unknown"}function ff(e){const r=e.indexOf("@");return r>=0?e.slice(r+1):""}function Qn(e,r){const a=En(e),i=r.filter(l=>En(l.id)===a).sort((l,u)=>ff(u.id).localeCompare(ff(l.id),void 0,{numeric:!0}))[0];return Vt(e,i==null?void 0:i.name)}function Ac(e,r){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==r.trim().toLowerCase():!1}function Xm(e){return e&&e.trim()?e.trim():null}function Zm(e,r){return r===null||En(e)===r}let hc=null;function ep(){return hc||(hc=P.listProfiles().catch(()=>[])),hc}function On(){const[e,r]=f.useState([]);return f.useEffect(()=>{let a=!0;return ep().then(i=>{a&&r(i)}),()=>{a=!1}},[]),e}function Zj(e){const r=On();return Qn(e,r)}const ew={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),invoicing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2-1.3-2 1.3-2-1.3-2 1.3-2-1.3L6 21z"}),n.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),masterData:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.5 7.5h15a1.5 1.5 0 0 1 1.5 1.5v9.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18.5V9a1.5 1.5 0 0 1 1.5-1.5z"}),n.jsx("path",{d:"M6 7.5V5h6v2.5M7 12h10M7 16h6"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function Dr({icon:e,className:r}){return n.jsx("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:ew[e]})}function go(){return n.jsxs("svg",{className:"ob-i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]})}function tp(){return n.jsx("svg",{className:"ob-i ob-chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function At({tag:e,parts:r,className:a,profileId:i}){return n.jsxs("div",{className:`ob-type${a?` ${a}`:""}`,children:[e&&n.jsx("span",{className:"ob-tag",children:e}),r.filter(Boolean).map((l,u)=>n.jsxs("span",{className:u===0&&i?"ob-area":void 0,children:[u===0&&i&&n.jsx(Dr,{icon:Jn(i)}),l]},u))]})}function Gt({title:e,summary:r,children:a,open:i,testId:l,attrs:u,onToggle:d}){return n.jsxs("details",{className:"ob-fold","data-testid":l,...u,open:i,onToggle:d?p=>d(p.currentTarget.open):void 0,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:e}),r!=null&&n.jsx("span",{className:"one",children:r}),n.jsx(tp,{})]}),n.jsx("div",{className:"ob-fold-body",children:a})]})}function va(){const e=f.useRef(null);return f.useCallback(r=>{var i;if((i=e.current)==null||i.call(e),e.current=null,!r)return;const a=l=>{var d;const u=l.target;!u.open||!((d=u.classList)!=null&&d.contains("ob-fold"))||r.querySelectorAll("details.ob-fold[open]").forEach(p=>{p!==u&&(p.open=!1)})};r.addEventListener("toggle",a,!0),e.current=()=>r.removeEventListener("toggle",a,!0)},[])}const tw={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},vs=e=>tw[e]??e,nw={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function rw(e){return(e&&nw[e])??{chip:"Blocked",sev:"info"}}function sw(e){const r=vs(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",r]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",r," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",r," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",r," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",r," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function aw(e,r){const a=Math.max(0,(r-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const i=Math.floor(a/86400);return i===1?"Yesterday":`${i} days ago`}const iw=5,ow=1440*60*1e3,lw=7;function cw(e,r){const a=r-lw*ow;return{recent:e.filter(i=>i.ts>=a),all:e}}function uw(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=On(),p=f.useCallback(()=>{P.getDenials({limit:200}).then(({records:x})=>{r(x),i(!1)}).catch(()=>i(!0)),P.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(f.useEffect(()=>{p()},[p]),Ht(p,12e4),Ke("denial-recorded",p),f.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",p),()=>window.removeEventListener("suveren:blocked-seen-changed",p)),[p]),a||e===null||l===null)return null;const{all:m}=cw(e,Date.now()),y=m.filter(x=>x.ts>l);if(y.length===0)return null;const v=y.slice(0,iw),j=(x,S)=>{const N=x.profile?Qn(x.profile,d):vs(x.integrationId),w=rw(x.reason);return n.jsxs(pt,{className:"ob-card dash-row",to:"/blocked","data-testid":"dash-blocked",children:[n.jsx(At,{tag:"Blocked",className:"obj-line",profileId:x.profile??void 0,parts:[N,`via ${vs(x.integrationId)}`,op(x.ts,Date.now())]}),n.jsx("span",{className:"ob-title",children:x.reason?sw(x):lp(x)}),n.jsxs("span",{className:"ob-one ob-check-x",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",n.jsx("b",{children:cp(x)})," ",n.jsx("span",{className:"ob-quiet-inline",children:x.reason?w.chip:ip(x).sentence})]})]},`${x.ts}-${S}`)};return n.jsxs("section",{className:"dash-sec","aria-label":"Blocked — new since you looked","data-testid":"dash-blocked-sec",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Blocked — new since you looked"}),n.jsx("span",{className:"pill-count",children:y.length})]}),n.jsx("div",{className:"dash-rows",children:v.map(j)}),y.length>v.length&&n.jsx(pt,{className:"ob-btn dash-btn",to:"/blocked",children:"All blocked"})]})}function vo(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const np=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function zt(e){const r=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return r.charAt(0).toUpperCase()+r.slice(1)}function Fn(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function dw(e){const{integrationId:r,toolName:a}=Fn(e);return r?`${r} · ${a}`:a}function wr(e,r){const a=r==null?void 0:r.find(i=>i.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function hw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
52
+ `)||e.length>120)?"markdown":"text"}function rp(e,r){var d,p;const a=(r==null?void 0:r.approvalView)??{},i=((d=r==null?void 0:r.inputSchema)==null?void 0:d.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(i),...Object.keys(e)])],u=[];for(const m of l){if(!(m in e)||np.has(m)||m===(r==null?void 0:r.aiTextArg))continue;const y=e[m],v=a[m]??{},j=v.kind??hw(y),x={key:m,label:v.label??zt(m),kind:j,value:y,hint:(p=i[m])==null?void 0:p.description};j==="money"&&v.currencyArg&&typeof e[v.currencyArg]=="string"&&(x.currency=e[v.currencyArg]),j==="profile"&&typeof y=="string"&&(x.profileRef=y),(j==="profile-limits"||j==="profile-scope")&&v.profileArg&&typeof e[v.profileArg]=="string"&&(x.profileRef=e[v.profileArg]),u.push(x)}return u}function mf(e,r){const a=r==null?void 0:r.aiTextArg;if(!a)return;const i=e[a];return typeof i=="string"&&i.length>0?i:void 0}function pf(e,r){var i,l;const a=(l=(i=r==null?void 0:r.scopeSchema)==null?void 0:i.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function sp(e,r,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const i=a==="limits"?r==null?void 0:r.boundsSchema:r==null?void 0:r.scopeSchema,l=(i==null?void 0:i.fields)??{},u=[...new Set([...(i==null?void 0:i.keyOrder)??[],...Object.keys(e)])],d=[];for(const p of u){if(p==="profile"||!(p in e))continue;const m=e[p],y=l[p],v=vo(y==null?void 0:y.unit),j=Array.isArray(m)?m.join(", "):String(m);d.push({key:p,label:(y==null?void 0:y.displayName)??zt(p),value:v?`${j} ${v}`:j,hint:y==null?void 0:y.description,unknown:r?!y:void 0})}return d}function ya(e){return e.kind??"read"}function fw(e,r){var u,d,p,m;if(!r)return"";if(!e)return r;const a=(d=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:d[r];if(a!=null&&a.displayName)return a.displayName;const i=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((m=i[r])!=null&&m.displayName)return i[r].displayName;const l=Object.values(i).find(y=>y.boundType&&"of"in y.boundType&&y.boundType.of===r);return l!=null&&l.displayName?l.displayName:r}const mw={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",check:"Blocked — a check failed",read:"Read blocked"},pw={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",check:"Nothing ran and no approval was asked for. The check reads the system's own data — correct the request or that data.",read:"Nothing was read."};function gw(e){const r=e.includes("_")?e.replace(/_/g," "):e;return r.charAt(0).toLowerCase()+r.slice(1)}function gf(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function vw(e,r){const a=ya(e),i=gf(e.value),l=gf(e.limit);switch(a){case"bound":return i&&l?`${r||"Value"} ${i} is above the limit ${l}.`:e.detail;case"scope":return i?`"${i}" is not within your mandate's ${r?gw(r):"scope"}.`:e.detail;case"cumulative":return i&&l?`${i} of ${l} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function ap(e,r){if(e.mandateId){const a=r==null?void 0:r[e.mandateId];if(a)return a}return e.mandateTitle}function yw(e,r){const a=ap(e,r);if(a){const i=[{text:` · mandate "${a}"`}];return e.mandateId&&i.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),i}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function xw(e,r){const a=ya(e),i=vs(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${i} · ${e.tool}`},...yw(e,r),{text:` · ${l}${u}`}]}function ip(e,r,a){const i=ya(e),l=fw(r,e.field);return{title:mw[i],sentence:vw(e,l),sourceLine:xw(e,a),whatYouCanDo:pw[i]}}function jw(e,r){const a=new Date(r);return a.setHours(0,0,0,0),e.filter(i=>i.ts>=a.getTime()).length}function ww(e,r){return e.filter(a=>a.ts>r).length}const bw=1440*60*1e3;function op(e,r){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),i=new Date(r);i.setHours(0,0,0,0);const l=i.getTime();return e>=l?`Today · ${a}`:e>=l-bw?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function lp(e){var i;const r=zt(Fn(e.tool).toolName),a=(i=e.target)==null?void 0:i.trim();return a?`${r} · ${a}`:r}const kw={bound:"Above your limit:",scope:"Outside your mandate:",cumulative:"Limit reached:",simulation:"Simulation mode:",not_authorized:"Not authorized:",check:"A check failed:",read:"Read blocked:"};function cp(e){return kw[ya(e)]}function Sw(e){return e.who==="authority-server"?"Refused by the Authority Server before anything ran.":"Refused by this gateway before anything ran."}function up(e,r){return!!e&&e.savedAt*1e3>r}function Nw(e){const r=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=r?r[1].replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function Cw(e){var r,a;return{verified:((a=(r=e.proof)==null?void 0:r.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(i=>i.status==="unverifiable").length}}const vf=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),yf=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Gi(e,r){const a=e==null?void 0:e.window;return a?{text:`Covers ${vf(a.start,r)} → ${vf(a.end,r)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${yf(a.start,r)} to ${yf(a.end,r)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function dp(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((r-e*1e3)/864e5);if(new Date(r).toDateString()===i.toDateString())return`today ${l}`;const p=`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}function hp(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function ys(e,r){var m,y,v;const{integrationId:a,toolName:i}=hp(e.action),l=r.find(j=>j.id===a),u=(y=(m=l==null?void 0:l.toolGating)==null?void 0:m.overrides)==null?void 0:y[i];if(u!=null&&u.actionLabel)return u.actionLabel;const d=Vt(e.profileId),p=e.actionType??((v=e.executionContext)==null?void 0:v.action_type);return typeof p=="string"&&p?`${d} · ${p}`:`${d} · ${i}`}function Ew(e,r){var l;const a=(l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields;if(!a)return"";const i=[];for(const[u,d]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(d??"").trim();p&&i.push(p.split(",").map(m=>m.trim()).filter(Boolean).join(", "))}return i.join(" · ")}function Aw(e,r){var l,u;if(!e)return"";const a=((l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields)??{},i=[];for(const[d,p]of Object.entries(e)){if(d==="action_type")continue;const m=String(p??"").trim();if(!m)continue;const y=((u=a[d])==null?void 0:u.displayName)??d;i.push(`${y} ${m.split(",").map(v=>v.trim()).filter(Boolean).join(", ")}`)}return i.join(" · ")}function xf(e){return e.appliesTo}function fp(e,r,a,i){var y,v,j;const l=(y=a==null?void 0:a.boundsSchema)==null?void 0:y.fields;if(!l||!r)return;const u=e.actionType??(typeof((v=e.executionContext)==null?void 0:v.action_type)=="string"?e.executionContext.action_type:void 0),d=Object.entries(l).filter(([x,S])=>{if(!(x in r))return!1;const N=S.boundType;if(!N||N.kind!=="cumulative_sum"&&N.kind!=="cumulative_count"||N.window!==i)return!1;const w=xf(S);return!w||!u||w.includes(u)}),m=(u?d.find(([,x])=>{var S;return(S=xf(x))==null?void 0:S.includes(u)}):void 0)??(d.length===1?d[0]:void 0);return m?{key:m[0],isAmount:((j=m[1].boundType)==null?void 0:j.kind)==="cumulative_sum"}:void 0}function ou(e,r,a,i){var p;const l=(p=e.cumulativeState)==null?void 0:p[i];if(!l)return null;const u=fp(e,r,a,i),d=u?Number(r==null?void 0:r[u.key]):NaN;return u&&Number.isFinite(d)?{used:u.isAmount?l.amount:l.count,limit:d}:{count:l.count}}function Tw(e,r,a){const i=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:d}of i){const p=ou(e,r,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${d}`:`${p.count} ${p.count===1?"call":"calls"} ${d}`)}return l.join(" · ")}function Iw(e,r,a){var u;const i=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!r||!i)return[];const l=[];for(const[d,p]of Object.entries(i)){const m=p.boundType;if(!m||m.kind!=="per_transaction")continue;const y=m.of;if(!(y in e)||!(d in r))continue;const v=Number(e[y]),j=Number(r[d]);if(!Number.isFinite(v)||!Number.isFinite(j))continue;const x=vo(p.unit),S=p.displayName??zt(y),N=w=>x?`${w.toLocaleString()} ${x}`:w.toLocaleString();l.push({key:d,label:S,ok:v<=j,valueText:N(v),limitText:N(j)})}return l}function Yi(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Rw(e){const r=Vt(e),a=e.split("@")[1];return a?`${r}@${a}`:r}const $w=["automatic","approved","all"];function Pw(e){return e==="automatic"||e==="approved"?e:"all"}function Ji(e,r){return r==="all"?!0:r==="approved"?Yi(e):!Yi(e)}function Br(e,r){return Qn(e,r)}function yo(e,r){return wr(hp(e).integrationId,r)}function mp(e,r){const a=Math.max(0,Math.floor((r-e)/1e3));if(a<60)return"just now";const i=Math.floor(a/60);if(i<60)return`${i} min`;const l=Math.floor(i/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}const _w=24*3600;function pp(e,r,a){const i=e-Math.floor(r/1e3);return i<=0||i>_w?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function lu(e){return e.replace(/-/g,"").slice(0,8)}function Lw(e,r){const a=new Date(e),i=new Date(r);return a.getFullYear()===i.getFullYear()&&a.getMonth()===i.getMonth()&&a.getDate()===i.getDate()}function Ur(e,r){return Lw(e*1e3,r)}function Qi(e,r){return e.timestamp*1e3>r}function Mw(e,r){var l;const a=new Map;for(const u of e){if(Yi(u))continue;const d=ys(u,r.manifests),m=`${u.authorizationId??u.profileId}|${u.action}`;let y=a.get(m);y||(y={key:m,area:Br(u.profileId,r.catalog),system:yo(u.action,r.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=r.titles)==null?void 0:l[u.authorizationId]:void 0,label:d,count:0,newCount:0,latestSec:0,tickets:[]},a.set(m,y)),y.count+=1,Qi(u,r.lastSeenMs)&&(y.newCount+=1),y.latestSec=Math.max(y.latestSec,u.timestamp),y.tickets.push(u)}const i=[...a.values()];for(const u of i)u.tickets.sort((d,p)=>p.timestamp-d.timestamp);return i.sort((u,d)=>+(d.newCount>0)-+(u.newCount>0)||d.latestSec-u.latestSec)}function Fw(e,r){var l,u,d,p,m;const a=new Map;for(const y of e){if(!y.authorizationId||!Ur(y.timestamp,r.nowMs))continue;const v=a.get(y.authorizationId);(!v||y.timestamp>v.timestamp||y.timestamp===v.timestamp&&(((u=(l=y.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=v.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&a.set(y.authorizationId,y)}const i=[];for(const[y,v]of a){const j=ou(v,r.boundsOf(y)??v.limits,r.profileOf(v.profileId),"daily"),x={authorizationId:y,area:Br(v.profileId,r.catalog),system:yo(v.action,r.manifests),profileId:v.profileId,mandateTitle:(m=r.titles)==null?void 0:m[y]};j&&"limit"in j?i.push({...x,used:j.used,limit:j.limit,ratio:j.limit>0?j.used/j.limit:0}):i.push({...x,used:j?j.count:1,ratio:0})}return i.sort((y,v)=>v.ratio-y.ratio||y.area.localeCompare(v.area))}function Ow(e){return e.ratio>=.8}function ma(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Ur(e,r)?`today ${l}`:`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}function zw(e,r){return e==="approve"?r?"Signing":"Approving":e==="reject"?"Rejecting":"Sending"}function Dw(e,r){return e==="approve"?r?"Signed":"Approved":e==="reject"?"Rejected":"Sent back to the AI"}function Bw(e,r){return r!=null&&r.detail?r.detail:e==="approve"&&(r!=null&&r.ticketId)?`Ticket ${lu(r.ticketId)}`:"Recorded"}function gp(e){if(!e||typeof e!="object")return;const r=e,a=r.id??r.receiptId??r.ticketId;return typeof a=="string"&&a.length>0?a:void 0}function Uw(e,r){const a=e.indexOf(r),i=e.filter(l=>l!==r);return i.length===0?null:a<0?i[0]:i[Math.min(a,i.length-1)]}function Ww(e,r){if(!r)return null;const a=e.indexOf(r);return a<0?null:`${a+1} of ${e.length}`}function Hw(e,r){const a=Ww(e,r);return a?`Next · ${a}`:null}const Vw=[{id:"me",label:"For me"},{id:"others",label:"Others"},{id:"all",label:"All"}];function qw(e){return e==="ArrowLeft"?"prev":e==="ArrowRight"?"next":e==="Escape"?"list":null}const Tc="suveren:approvals-changed";function jf(e=typeof window<"u"?window:void 0){e==null||e.dispatchEvent(new Event(Tc))}const Kw={dashboard:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.4"}),n.jsx("rect",{x:"13.5",y:"13.5",width:"7",height:"7",rx:"1.4"})]}),approvals:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 13.5 6.2 5h11.6l2.2 8.5V19H4z"}),n.jsx("path",{d:"M4 13.5h5l1 2.2h4l1-2.2h5"})]}),mandates:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4"}),n.jsx("path",{d:"M9 12h7M8.8 17c1.2-2 2.2 1 3.4-.8s1.6-.2 3 .1"})]}),tickets:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 8a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2a2 2 0 0 0 0 4v2a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-2a2 2 0 0 0 0-4z"}),n.jsx("path",{d:"M14.5 7.5v9",strokeDasharray:"1.8 2"})]}),reports:n.jsx("path",{d:"M4 20h16M7 20v-6M12 20V5M17 20v-9"}),blocked:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"8.5"}),n.jsx("path",{d:"M6 6l12 12"})]}),team:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),brief:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 3.5h14v17H5z"}),n.jsx("path",{d:"M8.5 8.5h7M8.5 12h7M8.5 15.5h4"})]}),integrations:n.jsx("path",{d:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4"}),settings:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h9M17 7h3M4 17h3M11 17h9"}),n.jsx("circle",{cx:"15",cy:"7",r:"2"}),n.jsx("circle",{cx:"9",cy:"17",r:"2"})]})};function Ic({name:e}){return n.jsx("svg",{className:"nav-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Kw[e]})}const Gw=[{to:"/",icon:"dashboard",label:"Dashboard",group:"top"},{to:"/approvals",icon:"approvals",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"mandates",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"tickets",label:"Tickets",group:"core"},{to:"/reports",icon:"reports",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"team",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"brief",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"integrations",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"settings",label:"Settings",statusKey:"assistant",group:"setup"}];function Yw(){const{activeDomain:e}=Nt(),[r,a]=f.useState({}),i=f.useCallback(async()=>{try{const[l,u,d,p,m,y,v,j,x,S]=await Promise.all([P.getCredential("ai-config").catch(()=>null),P.getMyAttestations().catch(()=>null),P.getMyProposals(e).catch(()=>null),P.getProposalsForApprover().catch(()=>null),P.getAgentContext().catch(()=>""),P.getArchivedMandates().catch(()=>[]),P.getDenials({limit:200}).catch(()=>null),P.getLastSeenBlockedAt().catch(()=>0),P.getReport().catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),N={};if(l&&!l.configured&&(N.assistant=1),u){const E=Ym(u,{archivedSet:new Set(y)}).expired.length;E>0&&(N.authorizations=E)}const w=(d==null?void 0:d.length)??0,k=(p==null?void 0:p.length)??0,C=w+k;if(C>0&&(N.proposals=C),(!m||!m.trim())&&(N.brief=1),v){const E=ww(v.records,j);E>0&&(N.blocked=E)}up(x==null?void 0:x.report,S)&&(N.report=1),a(N)}catch{}},[e]);return Ke("attestation-changed",i),Ke("proposal-added",i),Ke("proposal-resolved",i),Ke("proposal-approved",i),Ke("proposal-rejected",i),Ke("team-membership-changed",i),Ke("denial-recorded",i),Ke("report-written",i),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",i),()=>window.removeEventListener("suveren:archived-changed",i)),[i]),f.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",i),window.addEventListener("suveren:report-seen-changed",i),window.addEventListener(Tc,i),()=>{window.removeEventListener(Tc,i),window.removeEventListener("suveren:blocked-seen-changed",i),window.removeEventListener("suveren:report-seen-changed",i)}),[i]),Ht(i,3e5,e),r}const Jw={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"var(--elevation-2)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function Qw(){const{mode:e,activeTeam:r}=Nt(),a=Yw(),{attentionCount:i}=iu(),l={...a};i>0&&(l.integrations=i);const u=Gw.filter(v=>!v.teamOnly||e==="team"),d=f.useRef(null),[p,m]=f.useState(null),y=nn();return f.useEffect(()=>{if(d.current===null){d.current=e;return}d.current!==e&&(e==="team"&&r?m(`You are now acting in team context — ${r.name}`):e==="personal"&&m("You have left the team — back to personal context"),d.current=e)},[e,r]),f.useEffect(()=>{m(null)},[y.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(v=>{const j=u.filter(x=>(x.group??"setup")===v);return j.length===0?null:n.jsxs("div",{className:`sidebar-${v}`,children:[v==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),v==="setup"&&n.jsxs("span",{className:`sidebar-setup-rail${j.some(x=>y.pathname.startsWith(x.to))?" is-active":""}`,"aria-hidden":"true",children:[n.jsx(Ic,{name:"settings"}),j.some(x=>x.statusKey&&l[x.statusKey])&&n.jsx("span",{className:"nav-dot"})]}),n.jsx("ul",{className:"sidebar-nav",children:j.map(x=>{const S=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(tu,{to:x.to,end:x.to==="/",className:({isActive:N})=>`sidebar-item${N?" active":""}`,children:[n.jsx("span",{className:"icon",children:n.jsx(Ic,{name:x.icon})}),n.jsx("span",{className:"sidebar-label",children:x.label}),S?x.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${x.statusKey}`,children:"New"}):n.jsx("span",{className:`nav-count${x.quietCount||v==="setup"?" nav-count-setup":""}`,"data-testid":`nav-count-${x.statusKey}`,title:x.statusKey==="authorizations"?"Expired mandates":void 0,children:S}):null]})},x.to)})})]},v)}),p&&n.jsx("div",{style:Jw,role:"status","aria-live":"polite",children:p})]})}const fc="suveren:updatedTo";function Xw(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Zw="Updates for this gateway come from your company's IT — no action needed here.";function e0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const t0="Download the new installer and run it. Your settings and mandates stay.";function n0(e){const r="https://github.com/suverenai/suveren-gateway/releases";return e?`${r}/tag/v${e}`:`${r}/latest`}function r0(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const r=document.activeElement;if(r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)){const a=r.value;if(a&&a.trim())return!0}return!1}function vp(){const{updateAvailable:e,installMethod:r,version:a,latestVersion:i,serverRestarted:l,startFastPolling:u,dismiss:d}=nu(),[p,m]=f.useState(!1),[y,v]=f.useState(!1),[j,x]=f.useState(()=>{try{const $=sessionStorage.getItem(fc);if($)return sessionStorage.removeItem(fc),$}catch{}return null}),S=Xw(r),N=f.useRef(null),w=$=>{try{sessionStorage.setItem(fc,$||i||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!j)return;const $=setTimeout(()=>x(null),6e3);return()=>clearTimeout($)},[j]),f.useEffect(()=>{if(!p||!l)return;const $=()=>r0()?!1:(w(a),!0);if($())return;const T=setInterval($,1500);return()=>clearInterval(T)},[p,l,a]),f.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const k=e&&!p&&!j||!!j&&!p;f.useEffect(()=>{if(!k){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const $=()=>{var M;const F=((M=N.current)==null?void 0:M.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${F}px`)};$();const T=new ResizeObserver($);return N.current&&T.observe(N.current),()=>{T.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[k]);const C=()=>{m(!0),u()},E=async()=>{if(S)try{await navigator.clipboard.writeText(S),v(!0),setTimeout(()=>v(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[j&&!p&&n.jsx("div",{ref:N,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",j&&j!=="✓"?` — ${j} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>x(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!p&&!j&&n.jsxs("div",{ref:N,className:e0(r),role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"update-banner-row",children:[n.jsx("span",{className:"update-banner-text",children:r==="msi"&&i?`Update available — version ${i}.`:"Update available."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r==="msi"&&n.jsx("a",{className:"btn btn-sm btn-secondary",href:n0(i),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),r!=="managed"&&r!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:C,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:d,"aria-label":"Dismiss",children:"×"})]})]}),r==="managed"&&n.jsx("p",{className:"update-banner-hint",children:Zw}),r==="msi"&&n.jsx("p",{className:"update-banner-hint",children:t0})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:S}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:E,children:y?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>w(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>m(!1),children:"Cancel"})]})]})})]})}function yp(){const e=au(),r=f.useRef(null);return f.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=r.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const i=new ResizeObserver(a);return r.current&&i.observe(r.current),()=>{i.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:r,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const s0={system:"◑",light:"☀",dark:"☾"},a0=[{to:"/",icon:"dashboard",label:"Dashboard"},{to:"/approvals",icon:"approvals",label:"Approvals"},{to:"/mandates",icon:"mandates",label:"Mandates"},{to:"/tickets",icon:"tickets",label:"Tickets"},{to:"/reports",icon:"reports",label:"Reports"},{to:"/blocked",icon:"blocked",label:"Blocked"},{to:"/team",icon:"team",label:"Team"},{to:"/agent-brief",icon:"brief",label:"Agent Brief"},{to:"/integrations",icon:"integrations",label:"Integrations"},{to:"/settings",icon:"settings",label:"Settings"}];function i0({open:e,onClose:r}){const{user:a,activeGroup:i,activeDomain:l,logout:u}=Nt(),{theme:d,toggle:p}=qm(),m=nn();return f.useEffect(()=>{r()},[m.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:r}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:i?`${i.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:a0.map(y=>n.jsxs(tu,{to:y.to,end:y.to==="/",className:({isActive:v})=>`mobile-menu-item${v?" active":""}`,onClick:r,children:[n.jsx("span",{className:"icon",children:n.jsx(Ic,{name:y.icon})}),y.label]},y.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:s0[d]}),"Theme: ",d]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),r()},children:"Logout"})]})]})]}):null}function xp(e){return e.status==="pending"}function o0(e,r){return e.filter(xp).length+r.length}const Lr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],l0=500;function jp(){const{user:e,domain:r}=Nt(),[a,i]=f.useState(0),l=f.useRef(null),u=f.useCallback(async()=>{if(!e){i(0);return}try{const[p,m]=await Promise.all([P.getMyProposals(r).catch(()=>[]),P.getProposalsForApprover().catch(()=>[])]);i(o0(p,m))}catch{i(0)}},[e,r]),d=f.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},l0)},[u]);return f.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Ke(Lr[0],d),Ke(Lr[1],d),Ke(Lr[2],d),Ke(Lr[3],d),Ke(Lr[4],d),Ke(Lr[5],d),Ke(Lr[6],d),a}const wf="Suveren",c0="/favicon.svg",u0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ri={x1:74.54,y1:22.74,x2:94.46,y2:34.24},d0=14,h0="#f59e0b";function f0(e){const r=cu(e);return r>0?`(${r}) ${wf}`:wf}function cu(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function m0(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
53
+ <path class="m" d="${u0}"/>
54
54
  <line class="m" x1="${Ri.x1}" y1="${Ri.y1}" x2="${Ri.x2}" y2="${Ri.y2}"/>
55
- <circle cx="103" cy="103" r="25" fill="${u0}"/>
56
- <style>.m{stroke:#111111;stroke-width:${c0};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
57
- </svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function f0(){return document.querySelector('link[rel="icon"]')}function wp(e){const r=cu(e);document.title=d0(r),bp(r);const a=f0();if(!a)return;const i=r>0?h0():o0;a.getAttribute("href")!==i&&a.setAttribute("href",i)}function m0(){wp(0)}function bp(e,r=globalThis.navigator){var l;if(!r||typeof r.setAppBadge!="function")return;const a=cu(e),i=a>0?r.setAppBadge(a):r.clearAppBadge?r.clearAppBadge():r.setAppBadge(0);(l=i==null?void 0:i.catch)==null||l.call(i,()=>{})}function p0(){const e=jp();return f.useEffect(()=>{wp(e)},[e]),f.useEffect(()=>m0,[]),null}const kp="suveren:dockBadgePrompt";function g0(){var i;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((i=window.matchMedia)==null?void 0:i.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const r=navigator.userAgent;if(!(/Safari\//.test(r)&&!/Chrome\/|Chromium\/|Edg\//.test(r))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(kp))return!1}catch{}return!0}function v0(){const[e,r]=f.useState(!1),a=jp();if(f.useEffect(()=>{r(g0())},[]),!e)return null;const i=()=>{try{localStorage.setItem(kp,"1")}catch{}r(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&bp(a)}catch{}i()};return n.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:l,children:"Allow"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,"aria-label":"Not now",children:"Not now"})]})}function y0(){const[e,r]=f.useState(!1);return n.jsxs(Yj,{children:[n.jsx(p0,{}),n.jsx(ru,{onMenuToggle:()=>r(!e)}),n.jsx(vp,{}),n.jsx(yp,{}),n.jsx(Yw,{}),n.jsx(s0,{open:e,onClose:()=>r(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(v0,{}),n.jsx(zx,{})]})})]})}function x0({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Sp(){return typeof navigator<"u"&&navigator.webdriver===!0}const Np="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function j0(){const[e,r]=f.useState(""),{login:a,isLoading:i,error:l,clearError:u}=Nt(),[d,p]=f.useState(null),m=Sp(),y=async()=>{if(!(!e.trim()||m)){u();try{await a(e)}catch(x){if(x instanceof Um){p(x.summary);return}}}},v=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},j=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(ru,{}),n.jsx(vp,{}),n.jsx(yp,{}),n.jsxs("div",{className:"login-split",children:[n.jsx("div",{className:"login-split-left",children:n.jsxs("div",{style:{maxWidth:"28rem"},children:[n.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),n.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your tickets."})]})}),n.jsx("div",{className:"login-split-right",children:n.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),n.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),n.jsx(x0,{what:"sign-in"}),m&&n.jsx("div",{className:"error-message",children:Np}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>r(x.target.value),onKeyDown:x=>x.key==="Enter"&&y(),disabled:i,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:y,disabled:i||m,style:{marginBottom:"2rem"},children:i?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start giving mandates"].map((x,S)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:S<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[S+1,"."]}),x]},S))})]})]})})]}),d&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:j,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[d.credentialCount," stored service credential",d.credentialCount===1?"":"s",d.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",d.credentialIds.slice(0,5).join(", "),d.credentialIds.length>5?`, +${d.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[d.serviceCount," configured integration",d.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:v,disabled:i,children:i?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function w0(e,r){return!r&&e!=null}function b0(e,r){return e==="join-waiting"&&r==="team"}function k0(e,r,a,i){return a!=null||e!=="join-waiting"||r==="team"?null:i}function S0(e){return`${e} personal mandate${e===1?"":"s"}`}function N0({mandates:e,pendingProposals:r}){return e.length===0&&r===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",r>0&&` ${r} personal proposal${r===1?"":"s"} waiting for approval end${r===1?"s":""} too.`]})]})}function C0(){const{mode:e,pendingRequest:r,refreshGroups:a}=Nt(),i=yn(),[l,u]=f.useState("choose"),[d,p]=f.useState(""),[m,y]=f.useState(""),[v,j]=f.useState(null),[x,S]=f.useState(null),[N,w]=f.useState(""),[k,C]=f.useState(""),[E,$]=f.useState(!1),T=f.useRef(!1);f.useEffect(()=>{w0(r,T.current)&&(T.current=!0,u("join-waiting"))},[r]),f.useEffect(()=>{b0(l,e)&&i("/")},[l,e,i]);const F=f.useRef(null);f.useEffect(()=>{if(r){F.current=r.groupName;return}const V=k0(l,e,r,F.current);V&&(w(V),u("join-declined"),F.current=null)},[r,l,e]),f.useEffect(()=>{if(l!=="join-waiting")return;const V=setInterval(()=>{a()},5e3);return()=>clearInterval(V)},[l,a]);const M=f.useCallback(()=>{u("choose"),C(""),j(null),S(null),p(""),y("")},[]),B=async()=>{if(d.trim()){$(!0),C("");try{const V=await P.getJoinPreview(d.trim());j(V),u("join-preview")}catch(V){C(V instanceof Error?V.message:"Invalid or expired invite code")}finally{$(!1)}}},te=async()=>{$(!0),C("");try{await P.requestToJoinGroup(d.trim()),await a(),u("join-waiting")}catch(V){C(V instanceof Error?V.message:"Failed to join group")}finally{$(!1)}},Q=async()=>{$(!0),C("");try{await P.withdrawJoinRequest(),await a(),M()}catch(V){C(V instanceof Error?V.message:"Failed to withdraw request")}finally{$(!1)}},_=async()=>{u("create"),C(""),$(!0);try{const V=await P.getCreatePreview();S(V)}catch(V){C(V instanceof Error?V.message:"Failed to load preview")}finally{$(!1)}},z=async()=>{if(m.trim()){$(!0),C("");try{await P.createGroup(m.trim()),await a(),i("/")}catch(V){C(V instanceof Error?V.message:"Failed to create group")}finally{$(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(ru,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[k&&n.jsx("div",{className:"error-message",children:k}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:d,onChange:V=>p(V.target.value),onKeyDown:V=>V.key==="Enter"&&B(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:E}),n.jsx("button",{className:"btn btn-primary",onClick:B,disabled:E||!d.trim(),children:E?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:_,disabled:E,children:"Create a team"})]})]}),l==="join-preview"&&v&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",v.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(N0,{mandates:v.personalMandates,pendingProposals:v.pendingPersonalProposals}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",v.admin.name,") confirms your request. Nothing changes until then."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:te,disabled:E,children:E?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(r==null?void 0:r.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:Q,disabled:E,children:E?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",N," ended"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),n.jsx("button",{className:"btn btn-primary",onClick:M,disabled:E,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:m,onChange:V=>y(V.target.value),onKeyDown:V=>V.key==="Enter"&&z(),disabled:E,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",S0(x.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:z,disabled:E||!m.trim(),children:E?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]})]})})]})}const kf={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
55
+ <circle cx="103" cy="103" r="25" fill="${h0}"/>
56
+ <style>.m{stroke:#111111;stroke-width:${d0};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
57
+ </svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function p0(){return document.querySelector('link[rel="icon"]')}function wp(e){const r=cu(e);document.title=f0(r),bp(r);const a=p0();if(!a)return;const i=r>0?m0():c0;a.getAttribute("href")!==i&&a.setAttribute("href",i)}function g0(){wp(0)}function bp(e,r=globalThis.navigator){var l;if(!r||typeof r.setAppBadge!="function")return;const a=cu(e),i=a>0?r.setAppBadge(a):r.clearAppBadge?r.clearAppBadge():r.setAppBadge(0);(l=i==null?void 0:i.catch)==null||l.call(i,()=>{})}function v0(){const e=jp();return f.useEffect(()=>{wp(e)},[e]),f.useEffect(()=>g0,[]),null}const kp="suveren:dockBadgePrompt";function y0(){var i;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((i=window.matchMedia)==null?void 0:i.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const r=navigator.userAgent;if(!(/Safari\//.test(r)&&!/Chrome\/|Chromium\/|Edg\//.test(r))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(kp))return!1}catch{}return!0}function x0(){const[e,r]=f.useState(!1),a=jp();if(f.useEffect(()=>{r(y0())},[]),!e)return null;const i=()=>{try{localStorage.setItem(kp,"1")}catch{}r(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&bp(a)}catch{}i()};return n.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:l,children:"Allow"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,"aria-label":"Not now",children:"Not now"})]})}function j0(){const[e,r]=f.useState(!1);return n.jsxs(Qj,{children:[n.jsx(v0,{}),n.jsx(ru,{onMenuToggle:()=>r(!e)}),n.jsx(vp,{}),n.jsx(yp,{}),n.jsx(Qw,{}),n.jsx(i0,{open:e,onClose:()=>r(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(x0,{}),n.jsx(Bx,{})]})})]})}function w0({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Sp(){return typeof navigator<"u"&&navigator.webdriver===!0}const Np="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function b0(){const[e,r]=f.useState(""),{login:a,isLoading:i,error:l,clearError:u}=Nt(),[d,p]=f.useState(null),m=Sp(),y=async()=>{if(!(!e.trim()||m)){u();try{await a(e)}catch(x){if(x instanceof Um){p(x.summary);return}}}},v=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},j=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(ru,{}),n.jsx(vp,{}),n.jsx(yp,{}),n.jsxs("div",{className:"login-split",children:[n.jsx("div",{className:"login-split-left",children:n.jsxs("div",{style:{maxWidth:"28rem"},children:[n.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),n.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your tickets."})]})}),n.jsx("div",{className:"login-split-right",children:n.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),n.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),n.jsx(w0,{what:"sign-in"}),m&&n.jsx("div",{className:"error-message",children:Np}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>r(x.target.value),onKeyDown:x=>x.key==="Enter"&&y(),disabled:i,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:y,disabled:i||m,style:{marginBottom:"2rem"},children:i?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start giving mandates"].map((x,S)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:S<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[S+1,"."]}),x]},S))})]})]})})]}),d&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:j,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[d.credentialCount," stored service credential",d.credentialCount===1?"":"s",d.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",d.credentialIds.slice(0,5).join(", "),d.credentialIds.length>5?`, +${d.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[d.serviceCount," configured integration",d.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:v,disabled:i,children:i?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function k0(e,r){return!r&&e!=null}function S0(e,r){return e==="join-waiting"&&r==="team"}function N0(e,r,a,i){return a!=null||e!=="join-waiting"||r==="team"?null:i}function C0(e){return`${e} personal mandate${e===1?"":"s"}`}function E0({mandates:e,pendingProposals:r}){return e.length===0&&r===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",r>0&&` ${r} personal proposal${r===1?"":"s"} waiting for approval end${r===1?"s":""} too.`]})]})}function A0(){const{mode:e,pendingRequest:r,refreshGroups:a}=Nt(),i=yn(),[l,u]=f.useState("choose"),[d,p]=f.useState(""),[m,y]=f.useState(""),[v,j]=f.useState(null),[x,S]=f.useState(null),[N,w]=f.useState(""),[k,C]=f.useState(""),[E,$]=f.useState(!1),T=f.useRef(!1);f.useEffect(()=>{k0(r,T.current)&&(T.current=!0,u("join-waiting"))},[r]),f.useEffect(()=>{S0(l,e)&&i("/")},[l,e,i]);const F=f.useRef(null);f.useEffect(()=>{if(r){F.current=r.groupName;return}const V=N0(l,e,r,F.current);V&&(w(V),u("join-declined"),F.current=null)},[r,l,e]),f.useEffect(()=>{if(l!=="join-waiting")return;const V=setInterval(()=>{a()},5e3);return()=>clearInterval(V)},[l,a]);const M=f.useCallback(()=>{u("choose"),C(""),j(null),S(null),p(""),y("")},[]),B=async()=>{if(d.trim()){$(!0),C("");try{const V=await P.getJoinPreview(d.trim());j(V),u("join-preview")}catch(V){C(V instanceof Error?V.message:"Invalid or expired invite code")}finally{$(!1)}}},te=async()=>{$(!0),C("");try{await P.requestToJoinGroup(d.trim()),await a(),u("join-waiting")}catch(V){C(V instanceof Error?V.message:"Failed to join group")}finally{$(!1)}},Q=async()=>{$(!0),C("");try{await P.withdrawJoinRequest(),await a(),M()}catch(V){C(V instanceof Error?V.message:"Failed to withdraw request")}finally{$(!1)}},_=async()=>{u("create"),C(""),$(!0);try{const V=await P.getCreatePreview();S(V)}catch(V){C(V instanceof Error?V.message:"Failed to load preview")}finally{$(!1)}},z=async()=>{if(m.trim()){$(!0),C("");try{await P.createGroup(m.trim()),await a(),i("/")}catch(V){C(V instanceof Error?V.message:"Failed to create group")}finally{$(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(ru,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[k&&n.jsx("div",{className:"error-message",children:k}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:d,onChange:V=>p(V.target.value),onKeyDown:V=>V.key==="Enter"&&B(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:E}),n.jsx("button",{className:"btn btn-primary",onClick:B,disabled:E||!d.trim(),children:E?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:_,disabled:E,children:"Create a team"})]})]}),l==="join-preview"&&v&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",v.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(E0,{mandates:v.personalMandates,pendingProposals:v.pendingPersonalProposals}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",v.admin.name,") confirms your request. Nothing changes until then."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:te,disabled:E,children:E?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(r==null?void 0:r.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:Q,disabled:E,children:E?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",N," ended"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),n.jsx("button",{className:"btn btn-primary",onClick:M,disabled:E,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:m,onChange:V=>y(V.target.value),onKeyDown:V=>V.key==="Enter"&&z(),disabled:E,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",C0(x.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:z,disabled:E||!m.trim(),children:E?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]})]})})]})}const bf={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
58
58
 
59
59
  ${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
60
60
 
@@ -63,28 +63,28 @@ url = "${e}/mcp"
63
63
 
64
64
  Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
65
65
  SSE transport: GET ${e}/sse
66
- Health check: GET ${e}/health`}},Sf=["claude-code","claude-desktop","chatgpt-codex","other"];function Ic({mcpEndpoint:e}){const[r,a]=f.useState(Sf[0]),[i,l]=f.useState(!1),u=f.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),d=kf[r].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:Sf.map(p=>n.jsx("button",{className:`mcp-tab${r===p?" active":""}`,onClick:()=>a(p),children:kf[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:d}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(d),children:i?"Copied":"Copy"})]})}const Rc="suveren-setup-ai-skipped",$c="suveren-setup-agent-done",Pc="suveren-setup-dismissed",E0={"hap-setup-ai-skipped":Rc,"hap-setup-agent-done":$c,"hap-setup-dismissed":Pc};function A0(){for(const[e,r]of Object.entries(E0)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(r)===null&&localStorage.setItem(r,a),a!==null&&localStorage.removeItem(e)}}A0();function T0({aiConfigured:e,hasRunningIntegration:r,hasActiveAuth:a,hasAgentConnected:i,mcpEndpoint:l}){const[u,d]=f.useState(()=>localStorage.getItem(Rc)==="true"),[p,m]=f.useState(()=>localStorage.getItem($c)==="true"),[y,v]=f.useState(()=>localStorage.getItem(Pc)==="true"),[j,x]=f.useState(null),S=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings#ai-assistant",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:r?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:i||p?"done":"pending"}],N=S.filter(T=>T.status==="done"||T.status==="skipped").length,w=N===S.length,k=f.useCallback(()=>{localStorage.setItem(Rc,"true"),d(!0)},[]),C=f.useCallback(()=>{localStorage.setItem($c,"true"),m(!0),x(null)},[]),E=f.useCallback(()=>{localStorage.setItem(Pc,"true"),v(!0)},[]);if(y||w)return null;const $=S.findIndex(T=>T.status==="pending");return n.jsxs("div",{className:"setup-guide",style:{borderRadius:"var(--radius-xl)",boxShadow:"var(--elevation-2)",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get started"}),n.jsx("button",{onClick:E,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.2rem"},children:S.map((T,F)=>{const M=F===$,B=T.status==="done"?"✓":T.status==="skipped"?"–":"○",te=T.status==="pending"?"var(--text-primary)":"var(--text-muted)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.45rem 0.75rem",borderRadius:"var(--radius-md)",background:M?"var(--bg-sunken)":void 0},children:[n.jsx("span",{style:{color:te,fontSize:"0.85rem",width:"1rem",textAlign:"center",flexShrink:0},children:B}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[T.to&&T.status==="pending"?n.jsx(pt,{to:T.to,style:{fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)",textDecoration:"none"},children:T.label}):T.status==="pending"&&F===3?n.jsx("button",{onClick:()=>x(j===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)"},children:T.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:T.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:T.label}),T.optional&&T.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),T.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),T.detail&&T.status==="pending"&&M&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:T.detail})]}),T.optional&&T.status==="pending"&&n.jsx("button",{onClick:k,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),T.to&&T.status==="pending"&&n.jsx(pt,{to:T.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),F===3&&j===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(Ic,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:C,children:"Done"})]})]},F)})}),n.jsxs("div",{style:{fontSize:"var(--text-caption)",color:"var(--text-muted)",marginTop:"var(--space-3)"},children:[N," of ",S.length," done"]})]})}function Cp(e,r=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],i=a.every(Boolean),l=e.otherMandateCount===0&&!i,u=a.findIndex(y=>!y),d=r!==null&&a[r]===!1?r:u,p=e.managed?"managed":"self",m=y=>a[y]?{status:"done"}:y!==d?{status:"todo"}:y===1?{status:"open",variant:p,simulationOn:e.simulationOn}:y===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:m(0),step2:m(1),step3:m(2)}}const I0="/mandates?new=1&profile=delegation";function Nf({text:e}){const[r,a]=f.useState(!1),i=f.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:i,children:r?"Copied":"Copy"})}function fc({todo:e,onOpen:r,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:r,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function R0({contact:e,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u,mcpEndpoint:d}){const p={hasContact:e!==null,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u},[m,y]=f.useState(null),v=Cp(p,m);if(!v.visible)return null;const j=`Please connect to the Suveren gateway: MCP server at ${d}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step1.status==="open"?"open":v.step1.status==="done"?"done":"todo"}`,children:v.step1.status==="done"?"✓":"1"}),v.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",rw(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(fc,{todo:v.step1.status==="todo",onOpen:()=>y(0),children:"Connect your AI"})]}),v.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:v.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Ic,{mcpEndpoint:d})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:j}),n.jsx(Nf,{text:j})]})}),n.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Ic,{mcpEndpoint:d})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step2.status==="open"?"open":v.step2.status==="done"?"done":"todo"}`,children:v.step2.status==="done"?"✓":"2"}),v.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(pt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(fc,{todo:v.step2.status==="todo",onOpen:()=>y(1),children:"Give the Delegation mandate"})]}),v.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),v.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(pt,{to:I0,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),v.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:v.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(fc,{todo:v.step3.status==="todo",onOpen:()=>y(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),v.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(Nf,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(pt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function $0(){const[e,r]=f.useState(null);return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{!a&&typeof i.mcpPort=="number"&&r(`http://localhost:${i.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function P0(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const r=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:r}}function Ep(){const[e,r]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(P0(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function _0(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function L0(){const[e,r]=f.useState(!1);return f.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(_0(d))}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const Cf=new Map;function xo(e){let r=Cf.get(e);return r||(r=(async()=>{try{let a=e;if(!e.includes("@")){const i=await P.listProfiles(),l=d=>d.replace(/@.*$/,"").split("/").pop(),u=i.filter(d=>l(d.id)===e).sort((d,p)=>(p.id.split("@")[1]??"").localeCompare(d.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await P.getProfile(a)}catch{return null}})(),Cf.set(e,r)),r}function Ns(e){const[r,a]=f.useState(null);return f.useEffect(()=>{let i=!0;return e&&xo(e).then(l=>{i&&a(l)}),()=>{i=!1}},[e]),r}function $i(e){return typeof e=="string"&&e.length>0}function M0(e){if(e===null||typeof e!="object")return!1;const r=e;return!(!$i(r.filename)||!$i(r.contentType)||!$i(r.contentBase64)||!$i(r.sha256)||r.pages!==void 0&&typeof r.pages!="number")}function Ap(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function F0(e){return`data:${e.contentType};base64,${e.contentBase64}`}function O0(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function z0(e){const r=atob(e.contentBase64),a=new Uint8Array(new ArrayBuffer(r.length));for(let i=0;i<r.length;i++)a[i]=r.charCodeAt(i);return a}function Tp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}function Xi(e){return e==null||e===""?"—":Array.isArray(e)?e.length===0?"—":e.map(Xi).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}function D0(e,r){return new Date(e).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function B0(e,r,a){var y;if(!e.displayOnly||!e.attach)return null;const i=e.result;if(!i||i.status!=="ok")return null;const l=(y=Xn(i.body))==null?void 0:y.obj;if(!l)return null;const u=`${e.attach}.`,d=new Set((r==null?void 0:r.hidden)??[]),p=[];for(const[v,j]of Object.entries((r==null?void 0:r.labels)??{})){if(!v.startsWith(u)||d.has(v))continue;const x=Tp(l,v.slice(u.length));x==null||x===""||p.push({key:v,label:j,value:Xi(x)})}if(p.length===0)return null;const m=e.label??e.tool;return{key:e.tool,heading:`From ${m}${a?` — checked ${D0(a)}`:""}`,rows:p}}function U0(e,r,a){var l;const i=[];for(const[u,d]of Object.entries((r==null?void 0:r.compare)??{})){if(!(u in e))continue;const[p,...m]=d.split("."),y=m.length>0?Tp(a(p),m.join(".")):void 0;i.push({key:u,label:((l=r==null?void 0:r.labels)==null?void 0:l[u])??u,now:Xi(y),next:Xi(e[u])})}return i}function Mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $t(e,r=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?r||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function W0(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Ip(e,r){return e.length===0?"—":e.every(a=>!Mt(a)&&!Array.isArray(a))?e.map(a=>$t(a,r)).join(", "):e.length===1?"1 entry":`${e.length} entries`}function Mn(e,r,a){const i=r?Object.keys(r).filter(l=>l in e):Object.keys(e);return i.length===0?"—":i.map(l=>{var m,y;const u=e[l],d=((m=r==null?void 0:r[l])==null?void 0:m.title)??zt(l),p=Mt(u)?Mn(u,(y=r==null?void 0:r[l])==null?void 0:y.properties,a):Array.isArray(u)?Ip(u,a):$t(u,a);return`${d}: ${p}`}).join(" · ")}function Rp(e,r,a){const i=m=>m==null||m==="",l=(r?Object.keys(r).filter(m=>e.some(y=>m in y)):[...new Set(e.flatMap(m=>Object.keys(m)))]).filter(m=>e.some(y=>!i(y[m]))),u=l.map(m=>{var y,v,j;return{key:m,label:(a&&((v=(y=a.hints)==null?void 0:y.labels)==null?void 0:v[`${a.pathPrefix}.${m}`]))??((j=r==null?void 0:r[m])==null?void 0:j.title)??zt(m)}}),d=!!a,p=e.map(m=>({cells:l.map(y=>{var S,N,w;const v=m[y];if(i(v))return{value:"",sealed:d};if(a&&!Mt(v)&&xs((S=a.hints)==null?void 0:S.money,`${a.pathPrefix}.${y}`))return{...Lp(v,a.currency),sealed:d};const j=Mt(v)?Mn(v,(N=r==null?void 0:r[y])==null?void 0:N.properties,!1):$t(v),x=Mt(v)?Mn(v,(w=r==null?void 0:r[y])==null?void 0:w.properties,!0):$t(v,!0);return x===j?{value:j,sealed:d}:{value:j,valueTitle:x,sealed:d}})}));return{columns:u,rows:p}}function H0(e){return Mt(e)?Mn(e,void 0,!1):Array.isArray(e)?Ip(e,!1):$t(e)}function $p(e,r){return Array.isArray(e)&&e.length>0&&e.every(Mt)?{table:Rp(e,void 0,{hints:r==null?void 0:r.hints,pathPrefix:`${(r==null?void 0:r.key)??""}[]`,currency:r==null?void 0:r.currency})}:Mt(e)?{text:Mn(e,void 0,!1)}:null}function V0(e){return e.split(`
67
- `).map(r=>r.startsWith("+")&&!r.startsWith("+++")?{text:r,kind:"add"}:r.startsWith("-")&&!r.startsWith("---")?{text:r,kind:"remove"}:{text:r,kind:"context"})}function q0(e,r){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(v=>!Mt(v)&&!Array.isArray(v))){if(e.every(x=>typeof x=="string"))return{lines:e};const v=e.map(x=>$t(x)).join(", "),j=e.map(x=>$t(x,!0)).join(", ");return j===v?{value:v}:{value:v,valueTitle:j}}const u=(l=r==null?void 0:r.items)==null?void 0:l.properties,d=e.map(v=>Mt(v)?Mn(v,u,!1):$t(v)),p=e.map(v=>Mt(v)?Mn(v,u,!0):$t(v,!0)),m=d.map((v,j)=>v===p[j]?void 0:p[j]),y=e.every(Mt)?Rp(e,u):void 0;return{lines:d,...m.some(v=>v!==void 0)?{lineTitles:m}:{},...y?{table:y}:{}}}if(Mt(e)){const u=r==null?void 0:r.properties,d=u?Object.keys(u).filter(y=>y in e):Object.keys(e);if(d.length>0&&d.every(y=>!Mt(e[y])&&!Array.isArray(e[y])))return{sublist:d.map(v=>{var w;const j=e[v],x=((w=u==null?void 0:u[v])==null?void 0:w.title)??zt(v),S=$t(j),N=$t(j,!0);return N===S?{key:v,label:x,value:S}:{key:v,label:x,value:S,valueTitle:N}})};const p=Mn(e,u,!1),m=Mn(e,u,!0);return m===p?{value:p}:{value:p,valueTitle:m}}if(typeof e=="string"&&(r==null?void 0:r.contentMediaType)==="text/x-diff")return{diffLines:V0(e)};const a=$t(e),i=$t(e,!0);return i===a?{value:a}:{value:a,valueTitle:i}}function K0(e){let r;try{r=JSON.parse(e)}catch{return null}return Mt(r)?r:null}function Xn(e){const r=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(r)return{obj:r,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?K0(e.text):null;return a?{obj:a}:null}function Zi(e){const r=Xn(e);if(!r)return[];const{obj:a,schema:i}=r,l=(i==null?void 0:i.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],d=[];for(const p of u){if(!(p in a))continue;const m=l[p],y=(m==null?void 0:m.title)??zt(p),v={key:p,label:y,...q0(a[p],m)};m!=null&&m.description&&(v.description=m.description),d.push(v)}return d}function Pp(e,r){const a=Xn(e);if(a){const l=Zi(e),u=r==null?void 0:r.fields;let d;if(u&&u.length>0){const y=new Map(l.map(v=>[v.key,v]));d=u.map(v=>y.get(v)).filter(v=>v!==void 0)}else d=l.filter(y=>W0(a.obj[y.key]));const p=new Set(d.map(y=>y.key)),m=l.filter(y=>!p.has(y.key));return{kind:"structured",fields:d,moreFields:m,totalFields:l.length}}const i=e==null?void 0:e.text;return i&&i.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:i}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Ef(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(r=>[r.key,r.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function Pi(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function G0(e,r,a){const i=Xn(e),l=Xn(r);if(!i&&!l){const x=(e==null?void 0:e.text)??"",S=(r==null?void 0:r.text)??"";return x===S?{approved:Pi([]),current:Pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:S},unchanged:!1}}const u=new Map(Zi(e).map(x=>[x.key,x])),d=new Map(Zi(r).map(x=>[x.key,x])),m=[...new Set([...u.keys(),...d.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:Ef(u.get(x))!==Ef(d.get(x))),y=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>m.includes(x)),...m.filter(x=>!a.fields.includes(x))]:m,v=y.map(x=>u.get(x)).filter(x=>x!==void 0),j=y.map(x=>d.get(x)).filter(x=>x!==void 0);return{approved:Pi(v),current:Pi(j),unchanged:m.length===0}}function Y0(e){const r=e==null?void 0:e.structured;if(Array.isArray(r)&&r.every(Mt))return r;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(Mt))return a}return null}function jo(e){const r=$t(e),a=$t(e,!0);return a===r?{value:r}:{value:r,valueTitle:a}}function _p(e){return!e||e.status!=="ok"?[]:Zi(e.body)}function _c(e){if(!e)return"Not read.";switch(e.status){case"not_found":return e.message?`The system answered: ${e.message}`:"Not found in the system.";case"none":return"Nothing to read.";case"refused":return e.message?rb(e.message):"The system refused to answer.";default:return"Not available right now."}}function uu(e,r,a){var v,j,x;const i=_p(e);if(i.length===0)return{rawId:$t(r),context:[],unresolved:_c(e)};const l=e&&e.status==="ok"?(v=Xn(e.body))==null?void 0:v.obj:void 0,u=a==null?void 0:a.pathPrefix,d=u?(x=(j=a==null?void 0:a.displayHints)==null?void 0:j.names)==null?void 0:x[u]:void 0,p=d?Lc(l,d):void 0;if(typeof p=="string"&&p.length>0){const S=i.filter(N=>N.key!=="id"&&!to(a==null?void 0:a.displayHints,`${u}.${N.key}`)).map(N=>({...N,label:Or(a==null?void 0:a.displayHints,`${u}.${N.key}`,N.label)}));return{name:p,rawId:$t(r),context:Af(S,l,u,a)}}const m=i.find(S=>["name","title","label"].includes(S.key))??i.find(S=>typeof(l==null?void 0:l[S.key])=="string"&&!S.lines&&!S.sublist&&!S.diffLines),y=i.filter(S=>S.key!==(m==null?void 0:m.key)&&S.key!=="id").filter(S=>!u||!to(a==null?void 0:a.displayHints,`${u}.${S.key}`)).map(S=>{var E,$;if(!u)return S;const N=`${u}.${S.key}`,w=Or(a==null?void 0:a.displayHints,N,S.label);if(!xs((E=a==null?void 0:a.displayHints)==null?void 0:E.money,N)&&!xs(($=a==null?void 0:a.displayHints)==null?void 0:$.percent,N))return w===S.label?S:{...S,label:w};const{value:k,valueTitle:C}=eo(l==null?void 0:l[S.key],a==null?void 0:a.displayHints,N,a==null?void 0:a.currency);return{...S,label:w,value:k,valueTitle:C}});return{name:m==null?void 0:m.value,rawId:$t(r),context:Af(y,l,u,a)}}const J0=new Set(["id","name","title","label"]);function xs(e,r){return!!(e!=null&&e.includes(r))}function Or(e,r,a){var i;return((i=e==null?void 0:e.labels)==null?void 0:i[r])??a}function Lp(e,r){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${r?` ${r}`:""}`}:jo(e)}function Q0(e){return typeof e!="number"&&typeof e!="string"?jo(e):{value:`${e} %`}}function eo(e,r,a,i){return xs(r==null?void 0:r.money,a)?Lp(e,i):xs(r==null?void 0:r.percent,a)?Q0(e):jo(e)}function to(e,r){return xs(e==null?void 0:e.hidden,r)}function X0(e,r,a){var d;const i=e==null?void 0:e.currencyField;if(!i)return;const l=i.indexOf(".");if(l<0){const p=r[i];return typeof p=="string"?p:void 0}const u=(d=a(i.slice(0,l)))==null?void 0:d[i.slice(l+1)];return typeof u=="string"?u:void 0}function Z0(e,r,a,i){const l=e.forEach??"",u=e.attach,d=e.elements??[],p=Math.min(r.length,d.length),m=r.slice(0,p),y=d.slice(0,p),v=[...new Set(m.flatMap(k=>Object.keys(k)))].filter(k=>k!==e.sourceArg).filter(k=>!to(a,`${l}[].${k}`)),j=new Map;if(u)for(const k of y)for(const C of _p(k))j.has(C.key)||j.set(C.key,C.label);const x=u?[...j.keys()].filter(k=>!J0.has(k)):[],S=!!u&&y.some(k=>k&&k.status!=="none"),N=[];S&&N.push({key:`__attach:${u}`,label:Or(a,`${l}[].${u}`,zt(e.sourceArg??u))});for(const k of v)N.push({key:`bound:${k}`,label:Or(a,`${l}[].${k}`,zt(k))});for(const k of x)N.push({key:`attached:${k}`,label:Or(a,`${l}[].${u}.${k}`,j.get(k)??zt(k))});const w=m.map((k,C)=>{var F;const E=y[C],$=[];if(S){const M=uu(E,e.sourceArg?k[e.sourceArg]:void 0),B=(E==null?void 0:E.status)==="none"?"":M.name?`${M.name} (${M.rawId})`:M.unresolved?`${M.rawId} — ${M.unresolved}`:M.rawId;$.push({value:B,sealed:!1})}for(const M of v){const{value:B,valueTitle:te}=k[M]===void 0||k[M]===null?{value:"",valueTitle:void 0}:eo(k[M],a,`${l}[].${M}`,i);$.push({value:B,valueTitle:te,sealed:!0})}const T=E&&E.status==="ok"?(F=Xn(E.body))==null?void 0:F.obj:void 0;for(const M of x){const B=T==null?void 0:T[M],{value:te,valueTitle:Q}=B!=null?eo(B,a,`${l}[].${u}.${M}`,i):{value:"",valueTitle:void 0};$.push({value:te,valueTitle:Q,sealed:!1})}return{cells:$}});return{columns:N,rows:w,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function eb(e){return`${zt(e)} — from the system`}function tb(e){var l;const r=eb(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=Xn(a.body))==null?void 0:l.obj;return u&&M0(u)?{heading:r,document:u}:{heading:r,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:r,note:_c(a)}}if(!a||a.status!=="ok")return{heading:r,note:_c(a)};const i=Y0(a.body);if(i){if(i.length===0)return{heading:r,note:"Nothing found."};const u=[...new Set(i.flatMap(m=>Object.keys(m)))],d=u.map(m=>({key:m,label:zt(m)})),p=i.map(m=>({cells:u.map(y=>({...jo(m[y]),sealed:!1}))}));return{heading:r,table:{columns:d,rows:p}}}return{heading:r,body:Pp(a.body,{fields:e.fields})}}function nb(e,r,a,i={}){const l=new Map(r.filter(w=>w.attach&&!w.forEach&&!w.displayOnly).map(w=>[w.attach,w])),u=new Map(r.filter(w=>w.forEach).map(w=>[w.forEach,w])),d=r.filter(w=>!w.attach&&!w.forEach&&!w.as&&!w.displayOnly),p=r.map(w=>B0(w,a,i.readAt)).filter(w=>w!==null),m=w=>{var C,E;const k=(C=l.get(w))==null?void 0:C.result;return k&&k.status==="ok"?(E=Xn(k.body))==null?void 0:E.obj:void 0},y=X0(a,e,m),v=(a==null?void 0:a.order)??[],j=[...new Set([...v,...Object.keys(e)])],x=[],S=new Set(Object.keys((a==null?void 0:a.compare)??{}));for(const w of j){if(!(w in e)||np.has(w)||to(a,w))continue;if(S.has(w)){x.some(B=>B.kind==="compare")||x.push({kind:"compare",key:"compare",label:"",lines:U0(e,a,m)});continue}const k=Or(a,w,zt(w)),C=u.get(w);if(C){const B=Array.isArray(e[w])?e[w]:[];x.push({kind:"table",key:w,label:k,table:Z0(C,B,a,y)});continue}const E=l.get(w);if(E){const B=uu(E.result,e[w],{pathPrefix:w,displayHints:a,currency:y,fields:E.fields});x.push({kind:"identity",key:w,label:k,identity:B});continue}const $=e[w],T=$p($,{key:w,hints:a,currency:y});if(T&&"table"in T){x.push({kind:"table",key:w,label:k,table:T.table});continue}if(T&&Mt($)){const B=Mn($,void 0,!0);x.push({kind:"scalar",key:w,label:k,value:T.text,...B!==T.text?{valueTitle:B}:{}});continue}if(Array.isArray($)){x.push({kind:"scalar",key:w,label:k,value:$.length===0?"—":$.map(B=>$t(B)).join(", ")});continue}const{value:F,valueTitle:M}=eo($,a,w,y);x.push({kind:"scalar",key:w,label:k,value:F,valueTitle:M})}const N=d.map(tb).filter(w=>w!==null);return{rows:x,sections:N,systemBoxes:p}}function rb(e){return e.length>300?`${e.slice(0,299)}…`:e}function Lc(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}const sb=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function ab(e,r){const a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Af(e,r,a,i){var u;let l=e;return(u=i==null?void 0:i.fields)!=null&&u.length&&(l=i.fields.flatMap(d=>{const p=e.find(v=>v.key===d);if(p)return[p];if(!d.includes("."))return[];const m=Lc(r,d);if(m==null||typeof m=="object")return[];const y=Or(i.displayHints,a?`${a}.${d}`:d,zt(d.split(".").pop()));return[{key:d,label:y,value:String(m)}]})),l.filter(d=>{var p,m,y;return((p=d.lines)==null?void 0:p.length)||((m=d.sublist)==null?void 0:m.length)||d.table||((y=d.diffLines)==null?void 0:y.length)||d.value!==void 0&&d.value!==""&&d.value!=="—"}).map(d=>{const p=d.key.includes(".")?Lc(r,d.key):r==null?void 0:r[d.key];return typeof p=="string"&&sb.test(p)?{...d,value:ab(p),valueTitle:p}:d})}const Mp=new Map,Mc=new Set;function ib(e,r){r!==null&&(Mp.set(e,r),Mc.forEach(a=>a()))}function ob(e){return Mc.add(e),()=>Mc.delete(e)}function Fp(e){return f.useSyncExternalStore(ob,()=>Mp.get(e))}function Op(e,r){return a=>{if(!e||e.status!=="ok"||!("reads"in e)||!r)return;const i=e.reads.find(l=>l.attach===a&&!l.forEach&&!l.displayOnly);if(i)return uu(i.result,r[a],{pathPrefix:a,displayHints:e.display}).name}}function lb(e){if(!e||e.status!=="ok")return;const r=e.checks;if(!r||r.length===0)return;const a=r.find(u=>u.status==="fail");if(a)return{text:`✕ ${a.label}: failed`,status:"fail"};const i=r.find(u=>u.status==="not_checked");if(i)return{text:`${i.label}: not checked`,status:"not_checked"};const l=r.find(u=>u.status==="notice");if(l)return{text:l.label,status:"notice"}}async function Tf(e){const r=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(a)).map(i=>i.toString(16).padStart(2,"0")).join("")}function cb(e){return e.normalize("NFC").replace(/\r\n?/g,`
66
+ Health check: GET ${e}/health`}},kf=["claude-code","claude-desktop","chatgpt-codex","other"];function Rc({mcpEndpoint:e}){const[r,a]=f.useState(kf[0]),[i,l]=f.useState(!1),u=f.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),d=bf[r].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:kf.map(p=>n.jsx("button",{className:`mcp-tab${r===p?" active":""}`,onClick:()=>a(p),children:bf[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:d}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(d),children:i?"Copied":"Copy"})]})}const $c="suveren-setup-ai-skipped",Pc="suveren-setup-agent-done",_c="suveren-setup-dismissed",T0={"hap-setup-ai-skipped":$c,"hap-setup-agent-done":Pc,"hap-setup-dismissed":_c};function I0(){for(const[e,r]of Object.entries(T0)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(r)===null&&localStorage.setItem(r,a),a!==null&&localStorage.removeItem(e)}}I0();function R0({aiConfigured:e,hasRunningIntegration:r,hasActiveAuth:a,hasAgentConnected:i,mcpEndpoint:l}){const[u,d]=f.useState(()=>localStorage.getItem($c)==="true"),[p,m]=f.useState(()=>localStorage.getItem(Pc)==="true"),[y,v]=f.useState(()=>localStorage.getItem(_c)==="true"),[j,x]=f.useState(null),S=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings#ai-assistant",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:r?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:i||p?"done":"pending"}],N=S.filter(T=>T.status==="done"||T.status==="skipped").length,w=N===S.length,k=f.useCallback(()=>{localStorage.setItem($c,"true"),d(!0)},[]),C=f.useCallback(()=>{localStorage.setItem(Pc,"true"),m(!0),x(null)},[]),E=f.useCallback(()=>{localStorage.setItem(_c,"true"),v(!0)},[]);if(y||w)return null;const $=S.findIndex(T=>T.status==="pending");return n.jsxs("div",{className:"setup-guide",style:{borderRadius:"var(--radius-xl)",boxShadow:"var(--elevation-2)",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get started"}),n.jsx("button",{onClick:E,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.2rem"},children:S.map((T,F)=>{const M=F===$,B=T.status==="done"?"✓":T.status==="skipped"?"–":"○",te=T.status==="pending"?"var(--text-primary)":"var(--text-muted)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.45rem 0.75rem",borderRadius:"var(--radius-md)",background:M?"var(--bg-sunken)":void 0},children:[n.jsx("span",{style:{color:te,fontSize:"0.85rem",width:"1rem",textAlign:"center",flexShrink:0},children:B}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[T.to&&T.status==="pending"?n.jsx(pt,{to:T.to,style:{fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)",textDecoration:"none"},children:T.label}):T.status==="pending"&&F===3?n.jsx("button",{onClick:()=>x(j===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)"},children:T.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:T.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:T.label}),T.optional&&T.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),T.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),T.detail&&T.status==="pending"&&M&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:T.detail})]}),T.optional&&T.status==="pending"&&n.jsx("button",{onClick:k,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),T.to&&T.status==="pending"&&n.jsx(pt,{to:T.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),F===3&&j===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(Rc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:C,children:"Done"})]})]},F)})}),n.jsxs("div",{style:{fontSize:"var(--text-caption)",color:"var(--text-muted)",marginTop:"var(--space-3)"},children:[N," of ",S.length," done"]})]})}function Cp(e,r=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],i=a.every(Boolean),l=e.otherMandateCount===0&&!i,u=a.findIndex(y=>!y),d=r!==null&&a[r]===!1?r:u,p=e.managed?"managed":"self",m=y=>a[y]?{status:"done"}:y!==d?{status:"todo"}:y===1?{status:"open",variant:p,simulationOn:e.simulationOn}:y===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:m(0),step2:m(1),step3:m(2)}}const $0="/mandates?new=1&profile=delegation";function Sf({text:e}){const[r,a]=f.useState(!1),i=f.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:i,children:r?"Copied":"Copy"})}function mc({todo:e,onOpen:r,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:r,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function P0({contact:e,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u,mcpEndpoint:d}){const p={hasContact:e!==null,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u},[m,y]=f.useState(null),v=Cp(p,m);if(!v.visible)return null;const j=`Please connect to the Suveren gateway: MCP server at ${d}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step1.status==="open"?"open":v.step1.status==="done"?"done":"todo"}`,children:v.step1.status==="done"?"✓":"1"}),v.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",aw(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(mc,{todo:v.step1.status==="todo",onOpen:()=>y(0),children:"Connect your AI"})]}),v.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:v.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Rc,{mcpEndpoint:d})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:j}),n.jsx(Sf,{text:j})]})}),n.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Rc,{mcpEndpoint:d})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step2.status==="open"?"open":v.step2.status==="done"?"done":"todo"}`,children:v.step2.status==="done"?"✓":"2"}),v.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(pt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(mc,{todo:v.step2.status==="todo",onOpen:()=>y(1),children:"Give the Delegation mandate"})]}),v.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),v.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(pt,{to:$0,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),v.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:v.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${v.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(mc,{todo:v.step3.status==="todo",onOpen:()=>y(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),v.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(Sf,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(pt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function _0(){const[e,r]=f.useState(null);return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{!a&&typeof i.mcpPort=="number"&&r(`http://localhost:${i.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function L0(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const r=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:r}}function Ep(){const[e,r]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(L0(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function M0(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function F0(){const[e,r]=f.useState(!1);return f.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(M0(d))}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const Nf=new Map;function xo(e){let r=Nf.get(e);return r||(r=(async()=>{try{let a=e;if(!e.includes("@")){const i=await P.listProfiles(),l=d=>d.replace(/@.*$/,"").split("/").pop(),u=i.filter(d=>l(d.id)===e).sort((d,p)=>(p.id.split("@")[1]??"").localeCompare(d.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await P.getProfile(a)}catch{return null}})(),Nf.set(e,r)),r}function Ns(e){const[r,a]=f.useState(null);return f.useEffect(()=>{let i=!0;return e&&xo(e).then(l=>{i&&a(l)}),()=>{i=!1}},[e]),r}function $i(e){return typeof e=="string"&&e.length>0}function O0(e){if(e===null||typeof e!="object")return!1;const r=e;return!(!$i(r.filename)||!$i(r.contentType)||!$i(r.contentBase64)||!$i(r.sha256)||r.pages!==void 0&&typeof r.pages!="number")}function Ap(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function z0(e){return`data:${e.contentType};base64,${e.contentBase64}`}function D0(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function B0(e){const r=atob(e.contentBase64),a=new Uint8Array(new ArrayBuffer(r.length));for(let i=0;i<r.length;i++)a[i]=r.charCodeAt(i);return a}function Tp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}function Xi(e){return e==null||e===""?"—":Array.isArray(e)?e.length===0?"—":e.map(Xi).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}function U0(e,r){return new Date(e).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function W0(e,r,a){var y;if(!e.displayOnly||!e.attach)return null;const i=e.result;if(!i||i.status!=="ok")return null;const l=(y=Xn(i.body))==null?void 0:y.obj;if(!l)return null;const u=`${e.attach}.`,d=new Set((r==null?void 0:r.hidden)??[]),p=[];for(const[v,j]of Object.entries((r==null?void 0:r.labels)??{})){if(!v.startsWith(u)||d.has(v))continue;const x=Tp(l,v.slice(u.length));x==null||x===""||p.push({key:v,label:j,value:Xi(x)})}if(p.length===0)return null;const m=e.label??e.tool;return{key:e.tool,heading:`From ${m}${a?` — checked ${U0(a)}`:""}`,rows:p}}function H0(e,r,a){var l;const i=[];for(const[u,d]of Object.entries((r==null?void 0:r.compare)??{})){if(!(u in e))continue;const[p,...m]=d.split("."),y=m.length>0?Tp(a(p),m.join(".")):void 0;i.push({key:u,label:((l=r==null?void 0:r.labels)==null?void 0:l[u])??u,now:Xi(y),next:Xi(e[u])})}return i}function Mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $t(e,r=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?r||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function V0(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Ip(e,r){return e.length===0?"—":e.every(a=>!Mt(a)&&!Array.isArray(a))?e.map(a=>$t(a,r)).join(", "):e.length===1?"1 entry":`${e.length} entries`}function Mn(e,r,a){const i=r?Object.keys(r).filter(l=>l in e):Object.keys(e);return i.length===0?"—":i.map(l=>{var m,y;const u=e[l],d=((m=r==null?void 0:r[l])==null?void 0:m.title)??zt(l),p=Mt(u)?Mn(u,(y=r==null?void 0:r[l])==null?void 0:y.properties,a):Array.isArray(u)?Ip(u,a):$t(u,a);return`${d}: ${p}`}).join(" · ")}function Rp(e,r,a){const i=m=>m==null||m==="",l=(r?Object.keys(r).filter(m=>e.some(y=>m in y)):[...new Set(e.flatMap(m=>Object.keys(m)))]).filter(m=>e.some(y=>!i(y[m]))),u=l.map(m=>{var y,v,j;return{key:m,label:(a&&((v=(y=a.hints)==null?void 0:y.labels)==null?void 0:v[`${a.pathPrefix}.${m}`]))??((j=r==null?void 0:r[m])==null?void 0:j.title)??zt(m)}}),d=!!a,p=e.map(m=>({cells:l.map(y=>{var S,N,w;const v=m[y];if(i(v))return{value:"",sealed:d};if(a&&!Mt(v)&&xs((S=a.hints)==null?void 0:S.money,`${a.pathPrefix}.${y}`))return{...Lp(v,a.currency),sealed:d};const j=Mt(v)?Mn(v,(N=r==null?void 0:r[y])==null?void 0:N.properties,!1):$t(v),x=Mt(v)?Mn(v,(w=r==null?void 0:r[y])==null?void 0:w.properties,!0):$t(v,!0);return x===j?{value:j,sealed:d}:{value:j,valueTitle:x,sealed:d}})}));return{columns:u,rows:p}}function q0(e){return Mt(e)?Mn(e,void 0,!1):Array.isArray(e)?Ip(e,!1):$t(e)}function $p(e,r){return Array.isArray(e)&&e.length>0&&e.every(Mt)?{table:Rp(e,void 0,{hints:r==null?void 0:r.hints,pathPrefix:`${(r==null?void 0:r.key)??""}[]`,currency:r==null?void 0:r.currency})}:Mt(e)?{text:Mn(e,void 0,!1)}:null}function K0(e){return e.split(`
67
+ `).map(r=>r.startsWith("+")&&!r.startsWith("+++")?{text:r,kind:"add"}:r.startsWith("-")&&!r.startsWith("---")?{text:r,kind:"remove"}:{text:r,kind:"context"})}function G0(e,r){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(v=>!Mt(v)&&!Array.isArray(v))){if(e.every(x=>typeof x=="string"))return{lines:e};const v=e.map(x=>$t(x)).join(", "),j=e.map(x=>$t(x,!0)).join(", ");return j===v?{value:v}:{value:v,valueTitle:j}}const u=(l=r==null?void 0:r.items)==null?void 0:l.properties,d=e.map(v=>Mt(v)?Mn(v,u,!1):$t(v)),p=e.map(v=>Mt(v)?Mn(v,u,!0):$t(v,!0)),m=d.map((v,j)=>v===p[j]?void 0:p[j]),y=e.every(Mt)?Rp(e,u):void 0;return{lines:d,...m.some(v=>v!==void 0)?{lineTitles:m}:{},...y?{table:y}:{}}}if(Mt(e)){const u=r==null?void 0:r.properties,d=u?Object.keys(u).filter(y=>y in e):Object.keys(e);if(d.length>0&&d.every(y=>!Mt(e[y])&&!Array.isArray(e[y])))return{sublist:d.map(v=>{var w;const j=e[v],x=((w=u==null?void 0:u[v])==null?void 0:w.title)??zt(v),S=$t(j),N=$t(j,!0);return N===S?{key:v,label:x,value:S}:{key:v,label:x,value:S,valueTitle:N}})};const p=Mn(e,u,!1),m=Mn(e,u,!0);return m===p?{value:p}:{value:p,valueTitle:m}}if(typeof e=="string"&&(r==null?void 0:r.contentMediaType)==="text/x-diff")return{diffLines:K0(e)};const a=$t(e),i=$t(e,!0);return i===a?{value:a}:{value:a,valueTitle:i}}function Y0(e){let r;try{r=JSON.parse(e)}catch{return null}return Mt(r)?r:null}function Xn(e){const r=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(r)return{obj:r,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?Y0(e.text):null;return a?{obj:a}:null}function Zi(e){const r=Xn(e);if(!r)return[];const{obj:a,schema:i}=r,l=(i==null?void 0:i.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],d=[];for(const p of u){if(!(p in a))continue;const m=l[p],y=(m==null?void 0:m.title)??zt(p),v={key:p,label:y,...G0(a[p],m)};m!=null&&m.description&&(v.description=m.description),d.push(v)}return d}function Pp(e,r){const a=Xn(e);if(a){const l=Zi(e),u=r==null?void 0:r.fields;let d;if(u&&u.length>0){const y=new Map(l.map(v=>[v.key,v]));d=u.map(v=>y.get(v)).filter(v=>v!==void 0)}else d=l.filter(y=>V0(a.obj[y.key]));const p=new Set(d.map(y=>y.key)),m=l.filter(y=>!p.has(y.key));return{kind:"structured",fields:d,moreFields:m,totalFields:l.length}}const i=e==null?void 0:e.text;return i&&i.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:i}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Cf(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(r=>[r.key,r.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function Pi(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function J0(e,r,a){const i=Xn(e),l=Xn(r);if(!i&&!l){const x=(e==null?void 0:e.text)??"",S=(r==null?void 0:r.text)??"";return x===S?{approved:Pi([]),current:Pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:S},unchanged:!1}}const u=new Map(Zi(e).map(x=>[x.key,x])),d=new Map(Zi(r).map(x=>[x.key,x])),m=[...new Set([...u.keys(),...d.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:Cf(u.get(x))!==Cf(d.get(x))),y=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>m.includes(x)),...m.filter(x=>!a.fields.includes(x))]:m,v=y.map(x=>u.get(x)).filter(x=>x!==void 0),j=y.map(x=>d.get(x)).filter(x=>x!==void 0);return{approved:Pi(v),current:Pi(j),unchanged:m.length===0}}function Q0(e){const r=e==null?void 0:e.structured;if(Array.isArray(r)&&r.every(Mt))return r;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(Mt))return a}return null}function jo(e){const r=$t(e),a=$t(e,!0);return a===r?{value:r}:{value:r,valueTitle:a}}function _p(e){return!e||e.status!=="ok"?[]:Zi(e.body)}function Lc(e){if(!e)return"Not read.";switch(e.status){case"not_found":return e.message?`The system answered: ${e.message}`:"Not found in the system.";case"none":return"Nothing to read.";case"refused":return e.message?ab(e.message):"The system refused to answer.";default:return"Not available right now."}}function uu(e,r,a){var v,j,x;const i=_p(e);if(i.length===0)return{rawId:$t(r),context:[],unresolved:Lc(e)};const l=e&&e.status==="ok"?(v=Xn(e.body))==null?void 0:v.obj:void 0,u=a==null?void 0:a.pathPrefix,d=u?(x=(j=a==null?void 0:a.displayHints)==null?void 0:j.names)==null?void 0:x[u]:void 0,p=d?Mc(l,d):void 0;if(typeof p=="string"&&p.length>0){const S=i.filter(N=>N.key!=="id"&&!to(a==null?void 0:a.displayHints,`${u}.${N.key}`)).map(N=>({...N,label:Or(a==null?void 0:a.displayHints,`${u}.${N.key}`,N.label)}));return{name:p,rawId:$t(r),context:Ef(S,l,u,a)}}const m=i.find(S=>["name","title","label"].includes(S.key))??i.find(S=>typeof(l==null?void 0:l[S.key])=="string"&&!S.lines&&!S.sublist&&!S.diffLines),y=i.filter(S=>S.key!==(m==null?void 0:m.key)&&S.key!=="id").filter(S=>!u||!to(a==null?void 0:a.displayHints,`${u}.${S.key}`)).map(S=>{var E,$;if(!u)return S;const N=`${u}.${S.key}`,w=Or(a==null?void 0:a.displayHints,N,S.label);if(!xs((E=a==null?void 0:a.displayHints)==null?void 0:E.money,N)&&!xs(($=a==null?void 0:a.displayHints)==null?void 0:$.percent,N))return w===S.label?S:{...S,label:w};const{value:k,valueTitle:C}=eo(l==null?void 0:l[S.key],a==null?void 0:a.displayHints,N,a==null?void 0:a.currency);return{...S,label:w,value:k,valueTitle:C}});return{name:m==null?void 0:m.value,rawId:$t(r),context:Ef(y,l,u,a)}}const X0=new Set(["id","name","title","label"]);function xs(e,r){return!!(e!=null&&e.includes(r))}function Or(e,r,a){var i;return((i=e==null?void 0:e.labels)==null?void 0:i[r])??a}function Lp(e,r){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${r?` ${r}`:""}`}:jo(e)}function Z0(e){return typeof e!="number"&&typeof e!="string"?jo(e):{value:`${e} %`}}function eo(e,r,a,i){return xs(r==null?void 0:r.money,a)?Lp(e,i):xs(r==null?void 0:r.percent,a)?Z0(e):jo(e)}function to(e,r){return xs(e==null?void 0:e.hidden,r)}function eb(e,r,a){var d;const i=e==null?void 0:e.currencyField;if(!i)return;const l=i.indexOf(".");if(l<0){const p=r[i];return typeof p=="string"?p:void 0}const u=(d=a(i.slice(0,l)))==null?void 0:d[i.slice(l+1)];return typeof u=="string"?u:void 0}function tb(e,r,a,i){const l=e.forEach??"",u=e.attach,d=e.elements??[],p=Math.min(r.length,d.length),m=r.slice(0,p),y=d.slice(0,p),v=[...new Set(m.flatMap(k=>Object.keys(k)))].filter(k=>k!==e.sourceArg).filter(k=>!to(a,`${l}[].${k}`)),j=new Map;if(u)for(const k of y)for(const C of _p(k))j.has(C.key)||j.set(C.key,C.label);const x=u?[...j.keys()].filter(k=>!X0.has(k)):[],S=!!u&&y.some(k=>k&&k.status!=="none"),N=[];S&&N.push({key:`__attach:${u}`,label:Or(a,`${l}[].${u}`,zt(e.sourceArg??u))});for(const k of v)N.push({key:`bound:${k}`,label:Or(a,`${l}[].${k}`,zt(k))});for(const k of x)N.push({key:`attached:${k}`,label:Or(a,`${l}[].${u}.${k}`,j.get(k)??zt(k))});const w=m.map((k,C)=>{var F;const E=y[C],$=[];if(S){const M=uu(E,e.sourceArg?k[e.sourceArg]:void 0),B=(E==null?void 0:E.status)==="none"?"":M.name?`${M.name} (${M.rawId})`:M.unresolved?`${M.rawId} — ${M.unresolved}`:M.rawId;$.push({value:B,sealed:!1})}for(const M of v){const{value:B,valueTitle:te}=k[M]===void 0||k[M]===null?{value:"",valueTitle:void 0}:eo(k[M],a,`${l}[].${M}`,i);$.push({value:B,valueTitle:te,sealed:!0})}const T=E&&E.status==="ok"?(F=Xn(E.body))==null?void 0:F.obj:void 0;for(const M of x){const B=T==null?void 0:T[M],{value:te,valueTitle:Q}=B!=null?eo(B,a,`${l}[].${u}.${M}`,i):{value:"",valueTitle:void 0};$.push({value:te,valueTitle:Q,sealed:!1})}return{cells:$}});return{columns:N,rows:w,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function nb(e){return`${zt(e)} — from the system`}function rb(e){var l;const r=nb(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=Xn(a.body))==null?void 0:l.obj;return u&&O0(u)?{heading:r,document:u}:{heading:r,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:r,note:Lc(a)}}if(!a||a.status!=="ok")return{heading:r,note:Lc(a)};const i=Q0(a.body);if(i){if(i.length===0)return{heading:r,note:"Nothing found."};const u=[...new Set(i.flatMap(m=>Object.keys(m)))],d=u.map(m=>({key:m,label:zt(m)})),p=i.map(m=>({cells:u.map(y=>({...jo(m[y]),sealed:!1}))}));return{heading:r,table:{columns:d,rows:p}}}return{heading:r,body:Pp(a.body,{fields:e.fields})}}function sb(e,r,a,i={}){const l=new Map(r.filter(w=>w.attach&&!w.forEach&&!w.displayOnly).map(w=>[w.attach,w])),u=new Map(r.filter(w=>w.forEach).map(w=>[w.forEach,w])),d=r.filter(w=>!w.attach&&!w.forEach&&!w.as&&!w.displayOnly),p=r.map(w=>W0(w,a,i.readAt)).filter(w=>w!==null),m=w=>{var C,E;const k=(C=l.get(w))==null?void 0:C.result;return k&&k.status==="ok"?(E=Xn(k.body))==null?void 0:E.obj:void 0},y=eb(a,e,m),v=(a==null?void 0:a.order)??[],j=[...new Set([...v,...Object.keys(e)])],x=[],S=new Set(Object.keys((a==null?void 0:a.compare)??{}));for(const w of j){if(!(w in e)||np.has(w)||to(a,w))continue;if(S.has(w)){x.some(B=>B.kind==="compare")||x.push({kind:"compare",key:"compare",label:"",lines:H0(e,a,m)});continue}const k=Or(a,w,zt(w)),C=u.get(w);if(C){const B=Array.isArray(e[w])?e[w]:[];x.push({kind:"table",key:w,label:k,table:tb(C,B,a,y)});continue}const E=l.get(w);if(E){const B=uu(E.result,e[w],{pathPrefix:w,displayHints:a,currency:y,fields:E.fields});x.push({kind:"identity",key:w,label:k,identity:B});continue}const $=e[w],T=$p($,{key:w,hints:a,currency:y});if(T&&"table"in T){x.push({kind:"table",key:w,label:k,table:T.table});continue}if(T&&Mt($)){const B=Mn($,void 0,!0);x.push({kind:"scalar",key:w,label:k,value:T.text,...B!==T.text?{valueTitle:B}:{}});continue}if(Array.isArray($)){x.push({kind:"scalar",key:w,label:k,value:$.length===0?"—":$.map(B=>$t(B)).join(", ")});continue}const{value:F,valueTitle:M}=eo($,a,w,y);x.push({kind:"scalar",key:w,label:k,value:F,valueTitle:M})}const N=d.map(rb).filter(w=>w!==null);return{rows:x,sections:N,systemBoxes:p}}function ab(e){return e.length>300?`${e.slice(0,299)}…`:e}function Mc(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}const ib=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function ob(e,r){const a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ef(e,r,a,i){var u;let l=e;return(u=i==null?void 0:i.fields)!=null&&u.length&&(l=i.fields.flatMap(d=>{const p=e.find(v=>v.key===d);if(p)return[p];if(!d.includes("."))return[];const m=Mc(r,d);if(m==null||typeof m=="object")return[];const y=Or(i.displayHints,a?`${a}.${d}`:d,zt(d.split(".").pop()));return[{key:d,label:y,value:String(m)}]})),l.filter(d=>{var p,m,y;return((p=d.lines)==null?void 0:p.length)||((m=d.sublist)==null?void 0:m.length)||d.table||((y=d.diffLines)==null?void 0:y.length)||d.value!==void 0&&d.value!==""&&d.value!=="—"}).map(d=>{const p=d.key.includes(".")?Mc(r,d.key):r==null?void 0:r[d.key];return typeof p=="string"&&ib.test(p)?{...d,value:ob(p),valueTitle:p}:d})}const Mp=new Map,Fc=new Set;function lb(e,r){r!==null&&(Mp.set(e,r),Fc.forEach(a=>a()))}function cb(e){return Fc.add(e),()=>Fc.delete(e)}function Fp(e){return f.useSyncExternalStore(cb,()=>Mp.get(e))}function Op(e,r){return a=>{if(!e||e.status!=="ok"||!("reads"in e)||!r)return;const i=e.reads.find(l=>l.attach===a&&!l.forEach&&!l.displayOnly);if(i)return uu(i.result,r[a],{pathPrefix:a,displayHints:e.display}).name}}function ub(e){if(!e||e.status!=="ok")return;const r=e.checks;if(!r||r.length===0)return;const a=r.find(u=>u.status==="fail");if(a)return{text:`✕ ${a.label}: failed`,status:"fail"};const i=r.find(u=>u.status==="not_checked");if(i)return{text:`${i.label}: not checked`,status:"not_checked"};const l=r.find(u=>u.status==="notice");if(l)return{text:l.label,status:"notice"}}async function Af(e){const r=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(a)).map(i=>i.toString(16).padStart(2,"0")).join("")}function db(e){return e.normalize("NFC").replace(/\r\n?/g,`
68
68
  `).split(`
69
69
  `).map(l=>l.replace(/[ \t]+$/,"")).join(`
70
- `).replace(/\n+$/,"")}function Fc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":Fc(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+Fc(l))}return"{"+a.join(",")+"}"}async function zp(e,r){if(e==="jcs"){if(typeof r=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Tf(Fc(r))}`}if(typeof r!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Tf(cb(r))}`}async function Dp(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:r}=await P.decryptProposalContent(e.content),a=JSON.parse(r);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function ub(e){if(!e.content)return[];const r=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(r).filter(i=>!a.has(i))}function db(e){return!e.loading&&e.readable}function Bp(e,r){const a=new Set;if(e.content)for(const i of Object.keys(e.content.keys))a.add(i);else{e.createdBy&&a.add(e.createdBy);for(const i of e.pendingApprovers??[])a.add(i)}return r&&a.add(r),Array.from(a)}async function du(e){const r=await Dp(e);if(r)return zp("jcs",r)}function hb(e){var i;const[r,a]=f.useState((e==null?void 0:e.note)??null);return f.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),P.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(i=e==null?void 0:e.noteEncrypted)==null?void 0:i.ciphertext]),r}const fb={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function xa(e){var i;const[r,a]=f.useState(fb);return f.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Dp(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(i=e.content)==null?void 0:i.ciphertext,e.toolArgs]),r}const If=140,Rf=60,mb=/\{([^{}]+)\}/g;function Up(e,r){var u,d;const{integrationId:a,toolName:i}=Fn(e),l=r==null?void 0:r.find(p=>p.id===a);return((d=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:d[i])??void 0}function Wp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object")return;a=a[i]}return a}function $f(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function pb(e,r,a,i){if(r==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(i,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(i,{maximumFractionDigits:2}).format(u)}if(r==="percent")return`${e}%`;if(r==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(i,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(d=>typeof d=="object"&&d!==null?JSON.stringify(d):String(d));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return r==="short"&&l.length>Rf?`${l.slice(0,Rf-1).trimEnd()}…`:l}function Pf(e,r,a,i,l){let u=!1;const d=e.replace(mb,(p,m)=>{const[y,v]=m.split("|").map(x=>x.trim()),j=y.split(",").map(x=>Wp(r,x.trim())).find($f);if(!$f(j))return u=!0,"";if(v==="ref"){const x=l==null?void 0:l(y.split(",")[0].trim()),S=String(j),N=S.length>12?`${S.slice(0,8)}…`:S;return x?`${x} (${N})`:S}return pb(j,v,a,i)});return u?null:d}function Hp(e,r,a={}){const i=Wp(r,a.currencyField??"currency"),l=typeof i=="string"?i:void 0,u=e.replace(/\[([^[\]]*)\]/g,(m,y)=>Pf(y,r,l,a.locale,a.refName)??""),d=Pf(u,r,l,a.locale,a.refName);if(d===null)return null;const p=d.replace(/\s+/g," ").trim();return p.length>If?`${p.slice(0,If-1).trimEnd()}…`:p}function Vp(e,r,a,i,l){var p;const u=zt(Fn(e).toolName),d=Up(e,a);return!(d!=null&&d.summary)||!r?u:Hp(d.summary,r,{currencyField:(p=d.display)==null?void 0:p.currencyField,locale:i,refName:l})??u}function gb(e,r,a,i){var u;const l=Up(e,a);return!(l!=null&&l.summary)||!r?null:Hp(l.summary,r,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:i})}const Di="Commitment",no={title:"Review Each Action",text:"You review and approve each action before it executes."},ro={title:"Automatic",text:"Agent acts freely within your limits."},qp="setup__create_mandate",vb=["proposal","profile_version","workspace","mode","intent","checks","title"];function yb(e){if(typeof e!="string"||!e.trim())return null;switch(e.trim()){case"review":return{label:Di,...no};case"automatic":return{label:Di,...ro};default:return{label:Di,title:e.trim(),text:""}}}function xb(e){const r=a=>typeof a=="string"&&a.trim()?a.trim():void 0;return{intent:r(e==null?void 0:e.intent),mode:r(e==null?void 0:e.mode),proposal:r(e==null?void 0:e.proposal),profileVersion:r(e==null?void 0:e.profile_version),workspace:r(e==null?void 0:e.workspace),title:r(e==null?void 0:e.title),checks:Array.isArray(e==null?void 0:e.checks)?e.checks.filter(a=>typeof a=="string"&&a.trim()!==""):[]}}function jb(e){return[e.proposal,e.profileVersion].filter(Boolean).join(" · ")||"new mandate"}function Kp(e,r){const a=r==null?void 0:r.title;return{area:e,name:typeof a=="string"&&a.trim()?a.trim():null}}function so(e,r){const a=e==null?void 0:e.profile;return typeof a=="string"&&a?a:r}function wb({proposal:e,manifests:r}){const a=xa(e),i=Fp(e.id),l=On();if(e.tool===qp&&a.toolArgs){const u=Kp(Br(so(a.toolArgs,e.profileId),l),a.toolArgs);return n.jsxs(n.Fragment,{children:[u.area," · ",u.name??"new mandate"]})}return n.jsx(n.Fragment,{children:Vp(e.tool,a.toolArgs,r,void 0,Op(i,a.toolArgs))})}const bb="setup__create_mandate";function Gp({proposal:e,manifests:r,titles:a,selected:i=!1,onOpen:l,who:u}){const d=Date.now(),p=pp(e.expiresAt,d),m=On(),y=Fp(e.id),v=lb(y),j=xa(e),x=e.tool===bb,S=x?so(j.toolArgs,e.profileId):e.profileId,N=Br(S,m),w=e.authorizationId?a[e.authorizationId]:void 0,k=Ec(w,N)?w:void 0,C=[k,v==null?void 0:v.text].filter(Boolean);return n.jsx("div",{className:`av3-row${i?" is-selected":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:n.jsxs("button",{type:"button",className:"appr-item-head av3-row-head","aria-current":i||void 0,onClick:l,children:[n.jsxs("span",{className:"av3-type",children:[x?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Dr,{icon:Jn(S)}),N]}),n.jsx("span",{children:mp(e.createdAt*1e3,d)})]}),n.jsx("span",{className:"av3-row-title","data-testid":"approval-row-summary",children:n.jsx(wb,{proposal:e,manifests:r})}),(C.length>0||u||p)&&n.jsxs("span",{className:"av3-row-meta",children:[k&&n.jsx("span",{children:k}),v&&n.jsx("b",{className:v.status==="fail"?"av3-flag-fail":void 0,children:v.text}),p&&n.jsx("span",{children:p}),u&&n.jsx("span",{children:u})]})]})})}function mc({variant:e="base",style:r,className:a,...i}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:r,role:"status","aria-busy":"true","aria-label":i["aria-label"]??"Loading"})}const yr=5;function _f(e){return e.replace(/^today\s+/i,"")}function pc(e,r){return e&&e.trim().toLowerCase()!==r.trim().toLowerCase()?`via ${e}`:null}function kb({auths:e,activeCount:r,waiting:a,waitingReady:i}){const[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState([]),[v,j]=f.useState({}),[x,S]=f.useState({}),N=f.useCallback(()=>{P.getMyReceiptsPage({limit:200}).then(_=>u(_.receipts)).catch(()=>u(_=>_??[])),P.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Ht(N,3e5),Ke("ticket-recorded",N),f.useEffect(()=>{P.getLabelManifests().then(y).catch(()=>{}),P.getLocalAuthorizations().then(({authorizations:_})=>j(_)).catch(()=>{})},[]);const w=On(),k=f.useMemo(()=>{const _={};for(const z of e)z.authorization_id&&z.title&&(_[z.authorization_id]=z.title);return _},[e]),C=Date.now(),E=f.useMemo(()=>{const _=Date.now();return(l??[]).filter(z=>Ur(z.timestamp,_))},[l]);f.useEffect(()=>{const _=[...new Set(E.map(z=>z.profileId))].filter(z=>!(z in x));_.length!==0&&Promise.all(_.map(z=>xo(z).then(V=>[z,V]).catch(()=>[z,null]))).then(z=>S(V=>({...V,...Object.fromEntries(z)})))},[E,x]);const $=f.useMemo(()=>_w(E,{catalog:w,manifests:m,titles:k,lastSeenMs:d??Number.POSITIVE_INFINITY}),[E,w,m,k,d]),T=E.filter(_=>Ji(_,"approved")).length,F=f.useMemo(()=>Lw(E,{nowMs:Date.now(),catalog:w,manifests:m,titles:k,boundsOf:_=>{var z;return(z=v[_])==null?void 0:z.bounds},profileOf:_=>x[_]}),[E,w,m,k,v,x]),M=$.filter(_=>_.newCount>0).length,B=[...a].sort((_,z)=>_.createdAt-z.createdAt),te=E.filter(_=>Ji(_,"approved")).sort((_,z)=>z.timestamp-_.timestamp).slice(0,Math.max(0,yr-Math.min($.length,yr))),Q=yn();return n.jsxs("div",{className:"core-cols dash-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),i?B.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):n.jsx("div",{className:"dash-rows",children:B.slice(0,yr).map(_=>n.jsx("div",{"data-testid":"dash-approval",children:n.jsx(Gp,{proposal:_,manifests:m,titles:k,onOpen:()=>Q(`/approvals?open=${encodeURIComponent(_.id)}`)})},_.id))}):n.jsx(mc,{variant:"line"}),B.length>0&&n.jsx(pt,{to:"/approvals",className:"ob-btn dash-btn",children:"All approvals"})]}),n.jsxs("section",{"aria-label":"Done today","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done today"}),M>0&&n.jsxs("span",{className:"meta",children:[$.reduce((_,z)=>_+z.newCount,0)," new"]})]}),l===null?n.jsx(mc,{variant:"line"}):$.length===0&&te.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done today."}):n.jsxs("div",{className:"dash-rows",children:[$.slice(0,yr).map(_=>n.jsxs("details",{className:`ob-card dash-row auto-grp${_.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx(At,{tag:"Ticket",className:"obj-line",profileId:_.profileId,parts:[n.jsx("span",{className:"sr-only",children:_.area},"a"),pc(_.system,_.area),_f(ma(_.latestSec,C)),n.jsx("span",{className:"ob-st",children:"Automatic"},"st")]}),n.jsxs("span",{className:"ob-title",children:[_.area," · ",_.count," × ",_.label]}),n.jsxs("span",{className:"ob-one",children:[Ec(_.mandateTitle,_.area)&&n.jsxs("span",{"data-testid":"mandate-line",children:["Mandate: ",_.mandateTitle]}),n.jsx("span",{children:_.newCount>0?n.jsxs("b",{className:"ob-bold",children:[_.newCount," new"]}):"seen"})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[_.tickets.slice(0,yr).map(z=>n.jsxs("div",{className:"auto-grp-row",children:[ys(z,m),n.jsxs("span",{className:"t",children:[ma(z.timestamp,C)," · ",lu(z.id),Qi(z,d??Number.POSITIVE_INFINITY)?" · new":""]})]},z.id)),_.tickets.length>yr&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",_.tickets.length-yr," more in Tickets"]})]})]},_.key)),te.map(_=>{const z=Br(_.profileId,w),V=yo(_.action,m),K=_.authorizationId?k[_.authorizationId]:void 0;return n.jsxs(pt,{to:"/tickets?filter=approved",className:"ob-card dash-row","data-testid":"dash-approved-ticket",children:[n.jsx(At,{tag:"Ticket",className:"obj-line",profileId:_.profileId,parts:[n.jsx("span",{className:"sr-only",children:z},"a"),pc(V,z),_f(ma(_.timestamp,C)),n.jsx("span",{className:"ob-st",children:"Approved"},"st")]}),n.jsxs("span",{className:"ob-title",children:[z," · ",ys(_,m)]}),Ec(K,z)&&n.jsxs("span",{className:"ob-one","data-testid":"mandate-line",children:["Mandate: ",K]})]},_.id)})]}),($.length>0||te.length>0)&&n.jsx(pt,{to:$.length>0?"/tickets?filter=automatic":"/tickets",className:"ob-btn dash-btn","data-testid":"btn-automatic-tickets",children:"All tickets"}),T>te.length&&n.jsxs("div",{className:"core-quiet-line",children:[T," approved today — ",n.jsx(pt,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(mc,{variant:"line"}):F.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):n.jsx("div",{className:"dash-rows",children:F.slice(0,yr).map(_=>{var z;return n.jsxs(pt,{to:"/mandates",className:"ob-card dash-row mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(At,{tag:"Mandate",className:"obj-line",profileId:_.profileId,parts:[_.area,pc(_.system,_.area)]}),n.jsx("span",{className:"ob-title",children:(z=_.mandateTitle)!=null&&z.trim()?_.mandateTitle:_.area}),n.jsx("span",{className:"ob-one",children:_.limit!==void 0?Mw(_)?n.jsxs("b",{className:"ob-bold",children:[_.used," of ",_.limit," used today"]}):`${_.used} of ${_.limit} used today`:`${_.used} ${_.used===1?"action":"actions"} today`})]},_.authorizationId)})}),l!==null&&r>F.length&&n.jsxs("p",{className:"core-quiet-line",children:[r-F.length," more mandate",r-F.length===1?"":"s"," in force — no actions today."]}),r>0&&n.jsx(pt,{to:"/mandates",className:"ob-btn dash-btn",children:"All mandates"})]})]})}function Sb(){const[e,r]=f.useState(null),[a,i]=f.useState(Number.POSITIVE_INFINITY),l=f.useCallback(()=>{Promise.all([P.getReport().then(p=>p.report).catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,m])=>{r(p),i(m)})},[]);if(Ht(l,3e5),Ke("report-written",l),!e||!up(e,a))return null;const{verified:u,unchecked:d}=Sw(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:kw(e.renderedHtml)})," — ",n.jsx("span",{title:Gi(e.coverage).title,children:Gi(e.coverage).text})," · written ",dp(e.savedAt,Date.now()),d===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",d," could not be checked"]})]})]}),n.jsx(pt,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function Nb(){const[e,r]=f.useState([]);return Ht(async()=>{try{const{skipped:i}=await P.getSkippedCommitments();r(i)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(i=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:i.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",i.id,")"]})]},i.id))})]})}const Cb=1800;function ca(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Eb(){const{domain:e}=Nt(),[r,a]=f.useState([]),[i,l]=f.useState([]),[u,d]=f.useState([]),[p,m]=f.useState(!0),[y,v]=f.useState(!1),[j,x]=f.useState([]),[S,N]=f.useState(!1),[w,k]=f.useState(!1),[C,E]=f.useState(null),[$,T]=f.useState(!1),{entries:F,activeSessions:M,loading:B}=iu(),te=$0(),Q=!B,{simulation:_}=Ep(),z=_===!0,V=L0(),K=f.useCallback(()=>{P.getMyAttestations().then(oe=>{a(oe),v(!0)}).catch(()=>v(!0)),P.getArchivedMandates().then(x).catch(()=>x([])),P.getMyProposals(e).then(oe=>{l(oe),N(!0)}).catch(()=>N(!0)),P.getProposalsForApprover().then(oe=>d(oe)).catch(()=>d([])),P.getCredential("ai-config").then(oe=>{m(oe.configured),k(!0)}).catch(()=>k(!0)),P.getAgentContact().then(oe=>{E(oe.contact),T(!0)}).catch(()=>T(!0))},[e]);Ke("attestation-changed",K),Ke("proposal-added",K),Ke("proposal-resolved",K),Ke("proposal-approved",K),Ke("proposal-rejected",K),Ke("execution-failed",K),Ht(K,3e5,e);const le=y&&S&&w&&Q&&$&&_!==null,me=Ym(r,{archivedSet:new Set(j)}),we=me.active,Ae=me.expired,Z=we.some(oe=>ca(oe.profile_id)==="delegation"),G=we.filter(oe=>ca(oe.profile_id)!=="delegation").length,J=i.filter(oe=>ca(oe.profileId)==="delegation").length,I=Cp({hasContact:C!==null,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:J,managed:V,simulationOn:z}),D=z&&I.visible,pe=we.filter(oe=>oe.remaining_seconds!==null&&oe.remaining_seconds<=Cb),de=i.filter(xp),$e=F.filter(oe=>oe.state==="running"),ve=F.filter(oe=>oe.state==="starting"),Y=Hj(F),he=[...de,...u.filter(oe=>!de.some(Oe=>Oe.id===oe.id))],ee=[];for(const oe of pe){const Oe=Math.ceil((oe.remaining_seconds??0)/60);ee.push({label:"Expiring soon",detail:`${oe.title??ca(oe.profile_id)} — ${Oe} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const oe of Ae)ee.push({label:"Expired",detail:oe.title??ca(oe.profile_id),to:"/mandates",color:"var(--text-primary)"});ee.push(...Wj(F,z));for(const oe of ve)ee.push({label:"Integration starting",detail:`${oe.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const oe of F)oe.authStatus==="failed"&&oe.state!=="not-running"&&oe.state!=="error"&&oe.state!=="paused"&&ee.push({label:"Reconnect needed",detail:`${oe.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return p||ee.push({label:"AI Assistant",detail:"Optional — not set up yet. Helps you write mandates and the brief.",to:"/settings#ai-assistant",color:"var(--text-tertiary)"}),n.jsxs("div",{className:"dash-page",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Dashboard"})}),le&&te&&(D?n.jsx(R0,{contact:C,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:J,managed:V,simulationOn:z,mcpEndpoint:te}):!z&&n.jsx(T0,{aiConfigured:p,hasRunningIntegration:$e.length>0,hasActiveAuth:we.length>0,hasAgentConnected:M>0,mcpEndpoint:te})),!D&&n.jsxs(n.Fragment,{children:[n.jsx(kb,{auths:r,activeCount:we.length,waiting:he,waitingReady:S}),n.jsx(Sb,{})]}),Y&&n.jsxs("div",{className:"sim-paused-summary",role:"status",children:[n.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),n.jsxs("span",{children:[n.jsxs("b",{children:[Y.count," real system",Y.count===1?"":"s"," ",Y.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Y.namesText,"."]})]}),n.jsx(Nb,{}),n.jsx(lw,{}),!D&&ee.length>0&&n.jsxs("section",{className:"dash-sec","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Setup — needs attention"}),n.jsx("span",{className:"pill-count",children:ee.length})]}),n.jsx("div",{className:"ob-card dash-att",children:ee.map((oe,Oe)=>n.jsxs(pt,{to:oe.to,className:"dash-att-row",children:[n.jsx("b",{children:oe.label}),n.jsx("span",{children:oe.detail}),n.jsx("i",{"aria-hidden":"true",children:"›"})]},Oe))})]})]})}const Ab=["Scope & Limits","Intent","Sign"];function Yp({currentStep:e,onStepClick:r}){const a=yn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:Ab.map((i,l)=>{const u=l+2,d=u<e,p=u===e,m=u-1<e,y=d&&!!r;return n.jsxs("li",{className:`wizard-step${m?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${d?" completed":""}${p?" current":""}`,onClick:y?()=>r(u):void 0,disabled:!y,"aria-label":`${i}${d?" (done)":p?" (current)":""}`,children:d?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":d?" completed":""}`,children:i})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function Tb({profileId:e,bounds:r,groupName:a,domain:i,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),i?` / ${i}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Vt(e)]}),r&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",r]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function Ib({integrationId:e,field:r,value:a,onChange:i,disabled:l,onLabels:u}){const[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState(!0);f.useEffect(()=>{let N=!1;return P.discoverScopeField(e,r).then(w=>{var k;N||(p(w.options),j(!1),(k=w.options)!=null&&k.length&&(u==null||u(Object.fromEntries(w.options.map(C=>[C.value,C.label])))))}).catch(w=>{N||(y(w instanceof Error?w.message:String(w)),j(!1))}),()=>{N=!0}},[e,r]);const x=new Set(a.split(",").map(N=>N.trim()).filter(Boolean)),S=N=>{const w=new Set(x);w.has(N)?w.delete(N):w.add(N),i(Array.from(w).join(","))};return v?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):m||!d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",m??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:N=>i(N.target.value),disabled:l})]}):d.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:d.map(N=>{const w=N.extras??{},k=typeof w.access=="string"?w.access:void 0,C=k==="reader",E=w.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:C?"var(--text-tertiary)":"var(--text-primary)",cursor:l||C?"not-allowed":"pointer"},title:C?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(N.value)),onChange:()=>S(String(N.value)),disabled:l||C}),n.jsx("span",{children:N.label||N.value}),E&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),k&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",k]})]},N.value)})})}function hu(e){if(e.type!=="number")return 0;const r=e.boundType,a=e.unit;return(r==null?void 0:r.kind)==="per_transaction"&&a==="count"?1:0}function Lf(e,r){if(r!==void 0)return String(r);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):hu(e)===1?"1":""}function Oc(e){const r=e.maximum;return typeof r=="number"&&Number.isFinite(r)?r:void 0}function Mf(e,r){const a=hu(e),i=Oc(e),l=r===""?a:Math.max(a,Number(r));return i!==void 0?Math.min(i,l):l}function Rb(e,r){var i;const a=(i=e.capKinds)==null?void 0:i[r];return a||(e.approvers.length>0?"approval":"hard")}function fu(e,r,a){var i;return e.approvers.length===0||(r==null?void 0:r.enforcedBy)==="gatekeeper"||((i=r==null?void 0:r.boundType)==null?void 0:i.kind)==="enum"?"hard":Rb(e,a)}function Jp(e,r,a){const i=e.indexOf(r),l=e.indexOf(a);return i===-1||l===-1?!1:l<i}function ao(e,r){var a;return((a=e.caps)==null?void 0:a[r])!==void 0}function $b(e,r,a){const i=Object.entries(r.caps??{}).filter(([u])=>fu(r,a[u],u)==="approval");if(i.length===0)return null;const l=u=>{var d;return((d=a[u])==null?void 0:d.displayName)??u};for(const[u,d]of i){const p=a[u],m=p==null?void 0:p.boundType,y=(m==null?void 0:m.kind)==="per_transaction"||(m==null?void 0:m.kind)==="cumulative_sum"?m.of:void 0,v=y?e[y]:void 0;if(typeof d=="number"&&typeof v=="number"&&v>d)return{field:u,fieldLabel:l(u),cap:d,value:v}}if(i.length===1){const[u,d]=i[0];return{field:u,fieldLabel:l(u),cap:d}}return null}function Pb(e){return(e==null?void 0:e.valuesFrom)==="profiles"}const Qp=e=>(e.replace(/@.*$/,"").split("/").pop()??e).toLowerCase(),Ff=e=>e.split("@")[1]??"";function _b(e){const r=new Map;for(const{id:a}of e){const i=Qp(a),l=r.get(i);(!l||Ff(a).localeCompare(Ff(l),void 0,{numeric:!0})>0)&&r.set(i,a)}return[...r.values()]}function Lb(e,r,a){var l;const i=((l=e.constraint)==null?void 0:l.requiredFor)??[];return r.filter(u=>a(u.id)).filter(u=>{var d;return!(((d=u.boundsSchema)==null?void 0:d.actionTypes)??[]).some(p=>i.includes(p))}).map(u=>Qp(u.id)).sort((u,d)=>u.localeCompare(d))}function Mb(e,r){var m;const[a,i]=f.useState({}),l=Object.entries(((m=e.scopeSchema)==null?void 0:m.fields)??{}).filter(([,y])=>Pb(y)),u=l.length>0,d=r==null?void 0:r.groupId,p=!!(r!=null&&r.isPersonal);return f.useEffect(()=>{if(!u)return;let y=!0;return(async()=>{const v=_b(await ep()),j=(await Promise.all(v.map(N=>xo(N)))).filter(N=>!!N);let x;if(p)x=()=>!0;else if(d){const N=await Promise.all(j.map(k=>P.getTeamProfileConfig(d,k.id).catch(()=>null))),w=new Set(j.filter((k,C)=>N[C]).map(k=>k.id));x=k=>w.has(k)}else x=()=>!1;const S={};for(const[N,w]of l)S[N]=Lb(w,j,x);y&&i(S)})(),()=>{y=!1}},[e.id,u,d,p]),a}function Fb(e){return e.replace(/@.*$/,"").split("/").pop()??e}function mu(e,r){return r.displayName?r.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Ob(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function zb(e){var a;const r=e;return!!(r.enum&&((a=r.constraint)!=null&&a.enforceable.includes("subset")))}function Db(e,r){if(!e)return;const a=(r??"").split(",").map(i=>i.trim()).filter(Boolean);return[...e,...a.filter(i=>!e.includes(i))]}function Of(e,r){const a=e.trim();return a?r==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:r==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Bb(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Ub(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Wb(e,r){if(!e||!r)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(r==="minutes"&&a>=60){const i=Math.floor(a/60),l=a%60;return l===0?`${i} hour${i!==1?"s":""}`:`${i}h ${l}m`}if(r==="hours"&&a>=24&&a%24===0){const i=a/24;return`${i} day${i!==1?"s":""}`}if(r==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function Hb({id:e,value:r,onChange:a,disabled:i,placeholder:l,unit:u,min:d=0,max:p}){const m=Bb(u),y=Ub(u).filter(w=>p===void 0||w.value<=p),v=vo(u),j=Wb(r,u),x=r===""?null:Number(r),S=()=>{const w=r===""?0:Number(r),k=w%m,C=k===0?w+m:w+(m-k);a(String(p!==void 0?Math.min(p,C):C))},N=()=>{const w=r===""?0:Number(r);if(w<=d)return;const k=w%m,C=k===0?w-m:w-k;a(String(Math.max(d,C)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:N,disabled:i||r===""||Number(r)<=d,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:d,max:p,step:m,value:r,placeholder:l??String(d),onChange:w=>{const k=w.target.value;a(p!==void 0&&k!==""&&Number(k)>p?String(p):k)},onFocus:w=>w.target.select(),disabled:i}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:S,disabled:i||p!==void 0&&r!==""&&Number(r)>=p,"aria-label":"Increase",children:"+"}),v&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:v})]}),y.length>0&&!i&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:y.map(w=>n.jsx("button",{type:"button",className:`preset-chip${x===w.value?" preset-chip-selected":""}`,onClick:()=>a(String(w.value)),children:w.label},w.value))}),j&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",j]})]})}function zf({htmlFor:e,label:r,description:a}){const[i,l]=f.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:r}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${r}" mean?`,"aria-expanded":i,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),i&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function Vb({id:e,value:r,onChange:a,disabled:i,format:l,placeholder:u}){const[d,p]=f.useState(""),[m,y]=f.useState(!1),v=f.useRef(null),j=r?r.split(",").map(C=>C.trim()).filter(Boolean):[],x=C=>{const E=C.trim();if(!E)return;if(!Of(E,l)){y(!0);return}y(!1);const $=j.includes(E)?j:[...j,E];a($.join(",")),p("")},S=C=>{const E=j.filter(($,T)=>T!==C);a(E.join(","))},N=C=>{C.key==="Enter"||C.key===","||C.key==="Tab"?d.trim()&&(C.preventDefault(),x(d)):C.key==="Backspace"&&!d&&j.length>0&&S(j.length-1)},w=C=>{const E=C.clipboardData.getData("text");if(E.includes(",")){C.preventDefault();const T=E.split(",").map(M=>M.trim()).filter(Boolean).filter(M=>Of(M,l)),F=[...new Set([...j,...T])];a(F.join(",")),p(""),y(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${m?" tag-input-invalid":""}`,onClick:()=>{var C;return(C=v.current)==null?void 0:C.focus()},children:[j.map((C,E)=>n.jsxs("span",{className:"tag-pill",children:[C,!i&&n.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),S(E)},"aria-label":`Remove ${C}`,children:"×"})]},C)),!i&&n.jsx("input",{ref:v,id:e,className:"tag-input-field",type:"text",value:d,onChange:C=>{p(C.target.value),y(!1)},onKeyDown:N,onPaste:w,onBlur:()=>{d.trim()&&x(d)},placeholder:j.length===0?u??k:""})]})}function qb({id:e,options:r,value:a,onChange:i,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],d=p=>{const m=u.includes(p)?u.filter(y=>y!==p):[...u,p];i(m.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:r.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>d(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function Df({fieldKey:e,fieldDef:r,value:a,onChange:i,prefix:l,readOnly:u,twoColumn:d,discoveryIntegrationId:p,onLabels:m,capMax:y,enumAllowedFrom:v,options:j}){const x=mu(e,r),S=`${l}-field-${e}`,N=n.jsx(n.Fragment,{children:zb(r)||j?n.jsx(qb,{id:S,options:j??r.enum,value:a,onChange:w=>i(e,w),disabled:u}):(()=>{const w=r.boundType;return(w==null?void 0:w.kind)==="enum"&&Array.isArray(w.values)})()?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:w=>i(e,w.target.value),disabled:u||v!==void 0&&r.boundType.values.length-v<=1,children:[n.jsx("option",{value:"",children:"Select..."}),r.boundType.values.map((w,k)=>n.jsx("option",{value:w,disabled:v!==void 0&&k<v,children:w},w))]}):r.enum?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:w=>i(e,w.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),r.enum.map(w=>n.jsx("option",{value:w,children:w},w))]}):r.type==="number"?n.jsx(Hb,{id:S,value:a,onChange:w=>i(e,w),disabled:u,unit:r.unit,min:hu(r),max:y!==void 0?Math.min(y,Oc(r)??y):Oc(r)}):Ob(r)?n.jsx(Vb,{id:S,value:a,onChange:w=>i(e,w),disabled:u,format:r.format}):p?n.jsx(Ib,{integrationId:p,field:e,value:a,onChange:w=>i(e,w),disabled:u,onLabels:w=>m==null?void 0:m(e,w)}):n.jsx("input",{id:S,className:"form-input",type:"text",value:a,onChange:w=>i(e,w.target.value),disabled:u})});return d?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(zf,{htmlFor:S,label:x,description:r.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(zf,{htmlFor:S,label:x,description:r.description}),N]},`${l}-${e}`)}function Kb(e,r,a,i){if(!i||!ao(i,e))return null;const l=i.caps[e],u=fu(i,r,e);let d=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);d=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=r.boundType;d=(p==null?void 0:p.kind)==="enum"?Jp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:d}}function Bf(e,r,a,i){if(!i||!ao(i,e))return a;const l=fu(i,r,e),u=i.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const d=a===""?NaN:Number(a);return String(Number.isNaN(d)?u:Math.min(d,u))}if(typeof u=="string"){const d=r.boundType,p=(d==null?void 0:d.kind)==="enum"?d.values??[]:[];return a!==""&&Jp(p,u,a)?u:a}return a}function Gb(e,r){if(typeof r!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const i=(a.values??[]).indexOf(r);return i===-1?void 0:i}function Yb(e,r){return vo(r.unit)||mu(e,r).toLowerCase()}function Xp(e,r){if(r&&r.length>0)return r.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Jb(e,r,a,i,l){var y;const u=r.enforcedBy==="gatekeeper",d=((y=r.boundType)==null?void 0:y.kind)==="enum";if(a.kind==="hard")return d?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",mu(e,r).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=Yb(e,r),m=Xp(i,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",m," for approval."]})}function Qb({profile:e,onConfirm:r,onCancel:a,readOnly:i,initialBounds:l,initialContext:u,initialFrame:d,profileConfig:p,approverNames:m,adminName:y,workspace:v}){var ve;const j=e.boundsSchema,x=Mb(e,v),S=e.scopeSchema,N=Y=>!!p&&ao(p,Y),w=j?Object.entries(j.fields).filter(([Y,he])=>!(Y==="profile"||Y==="path"||he.enforced===!1||he.enforcedBy==="gatekeeper"&&!N(Y))):[],k=j?Object.entries(j.fields).filter(([Y,he])=>he.enforcedBy==="gatekeeper"&&!N(Y)).filter(([,Y])=>Y.enforced!==!1).map(([Y,he])=>he.displayName??Y):[],C=S&&S.keyOrder.length>0?Object.entries(S.fields):[],E=l??d??{},$=u??{},T={};for(const[Y,he]of w)T[Y]=Bf(Y,he,Lf(he,E[Y]),p);const F={};for(const[Y]of C)F[Y]=$[Y]!==void 0?String($[Y]):"";const[M,B]=f.useState(T),[te,Q]=f.useState(F),[_,z]=f.useState({}),V=f.useRef(new Set);f.useEffect(()=>{B(Y=>{let he=!1;const ee={...Y};for(const[oe,Oe]of w){if(V.current.has(oe))continue;const Fe=Y[oe]!==void 0?Y[oe]:Lf(Oe,E[oe]),se=Bf(oe,Oe,Fe,p);ee[oe]!==se&&(ee[oe]=se,he=!0)}return he?ee:Y})},[p]);const[K,le]=f.useState(null);f.useEffect(()=>{const Y=Fb(e.id);P.getIntegrationManifests().then(({manifests:he})=>{const ee=he.find(oe=>oe.profile===Y&&oe.contextDiscovery&&Object.keys(oe.contextDiscovery).length>0);le(ee??null)}).catch(()=>le(null))},[e.id]);const me={};for(const[Y,he]of w)me[Y]=Kb(Y,he,M[Y]??"",p);const we=Object.entries(me).filter(([,Y])=>(Y==null?void 0:Y.kind)==="hard"&&Y.violating).map(([Y])=>Y),Ae=!!p&&(((ve=p.approvers)==null?void 0:ve.length)??0)>0&&w.every(([Y])=>!ao(p,Y)),Z=(Y,he)=>{V.current.add(Y),B(ee=>({...ee,[Y]:he}))},G=(Y,he)=>{Q(ee=>({...ee,[Y]:he}))},J=()=>{const Y={profile:e.id};for(const[ee,oe]of w)oe.type==="number"?Y[ee]=Mf(oe,M[ee]):Y[ee]=M[ee];const he={};for(const[ee,oe]of C)oe.type==="number"?he[ee]=te[ee]===""?0:Number(te[ee]):he[ee]=te[ee];return[Y,he]},I=()=>{const[Y,he]=J();r(Y,he,_)},D=()=>{var oe;const Y={...M};for(const Oe of we){const Fe=(oe=me[Oe])==null?void 0:oe.cap;Fe!==void 0&&(Y[Oe]=String(Fe))}B(Y);const he={profile:e.id};for(const[Oe,Fe]of w)Fe.type==="number"?he[Oe]=Mf(Fe,Y[Oe]??""):he[Oe]=Y[Oe]??"";const ee={};for(const[Oe,Fe]of C)Fe.type==="number"?ee[Oe]=te[Oe]===""?0:Number(te[Oe]):ee[Oe]=te[Oe];r(he,ee,_)},pe=()=>{if(!Ae)return null;const Y=Xp(p,m);return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",Y]}),n.jsxs("div",{children:["No caps are set on this profile, so ",Y," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})},de=()=>{if(we.length===0)return null;const Y=y??"the team admin";return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"2px solid var(--border-strong)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsx("div",{className:"msg-error",style:{marginBottom:"0.25rem"},children:"Hard team ceiling."}),n.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Lower the bound(s) above, or ask ",Y," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:D,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},$e=we.length>0;return n.jsxs("div",{children:[C.length>0&&n.jsxs("div",{className:"context-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🛡"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),C.map(([Y,he])=>{var oe;const ee=!!((oe=K==null?void 0:K.contextDiscovery)!=null&&oe[Y]);return n.jsx(Df,{fieldKey:Y,fieldDef:he,value:te[Y],onChange:G,prefix:"context",readOnly:i,discoveryIntegrationId:ee?K.id:void 0,onLabels:(Oe,Fe)=>z(se=>({...se,[Oe]:Fe})),options:Db(x[Y],te[Y])},`context-${Y}`)})]}),w.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:w.map(([Y,he])=>{const ee=me[Y];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(Df,{fieldKey:Y,fieldDef:he,value:M[Y],onChange:Z,prefix:"bounds",readOnly:i,twoColumn:!0,capMax:(ee==null?void 0:ee.kind)==="hard"&&typeof ee.cap=="number"?ee.cap:void 0,enumAllowedFrom:(ee==null?void 0:ee.kind)==="hard"?Gb(he,ee.cap):void 0}),ee&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Jb(Y,he,ee,p,m)})]},`bounds-${Y}`)})}),pe(),de(),k.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[k.join(", ")," ",k.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",n.jsx(pt,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:I,disabled:$e,style:{marginTop:"0.5rem"},children:i?"Next: Gates":"Next: Problem Statement"})]})}function Xb(e){var a;const r=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=r==null?void 0:r[1])==null?void 0:a.trim())??null}function Zb(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const ek="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function io({target:e,currentText:r,onApply:a,greeting:i,placeholder:l,title:u}){const[d,p]=f.useState([{role:"assistant",content:i??ek}]),[m,y]=f.useState(""),[v,j]=f.useState(!1),[x,S]=f.useState(null),N=f.useRef(null),w=f.useRef(null);f.useEffect(()=>{const E=N.current;if(!E)return;const $=d[d.length-1],T=w.current;!v&&($==null?void 0:$.role)==="assistant"&&d.length>1&&T?E.scrollTop=T.offsetTop:E.scrollTop=E.scrollHeight},[d,v]);const k=async()=>{const E=m.trim();if(!E||v)return;const $=[...d,{role:"user",content:E}];p($),y(""),S(null),j(!0);try{const T=await P.aiChat({target:e,currentText:r,messages:$.filter((F,M)=>!(M===0&&F.role==="assistant"))});T.success&&T.reply?p(F=>[...F,{role:"assistant",content:T.reply}]):S(T.error??"AI returned no reply")}catch(T){S(T instanceof Error?T.message:"Chat failed")}finally{j(!1)}},C=E=>{E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),k())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:N,className:"chat-messages",children:[d.map((E,$)=>{const T=E.role==="assistant"?Xb(E.content):null,F=T?Zb(E.content):E.content;return n.jsx("div",{className:`chat-msg ${E.role}`,ref:$===d.length-1?w:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[F&&n.jsx("div",{className:"chat-msg-prose",children:F}),T!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:T}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(T),children:"Apply this draft"})]})]})},$)}),v&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:m,onChange:E=>y(E.target.value),onKeyDown:C,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:v}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:k,disabled:v||!m.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Zp({open:e,onClose:r,children:a,ariaLabel:i}){const l=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,r]),wj.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:r,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:r,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function tk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nk(e,r,a){if(r.length===0)return[{text:e,label:e,matched:null}];const i=[],l=new Set;for(const m of r)if(!(!m.scope||m.scope==="all (unscoped)"))for(const y of[m.scope,...m.scope.split(",").map(v=>v.trim())]){const v=y.toLowerCase();y&&!l.has(v)&&(l.add(v),i.push(y))}i.sort((m,y)=>y.length-m.length);const u=m=>{const y=m.toLowerCase();return r.filter(v=>{var j,x;return((j=v.scope)==null?void 0:j.toLowerCase())===y||((x=v.scope)==null?void 0:x.split(",").map(S=>S.trim().toLowerCase()).includes(y))})},d=["\\[\\d+\\]",...i.map(tk)],p=new RegExp(`(${d.join("|")})`,"gi");return e.split(p).filter(m=>m!=="").map(m=>{const y=/^\[(\d+)\]$/.exec(m);if(y){const v=r[Number(y[1])-1];if(v){const j=v.scope&&v.scope!=="all (unscoped)"?v.scope:"all recipients",x=a?`${a}: ${j}`:j;return{text:m,label:x,matched:[v]}}}else if(i.some(v=>v.toLowerCase()===m.toLowerCase())){const v=u(m);if(v.length>0)return{text:m,label:m,matched:v}}return{text:m,label:m,matched:null}})}const Uf=`Why — What's the situation? Why does this need to happen?
70
+ `).replace(/\n+$/,"")}function Oc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":Oc(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+Oc(l))}return"{"+a.join(",")+"}"}async function zp(e,r){if(e==="jcs"){if(typeof r=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Af(Oc(r))}`}if(typeof r!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Af(db(r))}`}async function Dp(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:r}=await P.decryptProposalContent(e.content),a=JSON.parse(r);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function hb(e){if(!e.content)return[];const r=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(r).filter(i=>!a.has(i))}function fb(e){return!e.loading&&e.readable}function Bp(e,r){const a=new Set;if(e.content)for(const i of Object.keys(e.content.keys))a.add(i);else{e.createdBy&&a.add(e.createdBy);for(const i of e.pendingApprovers??[])a.add(i)}return r&&a.add(r),Array.from(a)}async function du(e){const r=await Dp(e);if(r)return zp("jcs",r)}function mb(e){var i;const[r,a]=f.useState((e==null?void 0:e.note)??null);return f.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),P.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(i=e==null?void 0:e.noteEncrypted)==null?void 0:i.ciphertext]),r}const pb={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function xa(e){var i;const[r,a]=f.useState(pb);return f.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Dp(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(i=e.content)==null?void 0:i.ciphertext,e.toolArgs]),r}const Tf=140,If=60,gb=/\{([^{}]+)\}/g;function Up(e,r){var u,d;const{integrationId:a,toolName:i}=Fn(e),l=r==null?void 0:r.find(p=>p.id===a);return((d=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:d[i])??void 0}function Wp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object")return;a=a[i]}return a}function Rf(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function vb(e,r,a,i){if(r==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(i,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(i,{maximumFractionDigits:2}).format(u)}if(r==="percent")return`${e}%`;if(r==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(i,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(d=>typeof d=="object"&&d!==null?JSON.stringify(d):String(d));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return r==="short"&&l.length>If?`${l.slice(0,If-1).trimEnd()}…`:l}function $f(e,r,a,i,l){let u=!1;const d=e.replace(gb,(p,m)=>{const[y,v]=m.split("|").map(x=>x.trim()),j=y.split(",").map(x=>Wp(r,x.trim())).find(Rf);if(!Rf(j))return u=!0,"";if(v==="ref"){const x=l==null?void 0:l(y.split(",")[0].trim()),S=String(j),N=S.length>12?`${S.slice(0,8)}…`:S;return x?`${x} (${N})`:S}return vb(j,v,a,i)});return u?null:d}function Hp(e,r,a={}){const i=Wp(r,a.currencyField??"currency"),l=typeof i=="string"?i:void 0,u=e.replace(/\[([^[\]]*)\]/g,(m,y)=>$f(y,r,l,a.locale,a.refName)??""),d=$f(u,r,l,a.locale,a.refName);if(d===null)return null;const p=d.replace(/\s+/g," ").trim();return p.length>Tf?`${p.slice(0,Tf-1).trimEnd()}…`:p}function Vp(e,r,a,i,l){var p;const u=zt(Fn(e).toolName),d=Up(e,a);return!(d!=null&&d.summary)||!r?u:Hp(d.summary,r,{currencyField:(p=d.display)==null?void 0:p.currencyField,locale:i,refName:l})??u}function yb(e,r,a,i){var u;const l=Up(e,a);return!(l!=null&&l.summary)||!r?null:Hp(l.summary,r,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:i})}const Di="Commitment",no={title:"Review Each Action",text:"You review and approve each action before it executes."},ro={title:"Automatic",text:"Agent acts freely within your limits."},qp="setup__create_mandate",xb=["proposal","profile_version","workspace","mode","intent","checks","title"];function jb(e){if(typeof e!="string"||!e.trim())return null;switch(e.trim()){case"review":return{label:Di,...no};case"automatic":return{label:Di,...ro};default:return{label:Di,title:e.trim(),text:""}}}function wb(e){const r=a=>typeof a=="string"&&a.trim()?a.trim():void 0;return{intent:r(e==null?void 0:e.intent),mode:r(e==null?void 0:e.mode),proposal:r(e==null?void 0:e.proposal),profileVersion:r(e==null?void 0:e.profile_version),workspace:r(e==null?void 0:e.workspace),title:r(e==null?void 0:e.title),checks:Array.isArray(e==null?void 0:e.checks)?e.checks.filter(a=>typeof a=="string"&&a.trim()!==""):[]}}function bb(e){return[e.proposal,e.profileVersion].filter(Boolean).join(" · ")||"new mandate"}function Kp(e,r){const a=r==null?void 0:r.title;return{area:e,name:typeof a=="string"&&a.trim()?a.trim():null}}function so(e,r){const a=e==null?void 0:e.profile;return typeof a=="string"&&a?a:r}function kb({proposal:e,manifests:r}){const a=xa(e),i=Fp(e.id),l=On();if(e.tool===qp&&a.toolArgs){const u=Kp(Br(so(a.toolArgs,e.profileId),l),a.toolArgs);return n.jsxs(n.Fragment,{children:[u.area," · ",u.name??"new mandate"]})}return n.jsx(n.Fragment,{children:Vp(e.tool,a.toolArgs,r,void 0,Op(i,a.toolArgs))})}const Sb="setup__create_mandate";function Gp({proposal:e,manifests:r,titles:a,selected:i=!1,onOpen:l,who:u}){const d=Date.now(),p=pp(e.expiresAt,d),m=On(),y=Fp(e.id),v=ub(y),j=xa(e),x=e.tool===Sb,S=x?so(j.toolArgs,e.profileId):e.profileId,N=Br(S,m),w=e.authorizationId?a[e.authorizationId]:void 0,k=Ac(w,N)?w:void 0,C=[k,v==null?void 0:v.text].filter(Boolean);return n.jsx("div",{className:`av3-row${i?" is-selected":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:n.jsxs("button",{type:"button",className:"appr-item-head av3-row-head","aria-current":i||void 0,onClick:l,children:[n.jsxs("span",{className:"av3-type",children:[x?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Dr,{icon:Jn(S)}),N]}),n.jsx("span",{children:mp(e.createdAt*1e3,d)})]}),n.jsx("span",{className:"av3-row-title","data-testid":"approval-row-summary",children:n.jsx(kb,{proposal:e,manifests:r})}),(C.length>0||u||p)&&n.jsxs("span",{className:"av3-row-meta",children:[k&&n.jsx("span",{children:k}),v&&n.jsx("b",{className:v.status==="fail"?"av3-flag-fail":void 0,children:v.text}),p&&n.jsx("span",{children:p}),u&&n.jsx("span",{children:u})]})]})})}function pc({variant:e="base",style:r,className:a,...i}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:r,role:"status","aria-busy":"true","aria-label":i["aria-label"]??"Loading"})}const yr=5;function Pf(e){return e.replace(/^today\s+/i,"")}function gc(e,r){return e&&e.trim().toLowerCase()!==r.trim().toLowerCase()?`via ${e}`:null}function Nb({auths:e,activeCount:r,waiting:a,waitingReady:i}){const[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState([]),[v,j]=f.useState({}),[x,S]=f.useState({}),N=f.useCallback(()=>{P.getMyReceiptsPage({limit:200}).then(_=>u(_.receipts)).catch(()=>u(_=>_??[])),P.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Ht(N,3e5),Ke("ticket-recorded",N),f.useEffect(()=>{P.getLabelManifests().then(y).catch(()=>{}),P.getLocalAuthorizations().then(({authorizations:_})=>j(_)).catch(()=>{})},[]);const w=On(),k=f.useMemo(()=>{const _={};for(const z of e)z.authorization_id&&z.title&&(_[z.authorization_id]=z.title);return _},[e]),C=Date.now(),E=f.useMemo(()=>{const _=Date.now();return(l??[]).filter(z=>Ur(z.timestamp,_))},[l]);f.useEffect(()=>{const _=[...new Set(E.map(z=>z.profileId))].filter(z=>!(z in x));_.length!==0&&Promise.all(_.map(z=>xo(z).then(V=>[z,V]).catch(()=>[z,null]))).then(z=>S(V=>({...V,...Object.fromEntries(z)})))},[E,x]);const $=f.useMemo(()=>Mw(E,{catalog:w,manifests:m,titles:k,lastSeenMs:d??Number.POSITIVE_INFINITY}),[E,w,m,k,d]),T=E.filter(_=>Ji(_,"approved")).length,F=f.useMemo(()=>Fw(E,{nowMs:Date.now(),catalog:w,manifests:m,titles:k,boundsOf:_=>{var z;return(z=v[_])==null?void 0:z.bounds},profileOf:_=>x[_]}),[E,w,m,k,v,x]),M=$.filter(_=>_.newCount>0).length,B=[...a].sort((_,z)=>_.createdAt-z.createdAt),te=E.filter(_=>Ji(_,"approved")).sort((_,z)=>z.timestamp-_.timestamp).slice(0,Math.max(0,yr-Math.min($.length,yr))),Q=yn();return n.jsxs("div",{className:"core-cols dash-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),i?B.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):n.jsx("div",{className:"dash-rows",children:B.slice(0,yr).map(_=>n.jsx("div",{"data-testid":"dash-approval",children:n.jsx(Gp,{proposal:_,manifests:m,titles:k,onOpen:()=>Q(`/approvals?open=${encodeURIComponent(_.id)}`)})},_.id))}):n.jsx(pc,{variant:"line"}),B.length>0&&n.jsx(pt,{to:"/approvals",className:"ob-btn dash-btn",children:"All approvals"})]}),n.jsxs("section",{"aria-label":"Done today","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done today"}),M>0&&n.jsxs("span",{className:"meta",children:[$.reduce((_,z)=>_+z.newCount,0)," new"]})]}),l===null?n.jsx(pc,{variant:"line"}):$.length===0&&te.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done today."}):n.jsxs("div",{className:"dash-rows",children:[$.slice(0,yr).map(_=>n.jsxs("details",{className:`ob-card dash-row auto-grp${_.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx(At,{tag:"Ticket",className:"obj-line",profileId:_.profileId,parts:[n.jsx("span",{className:"sr-only",children:_.area},"a"),gc(_.system,_.area),Pf(ma(_.latestSec,C)),n.jsx("span",{className:"ob-st",children:"Automatic"},"st")]}),n.jsxs("span",{className:"ob-title",children:[_.area," · ",_.count," × ",_.label]}),n.jsxs("span",{className:"ob-one",children:[Ac(_.mandateTitle,_.area)&&n.jsxs("span",{"data-testid":"mandate-line",children:["Mandate: ",_.mandateTitle]}),n.jsx("span",{children:_.newCount>0?n.jsxs("b",{className:"ob-bold",children:[_.newCount," new"]}):"seen"})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[_.tickets.slice(0,yr).map(z=>n.jsxs("div",{className:"auto-grp-row",children:[ys(z,m),n.jsxs("span",{className:"t",children:[ma(z.timestamp,C)," · ",lu(z.id),Qi(z,d??Number.POSITIVE_INFINITY)?" · new":""]})]},z.id)),_.tickets.length>yr&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",_.tickets.length-yr," more in Tickets"]})]})]},_.key)),te.map(_=>{const z=Br(_.profileId,w),V=yo(_.action,m),K=_.authorizationId?k[_.authorizationId]:void 0;return n.jsxs(pt,{to:"/tickets?filter=approved",className:"ob-card dash-row","data-testid":"dash-approved-ticket",children:[n.jsx(At,{tag:"Ticket",className:"obj-line",profileId:_.profileId,parts:[n.jsx("span",{className:"sr-only",children:z},"a"),gc(V,z),Pf(ma(_.timestamp,C)),n.jsx("span",{className:"ob-st",children:"Approved"},"st")]}),n.jsxs("span",{className:"ob-title",children:[z," · ",ys(_,m)]}),Ac(K,z)&&n.jsxs("span",{className:"ob-one","data-testid":"mandate-line",children:["Mandate: ",K]})]},_.id)})]}),($.length>0||te.length>0)&&n.jsx(pt,{to:$.length>0?"/tickets?filter=automatic":"/tickets",className:"ob-btn dash-btn","data-testid":"btn-automatic-tickets",children:"All tickets"}),T>te.length&&n.jsxs("div",{className:"core-quiet-line",children:[T," approved today — ",n.jsx(pt,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(pc,{variant:"line"}):F.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):n.jsx("div",{className:"dash-rows",children:F.slice(0,yr).map(_=>{var z;return n.jsxs(pt,{to:"/mandates",className:"ob-card dash-row mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(At,{tag:"Mandate",className:"obj-line",profileId:_.profileId,parts:[_.area,gc(_.system,_.area)]}),n.jsx("span",{className:"ob-title",children:(z=_.mandateTitle)!=null&&z.trim()?_.mandateTitle:_.area}),n.jsx("span",{className:"ob-one",children:_.limit!==void 0?Ow(_)?n.jsxs("b",{className:"ob-bold",children:[_.used," of ",_.limit," used today"]}):`${_.used} of ${_.limit} used today`:`${_.used} ${_.used===1?"action":"actions"} today`})]},_.authorizationId)})}),l!==null&&r>F.length&&n.jsxs("p",{className:"core-quiet-line",children:[r-F.length," more mandate",r-F.length===1?"":"s"," in force — no actions today."]}),r>0&&n.jsx(pt,{to:"/mandates",className:"ob-btn dash-btn",children:"All mandates"})]})]})}function Cb(){const[e,r]=f.useState(null),[a,i]=f.useState(Number.POSITIVE_INFINITY),l=f.useCallback(()=>{Promise.all([P.getReport().then(p=>p.report).catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,m])=>{r(p),i(m)})},[]);if(Ht(l,3e5),Ke("report-written",l),!e||!up(e,a))return null;const{verified:u,unchecked:d}=Cw(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:Nw(e.renderedHtml)})," — ",n.jsx("span",{title:Gi(e.coverage).title,children:Gi(e.coverage).text})," · written ",dp(e.savedAt,Date.now()),d===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",d," could not be checked"]})]})]}),n.jsx(pt,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function Eb(){const[e,r]=f.useState([]);return Ht(async()=>{try{const{skipped:i}=await P.getSkippedCommitments();r(i)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(i=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:i.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",i.id,")"]})]},i.id))})]})}const Ab=1800;function ca(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Tb(){const{domain:e}=Nt(),[r,a]=f.useState([]),[i,l]=f.useState([]),[u,d]=f.useState([]),[p,m]=f.useState(!0),[y,v]=f.useState(!1),[j,x]=f.useState([]),[S,N]=f.useState(!1),[w,k]=f.useState(!1),[C,E]=f.useState(null),[$,T]=f.useState(!1),{entries:F,activeSessions:M,loading:B}=iu(),te=_0(),Q=!B,{simulation:_}=Ep(),z=_===!0,V=F0(),K=f.useCallback(()=>{P.getMyAttestations().then(oe=>{a(oe),v(!0)}).catch(()=>v(!0)),P.getArchivedMandates().then(x).catch(()=>x([])),P.getMyProposals(e).then(oe=>{l(oe),N(!0)}).catch(()=>N(!0)),P.getProposalsForApprover().then(oe=>d(oe)).catch(()=>d([])),P.getCredential("ai-config").then(oe=>{m(oe.configured),k(!0)}).catch(()=>k(!0)),P.getAgentContact().then(oe=>{E(oe.contact),T(!0)}).catch(()=>T(!0))},[e]);Ke("attestation-changed",K),Ke("proposal-added",K),Ke("proposal-resolved",K),Ke("proposal-approved",K),Ke("proposal-rejected",K),Ke("execution-failed",K),Ht(K,3e5,e);const le=y&&S&&w&&Q&&$&&_!==null,me=Ym(r,{archivedSet:new Set(j)}),we=me.active,Ae=me.expired,Z=we.some(oe=>ca(oe.profile_id)==="delegation"),G=we.filter(oe=>ca(oe.profile_id)!=="delegation").length,J=i.filter(oe=>ca(oe.profileId)==="delegation").length,I=Cp({hasContact:C!==null,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:J,managed:V,simulationOn:z}),D=z&&I.visible,pe=we.filter(oe=>oe.remaining_seconds!==null&&oe.remaining_seconds<=Ab),de=i.filter(xp),$e=F.filter(oe=>oe.state==="running"),ve=F.filter(oe=>oe.state==="starting"),Y=qj(F),he=[...de,...u.filter(oe=>!de.some(Oe=>Oe.id===oe.id))],ee=[];for(const oe of pe){const Oe=Math.ceil((oe.remaining_seconds??0)/60);ee.push({label:"Expiring soon",detail:`${oe.title??ca(oe.profile_id)} — ${Oe} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const oe of Ae)ee.push({label:"Expired",detail:oe.title??ca(oe.profile_id),to:"/mandates",color:"var(--text-primary)"});ee.push(...Vj(F,z));for(const oe of ve)ee.push({label:"Integration starting",detail:`${oe.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const oe of F)oe.authStatus==="failed"&&oe.state!=="not-running"&&oe.state!=="error"&&oe.state!=="paused"&&ee.push({label:"Reconnect needed",detail:`${oe.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return p||ee.push({label:"AI Assistant",detail:"Optional — not set up yet. Helps you write mandates and the brief.",to:"/settings#ai-assistant",color:"var(--text-tertiary)"}),n.jsxs("div",{className:"dash-page",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Dashboard"})}),le&&te&&(D?n.jsx(P0,{contact:C,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:J,managed:V,simulationOn:z,mcpEndpoint:te}):!z&&n.jsx(R0,{aiConfigured:p,hasRunningIntegration:$e.length>0,hasActiveAuth:we.length>0,hasAgentConnected:M>0,mcpEndpoint:te})),!D&&n.jsxs(n.Fragment,{children:[n.jsx(Nb,{auths:r,activeCount:we.length,waiting:he,waitingReady:S}),n.jsx(Cb,{})]}),Y&&n.jsxs("div",{className:"sim-paused-summary",role:"status",children:[n.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),n.jsxs("span",{children:[n.jsxs("b",{children:[Y.count," real system",Y.count===1?"":"s"," ",Y.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Y.namesText,"."]})]}),n.jsx(Eb,{}),n.jsx(uw,{}),!D&&ee.length>0&&n.jsxs("section",{className:"dash-sec","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Setup — needs attention"}),n.jsx("span",{className:"pill-count",children:ee.length})]}),n.jsx("div",{className:"ob-card dash-att",children:ee.map((oe,Oe)=>n.jsxs(pt,{to:oe.to,className:"dash-att-row",children:[n.jsx("b",{children:oe.label}),n.jsx("span",{children:oe.detail}),n.jsx("i",{"aria-hidden":"true",children:"›"})]},Oe))})]})]})}const Ib=["Scope & Limits","Intent","Sign"];function Yp({currentStep:e,onStepClick:r}){const a=yn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:Ib.map((i,l)=>{const u=l+2,d=u<e,p=u===e,m=u-1<e,y=d&&!!r;return n.jsxs("li",{className:`wizard-step${m?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${d?" completed":""}${p?" current":""}`,onClick:y?()=>r(u):void 0,disabled:!y,"aria-label":`${i}${d?" (done)":p?" (current)":""}`,children:d?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":d?" completed":""}`,children:i})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function Rb({profileId:e,bounds:r,groupName:a,domain:i,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),i?` / ${i}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Vt(e)]}),r&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",r]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function $b({integrationId:e,field:r,value:a,onChange:i,disabled:l,onLabels:u}){const[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState(!0);f.useEffect(()=>{let N=!1;return P.discoverScopeField(e,r).then(w=>{var k;N||(p(w.options),j(!1),(k=w.options)!=null&&k.length&&(u==null||u(Object.fromEntries(w.options.map(C=>[C.value,C.label])))))}).catch(w=>{N||(y(w instanceof Error?w.message:String(w)),j(!1))}),()=>{N=!0}},[e,r]);const x=new Set(a.split(",").map(N=>N.trim()).filter(Boolean)),S=N=>{const w=new Set(x);w.has(N)?w.delete(N):w.add(N),i(Array.from(w).join(","))};return v?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):m||!d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",m??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:N=>i(N.target.value),disabled:l})]}):d.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:d.map(N=>{const w=N.extras??{},k=typeof w.access=="string"?w.access:void 0,C=k==="reader",E=w.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:C?"var(--text-tertiary)":"var(--text-primary)",cursor:l||C?"not-allowed":"pointer"},title:C?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(N.value)),onChange:()=>S(String(N.value)),disabled:l||C}),n.jsx("span",{children:N.label||N.value}),E&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),k&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",k]})]},N.value)})})}function hu(e){if(e.type!=="number")return 0;const r=e.boundType,a=e.unit;return(r==null?void 0:r.kind)==="per_transaction"&&a==="count"?1:0}function _f(e,r){if(r!==void 0)return String(r);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):hu(e)===1?"1":""}function zc(e){const r=e.maximum;return typeof r=="number"&&Number.isFinite(r)?r:void 0}function Lf(e,r){const a=hu(e),i=zc(e),l=r===""?a:Math.max(a,Number(r));return i!==void 0?Math.min(i,l):l}function Pb(e,r){var i;const a=(i=e.capKinds)==null?void 0:i[r];return a||(e.approvers.length>0?"approval":"hard")}function fu(e,r,a){var i;return e.approvers.length===0||(r==null?void 0:r.enforcedBy)==="gatekeeper"||((i=r==null?void 0:r.boundType)==null?void 0:i.kind)==="enum"?"hard":Pb(e,a)}function Jp(e,r,a){const i=e.indexOf(r),l=e.indexOf(a);return i===-1||l===-1?!1:l<i}function ao(e,r){var a;return((a=e.caps)==null?void 0:a[r])!==void 0}function _b(e,r,a){const i=Object.entries(r.caps??{}).filter(([u])=>fu(r,a[u],u)==="approval");if(i.length===0)return null;const l=u=>{var d;return((d=a[u])==null?void 0:d.displayName)??u};for(const[u,d]of i){const p=a[u],m=p==null?void 0:p.boundType,y=(m==null?void 0:m.kind)==="per_transaction"||(m==null?void 0:m.kind)==="cumulative_sum"?m.of:void 0,v=y?e[y]:void 0;if(typeof d=="number"&&typeof v=="number"&&v>d)return{field:u,fieldLabel:l(u),cap:d,value:v}}if(i.length===1){const[u,d]=i[0];return{field:u,fieldLabel:l(u),cap:d}}return null}function Lb(e){return(e==null?void 0:e.valuesFrom)==="profiles"}const Qp=e=>(e.replace(/@.*$/,"").split("/").pop()??e).toLowerCase(),Mf=e=>e.split("@")[1]??"";function Mb(e){const r=new Map;for(const{id:a}of e){const i=Qp(a),l=r.get(i);(!l||Mf(a).localeCompare(Mf(l),void 0,{numeric:!0})>0)&&r.set(i,a)}return[...r.values()]}function Fb(e,r,a){var l;const i=((l=e.constraint)==null?void 0:l.requiredFor)??[];return r.filter(u=>a(u.id)).filter(u=>{var d;return!(((d=u.boundsSchema)==null?void 0:d.actionTypes)??[]).some(p=>i.includes(p))}).map(u=>Qp(u.id)).sort((u,d)=>u.localeCompare(d))}function Ob(e,r){var m;const[a,i]=f.useState({}),l=Object.entries(((m=e.scopeSchema)==null?void 0:m.fields)??{}).filter(([,y])=>Lb(y)),u=l.length>0,d=r==null?void 0:r.groupId,p=!!(r!=null&&r.isPersonal);return f.useEffect(()=>{if(!u)return;let y=!0;return(async()=>{const v=Mb(await ep()),j=(await Promise.all(v.map(N=>xo(N)))).filter(N=>!!N);let x;if(p)x=()=>!0;else if(d){const N=await Promise.all(j.map(k=>P.getTeamProfileConfig(d,k.id).catch(()=>null))),w=new Set(j.filter((k,C)=>N[C]).map(k=>k.id));x=k=>w.has(k)}else x=()=>!1;const S={};for(const[N,w]of l)S[N]=Fb(w,j,x);y&&i(S)})(),()=>{y=!1}},[e.id,u,d,p]),a}function zb(e){return e.replace(/@.*$/,"").split("/").pop()??e}function mu(e,r){return r.displayName?r.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Db(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Bb(e){var a;const r=e;return!!(r.enum&&((a=r.constraint)!=null&&a.enforceable.includes("subset")))}function Ub(e,r){if(!e)return;const a=(r??"").split(",").map(i=>i.trim()).filter(Boolean);return[...e,...a.filter(i=>!e.includes(i))]}function Ff(e,r){const a=e.trim();return a?r==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:r==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Wb(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Hb(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Vb(e,r){if(!e||!r)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(r==="minutes"&&a>=60){const i=Math.floor(a/60),l=a%60;return l===0?`${i} hour${i!==1?"s":""}`:`${i}h ${l}m`}if(r==="hours"&&a>=24&&a%24===0){const i=a/24;return`${i} day${i!==1?"s":""}`}if(r==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function qb({id:e,value:r,onChange:a,disabled:i,placeholder:l,unit:u,min:d=0,max:p}){const m=Wb(u),y=Hb(u).filter(w=>p===void 0||w.value<=p),v=vo(u),j=Vb(r,u),x=r===""?null:Number(r),S=()=>{const w=r===""?0:Number(r),k=w%m,C=k===0?w+m:w+(m-k);a(String(p!==void 0?Math.min(p,C):C))},N=()=>{const w=r===""?0:Number(r);if(w<=d)return;const k=w%m,C=k===0?w-m:w-k;a(String(Math.max(d,C)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:N,disabled:i||r===""||Number(r)<=d,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:d,max:p,step:m,value:r,placeholder:l??String(d),onChange:w=>{const k=w.target.value;a(p!==void 0&&k!==""&&Number(k)>p?String(p):k)},onFocus:w=>w.target.select(),disabled:i}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:S,disabled:i||p!==void 0&&r!==""&&Number(r)>=p,"aria-label":"Increase",children:"+"}),v&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:v})]}),y.length>0&&!i&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:y.map(w=>n.jsx("button",{type:"button",className:`preset-chip${x===w.value?" preset-chip-selected":""}`,onClick:()=>a(String(w.value)),children:w.label},w.value))}),j&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",j]})]})}function Of({htmlFor:e,label:r,description:a}){const[i,l]=f.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:r}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${r}" mean?`,"aria-expanded":i,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),i&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function Kb({id:e,value:r,onChange:a,disabled:i,format:l,placeholder:u}){const[d,p]=f.useState(""),[m,y]=f.useState(!1),v=f.useRef(null),j=r?r.split(",").map(C=>C.trim()).filter(Boolean):[],x=C=>{const E=C.trim();if(!E)return;if(!Ff(E,l)){y(!0);return}y(!1);const $=j.includes(E)?j:[...j,E];a($.join(",")),p("")},S=C=>{const E=j.filter(($,T)=>T!==C);a(E.join(","))},N=C=>{C.key==="Enter"||C.key===","||C.key==="Tab"?d.trim()&&(C.preventDefault(),x(d)):C.key==="Backspace"&&!d&&j.length>0&&S(j.length-1)},w=C=>{const E=C.clipboardData.getData("text");if(E.includes(",")){C.preventDefault();const T=E.split(",").map(M=>M.trim()).filter(Boolean).filter(M=>Ff(M,l)),F=[...new Set([...j,...T])];a(F.join(",")),p(""),y(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${m?" tag-input-invalid":""}`,onClick:()=>{var C;return(C=v.current)==null?void 0:C.focus()},children:[j.map((C,E)=>n.jsxs("span",{className:"tag-pill",children:[C,!i&&n.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),S(E)},"aria-label":`Remove ${C}`,children:"×"})]},C)),!i&&n.jsx("input",{ref:v,id:e,className:"tag-input-field",type:"text",value:d,onChange:C=>{p(C.target.value),y(!1)},onKeyDown:N,onPaste:w,onBlur:()=>{d.trim()&&x(d)},placeholder:j.length===0?u??k:""})]})}function Gb({id:e,options:r,value:a,onChange:i,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],d=p=>{const m=u.includes(p)?u.filter(y=>y!==p):[...u,p];i(m.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:r.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>d(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function zf({fieldKey:e,fieldDef:r,value:a,onChange:i,prefix:l,readOnly:u,twoColumn:d,discoveryIntegrationId:p,onLabels:m,capMax:y,enumAllowedFrom:v,options:j}){const x=mu(e,r),S=`${l}-field-${e}`,N=n.jsx(n.Fragment,{children:Bb(r)||j?n.jsx(Gb,{id:S,options:j??r.enum,value:a,onChange:w=>i(e,w),disabled:u}):(()=>{const w=r.boundType;return(w==null?void 0:w.kind)==="enum"&&Array.isArray(w.values)})()?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:w=>i(e,w.target.value),disabled:u||v!==void 0&&r.boundType.values.length-v<=1,children:[n.jsx("option",{value:"",children:"Select..."}),r.boundType.values.map((w,k)=>n.jsx("option",{value:w,disabled:v!==void 0&&k<v,children:w},w))]}):r.enum?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:w=>i(e,w.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),r.enum.map(w=>n.jsx("option",{value:w,children:w},w))]}):r.type==="number"?n.jsx(qb,{id:S,value:a,onChange:w=>i(e,w),disabled:u,unit:r.unit,min:hu(r),max:y!==void 0?Math.min(y,zc(r)??y):zc(r)}):Db(r)?n.jsx(Kb,{id:S,value:a,onChange:w=>i(e,w),disabled:u,format:r.format}):p?n.jsx($b,{integrationId:p,field:e,value:a,onChange:w=>i(e,w),disabled:u,onLabels:w=>m==null?void 0:m(e,w)}):n.jsx("input",{id:S,className:"form-input",type:"text",value:a,onChange:w=>i(e,w.target.value),disabled:u})});return d?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(Of,{htmlFor:S,label:x,description:r.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(Of,{htmlFor:S,label:x,description:r.description}),N]},`${l}-${e}`)}function Yb(e,r,a,i){if(!i||!ao(i,e))return null;const l=i.caps[e],u=fu(i,r,e);let d=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);d=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=r.boundType;d=(p==null?void 0:p.kind)==="enum"?Jp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:d}}function Df(e,r,a,i){if(!i||!ao(i,e))return a;const l=fu(i,r,e),u=i.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const d=a===""?NaN:Number(a);return String(Number.isNaN(d)?u:Math.min(d,u))}if(typeof u=="string"){const d=r.boundType,p=(d==null?void 0:d.kind)==="enum"?d.values??[]:[];return a!==""&&Jp(p,u,a)?u:a}return a}function Jb(e,r){if(typeof r!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const i=(a.values??[]).indexOf(r);return i===-1?void 0:i}function Qb(e,r){return vo(r.unit)||mu(e,r).toLowerCase()}function Xp(e,r){if(r&&r.length>0)return r.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Xb(e,r,a,i,l){var y;const u=r.enforcedBy==="gatekeeper",d=((y=r.boundType)==null?void 0:y.kind)==="enum";if(a.kind==="hard")return d?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",mu(e,r).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=Qb(e,r),m=Xp(i,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",m," for approval."]})}function Zb({profile:e,onConfirm:r,onCancel:a,readOnly:i,initialBounds:l,initialContext:u,initialFrame:d,profileConfig:p,approverNames:m,adminName:y,workspace:v}){var ve;const j=e.boundsSchema,x=Ob(e,v),S=e.scopeSchema,N=Y=>!!p&&ao(p,Y),w=j?Object.entries(j.fields).filter(([Y,he])=>!(Y==="profile"||Y==="path"||he.enforced===!1||he.enforcedBy==="gatekeeper"&&!N(Y))):[],k=j?Object.entries(j.fields).filter(([Y,he])=>he.enforcedBy==="gatekeeper"&&!N(Y)).filter(([,Y])=>Y.enforced!==!1).map(([Y,he])=>he.displayName??Y):[],C=S&&S.keyOrder.length>0?Object.entries(S.fields):[],E=l??d??{},$=u??{},T={};for(const[Y,he]of w)T[Y]=Df(Y,he,_f(he,E[Y]),p);const F={};for(const[Y]of C)F[Y]=$[Y]!==void 0?String($[Y]):"";const[M,B]=f.useState(T),[te,Q]=f.useState(F),[_,z]=f.useState({}),V=f.useRef(new Set);f.useEffect(()=>{B(Y=>{let he=!1;const ee={...Y};for(const[oe,Oe]of w){if(V.current.has(oe))continue;const Fe=Y[oe]!==void 0?Y[oe]:_f(Oe,E[oe]),se=Df(oe,Oe,Fe,p);ee[oe]!==se&&(ee[oe]=se,he=!0)}return he?ee:Y})},[p]);const[K,le]=f.useState(null);f.useEffect(()=>{const Y=zb(e.id);P.getIntegrationManifests().then(({manifests:he})=>{const ee=he.find(oe=>oe.profile===Y&&oe.contextDiscovery&&Object.keys(oe.contextDiscovery).length>0);le(ee??null)}).catch(()=>le(null))},[e.id]);const me={};for(const[Y,he]of w)me[Y]=Yb(Y,he,M[Y]??"",p);const we=Object.entries(me).filter(([,Y])=>(Y==null?void 0:Y.kind)==="hard"&&Y.violating).map(([Y])=>Y),Ae=!!p&&(((ve=p.approvers)==null?void 0:ve.length)??0)>0&&w.every(([Y])=>!ao(p,Y)),Z=(Y,he)=>{V.current.add(Y),B(ee=>({...ee,[Y]:he}))},G=(Y,he)=>{Q(ee=>({...ee,[Y]:he}))},J=()=>{const Y={profile:e.id};for(const[ee,oe]of w)oe.type==="number"?Y[ee]=Lf(oe,M[ee]):Y[ee]=M[ee];const he={};for(const[ee,oe]of C)oe.type==="number"?he[ee]=te[ee]===""?0:Number(te[ee]):he[ee]=te[ee];return[Y,he]},I=()=>{const[Y,he]=J();r(Y,he,_)},D=()=>{var oe;const Y={...M};for(const Oe of we){const Fe=(oe=me[Oe])==null?void 0:oe.cap;Fe!==void 0&&(Y[Oe]=String(Fe))}B(Y);const he={profile:e.id};for(const[Oe,Fe]of w)Fe.type==="number"?he[Oe]=Lf(Fe,Y[Oe]??""):he[Oe]=Y[Oe]??"";const ee={};for(const[Oe,Fe]of C)Fe.type==="number"?ee[Oe]=te[Oe]===""?0:Number(te[Oe]):ee[Oe]=te[Oe];r(he,ee,_)},pe=()=>{if(!Ae)return null;const Y=Xp(p,m);return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",Y]}),n.jsxs("div",{children:["No caps are set on this profile, so ",Y," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})},de=()=>{if(we.length===0)return null;const Y=y??"the team admin";return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"2px solid var(--border-strong)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsx("div",{className:"msg-error",style:{marginBottom:"0.25rem"},children:"Hard team ceiling."}),n.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Lower the bound(s) above, or ask ",Y," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:D,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},$e=we.length>0;return n.jsxs("div",{children:[C.length>0&&n.jsxs("div",{className:"context-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🛡"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),C.map(([Y,he])=>{var oe;const ee=!!((oe=K==null?void 0:K.contextDiscovery)!=null&&oe[Y]);return n.jsx(zf,{fieldKey:Y,fieldDef:he,value:te[Y],onChange:G,prefix:"context",readOnly:i,discoveryIntegrationId:ee?K.id:void 0,onLabels:(Oe,Fe)=>z(se=>({...se,[Oe]:Fe})),options:Ub(x[Y],te[Y])},`context-${Y}`)})]}),w.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:w.map(([Y,he])=>{const ee=me[Y];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(zf,{fieldKey:Y,fieldDef:he,value:M[Y],onChange:Z,prefix:"bounds",readOnly:i,twoColumn:!0,capMax:(ee==null?void 0:ee.kind)==="hard"&&typeof ee.cap=="number"?ee.cap:void 0,enumAllowedFrom:(ee==null?void 0:ee.kind)==="hard"?Jb(he,ee.cap):void 0}),ee&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Xb(Y,he,ee,p,m)})]},`bounds-${Y}`)})}),pe(),de(),k.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[k.join(", ")," ",k.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",n.jsx(pt,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:I,disabled:$e,style:{marginTop:"0.5rem"},children:i?"Next: Gates":"Next: Problem Statement"})]})}function ek(e){var a;const r=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=r==null?void 0:r[1])==null?void 0:a.trim())??null}function tk(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const nk="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function io({target:e,currentText:r,onApply:a,greeting:i,placeholder:l,title:u}){const[d,p]=f.useState([{role:"assistant",content:i??nk}]),[m,y]=f.useState(""),[v,j]=f.useState(!1),[x,S]=f.useState(null),N=f.useRef(null),w=f.useRef(null);f.useEffect(()=>{const E=N.current;if(!E)return;const $=d[d.length-1],T=w.current;!v&&($==null?void 0:$.role)==="assistant"&&d.length>1&&T?E.scrollTop=T.offsetTop:E.scrollTop=E.scrollHeight},[d,v]);const k=async()=>{const E=m.trim();if(!E||v)return;const $=[...d,{role:"user",content:E}];p($),y(""),S(null),j(!0);try{const T=await P.aiChat({target:e,currentText:r,messages:$.filter((F,M)=>!(M===0&&F.role==="assistant"))});T.success&&T.reply?p(F=>[...F,{role:"assistant",content:T.reply}]):S(T.error??"AI returned no reply")}catch(T){S(T instanceof Error?T.message:"Chat failed")}finally{j(!1)}},C=E=>{E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),k())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:N,className:"chat-messages",children:[d.map((E,$)=>{const T=E.role==="assistant"?ek(E.content):null,F=T?tk(E.content):E.content;return n.jsx("div",{className:`chat-msg ${E.role}`,ref:$===d.length-1?w:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[F&&n.jsx("div",{className:"chat-msg-prose",children:F}),T!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:T}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(T),children:"Apply this draft"})]})]})},$)}),v&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:m,onChange:E=>y(E.target.value),onKeyDown:C,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:v}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:k,disabled:v||!m.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Zp({open:e,onClose:r,children:a,ariaLabel:i}){const l=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,r]),kj.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:r,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:r,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function rk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sk(e,r,a){if(r.length===0)return[{text:e,label:e,matched:null}];const i=[],l=new Set;for(const m of r)if(!(!m.scope||m.scope==="all (unscoped)"))for(const y of[m.scope,...m.scope.split(",").map(v=>v.trim())]){const v=y.toLowerCase();y&&!l.has(v)&&(l.add(v),i.push(y))}i.sort((m,y)=>y.length-m.length);const u=m=>{const y=m.toLowerCase();return r.filter(v=>{var j,x;return((j=v.scope)==null?void 0:j.toLowerCase())===y||((x=v.scope)==null?void 0:x.split(",").map(S=>S.trim().toLowerCase()).includes(y))})},d=["\\[\\d+\\]",...i.map(rk)],p=new RegExp(`(${d.join("|")})`,"gi");return e.split(p).filter(m=>m!=="").map(m=>{const y=/^\[(\d+)\]$/.exec(m);if(y){const v=r[Number(y[1])-1];if(v){const j=v.scope&&v.scope!=="all (unscoped)"?v.scope:"all recipients",x=a?`${a}: ${j}`:j;return{text:m,label:x,matched:[v]}}}else if(i.some(v=>v.toLowerCase()===m.toLowerCase())){const v=u(m);if(v.length>0)return{text:m,label:m,matched:v}}return{text:m,label:m,matched:null}})}const Bf=`Why — What's the situation? Why does this need to happen?
71
71
 
72
72
  Goal — What should the agent try to achieve?
73
73
 
74
- Watch out — What should the agent avoid or be careful about?`;function rk(e,r,a,i){return nk(e,r,i).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const d=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(d),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function sk(){var Fe;const e=yn(),[r]=Ss(),a=Number(r.get("step"))||2,[i,l]=f.useState(null),[u,d]=f.useState(null),[p,m]=f.useState(a),[y,v]=f.useState(null),[j,x]=f.useState(null),[S,N]=f.useState({}),[w,k]=f.useState(Uf),[C,E]=f.useState(!1),[$,T]=f.useState(null),[F,M]=f.useState(!0),[B,te]=f.useState(null),[Q,_]=f.useState([]),[z,V]=f.useState(void 0),[K,le]=f.useState(!1),[me,we]=f.useState(null),[Ae,Z]=f.useState(null),[G,J]=f.useState(null),[I,D]=f.useState([]),[pe,de]=f.useState(null);f.useEffect(()=>{var Ve;const se=sessionStorage.getItem("agentAuth");if(!se){e("/mandates?new=1");return}const Te=JSON.parse(se);l(Te),Te.intentHint&&k(Te.intentHint),P.getCredential("ai-config").then(Ge=>T(Ge.configured)).catch(()=>T(!1));const _e=sessionStorage.getItem("agentGate");if(_e){const Ge=JSON.parse(_e);Ge.bounds&&v(Ge.bounds),Ge.context&&x(Ge.context),(Ve=Ge.gateContent)!=null&&Ve.intent&&k(Ge.gateContent.intent)}P.getProfile(Te.profileId).then(Ge=>d(Ge)).catch(()=>e("/mandates?new=1")).finally(()=>M(!1)),Te.groupId&&Promise.all([P.getTeamProfileConfig(Te.groupId,Te.profileId).catch(()=>null),P.getGroupById(Te.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([Ge,ct,nt])=>{if(te(Ge),Ge){const Je=new Map;for(const De of nt){const Ie=De.name&&De.email?`${De.name} (${De.email})`:De.name||De.email||De.id;Je.set(De.id,Ie)}const Be=(ct==null?void 0:ct.members)??[];for(const De of Be){const Ie=De.userId??De.id;Ie&&(De.name&&De.email?Je.set(Ie,`${De.name} (${De.email})`):De.name&&Je.set(Ie,De.name))}const dt=(Ge.approvers??[]).map(De=>Je.get(De)??De);_(dt);const et=Be.find(De=>De.role==="admin");if(et){const De=et.userId??et.id;De&&V(Je.get(De)??et.name)}}})},[e]);const $e=y?Object.entries(y).filter(([se])=>se!=="profile"&&se!=="path").map(([se,Te])=>`${se} = ${Te}`).join(", "):"",ve=(se,Te,_e)=>{v(se),x(Te),_e&&N(_e),m(3)},Y=w.trim()!==Uf.trim()&&w.trim()!=="",he=se=>{Y&&!confirm("Replace your current intent with the AI draft?")||k(se)},ee=()=>{const se=u==null?void 0:u.ttl,Te={intent:w},_e=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({..._e,bounds:y,context:j,contextLabels:S,gateContent:Te,ttlConfig:se})),e("/mandates/new/sign")},oe=async()=>{if(i){le(!0),we(null),Z(null),J(null),D([]),de(null);try{const se=await P.aiIntentReview({profileId:i.profileId,newIntent:w,context:j??void 0});D(se.grants??[]),se.success?se.review?we(se.review):Z(se.note??"No other mandates on this profile to compare against."):J(se.error??"Check failed.")}catch(se){J(se instanceof Error?se.message:"Check failed.")}finally{le(!1)}}},Oe=se=>{k(se),(me||Ae||G)&&(we(null),Z(null),J(null),D([]),de(null))};return F||!i||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Yp,{currentStep:p,onStepClick:se=>{se>=2&&m(se)}}),n.jsx(Tb,{profileId:i.profileId,bounds:$e||void 0,groupName:i.groupName,domain:i.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(Qb,{profile:u,onConfirm:ve,onCancel:()=>e("/mandates?new=1"),initialBounds:y||void 0,initialContext:j||void 0,profileConfig:B,approverNames:Q,adminName:z,workspace:{groupId:i.groupId,isPersonal:i.isPersonal}})}),p===3&&n.jsxs("div",{className:`intent-layout${$?"":" no-chat"}`,children:[$&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(io,{target:{kind:"intent",profileId:i.profileId,bounds:$e||void 0},currentText:w,onApply:he})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:w,onChange:se=>Oe(se.target.value)}),n.jsxs("div",{className:"char-counter",children:[w.length," / 2000"]})]}),$===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(pt,{to:"/settings#ai-assistant",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),$&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:oe,disabled:K||!Y,children:K?"Checking…":"Check against my other grants"}),G&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:G})]}),Ae&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:Ae})]}),me&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:rk(me,I,de,Vt(i.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>m(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ee,disabled:!Y,children:"Continue to Review"})]}),(((Fe=B==null?void 0:B.approvers)==null?void 0:Fe.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",Q.length>0?Q.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Q.length>0?Q.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>E(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(Zp,{open:C,onClose:()=>E(!1),ariaLabel:"Intent assistant",children:n.jsx(io,{target:{kind:"intent",profileId:i.profileId,bounds:$e||void 0},currentText:w,onApply:se=>{he(se),E(!1)}})})]}),pe&&n.jsx("div",{className:"modal-backdrop",onClick:se=>se.target===se.currentTarget&&de(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:pe.length>1?`Existing mandates (${pe.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>de(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:pe.map((se,Te)=>{var _e;return n.jsxs("div",{style:{marginBottom:Te<pe.length-1?"1rem":0,paddingBottom:Te<pe.length-1?"1rem":0,borderBottom:Te<pe.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:se.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((_e=se.intent)==null?void 0:_e.trim())||"(no intent recorded)"}),Object.entries(se.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(se.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").map(([Ve,Ge])=>`${Ve}: ${Ge}`).join(" · ")})]})]},Te)})})]})})]})]})}function ak(e){return e.normalize("NFC").replace(/\r\n?/g,`
74
+ Watch out — What should the agent avoid or be careful about?`;function ak(e,r,a,i){return sk(e,r,i).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const d=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(d),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function ik(){var Fe;const e=yn(),[r]=Ss(),a=Number(r.get("step"))||2,[i,l]=f.useState(null),[u,d]=f.useState(null),[p,m]=f.useState(a),[y,v]=f.useState(null),[j,x]=f.useState(null),[S,N]=f.useState({}),[w,k]=f.useState(Bf),[C,E]=f.useState(!1),[$,T]=f.useState(null),[F,M]=f.useState(!0),[B,te]=f.useState(null),[Q,_]=f.useState([]),[z,V]=f.useState(void 0),[K,le]=f.useState(!1),[me,we]=f.useState(null),[Ae,Z]=f.useState(null),[G,J]=f.useState(null),[I,D]=f.useState([]),[pe,de]=f.useState(null);f.useEffect(()=>{var Ve;const se=sessionStorage.getItem("agentAuth");if(!se){e("/mandates?new=1");return}const Te=JSON.parse(se);l(Te),Te.intentHint&&k(Te.intentHint),P.getCredential("ai-config").then(Ge=>T(Ge.configured)).catch(()=>T(!1));const _e=sessionStorage.getItem("agentGate");if(_e){const Ge=JSON.parse(_e);Ge.bounds&&v(Ge.bounds),Ge.context&&x(Ge.context),(Ve=Ge.gateContent)!=null&&Ve.intent&&k(Ge.gateContent.intent)}P.getProfile(Te.profileId).then(Ge=>d(Ge)).catch(()=>e("/mandates?new=1")).finally(()=>M(!1)),Te.groupId&&Promise.all([P.getTeamProfileConfig(Te.groupId,Te.profileId).catch(()=>null),P.getGroupById(Te.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([Ge,ct,nt])=>{if(te(Ge),Ge){const Je=new Map;for(const De of nt){const Ie=De.name&&De.email?`${De.name} (${De.email})`:De.name||De.email||De.id;Je.set(De.id,Ie)}const Be=(ct==null?void 0:ct.members)??[];for(const De of Be){const Ie=De.userId??De.id;Ie&&(De.name&&De.email?Je.set(Ie,`${De.name} (${De.email})`):De.name&&Je.set(Ie,De.name))}const dt=(Ge.approvers??[]).map(De=>Je.get(De)??De);_(dt);const et=Be.find(De=>De.role==="admin");if(et){const De=et.userId??et.id;De&&V(Je.get(De)??et.name)}}})},[e]);const $e=y?Object.entries(y).filter(([se])=>se!=="profile"&&se!=="path").map(([se,Te])=>`${se} = ${Te}`).join(", "):"",ve=(se,Te,_e)=>{v(se),x(Te),_e&&N(_e),m(3)},Y=w.trim()!==Bf.trim()&&w.trim()!=="",he=se=>{Y&&!confirm("Replace your current intent with the AI draft?")||k(se)},ee=()=>{const se=u==null?void 0:u.ttl,Te={intent:w},_e=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({..._e,bounds:y,context:j,contextLabels:S,gateContent:Te,ttlConfig:se})),e("/mandates/new/sign")},oe=async()=>{if(i){le(!0),we(null),Z(null),J(null),D([]),de(null);try{const se=await P.aiIntentReview({profileId:i.profileId,newIntent:w,context:j??void 0});D(se.grants??[]),se.success?se.review?we(se.review):Z(se.note??"No other mandates on this profile to compare against."):J(se.error??"Check failed.")}catch(se){J(se instanceof Error?se.message:"Check failed.")}finally{le(!1)}}},Oe=se=>{k(se),(me||Ae||G)&&(we(null),Z(null),J(null),D([]),de(null))};return F||!i||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Yp,{currentStep:p,onStepClick:se=>{se>=2&&m(se)}}),n.jsx(Rb,{profileId:i.profileId,bounds:$e||void 0,groupName:i.groupName,domain:i.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(Zb,{profile:u,onConfirm:ve,onCancel:()=>e("/mandates?new=1"),initialBounds:y||void 0,initialContext:j||void 0,profileConfig:B,approverNames:Q,adminName:z,workspace:{groupId:i.groupId,isPersonal:i.isPersonal}})}),p===3&&n.jsxs("div",{className:`intent-layout${$?"":" no-chat"}`,children:[$&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(io,{target:{kind:"intent",profileId:i.profileId,bounds:$e||void 0},currentText:w,onApply:he})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:w,onChange:se=>Oe(se.target.value)}),n.jsxs("div",{className:"char-counter",children:[w.length," / 2000"]})]}),$===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(pt,{to:"/settings#ai-assistant",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),$&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:oe,disabled:K||!Y,children:K?"Checking…":"Check against my other grants"}),G&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:G})]}),Ae&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:Ae})]}),me&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:ak(me,I,de,Vt(i.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>m(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ee,disabled:!Y,children:"Continue to Review"})]}),(((Fe=B==null?void 0:B.approvers)==null?void 0:Fe.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",Q.length>0?Q.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Q.length>0?Q.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>E(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(Zp,{open:C,onClose:()=>E(!1),ariaLabel:"Intent assistant",children:n.jsx(io,{target:{kind:"intent",profileId:i.profileId,bounds:$e||void 0},currentText:w,onApply:se=>{he(se),E(!1)}})})]}),pe&&n.jsx("div",{className:"modal-backdrop",onClick:se=>se.target===se.currentTarget&&de(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:pe.length>1?`Existing mandates (${pe.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>de(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:pe.map((se,Te)=>{var _e;return n.jsxs("div",{style:{marginBottom:Te<pe.length-1?"1rem":0,paddingBottom:Te<pe.length-1?"1rem":0,borderBottom:Te<pe.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:se.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((_e=se.intent)==null?void 0:_e.trim())||"(no intent recorded)"}),Object.entries(se.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(se.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").map(([Ve,Ge])=>`${Ve}: ${Ge}`).join(" · ")})]})]},Te)})})]})})]})]})}function ok(e){return e.normalize("NFC").replace(/\r\n?/g,`
75
75
  `).split(`
76
76
  `).map(l=>l.replace(/[ \t]+$/,"")).join(`
77
- `).replace(/\n+$/,"")}async function pu(e){const a=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(i)).map(u=>u.toString(16).padStart(2,"0")).join("")}class ik extends Error{constructor(a,i,l){super(l);ia(this,"code");ia(this,"field");this.name="CanonicalValueError",this.code=a,this.field=i}}function ok(e){const r=new TextEncoder().encode(e);let a="";for(const i of r)i===61||i===37||i<32||i>126?a+="%"+i.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(i);return a}function eg(e,r,a){const i=[];for(const l of r){const u=e[l];if(u==null)continue;const d=String(u);if(d.includes(`
78
- `)||d.includes("\r"))throw new ik(a,l,`Value for "${l}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);i.push(`${l}=${ok(d)}`)}return i.join(`
79
- `)}async function Bi(e,r){const a=r.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const i=eg(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await pu(i)}`}async function tg(e,r){const a=r.scopeSchema?eg(e,r.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await pu(a)}`}function zc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":zc(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+zc(l))}return"{"+a.join(",")+"}"}async function ng(e){return`sha256:${await pu(zc(e))}`}async function oo(e){const r=new TextEncoder().encode(ak(e)),a=await crypto.subtle.digest("SHA-256",r);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function rg(e,r){if(!e.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??r.boundsHash,contextHash:r.contextHash,context:r.context,...r.contextLabels&&Object.keys(r.contextLabels).length>0?{contextLabels:r.contextLabels}:{},gateContent:r.gateContent,...r.path?{path:r.path}:{}}}function lk(e){const r=e.commitment_modes;return r===void 0?["review","automatic"]:Array.isArray(r)?["review","automatic"].filter(a=>r.includes(a)):[]}function ck(e){return e==="per-action"?"review":"automatic"}function Wf(e){return e?lk(e).map(r=>r==="review"?"per-action":"immediate"):["per-action","immediate"]}function uk(e,r){return r.includes(e)?e:r[0]??null}function Hf(e){return e==null?new Set:new Set(String(e).split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}function dk(e,r){for(const a of e)if(r.has(a))return!0;return!1}function hk(e,r,a){for(const i of e){const l=Hf(r[i]),u=Hf(a[i]);if(!(l.size===0||u.size===0)&&!dk(l,u))return!1}return!0}function fk(e){return e.length>24?`${e.slice(0,10)}…`:e}function sg(e,r,a){const i=a==null?void 0:a[e];return String(r).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const d=i==null?void 0:i[u];return d?`${d} (${fk(u)})`:u}).join(", ")}function ag(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const r=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${r}.`,fix:`Ask an admin of ${r} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${r} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const Dc=500;function mk(e){const r=e.trim();return r.length===0?{valid:!1,error:"Describe what should change."}:r.length>Dc?{valid:!1,error:`At most ${Dc} characters (currently ${r.length}).`}:{valid:!0,trimmed:r}}function ig(){return{outcome:"rejected"}}function Vf(){return{outcome:"replaced"}}function pk(e,r){if((e.pendingApprovers??[]).includes(r))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(r)?{route:"resolve",domain:r}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const gk={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function vk(e,r){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const i=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:gk[i],who:a.userId===r?"You":a.userId,at:a.at,note:l}}function yk(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function xk(){var Qe,ut;const e=yn(),{user:r,mode:a,domain:i}=Nt(),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState("per-action"),[x,S]=f.useState(1800),[N,w]=f.useState(86400),[k,C]=f.useState(""),[E,$]=f.useState("hours"),[T,F]=f.useState(""),[M,B]=f.useState(!0),[te,Q]=f.useState(!1);f.useEffect(()=>{P.getIdentityDisclosure().then(ye=>Q(ye.always)).catch(()=>{})},[]);const[_,z]=f.useState(!1),[V,K]=f.useState(""),[le,me]=f.useState(null),[we,Ae]=f.useState([]),[Z,G]=f.useState(!1),[J,I]=f.useState([]),[D,pe]=f.useState(0);f.useEffect(()=>{var jt;const ye=sessionStorage.getItem("agentAuth"),ze=sessionStorage.getItem("agentGate");if(!ye||!ze){e("/mandates?new=1");return}const Ye=JSON.parse(ye),tt=JSON.parse(ze),st={bounds:tt.bounds??{},context:tt.context??{},contextLabels:tt.contextLabels??void 0,gateContent:tt.gateContent};u(Ye),p(st),tt.ttlConfig&&(S(tt.ttlConfig.default??1800),w(tt.ttlConfig.max??86400)),tt.templateMode==="automatic"?j("immediate"):tt.templateMode==="review"&&j("per-action");const ht=((jt=tt.ttlConfig)==null?void 0:jt.max)??86400;if(typeof tt.templateTtl=="number"&&tt.templateTtl>0){const qe=Math.min(tt.templateTtl,ht);S(qe),[3600,86400,604800,2592e3,31536e3].includes(qe)||(qe%86400===0?(C(String(qe/86400)),$("days")):(C(String(Math.max(1,Math.round(qe/3600)))),$("hours")))}P.getProfile(Ye.profileId).then(qe=>{var H;if(y(qe),!T){const ge=qe.name??((H=Ye.profileId.split("/").pop())==null?void 0:H.replace(/@.*$/,""))??"",be=[];if(st.context&&qe.scopeSchema)for(const Ne of qe.scopeSchema.keyOrder){const ke=st.context[Ne];if(ke!==void 0&&ke!==""){const ue=String(ke).split(",").map(He=>He.trim()).filter(Boolean);be.push(ue.join(", "))}}const X=be.length>0?`${ge}: ${be.join(" · ")}`:ge;F(X)}}).catch(()=>{}),Ye.isPersonal?G(!0):Promise.all([P.getTeamProfileConfig(Ye.groupId,Ye.profileId).catch(()=>null),P.getGroupById(Ye.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([qe,H,ge])=>{if(me(qe),qe){const be=new Map;for(const ke of ge){const ue=ke.name&&ke.email?`${ke.name} (${ke.email})`:ke.name||ke.email||ke.id;be.set(ke.id,ue)}const X=(H==null?void 0:H.members)??[];for(const ke of X){const ue=ke.userId??ke.id;ue&&(ke.name&&ke.email?be.set(ue,`${ke.name} (${ke.email})`):ke.name&&be.set(ue,ke.name))}const Ne=(qe.approvers??[]).map(ke=>be.get(ke)??ke);Ae(Ne)}}).finally(()=>{G(!0)})},[e]),f.useEffect(()=>{if(!(l!=null&&l.profileId))return;const ye=l.profileId,ze=sessionStorage.getItem("agentEditReplaces");P.getEnrichedAuthorizations().then(Ye=>{const tt=Ye.filter(st=>st.profileId===ye&&st.authorizationId!==ze).map(st=>({authorizationId:st.authorizationId,bounds:st.bounds,context:st.context??{},intent:st.intent}));I(tt)}).catch(()=>I([]))},[l==null?void 0:l.profileId]),f.useEffect(()=>{if(!m)return;const ye=uk(v,Wf(m));ye&&ye!==v&&j(ye)},[m,v]),f.useEffect(()=>{if(!d||!m||J.length===0){pe(0);return}let ye=!1;return(async()=>{const ze=await Bi(d.bounds,m),Ye=await Promise.all(J.map(tt=>Bi(tt.bounds,m).catch(()=>null)));ye||pe(Ye.filter(tt=>tt===ze).length)})().catch(()=>{ye||pe(0)}),()=>{ye=!0}},[d,m,J]);const de=async()=>{if(!(!l||!d||!m||!r)){if(!l.groupId){K("No active group; cannot create mandate.");return}z(!0),K("");try{const ye=i||l.domain||"owner",ze=await Bi(d.bounds,m),Ye=await tg(d.context,m),[tt,st]=await Promise.all([oo(d.gateContent.intent),oo(JSON.stringify({profile:l.profileId,domain:ye,group:l.groupId}))]);let ht,jt,qe,H;if(l.isTeam){const He=await P.getApproversPubkeys(l.groupId,l.profileId);if(He.length>0){const kt=await P.encryptIntent(d.gateContent.intent,He);ht=kt.intentCiphertext,jt=kt.encryptedKeys,qe=kt.approversFrozen,H=kt.intentDisclosureHash}}const ge=`authz_${crypto.randomUUID()}`,be=sessionStorage.getItem("agentEditReplaces")||void 0,X=sessionStorage.getItem("agentReplacesProposal")||void 0,Ne=await ng(m),ke=await P.attest({authorization_id:ge,replaces:be,profile_id:l.profileId,profile_hash:Ne,supported_versions:["0.7"],bounds:d.bounds,bounds_hash:ze,scope_hash:Ye,domain:ye,did:r.did,mandate_owners:[{did:r.did}],gate_content_hashes:{intent:tt},execution_context_hash:st,group_id:l.groupId,ttl:x,commitment_mode:ck(v),title:T.trim(),intent_ciphertext:ht,encrypted_keys:jt,approvers_frozen:qe,intent_disclosure_hash:H,disclose_identity:M});try{await P.pushGateContent(rg(ke,{boundsHash:ze,contextHash:Ye,context:d.context,contextLabels:d.contextLabels,gateContent:d.gateContent}))}catch(He){try{await P.revokeAttestation(ge,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${He instanceof Error?He.message:"Unknown error"})`)}if(be)try{await P.revokeAttestation(be,`Replaced by ${ge} (edit)`),P.resyncGates().catch(()=>{})}catch{}let ue="";if(X)try{const He=await P.getProposal(X);if(He.status==="pending"){const kt=pk(He,(r==null?void 0:r.id)??"");kt?kt.route==="approver"?await P.rejectProposal(X,Vf()):await P.resolveProposal(X,"reject",kt.domain,Vf()):ue="you are not one of the people who may decide it"}}catch(He){ue=He instanceof Error?He.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),ue){K(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${ue}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(ge)}`)}catch(ye){K(ye instanceof Error?ye.message:"Signing the mandate failed")}finally{z(!1)}}};if(!l||!d)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const $e=Object.entries(d.bounds).filter(([ye])=>ye!=="profile"&&ye!=="path"),ve=Object.entries(d.context),he=((le==null?void 0:le.caps)!=null?Object.keys(le.caps):[]).length!==0,ee=we.length>0?we.join(", "):((le==null?void 0:le.approvers)??[]).join(", "),oe=he?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ee}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Oe=he?`Over-cap actions will be reviewed by you and ${ee}. Within-cap actions run per the mode you chose above.`:`Approvers ${ee} can read your intent but won't gate any action — no caps configured on this profile.`,Fe=!!((Qe=le==null?void 0:le.approvers)!=null&&Qe.length),se=ag({isPersonal:l.isPersonal,configLoaded:Z,grantors:le?Wm(le):void 0,userId:r==null?void 0:r.id,profileName:Vt(l.profileId),teamName:l.groupName}),Te=!se.can,_e=Wf(m),Ve=_e.length===0,Ge=x>N,ct={flex:1,padding:"0.75rem",border:v==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:v==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},nt={flex:1,padding:"0.75rem",border:v==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:v==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Je=((ut=m==null?void 0:m.scopeSchema)==null?void 0:ut.keyOrder)??[],Be=J.filter(ye=>hk(Je,d.context,ye.context)),dt=Be.length>0,et=Vt(l.profileId),De=ye=>{const ze=Object.values(ye).map(Ye=>String(Ye).trim()).filter(Boolean);return ze.length>0?ze.join(", "):"all (unscoped)"},Ie=Be.map(ye=>De(ye.context)).join("; "),We=`This grant's scope overlaps an existing grant on ${et} (scoped to: ${Ie}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return n.jsxs(n.Fragment,{children:[n.jsx(Yp,{currentStep:4,onStepClick:ye=>{ye<=3&&e(`/mandates/new/intent?step=${ye}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&m&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Vt(l.profileId)," ",m.version," — the current version of this profile."]})]}),V&&n.jsx("div",{className:"error-message",children:V}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Vt(l.profileId)}: daily operations`,value:T,onChange:ye=>F(ye.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," ",Di]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[_e.includes("per-action")&&n.jsxs("button",{onClick:()=>j("per-action"),style:nt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:no.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:no.text})]}),_e.includes("immediate")&&n.jsxs("button",{onClick:()=>j("immediate"),style:ct,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:ro.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:ro.text})]})]}),_e.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:_e[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ve&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(ye=>ye.seconds<=N).map(ye=>n.jsx("button",{onClick:()=>{S(ye.seconds),C("")},style:{padding:"0.5rem 0.85rem",border:x===ye.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===ye.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:ye.label},ye.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:k,onChange:ye=>{C(ye.target.value);const ze=parseInt(ye.target.value,10);if(ze>0){const Ye=E==="days"?ze*86400:ze*3600;S(Math.min(Ye,N))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:E,onChange:ye=>{$(ye.target.value);const ze=parseInt(k,10);if(ze>0){const Ye=ye.target.value==="days"?ze*86400:ze*3600;S(Math.min(Ye,N))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),Ge&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",N>=86400?`${Math.floor(N/86400)} days`:`${Math.floor(N/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:te||M,disabled:te,onChange:ye=>B(ye.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',te&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:d.gateContent.intent})]}),(!!$e.length||!!ve.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[ve.map(([ye,ze])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:ye}),n.jsx("dd",{children:sg(ye,ze,d.contextLabels)})]},ye)),$e.map(([ye,ze])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:ye}),n.jsx("dd",{children:String(ze)})]},ye))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Vt(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:Z?se.can?n.jsxs(n.Fragment,{children:[ee,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:oe})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:se.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),se.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ee}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[se.reason," ",se.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),D>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[D===1?`An active grant on ${et} already has exactly these limits.`:`${D} active grants on ${et} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,dt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:We})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:de,disabled:_||!T.trim()||Te||Ve,children:_?"Signing...":v==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Fe?"block":"none"},children:Oe})]})]})}function jk(e,r){return e==="running"?{text:"Running",tone:"bold"}:e==="starting"?{text:"Starting",tone:"muted"}:e==="unconfigured"||e==="needs-oauth"?{text:"Not set up",tone:"muted"}:{text:r.t,tone:r.t==="Crashed"?"bold":"muted"}}function wk(e){return e.needsAuth?e.authFailed?{text:"Auth failed",tone:"bold"}:e.authConnected?{text:"Auth OK",tone:"muted"}:null:{text:"No auth",tone:"muted"}}function bk(e,r,a=!1){return r?!0:e==="unconfigured"?a:e==="needs-oauth"||e==="ready"}function kk(e,r){return e===void 0?null:e===null?"reads follow your mandate":e===0?"reads nothing":`reads ${r(e).toLowerCase()}`}function Sk(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Nk(e){var r;if(e.authFailed)return"The stored credentials stopped working — reconnect to use it again";switch(e.cardState){case"running":{const a=[(r=e.modeNote)==null?void 0:r.replace(/\.$/,""),e.reads].filter(Boolean);return a.length?a.join(" · "):e.noFields?"Nothing to set up":"Credentials on file"}case"starting":return"Starting…";case"needs-oauth":return"Credentials saved — connect your account";case"unconfigured":{if(e.requiredLabels.length===0)return e.setupHint??e.modeNote??"Works out of the box — activate it to start";const a=`Needs ${Sk(e.requiredLabels)}`;return e.oauth?`${a}, then connect your account`:a}case"ready":return e.stopped==="paused"?"Paused while simulation mode is on":e.stopped==="crashed"?"Stopped with an error":"Credentials saved — start it to use it"}}function og(e){var a;const r=[e.profile];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(l)&&r.push(l)}return r}function lg(e,r){const a=new Map;for(const i of e)for(const l of og(i.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Jn(l),name:Qn(l,r),entries:[]},a.set(l,u)),u.entries.push(i)}return[...a.values()].sort((i,l)=>i.name.localeCompare(l.name))}function Ck(e,r){if(!r)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(d=>qi(d.manifest)&&!Ki(d,r)),i=e.filter(d=>!qi(d.manifest)||Ki(d,r)),l=i.filter(d=>d.state==="error"),u=i.filter(d=>d.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function Ek(e){const r=[],a=[];for(const i of e){const l=i.authStatus==="not_configured"||i.authStatus==="not_connected";(i.state==="running"&&!l?r:a).push(i)}return{inUse:r,notSetUp:a}}function Ak(e){const r=e==null?void 0:e.overrides;return!r||typeof r!="object"?!1:Object.values(r).some(a=>{var i;return typeof((i=a==null?void 0:a.read)==null?void 0:i.ageField)=="string"})}const Tk=[0,7,30,90,365,3650];function ua(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function Ik(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{t:"Crashed"},showStart:!0}:{chip:{t:"Stopped"},showStart:!0}}function Rk({manifest:e,area:r,integration:a,state:i,onStatusChange:l,onSuccess:u}){var be;const[d,p]=f.useState({}),[m,y]=f.useState(!1),[v,j]=f.useState(!1),[x,S]=f.useState({}),[N,w]=f.useState({}),[k,C]=f.useState(void 0),[E,$]=f.useState(!1),[T,F]=f.useState(null),[M,B]=f.useState(!1),[te,Q]=f.useState(!1),[_,z]=f.useState(null),V=va(),[K,le]=f.useState(!1),[me,we]=f.useState(!1),[Ae,Z]=f.useState({}),[G,J]=f.useState(null),[I,D]=f.useState(!1),[pe,de]=f.useState(null),[$e,ve]=f.useState(!1);f.useEffect(()=>{let X=!1;return P.getCredential(e.id).then(Ne=>{var ke;if(!X&&(Q(!0),!!Ne.configured)){if(y(!0),j(!0),Ne.fields){const ue={};for(const He of e.credentials.fields)Ne.fields[He.key]!=null&&(ue[He.key]=Ne.fields[He.key]);S(ue)}if(w(Ne.secrets??{}),C(Ne.updatedAt),e.oauth){const ue=((ke=Ne.fieldNames)==null?void 0:ke.includes(e.oauth.tokenStorage))??!1;$(ue),ue&&P.getOAuthHealth(e.id).then(He=>{X||F(He)})}}}).catch(()=>{X||Q(!0)}),()=>{X=!0}},[e.id,e.oauth]);const Y=Ak(e.toolGating),he=a?a.readAgeDays??null:void 0,ee=I&&G?G.value:he,oe=async X=>{J({value:X}),D(!0),de(null);try{await P.setReadPolicy(e.id,X),u(X===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${ua(X).toLowerCase()}`),l()}catch(Ne){de(Ne instanceof Error?Ne.message:"Could not save")}finally{D(!1),J(null)}},Oe=!!e.oauth||e.credentials.fields.some(X=>!X.optional),Fe=e.oauth?E:m,se=!Oe||Fe,Te=i==="starting"?"starting":se?a!=null&&a.running?"running":!m&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&m&&!E?"needs-oauth":"unconfigured",_e=async()=>{if(e.credentials.fields.some(Ne=>{var ke;return(ke=d[Ne.key])==null?void 0:ke.trim()})){B(!0);try{await P.setCredential(e.id,d),y(!0),p({}),e.oauth?u(`${e.name} credentials saved!`):(u(`${e.name} credentials saved — starting integration...`),await Je())}catch{u(`Failed to save ${e.name} credentials`)}finally{B(!1)}}},Ve=()=>{const X={};for(const Ne of e.credentials.fields){const ke=d[Ne.key];Ne.type==="password"?ke!=null&&ke.trim()&&(X[Ne.key]=ke):ke!=null&&ke!==(x[Ne.key]??"")&&(X[Ne.key]=ke)}return X},Ge=Object.keys(Ve()).length>0,ct=async()=>{const X=Ve();if(Object.keys(X).length!==0){B(!0);try{await P.setCredential(e.id,X),p({}),y(!0),e.oauth?u(`${e.name} credentials saved — now click Connect.`):(we(!1),u(`${e.name} credentials updated — restarting...`),await Je())}catch{u(`Failed to update ${e.name} credentials`)}finally{B(!1)}}},nt=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const X=setInterval(async()=>{var Ne;try{const ke=await P.getCredential(e.id);ke.configured&&e.oauth&&((Ne=ke.fieldNames)!=null&&Ne.includes(e.oauth.tokenStorage))&&($(!0),we(!1),F(null),clearInterval(X),u(`${e.name} connected — starting integration...`),P.getOAuthHealth(e.id).then(F).catch(()=>{}),await Je())}catch{}},2e3);setTimeout(()=>clearInterval(X),12e4)},Je=async()=>{le(!0);try{const X=await P.activateIntegration(e.id);X.warning?u(X.warning):u(`${e.name} integration started with ${X.tools.length} tools`),l()}catch(X){u(`Failed to start ${e.name}: ${X instanceof Error?X.message:"Unknown error"}`)}finally{le(!1)}},Be=async()=>{try{await P.removeMcpIntegration(e.id),u(`${e.name} integration removed`),l()}catch{u(`Failed to remove ${e.name}`)}},dt=Ik(a),et=e.oauth&&E&&(T==null?void 0:T.status)==="failed",De=X=>X.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`),Ie=dt.chip.t==="Paused"?"paused":dt.chip.t==="Crashed"?"crashed":"stopped",We=jk(Te,dt.chip),Qe=wk({needsAuth:Oe,authFailed:!!et,authConnected:Fe}),ut=Bj(e,x),ye=Uj(e,x),ze=Dj(e,x),Ye=Nk({cardState:Te,authFailed:!!et,modeNote:ye,requiredLabels:e.credentials.fields.filter(X=>!X.optional).map(X=>X.label),oauth:!!e.oauth,noFields:e.credentials.fields.length===0&&!e.oauth,setupHint:e.setupHint,reads:Y?kk(ee,ua):null,stopped:Ie}),tt=se&&!e.oauth&&e.credentials.fields.every(X=>X.optional),st=_??(te&&bk(Te,!!et,tt)),ht=X=>X.includes("/")||X.includes("\\"),jt=e.credentials.fields.length>0||!!e.oauth,qe=e.setupGuide&&e.setupGuide.length>0&&(Te!=="running"||et)?e.setupGuide:null,H=Te==="unconfigured"||Te==="needs-oauth",ge=(X,Ne)=>{var ke;return n.jsxs("div",{className:"form-group",children:[n.jsx("label",{className:"form-label",children:X.label}),X.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:Ae[X.key]?"text":"password",name:`${e.id}-${X.key}-credential`,autoComplete:"new-password",placeholder:Ne?(ke=N[X.key])!=null&&ke.preview?`Unchanged — ends in ${N[X.key].preview}`:v?"Unchanged — paste a new value to replace":X.placeholder:X.placeholder,value:d[X.key]||"",onChange:ue=>p(He=>({...He,[X.key]:ue.target.value}))}),n.jsx("button",{type:"button",className:"cred-toggle",onClick:()=>Z(ue=>({...ue,[X.key]:!ue[X.key]})),children:Ae[X.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${X.key}-credential`,autoComplete:"off",placeholder:X.placeholder,value:d[X.key]||"",onChange:ue=>p(He=>({...He,[X.key]:ue.target.value}))})]},X.key)};return n.jsxs("details",{className:"card ob-card su-cn",open:st,children:[n.jsxs("summary",{onClick:X=>{X.preventDefault(),z(!st)},children:[n.jsxs("div",{className:"su-cn-head",children:[n.jsx(At,{tag:"CONNECTOR",profileId:r==null?void 0:r.shortId,parts:[r==null?void 0:r.name,n.jsx("span",{className:`ob-st${We.tone==="muted"?" is-off":""}`,children:We.text}),ze&&n.jsx("span",{className:"ob-st is-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:"Simulation"}),Qe&&(Qe.tone==="bold"?n.jsx("span",{className:"ob-st",children:Qe.text}):Qe.text)]}),n.jsxs("h3",{className:"card-title ob-title",children:[e.name,ut&&n.jsxs("span",{className:"ob-quiet-inline",children:[" · ",ut]})]}),n.jsx("p",{className:"ob-one","data-testid":ye?"integration-mode-note":void 0,children:Ye})]}),n.jsx(tp,{})]}),n.jsxs("div",{className:"su-cn-body",ref:V,children:[n.jsx("section",{className:"ob-tile",children:n.jsx("dl",{className:"ob-kv",children:Te==="running"&&a?n.jsxs(n.Fragment,{children:[ye&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Runs on"}),n.jsx("dd",{className:"ob-plain",children:ye})]}),n.jsx("dt",{children:"Access"}),n.jsx("dd",{children:Oe?et?"Auth failed":e.oauth&&E&&(T!=null&&T.account)?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:T.account})]}):"Auth OK":"No auth"}),e.credentials.fields.map(X=>{const Ne=X.type==="password",ke=N[X.key];if(!Ne&&x[X.key]==null||Ne&&ke==null)return null;const ue=Ne?ke.preview??"set":x[X.key];return n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:X.label}),n.jsxs("dd",{className:Ne||ht(ue)?"ob-mono is-strong":void 0,children:[ue,Ne&&k&&n.jsxs("span",{className:"ob-quiet-inline",children:[" ","· added ",new Date(k).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},X.key)}),Y&&ee!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Reads"}),n.jsxs("dd",{children:[ee===null?"window from your mandate":ua(ee).toLowerCase(),I&&n.jsx("span",{className:"ob-quiet-inline",children:" saving…"}),pe&&n.jsxs("span",{className:"ob-bold",children:[" ",pe]})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Status"}),n.jsx("dd",{children:Te==="starting"?"Starting…":We.text}),e.oauth&&Te==="unconfigured"&&!v&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Step"}),n.jsx("dd",{className:"ob-plain",children:"1 of 2 — enter credentials, then connect your account"})]}),Te==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Step"}),n.jsxs("dd",{className:"ob-plain",children:["✓"," Step 1 done — credentials saved. Step 2: connect your ",e.name," account to authorize access."]})]}),Te==="ready"&&!a&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Credentials"}),n.jsxs("dd",{className:"ob-plain",children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]})]}),Te==="ready"&&a&&!a.running&&a.error&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Error"}),n.jsx("dd",{className:"ob-plain",children:a.error})]})]})})}),e.oauth&&E&&!(T!=null&&T.account)&&n.jsx("p",{className:"ob-lbl ob-gap",children:"Account not recorded — reconnect to capture which account is used"}),et&&!me&&n.jsxs("section",{className:"ob-tile",children:[n.jsxs("div",{className:"ob-sent-h",children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{className:"ob-lbl",children:[(T==null?void 0:T.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):T!=null&&T.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:T.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]})]}),qe&&n.jsxs(Gt,{title:`How to set up ${e.name}`,summary:qe[0].title,open:H,children:[e.setupHint&&!v&&n.jsx("p",{children:e.setupHint}),n.jsx("ol",{className:"su-list",children:qe.map((X,Ne)=>n.jsxs("li",{children:[n.jsx("b",{children:X.title}),n.jsxs("div",{className:"ob-lbl",children:[De(X.description),X.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:X.link,target:"_blank",rel:"noopener noreferrer",children:["Open ","↗"]})]})]})]},Ne))})]}),!qe&&e.setupHint&&!v&&H&&n.jsx("p",{className:"ob-lbl ob-gap",children:e.setupHint}),Te==="starting"&&n.jsx("p",{className:"ob-lbl ob-gap",children:"Starting…"}),me&&n.jsxs("div",{className:"su-edit",children:[n.jsx("div",{className:"ob-sent-h",children:"Change credentials"}),v&&n.jsxs("p",{className:"ob-lbl",children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(X=>ge(X,!0)),n.jsxs("div",{className:"ob-btns is-inline is-tight",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:ct,disabled:M||!Ge,children:M?"Saving…":"Save"}),e.oauth&&n.jsxs("button",{className:"ob-btn",onClick:nt,children:["Connect ",e.name]}),n.jsx("button",{className:"ob-btn",onClick:()=>{we(!1),p({})},children:"Cancel"})]}),!Ge&&!M&&n.jsx("p",{className:"ob-lbl ob-gap",children:"No changes yet"})]}),Te==="running"&&Y&&ee!==void 0&&$e&&n.jsxs("div",{className:"su-edit",children:[n.jsx("div",{className:"ob-sent-h",children:"How far back may your agent read?"}),n.jsx("p",{className:"ob-lbl",children:"Applies immediately — no Save, no new mandate."}),n.jsxs("div",{className:"ob-btns is-tight",children:[Tk.map(X=>{const Ne=ee===X;return n.jsx("button",{className:`ob-btn${Ne?" is-solid":""}`,"aria-pressed":Ne,disabled:I,onClick:()=>oe(X),children:ua(X)},X)}),n.jsx("button",{className:`ob-btn${ee===null?" is-solid":""}`,"aria-pressed":ee===null,disabled:I,onClick:()=>oe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:ua(null)})]}),n.jsx("p",{className:"ob-lbl ob-gap",children:pe?n.jsx("span",{className:"ob-bold",children:pe}):I?"Saving…":ee===null?"Using the window from your mandate. If none is set there, reads are blocked.":ee===0?"Your agent cannot read any mail.":`Anything older than ${ee} days is blocked, whoever it is from.`}),n.jsx("div",{className:"ob-btns is-inline is-tight",children:n.jsx("button",{className:"ob-btn",onClick:()=>ve(!1),children:"Done"})})]}),!me&&Te==="running"&&a&&n.jsxs("div",{className:"ob-btns",children:[et&&n.jsxs("button",{className:"ob-btn is-solid",onClick:nt,children:["Reconnect ",e.name]}),n.jsx(pt,{to:"/mandates?new=1",className:"ob-btn",children:"Give a mandate"}),jt&&n.jsx("button",{className:"ob-btn",onClick:()=>{p({...x}),we(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),Y&&ee!==void 0&&!$e&&n.jsx("button",{className:"ob-btn",onClick:()=>ve(!0),children:"Edit reads window"}),n.jsx("button",{className:"ob-btn",onClick:Be,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),Te==="unconfigured"&&(()=>{const X=e.credentials.fields.every(ue=>ue.optional),Ne=e.credentials.fields.some(ue=>!ue.optional),ke=e.credentials.fields.some(ue=>{var He;return(He=d[ue.key])==null?void 0:He.trim()});return n.jsxs(n.Fragment,{children:[v&&n.jsxs("p",{className:"ob-lbl ob-gap",children:[n.jsx("b",{className:"ob-bold",children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",n.jsx("button",{className:"ob-link",onClick:()=>{y(!0),e.oauth&&$(!0)},children:"keep existing"}),"."]}),n.jsx("div",{className:"su-fields",children:e.credentials.fields.map(ue=>ge(ue,!1))}),n.jsxs("div",{className:"ob-btns is-inline",children:[(ke||Ne)&&n.jsx("button",{className:"ob-btn is-solid",onClick:_e,disabled:M||!ke||Ne&&!e.credentials.fields.filter(ue=>!ue.optional).every(ue=>{var He;return(He=d[ue.key])==null?void 0:He.trim()}),children:M?"Saving...":"Save & Encrypt"}),X&&!ke&&n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":`Activate ${e.name}`})]})]})})(),Te==="needs-oauth"&&n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsxs("button",{className:"ob-btn is-solid",onClick:nt,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"ob-btn",onClick:()=>y(!1),children:"Change Credentials"})]}),Te==="ready"&&!a&&n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"ob-btn",onClick:()=>y(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"ob-btn",onClick:()=>{y(!1),$(!1)},children:"Change Credentials"})]}),Te==="ready"&&a&&!a.running&&(dt.showStart?n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":"Start"}),n.jsx("button",{className:"ob-btn",onClick:Be,children:"Disable"})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ob-lbl ob-gap",children:"Real systems are off while simulation mode is on."}),n.jsx("div",{className:"ob-btns is-inline",children:n.jsx("button",{className:"ob-btn",onClick:Be,children:"Disable"})})]})),n.jsx(Gt,{title:"Details",summary:"what it does",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"What"}),n.jsx("dd",{className:"ob-plain",children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Profile"}),n.jsx("dd",{className:"ob-plain",children:og(e).join(", ")})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Scopes"}),n.jsx("dd",{className:"ob-plain",children:((be=e.oauth.scopes)==null?void 0:be.join(", "))||"—"})]}),a&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Tools"}),n.jsxs("dd",{className:"ob-plain",children:[a.toolCount," gated"]})]})]})})]})]})}const $k={card:"💳",mail:"✉️"};function Pk(e){return $k[e]??"🔧"}function _i({entries:e,catalog:r,refresh:a,onSuccess:i}){return n.jsx(n.Fragment,{children:lg(e,r).map(l=>n.jsxs("div",{className:"area-group su-area","data-testid":"integration-area","data-area":l.shortId,children:[n.jsxs("div",{className:"area-group-h sr-only",children:[n.jsx(Dr,{icon:l.icon}),n.jsx("b",{children:l.name})]}),l.entries.map(u=>n.jsx(Rk,{manifest:u.manifest,area:{shortId:l.shortId,name:l.name},integration:u.integration,state:u.state,onStatusChange:a,onSuccess:i},u.id))]},l.shortId))})}function Li({title:e,count:r,note:a}){return n.jsxs("div",{className:"su-sec",children:[e,n.jsxs("small",{children:[r," ",r===1?"connector":"connectors",a?` · ${a}`:""]})]})}function _k({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Pk(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsx("span",{className:"int-paused-state",children:"Paused"})]})}function Lk(){const{loading:e,mcpServerUp:r,manifestsError:a,entries:i,refresh:l}=iu(),u=au(),[d,p]=f.useState(""),m=On(),y=f.useCallback(C=>{p(C),setTimeout(()=>p(""),5e3)},[]),v=Ck(i,u),{inUse:j,notSetUp:x}=Ek(i),S=C=>lg(C,m).reduce((E,$)=>E+$.entries.length,0),N=S(j),w=S(x),k=!e&&r!==!1&&i.length>0&&!v.grouped?` ${N} in use · ${w} not set up.`:"";return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsxs("p",{className:"page-subtitle",children:["Connect external services and manage MCP integrations.",k]})]}),d&&n.jsx("div",{className:"alert alert-success",children:d}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):r===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):v.grouped?n.jsxs(n.Fragment,{children:[v.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Test systems",count:v.testSystems.length}),n.jsx(_i,{entries:v.testSystems,catalog:m,refresh:l,onSuccess:y})]}),(v.realErrors.length>0||v.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Real systems",count:v.realErrors.length+v.pausedReal.length}),n.jsx(_i,{entries:v.realErrors,catalog:m,refresh:l,onSuccess:y}),v.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",v.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),v.pausedReal.map(C=>n.jsx(_k,{entry:C},C.id))]})]}),i.length===0&&n.jsx(qf,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[j.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"In use",count:N}),n.jsx(_i,{entries:j,catalog:m,refresh:l,onSuccess:y})]}),x.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Not set up",count:w,note:"open one to set it up"}),n.jsx(_i,{entries:x,catalog:m,refresh:l,onSuccess:y})]}),i.length===0&&n.jsx(qf,{manifestsError:a})]})]})}function qf({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function Mk(){var _;const{activeTeam:e,activeMembership:r,refreshGroups:a,user:i}=Nt(),l=yn(),u=va(),[d,p]=f.useState(null),[m,y]=f.useState(!1),[v,j]=f.useState(""),[x,S]=f.useState(""),[N,w]=f.useState(""),[k,C]=f.useState("");f.useEffect(()=>{fetch("/health").then(z=>z.json()).then(z=>{typeof z.spUrl=="string"&&C(z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!e){p(null);return}P.getGroupById(e.id).then(z=>{const V=z.group??z,K=z.members??[],le=z.isAdmin??!1,me=K.map(we=>{const Ae=we.userId||we.id||"",Z=we.role||(le&&Ae===V.createdBy?"admin":"member");return{id:Ae,name:we.name||Ae.slice(0,8)||"Member",email:we.email||"",domains:we.domains||[],role:Z,isAdmin:Z==="admin"||le&&Ae===V.createdBy}});p({id:V.id,name:V.name,members:me})}).catch(()=>p(null))},[e==null?void 0:e.id]);const E=(d==null?void 0:d.members.filter(z=>z.isAdmin))??[],$=(e==null?void 0:e.isAdmin)===!0&&E.length<=1&&E.some(z=>z.id===(i==null?void 0:i.id)),T=(e==null?void 0:e.name)??"",F=N.trim()===T&&!m,M=async()=>{if(!(!e||!F)){y(!0),j("");try{await P.leaveTeam(e.id),await a(),S("You have left the team."),p(null),w("")}catch(z){j(z instanceof Error?z.message:"Failed to leave team")}finally{y(!1)}}},B=e&&k?`${k}/dashboard/groups/${e.id}`:void 0,te=k?`${k}/dashboard/groups`:void 0,Q=((_=d==null?void 0:d.members)==null?void 0:_.length)??0;return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]}),v&&n.jsx("div",{className:"error-message",children:v}),x&&n.jsx("div",{className:"alert alert-success",children:x}),e?n.jsxs("article",{className:"ob-card su-card",ref:u,children:[n.jsx(At,{tag:"TEAM",parts:[n.jsx("span",{className:"ob-st",children:"Active"}),`${Q} ${Q===1?"member":"members"}`]}),n.jsx("h2",{className:"ob-title is-h3",children:e.name}),Q>0&&n.jsxs("section",{className:"ob-tile su-members",children:[n.jsx("div",{className:"su-tile-h",children:"Members"}),d==null?void 0:d.members.map(z=>n.jsxs("div",{className:"su-m",children:[n.jsx("span",{className:"su-av",children:z.name.split(" ").map(V=>V[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"su-who",children:[n.jsx("b",{children:z.name}),n.jsx("span",{children:z.email})]}),n.jsx("span",{className:`su-role${z.isAdmin?" is-admin":""}`,children:z.role})]},z.id))]}),n.jsxs(Gt,{title:"Leave team",summary:$?"you are the only admin":"revokes your mandates in this team",children:[n.jsx("p",{children:"Leaving will:"}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsx("p",{className:"ob-lbl ob-gap",children:"Your personal mandates are not affected."}),$?n.jsx("p",{className:"ob-lbl",children:"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving."}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",className:"form-label",children:["Type ",n.jsx("code",{children:T})," to confirm"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:N,onChange:z=>w(z.target.value),placeholder:T,disabled:m})]}),n.jsx("div",{className:"ob-btns is-inline is-tight",children:n.jsx("button",{className:"ob-btn",onClick:M,disabled:!F,children:m?"Leaving...":"Leave team"})})]})]}),B&&n.jsx("div",{className:"ob-btns",children:n.jsx("a",{className:"ob-btn",href:B,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server ↗"})})]}):n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{tag:"TEAM",parts:[n.jsx("span",{className:"ob-st",children:"Personal"})]}),n.jsx("h2",{className:"ob-title is-h3",children:"You are working solo."}),n.jsx("p",{className:"ob-one",children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:()=>l("/onboarding"),children:"Join or create a team"}),te&&n.jsx("a",{className:"ob-btn",href:te,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server ↗"})]})]})]})}function gu({areas:e,selected:r,onSelect:a,totalCount:i}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":r===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:i})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":r===l.shortId,onClick:()=>a(r===l.shortId?null:l.shortId),children:[n.jsx(Dr,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const xr=e=>e.replace(/@.*$/,"").split("/").pop()??e,Kf=e=>e.split("@")[1]??"";function Gf(e){var a;const r=e.profile?[xr(e.profile)]:[];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(xr(l))&&r.push(xr(l))}return r}function Fk(e,r){const a=new Map;for(const i of e){const l=xr(i.id);if(!r.has(l))continue;const u=a.get(l);(!u||Kf(i.id).localeCompare(Kf(u.id),void 0,{numeric:!0})>0)&&a.set(l,i)}return a}function Ok(e,r,a,i){var p;const l=new Set([...r.flatMap(m=>Gf(m)),...i.map(m=>xr(m.profile))]),u=Fk(e,l),d=[];for(const m of r){const y=Gf(m);for(const[v,j]of y.entries()){const x=u.get(j);x&&d.push({key:v===0?`connector:${m.id}`:`connector:${m.id}:${j}`,name:y.length>1?`${m.name} — ${x.name??j}`:m.name,description:m.description||x.description,profile:x,kind:"connector",ready:((p=a.find(S=>S.id===m.id))==null?void 0:p.running)===!0,setupId:m.id,...m.intentHint&&v===0?{intentHint:m.intentHint}:{}})}}for(const m of i){const y=u.get(xr(m.profile));y&&d.push({key:`builtin:${m.id}`,name:m.name,description:m.description||y.description,profile:y,kind:"builtin",ready:m.available,unavailableReason:m.available?void 0:"Available only while simulation mode is on.",...m.intentHint?{intentHint:m.intentHint}:{}})}return d}function zk(e,r,a){if(r)return e.find(i=>xr(i.profile.id)===xr(r)&&i.ready&&a(i))}function cg({icon:e,className:r}){return n.jsx(Dr,{icon:e,className:r})}function Dk({onDismiss:e,preselectProfileId:r}){const a=yn(),{group:i,groupId:l,domain:u,user:d}=Nt(),[p,m]=f.useState([]),[y,v]=f.useState([]),[j,x]=f.useState([]),[S,N]=f.useState([]),[w,k]=f.useState(!0),[C,E]=f.useState({});f.useEffect(()=>{Promise.all([P.listProfiles().catch(()=>[]),P.getIntegrationManifests().then(Q=>Q.manifests??[]).catch(()=>[]),P.getMcpHealth().catch(()=>null)]).then(async([Q,_,z])=>{if(m(Q),v(_),x((z==null?void 0:z.integrations)??[]),N((z==null?void 0:z.builtins)??[]),l){const V=await Promise.all(Q.map(le=>P.getTeamProfileConfig(l,le.id).catch(()=>null))),K={};Q.forEach((le,me)=>{const we=V[me];we&&(K[le.id]=we)}),E(K)}}).finally(()=>k(!1))},[l]);const $=Ok(p,y,j,S),T=Q=>{const _=C[Q.id];return ag({isPersonal:!!(i!=null&&i.isPersonal),configLoaded:!w,grantors:_?Wm(_):void 0,userId:d==null?void 0:d.id,profileName:Vt(Q.id),teamName:i==null?void 0:i.name})},F=Q=>Q in C,M=(Q,_)=>{if(!l){console.error("No active group when creating authorization");return}const z=F(Q);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Q,groupId:l,groupName:(i==null?void 0:i.name)??null,domain:u,isTeam:z,isPersonal:!!(i!=null&&i.isPersonal),..._?{intentHint:_}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},B=(Q,_)=>{l&&M(Q,_)},te=f.useRef(!1);return f.useEffect(()=>{if(w||!r||te.current)return;const Q=zk($,r,_=>T(_.profile).can);Q&&(te.current=!0,B(Q.profile.id,Q.intentHint))},[w,r]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
77
+ `).replace(/\n+$/,"")}async function wo(e){const a=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(i)).map(u=>u.toString(16).padStart(2,"0")).join("")}class lk extends Error{constructor(a,i,l){super(l);ia(this,"code");ia(this,"field");this.name="CanonicalValueError",this.code=a,this.field=i}}function ck(e){const r=new TextEncoder().encode(e);let a="";for(const i of r)i===61||i===37||i<32||i>126?a+="%"+i.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(i);return a}function eg(e,r,a){const i=[];for(const l of r){const u=e[l];if(u==null)continue;const d=String(u);if(d.includes(`
78
+ `)||d.includes("\r"))throw new lk(a,l,`Value for "${l}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);i.push(`${l}=${ck(d)}`)}return i.join(`
79
+ `)}async function Bi(e,r){const a=r.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const i=eg(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await wo(i)}`}async function tg(e){return`sha256:${await wo(oo(e.executionContextSchema??{}))}`}async function ng(e,r){const a=r.scopeSchema?eg(e,r.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await wo(a)}`}function oo(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":oo(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+oo(l))}return"{"+a.join(",")+"}"}async function rg(e){return`sha256:${await wo(oo(e))}`}async function sg(e){const r=new TextEncoder().encode(ok(e)),a=await crypto.subtle.digest("SHA-256",r);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function ag(e,r){if(!e.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??r.boundsHash,contextHash:r.contextHash,context:r.context,...r.contextLabels&&Object.keys(r.contextLabels).length>0?{contextLabels:r.contextLabels}:{},gateContent:r.gateContent,...r.path?{path:r.path}:{}}}function uk(e){const r=e.commitment_modes;return r===void 0?["review","automatic"]:Array.isArray(r)?["review","automatic"].filter(a=>r.includes(a)):[]}function dk(e){return e==="per-action"?"review":"automatic"}function Uf(e){return e?uk(e).map(r=>r==="review"?"per-action":"immediate"):["per-action","immediate"]}function hk(e,r){return r.includes(e)?e:r[0]??null}function Wf(e){return e==null?new Set:new Set(String(e).split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}function fk(e,r){for(const a of e)if(r.has(a))return!0;return!1}function mk(e,r,a){for(const i of e){const l=Wf(r[i]),u=Wf(a[i]);if(!(l.size===0||u.size===0)&&!fk(l,u))return!1}return!0}function pk(e){return e.length>24?`${e.slice(0,10)}…`:e}function ig(e,r,a){const i=a==null?void 0:a[e];return String(r).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const d=i==null?void 0:i[u];return d?`${d} (${pk(u)})`:u}).join(", ")}function og(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const r=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${r}.`,fix:`Ask an admin of ${r} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${r} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const Dc=500;function gk(e){const r=e.trim();return r.length===0?{valid:!1,error:"Describe what should change."}:r.length>Dc?{valid:!1,error:`At most ${Dc} characters (currently ${r.length}).`}:{valid:!0,trimmed:r}}function lg(){return{outcome:"rejected"}}function Hf(){return{outcome:"replaced"}}function vk(e,r){if((e.pendingApprovers??[]).includes(r))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(r)?{route:"resolve",domain:r}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const yk={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function xk(e,r){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const i=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:yk[i],who:a.userId===r?"You":a.userId,at:a.at,note:l}}function jk(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function wk(){var Qe,ut;const e=yn(),{user:r,mode:a,domain:i}=Nt(),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState("per-action"),[x,S]=f.useState(1800),[N,w]=f.useState(86400),[k,C]=f.useState(""),[E,$]=f.useState("hours"),[T,F]=f.useState(""),[M,B]=f.useState(!0),[te,Q]=f.useState(!1);f.useEffect(()=>{P.getIdentityDisclosure().then(ye=>Q(ye.always)).catch(()=>{})},[]);const[_,z]=f.useState(!1),[V,K]=f.useState(""),[le,me]=f.useState(null),[we,Ae]=f.useState([]),[Z,G]=f.useState(!1),[J,I]=f.useState([]),[D,pe]=f.useState(0);f.useEffect(()=>{var jt;const ye=sessionStorage.getItem("agentAuth"),ze=sessionStorage.getItem("agentGate");if(!ye||!ze){e("/mandates?new=1");return}const Ye=JSON.parse(ye),tt=JSON.parse(ze),st={bounds:tt.bounds??{},context:tt.context??{},contextLabels:tt.contextLabels??void 0,gateContent:tt.gateContent};u(Ye),p(st),tt.ttlConfig&&(S(tt.ttlConfig.default??1800),w(tt.ttlConfig.max??86400)),tt.templateMode==="automatic"?j("immediate"):tt.templateMode==="review"&&j("per-action");const ht=((jt=tt.ttlConfig)==null?void 0:jt.max)??86400;if(typeof tt.templateTtl=="number"&&tt.templateTtl>0){const qe=Math.min(tt.templateTtl,ht);S(qe),[3600,86400,604800,2592e3,31536e3].includes(qe)||(qe%86400===0?(C(String(qe/86400)),$("days")):(C(String(Math.max(1,Math.round(qe/3600)))),$("hours")))}P.getProfile(Ye.profileId).then(qe=>{var H;if(y(qe),!T){const ge=qe.name??((H=Ye.profileId.split("/").pop())==null?void 0:H.replace(/@.*$/,""))??"",be=[];if(st.context&&qe.scopeSchema)for(const Ne of qe.scopeSchema.keyOrder){const ke=st.context[Ne];if(ke!==void 0&&ke!==""){const ue=String(ke).split(",").map(He=>He.trim()).filter(Boolean);be.push(ue.join(", "))}}const X=be.length>0?`${ge}: ${be.join(" · ")}`:ge;F(X)}}).catch(()=>{}),Ye.isPersonal?G(!0):Promise.all([P.getTeamProfileConfig(Ye.groupId,Ye.profileId).catch(()=>null),P.getGroupById(Ye.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([qe,H,ge])=>{if(me(qe),qe){const be=new Map;for(const ke of ge){const ue=ke.name&&ke.email?`${ke.name} (${ke.email})`:ke.name||ke.email||ke.id;be.set(ke.id,ue)}const X=(H==null?void 0:H.members)??[];for(const ke of X){const ue=ke.userId??ke.id;ue&&(ke.name&&ke.email?be.set(ue,`${ke.name} (${ke.email})`):ke.name&&be.set(ue,ke.name))}const Ne=(qe.approvers??[]).map(ke=>be.get(ke)??ke);Ae(Ne)}}).finally(()=>{G(!0)})},[e]),f.useEffect(()=>{if(!(l!=null&&l.profileId))return;const ye=l.profileId,ze=sessionStorage.getItem("agentEditReplaces");P.getEnrichedAuthorizations().then(Ye=>{const tt=Ye.filter(st=>st.profileId===ye&&st.authorizationId!==ze).map(st=>({authorizationId:st.authorizationId,bounds:st.bounds,context:st.context??{},intent:st.intent}));I(tt)}).catch(()=>I([]))},[l==null?void 0:l.profileId]),f.useEffect(()=>{if(!m)return;const ye=hk(v,Uf(m));ye&&ye!==v&&j(ye)},[m,v]),f.useEffect(()=>{if(!d||!m||J.length===0){pe(0);return}let ye=!1;return(async()=>{const ze=await Bi(d.bounds,m),Ye=await Promise.all(J.map(tt=>Bi(tt.bounds,m).catch(()=>null)));ye||pe(Ye.filter(tt=>tt===ze).length)})().catch(()=>{ye||pe(0)}),()=>{ye=!0}},[d,m,J]);const de=async()=>{if(!(!l||!d||!m||!r)){if(!l.groupId){K("No active group; cannot create mandate.");return}z(!0),K("");try{const ye=i||l.domain||"owner",ze=await Bi(d.bounds,m),Ye=await ng(d.context,m),[tt,st]=await Promise.all([sg(d.gateContent.intent),tg(m)]);let ht,jt,qe,H;if(l.isTeam){const He=await P.getApproversPubkeys(l.groupId,l.profileId);if(He.length>0){const kt=await P.encryptIntent(d.gateContent.intent,He);ht=kt.intentCiphertext,jt=kt.encryptedKeys,qe=kt.approversFrozen,H=kt.intentDisclosureHash}}const ge=`authz_${crypto.randomUUID()}`,be=sessionStorage.getItem("agentEditReplaces")||void 0,X=sessionStorage.getItem("agentReplacesProposal")||void 0,Ne=await rg(m),ke=await P.attest({authorization_id:ge,replaces:be,profile_id:l.profileId,profile_hash:Ne,supported_versions:[...Bm],bounds:d.bounds,bounds_hash:ze,scope_hash:Ye,domain:ye,did:r.did,mandate_owners:[{did:r.did}],gate_content_hashes:{intent:tt},execution_context_hash:st,group_id:l.groupId,ttl:x,commitment_mode:dk(v),title:T.trim(),intent_ciphertext:ht,encrypted_keys:jt,approvers_frozen:qe,intent_disclosure_hash:H,disclose_identity:M});try{await P.pushGateContent(ag(ke,{boundsHash:ze,contextHash:Ye,context:d.context,contextLabels:d.contextLabels,gateContent:d.gateContent}))}catch(He){try{await P.revokeAttestation(ge,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${He instanceof Error?He.message:"Unknown error"})`)}if(be)try{await P.revokeAttestation(be,`Replaced by ${ge} (edit)`),P.resyncGates().catch(()=>{})}catch{}let ue="";if(X)try{const He=await P.getProposal(X);if(He.status==="pending"){const kt=vk(He,(r==null?void 0:r.id)??"");kt?kt.route==="approver"?await P.rejectProposal(X,Hf()):await P.resolveProposal(X,"reject",kt.domain,Hf()):ue="you are not one of the people who may decide it"}}catch(He){ue=He instanceof Error?He.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),ue){K(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${ue}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(ge)}`)}catch(ye){K(ye instanceof Error?ye.message:"Signing the mandate failed")}finally{z(!1)}}};if(!l||!d)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const $e=Object.entries(d.bounds).filter(([ye])=>ye!=="profile"&&ye!=="path"),ve=Object.entries(d.context),he=((le==null?void 0:le.caps)!=null?Object.keys(le.caps):[]).length!==0,ee=we.length>0?we.join(", "):((le==null?void 0:le.approvers)??[]).join(", "),oe=he?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ee}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Oe=he?`Over-cap actions will be reviewed by you and ${ee}. Within-cap actions run per the mode you chose above.`:`Approvers ${ee} can read your intent but won't gate any action — no caps configured on this profile.`,Fe=!!((Qe=le==null?void 0:le.approvers)!=null&&Qe.length),se=og({isPersonal:l.isPersonal,configLoaded:Z,grantors:le?Wm(le):void 0,userId:r==null?void 0:r.id,profileName:Vt(l.profileId),teamName:l.groupName}),Te=!se.can,_e=Uf(m),Ve=_e.length===0,Ge=x>N,ct={flex:1,padding:"0.75rem",border:v==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:v==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},nt={flex:1,padding:"0.75rem",border:v==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:v==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Je=((ut=m==null?void 0:m.scopeSchema)==null?void 0:ut.keyOrder)??[],Be=J.filter(ye=>mk(Je,d.context,ye.context)),dt=Be.length>0,et=Vt(l.profileId),De=ye=>{const ze=Object.values(ye).map(Ye=>String(Ye).trim()).filter(Boolean);return ze.length>0?ze.join(", "):"all (unscoped)"},Ie=Be.map(ye=>De(ye.context)).join("; "),We=`This grant's scope overlaps an existing grant on ${et} (scoped to: ${Ie}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return n.jsxs(n.Fragment,{children:[n.jsx(Yp,{currentStep:4,onStepClick:ye=>{ye<=3&&e(`/mandates/new/intent?step=${ye}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&m&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Vt(l.profileId)," ",m.version," — the current version of this profile."]})]}),V&&n.jsx("div",{className:"error-message",children:V}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Vt(l.profileId)}: daily operations`,value:T,onChange:ye=>F(ye.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," ",Di]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[_e.includes("per-action")&&n.jsxs("button",{onClick:()=>j("per-action"),style:nt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:no.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:no.text})]}),_e.includes("immediate")&&n.jsxs("button",{onClick:()=>j("immediate"),style:ct,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:ro.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:ro.text})]})]}),_e.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:_e[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ve&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(ye=>ye.seconds<=N).map(ye=>n.jsx("button",{onClick:()=>{S(ye.seconds),C("")},style:{padding:"0.5rem 0.85rem",border:x===ye.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===ye.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:ye.label},ye.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:k,onChange:ye=>{C(ye.target.value);const ze=parseInt(ye.target.value,10);if(ze>0){const Ye=E==="days"?ze*86400:ze*3600;S(Math.min(Ye,N))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:E,onChange:ye=>{$(ye.target.value);const ze=parseInt(k,10);if(ze>0){const Ye=ye.target.value==="days"?ze*86400:ze*3600;S(Math.min(Ye,N))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),Ge&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",N>=86400?`${Math.floor(N/86400)} days`:`${Math.floor(N/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:te||M,disabled:te,onChange:ye=>B(ye.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',te&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:d.gateContent.intent})]}),(!!$e.length||!!ve.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[ve.map(([ye,ze])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:ye}),n.jsx("dd",{children:ig(ye,ze,d.contextLabels)})]},ye)),$e.map(([ye,ze])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:ye}),n.jsx("dd",{children:String(ze)})]},ye))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Vt(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:Z?se.can?n.jsxs(n.Fragment,{children:[ee,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:oe})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:se.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),se.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ee}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[se.reason," ",se.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),D>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[D===1?`An active grant on ${et} already has exactly these limits.`:`${D} active grants on ${et} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,dt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:We})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:de,disabled:_||!T.trim()||Te||Ve,children:_?"Signing...":v==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Fe?"block":"none"},children:Oe})]})]})}function bk(e,r){return e==="running"?{text:"Running",tone:"bold"}:e==="starting"?{text:"Starting",tone:"muted"}:e==="unconfigured"||e==="needs-oauth"?{text:"Not set up",tone:"muted"}:{text:r.t,tone:r.t==="Crashed"?"bold":"muted"}}function kk(e){return e.needsAuth?e.authFailed?{text:"Auth failed",tone:"bold"}:e.authConnected?{text:"Auth OK",tone:"muted"}:null:{text:"No auth",tone:"muted"}}function Sk(e,r,a=!1){return r?!0:e==="unconfigured"?a:e==="needs-oauth"||e==="ready"}function Nk(e,r){return e===void 0?null:e===null?"reads follow your mandate":e===0?"reads nothing":`reads ${r(e).toLowerCase()}`}function Ck(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Ek(e){var r;if(e.authFailed)return"The stored credentials stopped working — reconnect to use it again";switch(e.cardState){case"running":{const a=[(r=e.modeNote)==null?void 0:r.replace(/\.$/,""),e.reads].filter(Boolean);return a.length?a.join(" · "):e.noFields?"Nothing to set up":"Credentials on file"}case"starting":return"Starting…";case"needs-oauth":return"Credentials saved — connect your account";case"unconfigured":{if(e.requiredLabels.length===0)return e.setupHint??e.modeNote??"Works out of the box — activate it to start";const a=`Needs ${Ck(e.requiredLabels)}`;return e.oauth?`${a}, then connect your account`:a}case"ready":return e.stopped==="paused"?"Paused while simulation mode is on":e.stopped==="crashed"?"Stopped with an error":"Credentials saved — start it to use it"}}function cg(e){var a;const r=[e.profile];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(l)&&r.push(l)}return r}function ug(e,r){const a=new Map;for(const i of e)for(const l of cg(i.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Jn(l),name:Qn(l,r),entries:[]},a.set(l,u)),u.entries.push(i)}return[...a.values()].sort((i,l)=>i.name.localeCompare(l.name))}function Ak(e,r){if(!r)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(d=>qi(d.manifest)&&!Ki(d,r)),i=e.filter(d=>!qi(d.manifest)||Ki(d,r)),l=i.filter(d=>d.state==="error"),u=i.filter(d=>d.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function Tk(e){const r=[],a=[];for(const i of e){const l=i.authStatus==="not_configured"||i.authStatus==="not_connected";(i.state==="running"&&!l?r:a).push(i)}return{inUse:r,notSetUp:a}}function Ik(e){const r=e==null?void 0:e.overrides;return!r||typeof r!="object"?!1:Object.values(r).some(a=>{var i;return typeof((i=a==null?void 0:a.read)==null?void 0:i.ageField)=="string"})}const Rk=[0,7,30,90,365,3650];function ua(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function $k(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{t:"Crashed"},showStart:!0}:{chip:{t:"Stopped"},showStart:!0}}function Pk({manifest:e,area:r,integration:a,state:i,onStatusChange:l,onSuccess:u}){var be;const[d,p]=f.useState({}),[m,y]=f.useState(!1),[v,j]=f.useState(!1),[x,S]=f.useState({}),[N,w]=f.useState({}),[k,C]=f.useState(void 0),[E,$]=f.useState(!1),[T,F]=f.useState(null),[M,B]=f.useState(!1),[te,Q]=f.useState(!1),[_,z]=f.useState(null),V=va(),[K,le]=f.useState(!1),[me,we]=f.useState(!1),[Ae,Z]=f.useState({}),[G,J]=f.useState(null),[I,D]=f.useState(!1),[pe,de]=f.useState(null),[$e,ve]=f.useState(!1);f.useEffect(()=>{let X=!1;return P.getCredential(e.id).then(Ne=>{var ke;if(!X&&(Q(!0),!!Ne.configured)){if(y(!0),j(!0),Ne.fields){const ue={};for(const He of e.credentials.fields)Ne.fields[He.key]!=null&&(ue[He.key]=Ne.fields[He.key]);S(ue)}if(w(Ne.secrets??{}),C(Ne.updatedAt),e.oauth){const ue=((ke=Ne.fieldNames)==null?void 0:ke.includes(e.oauth.tokenStorage))??!1;$(ue),ue&&P.getOAuthHealth(e.id).then(He=>{X||F(He)})}}}).catch(()=>{X||Q(!0)}),()=>{X=!0}},[e.id,e.oauth]);const Y=Ik(e.toolGating),he=a?a.readAgeDays??null:void 0,ee=I&&G?G.value:he,oe=async X=>{J({value:X}),D(!0),de(null);try{await P.setReadPolicy(e.id,X),u(X===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${ua(X).toLowerCase()}`),l()}catch(Ne){de(Ne instanceof Error?Ne.message:"Could not save")}finally{D(!1),J(null)}},Oe=!!e.oauth||e.credentials.fields.some(X=>!X.optional),Fe=e.oauth?E:m,se=!Oe||Fe,Te=i==="starting"?"starting":se?a!=null&&a.running?"running":!m&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&m&&!E?"needs-oauth":"unconfigured",_e=async()=>{if(e.credentials.fields.some(Ne=>{var ke;return(ke=d[Ne.key])==null?void 0:ke.trim()})){B(!0);try{await P.setCredential(e.id,d),y(!0),p({}),e.oauth?u(`${e.name} credentials saved!`):(u(`${e.name} credentials saved — starting integration...`),await Je())}catch{u(`Failed to save ${e.name} credentials`)}finally{B(!1)}}},Ve=()=>{const X={};for(const Ne of e.credentials.fields){const ke=d[Ne.key];Ne.type==="password"?ke!=null&&ke.trim()&&(X[Ne.key]=ke):ke!=null&&ke!==(x[Ne.key]??"")&&(X[Ne.key]=ke)}return X},Ge=Object.keys(Ve()).length>0,ct=async()=>{const X=Ve();if(Object.keys(X).length!==0){B(!0);try{await P.setCredential(e.id,X),p({}),y(!0),e.oauth?u(`${e.name} credentials saved — now click Connect.`):(we(!1),u(`${e.name} credentials updated — restarting...`),await Je())}catch{u(`Failed to update ${e.name} credentials`)}finally{B(!1)}}},nt=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const X=setInterval(async()=>{var Ne;try{const ke=await P.getCredential(e.id);ke.configured&&e.oauth&&((Ne=ke.fieldNames)!=null&&Ne.includes(e.oauth.tokenStorage))&&($(!0),we(!1),F(null),clearInterval(X),u(`${e.name} connected — starting integration...`),P.getOAuthHealth(e.id).then(F).catch(()=>{}),await Je())}catch{}},2e3);setTimeout(()=>clearInterval(X),12e4)},Je=async()=>{le(!0);try{const X=await P.activateIntegration(e.id);X.warning?u(X.warning):u(`${e.name} integration started with ${X.tools.length} tools`),l()}catch(X){u(`Failed to start ${e.name}: ${X instanceof Error?X.message:"Unknown error"}`)}finally{le(!1)}},Be=async()=>{try{await P.removeMcpIntegration(e.id),u(`${e.name} integration removed`),l()}catch{u(`Failed to remove ${e.name}`)}},dt=$k(a),et=e.oauth&&E&&(T==null?void 0:T.status)==="failed",De=X=>X.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`),Ie=dt.chip.t==="Paused"?"paused":dt.chip.t==="Crashed"?"crashed":"stopped",We=bk(Te,dt.chip),Qe=kk({needsAuth:Oe,authFailed:!!et,authConnected:Fe}),ut=Wj(e,x),ye=Hj(e,x),ze=Uj(e,x),Ye=Ek({cardState:Te,authFailed:!!et,modeNote:ye,requiredLabels:e.credentials.fields.filter(X=>!X.optional).map(X=>X.label),oauth:!!e.oauth,noFields:e.credentials.fields.length===0&&!e.oauth,setupHint:e.setupHint,reads:Y?Nk(ee,ua):null,stopped:Ie}),tt=se&&!e.oauth&&e.credentials.fields.every(X=>X.optional),st=_??(te&&Sk(Te,!!et,tt)),ht=X=>X.includes("/")||X.includes("\\"),jt=e.credentials.fields.length>0||!!e.oauth,qe=e.setupGuide&&e.setupGuide.length>0&&(Te!=="running"||et)?e.setupGuide:null,H=Te==="unconfigured"||Te==="needs-oauth",ge=(X,Ne)=>{var ke;return n.jsxs("div",{className:"form-group",children:[n.jsx("label",{className:"form-label",children:X.label}),X.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:Ae[X.key]?"text":"password",name:`${e.id}-${X.key}-credential`,autoComplete:"new-password",placeholder:Ne?(ke=N[X.key])!=null&&ke.preview?`Unchanged — ends in ${N[X.key].preview}`:v?"Unchanged — paste a new value to replace":X.placeholder:X.placeholder,value:d[X.key]||"",onChange:ue=>p(He=>({...He,[X.key]:ue.target.value}))}),n.jsx("button",{type:"button",className:"cred-toggle",onClick:()=>Z(ue=>({...ue,[X.key]:!ue[X.key]})),children:Ae[X.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${X.key}-credential`,autoComplete:"off",placeholder:X.placeholder,value:d[X.key]||"",onChange:ue=>p(He=>({...He,[X.key]:ue.target.value}))})]},X.key)};return n.jsxs("details",{className:"card ob-card su-cn",open:st,children:[n.jsxs("summary",{onClick:X=>{X.preventDefault(),z(!st)},children:[n.jsxs("div",{className:"su-cn-head",children:[n.jsx(At,{tag:"CONNECTOR",profileId:r==null?void 0:r.shortId,parts:[r==null?void 0:r.name,n.jsx("span",{className:`ob-st${We.tone==="muted"?" is-off":""}`,children:We.text}),ze&&n.jsx("span",{className:"ob-st is-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:"Simulation"}),Qe&&(Qe.tone==="bold"?n.jsx("span",{className:"ob-st",children:Qe.text}):Qe.text)]}),n.jsxs("h3",{className:"card-title ob-title",children:[e.name,ut&&n.jsxs("span",{className:"ob-quiet-inline",children:[" · ",ut]})]}),n.jsx("p",{className:"ob-one","data-testid":ye?"integration-mode-note":void 0,children:Ye})]}),n.jsx(tp,{})]}),n.jsxs("div",{className:"su-cn-body",ref:V,children:[n.jsx("section",{className:"ob-tile",children:n.jsx("dl",{className:"ob-kv",children:Te==="running"&&a?n.jsxs(n.Fragment,{children:[ye&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Runs on"}),n.jsx("dd",{className:"ob-plain",children:ye})]}),n.jsx("dt",{children:"Access"}),n.jsx("dd",{children:Oe?et?"Auth failed":e.oauth&&E&&(T!=null&&T.account)?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:T.account})]}):"Auth OK":"No auth"}),e.credentials.fields.map(X=>{const Ne=X.type==="password",ke=N[X.key];if(!Ne&&x[X.key]==null||Ne&&ke==null)return null;const ue=Ne?ke.preview??"set":x[X.key];return n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:X.label}),n.jsxs("dd",{className:Ne||ht(ue)?"ob-mono is-strong":void 0,children:[ue,Ne&&k&&n.jsxs("span",{className:"ob-quiet-inline",children:[" ","· added ",new Date(k).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},X.key)}),Y&&ee!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Reads"}),n.jsxs("dd",{children:[ee===null?"window from your mandate":ua(ee).toLowerCase(),I&&n.jsx("span",{className:"ob-quiet-inline",children:" saving…"}),pe&&n.jsxs("span",{className:"ob-bold",children:[" ",pe]})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Status"}),n.jsx("dd",{children:Te==="starting"?"Starting…":We.text}),e.oauth&&Te==="unconfigured"&&!v&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Step"}),n.jsx("dd",{className:"ob-plain",children:"1 of 2 — enter credentials, then connect your account"})]}),Te==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Step"}),n.jsxs("dd",{className:"ob-plain",children:["✓"," Step 1 done — credentials saved. Step 2: connect your ",e.name," account to authorize access."]})]}),Te==="ready"&&!a&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Credentials"}),n.jsxs("dd",{className:"ob-plain",children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]})]}),Te==="ready"&&a&&!a.running&&a.error&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Error"}),n.jsx("dd",{className:"ob-plain",children:a.error})]})]})})}),e.oauth&&E&&!(T!=null&&T.account)&&n.jsx("p",{className:"ob-lbl ob-gap",children:"Account not recorded — reconnect to capture which account is used"}),et&&!me&&n.jsxs("section",{className:"ob-tile",children:[n.jsxs("div",{className:"ob-sent-h",children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{className:"ob-lbl",children:[(T==null?void 0:T.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):T!=null&&T.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:T.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]})]}),qe&&n.jsxs(Gt,{title:`How to set up ${e.name}`,summary:qe[0].title,open:H,children:[e.setupHint&&!v&&n.jsx("p",{children:e.setupHint}),n.jsx("ol",{className:"su-list",children:qe.map((X,Ne)=>n.jsxs("li",{children:[n.jsx("b",{children:X.title}),n.jsxs("div",{className:"ob-lbl",children:[De(X.description),X.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:X.link,target:"_blank",rel:"noopener noreferrer",children:["Open ","↗"]})]})]})]},Ne))})]}),!qe&&e.setupHint&&!v&&H&&n.jsx("p",{className:"ob-lbl ob-gap",children:e.setupHint}),Te==="starting"&&n.jsx("p",{className:"ob-lbl ob-gap",children:"Starting…"}),me&&n.jsxs("div",{className:"su-edit",children:[n.jsx("div",{className:"ob-sent-h",children:"Change credentials"}),v&&n.jsxs("p",{className:"ob-lbl",children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(X=>ge(X,!0)),n.jsxs("div",{className:"ob-btns is-inline is-tight",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:ct,disabled:M||!Ge,children:M?"Saving…":"Save"}),e.oauth&&n.jsxs("button",{className:"ob-btn",onClick:nt,children:["Connect ",e.name]}),n.jsx("button",{className:"ob-btn",onClick:()=>{we(!1),p({})},children:"Cancel"})]}),!Ge&&!M&&n.jsx("p",{className:"ob-lbl ob-gap",children:"No changes yet"})]}),Te==="running"&&Y&&ee!==void 0&&$e&&n.jsxs("div",{className:"su-edit",children:[n.jsx("div",{className:"ob-sent-h",children:"How far back may your agent read?"}),n.jsx("p",{className:"ob-lbl",children:"Applies immediately — no Save, no new mandate."}),n.jsxs("div",{className:"ob-btns is-tight",children:[Rk.map(X=>{const Ne=ee===X;return n.jsx("button",{className:`ob-btn${Ne?" is-solid":""}`,"aria-pressed":Ne,disabled:I,onClick:()=>oe(X),children:ua(X)},X)}),n.jsx("button",{className:`ob-btn${ee===null?" is-solid":""}`,"aria-pressed":ee===null,disabled:I,onClick:()=>oe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:ua(null)})]}),n.jsx("p",{className:"ob-lbl ob-gap",children:pe?n.jsx("span",{className:"ob-bold",children:pe}):I?"Saving…":ee===null?"Using the window from your mandate. If none is set there, reads are blocked.":ee===0?"Your agent cannot read any mail.":`Anything older than ${ee} days is blocked, whoever it is from.`}),n.jsx("div",{className:"ob-btns is-inline is-tight",children:n.jsx("button",{className:"ob-btn",onClick:()=>ve(!1),children:"Done"})})]}),!me&&Te==="running"&&a&&n.jsxs("div",{className:"ob-btns",children:[et&&n.jsxs("button",{className:"ob-btn is-solid",onClick:nt,children:["Reconnect ",e.name]}),n.jsx(pt,{to:"/mandates?new=1",className:"ob-btn",children:"Give a mandate"}),jt&&n.jsx("button",{className:"ob-btn",onClick:()=>{p({...x}),we(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),Y&&ee!==void 0&&!$e&&n.jsx("button",{className:"ob-btn",onClick:()=>ve(!0),children:"Edit reads window"}),n.jsx("button",{className:"ob-btn",onClick:Be,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),Te==="unconfigured"&&(()=>{const X=e.credentials.fields.every(ue=>ue.optional),Ne=e.credentials.fields.some(ue=>!ue.optional),ke=e.credentials.fields.some(ue=>{var He;return(He=d[ue.key])==null?void 0:He.trim()});return n.jsxs(n.Fragment,{children:[v&&n.jsxs("p",{className:"ob-lbl ob-gap",children:[n.jsx("b",{className:"ob-bold",children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",n.jsx("button",{className:"ob-link",onClick:()=>{y(!0),e.oauth&&$(!0)},children:"keep existing"}),"."]}),n.jsx("div",{className:"su-fields",children:e.credentials.fields.map(ue=>ge(ue,!1))}),n.jsxs("div",{className:"ob-btns is-inline",children:[(ke||Ne)&&n.jsx("button",{className:"ob-btn is-solid",onClick:_e,disabled:M||!ke||Ne&&!e.credentials.fields.filter(ue=>!ue.optional).every(ue=>{var He;return(He=d[ue.key])==null?void 0:He.trim()}),children:M?"Saving...":"Save & Encrypt"}),X&&!ke&&n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":`Activate ${e.name}`})]})]})})(),Te==="needs-oauth"&&n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsxs("button",{className:"ob-btn is-solid",onClick:nt,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"ob-btn",onClick:()=>y(!1),children:"Change Credentials"})]}),Te==="ready"&&!a&&n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"ob-btn",onClick:()=>y(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"ob-btn",onClick:()=>{y(!1),$(!1)},children:"Change Credentials"})]}),Te==="ready"&&a&&!a.running&&(dt.showStart?n.jsxs("div",{className:"ob-btns is-inline",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Je,disabled:K,children:K?"Starting...":"Start"}),n.jsx("button",{className:"ob-btn",onClick:Be,children:"Disable"})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ob-lbl ob-gap",children:"Real systems are off while simulation mode is on."}),n.jsx("div",{className:"ob-btns is-inline",children:n.jsx("button",{className:"ob-btn",onClick:Be,children:"Disable"})})]})),n.jsx(Gt,{title:"Details",summary:"what it does",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"What"}),n.jsx("dd",{className:"ob-plain",children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Profile"}),n.jsx("dd",{className:"ob-plain",children:cg(e).join(", ")})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Scopes"}),n.jsx("dd",{className:"ob-plain",children:((be=e.oauth.scopes)==null?void 0:be.join(", "))||"—"})]}),a&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Tools"}),n.jsxs("dd",{className:"ob-plain",children:[a.toolCount," gated"]})]})]})})]})]})}const _k={card:"💳",mail:"✉️"};function Lk(e){return _k[e]??"🔧"}function _i({entries:e,catalog:r,refresh:a,onSuccess:i}){return n.jsx(n.Fragment,{children:ug(e,r).map(l=>n.jsxs("div",{className:"area-group su-area","data-testid":"integration-area","data-area":l.shortId,children:[n.jsxs("div",{className:"area-group-h sr-only",children:[n.jsx(Dr,{icon:l.icon}),n.jsx("b",{children:l.name})]}),l.entries.map(u=>n.jsx(Pk,{manifest:u.manifest,area:{shortId:l.shortId,name:l.name},integration:u.integration,state:u.state,onStatusChange:a,onSuccess:i},u.id))]},l.shortId))})}function Li({title:e,count:r,note:a}){return n.jsxs("div",{className:"su-sec",children:[e,n.jsxs("small",{children:[r," ",r===1?"connector":"connectors",a?` · ${a}`:""]})]})}function Mk({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Lk(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsx("span",{className:"int-paused-state",children:"Paused"})]})}function Fk(){const{loading:e,mcpServerUp:r,manifestsError:a,entries:i,refresh:l}=iu(),u=au(),[d,p]=f.useState(""),m=On(),y=f.useCallback(C=>{p(C),setTimeout(()=>p(""),5e3)},[]),v=Ak(i,u),{inUse:j,notSetUp:x}=Tk(i),S=C=>ug(C,m).reduce((E,$)=>E+$.entries.length,0),N=S(j),w=S(x),k=!e&&r!==!1&&i.length>0&&!v.grouped?` ${N} in use · ${w} not set up.`:"";return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsxs("p",{className:"page-subtitle",children:["Connect external services and manage MCP integrations.",k]})]}),d&&n.jsx("div",{className:"alert alert-success",children:d}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):r===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):v.grouped?n.jsxs(n.Fragment,{children:[v.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Test systems",count:v.testSystems.length}),n.jsx(_i,{entries:v.testSystems,catalog:m,refresh:l,onSuccess:y})]}),(v.realErrors.length>0||v.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Real systems",count:v.realErrors.length+v.pausedReal.length}),n.jsx(_i,{entries:v.realErrors,catalog:m,refresh:l,onSuccess:y}),v.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",v.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),v.pausedReal.map(C=>n.jsx(Mk,{entry:C},C.id))]})]}),i.length===0&&n.jsx(Vf,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[j.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"In use",count:N}),n.jsx(_i,{entries:j,catalog:m,refresh:l,onSuccess:y})]}),x.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Li,{title:"Not set up",count:w,note:"open one to set it up"}),n.jsx(_i,{entries:x,catalog:m,refresh:l,onSuccess:y})]}),i.length===0&&n.jsx(Vf,{manifestsError:a})]})]})}function Vf({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function Ok(){var _;const{activeTeam:e,activeMembership:r,refreshGroups:a,user:i}=Nt(),l=yn(),u=va(),[d,p]=f.useState(null),[m,y]=f.useState(!1),[v,j]=f.useState(""),[x,S]=f.useState(""),[N,w]=f.useState(""),[k,C]=f.useState("");f.useEffect(()=>{fetch("/health").then(z=>z.json()).then(z=>{typeof z.spUrl=="string"&&C(z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!e){p(null);return}P.getGroupById(e.id).then(z=>{const V=z.group??z,K=z.members??[],le=z.isAdmin??!1,me=K.map(we=>{const Ae=we.userId||we.id||"",Z=we.role||(le&&Ae===V.createdBy?"admin":"member");return{id:Ae,name:we.name||Ae.slice(0,8)||"Member",email:we.email||"",domains:we.domains||[],role:Z,isAdmin:Z==="admin"||le&&Ae===V.createdBy}});p({id:V.id,name:V.name,members:me})}).catch(()=>p(null))},[e==null?void 0:e.id]);const E=(d==null?void 0:d.members.filter(z=>z.isAdmin))??[],$=(e==null?void 0:e.isAdmin)===!0&&E.length<=1&&E.some(z=>z.id===(i==null?void 0:i.id)),T=(e==null?void 0:e.name)??"",F=N.trim()===T&&!m,M=async()=>{if(!(!e||!F)){y(!0),j("");try{await P.leaveTeam(e.id),await a(),S("You have left the team."),p(null),w("")}catch(z){j(z instanceof Error?z.message:"Failed to leave team")}finally{y(!1)}}},B=e&&k?`${k}/dashboard/groups/${e.id}`:void 0,te=k?`${k}/dashboard/groups`:void 0,Q=((_=d==null?void 0:d.members)==null?void 0:_.length)??0;return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]}),v&&n.jsx("div",{className:"error-message",children:v}),x&&n.jsx("div",{className:"alert alert-success",children:x}),e?n.jsxs("article",{className:"ob-card su-card",ref:u,children:[n.jsx(At,{tag:"TEAM",parts:[n.jsx("span",{className:"ob-st",children:"Active"}),`${Q} ${Q===1?"member":"members"}`]}),n.jsx("h2",{className:"ob-title is-h3",children:e.name}),Q>0&&n.jsxs("section",{className:"ob-tile su-members",children:[n.jsx("div",{className:"su-tile-h",children:"Members"}),d==null?void 0:d.members.map(z=>n.jsxs("div",{className:"su-m",children:[n.jsx("span",{className:"su-av",children:z.name.split(" ").map(V=>V[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"su-who",children:[n.jsx("b",{children:z.name}),n.jsx("span",{children:z.email})]}),n.jsx("span",{className:`su-role${z.isAdmin?" is-admin":""}`,children:z.role})]},z.id))]}),n.jsxs(Gt,{title:"Leave team",summary:$?"you are the only admin":"revokes your mandates in this team",children:[n.jsx("p",{children:"Leaving will:"}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsx("p",{className:"ob-lbl ob-gap",children:"Your personal mandates are not affected."}),$?n.jsx("p",{className:"ob-lbl",children:"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving."}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",className:"form-label",children:["Type ",n.jsx("code",{children:T})," to confirm"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:N,onChange:z=>w(z.target.value),placeholder:T,disabled:m})]}),n.jsx("div",{className:"ob-btns is-inline is-tight",children:n.jsx("button",{className:"ob-btn",onClick:M,disabled:!F,children:m?"Leaving...":"Leave team"})})]})]}),B&&n.jsx("div",{className:"ob-btns",children:n.jsx("a",{className:"ob-btn",href:B,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server ↗"})})]}):n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{tag:"TEAM",parts:[n.jsx("span",{className:"ob-st",children:"Personal"})]}),n.jsx("h2",{className:"ob-title is-h3",children:"You are working solo."}),n.jsx("p",{className:"ob-one",children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:()=>l("/onboarding"),children:"Join or create a team"}),te&&n.jsx("a",{className:"ob-btn",href:te,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server ↗"})]})]})]})}function pu({areas:e,selected:r,onSelect:a,totalCount:i}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":r===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:i})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":r===l.shortId,onClick:()=>a(r===l.shortId?null:l.shortId),children:[n.jsx(Dr,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const xr=e=>e.replace(/@.*$/,"").split("/").pop()??e,qf=e=>e.split("@")[1]??"";function Kf(e){var a;const r=e.profile?[xr(e.profile)]:[];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(xr(l))&&r.push(xr(l))}return r}function zk(e,r){const a=new Map;for(const i of e){const l=xr(i.id);if(!r.has(l))continue;const u=a.get(l);(!u||qf(i.id).localeCompare(qf(u.id),void 0,{numeric:!0})>0)&&a.set(l,i)}return a}function Dk(e,r,a,i){var p;const l=new Set([...r.flatMap(m=>Kf(m)),...i.map(m=>xr(m.profile))]),u=zk(e,l),d=[];for(const m of r){const y=Kf(m);for(const[v,j]of y.entries()){const x=u.get(j);x&&d.push({key:v===0?`connector:${m.id}`:`connector:${m.id}:${j}`,name:y.length>1?`${m.name} — ${x.name??j}`:m.name,description:m.description||x.description,profile:x,kind:"connector",ready:((p=a.find(S=>S.id===m.id))==null?void 0:p.running)===!0,setupId:m.id,...m.intentHint&&v===0?{intentHint:m.intentHint}:{}})}}for(const m of i){const y=u.get(xr(m.profile));y&&d.push({key:`builtin:${m.id}`,name:m.name,description:m.description||y.description,profile:y,kind:"builtin",ready:m.available,unavailableReason:m.available?void 0:"Available only while simulation mode is on.",...m.intentHint?{intentHint:m.intentHint}:{}})}return d}function Bk(e,r,a){if(r)return e.find(i=>xr(i.profile.id)===xr(r)&&i.ready&&a(i))}function dg({icon:e,className:r}){return n.jsx(Dr,{icon:e,className:r})}function Uk({onDismiss:e,preselectProfileId:r}){const a=yn(),{group:i,groupId:l,domain:u,user:d}=Nt(),[p,m]=f.useState([]),[y,v]=f.useState([]),[j,x]=f.useState([]),[S,N]=f.useState([]),[w,k]=f.useState(!0),[C,E]=f.useState({});f.useEffect(()=>{Promise.all([P.listProfiles().catch(()=>[]),P.getIntegrationManifests().then(Q=>Q.manifests??[]).catch(()=>[]),P.getMcpHealth().catch(()=>null)]).then(async([Q,_,z])=>{if(m(Q),v(_),x((z==null?void 0:z.integrations)??[]),N((z==null?void 0:z.builtins)??[]),l){const V=await Promise.all(Q.map(le=>P.getTeamProfileConfig(l,le.id).catch(()=>null))),K={};Q.forEach((le,me)=>{const we=V[me];we&&(K[le.id]=we)}),E(K)}}).finally(()=>k(!1))},[l]);const $=Dk(p,y,j,S),T=Q=>{const _=C[Q.id];return og({isPersonal:!!(i!=null&&i.isPersonal),configLoaded:!w,grantors:_?Wm(_):void 0,userId:d==null?void 0:d.id,profileName:Vt(Q.id),teamName:i==null?void 0:i.name})},F=Q=>Q in C,M=(Q,_)=>{if(!l){console.error("No active group when creating authorization");return}const z=F(Q);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Q,groupId:l,groupName:(i==null?void 0:i.name)??null,domain:u,isTeam:z,isPersonal:!!(i!=null&&i.isPersonal),..._?{intentHint:_}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},B=(Q,_)=>{l&&M(Q,_)},te=f.useRef(!1);return f.useEffect(()=>{if(w||!r||te.current)return;const Q=Bk($,r,_=>T(_.profile).can);Q&&(te.current=!0,B(Q.profile.id,Q.intentHint))},[w,r]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
80
80
  .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
81
81
  .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
82
82
  @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
83
83
  @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
84
- `}),w?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(pt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:$.map(Q=>{const _=Q.profile,z=F(_.id),V=T(_),K=!Q.ready||!V.can,{icon:le}=jr(_.id,{name:_.name});return n.jsxs("div",{className:"card",style:K?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(cg,{icon:le,className:"profile-chip-icon"}),Q.name]}),z?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):i!=null&&i.isPersonal?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:Q.description}),V.can?Q.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>B(_.id,Q.intentHint),children:"Give a mandate"}):Q.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:Q.unavailableReason})]}):n.jsxs(pt,{to:`/integrations?setup=${Q.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",Q.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[V.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:V.fix})]})]})]},Q.key)})})]})}function Bk({domain:e,attested:r}){const a=r===!0?"domain-attested":r===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const ug=200;function Uk(e,r,a=ug){return e.length<a?!0:e.some(i=>!Ur(i.timestamp,r))}function dg(e,r){return e.filter(a=>a.authorizationId===r).sort((a,i)=>i.timestamp-a.timestamp)}function Wk(e){var m,y;const r={},{bounds:a,profile:i,authorizationId:l,nowMs:u}=e;if(!a)return r;const p=dg(e.receipts,l).filter(v=>Ur(v.timestamp,u)).reduce((v,j)=>{var x,S,N,w;return!v||j.timestamp>v.timestamp||j.timestamp===v.timestamp&&(((S=(x=j.cumulativeState)==null?void 0:x.daily)==null?void 0:S.count)??0)>(((w=(N=v.cumulativeState)==null?void 0:N.daily)==null?void 0:w.count)??0)?j:v},null);if(p){const v=fp(p,a,i,"daily"),j=(m=p.cumulativeState)==null?void 0:m.daily;return v&&j&&(r[v.key]=`${v.isAmount?j.amount:j.count} used today`),r}if(!e.coversToday)return r;for(const[v,j]of Object.entries(((y=i==null?void 0:i.boundsSchema)==null?void 0:y.fields)??{})){const x=j.boundType;v in a&&x&&(x.kind==="cumulative_sum"||x.kind==="cumulative_count")&&x.window==="daily"&&(r[v]="0 used today")}return r}const Hk=15e3;let hs=null;function Vk(){const e=Date.now();if(!hs||e-hs.at>Hk){const r={at:e,p:P.getMyReceiptsPage({limit:ug}).then(a=>({receipts:a.receipts,coversToday:Uk(a.receipts,Date.now())}))};r.p.catch(()=>{hs===r&&(hs=null)}),hs=r}return hs.p}function hg(){const[e,r]=f.useState({state:"loading"});return f.useEffect(()=>{let a=!0;return Vk().then(i=>{a&&r({state:"ok",...i})},()=>{a&&r({state:"failed"})}),()=>{a=!1}},[]),e}function js({icon:e,title:r,text:a,children:i}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:r}),a&&n.jsx("div",{className:"empty-state-text",children:a}),i]})}function qk(e){const r=Math.floor(e/86400);if(r>=1)return`${r} day${r===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const i=Math.ceil(e/60);return`${i} minute${i===1?"":"s"}`}const Kk=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function Gk({item:e,onClose:r,onSuccess:a}){var $;const{user:i,activeDomain:l,groupId:u}=Nt(),[d,p]=f.useState(null);f.useEffect(()=>{let T=!1;return P.getProfile(e.profile_id).then(F=>{var M;T||p(((M=F==null?void 0:F.ttl)==null?void 0:M.max)??null)}).catch(()=>{}),()=>{T=!0}},[e.profile_id]);const m=e.remaining_seconds??0,y=Kk.filter(T=>T.seconds>m&&(d===null||T.seconds<=d)),v=(($=y[0])==null?void 0:$.seconds)??2592e3,[j,x]=f.useState(v);f.useEffect(()=>{var T;if(d!==null&&j>d){const F=(T=y[y.length-1])==null?void 0:T.seconds;F&&x(F)}},[d]);const[S,N]=f.useState(!1),[w,k]=f.useState(""),C=Object.entries(e.frame).filter(([T])=>T!=="profile"&&T!=="path"),E=async()=>{var T;if(i){N(!0),k("");try{const F=e.authorization_id,M=await P.getGateContent(F);if(!M)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const B=await P.getProfile(e.profile_id),te=e.frame,Q=M.context??{},_=e.attested_domains[0]||l||"owner",z=await Bi(te,B),V=await tg(Q,B),[K,le]=await Promise.all([oo(M.gateContent.intent),oo(JSON.stringify({profile:e.profile_id,path:e.path,domain:_}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const me=(((T=e.deferred_commitment_domains)==null?void 0:T.length)??0)>0?"review":"automatic",we=await ng(B),Ae=await P.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:we,supported_versions:["0.7"],bounds:te,bounds_hash:z,scope_hash:V,domain:_,did:i.did,mandate_owners:[{did:i.did}],gate_content_hashes:{intent:K},execution_context_hash:le,group_id:u,commitment_mode:me,ttl:j});await P.pushGateContent(rg(Ae,{boundsHash:z,contextHash:V,context:Q,path:e.path,gateContent:M.gateContent})),a()}catch(F){k(F instanceof Error?F.message:"Extension failed")}finally{N(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:T=>T.target===T.currentTarget&&r(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:r,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Vt(e.profile_id)," / ",e.path]}),C.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:C.map(([T,F])=>`${T}=${F}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),m>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",qk(m),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:y.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):y.map(T=>n.jsx("button",{className:`btn ${j===T.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(T.seconds),style:{minWidth:"3.5rem"},children:T.label},T.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),w&&n.jsx("div",{className:"error-message",children:w})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:r,disabled:S,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:E,disabled:S,children:S?"Extending...":"Extend"})]})]})})}function Yf(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Jf(e){return e.split("@")[1]??""}function Yk(e,r){return Jf(e).localeCompare(Jf(r),void 0,{numeric:!0})>0}function fg(e,r){const a=Yf(e);let i;for(const l of r)Yf(l.id)===a&&(!i||Yk(l.id,i.id))&&(i=l);return i}function mg(e,r){var i;if(!r)return{};const a={};for(const l of r.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(i=r.fields[l])==null?void 0:i.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function pg(e,r){return mg(e,r.boundsSchema)}function gg(e,r){return mg(e,r.scopeSchema)}function Jk(e,r,a){return[...e].sort((i,l)=>{if(a){if(i.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&i.authorization_id!==a)return 1}const u=Vi(i,r),d=Vi(l,r),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[d]?p[u]-p[d]:new Date(l.created_at).getTime()-new Date(i.created_at).getTime()})}function Qk(e,r){const a=(r==null?void 0:r.keyedApprovers)??(r==null?void 0:r.approvers)??[];return e.length===0||a.length===0?!1:e.length!==a.length||e.some(i=>!a.includes(i))||a.some(i=>!e.includes(i))}function Xk({item:e,newerProfile:r,area:a,revokedSet:i,expandedHash:l,gateCache:u,gateLoading:d,copiedHash:p,revokingHash:m,copyingHash:y,profileConfigCache:v,mode:j,group:x,ownerLabel:S,isAdmin:N,onExpand:w,onCopyHash:k,onCopy:C,onRevoke:E,onExtend:$,archivedSet:T,archivingHash:F,onArchive:M,highlightHash:B,needsReapprovalSet:te,manifests:Q=[]}){var De;const _=su(e,{revokedSet:i}),z=_==="active"&&((te==null?void 0:te.has(e.authorization_id))??!1),V=Gm(e,{revokedSet:i,archivedSet:T}),K=!S&&!!M&&Km(_),le=l===e.authorization_id,me=u[e.authorization_id],we=_==="active"||_==="pending"||_==="expired",Ae=Object.entries(e.frame).filter(([Ie])=>Ie!=="profile"&&Ie!=="path"),Z=Ns(e.profile_id),G=new Map(sp(e.frame,Z,"limits").map(Ie=>[Ie.key,Ie])),J=Ie=>{var We;return((We=G.get(Ie))==null?void 0:We.label)??Ie},I=(Ie,We)=>{var Qe;return((Qe=G.get(Ie))==null?void 0:Qe.value)??String(We)},D=v.get(e.profile_id)??null,pe=(((De=D==null?void 0:D.approvers)==null?void 0:De.length)??0)>0,de=new Map;if(D!=null&&D.caps&&j==="team")for(const[Ie,We]of Ae){const Qe=D.caps[Ie];typeof Qe=="number"&&Number(We)>Qe&&de.set(Ie,{authorized:Number(We),cap:Qe})}const $e=de.size>0,ve=j==="team"&&Qk(e.approvers_frozen??[],D),Y=Array.from(de.entries()).map(([Ie,We])=>`${Ie}: ${We.authorized} (cap ${We.cap})`).join(", "),he=Array.from(de.entries()).map(([Ie,We])=>`${Ie}: ${We.authorized} → ${We.cap}`).join(", "),ee=$e?pe?de.size===1?`Above team cap: ${Y} — actions require approval`:`Above team cap (${de.size}): ${Y} — actions require approval`:de.size===1?`Reduced by hard cap: ${he}`:`Reduced by hard cap (${de.size}): ${he}`:"",oe=$e?pe?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,Oe=jr(e.profile_id),Fe=Oe.name,se=r?n.jsxs("p",{className:"ob-quiet","data-testid":"mandate-upgrade-hint",children:[n.jsxs("b",{children:[Fe,"@",r.version," available"]}),r.whatsNew?n.jsxs(n.Fragment,{children:[" — ",r.whatsNew]}):null," ","This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]}):null,Te=B!=null&&e.authorization_id===B,_e=e.deferred_commitment_domains.length>0?no.title:ro.title,Ge=Ae.slice(0,3).map(([Ie,We])=>`${J(Ie)} ${I(Ie,We)}`),ct=Ae.length-Ge.length,nt=[_e,...Ge,...ct>0?[`+${ct} more`]:[]].join(" · "),Je=e.created_at?`since ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:null,Be=_==="expired"?zj(e,_):null,dt=va(),et=f.useRef(null);return f.useLayoutEffect(()=>{var We,Qe;if(!le)return;const Ie=(We=window.matchMedia)==null?void 0:We.call(window,"(prefers-reduced-motion: reduce)").matches;(Qe=et.current)==null||Qe.scrollIntoView({block:"start",behavior:Ie?"auto":"smooth"})},[le]),n.jsxs("div",{ref:et,className:`ob-card mandate-card${le?" is-open":""}${Te?" card-highlight":""}`,"data-testid":"mandate-card",children:[n.jsxs("button",{type:"button",className:"ob-head","aria-expanded":le,onClick:()=>w(e),children:[n.jsx(At,{tag:"Mandate",profileId:e.profile_id,parts:[a,Je,n.jsxs("span",{className:"ob-st",children:[_.charAt(0).toUpperCase()+_.slice(1),Be?` ${new Date(Be.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`:""]},"st"),z?n.jsx("span",{className:"ob-st",title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",children:"Needs re-approval"},"re"):null,Oe.testSetup?"Test setup":null]}),n.jsx("span",{className:"ob-title",children:e.title||Fe}),!le&&n.jsx("span",{className:"ob-one",children:nt})]}),se,S&&n.jsxs("p",{className:"ob-quiet",children:["Owner: ",n.jsx("b",{children:S})]}),(e.required_domains.length>1||e.missing_domains.length>0)&&n.jsx("div",{className:"ob-badges",children:e.required_domains.map(Ie=>n.jsx(Bk,{domain:Ie,attested:e.attested_domains.includes(Ie)},Ie))}),$e&&n.jsx("p",{className:"ob-quiet ob-bold",title:oe,"data-testid":"mandate-cap-note",children:ee}),ve&&n.jsx("p",{className:"ob-quiet",children:n.jsx("button",{type:"button",className:"ob-link",onClick:()=>C(e),disabled:y===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:y===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})}),le&&n.jsxs("div",{ref:dt,className:"ob-open","data-testid":"mandate-open",children:[n.jsxs("section",{className:"ob-tile","data-testid":"mandate-signed",children:[n.jsxs("div",{className:"ob-tile-h",children:[n.jsx(go,{}),"You signed this"]}),n.jsxs("div",{className:"ob-part",children:[n.jsxs("div",{className:"ob-lbl",children:["Intent — your words",e.created_at?`, signed ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:""]}),d===e.authorization_id?n.jsx("p",{className:"ob-quiet",children:"Loading gate content..."}):me?n.jsx("p",{className:"ob-intent","data-testid":"mandate-intent",children:me.gateContent.intent}):n.jsx("p",{className:"ob-quiet",children:"Gate content not available."})]}),n.jsxs("dl",{className:"ob-kv ob-part",children:[n.jsx("dt",{children:"Commitment"}),n.jsx("dd",{children:_e}),(e.earliest_expiry||_==="revoked")&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Valid"}),n.jsx("dd",{children:_==="revoked"?"revoked":_==="expired"?`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} — expired`:`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}, or until you revoke it`})]}),Ae.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Limits"}),n.jsx("dd",{children:n.jsx(Zk,{item:e,boundsEntries:Ae,limitLines:G,limitLabel:J,limitValue:I,aboveCapByKey:de,hasApprovers:pe,profile:Z})})]}),(me==null?void 0:me.context)&&Object.keys(me.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Scope"}),n.jsx("dd",{children:Object.entries(me.context).map(([Ie,We])=>n.jsx("div",{title:String(We),children:sg(Ie,We,me.contextLabels)},Ie))})]}),n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:j==="team"&&x?`${x.name} (team)`:"Personal"})]})]}),!S&&n.jsx(eS,{item:e,manifests:Q}),n.jsx(Gt,{title:"Technical details",summary:e.created_at?`created ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:void 0,testId:"mandate-technical",children:n.jsxs("dl",{className:"ob-kv",children:[e.created_at&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Created"}),n.jsx("dd",{children:new Date(e.created_at).toLocaleString()})]}),n.jsx("dt",{children:"Mandate id"}),n.jsxs("dd",{className:"ob-mono",children:[e.authorization_id," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>k(e.authorization_id),children:p===e.authorization_id?"copied":"copy"})]}),n.jsx("dt",{children:"Profile"}),n.jsx("dd",{className:"ob-mono",children:e.profile_id})]})}),n.jsxs("div",{className:"ob-btns",children:[!S&&(_==="active"||_==="pending")&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e,{asEdit:!0}),disabled:y===e.authorization_id,title:z?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:z?"Re-approve":"Edit"}),!S&&we&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>$(e),children:"Extend"}),!S&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e),disabled:y===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:y===e.authorization_id?"Copying…":"Copy"}),S&&N&&_!=="revoked"?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id,S,Fe),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):!S&&(_==="active"||_==="pending")?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):null,K&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>M(e.authorization_id,!V),disabled:F===e.authorization_id,title:V?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:F===e.authorization_id?V?"Unarchiving…":"Archiving…":V?"Unarchive":"Archive"})]})]})]},e.authorization_id)}function Zk({item:e,boundsEntries:r,limitLines:a,limitLabel:i,limitValue:l,aboveCapByKey:u,hasApprovers:d,profile:p}){const m=hg(),y=m.state==="ok"?Wk({receipts:m.receipts,coversToday:m.coversToday,authorizationId:e.authorization_id,bounds:e.frame,profile:p,nowMs:Date.now()}):{};return n.jsx("dl",{className:"ob-kv ob-sub","data-testid":"mandate-limits",children:r.map(([v,j])=>{var S;const x=u.get(v);return n.jsxs(f.Fragment,{children:[n.jsx("dt",{title:(S=a.get(v))==null?void 0:S.hint,children:i(v)}),n.jsx("dd",{children:x?d?n.jsxs("span",{title:`Team cap on ${v} is ${x.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${x.authorized}.`,children:[l(v,j)," ",n.jsxs("span",{className:"ob-quiet-inline",children:["↑ approval at ",x.cap]})]}):n.jsxs("span",{title:`Team cap on ${v} is ${x.cap} with no approvers configured (hard cap). Authorized for ${x.authorized}; effective ${x.cap}.`,children:[n.jsx("s",{children:l(v,j)})," → ",x.cap]}):l(v,j)}),n.jsx("dd",{className:"ob-use",children:y[v]??""})]},v)})})}function eS({item:e,manifests:r}){const a=hg(),i=a.state==="ok"?dg(a.receipts,e.authorization_id):[],l=i.filter(d=>Ur(d.timestamp,Date.now())).length,u=a.state==="loading"?"loading…":a.state==="failed"?"could not load":i.length===0?"none in the latest tickets":`${i.length} recent${l>0?` · ${l} today`:""}`;return n.jsxs(Gt,{title:"Tickets under this mandate",summary:u,testId:"mandate-tickets",children:[n.jsx("p",{className:"ob-lbl",children:"From the latest tickets signed on this account."}),a.state==="failed"&&n.jsx("p",{children:"Tickets could not be loaded. Try again shortly."}),a.state==="ok"&&i.length===0&&n.jsx("p",{children:"No action has run under this mandate in the latest tickets."}),i.slice(0,5).map(d=>n.jsxs("p",{className:"ob-ticket-row",children:[n.jsx(pt,{to:"/tickets",className:"ob-link-strong",children:ys(d,r)}),n.jsxs("span",{className:"ob-quiet-inline",children:[" · ",ma(d.timestamp,Date.now())]})]},d.id)),i.length>0&&n.jsx("p",{children:n.jsx(pt,{to:"/tickets",className:"ob-link-strong",children:"All tickets ›"})})]})}function tS(){const[e,r]=f.useState([]),[a,i]=f.useState(!0),[l,u]=f.useState([]),[d,p]=f.useState(!1),[m,y]=f.useState(new Map),[v,j]=f.useState("mine"),[x,S]=f.useState("active"),[N,w]=f.useState(null),[k,C]=f.useState(null),[E,$]=Ss(),[T,F]=f.useState(()=>E.get("new")==="1"),[M]=f.useState(()=>E.get("profile")),[B,te]=f.useState(()=>E.get("highlight")),[Q,_]=f.useState(null),[z,V]=f.useState({}),[K,le]=f.useState(null),[me,we]=f.useState(null),[Ae,Z]=f.useState(null),[G,J]=f.useState(new Set),[I,D]=f.useState(null),[pe,de]=f.useState(new Set),[$e,ve]=f.useState(null),[Y,he]=f.useState(null),[ee,oe]=f.useState(new Set),Oe=yn(),{group:Fe,groupId:se,domain:Te,mode:_e,activeTeam:Ve}=Nt(),Ge=(Ve==null?void 0:Ve.isAdmin)===!0,[ct,nt]=f.useState(()=>new Map),[Je,Be]=f.useState([]);f.useEffect(()=>{P.getLabelManifests().then(Be).catch(()=>{})},[]);const dt=f.useCallback(()=>{i(!0),P.getMyAttestations().then(r).catch(()=>{}).finally(()=>i(!1))},[]),et=f.useCallback(()=>{P.getArchivedMandates().then(ne=>de(new Set(ne))).catch(()=>{})},[]);f.useEffect(()=>{et()},[et]);const De=f.useCallback(()=>{P.getEnrichedAuthorizations().then(ne=>oe(new Set(ne.filter(xe=>xe.needsReapproval).map(xe=>xe.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{De()},[De]);const Ie=async(ne,xe)=>{ve(ne);try{const U=await P.setMandateArchived(ne,xe);de(new Set(U)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(U){alert(U instanceof Error?U.message:"Failed to update archive")}finally{ve(null)}},We=f.useCallback(()=>{se&&(p(!0),P.listTeamAuthorizations(se).then(u).catch(()=>{}).finally(()=>p(!1)))},[se]);Ke("attestation-changed",()=>{dt(),Ge&&se&&We(),De()}),f.useEffect(()=>{if(!B)return;E.get("highlight")&&(E.delete("highlight"),$(E,{replace:!0}));const ne=window.setTimeout(()=>te(null),3e3);return()=>window.clearTimeout(ne)},[]),Ht(dt,3e5),f.useEffect(()=>{v==="team"&&Ge&&se&&l.length===0&&!d&&We()},[v,Ge,se,l.length,d,We]),f.useEffect(()=>{let ne=!1;return P.listProfiles().then(xe=>{if(ne)return;const U=it=>it.replace(/@.*$/,"").split("/").pop()??it,ie=it=>it.split("@")[1]??"",Ee=new Map;for(const it of xe){const ot=U(it.id),zn=Ee.get(ot);(!zn||ie(it.id).localeCompare(ie(zn.id),void 0,{numeric:!0})>0)&&Ee.set(ot,it)}y(Ee)}).catch(()=>{}),()=>{ne=!0}},[]);const Qe=f.useCallback(ne=>{const xe=ot=>ot.replace(/@.*$/,"").split("/").pop()??ot,U=ot=>ot.split("@")[1]??"",ie=m.get(xe(ne));if(!ie)return;const Ee=U(ne),it=U(ie.id);if(!(!Ee||!it))return it.localeCompare(Ee,void 0,{numeric:!0})>0?ie:void 0},[m]),ut=f.useCallback(ne=>Qn(ne,[...m.values()]),[m]);f.useEffect(()=>{if(_e!=="team"||!se)return;const ne=v==="mine"?e:l;if(ne.length===0)return;const xe=[...new Set(ne.map(U=>U.profile_id))].filter(U=>!ct.has(U));if(xe.length!==0){nt(U=>{const ie=new Map(U);for(const Ee of xe)ie.set(Ee,null);return ie});for(const U of xe)Promise.all([P.getTeamProfileConfig(se,U),P.getApproversPubkeys(se,U).catch(()=>null)]).then(([ie,Ee])=>{const it=ie&&Ee?{...ie,keyedApprovers:Ee.map(ot=>ot.userId)}:ie;nt(ot=>new Map(ot).set(U,it))}).catch(()=>{})}},[e,l,v,se,_e,ct]);const ye=async ne=>{if(Q===ne.authorization_id){_(null);return}_(ne.authorization_id);const xe=ne.authorization_id;if(!(xe in z)){le(ne.authorization_id);try{const U=await P.getGateContent(xe);V(ie=>({...ie,[xe]:U}))}catch{V(U=>({...U,[xe]:null}))}finally{le(null)}}},ze=ne=>{navigator.clipboard.writeText(ne).then(()=>{Z(ne),setTimeout(()=>Z(null),2e3)})},Ye=async(ne,xe)=>{var U;if(!se){alert("No active group; cannot copy mandate.");return}he(ne.authorization_id);try{const ie=ne.authorization_id;let Ee=z[ie]??null;ie in z||(Ee=await P.getGateContent(ie),V(In=>({...In,[ie]:Ee})));const it=Object.fromEntries(Object.entries(ne.frame).filter(([In])=>In!=="profile"&&In!=="path")),ot=(Ee==null?void 0:Ee.context)??{},zn=((U=Ee==null?void 0:Ee.gateContent)==null?void 0:U.intent)??"",rn=ne.deferred_commitment_domains.length>0?"review":"automatic",sn=ne.attested_domains[0]||Te||"owner",Yt=Date.parse(ne.created_at),br=ne.earliest_expiry?Date.parse(ne.earliest_expiry):NaN,wo=Number.isFinite(Yt)&&Number.isFinite(br)&&br>Yt?Math.round((br-Yt)/1e3):void 0;let ja=ne.profile_id,wa=it,Tn=ot,Cs;const ba=await P.listProfiles(),Wr=fg(ne.profile_id,ba);if(Wr&&Wr.id!==ne.profile_id){const In=await P.getProfile(Wr.id);ja=Wr.id,wa=pg(it,In),Tn=gg(ot,In),Cs=ne.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ja,groupId:se,groupName:(Fe==null?void 0:Fe.name)??null,domain:sn,isPersonal:!!(Fe!=null&&Fe.isPersonal),upgradedFromProfileId:Cs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:wa,context:Tn,gateContent:{intent:zn},templateMode:rn,templateTtl:wo})),xe!=null&&xe.asEdit?sessionStorage.setItem("agentEditReplaces",ne.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Oe("/mandates/new/intent")}catch(ie){alert(ie instanceof Error?ie.message:"Failed to copy mandate")}finally{he(null)}},tt=async(ne,xe,U)=>{const ie=xe&&U?`Revoke ${xe}'s ${U} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(ie)){D(ne);try{await P.revokeAttestation(ne),J(Ee=>new Set(Ee).add(ne)),P.resyncGates().catch(()=>{}),xe&&se&&We()}catch(Ee){alert(Ee instanceof Error?Ee.message:"Failed to revoke mandate")}finally{D(null)}}},st=v==="mine"?e:l,ht=v==="mine"?a:d,jt=v==="mine"?{revokedSet:G,archivedSet:pe}:{revokedSet:G},qe=ne=>Vi(ne,jt),H={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ne of st)H[qe(ne)]+=1;const ge=v==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],be=(()=>{const ne=new Map;for(const xe of st){if(qe(xe)!==x)continue;const U=En(xe.profile_id),ie=ne.get(U);ie?ie.count+=1:ne.set(U,{shortId:U,icon:Jn(xe.profile_id),name:ut(xe.profile_id),count:1})}return[...ne.values()].sort((xe,U)=>xe.name.localeCompare(U.name))})(),X=be.reduce((ne,xe)=>ne+xe.count,0),Ne=Jk(st.filter(ne=>{if(qe(ne)!==x||N!==null&&En(ne.profile_id)!==N)return!1;if(k!==null){const xe=ne.deferred_commitment_domains.length>0;if(k==="review"&&!xe||k==="auto"&&xe)return!1}return!0}),jt,B),ke=f.useMemo(()=>{const ne=new Map;for(const xe of Ne){const U=En(xe.profile_id);let ie=ne.get(U);ie||(ie={shortId:U,icon:Jn(xe.profile_id),name:ut(xe.profile_id),items:[]},ne.set(U,ie)),ie.items.push(xe)}return[...ne.values()].sort((xe,U)=>U.items.length-xe.items.length||xe.name.localeCompare(U.name))},[Ne,ut]),ue=f.useCallback(ne=>[...new Set(Je.filter(xe=>{var U;return xe.profile===ne||Object.values(((U=xe.toolGating)==null?void 0:U.overrides)??{}).some(ie=>(ie==null?void 0:ie.profile)===ne)}).map(xe=>xe.name))],[Je]),He={revokedSet:G,expandedHash:Q,gateCache:z,gateLoading:K,copiedHash:Ae,revokingHash:I,copyingHash:Y,profileConfigCache:ct,mode:_e,activeDomain:Te,group:Fe,groupId:se,onExpand:ye,onCopyHash:ze,onCopy:Ye,onRevoke:tt,onExtend:we,highlightHash:B,manifests:Je},kt={...He,archivedSet:pe,archivingHash:$e,onArchive:Ie,needsReapprovalSet:ee};return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>F(!0),children:"+ New mandate"})]}),T&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{F(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),$(E,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:ne=>ne.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{F(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),$(E,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),n.jsx(Dk,{onDismiss:()=>F(!1),preselectProfileId:M})]})]})}),Ge&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${v==="mine"?" active":""}`,onClick:()=>{j("mine"),S("active"),w(null),C(null),_(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${v==="team"?" active":""}`,onClick:()=>{j("team"),S("active"),w(null),C(null),_(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:ge.map(ne=>n.jsxs("button",{className:`nav-tab${x===ne?" active":""}`,onClick:()=>{S(ne),w(null),C(null)},children:[ne.charAt(0).toUpperCase()+ne.slice(1)," (",H[ne],")"]},ne))}),X>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(gu,{areas:be,selected:N,onSelect:w,totalCount:X}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(ne=>{const xe=k===ne;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${ne}`,"aria-selected":xe,onClick:()=>C(xe?null:ne),children:ne==="auto"?"Automatic":"Review"},ne)})})]}),ht&&st.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ne.length===0?n.jsx(js,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:ke.map(ne=>n.jsxs("section",{"data-testid":"mandate-area","data-area":ne.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(Dr,{icon:ne.icon}),n.jsx("b",{children:ne.name}),n.jsxs("span",{className:"meta",children:[ne.items.length," mandate",ne.items.length===1?"":"s",ue(ne.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",ue(ne.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:ne.items.map(xe=>{const U=v==="team"?xe:null,ie=U!=null&&U.owner?U.owner.name??U.owner.email??U.owner.userId:void 0;return n.jsx(Xk,{item:xe,newerProfile:Qe(xe.profile_id),area:ne.name,ownerLabel:ie,isAdmin:Ge,...v==="mine"?kt:He},xe.authorization_id)})})]},ne.shortId))}),me&&n.jsx(Gk,{item:me,onClose:()=>we(null),onSuccess:()=>{we(null),dt()}})]})}function vg(e){const r=e.approved?e.proposalArgs:e.sentArgs;return gb(e.tool,r??null,e.manifests)??e.label}function nS(e){if(e.offDevice)return{level:"off-device"};const r=e.sentArgs??e.proposalArgs,a=r?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:r?rS(e.boundContent,r):null,argsCheck:a}:r?{level:"recorded",content:r,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function rS(e,r){const a={};for(const[i,l]of Object.entries(r))(typeof e=="string"?l===e:i in e)||(a[i]=l);return Object.keys(a).length>0?a:null}function yg(e,r,a){return rp(e,r).map(i=>{var l;return{...i,inTicket:aS(i.value,(l=r==null?void 0:r.executionMapping)==null?void 0:l[i.key],a)}})}function sS(e,r){if(String(e)===String(r))return!0;if(typeof e=="boolean"||typeof r=="boolean"||e===""||r===""||e===null||r===null)return!1;const a=Number(e),i=Number(r);return Number.isFinite(a)&&Number.isFinite(i)&&a===i}function aS(e,r,a){return!r||!a||e===void 0||e===null?!1:(typeof r=="string"?[{field:r}]:Array.isArray(r)?r:[r]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:sS(e,u)})}function gc(e){return e==null?"—":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):H0(e)}function iS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Qf(e,r){return Object.entries(e).filter(([a,i])=>!iS(i)&&!(r&&a in r&&gc(r[a])===gc(i))).map(([a,i])=>({key:a,label:zt(a),value:gc(i)}))}function oS(e,r){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Qf(a,r)};const i=e.text.trim();if(i.startsWith("{"))try{const l=JSON.parse(i);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Qf(l,r)}}catch{}return{kind:"text",text:e.text}}const Xf=new Map;function lS(e){let r=Xf.get(e);return r||(r=P.getProposal(e).catch(()=>null),Xf.set(e,r)),r}let fs=null;function cS(e){if(!fs||e*1e3>fs.fetchedAtMs){const r={fetchedAtMs:Date.now(),map:P.getTicketHeadlines().catch(()=>(fs===r&&(fs=null),{}))};fs=r}return fs.map}function uS({proposal:e,tool:r,manifests:a,label:i}){const l=xa(e);return n.jsx(n.Fragment,{children:vg({tool:r,manifests:a,label:i,approved:!0,proposalArgs:l.toolArgs})})}function dS({ticketId:e,timestamp:r,proposalId:a,tool:i,manifests:l,label:u}){const[d,p]=f.useState(null),[m,y]=f.useState(null);return f.useEffect(()=>{let v=!0;return p(null),y(null),a?lS(a).then(j=>{v&&p(j)}):cS(r).then(j=>{v&&y(j[e]??null)}),()=>{v=!1}},[a,e,r]),a?d?n.jsx(uS,{proposal:d,tool:i,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:vg({tool:i,manifests:l,label:u,approved:!1,sentArgs:m})})}function ps({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"preview-table-wrap",children:n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(r=>n.jsx("th",{children:r.label},r.key))})}),n.jsx("tbody",{children:e.rows.map((r,a)=>n.jsx("tr",{children:r.cells.map((i,l)=>n.jsx("td",{className:i.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:i.valueTitle,children:i.value},l))},a))})]})}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}const hS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function fS(e,r){return typeof r!="string"?!1:/^data:image\//i.test(r)?!0:hS.test(e)?/^https?:\/\//.test(r):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(r)}function Mr(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Zf({row:e,which:r}){const a=Ns(e.profileRef),i=sp(e.value,a,r);return i.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:i.map(l=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function mS({row:e}){const r=Ns(e.profileRef),a=(r==null?void 0:r.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(r==null?void 0:r.name)??Vt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function xg({row:e,altText:r}){if(e.kind==="list"||e.kind==="object"){const a=$p(e.value);if(a&&"table"in a)return n.jsx(ps,{table:a.table});if(a)return n.jsx(n.Fragment,{children:a.text})}switch(e.kind){case"profile":return n.jsx(mS,{row:e});case"profile-limits":return n.jsx(Zf,{row:e,which:"limits"});case"profile-scope":return n.jsx(Zf,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Mr(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,i)=>n.jsx("li",{children:Mr(a)},i))}):n.jsx(n.Fragment,{children:Mr(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Mr(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Mr(e.value)});default:return fS(e.key,e.value)?n.jsx("img",{src:e.value,alt:r??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Mr(e.value)})}}function Ui({args:e,display:r,heading:a="Details",requestRefArg:i}){const l=rp(e,r);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(d=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:d.hint,children:d.key===i?"Replying to":d.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:d.key===i?n.jsx("span",{"data-testid":"request-ref",title:Mr(d.value),children:"the message shown under Request"}):n.jsx(xg,{row:d,altText:u})})]},d.key))})]})}function pS(e){const r=f.useMemo(()=>typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof Blob>"u"?F0(e):URL.createObjectURL(new Blob([z0(e)],{type:e.contentType})),[e.contentBase64,e.contentType]);return f.useEffect(()=>()=>{r.startsWith("blob:")&&URL.revokeObjectURL(r)},[r]),r}function jg({doc:e,systemName:r,heading:a,sourceLine:i,trailingNote:l}){const u=pS(e),d=O0(e.pages),p=r?`Rendered by ${r}`:"Rendered",m=n.jsxs(n.Fragment,{children:[p," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),d&&n.jsx("div",{className:"preview-note",children:d}),i&&n.jsx("div",{className:"preview-note",children:i}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ap(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??m})]})]})]})}const gS="_attachmentsSealed";function vS(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.filename=="string"&&typeof r.contentType=="string"&&typeof r.sha256=="string"&&typeof r.bytes=="number"}function yS(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.placeholder=="string"&&typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.value=="string"}function vu(e){const r={attachments:[],inserts:[]};if(!e)return r;const a=e[gS];if(a===null||typeof a!="object")return r;const i=a,l=Array.isArray(i.attachments)?i.attachments.filter(vS):[],u=Array.isArray(i.inserts)?i.inserts.filter(yS):[];return{attachments:l,inserts:u}}function xS(e){return!Number.isFinite(e)||e<0?"—":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function jS(e){return vu(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function wg(e,r,a,i){var u,d,p;const l=(p=(d=(u=e==null?void 0:e.find(m=>m.id===r))==null?void 0:u.documents)==null?void 0:d[a])==null?void 0:p.label;if(l)return l.replace(/\{id\}/g,i)}function wS(e,r){return!e||!r||r==="loading"?null:r.status==="ok"?{key:"attachment-same-file",label:`same file as ${e}`,ok:!0,valueText:"",limitText:""}:r.status==="changed"?{key:"attachment-same-file",label:"attachment changed since it was sealed",ok:!1,valueText:"",limitText:""}:null}function bS({a:e,manifests:r,preview:a}){const i=wr(e.connector,r),l=wg(r,e.connector,e.kind,e.id),u=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"src-tag-value src-tag-system-cell",children:["from ",i]}),l?n.jsxs(n.Fragment,{children:[" — ",l]}):null]});return a&&a!=="loading"&&a.status==="ok"?n.jsx(jg,{doc:{filename:a.filename,contentType:a.contentType,contentBase64:a.contentBase64,sha256:a.sha256},heading:"Attachment",sourceLine:u,trailingNote:null}):n.jsxs("div",{className:"document-preview-box","data-testid":"attachment-sealed",children:[n.jsx("h4",{children:"Attachment"}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),n.jsx("div",{className:"preview-note",children:xS(e.bytes)}),n.jsx("div",{className:"preview-note",children:u}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ap(e.sha256)})]}),!a||a==="loading"?n.jsx("div",{className:"preview-note",children:"Loading preview…"}):a.status==="changed"?n.jsx("p",{className:"preview-note","data-testid":"attachment-changed",style:{color:"var(--check-failed)",fontWeight:700},children:"✕ changed since it was sealed"}):n.jsx("div",{className:"preview-note",children:"Preview not available."})]})]})}function kS({i:e,manifests:r}){const a=wr(e.connector,r);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function bg({attachments:e,inserts:r,manifests:a,fetchPreview:i,onChecks:l}){const[u,d]=f.useState({});return f.useEffect(()=>{if(!i)return;let p=!0;for(const m of e)d(y=>y[m.sha256]?y:{...y,[m.sha256]:"loading"}),i(m.sha256).then(y=>{p&&d(v=>({...v,[m.sha256]:y}))}).catch(()=>{p&&d(y=>({...y,[m.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{p=!1}},[e.map(p=>p.sha256).join(","),i]),f.useEffect(()=>{if(!l)return;const p=e.map(m=>wS(wg(a,m.connector,m.kind,m.id),u[m.sha256])).filter(m=>m!==null);l(p)},[e,a,u,l]),e.length===0&&r.length===0?null:n.jsxs(n.Fragment,{children:[e.map(p=>n.jsx(bS,{a:p,manifests:a,preview:u[p.sha256]},`${p.connector}:${p.kind}:${p.id}`)),r.map(p=>n.jsx(kS,{i:p,manifests:a},`${p.placeholder}:${p.connector}:${p.kind}:${p.id}`))]})}let Mi=null;function SS(){return Mi||(Mi=P.getToolDisplay().catch(()=>(Mi=null,{}))),Mi}function kg({args:e,display:r,executionContext:a,sealed:i}){const l=yg(e,r,a);return l.length===0?null:n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:l.map(u=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:i?"is-sealed":void 0,children:[n.jsx(xg,{row:u}),u.inTicket&&n.jsx("span",{className:"ob-quiet-inline",title:"This value is also in the signed ticket",children:" · also in the ticket"})]})]},u.key))})}function em({content:e,display:r,executionContext:a,sealed:i}){return typeof e=="string"?n.jsx("p",{className:`ob-text${i?" is-sealed":""}`,children:e}):n.jsx(kg,{args:e,display:r,executionContext:a,sealed:i})}function tm({check:e}){return e==="match"?n.jsx("p",{className:"ob-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match what this gateway executed"})]}):n.jsx("p",{className:"ob-quiet",children:"Could not be checked against this gateway's execution record."})}function NS({view:e,display:r,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-quiet",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsxs("p",{className:"ob-quiet",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("section",{className:"ob-tile ob-sealed is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{className:"ob-tile-h",children:[n.jsx(go,{}),"Sealed in the ticket"]}),n.jsx(em,{content:e.bound,display:r,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match the fingerprint in the signed ticket — this local copy was changed"})]}),e.extras&&yg(e.extras,r,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ob-lbl ob-gap",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(kg,{args:e.extras,display:r,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(tm,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-lbl ob-after-h",children:"Recorded by this gateway — not sealed in the ticket"}),n.jsx(em,{content:e.content,display:r,executionContext:a,sealed:!1}),n.jsx(tm,{check:e.check})]})}const nm=5;function CS({result:e,systemName:r,sent:a}){const i=oS(e,a),[l,u]=f.useState(!1),d=e.ok?i.kind==="rows"?`what ${r} answered · ${i.rows.length} value${i.rows.length===1?"":"s"}`:`what ${r} answered`:"the action failed";return n.jsxs(Gt,{title:"Result",summary:d,testId:"ticket-result",attrs:{"data-ok":e.ok?"true":"false"},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway from ",r]}),!e.ok&&n.jsx("p",{className:"ob-check",children:n.jsx("b",{children:"The action failed."})}),i.kind==="rows"?n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:(l?i.rows:i.rows.slice(0,nm)).map(p=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:p.label}),n.jsx("dd",{className:"is-system",children:p.value})]},p.key))}):n.jsx("p",{className:"ob-text is-system",children:i.text}),i.kind==="rows"&&i.rows.length>nm&&n.jsx("button",{type:"button",className:"ob-link",onClick:()=>u(p=>!p),children:l?"Show less":`Show all ${i.rows.length}`}),e.truncated&&n.jsx("p",{className:"ob-quiet",children:"Shortened to fit what this device keeps."})]})}function rm(e){var a;const r=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const i of r)if(i&&typeof i=="object"&&!Array.isArray(i))return i;return null}function Sg({receipt:e,manifests:r}){var N;const[a,i]=f.useState(void 0),[l,u]=f.useState(null),[d,p]=f.useState(void 0),m=!!(e.contentHash&&e.contentBinding);f.useEffect(()=>{let w=!0;return SS().then(k=>{w&&p(k[e.action])}),()=>{w=!1}},[e.action]),f.useEffect(()=>{let w=!0;return i(void 0),u(null),(async()=>{let k;try{k=await P.getArchivedReceipt(e.id)}catch{w&&i(null);return}let C=null;const E=k==null?void 0:k.entry.boundContent;if(E!==void 0&&m)try{C=await zp(e.contentBinding.kind,E)===e.contentHash}catch{C=!1}w&&(u(C),i(k))})(),()=>{w=!1}},[e.id,e.contentHash,e.contentBinding,m]);const y=f.useCallback(w=>P.getReceiptAttachmentPreview(e.id,w),[e.id]);if(a===void 0)return n.jsx("div",{className:"ob-sent ob-quiet","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const v=(N=a==null?void 0:a.entry.proposal)==null?void 0:N.toolArgs,j=nS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:v&&typeof v=="object"&&!Array.isArray(v)?v:void 0,hasHashToCheck:m,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=wr(Fn(e.action).integrationId,r),S=vu((a?rm(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(NS,{view:j,display:d,executionContext:e.executionContext}),n.jsx(bg,{attachments:S.attachments,inserts:S.inserts,manifests:r,fetchPreview:y}),(a==null?void 0:a.result)&&n.jsx(CS,{result:a.result,systemName:x,sent:rm(a)})]})}const sm=500;function Wi(e){return e.length>sm?`${e.slice(0,sm)}…`:e}function am(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function ES(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function lo(e,r,a){var i;switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${r}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${r}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${Wi(e.message)}`:"Preview not available."};case"refused":return{heading:`Refused by ${r}`,note:e.message?Wi(e.message):`${r} refused to answer.`};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${Wi(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e){const p=nb(a??{},e.reads,e.display,{readAt:e.readAt});return{heading:`What will be ${((i=e.display)==null?void 0:i.verb)??"created"} in ${r}`,note:IS(p)?`Values marked from the system were read by the gateway, not by the AI — read at ${ES(e.readAt)}.`:"",creation:p}}const l=Pp(e.body,{fields:e.fields}),u={heading:`From ${r}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:l},d=e.version;if(d&&(u.versionNote=`You approve ${d.field} ${d.approved}; if it changes, ${r} refuses it.`,d.stale)){const p=G0(e.body,d.currentBody,{fields:e.fields,excludeKey:d.field});u.stale={heading:`A newer ${d.field} exists (${d.current})`,approvedLabel:`${am(d.field)} ${d.approved}`,currentLabel:`${am(d.field)} ${d.current}`,...p.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:p.approved,currentRendered:p.current}}}return u}}}function AS(e,r){if(e.state!=="failed")return null;const a=e.detail?Wi(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${r} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${r}`,note:`${r} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function TS(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function IS(e){return e.sections.length>0?!0:e.rows.some(r=>r.kind==="identity"?!!r.identity.name:r.kind==="compare"?r.lines.some(a=>a.now!=="—"):r.kind==="table"?r.table.rows.some(a=>a.cells.some(i=>!i.sealed&&i.value!=="—"&&i.value!=="")):!1)}function im({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function RS({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(r=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:r.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:r.valueTitle,children:r.value})]},r.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((r,a)=>n.jsx("div",{style:r.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:r.kind==="add"?{fontWeight:600}:void 0,children:r.text||" "},a))}):e.table?n.jsx(ps,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((r,a)=>{var i;return n.jsx("div",{title:(i=e.lineTitles)==null?void 0:i[a],children:r},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function Bc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(r=>r.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(im,{row:r}),n.jsx(ps,{table:r.table})]},r.key):n.jsxs(f.Fragment,{children:[n.jsx(im,{row:r}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(RS,{row:r})})]},r.key))})}function vc({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(Bc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(Bc,{rows:e.moreFields})]})]})}function $S({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.filter(r=>!r.table).map(r=>{var a,i;return n.jsxs("span",{children:[" · ",r.label," ",r.value??((a=r.lines)==null?void 0:a.join(", "))??((i=r.sublist)==null?void 0:i.map(l=>l.value).join(", "))]},r.key)})})]})}function PS({view:e,systemName:r}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(a=>a.kind==="table"||a.kind==="compare"?null:n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:a.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:a.kind==="identity"?n.jsx($S,{identity:a.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:a.valueTitle,children:a.value})})]},a.key))}),e.rows.map(a=>a.kind==="compare"&&n.jsxs("table",{className:"compare-table","data-testid":"compare-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),n.jsxs("th",{children:["Now (from ",r??"the system",")"]}),n.jsx("th",{children:"New"})]})}),n.jsx("tbody",{children:a.lines.map(i=>n.jsxs("tr",{children:[n.jsx("td",{className:"compare-label",children:i.label}),n.jsx("td",{className:"compare-now",children:i.now}),n.jsx("td",{className:"compare-new",children:i.next})]},i.key))})]},a.key)),e.rows.flatMap(a=>a.kind==="identity"?a.identity.context.filter(i=>i.table).map(i=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:i.label}),n.jsx(ps,{table:i.table})]},`${a.key}.${i.key}`)):[]),e.rows.filter(a=>a.kind==="table").map(a=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:a.label}),n.jsx(ps,{table:a.table})]},a.key)),e.sections.map((a,i)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(jg,{doc:a.document,systemName:r}):n.jsxs(n.Fragment,{children:[n.jsxs("h5",{children:[a.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),a.table&&n.jsx(ps,{table:a.table}),a.body&&n.jsx(Bc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},i))]})}function Ng({view:e}){return e.systemBoxes.length===0?null:n.jsx(n.Fragment,{children:e.systemBoxes.map(r=>n.jsxs("div",{className:"system-box","data-testid":"system-box",children:[n.jsx("div",{className:"system-box-heading",children:r.heading}),n.jsx("dl",{children:r.rows.map(a=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:a.label}),n.jsx("dd",{children:a.value})]},a.key))}),n.jsx("p",{className:"system-box-note",children:"Shown for this decision only. It is asked again when this is saved; that answer is stored."})]},r.key))})}function _S(e,r){if(!(r!=null&&r.length)||e.status!=="ok"||!("body"in e)||!e.body.structured)return e;const a=Object.fromEntries(Object.entries(e.body.structured).filter(([i])=>!r.includes(i)));return{...e,body:{...e.body,structured:a},...e.fields?{fields:e.fields.filter(i=>!r.includes(i))}:{}}}function Cg({resp:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l=!0,omitKeys:u,hideNote:d=!1}){const p=_S(e,u),m=lo(p,r,a??void 0),y=p.status==="ok"?m.stale?"stale":"ok":p.status;return y==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:m.note}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`preview-box preview-box-${y}`,"data-testid":"approval-preview","data-preview-status":y,children:[n.jsxs("h4",{children:[m.heading,m.creation&&(i?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),m.creation&&n.jsx(PS,{view:m.creation,systemName:r}),m.rendered&&n.jsx(vc,{rendered:m.rendered}),m.note&&!d&&n.jsx("p",{className:"preview-note",children:m.note}),m.versionNote&&!m.stale&&n.jsx("p",{className:"preview-note",children:m.versionNote}),m.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:m.stale.heading}),m.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:m.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:m.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(vc,{rendered:m.stale.approvedRendered})}),n.jsx("dt",{children:m.stale.currentLabel}),n.jsx("dd",{children:n.jsx(vc,{rendered:m.stale.currentRendered})})]})]})]}),l&&m.creation&&n.jsx(Ng,{view:m.creation})]})}function LS({proposalId:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d,onTone:p,onData:m}){const[y,v]=f.useState(null),[j,x]=f.useState(!1);return f.useEffect(()=>{let S=!0;return v(null),x(!1),P.getProposalPreview(e).then(N=>{S&&v(N)}).catch(()=>{S&&x(!0)}),()=>{S=!1}},[e]),f.useEffect(()=>{if(j){p==null||p("unavailable"),m==null||m({status:"unavailable",reason:"connector_error"});return}if(!y){m==null||m(null);return}const S=lo(y,r,a??void 0);p==null||p(y.status==="ok"?S.stale?"stale":"ok":y.status),m==null||m(y)},[y,j,r,p,m]),j?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):y?n.jsx(Cg,{resp:y,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",r,"…"]})}const yc=6;function co(e){if(!e)return;const r=Date.parse(e);return Number.isNaN(r)?e:new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function MS(e){if(!e)return{first:""};const r=e.split(`
85
- `);return r.length<=yc?{first:e}:{first:r.slice(0,yc).join(`
86
- `),more:r.slice(yc).join(`
87
- `)}}const FS="Linked by the AI",OS="linked automatically — this action already carried a reference to it";function Eg(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:r,more:a}=MS(e.body),i=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,co(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:FS,...e.implicit?{implicitNote:OS}:{},metaLine:i.join(" · "),title:e.title,bodyFirst:r,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:co(l.at)}))}}const da="Read by the gateway — same customer, not matched to this request";function zS(e){const r=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${r})`}function DS(e){var l;const r=!!e.aiWritten,a=r?"Activity":e.type??e.kind??"Entry";let i;if(r){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?co(new Date(e.aiWritten.at).toISOString()):void 0;i=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else i=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:co(e.at),title:e.title,body:e.body,attribution:i,aiWritten:r}}function Ag(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:da,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:da,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:da,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const r=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>DS(l)),a=e.matches.map(zS),i=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return r.length===0?{state:"empty",label:da,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:i}:{state:"ok",label:da,note:"",matchNotes:a,items:r,unreachableNote:i}}function Tg({req:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:e.implicitNote}),e.metaLine&&n.jsx("p",{className:"au10-req-meta",children:e.metaLine}),e.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:e.title})}),e.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:e.bodyFirst}),e.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:e.bodyMore})]}),e.attribution&&n.jsx("p",{className:"au10-req-attrib",children:e.attribution}),e.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",e.chain.length,")"]}),e.chain.map((r,a)=>n.jsxs("div",{className:"au10-chain-item",children:[(r.author||r.at)&&n.jsxs("p",{className:"au10-req-meta",children:[r.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:r.author})]}):null,r.author&&r.at?" · ":"",r.at]}),r.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:r.title})}),r.body&&n.jsx("p",{className:"au10-req-quote",children:r.body}),r.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",r.author,", not checked"]})]},a))]})]})}function Ig({hist:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.matchNotes.map((r,a)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:r},a)),n.jsx("ul",{className:"au10-hist-list",children:e.items.map((r,a)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[r.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),r.headLabel]}),n.jsx("span",{children:r.at})]}),r.title&&n.jsx("div",{className:"au10-hist-title",children:r.title}),r.body&&n.jsx("div",{className:"au10-hist-body",children:r.body}),n.jsx("p",{className:"au10-hist-attrib",children:r.attribution})]},a))}),e.unreachableNote&&n.jsx("p",{className:"preview-note",children:e.unreachableNote})]})}function Rg({resp:e}){const r=Eg(e.request),a=Ag(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("h4",{children:["Request",r.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:r.tag})]}),n.jsx(Tg,{req:r})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),n.jsx(Ig,{hist:a})]})]})}const om=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function BS(e){if(e.state!=="ok")return e.note;const r=e.items.length,a=e.items[0];return`${r} ${r===1?"entry":"entries"}${a!=null&&a.at?` · latest ${a.at}`:""}`}function US(e){return e.state!=="ok"?e.note??"":e.title??e.metaLine??""}function WS({resp:e}){const r=Eg(e.request),a=Ag(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("details",{className:"av3-fold",style:{order:12},"data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Request"}),n.jsx("span",{className:"one",children:US(r)}),om]}),n.jsxs("div",{className:"av3-fold-body",children:[r.tag&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-ai",style:{marginLeft:0},children:r.tag})}),n.jsx(Tg,{req:r})]})]}),n.jsxs("details",{className:"av3-fold",style:{order:13},"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"History"}),n.jsx("span",{className:"one",children:BS(a)}),om]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-system",style:{marginLeft:0},children:a.label})}),n.jsx(Ig,{hist:a})]})]})]})}function HS({proposalId:e,onData:r,layout:a="boxes"}){const[i,l]=f.useState(null),[u,d]=f.useState(!1);return f.useEffect(()=>{let p=!0;return l(null),d(!1),P.getProposalRequestContext(e).then(m=>{p&&l(m)}).catch(()=>{p&&d(!0)}),()=>{p=!1}},[e]),f.useEffect(()=>{r==null||r(u?null:i)},[i,u,r]),u||!i?null:a==="folds"?n.jsx(WS,{resp:i}):n.jsx(Rg,{resp:i})}function VS(e,r,a){const i=Object.entries(e??{});if(i.length===0)return{entry:void 0,otherCount:0};const u=i.find(([,p])=>p.by===r)??(a?i.find(([p])=>p===`domain:${a}`):void 0),d=u?i.length-1:i.length;return{entry:u==null?void 0:u[1],otherCount:d}}function qS(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function KS(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function GS(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function $g({proposalId:e,tool:r,manifests:a}){const{user:i,domain:l}=Nt(),[u,d]=f.useState(null),[p,m]=f.useState(null),[y,v]=f.useState(!1);if(f.useEffect(()=>{let F=!0;return d(null),m(null),v(!1),Promise.all([P.getShownSnapshot(e),P.getProposal(e)]).then(([M,B])=>{F&&(d(M),m(B))}).catch(()=>{F&&v(!0)}),()=>{F=!1}},[e]),y||!u||!p)return null;const j=u.status==="off_device",{entry:x,otherCount:S}=VS(p.shownHashes,(i==null?void 0:i.id)??"",l),N=qS({offDevice:j,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),w=KS(S);if(j)return n.jsx(Gt,{title:"What you saw",summary:"only on the approving gateway",testId:"au10-shown",attrs:{"data-shown-status":"off-device"},children:n.jsx("p",{className:"ob-quiet",children:"Only on the approving gateway — this device has no local copy."})});const{snapshot:k}=u,{integrationId:C}=Fn(r),E=wr(C,a),$=GS(k.readAt),T=N==="verified"?`read ${$} · verified`:N==="mismatch"?`read ${$} · does not match what was approved`:`read ${$}`;return n.jsxs(Gt,{title:"What you saw",summary:T,testId:"au10-shown",attrs:{"data-shown-status":N},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway at ",$,", kept on this device — not read again now."]}),n.jsx(Cg,{resp:k.preview,systemName:E,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(Rg,{resp:k.requestContext}),N==="verified"&&n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint recorded with your approval."}),N==="mismatch"&&n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"This copy differs from the fingerprint recorded with your approval."})]}),N==="unchecked"&&n.jsx("p",{className:"ob-quiet",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),w&&n.jsx("p",{className:"ob-quiet","data-testid":"au10-shown-others",children:w})]})}function YS({receipt:e,manifests:r,localAuth:a,localUnavailable:i,signature:l,grantTitle:u,ownerLabel:d,spUrl:p,formatDate:m,onOpenComplete:y,isNew:v=!1,defaultOpen:j=!1}){const x=Ns(e.profileId),S=Nw(e,x),N=Cw(a==null?void 0:a.context,x),w=Ew(e,(a==null?void 0:a.bounds)??e.limits,x),k=a==null?void 0:a.intent,C=jr(e.profileId).testSetup||po(e.action),[E,$]=f.useState(!1),[T,F]=f.useState(j),M=Date.now(),B=On(),te=Br(e.profileId,B),Q=yo(e.action,r),_=va(),z=u||Tw(e.profileId),V=ma(e.timestamp,M),K=lu(e.id);return n.jsxs("div",{className:`ob-card ticket-obj-card${v?" is-new":""}${T?" is-open":""}`,"data-new":v?"true":"false","data-testid":"ticket-card",children:[n.jsxs("button",{type:"button",className:"ob-head ticket-obj-head","aria-expanded":T,onClick:()=>F(le=>!le),children:[n.jsx(At,{tag:"Ticket",profileId:e.profileId,className:"obj-line",parts:[te,`via ${Q}`,V,n.jsx("span",{className:"ob-st",children:Yi(e)?"Approved":"Automatic"},"st"),C?"Test setup":null,v?n.jsx("span",{className:"ob-st","aria-label":"new since your last visit",children:"New"},"new"):null]}),n.jsxs("span",{className:"ob-title receipt-what",children:[te," · ",n.jsx("span",{"data-testid":"ticket-headline",children:n.jsx(dS,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:r,label:ys(e,r)})})]}),l==="valid"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="valid-legacy"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · issued before protocol 0.7 · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="invalid"&&n.jsxs("span",{className:"ob-check ob-check-x",title:"The stored ticket does not match what was signed.",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("b",{children:["Signature check failed · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l!=="valid"&&l!=="valid-legacy"&&l!=="invalid"&&n.jsxs("span",{className:"ob-one",children:["Ticket ",n.jsx("span",{className:"ob-mono",children:K})]}),S&&n.jsx("span",{className:"ob-one receipt-scope",children:S})]}),T&&n.jsxs("div",{ref:_,className:"ob-open",children:[n.jsx(Sg,{receipt:e,manifests:r}),e.proposalId&&n.jsx($g,{proposalId:e.proposalId,tool:e.action,manifests:r}),n.jsxs(Gt,{title:"Mandate",summary:[z,w].filter(Boolean).join(" · "),testId:"ticket-mandate",children:[n.jsxs("p",{className:"ob-lbl",children:[k||N?"Name, allowed values and intent: from this device.":"Name: from this device.",w?" Use: sealed in the ticket.":""]}),n.jsxs("dl",{className:"ob-kv receipt-rows",children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:z}),d&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Owner"}),n.jsx("dd",{children:d})]}),N&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Allowed"}),n.jsx("dd",{children:N})]}),w&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Used"}),n.jsx("dd",{className:"receipt-num",children:w})]}),n.jsx("dt",{children:"Intent"}),n.jsx("dd",{className:"ob-plain",children:k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${E?"":" intent-clamped"}`,children:k})," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>$(!E),children:E?"Show less":"Show full intent"})]}):n.jsx("span",{className:"receipt-absent",children:i?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]})]}),n.jsxs(Gt,{title:"Technical details",summary:`ticket ${K} · ${m(e.timestamp)}`,testId:"ticket-technical",children:[n.jsx("p",{className:"ob-lbl",children:"Read from the signed ticket."}),n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Ticket"}),n.jsx("dd",{className:"ob-mono",children:e.id}),n.jsx("dt",{children:"Issued"}),n.jsx("dd",{className:"receipt-when",children:m(e.timestamp)}),n.jsx("dt",{children:"Action"}),n.jsx("dd",{className:"ob-mono",children:e.action})]}),n.jsxs("details",{className:"ob-raw receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"ob-mono receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([le,me])=>`${le}=${me}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]}),n.jsxs("div",{className:"ob-btns receipt-foot",children:[n.jsx("button",{type:"button",className:"ob-btn receipt-evidence-link",onClick:y,children:"Complete ticket"}),p&&n.jsxs("a",{className:"ob-btn receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",title:"Redacted, shareable",children:["Public link ↗",n.jsx("span",{className:"ob-btn-q",children:" · redacted"})]})]})]})]})}function JS({receipt:e,onClose:r}){const[a,i]=f.useState(null),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(!0),[v,j]=f.useState(!1);f.useEffect(()=>{let k=!1;return y(!0),P.getArchivedReceipt(e.id).then(C=>{k||(i(C),u(C?"local":"authority-server"),p((C==null?void 0:C.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||y(!1)}),()=>{k=!0}},[e.id]);const x=a?a.entry:{receipt:e},S=JSON.stringify(x,null,2);function N(){const k=URL.createObjectURL(new Blob([S],{type:"application/json"})),C=document.createElement("a");C.href=k,C.download=`suveren-ticket-${e.id.slice(0,8)}.json`,C.click(),URL.revokeObjectURL(k)}async function w(){try{await navigator.clipboard.writeText(S),j(!0),setTimeout(()=>j(!1),2e3)}catch{j(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:k=>k.target===k.currentTarget&&r(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:r,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[d==="valid"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),d==="valid-legacy"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),d==="invalid"&&n.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:m?"Loading…":l==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),n.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:N,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:w,children:v?"Copied":"Copy"})]})]})})}function QS(e){return new Date(e*1e3).toLocaleString()}function XS(e,r){if(r==="all")return!0;const a=r==="1d"?1:r==="7d"?7:30,i=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=i}function ZS(e,r,a){const i=r.trim().toLowerCase();return i?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(i)):!0}function lm(e,r){const a=new Map(e.map(i=>[i.id,i]));for(const i of r)a.set(i.id,i);return[...a.values()].sort((i,l)=>l.timestamp-i.timestamp)}function eN(){const{activeTeam:e,groupId:r}=Nt(),a=(e==null?void 0:e.isAdmin)===!0,[i,l]=f.useState("mine"),[u,d]=Ss(),p=Rw(u.get("filter")),m=H=>{const ge=new URLSearchParams(u);H==="all"?ge.delete("filter"):ge.set("filter",H),d(ge,{replace:!0})},y=Xm(u.get("area")),v=H=>{const ge=new URLSearchParams(u);H===null?ge.delete("area"):ge.set("area",H),d(ge,{replace:!0})},j=On(),[x,S]=f.useState(null),N=f.useRef(!1),[w,k]=f.useState([]),[C,E]=f.useState([]),[$,T]=f.useState(""),[F,M]=f.useState(!0),[B,te]=f.useState({}),[Q,_]=f.useState(new Set),[z,V]=f.useState(""),[K,le]=f.useState(new Set),[me,we]=f.useState("all"),[Ae,Z]=f.useState(!1),[G,J]=f.useState(!1),[I,D]=f.useState(null),[pe,de]=f.useState({}),[$e,ve]=f.useState(!1),[Y,he]=f.useState({}),[ee,oe]=f.useState({}),[Oe,Fe]=f.useState(null),[se,Te]=f.useState(null),[_e,Ve]=f.useState(!1),[Ge,ct]=f.useState(!1),nt=f.useRef(""),Je=f.useCallback(H=>i==="team"&&a&&r?P.listTeamReceiptsPage(r,{before:H,limit:200}):P.getMyReceiptsPage({before:H,limit:200}),[i,a,r]),Be=f.useCallback(()=>{const H=i==="team"?`team:${r}`:"mine",ge=nt.current!==H;nt.current=H,M(!0),ct(!1),Je().then(be=>{k(X=>ge?be.receipts:lm(X,be.receipts)),Te(X=>ge?be.nextBefore:X??be.nextBefore)}).catch(()=>{ge&&k([]),ct(!0)}).finally(()=>M(!1))},[Je,i,r]),dt=f.useCallback(()=>{!se||_e||(Ve(!0),ct(!1),Je(se).then(H=>{k(ge=>lm(ge,H.receipts)),Te(H.nextBefore)}).catch(()=>ct(!0)).finally(()=>Ve(!1)))},[se,_e,Je]);Ht(Be,12e4);const et=f.useCallback(()=>{Be(),x!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markTicketsSeen(Date.now()).catch(()=>{}))},[Be,x]);Ke("ticket-recorded",et),f.useEffect(()=>{F||N.current||(N.current=!0,P.getLastSeenTicketsAt().then(H=>(S(H),P.markTicketsSeen(Date.now()))).catch(()=>S(Number.POSITIVE_INFINITY)))},[F]),f.useEffect(()=>{P.getLabelManifests().then(E).catch(()=>{}),fetch("/health").then(H=>H.json()).then(H=>{typeof H.spUrl=="string"&&T(H.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{P.getLocalAuthorizations().then(({authorizations:H,signatures:ge})=>{de(H),he(ge),ve(!1)}).catch(()=>{de({}),he({}),ve(!0)}),P.getMyAttestations().then(H=>{const ge={};for(const be of H)be.authorization_id&&be.title&&(ge[be.authorization_id]=be.title);oe(ge)}).catch(()=>{})},[]),f.useEffect(()=>{i!=="team"||Object.keys(B).length>0||P.listUsers().then(H=>{const ge={};for(const be of H)ge[be.id]={name:be.name,email:be.email};te(ge)}).catch(()=>{})},[i,B]);const De=f.useMemo(()=>{const H=new Set;for(const ge of w)H.add(ge.action);return[...H].sort()},[w]),Ie=f.useMemo(()=>{if(i!=="team")return[];const H=new Set;for(const ge of w)ge.userId&&H.add(ge.userId);return[...H].map(ge=>{var be;return{id:ge,label:(be=B[ge])!=null&&be.name?`${B[ge].name} (${B[ge].email})`:ge}}).sort((ge,be)=>ge.label.localeCompare(be.label))},[i,w,B]),We=f.useMemo(()=>w.filter(H=>!(!ZS(H,z,[Qn(H.profileId,j),ys(H,C),wr(Fn(H.action).integrationId,C),H.authorizationId?ee[H.authorizationId]:null])||K.size>0&&!K.has(H.action)||Q.size>0&&H.userId&&!Q.has(H.userId)||!XS(H,me))),[w,z,j,C,ee,K,Q,me]),Qe=f.useMemo(()=>{const H={automatic:0,approved:0,all:0};for(const ge of We)H.all+=1,H[Ji(ge,"approved")?"approved":"automatic"]+=1;return H},[We]),ut=f.useMemo(()=>We.filter(H=>Ji(H,p)),[We,p]),ye=f.useMemo(()=>{const H=new Map;for(const ge of ut){const be=En(ge.profileId),X=H.get(be);X?X.count+=1:H.set(be,{shortId:be,icon:Jn(ge.profileId),name:Qn(ge.profileId,j),count:1})}return[...H.values()].sort((ge,be)=>ge.name.localeCompare(be.name))},[ut,j]),ze=f.useMemo(()=>ut.filter(H=>Zm(H.profileId,y)),[ut,y]),Ye=f.useMemo(()=>x===null?0:ze.filter(H=>Qi(H,x)).length,[ze,x]),tt=K.size>0||Q.size>0||me!=="all";function st(H){le(ge=>{const be=new Set(ge);return be.has(H)?be.delete(H):be.add(H),be})}function ht(H){_(ge=>{const be=new Set(ge);return be.has(H)?be.delete(H):be.add(H),be})}function jt(){le(new Set),_(new Set),we("all"),V("")}async function qe(){J(!0),D(null);try{const{bundle:H,filename:ge}=await P.fetchEvidenceBundle(),be=URL.createObjectURL(new Blob([JSON.stringify(H,null,2)],{type:"application/json"})),X=document.createElement("a");X.href=be,X.download=ge,X.click(),URL.revokeObjectURL(be);const Ne=H.sources??{};Ne.authorityServer?Ne.local||D(`Downloaded Authority Server history only — ${Ne.localError??"local archive unavailable."}`):D(`Downloaded local evidence only — ${Ne.asError??"Authority Server export unavailable."}`)}catch(H){D(`Export failed: ${H instanceof Error?H.message:String(H)}`)}finally{J(!1)}}return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ye>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ye," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:qe,disabled:G,children:G?"Preparing…":"Download evidence"})]}),I&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:I}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(H=>n.jsx("button",{onClick:()=>l(H),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:i===H?"2px solid var(--accent)":"2px solid transparent",color:i===H?"var(--text-primary)":"var(--text-tertiary)",fontWeight:i===H?600:500},children:H==="mine"?"Mine":"Team"},H))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:Iw.map(H=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${H}`,"aria-selected":p===H,onClick:()=>m(H),children:[H==="automatic"?"Automatic":H==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Qe[H]})]},H))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:z,onChange:H=>V(H.target.value)}),z&&n.jsx("button",{className:"search-clear",onClick:()=>V(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${Ae?" active":""}`,onClick:()=>Z(!Ae),children:["Filters",tt?` (${K.size+(me!=="all"?1:0)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(gu,{areas:ye,selected:y,onSelect:v,totalCount:ut.length}),Ae&&n.jsxs("div",{className:"filter-panel",children:[De.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:De.map(H=>n.jsx("button",{className:`filter-chip${K.has(H)?" selected":""}`,onClick:()=>st(H),children:H},H))})]}),i==="team"&&Ie.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:Ie.map(H=>n.jsx("button",{className:`filter-chip${Q.has(H.id)?" selected":""}`,onClick:()=>ht(H.id),children:H.label},H.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([H,ge])=>n.jsx("button",{className:`filter-chip${me===H?" selected":""}`,onClick:()=>we(H),children:ge},H))})]})]}),tt&&n.jsxs("div",{className:"active-filters",children:[[...K].map(H=>n.jsxs("span",{className:"active-chip",onClick:()=>st(H),children:[H," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)),[...Q].map(H=>{const ge=B[H],be=ge?ge.name:H;return n.jsxs("span",{className:"active-chip",onClick:()=>ht(H),children:[be," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)}),me!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>we("all"),children:[me==="1d"?"Today":me==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:jt,children:"Clear all"})]}),Ge&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),F&&w.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ze.length===0?n.jsx(js,{icon:"⌕",title:w.length===0?"No tickets in the last 30 days":"No matching tickets",text:w.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ze.length===w.length?`${w.length} ticket${w.length!==1?"s":""}`:`${ze.length} of ${w.length} tickets`}),n.jsx("div",{className:"ob-list",children:ze.map(H=>{const ge=H.userId?B[H.userId]:void 0;return n.jsx("div",{className:"ob-list-item",children:n.jsx(YS,{receipt:H,manifests:C,localAuth:H.authorizationId?pe[H.authorizationId]:void 0,localUnavailable:$e,signature:Y[H.id],grantTitle:H.authorizationId?ee[H.authorizationId]:null,ownerLabel:i==="team"&&H.userId?ge?`${ge.name} (${ge.email})`:H.userId:null,spUrl:$,formatDate:QS,onOpenComplete:()=>Fe(H),isNew:x!==null&&Qi(H,x),defaultOpen:ze.length===1})},H.id)})})]}),Oe&&n.jsx(JS,{receipt:Oe,onClose:()=>Fe(null)}),se&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:dt,disabled:_e,children:_e?"Loading…":"Load older"})})]})}function tN(){const[e,r]=f.useState(null),[a,i]=f.useState({}),[l,u]=f.useState(!1),d=On(),[p,m]=Ss(),y=Xm(p.get("area")),v=f.useCallback(M=>{const B=new URLSearchParams(p);M===null?B.delete("area"):B.set("area",M),m(B,{replace:!0})},[p,m]),[j,x]=f.useState({}),S=f.useCallback(()=>{P.getMyAttestations().then(M=>{const B={};for(const te of M)te.title&&(B[te.authorization_id]=te.title);x(B)}).catch(()=>{})},[]);f.useEffect(()=>{S()},[S]),Ht(S,3e5);const[N,w]=f.useState(null),k=f.useRef(!1),C=f.useCallback(()=>{P.getDenials({limit:200}).then(({records:M})=>{r(M),u(!1)}).catch(()=>u(!0))},[]);f.useEffect(()=>{C()},[C]),Ht(C,6e4),f.useEffect(()=>{if(!e)return;const M=[...new Set(e.map(B=>B.profile).filter(B=>!!B))].filter(B=>!(B in a));M.length!==0&&Promise.all(M.map(B=>xo(B))).then(B=>{i(te=>{const Q={...te};return M.forEach((_,z)=>{Q[_]=B[z]}),Q})})},[e,a]),f.useEffect(()=>{!e||k.current||(k.current=!0,P.getLastSeenBlockedAt().then(M=>(w(M),P.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const E=f.useCallback(()=>{C(),S(),N!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[C,S,N]);Ke("denial-recorded",E);const $=f.useMemo(()=>{const M=new Map;for(const B of e??[]){const te=B.profile??B.integrationId,Q=En(te),_=M.get(Q);_?_.count+=1:M.set(Q,{shortId:Q,icon:Jn(te),name:Qn(te,d),count:1})}return[...M.values()].sort((B,te)=>B.name.localeCompare(te.name))},[e,d]);if(l)return n.jsx(js,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const T=yw(e,Date.now()),F=e.filter(M=>Zm(M.profile??M.integrationId,y));return n.jsxs("div",{className:"blocked-page ob-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[T," today · nothing ran"]})]}),e.length===0?n.jsx(js,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(gu,{areas:$,selected:y,onSelect:v,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:F.map((M,B)=>{const te=ip(M,M.profile?a[M.profile]??void 0:void 0,j),Q=N!==null&&M.ts>N,_=M.profile??M.integrationId;return n.jsx(nN,{record:M,view:te,area:Qn(_,d),unseen:Q,mandateTitle:ap(M,j)},`${M.ts}-${B}`)})})]})]})}function nN({record:e,view:r,area:a,unseen:i,mandateTitle:l}){const u=va();return n.jsx("div",{className:"ob-card blocked-item blocked-card","data-seen":i?"false":"true","data-testid":"blocked-card",children:n.jsxs("div",{ref:u,children:[n.jsx(At,{tag:"Blocked",profileId:e.profile??void 0,className:"obj-line",parts:[a,e.integrationId?`via ${vs(e.integrationId)}`:null,op(e.ts,Date.now()),i?n.jsx("span",{className:"ob-st new-pill","data-testid":"blocked-new",children:"New"}):null]}),n.jsx("h3",{className:"ob-title",children:lp(e)}),n.jsxs("p",{className:"ob-check ob-check-x","data-kind":ya(e),children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("span",{children:[n.jsx("b",{children:cp(e)})," ",r.sentence]})]}),n.jsx("p",{className:"ob-quiet",children:bw(e)}),n.jsx(Gt,{title:"What you can do",summary:"change the mandate or ignore it",testId:"blocked-advice",children:n.jsx("p",{children:r.whatYouCanDo})}),n.jsx(Gt,{title:"Technical details",summary:e.code??void 0,testId:"blocked-technical",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Action"}),n.jsxs("dd",{className:"ob-mono",children:[vs(e.integrationId)," · ",e.tool]}),n.jsx("dt",{children:"Mandate"}),n.jsxs("dd",{children:[l??(e.mandateId?"":"none covers it"),e.mandateId&&n.jsxs("span",{className:"ob-mono",children:[" ",e.mandateId.slice(0,14),"…"]})]}),e.code&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Code"}),n.jsx("dd",{className:"ob-mono",children:e.code})]})]})}),n.jsx("div",{className:"ob-btns",children:n.jsx(pt,{className:"ob-btn",to:e.mandateId?`/mandates?highlight=${encodeURIComponent(e.mandateId)}`:"/mandates",children:"Open mandate"})})]})})}const rN={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function sN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{r(await P.getAutostart())}catch(y){u(y instanceof Error?y.message:"Could not read autostart state")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){i(!0),u(null);try{await P.setAutostart(!e.installed)}catch(y){u(y instanceof Error?y.message:"Failed")}finally{try{r(await P.getAutostart()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not re-read state")}i(!1)}}},[e,a,d]);if(!e)return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Autostart"]}),n.jsx("h3",{className:"ob-title",children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const m=rN[e.platform]??"a login service";return n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Autostart",e.supported?n.jsx("span",{className:`ob-st${e.installed?"":" is-off"}`,children:e.installed?"On":"Off"}):"Not available"]}),n.jsx("h3",{className:"ob-title",children:"Keep Suveren running"}),n.jsx("p",{className:"ob-one",children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",m," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:`ob-btn${e.installed?"":" is-solid"}`,children:a?"Working…":e.installed?"Turn off":"Turn on"})})]}),e.supported&&n.jsx(Gt,{title:"What happens after a restart",summary:"takes effect at your next login",children:n.jsxs("p",{children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]})}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}function aN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{const m=await P.getGatewaySettings();r(m.desktopNotifications),u(null)}catch(m){u(m instanceof Error?m.message:"Could not read notification setting")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(e===null||a)){i(!0),u(null);try{const m=await P.setGatewaySettings({desktopNotifications:!e});r(m.desktopNotifications)}catch(m){u(m instanceof Error?m.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]);return e===null?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Notifications"]}),n.jsx("h3",{className:"ob-title",children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Notifications",n.jsx("span",{className:`ob-st${e?"":" is-off"}`,children:e?"On":"Off"})]}),n.jsx("h3",{className:"ob-title",children:"Desktop notifications"}),n.jsx("p",{className:"ob-one",children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:`ob-btn${e?"":" is-solid"}`,children:a?"Saving…":e?"Turn off":"Turn on"})})]}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}const cm={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function iN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{r(await P.getIdentityDisclosure()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not read the setting")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(!e||a)){i(!0),u(null);try{r(await P.setIdentityDisclosure(!e.always))}catch(v){u(v instanceof Error?v.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]),m=n.jsx("h3",{className:"ob-title",children:"Your name on mandates and tickets"});if(!e)return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Mandates and tickets"]}),m,n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read the setting: ${l}`:"Checking…"})]});const y=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${cm.as_vouched} ${e.verifier}`:cm[e.method??""]??e.method}`:null;return n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Mandates and tickets",n.jsx("span",{className:`ob-st${e.always?"":" is-off"}`,children:e.always?"On":"Off"})]}),m,n.jsxs("p",{className:"ob-one",children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{className:"ob-one",children:y?`Your identity: ${y}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:"ob-btn",children:a?"Saving…":e.always?"Turn off":"Always show my name"})})]}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}const oN={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function lN(){const{version:e,latestVersion:r,updateAvailable:a,installMethod:i}=nu();return e?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Version"]}),n.jsxs("h3",{className:"ob-title",children:["Running ",n.jsx("b",{children:e}),a&&r?n.jsxs(n.Fragment,{children:[" — ",n.jsx("b",{children:r})," is available"]}):null]}),n.jsxs("p",{className:"ob-one",children:[oN[i]??"Update checking is unavailable",i==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Uc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx(go,{})," Set by your IT"]})}function um(e){return e===!0}function cN(){const[e,r]=f.useState(null),[a,i]=f.useState(null);f.useEffect(()=>{let d=!1;return P.getAsPairing().then(p=>{d||r(p)}).catch(p=>{d||i(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{d=!0}},[]);const l=um(e==null?void 0:e.asUrlLockedByPolicy),u=um(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{tag:"SERVER",parts:["Connection",l&&n.jsx(Uc,{})]}),n.jsx("h3",{className:"ob-title",children:"Your Authority Server"}),!e&&!a&&n.jsx("p",{className:"ob-one",children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"ob-tile",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"URL"}),n.jsx("dd",{className:"ob-mono is-strong",children:e.asUrl}),e.paired&&e.fingerprint&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Key fingerprint"}),n.jsx("dd",{className:"ob-mono is-strong",children:e.fingerprint})]}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs(n.Fragment,{children:[n.jsxs("dt",{children:["TLS certificate pin ",u&&n.jsx(Uc,{title:"TLS pinning is set by your IT policy"})]}),n.jsx("dd",{className:e.tlsPinFingerprint?"ob-mono is-strong":"ob-plain",children:e.tlsPinFingerprint??n.jsxs(n.Fragment,{children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]})})]})]})}),e.paired&&e.fingerprint?n.jsx("p",{className:"ob-one",children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."}):n.jsx("p",{className:"ob-one",children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{className:"ob-one",children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]}),l?n.jsx("p",{className:"ob-one",children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):n.jsxs(Gt,{title:"Point this gateway at a different server",summary:"command, then restart",children:[n.jsxs("p",{children:[n.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart."]}),n.jsx("p",{children:"Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."})]})]})]})}function uN(){const{simulation:e,locked:r}=Ep();return r?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Simulation mode",e!==null?n.jsx("span",{className:`ob-st${e?"":" is-off"}`,children:e?"On":"Off"}):null,n.jsx(Uc,{})]}),n.jsx("h3",{className:"ob-title",children:"Simulation mode"}),n.jsxs("p",{className:"ob-one",children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]}),n.jsxs("p",{className:"ob-one",children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const dN={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},ha=["Authority Server","This computer","Security","Version","AI Assistant"];function hN(){const[e,r]=f.useState("");f.useEffect(()=>{if(window.location.hash!=="#ai-assistant")return;const G=window.setTimeout(()=>{var J;return(J=document.getElementById("ai-assistant"))==null?void 0:J.scrollIntoView({block:"start"})},50);return()=>window.clearTimeout(G)},[]);const[a,i]=f.useState("openrouter"),[l,u]=f.useState("openai-compatible"),[d,p]=f.useState("https://openrouter.ai/api/v1"),[m,y]=f.useState("google/gemma-4-31b-it"),[v,j]=f.useState(""),[x,S]=f.useState(!1),[N,w]=f.useState(!1),[k,C]=f.useState(!1),[E,$]=f.useState(null),[T,F]=f.useState([]),[M,B]=f.useState(!1),[te,Q]=f.useState(null),[_,z]=f.useState(""),V=f.useCallback(G=>{r(G),setTimeout(()=>r(""),3e3)},[]),K=f.useCallback(async(G,J,I)=>{B(!0),Q(null);try{const D=await P.aiModels({provider:G,endpoint:J,...I?{apiKey:I}:{}});D.ok&&D.models.length>0?(F(D.models),Q(`${D.models.length} models available`)):(F([]),Q(D.message||"No models returned — using defaults"))}catch(D){F([]),Q(D instanceof Error?D.message:"Failed to load models")}finally{B(!1)}},[]),le=f.useCallback(async()=>{try{const G=await P.getCredential("ai-config");if(S(G.configured),G.configured&&G.fields){const J=G.fields.provider||"openai-compatible",I=G.fields.endpoint||"";G.fields.provider&&u(J),G.fields.endpoint&&p(I),G.fields.model&&y(G.fields.model),I.includes("openai.com")?i("openai"):I.includes("groq.com")?i("groq"):I.includes("together.xyz")?i("together"):I.includes("openrouter.ai")?i("openrouter"):i("ollama"),I&&K(J,I)}}catch{}},[K]);f.useEffect(()=>{le()},[le]);const me=G=>{i(G),F([]),Q(null),z("");const J=dN[G];J&&(u(J.provider),p(J.endpoint),y(""),K(J.provider,J.endpoint,v||void 0))},we=()=>K(l,d,v||void 0),Ae=async()=>{w(!0);try{await P.setCredential("ai-config",{provider:l,endpoint:d,model:m,...v?{apiKey:v}:{}}),S(!0),V("AI configuration saved!")}catch{V("Failed to save AI config")}finally{w(!1)}},Z=async()=>{C(!0),$(null);try{const G=await P.aiTest({provider:l,endpoint:d,model:m,...v?{apiKey:v}:{}});$(G.ok?`OK: ${G.message}`:`Failed: ${G.message}`)}catch(G){$(`Error: ${G instanceof Error?G.message:"Unknown"}`)}finally{C(!1)}};return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"The connection to your Authority Server, this computer, security, version and your AI assistant."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsx("h2",{className:"su-sec",children:ha[0]}),n.jsx(cN,{}),n.jsx(iN,{}),n.jsx("h2",{className:"su-sec",children:ha[1]}),n.jsx(sN,{}),n.jsx(aN,{}),n.jsx(uN,{}),n.jsx("h2",{className:"su-sec",children:ha[2]}),n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Security"]}),n.jsx("h3",{className:"ob-title",children:"What the gateway does and does not cover"}),n.jsxs("section",{className:"ob-tile",children:[n.jsxs("div",{className:"ob-part",children:[n.jsxs("div",{className:"su-tile-h",children:[n.jsx(go,{}),"What the gateway protects"]}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{className:"ob-part",children:[n.jsx("div",{className:"su-tile-h",children:"Your responsibility"}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]}),n.jsx("h2",{className:"su-sec",children:ha[3]}),n.jsx(lN,{}),n.jsx("h2",{className:"su-sec",id:"ai-assistant",style:{scrollMarginTop:"calc(var(--nav-height) + 1rem)"},children:ha[4]}),n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["AI assistant","Optional",n.jsx("span",{className:`ob-st${x?"":" is-off"}`,children:x?"Set up":"Not set up"})]}),n.jsx("h3",{className:"ob-title",children:"AI Assistant"}),n.jsx("p",{className:"ob-one",children:"Helps you write mandates and the brief. Keys are encrypted in your vault."}),n.jsxs("div",{className:"su-fields",children:[n.jsxs("div",{className:"form-group",children:[n.jsx("label",{className:"form-label",children:"Provider"}),n.jsxs("select",{className:"form-input",value:a,onChange:G=>me(G.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{className:"form-label",children:["API key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:v,onChange:G=>j(G.target.value),onBlur:()=>{v.trim()&&K(l,d,v.trim())},placeholder:x?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.jsx("p",{className:"su-hint",children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("div",{className:"su-label-row",children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"ob-link",onClick:we,disabled:M,title:"Re-fetch the model list from the provider",children:M?"Loading…":"↻ Refresh"})]}),T.length===0?n.jsx("div",{className:"form-input su-placeholder-field",children:M?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const G=T,J=G.includes(m),I=G.length>12,D=_.trim().toLowerCase();let pe=D?G.filter(de=>de.toLowerCase().includes(D)):G;return J&&!pe.includes(m)&&(pe=[m,...pe]),n.jsxs(n.Fragment,{children:[I&&n.jsx("input",{className:"form-input",value:_,onChange:de=>z(de.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:J?m:"__unset__",onChange:de=>y(de.target.value==="__unset__"?"":de.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),pe.map(de=>n.jsx("option",{value:de,children:de},de)),D&&pe.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",_,"”"]})]})]})})(),te&&n.jsx("p",{className:"su-hint",children:te})]})]}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Ae,disabled:N||!m.trim(),title:m.trim()?void 0:"Select a model first",children:N?"Saving...":"Save & Encrypt"}),x&&n.jsx("button",{className:"ob-btn",onClick:Z,disabled:k,children:k?"Testing...":"Test Connection"})]}),E&&n.jsx("div",{className:`alert ${E.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:E}),n.jsx(fN,{})]})]})}function fN(){const[e,r]=f.useState(null),[a,i]=f.useState({intent:"",context:""}),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState(!1),x=f.useCallback(async()=>{if(!v)try{const w=await P.getAIPrompts();r(w),i({intent:w.intent.current,context:w.context.current}),j(!0)}catch(w){p(w instanceof Error?w.message:"Failed to load prompts")}},[v]),S=async w=>{if(e){u(w),p(null);try{const k=a[w],C=k.trim()===e[w].default.trim()?"":k;await P.setAIPrompt(w,C);const E=await P.getAIPrompts();r(E),i({intent:E.intent.current,context:E.context.current}),y(w),setTimeout(()=>y(null),2e3)}catch(k){p(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},N=async w=>{if(confirm(`Revert ${w} prompt to the built-in default?`)){u(w),p(null);try{await P.setAIPrompt(w,"");const k=await P.getAIPrompts();r(k),i({intent:k.intent.current,context:k.context.current})}catch(k){p(k instanceof Error?k.message:"Revert failed")}finally{u(null)}}};return n.jsxs(Gt,{title:"Advanced — AI assistant prompts",summary:"the prompts it sees",onToggle:w=>{w&&x()},children:[n.jsx("p",{children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your Agent Brief). Edit with care — changes apply on the next chat turn."}),d&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:d}),!v&&!d&&n.jsx("p",{className:"ob-lbl",children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(dm,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:w=>i(k=>({...k,intent:w})),onSave:()=>S("intent"),onRevert:()=>N("intent"),saving:l==="intent",justSaved:m==="intent"}),n.jsx(dm,{kind:"context",label:"Agent Brief",description:"Used on the Agent Brief page when refining your brief.",state:e.context,draft:a.context,onChange:w=>i(k=>({...k,context:w})),onSave:()=>S("context"),onRevert:()=>N("context"),saving:l==="context",justSaved:m==="context"})]})]})}function dm({kind:e,label:r,description:a,state:i,draft:l,onChange:u,onSave:d,onRevert:p,saving:m,justSaved:y}){const v=l!==i.current;return n.jsxs("section",{className:"su-prompt",children:[n.jsxs("div",{className:"su-label-row",children:[n.jsxs("div",{children:[n.jsx("div",{className:"su-prompt-h",children:r}),n.jsx("div",{className:"ob-lbl",children:a})]}),i.overridden&&n.jsx("span",{className:"ob-st",children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea su-prompt-text",value:l,onChange:j=>u(j.target.value),rows:12,spellCheck:!1,"aria-label":`${r} system prompt`}),n.jsxs("div",{className:"ob-btns is-inline is-tight",children:[n.jsx("button",{type:"button",className:"ob-btn is-solid",onClick:d,disabled:m||!v,children:m?"Saving…":"Save"}),i.overridden&&n.jsx("button",{type:"button",className:"ob-btn",onClick:p,disabled:m,title:"Discard the override and use the built-in default",children:"Revert to default"})]}),(y||v&&!m)&&n.jsx("p",{className:"ob-lbl ob-gap",children:y?"Saved":"Unsaved changes"}),n.jsxs("details",{className:"ob-raw",children:[n.jsx("summary",{children:"Show built-in default"}),n.jsx("pre",{className:"ob-mono su-prompt-default",children:i.default})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function mN(e){return e.proposalId?"review":"automatic"}function hm(e,r,a={}){const i=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const d of e)i==="pending"&&d.status!=="pending"||a.profile&&d.profileId!==a.profile||u.push({kind:"proposal",id:d.id,sortTimestamp:d.createdAt,commitmentMode:"review",profileId:d.profileId,proposal:d});if(i==="all")for(const d of r){const p=mN(d);!l&&p==="automatic"||a.profile&&d.profileId!==a.profile||u.push({kind:"receipt",id:d.id,sortTimestamp:d.timestamp,commitmentMode:p,profileId:d.profileId,receipt:d})}return u.sort((d,p)=>p.sortTimestamp-d.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}function fm(e){const r=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,[a,i]=f.useState(r);return f.useEffect(()=>{if(typeof window.matchMedia!="function")return;const l=window.matchMedia(e),u=()=>i(l.matches);return u(),l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[e]),a}const pN=["https://","http://"];function Pg(e,r){return e!=null&&e.length?e.flatMap(a=>{const i=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const d=r[u];return typeof d=="string"||typeof d=="number"?String(d):"\0"});return i.includes("\0")||/\{|\}/.test(i)?[]:pN.some(l=>i.toLowerCase().startsWith(l))?[{label:a.label,href:i,description:a.description}]:[]}):[]}function gN(e,r){const a=e-Math.floor(r/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const i=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let d;return i>0?d=`expires in ${i}d ${l}h`:l>0?d=`expires in ${l}h ${u}m`:d=`expires in ${Math.max(1,u)}m`,{label:d,urgent:a<2*3600,expired:!1}}function vN({profileId:e,declared:r}){const{icon:a}=jr(e,r),i=Qj(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(cg,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:i})]}),n.jsx("div",{className:"id-sep"})]})}function yN({proposalId:e,systemName:r}){const[a,i]=f.useState(null);if(f.useEffect(()=>{let u=!0;return i(null),P.getProposalOutcome(e).then(d=>{u&&i(d)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=AS(a,r);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}const xN=15e3;let Fi=null;function jN(){const e=Date.now();return(!Fi||e-Fi.at>xN)&&(Fi={at:e,p:P.getMyReceiptsPage({limit:200}).then(r=>r.receipts).catch(()=>[])}),Fi.p}function wN(e,r,a){var l,u,d,p;let i=null;for(const m of e)m.authorizationId!==r||!Ur(m.timestamp,a)||(!i||m.timestamp>i.timestamp||m.timestamp===i.timestamp&&(((u=(l=m.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=i.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&(i=m);return i}function bN(e,r,a){const i=[];for(const[l,u]of[["daily","today"],["monthly","this month"]]){const d=ou(e,r,a,l);d&&i.push({label:u,text:"limit"in d?`${d.used} of ${d.limit}`:`${d.count} ${d.count===1?"call":"calls"}`})}return i}function kN(e,r,a){const[i,l]=f.useState(void 0);if(f.useEffect(()=>{let d=!0;return l(void 0),jN().then(p=>{d&&l(wN(p,e,Date.now()))}),()=>{d=!1}},[e]),i===void 0)return{state:"loading"};if(i===null)return{state:"none"};const u=bN(i,r,a);return u.length?{state:"ok",lines:u}:{state:"none"}}function SN({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let xc=null;function NN(){return xc||(xc=P.getEnrichedAuthorizations().then(e=>new Map(e.map(r=>[r.authorizationId,r.bounds]))).catch(()=>new Map)),xc}function CN(e){const[r,a]=f.useState(void 0);return f.useEffect(()=>{let i=!0;if(e)return NN().then(l=>{i&&a(l.get(e))}),()=>{i=!1}},[e]),r}function EN(e,r){const[a,i]=f.useState(null),[l,u]=f.useState(!1),[d,p]=f.useState(null);return f.useEffect(()=>{let m=!0;return i(null),p(null),u(!0),(async()=>{var y;try{try{const x=await P.getGateContent(e);if((y=x==null?void 0:x.gateContent)!=null&&y.intent){m&&i(x.gateContent.intent);return}}catch{}const v=await P.getAttestationIntent(e);if(!v){m&&p("Intent not available or you are not an authorized approver.");return}const j=await P.decryptIntent({intentCiphertext:v.intentCiphertext,encryptedKey:v.encryptedKey,approverId:r});m&&i(j)}catch(v){m&&p(v instanceof Error?v.message:"Failed to decrypt intent")}finally{m&&u(!1)}})(),()=>{m=!1}},[e,r]),{intent:a,loading:l,error:d}}function AN(e,r){const a=e.map(l=>({key:`limit:${l.key}`,status:l.ok?"pass":"fail",label:l.label,...l.valueText||l.limitText?{text:`${l.valueText} — your limit ${l.limitText}`.trim()}:{}})),i=(r??[]).map(l=>{const u=l.detail??l.reason;return{key:`check:${l.key}${l.index!==void 0?`:${l.index}`:""}`,status:l.status,label:l.label,...u?{text:u}:{}}});return[...a,...i]}function TN(e){switch(e.status){case"pass":return e.text?`${e.label} — ${e.text}`:e.label;case"fail":return e.text?`${e.label}: ${e.text}`:e.label;case"not_checked":return`${e.label}: not checked${e.text?` — ${e.text}`:""}`;case"notice":return e.text?`${e.label}: ${e.text}`:e.label}}const IN=n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),RN=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function jc({l:e}){if(e.status==="notice")return n.jsxs("div",{className:"check-line check-notice","data-check-status":"notice",children:[IN,n.jsx("span",{children:e.text?n.jsxs(n.Fragment,{children:[n.jsxs("strong",{children:[e.label,":"]})," ",e.text]}):n.jsx("strong",{children:e.label})})]});const r=e.status==="pass"?"✓":e.status==="fail"?"✕":"–";return n.jsxs("div",{className:`check-line check-${e.status.replace("_","-")}`,"data-check-status":e.status,children:[n.jsx("span",{className:"check-mark","aria-hidden":"true",children:r}),n.jsx("span",{children:TN(e)})]})}function mm({lines:e,placement:r}){if(r==="top"){const u=e.filter(d=>d.status==="fail");return u.length===0?null:n.jsx("div",{className:"card-checks card-checks-top","data-testid":"card-checks-top",style:{order:2},children:u.map(d=>n.jsx(jc,{l:d},d.key))})}const a={not_checked:0,notice:1},i=e.filter(u=>u.status==="not_checked"||u.status==="notice").map((u,d)=>({l:u,i:d})).sort((u,d)=>a[u.l.status]-a[d.l.status]||u.i-d.i).map(({l:u})=>u),l=e.filter(u=>u.status==="pass");return i.length===0&&l.length===0?null:n.jsxs("div",{className:"card-checks card-checks-body","data-testid":"card-checks-body",children:[i.length>0&&n.jsx("div",{className:"av3-attention",style:{order:4},children:i.map(u=>n.jsx(jc,{l:u},u.key))}),l.length>0&&n.jsxs("details",{className:"av3-fold",style:{order:11},"data-testid":"checks-passed",children:[n.jsxs("summary",{children:[n.jsxs("span",{className:"h",children:["✓ ",l.length," ",l.length===1?"check":"checks"," passed"]}),n.jsx("span",{className:"one",children:l.map(u=>u.label).join(" · ")}),RN]}),n.jsx("div",{className:"av3-fold-body",children:l.map(u=>n.jsx(jc,{l:u},u.key))})]})]})}function pm(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[a,i]of Object.entries(e))(typeof i=="string"||typeof i=="number")&&(r[a]=i);return r}function $N(e){const r=pm(e.limits),a=pm(e.scope),i=typeof e.intent=="string"?e.intent:"",l={bounds:r,context:a,gateContent:{intent:i}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function Wc(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Wc(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function PN({proposal:e,currentUserId:r,proposalLinks:a,toolDisplay:i,manifests:l,onContentState:u,onShownSnapshot:d,nameOf:p,mandateTitle:m,topExtras:y}){var qe,H,ge,be,X,Ne,ke;const[v,j]=f.useState(!1),[x,S]=f.useState(!1),[N,w]=f.useState(null),k=yn(),{group:C,groupId:E,domain:$}=Nt(),T=Object.entries(e.executionContext),F=Ns(e.profileId),M=CN(e.authorizationId),B=cw(e.tool),{integrationId:te}=Fn(e.tool),Q=wr(te,l),{intent:_,loading:z,error:V}=EN(e.authorizationId,r),K=xa(e),le=K.toolArgs!==null,[me,we]=f.useState([]),Ae=[...Aw(e.executionContext,M,F),...jS(K.toolArgs),...me],Z=f.useMemo(()=>vu(K.toolArgs),[K.toolArgs]),G=f.useCallback(ue=>P.getProposalAttachmentPreview(e.id,ue),[e.id]);f.useEffect(()=>{u==null||u({loading:K.loading,readable:le})},[K.loading,le]);const J=ub(e),I=K.toolArgs?Pg(a,K.toolArgs):[],D=async()=>{if(!E){w("No active workspace; cannot open the mandate screen.");return}S(!0),w(null);try{if(!K.toolArgs){w("This content is not readable on this device yet.");return}const ue=K.toolArgs,He=typeof ue.profile=="string"?ue.profile:"",kt=await P.listProfiles(),ne=fg(He,kt);if(!ne){w(`Unknown profile "${He}".`);return}const xe=await P.getProfile(ne.id),U=$N(ue),ie=pg(U.bounds,xe),Ee=gg(U.context,xe);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ne.id,groupId:E,groupName:(C==null?void 0:C.name)??null,domain:$,isPersonal:!!(C!=null&&C.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...U,bounds:ie,context:Ee})),sessionStorage.setItem("agentReplacesProposal",e.id),k("/mandates/new/intent")}catch(ue){w(ue instanceof Error?ue.message:"Could not open the mandate screen.")}finally{S(!1)}},[pe,de]=f.useState(null),$e=TS(pe),[ve,Y]=f.useState(null),he=AN(Ae,ve==null?void 0:ve.checks);f.useEffect(()=>{ib(e.id,ve)},[e.id,ve]);const[ee,oe]=f.useState(null);f.useEffect(()=>{if(!ve||!ee){d==null||d(null);return}const ue=ve.status==="ok"?ve.readAt:Date.now();d==null||d({readAt:ue,preview:ve,requestContext:ee,...K.toolArgs?{toolArgs:K.toolArgs}:{},sealed:K.sealed})},[ve,ee,K.toolArgs,K.sealed,d]);const{toolName:Oe}=Fn(e.tool),Fe=(X=(be=(ge=(H=(qe=l==null?void 0:l.find(ue=>ue.id===te))==null?void 0:qe.toolGating)==null?void 0:H.overrides)==null?void 0:ge[Oe])==null?void 0:be.sourceFromArg)==null?void 0:X.arg;K.toolArgs&&K.toolArgs;const se=K.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(Ui,{args:K.toolArgs,display:i,heading:"",requestRefArg:Fe}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([ue,He],kt)=>{const{label:ne,hint:xe}=gf(ue,F);return n.jsxs("span",{children:[kt>0&&" · ",n.jsxs("span",{title:xe,children:[ne,"=",Wc(He)]})]},ue)})})]}):null,Te=On(),_e=e.tool===qp,Ve=_e?K.toolArgs:null,Ge=_e?so(Ve,e.profileId):e.profileId,ct=Br(Ge,Te),nt=_e?jr(so(Ve,e.profileId)).testSetup:jr(e.profileId).testSetup||po(e.tool),Je=pp(e.expiresAt,Date.now()),Be=xb(ve&&ve.status==="ok"&&"body"in ve?ve.body.structured:void 0),dt=typeof(Ve==null?void 0:Ve.intent)=="string"&&Ve.intent.trim()?Ve.intent:_e?Be.intent??null:null,et=_e?yb((Ve==null?void 0:Ve.mode)??Be.mode):null,De=_e&&K.toolArgs?Object.fromEntries(Object.entries(K.toolArgs).filter(([ue])=>ue!=="intent"&&ue!=="mode")):K.toolArgs,Ie=De?n.jsx(Ui,{args:De,display:i,heading:"",requestRefArg:Fe}):null,We=m||(F==null?void 0:F.name)||Vt(e.profileId),Qe=kN(e.authorizationId,M,F),ut=Qe.state==="ok"?Qe.lines.map(ue=>`${ue.text} ${ue.label}`).join(" · "):Qe.state==="none"?"none yet today":"",ye=ve?lo(ve,Q,K.toolArgs??void 0).creation:void 0,ze=ve?lo(ve,Q,K.toolArgs??void 0).note:void 0,Ye=e.tool.toLowerCase(),tt=["delete","refund","cancel","revoke"].some(ue=>Ye.includes(ue)),st=typeof((Ne=K.toolArgs)==null?void 0:Ne._imagePreview)=="string"?K.toolArgs._imagePreview:null,ht=_e?"You sign this":"Runs exactly as shown",jt=_e?jb(Be):`${B} · ${En(e.profileId)}${e.profileId.includes("@")?`@${e.profileId.split("@")[1]}`:""}`;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"av3-type",style:{order:0},"data-testid":"approval-type",children:[_e?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Dr,{icon:Jn(Ge)}),ct]}),n.jsx("span",{children:mp(e.createdAt*1e3,Date.now())}),nt&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx("h2",{className:"av3-title",style:{order:1},"data-testid":"approval-summary",children:_e?n.jsxs(n.Fragment,{children:[ct," · ",Kp(ct,Ve).name??"new mandate"]}):Vp(e.tool,K.toolArgs,l,void 0,Op(ve??void 0,K.toolArgs))}),Je&&n.jsx("p",{className:"av3-quiet av3-due",style:{order:1},"data-testid":"approval-deadline",children:Je}),n.jsx(mm,{lines:he,placement:"top"}),y&&n.jsx("div",{className:"av3-extras",style:{order:3},children:y}),n.jsx(mm,{lines:he,placement:"body"}),tt&&n.jsx("div",{className:"av3-attention",style:{order:4},"data-testid":"irreversible-note",children:n.jsxs("div",{className:"check-line check-notice",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),n.jsx("span",{children:n.jsx("strong",{children:"Irreversible action"})})]})}),K.sealed&&K.undecryptable&&n.jsxs("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-undecryptable",children:[n.jsx("strong",{children:"Encrypted for another device."}),n.jsx("p",{children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),K.sealed&&K.loading&&n.jsx("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-decrypting",children:"Decrypting…"}),n.jsxs("section",{className:"av3-sealed",style:{order:6},"data-testid":"sealed-values","aria-labelledby":`sealed-h-${e.id}`,children:[n.jsxs("h3",{id:`sealed-h-${e.id}`,className:"av3-sealed-h",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]}),ht]}),_e&&dt&&n.jsxs("div",{className:"av3-intent","data-testid":"mandate-intent-ai",children:[n.jsx("div",{className:"av3-intent-l",children:"Intent — written by the AI, becomes your words when you sign"}),n.jsx("p",{children:dt})]}),le&&_e&&n.jsxs("div",{className:"av3-edit",children:[n.jsx("button",{type:"button",className:"av3-link","data-testid":"edit-before-signing",onClick:D,disabled:x,children:x?"Opening…":"Edit before signing"}),N&&n.jsx("p",{className:"msg-error",children:N})]}),et&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-mode",children:[n.jsx("dt",{children:et.label}),n.jsx("dd",{children:et.title})]}),st&&n.jsx("img",{src:st,alt:typeof((ke=K.toolArgs)==null?void 0:ke.altText)=="string"?K.toolArgs.altText:"local image preview",className:"av3-image"}),$e&&le&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",children:[n.jsxs("h4",{children:["What will be sent ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),Ie]}),le&&K.toolArgs&&pf(K.toolArgs,i)!==void 0&&n.jsx(SN,{text:pf(K.toolArgs,i)}),le&&n.jsx(bg,{attachments:Z.attachments,inserts:Z.inserts,manifests:l,fetchPreview:G,onChecks:we}),le&&n.jsx(LS,{proposalId:e.id,systemName:Q,toolArgs:K.toolArgs,sealed:K.sealed,systemBoxes:!1,omitKeys:_e?vb:void 0,hideNote:!0,onTone:de,onData:Y}),_e&&(Be.workspace||Be.title)&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-applies-to",children:[Be.workspace&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:Be.workspace})]}),Be.title&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Title"}),n.jsx("dd",{children:Be.title})]})]})]}),ye&&ye.systemBoxes.length>0&&n.jsx("div",{style:{order:7},children:n.jsx(Ng,{view:ye})}),J.length>0&&n.jsxs("p",{className:"av3-quiet",style:{order:7},"data-testid":"proposal-cannot-read",children:["Cannot read this proposal yet: ",J.map(ue=>(p==null?void 0:p(ue))??ue).join(", ")," — shared automatically once they sign in on a device."]}),_e?n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"proposed-through",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Proposed through"}),n.jsxs("span",{className:"one",children:["Delegation",Be.checks[0]?` · ${Be.checks[0]}`:""]}),n.jsx(wc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsxs("p",{children:["Proposed by the AI through your ",n.jsx("strong",{children:"Delegation"})," mandate."]}),Be.checks.length>0&&n.jsx("ul",{className:"av3-plain","data-testid":"mandate-checks",children:Be.checks.map(ue=>n.jsx("li",{children:ue},ue))}),n.jsx(gm,{intent:_,loading:z,error:V,expanded:v,onToggle:()=>j(!v)})]})]}):n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"covered-by",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Covered by"}),n.jsxs("span",{className:"one",children:[We,ut?` · ${ut}`:""]}),n.jsx(wc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{children:n.jsxs(pt,{to:"/mandates",className:"av3-link-strong",children:[We," ›"]})}),Qe.state==="ok"&&n.jsx("dl",{className:"av3-usage",children:Qe.lines.map(ue=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:ue.label}),n.jsx("dd",{children:ue.text})]},ue.label))}),Qe.state==="none"&&n.jsx("p",{className:"av3-quiet",children:"No ticket under this mandate yet today."}),n.jsx(gm,{intent:_,loading:z,error:V,expanded:v,onToggle:()=>j(!v)})]})]}),le&&n.jsx(HS,{proposalId:e.id,layout:"folds",onData:oe}),le&&I.length>0&&n.jsx("div",{className:"av3-links",style:{order:9},children:I.map(ue=>n.jsxs("a",{href:ue.href,target:"_blank",rel:"noopener noreferrer",className:"av3-link-btn",title:ue.description??ue.href,children:[ue.label," ↗"]},ue.label))}),le&&n.jsxs("details",{className:"av3-fold",style:{order:15},"data-testid":"technical-details",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Technical details"}),n.jsx("span",{className:"one",children:jt}),n.jsx(wc,{})]}),n.jsxs("div",{className:"av3-fold-body proposal-args-fold",children:[_e&&(Be.proposal||Be.profileVersion)&&n.jsxs("dl",{className:"av3-usage",children:[Be.proposal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Proposal"}),n.jsx("dd",{children:Be.proposal})]}),Be.profileVersion&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Version"}),n.jsx("dd",{children:Be.profileVersion})]})]}),_e?null:$e?T.length>0&&n.jsx("div",{className:"av3-bound",children:T.map(([ue,He],kt)=>{const{label:ne,hint:xe}=gf(ue,F);return n.jsxs("span",{children:[kt>0&&" · ",n.jsxs("span",{title:xe,children:[ne,"=",Wc(He)]})]},ue)})}):se,ze&&n.jsx("p",{className:"av3-quiet","data-testid":"preview-source-note",children:ze}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),K.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]})]})]})}function wc(){return n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function gm({intent:e,loading:r,error:a,expanded:i,onToggle:l}){return n.jsxs("div",{className:"av3-mintent",children:[n.jsx("div",{className:"av3-quiet",children:"Intent"}),a?n.jsx("p",{className:"msg-error",children:a}):e!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${i?"":" intent-clamped"}`,children:e}),n.jsx("button",{type:"button",className:"av3-link",onClick:l,children:i?"Show less":"Show full intent"})]}):r?n.jsx("p",{className:"av3-quiet",children:"Loading intent…"}):n.jsx("p",{className:"av3-quiet",children:"No intent available for this mandate."})]})}const _N="setup__create_mandate";function _g({proposal:e,currentUserId:r,manifests:a,toolDisplay:i,proposalLinks:l,mandateTitle:u,nameOf:d,topExtras:p,canApprove:m=!0,alreadyDecided:y=!1,decide:v,onDecided:j,nextLabelText:x,onBusyChange:S,className:N}){const w=e.tool===_N,[k,C]=f.useState({t:"idle"}),[E,$]=f.useState(""),[T,F]=f.useState(""),[M,B]=f.useState(!1),[te,Q]=f.useState(!0),_=f.useRef(null),z=async()=>{const G=_.current;if(G)try{const{shownHash:J}=await P.saveShownSnapshot(e.id,G);return J}catch{return}},V=async(G,J)=>{if(!(k.t==="working"||k.t==="done")){if(G==="approve"&&Sp()){F(Np);return}F(""),C({t:"working",kind:G});try{const I=await z(),D=await v({kind:G,note:J,shownHash:I});C({t:"done",kind:G,result:D}),j==null||j(G,D)}catch(I){F(I instanceof Error?I.message:"Failed"),C(G==="change"?{t:"change"}:{t:"idle"})}}},K=()=>{const G=mk(E);if(!G.valid){F(G.error);return}V("change",G.trimmed)},le=f.useRef(null);f.useEffect(()=>{const G=le.current;if(!G)return;const J=I=>{var pe;const D=I.target;!D.open||!((pe=D.classList)!=null&&pe.contains("av3-fold"))||G.querySelectorAll("details.av3-fold[open]").forEach(de=>{de!==D&&(de.open=!1)})};return G.addEventListener("toggle",J,!0),()=>G.removeEventListener("toggle",J,!0)},[]);const me=k.t==="working"||k.t==="done";f.useEffect(()=>(S==null||S(me),()=>{me&&(S==null||S(!1))}),[me]);const we=!y&&!me&&db({loading:M,readable:te}),Ae=w?"Sign mandate":"Approve",Z=`human-only-${e.id}`;return n.jsxs("div",{className:`card av3-card${me?" av3-busy":""}${N?` ${N}`:""}`,"data-testid":"approval-card","data-proposal-id":e.id,"data-phase":k.t,children:[n.jsx("div",{className:"av3-scroll",children:n.jsxs("article",{ref:le,className:"av3-body","aria-hidden":me||void 0,children:[x&&n.jsx("div",{className:"av3-next",role:"status",style:{order:-1},children:x}),n.jsx(PN,{proposal:e,currentUserId:r,proposalLinks:l,toolDisplay:i,manifests:a,nameOf:d,mandateTitle:u,topExtras:p,onContentState:({loading:G,readable:J})=>{B(G),Q(J)},onShownSnapshot:G=>{_.current=G}})]})}),n.jsx("span",{id:Z,className:"sr-only",children:"Only you approve. Never let an AI or a browser it controls open this page or approve for you."}),we&&k.t!=="change"&&n.jsxs("footer",{className:"av3-foot",children:[T&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:T}),n.jsxs("div",{className:`av3-btns${m?"":" av3-btns-two"}`,children:[m&&n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-approve","aria-describedby":Z,onClick:()=>void V("approve"),children:Ae}),n.jsxs("button",{type:"button",className:"av3-btn","data-testid":"btn-change-needed",onClick:()=>{F(""),C({t:"change"})},children:[n.jsx("span",{className:"long",children:"Ask for changes"}),n.jsx("span",{className:"short",children:"Changes"})]}),n.jsx("button",{type:"button",className:"av3-btn","data-testid":"btn-reject",onClick:()=>void V("reject"),children:"Reject"})]})]}),!y&&!me&&k.t==="change"&&n.jsxs("footer",{className:"av3-foot av3-chg",children:[n.jsx("label",{className:"av3-chg-l",htmlFor:`chg-${e.id}`,children:"What should the AI change?"}),n.jsx("textarea",{id:`chg-${e.id}`,"data-testid":"change-note",value:E,maxLength:Dc,rows:3,onChange:G=>$(G.target.value),autoFocus:!0}),T&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:T}),n.jsxs("div",{className:"av3-btns av3-btns-two",children:[n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-send-back",onClick:K,children:"Send to the AI"}),n.jsx("button",{type:"button",className:"av3-btn",onClick:()=>{C({t:"idle"}),F("")},children:"Back"})]})]}),k.t==="working"&&n.jsxs("div",{className:"av3-stamp av3-stamp-wait",role:"status","data-testid":"decision-working",children:[n.jsx("span",{className:"av3-spin","aria-hidden":"true"}),Fw(k.kind,w),"…"]}),k.t==="done"&&n.jsxs("div",{className:"av3-stamp",role:"status","data-testid":"decision-stamp",children:[n.jsx("svg",{className:"av3-check",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"m5 12.5 4.5 4.5L19 7.5"})}),n.jsx("div",{className:"av3-stamp-w",children:Ow(k.kind,w)}),n.jsx("div",{className:"av3-stamp-t",children:zw(k.kind,k.result)})]})]})}async function LN(e,{kind:r,note:a,shownHash:i},l){const u=Sj(e,l.activeDomain),d=await du(e);if(r==="approve"){const m=await P.resolveProposal(e.id,"commit",u,{contentHash:d,shownHash:i});return{ticketId:gp(m.receipt)}}if(r==="reject")return await P.resolveProposal(e.id,"reject",u,{...ig(),contentHash:d,shownHash:i}),{};const{noteEncrypted:p}=await P.encryptProposalNote(a??"",Bp(e,l.userId));return await P.resolveProposal(e.id,"reject",u,{outcome:"change_needed",noteEncrypted:p,contentHash:d,shownHash:i}),{}}function MN(e){const r=e instanceof Error?e.message:"Approval failed";return r.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":r.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":r}async function FN(e,{kind:r,note:a,shownHash:i},l){try{const u=await du(e);if(r==="approve"){const p=await P.approveProposal(e.id,u,i);try{const j=await P.getAttestationIntent(e.authorizationId);if(j){const x=await P.decryptIntent({intentCiphertext:j.intentCiphertext,encryptedKey:j.encryptedKey,approverId:l.userId});await P.storeApprovedIntent(e.authorizationId,x)}}catch{}const{requiredApprovals:m,approvedCount:y}=p,v=m!==void 0&&y!==void 0?m-y:void 0;return{ticketId:gp(p.receipt),...v!==void 0&&v>0?{detail:`${v} more approval${v===1?"":"s"} still needed`}:{}}}if(r==="reject")return await P.rejectProposal(e.id,ig(),u,i),{};const{noteEncrypted:d}=await P.encryptProposalNote(a??"",Bp(e,l.userId));return await P.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:d},u,i),{}}catch(u){throw new Error(MN(u))}}const ON={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},zN={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},vm={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function bc(e){const r=Date.now()-e*1e3,a=r/36e5;return a<48?a<1?`${Math.max(1,Math.round(r/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function DN(e){return e.split("__").pop()??e}function BN(e){const r=e.toLowerCase();return r.includes("delete")||r.includes("refund")||r.includes("cancel")||r.includes("revoke")}function Lg(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Lg(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Mg({proposal:e,manifests:r,toolDisplay:a,proposalLinks:i,currentUserId:l,mandateTitle:u,onDecided:d,nextLabelText:p,onBusyChange:m}){const{domain:y}=Nt();return n.jsx(_g,{proposal:e,currentUserId:l,manifests:r,toolDisplay:a,proposalLinks:i,mandateTitle:u,nextLabelText:p,onBusyChange:m,decide:v=>LN(e,v,{activeDomain:y,userId:l}),onDecided:(v,j)=>d==null?void 0:d(e.id,v,j)})}function UN(e){const{item:r}=e;return r.kind==="proposal"&&r.proposal.status==="pending"?n.jsx(Mg,{proposal:r.proposal,manifests:e.manifests,toolDisplay:e.toolDisplay,proposalLinks:e.proposalLinks,currentUserId:e.currentUserId??"",mandateTitle:e.mandateTitle,onDecided:e.onDecided}):n.jsx(WN,{...e})}function WN({item:e,proposalLinks:r,toolDisplay:a,manifests:i,currentUserId:l}){const u=e.kind==="proposal",d=u?e.proposal.status:"executed",p=u?e.proposal.tool:e.receipt.action,m=DN(p),y=BN(p),{integrationId:v}=Fn(p),j=wr(v,i),x=u&&d==="rejected"?vk(e.proposal,l??""):null,S=u&&d==="refused"?yk(e.proposal):null,N=hb(u?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),w=xa(u?e.proposal:{toolArgs:void 0,content:void 0}),k=u?w.toolArgs:null,C=u?e.proposal.executionContext:e.receipt.executionContext,E=u?null:e.receipt.cumulativeState,$=u&&w.toolArgs?Pg(r,w.toolArgs):[],T=Object.entries(C??{}),F=jr(e.profileId).testSetup||po(p);return n.jsxs("div",{className:"card id-card",children:[n.jsx(vN,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:m}),F&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"automatic"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[u&&d==="pending"&&(()=>{const M=gN(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:M.urgent?600:400,whiteSpace:"nowrap"},children:M.label})})(),n.jsx("span",{"data-testid":x||S?"outcome-kind":void 0,className:`status-badge ${x?vm[x.kind]:S?vm.REFUSED:zN[d]}`,children:x?x.kind:S?S.kind:ON[d]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:bc(e.sortTimestamp)})]})]}),u&&e.proposal.status==="executed"&&n.jsx(yN,{proposalId:e.proposal.id,systemName:j}),x&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",x.who,", ",bc(x.at)]}),(N??x.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[x.kind==="CHANGE NEEDED"?"Change: ":"Note: ",N??x.note]})]}),S&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",bc(S.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",S.message]})]}),y&&n.jsx("div",{className:"note-attention",style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-attention",children:"Irreversible action"})}),u&&typeof(k==null?void 0:k._imagePreview)=="string"&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),n.jsx("img",{src:k._imagePreview,alt:typeof(k==null?void 0:k.altText)=="string"?k.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),n.jsxs(n.Fragment,{children:[$.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:$.map(M=>n.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:M.description??M.href,children:[M.label," ↗"]},M.label))}),u?n.jsxs(n.Fragment,{children:[k&&n.jsx(Ui,{args:k,display:a}),T.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:T.map(([M,B])=>`${M}=${Lg(B)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Sg,{receipt:e.receipt,manifests:i}),e.receipt.proposalId&&n.jsx($g,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:i})]})]}),E&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",E.daily.count," action",E.daily.count===1?"":"s",E.daily.amount>0?`, ${E.daily.amount}`:""," · ","this month: ",E.monthly.count,E.monthly.amount>0?`, ${E.monthly.amount}`:""]}),n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[u?"Proposal":"Ticket",": ",e.id]})]})]})}function HN(e,r=[]){const a=new Map;for(const i of e){const l=i.name&&i.email?`${i.name} (${i.email})`:i.name||i.email||i.id;a.set(i.id,l)}for(const i of r){const l=i.userId??i.id;l&&(i.name&&i.email?a.set(l,`${i.name} (${i.email})`):i.name&&a.set(l,i.name))}return a}function VN(e,r){return e.map(a=>r.get(a)??a)}function Fg(e){var S;const{groupId:r}=Nt(),a=Ns(e.profileId),[i,l]=f.useState(null),[u,d]=f.useState(new Map),[p,m]=f.useState(!0);f.useEffect(()=>{let N=!0;if(!r){m(!1);return}return m(!0),Promise.all([P.getTeamProfileConfig(r,e.profileId).catch(()=>null),P.getGroupById(r).catch(()=>null),P.listUsers().catch(()=>[])]).then(([w,k,C])=>{N&&(l(w),d(HN(C,(k==null?void 0:k.members)??[])))}).finally(()=>{N&&m(!1)}),()=>{N=!1}},[r,e.profileId]);const y=Cj(i??{}),v=VN(e.pendingApprovers??[],u),j=N=>u.get(N)??N,x=i&&((S=a==null?void 0:a.boundsSchema)!=null&&S.fields)?$b(e.executionContext,i,a.boundsSchema.fields):null;return{loading:p,profileConfig:i,requiredApprovals:y,approverNames:v,nameOf:j,aboveCapReason:x}}function Og(e,r){return!!e.createdBy&&!!r&&e.createdBy===r}function zg(e){return(e.pendingApprovers??[]).filter(r=>r!==e.createdBy)}function qN({proposal:e,currentUserId:r,onDecided:a,proposalLinks:i,toolDisplay:l,manifests:u,mandateTitle:d,nextLabelText:p,onBusyChange:m}){const y=zg(e),v=e.approvedBy??{},j=Object.keys(v).length,x=r in v,S=Fg(e),N=Og(e,r),w=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"approver-progress av3-quiet",children:["Needs ",S.requiredApprovals," approval",S.requiredApprovals===1?"":"s"," from:"," ",y.map((k,C)=>n.jsxs("span",{className:`who${k in v?" done":""}`,style:{marginLeft:C===0?"0.25rem":"0.5rem",fontWeight:k in v?600:void 0},children:[k in v?"✓ ":"",S.nameOf(k),k===r?" (you)":"",C<y.length-1?",":""]},k)),S.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",j," of ",S.requiredApprovals,")"]})]}),S.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",children:[n.jsx("b",{children:"Above the team limit:"})," ",n.jsxs("span",{children:[S.aboveCapReason.fieldLabel,S.aboveCapReason.value!==void 0?` ${S.aboveCapReason.value}`:""," (limit ",String(S.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${S.nameOf(e.createdBy)}.`:""]})]}),N&&n.jsx("p",{className:"blocked-note av3-bold","data-testid":"cant-approve-own-action",children:"You can't approve your own action."}),x&&n.jsxs("p",{className:"av3-quiet",children:["You approved this action.",S.requiredApprovals>1&&j<S.requiredApprovals?` Waiting on ${S.requiredApprovals-j} more approval(s).`:""]})]});return n.jsx(_g,{proposal:e,currentUserId:r,manifests:u,toolDisplay:l,proposalLinks:i,mandateTitle:d,nameOf:S.nameOf,nextLabelText:p,onBusyChange:m,topExtras:w,canApprove:!N,alreadyDecided:x,decide:k=>FN(e,k,{userId:r}),onDecided:(k,C)=>a==null?void 0:a(e.id,k,C)})}function KN(){const{domain:e,user:r}=Nt(),a=(r==null?void 0:r.id)??"",[i,l]=f.useState("me"),[u,d]=f.useState([]),[p,m]=f.useState([]),[y,v]=f.useState({}),[j,x]=f.useState(!0),S=f.useCallback(async()=>{try{const U=await P.getProposalsForApprover();d(U)}catch{}finally{x(!1)}},[]);Ke("proposal-added",S),Ke("proposal-approved",S),Ke("proposal-rejected",S),Ke("proposal-resolved",S),Ht(S,3e4);const[N,w]=f.useState([]),[k,C]=f.useState(!0),E=f.useCallback(async()=>{try{const U=await P.getMyProposals(e);w(U)}catch{}finally{C(!1)}},[e]);Ke("proposal-added",E),Ke("proposal-approved",E),Ke("proposal-rejected",E),Ke("proposal-resolved",E),Ke("execution-failed",E),Ht(E,3e4,e);const $=f.useMemo(()=>N.filter(U=>{var ie;return U.status==="pending"&&(((ie=U.pendingApprovers)==null?void 0:ie.length)??0)===0}),[N]),T=f.useMemo(()=>hm($,[],{status:"pending"}),[$]),[F,M]=f.useState([]),B=f.useCallback(async()=>{if(a)try{const ie=(await P.getMyProposals(e)).filter(Ee=>Ee.status==="pending"&&Ee.pendingApprovers&&Ee.pendingApprovers.includes(a)&&Ee.approvedBy&&a in Ee.approvedBy);M(ie)}catch{}},[a,e]);Ke("proposal-approved",B),Ke("proposal-rejected",B),Ht(B,3e4,`${a}:${e}`);const[te,Q]=f.useState([]),_=f.useCallback(async()=>{try{const U=await P.getProposalsCreatedByMe();if(U!==null){Q(U);return}Q(await P.getMyPendingProposals())}catch{}},[]);Ke("proposal-added",_),Ke("proposal-approved",_),Ke("proposal-rejected",_),Ht(_,3e4),f.useEffect(()=>{P.getLabelManifests().then(m).catch(()=>{}),P.getToolDisplay().then(v).catch(()=>{})},[]);const z=U=>{var ie;return(ie=p.find(Ee=>Ee.id===U.split("__")[0]))==null?void 0:ie.proposalLinks};f.useEffect(()=>{S(),E(),B(),_()},[]);const[V,K]=f.useState([]),[le,me]=f.useState([]),[we,Ae]=f.useState(!0),[Z,G]=f.useState("pending"),[J,I]=f.useState(null),[D,pe]=f.useState(!1),de=f.useCallback(async()=>{try{const{proposals:U,receipts:ie}=await P.getThread({domain:e,status:Z,sinceDays:7});K(U),me(ie)}catch{}finally{Ae(!1)}},[e,Z]);Ht(de,3e4,`${e}:${Z}`);const $e=f.useMemo(()=>{const U=new Set;for(const ie of V)U.add(ie.profileId);for(const ie of le)U.add(ie.profileId);return Array.from(U).sort()},[V,le]),ve=f.useMemo(()=>hm(V,le,{status:Z,profile:J??void 0,includeAutonomous:D}),[V,le,Z,J,D]),Y=f.useMemo(()=>{const U=new Set,ie=[];for(const Ee of[...F,...te])U.has(Ee.id)||(U.add(Ee.id),ie.push(Ee));return ie.sort((Ee,it)=>it.createdAt-Ee.createdAt)},[F,te]),[he,ee]=f.useState({});f.useEffect(()=>{P.getMyAttestations().then(U=>{const ie={};for(const Ee of U)Ee.authorization_id&&Ee.title&&(ie[Ee.authorization_id]=Ee.title);ee(ie)}).catch(()=>{})},[]);const[oe,Oe]=f.useState(new Set),Fe=f.useMemo(()=>{const U=[];for(const ie of T)ie.kind==="proposal"&&U.push({id:ie.proposal.id,proposal:ie.proposal,route:"queue"});for(const ie of u)U.some(Ee=>Ee.id===ie.id)||U.push({id:ie.id,proposal:ie,route:"approver"});return U.filter(ie=>!oe.has(ie.id)).sort((ie,Ee)=>ie.proposal.createdAt-Ee.proposal.createdAt)},[T,u,oe]),se=f.useMemo(()=>Fe.map(U=>U.id),[Fe]),Te=f.useRef(se);Te.current=se;const _e=Fe.length,Ve=fm("(min-width: 1400px)"),Ge=fm("(prefers-reduced-motion: reduce)"),[ct]=Ss(),[nt,Je]=f.useState(()=>ct.get("open")),[Be,dt]=f.useState(!1),[et,De]=f.useState(!1),[Ie,We]=f.useState(null),[Qe,ut]=f.useState(null),ye=f.useRef([]);f.useEffect(()=>()=>{ye.current.forEach(U=>window.clearTimeout(U))},[]);const ze=(U,ie)=>{ye.current.push(window.setTimeout(U,ie))},Ye=j||k,tt=f.useRef(null);f.useEffect(()=>{if(!(Ie||Ye)){if(se.length===1&&nt===null&&tt.current!==se[0]){tt.current=se[0],Je(se[0]);return}nt&&!se.includes(nt)&&Je(null)}},[se,nt,Ie,Ye]);const st=!Ye&&!Ie&&se.length===1&&nt===null&&tt.current!==se[0],ht=(Ie==null?void 0:Ie.entry)??(nt?Fe.find(U=>U.id===nt)??null:null),jt=ht&&!Ie?se.indexOf(ht.id):-1,qe=f.useCallback(U=>{ut(null),Je(U)},[]),H=f.useCallback((U,ie,Ee)=>{const it=Te.current,ot=Fe.find(rn=>rn.id===U);if(!ot)return;Oe(rn=>new Set(rn).add(U)),We({entry:ot,before:it}),S(),E(),B(),_(),de(),wf();const zn=()=>{const rn=it.filter(Yt=>Yt!==U),sn=Dw(it,U);We(null),dt(!1),Je(sn),ut(sn?{id:sn,label:Uw(rn,sn)}:null),sn&&ze(()=>ut(Yt=>Yt&&Yt.id===sn?null:Yt),2200)};ze(()=>{if(Ge){zn();return}dt(!0),ze(zn,320)},1100)},[Fe,Ge,S,E,B,_,de]),ge=f.useCallback(()=>{S(),E(),B(),de(),wf()},[S,E,B,de]);f.useEffect(()=>{if(i!=="me"||!nt||Ie||et)return;const U=ie=>{if(ie.metaKey||ie.ctrlKey||ie.altKey)return;const Ee=ie.target;if(Ee&&(Ee.tagName==="TEXTAREA"||Ee.tagName==="INPUT"||Ee.tagName==="SELECT"||Ee.isContentEditable))return;const it=Hw(ie.key);if(!it)return;const ot=Te.current.indexOf(nt);it==="prev"&&ot>0?(ie.preventDefault(),qe(Te.current[ot-1])):it==="next"&&ot>=0&&ot<Te.current.length-1?(ie.preventDefault(),qe(Te.current[ot+1])):it==="list"&&(ie.preventDefault(),qe(null))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[i,nt,Ie,et,qe]);const be=U=>z(U.proposal.tool),X=U=>U.authorizationId?he[U.authorizationId]:void 0,Ne=U=>{const ie=Qe&&Qe.id===U.id?Qe.label:null;return U.route==="queue"?n.jsx(Mg,{proposal:U.proposal,manifests:p,toolDisplay:y[U.proposal.tool],proposalLinks:be(U),currentUserId:a,mandateTitle:X(U.proposal),onDecided:H,nextLabelText:ie,onBusyChange:De},U.id):n.jsx(qN,{proposal:U.proposal,currentUserId:a,manifests:p,toolDisplay:y[U.proposal.tool],proposalLinks:be(U),mandateTitle:X(U.proposal),onDecided:H,nextLabelText:ie,onBusyChange:De},U.id)},ke=n.jsxs("label",{className:"av3-show",children:[n.jsx("span",{children:"Show"}),n.jsxs("span",{className:"av3-select",children:[n.jsx("select",{"data-testid":"queue-view",value:i,onChange:U=>{const ie=U.target.value;l(ie),ie==="all"&&de()},"aria-label":"Show",children:Ww.map(U=>n.jsx("option",{value:U.id,children:U.label},U.id))}),n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4"})})]})]}),ue=n.jsxs("header",{className:"av3-ph",children:[n.jsx("h1",{className:"av3-ph-title",children:"Approvals"}),n.jsx("span",{className:"av3-sp"}),ke]}),He=n.jsxs("header",{className:"av3-ph",children:[!Ve&&n.jsxs("button",{type:"button",className:"av3-back","data-testid":"back-to-list",disabled:et,onClick:()=>qe(null),children:[n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})}),"Approvals ",n.jsx("span",{className:"n",children:_e})]}),n.jsx("span",{className:"av3-sp"}),Ie||et?n.jsx("span",{className:"av3-pos",children:_e>0?`${_e} left`:"none left"}):jt>=0&&se.length>1?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"av3-pos","data-testid":"card-position",children:[jt+1," of ",se.length]}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Previous approval",disabled:jt<=0,onClick:()=>qe(se[jt-1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})})}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Next approval",disabled:jt>=se.length-1,onClick:()=>qe(se[jt+1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})})]}):null]}),kt=n.jsxs("div",{className:"av3-rows",children:[Fe.length>0&&n.jsxs("div",{className:"av3-lh",children:[n.jsxs("span",{children:[Fe.length," waiting for you"]}),n.jsx("span",{children:"oldest first"})]}),Fe.map(U=>n.jsx(Gp,{proposal:U.proposal,manifests:p,titles:he,selected:nt===U.id,onOpen:()=>qe(U.id),who:U.route==="approver"?"Team approval — other people are involved":void 0},U.id))]}),ne=n.jsx("p",{className:"av3-empty","data-testid":"queue-empty",children:"Nothing waiting for you."}),xe=ht&&n.jsx("div",{className:`av3-stage is-open${Ie&&Be?" av3-out":""}${Qe&&Qe.id===ht.id?" av3-in":""}`,"data-testid":Ve?"approval-open":"approval-row","data-proposal-id":ht.id,children:Ne(ht)},ht.id);return n.jsxs("div",{className:`av3-page${Ve?" av3-wide":""}`,"data-view":i,children:[i==="me"&&((Ye||st)&&!Ie?n.jsxs(n.Fragment,{children:[ue,n.jsx("p",{className:"av3-empty",children:"Loading…"})]}):Ve?n.jsxs("div",{className:"av3-split",children:[n.jsxs("section",{className:"av3-pane av3-pane-list","aria-label":"Approvals",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:_e===0?ne:kt})]}),n.jsx("section",{className:"av3-pane av3-pane-card",children:ht?n.jsxs(n.Fragment,{children:[He,n.jsx("div",{className:"av3-cbox",children:xe})]}):_e>0&&n.jsx("p",{className:"av3-empty",children:"Pick an approval from the list."})})]}):ht?n.jsxs("section",{className:"av3-pane","aria-label":"Approval",children:[He,n.jsx("div",{className:"av3-cbox",children:xe})]}):n.jsxs("section",{className:"av3-pane","aria-label":"Approvals",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:_e===0?ne:kt})]})),i==="others"&&n.jsxs("section",{className:"av3-pane","aria-label":"Waiting on others",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:Y.length===0?n.jsx("p",{className:"av3-empty",children:"Nothing is waiting on others."}):n.jsx("div",{className:"av3-stack",children:Y.map(U=>n.jsx(YN,{proposal:U,currentUserId:a,onCancel:async()=>{try{await P.rejectProposal(U.id,{reason:"cancelled by creator"}),B(),E()}catch(ie){alert(ie instanceof Error?ie.message:"Cancel failed")}},onWithdraw:async()=>{const ie=await du(U);await P.withdrawProposal(U.id,void 0,ie),_(),B()}},U.id))})})]}),i==="all"&&n.jsxs("section",{className:"av3-pane","aria-label":"All approvals",children:[ue,n.jsxs("div",{className:"av3-pane-scroll",children:[n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${Z==="pending"?"selected":""}`,onClick:()=>G("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${Z==="all"?"selected":""}`,onClick:()=>G("all"),children:"All"}),$e.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),$e.map(U=>n.jsx("button",{className:`filter-chip ${J===U?"selected":""}`,onClick:()=>I(J===U?null:U),children:Vt(U)},U)),Z==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${D?"selected":""}`,onClick:()=>pe(!D),title:"Include actions that ran without a human review (automatic mode)",children:[D?"✓ ":"","Automatic actions"]})]})]}),we&&ve.length===0?n.jsx("p",{className:"av3-empty",children:"Loading…"}):ve.length===0?n.jsx("p",{className:"av3-empty",children:Z==="pending"?"Nothing waiting for you.":"Nothing here yet."}):n.jsx("div",{className:"av3-stack av3-inline",children:ve.map(U=>n.jsx(UN,{proposalLinks:U.kind==="proposal"?z(U.proposal.tool):void 0,toolDisplay:U.kind==="proposal"?y[U.proposal.tool]:void 0,manifests:p,currentUserId:a,item:U,mandateTitle:U.kind==="proposal"?X(U.proposal):void 0,onDecided:ge},U.id))})]})]})]})}function GN(e){const r=Date.now()-e*1e3,a=Math.floor(r/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const i=Math.floor(r/36e5);return i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function YN({proposal:e,currentUserId:r,onCancel:a,onWithdraw:i}){const[l,u]=f.useState(!1),[d,p]=f.useState(!1),[m,y]=f.useState(""),v=Fg(e),j=Og(e,r),x=zg(e),S=e.approvedBy??{},N=Object.keys(S).length,w=x.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},C=async()=>{p(!0),y("");try{await i()}catch($){y($ instanceof Error?$.message:"Withdraw failed")}finally{p(!1)}},E=jr(e.profileId).testSetup||po(e.tool);return n.jsx("div",{className:"card av3-other",children:n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:GN(e.createdAt)})]}),w&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",v.requiredApprovals," approval",v.requiredApprovals===1?"":"s"," from:"," ",x.map(($,T)=>n.jsxs("span",{className:`who${$ in S?" done":""}`,style:{marginLeft:T===0?"0.25rem":"0.5rem",fontWeight:$ in S?600:void 0},children:[$ in S?"✓ ":"",v.nameOf($),$===r?" (you)":"",T<x.length-1?",":""]},$)),v.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",N," of ",v.requiredApprovals,")"]})]}),v.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[v.aboveCapReason.fieldLabel,v.aboveCapReason.value!==void 0?` ${v.aboveCapReason.value}`:""," (limit ",String(v.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${v.nameOf(e.createdBy)}.`:""]})]}),w&&j&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),w&&j?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:C,disabled:d,children:d?"Withdrawing...":"Withdraw"}),m&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:m})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:k,disabled:l,children:l?"Cancelling...":"Cancel"})})]})})}const JN=`# Agent Brief
84
+ `}),w?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(pt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:$.map(Q=>{const _=Q.profile,z=F(_.id),V=T(_),K=!Q.ready||!V.can,{icon:le}=jr(_.id,{name:_.name});return n.jsxs("div",{className:"card",style:K?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(dg,{icon:le,className:"profile-chip-icon"}),Q.name]}),z?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):i!=null&&i.isPersonal?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:Q.description}),V.can?Q.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>B(_.id,Q.intentHint),children:"Give a mandate"}):Q.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:Q.unavailableReason})]}):n.jsxs(pt,{to:`/integrations?setup=${Q.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",Q.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[V.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:V.fix})]})]})]},Q.key)})})]})}function Wk({domain:e,attested:r}){const a=r===!0?"domain-attested":r===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const hg=200;function Hk(e,r,a=hg){return e.length<a?!0:e.some(i=>!Ur(i.timestamp,r))}function fg(e,r){return e.filter(a=>a.authorizationId===r).sort((a,i)=>i.timestamp-a.timestamp)}function Vk(e){var m,y;const r={},{bounds:a,profile:i,authorizationId:l,nowMs:u}=e;if(!a)return r;const p=fg(e.receipts,l).filter(v=>Ur(v.timestamp,u)).reduce((v,j)=>{var x,S,N,w;return!v||j.timestamp>v.timestamp||j.timestamp===v.timestamp&&(((S=(x=j.cumulativeState)==null?void 0:x.daily)==null?void 0:S.count)??0)>(((w=(N=v.cumulativeState)==null?void 0:N.daily)==null?void 0:w.count)??0)?j:v},null);if(p){const v=fp(p,a,i,"daily"),j=(m=p.cumulativeState)==null?void 0:m.daily;return v&&j&&(r[v.key]=`${v.isAmount?j.amount:j.count} used today`),r}if(!e.coversToday)return r;for(const[v,j]of Object.entries(((y=i==null?void 0:i.boundsSchema)==null?void 0:y.fields)??{})){const x=j.boundType;v in a&&x&&(x.kind==="cumulative_sum"||x.kind==="cumulative_count")&&x.window==="daily"&&(r[v]="0 used today")}return r}const qk=15e3;let hs=null;function Kk(){const e=Date.now();if(!hs||e-hs.at>qk){const r={at:e,p:P.getMyReceiptsPage({limit:hg}).then(a=>({receipts:a.receipts,coversToday:Hk(a.receipts,Date.now())}))};r.p.catch(()=>{hs===r&&(hs=null)}),hs=r}return hs.p}function mg(){const[e,r]=f.useState({state:"loading"});return f.useEffect(()=>{let a=!0;return Kk().then(i=>{a&&r({state:"ok",...i})},()=>{a&&r({state:"failed"})}),()=>{a=!1}},[]),e}function js({icon:e,title:r,text:a,children:i}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:r}),a&&n.jsx("div",{className:"empty-state-text",children:a}),i]})}function Gk(e){const r=Math.floor(e/86400);if(r>=1)return`${r} day${r===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const i=Math.ceil(e/60);return`${i} minute${i===1?"":"s"}`}const Yk=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function Jk({item:e,onClose:r,onSuccess:a}){var $;const{user:i,activeDomain:l,groupId:u}=Nt(),[d,p]=f.useState(null);f.useEffect(()=>{let T=!1;return P.getProfile(e.profile_id).then(F=>{var M;T||p(((M=F==null?void 0:F.ttl)==null?void 0:M.max)??null)}).catch(()=>{}),()=>{T=!0}},[e.profile_id]);const m=e.remaining_seconds??0,y=Yk.filter(T=>T.seconds>m&&(d===null||T.seconds<=d)),v=(($=y[0])==null?void 0:$.seconds)??2592e3,[j,x]=f.useState(v);f.useEffect(()=>{var T;if(d!==null&&j>d){const F=(T=y[y.length-1])==null?void 0:T.seconds;F&&x(F)}},[d]);const[S,N]=f.useState(!1),[w,k]=f.useState(""),C=Object.entries(e.frame).filter(([T])=>T!=="profile"&&T!=="path"),E=async()=>{var T;if(i){N(!0),k("");try{const F=e.authorization_id,M=await P.getGateContent(F);if(!M)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const B=await P.getProfile(e.profile_id),te=e.frame,Q=M.context??{},_=e.attested_domains[0]||l||"owner",z=await Bi(te,B),V=await ng(Q,B),[K,le]=await Promise.all([sg(M.gateContent.intent),tg(B)]);if(!u)throw new Error("No active group; cannot extend mandate.");const me=(((T=e.deferred_commitment_domains)==null?void 0:T.length)??0)>0?"review":"automatic",we=await rg(B),Ae=await P.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:we,supported_versions:[...Bm],bounds:te,bounds_hash:z,scope_hash:V,domain:_,did:i.did,mandate_owners:[{did:i.did}],gate_content_hashes:{intent:K},execution_context_hash:le,group_id:u,commitment_mode:me,ttl:j});await P.pushGateContent(ag(Ae,{boundsHash:z,contextHash:V,context:Q,path:e.path,gateContent:M.gateContent})),a()}catch(F){k(F instanceof Error?F.message:"Extension failed")}finally{N(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:T=>T.target===T.currentTarget&&r(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:r,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Vt(e.profile_id)," / ",e.path]}),C.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:C.map(([T,F])=>`${T}=${F}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),m>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Gk(m),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:y.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):y.map(T=>n.jsx("button",{className:`btn ${j===T.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(T.seconds),style:{minWidth:"3.5rem"},children:T.label},T.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),w&&n.jsx("div",{className:"error-message",children:w})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:r,disabled:S,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:E,disabled:S,children:S?"Extending...":"Extend"})]})]})})}function Gf(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Yf(e){return e.split("@")[1]??""}function Qk(e,r){return Yf(e).localeCompare(Yf(r),void 0,{numeric:!0})>0}function pg(e,r){const a=Gf(e);let i;for(const l of r)Gf(l.id)===a&&(!i||Qk(l.id,i.id))&&(i=l);return i}function gg(e,r){var i;if(!r)return{};const a={};for(const l of r.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(i=r.fields[l])==null?void 0:i.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function vg(e,r){return gg(e,r.boundsSchema)}function yg(e,r){return gg(e,r.scopeSchema)}function Xk(e,r,a){return[...e].sort((i,l)=>{if(a){if(i.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&i.authorization_id!==a)return 1}const u=Vi(i,r),d=Vi(l,r),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[d]?p[u]-p[d]:new Date(l.created_at).getTime()-new Date(i.created_at).getTime()})}function Zk(e,r){const a=(r==null?void 0:r.keyedApprovers)??(r==null?void 0:r.approvers)??[];return e.length===0||a.length===0?!1:e.length!==a.length||e.some(i=>!a.includes(i))||a.some(i=>!e.includes(i))}function eS({item:e,newerProfile:r,area:a,revokedSet:i,expandedHash:l,gateCache:u,gateLoading:d,copiedHash:p,revokingHash:m,copyingHash:y,profileConfigCache:v,mode:j,group:x,ownerLabel:S,isAdmin:N,onExpand:w,onCopyHash:k,onCopy:C,onRevoke:E,onExtend:$,archivedSet:T,archivingHash:F,onArchive:M,highlightHash:B,needsReapprovalSet:te,manifests:Q=[]}){var De;const _=su(e,{revokedSet:i}),z=_==="active"&&((te==null?void 0:te.has(e.authorization_id))??!1),V=Gm(e,{revokedSet:i,archivedSet:T}),K=!S&&!!M&&Km(_),le=l===e.authorization_id,me=u[e.authorization_id],we=_==="active"||_==="pending"||_==="expired",Ae=Object.entries(e.frame).filter(([Ie])=>Ie!=="profile"&&Ie!=="path"),Z=Ns(e.profile_id),G=new Map(sp(e.frame,Z,"limits").map(Ie=>[Ie.key,Ie])),J=Ie=>{var We;return((We=G.get(Ie))==null?void 0:We.label)??Ie},I=(Ie,We)=>{var Qe;return((Qe=G.get(Ie))==null?void 0:Qe.value)??String(We)},D=v.get(e.profile_id)??null,pe=(((De=D==null?void 0:D.approvers)==null?void 0:De.length)??0)>0,de=new Map;if(D!=null&&D.caps&&j==="team")for(const[Ie,We]of Ae){const Qe=D.caps[Ie];typeof Qe=="number"&&Number(We)>Qe&&de.set(Ie,{authorized:Number(We),cap:Qe})}const $e=de.size>0,ve=j==="team"&&Zk(e.approvers_frozen??[],D),Y=Array.from(de.entries()).map(([Ie,We])=>`${Ie}: ${We.authorized} (cap ${We.cap})`).join(", "),he=Array.from(de.entries()).map(([Ie,We])=>`${Ie}: ${We.authorized} → ${We.cap}`).join(", "),ee=$e?pe?de.size===1?`Above team cap: ${Y} — actions require approval`:`Above team cap (${de.size}): ${Y} — actions require approval`:de.size===1?`Reduced by hard cap: ${he}`:`Reduced by hard cap (${de.size}): ${he}`:"",oe=$e?pe?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,Oe=jr(e.profile_id),Fe=Oe.name,se=r?n.jsxs("p",{className:"ob-quiet","data-testid":"mandate-upgrade-hint",children:[n.jsxs("b",{children:[Fe,"@",r.version," available"]}),r.whatsNew?n.jsxs(n.Fragment,{children:[" — ",r.whatsNew]}):null," ","This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]}):null,Te=B!=null&&e.authorization_id===B,_e=e.deferred_commitment_domains.length>0?no.title:ro.title,Ge=Ae.slice(0,3).map(([Ie,We])=>`${J(Ie)} ${I(Ie,We)}`),ct=Ae.length-Ge.length,nt=[_e,...Ge,...ct>0?[`+${ct} more`]:[]].join(" · "),Je=e.created_at?`since ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:null,Be=_==="expired"?Bj(e,_):null,dt=va(),et=f.useRef(null);return f.useLayoutEffect(()=>{var We,Qe;if(!le)return;const Ie=(We=window.matchMedia)==null?void 0:We.call(window,"(prefers-reduced-motion: reduce)").matches;(Qe=et.current)==null||Qe.scrollIntoView({block:"start",behavior:Ie?"auto":"smooth"})},[le]),n.jsxs("div",{ref:et,className:`ob-card mandate-card${le?" is-open":""}${Te?" card-highlight":""}`,"data-testid":"mandate-card",children:[n.jsxs("button",{type:"button",className:"ob-head","aria-expanded":le,onClick:()=>w(e),children:[n.jsx(At,{tag:"Mandate",profileId:e.profile_id,parts:[a,Je,n.jsxs("span",{className:"ob-st",children:[_.charAt(0).toUpperCase()+_.slice(1),Be?` ${new Date(Be.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`:""]},"st"),z?n.jsx("span",{className:"ob-st",title:"The Authority Server no longer accepts mandates signed under this protocol version (since v0.8 every mandate is signed again). Sign it again to keep using it.",children:"Sign again"},"re"):null,Oe.testSetup?"Test setup":null]}),n.jsx("span",{className:"ob-title",children:e.title||Fe}),!le&&n.jsx("span",{className:"ob-one",children:nt})]}),se,S&&n.jsxs("p",{className:"ob-quiet",children:["Owner: ",n.jsx("b",{children:S})]}),(e.required_domains.length>1||e.missing_domains.length>0)&&n.jsx("div",{className:"ob-badges",children:e.required_domains.map(Ie=>n.jsx(Wk,{domain:Ie,attested:e.attested_domains.includes(Ie)},Ie))}),$e&&n.jsx("p",{className:"ob-quiet ob-bold",title:oe,"data-testid":"mandate-cap-note",children:ee}),ve&&n.jsx("p",{className:"ob-quiet",children:n.jsx("button",{type:"button",className:"ob-link",onClick:()=>C(e),disabled:y===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:y===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})}),le&&n.jsxs("div",{ref:dt,className:"ob-open","data-testid":"mandate-open",children:[n.jsxs("section",{className:"ob-tile","data-testid":"mandate-signed",children:[n.jsxs("div",{className:"ob-tile-h",children:[n.jsx(go,{}),"You signed this"]}),n.jsxs("div",{className:"ob-part",children:[n.jsxs("div",{className:"ob-lbl",children:["Intent — your words",e.created_at?`, signed ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:""]}),d===e.authorization_id?n.jsx("p",{className:"ob-quiet",children:"Loading gate content..."}):me?n.jsx("p",{className:"ob-intent","data-testid":"mandate-intent",children:me.gateContent.intent}):n.jsx("p",{className:"ob-quiet",children:"Gate content not available."})]}),n.jsxs("dl",{className:"ob-kv ob-part",children:[n.jsx("dt",{children:"Commitment"}),n.jsx("dd",{children:_e}),(e.earliest_expiry||_==="revoked")&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Valid"}),n.jsx("dd",{children:_==="revoked"?"revoked":_==="expired"?`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} — expired`:`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}, or until you revoke it`})]}),Ae.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Limits"}),n.jsx("dd",{children:n.jsx(tS,{item:e,boundsEntries:Ae,limitLines:G,limitLabel:J,limitValue:I,aboveCapByKey:de,hasApprovers:pe,profile:Z})})]}),(me==null?void 0:me.context)&&Object.keys(me.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Scope"}),n.jsx("dd",{children:Object.entries(me.context).map(([Ie,We])=>n.jsx("div",{title:String(We),children:ig(Ie,We,me.contextLabels)},Ie))})]}),n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:j==="team"&&x?`${x.name} (team)`:"Personal"})]})]}),!S&&n.jsx(nS,{item:e,manifests:Q}),n.jsx(Gt,{title:"Technical details",summary:e.created_at?`created ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:void 0,testId:"mandate-technical",children:n.jsxs("dl",{className:"ob-kv",children:[e.created_at&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Created"}),n.jsx("dd",{children:new Date(e.created_at).toLocaleString()})]}),n.jsx("dt",{children:"Mandate id"}),n.jsxs("dd",{className:"ob-mono",children:[e.authorization_id," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>k(e.authorization_id),children:p===e.authorization_id?"copied":"copy"})]}),n.jsx("dt",{children:"Profile"}),n.jsx("dd",{className:"ob-mono",children:e.profile_id})]})}),n.jsxs("div",{className:"ob-btns",children:[!S&&(_==="active"||_==="pending")&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e,{asEdit:!0}),disabled:y===e.authorization_id,title:z?"The Authority Server no longer accepts mandates signed under this protocol version. Sign again opens the signing pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:z?"Sign again":"Edit"}),!S&&we&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>$(e),children:"Extend"}),!S&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e),disabled:y===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:y===e.authorization_id?"Copying…":"Copy"}),S&&N&&_!=="revoked"?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id,S,Fe),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):!S&&(_==="active"||_==="pending")?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):null,K&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>M(e.authorization_id,!V),disabled:F===e.authorization_id,title:V?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:F===e.authorization_id?V?"Unarchiving…":"Archiving…":V?"Unarchive":"Archive"})]})]})]},e.authorization_id)}function tS({item:e,boundsEntries:r,limitLines:a,limitLabel:i,limitValue:l,aboveCapByKey:u,hasApprovers:d,profile:p}){const m=mg(),y=m.state==="ok"?Vk({receipts:m.receipts,coversToday:m.coversToday,authorizationId:e.authorization_id,bounds:e.frame,profile:p,nowMs:Date.now()}):{};return n.jsx("dl",{className:"ob-kv ob-sub","data-testid":"mandate-limits",children:r.map(([v,j])=>{var S;const x=u.get(v);return n.jsxs(f.Fragment,{children:[n.jsx("dt",{title:(S=a.get(v))==null?void 0:S.hint,children:i(v)}),n.jsx("dd",{children:x?d?n.jsxs("span",{title:`Team cap on ${v} is ${x.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${x.authorized}.`,children:[l(v,j)," ",n.jsxs("span",{className:"ob-quiet-inline",children:["↑ approval at ",x.cap]})]}):n.jsxs("span",{title:`Team cap on ${v} is ${x.cap} with no approvers configured (hard cap). Authorized for ${x.authorized}; effective ${x.cap}.`,children:[n.jsx("s",{children:l(v,j)})," → ",x.cap]}):l(v,j)}),n.jsx("dd",{className:"ob-use",children:y[v]??""})]},v)})})}function nS({item:e,manifests:r}){const a=mg(),i=a.state==="ok"?fg(a.receipts,e.authorization_id):[],l=i.filter(d=>Ur(d.timestamp,Date.now())).length,u=a.state==="loading"?"loading…":a.state==="failed"?"could not load":i.length===0?"none in the latest tickets":`${i.length} recent${l>0?` · ${l} today`:""}`;return n.jsxs(Gt,{title:"Tickets under this mandate",summary:u,testId:"mandate-tickets",children:[n.jsx("p",{className:"ob-lbl",children:"From the latest tickets signed on this account."}),a.state==="failed"&&n.jsx("p",{children:"Tickets could not be loaded. Try again shortly."}),a.state==="ok"&&i.length===0&&n.jsx("p",{children:"No action has run under this mandate in the latest tickets."}),i.slice(0,5).map(d=>n.jsxs("p",{className:"ob-ticket-row",children:[n.jsx(pt,{to:"/tickets",className:"ob-link-strong",children:ys(d,r)}),n.jsxs("span",{className:"ob-quiet-inline",children:[" · ",ma(d.timestamp,Date.now())]})]},d.id)),i.length>0&&n.jsx("p",{children:n.jsx(pt,{to:"/tickets",className:"ob-link-strong",children:"All tickets ›"})})]})}function rS(){const[e,r]=f.useState([]),[a,i]=f.useState(!0),[l,u]=f.useState([]),[d,p]=f.useState(!1),[m,y]=f.useState(new Map),[v,j]=f.useState("mine"),[x,S]=f.useState("active"),[N,w]=f.useState(null),[k,C]=f.useState(null),[E,$]=Ss(),[T,F]=f.useState(()=>E.get("new")==="1"),[M]=f.useState(()=>E.get("profile")),[B,te]=f.useState(()=>E.get("highlight")),[Q,_]=f.useState(null),[z,V]=f.useState({}),[K,le]=f.useState(null),[me,we]=f.useState(null),[Ae,Z]=f.useState(null),[G,J]=f.useState(new Set),[I,D]=f.useState(null),[pe,de]=f.useState(new Set),[$e,ve]=f.useState(null),[Y,he]=f.useState(null),[ee,oe]=f.useState(new Set),Oe=yn(),{group:Fe,groupId:se,domain:Te,mode:_e,activeTeam:Ve}=Nt(),Ge=(Ve==null?void 0:Ve.isAdmin)===!0,[ct,nt]=f.useState(()=>new Map),[Je,Be]=f.useState([]);f.useEffect(()=>{P.getLabelManifests().then(Be).catch(()=>{})},[]);const dt=f.useCallback(()=>{i(!0),P.getMyAttestations().then(r).catch(()=>{}).finally(()=>i(!1))},[]),et=f.useCallback(()=>{P.getArchivedMandates().then(ne=>de(new Set(ne))).catch(()=>{})},[]);f.useEffect(()=>{et()},[et]);const De=f.useCallback(()=>{P.getEnrichedAuthorizations().then(ne=>oe(new Set(ne.filter(xe=>xe.needsReapproval).map(xe=>xe.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{De()},[De]);const Ie=async(ne,xe)=>{ve(ne);try{const U=await P.setMandateArchived(ne,xe);de(new Set(U)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(U){alert(U instanceof Error?U.message:"Failed to update archive")}finally{ve(null)}},We=f.useCallback(()=>{se&&(p(!0),P.listTeamAuthorizations(se).then(u).catch(()=>{}).finally(()=>p(!1)))},[se]);Ke("attestation-changed",()=>{dt(),Ge&&se&&We(),De()}),f.useEffect(()=>{if(!B)return;E.get("highlight")&&(E.delete("highlight"),$(E,{replace:!0}));const ne=window.setTimeout(()=>te(null),3e3);return()=>window.clearTimeout(ne)},[]),Ht(dt,3e5),f.useEffect(()=>{v==="team"&&Ge&&se&&l.length===0&&!d&&We()},[v,Ge,se,l.length,d,We]),f.useEffect(()=>{let ne=!1;return P.listProfiles().then(xe=>{if(ne)return;const U=it=>it.replace(/@.*$/,"").split("/").pop()??it,ie=it=>it.split("@")[1]??"",Ee=new Map;for(const it of xe){const ot=U(it.id),zn=Ee.get(ot);(!zn||ie(it.id).localeCompare(ie(zn.id),void 0,{numeric:!0})>0)&&Ee.set(ot,it)}y(Ee)}).catch(()=>{}),()=>{ne=!0}},[]);const Qe=f.useCallback(ne=>{const xe=ot=>ot.replace(/@.*$/,"").split("/").pop()??ot,U=ot=>ot.split("@")[1]??"",ie=m.get(xe(ne));if(!ie)return;const Ee=U(ne),it=U(ie.id);if(!(!Ee||!it))return it.localeCompare(Ee,void 0,{numeric:!0})>0?ie:void 0},[m]),ut=f.useCallback(ne=>Qn(ne,[...m.values()]),[m]);f.useEffect(()=>{if(_e!=="team"||!se)return;const ne=v==="mine"?e:l;if(ne.length===0)return;const xe=[...new Set(ne.map(U=>U.profile_id))].filter(U=>!ct.has(U));if(xe.length!==0){nt(U=>{const ie=new Map(U);for(const Ee of xe)ie.set(Ee,null);return ie});for(const U of xe)Promise.all([P.getTeamProfileConfig(se,U),P.getApproversPubkeys(se,U).catch(()=>null)]).then(([ie,Ee])=>{const it=ie&&Ee?{...ie,keyedApprovers:Ee.map(ot=>ot.userId)}:ie;nt(ot=>new Map(ot).set(U,it))}).catch(()=>{})}},[e,l,v,se,_e,ct]);const ye=async ne=>{if(Q===ne.authorization_id){_(null);return}_(ne.authorization_id);const xe=ne.authorization_id;if(!(xe in z)){le(ne.authorization_id);try{const U=await P.getGateContent(xe);V(ie=>({...ie,[xe]:U}))}catch{V(U=>({...U,[xe]:null}))}finally{le(null)}}},ze=ne=>{navigator.clipboard.writeText(ne).then(()=>{Z(ne),setTimeout(()=>Z(null),2e3)})},Ye=async(ne,xe)=>{var U;if(!se){alert("No active group; cannot copy mandate.");return}he(ne.authorization_id);try{const ie=ne.authorization_id;let Ee=z[ie]??null;ie in z||(Ee=await P.getGateContent(ie),V(In=>({...In,[ie]:Ee})));const it=Object.fromEntries(Object.entries(ne.frame).filter(([In])=>In!=="profile"&&In!=="path")),ot=(Ee==null?void 0:Ee.context)??{},zn=((U=Ee==null?void 0:Ee.gateContent)==null?void 0:U.intent)??"",rn=ne.deferred_commitment_domains.length>0?"review":"automatic",sn=ne.attested_domains[0]||Te||"owner",Yt=Date.parse(ne.created_at),br=ne.earliest_expiry?Date.parse(ne.earliest_expiry):NaN,bo=Number.isFinite(Yt)&&Number.isFinite(br)&&br>Yt?Math.round((br-Yt)/1e3):void 0;let ja=ne.profile_id,wa=it,Tn=ot,Cs;const ba=await P.listProfiles(),Wr=pg(ne.profile_id,ba);if(Wr&&Wr.id!==ne.profile_id){const In=await P.getProfile(Wr.id);ja=Wr.id,wa=vg(it,In),Tn=yg(ot,In),Cs=ne.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ja,groupId:se,groupName:(Fe==null?void 0:Fe.name)??null,domain:sn,isPersonal:!!(Fe!=null&&Fe.isPersonal),upgradedFromProfileId:Cs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:wa,context:Tn,gateContent:{intent:zn},templateMode:rn,templateTtl:bo})),xe!=null&&xe.asEdit?sessionStorage.setItem("agentEditReplaces",ne.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Oe("/mandates/new/intent")}catch(ie){alert(ie instanceof Error?ie.message:"Failed to copy mandate")}finally{he(null)}},tt=async(ne,xe,U)=>{const ie=xe&&U?`Revoke ${xe}'s ${U} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(ie)){D(ne);try{await P.revokeAttestation(ne),J(Ee=>new Set(Ee).add(ne)),P.resyncGates().catch(()=>{}),xe&&se&&We()}catch(Ee){alert(Ee instanceof Error?Ee.message:"Failed to revoke mandate")}finally{D(null)}}},st=v==="mine"?e:l,ht=v==="mine"?a:d,jt=v==="mine"?{revokedSet:G,archivedSet:pe}:{revokedSet:G},qe=ne=>Vi(ne,jt),H={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ne of st)H[qe(ne)]+=1;const ge=v==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],be=(()=>{const ne=new Map;for(const xe of st){if(qe(xe)!==x)continue;const U=En(xe.profile_id),ie=ne.get(U);ie?ie.count+=1:ne.set(U,{shortId:U,icon:Jn(xe.profile_id),name:ut(xe.profile_id),count:1})}return[...ne.values()].sort((xe,U)=>xe.name.localeCompare(U.name))})(),X=be.reduce((ne,xe)=>ne+xe.count,0),Ne=Xk(st.filter(ne=>{if(qe(ne)!==x||N!==null&&En(ne.profile_id)!==N)return!1;if(k!==null){const xe=ne.deferred_commitment_domains.length>0;if(k==="review"&&!xe||k==="auto"&&xe)return!1}return!0}),jt,B),ke=f.useMemo(()=>{const ne=new Map;for(const xe of Ne){const U=En(xe.profile_id);let ie=ne.get(U);ie||(ie={shortId:U,icon:Jn(xe.profile_id),name:ut(xe.profile_id),items:[]},ne.set(U,ie)),ie.items.push(xe)}return[...ne.values()].sort((xe,U)=>U.items.length-xe.items.length||xe.name.localeCompare(U.name))},[Ne,ut]),ue=f.useCallback(ne=>[...new Set(Je.filter(xe=>{var U;return xe.profile===ne||Object.values(((U=xe.toolGating)==null?void 0:U.overrides)??{}).some(ie=>(ie==null?void 0:ie.profile)===ne)}).map(xe=>xe.name))],[Je]),He={revokedSet:G,expandedHash:Q,gateCache:z,gateLoading:K,copiedHash:Ae,revokingHash:I,copyingHash:Y,profileConfigCache:ct,mode:_e,activeDomain:Te,group:Fe,groupId:se,onExpand:ye,onCopyHash:ze,onCopy:Ye,onRevoke:tt,onExtend:we,highlightHash:B,manifests:Je},kt={...He,archivedSet:pe,archivingHash:$e,onArchive:Ie,needsReapprovalSet:ee};return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>F(!0),children:"+ New mandate"})]}),T&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{F(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),$(E,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:ne=>ne.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{F(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),$(E,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),n.jsx(Uk,{onDismiss:()=>F(!1),preselectProfileId:M})]})]})}),Ge&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${v==="mine"?" active":""}`,onClick:()=>{j("mine"),S("active"),w(null),C(null),_(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${v==="team"?" active":""}`,onClick:()=>{j("team"),S("active"),w(null),C(null),_(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:ge.map(ne=>n.jsxs("button",{className:`nav-tab${x===ne?" active":""}`,onClick:()=>{S(ne),w(null),C(null)},children:[ne.charAt(0).toUpperCase()+ne.slice(1)," (",H[ne],")"]},ne))}),X>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(pu,{areas:be,selected:N,onSelect:w,totalCount:X}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(ne=>{const xe=k===ne;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${ne}`,"aria-selected":xe,onClick:()=>C(xe?null:ne),children:ne==="auto"?"Automatic":"Review"},ne)})})]}),ht&&st.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ne.length===0?n.jsx(js,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:ke.map(ne=>n.jsxs("section",{"data-testid":"mandate-area","data-area":ne.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(Dr,{icon:ne.icon}),n.jsx("b",{children:ne.name}),n.jsxs("span",{className:"meta",children:[ne.items.length," mandate",ne.items.length===1?"":"s",ue(ne.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",ue(ne.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:ne.items.map(xe=>{const U=v==="team"?xe:null,ie=U!=null&&U.owner?U.owner.name??U.owner.email??U.owner.userId:void 0;return n.jsx(eS,{item:xe,newerProfile:Qe(xe.profile_id),area:ne.name,ownerLabel:ie,isAdmin:Ge,...v==="mine"?kt:He},xe.authorization_id)})})]},ne.shortId))}),me&&n.jsx(Jk,{item:me,onClose:()=>we(null),onSuccess:()=>{we(null),dt()}})]})}function xg(e){const r=e.approved?e.proposalArgs:e.sentArgs;return yb(e.tool,r??null,e.manifests)??e.label}function sS(e){if(e.offDevice)return{level:"off-device"};const r=e.sentArgs??e.proposalArgs,a=r?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:r?aS(e.boundContent,r):null,argsCheck:a}:r?{level:"recorded",content:r,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function aS(e,r){const a={};for(const[i,l]of Object.entries(r))(typeof e=="string"?l===e:i in e)||(a[i]=l);return Object.keys(a).length>0?a:null}function jg(e,r,a){return rp(e,r).map(i=>{var l;return{...i,inTicket:oS(i.value,(l=r==null?void 0:r.executionMapping)==null?void 0:l[i.key],a)}})}function iS(e,r){if(String(e)===String(r))return!0;if(typeof e=="boolean"||typeof r=="boolean"||e===""||r===""||e===null||r===null)return!1;const a=Number(e),i=Number(r);return Number.isFinite(a)&&Number.isFinite(i)&&a===i}function oS(e,r,a){return!r||!a||e===void 0||e===null?!1:(typeof r=="string"?[{field:r}]:Array.isArray(r)?r:[r]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:iS(e,u)})}function vc(e){return e==null?"—":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):q0(e)}function lS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Jf(e,r){return Object.entries(e).filter(([a,i])=>!lS(i)&&!(r&&a in r&&vc(r[a])===vc(i))).map(([a,i])=>({key:a,label:zt(a),value:vc(i)}))}function cS(e,r){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Jf(a,r)};const i=e.text.trim();if(i.startsWith("{"))try{const l=JSON.parse(i);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Jf(l,r)}}catch{}return{kind:"text",text:e.text}}const Qf=new Map;function uS(e){let r=Qf.get(e);return r||(r=P.getProposal(e).catch(()=>null),Qf.set(e,r)),r}let fs=null;function dS(e){if(!fs||e*1e3>fs.fetchedAtMs){const r={fetchedAtMs:Date.now(),map:P.getTicketHeadlines().catch(()=>(fs===r&&(fs=null),{}))};fs=r}return fs.map}function hS({proposal:e,tool:r,manifests:a,label:i}){const l=xa(e);return n.jsx(n.Fragment,{children:xg({tool:r,manifests:a,label:i,approved:!0,proposalArgs:l.toolArgs})})}function fS({ticketId:e,timestamp:r,proposalId:a,tool:i,manifests:l,label:u}){const[d,p]=f.useState(null),[m,y]=f.useState(null);return f.useEffect(()=>{let v=!0;return p(null),y(null),a?uS(a).then(j=>{v&&p(j)}):dS(r).then(j=>{v&&y(j[e]??null)}),()=>{v=!1}},[a,e,r]),a?d?n.jsx(hS,{proposal:d,tool:i,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:xg({tool:i,manifests:l,label:u,approved:!1,sentArgs:m})})}function ps({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"preview-table-wrap",children:n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(r=>n.jsx("th",{children:r.label},r.key))})}),n.jsx("tbody",{children:e.rows.map((r,a)=>n.jsx("tr",{children:r.cells.map((i,l)=>n.jsx("td",{className:i.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:i.valueTitle,children:i.value},l))},a))})]})}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}const mS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function pS(e,r){return typeof r!="string"?!1:/^data:image\//i.test(r)?!0:mS.test(e)?/^https?:\/\//.test(r):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(r)}function Mr(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xf({row:e,which:r}){const a=Ns(e.profileRef),i=sp(e.value,a,r);return i.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:i.map(l=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function gS({row:e}){const r=Ns(e.profileRef),a=(r==null?void 0:r.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(r==null?void 0:r.name)??Vt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function wg({row:e,altText:r}){if(e.kind==="list"||e.kind==="object"){const a=$p(e.value);if(a&&"table"in a)return n.jsx(ps,{table:a.table});if(a)return n.jsx(n.Fragment,{children:a.text})}switch(e.kind){case"profile":return n.jsx(gS,{row:e});case"profile-limits":return n.jsx(Xf,{row:e,which:"limits"});case"profile-scope":return n.jsx(Xf,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Mr(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,i)=>n.jsx("li",{children:Mr(a)},i))}):n.jsx(n.Fragment,{children:Mr(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Mr(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Mr(e.value)});default:return pS(e.key,e.value)?n.jsx("img",{src:e.value,alt:r??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Mr(e.value)})}}function Ui({args:e,display:r,heading:a="Details",requestRefArg:i}){const l=rp(e,r);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(d=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:d.hint,children:d.key===i?"Replying to":d.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:d.key===i?n.jsx("span",{"data-testid":"request-ref",title:Mr(d.value),children:"the message shown under Request"}):n.jsx(wg,{row:d,altText:u})})]},d.key))})]})}function vS(e){const r=f.useMemo(()=>typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof Blob>"u"?z0(e):URL.createObjectURL(new Blob([B0(e)],{type:e.contentType})),[e.contentBase64,e.contentType]);return f.useEffect(()=>()=>{r.startsWith("blob:")&&URL.revokeObjectURL(r)},[r]),r}function bg({doc:e,systemName:r,heading:a,sourceLine:i,trailingNote:l}){const u=vS(e),d=D0(e.pages),p=r?`Rendered by ${r}`:"Rendered",m=n.jsxs(n.Fragment,{children:[p," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),d&&n.jsx("div",{className:"preview-note",children:d}),i&&n.jsx("div",{className:"preview-note",children:i}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ap(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??m})]})]})]})}const yS="_attachmentsSealed";function xS(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.filename=="string"&&typeof r.contentType=="string"&&typeof r.sha256=="string"&&typeof r.bytes=="number"}function jS(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.placeholder=="string"&&typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.value=="string"}function gu(e){const r={attachments:[],inserts:[]};if(!e)return r;const a=e[yS];if(a===null||typeof a!="object")return r;const i=a,l=Array.isArray(i.attachments)?i.attachments.filter(xS):[],u=Array.isArray(i.inserts)?i.inserts.filter(jS):[];return{attachments:l,inserts:u}}function wS(e){return!Number.isFinite(e)||e<0?"—":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function bS(e){return gu(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function kg(e,r,a,i){var u,d,p;const l=(p=(d=(u=e==null?void 0:e.find(m=>m.id===r))==null?void 0:u.documents)==null?void 0:d[a])==null?void 0:p.label;if(l)return l.replace(/\{id\}/g,i)}function kS(e,r){return!e||!r||r==="loading"?null:r.status==="ok"?{key:"attachment-same-file",label:`same file as ${e}`,ok:!0,valueText:"",limitText:""}:r.status==="changed"?{key:"attachment-same-file",label:"attachment changed since it was sealed",ok:!1,valueText:"",limitText:""}:null}function SS({a:e,manifests:r,preview:a}){const i=wr(e.connector,r),l=kg(r,e.connector,e.kind,e.id),u=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"src-tag-value src-tag-system-cell",children:["from ",i]}),l?n.jsxs(n.Fragment,{children:[" — ",l]}):null]});return a&&a!=="loading"&&a.status==="ok"?n.jsx(bg,{doc:{filename:a.filename,contentType:a.contentType,contentBase64:a.contentBase64,sha256:a.sha256},heading:"Attachment",sourceLine:u,trailingNote:null}):n.jsxs("div",{className:"document-preview-box","data-testid":"attachment-sealed",children:[n.jsx("h4",{children:"Attachment"}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),n.jsx("div",{className:"preview-note",children:wS(e.bytes)}),n.jsx("div",{className:"preview-note",children:u}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ap(e.sha256)})]}),!a||a==="loading"?n.jsx("div",{className:"preview-note",children:"Loading preview…"}):a.status==="changed"?n.jsx("p",{className:"preview-note","data-testid":"attachment-changed",style:{color:"var(--check-failed)",fontWeight:700},children:"✕ changed since it was sealed"}):n.jsx("div",{className:"preview-note",children:"Preview not available."})]})]})}function NS({i:e,manifests:r}){const a=wr(e.connector,r);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function Sg({attachments:e,inserts:r,manifests:a,fetchPreview:i,onChecks:l}){const[u,d]=f.useState({});return f.useEffect(()=>{if(!i)return;let p=!0;for(const m of e)d(y=>y[m.sha256]?y:{...y,[m.sha256]:"loading"}),i(m.sha256).then(y=>{p&&d(v=>({...v,[m.sha256]:y}))}).catch(()=>{p&&d(y=>({...y,[m.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{p=!1}},[e.map(p=>p.sha256).join(","),i]),f.useEffect(()=>{if(!l)return;const p=e.map(m=>kS(kg(a,m.connector,m.kind,m.id),u[m.sha256])).filter(m=>m!==null);l(p)},[e,a,u,l]),e.length===0&&r.length===0?null:n.jsxs(n.Fragment,{children:[e.map(p=>n.jsx(SS,{a:p,manifests:a,preview:u[p.sha256]},`${p.connector}:${p.kind}:${p.id}`)),r.map(p=>n.jsx(NS,{i:p,manifests:a},`${p.placeholder}:${p.connector}:${p.kind}:${p.id}`))]})}let Mi=null;function CS(){return Mi||(Mi=P.getToolDisplay().catch(()=>(Mi=null,{}))),Mi}function Ng({args:e,display:r,executionContext:a,sealed:i}){const l=jg(e,r,a);return l.length===0?null:n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:l.map(u=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:i?"is-sealed":void 0,children:[n.jsx(wg,{row:u}),u.inTicket&&n.jsx("span",{className:"ob-quiet-inline",title:"This value is also in the signed ticket",children:" · also in the ticket"})]})]},u.key))})}function Zf({content:e,display:r,executionContext:a,sealed:i}){return typeof e=="string"?n.jsx("p",{className:`ob-text${i?" is-sealed":""}`,children:e}):n.jsx(Ng,{args:e,display:r,executionContext:a,sealed:i})}function em({check:e}){return e==="match"?n.jsx("p",{className:"ob-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match what this gateway executed"})]}):n.jsx("p",{className:"ob-quiet",children:"Could not be checked against this gateway's execution record."})}function ES({view:e,display:r,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-quiet",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsxs("p",{className:"ob-quiet",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("section",{className:"ob-tile ob-sealed is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{className:"ob-tile-h",children:[n.jsx(go,{}),"Sealed in the ticket"]}),n.jsx(Zf,{content:e.bound,display:r,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match the fingerprint in the signed ticket — this local copy was changed"})]}),e.extras&&jg(e.extras,r,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ob-lbl ob-gap",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(Ng,{args:e.extras,display:r,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(em,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-lbl ob-after-h",children:"Recorded by this gateway — not sealed in the ticket"}),n.jsx(Zf,{content:e.content,display:r,executionContext:a,sealed:!1}),n.jsx(em,{check:e.check})]})}const tm=5;function AS({result:e,systemName:r,sent:a}){const i=cS(e,a),[l,u]=f.useState(!1),d=e.ok?i.kind==="rows"?`what ${r} answered · ${i.rows.length} value${i.rows.length===1?"":"s"}`:`what ${r} answered`:"the action failed";return n.jsxs(Gt,{title:"Result",summary:d,testId:"ticket-result",attrs:{"data-ok":e.ok?"true":"false"},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway from ",r]}),!e.ok&&n.jsx("p",{className:"ob-check",children:n.jsx("b",{children:"The action failed."})}),i.kind==="rows"?n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:(l?i.rows:i.rows.slice(0,tm)).map(p=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:p.label}),n.jsx("dd",{className:"is-system",children:p.value})]},p.key))}):n.jsx("p",{className:"ob-text is-system",children:i.text}),i.kind==="rows"&&i.rows.length>tm&&n.jsx("button",{type:"button",className:"ob-link",onClick:()=>u(p=>!p),children:l?"Show less":`Show all ${i.rows.length}`}),e.truncated&&n.jsx("p",{className:"ob-quiet",children:"Shortened to fit what this device keeps."})]})}function nm(e){var a;const r=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const i of r)if(i&&typeof i=="object"&&!Array.isArray(i))return i;return null}function Cg({receipt:e,manifests:r}){var N;const[a,i]=f.useState(void 0),[l,u]=f.useState(null),[d,p]=f.useState(void 0),m=!!(e.contentHash&&e.contentBinding);f.useEffect(()=>{let w=!0;return CS().then(k=>{w&&p(k[e.action])}),()=>{w=!1}},[e.action]),f.useEffect(()=>{let w=!0;return i(void 0),u(null),(async()=>{let k;try{k=await P.getArchivedReceipt(e.id)}catch{w&&i(null);return}let C=null;const E=k==null?void 0:k.entry.boundContent;if(E!==void 0&&m)try{C=await zp(e.contentBinding.kind,E)===e.contentHash}catch{C=!1}w&&(u(C),i(k))})(),()=>{w=!1}},[e.id,e.contentHash,e.contentBinding,m]);const y=f.useCallback(w=>P.getReceiptAttachmentPreview(e.id,w),[e.id]);if(a===void 0)return n.jsx("div",{className:"ob-sent ob-quiet","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const v=(N=a==null?void 0:a.entry.proposal)==null?void 0:N.toolArgs,j=sS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:v&&typeof v=="object"&&!Array.isArray(v)?v:void 0,hasHashToCheck:m,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=wr(Fn(e.action).integrationId,r),S=gu((a?nm(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(ES,{view:j,display:d,executionContext:e.executionContext}),n.jsx(Sg,{attachments:S.attachments,inserts:S.inserts,manifests:r,fetchPreview:y}),(a==null?void 0:a.result)&&n.jsx(AS,{result:a.result,systemName:x,sent:nm(a)})]})}const rm=500;function Wi(e){return e.length>rm?`${e.slice(0,rm)}…`:e}function sm(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function TS(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function lo(e,r,a){var i;switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${r}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${r}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${Wi(e.message)}`:"Preview not available."};case"refused":return{heading:`Refused by ${r}`,note:e.message?Wi(e.message):`${r} refused to answer.`};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${Wi(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e){const p=sb(a??{},e.reads,e.display,{readAt:e.readAt});return{heading:`What will be ${((i=e.display)==null?void 0:i.verb)??"created"} in ${r}`,note:$S(p)?`Values marked from the system were read by the gateway, not by the AI — read at ${TS(e.readAt)}.`:"",creation:p}}const l=Pp(e.body,{fields:e.fields}),u={heading:`From ${r}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:l},d=e.version;if(d&&(u.versionNote=`You approve ${d.field} ${d.approved}; if it changes, ${r} refuses it.`,d.stale)){const p=J0(e.body,d.currentBody,{fields:e.fields,excludeKey:d.field});u.stale={heading:`A newer ${d.field} exists (${d.current})`,approvedLabel:`${sm(d.field)} ${d.approved}`,currentLabel:`${sm(d.field)} ${d.current}`,...p.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:p.approved,currentRendered:p.current}}}return u}}}function IS(e,r){if(e.state!=="failed")return null;const a=e.detail?Wi(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${r} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${r}`,note:`${r} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function RS(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function $S(e){return e.sections.length>0?!0:e.rows.some(r=>r.kind==="identity"?!!r.identity.name:r.kind==="compare"?r.lines.some(a=>a.now!=="—"):r.kind==="table"?r.table.rows.some(a=>a.cells.some(i=>!i.sealed&&i.value!=="—"&&i.value!=="")):!1)}function am({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function PS({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(r=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:r.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:r.valueTitle,children:r.value})]},r.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((r,a)=>n.jsx("div",{style:r.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:r.kind==="add"?{fontWeight:600}:void 0,children:r.text||" "},a))}):e.table?n.jsx(ps,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((r,a)=>{var i;return n.jsx("div",{title:(i=e.lineTitles)==null?void 0:i[a],children:r},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function Bc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(r=>r.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(am,{row:r}),n.jsx(ps,{table:r.table})]},r.key):n.jsxs(f.Fragment,{children:[n.jsx(am,{row:r}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(PS,{row:r})})]},r.key))})}function yc({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(Bc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(Bc,{rows:e.moreFields})]})]})}function _S({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.filter(r=>!r.table).map(r=>{var a,i;return n.jsxs("span",{children:[" · ",r.label," ",r.value??((a=r.lines)==null?void 0:a.join(", "))??((i=r.sublist)==null?void 0:i.map(l=>l.value).join(", "))]},r.key)})})]})}function LS({view:e,systemName:r}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(a=>a.kind==="table"||a.kind==="compare"?null:n.jsxs(f.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:a.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:a.kind==="identity"?n.jsx(_S,{identity:a.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:a.valueTitle,children:a.value})})]},a.key))}),e.rows.map(a=>a.kind==="compare"&&n.jsxs("table",{className:"compare-table","data-testid":"compare-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),n.jsxs("th",{children:["Now (from ",r??"the system",")"]}),n.jsx("th",{children:"New"})]})}),n.jsx("tbody",{children:a.lines.map(i=>n.jsxs("tr",{children:[n.jsx("td",{className:"compare-label",children:i.label}),n.jsx("td",{className:"compare-now",children:i.now}),n.jsx("td",{className:"compare-new",children:i.next})]},i.key))})]},a.key)),e.rows.flatMap(a=>a.kind==="identity"?a.identity.context.filter(i=>i.table).map(i=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:i.label}),n.jsx(ps,{table:i.table})]},`${a.key}.${i.key}`)):[]),e.rows.filter(a=>a.kind==="table").map(a=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:a.label}),n.jsx(ps,{table:a.table})]},a.key)),e.sections.map((a,i)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(bg,{doc:a.document,systemName:r}):n.jsxs(n.Fragment,{children:[n.jsxs("h5",{children:[a.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),a.table&&n.jsx(ps,{table:a.table}),a.body&&n.jsx(Bc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},i))]})}function Eg({view:e}){return e.systemBoxes.length===0?null:n.jsx(n.Fragment,{children:e.systemBoxes.map(r=>n.jsxs("div",{className:"system-box","data-testid":"system-box",children:[n.jsx("div",{className:"system-box-heading",children:r.heading}),n.jsx("dl",{children:r.rows.map(a=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:a.label}),n.jsx("dd",{children:a.value})]},a.key))}),n.jsx("p",{className:"system-box-note",children:"Shown for this decision only. It is asked again when this is saved; that answer is stored."})]},r.key))})}function MS(e,r){if(!(r!=null&&r.length)||e.status!=="ok"||!("body"in e)||!e.body.structured)return e;const a=Object.fromEntries(Object.entries(e.body.structured).filter(([i])=>!r.includes(i)));return{...e,body:{...e.body,structured:a},...e.fields?{fields:e.fields.filter(i=>!r.includes(i))}:{}}}function Ag({resp:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l=!0,omitKeys:u,hideNote:d=!1}){const p=MS(e,u),m=lo(p,r,a??void 0),y=p.status==="ok"?m.stale?"stale":"ok":p.status;return y==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:m.note}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`preview-box preview-box-${y}`,"data-testid":"approval-preview","data-preview-status":y,children:[n.jsxs("h4",{children:[m.heading,m.creation&&(i?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),m.creation&&n.jsx(LS,{view:m.creation,systemName:r}),m.rendered&&n.jsx(yc,{rendered:m.rendered}),m.note&&!d&&n.jsx("p",{className:"preview-note",children:m.note}),m.versionNote&&!m.stale&&n.jsx("p",{className:"preview-note",children:m.versionNote}),m.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:m.stale.heading}),m.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:m.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:m.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(yc,{rendered:m.stale.approvedRendered})}),n.jsx("dt",{children:m.stale.currentLabel}),n.jsx("dd",{children:n.jsx(yc,{rendered:m.stale.currentRendered})})]})]})]}),l&&m.creation&&n.jsx(Eg,{view:m.creation})]})}function FS({proposalId:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d,onTone:p,onData:m}){const[y,v]=f.useState(null),[j,x]=f.useState(!1);return f.useEffect(()=>{let S=!0;return v(null),x(!1),P.getProposalPreview(e).then(N=>{S&&v(N)}).catch(()=>{S&&x(!0)}),()=>{S=!1}},[e]),f.useEffect(()=>{if(j){p==null||p("unavailable"),m==null||m({status:"unavailable",reason:"connector_error"});return}if(!y){m==null||m(null);return}const S=lo(y,r,a??void 0);p==null||p(y.status==="ok"?S.stale?"stale":"ok":y.status),m==null||m(y)},[y,j,r,p,m]),j?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):y?n.jsx(Ag,{resp:y,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",r,"…"]})}const xc=6;function co(e){if(!e)return;const r=Date.parse(e);return Number.isNaN(r)?e:new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function OS(e){if(!e)return{first:""};const r=e.split(`
85
+ `);return r.length<=xc?{first:e}:{first:r.slice(0,xc).join(`
86
+ `),more:r.slice(xc).join(`
87
+ `)}}const zS="Linked by the AI",DS="linked automatically — this action already carried a reference to it";function Tg(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:r,more:a}=OS(e.body),i=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,co(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:zS,...e.implicit?{implicitNote:DS}:{},metaLine:i.join(" · "),title:e.title,bodyFirst:r,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:co(l.at)}))}}const da="Read by the gateway — same customer, not matched to this request";function BS(e){const r=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${r})`}function US(e){var l;const r=!!e.aiWritten,a=r?"Activity":e.type??e.kind??"Entry";let i;if(r){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?co(new Date(e.aiWritten.at).toISOString()):void 0;i=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else i=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:co(e.at),title:e.title,body:e.body,attribution:i,aiWritten:r}}function Ig(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:da,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:da,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:da,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const r=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>US(l)),a=e.matches.map(BS),i=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return r.length===0?{state:"empty",label:da,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:i}:{state:"ok",label:da,note:"",matchNotes:a,items:r,unreachableNote:i}}function Rg({req:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:e.implicitNote}),e.metaLine&&n.jsx("p",{className:"au10-req-meta",children:e.metaLine}),e.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:e.title})}),e.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:e.bodyFirst}),e.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:e.bodyMore})]}),e.attribution&&n.jsx("p",{className:"au10-req-attrib",children:e.attribution}),e.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",e.chain.length,")"]}),e.chain.map((r,a)=>n.jsxs("div",{className:"au10-chain-item",children:[(r.author||r.at)&&n.jsxs("p",{className:"au10-req-meta",children:[r.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:r.author})]}):null,r.author&&r.at?" · ":"",r.at]}),r.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:r.title})}),r.body&&n.jsx("p",{className:"au10-req-quote",children:r.body}),r.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",r.author,", not checked"]})]},a))]})]})}function $g({hist:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.matchNotes.map((r,a)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:r},a)),n.jsx("ul",{className:"au10-hist-list",children:e.items.map((r,a)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[r.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),r.headLabel]}),n.jsx("span",{children:r.at})]}),r.title&&n.jsx("div",{className:"au10-hist-title",children:r.title}),r.body&&n.jsx("div",{className:"au10-hist-body",children:r.body}),n.jsx("p",{className:"au10-hist-attrib",children:r.attribution})]},a))}),e.unreachableNote&&n.jsx("p",{className:"preview-note",children:e.unreachableNote})]})}function Pg({resp:e}){const r=Tg(e.request),a=Ig(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("h4",{children:["Request",r.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:r.tag})]}),n.jsx(Rg,{req:r})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),n.jsx($g,{hist:a})]})]})}const im=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function WS(e){if(e.state!=="ok")return e.note;const r=e.items.length,a=e.items[0];return`${r} ${r===1?"entry":"entries"}${a!=null&&a.at?` · latest ${a.at}`:""}`}function HS(e){return e.state!=="ok"?e.note??"":e.title??e.metaLine??""}function VS({resp:e}){const r=Tg(e.request),a=Ig(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("details",{className:"av3-fold",style:{order:12},"data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Request"}),n.jsx("span",{className:"one",children:HS(r)}),im]}),n.jsxs("div",{className:"av3-fold-body",children:[r.tag&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-ai",style:{marginLeft:0},children:r.tag})}),n.jsx(Rg,{req:r})]})]}),n.jsxs("details",{className:"av3-fold",style:{order:13},"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"History"}),n.jsx("span",{className:"one",children:WS(a)}),im]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-system",style:{marginLeft:0},children:a.label})}),n.jsx($g,{hist:a})]})]})]})}function qS({proposalId:e,onData:r,layout:a="boxes"}){const[i,l]=f.useState(null),[u,d]=f.useState(!1);return f.useEffect(()=>{let p=!0;return l(null),d(!1),P.getProposalRequestContext(e).then(m=>{p&&l(m)}).catch(()=>{p&&d(!0)}),()=>{p=!1}},[e]),f.useEffect(()=>{r==null||r(u?null:i)},[i,u,r]),u||!i?null:a==="folds"?n.jsx(VS,{resp:i}):n.jsx(Pg,{resp:i})}function KS(e,r,a){const i=Object.entries(e??{});if(i.length===0)return{entry:void 0,otherCount:0};const u=i.find(([,p])=>p.by===r)??(a?i.find(([p])=>p===`domain:${a}`):void 0),d=u?i.length-1:i.length;return{entry:u==null?void 0:u[1],otherCount:d}}function GS(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function YS(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function JS(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function _g({proposalId:e,tool:r,manifests:a}){const{user:i,domain:l}=Nt(),[u,d]=f.useState(null),[p,m]=f.useState(null),[y,v]=f.useState(!1);if(f.useEffect(()=>{let F=!0;return d(null),m(null),v(!1),Promise.all([P.getShownSnapshot(e),P.getProposal(e)]).then(([M,B])=>{F&&(d(M),m(B))}).catch(()=>{F&&v(!0)}),()=>{F=!1}},[e]),y||!u||!p)return null;const j=u.status==="off_device",{entry:x,otherCount:S}=KS(p.shownHashes,(i==null?void 0:i.id)??"",l),N=GS({offDevice:j,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),w=YS(S);if(j)return n.jsx(Gt,{title:"What you saw",summary:"only on the approving gateway",testId:"au10-shown",attrs:{"data-shown-status":"off-device"},children:n.jsx("p",{className:"ob-quiet",children:"Only on the approving gateway — this device has no local copy."})});const{snapshot:k}=u,{integrationId:C}=Fn(r),E=wr(C,a),$=JS(k.readAt),T=N==="verified"?`read ${$} · verified`:N==="mismatch"?`read ${$} · does not match what was approved`:`read ${$}`;return n.jsxs(Gt,{title:"What you saw",summary:T,testId:"au10-shown",attrs:{"data-shown-status":N},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway at ",$,", kept on this device — not read again now."]}),n.jsx(Ag,{resp:k.preview,systemName:E,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(Pg,{resp:k.requestContext}),N==="verified"&&n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint recorded with your approval."}),N==="mismatch"&&n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"This copy differs from the fingerprint recorded with your approval."})]}),N==="unchecked"&&n.jsx("p",{className:"ob-quiet",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),w&&n.jsx("p",{className:"ob-quiet","data-testid":"au10-shown-others",children:w})]})}function QS({receipt:e,manifests:r,localAuth:a,localUnavailable:i,signature:l,grantTitle:u,ownerLabel:d,spUrl:p,formatDate:m,onOpenComplete:y,isNew:v=!1,defaultOpen:j=!1}){const x=Ns(e.profileId),S=Ew(e,x),N=Aw(a==null?void 0:a.context,x),w=Tw(e,(a==null?void 0:a.bounds)??e.limits,x),k=a==null?void 0:a.intent,C=jr(e.profileId).testSetup||po(e.action),[E,$]=f.useState(!1),[T,F]=f.useState(j),M=Date.now(),B=On(),te=Br(e.profileId,B),Q=yo(e.action,r),_=va(),z=u||Rw(e.profileId),V=ma(e.timestamp,M),K=lu(e.id);return n.jsxs("div",{className:`ob-card ticket-obj-card${v?" is-new":""}${T?" is-open":""}`,"data-new":v?"true":"false","data-testid":"ticket-card",children:[n.jsxs("button",{type:"button",className:"ob-head ticket-obj-head","aria-expanded":T,onClick:()=>F(le=>!le),children:[n.jsx(At,{tag:"Ticket",profileId:e.profileId,className:"obj-line",parts:[te,`via ${Q}`,V,n.jsx("span",{className:"ob-st",children:Yi(e)?"Approved":"Automatic"},"st"),C?"Test setup":null,v?n.jsx("span",{className:"ob-st","aria-label":"new since your last visit",children:"New"},"new"):null]}),n.jsxs("span",{className:"ob-title receipt-what",children:[te," · ",n.jsx("span",{"data-testid":"ticket-headline",children:n.jsx(fS,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:r,label:ys(e,r)})})]}),l==="valid"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="valid-legacy"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · issued before protocol 0.7 · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="invalid"&&n.jsxs("span",{className:"ob-check ob-check-x",title:"The stored ticket does not match what was signed.",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("b",{children:["Signature check failed · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l!=="valid"&&l!=="valid-legacy"&&l!=="invalid"&&n.jsxs("span",{className:"ob-one",children:["Ticket ",n.jsx("span",{className:"ob-mono",children:K})]}),S&&n.jsx("span",{className:"ob-one receipt-scope",children:S})]}),T&&n.jsxs("div",{ref:_,className:"ob-open",children:[n.jsx(Cg,{receipt:e,manifests:r}),e.proposalId&&n.jsx(_g,{proposalId:e.proposalId,tool:e.action,manifests:r}),n.jsxs(Gt,{title:"Mandate",summary:[z,w].filter(Boolean).join(" · "),testId:"ticket-mandate",children:[n.jsxs("p",{className:"ob-lbl",children:[k||N?"Name, allowed values and intent: from this device.":"Name: from this device.",w?" Use: sealed in the ticket.":""]}),n.jsxs("dl",{className:"ob-kv receipt-rows",children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:z}),d&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Owner"}),n.jsx("dd",{children:d})]}),N&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Allowed"}),n.jsx("dd",{children:N})]}),w&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Used"}),n.jsx("dd",{className:"receipt-num",children:w})]}),n.jsx("dt",{children:"Intent"}),n.jsx("dd",{className:"ob-plain",children:k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${E?"":" intent-clamped"}`,children:k})," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>$(!E),children:E?"Show less":"Show full intent"})]}):n.jsx("span",{className:"receipt-absent",children:i?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]})]}),n.jsxs(Gt,{title:"Technical details",summary:`ticket ${K} · ${m(e.timestamp)}`,testId:"ticket-technical",children:[n.jsx("p",{className:"ob-lbl",children:"Read from the signed ticket."}),n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Ticket"}),n.jsx("dd",{className:"ob-mono",children:e.id}),n.jsx("dt",{children:"Issued"}),n.jsx("dd",{className:"receipt-when",children:m(e.timestamp)}),n.jsx("dt",{children:"Action"}),n.jsx("dd",{className:"ob-mono",children:e.action})]}),n.jsxs("details",{className:"ob-raw receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"ob-mono receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([le,me])=>`${le}=${me}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]}),n.jsxs("div",{className:"ob-btns receipt-foot",children:[n.jsx("button",{type:"button",className:"ob-btn receipt-evidence-link",onClick:y,children:"Complete ticket"}),p&&n.jsxs("a",{className:"ob-btn receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",title:"Redacted, shareable",children:["Public link ↗",n.jsx("span",{className:"ob-btn-q",children:" · redacted"})]})]})]})]})}function XS({receipt:e,onClose:r}){const[a,i]=f.useState(null),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(!0),[v,j]=f.useState(!1);f.useEffect(()=>{let k=!1;return y(!0),P.getArchivedReceipt(e.id).then(C=>{k||(i(C),u(C?"local":"authority-server"),p((C==null?void 0:C.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||y(!1)}),()=>{k=!0}},[e.id]);const x=a?a.entry:{receipt:e},S=JSON.stringify(x,null,2);function N(){const k=URL.createObjectURL(new Blob([S],{type:"application/json"})),C=document.createElement("a");C.href=k,C.download=`suveren-ticket-${e.id.slice(0,8)}.json`,C.click(),URL.revokeObjectURL(k)}async function w(){try{await navigator.clipboard.writeText(S),j(!0),setTimeout(()=>j(!1),2e3)}catch{j(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:k=>k.target===k.currentTarget&&r(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:r,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[d==="valid"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),d==="valid-legacy"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),d==="invalid"&&n.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:m?"Loading…":l==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),n.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:N,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:w,children:v?"Copied":"Copy"})]})]})})}function ZS(e){return new Date(e*1e3).toLocaleString()}function eN(e,r){if(r==="all")return!0;const a=r==="1d"?1:r==="7d"?7:30,i=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=i}function tN(e,r,a){const i=r.trim().toLowerCase();return i?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(i)):!0}function om(e,r){const a=new Map(e.map(i=>[i.id,i]));for(const i of r)a.set(i.id,i);return[...a.values()].sort((i,l)=>l.timestamp-i.timestamp)}function nN(){const{activeTeam:e,groupId:r}=Nt(),a=(e==null?void 0:e.isAdmin)===!0,[i,l]=f.useState("mine"),[u,d]=Ss(),p=Pw(u.get("filter")),m=H=>{const ge=new URLSearchParams(u);H==="all"?ge.delete("filter"):ge.set("filter",H),d(ge,{replace:!0})},y=Xm(u.get("area")),v=H=>{const ge=new URLSearchParams(u);H===null?ge.delete("area"):ge.set("area",H),d(ge,{replace:!0})},j=On(),[x,S]=f.useState(null),N=f.useRef(!1),[w,k]=f.useState([]),[C,E]=f.useState([]),[$,T]=f.useState(""),[F,M]=f.useState(!0),[B,te]=f.useState({}),[Q,_]=f.useState(new Set),[z,V]=f.useState(""),[K,le]=f.useState(new Set),[me,we]=f.useState("all"),[Ae,Z]=f.useState(!1),[G,J]=f.useState(!1),[I,D]=f.useState(null),[pe,de]=f.useState({}),[$e,ve]=f.useState(!1),[Y,he]=f.useState({}),[ee,oe]=f.useState({}),[Oe,Fe]=f.useState(null),[se,Te]=f.useState(null),[_e,Ve]=f.useState(!1),[Ge,ct]=f.useState(!1),nt=f.useRef(""),Je=f.useCallback(H=>i==="team"&&a&&r?P.listTeamReceiptsPage(r,{before:H,limit:200}):P.getMyReceiptsPage({before:H,limit:200}),[i,a,r]),Be=f.useCallback(()=>{const H=i==="team"?`team:${r}`:"mine",ge=nt.current!==H;nt.current=H,M(!0),ct(!1),Je().then(be=>{k(X=>ge?be.receipts:om(X,be.receipts)),Te(X=>ge?be.nextBefore:X??be.nextBefore)}).catch(()=>{ge&&k([]),ct(!0)}).finally(()=>M(!1))},[Je,i,r]),dt=f.useCallback(()=>{!se||_e||(Ve(!0),ct(!1),Je(se).then(H=>{k(ge=>om(ge,H.receipts)),Te(H.nextBefore)}).catch(()=>ct(!0)).finally(()=>Ve(!1)))},[se,_e,Je]);Ht(Be,12e4);const et=f.useCallback(()=>{Be(),x!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markTicketsSeen(Date.now()).catch(()=>{}))},[Be,x]);Ke("ticket-recorded",et),f.useEffect(()=>{F||N.current||(N.current=!0,P.getLastSeenTicketsAt().then(H=>(S(H),P.markTicketsSeen(Date.now()))).catch(()=>S(Number.POSITIVE_INFINITY)))},[F]),f.useEffect(()=>{P.getLabelManifests().then(E).catch(()=>{}),fetch("/health").then(H=>H.json()).then(H=>{typeof H.spUrl=="string"&&T(H.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{P.getLocalAuthorizations().then(({authorizations:H,signatures:ge})=>{de(H),he(ge),ve(!1)}).catch(()=>{de({}),he({}),ve(!0)}),P.getMyAttestations().then(H=>{const ge={};for(const be of H)be.authorization_id&&be.title&&(ge[be.authorization_id]=be.title);oe(ge)}).catch(()=>{})},[]),f.useEffect(()=>{i!=="team"||Object.keys(B).length>0||P.listUsers().then(H=>{const ge={};for(const be of H)ge[be.id]={name:be.name,email:be.email};te(ge)}).catch(()=>{})},[i,B]);const De=f.useMemo(()=>{const H=new Set;for(const ge of w)H.add(ge.action);return[...H].sort()},[w]),Ie=f.useMemo(()=>{if(i!=="team")return[];const H=new Set;for(const ge of w)ge.userId&&H.add(ge.userId);return[...H].map(ge=>{var be;return{id:ge,label:(be=B[ge])!=null&&be.name?`${B[ge].name} (${B[ge].email})`:ge}}).sort((ge,be)=>ge.label.localeCompare(be.label))},[i,w,B]),We=f.useMemo(()=>w.filter(H=>!(!tN(H,z,[Qn(H.profileId,j),ys(H,C),wr(Fn(H.action).integrationId,C),H.authorizationId?ee[H.authorizationId]:null])||K.size>0&&!K.has(H.action)||Q.size>0&&H.userId&&!Q.has(H.userId)||!eN(H,me))),[w,z,j,C,ee,K,Q,me]),Qe=f.useMemo(()=>{const H={automatic:0,approved:0,all:0};for(const ge of We)H.all+=1,H[Ji(ge,"approved")?"approved":"automatic"]+=1;return H},[We]),ut=f.useMemo(()=>We.filter(H=>Ji(H,p)),[We,p]),ye=f.useMemo(()=>{const H=new Map;for(const ge of ut){const be=En(ge.profileId),X=H.get(be);X?X.count+=1:H.set(be,{shortId:be,icon:Jn(ge.profileId),name:Qn(ge.profileId,j),count:1})}return[...H.values()].sort((ge,be)=>ge.name.localeCompare(be.name))},[ut,j]),ze=f.useMemo(()=>ut.filter(H=>Zm(H.profileId,y)),[ut,y]),Ye=f.useMemo(()=>x===null?0:ze.filter(H=>Qi(H,x)).length,[ze,x]),tt=K.size>0||Q.size>0||me!=="all";function st(H){le(ge=>{const be=new Set(ge);return be.has(H)?be.delete(H):be.add(H),be})}function ht(H){_(ge=>{const be=new Set(ge);return be.has(H)?be.delete(H):be.add(H),be})}function jt(){le(new Set),_(new Set),we("all"),V("")}async function qe(){J(!0),D(null);try{const{bundle:H,filename:ge}=await P.fetchEvidenceBundle(),be=URL.createObjectURL(new Blob([JSON.stringify(H,null,2)],{type:"application/json"})),X=document.createElement("a");X.href=be,X.download=ge,X.click(),URL.revokeObjectURL(be);const Ne=H.sources??{};Ne.authorityServer?Ne.local||D(`Downloaded Authority Server history only — ${Ne.localError??"local archive unavailable."}`):D(`Downloaded local evidence only — ${Ne.asError??"Authority Server export unavailable."}`)}catch(H){D(`Export failed: ${H instanceof Error?H.message:String(H)}`)}finally{J(!1)}}return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ye>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ye," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:qe,disabled:G,children:G?"Preparing…":"Download evidence"})]}),I&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:I}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(H=>n.jsx("button",{onClick:()=>l(H),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:i===H?"2px solid var(--accent)":"2px solid transparent",color:i===H?"var(--text-primary)":"var(--text-tertiary)",fontWeight:i===H?600:500},children:H==="mine"?"Mine":"Team"},H))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:$w.map(H=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${H}`,"aria-selected":p===H,onClick:()=>m(H),children:[H==="automatic"?"Automatic":H==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Qe[H]})]},H))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:z,onChange:H=>V(H.target.value)}),z&&n.jsx("button",{className:"search-clear",onClick:()=>V(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${Ae?" active":""}`,onClick:()=>Z(!Ae),children:["Filters",tt?` (${K.size+(me!=="all"?1:0)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(pu,{areas:ye,selected:y,onSelect:v,totalCount:ut.length}),Ae&&n.jsxs("div",{className:"filter-panel",children:[De.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:De.map(H=>n.jsx("button",{className:`filter-chip${K.has(H)?" selected":""}`,onClick:()=>st(H),children:H},H))})]}),i==="team"&&Ie.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:Ie.map(H=>n.jsx("button",{className:`filter-chip${Q.has(H.id)?" selected":""}`,onClick:()=>ht(H.id),children:H.label},H.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([H,ge])=>n.jsx("button",{className:`filter-chip${me===H?" selected":""}`,onClick:()=>we(H),children:ge},H))})]})]}),tt&&n.jsxs("div",{className:"active-filters",children:[[...K].map(H=>n.jsxs("span",{className:"active-chip",onClick:()=>st(H),children:[H," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)),[...Q].map(H=>{const ge=B[H],be=ge?ge.name:H;return n.jsxs("span",{className:"active-chip",onClick:()=>ht(H),children:[be," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)}),me!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>we("all"),children:[me==="1d"?"Today":me==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:jt,children:"Clear all"})]}),Ge&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),F&&w.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ze.length===0?n.jsx(js,{icon:"⌕",title:w.length===0?"No tickets in the last 30 days":"No matching tickets",text:w.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ze.length===w.length?`${w.length} ticket${w.length!==1?"s":""}`:`${ze.length} of ${w.length} tickets`}),n.jsx("div",{className:"ob-list",children:ze.map(H=>{const ge=H.userId?B[H.userId]:void 0;return n.jsx("div",{className:"ob-list-item",children:n.jsx(QS,{receipt:H,manifests:C,localAuth:H.authorizationId?pe[H.authorizationId]:void 0,localUnavailable:$e,signature:Y[H.id],grantTitle:H.authorizationId?ee[H.authorizationId]:null,ownerLabel:i==="team"&&H.userId?ge?`${ge.name} (${ge.email})`:H.userId:null,spUrl:$,formatDate:ZS,onOpenComplete:()=>Fe(H),isNew:x!==null&&Qi(H,x),defaultOpen:ze.length===1})},H.id)})})]}),Oe&&n.jsx(XS,{receipt:Oe,onClose:()=>Fe(null)}),se&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:dt,disabled:_e,children:_e?"Loading…":"Load older"})})]})}function rN(){const[e,r]=f.useState(null),[a,i]=f.useState({}),[l,u]=f.useState(!1),d=On(),[p,m]=Ss(),y=Xm(p.get("area")),v=f.useCallback(M=>{const B=new URLSearchParams(p);M===null?B.delete("area"):B.set("area",M),m(B,{replace:!0})},[p,m]),[j,x]=f.useState({}),S=f.useCallback(()=>{P.getMyAttestations().then(M=>{const B={};for(const te of M)te.title&&(B[te.authorization_id]=te.title);x(B)}).catch(()=>{})},[]);f.useEffect(()=>{S()},[S]),Ht(S,3e5);const[N,w]=f.useState(null),k=f.useRef(!1),C=f.useCallback(()=>{P.getDenials({limit:200}).then(({records:M})=>{r(M),u(!1)}).catch(()=>u(!0))},[]);f.useEffect(()=>{C()},[C]),Ht(C,6e4),f.useEffect(()=>{if(!e)return;const M=[...new Set(e.map(B=>B.profile).filter(B=>!!B))].filter(B=>!(B in a));M.length!==0&&Promise.all(M.map(B=>xo(B))).then(B=>{i(te=>{const Q={...te};return M.forEach((_,z)=>{Q[_]=B[z]}),Q})})},[e,a]),f.useEffect(()=>{!e||k.current||(k.current=!0,P.getLastSeenBlockedAt().then(M=>(w(M),P.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const E=f.useCallback(()=>{C(),S(),N!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[C,S,N]);Ke("denial-recorded",E);const $=f.useMemo(()=>{const M=new Map;for(const B of e??[]){const te=B.profile??B.integrationId,Q=En(te),_=M.get(Q);_?_.count+=1:M.set(Q,{shortId:Q,icon:Jn(te),name:Qn(te,d),count:1})}return[...M.values()].sort((B,te)=>B.name.localeCompare(te.name))},[e,d]);if(l)return n.jsx(js,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const T=jw(e,Date.now()),F=e.filter(M=>Zm(M.profile??M.integrationId,y));return n.jsxs("div",{className:"blocked-page ob-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[T," today · nothing ran"]})]}),e.length===0?n.jsx(js,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(pu,{areas:$,selected:y,onSelect:v,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:F.map((M,B)=>{const te=ip(M,M.profile?a[M.profile]??void 0:void 0,j),Q=N!==null&&M.ts>N,_=M.profile??M.integrationId;return n.jsx(sN,{record:M,view:te,area:Qn(_,d),unseen:Q,mandateTitle:ap(M,j)},`${M.ts}-${B}`)})})]})]})}function sN({record:e,view:r,area:a,unseen:i,mandateTitle:l}){const u=va();return n.jsx("div",{className:"ob-card blocked-item blocked-card","data-seen":i?"false":"true","data-testid":"blocked-card",children:n.jsxs("div",{ref:u,children:[n.jsx(At,{tag:"Blocked",profileId:e.profile??void 0,className:"obj-line",parts:[a,e.integrationId?`via ${vs(e.integrationId)}`:null,op(e.ts,Date.now()),i?n.jsx("span",{className:"ob-st new-pill","data-testid":"blocked-new",children:"New"}):null]}),n.jsx("h3",{className:"ob-title",children:lp(e)}),n.jsxs("p",{className:"ob-check ob-check-x","data-kind":ya(e),children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("span",{children:[n.jsx("b",{children:cp(e)})," ",r.sentence]})]}),n.jsx("p",{className:"ob-quiet",children:Sw(e)}),n.jsx(Gt,{title:"What you can do",summary:"change the mandate or ignore it",testId:"blocked-advice",children:n.jsx("p",{children:r.whatYouCanDo})}),n.jsx(Gt,{title:"Technical details",summary:e.code??void 0,testId:"blocked-technical",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Action"}),n.jsxs("dd",{className:"ob-mono",children:[vs(e.integrationId)," · ",e.tool]}),n.jsx("dt",{children:"Mandate"}),n.jsxs("dd",{children:[l??(e.mandateId?"":"none covers it"),e.mandateId&&n.jsxs("span",{className:"ob-mono",children:[" ",e.mandateId.slice(0,14),"…"]})]}),e.code&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Code"}),n.jsx("dd",{className:"ob-mono",children:e.code})]})]})}),n.jsx("div",{className:"ob-btns",children:n.jsx(pt,{className:"ob-btn",to:e.mandateId?`/mandates?highlight=${encodeURIComponent(e.mandateId)}`:"/mandates",children:"Open mandate"})})]})})}const aN={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function iN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{r(await P.getAutostart())}catch(y){u(y instanceof Error?y.message:"Could not read autostart state")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){i(!0),u(null);try{await P.setAutostart(!e.installed)}catch(y){u(y instanceof Error?y.message:"Failed")}finally{try{r(await P.getAutostart()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not re-read state")}i(!1)}}},[e,a,d]);if(!e)return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Autostart"]}),n.jsx("h3",{className:"ob-title",children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const m=aN[e.platform]??"a login service";return n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Autostart",e.supported?n.jsx("span",{className:`ob-st${e.installed?"":" is-off"}`,children:e.installed?"On":"Off"}):"Not available"]}),n.jsx("h3",{className:"ob-title",children:"Keep Suveren running"}),n.jsx("p",{className:"ob-one",children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",m," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:`ob-btn${e.installed?"":" is-solid"}`,children:a?"Working…":e.installed?"Turn off":"Turn on"})})]}),e.supported&&n.jsx(Gt,{title:"What happens after a restart",summary:"takes effect at your next login",children:n.jsxs("p",{children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]})}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}function oN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{const m=await P.getGatewaySettings();r(m.desktopNotifications),u(null)}catch(m){u(m instanceof Error?m.message:"Could not read notification setting")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(e===null||a)){i(!0),u(null);try{const m=await P.setGatewaySettings({desktopNotifications:!e});r(m.desktopNotifications)}catch(m){u(m instanceof Error?m.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]);return e===null?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Notifications"]}),n.jsx("h3",{className:"ob-title",children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Notifications",n.jsx("span",{className:`ob-st${e?"":" is-off"}`,children:e?"On":"Off"})]}),n.jsx("h3",{className:"ob-title",children:"Desktop notifications"}),n.jsx("p",{className:"ob-one",children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:`ob-btn${e?"":" is-solid"}`,children:a?"Saving…":e?"Turn off":"Turn on"})})]}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}const lm={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function lN(){const[e,r]=f.useState(null),[a,i]=f.useState(!1),[l,u]=f.useState(null),d=f.useCallback(async()=>{try{r(await P.getIdentityDisclosure()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not read the setting")}},[]);f.useEffect(()=>{d()},[d]);const p=f.useCallback(async()=>{if(!(!e||a)){i(!0),u(null);try{r(await P.setIdentityDisclosure(!e.always))}catch(v){u(v instanceof Error?v.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]),m=n.jsx("h3",{className:"ob-title",children:"Your name on mandates and tickets"});if(!e)return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Mandates and tickets"]}),m,n.jsx("p",{role:l?"alert":void 0,className:"ob-one",children:l?`Could not read the setting: ${l}`:"Checking…"})]});const y=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${lm.as_vouched} ${e.verifier}`:lm[e.method??""]??e.method}`:null;return n.jsxs("article",{className:"ob-card su-card",children:[n.jsxs("div",{className:"su-row",children:[n.jsxs("div",{children:[n.jsx(At,{parts:["Mandates and tickets",n.jsx("span",{className:`ob-st${e.always?"":" is-off"}`,children:e.always?"On":"Off"})]}),m,n.jsxs("p",{className:"ob-one",children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{className:"ob-one",children:y?`Your identity: ${y}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("div",{className:"ob-btns",children:n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:"ob-btn",children:a?"Saving…":e.always?"Turn off":"Always show my name"})})]}),l&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:l})]})}const cN={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function uN(){const{version:e,latestVersion:r,updateAvailable:a,installMethod:i}=nu();return e?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Version"]}),n.jsxs("h3",{className:"ob-title",children:["Running ",n.jsx("b",{children:e}),a&&r?n.jsxs(n.Fragment,{children:[" — ",n.jsx("b",{children:r})," is available"]}):null]}),n.jsxs("p",{className:"ob-one",children:[cN[i]??"Update checking is unavailable",i==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Uc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx(go,{})," Set by your IT"]})}function cm(e){return e===!0}function dN(){const[e,r]=f.useState(null),[a,i]=f.useState(null);f.useEffect(()=>{let d=!1;return P.getAsPairing().then(p=>{d||r(p)}).catch(p=>{d||i(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{d=!0}},[]);const l=cm(e==null?void 0:e.asUrlLockedByPolicy),u=cm(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{tag:"SERVER",parts:["Connection",l&&n.jsx(Uc,{})]}),n.jsx("h3",{className:"ob-title",children:"Your Authority Server"}),!e&&!a&&n.jsx("p",{className:"ob-one",children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"ob-one ob-bold msg-error",children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"ob-tile",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"URL"}),n.jsx("dd",{className:"ob-mono is-strong",children:e.asUrl}),e.paired&&e.fingerprint&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Key fingerprint"}),n.jsx("dd",{className:"ob-mono is-strong",children:e.fingerprint})]}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs(n.Fragment,{children:[n.jsxs("dt",{children:["TLS certificate pin ",u&&n.jsx(Uc,{title:"TLS pinning is set by your IT policy"})]}),n.jsx("dd",{className:e.tlsPinFingerprint?"ob-mono is-strong":"ob-plain",children:e.tlsPinFingerprint??n.jsxs(n.Fragment,{children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]})})]})]})}),e.paired&&e.fingerprint?n.jsx("p",{className:"ob-one",children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."}):n.jsx("p",{className:"ob-one",children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{className:"ob-one",children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]}),l?n.jsx("p",{className:"ob-one",children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):n.jsxs(Gt,{title:"Point this gateway at a different server",summary:"command, then restart",children:[n.jsxs("p",{children:[n.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart."]}),n.jsx("p",{children:"Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."})]})]})]})}function hN(){const{simulation:e,locked:r}=Ep();return r?n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Simulation mode",e!==null?n.jsx("span",{className:`ob-st${e?"":" is-off"}`,children:e?"On":"Off"}):null,n.jsx(Uc,{})]}),n.jsx("h3",{className:"ob-title",children:"Simulation mode"}),n.jsxs("p",{className:"ob-one",children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]}),n.jsxs("p",{className:"ob-one",children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const fN={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},ha=["Authority Server","This computer","Security","Version","AI Assistant"];function mN(){const[e,r]=f.useState("");f.useEffect(()=>{if(window.location.hash!=="#ai-assistant")return;const G=window.setTimeout(()=>{var J;return(J=document.getElementById("ai-assistant"))==null?void 0:J.scrollIntoView({block:"start"})},50);return()=>window.clearTimeout(G)},[]);const[a,i]=f.useState("openrouter"),[l,u]=f.useState("openai-compatible"),[d,p]=f.useState("https://openrouter.ai/api/v1"),[m,y]=f.useState("google/gemma-4-31b-it"),[v,j]=f.useState(""),[x,S]=f.useState(!1),[N,w]=f.useState(!1),[k,C]=f.useState(!1),[E,$]=f.useState(null),[T,F]=f.useState([]),[M,B]=f.useState(!1),[te,Q]=f.useState(null),[_,z]=f.useState(""),V=f.useCallback(G=>{r(G),setTimeout(()=>r(""),3e3)},[]),K=f.useCallback(async(G,J,I)=>{B(!0),Q(null);try{const D=await P.aiModels({provider:G,endpoint:J,...I?{apiKey:I}:{}});D.ok&&D.models.length>0?(F(D.models),Q(`${D.models.length} models available`)):(F([]),Q(D.message||"No models returned — using defaults"))}catch(D){F([]),Q(D instanceof Error?D.message:"Failed to load models")}finally{B(!1)}},[]),le=f.useCallback(async()=>{try{const G=await P.getCredential("ai-config");if(S(G.configured),G.configured&&G.fields){const J=G.fields.provider||"openai-compatible",I=G.fields.endpoint||"";G.fields.provider&&u(J),G.fields.endpoint&&p(I),G.fields.model&&y(G.fields.model),I.includes("openai.com")?i("openai"):I.includes("groq.com")?i("groq"):I.includes("together.xyz")?i("together"):I.includes("openrouter.ai")?i("openrouter"):i("ollama"),I&&K(J,I)}}catch{}},[K]);f.useEffect(()=>{le()},[le]);const me=G=>{i(G),F([]),Q(null),z("");const J=fN[G];J&&(u(J.provider),p(J.endpoint),y(""),K(J.provider,J.endpoint,v||void 0))},we=()=>K(l,d,v||void 0),Ae=async()=>{w(!0);try{await P.setCredential("ai-config",{provider:l,endpoint:d,model:m,...v?{apiKey:v}:{}}),S(!0),V("AI configuration saved!")}catch{V("Failed to save AI config")}finally{w(!1)}},Z=async()=>{C(!0),$(null);try{const G=await P.aiTest({provider:l,endpoint:d,model:m,...v?{apiKey:v}:{}});$(G.ok?`OK: ${G.message}`:`Failed: ${G.message}`)}catch(G){$(`Error: ${G instanceof Error?G.message:"Unknown"}`)}finally{C(!1)}};return n.jsxs("div",{className:"su-page",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"The connection to your Authority Server, this computer, security, version and your AI assistant."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsx("h2",{className:"su-sec",children:ha[0]}),n.jsx(dN,{}),n.jsx(lN,{}),n.jsx("h2",{className:"su-sec",children:ha[1]}),n.jsx(iN,{}),n.jsx(oN,{}),n.jsx(hN,{}),n.jsx("h2",{className:"su-sec",children:ha[2]}),n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["Security"]}),n.jsx("h3",{className:"ob-title",children:"What the gateway does and does not cover"}),n.jsxs("section",{className:"ob-tile",children:[n.jsxs("div",{className:"ob-part",children:[n.jsxs("div",{className:"su-tile-h",children:[n.jsx(go,{}),"What the gateway protects"]}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{className:"ob-part",children:[n.jsx("div",{className:"su-tile-h",children:"Your responsibility"}),n.jsxs("ul",{className:"su-list",children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]}),n.jsx("h2",{className:"su-sec",children:ha[3]}),n.jsx(uN,{}),n.jsx("h2",{className:"su-sec",id:"ai-assistant",style:{scrollMarginTop:"calc(var(--nav-height) + 1rem)"},children:ha[4]}),n.jsxs("article",{className:"ob-card su-card",children:[n.jsx(At,{parts:["AI assistant","Optional",n.jsx("span",{className:`ob-st${x?"":" is-off"}`,children:x?"Set up":"Not set up"})]}),n.jsx("h3",{className:"ob-title",children:"AI Assistant"}),n.jsx("p",{className:"ob-one",children:"Helps you write mandates and the brief. Keys are encrypted in your vault."}),n.jsxs("div",{className:"su-fields",children:[n.jsxs("div",{className:"form-group",children:[n.jsx("label",{className:"form-label",children:"Provider"}),n.jsxs("select",{className:"form-input",value:a,onChange:G=>me(G.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{className:"form-label",children:["API key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:v,onChange:G=>j(G.target.value),onBlur:()=>{v.trim()&&K(l,d,v.trim())},placeholder:x?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.jsx("p",{className:"su-hint",children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("div",{className:"su-label-row",children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"ob-link",onClick:we,disabled:M,title:"Re-fetch the model list from the provider",children:M?"Loading…":"↻ Refresh"})]}),T.length===0?n.jsx("div",{className:"form-input su-placeholder-field",children:M?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const G=T,J=G.includes(m),I=G.length>12,D=_.trim().toLowerCase();let pe=D?G.filter(de=>de.toLowerCase().includes(D)):G;return J&&!pe.includes(m)&&(pe=[m,...pe]),n.jsxs(n.Fragment,{children:[I&&n.jsx("input",{className:"form-input",value:_,onChange:de=>z(de.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:J?m:"__unset__",onChange:de=>y(de.target.value==="__unset__"?"":de.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),pe.map(de=>n.jsx("option",{value:de,children:de},de)),D&&pe.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",_,"”"]})]})]})})(),te&&n.jsx("p",{className:"su-hint",children:te})]})]}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn is-solid",onClick:Ae,disabled:N||!m.trim(),title:m.trim()?void 0:"Select a model first",children:N?"Saving...":"Save & Encrypt"}),x&&n.jsx("button",{className:"ob-btn",onClick:Z,disabled:k,children:k?"Testing...":"Test Connection"})]}),E&&n.jsx("div",{className:`alert ${E.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:E}),n.jsx(pN,{})]})]})}function pN(){const[e,r]=f.useState(null),[a,i]=f.useState({intent:"",context:""}),[l,u]=f.useState(null),[d,p]=f.useState(null),[m,y]=f.useState(null),[v,j]=f.useState(!1),x=f.useCallback(async()=>{if(!v)try{const w=await P.getAIPrompts();r(w),i({intent:w.intent.current,context:w.context.current}),j(!0)}catch(w){p(w instanceof Error?w.message:"Failed to load prompts")}},[v]),S=async w=>{if(e){u(w),p(null);try{const k=a[w],C=k.trim()===e[w].default.trim()?"":k;await P.setAIPrompt(w,C);const E=await P.getAIPrompts();r(E),i({intent:E.intent.current,context:E.context.current}),y(w),setTimeout(()=>y(null),2e3)}catch(k){p(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},N=async w=>{if(confirm(`Revert ${w} prompt to the built-in default?`)){u(w),p(null);try{await P.setAIPrompt(w,"");const k=await P.getAIPrompts();r(k),i({intent:k.intent.current,context:k.context.current})}catch(k){p(k instanceof Error?k.message:"Revert failed")}finally{u(null)}}};return n.jsxs(Gt,{title:"Advanced — AI assistant prompts",summary:"the prompts it sees",onToggle:w=>{w&&x()},children:[n.jsx("p",{children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your Agent Brief). Edit with care — changes apply on the next chat turn."}),d&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:d}),!v&&!d&&n.jsx("p",{className:"ob-lbl",children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(um,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:w=>i(k=>({...k,intent:w})),onSave:()=>S("intent"),onRevert:()=>N("intent"),saving:l==="intent",justSaved:m==="intent"}),n.jsx(um,{kind:"context",label:"Agent Brief",description:"Used on the Agent Brief page when refining your brief.",state:e.context,draft:a.context,onChange:w=>i(k=>({...k,context:w})),onSave:()=>S("context"),onRevert:()=>N("context"),saving:l==="context",justSaved:m==="context"})]})]})}function um({kind:e,label:r,description:a,state:i,draft:l,onChange:u,onSave:d,onRevert:p,saving:m,justSaved:y}){const v=l!==i.current;return n.jsxs("section",{className:"su-prompt",children:[n.jsxs("div",{className:"su-label-row",children:[n.jsxs("div",{children:[n.jsx("div",{className:"su-prompt-h",children:r}),n.jsx("div",{className:"ob-lbl",children:a})]}),i.overridden&&n.jsx("span",{className:"ob-st",children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea su-prompt-text",value:l,onChange:j=>u(j.target.value),rows:12,spellCheck:!1,"aria-label":`${r} system prompt`}),n.jsxs("div",{className:"ob-btns is-inline is-tight",children:[n.jsx("button",{type:"button",className:"ob-btn is-solid",onClick:d,disabled:m||!v,children:m?"Saving…":"Save"}),i.overridden&&n.jsx("button",{type:"button",className:"ob-btn",onClick:p,disabled:m,title:"Discard the override and use the built-in default",children:"Revert to default"})]}),(y||v&&!m)&&n.jsx("p",{className:"ob-lbl ob-gap",children:y?"Saved":"Unsaved changes"}),n.jsxs("details",{className:"ob-raw",children:[n.jsx("summary",{children:"Show built-in default"}),n.jsx("pre",{className:"ob-mono su-prompt-default",children:i.default})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function gN(e){return e.proposalId?"review":"automatic"}function dm(e,r,a={}){const i=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const d of e)i==="pending"&&d.status!=="pending"||a.profile&&d.profileId!==a.profile||u.push({kind:"proposal",id:d.id,sortTimestamp:d.createdAt,commitmentMode:"review",profileId:d.profileId,proposal:d});if(i==="all")for(const d of r){const p=gN(d);!l&&p==="automatic"||a.profile&&d.profileId!==a.profile||u.push({kind:"receipt",id:d.id,sortTimestamp:d.timestamp,commitmentMode:p,profileId:d.profileId,receipt:d})}return u.sort((d,p)=>p.sortTimestamp-d.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}function hm(e){const r=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,[a,i]=f.useState(r);return f.useEffect(()=>{if(typeof window.matchMedia!="function")return;const l=window.matchMedia(e),u=()=>i(l.matches);return u(),l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[e]),a}const vN=["https://","http://"];function Lg(e,r){return e!=null&&e.length?e.flatMap(a=>{const i=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const d=r[u];return typeof d=="string"||typeof d=="number"?String(d):"\0"});return i.includes("\0")||/\{|\}/.test(i)?[]:vN.some(l=>i.toLowerCase().startsWith(l))?[{label:a.label,href:i,description:a.description}]:[]}):[]}function yN(e,r){const a=e-Math.floor(r/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const i=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let d;return i>0?d=`expires in ${i}d ${l}h`:l>0?d=`expires in ${l}h ${u}m`:d=`expires in ${Math.max(1,u)}m`,{label:d,urgent:a<2*3600,expired:!1}}function xN({profileId:e,declared:r}){const{icon:a}=jr(e,r),i=Zj(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(dg,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:i})]}),n.jsx("div",{className:"id-sep"})]})}function jN({proposalId:e,systemName:r}){const[a,i]=f.useState(null);if(f.useEffect(()=>{let u=!0;return i(null),P.getProposalOutcome(e).then(d=>{u&&i(d)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=IS(a,r);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}const wN=15e3;let Fi=null;function bN(){const e=Date.now();return(!Fi||e-Fi.at>wN)&&(Fi={at:e,p:P.getMyReceiptsPage({limit:200}).then(r=>r.receipts).catch(()=>[])}),Fi.p}function kN(e,r,a){var l,u,d,p;let i=null;for(const m of e)m.authorizationId!==r||!Ur(m.timestamp,a)||(!i||m.timestamp>i.timestamp||m.timestamp===i.timestamp&&(((u=(l=m.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=i.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&(i=m);return i}function SN(e,r,a){const i=[];for(const[l,u]of[["daily","today"],["monthly","this month"]]){const d=ou(e,r,a,l);d&&i.push({label:u,text:"limit"in d?`${d.used} of ${d.limit}`:`${d.count} ${d.count===1?"call":"calls"}`})}return i}function NN(e,r,a){const[i,l]=f.useState(void 0);if(f.useEffect(()=>{let d=!0;return l(void 0),bN().then(p=>{d&&l(kN(p,e,Date.now()))}),()=>{d=!1}},[e]),i===void 0)return{state:"loading"};if(i===null)return{state:"none"};const u=SN(i,r,a);return u.length?{state:"ok",lines:u}:{state:"none"}}function CN({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let jc=null;function EN(){return jc||(jc=P.getEnrichedAuthorizations().then(e=>new Map(e.map(r=>[r.authorizationId,r.bounds]))).catch(()=>new Map)),jc}function AN(e){const[r,a]=f.useState(void 0);return f.useEffect(()=>{let i=!0;if(e)return EN().then(l=>{i&&a(l.get(e))}),()=>{i=!1}},[e]),r}function TN(e,r){const[a,i]=f.useState(null),[l,u]=f.useState(!1),[d,p]=f.useState(null);return f.useEffect(()=>{let m=!0;return i(null),p(null),u(!0),(async()=>{var y;try{try{const x=await P.getGateContent(e);if((y=x==null?void 0:x.gateContent)!=null&&y.intent){m&&i(x.gateContent.intent);return}}catch{}const v=await P.getAttestationIntent(e);if(!v){m&&p("Intent not available or you are not an authorized approver.");return}const j=await P.decryptIntent({intentCiphertext:v.intentCiphertext,encryptedKey:v.encryptedKey,approverId:r});m&&i(j)}catch(v){m&&p(v instanceof Error?v.message:"Failed to decrypt intent")}finally{m&&u(!1)}})(),()=>{m=!1}},[e,r]),{intent:a,loading:l,error:d}}function IN(e,r){const a=e.map(l=>({key:`limit:${l.key}`,status:l.ok?"pass":"fail",label:l.label,...l.valueText||l.limitText?{text:`${l.valueText} — your limit ${l.limitText}`.trim()}:{}})),i=(r??[]).map(l=>{const u=l.detail??l.reason;return{key:`check:${l.key}${l.index!==void 0?`:${l.index}`:""}`,status:l.status,label:l.label,...u?{text:u}:{}}});return[...a,...i]}function RN(e){switch(e.status){case"pass":return e.text?`${e.label} — ${e.text}`:e.label;case"fail":return e.text?`${e.label}: ${e.text}`:e.label;case"not_checked":return`${e.label}: not checked${e.text?` — ${e.text}`:""}`;case"notice":return e.text?`${e.label}: ${e.text}`:e.label}}const $N=n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),PN=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function wc({l:e}){if(e.status==="notice")return n.jsxs("div",{className:"check-line check-notice","data-check-status":"notice",children:[$N,n.jsx("span",{children:e.text?n.jsxs(n.Fragment,{children:[n.jsxs("strong",{children:[e.label,":"]})," ",e.text]}):n.jsx("strong",{children:e.label})})]});const r=e.status==="pass"?"✓":e.status==="fail"?"✕":"–";return n.jsxs("div",{className:`check-line check-${e.status.replace("_","-")}`,"data-check-status":e.status,children:[n.jsx("span",{className:"check-mark","aria-hidden":"true",children:r}),n.jsx("span",{children:RN(e)})]})}function fm({lines:e,placement:r}){if(r==="top"){const u=e.filter(d=>d.status==="fail");return u.length===0?null:n.jsx("div",{className:"card-checks card-checks-top","data-testid":"card-checks-top",style:{order:2},children:u.map(d=>n.jsx(wc,{l:d},d.key))})}const a={not_checked:0,notice:1},i=e.filter(u=>u.status==="not_checked"||u.status==="notice").map((u,d)=>({l:u,i:d})).sort((u,d)=>a[u.l.status]-a[d.l.status]||u.i-d.i).map(({l:u})=>u),l=e.filter(u=>u.status==="pass");return i.length===0&&l.length===0?null:n.jsxs("div",{className:"card-checks card-checks-body","data-testid":"card-checks-body",children:[i.length>0&&n.jsx("div",{className:"av3-attention",style:{order:4},children:i.map(u=>n.jsx(wc,{l:u},u.key))}),l.length>0&&n.jsxs("details",{className:"av3-fold",style:{order:11},"data-testid":"checks-passed",children:[n.jsxs("summary",{children:[n.jsxs("span",{className:"h",children:["✓ ",l.length," ",l.length===1?"check":"checks"," passed"]}),n.jsx("span",{className:"one",children:l.map(u=>u.label).join(" · ")}),PN]}),n.jsx("div",{className:"av3-fold-body",children:l.map(u=>n.jsx(wc,{l:u},u.key))})]})]})}function mm(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[a,i]of Object.entries(e))(typeof i=="string"||typeof i=="number")&&(r[a]=i);return r}function _N(e){const r=mm(e.limits),a=mm(e.scope),i=typeof e.intent=="string"?e.intent:"",l={bounds:r,context:a,gateContent:{intent:i}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function Wc(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Wc(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function LN({proposal:e,currentUserId:r,proposalLinks:a,toolDisplay:i,manifests:l,onContentState:u,onShownSnapshot:d,nameOf:p,mandateTitle:m,topExtras:y}){var qe,H,ge,be,X,Ne,ke;const[v,j]=f.useState(!1),[x,S]=f.useState(!1),[N,w]=f.useState(null),k=yn(),{group:C,groupId:E,domain:$}=Nt(),T=Object.entries(e.executionContext),F=Ns(e.profileId),M=AN(e.authorizationId),B=dw(e.tool),{integrationId:te}=Fn(e.tool),Q=wr(te,l),{intent:_,loading:z,error:V}=TN(e.authorizationId,r),K=xa(e),le=K.toolArgs!==null,[me,we]=f.useState([]),Ae=[...Iw(e.executionContext,M,F),...bS(K.toolArgs),...me],Z=f.useMemo(()=>gu(K.toolArgs),[K.toolArgs]),G=f.useCallback(ue=>P.getProposalAttachmentPreview(e.id,ue),[e.id]);f.useEffect(()=>{u==null||u({loading:K.loading,readable:le})},[K.loading,le]);const J=hb(e),I=K.toolArgs?Lg(a,K.toolArgs):[],D=async()=>{if(!E){w("No active workspace; cannot open the mandate screen.");return}S(!0),w(null);try{if(!K.toolArgs){w("This content is not readable on this device yet.");return}const ue=K.toolArgs,He=typeof ue.profile=="string"?ue.profile:"",kt=await P.listProfiles(),ne=pg(He,kt);if(!ne){w(`Unknown profile "${He}".`);return}const xe=await P.getProfile(ne.id),U=_N(ue),ie=vg(U.bounds,xe),Ee=yg(U.context,xe);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ne.id,groupId:E,groupName:(C==null?void 0:C.name)??null,domain:$,isPersonal:!!(C!=null&&C.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...U,bounds:ie,context:Ee})),sessionStorage.setItem("agentReplacesProposal",e.id),k("/mandates/new/intent")}catch(ue){w(ue instanceof Error?ue.message:"Could not open the mandate screen.")}finally{S(!1)}},[pe,de]=f.useState(null),$e=RS(pe),[ve,Y]=f.useState(null),he=IN(Ae,ve==null?void 0:ve.checks);f.useEffect(()=>{lb(e.id,ve)},[e.id,ve]);const[ee,oe]=f.useState(null);f.useEffect(()=>{if(!ve||!ee){d==null||d(null);return}const ue=ve.status==="ok"?ve.readAt:Date.now();d==null||d({readAt:ue,preview:ve,requestContext:ee,...K.toolArgs?{toolArgs:K.toolArgs}:{},sealed:K.sealed})},[ve,ee,K.toolArgs,K.sealed,d]);const{toolName:Oe}=Fn(e.tool),Fe=(X=(be=(ge=(H=(qe=l==null?void 0:l.find(ue=>ue.id===te))==null?void 0:qe.toolGating)==null?void 0:H.overrides)==null?void 0:ge[Oe])==null?void 0:be.sourceFromArg)==null?void 0:X.arg;K.toolArgs&&K.toolArgs;const se=K.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(Ui,{args:K.toolArgs,display:i,heading:"",requestRefArg:Fe}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([ue,He],kt)=>{const{label:ne,hint:xe}=pf(ue,F);return n.jsxs("span",{children:[kt>0&&" · ",n.jsxs("span",{title:xe,children:[ne,"=",Wc(He)]})]},ue)})})]}):null,Te=On(),_e=e.tool===qp,Ve=_e?K.toolArgs:null,Ge=_e?so(Ve,e.profileId):e.profileId,ct=Br(Ge,Te),nt=_e?jr(so(Ve,e.profileId)).testSetup:jr(e.profileId).testSetup||po(e.tool),Je=pp(e.expiresAt,Date.now()),Be=wb(ve&&ve.status==="ok"&&"body"in ve?ve.body.structured:void 0),dt=typeof(Ve==null?void 0:Ve.intent)=="string"&&Ve.intent.trim()?Ve.intent:_e?Be.intent??null:null,et=_e?jb((Ve==null?void 0:Ve.mode)??Be.mode):null,De=_e&&K.toolArgs?Object.fromEntries(Object.entries(K.toolArgs).filter(([ue])=>ue!=="intent"&&ue!=="mode")):K.toolArgs,Ie=De?n.jsx(Ui,{args:De,display:i,heading:"",requestRefArg:Fe}):null,We=m||(F==null?void 0:F.name)||Vt(e.profileId),Qe=NN(e.authorizationId,M,F),ut=Qe.state==="ok"?Qe.lines.map(ue=>`${ue.text} ${ue.label}`).join(" · "):Qe.state==="none"?"none yet today":"",ye=ve?lo(ve,Q,K.toolArgs??void 0).creation:void 0,ze=ve?lo(ve,Q,K.toolArgs??void 0).note:void 0,Ye=e.tool.toLowerCase(),tt=["delete","refund","cancel","revoke"].some(ue=>Ye.includes(ue)),st=typeof((Ne=K.toolArgs)==null?void 0:Ne._imagePreview)=="string"?K.toolArgs._imagePreview:null,ht=_e?"You sign this":"Runs exactly as shown",jt=_e?bb(Be):`${B} · ${En(e.profileId)}${e.profileId.includes("@")?`@${e.profileId.split("@")[1]}`:""}`;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"av3-type",style:{order:0},"data-testid":"approval-type",children:[_e?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Dr,{icon:Jn(Ge)}),ct]}),n.jsx("span",{children:mp(e.createdAt*1e3,Date.now())}),nt&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx("h2",{className:"av3-title",style:{order:1},"data-testid":"approval-summary",children:_e?n.jsxs(n.Fragment,{children:[ct," · ",Kp(ct,Ve).name??"new mandate"]}):Vp(e.tool,K.toolArgs,l,void 0,Op(ve??void 0,K.toolArgs))}),Je&&n.jsx("p",{className:"av3-quiet av3-due",style:{order:1},"data-testid":"approval-deadline",children:Je}),n.jsx(fm,{lines:he,placement:"top"}),y&&n.jsx("div",{className:"av3-extras",style:{order:3},children:y}),n.jsx(fm,{lines:he,placement:"body"}),tt&&n.jsx("div",{className:"av3-attention",style:{order:4},"data-testid":"irreversible-note",children:n.jsxs("div",{className:"check-line check-notice",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),n.jsx("span",{children:n.jsx("strong",{children:"Irreversible action"})})]})}),K.sealed&&K.undecryptable&&n.jsxs("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-undecryptable",children:[n.jsx("strong",{children:"Encrypted for another device."}),n.jsx("p",{children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),K.sealed&&K.loading&&n.jsx("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-decrypting",children:"Decrypting…"}),n.jsxs("section",{className:"av3-sealed",style:{order:6},"data-testid":"sealed-values","aria-labelledby":`sealed-h-${e.id}`,children:[n.jsxs("h3",{id:`sealed-h-${e.id}`,className:"av3-sealed-h",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]}),ht]}),_e&&dt&&n.jsxs("div",{className:"av3-intent","data-testid":"mandate-intent-ai",children:[n.jsx("div",{className:"av3-intent-l",children:"Intent — written by the AI, becomes your words when you sign"}),n.jsx("p",{children:dt})]}),le&&_e&&n.jsxs("div",{className:"av3-edit",children:[n.jsx("button",{type:"button",className:"av3-link","data-testid":"edit-before-signing",onClick:D,disabled:x,children:x?"Opening…":"Edit before signing"}),N&&n.jsx("p",{className:"msg-error",children:N})]}),et&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-mode",children:[n.jsx("dt",{children:et.label}),n.jsx("dd",{children:et.title})]}),st&&n.jsx("img",{src:st,alt:typeof((ke=K.toolArgs)==null?void 0:ke.altText)=="string"?K.toolArgs.altText:"local image preview",className:"av3-image"}),$e&&le&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",children:[n.jsxs("h4",{children:["What will be sent ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),Ie]}),le&&K.toolArgs&&mf(K.toolArgs,i)!==void 0&&n.jsx(CN,{text:mf(K.toolArgs,i)}),le&&n.jsx(Sg,{attachments:Z.attachments,inserts:Z.inserts,manifests:l,fetchPreview:G,onChecks:we}),le&&n.jsx(FS,{proposalId:e.id,systemName:Q,toolArgs:K.toolArgs,sealed:K.sealed,systemBoxes:!1,omitKeys:_e?xb:void 0,hideNote:!0,onTone:de,onData:Y}),_e&&(Be.workspace||Be.title)&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-applies-to",children:[Be.workspace&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:Be.workspace})]}),Be.title&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Title"}),n.jsx("dd",{children:Be.title})]})]})]}),ye&&ye.systemBoxes.length>0&&n.jsx("div",{style:{order:7},children:n.jsx(Eg,{view:ye})}),J.length>0&&n.jsxs("p",{className:"av3-quiet",style:{order:7},"data-testid":"proposal-cannot-read",children:["Cannot read this proposal yet: ",J.map(ue=>(p==null?void 0:p(ue))??ue).join(", ")," — shared automatically once they sign in on a device."]}),_e?n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"proposed-through",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Proposed through"}),n.jsxs("span",{className:"one",children:["Delegation",Be.checks[0]?` · ${Be.checks[0]}`:""]}),n.jsx(bc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsxs("p",{children:["Proposed by the AI through your ",n.jsx("strong",{children:"Delegation"})," mandate."]}),Be.checks.length>0&&n.jsx("ul",{className:"av3-plain","data-testid":"mandate-checks",children:Be.checks.map(ue=>n.jsx("li",{children:ue},ue))}),n.jsx(pm,{intent:_,loading:z,error:V,expanded:v,onToggle:()=>j(!v)})]})]}):n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"covered-by",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Covered by"}),n.jsxs("span",{className:"one",children:[We,ut?` · ${ut}`:""]}),n.jsx(bc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{children:n.jsxs(pt,{to:"/mandates",className:"av3-link-strong",children:[We," ›"]})}),Qe.state==="ok"&&n.jsx("dl",{className:"av3-usage",children:Qe.lines.map(ue=>n.jsxs(f.Fragment,{children:[n.jsx("dt",{children:ue.label}),n.jsx("dd",{children:ue.text})]},ue.label))}),Qe.state==="none"&&n.jsx("p",{className:"av3-quiet",children:"No ticket under this mandate yet today."}),n.jsx(pm,{intent:_,loading:z,error:V,expanded:v,onToggle:()=>j(!v)})]})]}),le&&n.jsx(qS,{proposalId:e.id,layout:"folds",onData:oe}),le&&I.length>0&&n.jsx("div",{className:"av3-links",style:{order:9},children:I.map(ue=>n.jsxs("a",{href:ue.href,target:"_blank",rel:"noopener noreferrer",className:"av3-link-btn",title:ue.description??ue.href,children:[ue.label," ↗"]},ue.label))}),le&&n.jsxs("details",{className:"av3-fold",style:{order:15},"data-testid":"technical-details",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Technical details"}),n.jsx("span",{className:"one",children:jt}),n.jsx(bc,{})]}),n.jsxs("div",{className:"av3-fold-body proposal-args-fold",children:[_e&&(Be.proposal||Be.profileVersion)&&n.jsxs("dl",{className:"av3-usage",children:[Be.proposal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Proposal"}),n.jsx("dd",{children:Be.proposal})]}),Be.profileVersion&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Version"}),n.jsx("dd",{children:Be.profileVersion})]})]}),_e?null:$e?T.length>0&&n.jsx("div",{className:"av3-bound",children:T.map(([ue,He],kt)=>{const{label:ne,hint:xe}=pf(ue,F);return n.jsxs("span",{children:[kt>0&&" · ",n.jsxs("span",{title:xe,children:[ne,"=",Wc(He)]})]},ue)})}):se,ze&&n.jsx("p",{className:"av3-quiet","data-testid":"preview-source-note",children:ze}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),K.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]})]})]})}function bc(){return n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function pm({intent:e,loading:r,error:a,expanded:i,onToggle:l}){return n.jsxs("div",{className:"av3-mintent",children:[n.jsx("div",{className:"av3-quiet",children:"Intent"}),a?n.jsx("p",{className:"msg-error",children:a}):e!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${i?"":" intent-clamped"}`,children:e}),n.jsx("button",{type:"button",className:"av3-link",onClick:l,children:i?"Show less":"Show full intent"})]}):r?n.jsx("p",{className:"av3-quiet",children:"Loading intent…"}):n.jsx("p",{className:"av3-quiet",children:"No intent available for this mandate."})]})}const MN="setup__create_mandate";function Mg({proposal:e,currentUserId:r,manifests:a,toolDisplay:i,proposalLinks:l,mandateTitle:u,nameOf:d,topExtras:p,canApprove:m=!0,alreadyDecided:y=!1,decide:v,onDecided:j,nextLabelText:x,onBusyChange:S,className:N}){const w=e.tool===MN,[k,C]=f.useState({t:"idle"}),[E,$]=f.useState(""),[T,F]=f.useState(""),[M,B]=f.useState(!1),[te,Q]=f.useState(!0),_=f.useRef(null),z=async()=>{const G=_.current;if(G)try{const{shownHash:J}=await P.saveShownSnapshot(e.id,G);return J}catch{return}},V=async(G,J)=>{if(!(k.t==="working"||k.t==="done")){if(G==="approve"&&Sp()){F(Np);return}F(""),C({t:"working",kind:G});try{const I=await z(),D=await v({kind:G,note:J,shownHash:I});C({t:"done",kind:G,result:D}),j==null||j(G,D)}catch(I){F(I instanceof Error?I.message:"Failed"),C(G==="change"?{t:"change"}:{t:"idle"})}}},K=()=>{const G=gk(E);if(!G.valid){F(G.error);return}V("change",G.trimmed)},le=f.useRef(null);f.useEffect(()=>{const G=le.current;if(!G)return;const J=I=>{var pe;const D=I.target;!D.open||!((pe=D.classList)!=null&&pe.contains("av3-fold"))||G.querySelectorAll("details.av3-fold[open]").forEach(de=>{de!==D&&(de.open=!1)})};return G.addEventListener("toggle",J,!0),()=>G.removeEventListener("toggle",J,!0)},[]);const me=k.t==="working"||k.t==="done";f.useEffect(()=>(S==null||S(me),()=>{me&&(S==null||S(!1))}),[me]);const we=!y&&!me&&fb({loading:M,readable:te}),Ae=w?"Sign mandate":"Approve",Z=`human-only-${e.id}`;return n.jsxs("div",{className:`card av3-card${me?" av3-busy":""}${N?` ${N}`:""}`,"data-testid":"approval-card","data-proposal-id":e.id,"data-phase":k.t,children:[n.jsx("div",{className:"av3-scroll",children:n.jsxs("article",{ref:le,className:"av3-body","aria-hidden":me||void 0,children:[x&&n.jsx("div",{className:"av3-next",role:"status",style:{order:-1},children:x}),n.jsx(LN,{proposal:e,currentUserId:r,proposalLinks:l,toolDisplay:i,manifests:a,nameOf:d,mandateTitle:u,topExtras:p,onContentState:({loading:G,readable:J})=>{B(G),Q(J)},onShownSnapshot:G=>{_.current=G}})]})}),n.jsx("span",{id:Z,className:"sr-only",children:"Only you approve. Never let an AI or a browser it controls open this page or approve for you."}),we&&k.t!=="change"&&n.jsxs("footer",{className:"av3-foot",children:[T&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:T}),n.jsxs("div",{className:`av3-btns${m?"":" av3-btns-two"}`,children:[m&&n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-approve","aria-describedby":Z,onClick:()=>void V("approve"),children:Ae}),n.jsxs("button",{type:"button",className:"av3-btn","data-testid":"btn-change-needed",onClick:()=>{F(""),C({t:"change"})},children:[n.jsx("span",{className:"long",children:"Ask for changes"}),n.jsx("span",{className:"short",children:"Changes"})]}),n.jsx("button",{type:"button",className:"av3-btn","data-testid":"btn-reject",onClick:()=>void V("reject"),children:"Reject"})]})]}),!y&&!me&&k.t==="change"&&n.jsxs("footer",{className:"av3-foot av3-chg",children:[n.jsx("label",{className:"av3-chg-l",htmlFor:`chg-${e.id}`,children:"What should the AI change?"}),n.jsx("textarea",{id:`chg-${e.id}`,"data-testid":"change-note",value:E,maxLength:Dc,rows:3,onChange:G=>$(G.target.value),autoFocus:!0}),T&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:T}),n.jsxs("div",{className:"av3-btns av3-btns-two",children:[n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-send-back",onClick:K,children:"Send to the AI"}),n.jsx("button",{type:"button",className:"av3-btn",onClick:()=>{C({t:"idle"}),F("")},children:"Back"})]})]}),k.t==="working"&&n.jsxs("div",{className:"av3-stamp av3-stamp-wait",role:"status","data-testid":"decision-working",children:[n.jsx("span",{className:"av3-spin","aria-hidden":"true"}),zw(k.kind,w),"…"]}),k.t==="done"&&n.jsxs("div",{className:"av3-stamp",role:"status","data-testid":"decision-stamp",children:[n.jsx("svg",{className:"av3-check",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"m5 12.5 4.5 4.5L19 7.5"})}),n.jsx("div",{className:"av3-stamp-w",children:Dw(k.kind,w)}),n.jsx("div",{className:"av3-stamp-t",children:Bw(k.kind,k.result)})]})]})}async function FN(e,{kind:r,note:a,shownHash:i},l){const u=Cj(e,l.activeDomain),d=await du(e);if(r==="approve"){const m=await P.resolveProposal(e.id,"commit",u,{contentHash:d,shownHash:i});return{ticketId:gp(m.receipt)}}if(r==="reject")return await P.resolveProposal(e.id,"reject",u,{...lg(),contentHash:d,shownHash:i}),{};const{noteEncrypted:p}=await P.encryptProposalNote(a??"",Bp(e,l.userId));return await P.resolveProposal(e.id,"reject",u,{outcome:"change_needed",noteEncrypted:p,contentHash:d,shownHash:i}),{}}function ON(e){const r=e instanceof Error?e.message:"Approval failed";return r.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":r.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":r}async function zN(e,{kind:r,note:a,shownHash:i},l){try{const u=await du(e);if(r==="approve"){const p=await P.approveProposal(e.id,u,i);try{const j=await P.getAttestationIntent(e.authorizationId);if(j){const x=await P.decryptIntent({intentCiphertext:j.intentCiphertext,encryptedKey:j.encryptedKey,approverId:l.userId});await P.storeApprovedIntent(e.authorizationId,x)}}catch{}const{requiredApprovals:m,approvedCount:y}=p,v=m!==void 0&&y!==void 0?m-y:void 0;return{ticketId:gp(p.receipt),...v!==void 0&&v>0?{detail:`${v} more approval${v===1?"":"s"} still needed`}:{}}}if(r==="reject")return await P.rejectProposal(e.id,lg(),u,i),{};const{noteEncrypted:d}=await P.encryptProposalNote(a??"",Bp(e,l.userId));return await P.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:d},u,i),{}}catch(u){throw new Error(ON(u))}}const DN={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},BN={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},gm={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function kc(e){const r=Date.now()-e*1e3,a=r/36e5;return a<48?a<1?`${Math.max(1,Math.round(r/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function UN(e){return e.split("__").pop()??e}function WN(e){const r=e.toLowerCase();return r.includes("delete")||r.includes("refund")||r.includes("cancel")||r.includes("revoke")}function Fg(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Fg(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Og({proposal:e,manifests:r,toolDisplay:a,proposalLinks:i,currentUserId:l,mandateTitle:u,onDecided:d,nextLabelText:p,onBusyChange:m}){const{domain:y}=Nt();return n.jsx(Mg,{proposal:e,currentUserId:l,manifests:r,toolDisplay:a,proposalLinks:i,mandateTitle:u,nextLabelText:p,onBusyChange:m,decide:v=>FN(e,v,{activeDomain:y,userId:l}),onDecided:(v,j)=>d==null?void 0:d(e.id,v,j)})}function HN(e){const{item:r}=e;return r.kind==="proposal"&&r.proposal.status==="pending"?n.jsx(Og,{proposal:r.proposal,manifests:e.manifests,toolDisplay:e.toolDisplay,proposalLinks:e.proposalLinks,currentUserId:e.currentUserId??"",mandateTitle:e.mandateTitle,onDecided:e.onDecided}):n.jsx(VN,{...e})}function VN({item:e,proposalLinks:r,toolDisplay:a,manifests:i,currentUserId:l}){const u=e.kind==="proposal",d=u?e.proposal.status:"executed",p=u?e.proposal.tool:e.receipt.action,m=UN(p),y=WN(p),{integrationId:v}=Fn(p),j=wr(v,i),x=u&&d==="rejected"?xk(e.proposal,l??""):null,S=u&&d==="refused"?jk(e.proposal):null,N=mb(u?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),w=xa(u?e.proposal:{toolArgs:void 0,content:void 0}),k=u?w.toolArgs:null,C=u?e.proposal.executionContext:e.receipt.executionContext,E=u?null:e.receipt.cumulativeState,$=u&&w.toolArgs?Lg(r,w.toolArgs):[],T=Object.entries(C??{}),F=jr(e.profileId).testSetup||po(p);return n.jsxs("div",{className:"card id-card",children:[n.jsx(xN,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:m}),F&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"automatic"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[u&&d==="pending"&&(()=>{const M=yN(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:M.urgent?600:400,whiteSpace:"nowrap"},children:M.label})})(),n.jsx("span",{"data-testid":x||S?"outcome-kind":void 0,className:`status-badge ${x?gm[x.kind]:S?gm.REFUSED:BN[d]}`,children:x?x.kind:S?S.kind:DN[d]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:kc(e.sortTimestamp)})]})]}),u&&e.proposal.status==="executed"&&n.jsx(jN,{proposalId:e.proposal.id,systemName:j}),x&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",x.who,", ",kc(x.at)]}),(N??x.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[x.kind==="CHANGE NEEDED"?"Change: ":"Note: ",N??x.note]})]}),S&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",kc(S.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",S.message]})]}),y&&n.jsx("div",{className:"note-attention",style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-attention",children:"Irreversible action"})}),u&&typeof(k==null?void 0:k._imagePreview)=="string"&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),n.jsx("img",{src:k._imagePreview,alt:typeof(k==null?void 0:k.altText)=="string"?k.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),n.jsxs(n.Fragment,{children:[$.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:$.map(M=>n.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:M.description??M.href,children:[M.label," ↗"]},M.label))}),u?n.jsxs(n.Fragment,{children:[k&&n.jsx(Ui,{args:k,display:a}),T.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:T.map(([M,B])=>`${M}=${Fg(B)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Cg,{receipt:e.receipt,manifests:i}),e.receipt.proposalId&&n.jsx(_g,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:i})]})]}),E&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",E.daily.count," action",E.daily.count===1?"":"s",E.daily.amount>0?`, ${E.daily.amount}`:""," · ","this month: ",E.monthly.count,E.monthly.amount>0?`, ${E.monthly.amount}`:""]}),n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[u?"Proposal":"Ticket",": ",e.id]})]})]})}function qN(e,r=[]){const a=new Map;for(const i of e){const l=i.name&&i.email?`${i.name} (${i.email})`:i.name||i.email||i.id;a.set(i.id,l)}for(const i of r){const l=i.userId??i.id;l&&(i.name&&i.email?a.set(l,`${i.name} (${i.email})`):i.name&&a.set(l,i.name))}return a}function KN(e,r){return e.map(a=>r.get(a)??a)}function zg(e){var S;const{groupId:r}=Nt(),a=Ns(e.profileId),[i,l]=f.useState(null),[u,d]=f.useState(new Map),[p,m]=f.useState(!0);f.useEffect(()=>{let N=!0;if(!r){m(!1);return}return m(!0),Promise.all([P.getTeamProfileConfig(r,e.profileId).catch(()=>null),P.getGroupById(r).catch(()=>null),P.listUsers().catch(()=>[])]).then(([w,k,C])=>{N&&(l(w),d(qN(C,(k==null?void 0:k.members)??[])))}).finally(()=>{N&&m(!1)}),()=>{N=!1}},[r,e.profileId]);const y=Aj(i??{}),v=KN(e.pendingApprovers??[],u),j=N=>u.get(N)??N,x=i&&((S=a==null?void 0:a.boundsSchema)!=null&&S.fields)?_b(e.executionContext,i,a.boundsSchema.fields):null;return{loading:p,profileConfig:i,requiredApprovals:y,approverNames:v,nameOf:j,aboveCapReason:x}}function Dg(e,r){return!!e.createdBy&&!!r&&e.createdBy===r}function Bg(e){return(e.pendingApprovers??[]).filter(r=>r!==e.createdBy)}function GN({proposal:e,currentUserId:r,onDecided:a,proposalLinks:i,toolDisplay:l,manifests:u,mandateTitle:d,nextLabelText:p,onBusyChange:m}){const y=Bg(e),v=e.approvedBy??{},j=Object.keys(v).length,x=r in v,S=zg(e),N=Dg(e,r),w=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"approver-progress av3-quiet",children:["Needs ",S.requiredApprovals," approval",S.requiredApprovals===1?"":"s"," from:"," ",y.map((k,C)=>n.jsxs("span",{className:`who${k in v?" done":""}`,style:{marginLeft:C===0?"0.25rem":"0.5rem",fontWeight:k in v?600:void 0},children:[k in v?"✓ ":"",S.nameOf(k),k===r?" (you)":"",C<y.length-1?",":""]},k)),S.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",j," of ",S.requiredApprovals,")"]})]}),S.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",children:[n.jsx("b",{children:"Above the team limit:"})," ",n.jsxs("span",{children:[S.aboveCapReason.fieldLabel,S.aboveCapReason.value!==void 0?` ${S.aboveCapReason.value}`:""," (limit ",String(S.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${S.nameOf(e.createdBy)}.`:""]})]}),N&&n.jsx("p",{className:"blocked-note av3-bold","data-testid":"cant-approve-own-action",children:"You can't approve your own action."}),x&&n.jsxs("p",{className:"av3-quiet",children:["You approved this action.",S.requiredApprovals>1&&j<S.requiredApprovals?` Waiting on ${S.requiredApprovals-j} more approval(s).`:""]})]});return n.jsx(Mg,{proposal:e,currentUserId:r,manifests:u,toolDisplay:l,proposalLinks:i,mandateTitle:d,nameOf:S.nameOf,nextLabelText:p,onBusyChange:m,topExtras:w,canApprove:!N,alreadyDecided:x,decide:k=>zN(e,k,{userId:r}),onDecided:(k,C)=>a==null?void 0:a(e.id,k,C)})}function YN(){const{domain:e,user:r}=Nt(),a=(r==null?void 0:r.id)??"",[i,l]=f.useState("me"),[u,d]=f.useState([]),[p,m]=f.useState([]),[y,v]=f.useState({}),[j,x]=f.useState(!0),S=f.useCallback(async()=>{try{const U=await P.getProposalsForApprover();d(U)}catch{}finally{x(!1)}},[]);Ke("proposal-added",S),Ke("proposal-approved",S),Ke("proposal-rejected",S),Ke("proposal-resolved",S),Ht(S,3e4);const[N,w]=f.useState([]),[k,C]=f.useState(!0),E=f.useCallback(async()=>{try{const U=await P.getMyProposals(e);w(U)}catch{}finally{C(!1)}},[e]);Ke("proposal-added",E),Ke("proposal-approved",E),Ke("proposal-rejected",E),Ke("proposal-resolved",E),Ke("execution-failed",E),Ht(E,3e4,e);const $=f.useMemo(()=>N.filter(U=>{var ie;return U.status==="pending"&&(((ie=U.pendingApprovers)==null?void 0:ie.length)??0)===0}),[N]),T=f.useMemo(()=>dm($,[],{status:"pending"}),[$]),[F,M]=f.useState([]),B=f.useCallback(async()=>{if(a)try{const ie=(await P.getMyProposals(e)).filter(Ee=>Ee.status==="pending"&&Ee.pendingApprovers&&Ee.pendingApprovers.includes(a)&&Ee.approvedBy&&a in Ee.approvedBy);M(ie)}catch{}},[a,e]);Ke("proposal-approved",B),Ke("proposal-rejected",B),Ht(B,3e4,`${a}:${e}`);const[te,Q]=f.useState([]),_=f.useCallback(async()=>{try{const U=await P.getProposalsCreatedByMe();if(U!==null){Q(U);return}Q(await P.getMyPendingProposals())}catch{}},[]);Ke("proposal-added",_),Ke("proposal-approved",_),Ke("proposal-rejected",_),Ht(_,3e4),f.useEffect(()=>{P.getLabelManifests().then(m).catch(()=>{}),P.getToolDisplay().then(v).catch(()=>{})},[]);const z=U=>{var ie;return(ie=p.find(Ee=>Ee.id===U.split("__")[0]))==null?void 0:ie.proposalLinks};f.useEffect(()=>{S(),E(),B(),_()},[]);const[V,K]=f.useState([]),[le,me]=f.useState([]),[we,Ae]=f.useState(!0),[Z,G]=f.useState("pending"),[J,I]=f.useState(null),[D,pe]=f.useState(!1),de=f.useCallback(async()=>{try{const{proposals:U,receipts:ie}=await P.getThread({domain:e,status:Z,sinceDays:7});K(U),me(ie)}catch{}finally{Ae(!1)}},[e,Z]);Ht(de,3e4,`${e}:${Z}`);const $e=f.useMemo(()=>{const U=new Set;for(const ie of V)U.add(ie.profileId);for(const ie of le)U.add(ie.profileId);return Array.from(U).sort()},[V,le]),ve=f.useMemo(()=>dm(V,le,{status:Z,profile:J??void 0,includeAutonomous:D}),[V,le,Z,J,D]),Y=f.useMemo(()=>{const U=new Set,ie=[];for(const Ee of[...F,...te])U.has(Ee.id)||(U.add(Ee.id),ie.push(Ee));return ie.sort((Ee,it)=>it.createdAt-Ee.createdAt)},[F,te]),[he,ee]=f.useState({});f.useEffect(()=>{P.getMyAttestations().then(U=>{const ie={};for(const Ee of U)Ee.authorization_id&&Ee.title&&(ie[Ee.authorization_id]=Ee.title);ee(ie)}).catch(()=>{})},[]);const[oe,Oe]=f.useState(new Set),Fe=f.useMemo(()=>{const U=[];for(const ie of T)ie.kind==="proposal"&&U.push({id:ie.proposal.id,proposal:ie.proposal,route:"queue"});for(const ie of u)U.some(Ee=>Ee.id===ie.id)||U.push({id:ie.id,proposal:ie,route:"approver"});return U.filter(ie=>!oe.has(ie.id)).sort((ie,Ee)=>ie.proposal.createdAt-Ee.proposal.createdAt)},[T,u,oe]),se=f.useMemo(()=>Fe.map(U=>U.id),[Fe]),Te=f.useRef(se);Te.current=se;const _e=Fe.length,Ve=hm("(min-width: 1400px)"),Ge=hm("(prefers-reduced-motion: reduce)"),[ct]=Ss(),[nt,Je]=f.useState(()=>ct.get("open")),[Be,dt]=f.useState(!1),[et,De]=f.useState(!1),[Ie,We]=f.useState(null),[Qe,ut]=f.useState(null),ye=f.useRef([]);f.useEffect(()=>()=>{ye.current.forEach(U=>window.clearTimeout(U))},[]);const ze=(U,ie)=>{ye.current.push(window.setTimeout(U,ie))},Ye=j||k,tt=f.useRef(null);f.useEffect(()=>{if(!(Ie||Ye)){if(se.length===1&&nt===null&&tt.current!==se[0]){tt.current=se[0],Je(se[0]);return}nt&&!se.includes(nt)&&Je(null)}},[se,nt,Ie,Ye]);const st=!Ye&&!Ie&&se.length===1&&nt===null&&tt.current!==se[0],ht=(Ie==null?void 0:Ie.entry)??(nt?Fe.find(U=>U.id===nt)??null:null),jt=ht&&!Ie?se.indexOf(ht.id):-1,qe=f.useCallback(U=>{ut(null),Je(U)},[]),H=f.useCallback((U,ie,Ee)=>{const it=Te.current,ot=Fe.find(rn=>rn.id===U);if(!ot)return;Oe(rn=>new Set(rn).add(U)),We({entry:ot,before:it}),S(),E(),B(),_(),de(),jf();const zn=()=>{const rn=it.filter(Yt=>Yt!==U),sn=Uw(it,U);We(null),dt(!1),Je(sn),ut(sn?{id:sn,label:Hw(rn,sn)}:null),sn&&ze(()=>ut(Yt=>Yt&&Yt.id===sn?null:Yt),2200)};ze(()=>{if(Ge){zn();return}dt(!0),ze(zn,320)},1100)},[Fe,Ge,S,E,B,_,de]),ge=f.useCallback(()=>{S(),E(),B(),de(),jf()},[S,E,B,de]);f.useEffect(()=>{if(i!=="me"||!nt||Ie||et)return;const U=ie=>{if(ie.metaKey||ie.ctrlKey||ie.altKey)return;const Ee=ie.target;if(Ee&&(Ee.tagName==="TEXTAREA"||Ee.tagName==="INPUT"||Ee.tagName==="SELECT"||Ee.isContentEditable))return;const it=qw(ie.key);if(!it)return;const ot=Te.current.indexOf(nt);it==="prev"&&ot>0?(ie.preventDefault(),qe(Te.current[ot-1])):it==="next"&&ot>=0&&ot<Te.current.length-1?(ie.preventDefault(),qe(Te.current[ot+1])):it==="list"&&(ie.preventDefault(),qe(null))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[i,nt,Ie,et,qe]);const be=U=>z(U.proposal.tool),X=U=>U.authorizationId?he[U.authorizationId]:void 0,Ne=U=>{const ie=Qe&&Qe.id===U.id?Qe.label:null;return U.route==="queue"?n.jsx(Og,{proposal:U.proposal,manifests:p,toolDisplay:y[U.proposal.tool],proposalLinks:be(U),currentUserId:a,mandateTitle:X(U.proposal),onDecided:H,nextLabelText:ie,onBusyChange:De},U.id):n.jsx(GN,{proposal:U.proposal,currentUserId:a,manifests:p,toolDisplay:y[U.proposal.tool],proposalLinks:be(U),mandateTitle:X(U.proposal),onDecided:H,nextLabelText:ie,onBusyChange:De},U.id)},ke=n.jsxs("label",{className:"av3-show",children:[n.jsx("span",{children:"Show"}),n.jsxs("span",{className:"av3-select",children:[n.jsx("select",{"data-testid":"queue-view",value:i,onChange:U=>{const ie=U.target.value;l(ie),ie==="all"&&de()},"aria-label":"Show",children:Vw.map(U=>n.jsx("option",{value:U.id,children:U.label},U.id))}),n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4"})})]})]}),ue=n.jsxs("header",{className:"av3-ph",children:[n.jsx("h1",{className:"av3-ph-title",children:"Approvals"}),n.jsx("span",{className:"av3-sp"}),ke]}),He=n.jsxs("header",{className:"av3-ph",children:[!Ve&&n.jsxs("button",{type:"button",className:"av3-back","data-testid":"back-to-list",disabled:et,onClick:()=>qe(null),children:[n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})}),"Approvals ",n.jsx("span",{className:"n",children:_e})]}),n.jsx("span",{className:"av3-sp"}),Ie||et?n.jsx("span",{className:"av3-pos",children:_e>0?`${_e} left`:"none left"}):jt>=0&&se.length>1?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"av3-pos","data-testid":"card-position",children:[jt+1," of ",se.length]}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Previous approval",disabled:jt<=0,onClick:()=>qe(se[jt-1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})})}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Next approval",disabled:jt>=se.length-1,onClick:()=>qe(se[jt+1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})})]}):null]}),kt=n.jsxs("div",{className:"av3-rows",children:[Fe.length>0&&n.jsxs("div",{className:"av3-lh",children:[n.jsxs("span",{children:[Fe.length," waiting for you"]}),n.jsx("span",{children:"oldest first"})]}),Fe.map(U=>n.jsx(Gp,{proposal:U.proposal,manifests:p,titles:he,selected:nt===U.id,onOpen:()=>qe(U.id),who:U.route==="approver"?"Team approval — other people are involved":void 0},U.id))]}),ne=n.jsx("p",{className:"av3-empty","data-testid":"queue-empty",children:"Nothing waiting for you."}),xe=ht&&n.jsx("div",{className:`av3-stage is-open${Ie&&Be?" av3-out":""}${Qe&&Qe.id===ht.id?" av3-in":""}`,"data-testid":Ve?"approval-open":"approval-row","data-proposal-id":ht.id,children:Ne(ht)},ht.id);return n.jsxs("div",{className:`av3-page${Ve?" av3-wide":""}`,"data-view":i,children:[i==="me"&&((Ye||st)&&!Ie?n.jsxs(n.Fragment,{children:[ue,n.jsx("p",{className:"av3-empty",children:"Loading…"})]}):Ve?n.jsxs("div",{className:"av3-split",children:[n.jsxs("section",{className:"av3-pane av3-pane-list","aria-label":"Approvals",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:_e===0?ne:kt})]}),n.jsx("section",{className:"av3-pane av3-pane-card",children:ht?n.jsxs(n.Fragment,{children:[He,n.jsx("div",{className:"av3-cbox",children:xe})]}):_e>0&&n.jsx("p",{className:"av3-empty",children:"Pick an approval from the list."})})]}):ht?n.jsxs("section",{className:"av3-pane","aria-label":"Approval",children:[He,n.jsx("div",{className:"av3-cbox",children:xe})]}):n.jsxs("section",{className:"av3-pane","aria-label":"Approvals",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:_e===0?ne:kt})]})),i==="others"&&n.jsxs("section",{className:"av3-pane","aria-label":"Waiting on others",children:[ue,n.jsx("div",{className:"av3-pane-scroll",children:Y.length===0?n.jsx("p",{className:"av3-empty",children:"Nothing is waiting on others."}):n.jsx("div",{className:"av3-stack",children:Y.map(U=>n.jsx(QN,{proposal:U,currentUserId:a,onCancel:async()=>{try{await P.rejectProposal(U.id,{reason:"cancelled by creator"}),B(),E()}catch(ie){alert(ie instanceof Error?ie.message:"Cancel failed")}},onWithdraw:async()=>{const ie=await du(U);await P.withdrawProposal(U.id,void 0,ie),_(),B()}},U.id))})})]}),i==="all"&&n.jsxs("section",{className:"av3-pane","aria-label":"All approvals",children:[ue,n.jsxs("div",{className:"av3-pane-scroll",children:[n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${Z==="pending"?"selected":""}`,onClick:()=>G("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${Z==="all"?"selected":""}`,onClick:()=>G("all"),children:"All"}),$e.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),$e.map(U=>n.jsx("button",{className:`filter-chip ${J===U?"selected":""}`,onClick:()=>I(J===U?null:U),children:Vt(U)},U)),Z==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${D?"selected":""}`,onClick:()=>pe(!D),title:"Include actions that ran without a human review (automatic mode)",children:[D?"✓ ":"","Automatic actions"]})]})]}),we&&ve.length===0?n.jsx("p",{className:"av3-empty",children:"Loading…"}):ve.length===0?n.jsx("p",{className:"av3-empty",children:Z==="pending"?"Nothing waiting for you.":"Nothing here yet."}):n.jsx("div",{className:"av3-stack av3-inline",children:ve.map(U=>n.jsx(HN,{proposalLinks:U.kind==="proposal"?z(U.proposal.tool):void 0,toolDisplay:U.kind==="proposal"?y[U.proposal.tool]:void 0,manifests:p,currentUserId:a,item:U,mandateTitle:U.kind==="proposal"?X(U.proposal):void 0,onDecided:ge},U.id))})]})]})]})}function JN(e){const r=Date.now()-e*1e3,a=Math.floor(r/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const i=Math.floor(r/36e5);return i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function QN({proposal:e,currentUserId:r,onCancel:a,onWithdraw:i}){const[l,u]=f.useState(!1),[d,p]=f.useState(!1),[m,y]=f.useState(""),v=zg(e),j=Dg(e,r),x=Bg(e),S=e.approvedBy??{},N=Object.keys(S).length,w=x.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},C=async()=>{p(!0),y("");try{await i()}catch($){y($ instanceof Error?$.message:"Withdraw failed")}finally{p(!1)}},E=jr(e.profileId).testSetup||po(e.tool);return n.jsx("div",{className:"card av3-other",children:n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:JN(e.createdAt)})]}),w&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",v.requiredApprovals," approval",v.requiredApprovals===1?"":"s"," from:"," ",x.map(($,T)=>n.jsxs("span",{className:`who${$ in S?" done":""}`,style:{marginLeft:T===0?"0.25rem":"0.5rem",fontWeight:$ in S?600:void 0},children:[$ in S?"✓ ":"",v.nameOf($),$===r?" (you)":"",T<x.length-1?",":""]},$)),v.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",N," of ",v.requiredApprovals,")"]})]}),v.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[v.aboveCapReason.fieldLabel,v.aboveCapReason.value!==void 0?` ${v.aboveCapReason.value}`:""," (limit ",String(v.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${v.nameOf(e.createdBy)}.`:""]})]}),w&&j&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),w&&j?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:C,disabled:d,children:d?"Withdrawing...":"Withdraw"}),m&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:m})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:k,disabled:l,children:l?"Cancelling...":"Cancel"})})]})})}const XN=`# Agent Brief
88
88
 
89
89
  You act on my behalf through Suveren — the gateway that gates every
90
90
  privileged tool call you make. Suveren implements the bounded-authority
@@ -120,4 +120,4 @@ executes. When you propose an action:
120
120
  next.
121
121
  - Never email anyone outside the company without asking first.
122
122
  - When drafting posts, prefer plain language over marketing copy.
123
- `;function QN(){const[e,r]=f.useState(""),[a,i]=f.useState(""),[l,u]=f.useState(!0),[d,p]=f.useState(!1),[m,y]=f.useState(null),[v,j]=f.useState(!1),[x,S]=f.useState(!1);f.useEffect(()=>{P.getCredential("ai-config").then(F=>S(F.configured)).catch(()=>S(!1))},[]);const N=e!==a,w=new Blob([e]).size,k=16*1024,C=w>k;f.useEffect(()=>{if(!N)return;const F=B=>{B.preventDefault(),B.returnValue=""},M=B=>{var _,z;if(B.defaultPrevented||B.button!==0||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey)return;const te=(z=(_=B.target)==null?void 0:_.closest)==null?void 0:z.call(_,"a");if(!te||!te.href)return;let Q;try{Q=new URL(te.href)}catch{return}Q.origin===window.location.origin&&Q.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(B.preventDefault(),B.stopPropagation()))};return window.addEventListener("beforeunload",F),document.addEventListener("click",M,!0),()=>{window.removeEventListener("beforeunload",F),document.removeEventListener("click",M,!0)}},[N]),f.useEffect(()=>{let F=!1;return P.getAgentContext().then(M=>{F||(r(M),i(M))}).catch(M=>{F||y({kind:"error",text:M instanceof Error?M.message:"Failed to load context"})}).finally(()=>{F||u(!1)}),()=>{F=!0}},[]);const E=async()=>{p(!0),y(null);try{await P.saveAgentContext(e),i(e)}catch(F){y({kind:"error",text:F instanceof Error?F.message:"Save failed"})}finally{p(!1)}},$=()=>{r(a),y(null)},T=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||r(JN)};return n.jsxs("div",{className:"su-page is-wide",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"What every connected AI reads first, at the start of each session."})]}),m&&m.kind==="error"&&n.jsx("div",{className:"error-message",style:{marginBottom:"1rem"},children:m.text}),n.jsxs("div",{className:`intent-layout su-duo${x?"":" no-chat"}`,style:{marginBottom:"1rem"},children:[x&&n.jsx("article",{className:"ob-card su-card su-helper intent-pane chat",children:n.jsx(io,{target:{kind:"context"},currentText:e,onApply:F=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||r(F)},greeting:"Tell me what your agent should know — I'll help you write the brief.",placeholder:"Ask for help with your brief…"})}),n.jsxs("article",{className:"ob-card su-card su-brief intent-pane document",children:[n.jsx("textarea",{className:"su-editor","aria-label":"Agent brief",value:e,onChange:F=>r(F.target.value),placeholder:l?"Loading…":"Write what every AI should know — or start from a template.",disabled:l,rows:18}),n.jsxs("div",{className:"su-editor-line",children:[n.jsx("span",{children:N?"Unsaved changes":"Saved"}),n.jsxs("span",{className:C?"ob-bold":void 0,children:[w.toLocaleString()," / ",k.toLocaleString()," bytes",C?" — too long to save":""]})]}),!e.trim()&&!l&&n.jsx("div",{className:"ob-btns is-inline",children:n.jsx("button",{className:"ob-btn",onClick:T,disabled:d,title:"Insert a starter brief covering Suveren basics and example rules",children:"Insert starter template"})}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn",onClick:$,disabled:d||!N,children:"Revert"}),n.jsx("button",{className:"ob-btn is-solid",style:{flex:"3 1 10rem"},onClick:E,disabled:d||!N||C||l,children:d?"Saving…":"Save"})]})]}),x&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(Zp,{open:v,onClose:()=>j(!1),ariaLabel:"Brief assistant",children:n.jsx(io,{target:{kind:"context"},currentText:e,onApply:F=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(r(F),j(!1))},greeting:"Tell me what your agent should know — I'll help you write the brief.",placeholder:"Ask for help with your brief…"})})]})]})]})}function XN(e){const r=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return r&&r[1].replace(/<[^>]+>/g,"").trim()||"Report"}function ZN(e){const r=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!r)return null;const a=r.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const i=a.profile.split("@")[0].split("/").pop();return i?i.charAt(0).toUpperCase()+i.slice(1):null}function e1(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function t1(e,r){const a=r.emailExportError?"cases unknown":`${r.coveredCases.length}/${r.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${r.ticketsReferenced.length}/${r.ticketsInPeriod.length} tickets covered`}function n1(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function r1(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function ym(e,r="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:r}}function s1(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function a1(e,r){const a=r[e];return a==null||a===""||s1(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function i1(e){const r=[];return e.missingCases.length>0&&r.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&r.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),r.length>0?`Not in the report: ${r.join(" · ")}`:null}function o1(e,r){var a;if(r)return r;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const i=(a=e.data)==null?void 0:a.goal;return(i==null?void 0:i.ticketId)??null}return null}const l1="allow-popups allow-popups-to-escape-sandbox",c1="AI analysis — not verified",u1="Green = verified by the gateway — raw signed fields only",d1="Grey dashed = the AI's own analysis, not verified",h1="= translation by the AI, not verified",f1="Übersetzung anzeigen / show translation";function xm(e){var a;const r=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return r<=0?null:`${r} ${r===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function m1(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim()===""}function p1(e,r){return r&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function g1(e,r,a){const i=new URLSearchParams(e);return i.set("element",r),a?i.set("ticket",a):i.delete("ticket"),i}const v1={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function y1(e){return e.filter(r=>r.status==="unverifiable").map(r=>({elementId:r.id,text:`${v1[r.kind]??"Element"}: ${r.reason??"could not be checked"}`}))}function x1(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const r=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,i=[...r.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return i.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),i.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function j1(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const yu={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},w1={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function b1(e,r){return Array.isArray(r.fields)?r.fields.map(i=>({label:i.key,value:i.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(i=>r[i]!==void 0&&r[i]!==null).map(i=>({label:i,value:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])}))}function k1(e,r){const a=w1[e].filter(i=>r[i]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...yu,marginTop:"0.5rem"},children:a.map(i=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:i}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])})]},i))})]})}function kc(e,r){return r?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),r.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",r.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:yu,children:b1(e,r.data??{}).map(({label:a,value:i})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:i})]},a))}),k1(e,r.data??{})]})]}):null}function S1({report:e,elementId:r,ticketParam:a,onClose:i,onSelectTicket:l}){var j;const u=e.elements.find(x=>x.id===r),d=o1(u,a),p=d?e.ticketDetails[d]:void 0,m=x1(u),y=(j=e.proof.verifiedValues.find(x=>x.elementId===r))==null?void 0:j.summary,v=f.useRef(null);return f.useEffect(()=>{const x=v.current;if(!x||typeof x.getBoundingClientRect!="function")return;const S=x.getBoundingClientRect().top;(S<0||S>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[r,a]),n.jsxs("div",{className:"card reports-detail",ref:v,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,children:"Close"})]}),y&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:y}),m.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:m.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===d?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===d,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!d&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:yu,children:Object.keys(u.data??{}).map(x=>{const S=a1(x,u.data??{});return S===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:S})]},x)})})),p&&n.jsxs(n.Fragment,{children:[kc("Ticket",p.ticket),kc("Mandate",p.mandate),kc("Approval",p.approval)]}),d&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",d,"."]})]})}async function N1(e){const{html:r,filename:a}=await e.exportReport();e.download(r,a),await e.refresh()}function jm({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function C1({report:e,open:r,selectedId:a,onOpenElement:i,detail:l}){const{proof:u,coverage:d}=e,p=y1(e.elements),m=i1(d),y=n1(d),v=r1(d),j=ym(u.signaturesValid),x=ym(u.recordsChecked);return n.jsxs("div",{className:`reports-side${r?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:j.kind==="ok"?"msg-ok":void 0,children:j.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),children:[n.jsx("span",{children:S.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),y.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:y.text}),n.jsx(jm,{detail:y.detail})]}):n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Cases"}),n.jsx("b",{children:y.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets in test period"}),n.jsxs("b",{children:[d.ticketsReferenced.length," of ",d.ticketsInPeriod.length]})]}),v&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:v.detail?"reports-error":"reports-note",role:v.detail?"alert":void 0,children:v.text}),n.jsx(jm,{detail:v.detail})]}),m&&n.jsx("p",{className:"reports-missing",children:m})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),title:"Show details",children:[n.jsx("span",{children:S.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]})]})}function E1(){const[e,r]=f.useState(null),[a,i]=f.useState(!0),[l,u]=f.useState(null),[d,p]=f.useState(!1),[m,y]=f.useState(!1),[v,j]=f.useState(null),[x,S]=f.useState(!1),[N,w]=f.useState(!1),[k,C]=Ss(),E=f.useCallback(()=>P.getReport().then(({report:V})=>r(V)).catch(V=>u(V instanceof Error?V.message:String(V))),[]),$=f.useCallback(()=>{i(!0),u(null),E().finally(()=>i(!1))},[E]);f.useEffect(()=>{$()},[$]),f.useEffect(()=>{e&&P.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const T=f.useCallback(()=>{p(!0),P.recheckReport().then(({report:V})=>r(V)).catch(V=>u(V instanceof Error?V.message:String(V))).finally(()=>p(!1))},[]),F=f.useCallback(async()=>{y(!0),j(null);try{await N1({exportReport:()=>P.exportReportWithProof(),download:(V,K)=>{const le=URL.createObjectURL(new Blob([V],{type:"text/html"})),me=document.createElement("a");me.href=le,me.download=K,me.click(),URL.revokeObjectURL(le)},refresh:E})}catch(V){j(V instanceof Error?V.message:String(V))}finally{y(!1)}},[E]),M=k.get("element"),B=k.get("ticket"),te=f.useCallback((V,K)=>{C(g1(k,V,K))},[k,C]),Q=f.useCallback(()=>{const V=new URLSearchParams(k);V.delete("element"),V.delete("ticket"),C(V,{replace:!0})},[k,C]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const _=XN(e.renderedHtml),z=ZN(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:_}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Gi(e.coverage).title,children:[n.jsx("b",{children:Gi(e.coverage).text})," · written ",dp(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[z?`written by the AI under mandate ${z} · `:"","checked ",e1(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:T,disabled:d,children:d?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:F,disabled:m,children:m?"Exporting…":"Export with proof"})]})]}),v&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",v]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:t1(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>S(V=>!V),children:x?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),u1]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),d1," (“",c1,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",h1]})]}),xm(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:xm(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:N,onChange:V=>w(V.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:f1})]}),n.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),m1(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:l1,srcDoc:j1(p1(e,N)),className:"reports-iframe"})]}),n.jsx(C1,{report:e,open:x||!!M,selectedId:M,onOpenElement:V=>te(V),detail:M?n.jsx(S1,{report:e,elementId:M,ticketParam:B,onClose:Q,onSelectTicket:V=>te(M,V)}):void 0})]})]})})}function ms({to:e}){const{search:r,hash:a}=nn();return n.jsx(Gn,{to:`${e}${r}${a}`,replace:!0})}function A1({children:e}){const{user:r,mode:a,domain:i}=Nt();return r?a==="team"&&!i?n.jsx(Gn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(Gn,{to:"/login",replace:!0})}function T1(){const{user:e,handleSessionLocked:r,refreshGroups:a}=Nt();return Ke("session-locked",i=>{const l=i==null?void 0:i.message;r(l)}),Ke("team-membership-changed",()=>{a()}),n.jsxs(Bx,{children:[n.jsx(mt,{path:"/login",element:e?n.jsx(Gn,{to:"/",replace:!0}):n.jsx(j0,{})}),n.jsx(mt,{path:"/onboarding",element:e?n.jsx(C0,{}):n.jsx(Gn,{to:"/login",replace:!0})}),n.jsxs(mt,{element:n.jsx(A1,{children:n.jsx(y0,{})}),children:[n.jsx(mt,{path:"/",element:n.jsx(Eb,{})}),n.jsx(mt,{path:"/mandates",element:n.jsx(tS,{})}),n.jsx(mt,{path:"/mandates/new/intent",element:n.jsx(sk,{})}),n.jsx(mt,{path:"/mandates/new/sign",element:n.jsx(xk,{})}),n.jsx(mt,{path:"/integrations",element:n.jsx(Lk,{})}),n.jsx(mt,{path:"/team",element:n.jsx(Mk,{})}),n.jsx(mt,{path:"/tickets",element:n.jsx(eN,{})}),n.jsx(mt,{path:"/blocked",element:n.jsx(tN,{})}),n.jsx(mt,{path:"/approvals",element:n.jsx(KN,{})}),n.jsx(mt,{path:"/reports",element:n.jsx(E1,{})}),n.jsx(mt,{path:"/agent/new",element:n.jsx(Gn,{to:"/mandates?new=1",replace:!0})}),n.jsx(mt,{path:"/agent/gate",element:n.jsx(ms,{to:"/mandates/new/intent"})}),n.jsx(mt,{path:"/agent/review",element:n.jsx(ms,{to:"/mandates/new/sign"})}),n.jsx(mt,{path:"/authorizations",element:n.jsx(ms,{to:"/mandates"})}),n.jsx(mt,{path:"/groups",element:n.jsx(ms,{to:"/team"})}),n.jsx(mt,{path:"/audit",element:n.jsx(ms,{to:"/tickets"})}),n.jsx(mt,{path:"/proposals",element:n.jsx(ms,{to:"/approvals"})}),n.jsx(mt,{path:"/agent-brief",element:n.jsx(QN,{})}),n.jsx(mt,{path:"/settings",element:n.jsx(hN,{})}),n.jsx(mt,{path:"/settings/services",element:n.jsx(Gn,{to:"/settings",replace:!0})}),n.jsx(mt,{path:"/deploy",element:n.jsx(Gn,{to:"/integrations",replace:!0})})]}),n.jsx(mt,{path:"*",element:n.jsx(Gn,{to:"/",replace:!0})})]})}function I1(){return n.jsx(hj,{children:n.jsx(Tj,{children:n.jsx($j,{children:n.jsx(T1,{})})})})}Oy.createRoot(document.getElementById("root")).render(n.jsx(f.StrictMode,{children:n.jsx(I1,{})}));
123
+ `;function ZN(){const[e,r]=f.useState(""),[a,i]=f.useState(""),[l,u]=f.useState(!0),[d,p]=f.useState(!1),[m,y]=f.useState(null),[v,j]=f.useState(!1),[x,S]=f.useState(!1);f.useEffect(()=>{P.getCredential("ai-config").then(F=>S(F.configured)).catch(()=>S(!1))},[]);const N=e!==a,w=new Blob([e]).size,k=16*1024,C=w>k;f.useEffect(()=>{if(!N)return;const F=B=>{B.preventDefault(),B.returnValue=""},M=B=>{var _,z;if(B.defaultPrevented||B.button!==0||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey)return;const te=(z=(_=B.target)==null?void 0:_.closest)==null?void 0:z.call(_,"a");if(!te||!te.href)return;let Q;try{Q=new URL(te.href)}catch{return}Q.origin===window.location.origin&&Q.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(B.preventDefault(),B.stopPropagation()))};return window.addEventListener("beforeunload",F),document.addEventListener("click",M,!0),()=>{window.removeEventListener("beforeunload",F),document.removeEventListener("click",M,!0)}},[N]),f.useEffect(()=>{let F=!1;return P.getAgentContext().then(M=>{F||(r(M),i(M))}).catch(M=>{F||y({kind:"error",text:M instanceof Error?M.message:"Failed to load context"})}).finally(()=>{F||u(!1)}),()=>{F=!0}},[]);const E=async()=>{p(!0),y(null);try{await P.saveAgentContext(e),i(e)}catch(F){y({kind:"error",text:F instanceof Error?F.message:"Save failed"})}finally{p(!1)}},$=()=>{r(a),y(null)},T=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||r(XN)};return n.jsxs("div",{className:"su-page is-wide",children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"What every connected AI reads first, at the start of each session."})]}),m&&m.kind==="error"&&n.jsx("div",{className:"error-message",style:{marginBottom:"1rem"},children:m.text}),n.jsxs("div",{className:`intent-layout su-duo${x?"":" no-chat"}`,style:{marginBottom:"1rem"},children:[x&&n.jsx("article",{className:"ob-card su-card su-helper intent-pane chat",children:n.jsx(io,{target:{kind:"context"},currentText:e,onApply:F=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||r(F)},greeting:"Tell me what your agent should know — I'll help you write the brief.",placeholder:"Ask for help with your brief…"})}),n.jsxs("article",{className:"ob-card su-card su-brief intent-pane document",children:[n.jsx("textarea",{className:"su-editor","aria-label":"Agent brief",value:e,onChange:F=>r(F.target.value),placeholder:l?"Loading…":"Write what every AI should know — or start from a template.",disabled:l,rows:18}),n.jsxs("div",{className:"su-editor-line",children:[n.jsx("span",{children:N?"Unsaved changes":"Saved"}),n.jsxs("span",{className:C?"ob-bold":void 0,children:[w.toLocaleString()," / ",k.toLocaleString()," bytes",C?" — too long to save":""]})]}),!e.trim()&&!l&&n.jsx("div",{className:"ob-btns is-inline",children:n.jsx("button",{className:"ob-btn",onClick:T,disabled:d,title:"Insert a starter brief covering Suveren basics and example rules",children:"Insert starter template"})}),n.jsxs("div",{className:"ob-btns",children:[n.jsx("button",{className:"ob-btn",onClick:$,disabled:d||!N,children:"Revert"}),n.jsx("button",{className:"ob-btn is-solid",style:{flex:"3 1 10rem"},onClick:E,disabled:d||!N||C||l,children:d?"Saving…":"Save"})]})]}),x&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(Zp,{open:v,onClose:()=>j(!1),ariaLabel:"Brief assistant",children:n.jsx(io,{target:{kind:"context"},currentText:e,onApply:F=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(r(F),j(!1))},greeting:"Tell me what your agent should know — I'll help you write the brief.",placeholder:"Ask for help with your brief…"})})]})]})]})}function e1(e){const r=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return r&&r[1].replace(/<[^>]+>/g,"").trim()||"Report"}function t1(e){const r=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!r)return null;const a=r.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const i=a.profile.split("@")[0].split("/").pop();return i?i.charAt(0).toUpperCase()+i.slice(1):null}function n1(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function r1(e,r){const a=r.emailExportError?"cases unknown":`${r.coveredCases.length}/${r.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${r.ticketsReferenced.length}/${r.ticketsInPeriod.length} tickets covered`}function s1(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function a1(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function vm(e,r="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:r}}function i1(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function o1(e,r){const a=r[e];return a==null||a===""||i1(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function l1(e){const r=[];return e.missingCases.length>0&&r.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&r.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),r.length>0?`Not in the report: ${r.join(" · ")}`:null}function c1(e,r){var a;if(r)return r;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const i=(a=e.data)==null?void 0:a.goal;return(i==null?void 0:i.ticketId)??null}return null}const u1="allow-popups allow-popups-to-escape-sandbox",d1="AI analysis — not verified",h1="Green = verified by the gateway — raw signed fields only",f1="Grey dashed = the AI's own analysis, not verified",m1="= translation by the AI, not verified",p1="Übersetzung anzeigen / show translation";function ym(e){var a;const r=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return r<=0?null:`${r} ${r===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function g1(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim()===""}function v1(e,r){return r&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function y1(e,r,a){const i=new URLSearchParams(e);return i.set("element",r),a?i.set("ticket",a):i.delete("ticket"),i}const x1={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function j1(e){return e.filter(r=>r.status==="unverifiable").map(r=>({elementId:r.id,text:`${x1[r.kind]??"Element"}: ${r.reason??"could not be checked"}`}))}function w1(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const r=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,i=[...r.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return i.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),i.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function b1(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const vu={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},k1={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function S1(e,r){return Array.isArray(r.fields)?r.fields.map(i=>({label:i.key,value:i.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(i=>r[i]!==void 0&&r[i]!==null).map(i=>({label:i,value:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])}))}function N1(e,r){const a=k1[e].filter(i=>r[i]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...vu,marginTop:"0.5rem"},children:a.map(i=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:i}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])})]},i))})]})}function Sc(e,r){return r?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),r.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",r.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:vu,children:S1(e,r.data??{}).map(({label:a,value:i})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:i})]},a))}),N1(e,r.data??{})]})]}):null}function C1({report:e,elementId:r,ticketParam:a,onClose:i,onSelectTicket:l}){var j;const u=e.elements.find(x=>x.id===r),d=c1(u,a),p=d?e.ticketDetails[d]:void 0,m=w1(u),y=(j=e.proof.verifiedValues.find(x=>x.elementId===r))==null?void 0:j.summary,v=f.useRef(null);return f.useEffect(()=>{const x=v.current;if(!x||typeof x.getBoundingClientRect!="function")return;const S=x.getBoundingClientRect().top;(S<0||S>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[r,a]),n.jsxs("div",{className:"card reports-detail",ref:v,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,children:"Close"})]}),y&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:y}),m.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:m.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===d?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===d,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!d&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:vu,children:Object.keys(u.data??{}).map(x=>{const S=o1(x,u.data??{});return S===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:S})]},x)})})),p&&n.jsxs(n.Fragment,{children:[Sc("Ticket",p.ticket),Sc("Mandate",p.mandate),Sc("Approval",p.approval)]}),d&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",d,"."]})]})}async function E1(e){const{html:r,filename:a}=await e.exportReport();e.download(r,a),await e.refresh()}function xm({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function A1({report:e,open:r,selectedId:a,onOpenElement:i,detail:l}){const{proof:u,coverage:d}=e,p=j1(e.elements),m=l1(d),y=s1(d),v=a1(d),j=vm(u.signaturesValid),x=vm(u.recordsChecked);return n.jsxs("div",{className:`reports-side${r?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:j.kind==="ok"?"msg-ok":void 0,children:j.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),children:[n.jsx("span",{children:S.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),y.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:y.text}),n.jsx(xm,{detail:y.detail})]}):n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Cases"}),n.jsx("b",{children:y.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets in test period"}),n.jsxs("b",{children:[d.ticketsReferenced.length," of ",d.ticketsInPeriod.length]})]}),v&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:v.detail?"reports-error":"reports-note",role:v.detail?"alert":void 0,children:v.text}),n.jsx(xm,{detail:v.detail})]}),m&&n.jsx("p",{className:"reports-missing",children:m})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),title:"Show details",children:[n.jsx("span",{children:S.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]})]})}function T1(){const[e,r]=f.useState(null),[a,i]=f.useState(!0),[l,u]=f.useState(null),[d,p]=f.useState(!1),[m,y]=f.useState(!1),[v,j]=f.useState(null),[x,S]=f.useState(!1),[N,w]=f.useState(!1),[k,C]=Ss(),E=f.useCallback(()=>P.getReport().then(({report:V})=>r(V)).catch(V=>u(V instanceof Error?V.message:String(V))),[]),$=f.useCallback(()=>{i(!0),u(null),E().finally(()=>i(!1))},[E]);f.useEffect(()=>{$()},[$]),f.useEffect(()=>{e&&P.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const T=f.useCallback(()=>{p(!0),P.recheckReport().then(({report:V})=>r(V)).catch(V=>u(V instanceof Error?V.message:String(V))).finally(()=>p(!1))},[]),F=f.useCallback(async()=>{y(!0),j(null);try{await E1({exportReport:()=>P.exportReportWithProof(),download:(V,K)=>{const le=URL.createObjectURL(new Blob([V],{type:"text/html"})),me=document.createElement("a");me.href=le,me.download=K,me.click(),URL.revokeObjectURL(le)},refresh:E})}catch(V){j(V instanceof Error?V.message:String(V))}finally{y(!1)}},[E]),M=k.get("element"),B=k.get("ticket"),te=f.useCallback((V,K)=>{C(y1(k,V,K))},[k,C]),Q=f.useCallback(()=>{const V=new URLSearchParams(k);V.delete("element"),V.delete("ticket"),C(V,{replace:!0})},[k,C]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const _=e1(e.renderedHtml),z=t1(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:_}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Gi(e.coverage).title,children:[n.jsx("b",{children:Gi(e.coverage).text})," · written ",dp(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[z?`written by the AI under mandate ${z} · `:"","checked ",n1(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:T,disabled:d,children:d?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:F,disabled:m,children:m?"Exporting…":"Export with proof"})]})]}),v&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",v]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:r1(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>S(V=>!V),children:x?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),h1]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),f1," (“",d1,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",m1]})]}),ym(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:ym(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:N,onChange:V=>w(V.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:p1})]}),n.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),g1(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:u1,srcDoc:b1(v1(e,N)),className:"reports-iframe"})]}),n.jsx(A1,{report:e,open:x||!!M,selectedId:M,onOpenElement:V=>te(V),detail:M?n.jsx(C1,{report:e,elementId:M,ticketParam:B,onClose:Q,onSelectTicket:V=>te(M,V)}):void 0})]})]})})}function ms({to:e}){const{search:r,hash:a}=nn();return n.jsx(Gn,{to:`${e}${r}${a}`,replace:!0})}function I1({children:e}){const{user:r,mode:a,domain:i}=Nt();return r?a==="team"&&!i?n.jsx(Gn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(Gn,{to:"/login",replace:!0})}function R1(){const{user:e,handleSessionLocked:r,refreshGroups:a}=Nt();return Ke("session-locked",i=>{const l=i==null?void 0:i.message;r(l)}),Ke("team-membership-changed",()=>{a()}),n.jsxs(Wx,{children:[n.jsx(mt,{path:"/login",element:e?n.jsx(Gn,{to:"/",replace:!0}):n.jsx(b0,{})}),n.jsx(mt,{path:"/onboarding",element:e?n.jsx(A0,{}):n.jsx(Gn,{to:"/login",replace:!0})}),n.jsxs(mt,{element:n.jsx(I1,{children:n.jsx(j0,{})}),children:[n.jsx(mt,{path:"/",element:n.jsx(Tb,{})}),n.jsx(mt,{path:"/mandates",element:n.jsx(rS,{})}),n.jsx(mt,{path:"/mandates/new/intent",element:n.jsx(ik,{})}),n.jsx(mt,{path:"/mandates/new/sign",element:n.jsx(wk,{})}),n.jsx(mt,{path:"/integrations",element:n.jsx(Fk,{})}),n.jsx(mt,{path:"/team",element:n.jsx(Ok,{})}),n.jsx(mt,{path:"/tickets",element:n.jsx(nN,{})}),n.jsx(mt,{path:"/blocked",element:n.jsx(rN,{})}),n.jsx(mt,{path:"/approvals",element:n.jsx(YN,{})}),n.jsx(mt,{path:"/reports",element:n.jsx(T1,{})}),n.jsx(mt,{path:"/agent/new",element:n.jsx(Gn,{to:"/mandates?new=1",replace:!0})}),n.jsx(mt,{path:"/agent/gate",element:n.jsx(ms,{to:"/mandates/new/intent"})}),n.jsx(mt,{path:"/agent/review",element:n.jsx(ms,{to:"/mandates/new/sign"})}),n.jsx(mt,{path:"/authorizations",element:n.jsx(ms,{to:"/mandates"})}),n.jsx(mt,{path:"/groups",element:n.jsx(ms,{to:"/team"})}),n.jsx(mt,{path:"/audit",element:n.jsx(ms,{to:"/tickets"})}),n.jsx(mt,{path:"/proposals",element:n.jsx(ms,{to:"/approvals"})}),n.jsx(mt,{path:"/agent-brief",element:n.jsx(ZN,{})}),n.jsx(mt,{path:"/settings",element:n.jsx(mN,{})}),n.jsx(mt,{path:"/settings/services",element:n.jsx(Gn,{to:"/settings",replace:!0})}),n.jsx(mt,{path:"/deploy",element:n.jsx(Gn,{to:"/integrations",replace:!0})})]}),n.jsx(mt,{path:"*",element:n.jsx(Gn,{to:"/",replace:!0})})]})}function $1(){return n.jsx(mj,{children:n.jsx(Rj,{children:n.jsx(_j,{children:n.jsx(R1,{})})})})}Dy.createRoot(document.getElementById("root")).render(n.jsx(f.StrictMode,{children:n.jsx($1,{})}));