dispach 0.2.0 → 0.2.2

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 (226) hide show
  1. package/README.md +144 -49
  2. package/dist/APEv2Parser-etzjd528.js +5 -0
  3. package/dist/{FlacParser-6jwner07.js.map → APEv2Parser-etzjd528.js.map} +1 -1
  4. package/dist/{AiffParser-n65syezh.js → AiffParser-y21k3fak.js} +3 -3
  5. package/dist/{AiffParser-n65syezh.js.map → AiffParser-y21k3fak.js.map} +1 -1
  6. package/dist/App-4w3qkcs4.js +11 -0
  7. package/dist/{App-pmqmzsb3.js.map → App-4w3qkcs4.js.map} +1 -1
  8. package/dist/{AsfParser-da1fqvxz.js → AsfParser-wd98k2h4.js} +3 -3
  9. package/dist/{AsfParser-da1fqvxz.js.map → AsfParser-wd98k2h4.js.map} +1 -1
  10. package/dist/{ConfigEditor-4nqbeejh.js → ConfigEditor-vk7vxaa6.js} +3 -3
  11. package/dist/{ConfigEditor-4nqbeejh.js.map → ConfigEditor-vk7vxaa6.js.map} +1 -1
  12. package/dist/{DsdiffParser-gk95sj7t.js → DsdiffParser-cbfaj500.js} +3 -3
  13. package/dist/{DsdiffParser-gk95sj7t.js.map → DsdiffParser-cbfaj500.js.map} +1 -1
  14. package/dist/{DsfParser-b0enevjw.js → DsfParser-tybrja4x.js} +3 -3
  15. package/dist/{DsfParser-b0enevjw.js.map → DsfParser-tybrja4x.js.map} +1 -1
  16. package/dist/FlacParser-7t7da7qy.js +5 -0
  17. package/dist/{APEv2Parser-jdp5yp24.js.map → FlacParser-7t7da7qy.js.map} +1 -1
  18. package/dist/{KeyProbe-rspsxpsr.js → KeyProbe-5anphmb7.js} +3 -3
  19. package/dist/{KeyProbe-rspsxpsr.js.map → KeyProbe-5anphmb7.js.map} +1 -1
  20. package/dist/{MP4Parser-ph7rv2fn.js → MP4Parser-gc94h1n9.js} +3 -3
  21. package/dist/{MP4Parser-ph7rv2fn.js.map → MP4Parser-gc94h1n9.js.map} +1 -1
  22. package/dist/{MatroskaParser-fjk1mpct.js → MatroskaParser-cy2k4fac.js} +3 -3
  23. package/dist/{MatroskaParser-fjk1mpct.js.map → MatroskaParser-cy2k4fac.js.map} +1 -1
  24. package/dist/{MpegParser-vp7cj8ts.js → MpegParser-c460fwf0.js} +3 -3
  25. package/dist/{MpegParser-vp7cj8ts.js.map → MpegParser-c460fwf0.js.map} +1 -1
  26. package/dist/{MusepackParser-v22gft1f.js → MusepackParser-8mq2eabg.js} +3 -3
  27. package/dist/{MusepackParser-v22gft1f.js.map → MusepackParser-8mq2eabg.js.map} +1 -1
  28. package/dist/OggParser-7dnc6apg.js +5 -0
  29. package/dist/{OggParser-as1m8xsa.js.map → OggParser-7dnc6apg.js.map} +1 -1
  30. package/dist/Picker-j7txnm7w.js +5 -0
  31. package/dist/{Picker-jkmd5xnx.js.map → Picker-j7txnm7w.js.map} +1 -1
  32. package/dist/SessionPicker-hpv2ncsb.js +5 -0
  33. package/dist/{SessionPicker-3712ke3k.js.map → SessionPicker-hpv2ncsb.js.map} +3 -3
  34. package/dist/SkillBrowser-qc542n71.js +5 -0
  35. package/dist/{SkillBrowser-qhsyszt4.js.map → SkillBrowser-qc542n71.js.map} +1 -1
  36. package/dist/{WavPackParser-b4qqavzg.js → WavPackParser-kt7cds9c.js} +3 -3
  37. package/dist/{WavPackParser-b4qqavzg.js.map → WavPackParser-kt7cds9c.js.map} +1 -1
  38. package/dist/{WaveParser-fqs1h38f.js → WaveParser-g47ja0vy.js} +3 -3
  39. package/dist/{WaveParser-fqs1h38f.js.map → WaveParser-g47ja0vy.js.map} +1 -1
  40. package/dist/WizardApp-q4p979d1.js +5 -0
  41. package/dist/{WizardApp-qrq36nv8.js.map → WizardApp-q4p979d1.js.map} +3 -3
  42. package/dist/{channels-gf31stv7.js → channels-4t89qpdt.js} +18 -18
  43. package/dist/{channels-gf31stv7.js.map → channels-4t89qpdt.js.map} +1 -1
  44. package/dist/client.d.ts +242 -1
  45. package/dist/client.js +11 -11
  46. package/dist/client.js.map +5 -5
  47. package/dist/config-35r6n1gh.js +24 -0
  48. package/dist/{config-z2cd0c5f.js.map → config-35r6n1gh.js.map} +1 -1
  49. package/dist/credential-dpdgg4j6.js +19 -0
  50. package/dist/{credential-h0wmsjsw.js.map → credential-dpdgg4j6.js.map} +1 -1
  51. package/dist/{index-3s2q0m64.js → index-0444sh6x.js} +4 -4
  52. package/dist/{index-3s2q0m64.js.map → index-0444sh6x.js.map} +1 -1
  53. package/dist/{index-v271gbaz.js → index-095hrkyr.js} +6 -6
  54. package/dist/{index-v271gbaz.js.map → index-095hrkyr.js.map} +1 -1
  55. package/dist/index-1x8mzvz7.js +6 -0
  56. package/dist/{index-rhv6gqpt.js.map → index-1x8mzvz7.js.map} +1 -1
  57. package/dist/index-2bsardvh.js +5 -0
  58. package/dist/{index-tny7c703.js.map → index-2bsardvh.js.map} +2 -2
  59. package/dist/{index-9m6b14b4.js → index-2zjh5zd5.js} +4 -4
  60. package/dist/{index-9m6b14b4.js.map → index-2zjh5zd5.js.map} +1 -1
  61. package/dist/{index-t6xnecdx.js → index-323jvr1g.js} +4 -4
  62. package/dist/{index-t6xnecdx.js.map → index-323jvr1g.js.map} +1 -1
  63. package/dist/{index-gace5ac7.js → index-3826kf9t.js} +5 -5
  64. package/dist/{index-gace5ac7.js.map → index-3826kf9t.js.map} +1 -1
  65. package/dist/index-38gs9anh.js +9 -0
  66. package/dist/{index-b7qc21s7.js.map → index-38gs9anh.js.map} +1 -1
  67. package/dist/index-3c5jt6by.js +5 -0
  68. package/dist/{index-3mvenfbg.js.map → index-3c5jt6by.js.map} +2 -2
  69. package/dist/{index-k2q76dhw.js → index-3vzf253k.js} +7 -7
  70. package/dist/{index-k2q76dhw.js.map → index-3vzf253k.js.map} +1 -1
  71. package/dist/{index-t5d8ey5t.js → index-42e29zs4.js} +4 -4
  72. package/dist/{index-t5d8ey5t.js.map → index-42e29zs4.js.map} +1 -1
  73. package/dist/{index-v7mz396x.js → index-4fj1k64j.js} +4 -4
  74. package/dist/{index-v7mz396x.js.map → index-4fj1k64j.js.map} +1 -1
  75. package/dist/{index-gqbny9gy.js → index-51x0n5z0.js} +6 -6
  76. package/dist/{index-gqbny9gy.js.map → index-51x0n5z0.js.map} +1 -1
  77. package/dist/index-664xcamy.js +110 -0
  78. package/dist/index-664xcamy.js.map +13 -0
  79. package/dist/index-7mn8ack9.js +6 -0
  80. package/dist/{index-qe3ybzh6.js.map → index-7mn8ack9.js.map} +2 -2
  81. package/dist/index-8edck2pr.js +6 -0
  82. package/dist/{index-kktaw552.js.map → index-8edck2pr.js.map} +1 -1
  83. package/dist/index-8h6kewy1.js +9 -0
  84. package/dist/{index-s4a28ctb.js.map → index-8h6kewy1.js.map} +1 -1
  85. package/dist/index-8tmv33mr.js +6 -0
  86. package/dist/{index-v6taf4vn.js.map → index-8tmv33mr.js.map} +1 -1
  87. package/dist/index-9914wh1d.js +6 -0
  88. package/dist/index-9914wh1d.js.map +10 -0
  89. package/dist/{index-y6r1k2yd.js → index-a2eh8dnk.js} +7 -7
  90. package/dist/{index-y6r1k2yd.js.map → index-a2eh8dnk.js.map} +1 -1
  91. package/dist/{index-81vj1bxe.js → index-bqdkm3de.js} +4 -4
  92. package/dist/{index-81vj1bxe.js.map → index-bqdkm3de.js.map} +1 -1
  93. package/dist/{index-rfa0ztab.js → index-dzy19wtf.js} +4 -4
  94. package/dist/{index-rfa0ztab.js.map → index-dzy19wtf.js.map} +1 -1
  95. package/dist/{index-c2qjdz4q.js → index-eqqd4k4f.js} +9 -9
  96. package/dist/{index-c2qjdz4q.js.map → index-eqqd4k4f.js.map} +1 -1
  97. package/dist/{index-g1d06ct5.js → index-ew997be5.js} +7 -7
  98. package/dist/{index-g1d06ct5.js.map → index-ew997be5.js.map} +1 -1
  99. package/dist/{index-0v2gw4mk.js → index-fa9wvpyw.js} +3 -3
  100. package/dist/{index-0v2gw4mk.js.map → index-fa9wvpyw.js.map} +1 -1
  101. package/dist/{index-rvq7t636.js → index-fbsrhcga.js} +4 -4
  102. package/dist/{index-rvq7t636.js.map → index-fbsrhcga.js.map} +1 -1
  103. package/dist/index-fcsg95m5.js +11 -0
  104. package/dist/{index-5nprb9px.js.map → index-fcsg95m5.js.map} +1 -1
  105. package/dist/{index-dgrwpzz9.js → index-gbkma7ds.js} +4 -4
  106. package/dist/{index-dgrwpzz9.js.map → index-gbkma7ds.js.map} +1 -1
  107. package/dist/{index-0m0x1454.js → index-gq1npngp.js} +4 -4
  108. package/dist/{index-0m0x1454.js.map → index-gq1npngp.js.map} +1 -1
  109. package/dist/index-haypwvzd.js +308 -0
  110. package/dist/index-haypwvzd.js.map +21 -0
  111. package/dist/{index-g8n8rhtr.js → index-jc4kmfwa.js} +4 -4
  112. package/dist/{index-g8n8rhtr.js.map → index-jc4kmfwa.js.map} +1 -1
  113. package/dist/index-kjqksgch.js +429 -0
  114. package/dist/index-kjqksgch.js.map +12 -0
  115. package/dist/{index-es4bgkbh.js → index-m6fqx0ch.js} +7 -7
  116. package/dist/{index-es4bgkbh.js.map → index-m6fqx0ch.js.map} +1 -1
  117. package/dist/{index-60jxyzbe.js → index-ma6p7bt4.js} +4 -4
  118. package/dist/{index-60jxyzbe.js.map → index-ma6p7bt4.js.map} +1 -1
  119. package/dist/index-nvc24414.js +6 -0
  120. package/dist/{index-2yj11ykt.js.map → index-nvc24414.js.map} +1 -1
  121. package/dist/index-nxhqf597.js +6 -0
  122. package/dist/{index-m5rmhcez.js.map → index-nxhqf597.js.map} +1 -1
  123. package/dist/{index-jmnjcw61.js → index-p1zy871m.js} +4 -4
  124. package/dist/{index-jmnjcw61.js.map → index-p1zy871m.js.map} +1 -1
  125. package/dist/{index-2pzgta33.js → index-p6ya59m6.js} +5 -5
  126. package/dist/{index-2pzgta33.js.map → index-p6ya59m6.js.map} +1 -1
  127. package/dist/{index-6c4p19m1.js → index-pszmnhgq.js} +2 -2
  128. package/dist/index-qg9bn980.js +1213 -0
  129. package/dist/{index-1h9pqnec.js.map → index-qg9bn980.js.map} +28 -25
  130. package/dist/index-qgsdgbk8.js +5 -0
  131. package/dist/{index-ak304afj.js.map → index-qgsdgbk8.js.map} +2 -2
  132. package/dist/index-r4ax3x4d.js +74 -0
  133. package/dist/index-r4ax3x4d.js.map +13 -0
  134. package/dist/{index-m01mb74d.js → index-snz49ndn.js} +4 -4
  135. package/dist/{index-m01mb74d.js.map → index-snz49ndn.js.map} +1 -1
  136. package/dist/index-twn9bfm2.js +8 -0
  137. package/dist/{index-dwxmy0kx.js.map → index-twn9bfm2.js.map} +2 -2
  138. package/dist/{index-0p9p6fvc.js → index-wc4entme.js} +10 -10
  139. package/dist/{index-0p9p6fvc.js.map → index-wc4entme.js.map} +3 -3
  140. package/dist/{index-wxmqyv4c.js → index-ynsvkqgb.js} +4 -4
  141. package/dist/{index-wxmqyv4c.js.map → index-ynsvkqgb.js.map} +1 -1
  142. package/dist/index-ytxbw8py.js +63 -0
  143. package/dist/{index-fcqy46mh.js.map → index-ytxbw8py.js.map} +2 -2
  144. package/dist/index-yw3fby4n.js +6 -0
  145. package/dist/{index-dh2g58s1.js.map → index-yw3fby4n.js.map} +2 -2
  146. package/dist/{index-ccpq4k6r.js → index-z157at3s.js} +28 -28
  147. package/dist/{index-ccpq4k6r.js.map → index-z157at3s.js.map} +1 -1
  148. package/dist/{index-s78sq9g1.js → index-zce9gy22.js} +64 -64
  149. package/dist/{index-s78sq9g1.js.map → index-zce9gy22.js.map} +1 -1
  150. package/dist/{index-jv7egrh2.js → index-zw6wyas6.js} +4 -4
  151. package/dist/{index-jv7egrh2.js.map → index-zw6wyas6.js.map} +1 -1
  152. package/dist/index.js +308 -292
  153. package/dist/index.js.map +15 -12
  154. package/dist/init.d.ts.map +1 -1
  155. package/dist/lib/agent-template.d.ts +5 -0
  156. package/dist/lib/agent-template.d.ts.map +1 -1
  157. package/dist/lib/commands.d.ts.map +1 -1
  158. package/dist/lib/init-flow.d.ts +7 -30
  159. package/dist/lib/init-flow.d.ts.map +1 -1
  160. package/dist/lib/owner.d.ts +49 -0
  161. package/dist/lib/owner.d.ts.map +1 -0
  162. package/dist/lib/presets.d.ts +44 -0
  163. package/dist/lib/presets.d.ts.map +1 -0
  164. package/dist/lib/provision.d.ts +8 -1
  165. package/dist/lib/provision.d.ts.map +1 -1
  166. package/dist/lib/relay-client.d.ts +17 -0
  167. package/dist/lib/relay-client.d.ts.map +1 -0
  168. package/dist/lib/schema.d.ts +2 -0
  169. package/dist/lib/schema.d.ts.map +1 -1
  170. package/dist/lib/sessions-view.d.ts +2 -0
  171. package/dist/lib/sessions-view.d.ts.map +1 -1
  172. package/dist/lib/source.d.ts +17 -0
  173. package/dist/lib/source.d.ts.map +1 -1
  174. package/dist/lib/wizard.d.ts.map +1 -1
  175. package/dist/owner.d.ts +16 -0
  176. package/dist/owner.d.ts.map +1 -0
  177. package/dist/run.d.ts.map +1 -1
  178. package/dist/serve.d.ts.map +1 -1
  179. package/dist/transcript.d.ts.map +1 -1
  180. package/dist/web-zph4h3p9.js +14 -0
  181. package/dist/{web-stkkwyka.js.map → web-zph4h3p9.js.map} +1 -1
  182. package/dist/wire.d.ts +31 -0
  183. package/dist/wire.js +2 -2
  184. package/dist/wire.js.map +4 -4
  185. package/dist/wrapper-f662ny3r.js +5 -0
  186. package/dist/{wrapper-bwxbqa53.js.map → wrapper-f662ny3r.js.map} +1 -1
  187. package/package.json +5 -2
  188. package/dist/APEv2Parser-jdp5yp24.js +0 -5
  189. package/dist/App-pmqmzsb3.js +0 -11
  190. package/dist/FlacParser-6jwner07.js +0 -5
  191. package/dist/OggParser-as1m8xsa.js +0 -5
  192. package/dist/Picker-jkmd5xnx.js +0 -5
  193. package/dist/SessionPicker-3712ke3k.js +0 -5
  194. package/dist/SkillBrowser-qhsyszt4.js +0 -5
  195. package/dist/WizardApp-qrq36nv8.js +0 -5
  196. package/dist/config-z2cd0c5f.js +0 -24
  197. package/dist/credential-h0wmsjsw.js +0 -19
  198. package/dist/index-026q0y3a.js +0 -6
  199. package/dist/index-026q0y3a.js.map +0 -10
  200. package/dist/index-1h9pqnec.js +0 -1194
  201. package/dist/index-1wxw30j1.js +0 -74
  202. package/dist/index-1wxw30j1.js.map +0 -13
  203. package/dist/index-2yj11ykt.js +0 -6
  204. package/dist/index-358nsn9t.js +0 -65
  205. package/dist/index-358nsn9t.js.map +0 -21
  206. package/dist/index-3mvenfbg.js +0 -5
  207. package/dist/index-5nprb9px.js +0 -11
  208. package/dist/index-ak304afj.js +0 -5
  209. package/dist/index-b7qc21s7.js +0 -9
  210. package/dist/index-dh2g58s1.js +0 -6
  211. package/dist/index-dwxmy0kx.js +0 -8
  212. package/dist/index-fcqy46mh.js +0 -63
  213. package/dist/index-kktaw552.js +0 -6
  214. package/dist/index-m5rmhcez.js +0 -6
  215. package/dist/index-qe3ybzh6.js +0 -6
  216. package/dist/index-rhv6gqpt.js +0 -6
  217. package/dist/index-s4a28ctb.js +0 -9
  218. package/dist/index-tny7c703.js +0 -5
  219. package/dist/index-v6taf4vn.js +0 -6
  220. package/dist/index-y605a1rj.js +0 -429
  221. package/dist/index-y605a1rj.js.map +0 -11
  222. package/dist/index-z88f35vs.js +0 -96
  223. package/dist/index-z88f35vs.js.map +0 -13
  224. package/dist/web-stkkwyka.js +0 -14
  225. package/dist/wrapper-bwxbqa53.js +0 -5
  226. /package/dist/{index-6c4p19m1.js.map → index-pszmnhgq.js.map} +0 -0
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ import{Yt,R,te,xe,Jt,fr,hr,Br,ys,qr,Vr,Qs,ms,so,Ss,ws,Ds,Wr,bs,iA,Os,Zr,PA,yr,$r,Xr,go,ei,Rs,sA,un,co,GA,Ai,_s,ks,vs,ni,Ls,Ps,Gs,Fs,Us}from"./index-r4ax3x4d.js";import{Ze,si,ai,Ks,Ys,n,s,_,He,E,r,pt,x,D,ft}from"./index-qg9bn980.js";var cn=()=>{let a={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(p){return a[p]??null}let d={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},u={nan:"NaN"};return(p)=>{switch(p.code){case"invalid_type":{let m=u[p.expected]??p.expected,b=Ks(p.input),S=u[b]??b;return`Invalid input: expected ${m}, received ${S}`}case"invalid_value":if(p.values.length===1)return`Invalid input: expected ${ai(p.values[0])}`;return`Invalid option: expected one of ${si(p.values,"|")}`;case"too_big":{let m=p.inclusive?"<=":"<",b=e(p.origin);if(b)return`Too big: expected ${p.origin??"value"} to have ${m}${p.maximum.toString()} ${b.unit??"elements"}`;return`Too big: expected ${p.origin??"value"} to be ${m}${p.maximum.toString()}`}case"too_small":{let m=p.inclusive?">=":">",b=e(p.origin);if(b)return`Too small: expected ${p.origin} to have ${m}${p.minimum.toString()} ${b.unit}`;return`Too small: expected ${p.origin} to be ${m}${p.minimum.toString()}`}case"invalid_format":{let m=p;if(m.format==="starts_with")return`Invalid string: must start with "${m.prefix}"`;if(m.format==="ends_with")return`Invalid string: must end with "${m.suffix}"`;if(m.format==="includes")return`Invalid string: must include "${m.includes}"`;if(m.format==="regex")return`Invalid string: must match pattern ${m.pattern}`;return`Invalid ${d[m.format]??p.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${p.divisor}`;case"unrecognized_keys":return`Unrecognized key${p.keys.length>1?"s":""}: ${si(p.keys,", ")}`;case"invalid_key":return`Invalid key in ${p.origin}`;case"invalid_union":if(p.options&&Array.isArray(p.options)&&p.options.length>0)return`Invalid discriminator value. Expected ${p.options.map((b)=>`'${b}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${p.origin}`;default:return"Invalid input"}}};function Ne(){return{localeError:cn()}}Ze(Ne());import{existsSync as fe,mkdirSync as dn,readFileSync as Ge,rmSync as pn,statSync as hn,writeFileSync as qe}from"node:fs";import{mkdtemp as fn,readdir as mn,readFile as Me,rm as gn}from"node:fs/promises";import{tmpdir as vn}from"node:os";import{basename as ye,dirname as be,join as De,relative as yn,resolve as he,sep as bn}from"node:path";import{createReadStream as Ln}from"node:fs";import{stat as Un}from"node:fs/promises";import{Readable as et}from"node:stream";import{createGzip as Bn}from"node:zlib";function Yr(a={}){let e=a.now??(()=>new Date),d=new Map;return{approver:(p)=>new Promise((m)=>{let b={pending:{approvalId:p.approvalId,agentId:p.agentId,sessionKey:p.sessionKey,slug:p.slug,callId:p.callId,match:p.match,mutating:p.mutating,reason:p.reason,requestedAt:e().toISOString()},settle:(S)=>{d.delete(p.approvalId),m(S)}};d.set(p.approvalId,b),p.signal.addEventListener("abort",()=>b.settle(!1),{once:!0})}),pending:(p)=>[...d.values()].map((m)=>m.pending).filter((m)=>m.agentId===p).sort((m,b)=>m.requestedAt.localeCompare(b.requestedAt)),resolve:(p,m)=>{let b=d.get(p);if(b===void 0)return!1;return b.settle(m),!0},get size(){return d.size}}}function f(a,e,d={}){return new Response(JSON.stringify({error:a}),{status:e,headers:{"content-type":"application/json; charset=utf-8",...d}})}function We(){return f({code:"unauthorized",message:"Missing or invalid bearer token.",hint:"Send Authorization: Bearer <token>, where the token is either the value of the variable named by server.tokenEnv or an operator key from POST /v1/keys. A revoked key, an expired one and a wrong one answer the same way on purpose."},401)}function kt(){return f({code:"claim_spent",message:"That claim has already been exchanged.",hint:"A claim is good for one key. Use the key it minted; if it is lost, restart with --claim to print a new one — a claim lives in the process rather than the database, so it never outlives the boot that printed it."},401)}function wn(a,e){return f({code:"capability_required",message:`This credential cannot ${e}.`,hint:`The key is scoped, and "${a}" is not among its capabilities. GET /v1/keys shows what each key may do; mint another with POST /v1/keys, or use the server token. An unscoped key has all of them.`,field:"scope.can"},403)}function Ve(a,e){if(a.length!==e.length)return!1;let d=0;for(let u=0;u<a.length;u+=1)d|=a.charCodeAt(u)^e.charCodeAt(u);return d===0}function xn(a){let e=a.headers.get("authorization")??"";return e.startsWith("Bearer ")?e.slice(7):""}async function kn(a){let e=xn(a.request);if(a.expected!==void 0&&Ve(e,a.expected))return{kind:"token"};if(e!==""){let d=await a.keys.findLive(await hr(e),new Date(a.at).toISOString());if(d!==void 0)return await a.keys.touch(d.keyId,new Date(a.at).toISOString()),{kind:"key",keyId:d.keyId,label:d.label,...d.scope===void 0?{}:{scope:d.scope}};if(a.claim!==void 0&&Ve(e,a.claim.token)){if(a.request.method!=="POST"||a.pathname!=="/v1/keys")return We();if(!a.claim.live())return kt();return{kind:"claim"}}}return We()}var jt="dispach.bearer";function jn(a){let e=a.headers.get("sec-websocket-protocol");if(e===null)return;let d=e.split(",").map((p)=>p.trim()),u=d.indexOf(jt);return u===-1?void 0:d[u+1]??""}function Sn(a,e){let d=new Headers(a.headers);return d.set("authorization",`Bearer ${e}`),new Request(a.url,{method:a.method,headers:d})}function N(a,e){return a.meta({...e})}function ie(a,e){return a.meta({description:e})}var St=r({id:N(n().trim().min(1),{code:"sender_invalid",hint:'Send { "from": { "id": "agent:ops-bot", "kind": "agent" } }, or omit it entirely for a turn the token-holder is sending itself.',description:"Stable identifier for the sender. Appears on the turn row and in events."}),kind:N(D(iA,{error:(a)=>{let e=typeof a.input==="string"?a.input:void 0,d=e===void 0?void 0:Yt(e,iA);return`from.kind must be one of: ${iA.join(", ")}.${d===void 0?"":` Did you mean "${d}"?`}`}}),{code:"sender_invalid",hint:'This field decides the trust boundary — "agent" fences the message and blocks mutating tools for the turn, "user" does not — so there is no default and an unknown value is refused rather than guessed at. A turn the token-holder is sending itself omits "from".',description:'The trust boundary. "agent" fences the text as data and blocks mutating tools for the whole turn.'}),name:N(n().optional(),{code:"sender_invalid",hint:"A display name, shown beside the sender id. Omit it rather than sending an empty string.",description:"Human-readable name for the sender."})}).meta({description:"Attribution for a turn somebody other than the token-holder is sending. Omit for your own."}),Nn=N(pt([ft("none"),r({channel:n().min(1),to:n().min(1)})]),{code:"deliver_invalid",hint:'A bare channel id is not enough on an API turn: the request has no originating conversation, so there is no recipient to infer. Send { "channel": "tg", "to": "12345" }, or "none" to read the reply from the event stream.',description:'Where the reply goes. "none" leaves it on the event stream and in the store.'}),Qe=8000,Nt=r({text:N(n().trim().min(1),{code:"message_text_required",hint:'Send { "text": "..." }. An empty turn would be billed for a full prompt and produce nothing.',description:"What to say to the agent."}),sessionKey:ie(n().min(1).optional(),"Which conversation this belongs to. Defaults to `api:default`."),role:N(n().trim().min(1).optional(),{code:"model_role_unknown",hint:"Name a role declared under model: in the manifest (GET /v1/agents/:id/config lists them), or omit role to run on main. A person adds one with PATCH /config path model.<name>.",description:"A model role to run this turn on instead of main: one declared under `model:`, as a schedule names one with `role:`. This turn only; the conversation's other turns are unaffected. Refused before the turn starts when no such role is declared."}),runtimeNote:N(n().trim().min(1).max(Qe).optional(),{code:"message_note_invalid",hint:`Send runtimeNote as non-empty text of at most ${Qe} characters: the active project, today's date in the person's zone, an attachment's extracted text.`,description:"Your application's note about this message: shown to the model in its own block before the text, labelled as not written by the person, for this turn only. Kept on the turn record (`GET …/turns`), never in history. Refused when `from` is an agent."}),peerAsk:N(r({askedBy:n().trim().min(1).max(200)}).strict().optional(),{code:"message_peer_ask_invalid",hint:'Send { "peerAsk": { "askedBy": "<silo>/<agent>" } }, naming the agent that asked, or omit it.',description:"Marks this turn as another agent's ask (`docs/24-SPEC-PEER-ASK.md`): it runs without `handoff` and `ask_agent`, so it is one hop, and the agent is told who asked. It only narrows what the turn may do, so any caller may set it; the control plane's relay always does."}),images:N(E(r({path:n().optional(),data:n().optional(),mediaType:n().optional()}).strict()).optional(),{code:"message_images_invalid",hint:`Send images as [{ "path": "files/…/shot.png" }] (relative to the agent's directory), or [{ "data": "<base64>", "mediaType": "image/png" }].`,description:"Images sent with this message: PNG, JPEG, GIF or WebP, at most five, 3.75 MB each. A path inside the agent's directory, or inline base64 (within the 1 MB body limit). The model receives them on this turn; history keeps an `[image: <path>]` line."}),deliver:Nn.optional(),from:St.optional(),stream:ie(_().optional(),"Stream the turn's events inline as SSE rather than returning a handle."),chunks:ie(_().optional(),"Include per-token `model.chunk` frames. Off by default — the reader decides."),children:ie(_().optional(),"Include the events of subagents this turn runs (they carry `parentTurnId`). Off by default.")}),Et=r({content:N(n(),{code:"workspace_content_required",hint:'Send { "content": "<the whole file>" }. It replaces the file; frontmatter included.',description:"The file's new text, in full, frontmatter included."})}),Tt=r({vars:N(x(n(),N(n(),{code:"template_value_invalid",hint:"Template values are one line of text, sent as strings.",description:"One variable's value."})),{code:"vars_required",hint:'Send { "vars": { "userName": "…" } }: the template variables to change. The rest keep the values the agent was made with.',description:"The template variables to change. Only files nobody has edited since they were rendered are rewritten."})}),Ct=r({providers:N(E(n().min(1)).min(1).optional(),{code:"tools_refresh_providers_invalid",hint:`Name provider ids from the agent's tools.providers, e.g. { "providers": ["composio"] }, or send {} to refresh every one.`,description:"Which providers to refresh. Omit for all of them."})}),At=r({channel:N(n().min(1),{code:"delivery_channel_required",hint:`Name a channel id from the agent's manifest, e.g. { "channel": "tg", ... } — the id, not the type.`,description:"The channel id to send on."}),to:N(n().min(1),{code:"delivery_recipient_required",hint:"The channel's own address for the conversation: a Telegram chat id, a WhatsApp JID, a Slack channel id. The peer id an inbound message arrived with is always right.",description:"Who to send it to, in the channel's own addressing."}),text:N(n().trim().min(1),{code:"delivery_text_required",hint:'Send { "text": "..." }. An empty message has nothing to deliver.',description:"The exact text to send. No model turn runs."}),key:N(n().min(1),{code:"delivery_key_required",hint:"Any string unique to this send, such as your own message id. A retry with the same key is not sent or recorded twice.",description:"Idempotency key: a repeated key is accepted and does nothing."})}),_t=r({granted:N(_(),{code:"approval_decision_required",hint:'Send { "granted": true } or { "granted": false }. There is no default: one direction would deny a call over a typo and the other would grant one, and neither is a decision anybody made.',description:"Whether the blocked tool call may proceed."})}),En=r({agents:E(n().min(1)).optional().meta({code:"key_scope_agents_invalid",hint:'Send { "agents": ["milo"] } — a list of agent ids. Omit it for a key that reaches every agent. An id naming no agent on this server is reported rather than silently matching nothing.',description:"Agent ids this key may reach. Absent means all of them."}),sessions:n().min(1).optional().meta({code:"key_scope_sessions_invalid",hint:'Send { "sessions": "team_42:" } — a session-key prefix, with an optional trailing "*". A prefix rather than a list, because the conversations this key will cover do not exist yet when it is minted.',description:"Session-key prefix. Absent means every session."}),can:E(D(["read","chat","write","admin","peer"])).optional().meta({code:"key_scope_can_invalid",hint:'Send { "can": ["chat", "read"] }. read (every GET), chat (send a message, answer an approval, stop a turn), write (schedules, phase, clearing a session), admin (keys, provisioning, start/stop/reload), and peer (a plugin route that asks for it — an A2A endpoint — and nothing else). Absent means all five; an empty array means none, and is honoured as written.',description:"Capabilities this key may exercise. Absent means all of them."}),participant:n().min(1).optional().meta({code:"key_scope_participant_invalid",hint:'Send { "participant": "user:018f…" } — the id this key speaks for. Every turn it starts acts for that participant: a from naming anyone else is refused, and an omitted one is filled in. Omit it for a backend that names senders itself.',description:"The participant every turn this key starts acts for. Absent: any sender."}),expiresIn:s().int().positive().optional().meta({code:"key_scope_expires_invalid",hint:'Send { "expiresIn": 3600 } — whole seconds from now, as a number. Relative rather than an absolute instant, because that would need the caller and this server to agree about the clock; the response reports the absolute expiresAt this server computed.',description:"Seconds until this key stops authenticating. Absent means never."})}),Pt=r({label:N(n(),{code:"key_label_required",hint:'Send { "label": "my browser" }. A label is required rather than defaulted because it is the only thing distinguishing two credentials in a listing, and "key 2" is a name nobody can act on when deciding which to revoke.',description:"How this credential is shown in a listing. Required; see `keyLabelProblem`."}),scope:En.optional().meta({code:"key_scope_invalid",hint:'Send { "scope": { "agents": ["milo"], "can": ["chat"] } }, or omit it entirely for a key that reaches everything — which is what every key minted before scopes existed does.',description:"Opt-in narrowing. Absent is an unscoped key."})}),It=r({phase:N(n().min(1),{code:"phase_invalid",hint:"Send the name of a phase this agent's manifest declares. `GET /v1/agents/:id` lists them.",description:"The phase to move this session into."})}),$t=r({recall:N(_(),{code:"recall_invalid",hint:'Send { "recall": false } to keep this conversation out of history recall, or true to put it back. Its messages are kept either way.',description:"Whether this conversation is indexed for history recall."})}),Ot=r({reason:N(n().optional(),{code:"agent_stop_invalid",hint:"A short note, recorded on the row and shown wherever the agent is reported as off.",description:"Why, for whoever reads the listing later."})}),Ye=r({path:N(n().min(1),{code:"config_path_unknown",hint:"GET /v1/agents/:id/config lists every field this surface may change, with what each one does.",description:"A dotted path, exactly as it appears in the manifest — `tools.pinned`, `model.main.id`."}),value:N(n().optional(),{code:"config_value_unreadable",hint:'Text, the way it is typed at a terminal: a bare word, a number, true or false, a list as ["a", "b"], or a map as {k: v}. Quote anything containing a colon or a "#". To take a field out, send { "remove": true } instead.',description:"The new value, as text. Read by the same parser the `config` command uses. Required unless `remove` is true."}),remove:N(ft(!0).optional(),{code:"config_remove_invalid",hint:'Send { "path": "…", "remove": true } with no value to take a field out of the manifest, or a value to set it.',description:"Take the field out of the manifest instead of setting it, so it returns to its default. Checked like any edit: a required field is refused. A field that is not there is left as it is. Not sent together with `value`."}),confirm:ie(_().optional(),"Required only for a field whose own row carries a `confirm` sentence. Absent is not consent.")}),Tn=Ye.partial({path:!0}).extend({changes:ie(E(Ye).min(1).optional(),"Several changes, each `{path, value}` or `{path, remove: true}`, applied in order and checked against the file as the earlier ones left it. One write and one reload; any refusal writes nothing. Sent instead of a top-level `path`.")}),Cn=r({enabled:ie(_().optional(),"Switch the channel on or off. It takes effect at the agent's next start, because a channel is constructed at boot."),credential:N(n().min(1).optional(),{code:"channel_credential_unreadable",hint:"The value goes into the .env beside the manifest at 0600, under the variable that channel's own entry names. Send a non-empty string; an empty one fails the load exactly as a missing variable does.",description:"The channel's credential — a Telegram bot token. Never returned by any route; only whether it is set."})}),zt=r({answers:N(x(n(),N(n(),{code:"provision_answer_invalid",hint:"Answers arrive as strings from the terminal and from here, and are validated per step. Send the value as a string — including a boolean-looking choice, whose values are named in GET /v1/provision.",description:"One answer. Always text, whatever the step's type looks like."})).optional(),{code:"provision_answers_required",hint:'Send { "answers": { "name": "milo", … } }. Every step you leave out takes its default, exactly as `init --yes` does with flags; GET /v1/provision lists them.',description:"A subset of the wizard's steps, as strings. `GET /v1/provision` lists every step with its prompt, default and choices. Send this or `template`, not both."}),template:N(n().min(1).optional(),{code:"provision_template_invalid",hint:"Send the template's name as a string. GET /v1/templates lists what this server has.",description:"Create the agent from a template in this server's sandbox instead of from answers. Needs `name`; takes `vars`."}),name:N(n().optional(),{code:"provision_name_required",hint:'Send { "template": "…", "name": "Acme store" }. The id every route keys on is derived from it.',description:"The new agent's name, with `template`. Its slug becomes the id; the template sees both as {{agent.name}} and {{agent.id}}."}),vars:N(x(n(),N(n(),{code:"template_value_invalid",hint:"Template values are one line of text, sent as strings.",description:"One variable's value."})).optional(),{code:"template_value_invalid",hint:`Send { "vars": { "store": "Acme" } }, every value a string. GET /v1/templates lists each template's variables.`,description:"Values for the template's declared variables. A secret variable's value goes to the agent's .env and is never returned."})}),Rt=(a)=>N(n().trim().min(1),{code:"participant_id_invalid",hint:'A participant id as your system knows the person, e.g. "user:018f…". Agents are "agent:<agentId>".',description:`The participant id${a===""?"":` (${a})`}.`}),Mt=r({id:Rt(""),name:ie(n().min(1).optional(),"A display name, shown to agents beside the id."),role:N(D(["admin","member"]).optional(),{code:"participant_role_invalid",hint:'Either "admin" (may assign agents to members) or "member". Omitted is "member".',description:'What the participant may do: "admin" also assigns agents.'}),title:ie(n().trim().min(1).max(120).optional(),"A job title, as the team knows the person. Told to an agent answering another member's agent about whom it represents and who is asking. Not a permission."),timezone:ie(n().trim().min(1).optional(),`An IANA timezone, such as "Europe/London". Told to an agent answering another member's agent, so "tomorrow at nine" means the right hour. Refused when the runtime does not know it.`),channelIds:N(E(n().min(1)).optional(),{code:"participant_channel_ids_invalid",hint:'A list of the person\'s own channel senders as `<channel type>:<id or handle>`, e.g. ["telegram:@ada", "whatsapp:+44 7700 900123"].',description:"The person's own channel senders, matched like allowFrom. Under sessions.scope peer, their turns from these channels and from the API share one conversation. Absent, a channel turn from them keeps its own."})}),Dt=r({kind:N(D(["room","dm"]),{code:"conversation_kind_invalid",hint:'"dm" is one human and one agent and is always answered; "room" is anyone, and an agent answers only when mentioned.',description:"A room or a direct conversation."}),members:N(E(n().trim().min(1)).min(1),{code:"conversation_members_required",hint:'Participant ids: registered humans, and agents as "agent:<agentId>".',description:"Who is in it."}),title:ie(n().min(1).optional(),"A name for a room, for the embedder's own listing.")}),Lt=r({add:N(E(n().trim().min(1)).optional(),{code:"conversation_members_required",hint:"Participant ids to add.",description:"Participant ids to add."}),remove:N(E(n().trim().min(1)).optional(),{code:"conversation_members_required",hint:"Participant ids to remove.",description:"Participant ids to remove."})}),Ut=r({text:N(n().trim().min(1),{code:"message_text_required",hint:'Send { "text": "…" }.',description:"What was said."}),mentions:N(E(n().trim().min(1)).optional(),{code:"conversation_mention_unknown",hint:'Member participant ids this message addresses, e.g. ["agent:crew"]. In a room only a mentioned agent answers.',description:"Members this addresses. In a room, the agents that answer."}),authorId:N(n().trim().min(1).optional(),{code:"conversation_author_required",hint:"Who said it. A key bound to a participant fills this in and may name no one else; an unbound key must name the author.",description:"The human member who said it. Filled in from a participant-bound key."})}),Bt=r({from:St.optional()}),Ft=r({participantId:Rt("assignee"),channelIds:N(E(n().min(1)).optional(),{code:"assignee_channel_ids_invalid",hint:'A list of the owner\'s own channel senders as `<channel type>:<id or handle>`, e.g. ["telegram:@moeen", "whatsapp:+880 1711-223344", "slack:U0123ABC"].',description:"The owner's own channel senders (pilot.15), matched like allowFrom: case folded, `@` optional, a phone number by its digits. A turn from one of these acts as the owner: it keeps the owner's personal tools (Composio, MCP servers marked personal) and, under sessions.scope owner, lands in the owner's conversation. Absent, no channel turn does."})}),Kt=r({presence:N(D(["online","offline"]),{code:"presence_invalid",hint:'Send { "presence": "online" } or "offline". It is pushed by you, never inferred; until it is, a person reads as online and no agent stands in for them.',description:"Whether the person is there. Decides whether their agent stands in for them in a DM."})}),Ht=r({scope:N(n().trim().min(1),{code:"memory_scope_invalid",hint:'A shared scope: "space", "owner:<participantId>" or "project:<projectId>".',description:"Where the note goes. `owner:<id>` is written only by that person; `space` by an admin or the designated space writer; a project by an admin."}),text:N(n().trim().min(1),{code:"memory_note_empty",hint:'Send { "scope": "space", "text": "…" } — one or two sentences worth remembering.',description:"The note. Recalled into an agent's prompt when a turn is about it."})}),Gt=r({name:ie(n().min(1).optional(),"A display name for the embedder's own listing."),agents:N(E(n().trim().min(1)).optional(),{code:"project_agents_invalid",hint:'Agent ids, bare ("crew", not "agent:crew"). Given, it replaces the membership; omitted, it is left alone.',description:"The agents that share this project's memory. Replaces the list when given."})}),qt=r({writer:N(n().trim().min(1),{code:"space_writer_invalid",hint:'A registered participant id, or "agent:<agentId>" for an agent whose memory_write should go to the space.',description:"The one non-admin who may write the space. An agent named here saves every memory_write to the space, so name one that holds nobody's private context."})}),Wt=r({bundle:N(x(n(),He()),{code:"bundle_files_invalid",hint:'Send { "bundle": <the body GET /v1/agents/:id/export returned> }.',description:"A bundle from GET /v1/agents/:id/export: MEMORY.md, memory/<name>.md and knowledge/<name>.md, nothing else."}),mode:N(D(["skip","overwrite"]).optional(),{code:"bundle_mode_invalid",hint:'Either "skip" (keep a knowledge file that exists, the default) or "overwrite". Memory is always merged note by note.',description:"What to do with a knowledge file the agent already has. Memory is merged either way."})}),Vt=r({approve:N(_(),{code:"action_decision_required",hint:'Send { "approve": true } to run the queued call as it was asked, or false to decline it.',description:"Run the queued call (true) or decline it (false)."})}),Qt=r({url:N(n().min(1),{code:"webhook_url_invalid",hint:"Send an absolute https:// URL. A receiver on a private network needs the operator to allow it in WEBHOOK_ALLOW.",description:"Where deliveries are POSTed. Checked against every address it resolves to, at subscribe and at every send."}),types:N(E(n()).min(1),{code:"webhook_types_required",hint:'Send { "types": ["turn.end", "approval.requested"] }. Any event type except model.chunk; the wire spec lists them.',description:"The event types to deliver. `model.chunk` is not deliverable."}),agents:N(E(n()).min(1).optional(),{code:"webhook_scope_invalid",hint:"Send agent ids this credential can reach, or leave agents out to hear every agent it can reach.",description:"Narrow the subscription to these agents. It can never hear more than the creating credential reaches."})}),Xt=r({values:N(x(n(),N(n(),{code:"secret_value_invalid",hint:"Send each value as a non-empty string.",description:"One variable's value. Written to the agent's .env at 0600; never returned."})),{code:"secrets_values_required",hint:'Send { "values": { "MODEL_API_KEY": "…" } }. GET /v1/agents/:id/secrets lists the variables this agent reads.',description:"Variables to write into the agent's .env, keyed by name. Only names the agent's manifest reads are accepted."})});function K(a,e){let d=a.safeParse(e??{});if(d.success)return{ok:!0,value:d.data};let u=d.error.issues[0],p=(u?.path??[]).filter((S)=>typeof S==="string"),m=An(a,p);return{ok:!1,error:{...{code:"request_body_invalid",message:p.length===0?u?.message??"The request body is invalid.":`${p.join(".")}: ${u?.message}`,hint:"The field above is the one to fix. GET /v1/openapi.json describes every body this server accepts, including the error code each field produces."},...m?.code===void 0?{}:{code:m.code},...m?.hint===void 0?{}:{hint:m.hint},...p.length===0?{}:{field:p.join(".")}}}}function An(a,e){let d=a,u=Ee(a);for(let p of e){if(d=_n(d,p),d===void 0)break;u=Ee(d)??Ee(Zt(d))??u}return u}function Ee(a){let e=a?.meta();if(e?.code===void 0&&e?.hint===void 0)return;return e}function _n(a,e){let d=Zt(a),u=d?.shape;if(u?.[e]!==void 0)return u[e];return d?.def?.valueType}function Zt(a){let e=a;for(let d=0;d<8&&e!==void 0;d+=1){let u=e.def?.innerType;if(u===void 0)return e;e=u}return e}var Pn={"GET /v1/health":{summary:"Liveness, the version, and how many agents are hosted."},"GET /v1/ready":{summary:"Whether a turn can be served yet.",statuses:[{code:503,when:"still starting; channels may still be connecting"}]},"GET /v1/activity":{summary:"Whether the process is idle, and when it must next be woken. For an external waker.",statuses:[{code:403,when:"the key is scoped to agents or sessions"}]},"GET /v1/agents":{summary:"Every agent this server knows about, hosted or switched off."},"GET /v1/agents/:id":{summary:"One agent, with its dialect, window, counts and warnings."},"GET /v1/backup":{summary:"The silo as a tar.gz: a consistent store snapshot and every hosted agent's directory, with a backup.json manifest. No .env or .git unless asked for. An admin key with no agents scope.",query:[{name:"include",about:"Any of env, git, home, comma-separated: each agent's .env (its secrets), its .git directories, and the rest of the state directory under home/."}],statuses:[{code:400,when:"include names something other than env, git or home, or home on a server with no state directory"},{code:403,when:"the key is scoped to some agents"}]},"GET /v1/agents/:id/export":{summary:"A slice of the agent as a JSON bundle: its carried memory file, memory archive and knowledge. Never the manifest, secrets or skills."},"POST /v1/agents/:id/import":{summary:"Merge a bundle into the agent: memory note by note, knowledge kept or overwritten. Reloads when the carried file or knowledge changed, and restores everything if that reload refuses.",body:Wt,statuses:[{code:400,when:"a path a bundle cannot carry, or a bundle the agent would not load"}]},"GET /v1/agents/:id/workspace":{summary:"The files the agent's prompt is built from: name, tier, field, whether it exists, size.",statuses:[{code:409,when:"the manifest does not parse, so its files cannot be named"}]},"GET /v1/agents/:id/workspace/:file":{summary:"One declared workspace file's text, for an editor to show before it replaces it.",statuses:[{code:404,when:"not a file the manifest declares"},{code:409,when:"the manifest does not parse"}]},"PUT /v1/agents/:id/workspace/:file":{summary:"Replace one of the agent's declared workspace files; reload it, or diagnose it when it is not running.",body:Et,statuses:[{code:400,when:"a running agent would not load with the new text (the old text is put back)"},{code:404,when:"a file the manifest does not declare"},{code:409,when:"an agent with no manifest file, or one whose manifest does not parse"}]},"GET /v1/agents/:id/vars":{summary:"The template an agent was made from and the plain variable values it was last rendered with. Secrets never appear.",statuses:[{code:409,when:"an agent with no template record"},{code:501,when:"a server with no templates directory (an embedded handler)"}]},"PATCH /v1/agents/:id/vars":{summary:"Apply changed template variables: re-render the files nobody edited since they were rendered, then reload.",body:Tt,statuses:[{code:202,when:"files changed and a turn is running: the reload lands when it ends"},{code:400,when:"a secret or undeclared variable, or a result the agent would not load (every file is put back)"},{code:409,when:"the agent was not made from a template on 0.2.0 or later"},{code:501,when:"this server has no templates"}]},"POST /v1/agents/:id/tools/refresh":{summary:"Fetch the tool providers' catalogues and schemas now, and reload the agent only if what it serves changed.",body:Ct,statuses:[{code:202,when:"something changed and a turn is running: the reload lands when it ends"},{code:400,when:"a provider the agent does not have, or a reload the agent refuses"}]},"POST /v1/agents/:id/reload":{summary:"Re-read the manifest by replacing the agent with a new instance.",statuses:[{code:409,when:"a turn is running — it is not aborted to apply a change"},{code:400,when:"a team member, which has no manifest of its own"}]},"GET /v1/provision":{summary:"The questions creating an agent asks, and whether this server can answer them."},"POST /v1/agents":{summary:"Create an agent, from answers or from a template, and adopt it into this host, live.",body:zt,statuses:[{code:201,when:"created; `adopted` is empty with an `error` if it is not running"},{code:403,when:"neither a loopback bind nor an authenticated admin credential"},{code:501,when:"this server has no provisioner"}]},"POST /v1/webhooks":{summary:"Subscribe a URL to event types. The signing secret is returned once.",body:Qt,statuses:[{code:201,when:"created; `secret` is in this response and no other"},{code:400,when:"a refused URL, an undeliverable type, or agents outside this key's reach"}]},"POST /v1/participants":{summary:"Register a human participant under the embedder's own id. No account is stored.",body:Mt,statuses:[{code:201,when:"registered, or updated if the id existed"}]},"GET /v1/participants":{summary:"The registered human participants."},"DELETE /v1/participants/:participantId":{summary:"Remove a participant and their conversation memberships."},"POST /v1/conversations":{summary:"Create a room or a DM among participants and agents (agent:<id>).",body:Dt,statuses:[{code:201,when:"created"},{code:403,when:"a participant-bound key creating a conversation it is not in"}]},"GET /v1/conversations":{summary:"The conversations this credential can see."},"GET /v1/conversations/:conversationId":{summary:"One conversation and its members."},"PATCH /v1/conversations/:conversationId/members":{summary:"Add or remove members of a room.",body:Lt},"POST /v1/conversations/:conversationId/messages":{summary:"Post a human member's message. In a room only the mentioned agents answer; in a DM the agent always does. Their replies arrive as conversation.message.",body:Ut,statuses:[{code:202,when:"logged; the turns it starts run behind the response"},{code:403,when:"a participant-bound key naming another author"}]},"GET /v1/conversations/:conversationId/messages":{summary:"The conversation's log, oldest first, after a sequence number."},"PUT /v1/participants/:participantId/presence":{summary:"Push whether a person is there. In a DM between two people, an offline person's agent stands in for them.",body:Kt,statuses:[{code:403,when:"a participant-bound key setting someone else's presence"}]},"POST /v1/memory/notes":{summary:"Add a note to a shared memory scope — the space, a person's owner scope, or a project. Agents recall it when a turn is about it.",body:Ht,statuses:[{code:403,when:"this participant may not write that scope"},{code:404,when:"the scope's owner or project does not exist"}]},"GET /v1/memory/notes":{summary:"Every note in one shared scope, oldest first. An owner scope is readable by its owner."},"DELETE /v1/memory/notes/:noteId":{summary:"Remove a note. Whoever may write its scope may remove it."},"GET /v1/participants/:participantId/memory/reads":{summary:"The person's audit: every time an agent recalled their owner scope for somebody else, stand-ins included."},"GET /v1/projects":{summary:"Projects, each with the agents that share its memory."},"PUT /v1/projects/:projectId":{summary:"Define a project, or replace which agents share its memory. An admin's act.",body:Gt},"DELETE /v1/projects/:projectId":{summary:"Remove a project and its notes."},"PUT /v1/memory/space/writer":{summary:"Name the one non-admin who may write the space. An agent named here saves its memory_write to the space.",body:qt},"GET /v1/actions":{summary:"Mutating calls stand-ins queued for their owners. A member-bound key sees its own."},"POST /v1/actions/:actionId":{summary:"Approve or decline a queued action. Approved, the exact call runs as the owner's agent and the outcome is posted in the DM.",body:Vt,statuses:[{code:404,when:"no such action, or not this key's to decide"},{code:409,when:"already decided"}]},"PUT /v1/agents/:id/assignee":{summary:"Record which member an agent works for. An admin participant's act.",body:Ft},"GET /v1/agents/:id/assignee":{summary:"Who the agent is assigned to, as `{id, assignment}`; `assignment` is null when nobody."},"DELETE /v1/agents/:id/assignee":{summary:"Clear an agent's assignment."},"GET /v1/webhooks":{summary:"The subscriptions this credential can see, with their delivery health. Never a secret."},"DELETE /v1/webhooks/:webhookId":{summary:"Delete a subscription and anything it still owed.",statuses:[{code:404,when:"no such subscription, or one outside this key's reach"}]},"GET /v1/usage":{summary:"What every agent in scope cost, per model call, grouped by agent, model, day or sender.",statuses:[{code:400,when:"an unknown grouping or a date that does not parse"}]},"GET /v1/agents/:id/usage":{summary:"What this agent cost, from the meter.",statuses:[{code:400,when:"an unknown grouping or a date that does not parse"}]},"GET /v1/agents/:id/turns":{summary:"Every turn this agent has taken, newest first, across sessions, paged by `before`.",statuses:[{code:400,when:"`limit` or `before` is not a positive whole number"}]},"GET /v1/templates":{summary:"The templates an agent can be created from, and the variables each declares."},"GET /v1/agents/:id/secrets":{summary:"Which variables the agent's manifest reads, and whether each is set. Never a value.",statuses:[{code:501,when:"this server has no credential writer"}]},"PUT /v1/agents/:id/secrets":{summary:"Write the agent's credentials into its .env and apply them: reload or adopt.",body:Xt,statuses:[{code:200,when:"written; `applied` says whether the agent is running on them"},{code:400,when:"a variable the manifest does not read, or an empty value"},{code:501,when:"this server has no credential writer"}]},"DELETE /v1/agents/:id":{summary:"Delete an agent for good: off this host, its rows out of the store, its directory off disk. Needs ?confirm=<id>.",statuses:[{code:400,when:"no ?confirm=<id>"},{code:409,when:"two sandbox directories declare this id"},{code:501,when:"this server cannot delete agents"}]},"POST /v1/agents/:id/stop":{summary:"Switch an agent off durably and drop it from this host now.",body:Ot,statuses:[{code:409,when:"a turn is running"}]},"POST /v1/agents/:id/start":{summary:"Switch it back on and have this host adopt it.",statuses:[{code:501,when:"this server cannot look up manifests"}]},"POST /v1/agents/:id/messages":{summary:"Start a turn. Returns once accepted; the turn runs detached.",body:Nt,statuses:[{code:202,when:"accepted"},{code:429,when:"over limits.maxConcurrentTurns or limits.tokens; nothing recorded"}]},"POST /v1/agents/:id/deliveries":{summary:"Send exact text on one of the agent's channels, with no turn. It joins that conversation's history as the agent's.",body:At,statuses:[{code:202,when:"queued, or already queued under this key"},{code:404,when:"the agent has no running channel with that id"}]},"POST /v1/agents/:id/turns/:turnId/stop":{summary:"Cooperatively stop a turn this API started.",statuses:[{code:409,when:"no cancel handle — a channel or schedule started it"}]},"GET /v1/agents/:id/turns/:turnId/stream":{summary:"One turn's events as SSE, replayed from the start and then live.",query:[{name:"chunks",about:"Include per-token frames. Off by default."},{name:"types",about:"Narrow to these event types, comma-separated."}],statuses:[{code:200,when:"an event stream; see the event table in the wire spec"}]},"GET /v1/events":{summary:"Every event this process emits, as SSE. The firehose.",query:[{name:"agentId",about:"Narrow to one agent."},{name:"sessionKey",about:"Narrow to one conversation."},{name:"chunks",about:"Include per-token frames. Off by default."},{name:"types",about:"Narrow to these event types, comma-separated."}],statuses:[{code:200,when:"an event stream; see the event table in the wire spec"}]},"GET /v1/agents/:id/approvals":{summary:"Questions waiting on a person, oldest first."},"POST /v1/agents/:id/approvals/:approvalId":{summary:"Answer one blocked tool call.",body:_t},"POST /v1/keys":{summary:"Mint an operator key. The secret is returned once and never again.",body:Pt,statuses:[{code:201,when:"minted"}]},"GET /v1/keys":{summary:"Every key, live and revoked. Never a secret."},"DELETE /v1/keys/:keyId":{summary:"Revoke a key. A soft delete; the row survives."},"GET /v1/agents/:id/turns/:turnId":{summary:"One turn's stored row."},"GET /v1/agents/:id/sessions":{summary:"Conversations, most recently active first."},"GET /v1/agents/:id/sessions/:key":{summary:"One conversation's summary."},"GET /v1/agents/:id/sessions/:key/messages":{summary:"A page of a conversation's messages.",query:[{name:"limit",about:"How many to return."},{name:"before",about:"Page backwards from this message id."}]},"DELETE /v1/agents/:id/sessions/:key":{summary:"Drop a conversation's history, turns and derived index."},"POST /v1/agents/:id/sessions/:key/phase":{summary:"Move a session into a declared phase.",body:It},"POST /v1/agents/:id/sessions/:key/recall":{summary:"Keep a conversation out of history recall, or put it back; its messages stay.",body:$t},"POST /v1/agents/:id/sessions/rotate":{summary:"Start the caller's conversation afresh on every surface (sessions.scope owner or peer).",body:Bt},"GET /v1/agents/:id/config":{summary:"Every manifest field this surface may set, what it does, and its current value."},"PATCH /v1/agents/:id/config":{summary:"Set one manifest field, then replace the agent so it takes effect.",statuses:[{code:409,when:"the field carries a confirm sentence and `confirm` was not true"},{code:409,when:"the agent came from an object, so there is no manifest to edit"},{code:400,when:"the path is not settable here, or the result would not validate"}]},"PATCH /v1/agents/:id/channels/:channelId":{summary:"Connect or disconnect a channel, and set its credential.",statuses:[{code:400,when:"neither `enabled` nor `credential` was sent, or the channel is unknown"},{code:409,when:"the agent came from an object, so there is no manifest to edit"},{code:501,when:"the host supplied no channel actions"}]},"POST /v1/agents/:id/channels/:channelId/unpair":{summary:"Forget a channel's stored pairing, so the next start offers a new code.",statuses:[{code:404,when:"this agent has no such channel"},{code:409,when:"the channel stores no pairing — a typed credential is a PATCH"}]},"GET /v1/agents/:id/schedules":{summary:"Every schedule, from the store."},"POST /v1/agents/:id/schedules":{summary:"Create a schedule. Validated by the manifest's own schedule rules.",statuses:[{code:201,when:"created"}]},"GET /v1/agents/:id/schedules/preview":{summary:"What an expression means before it is written: the next instants, zone and jitter.",statuses:[{code:400,when:"an expression core's own parser refuses, with its hint"}]},"GET /v1/agents/:id/schedules/:sid":{summary:"One schedule's row."},"PATCH /v1/agents/:id/schedules/:sid":{summary:"Replace a schedule the API created.",statuses:[{code:409,when:"the manifest declares it, so reconciliation would undo the write"}]},"DELETE /v1/agents/:id/schedules/:sid":{summary:"Delete a schedule the API created.",statuses:[{code:409,when:"the manifest declares it, so the next boot would re-create it"}]},"POST /v1/agents/:id/schedules/:sid/run":{summary:"Fire a schedule now, out of band.",statuses:[{code:429,when:"over a governor limit; nothing recorded"}]},"GET /v1/agents/:id/tools":{summary:"The resolved catalogue, with trust and phases."},"GET /v1/agents/:id/skills":{summary:"What the skills index holds."},"GET /v1/agents/:id/context":{summary:"The prompt the next turn would be given, without running one.",query:[{name:"sessionKey",about:"Which conversation to assemble for."},{name:"input",about:"Pretend this is the next message."}]},"POST /v1/channels/:channelId/webhook/:agentId":{summary:"A channel provider's webhook. Open by design; the provider authenticates itself."},"GET /v1/openapi.json":{summary:"This document."},"GET /docs":{summary:"A browser reference over this document."}};function In(a){return a.startsWith("/v1/")||a==="/docs"}function $n(a){let e={};for(let d of a.routes){if(!In(d.pattern))continue;let u=Pn[`${d.method} ${d.pattern}`];if(u===void 0)continue;let p=d.pattern.replace(/:([A-Za-z0-9_]+)/g,"{$1}"),m=[...d.pattern.matchAll(/:([A-Za-z0-9_]+)/g)].map((B)=>({name:B[1],in:"path",required:!0,schema:{type:"string"}})),b=(u.query??[]).map((B)=>({name:B.name,in:"query",required:!1,description:B.about,schema:{type:"string"}})),S={};for(let B of u.statuses??[])S[String(B.code)]={description:B.when};if(S["200"]===void 0&&S["201"]===void 0){if(S["202"]===void 0)S["200"]={description:"OK"}}if(S["401"]={description:"No credential, or one this server does not accept."},d.pattern.includes(":id"))S["404"]={description:"No such agent, or it is switched off."};e[p]??={};let V={summary:u.summary,...m.length+b.length===0?{}:{parameters:[...m,...b]},responses:S};if(u.body!==void 0)V.requestBody={required:!0,content:{"application/json":{schema:Ys(u.body,{target:"draft-2020-12",io:"input"})}}};e[p][d.method.toLowerCase()]=V}return{openapi:"3.1.0",info:{title:"Dispach agent server",version:xe,description:"Generated from the router table and the request schemas — see openapi.ts. The binding contract is docs/04-SPEC-WIRE.md, which is checked against the code; @dispach/client's types are the response reference."},...a.serverUrl===void 0?{}:{servers:[{url:a.serverUrl}]},components:{securitySchemes:{bearer:{type:"http",scheme:"bearer",description:"An operator key or the configured token."}},schemas:{Error:{type:"object",description:"Every failure has this shape. `hint` is never absent — it is the part that says what to do.",properties:{error:{type:"object",required:["code","message","hint"],properties:{code:{type:"string"},message:{type:"string"},hint:{type:"string"},field:{type:"string"}}}}}}},security:[{bearer:[]}],paths:e}}var On=new Set(["127.0.0.1","::1","localhost","[::1]"]);function je(a){return On.has(a.toLowerCase())}function me(a){let e=a.trim();if(e===""||e.toLowerCase()==="null")return;try{return new URL(e.includes("://")?e:`http://${e}`).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{return}}function Je(a){return je(a)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a)}function Se(a,e){let d=je(e.host),u=a.headers.get("host"),p=a.headers.get("origin");if(d){let b=u===null?void 0:me(u),S=e.allowedHosts??[];if(!(b!==void 0&&(Je(b)||S.some((B)=>me(B)===b))))return{code:"host_not_allowed",message:`This server does not answer to the host ${u??"(absent)"}.`,hint:"It is bound to loopback, so only a loopback name or address can legitimately reach it — a request addressed to any other name arrived through DNS pointed at this machine, which is how a web page reaches a local server it was never given access to. Add the name to server.allowedHosts if a proxy on this machine needs it.",field:"server.allowedHosts"}}if(p===null)return;let m=me(p);if(m!==void 0){if(Je(m))return;if((e.allowedOrigins??[]).some((b)=>me(b)===m))return;if(!d&&u!==null&&me(u)===m)return}return{code:"origin_not_allowed",message:`Refusing a request from the origin ${p}.`,hint:d?"This server is bound to loopback, so a page served from anywhere else has no business calling it. Add the origin to server.allowedOrigins if you meant to allow it.":"Only a page served from this server's own host may call it. Add the origin to server.allowedOrigins if you meant to allow it — there is no wildcard, deliberately.",field:"server.allowedOrigins"}}function zn(a,e){let d=a.headers.get("origin");if(d===null)return{};if(Se(a,e)!==void 0)return{};return{"access-control-allow-origin":d,vary:"Origin"}}function Rn(a,e){let d=a.headers.get("access-control-request-headers");return{"access-control-allow-methods":e.join(", "),"access-control-allow-headers":d??"authorization, content-type","access-control-max-age":"600"}}function Te(a,e){if(a.kind!=="key")return a.kind!=="claim";let d=a.scope?.can;return d===void 0||d.includes(e)}function X(a,e){if(a.kind!=="key")return a.kind!=="claim";let d=a.scope?.agents;return d===void 0||d.includes(e)}function ce(a,e){if(a.kind!=="key")return a.kind!=="claim";let d=a.scope?.sessions;if(d===void 0)return!0;if(e.startsWith(d.endsWith("*")?d.slice(0,-1):d))return!0;let u=a.scope?.participant;return u!==void 0&&(Vr(e,`owner:${u}`)||Vr(e,`peer:${u}`))}function en(a,e){if(e.sessionKey===void 0||ce(a,e.sessionKey))return!0;return e.parentSessionKey!==void 0&&ce(a,e.parentSessionKey)}function ve(a){if(a.kind==="claim")return{agentIds:[]};if(a.kind!=="key")return{};let e=a.scope?.agents,d=a.scope?.sessions;return{...e===void 0?{}:{agentIds:e},...d===void 0?{}:{sessionPrefix:d.endsWith("*")?d.slice(0,-1):d}}}function Ue(a){if(a.kind!=="key")return!1;let e=a.scope;return e!==void 0&&(e.agents!==void 0||e.sessions!==void 0||e.can!==void 0)}function Le(a,e){let d=a.kind==="key"?a.scope?.participant:void 0;if(d===void 0)return{ok:!0,from:e};if(e===void 0)return{ok:!0,from:{id:d,kind:"user"}};if(e.id===d&&e.kind==="user")return{ok:!0,from:e};return{ok:!1,error:{code:"sender_not_bound_participant",message:`This key speaks for ${d}, and the message names ${e.kind} ${e.id}.`,hint:`A key bound to a participant starts turns only as that participant, so the tools the turn calls act for them. Omit from (it is filled in), or send from.id "${d}" with kind "user". A backend that names senders itself needs a key minted without scope.participant.`,field:"from"}}}async function tn(a,e,d,u,p){let m=await a.resolveSessionKey(d,{source:"api",...u===void 0?{}:{from:u},...p===void 0?{}:{peerAsk:p}});return ce(e,m)?m:d}class nn{#e=[];add(a,e,d,u){return this.#e.push({method:a.toUpperCase(),pattern:e,handler:d,capability:u.capability,streaming:u.streaming===!0,segments:Xe(e)}),this}routes(){return this.#e.map(({method:a,pattern:e,handler:d,streaming:u,capability:p})=>({method:a,pattern:e,handler:d,streaming:u,capability:p}))}match(a,e){let d=Xe(e),u=[];for(let p of this.#e){let m=Mn(p.segments,d);if(m===void 0)continue;if(u.push(p),p.method===a.toUpperCase())return{kind:"found",handler:p.handler,params:m,streaming:p.streaming,capability:p.capability}}if(u.length>0)return{kind:"method",allowed:[...new Set(u.map((p)=>p.method))]};return{kind:"none"}}}function Xe(a){return a.split("/").filter((e)=>e!=="")}function Mn(a,e){if(a.length!==e.length)return;let d={};for(let[u,p]of a.entries()){let m=e[u];if(m===void 0)return;if(p.startsWith(":")){try{d[p.slice(1)]=decodeURIComponent(m)}catch{return}continue}if(p!==m)return}return d}var rn=15000;function Dn(a){let e=[];if(a.event!==void 0)e.push(`event: ${a.event}`);if(a.id!==void 0)e.push(`id: ${a.id}`);let d=typeof a.data==="string"?a.data:JSON.stringify(a.data);for(let u of d.split(`
3
+ `))e.push(`data: ${u}`);return`${e.join(`
4
+ `)}
5
+
6
+ `}function Be(a){let e=new TextEncoder,d,u,p=!1,m=new ReadableStream({start(b){let S=()=>{if(p)return;if(p=!0,u!==void 0)clearInterval(u);d?.(),d=void 0;try{b.close()}catch{}},V=(j)=>{if(p)return;try{b.enqueue(e.encode(Dn(j)))}catch{S()}};a.signal?.addEventListener("abort",S,{once:!0});let B=a.start({send:V,close:S});if(p){B?.();return}d=B,u=setInterval(()=>{if(p)return;try{b.enqueue(e.encode(`: ping
7
+
8
+ `))}catch{S()}},a.heartbeatMs??rn),u.unref?.()},cancel(){if(p)return;if(p=!0,u!==void 0)clearInterval(u);d?.(),d=void 0}});return new Response(m,{status:a.status??200,headers:{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive","x-accel-buffering":"no"}})}var pe=512;function ge(a,e){return`${a.toString(8).padStart(e-1,"0")}\x00`}function Ce(a,e,d,u){let p=new Uint8Array(pe),m=(S,V)=>{p.set(new TextEncoder().encode(S),V)};m(a.slice(0,100),0),m(ge(420,8),100),m(ge(0,8),108),m(ge(0,8),116),m(ge(e,12),124),m(ge(Math.floor(d/1000),12),136),m(" ",148),m(u,156),m("ustar\x00",257),m("00",263);let b=0;for(let S of p)b+=S;return m(`${b.toString(8).padStart(6,"0")}\x00 `,148),p}function tt(a,e,d){if(new TextEncoder().encode(a).length<=100)return[Ce(a,e,d,"0")];let u=(b)=>`${b} path=${a}
9
+ `,p=u(0);for(let b=p.length;;b=p.length)if(p=u(new TextEncoder().encode(u(b)).length),new TextEncoder().encode(p).length===b)break;let m=new TextEncoder().encode(p);return[Ce("PaxHeader",m.length,d,"x"),...sn(m),Ce(a,e,d,"0")]}function sn(a){let e=a.length%pe;return e===0?[a]:[a,new Uint8Array(pe-e)]}async function*Fn(a,e){try{yield*Kn(a)}finally{await e()}}async function*Kn(a){for(let e of a){if("bytes"in e.source){yield*tt(e.name,e.source.bytes.length,Date.now()),yield*sn(e.source.bytes);continue}let d=await Un(e.source.path);yield*tt(e.name,d.size,d.mtimeMs);let u=0;if(d.size>0)for await(let p of Ln(e.source.path,{end:d.size-1})){let m=p;u+=m.length,yield m}if(u<d.size)yield new Uint8Array(d.size-u);if(d.size%pe!==0)yield new Uint8Array(pe-d.size%pe)}yield new Uint8Array(pe*2)}function Hn(a,e=async()=>{}){let d=et.from(Fn(a,e)).pipe(Bn());return et.toWeb(d)}var Gn=':root{color-scheme:dark;--ground: #0a0a0a;--raised: #111111;--raised-2: #171717;--line: #262626;--line-strong: #333333;--text: #ededed;--dim: #a1a1a1;--faint: #6b6b6b;--accent: #d75fd7;--accent-soft: rgb(215 95 215 / 12%);--accent-ink: #0a0a0a;--warn: #d7af5f;--warn-soft: rgb(215 175 95 / 10%);--bad: #f7768e;--bad-soft: rgb(247 118 142 / 10%);--ok: #5fd75f;--info: #5f87d7;--shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 25%);--radius: 8px;--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;--sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif}@media(prefers-color-scheme:light){:root:not([data-theme=dark]){color-scheme:light;--ground: #fafafa;--raised: #ffffff;--raised-2: #f4f4f5;--line: #e5e5e5;--line-strong: #d4d4d4;--text: #171717;--dim: #616161;--faint: #9a9a9a;--accent: #b23fb2;--accent-soft: rgb(178 63 178 / 9%);--accent-ink: #ffffff;--warn: #9a6b12;--warn-soft: rgb(154 107 18 / 8%);--bad: #c62a4a;--bad-soft: rgb(198 42 74 / 7%);--ok: #1f8a3a;--info: #2f5fb3;--shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 6%)}}:root[data-theme=light]{color-scheme:light;--ground: #fafafa;--raised: #ffffff;--raised-2: #f4f4f5;--line: #e5e5e5;--line-strong: #d4d4d4;--text: #171717;--dim: #616161;--faint: #9a9a9a;--accent: #b23fb2;--accent-soft: rgb(178 63 178 / 9%);--accent-ink: #ffffff;--warn: #9a6b12;--warn-soft: rgb(154 107 18 / 8%);--bad: #c62a4a;--bad-soft: rgb(198 42 74 / 7%);--ok: #1f8a3a;--info: #2f5fb3;--shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 6%)}*{box-sizing:border-box}html,body{margin:0;background:var(--ground);color:var(--text)}body{font:14px / 1.55 var(--sans);-webkit-font-smoothing:antialiased;font-feature-settings:"cv11","ss01"}code{font-family:var(--mono);font-size:.88em;background:var(--raised-2);border:1px solid var(--line);border-radius:4px;padding:1px 5px}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}::selection{background:var(--accent-soft)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}button{font:inherit;font-size:13px;font-weight:500;color:inherit;background:var(--raised);border:1px solid var(--line);border-radius:6px;padding:6px 12px;cursor:pointer;transition:background .12s,border-color .12s,color .12s}button:hover:not(:disabled){border-color:var(--line-strong);background:var(--raised-2)}button:disabled{opacity:.45;cursor:default}button.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink);font-weight:600}button.primary:hover:not(:disabled){background:var(--accent);border-color:var(--accent);filter:brightness(1.08)}button.bad{color:var(--bad)}input,textarea,select{font:inherit;color:inherit;background:var(--ground);border:1px solid var(--line);border-radius:6px;padding:8px 10px;width:100%;transition:border-color .12s,box-shadow .12s}input:focus,textarea:focus,select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}.shell{display:grid;grid-template-columns:248px 1fr;height:100vh}.side{background:var(--ground);border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0}.side header{padding:14px 16px;height:52px;display:flex;align-items:center;gap:10px;border-bottom:1px solid var(--line)}.brand{font-weight:700;letter-spacing:-.01em;font-size:15px;display:flex;align-items:center;gap:8px}.wordmark{display:block;color:var(--accent);width:auto}.version{font-family:var(--mono);font-size:11px;color:var(--faint)}.side nav{padding:8px 10px;overflow-y:auto;flex:1;min-height:0}.side footer{padding:10px 14px;border-top:1px solid var(--line);display:flex;gap:8px;align-items:center}.row-button{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:none;border:1px solid transparent;border-radius:6px;padding:6px 9px;font-size:13px;font-weight:450;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.row-button:hover:not(:disabled){background:var(--raised-2);border-color:transparent;color:var(--text)}.row-button[aria-current=true]{background:var(--raised-2);color:var(--text);border-color:var(--line)}.row-button.session{font-family:var(--mono);font-size:12px}.row-button.session.person{font-family:var(--sans)}.group{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--faint);padding:16px 9px 6px}.main{display:flex;flex-direction:column;min-height:0;min-width:0}.bar{display:flex;gap:12px;align-items:center;padding:0 20px;border-bottom:1px solid var(--line);font-size:12px;color:var(--dim);height:52px;flex-shrink:0;background:color-mix(in srgb,var(--ground) 85%,transparent);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.bar strong{color:var(--text);font-size:14px;font-weight:600;white-space:nowrap}.bar .crumb{color:var(--faint)}.bar .spacer{flex:1}.bar a,.bar .ghost{color:var(--dim);font-size:12px;font-weight:500;padding:5px 10px;border:1px solid var(--line);border-radius:6px;background:transparent;white-space:nowrap}.bar a:hover,.bar .ghost:hover:not(:disabled){color:var(--text);text-decoration:none;background:var(--raised-2)}.scroll{flex:1;overflow-y:auto;min-height:0;padding:28px 24px}.pad{max-width:820px;margin:0 auto}.pad.wide{max-width:1100px}.page-head{margin:0 0 22px}.page-head h1{font-size:24px;font-weight:650;letter-spacing:-.02em;margin:0 0 4px}.page-head p{color:var(--dim);margin:0;max-width:68ch}.row{margin:0 0 18px;white-space:pre-wrap;overflow-wrap:anywhere}.row.user{background:var(--raised-2);border:1px solid var(--line);border-radius:12px;padding:10px 14px;margin-left:auto;max-width:85%;width:fit-content}.row.reply{white-space:normal}.row.reply>:first-child{margin-top:0}.row.reply>:last-child{margin-bottom:0}.row.reply p,.row.reply ul,.row.reply ol,.row.reply blockquote{margin:0 0 10px}.row.reply h1,.row.reply h2,.row.reply h3,.row.reply h4{margin:16px 0 8px;letter-spacing:-.01em;line-height:1.3}.row.reply h1{font-size:20px}.row.reply h2{font-size:17px}.row.reply h3,.row.reply h4{font-size:15px}.row.reply ul,.row.reply ol{padding-left:22px}.row.reply li>p{margin:0 0 4px}.row.reply blockquote{border-left:3px solid var(--line-strong);padding:2px 12px;color:var(--dim)}.row.reply hr{border:none;border-top:1px solid var(--line);margin:14px 0}.row.reply a{text-decoration:underline;text-underline-offset:2px}.md-code{margin:0 0 10px;border:1px solid var(--line);border-radius:var(--radius);background:var(--ground);overflow:hidden}.md-code.open{border-style:dashed}.md-code-head{display:flex;justify-content:space-between;align-items:center;padding:4px 6px 4px 12px;font-family:var(--mono);font-size:11px;color:var(--faint);border-bottom:1px solid var(--line);background:var(--raised)}.md-code-head button{font-size:11px;padding:2px 8px}.md-code pre{margin:0;padding:12px 14px;overflow-x:auto;font-family:var(--mono);font-size:12.5px;line-height:1.55}.md-code pre code{background:none;border:none;padding:0;font-size:inherit}.md-table{overflow-x:auto;margin:0 0 10px}.md-table table{width:auto;min-width:50%;border:1px solid var(--line);border-radius:var(--radius);border-collapse:separate;border-spacing:0}.md-table th{padding:8px 12px;background:var(--raised-2);text-transform:none;letter-spacing:0;font-size:12px;color:var(--text);border-bottom:1px solid var(--line)}.md-table td{padding:8px 12px;font-family:var(--sans);font-size:13px;border-top:1px solid var(--line)}.label{font-family:var(--mono);font-size:11px;color:var(--faint);margin-bottom:4px}.tool{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:8px 12px;font-family:var(--mono);font-size:12px}.tool .slug{color:var(--accent);font-weight:600}.tool .out{color:var(--dim);max-height:13em;overflow-y:auto;margin-top:5px;display:inline}.tool.failed{border-color:color-mix(in srgb,var(--bad) 40%,var(--line))}.tool.failed .slug{color:var(--bad)}.tool .mut{color:var(--warn);font-size:11px}.fence{border:1px dashed var(--warn);border-radius:6px;padding:7px 9px;margin-top:5px}.fence .why{color:var(--warn);font-size:11px;margin-bottom:4px}.payload-code{font-family:var(--mono);font-size:28px;font-weight:600;letter-spacing:.18em;margin:10px 0;-webkit-user-select:all;user-select:all}.channel-input.stale .payload-code{opacity:.35}.payload-qr{display:block;width:240px;max-width:100%;height:auto;border-radius:6px;margin:8px 0}.channel-input.stale .payload-qr{opacity:.35}.note{font-size:12px;color:var(--dim);border-left:2px solid var(--line-strong);padding:2px 0 2px 11px;white-space:pre-wrap}.note.bad{color:var(--bad);border-left-color:var(--bad);background:var(--bad-soft);border-radius:0 6px 6px 0;padding:8px 12px}.ask{border:1px solid color-mix(in srgb,var(--warn) 55%,var(--line));border-radius:var(--radius);padding:12px 14px;background:var(--warn-soft)}.ask .what{font-family:var(--mono);font-size:12px;margin:6px 0 10px;white-space:pre-wrap;overflow-wrap:anywhere}.ask .buttons{display:flex;gap:8px;flex-wrap:wrap}.ask .settled{font-size:12px;color:var(--dim)}details.fold summary{cursor:pointer;color:var(--faint);font-family:var(--mono);font-size:11px}details.fold[open] summary{margin-bottom:5px}details.fold .body{color:var(--dim);font-size:13px}.tool details.subagent{margin-top:4px}.tool details.subagent summary{cursor:pointer;color:var(--dim);font-size:11px}.tool details.subagent ul{list-style:none;margin:4px 0 0;padding-left:12px;border-left:1px solid var(--line);color:var(--dim)}.tool details.subagent li.failed .slug{color:var(--bad)}.composer{padding:12px 24px 18px}.composer .inner{max-width:820px;margin:0 auto;display:flex;gap:8px;align-items:flex-end;background:var(--raised);border:1px solid var(--line);border-radius:12px;padding:8px;box-shadow:var(--shadow)}.composer .inner:focus-within{border-color:color-mix(in srgb,var(--accent) 60%,var(--line))}.composer .role-pick{width:auto;font-family:var(--mono);font-size:12px;padding:6px 8px}.attachments{max-width:820px;margin:0 auto 8px;display:flex;gap:8px;flex-wrap:wrap}.attachment{position:relative;display:inline-block}.attachment img{height:56px;width:56px;object-fit:cover;border-radius:8px;border:1px solid var(--line);display:block}.attachment button{position:absolute;top:-6px;right:-6px;width:18px;height:18px;padding:0;line-height:1;font-size:12px;border-radius:50%}.composer textarea{resize:none;min-height:40px;max-height:190px;font-family:var(--sans);border:none;background:transparent;box-shadow:none}.composer textarea:focus{box-shadow:none}.hint{font-size:11px;color:var(--faint);max-width:820px;margin:6px auto 0}.card{border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px;margin-bottom:14px;background:var(--raised)}.card h2{margin:0 0 4px;font-size:15px;font-weight:600}.card h3{margin:0 0 8px;font-size:13px;font-weight:600}.card p{margin:0 0 12px;color:var(--dim);font-size:13px}table{width:100%;border-collapse:collapse;font-size:13px}th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--faint);font-weight:600;padding:0 10px 8px 0}td{padding:9px 10px 9px 0;border-top:1px solid var(--line);font-family:var(--mono);font-size:12px}td.revoked{color:var(--faint);text-decoration:line-through}.secret{font-family:var(--mono);font-size:12px;background:var(--ground);border:1px solid var(--ok);border-radius:6px;padding:9px 11px;overflow-wrap:anywhere;margin-bottom:8px}.gate{display:grid;place-items:center;min-height:100vh;padding:20px;background:radial-gradient(ellipse 60% 40% at 50% 0%,var(--accent-soft),transparent 70%),var(--ground)}.gate .card{max-width:440px;width:100%;padding:28px;box-shadow:var(--shadow)}.gate .card h2{font-size:18px;letter-spacing:-.01em;margin-bottom:6px}.gate .brand{margin-bottom:18px}.gate input{font-family:var(--mono);font-size:12px}.gate .ask{border:none;background:none;padding:0}.dot{width:7px;height:7px;border-radius:50%;display:inline-block;flex-shrink:0;background:var(--faint)}.dot.live{background:var(--ok);box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 18%,transparent)}.dot.busy{background:var(--warn);box-shadow:0 0 0 3px color-mix(in srgb,var(--warn) 18%,transparent)}.dot.off{background:var(--faint)}.dot.warn{background:var(--warn)}@media(max-width:720px){.shell{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);height:100dvh}.side{min-width:0;border-right:none;border-bottom:1px solid var(--line)}.side header{height:48px}.side nav{display:flex;gap:4px;overflow-x:auto;padding:6px 10px;flex:none}.side nav .group,.side nav .agent-note,.side footer{display:none}.side nav .row-button,.side nav .agent-row{width:auto;flex-shrink:0}.bar{padding:0 14px;height:48px}.bar .hide-narrow{display:none}.scroll{padding:18px 16px}.composer{padding:10px 12px 12px}}.agent-row{display:block}.agent-row .row-button:disabled{color:var(--faint);cursor:default}.agent-off{color:var(--warn);font-size:11px}.agent-note{display:flex;gap:6px;align-items:baseline;padding:0 9px 6px 24px;font-size:11px;color:var(--faint)}.link{background:none;border:none;padding:0;color:var(--accent);font-size:11px;text-decoration:underline;cursor:pointer}.link:hover:not(:disabled){background:none}.link:disabled{color:var(--faint);cursor:default;text-decoration:none}.empty{color:var(--dim);font-size:13px;max-width:60ch}.empty-state{border:1px dashed var(--line-strong);border-radius:var(--radius);padding:28px;text-align:center;color:var(--dim)}.empty-state h3{color:var(--text);margin:0 0 6px;font-size:14px}.empty-state p{margin:0 auto;max-width:56ch;font-size:13px}.panel-table{width:100%;border-collapse:separate;border-spacing:0;font-size:12px;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--raised)}.panel-table th{text-align:left;font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--faint);padding:10px 12px;border-bottom:1px solid var(--line);background:var(--raised-2)}.panel-table td{padding:10px 12px;border-top:none;border-bottom:1px solid var(--line);vertical-align:top}.panel-table tr:last-child td{border-bottom:none}.panel-table tr:hover td{background:var(--raised-2)}.panel-table tr.off td{color:var(--faint)}.channel{border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;margin-bottom:12px;background:var(--raised)}.channel h3{margin:0 0 6px;font-size:13px;font-weight:600}.status{margin:0;font-size:12px}.status-connected{color:var(--ok)}.status-error,.status-disconnected{color:var(--bad)}.status-needs_input{color:var(--warn)}.channel-input{margin-top:10px;padding:10px;border-radius:6px;background:var(--ground)}.payload{margin:0;font-family:var(--mono);font-size:11px;white-space:pre-wrap;word-break:break-all;max-height:9em;overflow-y:auto}.channel-input.stale .payload{opacity:.45}.warn{color:var(--warn);font-size:12px;margin:0 0 6px}.provision{display:flex;flex-direction:column;gap:16px;max-width:60ch}.provision>button[type=submit]{align-self:flex-start}.field label{display:block;font-size:12px;font-weight:500;color:var(--dim);margin-bottom:6px}.field.invalid input,.field.invalid select{border-color:var(--bad)}.sub{color:var(--dim);font-size:12px;margin-top:2px;max-width:60ch}.error{color:var(--bad);font-size:13px;max-width:60ch}.ok{color:var(--ok);font-size:13px}.created{max-width:66ch;font-size:13px}.created h3{font-size:15px;font-weight:600;margin:0 0 10px}.created p{margin:0 0 10px}.blank-secrets{border:1px solid var(--warn);border-radius:6px;padding:11px 13px;margin:14px 0}.blank-secrets p{margin:0 0 6px}.blank-secrets p:last-child{margin:0}.config-row{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:14px 16px;margin-bottom:10px}.config-head{display:flex;align-items:baseline;gap:8px;font-family:var(--mono);font-size:13px;font-weight:600}.config-row .sub{margin:4px 0 10px;max-width:72ch}.config-row input[type=text],.config-row input:not([type]),.config-row textarea{width:100%;font-family:var(--mono);font-size:12px}.config-row button{margin-top:8px}.config-row label input[type=checkbox]{width:auto;margin-right:4px;vertical-align:baseline}.form-grid{display:grid;grid-template-columns:6em 1fr;gap:8px 12px;align-items:start;max-width:60ch}.form-grid label{font-size:12px;color:var(--dim);padding-top:9px}.form-grid input,.form-grid select{width:100%}.form-grid>div>input+input{margin-top:6px}.warnings{border:1px solid color-mix(in srgb,var(--warn) 45%,var(--line));background:var(--warn-soft);border-radius:var(--radius);padding:10px 14px;margin-bottom:20px;font-size:13px}.warnings summary{cursor:pointer;list-style:none;display:flex;gap:8px;align-items:center}.warnings summary::-webkit-details-marker{display:none}.warnings h3{margin:0;color:var(--warn);font-size:13px;font-weight:600}.warnings .sub{margin:8px 0 4px}.warning{margin-top:10px;padding-top:10px;border-top:1px solid color-mix(in srgb,var(--warn) 20%,transparent)}.warning-message{margin:0}.warning .hint{margin:4px 0 0;max-width:none}.channel-actions{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin-top:.5rem}.channel-actions form{display:flex;gap:.35rem}.channel-actions input{min-width:14rem}.status-off{opacity:.7}.model-card.primary{border-color:color-mix(in srgb,var(--accent) 35%,var(--line))}.model-head{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:18px}.model-role{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.07em;color:var(--faint)}.model-id{font-family:var(--mono);font-size:16px;font-weight:600;overflow-wrap:anywhere}.control{margin-bottom:16px;min-width:0}.control-label{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;font-size:13px;font-weight:600;margin-bottom:8px}.control-label .sub{font-weight:400;margin:0;flex-basis:100%}.mono-value{font-family:var(--mono);font-size:12px;color:var(--accent);margin-left:auto}.control-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:0 24px}.inline{display:flex;gap:8px;align-items:center}input[type=range]{accent-color:var(--accent);padding:0;border:none;background:none;box-shadow:none}.segmented{margin:0;min-width:0;display:inline-flex;flex-wrap:wrap;gap:2px;padding:3px;background:var(--ground);border:1px solid var(--line);border-radius:8px}.segmented button{border:1px solid transparent;background:none;padding:4px 11px;font-size:12px;color:var(--dim);border-radius:6px}.segmented button:hover:not(:disabled){background:var(--raised-2);border-color:transparent;color:var(--text)}.segmented button[aria-pressed=true]{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 45%,var(--line));color:var(--accent);font-weight:600}.model-foot{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:12px}.model-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px 16px;margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}.model-form label{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:500;color:var(--dim)}.model-form label .sub,.model-form label .error{font-size:11px;margin:0}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:14px}.agent-card{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:16px 18px;display:flex;flex-direction:column;gap:12px;text-align:left;transition:border-color .12s,transform .12s}button.agent-card{font-size:13px;font-weight:400;width:100%}button.agent-card:hover:not(:disabled){border-color:color-mix(in srgb,var(--accent) 50%,var(--line));background:var(--raised)}.agent-card.off{opacity:.75}.agent-card .head{display:flex;align-items:center;gap:10px}.agent-card .name{font-weight:600;font-size:15px;letter-spacing:-.01em}.agent-card .id{font-family:var(--mono);font-size:11px;color:var(--faint)}.agent-card .model{font-family:var(--mono);font-size:12px;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stats{display:flex;flex-wrap:wrap;gap:6px}.pill{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--line);border-radius:999px;padding:2px 9px;font-size:11px;font-weight:500;color:var(--dim);background:var(--ground);white-space:nowrap}.pill.accent{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 35%,var(--line));background:var(--accent-soft)}.pill.ok{color:var(--ok)}.pill.warn{color:var(--warn);border-color:color-mix(in srgb,var(--warn) 35%,var(--line))}.pill.bad{color:var(--bad);border-color:color-mix(in srgb,var(--bad) 40%,var(--line));background:var(--bad-soft)}.error-line{color:var(--bad);font-size:12px;margin-top:4px;overflow-wrap:anywhere}.member{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:14px 16px}.member .head{display:flex;align-items:center;gap:10px;margin-bottom:8px}.avatar{width:28px;height:28px;border-radius:7px;display:grid;place-items:center;font-weight:700;font-size:12px;color:var(--accent);background:var(--accent-soft);border:1px solid color-mix(in srgb,var(--accent) 30%,var(--line));flex-shrink:0;text-transform:uppercase}.member .task{color:var(--dim);font-size:13px;margin:0 0 10px}.lead{display:flex;align-items:center;gap:12px;border:1px solid color-mix(in srgb,var(--accent) 35%,var(--line));background:var(--accent-soft);border-radius:var(--radius);padding:14px 16px;margin-bottom:14px}.section-title{font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.07em;color:var(--faint);margin:28px 0 10px}pre.snippet{position:relative;margin:0;background:var(--ground);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;font-family:var(--mono);font-size:12px;line-height:1.6;overflow-x:auto;white-space:pre}.snippet-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}.snippet-head h3{margin:0;font-size:13px;font-weight:600}.snippet-head button{font-size:11px;padding:3px 9px}.method{font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.04em;padding:2px 6px;border-radius:4px;color:var(--accent-ink);background:var(--accent)}.method.get{background:var(--info);color:#fff}.endpoints{display:grid;gap:6px}.endpoint{display:flex;align-items:center;gap:10px;font-size:13px;padding:8px 12px;border:1px solid var(--line);border-radius:6px;background:var(--raised)}.endpoint code{background:none;border:none;padding:0;font-size:12px}.endpoint .what{color:var(--dim);margin-left:auto;font-size:12px;text-align:right}.cta-row{display:flex;gap:10px;flex-wrap:wrap}.cta-row a{display:inline-flex;align-items:center;gap:6px;padding:7px 14px;border:1px solid var(--line);border-radius:6px;font-size:13px;font-weight:500;color:var(--text);background:var(--raised)}.cta-row a.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}.cta-row a:hover{text-decoration:none;filter:brightness(1.08)}.fallbacks{margin:0 0 10px;padding-left:22px;display:grid;gap:6px}.fallbacks li{display:flex;align-items:center;gap:10px;font-size:13px}.schedule-card .head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:8px}.schedule-id{font-size:13px;font-weight:600}.schedule-card .task{margin:0 0 12px;color:var(--text)}.schedule-card.off .task{color:var(--dim)}.facts{display:grid;grid-template-columns:max-content 1fr;gap:4px 12px;margin:0 0 12px;font-size:12px}.facts dt{color:var(--faint);text-transform:uppercase;letter-spacing:.06em;font-size:10px;padding-top:2px}.facts dd{margin:0;overflow-wrap:anywhere}.schedule-card .actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center;border-top:1px solid var(--line);padding-top:10px}.schedule-form{margin-top:18px}.schedule-form h3{margin-bottom:14px}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}.chips .pill{cursor:pointer}.chips .pill:hover{color:var(--text);border-color:var(--line-strong)}.preview{display:block;margin-top:6px}.preview.bad{color:var(--bad)}.model-form textarea{resize:vertical;font-family:var(--sans)}.model-form .field-like{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:500;color:var(--dim)}.search{margin-bottom:14px;max-width:420px}.tool-group{margin-bottom:18px}.tool-group h3{font-size:13px;font-weight:600;margin:0 0 8px;display:flex;align-items:baseline;gap:8px}.tool-group h3 .sub{margin:0}.rules{list-style:none;margin:0 0 10px;padding:0;display:grid;gap:6px}.rules li{display:flex;align-items:center;gap:10px;font-size:13px}.refresh-report ul{margin:0 0 8px;padding-left:18px;font-size:13px}:root{--chart: #c955c9}@media(prefers-color-scheme:light){:root:not([data-theme=dark]){--chart: #b23fb2}}:root[data-theme=light]{--chart: #b23fb2}.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;margin-bottom:8px}.tile{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:14px 16px}.tile-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.07em;color:var(--faint)}.tile-value{font-size:24px;font-weight:650;letter-spacing:-.02em;font-variant-numeric:tabular-nums;margin:4px 0 2px}.chart{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);padding:12px 12px 6px;margin-bottom:18px}.chart svg{display:block;width:100%;height:auto}.chart .bar{fill:var(--chart)}.chart .bar.hot{fill:var(--accent)}.chart .axis{stroke:var(--line-strong);stroke-width:1}.chart .value{fill:var(--dim);font-size:10px;font-family:var(--mono)}.chart .tick{fill:var(--faint);font-size:10px;font-family:var(--mono)}.chart .tooltip{min-height:1.6em;font-size:12px;color:var(--dim);font-family:var(--mono);padding:4px 2px 0}.turns{display:grid;gap:8px}.turn{padding:0;margin:0;overflow:hidden}.turn.bad{border-color:color-mix(in srgb,var(--warn) 40%,var(--line))}.turn-head{width:100%;display:flex;align-items:center;gap:12px;text-align:left;background:none;border:none;border-radius:0;padding:12px 16px;font-weight:400}.turn-head:hover:not(:disabled){background:var(--raised-2);border-color:transparent}.turn-input{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}.turn-meta{display:flex;gap:12px;font-family:var(--mono);font-size:11px;color:var(--faint);white-space:nowrap}.turn-body{border-top:1px solid var(--line);padding:14px 16px 16px}.turn-body .facts{margin-bottom:14px}@media(max-width:720px){.turn-meta{display:none}}.person .head,.card>.head{display:flex;align-items:center;gap:10px;margin-bottom:10px}.person .name{font-weight:600}.person .id{font-family:var(--mono);font-size:11px;color:var(--faint)}.person{display:flex;flex-direction:column;gap:12px}.facts-label{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.07em;color:var(--faint);margin-bottom:6px}.check{display:inline-flex;align-items:center;gap:6px;font-size:13px;cursor:pointer}.check input{width:auto}.members{display:flex;flex-wrap:wrap;gap:10px 16px}.rooms-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:18px}.rooms-list .row-button{margin-bottom:2px}.rooms-main{border:1px solid var(--line);border-radius:var(--radius);background:var(--raised);display:flex;flex-direction:column;min-height:420px}.rooms-main .empty-state{border:none;margin:auto}.room-head{padding:12px 16px;border-bottom:1px solid var(--line);display:flex;flex-direction:column;gap:8px}.room-log{flex:1;padding:14px 16px;overflow-y:auto;display:grid;gap:12px;align-content:start}.room-msg{font-size:13px}.room-msg.agent{border-left:2px solid var(--accent);padding-left:12px}.room-post{border-top:1px solid var(--line);padding:12px 16px}.notes{display:grid;gap:8px}.note-card{margin:0;padding:12px 14px}@media(max-width:720px){.rooms-layout{grid-template-columns:minmax(0,1fr)}}.editor{flex:1;min-height:420px;border:none;border-radius:0;background:var(--ground);font-family:var(--mono);font-size:12.5px;line-height:1.6;padding:14px 16px;resize:vertical}.editor:focus{box-shadow:none}.model-form label.check,label.check{flex-direction:row;align-items:center;font-weight:400;color:var(--text)}.inline-field{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;font-size:12px;color:var(--dim)}.room-skip{margin-top:6px;font-size:12px;color:var(--warn)}.tool-detail{margin-top:6px}.tool-detail-summary{cursor:pointer;color:var(--dim);font-size:12px}.tool-detail pre{max-height:320px;overflow:auto}.replay{list-style:none;padding:0;margin:12px 0 0;display:grid;gap:10px}.replay pre,.tool-detail pre{max-width:100%;box-sizing:border-box;white-space:pre-wrap;overflow-wrap:anywhere}.replay pre{max-height:280px;overflow:auto;margin:4px 0 0}.palette-layer{position:fixed;inset:0;z-index:50;display:flex;justify-content:center;align-items:flex-start;padding:12vh 16px 16px}button.palette-backdrop,button.palette-backdrop:hover:not(:disabled){position:absolute;inset:0;border:none;border-radius:0;background:#00000059;cursor:default}.palette{position:relative;width:min(560px,100%);background:var(--raised);border:1px solid var(--line);border-radius:12px;box-shadow:0 16px 48px #0000004d;overflow:hidden}.palette input{width:100%;border:none;border-bottom:1px solid var(--line);border-radius:0;padding:14px 16px;font-size:15px;background:transparent}.palette-list{list-style:none;margin:0;padding:6px;max-height:50vh;overflow:auto}.palette-item{width:100%;display:flex;justify-content:space-between;gap:12px;padding:8px 10px;border:none;border-radius:8px;background:transparent;text-align:left}.palette-item[aria-current=true]{background:var(--raised-2)}.palette .sub{margin:0}.palette .empty{padding:16px}.caps-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0}.caps-row .mono-value{margin:0;min-width:80px}.caps-row select,.caps-row input{width:auto}\n',qn=`(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))r(d);new MutationObserver(d=>{for(const f of d)if(f.type==="childList")for(const m of f.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&r(m)}).observe(document,{childList:!0,subtree:!0});function o(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function r(d){if(d.ep)return;d.ep=!0;const f=o(d);fetch(d.href,f)}})();function n0(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Br={exports:{}},Ki={};var vm;function a0(){if(vm)return Ki;vm=1;var l=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function o(r,d,f){var m=null;if(f!==void 0&&(m=""+f),d.key!==void 0&&(m=""+d.key),"key"in d){f={};for(var v in d)v!=="key"&&(f[v]=d[v])}else f=d;return d=f.ref,{$$typeof:l,type:r,key:m,ref:d!==void 0?d:null,props:f}}return Ki.Fragment=u,Ki.jsx=o,Ki.jsxs=o,Ki}var ym;function l0(){return ym||(ym=1,Br.exports=a0()),Br.exports}var i=l0(),Hr={exports:{}},ve={};var bm;function i0(){if(bm)return ve;bm=1;var l=Symbol.for("react.transitional.element"),u=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),m=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),S=Symbol.iterator;function N(A){return A===null||typeof A!="object"?null:(A=S&&A[S]||A["@@iterator"],typeof A=="function"?A:null)}var R={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},L=Object.assign,P={};function J(A,q,I){this.props=A,this.context=q,this.refs=P,this.updater=I||R}J.prototype.isReactComponent={},J.prototype.setState=function(A,q){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,q,"setState")},J.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function Z(){}Z.prototype=J.prototype;function F(A,q,I){this.props=A,this.context=q,this.refs=P,this.updater=I||R}var _=F.prototype=new Z;_.constructor=F,L(_,J.prototype),_.isPureReactComponent=!0;var ge=Array.isArray;function ee(){}var V={H:null,A:null,T:null,S:null},le=Object.prototype.hasOwnProperty;function W(A,q,I){var ie=I.ref;return{$$typeof:l,type:A,key:q,ref:ie!==void 0?ie:null,props:I}}function Y(A,q){return W(A.type,q,A.props)}function ne(A){return typeof A=="object"&&A!==null&&A.$$typeof===l}function ae(A){var q={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(I){return q[I]})}var Q=/\\/+/g;function se(A,q){return typeof A=="object"&&A!==null&&A.key!=null?ae(""+A.key):q.toString(36)}function re(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(ee,ee):(A.status="pending",A.then(function(q){A.status==="pending"&&(A.status="fulfilled",A.value=q)},function(q){A.status==="pending"&&(A.status="rejected",A.reason=q)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function D(A,q,I,ie,me){var be=typeof A;(be==="undefined"||be==="boolean")&&(A=null);var ye=!1;if(A===null)ye=!0;else switch(be){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(A.$$typeof){case l:case u:ye=!0;break;case j:return ye=A._init,D(ye(A._payload),q,I,ie,me)}}if(ye)return me=me(A),ye=ie===""?"."+se(A,0):ie,ge(me)?(I="",ye!=null&&(I=ye.replace(Q,"$&/")+"/"),D(me,q,I,"",function(Wt){return Wt})):me!=null&&(ne(me)&&(me=Y(me,I+(me.key==null||A&&A.key===me.key?"":(""+me.key).replace(Q,"$&/")+"/")+ye)),q.push(me)),1;ye=0;var ze=ie===""?".":ie+":";if(ge(A))for(var oe=0;oe<A.length;oe++)ie=A[oe],be=ze+se(ie,oe),ye+=D(ie,q,I,be,me);else if(oe=N(A),typeof oe=="function")for(A=oe.call(A),oe=0;!(ie=A.next()).done;)ie=ie.value,be=ze+se(ie,oe++),ye+=D(ie,q,I,be,me);else if(be==="object"){if(typeof A.then=="function")return D(re(A),q,I,ie,me);throw q=String(A),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return ye}function te(A,q,I){if(A==null)return A;var ie=[],me=0;return D(A,ie,"","",function(be){return q.call(I,be,me++)}),ie}function K(A){if(A._status===-1){var q=A._result;q=q(),q.then(function(I){(A._status===0||A._status===-1)&&(A._status=1,A._result=I)},function(I){(A._status===0||A._status===-1)&&(A._status=2,A._result=I)}),A._status===-1&&(A._status=0,A._result=q)}if(A._status===1)return A._result.default;throw A._result}var Ce=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},Ae={map:te,forEach:function(A,q,I){te(A,function(){q.apply(this,arguments)},I)},count:function(A){var q=0;return te(A,function(){q++}),q},toArray:function(A){return te(A,function(q){return q})||[]},only:function(A){if(!ne(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};return ve.Activity=g,ve.Children=Ae,ve.Component=J,ve.Fragment=o,ve.Profiler=d,ve.PureComponent=F,ve.StrictMode=r,ve.Suspense=x,ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=V,ve.__COMPILER_RUNTIME={__proto__:null,c:function(A){return V.H.useMemoCache(A)}},ve.cache=function(A){return function(){return A.apply(null,arguments)}},ve.cacheSignal=function(){return null},ve.cloneElement=function(A,q,I){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var ie=L({},A.props),me=A.key;if(q!=null)for(be in q.key!==void 0&&(me=""+q.key),q)!le.call(q,be)||be==="key"||be==="__self"||be==="__source"||be==="ref"&&q.ref===void 0||(ie[be]=q[be]);var be=arguments.length-2;if(be===1)ie.children=I;else if(1<be){for(var ye=Array(be),ze=0;ze<be;ze++)ye[ze]=arguments[ze+2];ie.children=ye}return W(A.type,me,ie)},ve.createContext=function(A){return A={$$typeof:m,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:f,_context:A},A},ve.createElement=function(A,q,I){var ie,me={},be=null;if(q!=null)for(ie in q.key!==void 0&&(be=""+q.key),q)le.call(q,ie)&&ie!=="key"&&ie!=="__self"&&ie!=="__source"&&(me[ie]=q[ie]);var ye=arguments.length-2;if(ye===1)me.children=I;else if(1<ye){for(var ze=Array(ye),oe=0;oe<ye;oe++)ze[oe]=arguments[oe+2];me.children=ze}if(A&&A.defaultProps)for(ie in ye=A.defaultProps,ye)me[ie]===void 0&&(me[ie]=ye[ie]);return W(A,be,me)},ve.createRef=function(){return{current:null}},ve.forwardRef=function(A){return{$$typeof:v,render:A}},ve.isValidElement=ne,ve.lazy=function(A){return{$$typeof:j,_payload:{_status:-1,_result:A},_init:K}},ve.memo=function(A,q){return{$$typeof:y,type:A,compare:q===void 0?null:q}},ve.startTransition=function(A){var q=V.T,I={};V.T=I;try{var ie=A(),me=V.S;me!==null&&me(I,ie),typeof ie=="object"&&ie!==null&&typeof ie.then=="function"&&ie.then(ee,Ce)}catch(be){Ce(be)}finally{q!==null&&I.types!==null&&(q.types=I.types),V.T=q}},ve.unstable_useCacheRefresh=function(){return V.H.useCacheRefresh()},ve.use=function(A){return V.H.use(A)},ve.useActionState=function(A,q,I){return V.H.useActionState(A,q,I)},ve.useCallback=function(A,q){return V.H.useCallback(A,q)},ve.useContext=function(A){return V.H.useContext(A)},ve.useDebugValue=function(){},ve.useDeferredValue=function(A,q){return V.H.useDeferredValue(A,q)},ve.useEffect=function(A,q){return V.H.useEffect(A,q)},ve.useEffectEvent=function(A){return V.H.useEffectEvent(A)},ve.useId=function(){return V.H.useId()},ve.useImperativeHandle=function(A,q,I){return V.H.useImperativeHandle(A,q,I)},ve.useInsertionEffect=function(A,q){return V.H.useInsertionEffect(A,q)},ve.useLayoutEffect=function(A,q){return V.H.useLayoutEffect(A,q)},ve.useMemo=function(A,q){return V.H.useMemo(A,q)},ve.useOptimistic=function(A,q){return V.H.useOptimistic(A,q)},ve.useReducer=function(A,q,I){return V.H.useReducer(A,q,I)},ve.useRef=function(A){return V.H.useRef(A)},ve.useState=function(A){return V.H.useState(A)},ve.useSyncExternalStore=function(A,q,I){return V.H.useSyncExternalStore(A,q,I)},ve.useTransition=function(){return V.H.useTransition()},ve.version="19.2.8",ve}var pm;function Bo(){return pm||(pm=1,Hr.exports=i0()),Hr.exports}var T=Bo(),Lr={exports:{}},Yi={},qr={exports:{}},$r={};var xm;function s0(){return xm||(xm=1,(function(l){function u(D,te){var K=D.length;D.push(te);e:for(;0<K;){var Ce=K-1>>>1,Ae=D[Ce];if(0<d(Ae,te))D[Ce]=te,D[K]=Ae,K=Ce;else break e}}function o(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var te=D[0],K=D.pop();if(K!==te){D[0]=K;e:for(var Ce=0,Ae=D.length,A=Ae>>>1;Ce<A;){var q=2*(Ce+1)-1,I=D[q],ie=q+1,me=D[ie];if(0>d(I,K))ie<Ae&&0>d(me,I)?(D[Ce]=me,D[ie]=K,Ce=ie):(D[Ce]=I,D[q]=K,Ce=q);else if(ie<Ae&&0>d(me,K))D[Ce]=me,D[ie]=K,Ce=ie;else break e}}return te}function d(D,te){var K=D.sortIndex-te.sortIndex;return K!==0?K:D.id-te.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;l.unstable_now=function(){return f.now()}}else{var m=Date,v=m.now();l.unstable_now=function(){return m.now()-v}}var x=[],y=[],j=1,g=null,S=3,N=!1,R=!1,L=!1,P=!1,J=typeof setTimeout=="function"?setTimeout:null,Z=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;function _(D){for(var te=o(y);te!==null;){if(te.callback===null)r(y);else if(te.startTime<=D)r(y),te.sortIndex=te.expirationTime,u(x,te);else break;te=o(y)}}function ge(D){if(L=!1,_(D),!R)if(o(x)!==null)R=!0,ee||(ee=!0,ae());else{var te=o(y);te!==null&&re(ge,te.startTime-D)}}var ee=!1,V=-1,le=5,W=-1;function Y(){return P?!0:!(l.unstable_now()-W<le)}function ne(){if(P=!1,ee){var D=l.unstable_now();W=D;var te=!0;try{e:{R=!1,L&&(L=!1,Z(V),V=-1),N=!0;var K=S;try{t:{for(_(D),g=o(x);g!==null&&!(g.expirationTime>D&&Y());){var Ce=g.callback;if(typeof Ce=="function"){g.callback=null,S=g.priorityLevel;var Ae=Ce(g.expirationTime<=D);if(D=l.unstable_now(),typeof Ae=="function"){g.callback=Ae,_(D),te=!0;break t}g===o(x)&&r(x),_(D)}else r(x);g=o(x)}if(g!==null)te=!0;else{var A=o(y);A!==null&&re(ge,A.startTime-D),te=!1}}break e}finally{g=null,S=K,N=!1}te=void 0}}finally{te?ae():ee=!1}}}var ae;if(typeof F=="function")ae=function(){F(ne)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,se=Q.port2;Q.port1.onmessage=ne,ae=function(){se.postMessage(null)}}else ae=function(){J(ne,0)};function re(D,te){V=J(function(){D(l.unstable_now())},te)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(D){D.callback=null},l.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):le=0<D?Math.floor(1e3/D):5},l.unstable_getCurrentPriorityLevel=function(){return S},l.unstable_next=function(D){switch(S){case 1:case 2:case 3:var te=3;break;default:te=S}var K=S;S=te;try{return D()}finally{S=K}},l.unstable_requestPaint=function(){P=!0},l.unstable_runWithPriority=function(D,te){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var K=S;S=D;try{return te()}finally{S=K}},l.unstable_scheduleCallback=function(D,te,K){var Ce=l.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?Ce+K:Ce):K=Ce,D){case 1:var Ae=-1;break;case 2:Ae=250;break;case 5:Ae=1073741823;break;case 4:Ae=1e4;break;default:Ae=5e3}return Ae=K+Ae,D={id:j++,callback:te,priorityLevel:D,startTime:K,expirationTime:Ae,sortIndex:-1},K>Ce?(D.sortIndex=K,u(y,D),o(x)===null&&D===o(y)&&(L?(Z(V),V=-1):L=!0,re(ge,K-Ce))):(D.sortIndex=Ae,u(x,D),R||N||(R=!0,ee||(ee=!0,ae()))),D},l.unstable_shouldYield=Y,l.unstable_wrapCallback=function(D){var te=S;return function(){var K=S;S=te;try{return D.apply(this,arguments)}finally{S=K}}}})($r)),$r}var jm;function u0(){return jm||(jm=1,qr.exports=s0()),qr.exports}var Gr={exports:{}},yt={};var Sm;function c0(){if(Sm)return yt;Sm=1;var l=Bo();function u(x){var y="https://react.dev/errors/"+x;if(1<arguments.length){y+="?args[]="+encodeURIComponent(arguments[1]);for(var j=2;j<arguments.length;j++)y+="&args[]="+encodeURIComponent(arguments[j])}return"Minified React error #"+x+"; visit "+y+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(){}var r={d:{f:o,r:function(){throw Error(u(522))},D:o,C:o,L:o,m:o,X:o,S:o,M:o},p:0,findDOMNode:null},d=Symbol.for("react.portal");function f(x,y,j){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d,key:g==null?null:""+g,children:x,containerInfo:y,implementation:j}}var m=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function v(x,y){if(x==="font")return"";if(typeof y=="string")return y==="use-credentials"?y:""}return yt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,yt.createPortal=function(x,y){var j=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!y||y.nodeType!==1&&y.nodeType!==9&&y.nodeType!==11)throw Error(u(299));return f(x,y,null,j)},yt.flushSync=function(x){var y=m.T,j=r.p;try{if(m.T=null,r.p=2,x)return x()}finally{m.T=y,r.p=j,r.d.f()}},yt.preconnect=function(x,y){typeof x=="string"&&(y?(y=y.crossOrigin,y=typeof y=="string"?y==="use-credentials"?y:"":void 0):y=null,r.d.C(x,y))},yt.prefetchDNS=function(x){typeof x=="string"&&r.d.D(x)},yt.preinit=function(x,y){if(typeof x=="string"&&y&&typeof y.as=="string"){var j=y.as,g=v(j,y.crossOrigin),S=typeof y.integrity=="string"?y.integrity:void 0,N=typeof y.fetchPriority=="string"?y.fetchPriority:void 0;j==="style"?r.d.S(x,typeof y.precedence=="string"?y.precedence:void 0,{crossOrigin:g,integrity:S,fetchPriority:N}):j==="script"&&r.d.X(x,{crossOrigin:g,integrity:S,fetchPriority:N,nonce:typeof y.nonce=="string"?y.nonce:void 0})}},yt.preinitModule=function(x,y){if(typeof x=="string")if(typeof y=="object"&&y!==null){if(y.as==null||y.as==="script"){var j=v(y.as,y.crossOrigin);r.d.M(x,{crossOrigin:j,integrity:typeof y.integrity=="string"?y.integrity:void 0,nonce:typeof y.nonce=="string"?y.nonce:void 0})}}else y==null&&r.d.M(x)},yt.preload=function(x,y){if(typeof x=="string"&&typeof y=="object"&&y!==null&&typeof y.as=="string"){var j=y.as,g=v(j,y.crossOrigin);r.d.L(x,j,{crossOrigin:g,integrity:typeof y.integrity=="string"?y.integrity:void 0,nonce:typeof y.nonce=="string"?y.nonce:void 0,type:typeof y.type=="string"?y.type:void 0,fetchPriority:typeof y.fetchPriority=="string"?y.fetchPriority:void 0,referrerPolicy:typeof y.referrerPolicy=="string"?y.referrerPolicy:void 0,imageSrcSet:typeof y.imageSrcSet=="string"?y.imageSrcSet:void 0,imageSizes:typeof y.imageSizes=="string"?y.imageSizes:void 0,media:typeof y.media=="string"?y.media:void 0})}},yt.preloadModule=function(x,y){if(typeof x=="string")if(y){var j=v(y.as,y.crossOrigin);r.d.m(x,{as:typeof y.as=="string"&&y.as!=="script"?y.as:void 0,crossOrigin:j,integrity:typeof y.integrity=="string"?y.integrity:void 0})}else r.d.m(x)},yt.requestFormReset=function(x){r.d.r(x)},yt.unstable_batchedUpdates=function(x,y){return x(y)},yt.useFormState=function(x,y,j){return m.H.useFormState(x,y,j)},yt.useFormStatus=function(){return m.H.useHostTransitionStatus()},yt.version="19.2.8",yt}var Nm;function r0(){if(Nm)return Gr.exports;Nm=1;function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(u){console.error(u)}}return l(),Gr.exports=c0(),Gr.exports}var wm;function o0(){if(wm)return Yi;wm=1;var l=u0(),u=Bo(),o=r0();function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function m(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function v(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(f(e)!==e)throw Error(r(188))}function y(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(r(188));return t!==e?null:e}for(var n=e,a=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(a=s.return,a!==null){n=a;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return x(s),e;if(c===a)return x(s),t;c=c.sibling}throw Error(r(188))}if(n.return!==a.return)n=s,a=c;else{for(var h=!1,b=s.child;b;){if(b===n){h=!0,n=s,a=c;break}if(b===a){h=!0,a=s,n=c;break}b=b.sibling}if(!h){for(b=c.child;b;){if(b===n){h=!0,n=c,a=s;break}if(b===a){h=!0,a=c,n=s;break}b=b.sibling}if(!h)throw Error(r(189))}}if(n.alternate!==a)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function j(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=j(e),t!==null)return t;e=e.sibling}return null}var g=Object.assign,S=Symbol.for("react.element"),N=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),Z=Symbol.for("react.consumer"),F=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),ge=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),Y=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function ae(e){return e===null||typeof e!="object"?null:(e=ne&&e[ne]||e["@@iterator"],typeof e=="function"?e:null)}var Q=Symbol.for("react.client.reference");function se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case L:return"Fragment";case J:return"Profiler";case P:return"StrictMode";case ge:return"Suspense";case ee:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case R:return"Portal";case F:return e.displayName||"Context";case Z:return(e._context.displayName||"Context")+".Consumer";case _:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return t=e.displayName||null,t!==null?t:se(e.type)||"Memo";case le:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var re=Array.isArray,D=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},Ce=[],Ae=-1;function A(e){return{current:e}}function q(e){0>Ae||(e.current=Ce[Ae],Ce[Ae]=null,Ae--)}function I(e,t){Ae++,Ce[Ae]=e.current,e.current=t}var ie=A(null),me=A(null),be=A(null),ye=A(null);function ze(e,t){switch(I(be,t),I(me,e),I(ie,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Lh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Lh(t),e=qh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(ie),I(ie,e)}function oe(){q(ie),q(me),q(be)}function Wt(e){e.memoizedState!==null&&I(ye,e);var t=ie.current,n=qh(t,e.type);t!==n&&(I(me,e),I(ie,n))}function Ea(e){me.current===e&&(q(ie),q(me)),ye.current===e&&(q(ye),Li._currentValue=K)}var Qn,Vl;function St(e){if(Qn===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\\n( *(at )?)/);Qn=t&&t[1]||"",Vl=-1<n.stack.indexOf(\`
10
+ at\`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return\`
11
+ \`+Qn+e+Vl}var kt=!1;function cl(e,t){if(!e||kt)return"";kt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var G=function(){throw Error()};if(Object.defineProperty(G.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(G,[])}catch(U){var O=U}Reflect.construct(e,[],G)}else{try{G.call()}catch(U){O=U}e.call(G.prototype)}}else{try{throw Error()}catch(U){O=U}(G=e())&&typeof G.catch=="function"&&G.catch(function(){})}}catch(U){if(U&&O&&typeof U.stack=="string")return[U.stack,O.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var s=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");s&&s.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=a.DetermineComponentFrameRoot(),h=c[0],b=c[1];if(h&&b){var w=h.split(\`
12
+ \`),z=b.split(\`
13
+ \`);for(s=a=0;a<w.length&&!w[a].includes("DetermineComponentFrameRoot");)a++;for(;s<z.length&&!z[s].includes("DetermineComponentFrameRoot");)s++;if(a===w.length||s===z.length)for(a=w.length-1,s=z.length-1;1<=a&&0<=s&&w[a]!==z[s];)s--;for(;1<=a&&0<=s;a--,s--)if(w[a]!==z[s]){if(a!==1||s!==1)do if(a--,s--,0>s||w[a]!==z[s]){var B=\`
14
+ \`+w[a].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),B}while(1<=a&&0<=s);break}}}finally{kt=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?St(n):""}function zu(e,t){switch(e.tag){case 26:case 27:case 5:return St(e.type);case 16:return St("Lazy");case 13:return e.child!==t&&t!==null?St("Suspense Fallback"):St("Suspense");case 19:return St("SuspenseList");case 0:case 15:return cl(e.type,!1);case 11:return cl(e.type.render,!1);case 1:return cl(e.type,!0);case 31:return St("Activity");default:return""}}function ht(e){try{var t="",n=null;do t+=zu(e,n),n=e,e=e.return;while(e);return t}catch(a){return\`
15
+ Error generating stack: \`+a.message+\`
16
+ \`+a.stack}}var rl=Object.prototype.hasOwnProperty,Lt=l.unstable_scheduleCallback,ol=l.unstable_cancelCallback,nt=l.unstable_shouldYield,Xn=l.unstable_requestPaint,mt=l.unstable_now,Pi=l.unstable_getCurrentPriorityLevel,Zl=l.unstable_ImmediatePriority,Jl=l.unstable_UserBlockingPriority,jn=l.unstable_NormalPriority,es=l.unstable_LowPriority,Fl=l.unstable_IdlePriority,ts=l.log,Ou=l.unstable_setDisableYieldValue,Sn=null,bt=null;function on(e){if(typeof ts=="function"&&Ou(e),bt&&typeof bt.setStrictMode=="function")try{bt.setStrictMode(Sn,e)}catch{}}var gt=Math.clz32?Math.clz32:_u,ns=Math.log,as=Math.LN2;function _u(e){return e>>>=0,e===0?32:31-(ns(e)/as|0)|0}var Aa=256,Vn=262144,Nn=4194304;function It(e){var t=e&42;if(t!==0)return t;switch(e&-e){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function dl(e,t,n){var a=e.pendingLanes;if(a===0)return 0;var s=0,c=e.suspendedLanes,h=e.pingedLanes;e=e.warmLanes;var b=a&134217727;return b!==0?(a=b&~c,a!==0?s=It(a):(h&=b,h!==0?s=It(h):n||(n=b&~e,n!==0&&(s=It(n))))):(b=a&~c,b!==0?s=It(b):h!==0?s=It(h):n||(n=a&~e,n!==0&&(s=It(n)))),s===0?0:t!==0&&t!==s&&(t&c)===0&&(c=s&-s,n=t&-t,c>=n||c===32&&(n&4194048)!==0)?t:s}function Ca(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ls(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function fl(){var e=Nn;return Nn<<=1,(Nn&62914560)===0&&(Nn=4194304),e}function ka(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ma(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Uu(e,t,n,a,s,c){var h=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var b=e.entanglements,w=e.expirationTimes,z=e.hiddenUpdates;for(n=h&~n;0<n;){var B=31-gt(n),G=1<<B;b[B]=0,w[B]=-1;var O=z[B];if(O!==null)for(z[B]=null,B=0;B<O.length;B++){var U=O[B];U!==null&&(U.lane&=-536870913)}n&=~G}a!==0&&wn(e,a,0),c!==0&&s===0&&e.tag!==0&&(e.suspendedLanes|=c&~(h&~t))}function wn(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-gt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|n&261930}function Wl(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var a=31-gt(n),s=1<<a;s&t|e[a]&t&&(e[a]|=t),n&=~s}}function is(e,t){var n=t&-t;return n=(n&42)!==0?1:hl(n),(n&(e.suspendedLanes|t))!==0?0:n}function hl(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Il(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Pl(){var e=te.p;return e!==0?e:(e=window.event,e===void 0?32:rm(e.type))}function ss(e,t){var n=te.p;try{return te.p=e,t()}finally{te.p=n}}var dn=Math.random().toString(36).slice(2),qe="__reactFiber$"+dn,vt="__reactProps$"+dn,Zn="__reactContainer$"+dn,ml="__reactEvents$"+dn,us="__reactListeners$"+dn,Du="__reactHandles$"+dn,pt="__reactResources$"+dn,Jn="__reactMarker$"+dn;function Nt(e){delete e[qe],delete e[vt],delete e[ml],delete e[us],delete e[Du]}function fn(e){var t=e[qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Zn]||n[qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Vh(e);e!==null;){if(n=e[qe])return n;e=Vh(e)}return t}e=n,n=e.parentNode}return null}function xt(e){if(e=e[qe]||e[Zn]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function qt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Pt(e){var t=e[pt];return t||(t=e[pt]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Jn]=!0}var hn=new Set,cs={};function Tn(e,t){En(e,t),En(e+"Capture",t)}function En(e,t){for(cs[e]=t,e=0;e<t.length;e++)hn.add(t[e])}var rs=RegExp("^[: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]*$"),Ra={},os={};function Fn(e){return rl.call(os,e)?!0:rl.call(Ra,e)?!1:rs.test(e)?os[e]=!0:(Ra[e]=!0,!1)}function za(e,t,n){if(Fn(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var a=t.toLowerCase().slice(0,5);if(a!=="data-"&&a!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Oa(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function en(e,t,n,a){if(a===null)e.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+a)}}function st(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ei(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Bu(e,t,n){var a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var s=a.get,c=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(h){n=""+h,c.call(this,h)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return n},setValue:function(h){n=""+h},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Wn(e){if(!e._valueTracker){var t=ei(e)?"checked":"value";e._valueTracker=Bu(e,t,""+e[t])}}function In(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=ei(e)?e.checked?"true":"false":e.value),e=a,e!==n?(t.setValue(e),!0):!1}function _a(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var ds=/[\\n"\\\\]/g;function ut(e){return e.replace(ds,function(t){return"\\\\"+t.charCodeAt(0).toString(16)+" "})}function An(e,t,n,a,s,c,h,b){e.name="",h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.type=h:e.removeAttribute("type"),t!=null?h==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+st(t)):e.value!==""+st(t)&&(e.value=""+st(t)):h!=="submit"&&h!=="reset"||e.removeAttribute("value"),t!=null?Ua(e,h,st(t)):n!=null?Ua(e,h,st(n)):a!=null&&e.removeAttribute("value"),s==null&&c!=null&&(e.defaultChecked=!!c),s!=null&&(e.checked=s&&typeof s!="function"&&typeof s!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.name=""+st(b):e.removeAttribute("name")}function gl(e,t,n,a,s,c,h,b){if(c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(e.type=c),t!=null||n!=null){if(!(c!=="submit"&&c!=="reset"||t!=null)){Wn(e);return}n=n!=null?""+st(n):"",t=t!=null?""+st(t):n,b||t===e.value||(e.value=t),e.defaultValue=t}a=a??s,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=b?e.checked:!!a,e.defaultChecked=!!a,h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.name=h),Wn(e)}function Ua(e,t,n){t==="number"&&_a(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function $e(e,t,n,a){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&a&&(e[n].defaultSelected=!0)}else{for(n=""+st(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,a&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function tn(e,t,n){if(t!=null&&(t=""+st(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+st(n):""}function ti(e,t,n,a){if(t==null){if(a!=null){if(n!=null)throw Error(r(92));if(re(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}n==null&&(n=""),t=n}n=st(t),e.defaultValue=n,a=e.textContent,a===n&&a!==""&&a!==null&&(e.value=a),Wn(e)}function Pn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Hu=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function fs(e,t,n){var a=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?a?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":a?e.setProperty(t,n):typeof n!="number"||n===0||Hu.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function hs(e,t,n){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,n!=null){for(var a in n)!n.hasOwnProperty(a)||t!=null&&t.hasOwnProperty(a)||(a.indexOf("--")===0?e.setProperty(a,""):a==="float"?e.cssFloat="":e[a]="");for(var s in t)a=t[s],t.hasOwnProperty(s)&&n[s]!==a&&fs(e,s,a)}else for(var c in t)t.hasOwnProperty(c)&&fs(e,c,t[c])}function ni(e){if(e.indexOf("-")===-1)return!1;switch(e){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 $t=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ms=/^[\\u0000-\\u001F ]*j[\\r\\n\\t]*a[\\r\\n\\t]*v[\\r\\n\\t]*a[\\r\\n\\t]*s[\\r\\n\\t]*c[\\r\\n\\t]*r[\\r\\n\\t]*i[\\r\\n\\t]*p[\\r\\n\\t]*t[\\r\\n\\t]*:/i;function Cn(e){return ms.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Gt(){}var ai=null;function vl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var kn=null,nn=null;function Da(e){var t=xt(e);if(t&&(e=t.stateNode)){var n=e[vt]||null;e:switch(e=t.stateNode,t.type){case"input":if(An(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+ut(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var s=a[vt]||null;if(!s)throw Error(r(90));An(a,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name)}}for(t=0;t<n.length;t++)a=n[t],a.form===e.form&&In(a)}break e;case"textarea":tn(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&$e(e,!!n.multiple,t,!1)}}}var ea=!1;function gs(e,t,n){if(ea)return e(t,n);ea=!0;try{var a=e(t);return a}finally{if(ea=!1,(kn!==null||nn!==null)&&(Is(),kn&&(t=kn,e=nn,nn=kn=null,Da(t),e)))for(t=0;t<e.length;t++)Da(e[t])}}function ct(e,t){var n=e.stateNode;if(n===null)return null;var a=n[vt]||null;if(a===null)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(r(231,t,typeof n));return n}var an=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ba=!1;if(an)try{var Ha={};Object.defineProperty(Ha,"passive",{get:function(){Ba=!0}}),window.addEventListener("test",Ha,Ha),window.removeEventListener("test",Ha,Ha)}catch{Ba=!1}var ln=null,p=null,C=null;function $(){if(C)return C;var e,t=p,n=t.length,a,s="value"in ln?ln.value:ln.textContent,c=s.length;for(e=0;e<n&&t[e]===s[e];e++);var h=n-e;for(a=1;a<=h&&t[n-a]===s[c-a];a++);return C=s.slice(e,1<a?1-a:void 0)}function X(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function fe(){return!0}function pe(){return!1}function Ue(e){function t(n,a,s,c,h){this._reactName=n,this._targetInst=s,this.type=a,this.nativeEvent=c,this.target=h,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(n=e[b],this[b]=n?n(c):c[b]);return this.isDefaultPrevented=(c.defaultPrevented!=null?c.defaultPrevented:c.returnValue===!1)?fe:pe,this.isPropagationStopped=pe,this}return g(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=fe)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=fe)},persist:function(){},isPersistent:fe}),t}var Mt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},La=Ue(Mt),li=g({},Mt,{view:0,detail:0}),ev=Ue(li),Lu,qu,ii,vs=g({},li,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Gu,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ii&&(ii&&e.type==="mousemove"?(Lu=e.screenX-ii.screenX,qu=e.screenY-ii.screenY):qu=Lu=0,ii=e),Lu)},movementY:function(e){return"movementY"in e?e.movementY:qu}}),$o=Ue(vs),tv=g({},vs,{dataTransfer:0}),nv=Ue(tv),av=g({},li,{relatedTarget:0}),$u=Ue(av),lv=g({},Mt,{animationName:0,elapsedTime:0,pseudoElement:0}),iv=Ue(lv),sv=g({},Mt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),uv=Ue(sv),cv=g({},Mt,{data:0}),Go=Ue(cv),rv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ov={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"},dv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=dv[e])?!!t[e]:!1}function Gu(){return fv}var hv=g({},li,{key:function(e){if(e.key){var t=rv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=X(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ov[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Gu,charCode:function(e){return e.type==="keypress"?X(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?X(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),mv=Ue(hv),gv=g({},vs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ko=Ue(gv),vv=g({},li,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Gu}),yv=Ue(vv),bv=g({},Mt,{propertyName:0,elapsedTime:0,pseudoElement:0}),pv=Ue(bv),xv=g({},vs,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),jv=Ue(xv),Sv=g({},Mt,{newState:0,oldState:0}),Nv=Ue(Sv),wv=[9,13,27,32],Ku=an&&"CompositionEvent"in window,si=null;an&&"documentMode"in document&&(si=document.documentMode);var Tv=an&&"TextEvent"in window&&!si,Yo=an&&(!Ku||si&&8<si&&11>=si),Qo=" ",Xo=!1;function Vo(e,t){switch(e){case"keyup":return wv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zo(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var yl=!1;function Ev(e,t){switch(e){case"compositionend":return Zo(t);case"keypress":return t.which!==32?null:(Xo=!0,Qo);case"textInput":return e=t.data,e===Qo&&Xo?null:e;default:return null}}function Av(e,t){if(yl)return e==="compositionend"||!Ku&&Vo(e,t)?(e=$(),C=p=ln=null,yl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Yo&&t.locale!=="ko"?null:t.data;default:return null}}var Cv={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 Jo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Cv[e.type]:t==="textarea"}function Fo(e,t,n,a){kn?nn?nn.push(a):nn=[a]:kn=a,t=iu(t,"onChange"),0<t.length&&(n=new La("onChange","change",null,n,a),e.push({event:n,listeners:t}))}var ui=null,ci=null;function kv(e){Oh(e,0)}function ys(e){var t=qt(e);if(In(t))return e}function Wo(e,t){if(e==="change")return t}var Io=!1;if(an){var Yu;if(an){var Qu="oninput"in document;if(!Qu){var Po=document.createElement("div");Po.setAttribute("oninput","return;"),Qu=typeof Po.oninput=="function"}Yu=Qu}else Yu=!1;Io=Yu&&(!document.documentMode||9<document.documentMode)}function ed(){ui&&(ui.detachEvent("onpropertychange",td),ci=ui=null)}function td(e){if(e.propertyName==="value"&&ys(ci)){var t=[];Fo(t,ci,e,vl(e)),gs(kv,t)}}function Mv(e,t,n){e==="focusin"?(ed(),ui=t,ci=n,ui.attachEvent("onpropertychange",td)):e==="focusout"&&ed()}function Rv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ys(ci)}function zv(e,t){if(e==="click")return ys(t)}function Ov(e,t){if(e==="input"||e==="change")return ys(t)}function _v(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Rt=typeof Object.is=="function"?Object.is:_v;function ri(e,t){if(Rt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var s=n[a];if(!rl.call(t,s)||!Rt(e[s],t[s]))return!1}return!0}function nd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ad(e,t){var n=nd(e);e=0;for(var a;n;){if(n.nodeType===3){if(a=e+n.textContent.length,e<=t&&a>=t)return{node:n,offset:t-e};e=a}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=nd(n)}}function ld(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ld(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function id(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=_a(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=_a(e.document)}return t}function Xu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Uv=an&&"documentMode"in document&&11>=document.documentMode,bl=null,Vu=null,oi=null,Zu=!1;function sd(e,t,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zu||bl==null||bl!==_a(a)||(a=bl,"selectionStart"in a&&Xu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),oi&&ri(oi,a)||(oi=a,a=iu(Vu,"onSelect"),0<a.length&&(t=new La("onSelect","select",null,t,n),e.push({event:t,listeners:a}),t.target=bl)))}function qa(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var pl={animationend:qa("Animation","AnimationEnd"),animationiteration:qa("Animation","AnimationIteration"),animationstart:qa("Animation","AnimationStart"),transitionrun:qa("Transition","TransitionRun"),transitionstart:qa("Transition","TransitionStart"),transitioncancel:qa("Transition","TransitionCancel"),transitionend:qa("Transition","TransitionEnd")},Ju={},ud={};an&&(ud=document.createElement("div").style,"AnimationEvent"in window||(delete pl.animationend.animation,delete pl.animationiteration.animation,delete pl.animationstart.animation),"TransitionEvent"in window||delete pl.transitionend.transition);function $a(e){if(Ju[e])return Ju[e];if(!pl[e])return e;var t=pl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ud)return Ju[e]=t[n];return e}var cd=$a("animationend"),rd=$a("animationiteration"),od=$a("animationstart"),Dv=$a("transitionrun"),Bv=$a("transitionstart"),Hv=$a("transitioncancel"),dd=$a("transitionend"),fd=new Map,Fu="abort auxClick beforeToggle 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(" ");Fu.push("scrollEnd");function sn(e,t){fd.set(e,t),Tn(t,[e])}var bs=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Kt=[],xl=0,Wu=0;function ps(){for(var e=xl,t=Wu=xl=0;t<e;){var n=Kt[t];Kt[t++]=null;var a=Kt[t];Kt[t++]=null;var s=Kt[t];Kt[t++]=null;var c=Kt[t];if(Kt[t++]=null,a!==null&&s!==null){var h=a.pending;h===null?s.next=s:(s.next=h.next,h.next=s),a.pending=s}c!==0&&hd(n,s,c)}}function xs(e,t,n,a){Kt[xl++]=e,Kt[xl++]=t,Kt[xl++]=n,Kt[xl++]=a,Wu|=a,e.lanes|=a,e=e.alternate,e!==null&&(e.lanes|=a)}function Iu(e,t,n,a){return xs(e,t,n,a),js(e)}function Ga(e,t){return xs(e,null,null,t),js(e)}function hd(e,t,n){e.lanes|=n;var a=e.alternate;a!==null&&(a.lanes|=n);for(var s=!1,c=e.return;c!==null;)c.childLanes|=n,a=c.alternate,a!==null&&(a.childLanes|=n),c.tag===22&&(e=c.stateNode,e===null||e._visibility&1||(s=!0)),e=c,c=c.return;return e.tag===3?(c=e.stateNode,s&&t!==null&&(s=31-gt(n),e=c.hiddenUpdates,a=e[s],a===null?e[s]=[t]:a.push(t),t.lane=n|536870912),c):null}function js(e){if(50<zi)throw zi=0,ur=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var jl={};function Lv(e,t,n,a){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zt(e,t,n,a){return new Lv(e,t,n,a)}function Pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Mn(e,t){var n=e.alternate;return n===null?(n=zt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function md(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ss(e,t,n,a,s,c){var h=0;if(a=e,typeof e=="function")Pu(e)&&(h=1);else if(typeof e=="string")h=Yy(e,n,ie.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case W:return e=zt(31,n,t,s),e.elementType=W,e.lanes=c,e;case L:return Ka(n.children,s,c,t);case P:h=8,s|=24;break;case J:return e=zt(12,n,t,s|2),e.elementType=J,e.lanes=c,e;case ge:return e=zt(13,n,t,s),e.elementType=ge,e.lanes=c,e;case ee:return e=zt(19,n,t,s),e.elementType=ee,e.lanes=c,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case F:h=10;break e;case Z:h=9;break e;case _:h=11;break e;case V:h=14;break e;case le:h=16,a=null;break e}h=29,n=Error(r(130,e===null?"null":typeof e,"")),a=null}return t=zt(h,n,t,s),t.elementType=e,t.type=a,t.lanes=c,t}function Ka(e,t,n,a){return e=zt(7,e,a,t),e.lanes=n,e}function ec(e,t,n){return e=zt(6,e,null,t),e.lanes=n,e}function gd(e){var t=zt(18,null,null,0);return t.stateNode=e,t}function tc(e,t,n){return t=zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vd=new WeakMap;function Yt(e,t){if(typeof e=="object"&&e!==null){var n=vd.get(e);return n!==void 0?n:(t={value:e,source:t,stack:ht(t)},vd.set(e,t),t)}return{value:e,source:t,stack:ht(t)}}var Sl=[],Nl=0,Ns=null,di=0,Qt=[],Xt=0,ta=null,mn=1,gn="";function Rn(e,t){Sl[Nl++]=di,Sl[Nl++]=Ns,Ns=e,di=t}function yd(e,t,n){Qt[Xt++]=mn,Qt[Xt++]=gn,Qt[Xt++]=ta,ta=e;var a=mn;e=gn;var s=32-gt(a)-1;a&=~(1<<s),n+=1;var c=32-gt(t)+s;if(30<c){var h=s-s%5;c=(a&(1<<h)-1).toString(32),a>>=h,s-=h,mn=1<<32-gt(t)+s|n<<s|a,gn=c+e}else mn=1<<c|n<<s|a,gn=e}function nc(e){e.return!==null&&(Rn(e,1),yd(e,1,0))}function ac(e){for(;e===Ns;)Ns=Sl[--Nl],Sl[Nl]=null,di=Sl[--Nl],Sl[Nl]=null;for(;e===ta;)ta=Qt[--Xt],Qt[Xt]=null,gn=Qt[--Xt],Qt[Xt]=null,mn=Qt[--Xt],Qt[Xt]=null}function bd(e,t){Qt[Xt++]=mn,Qt[Xt++]=gn,Qt[Xt++]=ta,mn=t.id,gn=t.overflow,ta=e}var rt=null,Ge=null,Ee=!1,na=null,Vt=!1,lc=Error(r(519));function aa(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw fi(Yt(t,e)),lc}function pd(e){var t=e.stateNode,n=e.type,a=e.memoizedProps;switch(t[qe]=e,t[vt]=a,n){case"dialog":Ne("cancel",t),Ne("close",t);break;case"iframe":case"object":case"embed":Ne("load",t);break;case"video":case"audio":for(n=0;n<_i.length;n++)Ne(_i[n],t);break;case"source":Ne("error",t);break;case"img":case"image":case"link":Ne("error",t),Ne("load",t);break;case"details":Ne("toggle",t);break;case"input":Ne("invalid",t),gl(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":Ne("invalid",t);break;case"textarea":Ne("invalid",t),ti(t,a.value,a.defaultValue,a.children)}n=a.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||a.suppressHydrationWarning===!0||Bh(t.textContent,n)?(a.popover!=null&&(Ne("beforetoggle",t),Ne("toggle",t)),a.onScroll!=null&&Ne("scroll",t),a.onScrollEnd!=null&&Ne("scrollend",t),a.onClick!=null&&(t.onclick=Gt),t=!0):t=!1,t||aa(e,!0)}function xd(e){for(rt=e.return;rt;)switch(rt.tag){case 5:case 31:case 13:Vt=!1;return;case 27:case 3:Vt=!0;return;default:rt=rt.return}}function wl(e){if(e!==rt)return!1;if(!Ee)return xd(e),Ee=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||Sr(e.type,e.memoizedProps)),n=!n),n&&Ge&&aa(e),xd(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Ge=Xh(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Ge=Xh(e)}else t===27?(t=Ge,ya(e.type)?(e=Ar,Ar=null,Ge=e):Ge=t):Ge=rt?Jt(e.stateNode.nextSibling):null;return!0}function Ya(){Ge=rt=null,Ee=!1}function ic(){var e=na;return e!==null&&(At===null?At=e:At.push.apply(At,e),na=null),e}function fi(e){na===null?na=[e]:na.push(e)}var sc=A(null),Qa=null,zn=null;function la(e,t,n){I(sc,t._currentValue),t._currentValue=n}function On(e){e._currentValue=sc.current,q(sc)}function uc(e,t,n){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function cc(e,t,n,a){var s=e.child;for(s!==null&&(s.return=e);s!==null;){var c=s.dependencies;if(c!==null){var h=s.child;c=c.firstContext;e:for(;c!==null;){var b=c;c=s;for(var w=0;w<t.length;w++)if(b.context===t[w]){c.lanes|=n,b=c.alternate,b!==null&&(b.lanes|=n),uc(c.return,n,e),a||(h=null);break e}c=b.next}}else if(s.tag===18){if(h=s.return,h===null)throw Error(r(341));h.lanes|=n,c=h.alternate,c!==null&&(c.lanes|=n),uc(h,n,e),h=null}else h=s.child;if(h!==null)h.return=s;else for(h=s;h!==null;){if(h===e){h=null;break}if(s=h.sibling,s!==null){s.return=h.return,h=s;break}h=h.return}s=h}}function Tl(e,t,n,a){e=null;for(var s=t,c=!1;s!==null;){if(!c){if((s.flags&524288)!==0)c=!0;else if((s.flags&262144)!==0)break}if(s.tag===10){var h=s.alternate;if(h===null)throw Error(r(387));if(h=h.memoizedProps,h!==null){var b=s.type;Rt(s.pendingProps.value,h.value)||(e!==null?e.push(b):e=[b])}}else if(s===ye.current){if(h=s.alternate,h===null)throw Error(r(387));h.memoizedState.memoizedState!==s.memoizedState.memoizedState&&(e!==null?e.push(Li):e=[Li])}s=s.return}e!==null&&cc(t,e,n,a),t.flags|=262144}function ws(e){for(e=e.firstContext;e!==null;){if(!Rt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xa(e){Qa=e,zn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ot(e){return jd(Qa,e)}function Ts(e,t){return Qa===null&&Xa(e),jd(e,t)}function jd(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},zn===null){if(e===null)throw Error(r(308));zn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else zn=zn.next=t;return n}var qv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,a){e.push(a)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},$v=l.unstable_scheduleCallback,Gv=l.unstable_NormalPriority,We={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function rc(){return{controller:new qv,data:new Map,refCount:0}}function hi(e){e.refCount--,e.refCount===0&&$v(Gv,function(){e.controller.abort()})}var mi=null,oc=0,El=0,Al=null;function Kv(e,t){if(mi===null){var n=mi=[];oc=0,El=hr(),Al={status:"pending",value:void 0,then:function(a){n.push(a)}}}return oc++,t.then(Sd,Sd),t}function Sd(){if(--oc===0&&mi!==null){Al!==null&&(Al.status="fulfilled");var e=mi;mi=null,El=0,Al=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Yv(e,t){var n=[],a={status:"pending",value:null,reason:null,then:function(s){n.push(s)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var s=0;s<n.length;s++)(0,n[s])(t)},function(s){for(a.status="rejected",a.reason=s,s=0;s<n.length;s++)(0,n[s])(void 0)}),a}var Nd=D.S;D.S=function(e,t){uh=mt(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Kv(e,t),Nd!==null&&Nd(e,t)};var Va=A(null);function dc(){var e=Va.current;return e!==null?e:Le.pooledCache}function Es(e,t){t===null?I(Va,Va.current):I(Va,t.pool)}function wd(){var e=dc();return e===null?null:{parent:We._currentValue,pool:e}}var Cl=Error(r(460)),fc=Error(r(474)),As=Error(r(542)),Cs={then:function(){}};function Td(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Ed(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Gt,Gt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Cd(e),e;default:if(typeof t.status=="string")t.then(Gt,Gt);else{if(e=Le,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(a){if(t.status==="pending"){var s=t;s.status="fulfilled",s.value=a}},function(a){if(t.status==="pending"){var s=t;s.status="rejected",s.reason=a}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Cd(e),e}throw Ja=t,Cl}}function Za(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Ja=n,Cl):n}}var Ja=null;function Ad(){if(Ja===null)throw Error(r(459));var e=Ja;return Ja=null,e}function Cd(e){if(e===Cl||e===As)throw Error(r(483))}var kl=null,gi=0;function ks(e){var t=gi;return gi+=1,kl===null&&(kl=[]),Ed(kl,e,t)}function vi(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ms(e,t){throw t.$$typeof===S?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function kd(e){function t(k,E){if(e){var M=k.deletions;M===null?(k.deletions=[E],k.flags|=16):M.push(E)}}function n(k,E){if(!e)return null;for(;E!==null;)t(k,E),E=E.sibling;return null}function a(k){for(var E=new Map;k!==null;)k.key!==null?E.set(k.key,k):E.set(k.index,k),k=k.sibling;return E}function s(k,E){return k=Mn(k,E),k.index=0,k.sibling=null,k}function c(k,E,M){return k.index=M,e?(M=k.alternate,M!==null?(M=M.index,M<E?(k.flags|=67108866,E):M):(k.flags|=67108866,E)):(k.flags|=1048576,E)}function h(k){return e&&k.alternate===null&&(k.flags|=67108866),k}function b(k,E,M,H){return E===null||E.tag!==6?(E=ec(M,k.mode,H),E.return=k,E):(E=s(E,M),E.return=k,E)}function w(k,E,M,H){var de=M.type;return de===L?B(k,E,M.props.children,H,M.key):E!==null&&(E.elementType===de||typeof de=="object"&&de!==null&&de.$$typeof===le&&Za(de)===E.type)?(E=s(E,M.props),vi(E,M),E.return=k,E):(E=Ss(M.type,M.key,M.props,null,k.mode,H),vi(E,M),E.return=k,E)}function z(k,E,M,H){return E===null||E.tag!==4||E.stateNode.containerInfo!==M.containerInfo||E.stateNode.implementation!==M.implementation?(E=tc(M,k.mode,H),E.return=k,E):(E=s(E,M.children||[]),E.return=k,E)}function B(k,E,M,H,de){return E===null||E.tag!==7?(E=Ka(M,k.mode,H,de),E.return=k,E):(E=s(E,M),E.return=k,E)}function G(k,E,M){if(typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint")return E=ec(""+E,k.mode,M),E.return=k,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case N:return M=Ss(E.type,E.key,E.props,null,k.mode,M),vi(M,E),M.return=k,M;case R:return E=tc(E,k.mode,M),E.return=k,E;case le:return E=Za(E),G(k,E,M)}if(re(E)||ae(E))return E=Ka(E,k.mode,M,null),E.return=k,E;if(typeof E.then=="function")return G(k,ks(E),M);if(E.$$typeof===F)return G(k,Ts(k,E),M);Ms(k,E)}return null}function O(k,E,M,H){var de=E!==null?E.key:null;if(typeof M=="string"&&M!==""||typeof M=="number"||typeof M=="bigint")return de!==null?null:b(k,E,""+M,H);if(typeof M=="object"&&M!==null){switch(M.$$typeof){case N:return M.key===de?w(k,E,M,H):null;case R:return M.key===de?z(k,E,M,H):null;case le:return M=Za(M),O(k,E,M,H)}if(re(M)||ae(M))return de!==null?null:B(k,E,M,H,null);if(typeof M.then=="function")return O(k,E,ks(M),H);if(M.$$typeof===F)return O(k,E,Ts(k,M),H);Ms(k,M)}return null}function U(k,E,M,H,de){if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return k=k.get(M)||null,b(E,k,""+H,de);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case N:return k=k.get(H.key===null?M:H.key)||null,w(E,k,H,de);case R:return k=k.get(H.key===null?M:H.key)||null,z(E,k,H,de);case le:return H=Za(H),U(k,E,M,H,de)}if(re(H)||ae(H))return k=k.get(M)||null,B(E,k,H,de,null);if(typeof H.then=="function")return U(k,E,M,ks(H),de);if(H.$$typeof===F)return U(k,E,M,Ts(E,H),de);Ms(E,H)}return null}function ue(k,E,M,H){for(var de=null,ke=null,ce=E,je=E=0,Te=null;ce!==null&&je<M.length;je++){ce.index>je?(Te=ce,ce=null):Te=ce.sibling;var Me=O(k,ce,M[je],H);if(Me===null){ce===null&&(ce=Te);break}e&&ce&&Me.alternate===null&&t(k,ce),E=c(Me,E,je),ke===null?de=Me:ke.sibling=Me,ke=Me,ce=Te}if(je===M.length)return n(k,ce),Ee&&Rn(k,je),de;if(ce===null){for(;je<M.length;je++)ce=G(k,M[je],H),ce!==null&&(E=c(ce,E,je),ke===null?de=ce:ke.sibling=ce,ke=ce);return Ee&&Rn(k,je),de}for(ce=a(ce);je<M.length;je++)Te=U(ce,k,je,M[je],H),Te!==null&&(e&&Te.alternate!==null&&ce.delete(Te.key===null?je:Te.key),E=c(Te,E,je),ke===null?de=Te:ke.sibling=Te,ke=Te);return e&&ce.forEach(function(Sa){return t(k,Sa)}),Ee&&Rn(k,je),de}function he(k,E,M,H){if(M==null)throw Error(r(151));for(var de=null,ke=null,ce=E,je=E=0,Te=null,Me=M.next();ce!==null&&!Me.done;je++,Me=M.next()){ce.index>je?(Te=ce,ce=null):Te=ce.sibling;var Sa=O(k,ce,Me.value,H);if(Sa===null){ce===null&&(ce=Te);break}e&&ce&&Sa.alternate===null&&t(k,ce),E=c(Sa,E,je),ke===null?de=Sa:ke.sibling=Sa,ke=Sa,ce=Te}if(Me.done)return n(k,ce),Ee&&Rn(k,je),de;if(ce===null){for(;!Me.done;je++,Me=M.next())Me=G(k,Me.value,H),Me!==null&&(E=c(Me,E,je),ke===null?de=Me:ke.sibling=Me,ke=Me);return Ee&&Rn(k,je),de}for(ce=a(ce);!Me.done;je++,Me=M.next())Me=U(ce,k,je,Me.value,H),Me!==null&&(e&&Me.alternate!==null&&ce.delete(Me.key===null?je:Me.key),E=c(Me,E,je),ke===null?de=Me:ke.sibling=Me,ke=Me);return e&&ce.forEach(function(t0){return t(k,t0)}),Ee&&Rn(k,je),de}function He(k,E,M,H){if(typeof M=="object"&&M!==null&&M.type===L&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case N:e:{for(var de=M.key;E!==null;){if(E.key===de){if(de=M.type,de===L){if(E.tag===7){n(k,E.sibling),H=s(E,M.props.children),H.return=k,k=H;break e}}else if(E.elementType===de||typeof de=="object"&&de!==null&&de.$$typeof===le&&Za(de)===E.type){n(k,E.sibling),H=s(E,M.props),vi(H,M),H.return=k,k=H;break e}n(k,E);break}else t(k,E);E=E.sibling}M.type===L?(H=Ka(M.props.children,k.mode,H,M.key),H.return=k,k=H):(H=Ss(M.type,M.key,M.props,null,k.mode,H),vi(H,M),H.return=k,k=H)}return h(k);case R:e:{for(de=M.key;E!==null;){if(E.key===de)if(E.tag===4&&E.stateNode.containerInfo===M.containerInfo&&E.stateNode.implementation===M.implementation){n(k,E.sibling),H=s(E,M.children||[]),H.return=k,k=H;break e}else{n(k,E);break}else t(k,E);E=E.sibling}H=tc(M,k.mode,H),H.return=k,k=H}return h(k);case le:return M=Za(M),He(k,E,M,H)}if(re(M))return ue(k,E,M,H);if(ae(M)){if(de=ae(M),typeof de!="function")throw Error(r(150));return M=de.call(M),he(k,E,M,H)}if(typeof M.then=="function")return He(k,E,ks(M),H);if(M.$$typeof===F)return He(k,E,Ts(k,M),H);Ms(k,M)}return typeof M=="string"&&M!==""||typeof M=="number"||typeof M=="bigint"?(M=""+M,E!==null&&E.tag===6?(n(k,E.sibling),H=s(E,M),H.return=k,k=H):(n(k,E),H=ec(M,k.mode,H),H.return=k,k=H),h(k)):n(k,E)}return function(k,E,M,H){try{gi=0;var de=He(k,E,M,H);return kl=null,de}catch(ce){if(ce===Cl||ce===As)throw ce;var ke=zt(29,ce,null,k.mode);return ke.lanes=H,ke.return=k,ke}}}var Fa=kd(!0),Md=kd(!1),ia=!1;function hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function sa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ua(e,t,n){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Re&2)!==0){var s=a.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),a.pending=t,t=js(e),hd(e,null,n),t}return xs(e,a,t,n),js(e)}function yi(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,Wl(e,n)}}function gc(e,t){var n=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var s=null,c=null;if(n=n.firstBaseUpdate,n!==null){do{var h={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};c===null?s=c=h:c=c.next=h,n=n.next}while(n!==null);c===null?s=c=t:c=c.next=t}else s=c=t;n={baseState:a.baseState,firstBaseUpdate:s,lastBaseUpdate:c,shared:a.shared,callbacks:a.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var vc=!1;function bi(){if(vc){var e=Al;if(e!==null)throw e}}function pi(e,t,n,a){vc=!1;var s=e.updateQueue;ia=!1;var c=s.firstBaseUpdate,h=s.lastBaseUpdate,b=s.shared.pending;if(b!==null){s.shared.pending=null;var w=b,z=w.next;w.next=null,h===null?c=z:h.next=z,h=w;var B=e.alternate;B!==null&&(B=B.updateQueue,b=B.lastBaseUpdate,b!==h&&(b===null?B.firstBaseUpdate=z:b.next=z,B.lastBaseUpdate=w))}if(c!==null){var G=s.baseState;h=0,B=z=w=null,b=c;do{var O=b.lane&-536870913,U=O!==b.lane;if(U?(we&O)===O:(a&O)===O){O!==0&&O===El&&(vc=!0),B!==null&&(B=B.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var ue=e,he=b;O=t;var He=n;switch(he.tag){case 1:if(ue=he.payload,typeof ue=="function"){G=ue.call(He,G,O);break e}G=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=he.payload,O=typeof ue=="function"?ue.call(He,G,O):ue,O==null)break e;G=g({},G,O);break e;case 2:ia=!0}}O=b.callback,O!==null&&(e.flags|=64,U&&(e.flags|=8192),U=s.callbacks,U===null?s.callbacks=[O]:U.push(O))}else U={lane:O,tag:b.tag,payload:b.payload,callback:b.callback,next:null},B===null?(z=B=U,w=G):B=B.next=U,h|=O;if(b=b.next,b===null){if(b=s.shared.pending,b===null)break;U=b,b=U.next,U.next=null,s.lastBaseUpdate=U,s.shared.pending=null}}while(!0);B===null&&(w=G),s.baseState=w,s.firstBaseUpdate=z,s.lastBaseUpdate=B,c===null&&(s.shared.lanes=0),fa|=h,e.lanes=h,e.memoizedState=G}}function Rd(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function zd(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Rd(n[e],t)}var Ml=A(null),Rs=A(0);function Od(e,t){e=Gn,I(Rs,e),I(Ml,t),Gn=e|t.baseLanes}function yc(){I(Rs,Gn),I(Ml,Ml.current)}function bc(){Gn=Rs.current,q(Ml),q(Rs)}var Ot=A(null),Zt=null;function ca(e){var t=e.alternate;I(Je,Je.current&1),I(Ot,e),Zt===null&&(t===null||Ml.current!==null||t.memoizedState!==null)&&(Zt=e)}function pc(e){I(Je,Je.current),I(Ot,e),Zt===null&&(Zt=e)}function _d(e){e.tag===22?(I(Je,Je.current),I(Ot,e),Zt===null&&(Zt=e)):ra()}function ra(){I(Je,Je.current),I(Ot,Ot.current)}function _t(e){q(Ot),Zt===e&&(Zt=null),q(Je)}var Je=A(0);function zs(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Tr(n)||Er(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var _n=0,xe=null,De=null,Ie=null,Os=!1,Rl=!1,Wa=!1,_s=0,xi=0,zl=null,Qv=0;function Xe(){throw Error(r(321))}function xc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Rt(e[n],t[n]))return!1;return!0}function jc(e,t,n,a,s,c){return _n=c,xe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,D.H=e===null||e.memoizedState===null?bf:Dc,Wa=!1,c=n(a,s),Wa=!1,Rl&&(c=Dd(t,n,a,s)),Ud(e),c}function Ud(e){D.H=Ni;var t=De!==null&&De.next!==null;if(_n=0,Ie=De=xe=null,Os=!1,xi=0,zl=null,t)throw Error(r(300));e===null||Pe||(e=e.dependencies,e!==null&&ws(e)&&(Pe=!0))}function Dd(e,t,n,a){xe=e;var s=0;do{if(Rl&&(zl=null),xi=0,Rl=!1,25<=s)throw Error(r(301));if(s+=1,Ie=De=null,e.updateQueue!=null){var c=e.updateQueue;c.lastEffect=null,c.events=null,c.stores=null,c.memoCache!=null&&(c.memoCache.index=0)}D.H=pf,c=t(n,a)}while(Rl);return c}function Xv(){var e=D.H,t=e.useState()[0];return t=typeof t.then=="function"?ji(t):t,e=e.useState()[0],(De!==null?De.memoizedState:null)!==e&&(xe.flags|=1024),t}function Sc(){var e=_s!==0;return _s=0,e}function Nc(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function wc(e){if(Os){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Os=!1}_n=0,Ie=De=xe=null,Rl=!1,xi=_s=0,zl=null}function jt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ie===null?xe.memoizedState=Ie=e:Ie=Ie.next=e,Ie}function Fe(){if(De===null){var e=xe.alternate;e=e!==null?e.memoizedState:null}else e=De.next;var t=Ie===null?xe.memoizedState:Ie.next;if(t!==null)Ie=t,De=e;else{if(e===null)throw xe.alternate===null?Error(r(467)):Error(r(310));De=e,e={memoizedState:De.memoizedState,baseState:De.baseState,baseQueue:De.baseQueue,queue:De.queue,next:null},Ie===null?xe.memoizedState=Ie=e:Ie=Ie.next=e}return Ie}function Us(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ji(e){var t=xi;return xi+=1,zl===null&&(zl=[]),e=Ed(zl,e,t),t=xe,(Ie===null?t.memoizedState:Ie.next)===null&&(t=t.alternate,D.H=t===null||t.memoizedState===null?bf:Dc),e}function Ds(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ji(e);if(e.$$typeof===F)return ot(e)}throw Error(r(438,String(e)))}function Tc(e){var t=null,n=xe.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var a=xe.alternate;a!==null&&(a=a.updateQueue,a!==null&&(a=a.memoCache,a!=null&&(t={data:a.data.map(function(s){return s.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Us(),xe.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),a=0;a<e;a++)n[a]=Y;return t.index++,n}function Un(e,t){return typeof t=="function"?t(e):t}function Bs(e){var t=Fe();return Ec(t,De,e)}function Ec(e,t,n){var a=e.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var s=e.baseQueue,c=a.pending;if(c!==null){if(s!==null){var h=s.next;s.next=c.next,c.next=h}t.baseQueue=s=c,a.pending=null}if(c=e.baseState,s===null)e.memoizedState=c;else{t=s.next;var b=h=null,w=null,z=t,B=!1;do{var G=z.lane&-536870913;if(G!==z.lane?(we&G)===G:(_n&G)===G){var O=z.revertLane;if(O===0)w!==null&&(w=w.next={lane:0,revertLane:0,gesture:null,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null}),G===El&&(B=!0);else if((_n&O)===O){z=z.next,O===El&&(B=!0);continue}else G={lane:0,revertLane:z.revertLane,gesture:null,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null},w===null?(b=w=G,h=c):w=w.next=G,xe.lanes|=O,fa|=O;G=z.action,Wa&&n(c,G),c=z.hasEagerState?z.eagerState:n(c,G)}else O={lane:G,revertLane:z.revertLane,gesture:z.gesture,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null},w===null?(b=w=O,h=c):w=w.next=O,xe.lanes|=G,fa|=G;z=z.next}while(z!==null&&z!==t);if(w===null?h=c:w.next=b,!Rt(c,e.memoizedState)&&(Pe=!0,B&&(n=Al,n!==null)))throw n;e.memoizedState=c,e.baseState=h,e.baseQueue=w,a.lastRenderedState=c}return s===null&&(a.lanes=0),[e.memoizedState,a.dispatch]}function Ac(e){var t=Fe(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var a=n.dispatch,s=n.pending,c=t.memoizedState;if(s!==null){n.pending=null;var h=s=s.next;do c=e(c,h.action),h=h.next;while(h!==s);Rt(c,t.memoizedState)||(Pe=!0),t.memoizedState=c,t.baseQueue===null&&(t.baseState=c),n.lastRenderedState=c}return[c,a]}function Bd(e,t,n){var a=xe,s=Fe(),c=Ee;if(c){if(n===void 0)throw Error(r(407));n=n()}else n=t();var h=!Rt((De||s).memoizedState,n);if(h&&(s.memoizedState=n,Pe=!0),s=s.queue,Mc(qd.bind(null,a,s,e),[e]),s.getSnapshot!==t||h||Ie!==null&&Ie.memoizedState.tag&1){if(a.flags|=2048,Ol(9,{destroy:void 0},Ld.bind(null,a,s,n,t),null),Le===null)throw Error(r(349));c||(_n&127)!==0||Hd(a,t,n)}return n}function Hd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=xe.updateQueue,t===null?(t=Us(),xe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ld(e,t,n,a){t.value=n,t.getSnapshot=a,$d(t)&&Gd(e)}function qd(e,t,n){return n(function(){$d(t)&&Gd(e)})}function $d(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Rt(e,n)}catch{return!0}}function Gd(e){var t=Ga(e,2);t!==null&&Ct(t,e,2)}function Cc(e){var t=jt();if(typeof e=="function"){var n=e;if(e=n(),Wa){on(!0);try{n()}finally{on(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:e},t}function Kd(e,t,n,a){return e.baseState=n,Ec(e,De,typeof a=="function"?a:Un)}function Vv(e,t,n,a,s){if(qs(e))throw Error(r(485));if(e=t.action,e!==null){var c={payload:s,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(h){c.listeners.push(h)}};D.T!==null?n(!0):c.isTransition=!1,a(c),n=t.pending,n===null?(c.next=t.pending=c,Yd(t,c)):(c.next=n.next,t.pending=n.next=c)}}function Yd(e,t){var n=t.action,a=t.payload,s=e.state;if(t.isTransition){var c=D.T,h={};D.T=h;try{var b=n(s,a),w=D.S;w!==null&&w(h,b),Qd(e,t,b)}catch(z){kc(e,t,z)}finally{c!==null&&h.types!==null&&(c.types=h.types),D.T=c}}else try{c=n(s,a),Qd(e,t,c)}catch(z){kc(e,t,z)}}function Qd(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(a){Xd(e,t,a)},function(a){return kc(e,t,a)}):Xd(e,t,n)}function Xd(e,t,n){t.status="fulfilled",t.value=n,Vd(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Yd(e,n)))}function kc(e,t,n){var a=e.pending;if(e.pending=null,a!==null){a=a.next;do t.status="rejected",t.reason=n,Vd(t),t=t.next;while(t!==a)}e.action=null}function Vd(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zd(e,t){return t}function Jd(e,t){if(Ee){var n=Le.formState;if(n!==null){e:{var a=xe;if(Ee){if(Ge){t:{for(var s=Ge,c=Vt;s.nodeType!==8;){if(!c){s=null;break t}if(s=Jt(s.nextSibling),s===null){s=null;break t}}c=s.data,s=c==="F!"||c==="F"?s:null}if(s){Ge=Jt(s.nextSibling),a=s.data==="F!";break e}}aa(a)}a=!1}a&&(t=n[0])}}return n=jt(),n.memoizedState=n.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zd,lastRenderedState:t},n.queue=a,n=gf.bind(null,xe,a),a.dispatch=n,a=Cc(!1),c=Uc.bind(null,xe,!1,a.queue),a=jt(),s={state:t,dispatch:null,action:e,pending:null},a.queue=s,n=Vv.bind(null,xe,s,c,n),s.dispatch=n,a.memoizedState=e,[t,n,!1]}function Fd(e){var t=Fe();return Wd(t,De,e)}function Wd(e,t,n){if(t=Ec(e,t,Zd)[0],e=Bs(Un)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var a=ji(t)}catch(h){throw h===Cl?As:h}else a=t;t=Fe();var s=t.queue,c=s.dispatch;return n!==t.memoizedState&&(xe.flags|=2048,Ol(9,{destroy:void 0},Zv.bind(null,s,n),null)),[a,c,e]}function Zv(e,t){e.action=t}function Id(e){var t=Fe(),n=De;if(n!==null)return Wd(t,n,e);Fe(),t=t.memoizedState,n=Fe();var a=n.queue.dispatch;return n.memoizedState=e,[t,a,!1]}function Ol(e,t,n,a){return e={tag:e,create:n,deps:a,inst:t,next:null},t=xe.updateQueue,t===null&&(t=Us(),xe.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(a=n.next,n.next=e,e.next=a,t.lastEffect=e),e}function Pd(){return Fe().memoizedState}function Hs(e,t,n,a){var s=jt();xe.flags|=e,s.memoizedState=Ol(1|t,{destroy:void 0},n,a===void 0?null:a)}function Ls(e,t,n,a){var s=Fe();a=a===void 0?null:a;var c=s.memoizedState.inst;De!==null&&a!==null&&xc(a,De.memoizedState.deps)?s.memoizedState=Ol(t,c,n,a):(xe.flags|=e,s.memoizedState=Ol(1|t,c,n,a))}function ef(e,t){Hs(8390656,8,e,t)}function Mc(e,t){Ls(2048,8,e,t)}function Jv(e){xe.flags|=4;var t=xe.updateQueue;if(t===null)t=Us(),xe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function tf(e){var t=Fe().memoizedState;return Jv({ref:t,nextImpl:e}),function(){if((Re&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function nf(e,t){return Ls(4,2,e,t)}function af(e,t){return Ls(4,4,e,t)}function lf(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function sf(e,t,n){n=n!=null?n.concat([e]):null,Ls(4,4,lf.bind(null,t,e),n)}function Rc(){}function uf(e,t){var n=Fe();t=t===void 0?null:t;var a=n.memoizedState;return t!==null&&xc(t,a[1])?a[0]:(n.memoizedState=[e,t],e)}function cf(e,t){var n=Fe();t=t===void 0?null:t;var a=n.memoizedState;if(t!==null&&xc(t,a[1]))return a[0];if(a=e(),Wa){on(!0);try{e()}finally{on(!1)}}return n.memoizedState=[a,t],a}function zc(e,t,n){return n===void 0||(_n&1073741824)!==0&&(we&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=rh(),xe.lanes|=e,fa|=e,n)}function rf(e,t,n,a){return Rt(n,t)?n:Ml.current!==null?(e=zc(e,n,a),Rt(e,t)||(Pe=!0),e):(_n&42)===0||(_n&1073741824)!==0&&(we&261930)===0?(Pe=!0,e.memoizedState=n):(e=rh(),xe.lanes|=e,fa|=e,t)}function of(e,t,n,a,s){var c=te.p;te.p=c!==0&&8>c?c:8;var h=D.T,b={};D.T=b,Uc(e,!1,t,n);try{var w=s(),z=D.S;if(z!==null&&z(b,w),w!==null&&typeof w=="object"&&typeof w.then=="function"){var B=Yv(w,a);Si(e,t,B,Bt(e))}else Si(e,t,a,Bt(e))}catch(G){Si(e,t,{then:function(){},status:"rejected",reason:G},Bt())}finally{te.p=c,h!==null&&b.types!==null&&(h.types=b.types),D.T=h}}function Fv(){}function Oc(e,t,n,a){if(e.tag!==5)throw Error(r(476));var s=df(e).queue;of(e,s,t,K,n===null?Fv:function(){return ff(e),n(a)})}function df(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:K},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ff(e){var t=df(e);t.next===null&&(t=e.alternate.memoizedState),Si(e,t.next.queue,{},Bt())}function _c(){return ot(Li)}function hf(){return Fe().memoizedState}function mf(){return Fe().memoizedState}function Wv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Bt();e=sa(n);var a=ua(t,e,n);a!==null&&(Ct(a,t,n),yi(a,t,n)),t={cache:rc()},e.payload=t;return}t=t.return}}function Iv(e,t,n){var a=Bt();n={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},qs(e)?vf(t,n):(n=Iu(e,t,n,a),n!==null&&(Ct(n,e,a),yf(n,t,a)))}function gf(e,t,n){var a=Bt();Si(e,t,n,a)}function Si(e,t,n,a){var s={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(qs(e))vf(t,s);else{var c=e.alternate;if(e.lanes===0&&(c===null||c.lanes===0)&&(c=t.lastRenderedReducer,c!==null))try{var h=t.lastRenderedState,b=c(h,n);if(s.hasEagerState=!0,s.eagerState=b,Rt(b,h))return xs(e,t,s,0),Le===null&&ps(),!1}catch{}if(n=Iu(e,t,s,a),n!==null)return Ct(n,e,a),yf(n,t,a),!0}return!1}function Uc(e,t,n,a){if(a={lane:2,revertLane:hr(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},qs(e)){if(t)throw Error(r(479))}else t=Iu(e,n,a,2),t!==null&&Ct(t,e,2)}function qs(e){var t=e.alternate;return e===xe||t!==null&&t===xe}function vf(e,t){Rl=Os=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yf(e,t,n){if((n&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,Wl(e,n)}}var Ni={readContext:ot,use:Ds,useCallback:Xe,useContext:Xe,useEffect:Xe,useImperativeHandle:Xe,useLayoutEffect:Xe,useInsertionEffect:Xe,useMemo:Xe,useReducer:Xe,useRef:Xe,useState:Xe,useDebugValue:Xe,useDeferredValue:Xe,useTransition:Xe,useSyncExternalStore:Xe,useId:Xe,useHostTransitionStatus:Xe,useFormState:Xe,useActionState:Xe,useOptimistic:Xe,useMemoCache:Xe,useCacheRefresh:Xe};Ni.useEffectEvent=Xe;var bf={readContext:ot,use:Ds,useCallback:function(e,t){return jt().memoizedState=[e,t===void 0?null:t],e},useContext:ot,useEffect:ef,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,Hs(4194308,4,lf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Hs(4194308,4,e,t)},useInsertionEffect:function(e,t){Hs(4,2,e,t)},useMemo:function(e,t){var n=jt();t=t===void 0?null:t;var a=e();if(Wa){on(!0);try{e()}finally{on(!1)}}return n.memoizedState=[a,t],a},useReducer:function(e,t,n){var a=jt();if(n!==void 0){var s=n(t);if(Wa){on(!0);try{n(t)}finally{on(!1)}}}else s=t;return a.memoizedState=a.baseState=s,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:s},a.queue=e,e=e.dispatch=Iv.bind(null,xe,e),[a.memoizedState,e]},useRef:function(e){var t=jt();return e={current:e},t.memoizedState=e},useState:function(e){e=Cc(e);var t=e.queue,n=gf.bind(null,xe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Rc,useDeferredValue:function(e,t){var n=jt();return zc(n,e,t)},useTransition:function(){var e=Cc(!1);return e=of.bind(null,xe,e.queue,!0,!1),jt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=xe,s=jt();if(Ee){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Le===null)throw Error(r(349));(we&127)!==0||Hd(a,t,n)}s.memoizedState=n;var c={value:n,getSnapshot:t};return s.queue=c,ef(qd.bind(null,a,c,e),[e]),a.flags|=2048,Ol(9,{destroy:void 0},Ld.bind(null,a,c,n,t),null),n},useId:function(){var e=jt(),t=Le.identifierPrefix;if(Ee){var n=gn,a=mn;n=(a&~(1<<32-gt(a)-1)).toString(32)+n,t="_"+t+"R_"+n,n=_s++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Qv++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:_c,useFormState:Jd,useActionState:Jd,useOptimistic:function(e){var t=jt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Uc.bind(null,xe,!0,n),n.dispatch=t,[e,t]},useMemoCache:Tc,useCacheRefresh:function(){return jt().memoizedState=Wv.bind(null,xe)},useEffectEvent:function(e){var t=jt(),n={impl:e};return t.memoizedState=n,function(){if((Re&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},Dc={readContext:ot,use:Ds,useCallback:uf,useContext:ot,useEffect:Mc,useImperativeHandle:sf,useInsertionEffect:nf,useLayoutEffect:af,useMemo:cf,useReducer:Bs,useRef:Pd,useState:function(){return Bs(Un)},useDebugValue:Rc,useDeferredValue:function(e,t){var n=Fe();return rf(n,De.memoizedState,e,t)},useTransition:function(){var e=Bs(Un)[0],t=Fe().memoizedState;return[typeof e=="boolean"?e:ji(e),t]},useSyncExternalStore:Bd,useId:hf,useHostTransitionStatus:_c,useFormState:Fd,useActionState:Fd,useOptimistic:function(e,t){var n=Fe();return Kd(n,De,e,t)},useMemoCache:Tc,useCacheRefresh:mf};Dc.useEffectEvent=tf;var pf={readContext:ot,use:Ds,useCallback:uf,useContext:ot,useEffect:Mc,useImperativeHandle:sf,useInsertionEffect:nf,useLayoutEffect:af,useMemo:cf,useReducer:Ac,useRef:Pd,useState:function(){return Ac(Un)},useDebugValue:Rc,useDeferredValue:function(e,t){var n=Fe();return De===null?zc(n,e,t):rf(n,De.memoizedState,e,t)},useTransition:function(){var e=Ac(Un)[0],t=Fe().memoizedState;return[typeof e=="boolean"?e:ji(e),t]},useSyncExternalStore:Bd,useId:hf,useHostTransitionStatus:_c,useFormState:Id,useActionState:Id,useOptimistic:function(e,t){var n=Fe();return De!==null?Kd(n,De,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Tc,useCacheRefresh:mf};pf.useEffectEvent=tf;function Bc(e,t,n,a){t=e.memoizedState,n=n(a,t),n=n==null?t:g({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Hc={enqueueSetState:function(e,t,n){e=e._reactInternals;var a=Bt(),s=sa(a);s.payload=t,n!=null&&(s.callback=n),t=ua(e,s,a),t!==null&&(Ct(t,e,a),yi(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var a=Bt(),s=sa(a);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=ua(e,s,a),t!==null&&(Ct(t,e,a),yi(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Bt(),a=sa(n);a.tag=2,t!=null&&(a.callback=t),t=ua(e,a,n),t!==null&&(Ct(t,e,n),yi(t,e,n))}};function xf(e,t,n,a,s,c,h){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,c,h):t.prototype&&t.prototype.isPureReactComponent?!ri(n,a)||!ri(s,c):!0}function jf(e,t,n,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,a),t.state!==e&&Hc.enqueueReplaceState(t,t.state,null)}function Ia(e,t){var n=t;if("ref"in t){n={};for(var a in t)a!=="ref"&&(n[a]=t[a])}if(e=e.defaultProps){n===t&&(n=g({},n));for(var s in e)n[s]===void 0&&(n[s]=e[s])}return n}function Sf(e){bs(e)}function Nf(e){console.error(e)}function wf(e){bs(e)}function $s(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(a){setTimeout(function(){throw a})}}function Tf(e,t,n){try{var a=e.onCaughtError;a(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(s){setTimeout(function(){throw s})}}function Lc(e,t,n){return n=sa(n),n.tag=3,n.payload={element:null},n.callback=function(){$s(e,t)},n}function Ef(e){return e=sa(e),e.tag=3,e}function Af(e,t,n,a){var s=n.type.getDerivedStateFromError;if(typeof s=="function"){var c=a.value;e.payload=function(){return s(c)},e.callback=function(){Tf(t,n,a)}}var h=n.stateNode;h!==null&&typeof h.componentDidCatch=="function"&&(e.callback=function(){Tf(t,n,a),typeof s!="function"&&(ha===null?ha=new Set([this]):ha.add(this));var b=a.stack;this.componentDidCatch(a.value,{componentStack:b!==null?b:""})})}function Pv(e,t,n,a,s){if(n.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){if(t=n.alternate,t!==null&&Tl(t,n,s,!0),n=Ot.current,n!==null){switch(n.tag){case 31:case 13:return Zt===null?Ps():n.alternate===null&&Ve===0&&(Ve=3),n.flags&=-257,n.flags|=65536,n.lanes=s,a===Cs?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([a]):t.add(a),or(e,a,s)),!1;case 22:return n.flags|=65536,a===Cs?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([a]):n.add(a)),or(e,a,s)),!1}throw Error(r(435,n.tag))}return or(e,a,s),Ps(),!1}if(Ee)return t=Ot.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=s,a!==lc&&(e=Error(r(422),{cause:a}),fi(Yt(e,n)))):(a!==lc&&(t=Error(r(423),{cause:a}),fi(Yt(t,n))),e=e.current.alternate,e.flags|=65536,s&=-s,e.lanes|=s,a=Yt(a,n),s=Lc(e.stateNode,a,s),gc(e,s),Ve!==4&&(Ve=2)),!1;var c=Error(r(520),{cause:a});if(c=Yt(c,n),Ri===null?Ri=[c]:Ri.push(c),Ve!==4&&(Ve=2),t===null)return!0;a=Yt(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=s&-s,n.lanes|=e,e=Lc(n.stateNode,a,e),gc(n,e),!1;case 1:if(t=n.type,c=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||c!==null&&typeof c.componentDidCatch=="function"&&(ha===null||!ha.has(c))))return n.flags|=65536,s&=-s,n.lanes|=s,s=Ef(s),Af(s,e,n,a),gc(n,s),!1}n=n.return}while(n!==null);return!1}var qc=Error(r(461)),Pe=!1;function dt(e,t,n,a){t.child=e===null?Md(t,null,n,a):Fa(t,e.child,n,a)}function Cf(e,t,n,a,s){n=n.render;var c=t.ref;if("ref"in a){var h={};for(var b in a)b!=="ref"&&(h[b]=a[b])}else h=a;return Xa(t),a=jc(e,t,n,h,c,s),b=Sc(),e!==null&&!Pe?(Nc(e,t,s),Dn(e,t,s)):(Ee&&b&&nc(t),t.flags|=1,dt(e,t,a,s),t.child)}function kf(e,t,n,a,s){if(e===null){var c=n.type;return typeof c=="function"&&!Pu(c)&&c.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=c,Mf(e,t,c,a,s)):(e=Ss(n.type,null,a,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(c=e.child,!Zc(e,s)){var h=c.memoizedProps;if(n=n.compare,n=n!==null?n:ri,n(h,a)&&e.ref===t.ref)return Dn(e,t,s)}return t.flags|=1,e=Mn(c,a),e.ref=t.ref,e.return=t,t.child=e}function Mf(e,t,n,a,s){if(e!==null){var c=e.memoizedProps;if(ri(c,a)&&e.ref===t.ref)if(Pe=!1,t.pendingProps=a=c,Zc(e,s))(e.flags&131072)!==0&&(Pe=!0);else return t.lanes=e.lanes,Dn(e,t,s)}return $c(e,t,n,a,s)}function Rf(e,t,n,a){var s=a.children,c=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.mode==="hidden"){if((t.flags&128)!==0){if(c=c!==null?c.baseLanes|n:n,e!==null){for(a=t.child=e.child,s=0;a!==null;)s=s|a.lanes|a.childLanes,a=a.sibling;a=s&~c}else a=0,t.child=null;return zf(e,t,c,n,a)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Es(t,c!==null?c.cachePool:null),c!==null?Od(t,c):yc(),_d(t);else return a=t.lanes=536870912,zf(e,t,c!==null?c.baseLanes|n:n,n,a)}else c!==null?(Es(t,c.cachePool),Od(t,c),ra(),t.memoizedState=null):(e!==null&&Es(t,null),yc(),ra());return dt(e,t,s,n),t.child}function wi(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function zf(e,t,n,a,s){var c=dc();return c=c===null?null:{parent:We._currentValue,pool:c},t.memoizedState={baseLanes:n,cachePool:c},e!==null&&Es(t,null),yc(),_d(t),e!==null&&Tl(e,t,a,!0),t.childLanes=s,null}function Gs(e,t){return t=Ys({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Of(e,t,n){return Fa(t,e.child,null,n),e=Gs(t,t.pendingProps),e.flags|=2,_t(t),t.memoizedState=null,e}function ey(e,t,n){var a=t.pendingProps,s=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ee){if(a.mode==="hidden")return e=Gs(t,a),t.lanes=536870912,wi(null,e);if(pc(t),(e=Ge)?(e=Qh(e,Vt),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ta!==null?{id:mn,overflow:gn}:null,retryLane:536870912,hydrationErrors:null},n=gd(e),n.return=t,t.child=n,rt=t,Ge=null)):e=null,e===null)throw aa(t);return t.lanes=536870912,null}return Gs(t,a)}var c=e.memoizedState;if(c!==null){var h=c.dehydrated;if(pc(t),s)if(t.flags&256)t.flags&=-257,t=Of(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(Pe||Tl(e,t,n,!1),s=(n&e.childLanes)!==0,Pe||s){if(a=Le,a!==null&&(h=is(a,n),h!==0&&h!==c.retryLane))throw c.retryLane=h,Ga(e,h),Ct(a,e,h),qc;Ps(),t=Of(e,t,n)}else e=c.treeContext,Ge=Jt(h.nextSibling),rt=t,Ee=!0,na=null,Vt=!1,e!==null&&bd(t,e),t=Gs(t,a),t.flags|=4096;return t}return e=Mn(e.child,{mode:a.mode,children:a.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Ks(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function $c(e,t,n,a,s){return Xa(t),n=jc(e,t,n,a,void 0,s),a=Sc(),e!==null&&!Pe?(Nc(e,t,s),Dn(e,t,s)):(Ee&&a&&nc(t),t.flags|=1,dt(e,t,n,s),t.child)}function _f(e,t,n,a,s,c){return Xa(t),t.updateQueue=null,n=Dd(t,a,n,s),Ud(e),a=Sc(),e!==null&&!Pe?(Nc(e,t,c),Dn(e,t,c)):(Ee&&a&&nc(t),t.flags|=1,dt(e,t,n,c),t.child)}function Uf(e,t,n,a,s){if(Xa(t),t.stateNode===null){var c=jl,h=n.contextType;typeof h=="object"&&h!==null&&(c=ot(h)),c=new n(a,c),t.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Hc,t.stateNode=c,c._reactInternals=t,c=t.stateNode,c.props=a,c.state=t.memoizedState,c.refs={},hc(t),h=n.contextType,c.context=typeof h=="object"&&h!==null?ot(h):jl,c.state=t.memoizedState,h=n.getDerivedStateFromProps,typeof h=="function"&&(Bc(t,n,h,a),c.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof c.getSnapshotBeforeUpdate=="function"||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(h=c.state,typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount(),h!==c.state&&Hc.enqueueReplaceState(c,c.state,null),pi(t,a,c,s),bi(),c.state=t.memoizedState),typeof c.componentDidMount=="function"&&(t.flags|=4194308),a=!0}else if(e===null){c=t.stateNode;var b=t.memoizedProps,w=Ia(n,b);c.props=w;var z=c.context,B=n.contextType;h=jl,typeof B=="object"&&B!==null&&(h=ot(B));var G=n.getDerivedStateFromProps;B=typeof G=="function"||typeof c.getSnapshotBeforeUpdate=="function",b=t.pendingProps!==b,B||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(b||z!==h)&&jf(t,c,a,h),ia=!1;var O=t.memoizedState;c.state=O,pi(t,a,c,s),bi(),z=t.memoizedState,b||O!==z||ia?(typeof G=="function"&&(Bc(t,n,G,a),z=t.memoizedState),(w=ia||xf(t,n,w,a,O,z,h))?(B||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount()),typeof c.componentDidMount=="function"&&(t.flags|=4194308)):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=z),c.props=a,c.state=z,c.context=h,a=w):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{c=t.stateNode,mc(e,t),h=t.memoizedProps,B=Ia(n,h),c.props=B,G=t.pendingProps,O=c.context,z=n.contextType,w=jl,typeof z=="object"&&z!==null&&(w=ot(z)),b=n.getDerivedStateFromProps,(z=typeof b=="function"||typeof c.getSnapshotBeforeUpdate=="function")||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(h!==G||O!==w)&&jf(t,c,a,w),ia=!1,O=t.memoizedState,c.state=O,pi(t,a,c,s),bi();var U=t.memoizedState;h!==G||O!==U||ia||e!==null&&e.dependencies!==null&&ws(e.dependencies)?(typeof b=="function"&&(Bc(t,n,b,a),U=t.memoizedState),(B=ia||xf(t,n,B,a,O,U,w)||e!==null&&e.dependencies!==null&&ws(e.dependencies))?(z||typeof c.UNSAFE_componentWillUpdate!="function"&&typeof c.componentWillUpdate!="function"||(typeof c.componentWillUpdate=="function"&&c.componentWillUpdate(a,U,w),typeof c.UNSAFE_componentWillUpdate=="function"&&c.UNSAFE_componentWillUpdate(a,U,w)),typeof c.componentDidUpdate=="function"&&(t.flags|=4),typeof c.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof c.componentDidUpdate!="function"||h===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||h===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=U),c.props=a,c.state=U,c.context=w,a=B):(typeof c.componentDidUpdate!="function"||h===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||h===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),a=!1)}return c=a,Ks(e,t),a=(t.flags&128)!==0,c||a?(c=t.stateNode,n=a&&typeof n.getDerivedStateFromError!="function"?null:c.render(),t.flags|=1,e!==null&&a?(t.child=Fa(t,e.child,null,s),t.child=Fa(t,null,n,s)):dt(e,t,n,s),t.memoizedState=c.state,e=t.child):e=Dn(e,t,s),e}function Df(e,t,n,a){return Ya(),t.flags|=256,dt(e,t,n,a),t.child}var Gc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Kc(e){return{baseLanes:e,cachePool:wd()}}function Yc(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Dt),e}function Bf(e,t,n){var a=t.pendingProps,s=!1,c=(t.flags&128)!==0,h;if((h=c)||(h=e!==null&&e.memoizedState===null?!1:(Je.current&2)!==0),h&&(s=!0,t.flags&=-129),h=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ee){if(s?ca(t):ra(),(e=Ge)?(e=Qh(e,Vt),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ta!==null?{id:mn,overflow:gn}:null,retryLane:536870912,hydrationErrors:null},n=gd(e),n.return=t,t.child=n,rt=t,Ge=null)):e=null,e===null)throw aa(t);return Er(e)?t.lanes=32:t.lanes=536870912,null}var b=a.children;return a=a.fallback,s?(ra(),s=t.mode,b=Ys({mode:"hidden",children:b},s),a=Ka(a,s,n,null),b.return=t,a.return=t,b.sibling=a,t.child=b,a=t.child,a.memoizedState=Kc(n),a.childLanes=Yc(e,h,n),t.memoizedState=Gc,wi(null,a)):(ca(t),Qc(t,b))}var w=e.memoizedState;if(w!==null&&(b=w.dehydrated,b!==null)){if(c)t.flags&256?(ca(t),t.flags&=-257,t=Xc(e,t,n)):t.memoizedState!==null?(ra(),t.child=e.child,t.flags|=128,t=null):(ra(),b=a.fallback,s=t.mode,a=Ys({mode:"visible",children:a.children},s),b=Ka(b,s,n,null),b.flags|=2,a.return=t,b.return=t,a.sibling=b,t.child=a,Fa(t,e.child,null,n),a=t.child,a.memoizedState=Kc(n),a.childLanes=Yc(e,h,n),t.memoizedState=Gc,t=wi(null,a));else if(ca(t),Er(b)){if(h=b.nextSibling&&b.nextSibling.dataset,h)var z=h.dgst;h=z,a=Error(r(419)),a.stack="",a.digest=h,fi({value:a,source:null,stack:null}),t=Xc(e,t,n)}else if(Pe||Tl(e,t,n,!1),h=(n&e.childLanes)!==0,Pe||h){if(h=Le,h!==null&&(a=is(h,n),a!==0&&a!==w.retryLane))throw w.retryLane=a,Ga(e,a),Ct(h,e,a),qc;Tr(b)||Ps(),t=Xc(e,t,n)}else Tr(b)?(t.flags|=192,t.child=e.child,t=null):(e=w.treeContext,Ge=Jt(b.nextSibling),rt=t,Ee=!0,na=null,Vt=!1,e!==null&&bd(t,e),t=Qc(t,a.children),t.flags|=4096);return t}return s?(ra(),b=a.fallback,s=t.mode,w=e.child,z=w.sibling,a=Mn(w,{mode:"hidden",children:a.children}),a.subtreeFlags=w.subtreeFlags&65011712,z!==null?b=Mn(z,b):(b=Ka(b,s,n,null),b.flags|=2),b.return=t,a.return=t,a.sibling=b,t.child=a,wi(null,a),a=t.child,b=e.child.memoizedState,b===null?b=Kc(n):(s=b.cachePool,s!==null?(w=We._currentValue,s=s.parent!==w?{parent:w,pool:w}:s):s=wd(),b={baseLanes:b.baseLanes|n,cachePool:s}),a.memoizedState=b,a.childLanes=Yc(e,h,n),t.memoizedState=Gc,wi(e.child,a)):(ca(t),n=e.child,e=n.sibling,n=Mn(n,{mode:"visible",children:a.children}),n.return=t,n.sibling=null,e!==null&&(h=t.deletions,h===null?(t.deletions=[e],t.flags|=16):h.push(e)),t.child=n,t.memoizedState=null,n)}function Qc(e,t){return t=Ys({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ys(e,t){return e=zt(22,e,null,t),e.lanes=0,e}function Xc(e,t,n){return Fa(t,e.child,null,n),e=Qc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hf(e,t,n){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),uc(e.return,t,n)}function Vc(e,t,n,a,s,c){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:s,treeForkCount:c}:(h.isBackwards=t,h.rendering=null,h.renderingStartTime=0,h.last=a,h.tail=n,h.tailMode=s,h.treeForkCount=c)}function Lf(e,t,n){var a=t.pendingProps,s=a.revealOrder,c=a.tail;a=a.children;var h=Je.current,b=(h&2)!==0;if(b?(h=h&1|2,t.flags|=128):h&=1,I(Je,h),dt(e,t,a,n),a=Ee?di:0,!b&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Hf(e,n,t);else if(e.tag===19)Hf(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&zs(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Vc(t,!1,s,n,c,a);break;case"backwards":case"unstable_legacy-backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&zs(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Vc(t,!0,n,null,c,a);break;case"together":Vc(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function Dn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),fa|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Tl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Mn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Mn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Zc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&ws(e)))}function ty(e,t,n){switch(t.tag){case 3:ze(t,t.stateNode.containerInfo),la(t,We,e.memoizedState.cache),Ya();break;case 27:case 5:Wt(t);break;case 4:ze(t,t.stateNode.containerInfo);break;case 10:la(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,pc(t),null;break;case 13:var a=t.memoizedState;if(a!==null)return a.dehydrated!==null?(ca(t),t.flags|=128,null):(n&t.child.childLanes)!==0?Bf(e,t,n):(ca(t),e=Dn(e,t,n),e!==null?e.sibling:null);ca(t);break;case 19:var s=(e.flags&128)!==0;if(a=(n&t.childLanes)!==0,a||(Tl(e,t,n,!1),a=(n&t.childLanes)!==0),s){if(a)return Lf(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),I(Je,Je.current),a)break;return null;case 22:return t.lanes=0,Rf(e,t,n,t.pendingProps);case 24:la(t,We,e.memoizedState.cache)}return Dn(e,t,n)}function qf(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Pe=!0;else{if(!Zc(e,n)&&(t.flags&128)===0)return Pe=!1,ty(e,t,n);Pe=(e.flags&131072)!==0}else Pe=!1,Ee&&(t.flags&1048576)!==0&&yd(t,di,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=Za(t.elementType),t.type=e,typeof e=="function")Pu(e)?(a=Ia(e,a),t.tag=1,t=Uf(null,t,e,a,n)):(t.tag=0,t=$c(null,t,e,a,n));else{if(e!=null){var s=e.$$typeof;if(s===_){t.tag=11,t=Cf(null,t,e,a,n);break e}else if(s===V){t.tag=14,t=kf(null,t,e,a,n);break e}}throw t=se(e)||e,Error(r(306,t,""))}}return t;case 0:return $c(e,t,t.type,t.pendingProps,n);case 1:return a=t.type,s=Ia(a,t.pendingProps),Uf(e,t,a,s,n);case 3:e:{if(ze(t,t.stateNode.containerInfo),e===null)throw Error(r(387));a=t.pendingProps;var c=t.memoizedState;s=c.element,mc(e,t),pi(t,a,null,n);var h=t.memoizedState;if(a=h.cache,la(t,We,a),a!==c.cache&&cc(t,[We],n,!0),bi(),a=h.element,c.isDehydrated)if(c={element:a,isDehydrated:!1,cache:h.cache},t.updateQueue.baseState=c,t.memoizedState=c,t.flags&256){t=Df(e,t,a,n);break e}else if(a!==s){s=Yt(Error(r(424)),t),fi(s),t=Df(e,t,a,n);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Ge=Jt(e.firstChild),rt=t,Ee=!0,na=null,Vt=!0,n=Md(t,null,a,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ya(),a===s){t=Dn(e,t,n);break e}dt(e,t,a,n)}t=t.child}return t;case 26:return Ks(e,t),e===null?(n=Wh(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ee||(n=t.type,e=t.pendingProps,a=su(be.current).createElement(n),a[qe]=t,a[vt]=e,ft(a,n,e),Qe(a),t.stateNode=a):t.memoizedState=Wh(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Wt(t),e===null&&Ee&&(a=t.stateNode=Zh(t.type,t.pendingProps,be.current),rt=t,Vt=!0,s=Ge,ya(t.type)?(Ar=s,Ge=Jt(a.firstChild)):Ge=s),dt(e,t,t.pendingProps.children,n),Ks(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ee&&((s=a=Ge)&&(a=Ry(a,t.type,t.pendingProps,Vt),a!==null?(t.stateNode=a,rt=t,Ge=Jt(a.firstChild),Vt=!1,s=!0):s=!1),s||aa(t)),Wt(t),s=t.type,c=t.pendingProps,h=e!==null?e.memoizedProps:null,a=c.children,Sr(s,c)?a=null:h!==null&&Sr(s,h)&&(t.flags|=32),t.memoizedState!==null&&(s=jc(e,t,Xv,null,null,n),Li._currentValue=s),Ks(e,t),dt(e,t,a,n),t.child;case 6:return e===null&&Ee&&((e=n=Ge)&&(n=zy(n,t.pendingProps,Vt),n!==null?(t.stateNode=n,rt=t,Ge=null,e=!0):e=!1),e||aa(t)),null;case 13:return Bf(e,t,n);case 4:return ze(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=Fa(t,null,a,n):dt(e,t,a,n),t.child;case 11:return Cf(e,t,t.type,t.pendingProps,n);case 7:return dt(e,t,t.pendingProps,n),t.child;case 8:return dt(e,t,t.pendingProps.children,n),t.child;case 12:return dt(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,la(t,t.type,a.value),dt(e,t,a.children,n),t.child;case 9:return s=t.type._context,a=t.pendingProps.children,Xa(t),s=ot(s),a=a(s),t.flags|=1,dt(e,t,a,n),t.child;case 14:return kf(e,t,t.type,t.pendingProps,n);case 15:return Mf(e,t,t.type,t.pendingProps,n);case 19:return Lf(e,t,n);case 31:return ey(e,t,n);case 22:return Rf(e,t,n,t.pendingProps);case 24:return Xa(t),a=ot(We),e===null?(s=dc(),s===null&&(s=Le,c=rc(),s.pooledCache=c,c.refCount++,c!==null&&(s.pooledCacheLanes|=n),s=c),t.memoizedState={parent:a,cache:s},hc(t),la(t,We,s)):((e.lanes&n)!==0&&(mc(e,t),pi(t,null,null,n),bi()),s=e.memoizedState,c=t.memoizedState,s.parent!==a?(s={parent:a,cache:a},t.memoizedState=s,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=s),la(t,We,a)):(a=c.cache,la(t,We,a),a!==s.cache&&cc(t,[We],n,!0))),dt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function Bn(e){e.flags|=4}function Jc(e,t,n,a,s){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(s&335544128)===s)if(e.stateNode.complete)e.flags|=8192;else if(hh())e.flags|=8192;else throw Ja=Cs,fc}else e.flags&=-16777217}function $f(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!nm(t))if(hh())e.flags|=8192;else throw Ja=Cs,fc}function Qs(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?fl():536870912,e.lanes|=t,Bl|=t)}function Ti(e,t){if(!Ee)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Ke(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,a=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,a|=s.subtreeFlags&65011712,a|=s.flags&65011712,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,a|=s.subtreeFlags,a|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=a,e.childLanes=n,t}function ny(e,t,n){var a=t.pendingProps;switch(ac(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ke(t),null;case 1:return Ke(t),null;case 3:return n=t.stateNode,a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),On(We),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(wl(t)?Bn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,ic())),Ke(t),null;case 26:var s=t.type,c=t.memoizedState;return e===null?(Bn(t),c!==null?(Ke(t),$f(t,c)):(Ke(t),Jc(t,s,null,a,n))):c?c!==e.memoizedState?(Bn(t),Ke(t),$f(t,c)):(Ke(t),t.flags&=-16777217):(e=e.memoizedProps,e!==a&&Bn(t),Ke(t),Jc(t,s,e,a,n)),null;case 27:if(Ea(t),n=be.current,s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Bn(t);else{if(!a){if(t.stateNode===null)throw Error(r(166));return Ke(t),null}e=ie.current,wl(t)?pd(t):(e=Zh(s,a,n),t.stateNode=e,Bn(t))}return Ke(t),null;case 5:if(Ea(t),s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Bn(t);else{if(!a){if(t.stateNode===null)throw Error(r(166));return Ke(t),null}if(c=ie.current,wl(t))pd(t);else{var h=su(be.current);switch(c){case 1:c=h.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:c=h.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":c=h.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":c=h.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":c=h.createElement("div"),c.innerHTML="<script><\\/script>",c=c.removeChild(c.firstChild);break;case"select":c=typeof a.is=="string"?h.createElement("select",{is:a.is}):h.createElement("select"),a.multiple?c.multiple=!0:a.size&&(c.size=a.size);break;default:c=typeof a.is=="string"?h.createElement(s,{is:a.is}):h.createElement(s)}}c[qe]=t,c[vt]=a;e:for(h=t.child;h!==null;){if(h.tag===5||h.tag===6)c.appendChild(h.stateNode);else if(h.tag!==4&&h.tag!==27&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}t.stateNode=c;e:switch(ft(c,s,a),s){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Bn(t)}}return Ke(t),Jc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Bn(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=be.current,wl(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,s=rt,s!==null)switch(s.tag){case 27:case 5:a=s.memoizedProps}e[qe]=t,e=!!(e.nodeValue===n||a!==null&&a.suppressHydrationWarning===!0||Bh(e.nodeValue,n)),e||aa(t,!0)}else e=su(e).createTextNode(a),e[qe]=t,t.stateNode=e}return Ke(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(a=wl(t),n!==null){if(e===null){if(!a)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[qe]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ke(t),e=!1}else n=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(_t(t),t):(_t(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Ke(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(s=wl(t),a!==null&&a.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));s[qe]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ke(t),s=!1}else s=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),s=!0;if(!s)return t.flags&256?(_t(t),t):(_t(t),null)}return _t(t),(t.flags&128)!==0?(t.lanes=n,t):(n=a!==null,e=e!==null&&e.memoizedState!==null,n&&(a=t.child,s=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(s=a.alternate.memoizedState.cachePool.pool),c=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(c=a.memoizedState.cachePool.pool),c!==s&&(a.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Qs(t,t.updateQueue),Ke(t),null);case 4:return oe(),e===null&&yr(t.stateNode.containerInfo),Ke(t),null;case 10:return On(t.type),Ke(t),null;case 19:if(q(Je),a=t.memoizedState,a===null)return Ke(t),null;if(s=(t.flags&128)!==0,c=a.rendering,c===null)if(s)Ti(a,!1);else{if(Ve!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(c=zs(e),c!==null){for(t.flags|=128,Ti(a,!1),e=c.updateQueue,t.updateQueue=e,Qs(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)md(n,e),n=n.sibling;return I(Je,Je.current&1|2),Ee&&Rn(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&mt()>Fs&&(t.flags|=128,s=!0,Ti(a,!1),t.lanes=4194304)}else{if(!s)if(e=zs(c),e!==null){if(t.flags|=128,s=!0,e=e.updateQueue,t.updateQueue=e,Qs(t,e),Ti(a,!0),a.tail===null&&a.tailMode==="hidden"&&!c.alternate&&!Ee)return Ke(t),null}else 2*mt()-a.renderingStartTime>Fs&&n!==536870912&&(t.flags|=128,s=!0,Ti(a,!1),t.lanes=4194304);a.isBackwards?(c.sibling=t.child,t.child=c):(e=a.last,e!==null?e.sibling=c:t.child=c,a.last=c)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=mt(),e.sibling=null,n=Je.current,I(Je,s?n&1|2:n&1),Ee&&Rn(t,a.treeForkCount),e):(Ke(t),null);case 22:case 23:return _t(t),bc(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(n&536870912)!==0&&(t.flags&128)===0&&(Ke(t),t.subtreeFlags&6&&(t.flags|=8192)):Ke(t),n=t.updateQueue,n!==null&&Qs(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),e!==null&&q(Va),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),On(We),Ke(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function ay(e,t){switch(ac(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return On(We),oe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ea(t),null;case 31:if(t.memoizedState!==null){if(_t(t),t.alternate===null)throw Error(r(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(_t(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(Je),null;case 4:return oe(),null;case 10:return On(t.type),null;case 22:case 23:return _t(t),bc(),e!==null&&q(Va),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return On(We),null;case 25:return null;default:return null}}function Gf(e,t){switch(ac(t),t.tag){case 3:On(We),oe();break;case 26:case 27:case 5:Ea(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&_t(t);break;case 13:_t(t);break;case 19:q(Je);break;case 10:On(t.type);break;case 22:case 23:_t(t),bc(),e!==null&&q(Va);break;case 24:On(We)}}function Ei(e,t){try{var n=t.updateQueue,a=n!==null?n.lastEffect:null;if(a!==null){var s=a.next;n=s;do{if((n.tag&e)===e){a=void 0;var c=n.create,h=n.inst;a=c(),h.destroy=a}n=n.next}while(n!==s)}}catch(b){_e(t,t.return,b)}}function oa(e,t,n){try{var a=t.updateQueue,s=a!==null?a.lastEffect:null;if(s!==null){var c=s.next;a=c;do{if((a.tag&e)===e){var h=a.inst,b=h.destroy;if(b!==void 0){h.destroy=void 0,s=t;var w=n,z=b;try{z()}catch(B){_e(s,w,B)}}}a=a.next}while(a!==c)}}catch(B){_e(t,t.return,B)}}function Kf(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{zd(t,n)}catch(a){_e(e,e.return,a)}}}function Yf(e,t,n){n.props=Ia(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(a){_e(e,t,a)}}function Ai(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof n=="function"?e.refCleanup=n(a):n.current=a}}catch(s){_e(e,t,s)}}function vn(e,t){var n=e.ref,a=e.refCleanup;if(n!==null)if(typeof a=="function")try{a()}catch(s){_e(e,t,s)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(s){_e(e,t,s)}else n.current=null}function Qf(e){var t=e.type,n=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&a.focus();break e;case"img":n.src?a.src=n.src:n.srcSet&&(a.srcset=n.srcSet)}}catch(s){_e(e,e.return,s)}}function Fc(e,t,n){try{var a=e.stateNode;Ty(a,e.type,n,t),a[vt]=t}catch(s){_e(e,e.return,s)}}function Xf(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ya(e.type)||e.tag===4}function Wc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Xf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ya(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ic(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gt));else if(a!==4&&(a===27&&ya(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Ic(e,t,n),e=e.sibling;e!==null;)Ic(e,t,n),e=e.sibling}function Xs(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(a!==4&&(a===27&&ya(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Xs(e,t,n),e=e.sibling;e!==null;)Xs(e,t,n),e=e.sibling}function Vf(e){var t=e.stateNode,n=e.memoizedProps;try{for(var a=e.type,s=t.attributes;s.length;)t.removeAttributeNode(s[0]);ft(t,a,n),t[qe]=e,t[vt]=n}catch(c){_e(e,e.return,c)}}var Hn=!1,et=!1,Pc=!1,Zf=typeof WeakSet=="function"?WeakSet:Set,it=null;function ly(e,t){if(e=e.containerInfo,xr=hu,e=id(e),Xu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var a=n.getSelection&&n.getSelection();if(a&&a.rangeCount!==0){n=a.anchorNode;var s=a.anchorOffset,c=a.focusNode;a=a.focusOffset;try{n.nodeType,c.nodeType}catch{n=null;break e}var h=0,b=-1,w=-1,z=0,B=0,G=e,O=null;t:for(;;){for(var U;G!==n||s!==0&&G.nodeType!==3||(b=h+s),G!==c||a!==0&&G.nodeType!==3||(w=h+a),G.nodeType===3&&(h+=G.nodeValue.length),(U=G.firstChild)!==null;)O=G,G=U;for(;;){if(G===e)break t;if(O===n&&++z===s&&(b=h),O===c&&++B===a&&(w=h),(U=G.nextSibling)!==null)break;G=O,O=G.parentNode}G=U}n=b===-1||w===-1?null:{start:b,end:w}}else n=null}n=n||{start:0,end:0}}else n=null;for(jr={focusedElem:e,selectionRange:n},hu=!1,it=t;it!==null;)if(t=it,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,it=e;else for(;it!==null;){switch(t=it,c=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)s=e[n],s.ref.impl=s.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&c!==null){e=void 0,n=t,s=c.memoizedProps,c=c.memoizedState,a=n.stateNode;try{var ue=Ia(n.type,s);e=a.getSnapshotBeforeUpdate(ue,c),a.__reactInternalSnapshotBeforeUpdate=e}catch(he){_e(n,n.return,he)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)wr(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":wr(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(r(163))}if(e=t.sibling,e!==null){e.return=t.return,it=e;break}it=t.return}}function Jf(e,t,n){var a=n.flags;switch(n.tag){case 0:case 11:case 15:qn(e,n),a&4&&Ei(5,n);break;case 1:if(qn(e,n),a&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(h){_e(n,n.return,h)}else{var s=Ia(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(s,t,e.__reactInternalSnapshotBeforeUpdate)}catch(h){_e(n,n.return,h)}}a&64&&Kf(n),a&512&&Ai(n,n.return);break;case 3:if(qn(e,n),a&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{zd(e,t)}catch(h){_e(n,n.return,h)}}break;case 27:t===null&&a&4&&Vf(n);case 26:case 5:qn(e,n),t===null&&a&4&&Qf(n),a&512&&Ai(n,n.return);break;case 12:qn(e,n);break;case 31:qn(e,n),a&4&&If(e,n);break;case 13:qn(e,n),a&4&&Pf(e,n),a&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=hy.bind(null,n),Oy(e,n))));break;case 22:if(a=n.memoizedState!==null||Hn,!a){t=t!==null&&t.memoizedState!==null||et,s=Hn;var c=et;Hn=a,(et=t)&&!c?$n(e,n,(n.subtreeFlags&8772)!==0):qn(e,n),Hn=s,et=c}break;case 30:break;default:qn(e,n)}}function Ff(e){var t=e.alternate;t!==null&&(e.alternate=null,Ff(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ye=null,wt=!1;function Ln(e,t,n){for(n=n.child;n!==null;)Wf(e,t,n),n=n.sibling}function Wf(e,t,n){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Sn,n)}catch{}switch(n.tag){case 26:et||vn(n,t),Ln(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:et||vn(n,t);var a=Ye,s=wt;ya(n.type)&&(Ye=n.stateNode,wt=!1),Ln(e,t,n),Di(n.stateNode),Ye=a,wt=s;break;case 5:et||vn(n,t);case 6:if(a=Ye,s=wt,Ye=null,Ln(e,t,n),Ye=a,wt=s,Ye!==null)if(wt)try{(Ye.nodeType===9?Ye.body:Ye.nodeName==="HTML"?Ye.ownerDocument.body:Ye).removeChild(n.stateNode)}catch(c){_e(n,t,c)}else try{Ye.removeChild(n.stateNode)}catch(c){_e(n,t,c)}break;case 18:Ye!==null&&(wt?(e=Ye,Kh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Ql(e)):Kh(Ye,n.stateNode));break;case 4:a=Ye,s=wt,Ye=n.stateNode.containerInfo,wt=!0,Ln(e,t,n),Ye=a,wt=s;break;case 0:case 11:case 14:case 15:oa(2,n,t),et||oa(4,n,t),Ln(e,t,n);break;case 1:et||(vn(n,t),a=n.stateNode,typeof a.componentWillUnmount=="function"&&Yf(n,t,a)),Ln(e,t,n);break;case 21:Ln(e,t,n);break;case 22:et=(a=et)||n.memoizedState!==null,Ln(e,t,n),et=a;break;default:Ln(e,t,n)}}function If(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ql(e)}catch(n){_e(t,t.return,n)}}}function Pf(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ql(e)}catch(n){_e(t,t.return,n)}}function iy(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Zf),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Zf),t;default:throw Error(r(435,e.tag))}}function Vs(e,t){var n=iy(e);t.forEach(function(a){if(!n.has(a)){n.add(a);var s=my.bind(null,e,a);a.then(s,s)}})}function Tt(e,t){var n=t.deletions;if(n!==null)for(var a=0;a<n.length;a++){var s=n[a],c=e,h=t,b=h;e:for(;b!==null;){switch(b.tag){case 27:if(ya(b.type)){Ye=b.stateNode,wt=!1;break e}break;case 5:Ye=b.stateNode,wt=!1;break e;case 3:case 4:Ye=b.stateNode.containerInfo,wt=!0;break e}b=b.return}if(Ye===null)throw Error(r(160));Wf(c,h,s),Ye=null,wt=!1,c=s.alternate,c!==null&&(c.return=null),s.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)eh(t,e),t=t.sibling}var un=null;function eh(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Tt(t,e),Et(e),a&4&&(oa(3,e,e.return),Ei(3,e),oa(5,e,e.return));break;case 1:Tt(t,e),Et(e),a&512&&(et||n===null||vn(n,n.return)),a&64&&Hn&&(e=e.updateQueue,e!==null&&(a=e.callbacks,a!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?a:n.concat(a))));break;case 26:var s=un;if(Tt(t,e),Et(e),a&512&&(et||n===null||vn(n,n.return)),a&4){var c=n!==null?n.memoizedState:null;if(a=e.memoizedState,n===null)if(a===null)if(e.stateNode===null){e:{a=e.type,n=e.memoizedProps,s=s.ownerDocument||s;t:switch(a){case"title":c=s.getElementsByTagName("title")[0],(!c||c[Jn]||c[qe]||c.namespaceURI==="http://www.w3.org/2000/svg"||c.hasAttribute("itemprop"))&&(c=s.createElement(a),s.head.insertBefore(c,s.querySelector("head > title"))),ft(c,a,n),c[qe]=e,Qe(c),a=c;break e;case"link":var h=em("link","href",s).get(a+(n.href||""));if(h){for(var b=0;b<h.length;b++)if(c=h[b],c.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&c.getAttribute("rel")===(n.rel==null?null:n.rel)&&c.getAttribute("title")===(n.title==null?null:n.title)&&c.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){h.splice(b,1);break t}}c=s.createElement(a),ft(c,a,n),s.head.appendChild(c);break;case"meta":if(h=em("meta","content",s).get(a+(n.content||""))){for(b=0;b<h.length;b++)if(c=h[b],c.getAttribute("content")===(n.content==null?null:""+n.content)&&c.getAttribute("name")===(n.name==null?null:n.name)&&c.getAttribute("property")===(n.property==null?null:n.property)&&c.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&c.getAttribute("charset")===(n.charSet==null?null:n.charSet)){h.splice(b,1);break t}}c=s.createElement(a),ft(c,a,n),s.head.appendChild(c);break;default:throw Error(r(468,a))}c[qe]=e,Qe(c),a=c}e.stateNode=a}else tm(s,e.type,e.stateNode);else e.stateNode=Ph(s,a,e.memoizedProps);else c!==a?(c===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):c.count--,a===null?tm(s,e.type,e.stateNode):Ph(s,a,e.memoizedProps)):a===null&&e.stateNode!==null&&Fc(e,e.memoizedProps,n.memoizedProps)}break;case 27:Tt(t,e),Et(e),a&512&&(et||n===null||vn(n,n.return)),n!==null&&a&4&&Fc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Tt(t,e),Et(e),a&512&&(et||n===null||vn(n,n.return)),e.flags&32){s=e.stateNode;try{Pn(s,"")}catch(ue){_e(e,e.return,ue)}}a&4&&e.stateNode!=null&&(s=e.memoizedProps,Fc(e,s,n!==null?n.memoizedProps:s)),a&1024&&(Pc=!0);break;case 6:if(Tt(t,e),Et(e),a&4){if(e.stateNode===null)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(ue){_e(e,e.return,ue)}}break;case 3:if(ru=null,s=un,un=uu(t.containerInfo),Tt(t,e),un=s,Et(e),a&4&&n!==null&&n.memoizedState.isDehydrated)try{Ql(t.containerInfo)}catch(ue){_e(e,e.return,ue)}Pc&&(Pc=!1,th(e));break;case 4:a=un,un=uu(e.stateNode.containerInfo),Tt(t,e),Et(e),un=a;break;case 12:Tt(t,e),Et(e);break;case 31:Tt(t,e),Et(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Vs(e,a)));break;case 13:Tt(t,e),Et(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Js=mt()),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Vs(e,a)));break;case 22:s=e.memoizedState!==null;var w=n!==null&&n.memoizedState!==null,z=Hn,B=et;if(Hn=z||s,et=B||w,Tt(t,e),et=B,Hn=z,Et(e),a&8192)e:for(t=e.stateNode,t._visibility=s?t._visibility&-2:t._visibility|1,s&&(n===null||w||Hn||et||Pa(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){w=n=t;try{if(c=w.stateNode,s)h=c.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none";else{b=w.stateNode;var G=w.memoizedProps.style,O=G!=null&&G.hasOwnProperty("display")?G.display:null;b.style.display=O==null||typeof O=="boolean"?"":(""+O).trim()}}catch(ue){_e(w,w.return,ue)}}}else if(t.tag===6){if(n===null){w=t;try{w.stateNode.nodeValue=s?"":w.memoizedProps}catch(ue){_e(w,w.return,ue)}}}else if(t.tag===18){if(n===null){w=t;try{var U=w.stateNode;s?Yh(U,!0):Yh(w.stateNode,!1)}catch(ue){_e(w,w.return,ue)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}a&4&&(a=e.updateQueue,a!==null&&(n=a.retryQueue,n!==null&&(a.retryQueue=null,Vs(e,n))));break;case 19:Tt(t,e),Et(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Vs(e,a)));break;case 30:break;case 21:break;default:Tt(t,e),Et(e)}}function Et(e){var t=e.flags;if(t&2){try{for(var n,a=e.return;a!==null;){if(Xf(a)){n=a;break}a=a.return}if(n==null)throw Error(r(160));switch(n.tag){case 27:var s=n.stateNode,c=Wc(e);Xs(e,c,s);break;case 5:var h=n.stateNode;n.flags&32&&(Pn(h,""),n.flags&=-33);var b=Wc(e);Xs(e,b,h);break;case 3:case 4:var w=n.stateNode.containerInfo,z=Wc(e);Ic(e,z,w);break;default:throw Error(r(161))}}catch(B){_e(e,e.return,B)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function th(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;th(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function qn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Jf(e,t.alternate,t),t=t.sibling}function Pa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:oa(4,t,t.return),Pa(t);break;case 1:vn(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&Yf(t,t.return,n),Pa(t);break;case 27:Di(t.stateNode);case 26:case 5:vn(t,t.return),Pa(t);break;case 22:t.memoizedState===null&&Pa(t);break;case 30:Pa(t);break;default:Pa(t)}e=e.sibling}}function $n(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var a=t.alternate,s=e,c=t,h=c.flags;switch(c.tag){case 0:case 11:case 15:$n(s,c,n),Ei(4,c);break;case 1:if($n(s,c,n),a=c,s=a.stateNode,typeof s.componentDidMount=="function")try{s.componentDidMount()}catch(z){_e(a,a.return,z)}if(a=c,s=a.updateQueue,s!==null){var b=a.stateNode;try{var w=s.shared.hiddenCallbacks;if(w!==null)for(s.shared.hiddenCallbacks=null,s=0;s<w.length;s++)Rd(w[s],b)}catch(z){_e(a,a.return,z)}}n&&h&64&&Kf(c),Ai(c,c.return);break;case 27:Vf(c);case 26:case 5:$n(s,c,n),n&&a===null&&h&4&&Qf(c),Ai(c,c.return);break;case 12:$n(s,c,n);break;case 31:$n(s,c,n),n&&h&4&&If(s,c);break;case 13:$n(s,c,n),n&&h&4&&Pf(s,c);break;case 22:c.memoizedState===null&&$n(s,c,n),Ai(c,c.return);break;case 30:break;default:$n(s,c,n)}t=t.sibling}}function er(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&hi(n))}function tr(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&hi(e))}function cn(e,t,n,a){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)nh(e,t,n,a),t=t.sibling}function nh(e,t,n,a){var s=t.flags;switch(t.tag){case 0:case 11:case 15:cn(e,t,n,a),s&2048&&Ei(9,t);break;case 1:cn(e,t,n,a);break;case 3:cn(e,t,n,a),s&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&hi(e)));break;case 12:if(s&2048){cn(e,t,n,a),e=t.stateNode;try{var c=t.memoizedProps,h=c.id,b=c.onPostCommit;typeof b=="function"&&b(h,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(w){_e(t,t.return,w)}}else cn(e,t,n,a);break;case 31:cn(e,t,n,a);break;case 13:cn(e,t,n,a);break;case 23:break;case 22:c=t.stateNode,h=t.alternate,t.memoizedState!==null?c._visibility&2?cn(e,t,n,a):Ci(e,t):c._visibility&2?cn(e,t,n,a):(c._visibility|=2,_l(e,t,n,a,(t.subtreeFlags&10256)!==0||!1)),s&2048&&er(h,t);break;case 24:cn(e,t,n,a),s&2048&&tr(t.alternate,t);break;default:cn(e,t,n,a)}}function _l(e,t,n,a,s){for(s=s&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var c=e,h=t,b=n,w=a,z=h.flags;switch(h.tag){case 0:case 11:case 15:_l(c,h,b,w,s),Ei(8,h);break;case 23:break;case 22:var B=h.stateNode;h.memoizedState!==null?B._visibility&2?_l(c,h,b,w,s):Ci(c,h):(B._visibility|=2,_l(c,h,b,w,s)),s&&z&2048&&er(h.alternate,h);break;case 24:_l(c,h,b,w,s),s&&z&2048&&tr(h.alternate,h);break;default:_l(c,h,b,w,s)}t=t.sibling}}function Ci(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,a=t,s=a.flags;switch(a.tag){case 22:Ci(n,a),s&2048&&er(a.alternate,a);break;case 24:Ci(n,a),s&2048&&tr(a.alternate,a);break;default:Ci(n,a)}t=t.sibling}}var ki=8192;function Ul(e,t,n){if(e.subtreeFlags&ki)for(e=e.child;e!==null;)ah(e,t,n),e=e.sibling}function ah(e,t,n){switch(e.tag){case 26:Ul(e,t,n),e.flags&ki&&e.memoizedState!==null&&Qy(n,un,e.memoizedState,e.memoizedProps);break;case 5:Ul(e,t,n);break;case 3:case 4:var a=un;un=uu(e.stateNode.containerInfo),Ul(e,t,n),un=a;break;case 22:e.memoizedState===null&&(a=e.alternate,a!==null&&a.memoizedState!==null?(a=ki,ki=16777216,Ul(e,t,n),ki=a):Ul(e,t,n));break;default:Ul(e,t,n)}}function lh(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Mi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var a=t[n];it=a,sh(a,e)}lh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)ih(e),e=e.sibling}function ih(e){switch(e.tag){case 0:case 11:case 15:Mi(e),e.flags&2048&&oa(9,e,e.return);break;case 3:Mi(e);break;case 12:Mi(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Zs(e)):Mi(e);break;default:Mi(e)}}function Zs(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var a=t[n];it=a,sh(a,e)}lh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:oa(8,t,t.return),Zs(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Zs(t));break;default:Zs(t)}e=e.sibling}}function sh(e,t){for(;it!==null;){var n=it;switch(n.tag){case 0:case 11:case 15:oa(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var a=n.memoizedState.cachePool.pool;a!=null&&a.refCount++}break;case 24:hi(n.memoizedState.cache)}if(a=n.child,a!==null)a.return=n,it=a;else e:for(n=e;it!==null;){a=it;var s=a.sibling,c=a.return;if(Ff(a),a===n){it=null;break e}if(s!==null){s.return=c,it=s;break e}it=c}}}var sy={getCacheForType:function(e){var t=ot(We),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ot(We).controller.signal}},uy=typeof WeakMap=="function"?WeakMap:Map,Re=0,Le=null,Se=null,we=0,Oe=0,Ut=null,da=!1,Dl=!1,nr=!1,Gn=0,Ve=0,fa=0,el=0,ar=0,Dt=0,Bl=0,Ri=null,At=null,lr=!1,Js=0,uh=0,Fs=1/0,Ws=null,ha=null,at=0,ma=null,Hl=null,Kn=0,ir=0,sr=null,ch=null,zi=0,ur=null;function Bt(){return(Re&2)!==0&&we!==0?we&-we:D.T!==null?hr():Pl()}function rh(){if(Dt===0)if((we&536870912)===0||Ee){var e=Vn;Vn<<=1,(Vn&3932160)===0&&(Vn=262144),Dt=e}else Dt=536870912;return e=Ot.current,e!==null&&(e.flags|=32),Dt}function Ct(e,t,n){(e===Le&&(Oe===2||Oe===9)||e.cancelPendingCommit!==null)&&(Ll(e,0),ga(e,we,Dt,!1)),Ma(e,n),((Re&2)===0||e!==Le)&&(e===Le&&((Re&2)===0&&(el|=n),Ve===4&&ga(e,we,Dt,!1)),yn(e))}function oh(e,t,n){if((Re&6)!==0)throw Error(r(327));var a=!n&&(t&127)===0&&(t&e.expiredLanes)===0||Ca(e,t),s=a?oy(e,t):rr(e,t,!0),c=a;do{if(s===0){Dl&&!a&&ga(e,t,0,!1);break}else{if(n=e.current.alternate,c&&!cy(n)){s=rr(e,t,!1),c=!1;continue}if(s===2){if(c=t,e.errorRecoveryDisabledLanes&c)var h=0;else h=e.pendingLanes&-536870913,h=h!==0?h:h&536870912?536870912:0;if(h!==0){t=h;e:{var b=e;s=Ri;var w=b.current.memoizedState.isDehydrated;if(w&&(Ll(b,h).flags|=256),h=rr(b,h,!1),h!==2){if(nr&&!w){b.errorRecoveryDisabledLanes|=c,el|=c,s=4;break e}c=At,At=s,c!==null&&(At===null?At=c:At.push.apply(At,c))}s=h}if(c=!1,s!==2)continue}}if(s===1){Ll(e,0),ga(e,t,0,!0);break}e:{switch(a=e,c=s,c){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:ga(a,t,Dt,!da);break e;case 2:At=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(s=Js+300-mt(),10<s)){if(ga(a,t,Dt,!da),dl(a,0,!0)!==0)break e;Kn=t,a.timeoutHandle=$h(dh.bind(null,a,n,At,Ws,lr,t,Dt,el,Bl,da,c,"Throttled",-0,0),s);break e}dh(a,n,At,Ws,lr,t,Dt,el,Bl,da,c,null,-0,0)}}break}while(!0);yn(e)}function dh(e,t,n,a,s,c,h,b,w,z,B,G,O,U){if(e.timeoutHandle=-1,G=t.subtreeFlags,G&8192||(G&16785408)===16785408){G={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Gt},ah(t,c,G);var ue=(c&62914560)===c?Js-mt():(c&4194048)===c?uh-mt():0;if(ue=Xy(G,ue),ue!==null){Kn=c,e.cancelPendingCommit=ue(ph.bind(null,e,t,c,n,a,s,h,b,w,B,G,null,O,U)),ga(e,c,h,!z);return}}ph(e,t,c,n,a,s,h,b,w)}function cy(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var a=0;a<n.length;a++){var s=n[a],c=s.getSnapshot;s=s.value;try{if(!Rt(c(),s))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ga(e,t,n,a){t&=~ar,t&=~el,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var s=t;0<s;){var c=31-gt(s),h=1<<c;a[c]=-1,s&=~h}n!==0&&wn(e,n,t)}function Is(){return(Re&6)===0?(Oi(0),!1):!0}function cr(){if(Se!==null){if(Oe===0)var e=Se.return;else e=Se,zn=Qa=null,wc(e),kl=null,gi=0,e=Se;for(;e!==null;)Gf(e.alternate,e),e=e.return;Se=null}}function Ll(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Cy(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Kn=0,cr(),Le=e,Se=n=Mn(e.current,null),we=t,Oe=0,Ut=null,da=!1,Dl=Ca(e,t),nr=!1,Bl=Dt=ar=el=fa=Ve=0,At=Ri=null,lr=!1,(t&8)!==0&&(t|=t&32);var a=e.entangledLanes;if(a!==0)for(e=e.entanglements,a&=t;0<a;){var s=31-gt(a),c=1<<s;t|=e[s],a&=~c}return Gn=t,ps(),n}function fh(e,t){xe=null,D.H=Ni,t===Cl||t===As?(t=Ad(),Oe=3):t===fc?(t=Ad(),Oe=4):Oe=t===qc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ut=t,Se===null&&(Ve=1,$s(e,Yt(t,e.current)))}function hh(){var e=Ot.current;return e===null?!0:(we&4194048)===we?Zt===null:(we&62914560)===we||(we&536870912)!==0?e===Zt:!1}function mh(){var e=D.H;return D.H=Ni,e===null?Ni:e}function gh(){var e=D.A;return D.A=sy,e}function Ps(){Ve=4,da||(we&4194048)!==we&&Ot.current!==null||(Dl=!0),(fa&134217727)===0&&(el&134217727)===0||Le===null||ga(Le,we,Dt,!1)}function rr(e,t,n){var a=Re;Re|=2;var s=mh(),c=gh();(Le!==e||we!==t)&&(Ws=null,Ll(e,t)),t=!1;var h=Ve;e:do try{if(Oe!==0&&Se!==null){var b=Se,w=Ut;switch(Oe){case 8:cr(),h=6;break e;case 3:case 2:case 9:case 6:Ot.current===null&&(t=!0);var z=Oe;if(Oe=0,Ut=null,ql(e,b,w,z),n&&Dl){h=0;break e}break;default:z=Oe,Oe=0,Ut=null,ql(e,b,w,z)}}ry(),h=Ve;break}catch(B){fh(e,B)}while(!0);return t&&e.shellSuspendCounter++,zn=Qa=null,Re=a,D.H=s,D.A=c,Se===null&&(Le=null,we=0,ps()),h}function ry(){for(;Se!==null;)vh(Se)}function oy(e,t){var n=Re;Re|=2;var a=mh(),s=gh();Le!==e||we!==t?(Ws=null,Fs=mt()+500,Ll(e,t)):Dl=Ca(e,t);e:do try{if(Oe!==0&&Se!==null){t=Se;var c=Ut;t:switch(Oe){case 1:Oe=0,Ut=null,ql(e,t,c,1);break;case 2:case 9:if(Td(c)){Oe=0,Ut=null,yh(t);break}t=function(){Oe!==2&&Oe!==9||Le!==e||(Oe=7),yn(e)},c.then(t,t);break e;case 3:Oe=7;break e;case 4:Oe=5;break e;case 7:Td(c)?(Oe=0,Ut=null,yh(t)):(Oe=0,Ut=null,ql(e,t,c,7));break;case 5:var h=null;switch(Se.tag){case 26:h=Se.memoizedState;case 5:case 27:var b=Se;if(h?nm(h):b.stateNode.complete){Oe=0,Ut=null;var w=b.sibling;if(w!==null)Se=w;else{var z=b.return;z!==null?(Se=z,eu(z)):Se=null}break t}}Oe=0,Ut=null,ql(e,t,c,5);break;case 6:Oe=0,Ut=null,ql(e,t,c,6);break;case 8:cr(),Ve=6;break e;default:throw Error(r(462))}}dy();break}catch(B){fh(e,B)}while(!0);return zn=Qa=null,D.H=a,D.A=s,Re=n,Se!==null?0:(Le=null,we=0,ps(),Ve)}function dy(){for(;Se!==null&&!nt();)vh(Se)}function vh(e){var t=qf(e.alternate,e,Gn);e.memoizedProps=e.pendingProps,t===null?eu(e):Se=t}function yh(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=_f(n,t,t.pendingProps,t.type,void 0,we);break;case 11:t=_f(n,t,t.pendingProps,t.type.render,t.ref,we);break;case 5:wc(t);default:Gf(n,t),t=Se=md(t,Gn),t=qf(n,t,Gn)}e.memoizedProps=e.pendingProps,t===null?eu(e):Se=t}function ql(e,t,n,a){zn=Qa=null,wc(t),kl=null,gi=0;var s=t.return;try{if(Pv(e,s,t,n,we)){Ve=1,$s(e,Yt(n,e.current)),Se=null;return}}catch(c){if(s!==null)throw Se=s,c;Ve=1,$s(e,Yt(n,e.current)),Se=null;return}t.flags&32768?(Ee||a===1?e=!0:Dl||(we&536870912)!==0?e=!1:(da=e=!0,(a===2||a===9||a===3||a===6)&&(a=Ot.current,a!==null&&a.tag===13&&(a.flags|=16384))),bh(t,e)):eu(t)}function eu(e){var t=e;do{if((t.flags&32768)!==0){bh(t,da);return}e=t.return;var n=ny(t.alternate,t,Gn);if(n!==null){Se=n;return}if(t=t.sibling,t!==null){Se=t;return}Se=t=e}while(t!==null);Ve===0&&(Ve=5)}function bh(e,t){do{var n=ay(e.alternate,e);if(n!==null){n.flags&=32767,Se=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Se=e;return}Se=e=n}while(e!==null);Ve=6,Se=null}function ph(e,t,n,a,s,c,h,b,w){e.cancelPendingCommit=null;do tu();while(at!==0);if((Re&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(c=t.lanes|t.childLanes,c|=Wu,Uu(e,n,c,h,b,w),e===Le&&(Se=Le=null,we=0),Hl=t,ma=e,Kn=n,ir=c,sr=s,ch=a,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,gy(jn,function(){return wh(),null})):(e.callbackNode=null,e.callbackPriority=0),a=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||a){a=D.T,D.T=null,s=te.p,te.p=2,h=Re,Re|=4;try{ly(e,t,n)}finally{Re=h,te.p=s,D.T=a}}at=1,xh(),jh(),Sh()}}function xh(){if(at===1){at=0;var e=ma,t=Hl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=D.T,D.T=null;var a=te.p;te.p=2;var s=Re;Re|=4;try{eh(t,e);var c=jr,h=id(e.containerInfo),b=c.focusedElem,w=c.selectionRange;if(h!==b&&b&&b.ownerDocument&&ld(b.ownerDocument.documentElement,b)){if(w!==null&&Xu(b)){var z=w.start,B=w.end;if(B===void 0&&(B=z),"selectionStart"in b)b.selectionStart=z,b.selectionEnd=Math.min(B,b.value.length);else{var G=b.ownerDocument||document,O=G&&G.defaultView||window;if(O.getSelection){var U=O.getSelection(),ue=b.textContent.length,he=Math.min(w.start,ue),He=w.end===void 0?he:Math.min(w.end,ue);!U.extend&&he>He&&(h=He,He=he,he=h);var k=ad(b,he),E=ad(b,He);if(k&&E&&(U.rangeCount!==1||U.anchorNode!==k.node||U.anchorOffset!==k.offset||U.focusNode!==E.node||U.focusOffset!==E.offset)){var M=G.createRange();M.setStart(k.node,k.offset),U.removeAllRanges(),he>He?(U.addRange(M),U.extend(E.node,E.offset)):(M.setEnd(E.node,E.offset),U.addRange(M))}}}}for(G=[],U=b;U=U.parentNode;)U.nodeType===1&&G.push({element:U,left:U.scrollLeft,top:U.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<G.length;b++){var H=G[b];H.element.scrollLeft=H.left,H.element.scrollTop=H.top}}hu=!!xr,jr=xr=null}finally{Re=s,te.p=a,D.T=n}}e.current=t,at=2}}function jh(){if(at===2){at=0;var e=ma,t=Hl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=D.T,D.T=null;var a=te.p;te.p=2;var s=Re;Re|=4;try{Jf(e,t.alternate,t)}finally{Re=s,te.p=a,D.T=n}}at=3}}function Sh(){if(at===4||at===3){at=0,Xn();var e=ma,t=Hl,n=Kn,a=ch;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?at=5:(at=0,Hl=ma=null,Nh(e,e.pendingLanes));var s=e.pendingLanes;if(s===0&&(ha=null),Il(n),t=t.stateNode,bt&&typeof bt.onCommitFiberRoot=="function")try{bt.onCommitFiberRoot(Sn,t,void 0,(t.current.flags&128)===128)}catch{}if(a!==null){t=D.T,s=te.p,te.p=2,D.T=null;try{for(var c=e.onRecoverableError,h=0;h<a.length;h++){var b=a[h];c(b.value,{componentStack:b.stack})}}finally{D.T=t,te.p=s}}(Kn&3)!==0&&tu(),yn(e),s=e.pendingLanes,(n&261930)!==0&&(s&42)!==0?e===ur?zi++:(zi=0,ur=e):zi=0,Oi(0)}}function Nh(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,hi(t)))}function tu(){return xh(),jh(),Sh(),wh()}function wh(){if(at!==5)return!1;var e=ma,t=ir;ir=0;var n=Il(Kn),a=D.T,s=te.p;try{te.p=32>n?32:n,D.T=null,n=sr,sr=null;var c=ma,h=Kn;if(at=0,Hl=ma=null,Kn=0,(Re&6)!==0)throw Error(r(331));var b=Re;if(Re|=4,ih(c.current),nh(c,c.current,h,n),Re=b,Oi(0,!1),bt&&typeof bt.onPostCommitFiberRoot=="function")try{bt.onPostCommitFiberRoot(Sn,c)}catch{}return!0}finally{te.p=s,D.T=a,Nh(e,t)}}function Th(e,t,n){t=Yt(n,t),t=Lc(e.stateNode,t,2),e=ua(e,t,2),e!==null&&(Ma(e,2),yn(e))}function _e(e,t,n){if(e.tag===3)Th(e,e,n);else for(;t!==null;){if(t.tag===3){Th(t,e,n);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(ha===null||!ha.has(a))){e=Yt(n,e),n=Ef(2),a=ua(t,n,2),a!==null&&(Af(n,a,t,e),Ma(a,2),yn(a));break}}t=t.return}}function or(e,t,n){var a=e.pingCache;if(a===null){a=e.pingCache=new uy;var s=new Set;a.set(t,s)}else s=a.get(t),s===void 0&&(s=new Set,a.set(t,s));s.has(n)||(nr=!0,s.add(n),e=fy.bind(null,e,t,n),t.then(e,e))}function fy(e,t,n){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Le===e&&(we&n)===n&&(Ve===4||Ve===3&&(we&62914560)===we&&300>mt()-Js?(Re&2)===0&&Ll(e,0):ar|=n,Bl===we&&(Bl=0)),yn(e)}function Eh(e,t){t===0&&(t=fl()),e=Ga(e,t),e!==null&&(Ma(e,t),yn(e))}function hy(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Eh(e,n)}function my(e,t){var n=0;switch(e.tag){case 31:case 13:var a=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}a!==null&&a.delete(t),Eh(e,n)}function gy(e,t){return Lt(e,t)}var nu=null,$l=null,dr=!1,au=!1,fr=!1,va=0;function yn(e){e!==$l&&e.next===null&&($l===null?nu=$l=e:$l=$l.next=e),au=!0,dr||(dr=!0,yy())}function Oi(e,t){if(!fr&&au){fr=!0;do for(var n=!1,a=nu;a!==null;){if(e!==0){var s=a.pendingLanes;if(s===0)var c=0;else{var h=a.suspendedLanes,b=a.pingedLanes;c=(1<<31-gt(42|e)+1)-1,c&=s&~(h&~b),c=c&201326741?c&201326741|1:c?c|2:0}c!==0&&(n=!0,Mh(a,c))}else c=we,c=dl(a,a===Le?c:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(c&3)===0||Ca(a,c)||(n=!0,Mh(a,c));a=a.next}while(n);fr=!1}}function vy(){Ah()}function Ah(){au=dr=!1;var e=0;va!==0&&Ay()&&(e=va);for(var t=mt(),n=null,a=nu;a!==null;){var s=a.next,c=Ch(a,t);c===0?(a.next=null,n===null?nu=s:n.next=s,s===null&&($l=n)):(n=a,(e!==0||(c&3)!==0)&&(au=!0)),a=s}at!==0&&at!==5||Oi(e),va!==0&&(va=0)}function Ch(e,t){for(var n=e.suspendedLanes,a=e.pingedLanes,s=e.expirationTimes,c=e.pendingLanes&-62914561;0<c;){var h=31-gt(c),b=1<<h,w=s[h];w===-1?((b&n)===0||(b&a)!==0)&&(s[h]=ls(b,t)):w<=t&&(e.expiredLanes|=b),c&=~b}if(t=Le,n=we,n=dl(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a=e.callbackNode,n===0||e===t&&(Oe===2||Oe===9)||e.cancelPendingCommit!==null)return a!==null&&a!==null&&ol(a),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||Ca(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(a!==null&&ol(a),Il(n)){case 2:case 8:n=Jl;break;case 32:n=jn;break;case 268435456:n=Fl;break;default:n=jn}return a=kh.bind(null,e),n=Lt(n,a),e.callbackPriority=t,e.callbackNode=n,t}return a!==null&&a!==null&&ol(a),e.callbackPriority=2,e.callbackNode=null,2}function kh(e,t){if(at!==0&&at!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(tu()&&e.callbackNode!==n)return null;var a=we;return a=dl(e,e===Le?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a===0?null:(oh(e,a,t),Ch(e,mt()),e.callbackNode!=null&&e.callbackNode===n?kh.bind(null,e):null)}function Mh(e,t){if(tu())return null;oh(e,t,!0)}function yy(){ky(function(){(Re&6)!==0?Lt(Zl,vy):Ah()})}function hr(){if(va===0){var e=El;e===0&&(e=Aa,Aa<<=1,(Aa&261888)===0&&(Aa=256)),va=e}return va}function Rh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Cn(""+e)}function zh(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function by(e,t,n,a,s){if(t==="submit"&&n&&n.stateNode===s){var c=Rh((s[vt]||null).action),h=a.submitter;h&&(t=(t=h[vt]||null)?Rh(t.formAction):h.getAttribute("formAction"),t!==null&&(c=t,h=null));var b=new La("action","action",null,a,s);e.push({event:b,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(va!==0){var w=h?zh(s,h):new FormData(s);Oc(n,{pending:!0,data:w,method:s.method,action:c},null,w)}}else typeof c=="function"&&(b.preventDefault(),w=h?zh(s,h):new FormData(s),Oc(n,{pending:!0,data:w,method:s.method,action:c},c,w))},currentTarget:s}]})}}for(var mr=0;mr<Fu.length;mr++){var gr=Fu[mr],py=gr.toLowerCase(),xy=gr[0].toUpperCase()+gr.slice(1);sn(py,"on"+xy)}sn(cd,"onAnimationEnd"),sn(rd,"onAnimationIteration"),sn(od,"onAnimationStart"),sn("dblclick","onDoubleClick"),sn("focusin","onFocus"),sn("focusout","onBlur"),sn(Dv,"onTransitionRun"),sn(Bv,"onTransitionStart"),sn(Hv,"onTransitionCancel"),sn(dd,"onTransitionEnd"),En("onMouseEnter",["mouseout","mouseover"]),En("onMouseLeave",["mouseout","mouseover"]),En("onPointerEnter",["pointerout","pointerover"]),En("onPointerLeave",["pointerout","pointerover"]),Tn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Tn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Tn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Tn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Tn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Tn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _i="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(" "),jy=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(_i));function Oh(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var a=e[n],s=a.event;a=a.listeners;e:{var c=void 0;if(t)for(var h=a.length-1;0<=h;h--){var b=a[h],w=b.instance,z=b.currentTarget;if(b=b.listener,w!==c&&s.isPropagationStopped())break e;c=b,s.currentTarget=z;try{c(s)}catch(B){bs(B)}s.currentTarget=null,c=w}else for(h=0;h<a.length;h++){if(b=a[h],w=b.instance,z=b.currentTarget,b=b.listener,w!==c&&s.isPropagationStopped())break e;c=b,s.currentTarget=z;try{c(s)}catch(B){bs(B)}s.currentTarget=null,c=w}}}}function Ne(e,t){var n=t[ml];n===void 0&&(n=t[ml]=new Set);var a=e+"__bubble";n.has(a)||(_h(t,e,2,!1),n.add(a))}function vr(e,t,n){var a=0;t&&(a|=4),_h(n,e,a,t)}var lu="_reactListening"+Math.random().toString(36).slice(2);function yr(e){if(!e[lu]){e[lu]=!0,hn.forEach(function(n){n!=="selectionchange"&&(jy.has(n)||vr(n,!1,e),vr(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[lu]||(t[lu]=!0,vr("selectionchange",!1,t))}}function _h(e,t,n,a){switch(rm(t)){case 2:var s=Jy;break;case 8:s=Fy;break;default:s=zr}n=s.bind(null,t,n,e),s=void 0,!Ba||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),a?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function br(e,t,n,a,s){var c=a;if((t&1)===0&&(t&2)===0&&a!==null)e:for(;;){if(a===null)return;var h=a.tag;if(h===3||h===4){var b=a.stateNode.containerInfo;if(b===s)break;if(h===4)for(h=a.return;h!==null;){var w=h.tag;if((w===3||w===4)&&h.stateNode.containerInfo===s)return;h=h.return}for(;b!==null;){if(h=fn(b),h===null)return;if(w=h.tag,w===5||w===6||w===26||w===27){a=c=h;continue e}b=b.parentNode}}a=a.return}gs(function(){var z=c,B=vl(n),G=[];e:{var O=fd.get(e);if(O!==void 0){var U=La,ue=e;switch(e){case"keypress":if(X(n)===0)break e;case"keydown":case"keyup":U=mv;break;case"focusin":ue="focus",U=$u;break;case"focusout":ue="blur",U=$u;break;case"beforeblur":case"afterblur":U=$u;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":U=$o;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":U=nv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":U=yv;break;case cd:case rd:case od:U=iv;break;case dd:U=pv;break;case"scroll":case"scrollend":U=ev;break;case"wheel":U=jv;break;case"copy":case"cut":case"paste":U=uv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":U=Ko;break;case"toggle":case"beforetoggle":U=Nv}var he=(t&4)!==0,He=!he&&(e==="scroll"||e==="scrollend"),k=he?O!==null?O+"Capture":null:O;he=[];for(var E=z,M;E!==null;){var H=E;if(M=H.stateNode,H=H.tag,H!==5&&H!==26&&H!==27||M===null||k===null||(H=ct(E,k),H!=null&&he.push(Ui(E,H,M))),He)break;E=E.return}0<he.length&&(O=new U(O,ue,null,n,B),G.push({event:O,listeners:he}))}}if((t&7)===0){e:{if(O=e==="mouseover"||e==="pointerover",U=e==="mouseout"||e==="pointerout",O&&n!==ai&&(ue=n.relatedTarget||n.fromElement)&&(fn(ue)||ue[Zn]))break e;if((U||O)&&(O=B.window===B?B:(O=B.ownerDocument)?O.defaultView||O.parentWindow:window,U?(ue=n.relatedTarget||n.toElement,U=z,ue=ue?fn(ue):null,ue!==null&&(He=f(ue),he=ue.tag,ue!==He||he!==5&&he!==27&&he!==6)&&(ue=null)):(U=null,ue=z),U!==ue)){if(he=$o,H="onMouseLeave",k="onMouseEnter",E="mouse",(e==="pointerout"||e==="pointerover")&&(he=Ko,H="onPointerLeave",k="onPointerEnter",E="pointer"),He=U==null?O:qt(U),M=ue==null?O:qt(ue),O=new he(H,E+"leave",U,n,B),O.target=He,O.relatedTarget=M,H=null,fn(B)===z&&(he=new he(k,E+"enter",ue,n,B),he.target=M,he.relatedTarget=He,H=he),He=H,U&&ue)t:{for(he=Sy,k=U,E=ue,M=0,H=k;H;H=he(H))M++;H=0;for(var de=E;de;de=he(de))H++;for(;0<M-H;)k=he(k),M--;for(;0<H-M;)E=he(E),H--;for(;M--;){if(k===E||E!==null&&k===E.alternate){he=k;break t}k=he(k),E=he(E)}he=null}else he=null;U!==null&&Uh(G,O,U,he,!1),ue!==null&&He!==null&&Uh(G,He,ue,he,!0)}}e:{if(O=z?qt(z):window,U=O.nodeName&&O.nodeName.toLowerCase(),U==="select"||U==="input"&&O.type==="file")var ke=Wo;else if(Jo(O))if(Io)ke=Ov;else{ke=Rv;var ce=Mv}else U=O.nodeName,!U||U.toLowerCase()!=="input"||O.type!=="checkbox"&&O.type!=="radio"?z&&ni(z.elementType)&&(ke=Wo):ke=zv;if(ke&&(ke=ke(e,z))){Fo(G,ke,n,B);break e}ce&&ce(e,O,z),e==="focusout"&&z&&O.type==="number"&&z.memoizedProps.value!=null&&Ua(O,"number",O.value)}switch(ce=z?qt(z):window,e){case"focusin":(Jo(ce)||ce.contentEditable==="true")&&(bl=ce,Vu=z,oi=null);break;case"focusout":oi=Vu=bl=null;break;case"mousedown":Zu=!0;break;case"contextmenu":case"mouseup":case"dragend":Zu=!1,sd(G,n,B);break;case"selectionchange":if(Uv)break;case"keydown":case"keyup":sd(G,n,B)}var je;if(Ku)e:{switch(e){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else yl?Vo(e,n)&&(Te="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(Te="onCompositionStart");Te&&(Yo&&n.locale!=="ko"&&(yl||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&yl&&(je=$()):(ln=B,p="value"in ln?ln.value:ln.textContent,yl=!0)),ce=iu(z,Te),0<ce.length&&(Te=new Go(Te,e,null,n,B),G.push({event:Te,listeners:ce}),je?Te.data=je:(je=Zo(n),je!==null&&(Te.data=je)))),(je=Tv?Ev(e,n):Av(e,n))&&(Te=iu(z,"onBeforeInput"),0<Te.length&&(ce=new Go("onBeforeInput","beforeinput",null,n,B),G.push({event:ce,listeners:Te}),ce.data=je)),by(G,e,z,n,B)}Oh(G,t)})}function Ui(e,t,n){return{instance:e,listener:t,currentTarget:n}}function iu(e,t){for(var n=t+"Capture",a=[];e!==null;){var s=e,c=s.stateNode;if(s=s.tag,s!==5&&s!==26&&s!==27||c===null||(s=ct(e,n),s!=null&&a.unshift(Ui(e,s,c)),s=ct(e,t),s!=null&&a.push(Ui(e,s,c))),e.tag===3)return a;e=e.return}return[]}function Sy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Uh(e,t,n,a,s){for(var c=t._reactName,h=[];n!==null&&n!==a;){var b=n,w=b.alternate,z=b.stateNode;if(b=b.tag,w!==null&&w===a)break;b!==5&&b!==26&&b!==27||z===null||(w=z,s?(z=ct(n,c),z!=null&&h.unshift(Ui(n,z,w))):s||(z=ct(n,c),z!=null&&h.push(Ui(n,z,w)))),n=n.return}h.length!==0&&e.push({event:t,listeners:h})}var Ny=/\\r\\n?/g,wy=/\\u0000|\\uFFFD/g;function Dh(e){return(typeof e=="string"?e:""+e).replace(Ny,\`
17
+ \`).replace(wy,"")}function Bh(e,t){return t=Dh(t),Dh(e)===t}function Be(e,t,n,a,s,c){switch(n){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||Pn(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&Pn(e,""+a);break;case"className":Oa(e,"class",a);break;case"tabIndex":Oa(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Oa(e,n,a);break;case"style":hs(e,a,c);break;case"data":if(t!=="object"){Oa(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(n);break}a=Cn(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof c=="function"&&(n==="formAction"?(t!=="input"&&Be(e,t,"name",s.name,s,null),Be(e,t,"formEncType",s.formEncType,s,null),Be(e,t,"formMethod",s.formMethod,s,null),Be(e,t,"formTarget",s.formTarget,s,null)):(Be(e,t,"encType",s.encType,s,null),Be(e,t,"method",s.method,s,null),Be(e,t,"target",s.target,s,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(n);break}a=Cn(""+a),e.setAttribute(n,a);break;case"onClick":a!=null&&(e.onclick=Gt);break;case"onScroll":a!=null&&Ne("scroll",e);break;case"onScrollEnd":a!=null&&Ne("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(n=a.__html,n!=null){if(s.children!=null)throw Error(r(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}n=Cn(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,""+a):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":a===!0?e.setAttribute(n,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Ne("beforetoggle",e),Ne("toggle",e),za(e,"popover",a);break;case"xlinkActuate":en(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":en(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":en(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":en(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":en(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":en(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":en(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":en(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":en(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":za(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=$t.get(n)||n,za(e,n,a))}}function pr(e,t,n,a,s,c){switch(n){case"style":hs(e,a,c);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(n=a.__html,n!=null){if(s.children!=null)throw Error(r(60));e.innerHTML=n}}break;case"children":typeof a=="string"?Pn(e,a):(typeof a=="number"||typeof a=="bigint")&&Pn(e,""+a);break;case"onScroll":a!=null&&Ne("scroll",e);break;case"onScrollEnd":a!=null&&Ne("scrollend",e);break;case"onClick":a!=null&&(e.onclick=Gt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!cs.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(s=n.endsWith("Capture"),t=n.slice(2,s?n.length-7:void 0),c=e[vt]||null,c=c!=null?c[n]:null,typeof c=="function"&&e.removeEventListener(t,c,s),typeof a=="function")){typeof c!="function"&&c!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,s);break e}n in e?e[n]=a:a===!0?e.setAttribute(n,""):za(e,n,a)}}}function ft(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ne("error",e),Ne("load",e);var a=!1,s=!1,c;for(c in n)if(n.hasOwnProperty(c)){var h=n[c];if(h!=null)switch(c){case"src":a=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Be(e,t,c,h,n,null)}}s&&Be(e,t,"srcSet",n.srcSet,n,null),a&&Be(e,t,"src",n.src,n,null);return;case"input":Ne("invalid",e);var b=c=h=s=null,w=null,z=null;for(a in n)if(n.hasOwnProperty(a)){var B=n[a];if(B!=null)switch(a){case"name":s=B;break;case"type":h=B;break;case"checked":w=B;break;case"defaultChecked":z=B;break;case"value":c=B;break;case"defaultValue":b=B;break;case"children":case"dangerouslySetInnerHTML":if(B!=null)throw Error(r(137,t));break;default:Be(e,t,a,B,n,null)}}gl(e,c,b,w,z,h,s,!1);return;case"select":Ne("invalid",e),a=h=c=null;for(s in n)if(n.hasOwnProperty(s)&&(b=n[s],b!=null))switch(s){case"value":c=b;break;case"defaultValue":h=b;break;case"multiple":a=b;default:Be(e,t,s,b,n,null)}t=c,n=h,e.multiple=!!a,t!=null?$e(e,!!a,t,!1):n!=null&&$e(e,!!a,n,!0);return;case"textarea":Ne("invalid",e),c=s=a=null;for(h in n)if(n.hasOwnProperty(h)&&(b=n[h],b!=null))switch(h){case"value":a=b;break;case"defaultValue":s=b;break;case"children":c=b;break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(r(91));break;default:Be(e,t,h,b,n,null)}ti(e,a,s,c);return;case"option":for(w in n)n.hasOwnProperty(w)&&(a=n[w],a!=null)&&(w==="selected"?e.selected=a&&typeof a!="function"&&typeof a!="symbol":Be(e,t,w,a,n,null));return;case"dialog":Ne("beforetoggle",e),Ne("toggle",e),Ne("cancel",e),Ne("close",e);break;case"iframe":case"object":Ne("load",e);break;case"video":case"audio":for(a=0;a<_i.length;a++)Ne(_i[a],e);break;case"image":Ne("error",e),Ne("load",e);break;case"details":Ne("toggle",e);break;case"embed":case"source":case"link":Ne("error",e),Ne("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(z in n)if(n.hasOwnProperty(z)&&(a=n[z],a!=null))switch(z){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:Be(e,t,z,a,n,null)}return;default:if(ni(t)){for(B in n)n.hasOwnProperty(B)&&(a=n[B],a!==void 0&&pr(e,t,B,a,n,void 0));return}}for(b in n)n.hasOwnProperty(b)&&(a=n[b],a!=null&&Be(e,t,b,a,n,null))}function Ty(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var s=null,c=null,h=null,b=null,w=null,z=null,B=null;for(U in n){var G=n[U];if(n.hasOwnProperty(U)&&G!=null)switch(U){case"checked":break;case"value":break;case"defaultValue":w=G;default:a.hasOwnProperty(U)||Be(e,t,U,null,a,G)}}for(var O in a){var U=a[O];if(G=n[O],a.hasOwnProperty(O)&&(U!=null||G!=null))switch(O){case"type":c=U;break;case"name":s=U;break;case"checked":z=U;break;case"defaultChecked":B=U;break;case"value":h=U;break;case"defaultValue":b=U;break;case"children":case"dangerouslySetInnerHTML":if(U!=null)throw Error(r(137,t));break;default:U!==G&&Be(e,t,O,U,a,G)}}An(e,h,b,w,z,B,c,s);return;case"select":U=h=b=O=null;for(c in n)if(w=n[c],n.hasOwnProperty(c)&&w!=null)switch(c){case"value":break;case"multiple":U=w;default:a.hasOwnProperty(c)||Be(e,t,c,null,a,w)}for(s in a)if(c=a[s],w=n[s],a.hasOwnProperty(s)&&(c!=null||w!=null))switch(s){case"value":O=c;break;case"defaultValue":b=c;break;case"multiple":h=c;default:c!==w&&Be(e,t,s,c,a,w)}t=b,n=h,a=U,O!=null?$e(e,!!n,O,!1):!!a!=!!n&&(t!=null?$e(e,!!n,t,!0):$e(e,!!n,n?[]:"",!1));return;case"textarea":U=O=null;for(b in n)if(s=n[b],n.hasOwnProperty(b)&&s!=null&&!a.hasOwnProperty(b))switch(b){case"value":break;case"children":break;default:Be(e,t,b,null,a,s)}for(h in a)if(s=a[h],c=n[h],a.hasOwnProperty(h)&&(s!=null||c!=null))switch(h){case"value":O=s;break;case"defaultValue":U=s;break;case"children":break;case"dangerouslySetInnerHTML":if(s!=null)throw Error(r(91));break;default:s!==c&&Be(e,t,h,s,a,c)}tn(e,O,U);return;case"option":for(var ue in n)O=n[ue],n.hasOwnProperty(ue)&&O!=null&&!a.hasOwnProperty(ue)&&(ue==="selected"?e.selected=!1:Be(e,t,ue,null,a,O));for(w in a)O=a[w],U=n[w],a.hasOwnProperty(w)&&O!==U&&(O!=null||U!=null)&&(w==="selected"?e.selected=O&&typeof O!="function"&&typeof O!="symbol":Be(e,t,w,O,a,U));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var he in n)O=n[he],n.hasOwnProperty(he)&&O!=null&&!a.hasOwnProperty(he)&&Be(e,t,he,null,a,O);for(z in a)if(O=a[z],U=n[z],a.hasOwnProperty(z)&&O!==U&&(O!=null||U!=null))switch(z){case"children":case"dangerouslySetInnerHTML":if(O!=null)throw Error(r(137,t));break;default:Be(e,t,z,O,a,U)}return;default:if(ni(t)){for(var He in n)O=n[He],n.hasOwnProperty(He)&&O!==void 0&&!a.hasOwnProperty(He)&&pr(e,t,He,void 0,a,O);for(B in a)O=a[B],U=n[B],!a.hasOwnProperty(B)||O===U||O===void 0&&U===void 0||pr(e,t,B,O,a,U);return}}for(var k in n)O=n[k],n.hasOwnProperty(k)&&O!=null&&!a.hasOwnProperty(k)&&Be(e,t,k,null,a,O);for(G in a)O=a[G],U=n[G],!a.hasOwnProperty(G)||O===U||O==null&&U==null||Be(e,t,G,O,a,U)}function Hh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ey(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),a=0;a<n.length;a++){var s=n[a],c=s.transferSize,h=s.initiatorType,b=s.duration;if(c&&b&&Hh(h)){for(h=0,b=s.responseEnd,a+=1;a<n.length;a++){var w=n[a],z=w.startTime;if(z>b)break;var B=w.transferSize,G=w.initiatorType;B&&Hh(G)&&(w=w.responseEnd,h+=B*(w<b?1:(b-z)/(w-z)))}if(--a,t+=8*(c+h)/(s.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var xr=null,jr=null;function su(e){return e.nodeType===9?e:e.ownerDocument}function Lh(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function qh(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Sr(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Nr=null;function Ay(){var e=window.event;return e&&e.type==="popstate"?e===Nr?!1:(Nr=e,!0):(Nr=null,!1)}var $h=typeof setTimeout=="function"?setTimeout:void 0,Cy=typeof clearTimeout=="function"?clearTimeout:void 0,Gh=typeof Promise=="function"?Promise:void 0,ky=typeof queueMicrotask=="function"?queueMicrotask:typeof Gh<"u"?function(e){return Gh.resolve(null).then(e).catch(My)}:$h;function My(e){setTimeout(function(){throw e})}function ya(e){return e==="head"}function Kh(e,t){var n=t,a=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"||n==="/&"){if(a===0){e.removeChild(s),Ql(t);return}a--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")a++;else if(n==="html")Di(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Di(n);for(var c=n.firstChild;c;){var h=c.nextSibling,b=c.nodeName;c[Jn]||b==="SCRIPT"||b==="STYLE"||b==="LINK"&&c.rel.toLowerCase()==="stylesheet"||n.removeChild(c),c=h}}else n==="body"&&Di(e.ownerDocument.body);n=s}while(n);Ql(t)}function Yh(e,t){var n=e;e=0;do{var a=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=a}while(n)}function wr(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":wr(n),Nt(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function Ry(e,t,n,a){for(;e.nodeType===1;){var s=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(a){if(!e[Jn])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(c=e.getAttribute("rel"),c==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(c!==s.rel||e.getAttribute("href")!==(s.href==null||s.href===""?null:s.href)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin)||e.getAttribute("title")!==(s.title==null?null:s.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(c=e.getAttribute("src"),(c!==(s.src==null?null:s.src)||e.getAttribute("type")!==(s.type==null?null:s.type)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin))&&c&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var c=s.name==null?null:""+s.name;if(s.type==="hidden"&&e.getAttribute("name")===c)return e}else return e;if(e=Jt(e.nextSibling),e===null)break}return null}function zy(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Jt(e.nextSibling),e===null))return null;return e}function Qh(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Jt(e.nextSibling),e===null))return null;return e}function Tr(e){return e.data==="$?"||e.data==="$~"}function Er(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Oy(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var a=function(){t(),n.removeEventListener("DOMContentLoaded",a)};n.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}function Jt(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Ar=null;function Xh(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Jt(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function Vh(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function Zh(e,t,n){switch(t=su(n),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function Di(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var Ft=new Map,Jh=new Set;function uu(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Yn=te.d;te.d={f:_y,r:Uy,D:Dy,C:By,L:Hy,m:Ly,X:$y,S:qy,M:Gy};function _y(){var e=Yn.f(),t=Is();return e||t}function Uy(e){var t=xt(e);t!==null&&t.tag===5&&t.type==="form"?ff(t):Yn.r(e)}var Gl=typeof document>"u"?null:document;function Fh(e,t,n){var a=Gl;if(a&&typeof t=="string"&&t){var s=ut(t);s='link[rel="'+e+'"][href="'+s+'"]',typeof n=="string"&&(s+='[crossorigin="'+n+'"]'),Jh.has(s)||(Jh.add(s),e={rel:e,crossOrigin:n,href:t},a.querySelector(s)===null&&(t=a.createElement("link"),ft(t,"link",e),Qe(t),a.head.appendChild(t)))}}function Dy(e){Yn.D(e),Fh("dns-prefetch",e,null)}function By(e,t){Yn.C(e,t),Fh("preconnect",e,t)}function Hy(e,t,n){Yn.L(e,t,n);var a=Gl;if(a&&e&&t){var s='link[rel="preload"][as="'+ut(t)+'"]';t==="image"&&n&&n.imageSrcSet?(s+='[imagesrcset="'+ut(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(s+='[imagesizes="'+ut(n.imageSizes)+'"]')):s+='[href="'+ut(e)+'"]';var c=s;switch(t){case"style":c=Kl(e);break;case"script":c=Yl(e)}Ft.has(c)||(e=g({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Ft.set(c,e),a.querySelector(s)!==null||t==="style"&&a.querySelector(Bi(c))||t==="script"&&a.querySelector(Hi(c))||(t=a.createElement("link"),ft(t,"link",e),Qe(t),a.head.appendChild(t)))}}function Ly(e,t){Yn.m(e,t);var n=Gl;if(n&&e){var a=t&&typeof t.as=="string"?t.as:"script",s='link[rel="modulepreload"][as="'+ut(a)+'"][href="'+ut(e)+'"]',c=s;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":c=Yl(e)}if(!Ft.has(c)&&(e=g({rel:"modulepreload",href:e},t),Ft.set(c,e),n.querySelector(s)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Hi(c)))return}a=n.createElement("link"),ft(a,"link",e),Qe(a),n.head.appendChild(a)}}}function qy(e,t,n){Yn.S(e,t,n);var a=Gl;if(a&&e){var s=Pt(a).hoistableStyles,c=Kl(e);t=t||"default";var h=s.get(c);if(!h){var b={loading:0,preload:null};if(h=a.querySelector(Bi(c)))b.loading=5;else{e=g({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Ft.get(c))&&Cr(e,n);var w=h=a.createElement("link");Qe(w),ft(w,"link",e),w._p=new Promise(function(z,B){w.onload=z,w.onerror=B}),w.addEventListener("load",function(){b.loading|=1}),w.addEventListener("error",function(){b.loading|=2}),b.loading|=4,cu(h,t,a)}h={type:"stylesheet",instance:h,count:1,state:b},s.set(c,h)}}}function $y(e,t){Yn.X(e,t);var n=Gl;if(n&&e){var a=Pt(n).hoistableScripts,s=Yl(e),c=a.get(s);c||(c=n.querySelector(Hi(s)),c||(e=g({src:e,async:!0},t),(t=Ft.get(s))&&kr(e,t),c=n.createElement("script"),Qe(c),ft(c,"link",e),n.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},a.set(s,c))}}function Gy(e,t){Yn.M(e,t);var n=Gl;if(n&&e){var a=Pt(n).hoistableScripts,s=Yl(e),c=a.get(s);c||(c=n.querySelector(Hi(s)),c||(e=g({src:e,async:!0,type:"module"},t),(t=Ft.get(s))&&kr(e,t),c=n.createElement("script"),Qe(c),ft(c,"link",e),n.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},a.set(s,c))}}function Wh(e,t,n,a){var s=(s=be.current)?uu(s):null;if(!s)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Kl(n.href),n=Pt(s).hoistableStyles,a=n.get(t),a||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Kl(n.href);var c=Pt(s).hoistableStyles,h=c.get(e);if(h||(s=s.ownerDocument||s,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},c.set(e,h),(c=s.querySelector(Bi(e)))&&!c._p&&(h.instance=c,h.state.loading=5),Ft.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Ft.set(e,n),c||Ky(s,e,n,h.state))),t&&a===null)throw Error(r(528,""));return h}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Yl(n),n=Pt(s).hoistableScripts,a=n.get(t),a||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Kl(e){return'href="'+ut(e)+'"'}function Bi(e){return'link[rel="stylesheet"]['+e+"]"}function Ih(e){return g({},e,{"data-precedence":e.precedence,precedence:null})}function Ky(e,t,n,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),ft(t,"link",n),Qe(t),e.head.appendChild(t))}function Yl(e){return'[src="'+ut(e)+'"]'}function Hi(e){return"script[async]"+e}function Ph(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+ut(n.href)+'"]');if(a)return t.instance=a,Qe(a),a;var s=g({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Qe(a),ft(a,"style",s),cu(a,n.precedence,e),t.instance=a;case"stylesheet":s=Kl(n.href);var c=e.querySelector(Bi(s));if(c)return t.state.loading|=4,t.instance=c,Qe(c),c;a=Ih(n),(s=Ft.get(s))&&Cr(a,s),c=(e.ownerDocument||e).createElement("link"),Qe(c);var h=c;return h._p=new Promise(function(b,w){h.onload=b,h.onerror=w}),ft(c,"link",a),t.state.loading|=4,cu(c,n.precedence,e),t.instance=c;case"script":return c=Yl(n.src),(s=e.querySelector(Hi(c)))?(t.instance=s,Qe(s),s):(a=n,(s=Ft.get(c))&&(a=g({},n),kr(a,s)),e=e.ownerDocument||e,s=e.createElement("script"),Qe(s),ft(s,"link",a),e.head.appendChild(s),t.instance=s);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,cu(a,n.precedence,e));return t.instance}function cu(e,t,n){for(var a=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),s=a.length?a[a.length-1]:null,c=s,h=0;h<a.length;h++){var b=a[h];if(b.dataset.precedence===t)c=b;else if(c!==s)break}c?c.parentNode.insertBefore(e,c.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Cr(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function kr(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ru=null;function em(e,t,n){if(ru===null){var a=new Map,s=ru=new Map;s.set(n,a)}else s=ru,a=s.get(n),a||(a=new Map,s.set(n,a));if(a.has(e))return a;for(a.set(e,null),n=n.getElementsByTagName(e),s=0;s<n.length;s++){var c=n[s];if(!(c[Jn]||c[qe]||e==="link"&&c.getAttribute("rel")==="stylesheet")&&c.namespaceURI!=="http://www.w3.org/2000/svg"){var h=c.getAttribute(t)||"";h=e+h;var b=a.get(h);b?b.push(c):a.set(h,[c])}}return a}function tm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Yy(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function nm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Qy(e,t,n,a){if(n.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var s=Kl(a.href),c=t.querySelector(Bi(s));if(c){t=c._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ou.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=c,Qe(c);return}c=t.ownerDocument||t,a=Ih(a),(s=Ft.get(s))&&Cr(a,s),c=c.createElement("link"),Qe(c);var h=c;h._p=new Promise(function(b,w){h.onload=b,h.onerror=w}),ft(c,"link",a),n.instance=c}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=ou.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var Mr=0;function Xy(e,t){return e.stylesheets&&e.count===0&&fu(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var a=setTimeout(function(){if(e.stylesheets&&fu(e,e.stylesheets),e.unsuspend){var c=e.unsuspend;e.unsuspend=null,c()}},6e4+t);0<e.imgBytes&&Mr===0&&(Mr=62500*Ey());var s=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&fu(e,e.stylesheets),e.unsuspend)){var c=e.unsuspend;e.unsuspend=null,c()}},(e.imgBytes>Mr?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(s)}}:null}function ou(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var du=null;function fu(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,du=new Map,t.forEach(Vy,e),du=null,ou.call(e))}function Vy(e,t){if(!(t.state.loading&4)){var n=du.get(e);if(n)var a=n.get(null);else{n=new Map,du.set(e,n);for(var s=e.querySelectorAll("link[data-precedence],style[data-precedence]"),c=0;c<s.length;c++){var h=s[c];(h.nodeName==="LINK"||h.getAttribute("media")!=="not all")&&(n.set(h.dataset.precedence,h),a=h)}a&&n.set(null,a)}s=t.instance,h=s.getAttribute("data-precedence"),c=n.get(h)||a,c===a&&n.set(null,s),n.set(h,s),this.count++,a=ou.bind(this),s.addEventListener("load",a),s.addEventListener("error",a),c?c.parentNode.insertBefore(s,c.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(s,e.firstChild)),t.state.loading|=4}}var Li={$$typeof:F,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function Zy(e,t,n,a,s,c,h,b,w){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ka(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ka(0),this.hiddenUpdates=ka(null),this.identifierPrefix=a,this.onUncaughtError=s,this.onCaughtError=c,this.onRecoverableError=h,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=w,this.incompleteTransitions=new Map}function am(e,t,n,a,s,c,h,b,w,z,B,G){return e=new Zy(e,t,n,h,w,z,B,G,b),t=1,c===!0&&(t|=24),c=zt(3,null,null,t),e.current=c,c.stateNode=e,t=rc(),t.refCount++,e.pooledCache=t,t.refCount++,c.memoizedState={element:a,isDehydrated:n,cache:t},hc(c),e}function lm(e){return e?(e=jl,e):jl}function im(e,t,n,a,s,c){s=lm(s),a.context===null?a.context=s:a.pendingContext=s,a=sa(t),a.payload={element:n},c=c===void 0?null:c,c!==null&&(a.callback=c),n=ua(e,a,t),n!==null&&(Ct(n,e,t),yi(n,e,t))}function sm(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rr(e,t){sm(e,t),(e=e.alternate)&&sm(e,t)}function um(e){if(e.tag===13||e.tag===31){var t=Ga(e,67108864);t!==null&&Ct(t,e,67108864),Rr(e,67108864)}}function cm(e){if(e.tag===13||e.tag===31){var t=Bt();t=hl(t);var n=Ga(e,t);n!==null&&Ct(n,e,t),Rr(e,t)}}var hu=!0;function Jy(e,t,n,a){var s=D.T;D.T=null;var c=te.p;try{te.p=2,zr(e,t,n,a)}finally{te.p=c,D.T=s}}function Fy(e,t,n,a){var s=D.T;D.T=null;var c=te.p;try{te.p=8,zr(e,t,n,a)}finally{te.p=c,D.T=s}}function zr(e,t,n,a){if(hu){var s=Or(a);if(s===null)br(e,t,a,mu,n),om(e,a);else if(Iy(s,e,t,n,a))a.stopPropagation();else if(om(e,a),t&4&&-1<Wy.indexOf(e)){for(;s!==null;){var c=xt(s);if(c!==null)switch(c.tag){case 3:if(c=c.stateNode,c.current.memoizedState.isDehydrated){var h=It(c.pendingLanes);if(h!==0){var b=c;for(b.pendingLanes|=2,b.entangledLanes|=2;h;){var w=1<<31-gt(h);b.entanglements[1]|=w,h&=~w}yn(c),(Re&6)===0&&(Fs=mt()+500,Oi(0))}}break;case 31:case 13:b=Ga(c,2),b!==null&&Ct(b,c,2),Is(),Rr(c,2)}if(c=Or(a),c===null&&br(e,t,a,mu,n),c===s)break;s=c}s!==null&&a.stopPropagation()}else br(e,t,a,null,n)}}function Or(e){return e=vl(e),_r(e)}var mu=null;function _r(e){if(mu=null,e=fn(e),e!==null){var t=f(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=m(t),e!==null)return e;e=null}else if(n===31){if(e=v(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return mu=e,null}function rm(e){switch(e){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Pi()){case Zl:return 2;case Jl:return 8;case jn:case es:return 32;case Fl:return 268435456;default:return 32}default:return 32}}var Ur=!1,ba=null,pa=null,xa=null,qi=new Map,$i=new Map,ja=[],Wy="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".split(" ");function om(e,t){switch(e){case"focusin":case"focusout":ba=null;break;case"dragenter":case"dragleave":pa=null;break;case"mouseover":case"mouseout":xa=null;break;case"pointerover":case"pointerout":qi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":$i.delete(t.pointerId)}}function Gi(e,t,n,a,s,c){return e===null||e.nativeEvent!==c?(e={blockedOn:t,domEventName:n,eventSystemFlags:a,nativeEvent:c,targetContainers:[s]},t!==null&&(t=xt(t),t!==null&&um(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function Iy(e,t,n,a,s){switch(t){case"focusin":return ba=Gi(ba,e,t,n,a,s),!0;case"dragenter":return pa=Gi(pa,e,t,n,a,s),!0;case"mouseover":return xa=Gi(xa,e,t,n,a,s),!0;case"pointerover":var c=s.pointerId;return qi.set(c,Gi(qi.get(c)||null,e,t,n,a,s)),!0;case"gotpointercapture":return c=s.pointerId,$i.set(c,Gi($i.get(c)||null,e,t,n,a,s)),!0}return!1}function dm(e){var t=fn(e.target);if(t!==null){var n=f(t);if(n!==null){if(t=n.tag,t===13){if(t=m(n),t!==null){e.blockedOn=t,ss(e.priority,function(){cm(n)});return}}else if(t===31){if(t=v(n),t!==null){e.blockedOn=t,ss(e.priority,function(){cm(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function gu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Or(e.nativeEvent);if(n===null){n=e.nativeEvent;var a=new n.constructor(n.type,n);ai=a,n.target.dispatchEvent(a),ai=null}else return t=xt(n),t!==null&&um(t),e.blockedOn=n,!1;t.shift()}return!0}function fm(e,t,n){gu(e)&&n.delete(t)}function Py(){Ur=!1,ba!==null&&gu(ba)&&(ba=null),pa!==null&&gu(pa)&&(pa=null),xa!==null&&gu(xa)&&(xa=null),qi.forEach(fm),$i.forEach(fm)}function vu(e,t){e.blockedOn===t&&(e.blockedOn=null,Ur||(Ur=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,Py)))}var yu=null;function hm(e){yu!==e&&(yu=e,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){yu===e&&(yu=null);for(var t=0;t<e.length;t+=3){var n=e[t],a=e[t+1],s=e[t+2];if(typeof a!="function"){if(_r(a||n)===null)continue;break}var c=xt(n);c!==null&&(e.splice(t,3),t-=3,Oc(c,{pending:!0,data:s,method:n.method,action:a},a,s))}}))}function Ql(e){function t(w){return vu(w,e)}ba!==null&&vu(ba,e),pa!==null&&vu(pa,e),xa!==null&&vu(xa,e),qi.forEach(t),$i.forEach(t);for(var n=0;n<ja.length;n++){var a=ja[n];a.blockedOn===e&&(a.blockedOn=null)}for(;0<ja.length&&(n=ja[0],n.blockedOn===null);)dm(n),n.blockedOn===null&&ja.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(a=0;a<n.length;a+=3){var s=n[a],c=n[a+1],h=s[vt]||null;if(typeof c=="function")h||hm(n);else if(h){var b=null;if(c&&c.hasAttribute("formAction")){if(s=c,h=c[vt]||null)b=h.formAction;else if(_r(s)!==null)continue}else b=h.action;typeof b=="function"?n[a+1]=b:(n.splice(a,3),a-=3),hm(n)}}}function mm(){function e(c){c.canIntercept&&c.info==="react-transition"&&c.intercept({handler:function(){return new Promise(function(h){return s=h})},focusReset:"manual",scroll:"manual"})}function t(){s!==null&&(s(),s=null),a||setTimeout(n,20)}function n(){if(!a&&!navigation.transition){var c=navigation.currentEntry;c&&c.url!=null&&navigation.navigate(c.url,{state:c.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var a=!1,s=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){a=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),s!==null&&(s(),s=null)}}}function Dr(e){this._internalRoot=e}bu.prototype.render=Dr.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var n=t.current,a=Bt();im(n,a,e,t,null,null)},bu.prototype.unmount=Dr.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;im(e.current,2,null,e,null,null),Is(),t[Zn]=null}};function bu(e){this._internalRoot=e}bu.prototype.unstable_scheduleHydration=function(e){if(e){var t=Pl();e={blockedOn:null,target:e,priority:t};for(var n=0;n<ja.length&&t!==0&&t<ja[n].priority;n++);ja.splice(n,0,e),n===0&&dm(e)}};var gm=u.version;if(gm!=="19.2.8")throw Error(r(527,gm,"19.2.8"));te.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=y(t),e=e!==null?j(e):null,e=e===null?null:e.stateNode,e};var e0={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var pu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!pu.isDisabled&&pu.supportsFiber)try{Sn=pu.inject(e0),bt=pu}catch{}}return Yi.createRoot=function(e,t){if(!d(e))throw Error(r(299));var n=!1,a="",s=Sf,c=Nf,h=wf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(s=t.onUncaughtError),t.onCaughtError!==void 0&&(c=t.onCaughtError),t.onRecoverableError!==void 0&&(h=t.onRecoverableError)),t=am(e,1,!1,null,null,n,a,null,s,c,h,mm),e[Zn]=t.current,yr(e),new Dr(t)},Yi.hydrateRoot=function(e,t,n){if(!d(e))throw Error(r(299));var a=!1,s="",c=Sf,h=Nf,b=wf,w=null;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onUncaughtError!==void 0&&(c=n.onUncaughtError),n.onCaughtError!==void 0&&(h=n.onCaughtError),n.onRecoverableError!==void 0&&(b=n.onRecoverableError),n.formState!==void 0&&(w=n.formState)),t=am(e,1,!0,t,n??null,a,s,w,c,h,b,mm),t.context=lm(null),n=t.current,a=Bt(),a=hl(a),s=sa(a),s.callback=null,ua(n,s,a),n=a,t.current.lanes=n,Ma(t,n),yn(t),e[Zn]=t.current,yr(e),new bu(t)},Yi.version="19.2.8",Yi}var Tm;function d0(){if(Tm)return Lr.exports;Tm=1;function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(u){console.error(u)}}return l(),Lr.exports=o0(),Lr.exports}var f0=d0(),h0={},m0="dispach",g0="Dispach",v0=1;function Tg(l,u){return{slug:l,name:u,envPrefix:\`\${l.toUpperCase()}_\`,stateDir:\`.\${l}\`,apiVersion:\`\${l}/v\${v0}\`,packageScope:\`@\${l}\`}}var tt=Tg(m0,g0),Tu=\`\${tt.envPrefix}BRAND\`,y0=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function b0(l){return l.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(" ")}function p0(l){if(l===void 0)return tt;const u=l.trim();if(u==="")throw new Error(\`\${Tu} is set but empty. hint: unset \${Tu} entirely to use the default brand — an empty value is treated as a mistake rather than as "no override", because a declared-but-unset variable is usually a container passing through a name it never assigned.\`);if(!y0.test(u))throw new Error(\`\${Tu}="\${u}" is not a usable brand slug. hint: the slug becomes an env var prefix, a dot-directory, an npm scope, and the manifest apiVersion, so it must be lowercase alphanumeric with inner hyphens — e.g. acme or acme-run.\`);return u===tt.slug?tt:Tg(u,b0(u))}p0(h0[Tu]);var Eg=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.reloaded","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","peer.ask","peer.answer","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","phase.changed","model.call","model.chunk","model.retry","model.fallback","model.result","media.result","tool.usage","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","conversation.message","conversation.skipped","action.deferred","action.decided","agent.assigned","memory.read","memory.recalled","memory.forgotten","turn.end","error"],x0=/\\r\\n\\r\\n|\\n\\n|\\r\\r/;function Em(l){const u=[];let o,r,d;for(const f of l.split(/\\r\\n|\\n|\\r/)){if(f===""||f.startsWith(":"))continue;const m=f.indexOf(":"),v=m===-1?f:f.slice(0,m);let x=m===-1?"":f.slice(m+1);switch(x.startsWith(" ")&&(x=x.slice(1)),v){case"data":u.push(x);break;case"event":o=x;break;case"id":r=x;break;case"retry":{const y=Number.parseInt(x,10);Number.isFinite(y)&&(d=y);break}}}if(!(u.length===0&&o===void 0))return{...o===void 0?{}:{event:o},data:u.join(\`
18
+ \`),...r===void 0?{}:{id:r},...d===void 0?{}:{retry:d}}}async function*j0(l){const u=new TextDecoder;let o="";for await(const r of l)for(o+=typeof r=="string"?r:u.decode(r,{stream:!0});;){const d=x0.exec(o);if(d===null)break;const f=o.slice(0,d.index);o=o.slice(d.index+d[0].length);const m=Em(f);m!==void 0&&(yield m)}if(o+=u.decode(),o.trim()!==""){const r=Em(o);r!==void 0&&(yield r)}}function Ag(){return{push:l=>l,endStep:()=>"",end:()=>""}}function S0(l){return l!=="final"&&l!=="stopped"}function N0(l,u={}){switch(l){case"final":return;case"max_steps":return\`stopped\${u.steps===void 0?"":\` after \${u.steps} steps\`} without finishing — say "continue" to carry on, or raise limits.maxSteps\`;case"no_progress":return'stopped: the same tool call was repeated with no change — say "continue" with more to go on, or check whether that tool is telling it anything useful';case"truncated":return"the reply was cut off at the output limit — raise model.<role>.maxTokens, or ask for less";case"timeout":return\`timed out\${u.durationMs===void 0?"":\` after \${u.durationMs} ms\`} — raise limits.turnTimeoutMs\`;case"stopped":return u.cancelledAfterMs===void 0?"cancelled":\`cancelled after \${u.cancelledAfterMs.toFixed(0)} ms\`;case"error":return}}var w0="submit_artifact",T0="<<<",E0=">>>",Wi=/^\\s*(?:(?:[-*+]|\\d+[.)])\\s+)?(?:<\\s*)?action\\s*:(.+)$/i,A0=/^\\s*(?:[-*+]\\s+|\\d+[.)]\\s+)?([A-Za-z_][\\w.-]*?)\\s*:(.*)$/,Co=/^\\s*\`{3,}\\s*(?:[\\w+-]+\\s*)?$/,Kr=/^\\s*end\\s*$/i,C0=/^\\s*<\\s*action\\s*>\\s*$/i,Am=/^\\s*<\\s*\\/\\s*action\\s*>\\s*$/i,k0=/^\\s*<\\/?\\s*[A-Za-z_][\\w.:-]*\\s*(?:\\/\\s*)?>\\s*$/;function Cm(l){const u=(l??"").trim();return u.endsWith(">")?u.slice(0,-1).trimEnd():u}function Yr(l){return km(km(M0(l,"\`'\\"*<"),"\`'\\"*>"),".,;:").trim()}function M0(l,u){let o=0;for(;o<l.length&&u.includes(l[o]??"");)o+=1;return l.slice(o)}function km(l,u){let o=l.length;for(;o>0&&u.includes(l[o-1]??"");)o-=1;return l.slice(0,o)}function Cg(l,u,o){const r=l.fields.get(u);r===void 0?l.fields.set(u,[o]):r.push(o)}function kg(l){if(l.block===void 0||l.heredocKey===void 0)return;const u=[...l.heredocLines];u[u.length-1]===""&&u.pop(),Cg(l.block,l.heredocKey,u.join(\`
19
+ \`)),l.block.wrapped.add(l.heredocKey),l.heredocKey=void 0,l.heredocLines=[]}function tl(l){kg(l),l.block!==void 0&&l.blocks.push(l.block),l.block=void 0,l.openKey=void 0,l.awaitingSlug=!1}function Mm(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function R0(l,u,o){const r=u.trim();if(l.heredocKey!==void 0){if(r===E0){kg(l);return}if(Kr.test(r)){tl(l),l.justClosed=!0;return}if(Wi.test(u)){tl(l);const m=Wi.exec(u),v=Yr(Cm(m?.[1]));v!==""&&(l.block={slug:v,fields:new Map,wrapped:new Set,severed:new Set});return}l.heredocLines.push(u);return}const d=Wi.exec(u);if(d!==null){const m=Yr(Cm(d[1]));if(tl(l),m==="")return;l.block={slug:m,fields:new Map,wrapped:new Set,severed:new Set};return}if(C0.test(u)){tl(l),l.awaitingSlug=!0;return}if(l.awaitingSlug){if(r==="")return;if(Am.test(u)){l.awaitingSlug=!1;return}const m=Yr(r);l.awaitingSlug=!1,m!==""&&(l.block={slug:m,fields:new Map,wrapped:new Set,severed:new Set});return}if(Am.test(u)){l.block!==void 0&&(tl(l),l.justClosed=!0);return}if(k0.test(u))return;if(l.block===void 0){if(Co.test(u)&&(l.justClosed||o())){l.justClosed=!1;return}if(Kr.test(r)&&l.severedPending!==void 0){l.severedPending.block.severed.add(l.severedPending.key),l.severedPending=void 0;return}Wi.test(u)&&(l.severedPending=void 0),l.text.push(u),r!==""&&(l.justClosed=!1);return}if(r===""){l.openKey!==void 0&&(l.severedKey=l.openKey),l.openKey=void 0;return}if(Kr.test(r)){l.severedKey=void 0,tl(l),l.justClosed=!0;return}if(Co.test(u))return;const f=A0.exec(u);if(f!==null){const m=(f[1]??"").trim(),v=(f[2]??"").trim();l.severedKey=void 0,v===T0?(l.heredocKey=m,l.heredocLines=[],l.openKey=void 0):(Cg(l.block,m,v),l.openKey=m);return}if(l.openKey!==void 0){const m=l.block.fields.get(l.openKey),v=m?.[m.length-1];m!==void 0&&v!==void 0&&(m[m.length-1]=v===""?r:\`\${v}
20
+ \${r}\`);return}l.severedKey!==void 0&&(l.severedPending={block:l.block,key:l.severedKey},l.severedKey=void 0),tl(l),l.text.push(u)}function z0(l){if(/^\\s*(?:(?:[-*+]|\\d+[.)]?)\\s*)?$/.test(l))return!0;const u=l.replace(/^\\s*(?:[-*+]\\s+|\\d+[.)]\\s+)?/,"").toLowerCase(),o=u.startsWith("<")?u.slice(1):u;return"action:".startsWith(o)||o.startsWith("action:")||/^<\\/?$/.test(u)||/^<\\/?[a-z_][\\w.:-]*>?$/.test(u)?!0:/^\`{1,3}[\\w+-]*$/.test(u)}function Qr(l){return l.endsWith("\\r")?l.slice(0,-1):l}function O0(){let l=Mm(),u="",o=0,r,d="",f=!1;const m=g=>{if(g==="")return"";if(g.trim()==="")return d+=g,"";const S=d+g;return d="",f?S:(f=!0,S.replace(/^\\s+/,""))},v=(g,S)=>{const N=l.text.length;return R0(l,g,()=>S!==void 0&&Wi.test(S)),l.text.length>N?g:void 0},x=(g,S,N)=>{const R=v(g,S);return R===void 0?"":m(R.slice(N))+m(\`
21
+ \`)},y=g=>{if(r===void 0)return"";const S=r;return r=void 0,x(S,g,0)};return{push(g){let S="";u+=g;let N=u.indexOf(\`
22
+ \`);for(;N!==-1;){const L=Qr(u.slice(0,N));u=u.slice(N+1),S+=y(L),l.block===void 0&&Co.test(L)&&!l.justClosed?r=L:S+=x(L,void 0,o),o=0,N=u.indexOf(\`
23
+ \`)}const R=Qr(u);return l.block===void 0&&!l.awaitingSlug&&r===void 0&&!z0(R)&&(S+=m(R.slice(o)),o=R.length),S},endStep(){const g=j();return d=\`
24
+
25
+ \`,l=Mm(),g},end:j};function j(){let g=y(void 0);const S=Qr(u);if(S!==""){const N=v(S,void 0);N!==void 0&&(g+=m(N.slice(o)))}return u="",o=0,r=void 0,g}}function _0(l){return l.startsWith("subagent:")||l.startsWith("handoff:")}class xn extends Error{code;hint;field;details;status;request;constructor(u,o={}){super([u.message,...(u.details??[]).map(r=>\` - \${r.field===void 0?"":\`\${r.field}: \`}\${r.message}\`),...u.hint===void 0?[]:[\` hint: \${u.hint}\`]].join(\`
26
+ \`)),this.name="DispachError",this.code=u.code,this.hint=u.hint??"",this.field=u.field,this.details=u.details??[],this.status=o.status,this.request=o.method===void 0||o.path===void 0?void 0:{method:o.method,path:o.path},o.cause!==void 0&&(this.cause=o.cause)}}function U0(l,u){const o=l instanceof Error?l.message:String(l);return new xn({code:"transport_failed",message:\`\${u.method} \${u.path} did not reach \${u.baseUrl}: \${o}\`,hint:"Check the base URL, that the server is running, and that nothing between you and it is refusing the connection. \`GET /v1/health\` needs no token and is the cheapest probe."},{...u,cause:l})}async function D0(l,u){let o;try{const r=await l.json();typeof r.error?.code=="string"&&typeof r.error.message=="string"&&(o={code:r.error.code,message:r.error.message,...r.error.hint===void 0?{}:{hint:r.error.hint},...r.error.field===void 0?{}:{field:r.error.field}})}catch{}return new xn(o??{code:\`http_\${l.status}\`,message:\`\${u.method} \${u.path} returned \${l.status} with no error body.\`,hint:"This is not a response this server produces, so something between you and it answered — a proxy, a gateway, or a load balancer. Check the URL and what is in front of it."},{status:l.status,...u})}var Mg=new Set(Eg);async function*Rg(l){for await(const u of j0(B0(l))){if(u.event===void 0||u.data==="")continue;let o;try{o=JSON.parse(u.data)}catch{continue}yield{name:u.event,data:o}}}async function*B0(l){const u=l.getReader();try{for(;;){const{done:o,value:r}=await u.read();if(o)return;r!==void 0&&(yield r)}}finally{u.releaseLock()}}async function*H0(l){for await(const{name:u,data:o}of Rg(l)){if(Mg.has(u)){yield{kind:"event",event:o};continue}const r=o??{};switch(u){case"turn.accepted":yield{kind:"accepted",turnId:String(r.turnId??""),sessionKey:String(r.sessionKey??"")};break;case"stream.replay":yield{kind:"replay",report:{state:r.state==="ended"?"ended":"running",events:Number(r.events??0),truncated:r.truncated===!0,dropped:Number(r.dropped??0),chunks:r.chunks==="start"||r.chunks==="partial"?r.chunks:"none"}};break;case"stream.ended":yield{kind:"ended",turnId:String(r.turnId??""),status:String(r.status??"unknown"),steps:typeof r.steps=="number"?r.steps:void 0,errorCode:typeof r.errorCode=="string"?r.errorCode:void 0};break;case"stream.unavailable":yield{kind:"unavailable",turnId:String(r.turnId??""),reason:String(r.reason??"not observable from this process")};break}}}async function*L0(l){for await(const{name:u,data:o}of Rg(l)){if(Mg.has(u)){yield{kind:"event",event:o};continue}if(u==="stream.subscribed"){const r=o??{};yield{kind:"subscribed",report:{agentId:typeof r.agentId=="string"?r.agentId:null,types:Array.isArray(r.types)?r.types:null,chunks:r.chunks===!0,implied:typeof r.implied=="string"?r.implied:void 0}}}}}async function*q0(l,u={}){for await(const o of l){if(o.kind==="replay"&&o.report.truncated&&u.allowTruncated!==!0)throw new xn({code:"replay_truncated",message:\`This turn's replay is missing its oldest \${o.report.dropped} event(s), so the text reconstructed from it would be incomplete.\`,hint:"Read the finished text from GET /v1/agents/:id/turns/:turnId, or pass { allowTruncated: true } to accept a fragment. Streaming from the start of a turn is never truncated — this only happens when reattaching to one that has already produced more events than the buffer holds."});if(o.kind==="unavailable")throw new xn({code:"turn_not_observable",message:\`Turn \${o.turnId} is recorded as running but is not observable here: \${o.reason}.\`,hint:"Its events are buffered in whichever process is executing it. Poll GET /v1/agents/:id/turns/:turnId for the outcome."});if(o.kind!=="event"||o.event.type!=="model.chunk")continue;const r=o.event.data;r.kind!=="reasoning"&&typeof r.delta=="string"&&(yield r.delta)}}function $0(l){let u=l.baseUrl.length;for(;u>0&&l.baseUrl[u-1]==="/";)u-=1;const o=l.baseUrl.slice(0,u),r=l.fetch??fetch,d=(j={})=>({...l.token===void 0?{}:{authorization:\`Bearer \${l.token}\`},...j});async function f(j,g,S={}){let N;try{N=await r(\`\${o}\${g}\`,{method:j,headers:d({...S.body===void 0?{}:{"content-type":"application/json"},...S.accept===void 0?{}:{accept:S.accept},...S.headers}),...S.body===void 0?{}:{body:JSON.stringify(S.body)},...S.signal===void 0?{}:{signal:S.signal}})}catch(R){throw U0(R,{method:j,path:g,baseUrl:o})}if(!N.ok)throw await D0(N,{method:j,path:g});return N}async function m(j,g,S){return await(await f(j,g,S??{})).json()}async function v(j,g){const S=await f("GET",j,{accept:"text/event-stream",...g===void 0?{}:{signal:g}});if(S.body===null)throw new xn({code:"no_response_body",message:\`GET \${j} returned \${S.status} with no body to read.\`,hint:"An SSE route always has a body. A missing one means something between you and the server buffered the response — commonly a proxy without streaming enabled."},{status:S.status,method:"GET",path:j});return S.body}function x(j,g,S,N={}){const R=P=>{const J=new URLSearchParams;P?.chunks===!0&&J.set("chunks","true"),P?.children===!0&&J.set("children","true");const Z=J.toString();return Z===""?"":\`?\${Z}\`},L={turnId:g,sessionKey:S,replayed:N.replayed===!0,async*stream(P){const J=await v(\`/v1/agents/\${encodeURIComponent(j)}/turns/\${encodeURIComponent(g)}/stream\${R(P)}\`,P?.signal);yield*H0(J)},async*tokens(P){yield*q0(L.stream({chunks:!0,...P,children:!1}),{...P?.allowTruncated===void 0?{}:{allowTruncated:P.allowTruncated}})},async text(){for await(const P of L.stream())if(P.kind==="ended"||P.kind==="unavailable"||P.kind==="event"&&P.event.type==="turn.end")break;return(await L.get()).text},get:()=>m("GET",\`/v1/agents/\${encodeURIComponent(j)}/turns/\${encodeURIComponent(g)}\`),async stop(){await f("POST",\`/v1/agents/\${encodeURIComponent(j)}/turns/\${encodeURIComponent(g)}/stop\`)}};return L}function y(j){const g=S=>\`/v1/agents/\${encodeURIComponent(j)}\${S}\`;return{id:j,async send(S,N){const R=await m("POST",g("/messages"),{body:{text:S,...N?.sessionKey===void 0?{}:{sessionKey:N.sessionKey},...N?.deliver===void 0?{}:{deliver:N.deliver},...N?.from===void 0?{}:{from:N.from},...N?.images===void 0?{}:{images:N.images},...N?.runtimeNote===void 0?{}:{runtimeNote:N.runtimeNote},...N?.chunks===!0?{chunks:!0}:{},...N?.role===void 0?{}:{role:N.role}},...N?.idempotencyKey===void 0?{}:{headers:{"idempotency-key":N.idempotencyKey}},...N?.signal===void 0?{}:{signal:N.signal}});return x(j,R.turnId,R.sessionKey,{replayed:R.replayed===!0})},turn:S=>x(j,S,""),describe:()=>m("GET",g("")),tools:()=>m("GET",g("/tools")),skills:()=>m("GET",g("/skills")),sessions:()=>m("GET",g("/sessions")),messages:(S,N)=>{const R=new URLSearchParams;N?.before!==void 0&&R.set("before",String(N.before)),N?.limit!==void 0&&R.set("limit",String(N.limit));const L=R.size===0?"":\`?\${R.toString()}\`;return m("GET",g(\`/sessions/\${encodeURIComponent(S)}/messages\${L}\`))},clearSession:S=>m("DELETE",g(\`/sessions/\${encodeURIComponent(S)}\`)),reload:()=>m("POST",g("/reload"),{body:{}}),usage:S=>m("GET",g(\`/usage\${Rm(S)}\`)),turns:S=>{const N=new URLSearchParams;S?.limit!==void 0&&N.set("limit",String(S.limit)),S?.before!==void 0&&N.set("before",String(S.before));const R=N.size===0?"":\`?\${N.toString()}\`;return m("GET",g(\`/turns\${R}\`))},secrets:async()=>(await m("GET",g("/secrets"))).secrets,setSecrets:S=>m("PUT",g("/secrets"),{body:{values:S}}),schedules:async()=>(await m("GET",g("/schedules"))).schedules,approvals:async()=>(await m("GET",g("/approvals"))).approvals,createSchedule:S=>m("POST",g("/schedules"),{body:S}),updateSchedule:(S,N)=>m("PATCH",g(\`/schedules/\${encodeURIComponent(S)}\`),{body:N}),deleteSchedule:async S=>{await m("DELETE",g(\`/schedules/\${encodeURIComponent(S)}\`))},refreshTools:S=>m("POST",g("/tools/refresh"),{body:S?.providers===void 0?{}:{providers:S.providers}}),previewSchedule:S=>{const N=new URLSearchParams({kind:S.kind,expr:S.expr});return S.timezone!==void 0&&N.set("timezone",S.timezone),S.count!==void 0&&N.set("count",String(S.count)),m("GET",g(\`/schedules/preview?\${N.toString()}\`))},runSchedule:S=>m("POST",g(\`/schedules/\${encodeURIComponent(S)}/run\`),{body:{}}),config:()=>m("GET",g("/config")),setConfig:(S,N,R)=>m("PATCH",g("/config"),{body:{path:S,value:N,...R?.confirm===void 0?{}:{confirm:R.confirm}}}),removeConfig:(S,N)=>m("PATCH",g("/config"),{body:{path:S,remove:!0,...N?.confirm===void 0?{}:{confirm:N.confirm}}}),setConfigs:S=>m("PATCH",g("/config"),{body:{changes:S.map(N=>({...N}))}}),setChannel:(S,N)=>m("PATCH",g(\`/channels/\${encodeURIComponent(S)}\`),{body:{...N}}),unpairChannel:S=>m("POST",g(\`/channels/\${encodeURIComponent(S)}/unpair\`)),session:S=>m("GET",g(\`/sessions/\${encodeURIComponent(S)}\`)),setPhase:(S,N)=>m("POST",g(\`/sessions/\${encodeURIComponent(S)}/phase\`),{body:{phase:N}}),setRecall:(S,N)=>m("POST",g(\`/sessions/\${encodeURIComponent(S)}/recall\`),{body:{recall:N}}),rotateSession:S=>m("POST",g("/sessions/rotate"),{body:S?.from===void 0?{}:{from:S.from}}),approve:async(S,N)=>{await m("POST",g(\`/approvals/\${encodeURIComponent(S)}\`),{body:{granted:N}})},stop:S=>m("POST",g("/stop"),{body:S===void 0?{}:{reason:S}}),start:()=>m("POST",g("/start"),{body:{}}),assign:S=>m("PUT",g("/assignee"),{body:{participantId:S}}),unassign:()=>m("DELETE",g("/assignee")),assignment:()=>m("GET",g("/assignee")),workspaceFiles:()=>m("GET",g("/workspace")),workspaceFile:S=>m("GET",g(\`/workspace/\${encodeURIComponent(S)}\`)),putWorkspaceFile:(S,N)=>m("PUT",g(\`/workspace/\${encodeURIComponent(S)}\`),{body:{content:N}}),exportBundle:S=>m("GET",g(\`/export\${S===void 0?"":\`?paths=\${encodeURIComponent(S.join(","))}\`}\`)),importBundle:(S,N)=>m("POST",g("/import"),{body:{bundle:S,...N===void 0?{}:{mode:N}}}),setVars:S=>m("PATCH",g("/vars"),{body:{vars:S}}),vars:()=>m("GET",g("/vars")),deliver:S=>m("POST",g("/deliveries"),{body:S}),context:S=>{const N=new URLSearchParams;S?.sessionKey!==void 0&&N.set("sessionKey",S.sessionKey),S?.input!==void 0&&N.set("input",S.input);const R=N.size===0?"":\`?\${N.toString()}\`;return m("GET",g(\`/context\${R}\`))}}}return{agent:y,agents:()=>m("GET","/v1/agents"),health:()=>m("GET","/v1/health"),async ready(){try{return await f("GET","/v1/ready"),!0}catch(j){if(j instanceof xn&&j.status===503)return!1;throw j}},provision:()=>m("GET","/v1/provision"),keys:()=>m("GET","/v1/keys"),createKey:j=>m("POST","/v1/keys",{body:j}),revokeKey:j=>m("DELETE",\`/v1/keys/\${encodeURIComponent(j)}\`),deleteAgent:(j,g)=>m("DELETE",\`/v1/agents/\${encodeURIComponent(j)}?confirm=\${encodeURIComponent(g)}\`),backup:async j=>(await f("GET",\`/v1/backup\${j===void 0||j.length===0?"":\`?include=\${j.join(",")}\`}\`,{accept:"application/gzip"})).blob(),deleteParticipant:j=>m("DELETE",\`/v1/participants/\${encodeURIComponent(j)}\`),createAgent:j=>m("POST","/v1/agents",{body:{answers:j}}),usage:j=>m("GET",\`/v1/usage\${Rm(j)}\`),activity:()=>m("GET","/v1/activity"),participants:async()=>(await m("GET","/v1/participants")).participants,registerParticipant:j=>m("POST","/v1/participants",{body:j}),conversations:async()=>(await m("GET","/v1/conversations")).conversations,createConversation:j=>m("POST","/v1/conversations",{body:j}),conversation:j=>m("GET",\`/v1/conversations/\${encodeURIComponent(j)}\`),setMembers:(j,g)=>m("PATCH",\`/v1/conversations/\${encodeURIComponent(j)}/members\`,{body:g}),postMessage:(j,g)=>m("POST",\`/v1/conversations/\${encodeURIComponent(j)}/messages\`,{body:g}),conversationMessages:(j,g={})=>{const S=new URLSearchParams;g.after!==void 0&&S.set("after",String(g.after)),g.limit!==void 0&&S.set("limit",String(g.limit));const N=S.size===0?"":\`?\${S}\`;return m("GET",\`/v1/conversations/\${encodeURIComponent(j)}/messages\${N}\`)},setPresence:(j,g)=>m("PUT",\`/v1/participants/\${encodeURIComponent(j)}/presence\`,{body:{presence:g}}),actions:async(j={})=>(await m("GET",\`/v1/actions\${j.status===void 0?"":\`?status=\${j.status}\`}\`)).actions,decideAction:(j,g)=>m("POST",\`/v1/actions/\${encodeURIComponent(j)}\`,{body:{approve:g}}),addNote:j=>m("POST","/v1/memory/notes",{body:j}),notes:async j=>(await m("GET",\`/v1/memory/notes?scope=\${encodeURIComponent(j)}\`)).notes,deleteNote:j=>m("DELETE",\`/v1/memory/notes/\${encodeURIComponent(j)}\`),memoryReads:async j=>(await m("GET",\`/v1/participants/\${encodeURIComponent(j)}/memory/reads\`)).reads,projects:async()=>(await m("GET","/v1/projects")).projects,putProject:(j,g)=>m("PUT",\`/v1/projects/\${encodeURIComponent(j)}\`,{body:g}),deleteProject:j=>m("DELETE",\`/v1/projects/\${encodeURIComponent(j)}\`),setSpaceWriter:j=>m("PUT","/v1/memory/space/writer",{body:{writer:j}}),webhooks:async()=>(await m("GET","/v1/webhooks")).webhooks,createWebhook:j=>m("POST","/v1/webhooks",{body:j}),deleteWebhook:j=>m("DELETE",\`/v1/webhooks/\${encodeURIComponent(j)}\`),templates:async()=>(await m("GET","/v1/templates")).templates,createAgentFromTemplate:j=>m("POST","/v1/agents",{body:j}),async*events(j){const g=new URLSearchParams;j?.agentId!==void 0&&g.set("agentId",j.agentId),j?.types!==void 0&&j.types.length>0&&g.set("types",j.types.join(",")),j?.chunks===!0&&g.set("chunks","true");const S=g.size===0?"":\`?\${g.toString()}\`,N=await v(\`/v1/events\${S}\`,j?.signal);yield*L0(N)}}}function Rm(l){const u=new URLSearchParams;return l?.by!==void 0&&u.set("by",l.by.join(",")),l?.from!==void 0&&u.set("from",l.from),l?.to!==void 0&&u.set("to",l.to),u.size===0?"":\`?\${u.toString()}\`}const Xr=/^(\\s{0,3})(\`{3,}|~{3,})\\s*([^\\s\`]*)\\s*$/,Vr=/^(#{1,6})\\s+(.*?)\\s*#*\\s*$/,zm=/^\\s{0,3}([-*_])(\\s*\\1){2,}\\s*$/,Qi=/^(\\s*)([-*+])\\s+(.*)$/,Xi=/^(\\s*)(\\d{1,9})[.)]\\s+(.*)$/,Vi=/^\\s{0,3}>\\s?(.*)$/,xu=/^\\s*\\|.*\\|\\s*$/,Om=/^\\s*\\|?\\s*:?-+:?\\s*(\\|\\s*:?-+:?\\s*)*\\|?\\s*$/;function G0(l){return ko(l.replace(/\\r\\n?/g,\`
27
+ \`).split(\`
28
+ \`))}function ko(l){const u=[];let o=0;for(;o<l.length;){const r=l[o]??"";if(r.trim()===""){o++;continue}const d=Xr.exec(r);if(d){const y=d[2]??"\`\`\`",j=d[3]??"",g=[];let S=o+1,N=!1;for(;S<l.length;S++){const R=l[S]??"";if(R.trim().startsWith(y[0]??"\`")&&R.trim().length>=y.length&&/^[\`~]+\\s*$/.test(R.trim())){N=!0;break}g.push(R)}u.push({kind:"code",lang:j,text:g.join(\`
29
+ \`),open:!N}),o=N?S+1:S;continue}const f=Vr.exec(r);if(f){const y=Math.min(6,(f[1]??"#").length);u.push({kind:"heading",level:y,children:ll(f[2]??"")}),o++;continue}if(zm.test(r)){u.push({kind:"rule"}),o++;continue}if(Vi.test(r)){const y=[];for(;o<l.length&&Vi.test(l[o]??"");)y.push((Vi.exec(l[o]??"")??[])[1]??""),o++;u.push({kind:"quote",children:ko(y)});continue}if(xu.test(r)&&o+1<l.length&&Om.test(l[o+1]??"")){const y=Jr(r).map(ll),j=Jr(l[o+1]??"").map(S=>{const N=S.startsWith(":"),R=S.endsWith(":");return N&&R?"center":R?"right":N?"left":void 0}),g=[];for(o+=2;o<l.length&&xu.test(l[o]??"");)g.push(Jr(l[o]??"").map(ll)),o++;u.push({kind:"table",head:y,rows:g,align:j});continue}const m=Qi.exec(r),v=Xi.exec(r);if(m||v){const y=v!==null,j=(m??v??[])[1]?.length??0,g=y?Number(v?.[2]??"1"):1,S=[];for(;o<l.length;){const N=l[o]??"",R=(y?Xi:Qi).exec(N);if(!R||(R[1]?.length??0)!==j)break;const L=[R[3]??""];for(o++;o<l.length;){const P=l[o]??"";if(P.trim()===""){const F=l[o+1]??"";if(F.trim()!==""&&Zr(F)>j){L.push(""),o++;continue}break}if(Zr(P)>j){L.push(P.slice(Math.min(Zr(P),j+2))),o++;continue}const J=(y?Xi:Qi).exec(P),Z=(y?Qi:Xi).exec(P);if(J&&(J[1]?.length??0)===j||Z||Xr.test(P)||Vr.test(P)||Vi.test(P)||xu.test(P))break;L.push(P),o++}S.push(ko(L))}u.push({kind:"list",ordered:y,start:g,items:S});continue}const x=[r];for(o++;o<l.length;){const y=l[o]??"";if(y.trim()===""||Xr.test(y)||Vr.test(y)||zm.test(y)||Vi.test(y)||Qi.test(y)||Xi.test(y)||xu.test(y)&&Om.test(l[o+1]??""))break;x.push(y),o++}u.push({kind:"paragraph",children:ll(x.join(\`
30
+ \`))})}return u}function Zr(l){return l.length-l.trimStart().length}function Jr(l){const u=l.trim().replace(/^\\|/,"").replace(/\\|$/,""),o=[];let r="";for(let d=0;d<u.length;d++){const f=u[d];f==="\\\\"&&u[d+1]==="|"?(r+="|",d++):f==="|"?(o.push(r.trim()),r=""):r+=f}return o.push(r.trim()),o}const K0=/^(https?:\\/\\/|mailto:)/i;function ll(l){const u=[];let o="";const r=()=>{o!==""&&(u.push({kind:"text",text:o}),o="")};let d=0;for(;d<l.length;){const f=l.slice(d),m=/^(\`+)([^\`]|[^\`][\\s\\S]*?[^\`])\\1(?!\`)/.exec(f);if(m){r(),u.push({kind:"code",text:(m[2]??"").replace(new RegExp("^ (?=\\\\S)| (?<=\\\\S)$","g"),"")}),d+=m[0].length;continue}const v=/^\\[([^\\]]+)\\]\\(([^)\\s]+)(?:\\s+"[^"]*")?\\)/.exec(f);if(v){r();const j=v[2]??"";K0.test(j)?u.push({kind:"link",href:j,children:ll(v[1]??"")}):u.push(...ll(v[1]??"")),d+=v[0].length;continue}const x=/^https?:\\/\\/[^\\s<>()]+[^\\s<>().,;:!?'"]/.exec(f);if(x){r(),u.push({kind:"link",href:x[0],children:[{kind:"text",text:x[0]}]}),d+=x[0].length;continue}const y=/^(\\*\\*|__)(?=\\S)([\\s\\S]*?\\S)\\1/.exec(f)??/^(~~)(?=\\S)([\\s\\S]*?\\S)\\1/.exec(f)??/^(\\*|_)(?=\\S)([^*_\\n]+?\\S|\\S)\\1(?![*_\\w])/.exec(f);if(y&&!(y[1]==="_"&&d>0&&/\\w/.test(l[d-1]??""))){r();const j=y[1]??"",g=j==="~~"?"strike":j.length===2?"strong":"em";u.push({kind:g,children:ll(y[2]??"")}),d+=y[0].length;continue}if(l[d]==="\\\\"&&d+1<l.length&&/[\\\\\`*_{}[\\]()#+\\-.!|~>]/.test(l[d+1]??"")){o+=l[d+1],d+=2;continue}o+=l[d],d++}return r(),u}function Mu(l){return i.jsx(i.Fragment,{children:Mo(G0(l.text),"")})}function Mo(l,u){return l.map((o,r)=>{const d=\`\${u}\${r}\`;switch(o.kind){case"heading":{const f=\`h\${o.level}\`;return i.jsx(f,{children:wa(o.children,d)},d)}case"paragraph":return i.jsx("p",{children:wa(o.children,d)},d);case"code":return i.jsx(Y0,{lang:o.lang,text:o.text,open:o.open},d);case"quote":return i.jsx("blockquote",{children:Mo(o.children,\`\${d}.\`)},d);case"list":{const f=o.items.map((m,v)=>i.jsx("li",{children:Mo(m,\`\${d}.\${v}.\`)},\`\${d}.\${v}\`));return o.ordered?i.jsx("ol",{start:o.start,children:f},d):i.jsx("ul",{children:f},d)}case"table":return i.jsx("div",{className:"md-table",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsx("tr",{children:o.head.map((f,m)=>i.jsx("th",{style:_m(o.align[m]),children:wa(f,\`\${d}.h\${m}\`)},\`\${d}.h\${m}\`))})}),i.jsx("tbody",{children:o.rows.map((f,m)=>i.jsx("tr",{children:f.map((v,x)=>i.jsx("td",{style:_m(o.align[x]),children:wa(v,\`\${d}.r\${m}.\${x}\`)},\`\${d}.r\${m}.\${x}\`))},\`\${d}.r\${m}\`))})]})},d);case"rule":return i.jsx("hr",{},d)}})}function _m(l){return l===void 0?void 0:{textAlign:l}}function wa(l,u){return l.map((o,r)=>{const d=\`\${u}i\${r}\`;switch(o.kind){case"text":return o.text;case"code":return i.jsx("code",{children:o.text},d);case"strong":return i.jsx("strong",{children:wa(o.children,d)},d);case"em":return i.jsx("em",{children:wa(o.children,d)},d);case"strike":return i.jsx("del",{children:wa(o.children,d)},d);case"link":return i.jsx("a",{href:o.href,target:"_blank",rel:"noreferrer noopener",children:wa(o.children,d)},d)}})}function Y0(l){const[u,o]=T.useState(!1);return i.jsxs("div",{className:\`md-code\${l.open?" open":""}\`,children:[i.jsxs("div",{className:"md-code-head",children:[i.jsx("span",{children:l.lang||"text"}),i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(l.text).then(()=>{o(!0),setTimeout(()=>o(!1),1200)}).catch(()=>{})},children:u?"copied":"copy"})]}),i.jsx("pre",{children:i.jsx("code",{children:l.text})})]})}const Um=5,Q0=["image/png","image/jpeg","image/gif","image/webp"];function X0(l){return i.jsxs(i.Fragment,{children:[l.state.truncated?i.jsx("p",{className:"row note bad",children:"This turn produced more than the server keeps for a reattach, so the beginning of the reply is missing. The stored turn has all of it."}):null,l.state.rows.map(u=>i.jsx(V0,{row:u,onAnswer:l.onAnswer},u.id)),l.state.liveReasoning===""?null:i.jsx(zg,{label:"thinking",text:l.state.liveReasoning,open:!0}),l.state.live===""?null:i.jsx("div",{className:"row reply",children:i.jsx(Mu,{text:l.state.live})})]})}function V0(l){const u=l.row;switch(u.kind){case"user":return i.jsx("p",{className:"row user",children:u.text});case"reply":return i.jsx("div",{className:"row reply",children:i.jsx(Mu,{text:u.text})});case"reasoning":return i.jsx(zg,{label:"thinking",text:u.text});case"tool":return i.jsxs("div",{className:\`row tool\${u.ok===!1?" failed":""}\`,children:[i.jsx("span",{className:"slug",children:u.slug}),u.mutating?i.jsx("span",{className:"mut",children:" changes things"}):null,i.jsx("span",{className:"out",children:Z0(u)}),u.untrusted===!0?i.jsx("div",{className:"fence",children:i.jsx("div",{className:"why",children:"this result came from outside the agent — treated as data, and mutating tools are blocked for the rest of the turn"})}):null,u.args===void 0&&u.output===void 0?null:i.jsxs("details",{className:"tool-detail",children:[i.jsx("summary",{className:"tool-detail-summary",children:"details"}),u.args===void 0?null:i.jsx("pre",{className:"snippet",children:JSON.stringify(u.args,null,2)}),u.output===void 0?null:i.jsxs("pre",{className:"snippet",children:[u.output,u.outputTruncated===!0?\`
31
+ … (first 2 KB)\`:""]})]}),u.subagent===void 0?null:i.jsx(F0,{block:u.subagent})]});case"approval":return i.jsxs("div",{className:"row ask",children:[i.jsxs("div",{children:[i.jsx("strong",{children:u.slug})," needs permission — ",u.reason]}),u.match===void 0?null:i.jsx("div",{className:"what",children:u.match}),u.settled===void 0?i.jsxs("div",{className:"buttons",children:[i.jsx("button",{type:"button",className:"primary",onClick:()=>l.onAnswer(u.approvalId,!0),children:"Allow once"}),i.jsx("button",{type:"button",onClick:()=>l.onAnswer(u.approvalId,!1),children:"Refuse"})]}):i.jsx("div",{className:"settled",children:J0(u.settled)})]});case"note":return i.jsx("p",{className:\`row note\${u.bad?" bad":""}\`,children:u.text})}}function Z0(l){if(l.ok===void 0)return" running…";const u=l.bytes===void 0?"":\` · \${l.bytes} bytes\`,o=l.truncated===!0?" · truncated to fit the observation budget":"",r=l.latencyMs===void 0?"":\` · \${l.latencyMs} ms\`;return\`\${l.ok?" ok":" failed"}\${u}\${r}\${o}\`}function J0(l){switch(l){case"granted":return"Allowed — the call ran.";case"denied":return"Refused. The model was told a person declined it.";case"abandoned":return"The turn ended while this was waiting, so the call did not run. Nobody declined it.";case"error":return"The approver itself failed, so the call was refused. That says nothing about what anybody wanted."}}function F0(l){const{block:u}=l,o=u.outcome===void 0?"running…":\`\${u.steps??0} step\${u.steps===1?"":"s"} · \${u.tokens??0} tokens · \${u.outcome.replace("_"," ")}\`;return i.jsxs("details",{className:"subagent",children:[i.jsxs("summary",{children:["subagent ",u.name," · ",o]}),i.jsx("ul",{children:u.calls.map(r=>i.jsxs("li",{className:r.ok===!1?"failed":void 0,children:[i.jsx("span",{className:"slug",children:r.slug}),r.ok===void 0?" running…":\`\${r.ok?" ok":" failed"}\${r.latencyMs===void 0?"":\` · \${r.latencyMs} ms\`}\`]},r.callId))})]})}function zg(l){return i.jsxs("details",{className:"row fold",open:l.open===!0,children:[i.jsxs("summary",{children:[l.label," · ",l.text.length," chars"]}),i.jsx("div",{className:"body",children:l.text})]})}function W0(l){const u=T.useRef(null),[o,r]=T.useState(),d=l.images??[],f=m=>{const v=m.filter(y=>Q0.includes(y.type));if(v.length===0)return;const x=Um-d.length;if(x<=0){r(\`at most \${Um} images per message\`);return}r(void 0),Promise.all(v.slice(0,x).map(y=>new Promise((j,g)=>{const S=new FileReader;S.onerror=()=>g(S.error),S.onload=()=>{const N=String(S.result);j({name:y.name,mediaType:y.type,data:N.slice(N.indexOf(",")+1),url:N})},S.readAsDataURL(y)}))).then(y=>l.onImages?.([...d,...y]))};return T.useEffect(()=>{const m=u.current;m!==null&&(m.style.height="auto",m.style.height=\`\${Math.min(m.scrollHeight,190)}px\`)},[l.value]),i.jsxs("div",{className:"composer",children:[d.length===0?null:i.jsx("div",{className:"attachments",children:d.map((m,v)=>i.jsxs("span",{className:"attachment",children:[i.jsx("img",{src:m.url,alt:m.name}),i.jsx("button",{type:"button","aria-label":\`remove \${m.name}\`,onClick:()=>l.onImages?.(d.filter((x,y)=>y!==v)),children:"×"})]},\`\${m.name}:\${m.data.length}\`))}),i.jsxs("div",{className:"inner",children:[i.jsx("textarea",{ref:u,value:l.value,placeholder:"Ask the agent something",onChange:m=>l.onChange(m.target.value),onDragOver:m=>{l.onImages!==void 0&&m.preventDefault()},onDrop:m=>{l.onImages!==void 0&&(m.preventDefault(),f(Array.from(m.dataTransfer.files)))},onPaste:m=>{const v=Array.from(m.clipboardData.files);v.length>0&&l.onImages!==void 0&&(m.preventDefault(),f(v))},onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),l.onSend())}}),(l.roles??[]).length>1?i.jsx("select",{className:"role-pick","aria-label":"model role for this message",value:l.role??"",disabled:l.busy,onChange:m=>l.onRole?.(m.target.value===""?void 0:m.target.value),children:(l.roles??[]).map(m=>i.jsx("option",{value:m==="main"?"":m,children:m},m))}):null,l.busy?i.jsx("button",{type:"button",onClick:l.onStop,children:"Stop"}):i.jsx("button",{type:"button",className:"primary",disabled:l.value.trim()===""&&d.length===0,onClick:l.onSend,children:"Send"})]}),i.jsx("p",{className:"hint",children:l.busy?"Running. Closing this page does not stop it — the turn is detached, and reopening reattaches.":o??\`Enter sends · shift-enter for a new line\${l.onImages===void 0?"":" · paste or drop an image"}\`})]})}const il=\`\${tt.slug}.key\`;function I0(){const l=new URL(window.location.href),u=l.searchParams.get("claim");if(!(u===null||u===""))return l.searchParams.delete("claim"),window.history.replaceState({},"",l.pathname+l.search+l.hash),u}function Ro(){try{const l=window.localStorage.getItem(il);return l!==null&&(window.localStorage.removeItem(il),window.sessionStorage.setItem(il,l)),window.sessionStorage.getItem(il)??void 0}catch{return}}function Ho(l){try{window.sessionStorage.setItem(il,l)}catch{}}function Lo(){try{window.sessionStorage.removeItem(il),window.localStorage.removeItem(il)}catch{}}async function Og(l,u){const o=await fetch(\`\${l}/v1/keys\`,{method:"POST",headers:{"content-type":"application/json",authorization:\`Bearer \${u}\`},body:JSON.stringify({label:P0()})}),r=await o.json();if(!o.ok||typeof r.secret!="string")throw new Error(r.error?.message??\`The claim was refused (\${o.status}).\`);return r.secret}function P0(){const l=navigator.userAgent;return\`\${/Firefox\\//.test(l)?"Firefox":/Edg\\//.test(l)?"Edge":/Chrome\\//.test(l)?"Chrome":/Safari\\//.test(l)?"Safari":"browser"} · \${new Date().toISOString().slice(0,10)}\`}async function eb(l){const u=I0();if(u!==void 0)try{const r=await Og(l,u);return Ho(r),{kind:"key",secret:r}}catch(r){const d=r instanceof Error?r.message:String(r);if(Ro()===void 0)return{kind:"needed",because:d}}const o=Ro();return o!==void 0&&await Dm(l,o)?{kind:"key",secret:o}:(o!==void 0&&Lo(),await Dm(l,void 0)?{kind:"open"}:{kind:"needed",because:o===void 0?"This server needs a credential.":"The key this browser held no longer works — it was revoked, or this is a different server."})}async function Dm(l,u){try{return await _g(l,u).agents(),!0}catch(o){if(o instanceof xn&&o.code==="unauthorized")return!1;throw o}}function _g(l,u){return $0({baseUrl:l,...u===void 0?{}:{token:u}})}function tb(l,u){const o=[l.scope?.agents===void 0?"every agent":l.scope.agents.join(", "),...l.scope?.sessions===void 0?[]:[\`sessions \${l.scope.sessions}\`],l.scope?.can===void 0?"all capabilities":l.scope.can.join("+")];return l.expiresAt!==void 0&&o.push(Date.parse(l.expiresAt)<=u?"expired":\`until \${Eu(l.expiresAt)}\`),o.join(" · ")}function nb(l){const[u,o]=T.useState([]),[r,d]=T.useState(),[f,m]=T.useState(""),[v,x]=T.useState(),[y,j]=T.useState(),g=T.useCallback(async()=>{try{const Y=await l.client.keys();o(Y.keys),d(Y.scope)}catch(Y){j(Y instanceof Error?Y.message:String(Y))}},[l.client]);T.useEffect(()=>{g()},[g]);const[S,N]=T.useState(!1),[R,L]=T.useState([]),[P,J]=T.useState([]),[Z,F]=T.useState(""),[_,ge]=T.useState(""),[ee,V]=T.useState(""),le=async()=>{j(void 0);try{const Y=Number(ee),ne=S?{...R.length===0?{}:{agents:R},...P.length===0?{}:{can:P},...Z.trim()===""?{}:{sessions:Z.trim()},..._.trim()===""?{}:{participant:_.trim()},...Number.isInteger(Y)&&Y>0?{expiresIn:Y*86400}:{}}:void 0,ae=await l.client.createKey({label:f.trim(),...ne===void 0||Object.keys(ne).length===0?{}:{scope:ne}});x(ae.secret),m(""),await g()}catch(Y){j(Y instanceof Error?Y.message:String(Y))}},W=async Y=>{if(j(void 0),!window.confirm(\`Revoke "\${Y.label}"? If it is the key this browser is using, you will be signed out of this page. There is no way to tell from here — the listing carries no secrets.\`))return;const ne=Ro();try{if(await l.client.revokeKey(Y.keyId),ne!==void 0&&!await ab(l.baseUrl,ne)){Lo(),window.location.reload();return}await g()}catch(ae){j(ae instanceof Error?ae.message:String(ae))}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"card",children:[i.jsx("h2",{children:"Issue a key"}),i.jsx("p",{children:"A key is shown once and never again — the server stores a hash of it, so there is no way to recover one. Label it for the browser or machine that will hold it."}),v===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"secret",children:v}),i.jsxs("p",{className:"hint",style:{margin:"0 0 12px"},children:["Copy it now. This is the only time it is readable."," ",i.jsx("button",{type:"button",style:{padding:"2px 8px",fontSize:11},onClick:()=>{Ho(v),window.location.reload()},children:"use it in this browser"})]})]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("input",{value:f,placeholder:"my laptop",onChange:Y=>m(Y.target.value)}),i.jsx("button",{type:"button",className:"primary",disabled:f.trim()==="",onClick:()=>{le()},children:"Issue"})]}),i.jsxs("label",{className:"check",style:{marginTop:12},children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>N(!S)}),"narrow what this key reaches"]}),S?i.jsxs("div",{className:"model-form",children:[i.jsxs("div",{className:"field-like",children:[i.jsxs("span",{className:"field-label",children:["Agents ",i.jsx("span",{className:"sub",children:"none ticked reaches every agent"})]}),i.jsx("div",{className:"members",children:l.agents.map(Y=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:R.includes(Y.id),onChange:()=>L(R.includes(Y.id)?R.filter(ne=>ne!==Y.id):[...R,Y.id])}),Y.name]},Y.id))})]}),i.jsxs("div",{className:"field-like",children:[i.jsxs("span",{className:"field-label",children:["Capabilities ",i.jsx("span",{className:"sub",children:"none ticked means all five"})]}),i.jsx("div",{className:"members",children:["read","chat","write","admin","peer"].map(Y=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:P.includes(Y),onChange:()=>J(P.includes(Y)?P.filter(ne=>ne!==Y):[...P,Y])}),Y]},Y))})]}),i.jsxs("label",{children:["Session prefix ",i.jsx("span",{className:"sub",children:"e.g. team_42:"}),i.jsx("input",{value:Z,onChange:Y=>F(Y.target.value)})]}),i.jsxs("label",{children:["Acts for participant"," ",i.jsx("span",{className:"sub",children:"every turn it starts is this person's"}),i.jsx("input",{value:_,placeholder:"user:ada",onChange:Y=>ge(Y.target.value)})]}),i.jsxs("label",{children:["Expires in days ",i.jsx("span",{className:"sub",children:"blank never expires"}),i.jsx("input",{inputMode:"numeric",value:ee,onChange:Y=>V(Y.target.value.replace(/\\D/g,""))})]})]}):null]}),i.jsxs("div",{className:"card",children:[i.jsx("h2",{children:"Keys"}),i.jsx("p",{children:r??"…"}),y===void 0?null:i.jsx("p",{className:"note bad",children:y}),i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Label"}),i.jsx("th",{children:"Created"}),i.jsx("th",{children:"Reaches"}),i.jsx("th",{children:"Last used"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:u.map(Y=>i.jsxs("tr",{children:[i.jsx("td",{className:Y.revokedAt===void 0?"":"revoked",children:Y.label}),i.jsx("td",{children:Eu(Y.createdAt)}),i.jsx("td",{className:"sub",children:tb(Y,Date.now())}),i.jsx("td",{children:Y.revokedAt!==void 0?\`revoked \${Eu(Y.revokedAt)}\`:Y.lastUsedAt===void 0?"never":Eu(Y.lastUsedAt)}),i.jsx("td",{children:Y.revokedAt===void 0?i.jsx("button",{type:"button",className:"bad",style:{padding:"2px 9px",fontSize:11},onClick:()=>{W(Y)},children:"revoke"}):null})]},Y.keyId))})]}),u.length===0?i.jsx("p",{className:"hint",style:{marginTop:10},children:"No keys. This server is open to anyone who can reach the port — issuing the first key is what closes it."}):null]})]})}async function ab(l,u){try{return(await fetch(\`\${l}/v1/agents\`,{headers:{authorization:\`Bearer \${u}\`}})).ok}catch{return!0}}function Eu(l){const u=new Date(l);return Number.isNaN(u.getTime())?l:u.toISOString().slice(0,10)}const lb=["chat","home","new","team","models","turns","usage","server-usage","files","tools","schedules","channels","config","keys","people","rooms","actions","memory","webhooks","backup","api"];function ib(l){return l!==null&&lb.includes(l)}function sb(l){const u=new URL(l).searchParams,o=u.get("agent"),r=u.get("panel");return{...o===null||o===""?{}:{agentId:o},panel:ib(r)?r:"chat"}}function ub(l,u){const o=new URL(l);return u.agentId===void 0||u.agentId===""?o.searchParams.delete("agent"):o.searchParams.set("agent",u.agentId),u.panel==="chat"?o.searchParams.delete("panel"):o.searchParams.set("panel",u.panel),\`\${o.pathname}\${o.search}\`}const cb=40;function rb(l){return l.scrollHeight-l.scrollTop-l.clientHeight<=cb}function ob(l){return rb(l)}function db(){let l,u;return{begin(o){if(l!==o)return u?.abort(),l=o,u=new AbortController,u.signal},finish(o){l===o&&(l=void 0,u=void 0)},abort(){u?.abort()},following:()=>l,aborted:()=>u?.signal.aborted??!1}}function fb(l){const u=l.current;return[...u===void 0?[]:l.agentPanels.map(o=>({id:\`agent:\${u.id}:\${o.panel}\`,label:o.label,hint:u.name,target:{panel:o.panel,agentId:u.id}})),...l.serverPanels.map(o=>({id:\`server:\${o.panel}\`,label:o.label,hint:"server",target:{panel:o.panel}})),...l.agents.map(o=>({id:\`open:\${o.id}\`,label:o.name,hint:\`agent · \${o.id}\`,target:{panel:"chat",agentId:o.id}})),{id:"new",label:"New agent",hint:"server",target:{panel:"new"}}]}function hb(l,u){const o=u.toLowerCase().split(/\\s+/).filter(d=>d!=="");return o.length===0?l:l.flatMap((d,f)=>{const m=d.label.toLowerCase(),v=\`\${m} \${d.hint.toLowerCase()}\`;if(!o.every(j=>v.includes(j)))return[];const x=o[0]??"",y=m.startsWith(x)?0:m.includes(x)?1:2;return[{entry:d,score:y,index:f}]}).sort((d,f)=>d.score-f.score||d.index-f.index).map(d=>d.entry)}function mb(l){const u={};for(const o of l)u[o.step]=o.fallback;return u}const gb=8;function vb(l,u,o){let r=u;for(let d=0;d<gb;d+=1){if(r===void 0)return!1;const f=r.requires;if(f===void 0)return!0;if(o[f.step]!==f.value)return!1;r=l.find(m=>m.step===f.step)}return!1}function Ru(l,u){return l.filter(o=>vb(l,o,u))}function Ug(l,u){return Ru(l,u).filter(o=>o.optional!==!0&&(u[o.step]??"").trim()==="")}function yb(l,u){const o={};for(const r of Ru(l,u)){const d=(u[r.step]??"").trim();d!==""&&(o[r.step]=d)}return o}function bb(l,u){return Ru(l,u).filter(o=>o.secret&&(u[o.step]??"").trim()==="")}const pb="0123456789abcdefghjkmnpqrstvwxyz";function xb(l){return\`web:\${[...l(6)].map(u=>pb[u&31]).join("")}\`}const ju=\`\${tt.slug}.session\`;function jb(l,u){if(l===null)return;const[o,r]=l.split("\x1F");return o===u&&r!==void 0&&r!==""?r:void 0}function Bm(l,u){return\`\${l}\x1F\${u}\`}const Sb=/~[0-9a-hjkmnp-tv-z]{6}$/;function Nb(l){return l.startsWith("owner:")||l.startsWith("peer:")}function wb(l,u=new Date){const o=l.sessionKey,r=l.head===!1?\` · earlier\${l.lastActivityAt===void 0?"":\`, \${Tb(l.lastActivityAt,u)}\`}\`:"";return o.startsWith("owner:")?\`You\${r}\`:o.startsWith("peer:")?\`\${o.slice(5).replace(Sb,"")}\${r}\`:o}function Tb(l,u){const o=new Date(l),r=f=>String(f).padStart(2,"0"),d=f=>\`\${f.getFullYear()}-\${r(f.getMonth()+1)}-\${r(f.getDate())}\`;return d(o)===d(u)?\`\${r(o.getHours())}:\${r(o.getMinutes())}\`:d(o)}function Dg(l){return l==="owner"||l==="peer"}function Eb(l){return{...al,filter:l==="nlt"?O0():Ag()}}const al={filter:Ag(),rows:[],live:"",liveReasoning:"",running:!1,truncated:!1};let Hm=0;function pn(){return Hm+=1,\`r\${Hm}\`}function Ab(l,u){return{...l,rows:[...l.rows,{kind:"user",id:pn(),text:u}],running:!0}}function Cb(l,u){switch(u.kind){case"accepted":return l;case"replay":return u.report.truncated?{...l,truncated:!0}:l;case"ended":return{...l,running:!1,rows:[...l.rows,{kind:"note",id:pn(),text:\`This turn finished before the page attached — \${u.status}. Its reply is stored.\`,bad:u.status!=="final"}]};case"unavailable":return{...l,running:!1,rows:[...l.rows,{kind:"note",id:pn(),text:u.reason,bad:!0}]};case"event":return Mb(l,u.event)}}function Au(l,u,o){const r=l.rows.findIndex(v=>v.kind==="tool"&&u(v)),d=l.rows[r];if(d===void 0||d.kind!=="tool")return l;const f=o(d.subagent);if(f===void 0)return l;const m=[...l.rows];return m[r]={...d,subagent:f},{...l,rows:m}}function kb(l,u){const o=r=>r.subagent?.sessionKey===u.sessionKey;if(u.data.slug===w0)return l;if(u.type==="tool.call"){const r=u.data;return Au(l,o,d=>d===void 0?void 0:{...d,calls:[...d.calls,{callId:r.callId,slug:r.slug}]})}if(u.type==="tool.result"){const r=u.data;return Au(l,o,d=>d===void 0?void 0:{...d,calls:d.calls.map(f=>f.callId===r.callId?{...f,ok:r.ok,latencyMs:r.latencyMs}:f)})}return l}function Mb(l,u){if(u.parentTurnId!==void 0)return kb(l,u);switch(u.type){case"handoff.start":{const o=u.data;return o.kind!=="self"||o.callId===void 0?l:Au(l,r=>r.callId===o.callId,()=>({name:o.name??"subagent",sessionKey:o.sessionKey,calls:[]}))}case"handoff.result":{const o=u.data;return Au(l,r=>r.subagent?.sessionKey===o.sessionKey,r=>r===void 0?void 0:{...r,outcome:o.outcome,steps:o.steps,tokens:o.tokens.prompt+o.tokens.output})}case"turn.start":return{...l,running:!0};case"model.chunk":{const o=u.data;if(o.kind==="reasoning")return{...l,liveReasoning:l.liveReasoning+o.delta};const r=l.filter.push(o.delta);return r===""?l:{...l,live:l.live+r}}case"model.result":return Zi({...l,live:l.live+l.filter.endStep()});case"tool.call":{const o=u.data,r=Zi(l);return{...r,rows:[...r.rows,{kind:"tool",id:pn(),callId:o.callId,slug:o.slug,mutating:o.mutating,...o.args===void 0?{}:{args:o.args}}]}}case"tool.result":{const o=u.data,r=l.rows.findIndex(m=>m.kind==="tool"&&m.callId===o.callId);if(r===-1)return l;const d=l.rows[r];if(d===void 0||d.kind!=="tool")return l;const f=[...l.rows];return f[r]={...d,ok:o.ok,bytes:o.bytes,truncated:o.truncated,latencyMs:o.latencyMs,...o.trust==="untrusted"?{untrusted:!0}:{},...o.output===void 0?{}:{output:o.output},...o.outputTruncated===!0?{outputTruncated:!0}:{}},{...l,rows:f}}case"approval.requested":{const o=u.data,r=Zi(l);return{...r,rows:[...r.rows,{kind:"approval",id:pn(),approvalId:o.approvalId,slug:o.slug,...o.match===void 0?{}:{match:o.match},reason:o.reason}]}}case"approval.resolved":{const o=u.data,r=l.rows.findIndex(m=>m.kind==="approval"&&m.approvalId===o.approvalId);if(r===-1)return l;const d=l.rows[r];if(d===void 0||d.kind!=="approval")return l;const f=[...l.rows];return f[r]={...d,settled:o.by==="abandoned"?"abandoned":o.by==="error"?"error":o.granted?"granted":"denied"},{...l,rows:f}}case"error":{const o=u.data,r=Zi({...l,live:l.live+l.filter.end()});return{...r,running:!1,rows:[...r.rows,{kind:"note",id:pn(),text:\`\${o.code}: \${o.message}
32
+ hint: \${o.hint}\`,bad:!0}]}}case"agent.warning":{const o=u.data;return{...l,rows:[...l.rows,{kind:"note",id:pn(),text:o.message??"",bad:!1}]}}case"turn.end":{const o=u.data,r=Zi({...l,live:l.live+l.filter.end()}),d=N0(o.reason,{steps:o.steps});return{...r,running:!1,rows:d===void 0?r.rows:[...r.rows,{kind:"note",id:pn(),text:d,bad:S0(o.reason)}]}}default:return l}}function Zi(l){if(l.live===""&&l.liveReasoning==="")return l;const u=[...l.rows],o=l.liveReasoning.trim();o!==""&&u.push({kind:"reasoning",id:pn(),text:o});const r=l.live.trim();return r!==""&&u.push({kind:"reply",id:pn(),text:r}),{...l,rows:u,live:"",liveReasoning:""}}const Cu=[{id:"openai",label:"OpenAI",modelId:"gpt-5-6-sol",baseUrl:"https://api.openai.com/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"anthropic",label:"Anthropic (OpenAI-compatible endpoint)",modelId:"claude-sonnet-5",baseUrl:"https://api.anthropic.com/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"deepseek",label:"DeepSeek",modelId:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"openrouter",label:"OpenRouter (many providers, one key)",modelId:"deepseek/deepseek-chat",baseUrl:"https://openrouter.ai/api/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"groq",label:"Groq",modelId:"llama-3.3-70b-versatile",baseUrl:"https://api.groq.com/openai/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"nvidia",label:"NVIDIA NIM",modelId:"meta/llama-3.3-70b-instruct",baseUrl:"https://integrate.api.nvidia.com/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"ollama",label:"Ollama (local, no key)",modelId:"qwen3.5:9b",baseUrl:"http://localhost:11434/v1"},{id:"ollama-cloud",label:"Ollama Cloud (hosted, needs a key)",modelId:"gpt-oss:120b",baseUrl:"https://ollama.com/v1",apiKeyEnv:"MODEL_API_KEY"},{id:"bedrock",label:"AWS Bedrock (Converse; credentials from the AWS chain)",modelId:"eu.anthropic.claude-sonnet-4-6",baseUrl:"",api:"bedrock-converse",region:"eu-west-1"},{id:"custom",label:"any other OpenAI-compatible endpoint",modelId:"",baseUrl:"",apiKeyEnv:"MODEL_API_KEY"}],Bg=["none","minimal","low","medium","high","xhigh","max"];function Ta(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}}const lt=l=>typeof l=="string"?l:"";function Hg(l){const u=l.replace(/\\/+$/,"");return Cu.find(o=>o.baseUrl!==""&&o.baseUrl===u)}function Ii(l,u){const o={...l};for(const[r,d]of Object.entries(u))d===void 0||d===""?delete o[r]:o[r]=d;return JSON.stringify(o)}function Lm(l){if(lt(l.api)==="bedrock-converse"){const o=Ta(l.options);return\`Bedrock · \${lt(o.region)||"no region"}\`}const u=lt(l.baseUrl);return Hg(u)?.label.split(" (")[0]??(u||"default endpoint")}function qm(l){const u=Ta(l.options);return{id:lt(l.id),api:lt(l.api)==="bedrock-converse"?"bedrock-converse":"chat-completions",baseUrl:lt(l.baseUrl),apiKeyEnv:lt(l.apiKeyEnv),region:lt(u.region),profile:lt(u.profile)}}function zo(l){return l.api==="bedrock-converse"?{id:l.id,api:"bedrock-converse",options:{region:l.region,...l.profile===""?{}:{profile:l.profile}},baseUrl:void 0,apiKeyEnv:void 0}:{id:l.id,api:void 0,options:void 0,baseUrl:l.baseUrl,apiKeyEnv:l.apiKeyEnv}}const Rb=["none","anthropic","openai","deepseek"];function zb(l){const u=Ta(l.settings.find(d=>d.path==="model.main")?.value),o=l.settings.filter(d=>/^model\\.[^.<]+$/.test(d.path)&&d.path!=="model.main").map(d=>({name:d.path.slice(6),role:Ta(d.value)})),r=d=>l.secrets.find(f=>f.name===d)?.set;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Models"}),i.jsx("p",{children:"The model this agent runs on, how hard it reasons, and named roles a schedule or a message can run on instead. Saving replaces the agent; history survives."})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),i.jsx($m,{name:"main",role:u,keySet:r(lt(u.apiKeyEnv)),busy:l.busy==="model.main",onChange:d=>l.onChange("model.main",d),onSecret:l.onSecret,...l.resolved===void 0?{}:{resolved:l.resolved},primary:!0}),i.jsx("div",{className:"section-title",children:"Roles"}),o.length===0?i.jsxs("p",{className:"empty",style:{marginBottom:14},children:["No roles yet. A role is a second model — a cheap one for a nightly digest, a stronger one for a hard question — that a schedule names with ",i.jsx("code",{children:"role:"})," ","or a message with ",i.jsx("code",{children:'"role"'}),"."]}):o.map(({name:d,role:f})=>i.jsx($m,{name:d,role:f,keySet:r(lt(f.apiKeyEnv)),busy:l.busy===\`model.\${d}\`,onChange:m=>l.onChange(\`model.\${d}\`,m),onSecret:l.onSecret},d)),i.jsx(Ub,{taken:["main",...o.map(d=>d.name)],busy:l.busy==="model.new",onAdd:(d,f)=>l.onChange("model.new",[{path:\`model.\${d}\`,value:f}])})]})}function Ob(l){const{resolved:u,override:o}=l,[r,d]=T.useState(""),[f,m]=T.useState(""),v=(j,g)=>{const S={...o};g===void 0?delete S[j]:S[j]=g,l.onOverride(S)},x=j=>j in o?i.jsx("button",{type:"button",className:"link",disabled:l.busy,onClick:()=>v(j,void 0),title:"Drop this override and use the registry's value",children:"overridden · reset"}):i.jsx("span",{className:"sub",children:"registry"}),y=(j,g,S)=>i.jsxs("form",{className:"caps-row",onSubmit:N=>{N.preventDefault();const R=Number(g);Number.isInteger(R)&&R>0&&v(j,R),S("")},children:[i.jsx("span",{className:"mono-value",children:u[j].toLocaleString()}),i.jsx("input",{inputMode:"numeric","aria-label":\`override \${j}\`,placeholder:"override",value:g,disabled:l.busy,onChange:N=>S(N.target.value.replace(/[^0-9]/g,"")),style:{width:110}}),x(j)]});return i.jsxs("div",{className:"control",children:[i.jsxs("div",{className:"control-label",children:["Capabilities",i.jsx("span",{className:"sub",children:"What the shipped registry says this model can do. Override only when it is wrong for your endpoint."})]}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"context window"}),i.jsx("dd",{children:y("contextWindow",r,d)}),i.jsx("dt",{children:"output cap"}),i.jsx("dd",{children:y("maxOutput",f,m)}),i.jsx("dt",{children:"reasoning"}),i.jsxs("dd",{className:"caps-row",children:[i.jsx("select",{"aria-label":"reasoning protocol",value:u.thinking,disabled:l.busy,onChange:j=>v("thinking",j.target.value),children:Rb.map(j=>i.jsx("option",{value:j,children:j},j))}),x("thinking")]}),i.jsx("dt",{children:"images"}),i.jsxs("dd",{className:"caps-row",children:[i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:u.vision===!0,disabled:l.busy,onChange:j=>v("vision",j.target.checked)}),i.jsx("span",{children:"reads images"})]}),x("vision")]}),i.jsx("dt",{children:"native tools"}),i.jsx("dd",{children:u.nativeTools?"yes":"no"}),i.jsx("dt",{children:"prompt cache"}),i.jsx("dd",{children:u.promptCache}),i.jsx("dt",{children:"prompt style"}),i.jsxs("dd",{children:[u.promptStyle.delimiters," · ",u.promptStyle.intensity]})]})]})}function $m(l){const{role:u}=l,o=\`model.\${l.name}\`,r=lt(u.reasoningEffort),d=typeof u.temperature=="number"?u.temperature:void 0,f=typeof u.maxTokens=="number"?String(u.maxTokens):"",m=lt(u.baseUrl),v=lt(u.apiKeyEnv),x=Array.isArray(u.fallbacks)?u.fallbacks.map(Ta):[],[y,j]=T.useState(!1),[g,S]=T.useState(!1),[N,R]=T.useState(d),[L,P]=T.useState(f),J=(Z,F)=>l.onChange([{path:o,value:Ii(u,{[Z]:F})}]);return i.jsxs("div",{className:\`card model-card\${l.primary===!0?" primary":""}\`,children:[i.jsxs("div",{className:"model-head",children:[i.jsx("span",{className:"avatar",children:l.name.charAt(0)}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{className:"model-role",children:l.primary===!0?"main model":l.name}),i.jsx("div",{className:"model-id",children:lt(u.id)||"no model set"})]}),i.jsxs("div",{className:"stats",style:{marginLeft:"auto"},children:[i.jsx("span",{className:"pill",children:Lm(u)}),v===""?i.jsx("span",{className:"pill",children:"no key"}):i.jsxs("span",{className:\`pill \${l.keySet===!0?"ok":"warn"}\`,children:[i.jsx("span",{className:\`dot \${l.keySet===!0?"live":"warn"}\`}),v," ",l.keySet===!0?"set":"missing"]}),l.busy?i.jsx("span",{className:"pill accent",children:"saving…"}):null]})]}),i.jsxs("div",{className:"control",children:[i.jsxs("div",{className:"control-label",children:["Reasoning effort",i.jsx("span",{className:"sub",children:"How long a reasoning model thinks before answering. Lower is faster and cheaper; not every endpoint honours it."})]}),i.jsxs("fieldset",{className:"segmented",children:[i.jsx("button",{type:"button","aria-pressed":r==="",disabled:l.busy,onClick:()=>J("reasoningEffort",void 0),children:"default"}),Bg.map(Z=>i.jsx("button",{type:"button","aria-pressed":r===Z,disabled:l.busy,onClick:()=>J("reasoningEffort",Z),children:Z},Z))]})]}),i.jsxs("div",{className:"control-row",children:[i.jsxs("div",{className:"control",children:[i.jsxs("div",{className:"control-label",children:["Temperature",i.jsx("span",{className:"mono-value",children:N===void 0?"default":N.toFixed(1)})]}),i.jsxs("div",{className:"inline",children:[i.jsx("input",{type:"range",min:0,max:2,step:.1,value:N??1,disabled:l.busy,onChange:Z=>R(Number(Z.target.value)),onMouseUp:()=>N===void 0?void 0:l.onChange([{path:o,value:JSON.stringify({...u,temperature:N})}]),onKeyUp:()=>N===void 0?void 0:l.onChange([{path:o,value:JSON.stringify({...u,temperature:N})}])}),i.jsx("button",{type:"button",disabled:l.busy||d===void 0,onClick:()=>{R(void 0);const{temperature:Z,...F}=u;l.onChange([{path:o,value:JSON.stringify(F)}])},children:"reset"})]})]}),i.jsxs("div",{className:"control",children:[i.jsxs("div",{className:"control-label",children:["Max output tokens",i.jsx("span",{className:"sub",children:"Blank lets the endpoint decide."})]}),i.jsxs("form",{className:"inline",onSubmit:Z=>{Z.preventDefault();const{maxTokens:F,..._}=u,ge=Number(L);l.onChange([{path:o,value:JSON.stringify(L.trim()===""||!Number.isInteger(ge)||ge<=0?_:{..._,maxTokens:ge})}])},children:[i.jsx("input",{inputMode:"numeric",placeholder:"default",value:L,onChange:Z=>P(Z.target.value.replace(/[^0-9]/g,""))}),i.jsx("button",{type:"submit",disabled:l.busy||L===f,children:"save"})]})]})]}),i.jsxs("div",{className:"control",children:[i.jsxs("div",{className:"control-label",children:["Fallbacks",i.jsx("span",{className:"sub",children:"Tried in order when this model is unreachable or answers 5xx/429 before the first token. Each is a whole role, so a fallback can be another provider."})]}),x.length===0?null:i.jsx("ol",{className:"fallbacks",children:x.map((Z,F)=>i.jsxs("li",{children:[i.jsx("code",{children:lt(Z.id)||"?"}),i.jsx("span",{className:"sub",style:{margin:0},children:Lm(Z)}),i.jsx("button",{type:"button",className:"link",disabled:l.busy,onClick:()=>l.onChange([{path:o,value:Ii(u,{fallbacks:x.filter((_,ge)=>ge!==F)})}]),children:"remove"})]},JSON.stringify(Z)))}),g?i.jsx(Oo,{initial:{...qm({}),apiKeyEnv:"MODEL_API_KEY"},busy:l.busy,submitLabel:"add fallback",onSubmit:(Z,F)=>{const _=Object.fromEntries(Object.entries(zo(Z)).filter(([,ge])=>ge!==void 0));l.onChange([{path:o,value:Ii(u,{fallbacks:[...x,_]})}]),F!==""&&Z.apiKeyEnv!==""&&l.onSecret(Z.apiKeyEnv,F),S(!1)}}):i.jsx("button",{type:"button",disabled:l.busy,onClick:()=>S(!0),children:"+ add a fallback"})]}),l.resolved===void 0?null:i.jsx(Ob,{resolved:l.resolved,override:Ta(u.capabilities),busy:l.busy,onOverride:Z=>J("capabilities",Object.keys(Z).length===0?void 0:Z)}),i.jsxs("div",{className:"model-foot",children:[i.jsx("span",{className:"sub",style:{margin:0},children:lt(u.api)==="bedrock-converse"?\`AWS Bedrock Converse\${lt(Ta(u.options).profile)===""?"":\` · profile \${lt(Ta(u.options).profile)}\`} · credentials from the AWS chain\`:m===""?"transport default":m}),i.jsxs("span",{style:{marginLeft:"auto",display:"flex",gap:8},children:[l.primary===!0?null:i.jsx("button",{type:"button",className:"bad",disabled:l.busy,onClick:()=>l.onChange([{path:o,remove:!0}]),children:"remove"}),i.jsx("button",{type:"button",onClick:()=>j(!y),children:y?"close":"change model"})]})]}),y?i.jsx(Oo,{initial:qm(u),busy:l.busy,submitLabel:"save model",onSubmit:(Z,F)=>{l.onChange([{path:o,value:Ii(u,zo(Z))}]),F!==""&&Z.apiKeyEnv!==""&&l.onSecret(Z.apiKeyEnv,F),j(!1)}}):null]})}function Oo(l){const[u,o]=T.useState(l.initial),[r,d]=T.useState(""),f=u.api==="bedrock-converse",m=f?"bedrock":Hg(u.baseUrl)?.id??"custom",v=y=>j=>o({...u,[y]:j.target.value}),x=u.id.trim()!==""&&(!f||/^[a-z]{2}(-[a-z]+)+-\\d$/.test(u.region.trim()));return i.jsxs("form",{className:"model-form",onSubmit:y=>{y.preventDefault(),x&&(l.onSubmit({id:u.id.trim(),api:u.api,baseUrl:f?"":u.baseUrl.trim(),apiKeyEnv:f?"":u.apiKeyEnv.trim(),region:f?u.region.trim():"",profile:f?u.profile.trim():""},r),d(""))},children:[l.extra,i.jsxs("label",{children:["Provider",i.jsx("select",{value:m,onChange:y=>{const j=Cu.find(g=>g.id===y.target.value);j===void 0||j.id==="custom"||o({id:j.modelId,api:j.api??"chat-completions",baseUrl:j.baseUrl,apiKeyEnv:j.apiKeyEnv??"",region:j.region??"",profile:""})},children:Cu.map(y=>i.jsx("option",{value:y.id,children:y.label},y.id))})]}),i.jsxs("label",{children:["Model id",i.jsx("input",{value:u.id,placeholder:"deepseek-v4-pro",onChange:v("id")})]}),f?i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["AWS region",i.jsx("input",{value:u.region,placeholder:"eu-west-1",onChange:v("region")})]}),i.jsxs("label",{children:["AWS profile"," ",i.jsx("span",{className:"sub",children:"optional — otherwise the environment, container or instance role"}),i.jsx("input",{value:u.profile,placeholder:"default chain",onChange:v("profile")})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Endpoint",i.jsx("input",{value:u.baseUrl,placeholder:"https://api.example.com/v1",onChange:v("baseUrl")})]}),i.jsxs("label",{children:["Key variable",i.jsx("input",{value:u.apiKeyEnv,placeholder:"MODEL_API_KEY (blank for a keyless local model)",onChange:v("apiKeyEnv")})]})]}),f?null:i.jsxs("label",{children:["API key"," ",i.jsx("span",{className:"sub",children:"optional — written to the agent's .env, never shown again"}),i.jsx("input",{type:"password",autoComplete:"new-password",value:r,placeholder:u.apiKeyEnv===""?"no key variable":"leave blank to keep the current key",disabled:u.apiKeyEnv==="",onChange:y=>d(y.target.value)})]}),i.jsx("div",{children:i.jsx("button",{type:"submit",className:"primary",disabled:l.busy||!x,children:l.submitLabel})})]})}const _b=/^[a-z][a-z0-9_-]{0,31}$/;function Ub(l){const[u,o]=T.useState(!1),[r,d]=T.useState(""),[f,m]=T.useState(""),v=r===""?void 0:_b.test(r)?l.taken.includes(r)?"already a role":void 0:"lowercase letters, digits, - and _";if(!u)return i.jsx("button",{type:"button",onClick:()=>o(!0),children:"+ add a role"});const x=Cu[0];return i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"New role"}),i.jsx(Oo,{initial:{id:x?.modelId??"",api:x?.api??"chat-completions",baseUrl:x?.baseUrl??"",apiKeyEnv:x?.apiKeyEnv??"",region:x?.region??"",profile:""},busy:l.busy||r===""||v!==void 0,submitLabel:"add role",extra:i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Role name"," ",v===void 0?null:i.jsx("span",{className:"error",children:v}),i.jsx("input",{value:r,placeholder:"fast",onChange:y=>d(y.target.value.trim())})]}),i.jsxs("label",{children:["Reasoning effort",i.jsxs("select",{value:f,onChange:y=>m(y.target.value),children:[i.jsx("option",{value:"",children:"default"}),Bg.map(y=>i.jsx("option",{value:y,children:y},y))]})]})]}),onSubmit:y=>{l.onAdd(r,Ii({},{...zo(y),reasoningEffort:f})),o(!1),d("")}})]})}function Db(l){if(!l.available)return i.jsxs("p",{className:"empty",children:["This server has no provisioner, so it cannot create an agent — the case for an embedder mounting the API over its own agent store. Run"," ",i.jsxs("code",{children:[tt.slug," init"]})," where the sandbox is, or mount an agent directory."]});if(!l.allowed)return i.jsxs("p",{className:"empty",children:["Creating an agent needs a loopback bind or a credential with the ",i.jsx("code",{children:"admin"})," ","capability, and this request has neither. On a server reachable from elsewhere, set"," ",i.jsx("code",{children:"server.tokenEnv"})," or present an operator key minted with"," ",i.jsx("code",{children:"can: [admin]"})," — or mount a written agent at ",i.jsx("code",{children:"/agent"}),"."]})}function Bb(l){const{step:u,value:o}=l,r=\`provision-\${u.step}\`;return i.jsxs("div",{className:l.invalid?"field invalid":"field",children:[i.jsxs("label",{htmlFor:r,children:[u.prompt,u.optional?i.jsx("span",{className:"sub",children:" optional"}):null,u.secret?i.jsx("span",{className:"sub",children:" · written to .env, never read back"}):null]}),u.choices===void 0?i.jsx("input",{id:r,name:u.step,type:u.secret?"password":"text",value:o,disabled:l.disabled,autoComplete:u.secret?"new-password":"off",spellCheck:!1,onChange:d=>l.onChange(d.target.value)}):i.jsx("select",{id:r,name:u.step,value:o,disabled:l.disabled,onChange:d=>l.onChange(d.target.value),children:u.choices.map(d=>i.jsx("option",{value:d.value,children:d.hint===void 0?d.label:\`\${d.label} — \${d.hint}\`},d.value))}),l.invalid?i.jsx("div",{className:"sub error",children:"needs an answer"}):null]})}function Hb(l){const u=l.result.adopted.includes(l.result.id);return i.jsxs("div",{className:"created",children:[i.jsxs("h3",{children:["Created ",i.jsx("code",{children:l.result.id})]}),i.jsxs("p",{children:[i.jsx("code",{children:l.result.dir}),i.jsxs("span",{className:"sub",children:[" · ",l.result.files.length," files"]})]}),u?i.jsx("p",{className:"ok",children:"adopted · live on this host, with its channels and schedules"}):i.jsxs("p",{className:"error",children:["written, and ",i.jsx("strong",{children:"not running"}),l.result.error===void 0?null:i.jsxs(i.Fragment,{children:[": ",l.result.error.message,l.result.error.hint===void 0?null:i.jsxs("span",{className:"sub",children:[" ",l.result.error.hint]})]})]}),l.blank.length===0?null:i.jsxs("div",{className:"blank-secrets",children:[i.jsxs("p",{children:["Left empty, and needed before this works:"," ",l.blank.map(o=>o.prompt).join(", "),"."]}),i.jsxs("p",{className:"sub",children:["Fill them in ",i.jsxs("code",{children:[l.result.dir,"/.env"]})," at a terminal —"," ",i.jsx("code",{children:".env"})," is a protected path, so neither the agent nor this API can write it. The file names each variable in its own comments."]})]}),u?i.jsxs("button",{type:"button",onClick:()=>l.onOpen(l.result.id),children:["open ",l.result.id]}):null]})}function Gm(l){if(l.result!==void 0)return i.jsx(Hb,{result:l.result,blank:bb(l.offer.steps,l.answers),onOpen:l.onOpen});const u=Db(l.offer);if(u!==void 0)return u;const o=Ru(l.offer.steps,l.answers),r=Ug(l.offer.steps,l.answers),d=new Set(r.map(f=>f.step));return i.jsxs("form",{className:"provision",onSubmit:f=>{f.preventDefault(),l.onSubmit()},children:[i.jsxs("p",{className:"sub",children:["The same questions ",i.jsxs("code",{children:[tt.slug," init"]})," asks, served from the same walk. What you leave alone takes its default. The agent is adopted into this server as it is created — there is no second command."]}),o.map(f=>i.jsx(Bb,{step:f,value:l.answers[f.step]??"",invalid:l.touched&&d.has(f.step),disabled:l.busy,onChange:m=>l.onAnswer(f.step,m)},f.step)),l.error===void 0?null:i.jsx("p",{className:"error",children:l.error}),i.jsx("button",{type:"submit",disabled:l.busy,children:l.busy?"creating…":"create agent"}),l.touched&&r.length>0?i.jsxs("p",{className:"sub error",children:[r.map(f=>f.prompt).join(", ")," — still needed."]}):null]})}function Lb(l){const[u,o]=T.useState(""),[r,d]=T.useState(["turn.end"]),[f,m]=T.useState([]),[v,x]=T.useState(""),y=l.eventTypes.filter(g=>g!=="model.chunk"&&g.includes(v.trim())),j=/^https:\\/\\/\\S+$/.test(u.trim())&&r.length>0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Webhooks"}),i.jsxs("p",{children:["Events POSTed to a URL you own, signed per Standard Webhooks. A subscription hears only the agents its creating key could reach. ",i.jsx("code",{children:"model.chunk"})," is never delivered."]})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),l.secret===void 0?null:i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Signing secret"}),i.jsx("div",{className:"secret",children:l.secret}),i.jsxs("p",{className:"hint",style:{margin:0},children:["Shown once. Verify ",i.jsx("code",{children:"webhook-signature"})," with it."," ",i.jsx("button",{type:"button",className:"link",onClick:l.onDismissSecret,children:"I have copied it"})]})]}),l.webhooks.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No subscriptions"}),i.jsx("p",{children:"Add one below to be told when a turn ends, an approval is needed, or a delivery fails."})]}):i.jsxs("table",{className:"panel-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"url"}),i.jsx("th",{children:"events"}),i.jsx("th",{children:"health"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:l.webhooks.map(g=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("code",{children:g.url}),g.scope?.agents===void 0?null:i.jsxs("div",{className:"sub",children:["agents: ",g.scope.agents.join(", ")]})]}),i.jsx("td",{children:i.jsx("div",{className:"stats",children:g.types.map(S=>i.jsx("span",{className:"pill",children:S},S))})}),i.jsxs("td",{children:[i.jsxs("span",{className:\`pill \${g.failing?"warn":"ok"}\`,children:[i.jsx("span",{className:\`dot \${g.failing?"warn":"live"}\`}),g.failing?\`failing (\${g.consecutiveFailures})\`:"healthy"]}),g.pending>0?i.jsxs("div",{className:"sub",children:[g.pending," pending"]}):null,g.lastError===void 0?null:i.jsx("div",{className:"sub",children:g.lastError})]}),i.jsx("td",{children:l.onDelete===void 0?null:i.jsx("button",{type:"button",className:"bad",disabled:l.busy===g.subscriptionId,onClick:()=>l.onDelete?.(g.subscriptionId),children:"delete"})})]},g.subscriptionId))})]}),l.onCreate===void 0?null:i.jsxs("form",{className:"card",style:{marginTop:18},onSubmit:g=>{g.preventDefault(),j&&(l.onCreate?.({url:u.trim(),types:r,...f.length===0?{}:{agents:f}}),o(""))},children:[i.jsx("h3",{children:"New subscription"}),i.jsxs("div",{className:"model-form",style:{borderTop:"none",paddingTop:0,marginTop:0},children:[i.jsxs("label",{style:{gridColumn:"1 / -1"},children:["URL"," ",i.jsx("span",{className:"sub",children:"https only; a private address needs WEBHOOK_ALLOW on the server"}),i.jsx("input",{value:u,placeholder:"https://example.com/hooks/agent-events",onChange:g=>o(g.target.value)})]}),i.jsxs("div",{className:"field-like",style:{gridColumn:"1 / -1"},children:[i.jsxs("span",{className:"field-label",children:["Events ",i.jsxs("span",{className:"sub",children:[r.length," selected"]})]}),i.jsx("input",{"aria-label":"filter event types",value:v,placeholder:"filter…",onChange:g=>x(g.target.value)}),i.jsx("div",{className:"members",style:{marginTop:8},children:y.map(g=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:r.includes(g),onChange:()=>d(r.includes(g)?r.filter(S=>S!==g):[...r,g])}),i.jsx("code",{children:g})]},g))})]}),i.jsxs("div",{className:"field-like",style:{gridColumn:"1 / -1"},children:[i.jsxs("span",{className:"field-label",children:["Agents"," ",i.jsx("span",{className:"sub",children:"none ticked hears every agent this key reaches"})]}),i.jsx("div",{className:"members",children:l.agents.map(g=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:f.includes(g.id),onChange:()=>m(f.includes(g.id)?f.filter(S=>S!==g.id):[...f,g.id])}),g.name]},g.id))})]})]}),i.jsx("button",{type:"submit",className:"primary",style:{marginTop:12},disabled:!j||l.busy==="webhook",children:"subscribe"})]})]})}function qb(l){const[u,o]=T.useState([]),[r,d]=T.useState(""),f=r===""?l.agents[0]?.id??"":r,[m,v]=T.useState("skip"),[x,y]=T.useState(),j=g=>o(u.includes(g)?u.filter(S=>S!==g):[...u,g]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Backup"}),i.jsx("p",{children:"The whole server as a tar.gz, or one agent's memory and knowledge as a bundle another agent can take in."})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Server backup"}),i.jsxs("p",{children:["A consistent store snapshot and every hosted agent's directory, with a"," ",i.jsx("code",{children:"backup.json"})," manifest. Needs an unscoped key. Secrets, git history and the rest of the state directory are left out unless asked for."]}),i.jsx("div",{className:"members",style:{marginBottom:12},children:["env","git","home"].map(g=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:u.includes(g),onChange:()=>j(g)}),g==="env"?"each agent's .env (its secrets)":g==="git"?".git directories":"the rest of the state directory"]},g))}),i.jsx("button",{type:"button",className:"primary",disabled:l.onBackup===void 0||l.busy==="backup",onClick:()=>l.onBackup?.(u),children:l.busy==="backup"?"preparing…":"download backup"})]}),i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Agent bundle"}),i.jsxs("p",{children:[i.jsx("code",{children:"MEMORY.md"}),", the memory archive and ",i.jsx("code",{children:"knowledge/"}),". Never the manifest, secrets or skills. Importing merges memory note by note and keeps or overwrites a knowledge file."]}),i.jsxs("div",{className:"inline",style:{flexWrap:"wrap",gap:10},children:[i.jsx("select",{"aria-label":"agent",value:f,onChange:g=>d(g.target.value),style:{width:"auto"},children:l.agents.map(g=>i.jsx("option",{value:g.id,children:g.name},g.id))}),i.jsx("button",{type:"button",disabled:l.onExport===void 0||f===""||l.busy===\`export:\${f}\`,onClick:()=>l.onExport?.(f),children:"export bundle"})]}),i.jsxs("div",{className:"inline",style:{flexWrap:"wrap",gap:10,marginTop:12},children:[i.jsx("input",{type:"file",accept:"application/json,.json","aria-label":"bundle file",onChange:g=>y(g.target.files?.[0]),style:{width:"auto"}}),i.jsxs("select",{"aria-label":"knowledge mode",value:m,onChange:g=>v(g.target.value),style:{width:"auto"},children:[i.jsx("option",{value:"skip",children:"keep an existing knowledge file"}),i.jsx("option",{value:"overwrite",children:"overwrite knowledge files"})]}),i.jsxs("button",{type:"button",className:"primary",disabled:l.onImport===void 0||x===void 0||f===""||l.busy===\`import:\${f}\`,onClick:()=>{x!==void 0&&l.onImport?.(f,x,m)},children:["import into ",l.agents.find(g=>g.id===f)?.name??"agent"]})]}),l.lastImport===void 0?null:i.jsxs("p",{className:"sub",style:{marginTop:10},children:["imported: ",l.lastImport.added.length," added,"," ",l.lastImport.merged.reduce((g,S)=>g+S.notes,0)," notes merged,"," ",l.lastImport.skipped.length," kept,"," ",l.lastImport.overwritten.length," overwritten",l.lastImport.evicted>0?\`, \${l.lastImport.evicted} evicted\`:""," ","· reload ",l.lastImport.reload]})]})]})}function $b(l){const u=l.templates.filter(g=>g.problem===void 0),[o,r]=T.useState(u[0]?.name??""),[d,f]=T.useState(""),[m,v]=T.useState({}),x=l.templates.find(g=>g.name===o),y=(x?.vars??[]).filter(g=>g.required&&(m[g.name]??g.default??"")===""),j=x!==void 0&&d.trim()!==""&&y.length===0;return l.templates.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No templates"}),i.jsxs("p",{children:["A template is an agent directory under the sandbox's"," ",i.jsx("code",{children:"templates/<name>/"})," with a ",i.jsx("code",{children:"template.yaml"})," declaring its variables."]})]}):i.jsxs("form",{className:"provision",onSubmit:g=>{if(g.preventDefault(),!j||x===void 0)return;const S=Object.fromEntries(x.vars.map(N=>[N.name,m[N.name]??N.default??""]).filter(([,N])=>N!==""));l.onCreate({template:x.name,name:d.trim(),vars:S})},children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"tpl",children:"Template"}),i.jsx("select",{id:"tpl",value:o,onChange:g=>r(g.target.value),children:l.templates.map(g=>i.jsxs("option",{value:g.name,disabled:g.problem!==void 0,children:[g.name,g.problem===void 0?"":" (broken)"]},g.name))}),x?.description===void 0?null:i.jsx("p",{className:"sub",children:x.description}),x?.problem===void 0?null:i.jsx("p",{className:"error",children:x.problem.message})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"tpl-name",children:"Agent name"}),i.jsx("input",{id:"tpl-name",value:d,placeholder:"Acme store",onChange:g=>f(g.target.value)}),i.jsx("p",{className:"sub",children:"Its slug becomes the id every route keys on."})]}),(x?.vars??[]).map(g=>i.jsxs("div",{className:\`field\${y.includes(g)?" invalid":""}\`,children:[i.jsxs("label",{htmlFor:\`var-\${g.name}\`,children:[g.name,g.required?"":" (optional)",g.secret?" · secret, goes to .env":""]}),i.jsx("input",{id:\`var-\${g.name}\`,type:g.secret?"password":"text",autoComplete:g.secret?"new-password":"off",value:m[g.name]??"",placeholder:g.default??"",onChange:S=>v({...m,[g.name]:S.target.value})}),g.description===void 0?null:i.jsx("p",{className:"sub",children:g.description})]},g.name)),l.error===void 0?null:i.jsx("p",{className:"error",children:l.error}),i.jsx("button",{type:"submit",className:"primary",disabled:!j||l.busy,children:l.busy?"creating…":"create from template"})]})}function Gb(l){const[u,o]=T.useState({}),r=(l.declared??Object.keys(l.values).map(m=>({name:m,secret:!1}))).filter(m=>!m.secret),d=(l.declared??[]).filter(m=>m.secret),f=Object.fromEntries(Object.entries(u).filter(([m,v])=>v!==(l.values[m]??"")));return i.jsxs("form",{className:"card",style:{marginBottom:18},onSubmit:m=>{m.preventDefault(),l.onSave?.(f),o({})},children:[i.jsxs("h3",{children:["Made from ",i.jsx("code",{children:l.template})]}),i.jsx("p",{className:"sub",children:"Changing a value re-renders the files nobody has edited since they were made; an edited file and the agent's memory are kept as they are."}),i.jsx("div",{className:"model-form",style:{borderTop:"none",paddingTop:0,marginTop:0},children:r.map(m=>i.jsxs("label",{children:[m.name,"description"in m&&m.description!==void 0?i.jsxs("span",{className:"sub",children:[" ",m.description]}):null,i.jsx("input",{value:u[m.name]??l.values[m.name]??"",placeholder:"default"in m&&m.default!==void 0?m.default:"",onChange:v=>o({...u,[m.name]:v.target.value})})]},m.name))}),d.length===0?null:i.jsxs("p",{className:"sub",children:["Secret, kept in ",i.jsx("code",{children:".env"})," and not shown:"," ",d.map(m=>m.name).join(", "),"."]}),i.jsx("button",{type:"submit",className:"primary",style:{marginTop:12},disabled:Object.keys(f).length===0||l.onSave===void 0||l.busy,children:l.busy===!0?"saving…":"save and re-render"})]})}function Kb(l){const[u,o]=T.useState(),r=u??l.content??"",d=u!==void 0&&u!==l.content;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Files"}),i.jsxs("p",{children:["The workspace files the prompt is built from. Static files are cached and read-only for the agent; volatile ones are what ",i.jsx("code",{children:"memory_write"})," fills. A save replaces the file whole and reloads the agent; a text it would not load with is refused."]})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),l.above,l.files===void 0?i.jsx("p",{className:"empty",children:"reading…"}):l.files.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No workspace files declared"}),i.jsxs("p",{children:["Add names under ",i.jsx("code",{children:"context.static"})," or ",i.jsx("code",{children:"context.volatile"})," ","in Settings."]})]}):i.jsxs("div",{className:"rooms-layout",children:[i.jsx("div",{className:"rooms-list",children:l.files.map(f=>i.jsxs("button",{type:"button",className:"row-button","aria-current":f.name===l.selected,onClick:()=>{o(void 0),l.onSelect(f.name)},children:[i.jsx("span",{className:"pill",children:f.tier}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:f.name}),i.jsx("span",{className:"sub",style:{margin:"0 0 0 auto"},children:f.exists?\`\${f.bytes} B\`:"missing"})]},f.name))}),i.jsx("div",{className:"rooms-main",style:{minHeight:480},children:l.selected===void 0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Pick a file"}),i.jsx("p",{children:"Frontmatter and HTML comments are stripped before the model sees it."})]}):l.content===void 0?i.jsx("p",{className:"empty",style:{padding:16},children:"reading…"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"room-head",children:i.jsx("strong",{children:l.selected})}),i.jsx("textarea",{className:"editor","aria-label":\`contents of \${l.selected}\`,value:r,spellCheck:!1,onChange:f=>o(f.target.value)}),i.jsxs("div",{className:"room-post cta-row",children:[i.jsx("button",{type:"button",className:"primary",disabled:!d||l.onSave===void 0||l.busy===l.selected,onClick:()=>{l.selected!==void 0&&l.onSave?.(l.selected,r),o(void 0)},children:l.busy===l.selected?"saving…":"save and reload"}),i.jsx("button",{type:"button",disabled:!d,onClick:()=>o(void 0),children:"discard"})]})]})})]})]})}const Fr=[{type:"telegram",label:"Telegram",fields:[{key:"tokenEnv",label:"Bot token variable",hint:"the .env variable holding the BotFather token",default:"TELEGRAM_BOT_TOKEN"}]},{type:"whatsapp",label:"WhatsApp",fields:[{key:"pairWith",label:"Phone number",hint:"digits, no +; blank pairs by QR"}]},{type:"slack",label:"Slack (Socket Mode)",fields:[{key:"appTokenEnv",label:"App token variable",hint:"xapp-… in .env",default:"SLACK_APP_TOKEN"},{key:"botTokenEnv",label:"Bot token variable",hint:"xoxb-… in .env",default:"SLACK_BOT_TOKEN"}]},{type:"teams",label:"Microsoft Teams",fields:[{key:"appId",label:"App id",hint:"the Bot Framework app id"},{key:"tenantId",label:"Tenant id",hint:"optional: single-tenant bots"}]},{type:"a2a",label:"A2A (agent-to-agent)",fields:[{key:"tokenEnv",label:"Token variable",hint:"optional: a key peers present",default:"A2A_TOKEN"}]}];function Yb(l){const[u,o]=T.useState(!1),[r,d]=T.useState(Fr[0]?.type??"telegram"),[f,m]=T.useState(""),[v,x]=T.useState(""),[y,j]=T.useState({}),g=Fr.find(R=>R.type===r),S=f.trim()||r,N=l.existing.includes(S);return u?i.jsxs("form",{className:"card",style:{marginTop:14},onSubmit:R=>{if(R.preventDefault(),N||g===void 0)return;const L={id:S,type:r};for(const J of g.fields){const Z=(y[J.key]??J.default??"").trim();Z!==""&&(L[J.key]=Z)}const P=v.split(",").map(J=>J.trim()).filter(Boolean);P.length>0&&(L.allowFrom=P),l.onAdd(L),o(!1),m(""),x(""),j({})},children:[i.jsx("h3",{children:"Add a channel"}),i.jsxs("div",{className:"model-form",style:{borderTop:"none",paddingTop:0,marginTop:0},children:[i.jsxs("label",{children:["Type",i.jsx("select",{value:r,onChange:R=>d(R.target.value),children:Fr.map(R=>i.jsx("option",{value:R.type,children:R.label},R.type))})]}),i.jsxs("label",{children:["Id"," ",N?i.jsx("span",{className:"error",children:"already a channel"}):i.jsx("span",{className:"sub",children:"how schedules and the API name it"}),i.jsx("input",{value:f,placeholder:r,onChange:R=>m(R.target.value)})]}),(g?.fields??[]).map(R=>i.jsxs("label",{children:[R.label," ",i.jsx("span",{className:"sub",children:R.hint}),i.jsx("input",{value:y[R.key]??"",placeholder:R.default??"",onChange:L=>j({...y,[R.key]:L.target.value})})]},R.key)),i.jsxs("label",{style:{gridColumn:"1 / -1"},children:["Who may message it"," ",i.jsx("span",{className:"sub",children:"comma-separated handles or ids; empty permits nobody, and the log names the line to add"}),i.jsx("input",{value:v,placeholder:"@you, 123456789",onChange:R=>x(R.target.value)})]})]}),i.jsxs("p",{className:"sub",style:{margin:"10px 0"},children:["A token variable named here is read from the agent's ",i.jsx("code",{children:".env"}),"; set its value on the channel card after adding."]}),i.jsxs("div",{className:"cta-row",children:[i.jsx("button",{type:"submit",className:"primary",disabled:N||l.busy,children:"add"}),i.jsx("button",{type:"button",onClick:()=>o(!1),children:"cancel"})]})]}):i.jsx("button",{type:"button",style:{marginTop:14},onClick:()=>o(!0),children:"+ add a channel"})}const Lg=[{key:"7d",label:"7 days",days:7},{key:"30d",label:"30 days",days:30},{key:"90d",label:"90 days",days:90}];function rn(l){const u=o=>o.replace(/\\.0$/,"");return l>=1e6?\`\${u((l/1e6).toFixed(l>=1e7?0:1))}M\`:l>=1e3?\`\${u((l/1e3).toFixed(l>=1e4?0:1))}k\`:String(l)}function Su(l,u){return l.reduce((o,r)=>o+r[u],0)}function Km(l){const u=l.report,o=u?.byModel??[],r=Su(o,"promptTokens"),d=Su(o,"cachedPromptTokens"),f=Su(o,"outputTokens"),m=Su(o,"calls"),v=o.reduce((x,y)=>x+y.estimatedCalls,0);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Usage"}),i.jsxs("p",{children:["What ",l.agentName===void 0?"this server":l.agentName," spent, per model call, as the endpoint reported it.",u?.meteredSince===void 0?"":\` Metered since \${u.meteredSince.slice(0,10)}.\`]})]}),i.jsx("fieldset",{className:"segmented",style:{marginBottom:18},children:Lg.map(x=>i.jsx("button",{type:"button","aria-pressed":l.range===x.key,onClick:()=>l.onRange(x.key),children:x.label},x.key))}),l.loading&&u===void 0?i.jsx("p",{className:"empty",children:"reading the meter…"}):null,u===void 0&&!l.loading?i.jsx("p",{className:"empty",children:"nothing metered yet"}):null,u===void 0?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"tiles",children:[i.jsx(Nu,{label:"model calls",value:rn(m)}),i.jsx(Nu,{label:"prompt tokens",value:rn(r),sub:r===0?void 0:\`\${Math.round(d/r*100)}% from cache\`}),i.jsx(Nu,{label:"output tokens",value:rn(f)}),i.jsx(Nu,{label:"estimated",value:v===0?"none":\`\${v} call\${v===1?"":"s"}\`,sub:v===0?"every figure reported by the endpoint":"the endpoint reported no usage; counted by the estimator"})]}),i.jsx("div",{className:"section-title",children:"Tokens by day"}),i.jsx(Qb,{buckets:u.byDay}),i.jsxs("div",{className:"control-row",style:{gap:24},children:[i.jsxs("div",{children:[i.jsx("div",{className:"section-title",children:"By model"}),i.jsx(Wr,{buckets:u.byModel,keyOf:x=>x.model??"?",head:"model"})]}),i.jsxs("div",{children:[i.jsx("div",{className:"section-title",children:"By sender"}),i.jsx(Wr,{buckets:u.bySender,keyOf:x=>x.sender??"operator (API)",head:"sender"})]})]}),u.byAgent===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"section-title",children:"By agent"}),i.jsx(Wr,{buckets:u.byAgent,keyOf:x=>x.agentId??"?",head:"agent"})]})]})]})}function Nu(l){return i.jsxs("div",{className:"tile",children:[i.jsx("div",{className:"tile-label",children:l.label}),i.jsx("div",{className:"tile-value",children:l.value}),l.sub===void 0?null:i.jsx("div",{className:"sub",children:l.sub})]})}function Qb(l){const[u,o]=T.useState(),r=[...l.buckets].filter(R=>R.day!==void 0).sort((R,L)=>(R.day??"").localeCompare(L.day??""));if(r.length===0)return i.jsx("p",{className:"empty",children:"no calls in this range"});const d=r.map(R=>R.promptTokens+R.outputTokens),f=Math.max(...d,1),m=640,v=160,x={top:18,bottom:22,left:4,right:4},y=(m-x.left-x.right)/r.length,j=Math.max(2,y-2),g=v-x.top-x.bottom,S=[...d].sort((R,L)=>L-R).slice(0,3),N=u===void 0?void 0:r[u];return i.jsxs("div",{className:"chart",children:[i.jsxs("svg",{viewBox:\`0 0 \${m} \${v}\`,role:"img","aria-label":\`tokens per day over \${r.length} days\`,onMouseLeave:()=>o(void 0),onMouseMove:R=>{const L=R.currentTarget.getBoundingClientRect(),P=(R.clientX-L.left)/L.width*m-x.left,J=Math.floor(P/y);o(J>=0&&J<r.length?J:void 0)},children:[i.jsx("title",{children:"tokens per day"}),i.jsx("line",{x1:x.left,x2:m-x.right,y1:v-x.bottom,y2:v-x.bottom,className:"axis"}),r.map((R,L)=>{const P=d[L]??0,J=Math.max(P===0?0:2,P/f*g),Z=x.left+L*y+1,F=v-x.bottom-J,_=P>0&&S.includes(P)&&r.length<=90;return i.jsxs("g",{children:[i.jsx("rect",{className:\`bar\${u===L?" hot":""}\`,x:Z,y:F,width:j,height:J,rx:j>=6?2:0}),_?i.jsx("text",{x:Z+j/2,y:F-4,textAnchor:"middle",className:"value",children:rn(P)}):null]},R.day)}),r.length<=14?r.map((R,L)=>i.jsx("text",{x:x.left+L*y+y/2,y:v-6,textAnchor:"middle",className:"tick",children:(R.day??"").slice(5)},\`l\${R.day}\`)):[0,Math.floor(r.length/2),r.length-1].map(R=>i.jsx("text",{x:x.left+R*y+y/2,y:v-6,textAnchor:R===0?"start":R===r.length-1?"end":"middle",className:"tick",children:(r[R]?.day??"").slice(5)},\`l\${r[R]?.day}\`))]}),i.jsx("div",{className:"tooltip","aria-live":"polite",children:N===void 0?" ":\`\${N.day}: \${rn(N.promptTokens)} prompt (\${rn(N.cachedPromptTokens)} cached) · \${rn(N.outputTokens)} output · \${N.calls} call\${N.calls===1?"":"s"}\`})]})}function Wr(l){const u=[...l.buckets].sort((o,r)=>r.promptTokens+r.outputTokens-(o.promptTokens+o.outputTokens));return u.length===0?i.jsx("p",{className:"empty",children:"nothing in this range"}):i.jsxs("table",{className:"panel-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:l.head}),i.jsx("th",{children:"calls"}),i.jsx("th",{children:"prompt"}),i.jsx("th",{children:"cached"}),i.jsx("th",{children:"output"})]})}),i.jsx("tbody",{children:u.map(o=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("code",{children:l.keyOf(o)}),o.estimatedCalls>0?i.jsxs("div",{className:"sub",children:[o.estimatedCalls," estimated"]}):null]}),i.jsx("td",{children:o.calls}),i.jsx("td",{children:rn(o.promptTokens)}),i.jsx("td",{children:rn(o.cachedPromptTokens)}),i.jsx("td",{children:rn(o.outputTokens)})]},l.keyOf(o)))})]})}function ku(l){return l.trim().charAt(0)||"?"}const qg=l=>rn(l.promptTokens+l.outputTokens);function Xb(l){const u=l.agents.filter(r=>r.status!=="disabled").length,o=l.week===void 0?void 0:l.week.reduce((r,d)=>({calls:r.calls+d.calls,promptTokens:r.promptTokens+d.promptTokens,outputTokens:r.outputTokens+d.outputTokens}),{calls:0,promptTokens:0,outputTokens:0});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Agents"}),i.jsxs("p",{children:[l.agents.length," on this server · ",u," running",o===void 0?null:i.jsxs(i.Fragment,{children:[" · ",o.calls," model calls, ",qg(o)," tokens in 7 days",l.onUsage===void 0?null:i.jsxs(i.Fragment,{children:[" ",i.jsx("button",{type:"button",className:"link",onClick:l.onUsage,children:"usage"})]})]})]})]}),l.agents.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No agents yet"}),i.jsxs("p",{children:["Create one here, or run \`",tt.slug," init\` in a terminal."]}),i.jsx("p",{style:{marginTop:14},children:i.jsx("button",{type:"button",className:"primary",onClick:l.onNew,children:"New agent"})})]}):i.jsx("div",{className:"grid",children:l.agents.map(r=>i.jsx(Vb,{agent:r,...l.week===void 0?{}:{week:l.week.find(d=>d.agentId===r.id)??{calls:0,promptTokens:0,outputTokens:0}},onOpen:l.onOpen,onStart:l.onStart,starting:l.starting===r.id},r.id))})]})}function Vb(l){const{agent:u}=l,o=u.status==="disabled",r=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"head",children:[i.jsx("span",{className:"avatar",children:ku(u.name)}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{className:"name",children:u.name}),i.jsx("div",{className:"id",children:u.id})]}),i.jsxs("span",{style:{marginLeft:"auto"},className:\`pill \${o?"warn":"ok"}\`,children:[i.jsx("span",{className:\`dot \${o?"off":"live"}\`}),o?"stopped":"running"]})]}),u.model===void 0?null:i.jsx("div",{className:"model",children:u.model}),i.jsxs("div",{className:"stats",children:[u.dialect===void 0?null:i.jsx("span",{className:"pill accent",children:u.dialect}),(u.channels??[]).map(d=>i.jsxs("span",{className:"pill",children:[i.jsx("span",{className:\`dot \${d.status==="connected"?"live":"off"}\`}),d.type]},d.id))]}),l.week===void 0?null:i.jsx("div",{className:"sub",style:{margin:0},children:l.week.calls===0?"no model calls in 7 days":\`\${l.week.calls} calls · \${qg(l.week)} tokens in 7 days\`})]});return o?i.jsxs("div",{className:"agent-card off",children:[r,i.jsxs("div",{className:"sub",style:{margin:0},children:[u.reason??"switched off"," ",i.jsx("button",{type:"button",className:"link",disabled:l.starting,onClick:()=>l.onStart(u.id),children:l.starting?"starting…":"start"})]})]}):i.jsx("button",{type:"button",className:"agent-card",onClick:()=>l.onOpen(u.id),children:r})}function Zb(l){const u=l.team??[],o=l.peers??[];return i.jsxs(i.Fragment,{children:[l.owner===void 0?null:i.jsxs("label",{className:"inline-field",style:{marginBottom:18},children:["Works for",i.jsxs("select",{"aria-label":\`whom \${l.lead.name} works for\`,value:l.owner??"",disabled:l.busy===!0||l.onAssign===void 0,onChange:r=>l.onAssign?.(r.target.value===""?void 0:r.target.value),children:[i.jsx("option",{value:"",children:"nobody: a shared agent"}),(l.people??[]).map(r=>i.jsx("option",{value:r.id,children:r.name===void 0?r.id:\`\${r.name} (\${r.id})\`},r.id))]})]}),i.jsx(Jb,{name:l.lead.name,peers:o,ask:l.ask===!0,busy:l.busy===!0,...l.onAsk===void 0?{}:{onAsk:l.onAsk}}),i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Team"}),i.jsxs("p",{children:["Who ",l.lead.name," delegates to. Members are reached through it, never directly, so its policy holds for every call they make."]})]}),i.jsxs("div",{className:"lead",children:[i.jsx("span",{className:"avatar",style:{width:32,height:32},children:ku(l.lead.name)}),i.jsxs("div",{children:[i.jsx("div",{style:{fontWeight:600},children:l.lead.name}),i.jsxs("div",{className:"sub",style:{margin:0},children:["supervisor · ",u.length," member",u.length===1?"":"s"]})]})]}),u.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No team"}),i.jsxs("p",{children:["Add a ",i.jsx("code",{children:"team:"})," block to this agent's ",i.jsx("code",{children:"agent.yaml"})," to give it members it can hand work to."]})]}):i.jsx("div",{className:"grid",children:u.map(r=>i.jsxs("div",{className:"member",children:[i.jsxs("div",{className:"head",children:[i.jsx("span",{className:"avatar",children:ku(r.id)}),i.jsx("strong",{children:r.id})]}),i.jsx("p",{className:"task",children:r.task}),i.jsx("div",{className:"stats",children:r.artifact.map(d=>i.jsx("span",{className:"pill",children:d},d))})]},r.id))})]})}function Jb(l){return i.jsxs("section",{style:{marginBottom:40},children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Peers"}),i.jsxs("p",{children:["The other agents working for the same person, which ",l.name," can ask a question. Both sides have to switch this on."]})]}),i.jsxs("label",{className:"check",style:{marginBottom:16},children:[i.jsx("input",{type:"checkbox",checked:l.ask,disabled:l.busy||l.onAsk===void 0,onChange:u=>l.onAsk?.(u.target.checked)}),i.jsxs("span",{children:["Ask and be asked ",i.jsx("code",{children:"delegation.ask"})]})]}),l.peers.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Nobody to ask"}),i.jsx("p",{children:l.ask?"Either no other agent of this person, and no shared agent, has peer ask on, or this agent is assigned to nobody: a shared agent is asked but never asks.":"Switch it on to let this agent ask the person's other agents, and be asked by them."})]}):i.jsx("div",{className:"grid",children:l.peers.map(u=>i.jsxs("div",{className:"member",children:[i.jsxs("div",{className:"head",children:[i.jsx("span",{className:"avatar",children:ku(u.name??u.id)}),i.jsx("strong",{children:u.name??u.id})]}),u.description===void 0?null:i.jsx("p",{className:"task",children:u.description}),i.jsxs("div",{className:"stats",children:[u.name===void 0?null:i.jsx("span",{className:"pill",children:u.id}),u.shared?i.jsx("span",{className:"pill",children:"shared"}):null,u.remote?i.jsx("span",{className:"pill",children:"another silo"}):null]})]},u.id))})]})}function Fb(l){const[u,o]=T.useState(!1);return i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(l.text).then(()=>{o(!0),setTimeout(()=>o(!1),1200)}).catch(()=>{})},children:u?"copied":"copy"})}function Ym(l){return i.jsxs("div",{style:{marginBottom:16},children:[i.jsxs("div",{className:"snippet-head",children:[i.jsx("h3",{children:l.title}),i.jsx(Fb,{text:l.code})]}),i.jsx("pre",{className:"snippet",children:l.code})]})}const Wb=[{method:"GET",path:"/v1/agents",what:"every agent, running or stopped"},{method:"POST",path:"/v1/agents/:id/messages",what:"start a turn"},{method:"GET",path:"/v1/agents/:id/turns/:turnId/stream",what:"a turn's events (SSE)"},{method:"GET",path:"/v1/agents/:id/sessions",what:"conversations"},{method:"GET",path:"/v1/agents/:id/approvals",what:"questions waiting on you"},{method:"POST",path:"/v1/keys",what:"mint an operator key"}];function Ib(l){const u=l.baseUrl.replace(/\\/$/,""),o=l.agentId??"<agent>",r=\`\${tt.envPrefix}API_TOKEN\`,d=\`curl -X POST \${u}/v1/agents/\${o}/messages \\\\
33
+ -H "Authorization: Bearer $\${r}" \\\\
34
+ -H "Content-Type: application/json" \\\\
35
+ -d '{"text": "hello", "stream": true}'\`,f=\`curl \${u}/v1/agents \\\\
36
+ -H "Authorization: Bearer $\${r}"\`,m=\`\${tt.slug} credential create --label my-app\`;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"API"}),i.jsx("p",{children:"Everything on this page is one HTTP API. Your backend sends a message; the agent runs with its memory, tools, schedules and channels."})]}),i.jsxs("div",{className:"cta-row",style:{marginBottom:24},children:[i.jsx("a",{className:"primary",href:\`\${u}/docs\`,target:"_blank",rel:"noreferrer",children:"API reference ↗"}),i.jsx("a",{href:\`\${u}/v1/openapi.json\`,target:"_blank",rel:"noreferrer",children:"openapi.json"})]}),i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Authentication"}),i.jsxs("p",{style:{margin:0},children:["Send ",i.jsx("code",{children:"Authorization: Bearer <token>"}),". Two kinds work: the server's own ",i.jsx("code",{children:r})," — one per process, from the environment the server was started with (in a container, the container's), not an agent's"," ",i.jsx("code",{children:".env"})," — or an operator key minted with ",i.jsx("code",{children:m})," or"," ",i.jsx("code",{children:"POST /v1/keys"}),", which can be scoped and revoked."]})]}),i.jsx("div",{className:"section-title",children:"Quickstart"}),i.jsx(Ym,{title:"List agents",code:f}),i.jsx(Ym,{title:"Send a message, streamed",code:d}),i.jsx("div",{className:"section-title",children:"Common endpoints"}),i.jsx("div",{className:"endpoints",children:Wb.map(v=>i.jsxs("div",{className:"endpoint",children:[i.jsx("span",{className:\`method \${v.method==="GET"?"get":""}\`,children:v.method}),i.jsx("code",{children:v.path}),i.jsx("span",{className:"what",children:v.what})]},\`\${v.method} \${v.path}\`))})]})}const $g=\`\${tt.slug}.theme\`;function Gg(){try{const l=localStorage.getItem($g);return l==="dark"||l==="light"?l:void 0}catch{return}}function Kg(l){l===void 0?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",l)}function Pb(){const[l,u]=T.useState(()=>Gg()??(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")),o=l==="dark"?"light":"dark";return i.jsx("button",{type:"button",className:"ghost","aria-label":\`switch to \${o} theme\`,title:\`switch to \${o} theme\`,onClick:()=>{u(o),Kg(o);try{localStorage.setItem($g,o)}catch{}},children:l==="dark"?"☾":"☀"})}function ep(l){const[u,o]=T.useState(""),[r,d]=T.useState(0),f=T.useRef(null),m=hb(l.entries,u),v=Math.min(r,Math.max(m.length-1,0));return T.useEffect(()=>f.current?.focus(),[]),i.jsxs("div",{className:"palette-layer",children:[i.jsx("button",{type:"button",className:"palette-backdrop","aria-label":"close",tabIndex:-1,onClick:l.onClose}),i.jsxs("div",{className:"palette",role:"dialog","aria-label":"go to",children:[i.jsx("input",{ref:f,value:u,placeholder:"Go to a page or an agent…","aria-label":"search pages and agents",onChange:x=>{o(x.target.value),d(0)},onKeyDown:x=>{if(x.key==="Escape")l.onClose();else if(x.key==="ArrowDown")x.preventDefault(),d(Math.min(v+1,m.length-1));else if(x.key==="ArrowUp")x.preventDefault(),d(Math.max(v-1,0));else if(x.key==="Enter"){const y=m[v];y!==void 0&&l.onPick(y)}}}),m.length===0?i.jsxs("p",{className:"empty",children:['Nothing matches "',u,'".']}):i.jsx("ul",{className:"palette-list",children:m.map((x,y)=>i.jsx("li",{children:i.jsxs("button",{type:"button",className:"palette-item","aria-current":y===v,onMouseEnter:()=>d(y),onClick:()=>l.onPick(x),children:[i.jsx("span",{children:x.label}),i.jsx("span",{className:"sub",children:x.hint})]})},x.id))})]})]})}var Xl={},Ir,Qm;function tp(){return Qm||(Qm=1,Ir=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ir}var Pr={},Na={},Xm;function sl(){if(Xm)return Na;Xm=1;let l;const u=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Na.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Na.getSymbolTotalCodewords=function(r){return u[r]},Na.getBCHDigit=function(o){let r=0;for(;o!==0;)r++,o>>>=1;return r},Na.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');l=r},Na.isKanjiModeEnabled=function(){return typeof l<"u"},Na.toSJIS=function(r){return l(r)},Na}var eo={},Vm;function qo(){return Vm||(Vm=1,(function(l){l.L={bit:1},l.M={bit:0},l.Q={bit:3},l.H={bit:2};function u(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return l.L;case"m":case"medium":return l.M;case"q":case"quartile":return l.Q;case"h":case"high":return l.H;default:throw new Error("Unknown EC Level: "+o)}}l.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},l.from=function(r,d){if(l.isValid(r))return r;try{return u(r)}catch{return d}}})(eo)),eo}var to,Zm;function np(){if(Zm)return to;Zm=1;function l(){this.buffer=[],this.length=0}return l.prototype={get:function(u){const o=Math.floor(u/8);return(this.buffer[o]>>>7-u%8&1)===1},put:function(u,o){for(let r=0;r<o;r++)this.putBit((u>>>o-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(u){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),u&&(this.buffer[o]|=128>>>this.length%8),this.length++}},to=l,to}var no,Jm;function ap(){if(Jm)return no;Jm=1;function l(u){if(!u||u<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=u,this.data=new Uint8Array(u*u),this.reservedBit=new Uint8Array(u*u)}return l.prototype.set=function(u,o,r,d){const f=u*this.size+o;this.data[f]=r,d&&(this.reservedBit[f]=!0)},l.prototype.get=function(u,o){return this.data[u*this.size+o]},l.prototype.xor=function(u,o,r){this.data[u*this.size+o]^=r},l.prototype.isReserved=function(u,o){return this.reservedBit[u*this.size+o]},no=l,no}var ao={},Fm;function lp(){return Fm||(Fm=1,(function(l){const u=sl().getSymbolSize;l.getRowColCoords=function(r){if(r===1)return[];const d=Math.floor(r/7)+2,f=u(r),m=f===145?26:Math.ceil((f-13)/(2*d-2))*2,v=[f-7];for(let x=1;x<d-1;x++)v[x]=v[x-1]-m;return v.push(6),v.reverse()},l.getPositions=function(r){const d=[],f=l.getRowColCoords(r),m=f.length;for(let v=0;v<m;v++)for(let x=0;x<m;x++)v===0&&x===0||v===0&&x===m-1||v===m-1&&x===0||d.push([f[v],f[x]]);return d}})(ao)),ao}var lo={},Wm;function ip(){if(Wm)return lo;Wm=1;const l=sl().getSymbolSize,u=7;return lo.getPositions=function(r){const d=l(r);return[[0,0],[d-u,0],[0,d-u]]},lo}var io={},Im;function sp(){return Im||(Im=1,(function(l){l.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const u={N1:3,N2:3,N3:40,N4:10};l.isValid=function(d){return d!=null&&d!==""&&!isNaN(d)&&d>=0&&d<=7},l.from=function(d){return l.isValid(d)?parseInt(d,10):void 0},l.getPenaltyN1=function(d){const f=d.size;let m=0,v=0,x=0,y=null,j=null;for(let g=0;g<f;g++){v=x=0,y=j=null;for(let S=0;S<f;S++){let N=d.get(g,S);N===y?v++:(v>=5&&(m+=u.N1+(v-5)),y=N,v=1),N=d.get(S,g),N===j?x++:(x>=5&&(m+=u.N1+(x-5)),j=N,x=1)}v>=5&&(m+=u.N1+(v-5)),x>=5&&(m+=u.N1+(x-5))}return m},l.getPenaltyN2=function(d){const f=d.size;let m=0;for(let v=0;v<f-1;v++)for(let x=0;x<f-1;x++){const y=d.get(v,x)+d.get(v,x+1)+d.get(v+1,x)+d.get(v+1,x+1);(y===4||y===0)&&m++}return m*u.N2},l.getPenaltyN3=function(d){const f=d.size;let m=0,v=0,x=0;for(let y=0;y<f;y++){v=x=0;for(let j=0;j<f;j++)v=v<<1&2047|d.get(y,j),j>=10&&(v===1488||v===93)&&m++,x=x<<1&2047|d.get(j,y),j>=10&&(x===1488||x===93)&&m++}return m*u.N3},l.getPenaltyN4=function(d){let f=0;const m=d.data.length;for(let x=0;x<m;x++)f+=d.data[x];return Math.abs(Math.ceil(f*100/m/5)-10)*u.N4};function o(r,d,f){switch(r){case l.Patterns.PATTERN000:return(d+f)%2===0;case l.Patterns.PATTERN001:return d%2===0;case l.Patterns.PATTERN010:return f%3===0;case l.Patterns.PATTERN011:return(d+f)%3===0;case l.Patterns.PATTERN100:return(Math.floor(d/2)+Math.floor(f/3))%2===0;case l.Patterns.PATTERN101:return d*f%2+d*f%3===0;case l.Patterns.PATTERN110:return(d*f%2+d*f%3)%2===0;case l.Patterns.PATTERN111:return(d*f%3+(d+f)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}l.applyMask=function(d,f){const m=f.size;for(let v=0;v<m;v++)for(let x=0;x<m;x++)f.isReserved(x,v)||f.xor(x,v,o(d,x,v))},l.getBestMask=function(d,f){const m=Object.keys(l.Patterns).length;let v=0,x=1/0;for(let y=0;y<m;y++){f(y),l.applyMask(y,d);const j=l.getPenaltyN1(d)+l.getPenaltyN2(d)+l.getPenaltyN3(d)+l.getPenaltyN4(d);l.applyMask(y,d),j<x&&(x=j,v=y)}return v}})(io)),io}var wu={},Pm;function Yg(){if(Pm)return wu;Pm=1;const l=qo(),u=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return wu.getBlocksCount=function(d,f){switch(f){case l.L:return u[(d-1)*4+0];case l.M:return u[(d-1)*4+1];case l.Q:return u[(d-1)*4+2];case l.H:return u[(d-1)*4+3];default:return}},wu.getTotalCodewordsCount=function(d,f){switch(f){case l.L:return o[(d-1)*4+0];case l.M:return o[(d-1)*4+1];case l.Q:return o[(d-1)*4+2];case l.H:return o[(d-1)*4+3];default:return}},wu}var so={},Ji={},eg;function up(){if(eg)return Ji;eg=1;const l=new Uint8Array(512),u=new Uint8Array(256);return(function(){let r=1;for(let d=0;d<255;d++)l[d]=r,u[r]=d,r<<=1,r&256&&(r^=285);for(let d=255;d<512;d++)l[d]=l[d-255]})(),Ji.log=function(r){if(r<1)throw new Error("log("+r+")");return u[r]},Ji.exp=function(r){return l[r]},Ji.mul=function(r,d){return r===0||d===0?0:l[u[r]+u[d]]},Ji}var tg;function cp(){return tg||(tg=1,(function(l){const u=up();l.mul=function(r,d){const f=new Uint8Array(r.length+d.length-1);for(let m=0;m<r.length;m++)for(let v=0;v<d.length;v++)f[m+v]^=u.mul(r[m],d[v]);return f},l.mod=function(r,d){let f=new Uint8Array(r);for(;f.length-d.length>=0;){const m=f[0];for(let x=0;x<d.length;x++)f[x]^=u.mul(d[x],m);let v=0;for(;v<f.length&&f[v]===0;)v++;f=f.slice(v)}return f},l.generateECPolynomial=function(r){let d=new Uint8Array([1]);for(let f=0;f<r;f++)d=l.mul(d,new Uint8Array([1,u.exp(f)]));return d}})(so)),so}var uo,ng;function rp(){if(ng)return uo;ng=1;const l=cp();function u(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return u.prototype.initialize=function(r){this.degree=r,this.genPoly=l.generateECPolynomial(this.degree)},u.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const d=new Uint8Array(r.length+this.degree);d.set(r);const f=l.mod(d,this.genPoly),m=this.degree-f.length;if(m>0){const v=new Uint8Array(this.degree);return v.set(f,m),v}return f},uo=u,uo}var co={},ro={},oo={},ag;function Qg(){return ag||(ag=1,oo.isValid=function(u){return!isNaN(u)&&u>=1&&u<=40}),oo}var bn={},lg;function Xg(){if(lg)return bn;lg=1;const l="[0-9]+",u="[A-Z $%*+\\\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\\\u");const r="(?:(?![A-Z0-9 $%*+\\\\-./:]|"+o+\`)(?:.|[\\r
37
+ ]))+\`;bn.KANJI=new RegExp(o,"g"),bn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\\\-./:]+","g"),bn.BYTE=new RegExp(r,"g"),bn.NUMERIC=new RegExp(l,"g"),bn.ALPHANUMERIC=new RegExp(u,"g");const d=new RegExp("^"+o+"$"),f=new RegExp("^"+l+"$"),m=new RegExp("^[A-Z0-9 $%*+\\\\-./:]+$");return bn.testKanji=function(x){return d.test(x)},bn.testNumeric=function(x){return f.test(x)},bn.testAlphanumeric=function(x){return m.test(x)},bn}var ig;function ul(){return ig||(ig=1,(function(l){const u=Qg(),o=Xg();l.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},l.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},l.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},l.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},l.MIXED={bit:-1},l.getCharCountIndicator=function(f,m){if(!f.ccBits)throw new Error("Invalid mode: "+f);if(!u.isValid(m))throw new Error("Invalid version: "+m);return m>=1&&m<10?f.ccBits[0]:m<27?f.ccBits[1]:f.ccBits[2]},l.getBestModeForData=function(f){return o.testNumeric(f)?l.NUMERIC:o.testAlphanumeric(f)?l.ALPHANUMERIC:o.testKanji(f)?l.KANJI:l.BYTE},l.toString=function(f){if(f&&f.id)return f.id;throw new Error("Invalid mode")},l.isValid=function(f){return f&&f.bit&&f.ccBits};function r(d){if(typeof d!="string")throw new Error("Param is not a string");switch(d.toLowerCase()){case"numeric":return l.NUMERIC;case"alphanumeric":return l.ALPHANUMERIC;case"kanji":return l.KANJI;case"byte":return l.BYTE;default:throw new Error("Unknown mode: "+d)}}l.from=function(f,m){if(l.isValid(f))return f;try{return r(f)}catch{return m}}})(ro)),ro}var sg;function op(){return sg||(sg=1,(function(l){const u=sl(),o=Yg(),r=qo(),d=ul(),f=Qg(),m=7973,v=u.getBCHDigit(m);function x(S,N,R){for(let L=1;L<=40;L++)if(N<=l.getCapacity(L,R,S))return L}function y(S,N){return d.getCharCountIndicator(S,N)+4}function j(S,N){let R=0;return S.forEach(function(L){const P=y(L.mode,N);R+=P+L.getBitsLength()}),R}function g(S,N){for(let R=1;R<=40;R++)if(j(S,R)<=l.getCapacity(R,N,d.MIXED))return R}l.from=function(N,R){return f.isValid(N)?parseInt(N,10):R},l.getCapacity=function(N,R,L){if(!f.isValid(N))throw new Error("Invalid QR Code version");typeof L>"u"&&(L=d.BYTE);const P=u.getSymbolTotalCodewords(N),J=o.getTotalCodewordsCount(N,R),Z=(P-J)*8;if(L===d.MIXED)return Z;const F=Z-y(L,N);switch(L){case d.NUMERIC:return Math.floor(F/10*3);case d.ALPHANUMERIC:return Math.floor(F/11*2);case d.KANJI:return Math.floor(F/13);case d.BYTE:default:return Math.floor(F/8)}},l.getBestVersionForData=function(N,R){let L;const P=r.from(R,r.M);if(Array.isArray(N)){if(N.length>1)return g(N,P);if(N.length===0)return 1;L=N[0]}else L=N;return x(L.mode,L.getLength(),P)},l.getEncodedBits=function(N){if(!f.isValid(N)||N<7)throw new Error("Invalid QR Code version");let R=N<<12;for(;u.getBCHDigit(R)-v>=0;)R^=m<<u.getBCHDigit(R)-v;return N<<12|R}})(co)),co}var fo={},ug;function dp(){if(ug)return fo;ug=1;const l=sl(),u=1335,o=21522,r=l.getBCHDigit(u);return fo.getEncodedBits=function(f,m){const v=f.bit<<3|m;let x=v<<10;for(;l.getBCHDigit(x)-r>=0;)x^=u<<l.getBCHDigit(x)-r;return(v<<10|x)^o},fo}var ho={},mo,cg;function fp(){if(cg)return mo;cg=1;const l=ul();function u(o){this.mode=l.NUMERIC,this.data=o.toString()}return u.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},u.prototype.getLength=function(){return this.data.length},u.prototype.getBitsLength=function(){return u.getBitsLength(this.data.length)},u.prototype.write=function(r){let d,f,m;for(d=0;d+3<=this.data.length;d+=3)f=this.data.substr(d,3),m=parseInt(f,10),r.put(m,10);const v=this.data.length-d;v>0&&(f=this.data.substr(d),m=parseInt(f,10),r.put(m,v*3+1))},mo=u,mo}var go,rg;function hp(){if(rg)return go;rg=1;const l=ul(),u=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(r){this.mode=l.ALPHANUMERIC,this.data=r}return o.getBitsLength=function(d){return 11*Math.floor(d/2)+6*(d%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(d){let f;for(f=0;f+2<=this.data.length;f+=2){let m=u.indexOf(this.data[f])*45;m+=u.indexOf(this.data[f+1]),d.put(m,11)}this.data.length%2&&d.put(u.indexOf(this.data[f]),6)},go=o,go}var vo,og;function mp(){if(og)return vo;og=1;const l=ul();function u(o){this.mode=l.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return u.getBitsLength=function(r){return r*8},u.prototype.getLength=function(){return this.data.length},u.prototype.getBitsLength=function(){return u.getBitsLength(this.data.length)},u.prototype.write=function(o){for(let r=0,d=this.data.length;r<d;r++)o.put(this.data[r],8)},vo=u,vo}var yo,dg;function gp(){if(dg)return yo;dg=1;const l=ul(),u=sl();function o(r){this.mode=l.KANJI,this.data=r}return o.getBitsLength=function(d){return d*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let d;for(d=0;d<this.data.length;d++){let f=u.toSJIS(this.data[d]);if(f>=33088&&f<=40956)f-=33088;else if(f>=57408&&f<=60351)f-=49472;else throw new Error("Invalid SJIS character: "+this.data[d]+\`
38
+ Make sure your charset is UTF-8\`);f=(f>>>8&255)*192+(f&255),r.put(f,13)}},yo=o,yo}var bo={exports:{}},fg;function vp(){return fg||(fg=1,(function(l){var u={single_source_shortest_paths:function(o,r,d){var f={},m={};m[r]=0;var v=u.PriorityQueue.make();v.push(r,0);for(var x,y,j,g,S,N,R,L,P;!v.empty();){x=v.pop(),y=x.value,g=x.cost,S=o[y]||{};for(j in S)S.hasOwnProperty(j)&&(N=S[j],R=g+N,L=m[j],P=typeof m[j]>"u",(P||L>R)&&(m[j]=R,v.push(j,R),f[j]=y))}if(typeof d<"u"&&typeof m[d]>"u"){var J=["Could not find a path from ",r," to ",d,"."].join("");throw new Error(J)}return f},extract_shortest_path_from_predecessor_list:function(o,r){for(var d=[],f=r;f;)d.push(f),o[f],f=o[f];return d.reverse(),d},find_path:function(o,r,d){var f=u.single_source_shortest_paths(o,r,d);return u.extract_shortest_path_from_predecessor_list(f,d)},PriorityQueue:{make:function(o){var r=u.PriorityQueue,d={},f;o=o||{};for(f in r)r.hasOwnProperty(f)&&(d[f]=r[f]);return d.queue=[],d.sorter=o.sorter||r.default_sorter,d},default_sorter:function(o,r){return o.cost-r.cost},push:function(o,r){var d={value:o,cost:r};this.queue.push(d),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};l.exports=u})(bo)),bo.exports}var hg;function yp(){return hg||(hg=1,(function(l){const u=ul(),o=fp(),r=hp(),d=mp(),f=gp(),m=Xg(),v=sl(),x=vp();function y(J){return unescape(encodeURIComponent(J)).length}function j(J,Z,F){const _=[];let ge;for(;(ge=J.exec(F))!==null;)_.push({data:ge[0],index:ge.index,mode:Z,length:ge[0].length});return _}function g(J){const Z=j(m.NUMERIC,u.NUMERIC,J),F=j(m.ALPHANUMERIC,u.ALPHANUMERIC,J);let _,ge;return v.isKanjiModeEnabled()?(_=j(m.BYTE,u.BYTE,J),ge=j(m.KANJI,u.KANJI,J)):(_=j(m.BYTE_KANJI,u.BYTE,J),ge=[]),Z.concat(F,_,ge).sort(function(V,le){return V.index-le.index}).map(function(V){return{data:V.data,mode:V.mode,length:V.length}})}function S(J,Z){switch(Z){case u.NUMERIC:return o.getBitsLength(J);case u.ALPHANUMERIC:return r.getBitsLength(J);case u.KANJI:return f.getBitsLength(J);case u.BYTE:return d.getBitsLength(J)}}function N(J){return J.reduce(function(Z,F){const _=Z.length-1>=0?Z[Z.length-1]:null;return _&&_.mode===F.mode?(Z[Z.length-1].data+=F.data,Z):(Z.push(F),Z)},[])}function R(J){const Z=[];for(let F=0;F<J.length;F++){const _=J[F];switch(_.mode){case u.NUMERIC:Z.push([_,{data:_.data,mode:u.ALPHANUMERIC,length:_.length},{data:_.data,mode:u.BYTE,length:_.length}]);break;case u.ALPHANUMERIC:Z.push([_,{data:_.data,mode:u.BYTE,length:_.length}]);break;case u.KANJI:Z.push([_,{data:_.data,mode:u.BYTE,length:y(_.data)}]);break;case u.BYTE:Z.push([{data:_.data,mode:u.BYTE,length:y(_.data)}])}}return Z}function L(J,Z){const F={},_={start:{}};let ge=["start"];for(let ee=0;ee<J.length;ee++){const V=J[ee],le=[];for(let W=0;W<V.length;W++){const Y=V[W],ne=""+ee+W;le.push(ne),F[ne]={node:Y,lastCount:0},_[ne]={};for(let ae=0;ae<ge.length;ae++){const Q=ge[ae];F[Q]&&F[Q].node.mode===Y.mode?(_[Q][ne]=S(F[Q].lastCount+Y.length,Y.mode)-S(F[Q].lastCount,Y.mode),F[Q].lastCount+=Y.length):(F[Q]&&(F[Q].lastCount=Y.length),_[Q][ne]=S(Y.length,Y.mode)+4+u.getCharCountIndicator(Y.mode,Z))}}ge=le}for(let ee=0;ee<ge.length;ee++)_[ge[ee]].end=0;return{map:_,table:F}}function P(J,Z){let F;const _=u.getBestModeForData(J);if(F=u.from(Z,_),F!==u.BYTE&&F.bit<_.bit)throw new Error('"'+J+'" cannot be encoded with mode '+u.toString(F)+\`.
39
+ Suggested mode is: \`+u.toString(_));switch(F===u.KANJI&&!v.isKanjiModeEnabled()&&(F=u.BYTE),F){case u.NUMERIC:return new o(J);case u.ALPHANUMERIC:return new r(J);case u.KANJI:return new f(J);case u.BYTE:return new d(J)}}l.fromArray=function(Z){return Z.reduce(function(F,_){return typeof _=="string"?F.push(P(_,null)):_.data&&F.push(P(_.data,_.mode)),F},[])},l.fromString=function(Z,F){const _=g(Z,v.isKanjiModeEnabled()),ge=R(_),ee=L(ge,F),V=x.find_path(ee.map,"start","end"),le=[];for(let W=1;W<V.length-1;W++)le.push(ee.table[V[W]].node);return l.fromArray(N(le))},l.rawSplit=function(Z){return l.fromArray(g(Z,v.isKanjiModeEnabled()))}})(ho)),ho}var mg;function bp(){if(mg)return Pr;mg=1;const l=sl(),u=qo(),o=np(),r=ap(),d=lp(),f=ip(),m=sp(),v=Yg(),x=rp(),y=op(),j=dp(),g=ul(),S=yp();function N(ee,V){const le=ee.size,W=f.getPositions(V);for(let Y=0;Y<W.length;Y++){const ne=W[Y][0],ae=W[Y][1];for(let Q=-1;Q<=7;Q++)if(!(ne+Q<=-1||le<=ne+Q))for(let se=-1;se<=7;se++)ae+se<=-1||le<=ae+se||(Q>=0&&Q<=6&&(se===0||se===6)||se>=0&&se<=6&&(Q===0||Q===6)||Q>=2&&Q<=4&&se>=2&&se<=4?ee.set(ne+Q,ae+se,!0,!0):ee.set(ne+Q,ae+se,!1,!0))}}function R(ee){const V=ee.size;for(let le=8;le<V-8;le++){const W=le%2===0;ee.set(le,6,W,!0),ee.set(6,le,W,!0)}}function L(ee,V){const le=d.getPositions(V);for(let W=0;W<le.length;W++){const Y=le[W][0],ne=le[W][1];for(let ae=-2;ae<=2;ae++)for(let Q=-2;Q<=2;Q++)ae===-2||ae===2||Q===-2||Q===2||ae===0&&Q===0?ee.set(Y+ae,ne+Q,!0,!0):ee.set(Y+ae,ne+Q,!1,!0)}}function P(ee,V){const le=ee.size,W=y.getEncodedBits(V);let Y,ne,ae;for(let Q=0;Q<18;Q++)Y=Math.floor(Q/3),ne=Q%3+le-8-3,ae=(W>>Q&1)===1,ee.set(Y,ne,ae,!0),ee.set(ne,Y,ae,!0)}function J(ee,V,le){const W=ee.size,Y=j.getEncodedBits(V,le);let ne,ae;for(ne=0;ne<15;ne++)ae=(Y>>ne&1)===1,ne<6?ee.set(ne,8,ae,!0):ne<8?ee.set(ne+1,8,ae,!0):ee.set(W-15+ne,8,ae,!0),ne<8?ee.set(8,W-ne-1,ae,!0):ne<9?ee.set(8,15-ne-1+1,ae,!0):ee.set(8,15-ne-1,ae,!0);ee.set(W-8,8,1,!0)}function Z(ee,V){const le=ee.size;let W=-1,Y=le-1,ne=7,ae=0;for(let Q=le-1;Q>0;Q-=2)for(Q===6&&Q--;;){for(let se=0;se<2;se++)if(!ee.isReserved(Y,Q-se)){let re=!1;ae<V.length&&(re=(V[ae]>>>ne&1)===1),ee.set(Y,Q-se,re),ne--,ne===-1&&(ae++,ne=7)}if(Y+=W,Y<0||le<=Y){Y-=W,W=-W;break}}}function F(ee,V,le){const W=new o;le.forEach(function(se){W.put(se.mode.bit,4),W.put(se.getLength(),g.getCharCountIndicator(se.mode,ee)),se.write(W)});const Y=l.getSymbolTotalCodewords(ee),ne=v.getTotalCodewordsCount(ee,V),ae=(Y-ne)*8;for(W.getLengthInBits()+4<=ae&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const Q=(ae-W.getLengthInBits())/8;for(let se=0;se<Q;se++)W.put(se%2?17:236,8);return _(W,ee,V)}function _(ee,V,le){const W=l.getSymbolTotalCodewords(V),Y=v.getTotalCodewordsCount(V,le),ne=W-Y,ae=v.getBlocksCount(V,le),Q=W%ae,se=ae-Q,re=Math.floor(W/ae),D=Math.floor(ne/ae),te=D+1,K=re-D,Ce=new x(K);let Ae=0;const A=new Array(ae),q=new Array(ae);let I=0;const ie=new Uint8Array(ee.buffer);for(let oe=0;oe<ae;oe++){const Wt=oe<se?D:te;A[oe]=ie.slice(Ae,Ae+Wt),q[oe]=Ce.encode(A[oe]),Ae+=Wt,I=Math.max(I,Wt)}const me=new Uint8Array(W);let be=0,ye,ze;for(ye=0;ye<I;ye++)for(ze=0;ze<ae;ze++)ye<A[ze].length&&(me[be++]=A[ze][ye]);for(ye=0;ye<K;ye++)for(ze=0;ze<ae;ze++)me[be++]=q[ze][ye];return me}function ge(ee,V,le,W){let Y;if(Array.isArray(ee))Y=S.fromArray(ee);else if(typeof ee=="string"){let re=V;if(!re){const D=S.rawSplit(ee);re=y.getBestVersionForData(D,le)}Y=S.fromString(ee,re||40)}else throw new Error("Invalid data");const ne=y.getBestVersionForData(Y,le);if(!ne)throw new Error("The amount of data is too big to be stored in a QR Code");if(!V)V=ne;else if(V<ne)throw new Error(\`
40
+ The chosen QR Code version cannot contain this amount of data.
41
+ Minimum version required to store current data is: \`+ne+\`.
42
+ \`);const ae=F(V,le,Y),Q=l.getSymbolSize(V),se=new r(Q);return N(se,V),R(se),L(se,V),J(se,le,0),V>=7&&P(se,V),Z(se,ae),isNaN(W)&&(W=m.getBestMask(se,J.bind(null,se,le))),m.applyMask(W,se),J(se,le,W),{modules:se,version:V,errorCorrectionLevel:le,maskPattern:W,segments:Y}}return Pr.create=function(V,le){if(typeof V>"u"||V==="")throw new Error("No input text");let W=u.M,Y,ne;return typeof le<"u"&&(W=u.from(le.errorCorrectionLevel,u.M),Y=y.from(le.version),ne=m.from(le.maskPattern),le.toSJISFunc&&l.setToSJISFunction(le.toSJISFunc)),ge(V,Y,W,ne)},Pr}var po={},xo={},gg;function Vg(){return gg||(gg=1,(function(l){function u(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let r=o.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+o);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(f){return[f,f]}))),r.length===6&&r.push("F","F");const d=parseInt(r.join(""),16);return{r:d>>24&255,g:d>>16&255,b:d>>8&255,a:d&255,hex:"#"+r.slice(0,6).join("")}}l.getOptions=function(r){r||(r={}),r.color||(r.color={});const d=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,f=r.width&&r.width>=21?r.width:void 0,m=r.scale||4;return{width:f,scale:f?4:m,margin:d,color:{dark:u(r.color.dark||"#000000ff"),light:u(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},l.getScale=function(r,d){return d.width&&d.width>=r+d.margin*2?d.width/(r+d.margin*2):d.scale},l.getImageWidth=function(r,d){const f=l.getScale(r,d);return Math.floor((r+d.margin*2)*f)},l.qrToImageData=function(r,d,f){const m=d.modules.size,v=d.modules.data,x=l.getScale(m,f),y=Math.floor((m+f.margin*2)*x),j=f.margin*x,g=[f.color.light,f.color.dark];for(let S=0;S<y;S++)for(let N=0;N<y;N++){let R=(S*y+N)*4,L=f.color.light;if(S>=j&&N>=j&&S<y-j&&N<y-j){const P=Math.floor((S-j)/x),J=Math.floor((N-j)/x);L=g[v[P*m+J]?1:0]}r[R++]=L.r,r[R++]=L.g,r[R++]=L.b,r[R]=L.a}}})(xo)),xo}var vg;function pp(){return vg||(vg=1,(function(l){const u=Vg();function o(d,f,m){d.clearRect(0,0,f.width,f.height),f.style||(f.style={}),f.height=m,f.width=m,f.style.height=m+"px",f.style.width=m+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}l.render=function(f,m,v){let x=v,y=m;typeof x>"u"&&(!m||!m.getContext)&&(x=m,m=void 0),m||(y=r()),x=u.getOptions(x);const j=u.getImageWidth(f.modules.size,x),g=y.getContext("2d"),S=g.createImageData(j,j);return u.qrToImageData(S.data,f,x),o(g,y,j),g.putImageData(S,0,0),y},l.renderToDataURL=function(f,m,v){let x=v;typeof x>"u"&&(!m||!m.getContext)&&(x=m,m=void 0),x||(x={});const y=l.render(f,m,x),j=x.type||"image/png",g=x.rendererOpts||{};return y.toDataURL(j,g.quality)}})(po)),po}var jo={},yg;function xp(){if(yg)return jo;yg=1;const l=Vg();function u(d,f){const m=d.a/255,v=f+'="'+d.hex+'"';return m<1?v+" "+f+'-opacity="'+m.toFixed(2).slice(1)+'"':v}function o(d,f,m){let v=d+f;return typeof m<"u"&&(v+=" "+m),v}function r(d,f,m){let v="",x=0,y=!1,j=0;for(let g=0;g<d.length;g++){const S=Math.floor(g%f),N=Math.floor(g/f);!S&&!y&&(y=!0),d[g]?(j++,g>0&&S>0&&d[g-1]||(v+=y?o("M",S+m,.5+N+m):o("m",x,0),x=0,y=!1),S+1<f&&d[g+1]||(v+=o("h",j),j=0)):x++}return v}return jo.render=function(f,m,v){const x=l.getOptions(m),y=f.modules.size,j=f.modules.data,g=y+x.margin*2,S=x.color.light.a?"<path "+u(x.color.light,"fill")+' d="M0 0h'+g+"v"+g+'H0z"/>':"",N="<path "+u(x.color.dark,"stroke")+' d="'+r(j,y,x.margin)+'"/>',R='viewBox="0 0 '+g+" "+g+'"',P='<svg xmlns="http://www.w3.org/2000/svg" '+(x.width?'width="'+x.width+'" height="'+x.width+'" ':"")+R+' shape-rendering="crispEdges">'+S+N+\`</svg>
43
+ \`;return typeof v=="function"&&v(null,P),P},jo}var bg;function jp(){if(bg)return Xl;bg=1;const l=tp(),u=bp(),o=pp(),r=xp();function d(f,m,v,x,y){const j=[].slice.call(arguments,1),g=j.length,S=typeof j[g-1]=="function";if(!S&&!l())throw new Error("Callback required as last argument");if(S){if(g<2)throw new Error("Too few arguments provided");g===2?(y=v,v=m,m=x=void 0):g===3&&(m.getContext&&typeof y>"u"?(y=x,x=void 0):(y=x,x=v,v=m,m=void 0))}else{if(g<1)throw new Error("Too few arguments provided");return g===1?(v=m,m=x=void 0):g===2&&!m.getContext&&(x=v,v=m,m=void 0),new Promise(function(N,R){try{const L=u.create(v,x);N(f(L,m,x))}catch(L){R(L)}})}try{const N=u.create(v,x);y(null,f(N,m,x))}catch(N){y(N)}}return Xl.create=u.create,Xl.toCanvas=d.bind(null,o.render),Xl.toDataURL=d.bind(null,o.renderToDataURL),Xl.toString=d.bind(null,function(f,m,v){return r.render(f,v)}),Xl}var Sp=jp();const Np=n0(Sp);function Zg(l){return l==null?"":typeof l=="string"?l:typeof l=="number"||typeof l=="boolean"?String(l):JSON.stringify(l)}function wp(l){return!(l.text.trim()===""||l.text===Zg(l.setting.value)||l.setting.confirm!==void 0&&!l.confirmed)}const Tp=[{label:"every morning at 08:00",expr:"0 8 * * *"},{label:"weekdays at 09:00",expr:"0 9 * * 1-5"},{label:"every hour",expr:"0 * * * *"},{label:"Monday 09:00",expr:"0 9 * * 1"},{label:"first of the month",expr:"0 9 1 * *"}];function Ep(l){const u=l.timezone===void 0?"":\` (\${l.timezone})\`;return l.kind==="every"?\`every \${l.expr}\`:l.kind==="at"?\`once at \${l.expr}\${u}\`:\`cron \${l.expr}\${u}\`}function Jg(l,u,o=!1){const r=Date.parse(l)-u;if(Number.isNaN(r))return l;const d=Math.abs(r),f=Math.round(d/6e4),m=f<1?"now":f<60?\`\${f} min\`:f<2880?\`\${Math.floor(f/60)} h\${f%60===0?"":\` \${f%60} min\`}\`:\`\${Math.round(f/1440)} d\`;return m==="now"?o?"just now":r<0?"due now":"now":r<0?\`\${m} ago\`:\`in \${m}\`}function Ap(l){const[u,o]=T.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Schedules"}),i.jsx("p",{children:"Turns the agent takes on its own. Each runs as the scheduler would: a fresh session unless it names one, the role it asks for, and only the tools it allows."})]}),l.schedules.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Nothing scheduled"}),i.jsxs("p",{children:["Add one below, or declare it in the manifest's ",i.jsx("code",{children:"schedules:"})," block — a declared one survives a rebuild and shows up in a diff."]})]}):i.jsx("div",{className:"grid",children:l.schedules.map(r=>i.jsx(kp,{row:r,now:l.now,working:l.busy===r.id,...l.onRun===void 0?{}:{onRun:l.onRun},...l.onToggle===void 0?{}:{onToggle:l.onToggle},...l.onDelete===void 0?{}:{onDelete:l.onDelete}},r.id))}),l.onCreate===void 0?null:u?i.jsx(Mp,{roles:l.roles??[],recipients:l.recipients??[],...l.onPreview===void 0?{}:{onPreview:l.onPreview},onCancel:()=>o(!1),onCreate:r=>{l.onCreate?.(r),o(!1)}}):i.jsx("button",{type:"button",className:"primary",style:{marginTop:18},onClick:()=>o(!0),children:"+ New schedule"})]})}function Cp(l){const{row:u}=l;if(u.lastStatus===void 0||u.lastFiredAt===void 0)return i.jsx(i.Fragment,{children:"never run"});const o=Jg(u.lastFiredAt,l.now,!0),r=u.runs===void 0?"":\` · \${u.runs} run\${u.runs===1?"":"s"}\`;return u.lastStatus==="error"?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"pill bad",children:"failed"})," ",o,r,u.lastError===void 0?null:i.jsx("div",{className:"error-line",children:u.lastError})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:\`pill \${u.lastStatus==="ok"?"ok":"warn"}\`,children:u.lastStatus})," ",o,r]})}function kp(l){const{row:u}=l,o=u.origin==="manifest",r=u.enabled?u.nextRunAt===void 0?"never again — a spent one-shot":\`\${Jg(u.nextRunAt,l.now)} · \${u.nextRunAt}\`:"disabled";return i.jsxs("div",{className:\`card schedule-card\${u.enabled?"":" off"}\`,children:[i.jsxs("div",{className:"head",children:[i.jsx("code",{className:"schedule-id",children:u.id}),i.jsxs("span",{className:\`pill \${u.enabled?"ok":""}\`,children:[i.jsx("span",{className:\`dot \${u.enabled?"live":"off"}\`}),u.enabled?"armed":"disabled"]}),o?i.jsx("span",{className:"pill",title:"declared in agent.yaml; the file decides it",children:"agent.yaml"}):null]}),i.jsx("p",{className:"task",children:u.task}),i.jsxs("dl",{className:"facts",children:[i.jsx("dt",{children:"when"}),i.jsx("dd",{children:Ep(u)}),i.jsx("dt",{children:"next"}),i.jsx("dd",{children:r}),i.jsx("dt",{children:"last"}),i.jsx("dd",{children:i.jsx(Cp,{row:u,now:l.now})}),i.jsx("dt",{children:"delivers to"}),i.jsx("dd",{children:u.deliverChannel===void 0?"this session only":\`\${u.deliverChannel}\${u.deliverTo===void 0?"":\` → \${u.deliverTo}\`}\`}),u.role===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"role"}),i.jsx("dd",{children:i.jsx("code",{children:u.role})})]}),u.toolsAllow===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"tools"}),i.jsx("dd",{children:u.toolsAllow.join(", ")})]}),u.timeoutMs===void 0&&u.maxSteps===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"limits"}),i.jsx("dd",{children:[u.maxSteps===void 0?void 0:\`\${u.maxSteps} steps\`,u.timeoutMs===void 0?void 0:\`\${Math.round(u.timeoutMs/1e3)} s\`].filter(d=>d!==void 0).join(" · ")})]})]}),i.jsxs("div",{className:"actions",children:[l.onRun===void 0?null:i.jsx("button",{type:"button",disabled:l.working,onClick:()=>l.onRun?.(u.id),children:"run now"}),l.onToggle===void 0||o?null:i.jsx("button",{type:"button",disabled:l.working,onClick:()=>l.onToggle?.(u.id,!u.enabled),children:u.enabled?"disable":"enable"}),l.onDelete===void 0||o?null:i.jsx("button",{type:"button",className:"bad",disabled:l.working,onClick:()=>l.onDelete?.(u.id),children:"delete"}),o?i.jsxs("span",{className:"sub",style:{margin:0},children:["the manifest decides it — edit the file, or ",i.jsx("code",{children:"schedules"})," under Settings"]}):null]})]})}function Mp(l){const[u,o]=T.useState(""),[r,d]=T.useState("cron"),[f,m]=T.useState("0 8 * * *"),[v,x]=T.useState(typeof Intl=="object"?Intl.DateTimeFormat().resolvedOptions().timeZone??"":""),[y,j]=T.useState(""),[g,S]=T.useState(""),[N,R]=T.useState(""),[L,P]=T.useState(""),[J,Z]=T.useState(""),[F,_]=T.useState(""),[ge,ee]=T.useState(""),[V,le]=T.useState(""),[W,Y]=T.useState(),{onPreview:ne}=l;T.useEffect(()=>{if(ne===void 0||f.trim()===""){Y(void 0);return}let Q=!1;const se=setTimeout(()=>{ne({kind:r,expr:f.trim(),...v===""?{}:{timezone:v}}).then(re=>{Q||Y(re)}).catch(re=>{Q||Y({error:re instanceof Error?re.message:String(re)})})},350);return()=>{Q=!0,clearTimeout(se)}},[r,f,v,ne]);const ae=u.trim()!==""&&f.trim()!==""&&y.trim()!==""&&(g.trim()===""||N.trim()!=="")&&!(W!==void 0&&"error"in W);return i.jsxs("form",{className:"card schedule-form",onSubmit:Q=>{if(Q.preventDefault(),!ae)return;const se=Number(F),re=Number(ge);l.onCreate({id:u.trim(),kind:r,expr:f.trim(),task:y.trim(),deliver:g.trim()===""?"none":{channel:g.trim(),to:N.trim()},...v===""?{}:{timezone:v},...L===""?{}:{role:L},...J.trim()===""?{}:{tools:{allow:J.split(",").map(D=>D.trim()).filter(Boolean)}},...Number.isInteger(se)&&se>0?{maxSteps:se}:{},...Number.isInteger(re)&&re>0?{timeoutMs:re*1e3}:{},...V.trim()===""?{}:{session:\`shared:\${V.trim()}\`}})},children:[i.jsx("h3",{children:"New schedule"}),i.jsxs("div",{className:"model-form",style:{borderTop:"none",paddingTop:0,marginTop:0},children:[i.jsxs("label",{children:["Id",i.jsx("input",{value:u,placeholder:"morning-brief",onChange:Q=>o(Q.target.value)})]}),i.jsxs("label",{children:["Kind",i.jsxs("select",{value:r,onChange:Q=>d(Q.target.value),children:[i.jsx("option",{value:"cron",children:"cron — on a calendar"}),i.jsx("option",{value:"every",children:"every — on an interval"}),i.jsx("option",{value:"at",children:"at — once, at an instant"})]})]}),i.jsxs("label",{style:{gridColumn:"1 / -1"},children:[r==="cron"?"Expression":r==="every"?"Interval":"Instant",i.jsx("input",{value:f,placeholder:r==="cron"?"0 8 * * *":r==="every"?"15m":"2026-12-25T09:00:00+06:00",onChange:Q=>m(Q.target.value)}),r==="cron"?i.jsx("span",{className:"chips",children:Tp.map(Q=>i.jsx("button",{type:"button",className:"pill",onClick:()=>m(Q.expr),children:Q.label},Q.expr))}):null,i.jsx("span",{className:\`sub preview\${W!==void 0&&"error"in W?" bad":""}\`,children:W===void 0?l.onPreview===void 0?"":"…":"error"in W?W.error:W.next.length===0?"never fires":\`next: \${W.next.map(Q=>new Date(Q).toLocaleString()).join(" · ")} (\${W.zone}\${W.jitterMs>0?\`, ±\${Math.round(W.jitterMs/1e3)} s jitter\`:""})\`})]}),r==="every"?null:i.jsxs("label",{children:["Timezone",i.jsx("input",{value:v,placeholder:"Asia/Dhaka",onChange:Q=>x(Q.target.value)})]}),i.jsxs("label",{style:{gridColumn:"1 / -1"},children:["Task",i.jsx("textarea",{value:y,rows:2,placeholder:"Summarise today's calendar and unread email.",onChange:Q=>j(Q.target.value)})]}),i.jsxs("div",{className:"field-like",children:[i.jsx("span",{className:"field-label",children:"Deliver to"}),l.recipients.length>0?i.jsxs("select",{"aria-label":"deliver to",value:g===""?"":\`\${g}\x01\${N}\`,onChange:Q=>{const[se,re]=Q.target.value.split("\x01");S(se??""),R(re??"")},children:[i.jsx("option",{value:"",children:"this session only (event stream)"}),l.recipients.map(Q=>i.jsx("option",{value:\`\${Q.channel}\x01\${Q.to}\`,children:Q.label},\`\${Q.channel}\x01\${Q.to}\`))]}):i.jsx("input",{"aria-label":"deliver channel",value:g,placeholder:"channel id — blank for this session only",onChange:Q=>S(Q.target.value)}),l.recipients.length===0&&g.trim()!==""?i.jsx("input",{"aria-label":"deliver address",value:N,placeholder:"address — on Telegram the numeric chat id",onChange:Q=>R(Q.target.value)}):null,i.jsxs("span",{className:"sub",children:["Addresses offered are ones a message has arrived from. On Telegram it is the numeric chat id, never an ",i.jsx("code",{children:"@handle"}),"."]})]}),i.jsxs("label",{children:["Model role",i.jsxs("select",{value:L,onChange:Q=>P(Q.target.value),children:[i.jsx("option",{value:"",children:"main"}),l.roles.filter(Q=>Q!=="main").map(Q=>i.jsx("option",{value:Q,children:Q},Q))]})]}),i.jsxs("label",{children:["Tools allowed"," ",i.jsx("span",{className:"sub",children:"comma-separated slugs; blank is the agent's own"}),i.jsx("input",{value:J,placeholder:"now, web_search",onChange:Q=>Z(Q.target.value)})]}),i.jsxs("label",{children:["Max steps",i.jsx("input",{inputMode:"numeric",value:F,placeholder:"agent default",onChange:Q=>_(Q.target.value.replace(/\\D/g,""))})]}),i.jsxs("label",{children:["Timeout (seconds)",i.jsx("input",{inputMode:"numeric",value:ge,placeholder:"agent default",onChange:Q=>ee(Q.target.value.replace(/\\D/g,""))})]}),i.jsxs("label",{children:["Shared session"," ",i.jsx("span",{className:"sub",children:"blank runs isolated; a key appends to that conversation"}),i.jsx("input",{value:V,placeholder:"briefings",onChange:Q=>le(Q.target.value)})]})]}),i.jsxs("div",{className:"cta-row",style:{marginTop:14},children:[i.jsx("button",{type:"submit",className:"primary",disabled:!ae,children:"arm schedule"}),i.jsx("button",{type:"button",onClick:l.onCancel,children:"cancel"})]})]})}const pg=/^[a-z][a-z0-9_]*(\\([^)]*\\))?$/i,xg=[{id:"system",what:"shell and files"},{id:"web",what:"fetch pages; search with a backend"},{id:"composio",what:"SaaS apps through Composio",keyEnv:"COMPOSIO_API_KEY"}];function Rp(l){const u=new Set(Object.keys(l.config)),o=(d,f)=>{const m={...l.config};f===void 0?delete m[d]:m[d]=f,l.onChange?.(m)},r=[...xg.map(d=>({...d,on:u.has(d.id)})),...[...u].filter(d=>!xg.some(f=>f.id===d)).map(d=>({id:d,what:"",on:!0}))];return i.jsx("div",{className:"stats",style:{marginBottom:18,flexWrap:"wrap"},children:r.map(d=>{const f=l.providers.find(m=>m.id===d.id);return i.jsxs("span",{className:\`pill\${d.on?" ok":""}\`,title:d.what,children:[i.jsx("span",{className:\`dot \${d.on?"live":"off"}\`}),d.id,f?.keyEnv===void 0?null:i.jsxs(i.Fragment,{children:[" · ",f.keyEnv," ",f.keySet===!0?"set":"missing"]}),l.onChange===void 0?null:i.jsx("button",{type:"button",className:"link",disabled:l.busy,onClick:()=>d.on?o(d.id,void 0):o(d.id,"keyEnv"in d?{apiKeyEnv:d.keyEnv}:{}),children:d.on?"remove":"add"})]},d.id)})})}function zp(l){const[u,o]=T.useState(""),[r,d]=T.useState({kind:"allow",text:""}),f=T.useMemo(()=>{const y=u.trim().toLowerCase(),j=l.tools.filter(S=>y===""||S.slug.toLowerCase().includes(y)||S.summary.toLowerCase().includes(y)||(S.tags??[]).some(N=>N.toLowerCase().includes(y))),g=new Map;for(const S of j){const N=g.get(S.provider)??[];N.push(S),g.set(S.provider,N)}return[...g.entries()].sort(([S],[N])=>S.localeCompare(N))},[l.tools,u]),m=l.pinned??[],v=l.tools.filter(y=>y.mutating).length,x=l.tools.filter(y=>y.trust!=="trusted").length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Tools"}),i.jsx("p",{children:"What this agent may call. Every tool here is in its prompt on every turn, so the catalogue has a price; a tool that is not pinned is not offered."})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),i.jsxs("div",{className:"stats",style:{marginBottom:18},children:[i.jsxs("span",{className:"pill",children:[l.tools.length," tool",l.tools.length===1?"":"s"]}),l.catalogueTokens===void 0?null:i.jsxs("span",{className:"pill accent",children:[l.catalogueTokens," tokens / turn"]}),i.jsxs("span",{className:"pill",children:[v," change things"]}),i.jsxs("span",{className:\`pill\${x>0?" warn":""}\`,children:[x," untrusted"]}),l.onRefresh===void 0?null:i.jsx("button",{type:"button",style:{marginLeft:"auto"},disabled:l.busy==="tools.refresh",onClick:l.onRefresh,children:l.busy==="tools.refresh"?"refreshing…":"refresh catalogue"})]}),l.lastRefresh===void 0?null:i.jsxs("div",{className:"card refresh-report",children:[i.jsx("h3",{children:"Last refresh"}),i.jsx("ul",{children:l.lastRefresh.providers.map(y=>i.jsxs("li",{children:[i.jsx("code",{children:y.provider})," ",y.ok?\`\${y.fetched} fetched\`:\`failed: \${y.error??"unknown"}\`]},y.provider))}),i.jsx("p",{style:{margin:0},children:l.lastRefresh.added.length+l.lastRefresh.removed.length+l.lastRefresh.changed.length===0?"Nothing moved, so nothing reloaded.":[l.lastRefresh.added.length>0?\`added \${l.lastRefresh.added.join(", ")}\`:void 0,l.lastRefresh.removed.length>0?\`removed \${l.lastRefresh.removed.join(", ")}\`:void 0,l.lastRefresh.changed.length>0?\`changed \${l.lastRefresh.changed.join(", ")}\`:void 0].filter(y=>y!==void 0).join(" · ")})]}),i.jsx("div",{className:"section-title",children:"Providers"}),i.jsx(Rp,{providers:l.providers??[],config:l.providerConfig??{},busy:l.busy==="tools.providers",...l.onProviders===void 0?{}:{onChange:l.onProviders}}),i.jsx("div",{className:"section-title",children:"Catalogue"}),i.jsx("input",{className:"search",value:u,placeholder:"search slug, summary or tag",onChange:y=>o(y.target.value)}),l.tools.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No tools pinned"}),i.jsxs("p",{children:["An agent with none can still hold a conversation; a manifest's"," ",i.jsx("code",{children:"tools.pinned"})," is what grants the rest."]})]}):f.length===0?i.jsxs("p",{className:"empty",children:['Nothing matches "',u,'".']}):f.map(([y,j])=>i.jsxs("section",{className:"tool-group",children:[i.jsxs("h3",{children:[y," ",i.jsx("span",{className:"sub",children:j.length})]}),i.jsxs("table",{className:"panel-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"tool"}),i.jsx("th",{children:"writes"}),i.jsx("th",{children:"trust"}),l.tools.some(g=>g.phases!==void 0)?i.jsx("th",{children:"phases"}):null,l.onPin===void 0?null:i.jsx("th",{})]})}),i.jsx("tbody",{children:j.map(g=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("code",{children:g.slug}),i.jsx("div",{className:"sub",children:g.summary}),(g.tags??[]).length===0?null:i.jsx("div",{className:"stats",style:{marginTop:4},children:(g.tags??[]).map(S=>i.jsx("span",{className:"pill",children:S},S))})]}),i.jsx("td",{children:g.mutating?"yes":"no"}),i.jsxs("td",{children:[i.jsx("span",{className:g.trust==="trusted"?"":"warn",children:g.trust}),g.trustReason===void 0?null:i.jsx("div",{className:"sub",children:g.trustReason})]}),l.tools.some(S=>S.phases!==void 0)?i.jsx("td",{children:g.phases===void 0?"all":g.phases.join(", ")}):null,l.onPin===void 0?null:i.jsx("td",{style:{whiteSpace:"nowrap"},children:m.includes(g.slug)?i.jsx("button",{type:"button",disabled:l.busy==="tools.pinned",onClick:()=>l.onPin?.(m.filter(S=>S!==g.slug)),children:"unpin"}):null})]},g.slug))})]})]},y)),l.onPin===void 0?null:i.jsx(Op,{pinned:m,served:l.tools.map(y=>y.slug),busy:l.busy==="tools.pinned",onPin:l.onPin}),l.onRules===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"section-title",children:"Policy"}),i.jsxs("p",{className:"sub",style:{marginBottom:10},children:["A rule names a tool and optionally an argument pattern:"," ",i.jsx("code",{children:"exec(git status:*)"}),". An ",i.jsx("strong",{children:"allow"})," rule lets a call run without asking; a ",i.jsx("strong",{children:"deny"})," rule refuses it. Protected paths and the floor hold whatever is written here."]}),i.jsx("div",{className:"control-row",children:["allow","deny"].map(y=>{const j=(y==="allow"?l.allow:l.deny)??[];return i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:y}),j.length===0?i.jsxs("p",{className:"empty",children:["no ",y," rules"]}):i.jsx("ul",{className:"rules",children:j.map(g=>i.jsxs("li",{children:[i.jsx("code",{children:g}),i.jsx("button",{type:"button",className:"link",disabled:l.busy===\`tools.policy.\${y}\`,onClick:()=>l.onRules?.(y,j.filter(S=>S!==g)),children:"remove"})]},g))}),i.jsxs("form",{className:"inline",onSubmit:g=>{if(g.preventDefault(),r.kind!==y)return;const S=r.text.trim();!pg.test(S)||j.includes(S)||(l.onRules?.(y,[...j,S]),d({kind:y,text:""}))},children:[i.jsx("input",{"aria-label":\`new \${y} rule\`,value:r.kind===y?r.text:"",placeholder:y==="allow"?"memory_write":"exec(rm:*)",onFocus:()=>d({kind:y,text:r.kind===y?r.text:""}),onChange:g=>d({kind:y,text:g.target.value})}),i.jsx("button",{type:"submit",disabled:l.busy===\`tools.policy.\${y}\`||r.kind!==y||!pg.test(r.text.trim()),children:"add"})]})]},y)})})]})]})}function Op(l){const[u,o]=T.useState(""),r=u.trim(),d=l.pinned.includes(r)||l.served.includes(r);return i.jsxs("form",{className:"inline",style:{marginTop:12},onSubmit:f=>{f.preventDefault(),!(r===""||d)&&(l.onPin([...l.pinned,r]),o(""))},children:[i.jsx("input",{"aria-label":"pin a tool by slug",value:u,placeholder:"pin a slug — exec, web_search, GMAIL_FETCH_EMAILS…",onChange:f=>o(f.target.value)}),i.jsx("button",{type:"submit",disabled:l.busy||r===""||d,children:"pin"})]})}function _p(l){return l.agents.length===0?i.jsx("div",{className:"empty",style:{fontSize:12,padding:"4px 8px"},children:"no agents on this server"}):i.jsx(i.Fragment,{children:l.agents.map(u=>{const o=u.status==="disabled";return i.jsxs("div",{className:"agent-row",children:[i.jsxs("button",{type:"button",className:"row-button","aria-current":u.id===l.current,disabled:o,onClick:()=>l.onSelect(u.id),children:[u.name,o?i.jsx("span",{className:"agent-off",children:" · stopped"}):null]}),o?i.jsxs("div",{className:"agent-note",children:[u.reason??"switched off",i.jsx("button",{type:"button",className:"link",disabled:l.starting===u.id,onClick:()=>l.onStart(u.id),children:l.starting===u.id?"starting…":"start"})]}):null]},u.id)})})}function Up(l){return l.editable?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"sub",style:{marginTop:0},children:[l.file===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("code",{children:l.file}),"."," "]}),"An agent's settings are fixed for its instance's lifetime, so saving one replaces the agent — the conversation history is in the store and survives it."]}),l.note===void 0?null:i.jsx("p",{className:"row note",children:l.note}),l.settings.map(u=>i.jsx(Dp,{setting:u,busy:l.busy===u.path,onSet:l.onSet},u.path))]}):i.jsx("p",{className:"empty",children:"This agent was loaded from an object rather than a file, so there is no manifest to change. An embedder holding new settings passes the new object to its runtime."})}function Dp(l){const u=Zg(l.setting.value),[o,r]=T.useState(u),[d,f]=T.useState(!1),[m,v]=T.useState(u);m!==u&&(v(u),r(u),f(!1));const x=wp({setting:l.setting,text:o,confirmed:d}),y=u.length>48||u.includes("{")||u.includes("[");return i.jsxs("section",{className:"config-row",children:[i.jsxs("div",{className:"config-head",children:[i.jsx("code",{children:l.setting.path}),l.setting.value===void 0?i.jsx("span",{className:"sub",children:" not set"}):null]}),i.jsx("p",{className:"sub",children:l.setting.means}),y?i.jsx("textarea",{rows:2,value:o,"aria-label":l.setting.path,onChange:j=>r(j.target.value)}):i.jsx("input",{value:o,"aria-label":l.setting.path,onChange:j=>r(j.target.value)}),l.setting.confirm===void 0?null:i.jsxs("label",{className:"row note bad",style:{display:"block"},children:[i.jsx("input",{type:"checkbox",checked:d,onChange:j=>f(j.target.checked)})," ",l.setting.confirm]}),i.jsx("button",{type:"button",disabled:!x||l.busy,onClick:()=>l.onSet(l.setting.path,o,{confirm:d}),children:l.busy?"saving…":"save"})]})}function Bp(l){const u=l.session?.recall!==!1;return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ghost hide-narrow",disabled:l.busy===!0||l.session===void 0,title:u?"History recall can draw on this conversation. Keep it out; its messages stay.":"Kept out of history recall. Put it back.",onClick:()=>l.onRecall(!u),children:u?"recall: on":"recall: off"}),l.phases===void 0?null:i.jsxs("label",{className:"hide-narrow inline-field",children:["phase",i.jsxs("select",{value:l.session?.phase??"",disabled:l.busy===!0||l.session===void 0,onChange:o=>l.onPhase(o.target.value),children:[l.session?.phase===void 0?i.jsx("option",{value:"",children:"entry"}):null,l.phases.map(o=>i.jsx("option",{value:o,children:o},o))]})]})]})}function Hp(l){return l.warnings.length===0?null:i.jsxs("details",{className:"warnings",children:[i.jsxs("summary",{children:[i.jsx("span",{className:"dot warn"}),i.jsxs("h3",{children:[l.warnings.length," thing",l.warnings.length===1?"":"s"," this agent could not set up"]}),i.jsx("span",{className:"sub",style:{margin:"0 0 0 auto"},children:"details"})]}),i.jsx("p",{className:"sub",children:"It is running. Each of these is a capability it does not have — fix the cause and restart the agent."}),l.warnings.map(u=>i.jsxs("div",{className:"warning",children:[i.jsxs("p",{className:"warning-message",children:[u.field===void 0?null:i.jsx("code",{children:u.field})," ",u.message]}),u.hint===void 0?null:i.jsx("p",{className:"hint",children:u.hint})]},\`\${u.code}:\${u.message}\`))]})}function Lp(l){return l.channels.length===0?i.jsx("p",{className:"empty",children:"No channels. This agent is reached through this page and the HTTP API only."}):i.jsxs("div",{className:"channels",children:[l.channels.map(u=>{const o=u.input,r=o?.expiresAt!==void 0&&Date.parse(o.expiresAt)<=l.now;return i.jsxs("section",{className:"channel",children:[i.jsxs("h3",{children:[i.jsx("code",{children:u.id})," ",i.jsx("span",{className:"sub",children:u.type})]}),i.jsxs("p",{className:\`status status-\${u.status??"off"}\`,children:[u.enabled===!1?"disconnected":u.status??"not started here",u.detail===void 0?null:\` — \${u.detail}\`]}),u.type!=="a2a"||l.agentUrl===void 0?null:i.jsxs("p",{className:"sub",children:["agent card"," ",i.jsx("a",{href:\`\${l.agentUrl}/plugins/a2a/.well-known/agent-card.json\`,target:"_blank",rel:"noreferrer",children:i.jsx("code",{children:\`\${l.agentUrl}/plugins/a2a/.well-known/agent-card.json\`})}),". Behind a proxy, peers use the plugin's ",i.jsx("code",{children:"publicUrl"}),"."]}),u.credentialEnv===void 0?null:i.jsxs("p",{className:u.credentialSet===!0?"sub":"warn",children:[i.jsx("code",{children:u.credentialEnv})," ",u.credentialSet===!0?"is set":"is NOT set"]}),o===void 0?null:i.jsxs("div",{className:\`channel-input \${r?"stale":"fresh"}\`,children:[r?i.jsx("p",{className:"warn",children:"this expired — the channel will issue another"}):null,i.jsx($p,{kind:o.kind,payload:o.payload}),i.jsxs("p",{className:"sub",children:[o.kind," · issued ",o.issuedAt,o.expiresAt===void 0?" · no expiry reported":\` · expires \${o.expiresAt}\`]})]}),l.actions===void 0?null:i.jsx(qp,{channel:u,actions:l.actions})]},u.id)}),l.actions?.note===void 0?null:i.jsx("p",{className:"row note",children:l.actions.note})]})}function qp(l){const[u,o]=T.useState(""),{channel:r,actions:d}=l,f=d.busy===r.id,m=r.enabled!==!1,v=r.input!==void 0||r.type==="whatsapp";return i.jsxs("div",{className:"channel-actions",children:[i.jsx("button",{type:"button",disabled:f,onClick:()=>d.onConnect(r.id,!m),children:m?"disconnect":"connect"}),v?i.jsx("button",{type:"button",disabled:f,onClick:()=>d.onUnpair(r.id),children:"unpair"}):null,r.credentialEnv===void 0?null:i.jsxs("form",{onSubmit:x=>{x.preventDefault(),u!==""&&(d.onCredential(r.id,u),o(""))},children:[i.jsx("input",{type:"password",autoComplete:"new-password",placeholder:r.credentialEnv,value:u,disabled:f,onChange:x=>o(x.target.value)}),i.jsx("button",{type:"submit",disabled:f||u==="",children:r.credentialSet===!0?"replace":"set"})]}),f?i.jsx("span",{className:"sub",children:"working…"}):null]})}const So=[{panel:"chat",label:"Chat"},{panel:"models",label:"Models"},{panel:"team",label:"Team"},{panel:"tools",label:"Tools"},{panel:"schedules",label:"Schedules"},{panel:"channels",label:"Channels"},{panel:"turns",label:"Turns"},{panel:"usage",label:"Usage"},{panel:"files",label:"Files"},{panel:"config",label:"Settings"}],jg=[{panel:"home",label:"Overview"},{panel:"people",label:"People"},{panel:"rooms",label:"Rooms"},{panel:"actions",label:"Actions"},{panel:"memory",label:"Memory"},{panel:"server-usage",label:"Usage"},{panel:"webhooks",label:"Webhooks"},{panel:"backup",label:"Backup"},{panel:"keys",label:"Keys"},{panel:"api",label:"API"}];function $p(l){if(l.kind==="pairing_code")return i.jsx("p",{className:"payload-code","data-kind":l.kind,children:l.payload.length===8?\`\${l.payload.slice(0,4)} \${l.payload.slice(4)}\`:l.payload});const u=l.kind==="qr"?Gp(l.payload):void 0;return u===void 0?i.jsx("pre",{className:"payload","data-kind":l.kind,children:l.payload}):i.jsxs("svg",{className:"payload-qr",viewBox:\`0 0 \${u.extent} \${u.extent}\`,"data-kind":l.kind,"data-modules":u.size,shapeRendering:"crispEdges",role:"img","aria-label":"Scan this code from WhatsApp, under Linked devices",children:[i.jsx("rect",{width:u.extent,height:u.extent,fill:"#fff"}),i.jsx("path",{d:u.d,fill:"#000"})]})}const No=4;function Gp(l){try{const{modules:u}=Np.create(l,{errorCorrectionLevel:"L"}),o=u.size;let r="";for(let d=0;d<o;d+=1)for(let f=0;f<o;f+=1)u.data[d*o+f]===1&&(r+=\`M\${f+No},\${d+No}h1v1h-1z\`);return r===""?void 0:{d:r,size:o,extent:o+No*2}}catch{return}}function Kp(l){return(l.split(":").pop()??l).trim().charAt(0)||"?"}function Ht(l){return l.includes(":")?l.split(":").pop()??l:l}function Yp(l){const u={id:"",name:"",title:"",timezone:"",role:"member"},[o,r]=T.useState(u),d=f=>Object.entries(l.assignments).filter(([,m])=>m===f).map(([m])=>m);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"People"}),i.jsx("p",{children:"The humans this server knows, under the ids your own system gave them. An agent assigned to a person works for them: it keeps their personal tools, reads their memory scope, and stands in for them in a DM when they are away."})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),l.people.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Nobody registered"}),i.jsxs("p",{children:["Register a participant below, or ",i.jsx("code",{children:"POST /v1/participants"})," from your backend. A self-hosted install registers its owner on ",i.jsx("code",{children:"init"}),"."]})]}):i.jsx("div",{className:"grid",children:l.people.map(f=>{const m=d(f.id);return i.jsxs("div",{className:"card person",children:[i.jsxs("div",{className:"head",children:[i.jsx("span",{className:"avatar",children:Kp(f.name??f.id)}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{className:"name",children:f.name??Ht(f.id)}),i.jsx("div",{className:"id",children:f.id}),f.title===void 0&&f.timezone===void 0?null:i.jsx("div",{className:"sub",children:[f.title,f.timezone].filter(v=>v!==void 0).join(" · ")})]}),i.jsx("span",{className:\`pill\${f.role==="admin"?" accent":""}\`,style:{marginLeft:"auto"},children:f.role})]}),i.jsxs("div",{className:"stats",children:[i.jsxs("span",{className:"pill",children:[i.jsx("span",{className:\`dot \${f.presence==="offline"?"off":"live"}\`}),f.presence??"online (assumed)"]}),l.onPresence===void 0?null:i.jsxs("button",{type:"button",className:"link",disabled:l.busy===\`presence:\${f.id}\`,onClick:()=>l.onPresence?.(f.id,f.presence==="offline"?"online":"offline"),children:["mark"," ",f.presence==="offline"?"online":"offline"]})]}),i.jsxs("div",{children:[i.jsx("div",{className:"facts-label",children:"agents"}),m.length===0?i.jsx("p",{className:"sub",style:{margin:0},children:"none assigned"}):i.jsx("div",{className:"stats",children:m.map(v=>i.jsxs("span",{className:"pill",children:[l.agents.find(x=>x.id===v)?.name??v,l.onAssign===void 0?null:i.jsx("button",{type:"button",className:"link","aria-label":\`unassign \${v}\`,disabled:l.busy===\`assign:\${v}\`,onClick:()=>l.onAssign?.(v,void 0),children:"×"})]},v))}),l.onAssign===void 0?null:i.jsxs("select",{"aria-label":\`assign an agent to \${f.id}\`,value:"",style:{marginTop:8},disabled:l.busy?.startsWith("assign:"),onChange:v=>{v.target.value!==""&&l.onAssign?.(v.target.value,f.id)},children:[i.jsx("option",{value:"",children:"assign an agent…"}),l.agents.filter(v=>l.assignments[v.id]!==f.id).map(v=>i.jsxs("option",{value:v.id,children:[v.name," (",v.id,")"]},v.id))]})]}),l.onRemove===void 0?null:i.jsx("div",{style:{borderTop:"1px solid var(--line)",paddingTop:10},children:i.jsx("button",{type:"button",className:"bad",disabled:l.busy===\`remove:\${f.id}\`,onClick:()=>l.onRemove?.(f.id),children:"remove"})})]},f.id)})}),l.onRegister===void 0?null:i.jsxs("form",{className:"card",style:{marginTop:18},onSubmit:f=>{f.preventDefault(),o.id.trim()!==""&&(l.onRegister?.({id:o.id.trim(),...o.name.trim()===""?{}:{name:o.name.trim()},...o.title.trim()===""?{}:{title:o.title.trim()},...o.timezone.trim()===""?{}:{timezone:o.timezone.trim()},role:o.role}),r(u))},children:[i.jsx("h3",{children:"Register a person"}),i.jsxs("div",{className:"model-form",style:{borderTop:"none",paddingTop:0,marginTop:0},children:[i.jsxs("label",{children:["Id"," ",i.jsx("span",{className:"sub",children:"as your system knows them, e.g. user:018f…"}),i.jsx("input",{value:o.id,placeholder:"user:ada",onChange:f=>r({...o,id:f.target.value})})]}),i.jsxs("label",{children:["Name",i.jsx("input",{value:o.name,placeholder:"Ada",onChange:f=>r({...o,name:f.target.value})})]}),i.jsxs("label",{children:["Title ",i.jsx("span",{className:"sub",children:"optional, not a permission"}),i.jsx("input",{value:o.title,placeholder:"Head of support",onChange:f=>r({...o,title:f.target.value})})]}),i.jsxs("label",{children:["Timezone"," ",i.jsx("span",{className:"sub",children:'what "tomorrow at nine" means for them'}),i.jsx("input",{value:o.timezone,placeholder:"Europe/London",onChange:f=>r({...o,timezone:f.target.value})})]}),i.jsxs("label",{children:["Role",i.jsxs("select",{value:o.role,onChange:f=>r({...o,role:f.target.value}),children:[i.jsx("option",{value:"member",children:"member"}),i.jsx("option",{value:"admin",children:"admin — may assign agents and write the space"})]})]})]}),i.jsx("button",{type:"submit",className:"primary",style:{marginTop:12},disabled:o.id.trim()===""||l.busy==="register",children:"register"})]})]})}const Qp={hop_limit:"hop limit reached",refused:"refused",failed:"failed"};function Xp(l){const u=l.rooms.find(o=>o.id===l.selected);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Rooms"}),i.jsx("p",{children:"Conversations among people and agents. In a room an agent answers only when mentioned; in a DM it always does, and stands in for an absent owner."})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),i.jsxs("div",{className:"rooms-layout",children:[i.jsxs("div",{className:"rooms-list",children:[l.rooms.length===0?i.jsx("p",{className:"empty",children:"no rooms yet"}):l.rooms.map(o=>i.jsxs("button",{type:"button",className:"row-button","aria-current":o.id===l.selected,onClick:()=>l.onSelect(o.id),children:[i.jsx("span",{className:\`pill \${o.kind==="dm"?"":"accent"}\`,children:o.kind}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:o.title??o.members.map(Ht).join(", ")})]},o.id)),l.onCreate===void 0?null:i.jsx(Vp,{people:l.people,agents:l.agents,onCreate:l.onCreate})]}),i.jsx("div",{className:"rooms-main",children:u===void 0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Pick a room"}),i.jsx("p",{children:"Or create one on the left: a room for a team, a DM for one person and one agent."})]}):i.jsx(Zp,{room:u,people:l.people,agents:l.agents,messages:l.messages,skips:l.skips??[],busy:l.busy===\`post:\${u.id}\`,...l.onPost===void 0?{}:{onPost:l.onPost},...l.onMembers===void 0?{}:{onMembers:l.onMembers}})})]})]})}function Vp(l){const[u,o]=T.useState(!1),[r,d]=T.useState("room"),[f,m]=T.useState(""),[v,x]=T.useState([]),y=N=>x(v.includes(N)?v.filter(R=>R!==N):[...v,N]),j=v.filter(N=>!N.startsWith("agent:")).length,g=v.length-j,S=r==="dm"?j===1&&g===1:v.length>0;return u?i.jsxs("form",{className:"card",style:{marginTop:8},onSubmit:N=>{N.preventDefault(),S&&(l.onCreate({kind:r,members:v,...f.trim()===""||r==="dm"?{}:{title:f.trim()}}),o(!1),x([]),m(""))},children:[i.jsxs("fieldset",{className:"segmented",style:{marginBottom:10},children:[i.jsx("button",{type:"button","aria-pressed":r==="room",onClick:()=>d("room"),children:"room"}),i.jsx("button",{type:"button","aria-pressed":r==="dm",onClick:()=>d("dm"),children:"dm"})]}),r==="room"?i.jsx("input",{value:f,placeholder:"title",style:{marginBottom:10},onChange:N=>m(N.target.value)}):i.jsx("p",{className:"sub",style:{margin:"0 0 10px"},children:"one person and one agent"}),i.jsxs("div",{className:"members",children:[l.people.map(N=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:v.includes(N.id),onChange:()=>y(N.id)}),N.name??Ht(N.id)]},N.id)),l.agents.map(N=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:v.includes(\`agent:\${N.id}\`),onChange:()=>y(\`agent:\${N.id}\`)}),i.jsx("span",{className:"pill accent",children:"agent"})," ",N.name]},N.id))]}),i.jsxs("div",{className:"cta-row",style:{marginTop:10},children:[i.jsx("button",{type:"submit",className:"primary",disabled:!S,children:"create"}),i.jsx("button",{type:"button",onClick:()=>o(!1),children:"cancel"})]})]}):i.jsx("button",{type:"button",style:{marginTop:8},onClick:()=>o(!0),children:"+ new room"})}function Zp(l){const u=l.room.members.filter(j=>!j.startsWith("agent:")),o=l.room.members.filter(j=>j.startsWith("agent:")),[r,d]=T.useState(u[0]??""),[f,m]=T.useState(""),[v,x]=T.useState(l.room.kind==="dm"?o:[]),y=j=>j.startsWith("agent:")?l.agents.find(g=>g.id===j.slice(6))?.name??Ht(j):l.people.find(g=>g.id===j)?.name??Ht(j);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"room-head",children:[i.jsx("strong",{children:l.room.title??l.room.members.map(y).join(", ")}),i.jsx("div",{className:"stats",children:l.room.members.map(j=>i.jsxs("span",{className:\`pill\${j.startsWith("agent:")?" accent":""}\`,children:[y(j),l.onMembers===void 0||l.room.kind==="dm"?null:i.jsx("button",{type:"button",className:"link","aria-label":\`remove \${j}\`,onClick:()=>l.onMembers?.(l.room.id,{remove:[j]}),children:"×"})]},j))})]}),i.jsx("div",{className:"room-log",children:l.messages.length===0?i.jsx("p",{className:"empty",children:"nothing said yet"}):l.messages.map(j=>i.jsxs("div",{className:\`room-msg\${j.origin==="agent"?" agent":""}\`,children:[i.jsxs("div",{className:"label",children:[y(j.authorId),j.onBehalfOf===void 0?"":\` · standing in for \${y(j.onBehalfOf)}\`,j.hop>0?\` · hop \${j.hop}\`:""," · ",j.createdAt.replace("T"," ").slice(0,16)]}),j.origin==="agent"?i.jsx(Mu,{text:j.text}):i.jsx("p",{style:{margin:0},children:j.text}),l.skips.filter(g=>g.messageId===j.id).map((g,S)=>i.jsxs("div",{className:"room-skip",title:g.detail,children:["not answered: ",Qp[g.reason],g.reason==="hop_limit"?\` (hop \${g.hop} of \${g.ceiling})\`:\` — \${g.detail}\`]},S))]},j.id))}),l.onPost===void 0||u.length===0?null:i.jsxs("form",{className:"room-post",onSubmit:j=>{j.preventDefault(),!(f.trim()===""||r==="")&&(l.onPost?.(l.room.id,f.trim(),r,v),m(""))},children:[i.jsxs("div",{className:"inline",style:{flexWrap:"wrap"},children:[i.jsx("select",{"aria-label":"post as",value:r,onChange:j=>d(j.target.value),children:u.map(j=>i.jsxs("option",{value:j,children:["as ",y(j)]},j))}),l.room.kind==="dm"?null:o.map(j=>i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:v.includes(j),onChange:()=>x(v.includes(j)?v.filter(g=>g!==j):[...v,j])}),"@",y(j)]},j))]}),i.jsxs("div",{className:"inline",style:{marginTop:8},children:[i.jsx("input",{value:f,placeholder:l.room.kind==="dm"?"say something":v.length===0?"say something — tick an agent for it to answer":"say something",onChange:j=>m(j.target.value)}),i.jsx("button",{type:"submit",className:"primary",disabled:l.busy||f.trim()==="",children:"post"})]})]})]})}function Jp(l){const u=new Map;for(const o of l){const r=u.get(o.ownerId);r===void 0?u.set(o.ownerId,[o]):r.push(o)}return[...u.entries()]}function Fp(l){const u=l.actions.filter(r=>r.status==="pending"),o=l.actions.filter(r=>r.status!=="pending");return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Actions"}),i.jsx("p",{children:"Calls a stand-in wanted to make on somebody's behalf. A stand-in never changes anything itself: the exact call waits here for its owner, and runs as their agent only once approved."})]}),u.length===0?i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"Nothing waiting"}),i.jsx("p",{children:"A queued action appears when an agent standing in for an absent person tries a tool that changes things."})]}):Jp(u).map(([r,d])=>i.jsxs("div",{children:[i.jsxs("div",{className:"section-title",children:["for ",Ht(r)," · ",d.length," waiting"]}),i.jsx("div",{className:"grid",children:d.map(f=>i.jsxs("div",{className:"card",children:[i.jsxs("div",{className:"head",children:[i.jsx("code",{children:f.slug}),i.jsx("span",{className:"pill warn",style:{marginLeft:"auto"},children:"pending"})]}),i.jsxs("p",{className:"sub",children:["for ",Ht(f.ownerId),", asked by"," ",Ht(f.requestedBy)," · agent ",f.agentId," ·"," ",f.createdAt.replace("T"," ").slice(0,16)]}),i.jsx("pre",{className:"snippet",children:JSON.stringify(f.args,null,2)}),l.onDecide===void 0?null:i.jsxs("div",{className:"cta-row",style:{marginTop:10},children:[i.jsx("button",{type:"button",className:"primary",disabled:l.busy===f.id,onClick:()=>l.onDecide?.(f.id,!0),children:"approve and run"}),i.jsx("button",{type:"button",disabled:l.busy===f.id,onClick:()=>l.onDecide?.(f.id,!1),children:"decline"})]})]},f.id))})]},r)),o.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"section-title",children:"Decided"}),i.jsxs("table",{className:"panel-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"call"}),i.jsx("th",{children:"for"}),i.jsx("th",{children:"outcome"}),i.jsx("th",{children:"when"})]})}),i.jsx("tbody",{children:o.map(r=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:r.slug})}),i.jsx("td",{children:Ht(r.ownerId)}),i.jsxs("td",{children:[r.status,r.result===void 0?null:i.jsx("div",{className:"sub",children:r.result.slice(0,200)})]}),i.jsx("td",{children:(r.decidedAt??r.createdAt).replace("T"," ").slice(0,16)})]},r.id))})]})]})]})}function Wp(l){const[u,o]=T.useState(""),[r,d]=T.useState(""),[f,m]=T.useState("");return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Memory"}),i.jsxs("p",{children:["Shared scopes every agent recalls from when a turn is about them: the"," ",i.jsx("code",{children:"space"})," for everyone, ",i.jsx("code",{children:"owner:<person>"})," for one person's notes, ",i.jsx("code",{children:"project:<id>"})," for the agents on a project. Private memory stays on each agent."]})]}),l.note===void 0?null:i.jsx("p",{className:"note",children:l.note}),i.jsxs("div",{className:"inline",style:{marginBottom:14,flexWrap:"wrap"},children:[i.jsx("select",{"aria-label":"memory scope",value:l.scope,onChange:v=>l.onScope(v.target.value),style:{width:"auto"},children:l.scopes.map(v=>i.jsx("option",{value:v,children:v},v))}),i.jsx("input",{"aria-label":"another scope",placeholder:"or type one: owner:user:ada",style:{maxWidth:280},onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault();const x=v.target.value.trim();x!==""&&l.onScope(x)}}})]}),l.notes===void 0?i.jsx("p",{className:"empty",children:"reading…"}):l.notes.length===0?i.jsxs("p",{className:"empty",children:["no notes in ",l.scope]}):i.jsx("div",{className:"notes",children:l.notes.map(v=>i.jsxs("div",{className:"card note-card",children:[i.jsx("p",{style:{margin:0,color:"var(--text)"},children:v.text}),i.jsxs("div",{className:"sub",style:{display:"flex",gap:10,alignItems:"center"},children:[i.jsxs("span",{children:[Ht(v.writtenBy)," ·"," ",v.createdAt.replace("T"," ").slice(0,16)]}),l.onDelete===void 0?null:i.jsx("button",{type:"button",className:"link",disabled:l.busy===v.id,onClick:()=>l.onDelete?.(v.id),children:"remove"})]})]},v.id))}),l.onAdd===void 0?null:i.jsxs("form",{className:"inline",style:{marginTop:12},onSubmit:v=>{v.preventDefault(),u.trim()!==""&&(l.onAdd?.(l.scope,u.trim()),o(""))},children:[i.jsx("input",{value:u,placeholder:\`a note for \${l.scope}\`,onChange:v=>o(v.target.value)}),i.jsx("button",{type:"submit",className:"primary",disabled:u.trim()===""||l.busy==="add",children:"add"})]}),i.jsx("div",{className:"section-title",children:"Projects"}),i.jsx("p",{className:"sub",style:{marginBottom:10},children:"A project is a memory scope shared by the agents on it. Name the agents and they recall its notes."}),l.projects.length===0?i.jsx("p",{className:"empty",children:"no projects"}):null,i.jsx("div",{className:"grid",children:l.projects.map(v=>i.jsxs("div",{className:"card",children:[i.jsxs("div",{className:"head",children:[i.jsx("strong",{children:v.name??v.id}),i.jsxs("code",{style:{marginLeft:"auto"},children:["project:",v.id]})]}),i.jsx("div",{className:"stats",style:{margin:"8px 0"},children:l.agents.map(x=>{const y=v.agents.includes(x.id);return i.jsxs("label",{className:"check",children:[i.jsx("input",{type:"checkbox",checked:y,disabled:l.onProject===void 0||l.busy===\`project:\${v.id}\`,onChange:()=>l.onProject?.(v.id,{agents:y?v.agents.filter(j=>j!==x.id):[...v.agents,x.id]})}),x.name]},x.id)})}),i.jsxs("div",{className:"cta-row",children:[i.jsx("button",{type:"button",onClick:()=>l.onScope(\`project:\${v.id}\`),children:"notes"}),l.onDeleteProject===void 0?null:i.jsx("button",{type:"button",className:"bad",disabled:l.busy===\`project:\${v.id}\`,onClick:()=>l.onDeleteProject?.(v.id),children:"delete"})]})]},v.id))}),l.onProject===void 0?null:i.jsxs("form",{className:"inline",style:{marginTop:12},onSubmit:v=>{v.preventDefault();const x=r.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-");x!==""&&(l.onProject?.(x,{name:r.trim(),agents:[]}),d(""))},children:[i.jsx("input",{value:r,placeholder:"new project name",onChange:v=>d(v.target.value)}),i.jsx("button",{type:"submit",disabled:r.trim()==="",children:"create"})]}),l.onSpaceWriter===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"section-title",children:"Space writer"}),i.jsxs("p",{className:"sub",style:{marginBottom:10},children:["The one non-admin who may write ",i.jsx("code",{children:"space"}),". Name an agent as"," ",i.jsx("code",{children:"agent:<id>"})," and its ",i.jsx("code",{children:"memory_write"})," goes to the space — so name one that holds nobody's private context."]}),i.jsxs("form",{className:"inline",onSubmit:v=>{v.preventDefault(),f.trim()!==""&&l.onSpaceWriter?.(f.trim())},children:[i.jsx("input",{value:f,placeholder:"user:ada or agent:crew",onChange:v=>m(v.target.value)}),i.jsx("button",{type:"submit",disabled:f.trim()===""||l.busy==="space-writer",children:"set"})]})]}),l.reads===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"section-title",children:"Reads of this person's scope by others"}),l.reads.length===0?i.jsx("p",{className:"empty",children:"none recorded"}):i.jsxs("table",{className:"panel-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"when"}),i.jsx("th",{children:"reader"}),i.jsx("th",{children:"for"})]})}),i.jsx("tbody",{children:l.reads.map(v=>i.jsxs("tr",{children:[i.jsx("td",{children:v.at.replace("T"," ").slice(0,16)}),i.jsx("td",{children:Ht(v.reader)}),i.jsxs("td",{children:[v.requestedBy===void 0?"—":Ht(v.requestedBy),v.onBehalfOf===void 0?"":\` (standing in for \${Ht(v.onBehalfOf)})\`]})]},\`\${v.at}:\${v.reader}\`))})]})]})]})}function Ip(l){const u=(l.toolCalls??[]).map(o=>\`\${o.name}(\${o.arguments})\`);return[l.content,...u].filter(o=>o!=="").join(\`
44
+ \`)}function Pp(l){return l.origin==="call"?"tool call":l.origin==="observation"?"tool result":l.origin==="repair"?"repair asked for":l.origin==="digest"?"compaction digest":l.role==="user"?"asked":l.role==="assistant"?"reply":l.role}const wo=4e3,ex=new Set(["max_steps","no_progress","truncated","timeout","error"]);function Fg(l){return ex.has(l)}function tx(l){switch(l){case"final":return"answered";case"running":return"still running";case"stopped":return"stopped by a person";case"max_steps":return"hit the step budget";case"no_progress":return"stopped for repeating itself";case"truncated":return"cut off by the output limit";case"timeout":return"timed out";case"error":return"failed";default:return l}}function nx(l){const u=l.turns.filter(o=>Fg(o.status)).length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"Turns"}),i.jsxs("p",{children:["Every turn this agent has taken, newest first, across every conversation and schedule."," ",u>0?\`\${u} of the \${l.turns.length} shown ended badly.\`:""]})]}),l.turns.length===0?l.loading?i.jsx("p",{className:"empty",children:"reading…"}):i.jsxs("div",{className:"empty-state",children:[i.jsx("h3",{children:"No turns yet"}),i.jsx("p",{children:"The first message in Chat, a channel, or a schedule firing will appear here."})]}):i.jsx("div",{className:"turns",children:l.turns.map(o=>i.jsx(ax,{turn:o,...l.replays?.[o.turnId]===void 0?{}:{replay:l.replays[o.turnId]},...l.onReplay===void 0?{}:{onReplay:l.onReplay},...l.onOpenSession===void 0?{}:{onOpenSession:l.onOpenSession}},o.turnId))}),l.hasMore&&l.onMore!==void 0?i.jsx("button",{type:"button",style:{marginTop:14},disabled:l.loading,onClick:l.onMore,children:l.loading?"loading…":"older turns"}):null]})}function ax(l){const{turn:u}=l,[o,r]=T.useState(!1),d=Fg(u.status),f=u.senderName??u.sender??(u.source?.startsWith("schedule:")?u.source:void 0);return i.jsxs("div",{className:\`card turn\${d?" bad":""}\`,children:[i.jsxs("button",{type:"button",className:"turn-head","aria-expanded":o,onClick:()=>r(!o),children:[i.jsxs("span",{className:\`pill \${d?"warn":u.status==="running"?"accent":"ok"}\`,children:[i.jsx("span",{className:\`dot \${d?"warn":u.status==="running"?"busy":"live"}\`}),tx(u.status)]}),i.jsx("span",{className:"turn-input",children:u.input.length>140?\`\${u.input.slice(0,140)}…\`:u.input||"(no text)"}),i.jsxs("span",{className:"turn-meta",children:[u.startedAt===void 0?null:i.jsx("span",{children:u.startedAt.replace("T"," ").slice(0,16)}),i.jsxs("span",{children:[u.steps," step",u.steps===1?"":"s"]}),i.jsxs("span",{children:[u.promptTokens.toLocaleString()," → ",u.outputTokens.toLocaleString()," ","tokens"]}),u.durationMs===void 0?null:i.jsxs("span",{children:[(u.durationMs/1e3).toFixed(1)," s"]})]})]}),o?i.jsxs("div",{className:"turn-body",children:[i.jsxs("div",{className:"facts",children:[i.jsx("dt",{children:"session"}),i.jsx("dd",{children:l.onOpenSession===void 0?i.jsx("code",{children:u.sessionKey}):i.jsx("button",{type:"button",className:"link",onClick:()=>l.onOpenSession?.(u.sessionKey),children:u.sessionKey})}),f===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"from"}),i.jsxs("dd",{children:[f,u.senderKind==="agent"?" · an agent, so the text was treated as data":""]})]}),u.cachedPromptTokens===void 0||u.cachedPromptTokens===0?null:i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"cached"}),i.jsxs("dd",{children:[u.cachedPromptTokens.toLocaleString()," prompt tokens from cache"]})]}),i.jsx("dt",{children:"id"}),i.jsx("dd",{children:i.jsx("code",{children:u.turnId})})]}),u.errorCode===void 0?null:i.jsxs("p",{className:"note bad",children:[u.errorCode,": ",u.errorMessage??"",u.errorHint===void 0?"":\`
45
+ hint: \${u.errorHint}\`]}),u.note===void 0?null:i.jsx("p",{className:"note",children:u.note}),i.jsx("div",{className:"label",children:"asked"}),i.jsx("p",{className:"row user",style:{margin:"0 0 12px"},children:u.input}),i.jsx("div",{className:"label",children:"reply"}),u.text===""?i.jsx("p",{className:"empty",children:"no reply text"}):i.jsx("div",{className:"row reply",children:i.jsx(Mu,{text:u.text})}),i.jsx(lx,{turn:u,...l.replay===void 0?{}:{replay:l.replay},...l.onReplay===void 0?{}:{onReplay:l.onReplay}})]}):null]})}function lx(l){const{replay:u}=l;return u===void 0?l.onReplay===void 0?null:i.jsx("button",{type:"button",style:{marginTop:12},onClick:()=>l.onReplay?.(l.turn),children:"replay every step"}):u.state==="loading"?i.jsx("p",{className:"empty",children:"reading the stored steps…"}):u.state==="failed"?i.jsx("p",{className:"note bad",children:u.message}):u.steps.length===0?i.jsx("p",{className:"empty",children:"No stored steps for this turn: its conversation was cleared, or it is older than the last 1,000 messages of it."}):i.jsx("ol",{className:"replay",children:u.steps.map(o=>i.jsxs("li",{children:[i.jsx("div",{className:"label",children:Pp(o)}),i.jsx("pre",{className:"snippet",children:(()=>{const r=Ip(o);return r.length>wo?\`\${r.slice(0,wo)}
46
+ … (\${r.length-wo} more characters)\`:r})()})]},o.id))})}function ix(l,u){if(u<=0)return"";const o=l.replace(/\\s+/g," ").trim();return o.length<=u?o:u===1?"…":\`\${o.slice(0,u-1)}…\`}const _o="#",Uo={A:[".###.","#...#","#####","#...#","#...#"],B:["####.","#...#","####.","#...#","####."],C:[".####","#....","#....","#....",".####"],D:["####.","#...#","#...#","#...#","####."],E:["#####","#....","####.","#....","#####"],F:["#####","#....","####.","#....","#...."],G:[".####","#....","#..##","#...#",".###."],H:["#...#","#...#","#####","#...#","#...#"],I:["#####","..#..","..#..","..#..","#####"],J:["..###","....#","....#","#...#",".###."],K:["#...#","#..#.","###..","#..#.","#...#"],L:["#....","#....","#....","#....","#####"],M:["#...#","##.##","#.#.#","#...#","#...#"],N:["#...#","##..#","#.#.#","#..##","#...#"],O:[".###.","#...#","#...#","#...#",".###."],P:["####.","#...#","####.","#....","#...."],Q:[".###.","#...#","#.#.#","#..#.",".##.#"],R:["####.","#...#","####.","#..#.","#...#"],S:[".####","#....",".###.","....#","####."],T:["#####","..#..","..#..","..#..","..#.."],U:["#...#","#...#","#...#","#...#",".###."],V:["#...#","#...#","#...#",".#.#.","..#.."],W:["#...#","#...#","#.#.#","##.##","#...#"],X:["#...#",".#.#.","..#..",".#.#.","#...#"],Y:["#...#",".#.#.","..#..","..#..","..#.."],Z:["#####","...#.","..#..",".#...","#####"],0:[".###.","#..##","#.#.#","##..#",".###."],1:["..#..",".##..","..#..","..#..",".###."],2:[".###.","#...#","..##.",".#...","#####"],3:["####.","....#",".###.","....#","####."],4:["#..#.","#..#.","#####","...#.","...#."],5:["#####","#....","####.","....#","####."],6:[".###.","#....","####.","#...#",".###."],7:["#####","....#","...#.","..#..",".#..."],8:[".###.","#...#",".###.","#...#",".###."],9:[".###.","#...#",".####","....#",".###."],".":[".....",".....",".....",".....","..#.."],"-":[".....",".....",".###.",".....","....."]," ":[".....",".....",".....",".....","....."]},sx=5,ux=1;function cx(l){return[...l.toUpperCase()].every(u=>Uo[u]!==void 0)}function rx(l){const u=[...l.toUpperCase()].map(r=>Uo[r]??Uo[" "]),o=".".repeat(ux);return Array.from({length:sx},(r,d)=>u.map(f=>f?.[d]??"").join(o))}function Sg(l,u,o){const r=u.repeat(o),d=" ".repeat(o);return l.map(f=>[...f].map(m=>m===_o?r:d).join(""))}function ox(l){const u=[".".repeat([...l[0]??""].length),...l],o=[];for(let r=0;r<u.length;r+=2){const d=[...u[r]??""],f=[...u[r+1]??""],m=[];for(let v=0;v<Math.max(d.length,f.length);v+=1){const x=d[v]===_o,y=f[v]===_o;m.push(x&&y?"█":x?"▀":y?"▄":" ")}o.push(m.join(""))}return o}function Ng(l,u){return[ix([...l.toUpperCase()].join(" "),u)]}function To(l){return l.reduce((u,o)=>Math.max(u,[...o].length),0)}function dx(l,u){const o=l.trim();if(o===""||!cx(o)){const m=Ng(o,u.columns);return{lines:m,tier:"plain",width:To(m)}}const r=rx(o),d=[{tier:"wide",lines:Sg(r,"█",2)},{tier:"block",lines:Sg(r,"█",1)},{tier:"half",lines:ox(r)}];for(const m of d){const v=m.lines.map(y=>y.replace(/\\s+$/,"")),x=To(v);if(x<=u.columns&&v.length<=u.rows)return{lines:v,tier:m.tier,width:x}}const f=Ng(o,u.columns);return{lines:f,tier:"plain",width:To(f)}}function Wg(l,u){const o=dx(l,{columns:u,rows:5});return{width:o.width,height:o.lines.length,cells:o.lines.flatMap((r,d)=>[...r].flatMap((f,m)=>f==="█"?[{x:m,y:d}]:[]))}}const fx=Wg(tt.name,60),Fi=Wg(tt.name.slice(0,1),9);function hx(l){return i.jsx("svg",{role:"img","aria-label":l.label??tt.name,viewBox:\`0 0 \${l.grid.width} \${l.grid.height}\`,height:l.height,className:"wordmark",shapeRendering:"crispEdges",children:l.grid.cells.map(({x:u,y:o})=>i.jsx("rect",{x:u,y:o,width:1,height:1,fill:"currentColor"},\`\${u}:\${o}\`))})}function Ig(l){return i.jsx(hx,{grid:fx,height:l.height??14})}function mx(){const u=Math.max(Fi.width,Fi.height)+4,o=(u-Fi.width)/2,r=(u-Fi.height)/2,d=Fi.cells.map(({x:m,y:v})=>\`<rect x='\${m+o}' y='\${v+r}' width='1' height='1'/>\`).join(""),f=\`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 \${u} \${u}' shape-rendering='crispEdges'><rect width='\${u}' height='\${u}' rx='1.5' fill='#121212'/><g fill='#d75fd7'>\${d}</g></svg>\`;return\`data:image/svg+xml,\${encodeURIComponent(f)}\`}const Eo=\`\${tt.slug}.turn\`;function gx(l){const[u,o]=T.useState(),[r,d]=T.useState();return T.useEffect(()=>{eb(l.baseUrl).then(o).catch(f=>d(f instanceof Error?f.message:String(f)))},[l.baseUrl]),r!==void 0?i.jsxs(Do,{title:"Cannot reach the server",children:[i.jsx("p",{children:r}),i.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Try again"})]}):u===void 0?i.jsx(Do,{title:"Connecting…"}):u.kind==="needed"?i.jsx(vx,{baseUrl:l.baseUrl,because:u.because}):i.jsx(bx,{baseUrl:l.baseUrl,token:u.kind==="key"?u.secret:void 0})}function Do(l){return i.jsx("div",{className:"gate",children:i.jsxs("div",{className:"card",children:[i.jsx("div",{className:"brand",children:i.jsx(Ig,{height:20})}),i.jsx("h2",{children:l.title}),l.children]})})}function vx(l){const[u,o]=T.useState(""),[r,d]=T.useState(),[f,m]=T.useState(!1),v=async x=>{m(!0),d(void 0);try{const y=x?await Og(l.baseUrl,u.trim()):u.trim();Ho(y),window.location.reload()}catch(y){d(y instanceof Error?y.message:String(y)),m(!1)}};return i.jsxs(Do,{title:"This server needs a credential",children:[l.because.replace(/\\.$/,"")==="This server needs a credential"?null:i.jsx("p",{children:l.because}),i.jsx("input",{value:u,type:"password",autoComplete:"off",placeholder:"paste a claim or an operator key",onChange:x=>o(x.target.value)}),i.jsxs("p",{className:"hint",style:{margin:"10px 0 16px"},children:[i.jsxs("code",{children:[tt.slug," serve"]})," prints a one-time claim at boot while no key exists; a claim is exchanged for a key this browser keeps. To mint a key instead, run ",i.jsxs("code",{children:[tt.slug," credential create"]})," where the server runs. An agent's own ",i.jsx("code",{children:".env"})," token is not the server's."]}),i.jsx("div",{className:"ask",children:i.jsxs("div",{className:"buttons",children:[i.jsx("button",{type:"button",className:"primary",disabled:f||u.trim()==="",onClick:()=>v(!0),children:"Exchange a claim"}),i.jsx("button",{type:"button",disabled:f||u.trim()==="",onClick:()=>v(!1),children:"Use as a key"})]})}),r===void 0?null:i.jsx("p",{className:"note bad",style:{marginTop:12},children:r})]})}const nl=l=>l instanceof xn&&l.status===404,yx={home:"Overview",team:"Team",models:"Models",turns:"Turns",usage:"Usage","server-usage":"Usage, all agents",api:"API",new:"New agent",tools:"Tools",schedules:"Schedules",channels:"Channels",config:"Settings",keys:"Operator keys",people:"People",rooms:"Rooms",actions:"Actions",memory:"Memory",webhooks:"Webhooks",backup:"Backup",files:"Files"};function bx(l){const u=T.useRef(_g(l.baseUrl,l.token)),[o,r]=T.useState([]),[d,f]=T.useState(),[m,v]=T.useState(),[x,y]=T.useState(),[j,g]=T.useState([]),S=T.useCallback(async()=>{f(void 0),v(void 0),g([]),re("this agent is no longer running on this server — start it from the list");try{r(await u.current.agents())}catch{}},[]),[N,R]=T.useState([]),[L,P]=T.useState(),J=N.find(p=>p.sessionKey===L),[Z,F]=T.useState(!1),[_,ge]=T.useState(()=>{const p=new URL(window.location.href).searchParams;return p.get("agent")===null&&p.get("panel")===null?"home":sb(window.location.href).panel}),[ee,V]=T.useState(al),[le,W]=T.useState(""),[Y,ne]=T.useState([]),[ae,Q]=T.useState(),[se,re]=T.useState(),D=T.useRef(void 0),te=T.useRef(db());T.useEffect(()=>{const p=new URL(window.location.href).searchParams.get("agent")??void 0;u.current.agents().then(C=>{r(C);const $=C.filter(fe=>fe.status!=="disabled"),X=$.find(fe=>fe.id===p)??$[0];if(X===void 0){new URL(window.location.href).searchParams.get("panel")===null&&ge("new");return}f(X.id),v(X.name),V(fe=>({...fe,filter:Eb(X.dialect??"nlt").filter})),document.title=\`\${X.name} · \${tt.name}\`}).catch(C=>re(Ze(C)))},[]);const K=T.useMemo(()=>d===void 0?void 0:u.current.agent(d),[d]),[Ce,Ae]=T.useState([]);T.useEffect(()=>{if(Ae([]),Q(void 0),K===void 0)return;let p=!1;return K.config().then(C=>{p||Ae(C.settings.filter($=>/^model\\.[^.<]+$/.test($.path)&&$.value!==void 0).map($=>$.path.slice(6)))}).catch(()=>{}),()=>{p=!0}},[K]);const A=T.useMemo(()=>N.filter(p=>!["web","local","api","schedule","room","owner","peer","shared"].includes(p.channel)).map(p=>({channel:p.channel,to:p.peerId,label:\`\${p.channel} → \${p.peerId}\`})),[N]),q=p=>o.find(C=>C.id===p)?.sessionScope,I=T.useCallback(async()=>{if(K!==void 0)try{R((await K.sessions()).filter(p=>!_0(p.sessionKey))),re(void 0)}catch(p){nl(p)?S():re(Ze(p))}},[K,S]);T.useEffect(()=>{I()},[I]);const ie=T.useCallback(async(p,C)=>{const $=te.current,X=$.begin(p);if(X===void 0)return;const fe=C.turn(p);D.current=()=>fe.stop();try{sessionStorage.setItem(Eo,p);for await(const pe of fe.stream({chunks:!0,children:!0,signal:X}))V(Ue=>Cb(Ue,pe))}catch(pe){X.aborted||(re(Ze(pe)),V(Ue=>({...Ue,running:!1})))}finally{$.finish(p),sessionStorage.removeItem(Eo),D.current=void 0,X.aborted||I()}},[I]);T.useEffect(()=>{if(K===void 0)return;let p=null;try{p=sessionStorage.getItem(ju)}catch{}const C=d===void 0?void 0:jb(p,d),$=sessionStorage.getItem(Eo);let X=!1;return(async()=>{const fe=C??await xx(K);if(fe!==void 0&&!X){try{d!==void 0&&sessionStorage.setItem(ju,Bm(d,fe))}catch{}P(fe);try{const pe=await wg(K,fe);X||V({...al,rows:pe})}catch{}}$===null||X||(V(pe=>({...pe,running:!0})),ie($,K))})(),()=>{X=!0,te.current.abort()}},[K,d,ie]),T.useEffect(()=>{if(K===void 0)return;let p=!0;const C=()=>{K.approvals().then(X=>{p&&g(X)}).catch(X=>{p&&nl(X)&&S()})};C();const $=window.setInterval(C,5e3);return()=>{p=!1,window.clearInterval($)}},[K,S]);const me=async()=>{const p=Y,C=le.trim()===""&&p.length>0?"(image)":le.trim();if(!(C===""||K===void 0)){W(""),ne([]),re(void 0),V($=>Ab($,p.length===0?C:\`\${C}
47
+ [\${p.length} image\${p.length===1?"":"s"}]\`));try{const $=L===void 0&&Z&&Dg(q(d))?await K.rotateSession():void 0;Z&&F(!1);const X=L??$?.sessionKey??xb(pe=>crypto.getRandomValues(new Uint8Array(pe))),fe=await K.send(C,{sessionKey:X,chunks:!0,...ae===void 0?{}:{role:ae},...p.length===0?{}:{images:p.map(pe=>({data:pe.data,mediaType:pe.mediaType}))}});fe.sessionKey!==L&&(P(fe.sessionKey),ye(fe.sessionKey),I()),await ie(fe.turnId,K)}catch($){re(Ze($)),V(X=>({...X,running:!1}))}}},be=async(p,C)=>{if(K!==void 0)try{await K.approve(p,C)}catch($){$ instanceof xn&&$.code==="approval_not_found"||re(Ze($))}},ye=p=>{try{p===void 0||d===void 0?sessionStorage.removeItem(ju):sessionStorage.setItem(ju,Bm(d,p))}catch{}},ze=async p=>{if(te.current.abort(),ge("chat"),F(!1),P(p),ye(p),V(al),W(""),!(p===void 0||K===void 0))try{const C=await wg(K,p);V({...al,rows:C})}catch(C){re(Ze(C))}},[oe,Wt]=T.useState({tools:[],schedules:[],channels:[],warnings:[],secrets:[]}),[Ea,Qn]=T.useState(void 0),[Vl,St]=T.useState(void 0),kt=T.useCallback(async p=>{const[C,$,X,fe,pe]=await Promise.all([p.tools(),p.schedules(),p.describe(),p.config(),p.secrets().catch(()=>[])]);Wt({tools:C,schedules:$,channels:X.channels??[],warnings:X.warnings??[],...X.team===void 0?{}:{team:X.team},...X.peers===void 0?{}:{peers:X.peers},ask:X.ask===!0,secrets:pe,...X.catalogueTokens===void 0?{}:{catalogueTokens:X.catalogueTokens},...X.capabilities===void 0?{}:{capabilities:X.capabilities},...X.phases===void 0||X.phases.length===0?{}:{phases:X.phases},config:fe})},[]),cl=T.useCallback(async(p,C)=>{if(K!==void 0){Qn(p),St(void 0);try{const $=await K.setChannel(p,C);St([...$.notes,...$.applied?[]:[\`Not in force yet: \${$.pending?.message??"restart to apply"}\`]].join(" ")),await kt(K)}catch($){St($ instanceof Error?$.message:String($))}finally{Qn(void 0)}}},[K,kt]),zu=T.useCallback(async p=>{if(K!==void 0){Qn(p),St(void 0);try{St((await K.unpairChannel(p)).note),await kt(K)}catch(C){St(C instanceof Error?C.message:String(C))}finally{Qn(void 0)}}},[K,kt]);T.useEffect(()=>{if(K===void 0||_!=="team"&&_!=="models"&&_!=="tools"&&_!=="schedules"&&_!=="channels"&&_!=="config")return;let p=!1;return(async()=>{try{if(await kt(K),p)return}catch(C){if(p)return;nl(C)?S():re(Ze(C))}})(),()=>{p=!0}},[K,_,S,kt]);const[ht,rl]=T.useState(),[Lt,ol]=T.useState(),nt=T.useCallback(async(p,C)=>{if(K!==void 0){rl(p),re(void 0),ol(void 0);try{const $=await C(K);ol($),await kt(K)}catch($){nl($)?S():re(Ze($))}finally{rl(void 0)}}},[K,S,kt]),Xn=T.useCallback((p,C,$)=>{nt(p,async X=>{const fe=await X.setConfig(p,C,{...$.confirm?{confirm:!0}:{}});return fe.applied?fe.reflowed?\`\${p} saved. The manifest was re-serialised, so its comments have moved — worth a look at the diff.\`:void 0:\`\${p} was written to the manifest and is not in force yet: \${fe.pending?.message??"the agent could not be replaced"}\`})},[nt]),[mt,Pi]=T.useState(),[Zl,Jl]=T.useState();T.useEffect(()=>{if(_!=="home")return;let p=!1;return u.current.usage({by:["agent"],from:new Date(Date.now()-7*864e5).toISOString()}).then(C=>{p||Jl(C.buckets)}).catch(()=>{p||Jl(void 0)}),()=>{p=!0}},[_]);const[jn,es]=T.useState("30d"),[Fl,ts]=T.useState(!1);T.useEffect(()=>{const p=_==="server-usage";if(!p&&(_!=="usage"||K===void 0))return;const C=p?u.current:K;if(C===void 0)return;let $=!1;Pi(void 0),ts(!0);const X=Lg.find(pe=>pe.key===jn)?.days??30,fe=new Date(Date.now()-X*864e5).toISOString();return Promise.all([C.usage({by:["day"],from:fe}),C.usage({by:["model"],from:fe}),C.usage({by:["sender"],from:fe}),p?C.usage({by:["agent"],from:fe}):Promise.resolve(void 0)]).then(([pe,Ue,Mt,La])=>{$||Pi({byDay:pe.buckets,byModel:Ue.buckets,bySender:Mt.buckets,...La===void 0?{}:{byAgent:La.buckets},...pe.meteredSince===void 0?{}:{meteredSince:pe.meteredSince}})}).catch(pe=>{$||(nl(pe)?S():re(Ze(pe)))}).finally(()=>{$||ts(!1)}),()=>{$=!0}},[_,K,jn,S]);const[Ou,Sn]=T.useState({}),bt=T.useCallback(async(p,C)=>{if(K!==void 0){Sn($=>({...$,[p]:{state:"loading"}}));try{const $=[];let X;for(let fe=0;fe<5;fe+=1){const pe=await K.messages(C,{limit:200,...X===void 0?{}:{before:X}}),Ue=pe.messages.filter(Mt=>Mt.turnId===p);if($.push(...Ue),$.length>0&&Ue.length<pe.messages.length||pe.nextBefore===void 0)break;X=pe.nextBefore}Sn(fe=>({...fe,[p]:{state:"ready",steps:$.reverse()}}))}catch($){Sn(X=>({...X,[p]:{state:"failed",message:Ze($)}}))}}},[K]),[on,gt]=T.useState([]),[ns,as]=T.useState(),[_u,Aa]=T.useState(!1),Vn=T.useCallback(async p=>{if(K!==void 0){Aa(!0);try{const C=await K.turns({limit:50,...p===void 0?{}:{before:p}});gt($=>p===void 0?C.turns:[...$,...C.turns]),as(C.nextBefore)}catch(C){nl(C)?S():re(Ze(C))}finally{Aa(!1)}}},[K,S]);T.useEffect(()=>{_==="turns"&&(gt([]),as(void 0),Vn())},[_,Vn]);const[Nn,It]=T.useState([]),[dl,Ca]=T.useState({}),[ls,fl]=T.useState(),ka=T.useCallback(async p=>{const[C,$]=await Promise.all([p.assignment(),u.current.participants()]);It($),fl(C.assignment?.participantId??null)},[]);T.useEffect(()=>{_!=="team"||K===void 0||(fl(void 0),ka(K).catch(()=>fl(void 0)))},[_,K,ka]);const[Ma,Uu]=T.useState([]),[wn,Wl]=T.useState(),[is,hl]=T.useState([]),[Il,Pl]=T.useState([]),[ss,dn]=T.useState([]),[qe,vt]=T.useState("space"),[Zn,ml]=T.useState(),[us,Du]=T.useState([]),[pt,Jn]=T.useState(),[Nt,fn]=T.useState(),xt=T.useMemo(()=>o.filter(p=>p.status!=="disabled").map(p=>({id:p.id,name:p.name})),[o]),qt=T.useCallback(async()=>{const p=u.current,[C,$]=await Promise.all([p.participants(),Promise.all(o.filter(X=>X.status!=="disabled").map(async X=>{try{const fe=await p.agent(X.id).assignment();return[X.id,fe.assignment?.participantId]}catch{return[X.id,void 0]}}))]);It(C),Ca(Object.fromEntries($.filter(([,X])=>X!==void 0)))},[o]),Pt=T.useCallback(async()=>Uu(await u.current.conversations()),[]),Qe=T.useCallback(async()=>dn(await u.current.actions()),[]),hn=T.useCallback(async()=>{const p=u.current,[C,$,X]=await Promise.all([p.notes(qe),p.projects(),p.participants()]);ml(C),Du($),It(X)},[qe]);T.useEffect(()=>{const p=_==="people"?qt:_==="rooms"?Pt:_==="actions"?Qe:_==="memory"?hn:void 0;if(p===void 0)return;let C=!1;return _==="memory"&&ml(void 0),p().catch($=>{C||re(Ze($))}),()=>{C=!0}},[_,qt,Pt,Qe,hn]),T.useEffect(()=>{if(_!=="rooms"||wn===void 0)return;let p=!1,C;hl([]);const $=async()=>{try{const pe=await u.current.conversationMessages(wn,{...C===void 0?{}:{after:C}});if(p)return;pe.messages.length>0&&hl(Ue=>[...Ue,...pe.messages]),pe.nextAfter!==void 0&&(C=pe.nextAfter)}catch(pe){p||re(Ze(pe))}};$();const X=setInterval(()=>{$()},3e3);Pl([]);const fe=new AbortController;return(async()=>{try{for await(const pe of u.current.events({types:["conversation.skipped"],signal:fe.signal})){if(pe.kind!=="event"||pe.event.type!=="conversation.skipped")continue;const Ue=pe.event.data;Ue.conversationId===wn&&Pl(Mt=>[...Mt,Ue])}}catch{}})(),()=>{p=!0,clearInterval(X),fe.abort()}},[_,wn]);const[cs,Tn]=T.useState([]),[En,rs]=T.useState(),[Ra,os]=T.useState(),[Fn,za]=T.useState("answers"),[Oa,en]=T.useState(),st=T.useCallback(async()=>Tn(await u.current.webhooks()),[]);T.useEffect(()=>{_==="webhooks"&&st().catch(p=>re(Ze(p)))},[_,st]),T.useEffect(()=>{_!=="new"||Fn!=="template"||Ra!==void 0||u.current.templates().then(os).catch(p=>re(Ze(p)))},[_,Fn,Ra]);const ei=T.useCallback((p,C)=>{const $=URL.createObjectURL(C),X=document.createElement("a");X.href=$,X.download=p,document.body.appendChild(X),X.click(),X.remove(),URL.revokeObjectURL($)},[]),[Bu,Wn]=T.useState(),[In,_a]=T.useState(),[ds,ut]=T.useState(),[An,gl]=T.useState(),Ua=T.useCallback(async p=>{const C=await p.vars().catch(()=>{});if(C===void 0)return gl(void 0);const $=(await u.current.templates().catch(()=>[])).find(X=>X.name===C.template)?.vars;gl({template:C.template,vars:C.vars,...$===void 0?{}:{declared:$}})},[]);T.useEffect(()=>{if(_!=="files"||K===void 0)return;let p=!1;return Wn(void 0),_a(void 0),ut(void 0),gl(void 0),Ua(K),K.workspaceFiles().then(C=>{p||Wn(C.files)}).catch(C=>{p||(nl(C)?S():re(Ze(C)))}),()=>{p=!0}},[_,K,S,Ua]),T.useEffect(()=>{if(_!=="files"||K===void 0||In===void 0)return;let p=!1;return ut(void 0),K.workspaceFile(In).then(C=>{p||ut(C.content)}).catch(C=>{p||re(Ze(C))}),()=>{p=!0}},[_,K,In]);const $e=T.useCallback(async(p,C,$)=>{Jn(p),fn(void 0);try{fn(await C()),await $()}catch(X){fn(Ze(X))}finally{Jn(void 0)}},[]),tn=T.useCallback(p=>oe.config?.settings.find(C=>C.path===p)?.value,[oe.config]),[ti,Pn]=T.useState(),Hu=T.useMemo(()=>{const p=tn("tools.providers");return p!==null&&typeof p=="object"&&!Array.isArray(p)?p:{}},[tn]),fs=T.useMemo(()=>{const p=tn("tools.providers");return p===null||typeof p!="object"||Array.isArray(p)?[]:Object.entries(p).map(([C,$])=>{const X=$!==null&&typeof $=="object"&&typeof $.apiKeyEnv=="string"?$.apiKeyEnv:void 0;return{id:C,...X===void 0?{}:{keyEnv:X,keySet:oe.secrets.find(fe=>fe.name===X)?.set??!1}}})},[tn,oe.secrets]),hs=T.useCallback((p,C)=>{nt(p,async $=>{const X=await $.setConfigs(C);return!X.reloaded&&X.applied?"Nothing changed.":X.applied?"Saved — the agent was replaced and runs on it now.":\`Written, not in force yet: \${X.pending?.message??"the agent could not be replaced"}\`})},[nt]),ni=T.useCallback((p,C)=>{nt(\`secret:\${p}\`,async $=>{const X=await $.setSecrets({[p]:C});return X.shadowed.includes(p)?\`\${p} was written, and the server's own environment sets it too — that value wins.\`:X.applied==="none"?\`\${p} written; \${X.error?.message??"the agent was not reloaded"}\`:\`\${p} saved.\`})},[nt]),[$t,ms]=T.useState(),[Cn,Gt]=T.useState({}),[ai,vl]=T.useState(!1),[kn,nn]=T.useState(!1),[Da,ea]=T.useState();T.useEffect(()=>{if(_!=="new"||$t!==void 0)return;let p=!1;return(async()=>{try{const C=await u.current.provision();if(p)return;ms(C),Gt(mb(C.steps))}catch(C){p||re(Ze(C))}})(),()=>{p=!0}},[_,$t]);const gs=T.useCallback(async()=>{if($t!==void 0&&(vl(!0),!(Ug($t.steps,Cn).length>0))){nn(!0),re(void 0);try{const p=await u.current.createAgent(yb($t.steps,Cn));ea(p),r(await u.current.agents())}catch(p){re(Ze(p))}finally{nn(!1)}}},[$t,Cn]),ct=T.useCallback(p=>{const C=p.panel??_,$=p.agentId??d;ge(C),p.agentId!==void 0&&p.agentId!==d&&(f(p.agentId),v(o.find(X=>X.id===p.agentId)?.name),P(void 0),V(al),W("")),window.history.replaceState(null,"",ub(window.location.href,{...$===void 0?{}:{agentId:$},panel:C}))},[d,o,_]),[an,Ba]=T.useState(!1);T.useEffect(()=>{const p=C=>{(C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="k"&&(C.preventDefault(),Ba($=>!$))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[]);const Ha=T.useMemo(()=>fb({agentPanels:So,serverPanels:jg,agents:xt,...d===void 0?{}:{current:{id:d,name:m??d}}}),[xt,d,m]),ln=T.useCallback(async p=>{y(p);try{await u.current.agent(p).start(),r(await u.current.agents())}catch(C){re(Ze(C))}finally{y(void 0)}},[]);return i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"side",children:[i.jsxs("header",{children:[i.jsx("div",{className:"brand",children:i.jsx(Ig,{})}),i.jsxs("span",{className:"version",children:[o.length," agent",o.length===1?"":"s"]})]}),i.jsxs("nav",{children:[i.jsx("div",{className:"group",children:"Agents"}),i.jsx(_p,{agents:o,current:_==="home"||_==="keys"||_==="api"||_==="new"?void 0:d,onSelect:p=>ct({agentId:p,panel:"chat"}),onStart:p=>{ln(p)},...x===void 0?{}:{starting:x}}),d===void 0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"group",children:m??d}),So.map(p=>i.jsx("button",{type:"button",className:"row-button","aria-current":_===p.panel,onClick:()=>p.panel==="chat"?void ze(L):ct({panel:p.panel}),children:p.label},p.panel)),i.jsx("div",{className:"group",children:"Conversations"}),i.jsx("button",{type:"button",className:"row-button","aria-current":_==="chat"&&L===void 0,onClick:()=>{ze(void 0),F(!0)},children:"+ new conversation"}),N.map(p=>i.jsx("button",{type:"button",className:\`row-button session\${Nb(p.sessionKey)?" person":""}\`,"aria-current":_==="chat"&&L===p.sessionKey,onClick:()=>{ze(p.sessionKey)},title:p.sessionKey,children:wb(p)},p.sessionKey))]}),i.jsx("div",{className:"group",children:"Server"}),jg.map(p=>i.jsx("button",{type:"button",className:"row-button","aria-current":_===p.panel,onClick:()=>ct({panel:p.panel}),children:p.label},p.panel)),i.jsx("button",{type:"button",className:"row-button","aria-current":_==="new",onClick:()=>ct({panel:"new"}),children:"+ New agent"})]}),i.jsxs("footer",{children:[i.jsx("span",{className:\`dot \${ee.running?"busy":"live"}\`}),i.jsx("span",{style:{fontSize:12,color:"var(--dim)"},children:ee.running?"working":"ready"}),l.token===void 0?i.jsx("span",{style:{fontSize:11,color:"var(--warn)",marginLeft:"auto"},children:"unauthenticated"}):i.jsx("button",{type:"button",style:{marginLeft:"auto",padding:"3px 8px",fontSize:11},onClick:()=>{Lo(),window.location.reload()},children:"sign out"})]})]}),an?i.jsx(ep,{entries:Ha,onClose:()=>Ba(!1),onPick:p=>{Ba(!1),ct(p.target)}}):null,i.jsxs("main",{className:"main",children:[i.jsxs("div",{className:"bar",children:[i.jsx("strong",{children:_==="chat"?m??"":yx[_]}),_==="chat"&&L!==void 0&&K!==void 0?i.jsx("button",{type:"button",className:"ghost hide-narrow",disabled:ee.running,onClick:()=>{window.confirm("Clear this conversation's history? The agent's memory files are kept.")&&nt(\`clear:\${L}\`,async p=>(await p.clearSession(L),V(al),"History cleared."))},children:"clear history"}):null,_==="chat"&&L!==void 0&&K!==void 0?i.jsx(Bp,{...J===void 0?{}:{session:J},...oe.phases===void 0?{}:{phases:oe.phases},busy:ee.running,onRecall:p=>{nt(\`recall:\${L}\`,async C=>(await C.setRecall(L,p),await I(),p?"This conversation is recalled again.":"Kept out of history recall. Its messages stay."))},onPhase:p=>{nt(\`phase:\${L}\`,async C=>(await C.setPhase(L,p),await I(),\`Phase set to \${p}.\`))}}):null,_==="chat"?i.jsx("span",{className:"crumb hide-narrow",children:L??"new conversation"}):null,i.jsx("span",{className:"spacer"}),j.length>0?i.jsxs("span",{style:{color:"var(--warn)"},children:[j.length," waiting on you"]}):null,i.jsx("button",{type:"button",className:"ghost hide-narrow",onClick:()=>ct({panel:"api"}),children:"API"}),i.jsx("a",{href:\`\${l.baseUrl}/docs\`,target:"_blank",rel:"noreferrer",children:"Docs ↗"}),i.jsx(Pb,{})]}),_!=="chat"?i.jsx("div",{className:"scroll",children:i.jsxs("div",{className:_==="home"?"pad wide":"pad",children:[se===void 0?null:i.jsx("p",{className:"row note bad",children:se}),So.some(p=>p.panel===_)?i.jsx(Hp,{warnings:oe.warnings}):null,_==="home"?i.jsx(Xb,{agents:o,...Zl===void 0?{}:{week:Zl},onUsage:()=>ct({panel:"server-usage"}),onOpen:p=>ct({agentId:p,panel:"chat"}),onStart:p=>{ln(p)},onNew:()=>ct({panel:"new"}),...x===void 0?{}:{starting:x}}):null,_==="api"?i.jsx(Ib,{baseUrl:l.baseUrl,agentId:d}):null,_==="models"?oe.config===void 0?i.jsx("p",{className:"empty",children:"reading this agent's models…"}):i.jsx(zb,{settings:oe.config.settings,secrets:oe.secrets,...oe.capabilities===void 0?{}:{resolved:oe.capabilities},...ht===void 0?{}:{busy:ht},...Lt===void 0?{}:{note:Lt},onChange:hs,onSecret:ni}):null,_==="team"&&d!==void 0?i.jsx(Zb,{lead:{id:d,name:m??d},team:oe.team,...oe.peers===void 0?{}:{peers:oe.peers},...oe.ask===void 0?{}:{ask:oe.ask},busy:ht!==void 0,onAsk:p=>Xn("delegation.ask",p?"true":"false",{confirm:!1}),...ls===void 0?{}:{owner:ls},people:Nn,onAssign:p=>{nt("assign",async C=>(p===void 0?await C.unassign():await C.assign(p),await ka(C),await kt(C),p===void 0?"Now a shared agent: anyone's agent may ask it.":\`Now works for \${p}.\`))}}):null,_==="new"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"page-head",children:[i.jsx("h1",{children:"New agent"}),i.jsx("p",{children:"Answer the wizard's questions, or start from a template this server holds."})]}),i.jsxs("fieldset",{className:"segmented",style:{marginBottom:18},children:[i.jsx("button",{type:"button","aria-pressed":Fn==="answers",onClick:()=>za("answers"),children:"from answers"}),i.jsx("button",{type:"button","aria-pressed":Fn==="template",onClick:()=>za("template"),children:"from a template"})]})]}):null,_==="new"&&Fn==="template"?Ra===void 0?i.jsx("p",{className:"empty",children:"reading this server's templates…"}):Da!==void 0&&$t!==void 0?i.jsx(Gm,{offer:$t,answers:{},busy:!1,touched:!1,result:Da,onAnswer:()=>{},onSubmit:()=>{},onOpen:p=>{ea(void 0),ct({agentId:p,panel:"chat"})}}):i.jsx($b,{templates:Ra,busy:kn,...se===void 0?{}:{error:se},onCreate:p=>{(async()=>{nn(!0),re(void 0);try{ea(await u.current.createAgentFromTemplate(p)),r(await u.current.agents())}catch(C){re(Ze(C))}finally{nn(!1)}})()}}):null,_==="new"&&Fn==="answers"?$t===void 0?i.jsx("p",{className:"empty",children:"reading this server's questions…"}):i.jsx(Gm,{offer:$t,answers:Cn,busy:kn,touched:ai,...se===void 0?{}:{error:se},...Da===void 0?{}:{result:Da},onAnswer:(p,C)=>Gt($=>({...$,[p]:C})),onSubmit:()=>{gs()},onOpen:p=>{ea(void 0),ms(void 0),vl(!1),ct({agentId:p,panel:"chat"})}}):null,_==="keys"?i.jsx(nb,{client:u.current,baseUrl:l.baseUrl,token:l.token,agents:xt}):null,_==="people"?i.jsx(Yp,{people:Nn,assignments:dl,agents:xt,...pt===void 0?{}:{busy:pt},...Nt===void 0?{}:{note:Nt},onRegister:p=>{$e("register",async()=>{await u.current.registerParticipant(p)},qt)},onRemove:p=>{$e(\`remove:\${p}\`,async()=>{await u.current.deleteParticipant(p)},qt)},onPresence:(p,C)=>{$e(\`presence:\${p}\`,async()=>{await u.current.setPresence(p,C)},qt)},onAssign:(p,C)=>{$e(\`assign:\${p}\`,async()=>{C===void 0?await u.current.agent(p).unassign():await u.current.agent(p).assign(C)},qt)}}):null,_==="rooms"?i.jsx(Xp,{rooms:Ma,people:Nn,agents:xt,...wn===void 0?{}:{selected:wn},messages:is,skips:Il,...pt===void 0?{}:{busy:pt},...Nt===void 0?{}:{note:Nt},onSelect:Wl,onCreate:p=>{$e("room",async()=>{const C=await u.current.createConversation(p);Wl(C.id)},Pt)},onPost:(p,C,$,X)=>{$e(\`post:\${p}\`,async()=>{await u.current.postMessage(p,{text:C,authorId:$,...X.length===0?{}:{mentions:X}})},async()=>{})},onMembers:(p,C)=>{$e(\`members:\${p}\`,async()=>{await u.current.setMembers(p,C)},Pt)}}):null,_==="actions"?i.jsx(Fp,{actions:ss,...pt===void 0?{}:{busy:pt},onDecide:(p,C)=>{$e(p,async()=>(await u.current.decideAction(p,C)).status==="done"?"Ran as the owner's agent; the outcome is in the DM.":void 0,Qe)}}):null,_==="memory"?i.jsx(Wp,{scope:qe,scopes:["space",...Nn.map(p=>\`owner:\${p.id}\`),...us.map(p=>\`project:\${p.id}\`),...qe.startsWith("owner:")||qe.startsWith("project:")||qe==="space"?[]:[qe]].filter((p,C,$)=>$.indexOf(p)===C),notes:Zn,projects:us,agents:xt,...pt===void 0?{}:{busy:pt},...Nt===void 0?{}:{note:Nt},onScope:vt,onAdd:(p,C)=>{$e("add",async()=>{await u.current.addNote({scope:p,text:C})},hn)},onDelete:p=>{$e(p,async()=>{await u.current.deleteNote(p)},hn)},onProject:(p,C)=>{$e(\`project:\${p}\`,async()=>{await u.current.putProject(p,C)},hn)},onDeleteProject:p=>{$e(\`project:\${p}\`,async()=>{await u.current.deleteProject(p)},hn)},onSpaceWriter:p=>{$e("space-writer",async()=>(await u.current.setSpaceWriter(p),\`\${p} may write the space.\`),hn)}}):null,_==="webhooks"?i.jsx(Lb,{webhooks:cs,eventTypes:Eg,agents:xt,...En===void 0?{}:{secret:En},...pt===void 0?{}:{busy:pt},...Nt===void 0?{}:{note:Nt},onCreate:p=>{$e("webhook",async()=>{const C=await u.current.createWebhook(p);rs(C.secret)},st)},onDelete:p=>{$e(p,async()=>{await u.current.deleteWebhook(p)},st)},onDismissSecret:()=>rs(void 0)}):null,_==="backup"?i.jsx(qb,{agents:xt,...pt===void 0?{}:{busy:pt},...Nt===void 0?{}:{note:Nt},...Oa===void 0?{}:{lastImport:Oa},onBackup:p=>{$e("backup",async()=>(ei(\`\${tt.slug}-backup-\${new Date().toISOString().slice(0,10)}.tar.gz\`,await u.current.backup(p)),"Backup downloaded."),async()=>{})},onExport:p=>{$e(\`export:\${p}\`,async()=>{const C=await u.current.agent(p).exportBundle();return ei(\`\${p}-bundle.json\`,new Blob([JSON.stringify(C,null,2)],{type:"application/json"})),\`\${p}'s bundle downloaded: \${C.files.length} files.\`},async()=>{})},onImport:(p,C,$)=>{$e(\`import:\${p}\`,async()=>{const X=JSON.parse(await C.text());en(await u.current.agent(p).importBundle(X,$))},async()=>{})}}):null,_==="files"?i.jsx(Kb,{...An===void 0?{}:{above:i.jsx(Gb,{template:An.template,values:An.vars,...An.declared===void 0?{}:{declared:An.declared},busy:ht==="vars",onSave:p=>{nt("vars",async C=>{const $=await C.setVars(p);await Ua(C),Wn(await C.workspaceFiles().then(fe=>fe.files));const X=$.skipped.map(fe=>\`\${fe.file} (\${fe.reason})\`).join(", ");return\`\${$.rendered.length===0?"No file changed":\`Re-rendered \${$.rendered.join(", ")}\`}\${X===""?"":\`; kept \${X}\`}.\${$.reload==="pending"?" The reload waits for the running turn.":""}\`})}})},files:Bu,...In===void 0?{}:{selected:In},...ds===void 0?{}:{content:ds},...ht===void 0?{}:{busy:ht},...Lt===void 0?{}:{note:Lt},onSelect:_a,onSave:(p,C)=>{nt(p,async $=>{const X=await $.putWorkspaceFile(p,C);return ut(C),Wn(await $.workspaceFiles().then(fe=>fe.files)),X.loads?X.applied?\`\${p} saved and in force.\`:\`\${p} written; not in force yet: \${X.pending?.message??""}\`:\`\${p} written, but the agent would not load with it: \${X.error?.message??""}\`})}}):null,_==="usage"?i.jsx(Km,{report:mt,range:jn,onRange:es,loading:Fl,...m===void 0?{}:{agentName:m}}):null,_==="server-usage"?i.jsx(Km,{report:mt,range:jn,onRange:es,loading:Fl}):null,_==="turns"?i.jsx(nx,{turns:on,hasMore:ns!==void 0,loading:_u,onMore:()=>{Vn(ns)},onOpenSession:p=>{ze(p)},replays:Ou,onReplay:p=>{bt(p.turnId,p.sessionKey)}}):null,_==="tools"?i.jsx(zp,{tools:oe.tools,...oe.catalogueTokens===void 0?{}:{catalogueTokens:oe.catalogueTokens},pinned:Ao(tn("tools.pinned")),allow:Ao(tn("tools.policy.allow")),deny:Ao(tn("tools.policy.deny")),providers:fs,providerConfig:Hu,onProviders:p=>Xn("tools.providers",JSON.stringify(p),{confirm:!1}),...ht===void 0?{}:{busy:ht},...Lt===void 0?{}:{note:Lt},...ti===void 0?{}:{lastRefresh:ti},onPin:p=>Xn("tools.pinned",JSON.stringify(p),{confirm:!1}),onRules:(p,C)=>Xn(\`tools.policy.\${p}\`,JSON.stringify(C),{confirm:!1}),onRefresh:()=>{nt("tools.refresh",async p=>{const C=await p.refreshTools();return Pn(C),C.reload==="pending"?"Catalogue fetched; the reload lands when the running turn ends.":void 0})}}):null,_==="schedules"?i.jsx(Ap,{schedules:oe.schedules,now:Date.now(),roles:Ce,recipients:A,onPreview:p=>K===void 0?Promise.reject(new Error("no agent")):K.previewSchedule(p),...ht===void 0?{}:{busy:ht},onCreate:p=>{nt(String(p.id),C=>C.createSchedule(p).then(()=>{}))},onDelete:p=>{nt(p,C=>C.deleteSchedule(p).then(()=>{}))},onRun:p=>{nt(p,async C=>{const $=await C.runSchedule(p);return\`\${p} fired out of band as \${$.turnId} — its next scheduled run has not moved.\`})},onToggle:(p,C)=>{nt(p,$=>$.updateSchedule(p,{enabled:C}).then(()=>{}))}}):null,_==="config"?oe.config===void 0?i.jsx("p",{className:"empty",children:"reading this agent's settings…"}):i.jsx(Up,{settings:oe.config.settings,editable:oe.config.editable,...oe.config.file===void 0?{}:{file:oe.config.file},...ht===void 0?{}:{busy:ht},...Lt===void 0?{}:{note:Lt},onSet:Xn}):null,_==="channels"?i.jsx(Lp,{channels:oe.channels,now:Date.now(),...d===void 0?{}:{agentUrl:\`\${l.baseUrl}/v1/agents/\${encodeURIComponent(d)}\`},actions:{onConnect:(p,C)=>{cl(p,{enabled:C})},onCredential:(p,C)=>{cl(p,{credential:C})},onUnpair:p=>{zu(p)},...Ea===void 0?{}:{busy:Ea},...Vl===void 0?{}:{note:Vl}}}):null,_==="channels"?i.jsx(Yb,{existing:oe.channels.map(p=>p.id),busy:ht==="channels",onAdd:p=>{const C=tn("channels"),$=Array.isArray(C)?C:[];Xn("channels",JSON.stringify([...$,p]),{confirm:!1})}}):null]})}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"scroll",children:i.jsxs("div",{className:"pad",children:[se===void 0?null:i.jsx("p",{className:"row note bad",children:se}),i.jsx(X0,{state:ee,onAnswer:(p,C)=>{be(p,C)}}),i.jsx(px,{state:ee})]})}),i.jsx(W0,{value:le,busy:ee.running,onChange:W,onSend:()=>{me()},onStop:()=>{D.current?.()},roles:Ce,...ae===void 0?{}:{role:ae},onRole:Q,images:Y,onImages:ne})]})]})]})}function px(l){const u=T.useRef(null),o=T.useRef(!0);T.useEffect(()=>{const f=u.current?.closest(".scroll");if(f==null)return;const m=()=>{o.current=ob(f)};return f.addEventListener("scroll",m,{passive:!0}),()=>f.removeEventListener("scroll",m)},[]);const r=l.state.rows.length+l.state.live.length+l.state.liveReasoning.length,d=T.useRef(0);return T.useLayoutEffect(()=>{const f=u.current,m=d.current===0;d.current=r,f!==null&&(m&&(o.current=!0),o.current&&f.scrollIntoView({block:"end"}))},[r]),i.jsx("div",{ref:u})}async function wg(l,u){return[...(await l.messages(u,{limit:200})).messages??[]].reverse().filter(r=>r.origin===void 0&&(r.role==="user"||r.role==="assistant")&&(r.content??"")!=="").map((r,d)=>({kind:r.role==="user"?"user":"reply",id:\`h\${d}\`,text:r.content??""}))}function Ao(l){return Array.isArray(l)?l.filter(u=>typeof u=="string"):[]}function Ze(l){return l instanceof xn||l instanceof Error?l.message:String(l)}async function xx(l){try{return Dg((await l.describe()).sessionScope)?(await l.sessions()).find(u=>u.head!==!1&&u.sessionKey.startsWith("owner:"))?.sessionKey:void 0}catch{return}}Kg(Gg());document.querySelector("link[rel=icon]")?.setAttribute("href",mx());const Pg=document.getElementById("root");if(Pg===null)throw new Error("no #root in the document");f0.createRoot(Pg).render(i.jsx(T.StrictMode,{children:i.jsx(gx,{baseUrl:window.location.origin})}));
48
+ `;var Wn=`<!doctype html>
49
+ <html lang="en">
50
+ <head>
51
+ <meta charset="utf-8" />
52
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
53
+ <!--
54
+ An inline SVG data URI rather than a file, and that is a constraint rather than a
55
+ flourish: the server embeds these assets as *text* (decision 11.200), so a binary
56
+ favicon would be the one thing in the build that could not ride inside the bundle.
57
+ -->
58
+ <link
59
+ rel="icon"
60
+ href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%230b0b0c'/%3E%3Cpath d='M9 8h7a8 8 0 0 1 0 16H9z' fill='none' stroke='%23e8e6e3' stroke-width='2.5'/%3E%3C/svg%3E"
61
+ />
62
+ <title>Dispach</title>
63
+ <!--
64
+ No title text beyond the brand. The page sets \`document.title\` from the agent it is
65
+ actually talking to once it knows, because a tab saying "Dispach" next to three others
66
+ saying "Dispach" is a tab nobody can find.
67
+ -->
68
+ <script type="module" crossorigin src="./assets/app.js"></script>
69
+ <link rel="stylesheet" crossorigin href="./assets/app.css">
70
+ </head>
71
+ <body>
72
+ <div id="root"></div>
73
+ </body>
74
+ </html>
75
+ `;function Vn(a){let e=2166136261;for(let d=0;d<a.length;d+=1)e^=a.charCodeAt(d),e=Math.imul(e,16777619)>>>0;return`"${e.toString(36)}-${a.length.toString(36)}"`}function Ae(a,e){return{body:a,contentType:e,etag:Vn(a)}}var on={"/":Ae(Wn,"text/html; charset=utf-8"),"/assets/app.js":Ae(qn,"text/javascript; charset=utf-8"),"/assets/app.css":Ae(Gn,"text/css; charset=utf-8")},Qn=Object.keys(on);function Yn(a,e){let d=on[a];if(d===void 0)return;let u={"content-type":d.contentType,etag:d.etag,"cache-control":"no-cache"};if(e.headers.get("if-none-match")===d.etag)return new Response(null,{status:304,headers:u});return new Response(d.body,{status:200,headers:u})}var Jn=1e6,Xn=25000000,nt=256,Zn=128,_e=255,ea=`<!doctype html>
76
+ <html lang="en">
77
+ <head>
78
+ <meta charset="utf-8">
79
+ <meta name="viewport" content="width=device-width, initial-scale=1">
80
+ <title>Dispach API</title>
81
+ </head>
82
+ <body style="margin:0">
83
+ <noscript style="display:block;font:14px/1.5 system-ui;padding:2rem;max-width:40rem">
84
+ <h1 style="font-size:1rem">This page needs JavaScript and a network</h1>
85
+ <p>It loads the reference viewer from a CDN. The document itself is served locally and needs
86
+ neither: <a href="/v1/openapi.json">/v1/openapi.json</a>.</p>
87
+ </noscript>
88
+ <div id="app"></div>
89
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
90
+ <script>
91
+ Scalar.createApiReference('#app', { url: '/v1/openapi.json', theme: 'default' })
92
+ </script>
93
+ </body>
94
+ </html>
95
+ `;function ta(a){let{runtime:e}=a,d=a.token,u=a.now??(()=>Date.now()),p=u();if(d===void 0&&a.allowUnauthenticated!==!0)throw new te({code:"server_token_missing",message:"createHandler was called with no token and no allowUnauthenticated.",hint:"Pass token, or pass allowUnauthenticated: true to state that this handler is mounted somewhere already protected. Defaulting to open would make the safe configuration the one you have to remember."});let m=a.running??new Map,b=a.approvals??Yr(),S=()=>a.origin!==void 0&&je(a.origin.host),V=(i)=>S()||i.kind!=="open"&&Te(i,"admin"),B=(i)=>{if(a.origin===void 0)return;let t=Se(i,a.origin);return t===void 0?void 0:f(t,403)},j=(i,t)=>{if(a.origin===void 0)return t;let o=zn(i,a.origin);if(Object.keys(o).length===0)return t;let l=new Headers(t.headers);for(let[c,h]of Object.entries(o))l.set(c,h);return new Response(t.body,{status:t.status,statusText:t.statusText,headers:l})},Z=!1,z=async()=>{if(d!==void 0||Z)return!0;return Z=await e.store.operatorKeys.liveCount()>0,Z},F=async(i,t,o)=>{if(na(t)||!await z())return{kind:"open"};let l=await kn({request:i,expected:d,keys:e.store.operatorKeys,claim:a.claim,pathname:t,at:u()});if(l instanceof Response)return l;if(l.kind==="claim")return l;if(o!=="open"&&!Te(l,o))return wn(o,`${i.method} ${t}`);return l},g=new nn;g.add("GET","/v1/health",()=>w({status:"ok",version:xe,uptimeMs:u()-p,agents:e.list().length}),{capability:"open"}),g.add("GET","/v1/ready",()=>{if(e.ready)return w({status:"ready",agents:e.list().length});if(e.draining)return w({status:"draining",agents:e.list().length},503);return w({status:"starting",agents:e.list().length},503)},{capability:"open"}),g.add("GET","/v1/activity",async(i)=>{let t=i.principal;if(t.kind==="key"&&t.scope!==void 0&&(t.scope.agents!==void 0||t.scope.sessions!==void 0))return f({code:"activity_needs_unscoped_key",message:"Activity covers every agent on this server, and this key is scoped.",hint:"Call this with the server token or an operator key minted with no agents or sessions scope — it is meant for whatever suspends and wakes the process, not for a tenant."},403);return w(await e.activity(u()))},{capability:"admin"}),g.add("GET","/v1/agents",async(i)=>{let t=await Promise.all(e.list().map(async(c)=>({...yt(e,c),assignee:(await e.store.conversations.assignment(c.id))?.participantId??null}))),o=new Set(t.map((c)=>c.id)),l=(await e.store.agentState.list()).filter((c)=>!c.enabled&&!o.has(c.agentId)).map(ht);return w(sa(i.principal,[...t,...l]))},{capability:"read"}),g.add("GET","/v1/agents/:id",async(i)=>{let t=i.params.id??"";if(!e.list().some((o)=>o.id===t)&&X(i.principal,t)){let o=await e.store.agentState.get(t);if(o!==void 0&&!o.enabled)return w(ht(o));let l=a.resolveAgent?.(t);if(l!==void 0){let c=await e.diagnose(l);return w({id:t,status:c===void 0?"not_running":"failed",...c===void 0?{}:{error:c}})}}return I(e,i,async(o)=>{let l=await o.store.schedules.list(o.id),c=e.team(o.id),h=await e.store.conversations.assignment(o.id),y=await e.askPeers(o.id);return w({...yt(e,o),...h===void 0?{}:{assignedTo:{participantId:h.participantId,...h.assignedBy===void 0?{}:{assignedBy:h.assignedBy},assignedAt:h.assignedAt}},dialect:o.describe().dialect,window:o.window,capabilities:o.roles.main.capabilities,tools:o.tools.size,catalogueTokens:o.describe().catalogueTokens,skills:o.skills?.skills.length??0,schedules:l.length,...y.length===0?{}:{peers:y},...c.length===0?{}:{team:c.map((v)=>({id:v.id,task:v.task,artifact:Object.keys(v.artifact.properties)}))},warnings:[...o.warnings,...o.tools.warnings]})})},{capability:"read"}),g.add("GET","/v1/backup",async(i)=>{if(i.principal.kind==="key"&&i.principal.scope?.agents!==void 0)return f({code:"backup_requires_unscoped_key",message:"This key reaches only some agents, and a backup holds every agent's data.",hint:"Take backups with a key that has admin and no agents scope."},403);let t=(i.url.searchParams.get("include")??"").split(",").map((A)=>A.trim()).filter((A)=>A!==""),o=t.filter((A)=>A!=="home"&&!Object.hasOwn(Re,A));if(o.length>0)return f({code:"backup_include_invalid",message:`include names ${o.join(", ")}, which a backup cannot add.`,hint:`Accepted: ${[...Object.keys(Re),"home"].join(", ")}, comma-separated. env adds each agent's .env (its secrets), git its .git directories, home everything else in the state directory.`,field:"include"},400);let l=a.home;if(t.includes("home")&&l===void 0)return f({code:"backup_home_unavailable",message:"include=home asks for the state directory, and this server was not given one.",hint:"`serve` passes it; a handler embedded elsewhere sets HandlerOptions.home. The store and agent directories are backed up without it.",field:"include"},400);let c=new Set(pa);for(let A of t)for(let q of Re[A]??[])c.delete(q);let h=await fn(De(vn(),"backup-")),y=De(h,"store.db");await e.store.snapshot(y);let v=[{name:"store.db",source:{path:y}}],k=[];for(let A of e.list()){let q=await xt(A.dir,c);for(let P of q)v.push({name:`agents/${A.id}/${P.name}`,source:{bytes:await Me(P.path)}});k.push({id:A.id,dir:A.dir,files:q.length})}let C;if(t.includes("home")&&l!==void 0){let A=new Set(e.list().map((W)=>he(W.dir))),q=(...W)=>he(l,...W),P=new Set([...A,q("logs"),q("sources"),...["","-wal","-shm","-journal"].map((W)=>q(`store.db${W}`))]),Q=await xt(l,c,P);for(let W of Q)v.push({name:`home/${W.name}`,source:{path:W.path}});C=Q.length}let T={createdAt:new Date().toISOString(),version:xe,agents:k,included:t,...C===void 0?{}:{home:{dir:l,files:C}},excluded:[...c]};v.unshift({name:"backup.json",source:{bytes:new TextEncoder().encode(`${JSON.stringify(T,null,2)}
96
+ `)}});let U=T.createdAt.replace(/[:.]/g,"-");return new Response(Hn(v,()=>gn(h,{recursive:!0,force:!0})),{headers:{"content-type":"application/gzip","content-disposition":`attachment; filename="backup-${U}.tar.gz"`}})},{capability:"admin"}),g.add("GET","/v1/agents/:id/export",(i)=>I(e,i,async(t)=>{let o=await ee(i.principal);if(o!==void 0)return o;let l=i.url.searchParams.get("paths");try{let c=_s(l===null?void 0:l.split(",").map((h)=>h.trim()));return w(ks(t,c))}catch(c){return O(c)}}),{capability:"admin"}),g.add("POST","/v1/agents/:id/import",(i)=>I(e,i,async(t)=>{let o=await ee(i.principal);if(o!==void 0)return o;let l=await L(i.request,Xn);if(l.kind==="error")return f(l.error,400);let c=K(Wt,l.value);if(!c.ok)return f(c.error,400);try{let h=await vs({agent:t,bundle:c.value.bundle,...c.value.mode===void 0?{}:{mode:c.value.mode},reload:async()=>(await e.reload(t.id)).status});return w({id:t.id,...h})}catch(h){return O(h)}}),{capability:"admin"}),g.add("GET","/v1/agents/:id/vars",(i)=>de(e,a,i,async(t)=>{let o=a.provision?.templateOf;if(o===void 0)return f({code:"rerender_not_supported",message:"This server cannot read an agent's template record.",hint:"`serve` provides it; an embedder mounting this handler has no templates directory."},501);let l=o(t.agent?.dir??be(t.file??""));if(l===void 0)return f({code:"agent_not_from_template",message:"This agent has no record of the template it was made from.",hint:"Only an agent created with POST /v1/agents {template} on 0.2.0 or later carries one. Edit its files directly instead."},409);return w({id:t.id,template:l.template,vars:l.vars})}),{capability:"admin"}),g.add("PATCH","/v1/agents/:id/vars",(i)=>de(e,a,i,async(t)=>{let o=a.provision?.rerender;if(o===void 0)return f({code:"rerender_not_supported",message:"This server cannot re-render an agent's template.",hint:"`serve` provides it; an embedder mounting this handler has no templates directory. Edit the files and POST /reload instead."},501);if(!V(i.principal))return f({code:"provisioning_not_local",message:"Re-rendering an agent's files needs either a loopback bind or a credential with the admin capability.",hint:"It writes the agent's files, like creating one. Present the server's token or an operator key minted with `can: [admin]`."},403);let l=await L(i.request);if(l.kind==="error")return f(l.error,400);let c=K(Tt,l.value);if(!c.ok)return f(c.error,400);let h;try{h=o({agentDir:t.agent?.dir??be(t.file??""),vars:c.value.vars})}catch(v){if(R(v))return f(v.toDetail(),v.code==="agent_not_from_template"?409:400);throw v}let y=(v,k=200)=>w({id:t.id,rendered:h.rendered,skipped:h.skipped,reload:v},k);if(h.rendered.length===0)return y("none");if(t.agent===void 0)return y("none");try{let v=await e.reload(t.id);return y(v.status,v.status==="pending"?202:200)}catch(v){if(h.undo(),R(v))return f(v.toDetail(),400);throw v}}),{capability:"admin"}),g.add("GET","/v1/agents/:id/workspace",(i)=>de(e,a,i,async(t)=>{let o=t.file;if(o===void 0)return w({id:t.id,files:[]});let l=await $e(t.id,o);if(l instanceof Response)return l;return w({id:t.id,files:l.declared.map((c)=>({name:ye(c.path),tier:c.tier,field:c.field,exists:fe(c.path),bytes:fe(c.path)?hn(c.path).size:0}))})}),{capability:"admin"}),g.add("GET","/v1/agents/:id/workspace/:file",(i)=>de(e,a,i,async(t)=>{let o=t.file,l=i.params.file??"";if(o===void 0)return Oe(t.id,l,[]);let c=await $e(t.id,o);if(c instanceof Response)return c;let h=vt(c.declared,c.workspaceDir,l);if(h===void 0)return Oe(t.id,l,c.declared);let y=c.declared.find((v)=>v.path===h);return w({id:t.id,file:ye(h),...y===void 0?{}:{tier:y.tier,field:y.field},exists:fe(h),content:fe(h)?Ge(h,"utf8"):""})}),{capability:"admin"}),g.add("PUT","/v1/agents/:id/workspace/:file",(i)=>de(e,a,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Et,o.value);if(!l.ok)return f(l.error,400);let c=t.file;if(c===void 0)return f({code:"config_not_editable",message:`"${t.id}" was loaded from an object, so it has no files to write.`,hint:"An embedder holding new settings passes the new object to dispose() and adopt()."},409);let h=await $e(t.id,c);if(h instanceof Response)return h;let{workspaceDir:y,declared:v}=h,k=i.params.file??"",C=vt(v,y,k);if(C===void 0)return Oe(t.id,k,v);let T=fe(C)?Ge(C,"utf8"):void 0;dn(be(C),{recursive:!0}),qe(C,l.value.content,"utf8");let U=ye(C);if(t.agent===void 0){let A=await e.diagnose(c);return w({id:t.id,file:U,written:!0,loads:A===void 0,...A===void 0?{}:{error:A},applied:!1,pending:mt(t.id)})}try{let A=await e.reload(t.id);return w({id:t.id,file:U,written:!0,loads:!0,...A.status==="pending"?{applied:!1,pending:we(A)}:{applied:!0}})}catch(A){if(T===void 0)pn(C,{force:!0});else qe(C,T,"utf8");if(R(A))return f(A.toDetail(),400);throw A}}),{capability:"admin"}),g.add("POST","/v1/agents/:id/tools/refresh",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Ct,o.value);if(!l.ok)return f(l.error,400);try{let c=await e.refreshTools(t.id,{...l.value.providers===void 0?{}:{providers:l.value.providers}});return w({id:t.id,...c},c.reload==="pending"?202:200)}catch(c){if(R(c))return f(c.toDetail(),c.code==="agent_turn_in_flight"?409:400);throw c}}),{capability:"admin"}),g.add("POST","/v1/agents/:id/reload",(i)=>I(e,i,async(t)=>{try{let o=await e.reload(t.id);if(o.status==="pending")return w({id:t.id,status:"pending",adopted:[],running:o.running,holdAfterMs:o.holdAfterMs},202);return w({id:t.id,status:"loaded",adopted:o.adopted.map((l)=>l.id)})}catch(o){if(R(o))return f({code:o.code,message:o.message,hint:o.hint,...o.field===void 0?{}:{field:o.field}},o.code==="agent_turn_in_flight"?409:400);throw o}}),{capability:"admin"}),g.add("GET","/v1/openapi.json",(i)=>w($n({routes:g.routes(),serverUrl:`${i.url.protocol}//${i.url.host}`})),{capability:"open"}),g.add("GET","/docs",()=>new Response(ea,{status:200,headers:{"content-type":"text/html; charset=utf-8"}}),{capability:"open"}),g.add("GET","/v1/provision",(i)=>w({available:a.provision!==void 0,local:S(),allowed:V(i.principal),steps:a.provision?.steps()??[]}),{capability:"read"}),g.add("POST","/v1/agents",async(i)=>{let t=a.provision;if(t===void 0)return f({code:"provisioning_not_supported",message:"This server cannot create agents.",hint:"Creating one writes a directory of files from a question set this process was not given — an embedder mounting this handler over its own agent store is the case that lands here. Run `init` where the sandbox is, or mount an agent directory."},501);if(!V(i.principal))return f({code:"provisioning_not_local",message:"Creating an agent needs either a loopback bind or a credential with the admin capability.",hint:"This route writes files and starts an agent. A token-less loopback server is a supported configuration, so on a non-loopback bind it asks for a credential instead — set server.tokenEnv (the container's DISPACH_API_TOKEN does this) or present an operator key minted with `can: [admin]`. What is refused is provisioning on a server that required no credential at all and is reachable from the network."},403);let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(zt,o.value);if(!l.ok)return f(l.error,400);let{answers:c,template:h}=l.value;if(c!==void 0&&h!==void 0)return f({code:"provision_body_ambiguous",message:"The body has both answers and a template.",hint:"Send answers to create an agent the way init does, or template with name and vars to create one from a template in this server's sandbox. Not both.",field:"template"},400);if(c===void 0&&h===void 0)return f({code:"provision_answers_required",message:"The body has neither answers nor a template.",hint:'Send { "answers": { "name": "milo", … } } (GET /v1/provision lists the steps), or { "template": "…", "name": "…", "vars": {…} } (GET /v1/templates lists the templates).',field:"answers"},400);let y;try{y=h===void 0?t.create(c??{}):t.createFromTemplate({template:h,name:l.value.name??"",vars:l.value.vars??{}})}catch(v){if(R(v))return f(v.toDetail(),400);throw v}try{if(h===void 0)await t.claim?.(y.manifestPath);let v=await e.adopt(y.manifestPath);return w({id:y.agentId,dir:y.dir,files:y.files,adopted:v.map((k)=>k.id)},201)}catch(v){return w({id:y.agentId,dir:y.dir,files:y.files,adopted:[],error:R(v)?v.toDetail():ke("provision_adopt_failed","The agent was written and is not running. Fix what the server's log names and `start` it, or restart the host.",v)},201)}},{capability:"admin"}),g.add("GET","/v1/templates",()=>w({templates:a.provision?.templates()??[]}),{capability:"read"}),g.add("GET","/v1/agents/:id/secrets",async(i)=>{let t=ot(e,a,i);if(t.kind==="response")return t.response;return w({id:t.id,secrets:t.admin.status(t.manifestPath)})},{capability:"admin"}),g.add("PUT","/v1/agents/:id/secrets",async(i)=>{let t=ot(e,a,i);if(t.kind==="response")return t.response;let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Xt,o.value);if(!l.ok)return f(l.error,400);let c;try{c=t.admin.write(t.manifestPath,l.value.values)}catch(k){if(R(k))return f(k.toDetail(),400);throw k}let h={id:t.id,written:c.written,shadowed:c.shadowed},y=e.list().some((k)=>k.id===t.id),v=await e.store.agentState.get(t.id);if(!y&&v?.enabled===!1)return w({...h,applied:"none",adopted:[],stopped:!0});try{if(y){let C=await e.reload(t.id);if(C.status==="pending")return w({...h,applied:"pending",adopted:[]});return w({...h,applied:"reloaded",adopted:C.adopted.map((T)=>T.id)})}let k=await e.adopt(t.manifestPath);return w({...h,applied:"adopted",adopted:k.map((C)=>C.id)})}catch(k){return w({...h,applied:"none",adopted:[],error:R(k)?k.toDetail():ke("secrets_apply_failed","The values were written and the agent is not running on them yet. Fix what the server's log names and reload or start it.",k)})}},{capability:"admin"}),g.add("POST","/v1/agents/:id/stop",async(i)=>{let t=i.params.id??"";if(!X(i.principal,t))return G("agent",t);let o=e.list().some((k)=>k.id===t),l=await e.store.agentState.get(t);if(!o&&l===void 0)return G("agent",t);let c=await L(i.request);if(c.kind==="error")return f(c.error,400);let h=K(Ot,c.value);if(!h.ok)return f(h.error,400);let y=h.value.reason?.trim(),v=await e.store.agentState.disable(t,new Date(a.now?.()??Date.now()).toISOString(),y===void 0||y===""?void 0:y);if(o)try{await e.dispose(t,"stopped")}catch(k){if(R(k)&&k.code==="agent_turn_in_flight")return f(k.toDetail(),409);throw k}return w({id:t,status:"disabled",...ze(v)})},{capability:"admin"}),g.add("POST","/v1/agents/:id/start",async(i)=>{let t=i.params.id??"";if(!X(i.principal,t))return G("agent",t);if(e.list().some((h)=>h.id===t)){let h=await e.store.agentState.enable(t);return w({id:t,status:"loaded",...ze(h)})}let o=a.resolveAgent;if(o===void 0)return f({code:"start_not_supported",message:"This server cannot look up a manifest for an agent it is not hosting.",hint:"Starting a stopped agent needs its manifest, which lives wherever agents live — the sandbox for the CLI, a mounted path for a container. This process was built without that lookup, so pass the agent to `serve` and restart it instead."},501);let l=o(t);if(l===void 0)return G("agent",t);let c=await e.store.agentState.enable(t);try{let h=await e.adopt(l);return w({id:t,status:"loaded",...ze(c),adopted:h.map((y)=>y.id)})}catch(h){if(await e.store.agentState.disable(t,new Date(a.now?.()??Date.now()).toISOString(),"start failed"),R(h))return f(h.toDetail(),400);throw h}},{capability:"admin"}),g.add("DELETE","/v1/agents/:id",async(i)=>{let t=i.params.id??"";if(!X(i.principal,t))return G("agent",t);let o=e.list().some((v)=>v.id===t),l=await e.store.agentState.get(t),c=a.remover;if(c===void 0)return f({code:"agent_remove_unsupported",message:"This server cannot delete agents.",hint:"`serve` provides deletion; an embedded handler has no sandbox to delete from. Use the CLI's `remove`."},501);if(i.url.searchParams.get("confirm")!==t)return f({code:"agent_remove_unconfirmed",message:`Deleting ${t} needs ?confirm=${t}.`,hint:"It deletes the agent's conversations, memory and files for good, so the request names the agent twice. POST /v1/agents/:id/stop switches one off and keeps everything.",field:"confirm"},400);let h=c.locate(t);if(!h.ok){if(!o&&l===void 0&&h.status===404)return G("agent",t);return f(h.error,h.status)}if(o)try{await e.dispose(t,"stopped")}catch(v){if(R(v))return f(v.toDetail(),409);throw v}let y=await e.store.purgeAgent(t);return await c.deleteDir(h.dir),w({id:t,removed:!0,dir:h.dir,...y})},{capability:"admin"}),g.add("POST","/v1/agents/:id/deliveries",async(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(At,o.value);if(!l.ok)return f(l.error,400);let c=l.value;if(!e.channels.hasChannel(t.id,c.channel))return f({code:"delivery_channel_unknown",message:`${t.id} has no running channel "${c.channel}".`,hint:"Name a channel id from the agent's manifest (GET /v1/agents/:id lists them with their status). A disabled channel is not running and cannot send.",field:"channel"},404);let h=qr({channel:c.channel,peerId:c.to}),y=ue(i,h);if(y!==void 0)return y;let{inserted:v}=await e.channels.deliver({agentId:t.id,sessionKey:h,channelId:c.channel,recipient:c.to,text:c.text,key:c.key});if(v)await t.recordDelivered(c.text,{sessionKey:h});return w({sessionKey:h,key:c.key,duplicate:!v},202)}),{capability:"admin"}),g.add("POST","/v1/agents/:id/messages",async(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Nt,o.value);if(!l.ok)return f(l.error,400);let c=l.value,h=c.chunks===!0,y=c.text,v=c.sessionKey??"api:default",k=ue(i,v);if(k!==void 0)return k;let C=ca(c.deliver);if(C.kind==="error")return f(C.error,400);let T=bt(c.from);if(T.kind==="error")return f(T.error,400);let U=Le(i.principal,T.from);if(!U.ok)return f(U.error,403);let A=await tn(t,i.principal,v,U.from,c.peerAsk),q=oa(i.request);if(q.kind==="error")return f(q.error,400);if(c.runtimeNote!==void 0&&U.from?.kind==="agent")return f({code:"message_note_untrusted",message:"A message from an agent cannot carry a runtimeNote.",hint:"A note is trusted framing outside the fence a peer's text is shown in. Put what the peer has to say in text.",field:"runtimeNote"},400);if(c.role!==void 0)try{t.roles.byName(c.role)}catch(ae){if(R(ae))return f({...ae.toDetail(),field:"role"},400);throw ae}let P=[];if(c.images!==void 0&&c.images.length>0){let ae=t.refusesImages(c.role);if(ae!==void 0)return f(ae.toDetail(),400);try{P=await ms(t.dir,c.images)}catch(oe){if(R(oe))return f(oe.toDetail(),400);throw oe}}let Q=await t.admit();if(!Q.ok)return f(Q.error.toDetail(),429);let W=so();if(q.key!==void 0){let ae=await t.store.turns.claimInboundKey({agentId:t.id,key:q.key,turnId:W,inputHash:await la(A,P.length===0?y:`${y}
97
+ ${P.map((oe)=>oe.data).join(`
98
+ `)}`),now:new Date});if(ae.kind!=="claimed")Q.release();if(ae.kind==="replay")return w({turnId:ae.turnId,sessionKey:A,replayed:!0},200);if(ae.kind==="mismatch")return f({code:"idempotency_key_reused",message:`Idempotency-Key "${q.key}" was already used for a different message.`,hint:`It belongs to turn ${ae.turnId}, whose text or session differed from this request's. Nothing was run. Use a fresh key for a new message, or resend the original text byte for byte to get that turn back. A key is remembered for 24 hours.`,field:"Idempotency-Key"},409)}let Fe=new AbortController;m.set(W,Fe),e.streams.open(W,{chunks:h});let ma=t.send(y,{admission:Q,sessionKey:A,sessionResolved:!0,turnId:W,source:"api",...U.from===void 0?{}:{from:U.from},...P.length===0?{}:{images:P},...c.runtimeNote===void 0?{}:{turnNote:c.runtimeNote},...c.role===void 0?{}:{role:c.role},...c.peerAsk===void 0?{}:{peerAsk:c.peerAsk},signal:Fe.signal}).then(async(ae)=>{let oe=ae.attachments??[];if(C.target===void 0||ae.text.trim()===""&&oe.length===0)return;await e.channels.deliver({agentId:t.id,sessionKey:A,channelId:C.target.channel,recipient:C.target.to,turnId:W,text:ae.text,...oe.length===0?{}:{attachments:oe}})}).catch(()=>{}).finally(()=>{m.delete(W)});if(c.stream!==!0)return w({turnId:W,sessionKey:A},202);return wt(e,W,{accepted:{turnId:W,sessionKey:A},status:202,chunks:h,children:c.children===!0})}),{capability:"chat"}),g.add("GET","/v1/agents/:id/turns/:turnId/stream",(i)=>I(e,i,async(t)=>{let o=i.params.turnId??"",l=await t.store.turns.get(o);if(gt(i,l))return G("turn",o);if(e.streams.state(o)===void 0){if(l===void 0)return G("turn",o,"No turn with this id has ever run on this agent. A turn id is the `turnId` from POST /v1/agents/:id/messages — check the agent in the path too, since a turn belongs to one.");return da(l)}return wt(e,o,{chunks:i.url.searchParams.get("chunks")==="true",children:i.url.searchParams.get("children")==="true"})}),{capability:"read",streaming:!0}),g.add("POST","/v1/agents/:id/turns/:turnId/stop",(i)=>I(e,i,async(t)=>{let o=i.params.turnId??"";if(gt(i,await t.store.turns.get(o)))return G("turn",o);let l=m.get(o);if(l===void 0)return f({code:"turn_not_running",message:`No cancel handle for turn ${o} on this API.`,hint:"This surface can stop a turn it started. A turn that has already finished cannot be stopped at all — read its final state from GET /v1/agents/:id/turns/:turnId. A turn started by a channel, a schedule, or another process is running without a handle here."},409);return l.abort(),w({turnId:o,stopping:!0},202)}),{capability:"chat"}),g.add("GET","/v1/agents/:id/approvals",(i)=>I(e,i,async(t)=>w({approvals:Ie(i.principal,b.pending(t.id))})),{capability:"read"}),g.add("POST","/v1/agents/:id/approvals/:approvalId",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(_t,o.value);if(!l.ok)return f(l.error,400);let c=l.value,h=i.params.approvalId??"";if(!Ie(i.principal,b.pending(t.id)).some((v)=>v.approvalId===h)||!b.resolve(h,c.granted))return f({code:"approval_not_found",message:`No approval with id ${h} is waiting.`,hint:'It was answered already, or its turn ended while it waited — a stopped or timed-out turn abandons its question, and `approval.resolved` reports that as `by: "abandoned"`. GET /v1/agents/:id/approvals lists what is actually waiting. Nothing about a settled approval is kept, so this is also the answer for an id that was never real.'},404);return w({approvalId:h,granted:c.granted})}),{capability:"chat"}),g.add("GET","/",(i)=>Pe("/",i),{capability:"open"}),g.add("GET","/assets/app.js",(i)=>Pe("/assets/app.js",i),{capability:"open"}),g.add("GET","/assets/app.css",(i)=>Pe("/assets/app.css",i),{capability:"open"}),g.add("POST","/v1/keys",async(i)=>{let t=a.claim!==void 0&&ra(i.request)===a.claim.token,o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Pt,o.value);if(!l.ok)return f(l.error,400);let c=l.value,h=ys(c.label);if(h!==void 0)return f({code:"key_label_invalid",message:h,hint:`A label is shown in a listing and in the UI, so it is at most ${Br} printable characters on one line. It is a display name, not a description.`,field:"label"},400);if(t&&a.claim?.spend()!==!0)return kt();let y=c.scope;if(y?.agents!==void 0){let U=new Set(e.list().map((q)=>q.id));for(let q of await e.store.agentState.list())U.add(q.agentId);let A=y.agents.filter((q)=>!U.has(q));if(A.length>0)return f({code:"key_scope_agent_unknown",message:`No agent ${A.map((q)=>JSON.stringify(q)).join(", ")} on this server.`,hint:"A key scoped to an agent that does not exist authenticates and then reaches nothing, which looks exactly like a working credential until it is used. GET /v1/agents lists what this server holds, stopped agents included.",field:"scope.agents"},400)}let v=y?.expiresIn===void 0?void 0:new Date(u()+y.expiresIn*1000).toISOString(),k=y===void 0?void 0:{...y.agents===void 0?{}:{agents:y.agents},...y.sessions===void 0?{}:{sessions:y.sessions},...y.can===void 0?{}:{can:y.can},...y.participant===void 0?{}:{participant:y.participant}},C=fr(),T=await e.store.operatorKeys.issue({keyId:ws(u()),label:c.label.trim(),fingerprint:await hr(C),createdAt:new Date(u()).toISOString(),...k===void 0||Object.keys(k).length===0?{}:{scope:k},...v===void 0?{}:{expiresAt:v}});return w({...T,secret:C},201)},{capability:"admin"}),g.add("GET","/v1/keys",async()=>{let i=await e.store.operatorKeys.list();return w({keys:i,scope:"A key with no scope authenticates every route for every agent this server holds. A scope narrows an already-authenticated caller — it names agents, a session prefix and capabilities, and it is not an identity: there are no users, teams or roles here."})},{capability:"admin"}),g.add("DELETE","/v1/keys/:keyId",async(i)=>{let t=i.params.keyId??"",o=await e.store.operatorKeys.revoke(t,new Date(u()).toISOString());if(o===void 0)return G("key",t,"The id is the `keyId` from POST /v1/keys, not the secret — GET /v1/keys lists them. An already-revoked key is a 200 carrying its original stamp, so this really does mean no such key exists.");return w(o)},{capability:"admin"}),g.add("POST","/v1/webhooks",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(Qt,t.value);if(!o.ok)return f(o.error,400);let l=o.value,c=l.types.filter((T)=>!Jt.includes(T)||!Ps(T));if(c.length>0)return f({code:"webhook_type_invalid",message:`Cannot deliver ${c.join(", ")}.`,hint:"Any type from the event stream except model.chunk, which is one request per token. The wire spec's event table lists them.",field:"types"},400);let h=ve(i.principal);if(l.agents!==void 0){let T=new Set([...e.list().map((A)=>A.id),...(await e.store.agentState.list()).map((A)=>A.agentId)]),U=l.agents.filter((A)=>!X(i.principal,A)||!T.has(A));if(U.length>0)return f({code:"webhook_scope_invalid",message:`This credential cannot subscribe to ${U.join(", ")}.`,hint:"A subscription hears at most what the key creating it reaches, and only agents this server holds. GET /v1/agents lists them.",field:"agents"},400)}let y=l.agents??h.agentIds,v={...y===void 0?{}:{agents:[...y]},...h.sessionPrefix===void 0?{}:{sessionPrefix:h.sessionPrefix}};try{await e.webhooks.check(l.url)}catch(T){if(R(T))return f(T.toDetail(),400);throw T}let k=Ls(),C=await e.store.webhooks.create({subscriptionId:`wh_${crypto.randomUUID().replaceAll("-","").slice(0,20)}`,url:l.url,secret:k,types:[...new Set(l.types)],...Object.keys(v).length===0?{}:{scope:v},createdAt:new Date(a.now?.()??Date.now()).toISOString()});return await e.webhooks.changed(),w({...lt(C),secret:k},201)},{capability:"admin"}),g.add("GET","/v1/webhooks",async(i)=>{let t=await e.store.webhooks.list();return w({webhooks:t.filter((o)=>ct(i.principal,o)).map(lt)})},{capability:"admin"}),g.add("DELETE","/v1/webhooks/:webhookId",async(i)=>{let t=i.params.webhookId??"",o=await e.store.webhooks.get(t);if(o===void 0||!ct(i.principal,o))return f({code:"webhook_not_found",message:`No webhook with id "${t}".`,hint:"GET /v1/webhooks lists the subscriptions this credential can see."},404);return await e.store.webhooks.delete(t),await e.webhooks.changed(),w({id:t,deleted:!0})},{capability:"admin"});let M=(i)=>i.kind==="key"?i.scope?.participant:void 0,Y=(i,t)=>{let o=M(i);if(o!==void 0&&!t.members.includes(o))return!1;return t.members.every((l)=>{let c=ni(l);return c===void 0||X(i,c)})},re=(i)=>f({code:"conversation_not_found",message:`No conversation "${i}".`,hint:"GET /v1/conversations lists the ones this credential can see."},404),J=async(i,t)=>{let o=i.params.conversationId??"",l=await e.store.conversations.get(o);if(l===void 0||!Y(i.principal,l))return re(o);return t(l)},O=(i)=>{if(!R(i))throw i;return f(i.toDetail(),i.code.endsWith("_not_found")?404:i.code.endsWith("_forbidden")?403:400)};g.add("POST","/v1/participants",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(Mt,t.value);if(!o.ok)return f(o.error,400);try{let l=o.value;return w(await e.conversations.registerParticipant({id:l.id,...l.name===void 0?{}:{name:l.name},...l.role===void 0?{}:{role:l.role},...l.title===void 0?{}:{title:l.title},...l.timezone===void 0?{}:{timezone:l.timezone},...l.channelIds===void 0?{}:{channelIds:l.channelIds}}),201)}catch(l){return O(l)}},{capability:"admin"}),g.add("GET","/v1/participants",async()=>w({participants:await e.store.conversations.participants()}),{capability:"read"}),g.add("DELETE","/v1/participants/:participantId",async(i)=>{let t=i.params.participantId??"";if(!await e.store.conversations.deleteParticipant(t))return f({code:"participant_not_found",message:`No participant "${t}".`,hint:"GET /v1/participants lists them."},404);return w({id:t,deleted:!0})},{capability:"admin"}),g.add("POST","/v1/conversations",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(Dt,t.value);if(!o.ok)return f(o.error,400);let l=M(i.principal);if(l!==void 0&&!o.value.members.includes(l))return f({code:"conversation_creator_not_member",message:`This key speaks for ${l}, who is not among the members.`,hint:`Include "${l}" in members. A backend creating rooms for others needs a key minted without scope.participant.`,field:"members"},403);let c=o.value.members.map((h)=>ni(h)).filter((h)=>h!==void 0&&!X(i.principal,h));if(c.length>0)return f({code:"conversation_member_unknown",message:`No participant "agent:${c[0]}".`,hint:"That agent is not hosted here. GET /v1/agents lists the ones that are.",field:"members"},400);try{return w(await e.conversations.create({kind:o.value.kind,members:o.value.members,...o.value.title===void 0?{}:{title:o.value.title}}),201)}catch(h){return O(h)}},{capability:"admin"}),g.add("GET","/v1/conversations",async(i)=>{let t=await e.store.conversations.list();return w({conversations:t.filter((o)=>Y(i.principal,o))})},{capability:"read"}),g.add("GET","/v1/conversations/:conversationId",(i)=>J(i,async(t)=>w(t)),{capability:"read"}),g.add("PATCH","/v1/conversations/:conversationId/members",(i)=>J(i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Lt,o.value);if(!l.ok)return f(l.error,400);try{return w(await e.conversations.setMembers(t.id,l.value.add??[],l.value.remove??[]))}catch(c){return O(c)}}),{capability:"admin"}),g.add("POST","/v1/conversations/:conversationId/messages",(i)=>J(i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Ut,o.value);if(!l.ok)return f(l.error,400);let c=M(i.principal),h=l.value.authorId;if(c!==void 0&&h!==void 0&&h!==c)return f({code:"sender_not_bound_participant",message:`This key speaks for ${c}, and the message names ${h}.`,hint:`Omit authorId (it is filled in), or send "${c}". A backend that posts for others needs a key minted without scope.participant.`,field:"authorId"},403);let y=c??h;if(y===void 0)return f({code:"conversation_author_required",message:"A message needs an author.",hint:"Send authorId, the human member who said it. A key bound to a participant fills it in.",field:"authorId"},400);try{let v=await e.conversations.post({conversationId:t.id,authorId:y,text:l.value.text,...l.value.mentions===void 0?{}:{mentions:l.value.mentions}});return w(v,202)}catch(v){return O(v)}}),{capability:"chat"}),g.add("GET","/v1/conversations/:conversationId/messages",(i)=>J(i,async(t)=>{let o=Number(i.url.searchParams.get("after")??0),l=Number(i.url.searchParams.get("limit")??200),c=await e.store.conversations.messages(t.id,{after:Number.isFinite(o)&&o>0?o:0,limit:Number.isFinite(l)&&l>0?Math.min(l,500):200});return w({conversationId:t.id,messages:c,...c.length===0?{}:{nextAfter:c.at(-1)?.seq}})}),{capability:"read"}),g.add("PUT","/v1/participants/:participantId/presence",async(i)=>{let t=i.params.participantId??"",o=M(i.principal);if(o!==void 0&&o!==t)return f({code:"sender_not_bound_participant",message:`This key speaks for ${o}, and the presence names ${t}.`,hint:"A key bound to a participant sets only that participant's presence. The embedder's backend, holding an unbound key, sets anyone's."},403);let l=await L(i.request);if(l.kind==="error")return f(l.error,400);let c=K(Kt,l.value);if(!c.ok)return f(c.error,400);try{return w(await e.conversations.setPresence(t,c.value.presence))}catch(h){return O(h)}},{capability:"chat"}),g.add("GET","/v1/actions",async(i)=>{let t=i.url.searchParams.get("status"),o=M(i.principal),l=await e.store.conversations.actions({...o===void 0?{}:{ownerId:o},...t==="pending"||t==="done"||t==="failed"||t==="denied"?{status:t}:{}});return w({actions:l.filter((c)=>X(i.principal,c.agentId))})},{capability:"read"}),g.add("POST","/v1/actions/:actionId",async(i)=>{let t=i.params.actionId??"",o=await e.store.conversations.action(t),l=M(i.principal);if(o===void 0||!X(i.principal,o.agentId)||l!==void 0&&l!==o.ownerId)return f({code:"action_not_found",message:`No action "${t}".`,hint:"GET /v1/actions lists the ones waiting on you."},404);let c=await L(i.request);if(c.kind==="error")return f(c.error,400);let h=K(Vt,c.value);if(!h.ok)return f(h.error,400);try{return w(await e.conversations.decideAction(t,h.value.approve))}catch(y){if(R(y)&&y.code==="action_already_decided")return f(y.toDetail(),409);return O(y)}},{capability:"chat"}),g.add("PUT","/v1/agents/:id/assignee",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Ft,o.value);if(!l.ok)return f(l.error,400);let c=M(i.principal);if(c!==void 0){if((await e.store.conversations.participant(c))?.role!=="admin")return f({code:"assignment_requires_admin",message:`${c} is not an admin participant.`,hint:'Only a participant registered with role "admin" assigns agents to members.'},403)}try{let h=await e.conversations.assign({agentId:t.id,participantId:l.value.participantId,...c===void 0?{}:{assignedBy:c},...l.value.channelIds===void 0?{}:{channelIds:l.value.channelIds}});return await t.checkSessionScope(),w(h)}catch(h){return O(h)}}),{capability:"admin"}),g.add("GET","/v1/agents/:id/assignee",(i)=>I(e,i,async(t)=>w({id:t.id,assignment:await e.store.conversations.assignment(t.id)??null})),{capability:"read"}),g.add("DELETE","/v1/agents/:id/assignee",(i)=>I(e,i,async(t)=>{let o=await e.store.conversations.unassign(t.id);if(o)e.schedulePeerCheck();return await t.checkSessionScope(),w({id:t.id,unassigned:o})}),{capability:"admin"});let se=(i)=>{let t=M(i);if(t!==void 0||Te(i,"admin"))return{ok:!0,actor:t};return{ok:!1,response:f({code:"memory_write_requires_admin",message:"This key is bound to no participant and does not carry admin.",hint:"A member writes through a key minted with scope.participant; the embedder's backend writes shared scopes with an admin key."},403)}};g.add("POST","/v1/memory/notes",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(Ht,t.value);if(!o.ok)return f(o.error,400);let l=se(i.principal);if(!l.ok)return l.response;try{return w(await e.conversations.addNote({scope:o.value.scope,text:o.value.text,...l.actor===void 0?{}:{authorId:l.actor}}),201)}catch(c){return O(c)}},{capability:"chat"}),g.add("GET","/v1/memory/notes",async(i)=>{let t=i.url.searchParams.get("scope")??"";try{return w({notes:await e.conversations.notes(t,M(i.principal))})}catch(o){return O(o)}},{capability:"read"}),g.add("DELETE","/v1/memory/notes/:noteId",async(i)=>{let t=se(i.principal);if(!t.ok)return t.response;try{return await e.conversations.deleteNote(i.params.noteId??"",t.actor),w({id:i.params.noteId,deleted:!0})}catch(o){return O(o)}},{capability:"chat"}),g.add("GET","/v1/participants/:participantId/memory/reads",async(i)=>{try{return w({reads:await e.conversations.reads(i.params.participantId??"",M(i.principal))})}catch(t){return O(t)}},{capability:"read"});let ee=async(i)=>{let t=M(i);if(t===void 0)return;if((await e.store.conversations.participant(t))?.role==="admin")return;return f({code:"memory_scope_forbidden",message:`${t} is not an admin participant.`,hint:'Only a participant registered with role "admin" defines projects and names the space writer.'},403)};g.add("GET","/v1/projects",async()=>w({projects:await e.store.conversations.projects()}),{capability:"read"}),g.add("PUT","/v1/projects/:projectId",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(Gt,t.value);if(!o.ok)return f(o.error,400);let l=await ee(i.principal);if(l!==void 0)return l;let c=(o.value.agents??[]).find((h)=>!X(i.principal,h));if(c!==void 0)return f({code:"agent_not_found",message:`No agent "${c}".`,hint:"GET /v1/agents lists the ones hosted here."},404);try{return w(await e.conversations.upsertProject({id:i.params.projectId??"",...o.value.name===void 0?{}:{name:o.value.name},...o.value.agents===void 0?{}:{agents:o.value.agents}}))}catch(h){return O(h)}},{capability:"admin"}),g.add("DELETE","/v1/projects/:projectId",async(i)=>{let t=await ee(i.principal);if(t!==void 0)return t;let o=i.params.projectId??"";return w({id:o,deleted:await e.store.conversations.deleteProject(o)})},{capability:"admin"}),g.add("PUT","/v1/memory/space/writer",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o=K(qt,t.value);if(!o.ok)return f(o.error,400);let l=await ee(i.principal);if(l!==void 0)return l;let c=M(i.principal);try{return await e.conversations.setSpaceWriter(o.value.writer,c),w({writer:o.value.writer})}catch(h){return O(h)}},{capability:"admin"}),g.add("GET","/v1/usage",async(i)=>{let t=ut(i.url);if(t.kind==="error")return f(t.error,400);let o=ve(i.principal);return w(await e.store.usage.report({...t.value,...o}))},{capability:"read"}),g.add("GET","/v1/agents/:id/usage",(i)=>I(e,i,async(t)=>{let o=ut(i.url);if(o.kind==="error")return f(o.error,400);let l=ve(i.principal).sessionPrefix;return w({id:t.id,...await e.store.usage.report({...o.value,agentIds:[t.id],...l===void 0?{}:{sessionPrefix:l}})})}),{capability:"read"}),g.add("GET","/v1/agents/:id/turns",(i)=>I(e,i,async(t)=>{let o=dt(i.url,"limit"),l=dt(i.url,"before");if(o===null||l===null)return f({code:"turns_page_invalid",message:"`limit` and `before` must be positive whole numbers.",hint:"Pass `before` exactly as the previous page's `nextBefore` returned it, and a `limit` up to 200."},400);let c=ve(i.principal).sessionPrefix,h=await e.store.turns.listForAgent(t.id,{limit:Math.min(o??50,200),...l===void 0?{}:{before:l},...c===void 0?{}:{sessionPrefix:c}});return w({id:t.id,...h})}),{capability:"read"}),g.add("GET","/v1/agents/:id/turns/:turnId",(i)=>I(e,i,async(t)=>{let o=await t.store.turns.get(i.params.turnId??"");if(o===void 0||!ce(i.principal,o.sessionKey))return G("turn",i.params.turnId??"");return w(o)}),{capability:"read"}),g.add("GET","/v1/agents/:id/sessions",(i)=>I(e,i,async(t)=>{let o=await t.store.sessions.list(t.id),l=await t.store.sessions.heads(t.id);return w(Ie(i.principal,o.map((c)=>({...c,head:Qs(c.sessionKey,l)}))))}),{capability:"read"}),g.add("POST","/v1/agents/:id/sessions/rotate",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Bt,o.value);if(!l.ok)return f(l.error,400);let c=bt(l.value.from);if(c.kind==="error")return f(c.error,400);let h=Le(i.principal,c.from);if(!h.ok)return f(h.error,403);let y={source:"api",...h.from===void 0?{}:{from:h.from}},v="api:-",k=await t.resolveSessionKey(v,y),C=k===v||!ce(i.principal,k)?void 0:await t.rotateSession(y);if(C===void 0)return f({code:"session_not_rotatable",message:`Agent "${t.id}" has no conversation of yours to start afresh.`,hint:`Rotation is for sessions.scope owner or peer, for the owner or a registered participant, by a key that reaches that conversation; this agent's scope is "${t.manifest.sessions?.scope??"channel-peer"}". Otherwise a new conversation is a new sessionKey of your own on the next message.`},409);return w(C)}),{capability:"chat"}),g.add("GET","/v1/agents/:id/sessions/:key",(i)=>I(e,i,async(t)=>{let o=i.params.key??"",l=ue(i,o);if(l!==void 0)return l;let c=await t.store.sessions.get(t.id,o);if(c===void 0)return G("session",o);return w(c)}),{capability:"read"}),g.add("GET","/v1/agents/:id/sessions/:key/messages",(i)=>I(e,i,async(t)=>{let o=i.url.searchParams.get("before"),l=i.url.searchParams.get("limit"),c=ue(i,i.params.key??"");if(c!==void 0)return c;let h=await t.store.messages.page(t.id,i.params.key??"",{...o===null?{}:{before:Number.parseInt(o,10)},...l===null?{}:{limit:Number.parseInt(l,10)}});return w(h)}),{capability:"read"}),g.add("DELETE","/v1/agents/:id/sessions/:key",(i)=>I(e,i,async(t)=>{let o=ue(i,i.params.key??"");if(o!==void 0)return o;return await t.store.sessions.clear(t.id,i.params.key??""),w({cleared:i.params.key??"",memoryFilesKept:!0})}),{capability:"write"}),g.add("POST","/v1/agents/:id/sessions/:key/phase",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(It,o.value);if(!l.ok)return f(l.error,400);let c=l.value.phase;if(typeof c!=="string"&&c!==null)return f({code:"phase_invalid",message:"phase must be a string, or null to clear it.",hint:'Send { "phase": "triage" }. Phase-scoped tool visibility arrives in Phase 7; the column is written now so a session carries the value across a restart.',field:"phase"},400);let h=ue(i,i.params.key??"");if(h!==void 0)return h;let y=i.params.key??"";if(c===null)await t.store.sessions.setPhase(t.id,y,void 0);else await t.setPhase(y,c);return w({sessionKey:y,phase:c})}),{capability:"write"}),g.add("POST","/v1/agents/:id/sessions/:key/recall",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K($t,o.value);if(!l.ok)return f(l.error,400);let c=i.params.key??"",h=ue(i,c);if(h!==void 0)return h;if(await t.store.sessions.get(t.id,c)===void 0)return G("session",c);return await t.store.sessions.setRecall(t.id,c,l.value.recall),w({sessionKey:c,recall:l.value.recall})}),{capability:"write"}),g.add("GET","/v1/agents/:id/schedules",(i)=>I(e,i,async(t)=>{let o=i.url.searchParams.get("enabled"),l=await t.store.schedules.list(t.id,o===null?{}:{enabled:o==="true"});return w({schedules:l})}),{capability:"read"}),g.add("POST","/v1/agents/:id/schedules",(i)=>I(e,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);return rt(e,t,o.value,void 0)}),{capability:"write"}),g.add("GET","/v1/agents/:id/schedules/preview",(i)=>I(e,i,async()=>{let t=i.url.searchParams,o=t.get("kind")??"",l=t.get("expr")??"",c=t.get("timezone")??void 0,h=Math.min(10,Math.max(1,Number(t.get("count")??"3")||3));if(o!=="cron"&&o!=="every"&&o!=="at")return f({code:"schedule_invalid",message:`kind must be cron, every or at; got ${JSON.stringify(o)}.`,hint:"Send ?kind=cron&expr=0 8 * * *&timezone=Asia/Dhaka, or kind=every&expr=15m, or kind=at&expr=<ISO instant>.",field:"kind"},400);let y=Date.now(),v;try{v=yr({id:"preview",kind:o,expr:l,timezone:c,now:y,field:"expr"})}catch(T){if(R(T))return f(T.toDetail(),400);throw T}let k=[];if(v.kind==="at")k.push(v.at);else if(v.kind==="every")for(let T=1;T<=h;T+=1)k.push(y+T*v.every.ms);else{let T=y;for(let U=0;U<h;U+=1){let A=PA(v.spec,T,v.zone);if(A===void 0)break;k.push(A),T=A}}let C=v.kind==="every"?v.every.ms:v.kind==="cron"&&k.length>1?(k[1]??0)-(k[0]??0):void 0;return w({kind:v.kind,zone:v.zone,next:k.map((T)=>new Date(T).toISOString()),jitterMs:C===void 0?0:$r("preview",C)})}),{capability:"read"}),g.add("GET","/v1/agents/:id/schedules/:sid",(i)=>I(e,i,async(t)=>{let o=i.params.sid??"",l=await t.store.schedules.get(t.id,o);return l===void 0?G("schedule",o):w(l)}),{capability:"read"}),g.add("PATCH","/v1/agents/:id/schedules/:sid",(i)=>I(e,i,async(t)=>{let o=i.params.sid??"",l=await t.store.schedules.get(t.id,o);if(l===void 0)return G("schedule",o);let c=at(l);if(c!==void 0)return c;let h=await L(i.request);if(h.kind==="error")return f(h.error,400);let y=h.value===null||typeof h.value!=="object"||Array.isArray(h.value)?{}:h.value,{id:v,...k}=y,C={kind:l.kind,expr:l.expr,task:l.task,deliver:l.deliverChannel===void 0||l.deliverTo===void 0?"none":{channel:l.deliverChannel,to:l.deliverTo},session:l.sessionMode,enabled:l.enabled,...l.timezone===void 0?{}:{timezone:l.timezone},...l.role===void 0?{}:{role:l.role},...l.toolsAllow===void 0?{}:{tools:{allow:l.toolsAllow}},...l.timeoutMs===void 0?{}:{timeoutMs:l.timeoutMs},...l.maxSteps===void 0?{}:{maxSteps:l.maxSteps},...k,id:l.id};return rt(e,t,C,l)}),{capability:"write"}),g.add("DELETE","/v1/agents/:id/schedules/:sid",(i)=>I(e,i,async(t)=>{let o=i.params.sid??"",l=await t.store.schedules.get(t.id,o);if(l===void 0)return G("schedule",o);let c=at(l);if(c!==void 0)return c;if(!await t.store.schedules.remove(t.id,o))return G("schedule",o);return e.scheduler.changed(),w({removed:o})}),{capability:"write"}),g.add("POST","/v1/agents/:id/schedules/:sid/run",(i)=>I(e,i,async(t)=>{let o=i.params.sid??"",l=await t.store.schedules.get(t.id,o);if(l===void 0)return G("schedule",o);let c=await t.admit();if(!c.ok)return f(c.error.toDetail(),429);let h=Ss(),y=Gs(l.sessionMode,l.id,h),v=so();return e.streams.open(v),t.send(l.task,{admission:c,sessionKey:y,turnId:v,source:`schedule:${l.id}:manual`,...Us(l)}).catch(()=>{}),w({scheduleId:l.id,turnId:v,sessionKey:y,outOfBand:!0},202)}),{capability:"write"}),g.add("GET","/v1/agents/:id/config",(i)=>de(e,a,i,async(t)=>{let o=t.file,l=o===void 0?void 0:await Me(o,"utf8");return w({running:t.agent!==void 0,...o===void 0?{editable:!1}:{editable:!0,file:o},settings:[...sA.filter((c)=>GA.includes(c.path)||c.path==="model.<role>").map((c)=>({path:c.path,means:c.means,...c.confirm===void 0?{}:{confirm:c.confirm},...l===void 0?{}:{value:ei(l,c.path.split("."))}})),...ia(l)]})}),{capability:"admin"}),g.add("PATCH","/v1/agents/:id/config",(i)=>de(e,a,i,async(t)=>{let o=await L(i.request);if(o.kind==="error")return f(o.error,400);let l=K(Tn,o.value);if(!l.ok)return f(l.error,400);let c=l.value.changes===void 0;if(c===(l.value.path===void 0))return f({code:c?"config_path_unknown":"config_changes_invalid",message:c?"A request named no path.":"A request named both a path and changes.",hint:'Send { "path", "value" } for one change, or { "changes": [{ "path", "value" }, ...] } for several in one reload.',field:c?"path":"changes"},400);let h=l.value.changes??[{...l.value,path:l.value.path??""}],y=t.file;if(typeof y!=="string")return f({code:"config_not_editable",message:`"${t.id}" was loaded from an object, not from a file, so it has no manifest to change.`,hint:"An embedder holding new settings passes the new object to dispose() and adopt(). This route edits a manifest on disk."},409);let v=h.map((P,Q)=>({change:P,index:Q})).filter(({change:P})=>(co(P.path)??un(P.path))?.via===void 0&&co(P.path)===void 0);if(!c&&v.length>0){let P=v[0];return f({code:"config_path_unknown",message:`${v.map(({change:Q,index:W})=>`"${Q.path}" (changes.${W}.path)`).join(", ")} ${v.length===1?"is not a field":"are not fields"} this surface sets. Nothing was written.`,hint:`GET /v1/agents/:id/config lists every one. Nearest to "${P?.change.path}": ${Yt(P?.change.path??"",GA)??GA.join(", ")}.`,field:`changes.${P?.index??0}.path`},400)}let k=[];for(let P of h){let Q=co(P.path)??un(P.path);if(Q===void 0||co(P.path)===void 0)return f({code:"config_path_unknown",message:Q?.via===void 0?`"${P.path}" is not a field this surface sets.`:`"${P.path}" is set by \`${Q.via}\`, not by a dotted path.`,hint:Q?.via===void 0?`GET /v1/agents/:id/config lists every one. Nearest: ${Yt(P.path,GA)??GA.join(", ")}.`:"It is a key inside a list entry, and the source editor matches a key at an indent — it cannot index a sequence. That action also validates the handle against the service that issues it.",field:"path"},400);let W=P.remove===!0;if(W===(P.value!==void 0))return f({code:W?"config_remove_invalid":"config_value_unreadable",message:W?"A request named both a value and remove: true.":"A request named neither a value nor remove: true.",hint:'Send { "path", "value" } to set a field, or { "path", "remove": true } to take it out.',field:W?"remove":"value"},400);if(Q.confirm!==void 0&&P.confirm!==!0)return f({code:"config_confirm_required",message:Q.confirm,hint:'Send { "confirm": true } beside the value to make this change anyway. Nothing has been written.',field:"confirm"},409);k.push(Q)}let C;try{C=await Xr(y,h.map((P)=>({path:P.path.split("."),value:P.value===void 0?void 0:go(P.value),...P.remove===!0?{remove:!0}:{},providers:e.toolProviderFactories,mediaProviders:e.mediaProviderFactories})))}catch(P){if(R(P))return f(P.toDetail(),400);throw P}let T;if(C.written&&t.agent===void 0)T=mt(t.id);else if(C.written)try{T=we(await e.reload(t.id))}catch(P){if(!R(P))throw P;T=P.toDetail()}let A=h.some((P,Q)=>P.path==="delegation.offer"&&C.edits[Q]?.changed===!0)?await ua(e,t.id,T===void 0):void 0,q=C.edits.map((P,Q)=>({path:k[Q]?.path??"",before:P.before,after:P.after,reflowed:P.reflowed,changed:P.changed}));return w({...c?q[0]:{changes:q},reloaded:C.written&&T===void 0,...T===void 0?{applied:!0}:{applied:!1,pending:T},...A===void 0?{}:{peers:A}})}),{capability:"admin"}),g.add("PATCH","/v1/agents/:id/channels/:channelId",(i)=>I(e,i,async(t)=>{let o=a.channels;if(o===void 0)return f({code:"channels_not_supported",message:"This server cannot change a channel.",hint:"The host did not supply the channel actions — a library caller embedding this handler has to pass them. `dispach serve` does."},501);let l=e.sourceOf(t.id);if(typeof l!=="string")return f({code:"config_not_editable",message:`Agent "${t.id}" was loaded from an object, so it has no manifest to edit.`,hint:"Only an agent loaded from a file can be changed here."},409);let c=await L(i.request);if(c.kind==="error")return f(c.error,400);let h=K(Cn,c.value);if(!h.ok)return f(h.error,400);let{enabled:y,credential:v}=h.value;if(y===void 0&&v===void 0)return f({code:"channel_patch_empty",message:"Nothing to change.",hint:'Send { "enabled": true | false } to connect or disconnect it, { "credential": "…" } to set its token, or both.'},400);let k=i.params.channelId??"",C=[];try{if(v!==void 0)C.push(o.setCredential(l,k,v).note);if(y!==void 0)C.push((await o.setEnabled(l,k,y)).note)}catch(U){if(!R(U))throw U;return f(U.toDetail(),400)}let T;try{T=we(await e.reload(t.id))}catch(U){if(!R(U))throw U;T=U.toDetail()}return w({channelId:k,notes:C,...T===void 0?{applied:!0}:{applied:!1,pending:T}})}),{capability:"admin"}),g.add("POST","/v1/agents/:id/channels/:channelId/unpair",(i)=>I(e,i,async(t)=>{let o=i.params.channelId??"",l=await e.channels.reset(t.id,o);if(l==="reset")return w({channelId:o,note:"Pairing forgotten. The channel offers a new code to scan; the old device may still be listed on the phone, which is the only place it can be removed.",restarted:!1});let c=a.channels,h=e.sourceOf(t.id);if(c===void 0||typeof h!=="string")return f({code:l==="unsupported"?"channel_has_no_pairing":"channel_unknown",message:l==="unsupported"?`Channel "${o}" stores no pairing.`:`Agent "${t.id}" has no channel "${o}" registered.`,hint:"Only a channel linked by scanning a code has one to forget. A credential somebody typed is changed with PATCH on this channel, and a channel is switched off with { enabled: false }.",field:"channelId"},l==="unsupported"?409:404);try{return w({channelId:o,...c.unpair(h,o),restarted:!1})}catch(y){if(!R(y))throw y;return f(y.toDetail(),y.code==="channel_unknown"?404:409)}}),{capability:"admin"}),g.add("GET","/v1/agents/:id/tools",(i)=>I(e,i,(t)=>{let o=t.manifest.phases,l=Wr(o);return w(t.tools.specs().map((c)=>({slug:c.slug,summary:c.summary,mutating:c.mutating,trust:c.trust,...c.trustReason===void 0?{}:{trustReason:c.trustReason},provider:c.provider??"local",tags:c.tags,...l?{phases:bs(o,c)}:{}})))}),{capability:"read"}),g.add("GET","/v1/agents/:id/skills",(i)=>I(e,i,(t)=>{let o=t.skills;if(o===void 0)return w({skills:[],configured:!1});return w({configured:!0,maxActive:o.maxActive,threshold:o.threshold,cached:o.cached,skills:o.skills.map((l)=>({name:l.name,description:l.frontmatter.description,tokens:l.tokens,...l.frontmatter.whenNotToUse===void 0?{}:{whenNotToUse:l.frontmatter.whenNotToUse},scripts:l.scripts.map((c)=>c.slug),trusted:t.manifest.skills?.trusted===void 0||t.manifest.skills.trusted.includes(l.name)}))})}),{capability:"read"}),g.add("GET","/v1/agents/:id/context",(i)=>I(e,i,async(t)=>{let o=i.url.searchParams.get("sessionKey"),l=i.url.searchParams.get("input");return w(await t.previewContext({...o===null?{}:{sessionKey:o},...l===null?{}:{input:l}}))}),{capability:"read"}),g.add("POST","/v1/channels/:channelId/webhook/:agentId",async(i)=>{let t=await L(i.request);if(t.kind==="error")return f(t.error,400);let o={};i.request.headers.forEach((c,h)=>{o[h.toLowerCase()]=c});let l=await e.channels.handleWebhook(i.params.agentId??"",i.params.channelId??"",{body:t.value,headers:o});return new Response(l.detail??"",{status:l.status,headers:{"content-type":"text/plain; charset=utf-8"}})},{capability:"open"}),g.add("GET","/v1/events",(i)=>{let t=i.url.searchParams.get("agentId");if(t!==null&&!X(i.principal,t))return G("agent",t);let o=i.url.searchParams.get("types")?.split(",").filter(Boolean),l=i.url.searchParams.get("chunks")==="true",c=o?.includes("model.chunk")===!0,h=l||c,y=o?.filter((v)=>!Jt.includes(v));if(y!==void 0&&y.length>0){let v=Yt(y[0]??"",Jt);return f({code:"unknown_event_type",message:`No such event type: ${y.join(", ")}.`,hint:v===void 0?"The full catalogue is the event table in docs/04-SPEC-WIRE.md. Omit ?types= to receive every event.":`Did you mean "${v}"? The full catalogue is the event table in docs/04-SPEC-WIRE.md.`,field:"types"},400)}return Be({...i.request.signal===void 0?{}:{signal:i.request.signal},start:({send:v})=>(v({event:"stream.subscribed",data:{agentId:t??null,types:o??null,chunks:h,...h&&!l?{implied:"types names model.chunk"}:{}}}),e.bus.on("*",(k)=>{if(t!==null&&k.agentId!==t)return;if(k.agentId!==void 0&&!X(i.principal,k.agentId))return;if(!en(i.principal,k))return;if(o!==void 0&&o.length>0&&!o.includes(k.type))return;v({event:k.type,data:k})},{chunks:h}))})},{capability:"read",streaming:!0});let le=async(i)=>{let t;try{t=new URL(i.url)}catch{return f({code:"bad_request_url",message:"The request URL could not be parsed.",hint:"This usually means the server was handed a relative URL. A handler mounted inside another framework needs an absolute request.url."},400)}let o=i.method.toUpperCase();if(o==="OPTIONS"){let v=g.match("OPTIONS",t.pathname);if(v.kind==="method"){let C=g.match("HEAD",t.pathname).kind==="method"&&aa(g,t.pathname),T=[...v.allowed,...v.allowed.includes("GET")&&!C?["HEAD"]:[],"OPTIONS"];return j(i,new Response(null,{status:204,headers:{allow:T.join(", "),...a.origin===void 0?{}:Rn(i,T)}}))}}if(o==="HEAD"){let v=g.match("GET",t.pathname);if(v.kind==="found"){if(v.streaming)return f({code:"method_not_allowed",message:`HEAD is not allowed on ${t.pathname}.`,hint:"This path answers with an open event stream. A HEAD would have to start one and then throw the body away, leaving a subscription nothing ever closes — so it is refused rather than leaked. Use GET, or GET /v1/health to check the server is up."},405,{allow:"GET, OPTIONS"});let k=B(i);if(k!==void 0)return k;let C=await F(i,t.pathname,v.capability);if(C instanceof Response)return C;let T=await st(v.handler,{request:i,url:t,params:v.params,principal:C});return j(i,new Response(null,{status:T.status,headers:T.headers}))}}let l=H(o,t.pathname);if(l!==void 0){let v=B(i);if(v!==void 0)return v;return j(i,await ne(i,t,l))}let c=g.match(o,t.pathname);if(c.kind==="method")return f({code:"method_not_allowed",message:`${o} is not allowed on ${t.pathname}.`,hint:`This path accepts ${c.allowed.join(", ")}.`},405,{allow:c.allowed.join(", ")});if(c.kind==="none")return it(i.method,t.pathname);let h=B(i);if(h!==void 0)return h;let y=await F(i,t.pathname,c.capability);if(y instanceof Response)return y;return j(i,await st(c.handler,{request:i,url:t,params:c.params,principal:y}))},H=(i,t)=>{let o=/^\/v1\/agents\/([^/]+)\/plugins\/([^/]+)(\/.*)?$/.exec(t);if(o!==null){let c=e.list().find((k)=>k.id===decodeURIComponent(o[1]??"")),h=o[2]??"",y=o[3]??"/",v=c?.pluginRoutes.find((k)=>k.plugin===h&&k.method===i&&k.path===y);return c===void 0||v===void 0?void 0:{agent:c,route:v,path:y}}let l=e.list().flatMap((c)=>c.pluginRoutes.filter((h)=>h.root===t&&h.method===i).map((h)=>({agent:c,route:h,path:h.path})));return l.length===1?l[0]:void 0},ne=async(i,t,o)=>{let{agent:l,route:c,path:h}=o,y=c.capability==="open"?{kind:"open"}:await F(i,t.pathname,c.capability);if(y instanceof Response)return y;if(y.kind==="claim"||!X(y,l.id))return it(i.method,t.pathname);let v=y.kind==="key"?{kind:"key",keyId:y.keyId,label:y.label??""}:c.capability==="open"?{kind:"anonymous"}:{kind:"operator"};try{return await c.handler({request:i,url:t,path:h,caller:v})}catch(k){return f({code:"plugin_route_failed",message:`Plugin "${c.plugin}" failed answering ${i.method} ${t.pathname}: ${k instanceof Error?k.message:String(k)}`,hint:"This is the plugin's error, not the runtime's. The agent's own routes are unaffected."},500)}};return Object.assign(le,{authenticate:(i)=>F(i,"/v1/ws","read")})}function at(a){if(a.origin!=="manifest")return;return f({code:"schedule_manifest_owned",message:`Schedule "${a.id}" is declared in this agent's manifest, so the manifest decides it.`,hint:"Writing it here would last until the next start — reconciliation restores every field from the file, enabled included. Change the `schedules:` entry instead, with PATCH /v1/agents/:id/config, or create a separate schedule through this route."},409)}async function rt(a,e,d,u){if(d===null||typeof d!=="object"||Array.isArray(d))return f({code:"schedule_invalid",message:"A schedule must be a JSON object.",hint:"Send { id, kind, expr, task, deliver } — see docs/02-SPEC-MANIFEST.md."},400);try{let p=Fs({agentId:e.id,body:d,channelIds:e.manifest.channels.map((b)=>b.id),roleNames:Object.keys(e.manifest.model),toolSpecs:e.tools.specs(),now:Date.now(),origin:"api",...u===void 0?{}:{existing:u}}),m=await e.store.schedules.upsert(p);return a.scheduler.changed(),w(m,u===void 0?201:200)}catch(p){let m=R(p)?p.toDetail():ke("schedule_invalid","See docs/02-SPEC-MANIFEST.md for the schedule fields; the server's log has the cause.",p);return f(m,400)}}function Pe(a,e){let d=Yn(a,e.request);if(d===void 0)throw new te({code:"web_asset_missing",message:`No web asset for ${a}.`,hint:"The routes in handler.ts and the table in web.ts have diverged, which spec.test.ts asserts cannot happen — so this build is inconsistent. Rebuild with `bun run build`."});return d}function ke(a,e,d){return process.stderr.write(`${a}: ${d instanceof Error?d.stack??d.message:String(d)}
99
+ `),{code:a,message:"An unexpected failure; the server's log has the cause.",hint:e}}function w(a,e=200){return new Response(JSON.stringify(a),{status:e,headers:{"content-type":"application/json; charset=utf-8"}})}function na(a){return a==="/v1/health"||a==="/v1/ready"||a.startsWith("/v1/channels/")||Qn.includes(a)||a==="/docs"||a==="/v1/openapi.json"}function aa(a,e){let d=a.match("GET",e);return d.kind==="found"&&d.streaming}async function st(a,e){try{return await a(e)}catch(d){if(R(d))return f(d.toDetail(),400);return f(ke("internal_error","Not caused by the request. The server's log has the cause, and the runtime's event stream carries what happened around it.",d),500)}}function it(a,e){return f({code:"not_found",message:`No route for ${a} ${e}.`,hint:"Every path is under /v1. See docs/04-SPEC-WIRE.md for the surface."},404)}function G(a,e,d){return f({code:`${a}_not_found`,message:`No ${a} "${e}".`,hint:d??"Check the id — it is case-sensitive, and a session key includes its channel segment."},404)}function ra(a){let e=a.headers.get("authorization")??"";if(!e.startsWith("Bearer "))return;let d=e.slice(7);return d===""?void 0:d}function ot(a,e,d){let u=d.params.id??"";if(!X(d.principal,u))return{kind:"response",response:G("agent",u)};let p=e.secrets;if(p===void 0)return{kind:"response",response:f({code:"secrets_not_supported",message:"This server cannot write an agent's credentials.",hint:"Credentials go into the .env beside an agent's manifest, and this process was built without a writer for it. Set them where the agent lives, with `config env`, and reload it."},501)};let m=a.sourceOf(u),b=typeof m==="string"?m:e.resolveAgent?.(u);if(b===void 0)return{kind:"response",response:G("agent",u)};return{kind:"found",id:u,manifestPath:b,admin:p}}function lt(a){return{...a,failing:a.consecutiveFailures>0}}function ct(a,e){let d=ve(a);if(d.agentIds!==void 0){let u=e.scope?.agents;if(u===void 0||!u.every((p)=>d.agentIds?.includes(p)))return!1}if(d.sessionPrefix!==void 0){let u=e.scope?.sessionPrefix;if(u===void 0||!u.startsWith(d.sessionPrefix))return!1}return!0}function dt(a,e){let d=a.searchParams.get(e);if(d===null)return;let u=Number(d);return Number.isSafeInteger(u)&&u>0?u:null}function ut(a){let e=a.searchParams.get("by"),d=e===null?["agent","model"]:e.split(",").filter((m)=>m!==""),u=d.filter((m)=>!Ai.includes(m));if(u.length>0)return{kind:"error",error:{code:"usage_group_invalid",message:`Cannot group usage by ${u.join(", ")}.`,hint:`Group by any of ${Ai.join(", ")}, comma-separated, or pass by= for one total.`,field:"by"}};let p={};for(let m of["from","to"]){let b=a.searchParams.get(m);if(b===null)continue;let S=Date.parse(b);if(Number.isNaN(S))return{kind:"error",error:{code:"usage_range_invalid",message:`${m} is ${JSON.stringify(b)}, which is not a date.`,hint:"Send ISO-8601, like 2026-09-01 or 2026-09-01T00:00:00Z. `from` is inclusive and `to` exclusive, so a month is from=2026-09-01&to=2026-10-01.",field:m}};p[m]=new Date(S).toISOString()}return{kind:"ok",value:{by:d,...p}}}function ht(a){return{id:a.agentId,name:a.agentId,status:"disabled",...a.reason===void 0?{}:{reason:a.reason},...a.disabledAt===void 0?{}:{disabledAt:a.disabledAt}}}function de(a,e,d,u){let p=d.params.id??"";if(!X(d.principal,p))return G("agent",p);let m=a.list().find((S)=>S.id===p);if(m!==void 0){let S=a.sourceOf(p);return u({id:p,agent:m,file:typeof S==="string"?S:void 0})}let b=e.resolveAgent?.(p);if(b===void 0)return G("agent",p);return u({id:p,agent:void 0,file:b})}function mt(a){return{code:"agent_not_running",message:`${a} is not running, so the change is on disk and not yet in force.`,hint:`POST /v1/agents/${a}/start loads it from the files as they are now. GET /v1/agents/${a} says whether they load.`}}function I(a,e,d){let u=e.params.id??"",p=a.list().find((m)=>m.id===u);if(p===void 0)return G("agent",u);if(!X(e.principal,u))return G("agent",u);return d(p)}function sa(a,e){if(!Ue(a))return e;return e.filter((d)=>X(a,d.id))}function Ie(a,e){if(!Ue(a))return e;return e.filter((d)=>ce(a,d.sessionKey))}function ue(a,e){return ce(a.principal,e)?void 0:G("session",e)}function gt(a,e){if(e===void 0)return Ue(a.principal);return!ce(a.principal,e.sessionKey)}function ia(a){if(a===void 0)return[];let e=ei(a,["model"]);if(e===null||typeof e!=="object"||Array.isArray(e))return[];let d=un("model.<role>")?.means??"a named model role";return Object.entries(e).filter(([u])=>u!=="main").map(([u,p])=>({path:`model.${u}`,means:d,value:p}))}async function $e(a,e){let d=Zr.safeParse(Rs(await Me(e,"utf8")));if(!d.success)return f({code:"workspace_manifest_invalid",message:`${a}'s manifest does not parse, so its workspace files cannot be named.`,hint:"Fix the manifest first: PATCH /v1/agents/:id/config, and GET /v1/agents/:id for what is wrong."},409);let u=be(e),p=d.data.context,m=he(u,p.workspace),b=p.soul,S=[...Os(p,u).refs.map((V)=>({path:V.path,tier:V.tier,field:V.field})),...b?.file===void 0?[]:[{path:he(m,b.file),tier:"soul",field:"context.soul.file"}],...b?.distilled===void 0?[]:[{path:he(m,b.distilled),tier:"soul",field:"context.soul.distilled"}]];return{workspaceDir:m,declared:S}}function vt(a,e,d){return a.find((u)=>u.path===he(e,d)||ye(u.path)===d)?.path}function Oe(a,e,d){return f({code:"workspace_file_unknown",message:`${e} is not one of ${a}'s workspace files.`,hint:`Declared: ${d.map((u)=>ye(u.path)).join(", ")||"none"}. A new file is added to context.static or context.volatile with PATCH /config first.`,field:"file"},404)}function yt(a,e){let d=e.manifest.phases,u=Wr(d);return{id:e.id,name:e.manifest.name??e.id,...e.manifest.description===void 0?{}:{description:e.manifest.description},ask:e.manifest.delegation?.ask===!0,status:"loaded",model:e.manifest.model.main.id,channels:e.manifest.channels.map((p)=>{let m=a.channels.statusOf(e.id).find((S)=>S.id===p.id),b=typeof p.tokenEnv==="string"?p.tokenEnv:void 0;return{...m??{},id:p.id,type:p.type,enabled:p.enabled,...b===void 0?{}:{credentialEnv:b,credentialSet:e.hasEnv(b)}}}),entryPhase:u?Ds(d)??null:null,...u?{phases:Object.keys(d)}:{},sessionScope:e.manifest.sessions?.scope??"channel-peer"}}function ze(a){return{...a.disabledAt===void 0?{}:{disabledAt:a.disabledAt},...a.reason===void 0?{}:{reason:a.reason}}}async function L(a,e=Jn){let d=Number.parseInt(a.headers.get("content-length")??"0",10);if(Number.isFinite(d)&&d>e)return{kind:"error",error:{code:"body_too_large",message:`The request body declares ${d} bytes; the limit is ${e}.`,hint:"This cap is enforced before a channel plugin sees anything, so a plugin never has to defend against a large POST."}};let u=await a.text();if(u.length>e)return{kind:"error",error:{code:"body_too_large",message:`The request body is ${u.length} bytes; the limit is ${e}.`,hint:"Send less. A message longer than this is not a message."}};if(u==="")return{kind:"ok",value:{}};try{return{kind:"ok",value:JSON.parse(u)}}catch{return{kind:"error",error:{code:"body_not_json",message:"The request body is not valid JSON.",hint:"Send application/json. A shell quoting mistake is the usual cause — check for unescaped quotes inside the payload."}}}}function bt(a){if(a===void 0||a===null)return{kind:"ok",from:void 0};let e=(u,p,m="from")=>({kind:"error",error:{code:"sender_invalid",message:u,hint:p,field:m}});if(typeof a!=="object")return e("from must be an object.",'Send { "from": { "id": "agent:ops-bot", "kind": "agent" } }, or omit it entirely for a turn the token-holder is sending itself.');let d=a;if(typeof d.id!=="string"||d.id.trim()==="")return e("from.id is required and must be a non-empty string.","Use a stable identity in your own namespace — `agent:ops-bot`, `user:018f…`, an email address. It is opaque to this runtime and is recorded on the turn so an audit can answer who asked.","from.id");if(d.id.length>nt)return e(`from.id is ${d.id.length} characters, over the ${nt} limit.`,"A sender id is an identifier, not a payload. It is rendered into the prompt's fence label, so an unbounded one spends the context window the message needs.","from.id");if(typeof d.kind!=="string"||!iA.includes(d.kind)){let u=typeof d.kind==="string"?Yt(d.kind,iA):void 0;return e(`from.kind must be one of: ${iA.join(", ")}.`,`${u===void 0?"":`Did you mean "${u}"? `}This field decides the trust boundary — "agent" fences the message and blocks mutating tools for the turn, "user" does not — so there is no default and an unknown value is refused rather than guessed at. A turn the token-holder is sending itself omits "from".`,"from.kind")}if(d.name!==void 0&&typeof d.name!=="string")return e("from.name must be a string when present.","It is a display name only and is rendered inside the fence, never above it. Omit it if you have none.","from.name");return{kind:"ok",from:{id:d.id,kind:d.kind,...d.name===void 0?{}:{name:d.name.slice(0,Zn)}}}}function oa(a){let e=a.headers.get("idempotency-key");if(e===null)return{kind:"ok",key:void 0};let d=e.trim(),u=(p)=>({kind:"error",error:{code:"idempotency_key_invalid",message:p,hint:`Send 1-${_e} printable ASCII characters that are unique per logical request — a UUID is the usual choice. Omit the header entirely to accept that a retry runs the turn again. Printable ASCII because the key is a database key, and node:sqlite truncates a bound string at a NUL byte where bun:sqlite stores it whole.`,field:"Idempotency-Key"}});if(d==="")return u("Idempotency-Key is present but empty.");if(d.length>_e)return u(`Idempotency-Key is ${d.length} characters, over the ${_e} limit.`);if(!/^[\x20-\x7e]+$/.test(d))return u("Idempotency-Key contains characters that are not printable ASCII.");return{kind:"ok",key:d}}async function la(a,e){let d=new TextEncoder().encode(`${a}\x00${e}`),u=await crypto.subtle.digest("SHA-256",d);return Array.from(new Uint8Array(u)).map((p)=>p.toString(16).padStart(2,"0")).join("")}function ca(a){if(a===void 0||a===null||a==="none")return{kind:"ok",target:void 0};if(typeof a==="object"){let e=a;if(typeof e.channel==="string"&&typeof e.to==="string")return{kind:"ok",target:{channel:e.channel,to:e.to}}}return{kind:"error",error:{code:"deliver_invalid",message:'deliver must be "none" or { channel, to }.',hint:'A bare channel id is not enough on an API turn: the request has no originating conversation, so there is no recipient to infer. Send { "channel": "tg", "to": "12345" }, or "none" to read the reply from the event stream.',field:"deliver"}}}function da(a){let e=a.status==="running";return Be({start:({send:d,close:u})=>{d({event:e?"stream.unavailable":"stream.ended",data:{turnId:a.turnId,status:a.status,sessionKey:a.sessionKey,...e?{reason:"no buffer for this turn in this process",hint:"The turn is recorded as running but is not observable here — its events are buffered in whichever process is executing it, and buffers are in-memory and per-process. Poll GET /v1/agents/:id/turns/:turnId for the outcome."}:{steps:a.steps,...a.errorCode===void 0?{}:{errorCode:a.errorCode},hint:"This turn finished before you attached and its buffer has been evicted. Its full text is in GET /v1/agents/:id/turns/:turnId."}}}),u();return}})}function wt(a,e,d){return Be({...d?.status===void 0?{}:{status:d.status},start:({send:u,close:p})=>{if(d?.accepted!==void 0)u({event:"turn.accepted",data:d.accepted});let m=a.streams.attach(e,(b)=>{if(u({event:b.type,data:b}),b.type==="turn.end"&&b.turnId===e)p()},{chunks:d?.chunks===!0,children:d?.children===!0});if(m===void 0){u({event:"stream.unavailable",data:{turnId:e,reason:"no buffer for this turn in this process",hint:"Read the final state from GET /v1/agents/:id/turns/:turnId. Buffers are in-memory and are evicted after a turn ends."}}),p();return}u({event:"stream.replay",data:{turnId:e,state:m.state,events:m.replay.length,truncated:m.truncated,dropped:m.dropped,chunks:m.chunks,...m.truncated?{hint:`The oldest ${m.dropped} event(s) of this turn were discarded to stay under the buffer cap, so this replay starts mid-turn. The turn's final text is complete in GET /v1/agents/:id/turns/:turnId.`}:{}}});for(let b of m.replay)u({event:b.type,data:b});if(m.state==="ended")p();return()=>m.unsubscribe()}})}async function ua(a,e,d){let u=a.list().filter((m)=>{let b=m.manifest.delegation?.to;return m.id!==e&&(b==="*"||(b?.includes(e)??!1))}),p=[];for(let m of u){if(!d){p.push({id:m.id,applied:!1,pending:{code:"reload_pending",message:`${e}'s own reload is waiting for running turns, so ${m.id} still lists its old offer.`,hint:`POST /v1/agents/${m.id}/reload once ${e}'s agent.reloaded event arrives.`}});continue}try{let b=we(await a.reload(m.id));p.push(b===void 0?{id:m.id,applied:!0}:{id:m.id,applied:!1,pending:b})}catch(b){if(!R(b))throw b;p.push({id:m.id,applied:!1,pending:b.toDetail()})}}return p}function we(a){if(a.status!=="pending")return;return{code:"reload_pending",message:`It applies when the ${a.running} running turn(s) finish; they complete on the settings they started with.`,hint:`New turns keep the old settings for ${a.holdAfterMs} ms, then wait and start on the new ones. The agent.reloaded event says when it is in force.`}}var pa=new Set([".env",".api-token",".venv","node_modules",".git"]),Re={env:[".env",".api-token"],git:[".git"]};async function xt(a,e,d=new Set){let u=[],p=async(m)=>{for(let b of await mn(m,{withFileTypes:!0})){if(e.has(b.name))continue;let S=De(m,b.name);if(d.has(he(S)))continue;if(b.isDirectory())await p(S);else if(b.isFile())u.push({name:yn(a,S).split(bn).join("/"),path:S})}};return await p(a),u}function As(){let a=fr(),e=!1;return{token:a,live:()=>!e,spend:()=>{if(e)return!1;return e=!0,!0}}}function an(a){let e=a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a,d=e==="0.0.0.0"||e==="::"||e===""?"127.0.0.1":e;return d.includes(":")?`[${d}]`:d}function ns(a,e,d){return`http://${an(a)}:${e}/?claim=${d}`}function os(a,e,d){return`curl -sX POST http://${an(a)}:${e}/v1/keys -H 'Authorization: Bearer ${d}' -H 'content-type: application/json' -d '{"label":"my browser"}'`}function ln(a,e,d=new Map){let u=new Set,p,m=0,b,S=(j)=>{let Z=j.type==="model.chunk";for(let z of u){if(z.data.agentId!==void 0&&j.agentId!==z.data.agentId)continue;if(j.agentId!==void 0&&!X(z.data.principal,j.agentId))continue;if(!en(z.data.principal,j))continue;if(Z&&!z.data.chunks)continue;try{z.send(JSON.stringify(j))}catch{}}},V=()=>{if(m+=1,b===void 0)b=a.bus.on("model.chunk",S)},B=()=>{if(m===0)return;if(m-=1,m===0)b?.(),b=void 0};return{async accept(j){let Z=new URL(j.url),z=jn(j),F=Z.searchParams.get("token"),M=await e(Sn(j,z??F??""));if(M instanceof Response)return{kind:"reject",response:M};let Y=Z.searchParams.get("agentId");if(Y!==null&&!X(M,Y))return{kind:"reject",response:new Response(JSON.stringify({error:{code:"agent_not_found",message:`No agent "${Y}".`,hint:"Check the id — it is case-sensitive. A key scoped away from an agent sees exactly what a caller asking for one that does not exist sees."}}),{status:404,headers:{"content-type":"application/json"}})};return{kind:"accept",session:{agentId:Y??void 0,chunks:Z.searchParams.get("chunks")==="true",principal:M},...z===void 0?{}:{protocol:jt}}},handlers:{open(j){if(u.add(j),p===void 0)p=a.bus.on("*",S);if(j.data.chunks)V();j.send(JSON.stringify({type:"ws.open",agentId:j.data.agentId??null,chunks:j.data.chunks}))},message(j,Z){let z;try{z=JSON.parse(typeof Z==="string"?Z:new TextDecoder().decode(Z))}catch{j.send(JSON.stringify({type:"ws.error",code:"frame_not_json"}));return}if(z.type==="ping"){j.send(JSON.stringify({type:"pong"}));return}if(z.type==="subscribe"){if(z.agentId===void 0&&z.sessionKey!==void 0){j.send(JSON.stringify({type:"ws.error",code:"subscribe_needs_agent_id",hint:"Send { type: 'subscribe', agentId: '<agent>' }. A socket filters on the agent an event carries; sessionKey names a conversation and can never match one, so a socket pointed with it receives nothing."}));return}let H=typeof z.chunks==="boolean"?z.chunks:j.data.chunks;if(H&&!j.data.chunks)V();else if(!H&&j.data.chunks)B();let ne=z.agentId??j.data.agentId;if(ne!==void 0&&!X(j.data.principal,ne)){j.send(JSON.stringify({type:"ws.error",error:{code:"agent_not_found",message:`No agent "${ne}".`,hint:"Check the id — it is case-sensitive. A key scoped away from an agent sees exactly what a caller asking for one that does not exist sees."}}));return}j.data={agentId:ne,chunks:H,principal:j.data.principal},j.send(JSON.stringify({type:"ws.subscribed",agentId:j.data.agentId??null,chunks:j.data.chunks}));return}if(z.type==="stop"){let H=z.turnId===void 0?void 0:d.get(z.turnId);H?.abort(),j.send(JSON.stringify({type:"ws.stopping",turnId:z.turnId??null,found:H!==void 0}));return}if(z.type!=="message"){j.send(JSON.stringify({type:"ws.error",code:"unknown_frame_type"}));return}let F=j.data.agentId,g=a.list().find((H)=>H.id===F);if(g===void 0){j.send(JSON.stringify({type:"ws.error",code:"agent_not_found"}));return}let M=z.text??"";if(M.trim()===""){j.send(JSON.stringify({type:"ws.error",code:"message_text_required"}));return}let Y=Le(j.data.principal,void 0),re=Y.ok?Y.from:void 0,J=z.sessionKey??"api:default",O=(H,ne)=>{let i=so(),t=new AbortController;d.set(i,t),j.send(JSON.stringify({type:"ws.accepted",turnId:i,sessionKey:ne})),g.send(M,{admission:H,sessionKey:ne,sessionResolved:!0,turnId:i,source:"ws",...re===void 0?{}:{from:re},signal:t.signal}).catch(()=>{}).finally(()=>d.delete(i))},se=(g.manifest.sessions?.scope??"channel-peer")!=="channel-peer",ee=(H)=>{if(!H.ok){j.send(JSON.stringify({type:"ws.error",...H.error.toDetail()}));return}if(!se){O(H,J);return}tn(g,j.data.principal,J,re).then((ne)=>O(H,ne),(ne)=>{H.release(),process.stderr.write(`internal: ${ne instanceof Error?ne.stack??ne.message:String(ne)}
100
+ `),j.send(JSON.stringify({type:"ws.error",code:"internal_error",message:"The conversation for this message could not be read."}))})},le=g.admitNow();if(le!==void 0){ee(le);return}g.admit().then(ee,(H)=>{process.stderr.write(`internal: ${H instanceof Error?H.stack??H.message:String(H)}
101
+ `),j.send(JSON.stringify({type:"ws.error",code:"internal_error",message:"The turn budget could not be read."}))})},close(j){if(u.delete(j)&&j.data.chunks)B();if(u.size===0)p?.(),p=void 0}},closeAll(){for(let j of u)try{j.close(1001,"server stopping")}catch{}u.clear(),p?.(),p=void 0,b?.(),b=void 0,m=0}}}async function rs(a){let{host:e,port:d,runtime:u}=a;if(!je(e)&&a.token===void 0)throw new te({code:"server_public_without_token",message:`Refusing to bind ${e}:${d} with no API token.`,hint:"Set the variable named by server.tokenEnv, or bind 127.0.0.1. A public bind with no token exposes every endpoint — including the ones that start a turn — to anyone who can reach the port, and behaves identically to a safe one until someone finds it.",field:"server.host"});let p=new Map,m=ta({runtime:u,...a.token===void 0?{}:{token:a.token},...a.token===void 0?{allowUnauthenticated:!0}:{},...a.now===void 0?{}:{now:a.now},running:p,...a.approvals===void 0?{}:{approvals:a.approvals},...a.claim===void 0?{}:{claim:a.claim},...a.resolveAgent===void 0?{}:{resolveAgent:a.resolveAgent},...a.provision===void 0?{}:{provision:a.provision},...a.channels===void 0?{}:{channels:a.channels},...a.remover===void 0?{}:{remover:a.remover},...a.secrets===void 0?{}:{secrets:a.secrets},...a.home===void 0?{}:{home:a.home},origin:{host:a.host,...a.allowedOrigins===void 0?{}:{allowedOrigins:a.allowedOrigins},...a.allowedHosts===void 0?{}:{allowedHosts:a.allowedHosts}}});if(a.engine==="bun"||a.engine===void 0&&typeof Bun<"u"&&typeof Bun.serve==="function")return ha(m,a,p);return fa(m,a,p)}function ha(a,e,d){let u=ln(e.runtime,a.authenticate,d),p=Bun.serve({port:e.port,hostname:e.host,idleTimeout:Math.min(255,Math.ceil(rn/1000*3)),fetch:async(m,b)=>{if(new URL(m.url).pathname!=="/v1/ws")return a(m);let V=Se(m,{host:e.host,...e.allowedOrigins===void 0?{}:{allowedOrigins:e.allowedOrigins},...e.allowedHosts===void 0?{}:{allowedHosts:e.allowedHosts}});if(V!==void 0)return new Response(JSON.stringify({error:V}),{status:403,headers:{"content-type":"application/json; charset=utf-8"}});let B=await u.accept(m);if(B.kind==="reject")return B.response;if(b.upgrade(m,{data:B.session,...B.protocol===void 0?{}:{headers:{"sec-websocket-protocol":B.protocol}}}))return;return new Response("upgrade failed",{status:400})},websocket:{open:(m)=>u.handlers.open(m),message:(m,b)=>u.handlers.message(m,b),close:(m)=>u.handlers.close(m)}});return{url:`http://${e.host}:${p.port}`,port:p.port??e.port,host:e.host,websocket:!0,stop:async()=>{u.closeAll(),await p.stop(!0)}}}async function fa(a,e,d){let{createServer:u}=await import("node:http"),{WebSocketServer:p}=await import("./wrapper-f662ny3r.js"),m=ln(e.runtime,a.authenticate,d),b=(F,g)=>{let M=`http://${F.headers.host??`${e.host}:${e.port}`}${F.url??"/"}`,Y=new Headers;for(let[J,O]of Object.entries(F.headers))if(typeof O==="string")Y.set(J,O);else if(Array.isArray(O))Y.set(J,O.join(", "));let re=F.method??"GET";return new Request(M,{method:re,headers:Y,...re==="GET"||re==="HEAD"||g===void 0?{}:{body:g}})},S=u((F,g)=>{(async()=>{let M=[];for await(let O of F)M.push(O);let Y=await a(b(F,Buffer.concat(M))),re={};if(Y.headers.forEach((O,se)=>{re[se]=O}),g.writeHead(Y.status,re),Y.body===null){g.end();return}let J=Y.body.getReader();g.on("close",()=>void J.cancel().catch(()=>{}));for(;;){let{done:O,value:se}=await J.read();if(O)break;g.write(Buffer.from(se))}g.end()})().catch(()=>{if(!g.headersSent)g.writeHead(500);g.end()})}),V=new WeakMap,B=new p({noServer:!0,handleProtocols:(F,g)=>V.get(g)??!1}),j=(F,g,M)=>{F.end(`HTTP/1.1 ${g} Refused\r
102
+ content-type: application/json; charset=utf-8\r
103
+ content-length: ${Buffer.byteLength(M)}\r
104
+ connection: close\r
105
+ \r
106
+ ${M}`)};S.on("upgrade",(F,g,M)=>{(async()=>{let Y=b(F);if(new URL(Y.url).pathname!=="/v1/ws"){g.destroy();return}let re=Se(Y,{host:e.host,...e.allowedOrigins===void 0?{}:{allowedOrigins:e.allowedOrigins},...e.allowedHosts===void 0?{}:{allowedHosts:e.allowedHosts}});if(re!==void 0){j(g,403,JSON.stringify({error:re}));return}let J=await m.accept(Y);if(J.kind==="reject"){j(g,J.response.status,await J.response.text());return}if(J.protocol!==void 0)V.set(F,J.protocol);B.handleUpgrade(F,g,M,(O)=>{let se={data:J.session,send:(ee)=>O.send(ee),close:(ee,le)=>O.close(ee,le)};O.on("message",(ee,le)=>{let H=Array.isArray(ee)?Buffer.concat(ee):ee instanceof ArrayBuffer?Buffer.from(ee):ee;m.handlers.message(se,le?new Uint8Array(H):H.toString("utf8"))}),O.on("close",()=>m.handlers.close(se)),m.handlers.open(se)})})().catch(()=>g.destroy())}),await new Promise((F,g)=>{S.once("error",g),S.listen(e.port,e.host,()=>{S.removeListener("error",g),F()})});let Z=S.address(),z=typeof Z==="object"&&Z!==null?Z.port:e.port;return{url:`http://${e.host}:${z}`,port:z,host:e.host,websocket:!0,stop:()=>new Promise((F)=>{m.closeAll(),B.close(),S.closeAllConnections?.(),S.close(()=>F())})}}function AA(a,e){let d=new URL(a);if(d.pathname="/",d.hostname=an(d.hostname),e!==void 0&&e!=="")d.searchParams.set("agent",e);return d.toString()}
107
+ export{Yr,As,an,ns,os,rs,AA};
108
+
109
+ //# debugId=F290269EB682512764756E2164756E21
110
+ //# sourceMappingURL=index-664xcamy.js.map