@vectorize-io/hindsight-control-plane 0.8.2 → 0.8.3
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.
- package/package.json +1 -1
- package/standalone/.next/BUILD_ID +1 -1
- package/standalone/.next/app-path-routes-manifest.json +1 -0
- package/standalone/.next/build-manifest.json +5 -5
- package/standalone/.next/prerender-manifest.json +3 -3
- package/standalone/.next/routes-manifest.json +6 -0
- package/standalone/.next/server/app/[locale]/banks/[bankId]/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/[locale]/banks/[bankId]/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/dashboard/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/[locale]/dashboard/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/login/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/[locale]/login/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/[locale]/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/_global-error/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/_global-error.html +1 -1
- package/standalone/.next/server/app/_global-error.rsc +1 -1
- package/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/standalone/.next/server/app/_not-found/page/build-manifest.json +2 -2
- package/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/_not-found.html +1 -1
- package/standalone/.next/server/app/_not-found.rsc +2 -2
- package/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/api/extract/route/app-paths-manifest.json +3 -0
- package/standalone/.next/server/app/api/extract/route/build-manifest.json +9 -0
- package/standalone/.next/server/app/api/extract/route/server-reference-manifest.json +4 -0
- package/standalone/.next/server/app/api/extract/route.js +7 -0
- package/standalone/.next/server/app/api/extract/route.js.map +5 -0
- package/standalone/.next/server/app/api/extract/route.js.nft.json +1 -0
- package/standalone/.next/server/app/api/extract/route_client-reference-manifest.js +3 -0
- package/standalone/.next/server/app/de/dashboard.html +1 -1
- package/standalone/.next/server/app/de/dashboard.rsc +9 -9
- package/standalone/.next/server/app/de/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/de/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/de/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/de/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/de/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/de/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/de/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/de/login.html +1 -1
- package/standalone/.next/server/app/de/login.rsc +9 -9
- package/standalone/.next/server/app/de/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/de/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/de/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/de/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/de/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/de/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/de/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/en/dashboard.html +1 -1
- package/standalone/.next/server/app/en/dashboard.rsc +9 -9
- package/standalone/.next/server/app/en/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/en/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/en/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/en/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/en/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/en/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/en/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/en/login.html +1 -1
- package/standalone/.next/server/app/en/login.rsc +9 -9
- package/standalone/.next/server/app/en/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/en/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/en/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/en/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/en/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/en/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/en/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/es/dashboard.html +1 -1
- package/standalone/.next/server/app/es/dashboard.rsc +9 -9
- package/standalone/.next/server/app/es/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/es/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/es/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/es/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/es/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/es/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/es/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/es/login.html +1 -1
- package/standalone/.next/server/app/es/login.rsc +9 -9
- package/standalone/.next/server/app/es/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/es/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/es/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/es/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/es/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/es/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/es/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/dashboard.html +1 -1
- package/standalone/.next/server/app/fr/dashboard.rsc +9 -9
- package/standalone/.next/server/app/fr/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/fr/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/fr/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/fr/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/fr/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/login.html +1 -1
- package/standalone/.next/server/app/fr/login.rsc +9 -9
- package/standalone/.next/server/app/fr/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/fr/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/fr/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/fr/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/fr/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/fr/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/dashboard.html +1 -1
- package/standalone/.next/server/app/ja/dashboard.rsc +9 -9
- package/standalone/.next/server/app/ja/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/ja/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/ja/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/ja/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/ja/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/login.html +1 -1
- package/standalone/.next/server/app/ja/login.rsc +9 -9
- package/standalone/.next/server/app/ja/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/ja/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/ja/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/ja/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/ja/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/ja/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/dashboard.html +1 -1
- package/standalone/.next/server/app/ko/dashboard.rsc +9 -9
- package/standalone/.next/server/app/ko/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/ko/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/ko/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/ko/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/ko/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/login.html +1 -1
- package/standalone/.next/server/app/ko/login.rsc +9 -9
- package/standalone/.next/server/app/ko/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/ko/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/ko/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/ko/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/ko/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/ko/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/dashboard.html +1 -1
- package/standalone/.next/server/app/pt/dashboard.rsc +9 -9
- package/standalone/.next/server/app/pt/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/pt/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/pt/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/pt/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/pt/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/login.html +1 -1
- package/standalone/.next/server/app/pt/login.rsc +9 -9
- package/standalone/.next/server/app/pt/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/pt/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/pt/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/pt/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/pt/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/pt/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/dashboard.html +1 -1
- package/standalone/.next/server/app/yue-Hant/dashboard.rsc +9 -9
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/login.html +1 -1
- package/standalone/.next/server/app/yue-Hant/login.rsc +9 -9
- package/standalone/.next/server/app/yue-Hant/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/yue-Hant/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/yue-Hant/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/yue-Hant/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/yue-Hant/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/yue-Hant/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/dashboard.html +1 -1
- package/standalone/.next/server/app/zh-CN/dashboard.rsc +9 -9
- package/standalone/.next/server/app/zh-CN/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-CN/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/zh-CN/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/zh-CN/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-CN/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/login.html +1 -1
- package/standalone/.next/server/app/zh-CN/login.rsc +9 -9
- package/standalone/.next/server/app/zh-CN/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-CN/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/zh-CN/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/zh-CN/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-CN/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-CN/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/dashboard.html +1 -1
- package/standalone/.next/server/app/zh-TW/dashboard.rsc +9 -9
- package/standalone/.next/server/app/zh-TW/dashboard.segments/$d$locale/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/dashboard.segments/$d$locale/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-TW/dashboard.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/zh-TW/dashboard.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/zh-TW/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-TW/dashboard.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/login.html +1 -1
- package/standalone/.next/server/app/zh-TW/login.rsc +9 -9
- package/standalone/.next/server/app/zh-TW/login.segments/$d$locale/login/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/login.segments/$d$locale/login.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-TW/login.segments/$d$locale.segment.rsc +6 -6
- package/standalone/.next/server/app/zh-TW/login.segments/_full.segment.rsc +9 -9
- package/standalone/.next/server/app/zh-TW/login.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/zh-TW/login.segments/_index.segment.rsc +2 -2
- package/standalone/.next/server/app/zh-TW/login.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app-paths-manifest.json +1 -0
- package/standalone/.next/server/chunks/0pqf_dsight-control-plane__next-internal_server_app_api_extract_route_actions_0h1ku5b.js +3 -0
- package/standalone/.next/server/chunks/[root-of-the-server]__00pw45p._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__02dhsqm._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__04twg40._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__05ideqf._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__07qotdb._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0ha6-ug._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0k6x3t5._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0p9mepv._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0w9z-gl._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0y-n32k._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__0yncdx-._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__13e6sct._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__15bvgu8._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__190dn0v._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__1aq14zo._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__1dtws1u._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__1poot5x._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__1r1_40m._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__1v4w5-b._.js +3 -0
- package/standalone/.next/server/chunks/[root-of-the-server]__1xmfq8o._.js +1 -1
- package/standalone/.next/server/chunks/hindsight-control-plane_src_0xk6y3c._.js +1 -1
- package/standalone/.next/server/chunks/hindsight-control-plane_src_lib_hindsight-client_ts_0eje3tr._.js +1 -1
- package/standalone/.next/server/chunks/ssr/[root-of-the-server]__0_x23ke._.js +2 -2
- package/standalone/.next/server/chunks/ssr/_0ohntay._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_components_bank-selector_tsx_0b8_8lw._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_de_json_[json]_cjs_1ch1-23._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_en_json_[json]_cjs_08qm708._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_es_json_[json]_cjs_05p52ht._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_fr_json_[json]_cjs_1vp4nco._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_ja_json_[json]_cjs_0mldp7p._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_ko_json_[json]_cjs_0epqzja._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_pt_json_[json]_cjs_0d_3joa._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_yue-Hant_json_[json]_cjs_1i7xoui._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_zh-CN_json_[json]_cjs_14wtgi5._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_messages_zh-TW_json_[json]_cjs_05oa_ni._.js +1 -1
- package/standalone/.next/server/chunks/ssr/node_modules_next_dist_0q5c63s._.js +1 -1
- package/standalone/.next/server/edge/chunks/[root-of-the-server]__0idnhrz._.js +3 -3
- package/standalone/.next/server/middleware-build-manifest.js +5 -5
- package/standalone/.next/server/middleware-manifest.json +5 -5
- package/standalone/.next/server/pages/404.html +1 -1
- package/standalone/.next/server/pages/500.html +1 -1
- package/standalone/.next/server/server-reference-manifest.js +1 -1
- package/standalone/.next/server/server-reference-manifest.json +1 -1
- package/standalone/.next/static/chunks/02kvrfegmwqgf.css +2 -0
- package/standalone/.next/static/chunks/{1r7gd36us-7gm.js → 08b_2i7ky7st8.js} +1 -1
- package/standalone/.next/static/chunks/{1cld2c0a065s-.js → 1c2fgn0rkk-26.js} +4 -4
- package/standalone/.next/static/chunks/{2gsf16c8po4wd.js → 1zwqw64e9qw3h.js} +1 -1
- package/standalone/.next/static/chunks/{0rag4lxutugfo.js → 41yps_q384e4k.js} +2 -2
- package/standalone/.next/static/chunks/{turbopack-2cuxzdi-q-g57.js → turbopack-037qtgeo-0gy1.js} +1 -1
- package/standalone/node_modules/@next/env/package.json +2 -2
- package/standalone/node_modules/next/dist/build/swc/index.js +1 -1
- package/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/standalone/node_modules/next/dist/server/config.js +1 -1
- package/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
- package/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- package/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
- package/standalone/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- package/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
- package/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
- package/standalone/node_modules/next/package.json +15 -15
- package/standalone/package.json +1 -1
- package/standalone/.next/static/chunks/03pg4qenxm5it.css +0 -2
- /package/standalone/.next/static/{VltQCjH9Ti_ysKGJawY-Q → iyZowVO2ocagOopqmbLk9}/_buildManifest.js +0 -0
- /package/standalone/.next/static/{VltQCjH9Ti_ysKGJawY-Q → iyZowVO2ocagOopqmbLk9}/_clientMiddlewareManifest.js +0 -0
- /package/standalone/.next/static/{VltQCjH9Ti_ysKGJawY-Q → iyZowVO2ocagOopqmbLk9}/_ssgManifest.js +0 -0
|
@@ -5,7 +5,7 @@ You can add a description to the \`${Jf}\` by passing a \`${Jm}\` component as a
|
|
|
5
5
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Jf}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
6
6
|
|
|
7
7
|
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return C.useEffect(()=>{document.getElementById(a.current?.getAttribute("aria-describedby"))||console.warn(b)},[b,a]),null};let Js=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)(Je,{className:(0,S.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...b,ref:c}));Js.displayName=Je.displayName;let Jt=C.forwardRef(({className:a,...b},c)=>(0,B.jsxs)(Jd,{children:[(0,B.jsx)(Js,{}),(0,B.jsx)(Jj,{ref:c,className:(0,S.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...b})]}));Jt.displayName=Jj.displayName;let Ju=({className:a,...b})=>(0,B.jsx)("div",{className:(0,S.cn)("flex flex-col space-y-2 text-center sm:text-left",a),...b});Ju.displayName="AlertDialogHeader";let Jv=({className:a,...b})=>(0,B.jsx)("div",{className:(0,S.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...b});Jv.displayName="AlertDialogFooter";let Jw=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)(Jl,{ref:c,className:(0,S.cn)("text-lg font-semibold",a),...b}));Jw.displayName=Jl.displayName;let Jx=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)(Jn,{ref:c,className:(0,S.cn)("text-sm text-muted-foreground",a),...b}));Jx.displayName=Jn.displayName;let Jy=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)(Jo,{ref:c,className:(0,S.cn)((0,W.buttonVariants)(),a),...b}));Jy.displayName=Jo.displayName;let Jz=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)(Jq,{ref:c,className:(0,S.cn)((0,W.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",a),...b}));Jz.displayName=Jq.displayName;let JA=(0,K.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),JB=(0,K.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);var JC=a.i(5784);let JD=(0,K.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);var JE=a.i(73320),JF=a.i(43108);function JG(a){let b=Math.floor((Date.now()-new Date(a).getTime())/1e3);if(b<60)return"just now";let c=Math.floor(b/60);if(c<60)return`${c}m ago`;let d=Math.floor(c/60);if(d<24)return`${d}h ago`;let e=Math.floor(d/24);if(e<30)return`${e}d ago`;let f=Math.floor(e/30);return f<12?`${f}mo ago`:`${Math.floor(f/12)}y ago`}function JH(a){return a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`}function JI({metadata:a}){let b=Object.entries(a);return 0===b.length?(0,B.jsx)("span",{children:"-"}):(0,B.jsxs)("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(([a,b])=>(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 font-medium",children:[a,"=",String(b)]},a)),b.length>3&&(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",b.length-3]})]})}function JJ({children:a}){return(0,B.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground mb-1",children:a})}function JK({title:a,icon:b,children:c}){return(0,B.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-border bg-muted/40 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[b,a]}),(0,B.jsx)("div",{className:"p-4 space-y-4",children:c})]})}function JL({bankId:a,documentId:b}){let c=(0,E.useTranslations)("documentsView"),[d,e]=(0,C.useState)([]),[f,g]=(0,C.useState)(!1),[h,i]=(0,C.useState)(null);return((0,C.useEffect)(()=>{let c=!1;return(async()=>{try{let d=await V.client.listLLMRequests(a,{document_id:b,group:!0,limit:50});if(c)return;let f=new Map;for(let a of d.items||[]){let b=a.trace_id||a.id;f.has(b)||f.set(b,[]),f.get(b).push(a)}let g=[...f.entries()].map(([a,b])=>({traceId:a,entry:b[0],calls:b.length,tokens:b.reduce((a,b)=>a+(b.total_tokens??0),0),status:b.some(a=>"error"===a.status)?"error":"success",start:b.map(a=>a.started_at).filter(Boolean).sort()[0]??null}));g.sort((a,b)=>(b.start||"").localeCompare(a.start||"")),e(g)}catch{}finally{c||g(!0)}})(),()=>{c=!0}},[a,b]),f&&0!==d.length)?(0,B.jsxs)(JK,{title:c("retainTracesTitle"),icon:(0,B.jsx)(bj,{className:"w-3.5 h-3.5"}),children:[(0,B.jsx)("div",{className:"space-y-1",children:d.map(a=>(0,B.jsxs)("button",{type:"button",onClick:()=>i(a.entry),className:"w-full flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm text-left hover:bg-muted/50",children:[(0,B.jsxs)("span",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,B.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${"error"===a.status?"bg-red-500":"bg-green-500"}`}),(0,B.jsx)("span",{className:"font-mono text-xs",children:a.entry.operation||"retain"}),(0,B.jsx)("span",{className:"text-muted-foreground text-xs truncate",children:a.start?new Date(a.start).toLocaleString():""})]}),(0,B.jsx)("span",{className:"text-muted-foreground text-xs font-mono shrink-0",children:c("retainTracesSummary",{calls:a.calls,tokens:a.tokens.toLocaleString()})})]},a.traceId))}),(0,B.jsx)(wq,{bankId:a,entry:h,open:!!h,onOpenChange:a=>!a&&i(null)})]}):null}function JM({label:a,value:b}){return(0,B.jsxs)("div",{children:[(0,B.jsx)(JJ,{children:a}),(0,B.jsx)("div",{className:"text-sm text-foreground",children:b})]})}function JN({spec:a}){return"string"==typeof a?(0,B.jsx)("span",{className:"text-xs font-mono bg-muted px-1.5 py-0.5 rounded w-fit",children:a}):(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:a.map((a,b)=>(0,B.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20 font-medium",children:0===a.length?"—":a.map(a=>`#${a}`).join(" ")},b))})}function JO({nodesByFactType:a}){let b=(0,E.useTranslations)("dataView"),c=a??{world:0,experience:0,observation:0},d=c.world+c.experience+c.observation,e=[{name:"World",value:c.world,color:"#8b5cf6"},{name:"Experience",value:c.experience,color:"#ec4899"},{name:"Observations",value:c.observation,color:"#6366f1"}];return(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:b("memoryComposition")}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:d.toLocaleString()})]}),0===d?(0,B.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:b("noMemoriesYet")}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:e.filter(a=>a.value>0).map(a=>(0,B.jsx)("div",{className:"h-full",style:{width:`${a.value/d*100}%`,backgroundColor:a.color},title:`${a.name}: ${a.value.toLocaleString()}`},a.name))}),(0,B.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:e.map(a=>(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:a.color}}),(0,B.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:a.name})]}),(0,B.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums",children:a.value.toLocaleString()}),(0,B.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:d>0?`${(a.value/d*100).toFixed(0)}%`:"0%"})]})]},a.name))})]})]})}function JP({chunkFactType:a,setChunkFactType:b}){return(0,B.jsx)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-muted/30",children:["world","experience","observation"].map(c=>(0,B.jsx)("button",{onClick:()=>b(c),className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors ${a===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"observation"===c?"Obs":c.charAt(0).toUpperCase()+c.slice(1)},c))})}function JQ({bankId:a,documentId:b}){let c=(0,E.useTranslations)("documentsView"),d=(0,E.useTranslations)("memoryDetailPanel"),[e,f]=(0,C.useState)([]),[g,h]=(0,C.useState)(!1),[i,j]=(0,C.useState)(null),k=(0,C.useCallback)(async()=>{if(a&&b)try{let c=await V.client.listMemories(a,{state:"invalidated",documentId:b,limit:200});f(c?.items??[])}catch{f([])}finally{h(!0)}},[a,b]);(0,C.useEffect)(()=>{k()},[k]);let l=async b=>{j(b);try{await V.client.updateMemory(b,a,{state:"valid"}),await k()}finally{j(null)}};return g&&0!==e.length?(0,B.jsx)(JK,{title:`${c("invalidatedFactsTitle")} (${e.length})`,children:(0,B.jsx)("div",{className:"space-y-2",children:e.map(a=>(0,B.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,B.jsxs)("div",{className:"min-w-0",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[a.fact_type&&(0,B.jsx)("span",{className:"shrink-0 text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium capitalize",children:a.fact_type}),(0,B.jsx)("div",{className:"text-sm text-foreground line-clamp-2",children:a.text})]}),a.entities&&(0,B.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:a.entities.split(", ").filter(Boolean).slice(0,6).map((a,b)=>(0,B.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground",children:a},b))}),a.occurred_start&&(0,B.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[new Date(a.occurred_start).toLocaleDateString(),a.occurred_end&&a.occurred_end!==a.occurred_start&&(0,B.jsxs)(B.Fragment,{children:[" → ",new Date(a.occurred_end).toLocaleDateString()]})]}),(a.invalidation_reason||a.invalidated_at)&&(0,B.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[a.invalidation_reason&&(0,B.jsxs)(B.Fragment,{children:[d("curationReasonLabel"),": ",a.invalidation_reason]}),a.invalidation_reason&&a.invalidated_at&&" · ",a.invalidated_at&&new Date(a.invalidated_at).toLocaleString()]})]}),(0,B.jsxs)(W.Button,{variant:"secondary",size:"sm",disabled:i===a.id,onClick:()=>l(a.id),className:"shrink-0 h-7 px-2 text-xs gap-1",children:[(0,B.jsx)(bk,{className:"w-3 h-3"}),d("curationRevert")]})]},a.id))})}):null}function JR({chunk:a}){let[b,c]=(0,C.useState)(!1),[d,e]=(0,C.useState)(!1),[f,g]=(0,C.useState)("world"),h=a.chunk_text??"",i=h.length>150?h.slice(0,150)+"...":h;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-left hover:bg-muted/30 transition-colors",onClick:()=>c(!b),children:[(0,B.jsx)(JC.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${b?"":"-rotate-90"}`}),(0,B.jsxs)("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["#",a.chunk_index]}),(0,B.jsxs)("span",{className:"text-[11px] text-muted-foreground/60 shrink-0",children:[h.length.toLocaleString()," chars"]}),!b&&(0,B.jsx)("span",{className:"text-xs text-foreground/50 truncate",children:i})]}),b&&(d?(0,B.jsxs)("div",{style:{height:"500px"},className:"flex flex-col border-t border-border",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/30 border-b border-border",children:[(0,B.jsx)(JP,{chunkFactType:f,setChunkFactType:g}),(0,B.jsx)("div",{className:"flex-1"}),(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"h-6 px-2 text-xs gap-1",children:[(0,B.jsx)(ac,{className:"w-3 h-3"}),"Compact"]})]}),(0,B.jsx)("div",{className:"flex-1 min-h-0",children:(0,B.jsx)(I1,{factType:f,chunkId:a.chunk_id},`${a.chunk_id}-${f}-full`)})]}):(0,B.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border",style:{height:"350px"},children:[(0,B.jsx)("div",{className:"overflow-y-auto",children:(0,B.jsx)("pre",{className:"px-4 py-3 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:h})}),(0,B.jsxs)("div",{className:"flex flex-col overflow-hidden",children:[(0,B.jsx)(JP,{chunkFactType:f,setChunkFactType:g}),(0,B.jsx)("div",{className:"flex-1 min-h-0",children:(0,B.jsx)(I1,{factType:f,chunkId:a.chunk_id,compact:!0,onExpandToggle:()=>e(!0)},`${a.chunk_id}-${f}-compact`)})]})]}))]})}function JS(){let a=(0,E.useTranslations)("documentsView"),b=(0,E.useTranslations)("common"),c=(0,E.useTranslations)("bank"),{currentBank:d}=(0,H.useBank)(),{features:e}=(0,I3.useFeatures)(),[f,g]=(0,C.useState)([]),[h,i]=(0,C.useState)(!1),[j,k]=(0,C.useState)(""),[l,n]=(0,C.useState)(0),[o,p]=(0,C.useState)(!1),[q,r]=(0,C.useState)(!1),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(!1),[w,x]=(0,C.useState)(!1),[y,z]=(0,C.useState)(null),[A,D]=(0,C.useState)("skip"),[G,I]=(0,C.useState)(1),J=Math.ceil(l/50),K=(G-1)*50,[L,M]=(0,C.useState)(null),[O,S]=(0,C.useState)(!1),[T,U]=(0,C.useState)(null),[Y,Z]=(0,C.useState)(!1),[$,ab]=(0,C.useState)(""),[ac,ae]=(0,C.useState)(!1),[af,ah]=(0,C.useState)(!1),[ap,aq]=(0,C.useState)(""),[ar,as]=(0,C.useState)(!1),[at,au]=(0,C.useState)([]),[av,aw]=(0,C.useState)(0),[ax,ay]=(0,C.useState)(!1),[az,aB]=(0,C.useState)(!1),[aC,aD]=(0,C.useState)(!1),[aE,aF]=(0,C.useState)(null),[aG,aH]=(0,C.useState)(null),[aI,aJ]=(0,C.useState)(null),aK=async(a=1)=>{if(d){i(!0);try{let b=await V.client.listDocuments({bank_id:d,q:j,limit:50,offset:(a-1)*50});g(b.items||[]),n(b.total||0)}catch(a){}finally{i(!1)}}},aL=a=>{I(a),aK(a)},aM=async a=>{if(d){S(!0),M({id:a}),Z(!1),ab(""),ah(!1),aq(""),au([]),aw(0),aB(!1);try{let b=await V.client.getDocument(a,d);M(b)}catch(a){M(null)}finally{S(!1)}}},aN=async a=>{if(d){ay(!0);try{let b=await V.client.listDocumentChunks({document_id:a,bank_id:d,limit:100});au(b.items||[]),aw(b.total||0),aB(!0)}catch(a){}finally{ay(!1)}}},aO=async()=>{if(d&&L){aD(!0);try{let a=await V.client.reprocessDocument(L.id,d);aF({success:!0,message:`Reprocessing started (operation: ${a.operation_id})`})}catch(a){aF({success:!1,message:"Error reprocessing document: "+a.message})}finally{aD(!1)}}},aP=async()=>{if(!d||!aG)return;let b=aG.id;U(b),aH(null);try{let c=await V.client.deleteDocument(b,d);aJ({success:!0,message:a("toastDeletedDocumentAndUnits",{count:c.memory_units_deleted})}),L?.id===b&&M(null),aK(G)}catch(b){console.error("Error deleting document:",b),aJ({success:!1,message:a("toastErrorDeletingDocument")+b.message})}finally{U(null)}},aQ=()=>{Z(!1),ab("")},aR=async()=>{if(!d||!L||!ap.trim())return;let a=L.retain_params??{},b={content:ap,document_id:L.id};a.context&&(b.context=a.context),a.event_date&&(b.timestamp=a.event_date),a.metadata&&Object.keys(a.metadata).length>0&&(b.metadata=a.metadata),L.tags&&L.tags.length>0&&(b.tags=L.tags),as(!0);try{await V.client.retain({bank_id:d,items:[b],async:!1});let a=await V.client.getDocument(L.id,d);M(a),ah(!1),aq(""),aK(G)}catch(a){console.error("Error updating document content:",a)}finally{as(!1)}},aS=async()=>{if(!d||!L)return;let a=$.split(",").map(a=>a.trim()).filter(a=>a.length>0);ae(!0);try{await V.client.updateDocument(L.id,d,a),M({...L,tags:a}),g(b=>b.map(b=>b.id===L.id?{...b,tags:a}:b)),Z(!1),ab("")}catch(a){console.error("Error updating document tags:",a)}finally{ae(!1)}};(0,C.useEffect)(()=>{d&&(I(1),aK(1))},[d]),(0,C.useEffect)(()=>{if(!d)return;let a=setTimeout(()=>{I(1),aK(1)},300);return()=>clearTimeout(a)},[j]);let aT=async(b,c=!1)=>{if(d&&!o){p(!0);try{var e;let f,g,h=await V.client.exportDocuments(d,b,c),i=b&&1===b.length?`-${b[0]}`:"-documents";e=`${d}${i}.zip`,f=URL.createObjectURL(h),(g=document.createElement("a")).href=f,g.download=e,document.body.appendChild(g),g.click(),g.remove(),URL.revokeObjectURL(f),F.toast.success(a("exportSuccess")),t(!1)}catch{}finally{p(!1)}}},aU=async b=>{if(b&&d){r(!0);try{let{operation_id:c}=await V.client.importDocuments(d,b,A),e=Date.now()+3e5,f=null;for(;Date.now()<e;){let b=await V.client.getOperationStatus(d,c);if("completed"===b.status){f=b.result_metadata??{};break}if("failed"===b.status)return void F.toast.error(b.error_message||a("importFailed"));await new Promise(a=>setTimeout(a,1e3))}if(null===f)return void F.toast.error(a("importTimeout"));F.toast.success(a("importSuccess",{imported:f.documents_imported??0,facts:f.facts_imported??0,skipped:f.documents_skipped??0})),aK(G),x(!1),z(null)}catch{}finally{r(!1)}}},aV=e?.document_export_api??!1,aW=e?.document_import_api??!1;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"mb-6 flex items-start justify-between gap-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("documents")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:c("documentsDescription")})]}),(aV||aW)&&(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"h-8 shrink-0",disabled:!d||o||q,children:[o?a("exporting"):q?a("importing"):a("actionsButton"),(0,B.jsx)(JC.ChevronDown,{className:"w-4 h-4 ml-1"})]})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",children:[aV&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>{v(!1),t(!0)},children:[(0,B.jsx)(JD,{className:"h-4 w-4 mr-2"}),a("exportButton")]}),aW&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>x(!0),children:[(0,B.jsx)(JE.Upload,{className:"h-4 w-4 mr-2"}),a("importButton")]})]})]})]}),(0,B.jsx)(bm.Dialog,{open:s,onOpenChange:t,children:(0,B.jsxs)(bm.DialogContent,{children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("exportDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("exportDialogDescription")})]}),(0,B.jsxs)("div",{className:"flex items-start gap-2 py-2",children:[(0,B.jsx)(I4.Checkbox,{id:"export-include-observations",checked:u,onCheckedChange:a=>v(!0===a)}),(0,B.jsxs)("div",{className:"grid gap-1 leading-none",children:[(0,B.jsx)(aA,{htmlFor:"export-include-observations",children:a("exportIncludeObservationsLabel")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:a("exportIncludeObservationsHint")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),disabled:o,children:b("cancel")}),(0,B.jsxs)(W.Button,{size:"sm",onClick:()=>aT(void 0,u),disabled:o,children:[(0,B.jsx)(JD,{className:"h-4 w-4 mr-2"}),o?a("exporting"):a("exportButton")]})]})]})}),(0,B.jsx)(bm.Dialog,{open:w,onOpenChange:a=>{x(a),a||z(null)},children:(0,B.jsxs)(bm.DialogContent,{children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("importDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("importDialogDescription")})]}),(0,B.jsxs)("div",{className:"py-2 space-y-4",children:[(0,B.jsx)("input",{type:"file",accept:".zip,application/zip",disabled:q,onChange:a=>z(a.target.files?.[0]??null),className:"block w-full text-sm text-muted-foreground file:mr-3 file:rounded-md file:border-0 file:bg-muted file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-muted/80"}),(0,B.jsxs)("div",{className:"grid gap-1.5",children:[(0,B.jsx)(aA,{htmlFor:"import-on-conflict",children:a("importConflictLabel")}),(0,B.jsxs)(bb.Select,{value:A,onValueChange:a=>D(a),disabled:q,children:[(0,B.jsx)(bb.SelectTrigger,{id:"import-on-conflict",className:"h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"skip",children:a("importConflictSkip")}),(0,B.jsx)(bb.SelectItem,{value:"replace",children:a("importConflictReplace")}),(0,B.jsx)(bb.SelectItem,{value:"new-id",children:a("importConflictNewId")})]})]})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{x(!1),z(null)},disabled:q,children:b("cancel")}),(0,B.jsxs)(W.Button,{size:"sm",onClick:()=>y&&aU(y),disabled:!y||q,children:[(0,B.jsx)(JE.Upload,{className:"h-4 w-4 mr-2"}),q?a("importing"):a("importButton")]})]})]})}),h?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("loadingDocuments")})]})}):f.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:a("totalDocuments",{total:l})}),(0,B.jsxs)("div",{className:"w-full",children:[(0,B.jsx)("div",{className:"px-5 mb-4",children:(0,B.jsx)(X.Input,{type:"text",value:j,onChange:a=>k(a.target.value),placeholder:a("searchPlaceholder"),className:"max-w-2xl"})}),(0,B.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{children:a("colDocumentId")}),(0,B.jsx)(an,{children:a("colCreated")}),(0,B.jsx)(an,{children:a("colUpdated")}),(0,B.jsx)(an,{children:a("colTags")}),(0,B.jsx)(an,{children:a("colMetadata")}),(0,B.jsx)(an,{children:a("colSize")}),(0,B.jsx)(an,{children:a("colMemoryUnits")})]})}),(0,B.jsx)(al,{children:f.length>0?f.map(a=>(0,B.jsxs)(am,{className:`cursor-pointer hover:bg-muted/50 ${L?.id===a.id?"bg-primary/10":""}`,onClick:()=>aM(a.id),children:[(0,B.jsx)(ao,{className:"text-card-foreground font-mono text-xs break-all",children:a.id}),(0,B.jsx)(ao,{className:"text-card-foreground",title:a.created_at?new Date(a.created_at).toLocaleString():"",children:a.created_at?JG(a.created_at):"N/A"}),(0,B.jsx)(ao,{className:"text-card-foreground",title:a.updated_at?new Date(a.updated_at).toLocaleString():"",children:a.updated_at?JG(a.updated_at):"N/A"}),(0,B.jsx)(ao,{className:"text-card-foreground",children:a.tags&&a.tags.length>0?(0,B.jsxs)("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map((a,b)=>(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:a},b)),a.tags.length>3&&(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",a.tags.length-3]})]}):"-"}),(0,B.jsx)(ao,{className:"text-card-foreground",children:a.document_metadata&&Object.keys(a.document_metadata).length>0?(0,B.jsx)(JI,{metadata:a.document_metadata}):"-"}),(0,B.jsx)(ao,{className:"text-card-foreground",children:JH(a.text_length||0)}),(0,B.jsx)(ao,{className:"text-card-foreground",children:a.memory_unit_count})]},a.id)):(0,B.jsx)(am,{children:(0,B.jsx)(ao,{colSpan:7,className:"text-center",children:a("clickLoadDocumentsToView")})})})]})}),J>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t px-5",children:[(0,B.jsxs)("div",{className:"text-xs text-muted-foreground",children:[K+1,"-",Math.min(K+50,l)," of ",l]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>aL(1),disabled:1===G||h,className:"h-7 w-7 p-0",children:(0,B.jsx)(_,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>aL(G-1),disabled:1===G||h,className:"h-7 w-7 p-0",children:(0,B.jsx)(P,{className:"h-3 w-3"})}),(0,B.jsxs)("span",{className:"text-xs px-2",children:[G," / ",J]}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>aL(G+1),disabled:G===J||h,className:"h-7 w-7 p-0",children:(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>aL(J),disabled:G===J||h,className:"h-7 w-7 p-0",children:(0,B.jsx)(aa,{className:"h-3 w-3"})})]})]})]})]}):(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("noDocumentsFound")})]})}),(0,B.jsx)(bm.Dialog,{open:!!L,onOpenChange:a=>!a&&M(null),children:(0,B.jsxs)(bm.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,B.jsx)(bm.DialogHeader,{className:"pr-10",children:(0,B.jsx)(bm.DialogTitle,{className:"flex items-center gap-2",children:(0,B.jsx)("span",{className:"truncate font-mono text-sm",children:L?.id??"Document"})})}),O?(0,B.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("loadingDocument")})]})}):L?(0,B.jsxs)(br.Tabs,{defaultValue:"general",className:"flex-1 flex flex-col overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,B.jsxs)(br.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,B.jsxs)(br.TabsTrigger,{value:"general",className:"flex items-center gap-1.5",children:[(0,B.jsx)(R,{className:"w-3.5 h-3.5"}),"General"]}),(0,B.jsxs)(br.TabsTrigger,{value:"memories",className:"flex items-center gap-1.5",children:[(0,B.jsx)(ag,{className:"w-3.5 h-3.5"}),"Memories"]}),(0,B.jsxs)(br.TabsTrigger,{value:"chunks",className:"flex items-center gap-1.5",onClick:()=>{!az&&L?.id&&aN(L.id)},children:[(0,B.jsx)(ai,{className:"w-3.5 h-3.5"}),"Chunks",az?` (${av})`:""]})]}),(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:aC,"aria-label":b("actions"),children:(0,B.jsx)(JB,{className:"h-4 w-4"})})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",children:[(0,B.jsxs)(I5.DropdownMenuItem,{onClick:aO,disabled:aC,children:[(0,B.jsx)(ad,{className:"h-4 w-4 mr-2"}),"Reprocess"]}),aV&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>aT([L.id]),disabled:o,children:[(0,B.jsx)(JD,{className:"h-4 w-4 mr-2"}),a("exportButton")]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>{aH({id:L.id,memoryCount:L.memory_unit_count})},className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,B.jsx)(JA,{className:"h-4 w-4 mr-2"}),a("deleteButton")]})]})]})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,B.jsx)(br.TabsContent,{value:"memories",className:"mt-0",children:(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)(br.Tabs,{defaultValue:"world",className:"flex flex-col",children:[(0,B.jsxs)(br.TabsList,{className:"w-fit",children:[(0,B.jsx)(br.TabsTrigger,{value:"world",children:"World"}),(0,B.jsx)(br.TabsTrigger,{value:"experience",children:"Experience"}),(0,B.jsx)(br.TabsTrigger,{value:"observation",children:"Observations"})]}),(0,B.jsxs)("div",{className:"mt-2",children:[(0,B.jsx)(br.TabsContent,{value:"world",className:"mt-0",children:(0,B.jsx)(I1,{factType:"world",documentId:L.id,compact:!0})}),(0,B.jsx)(br.TabsContent,{value:"experience",className:"mt-0",children:(0,B.jsx)(I1,{factType:"experience",documentId:L.id,compact:!0})}),(0,B.jsx)(br.TabsContent,{value:"observation",className:"mt-0",children:(0,B.jsx)(I1,{factType:"observation",documentId:L.id,compact:!0})})]})]}),d&&L?.id&&(0,B.jsx)(JQ,{bankId:d,documentId:L.id})]})}),(0,B.jsx)(br.TabsContent,{value:"general",className:"mt-0",children:(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,B.jsxs)(JK,{title:"Document",icon:(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),children:[L.created_at&&(0,B.jsx)(JM,{label:a("labelCreated"),value:new Date(L.created_at).toLocaleString()}),L.updated_at&&(0,B.jsx)(JM,{label:a("labelUpdated"),value:new Date(L.updated_at).toLocaleString()}),L.original_text&&(0,B.jsx)(JM,{label:a("colSize"),value:JH(new Blob([L.original_text]).size)}),(0,B.jsx)(JM,{label:a("labelTags"),value:Y?(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(X.Input,{value:$,onChange:a=>ab(a.target.value),placeholder:a("tagsInputPlaceholder"),className:"text-sm h-7 w-64",onKeyDown:a=>{"Enter"===a.key&&aS(),"Escape"===a.key&&aQ()},autoFocus:!0}),(0,B.jsx)(W.Button,{size:"sm",onClick:aS,disabled:ac,className:"h-7 w-7 p-0",children:ac?(0,B.jsx)("span",{className:"animate-spin text-xs",children:"⏳"}):(0,B.jsx)(bf.Check,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:aQ,disabled:ac,className:"h-7 w-7 p-0",children:(0,B.jsx)(bg.X,{className:"h-3 w-3"})})]}):(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[L.tags&&L.tags.length>0?(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:L.tags.map((a,b)=>(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:a},b))}):(0,B.jsx)("span",{className:"text-sm text-muted-foreground italic",children:"none"}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{ab((L?.tags??[]).join(", ")),Z(!0)},className:"h-6 w-6 p-0",children:(0,B.jsx)(bl,{className:"h-3 w-3"})})]})}),L.retain_params?.context&&(0,B.jsx)(JM,{label:"Context",value:L.retain_params.context}),L.retain_params?.event_date&&(0,B.jsx)(JM,{label:a("labelEventDate"),value:new Date(L.retain_params.event_date).toLocaleString()}),L.retain_params?.metadata&&Object.keys(L.retain_params.metadata).length>0&&(0,B.jsx)(JM,{label:"Metadata",value:(0,B.jsx)(JI,{metadata:L.retain_params.metadata})}),L.observation_scopes&&(0,B.jsx)(JM,{label:a("labelObservationScopes"),value:(0,B.jsx)(JN,{spec:L.observation_scopes})})]}),(0,B.jsx)(JK,{title:a("memoryCompositionTitle"),icon:(0,B.jsx)(ag,{className:"w-3.5 h-3.5"}),children:(0,B.jsx)(JO,{nodesByFactType:L.nodes_by_fact_type})}),d&&L?.id&&(0,B.jsx)(JL,{bankId:d,documentId:L.id})]}),e?.store_document_text||L.original_text?void 0!==L.original_text?af?(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("div",{className:"flex items-center justify-end mb-2",children:(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsxs)(W.Button,{size:"sm",onClick:aR,disabled:ar||!ap.trim(),className:"h-7 px-3 gap-1 text-xs",children:[ar?(0,B.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,B.jsx)(bf.Check,{className:"h-3 w-3"}),a("saveButton")]}),(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{ah(!1),aq("")},disabled:ar,className:"h-7 px-3 gap-1 text-xs",children:[(0,B.jsx)(bg.X,{className:"h-3 w-3"}),a("cancelButton")]})]})}),(0,B.jsx)("textarea",{value:ap,onChange:a=>aq(a.target.value),className:"w-full min-h-[400px] max-h-[600px] p-4 bg-muted/50 rounded-lg border border-border text-sm font-mono leading-relaxed text-card-foreground resize-y",autoFocus:!0}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:a("saveHint")})]}):(0,B.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-2 border-b border-border bg-muted/50 text-xs text-muted-foreground",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),(0,B.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:"Content"}),(0,B.jsxs)("span",{className:"text-muted-foreground/70",children:["·"," ",L.original_text?.length?.toLocaleString()??0," ","chars"]})]}),(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{aq(L?.original_text??""),ah(!0)},className:"h-6 px-2 gap-1 text-xs",children:[(0,B.jsx)(bl,{className:"h-3 w-3"}),a("editButton")]})]}),(0,B.jsx)("pre",{className:"p-4 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:L.original_text})]}):null:(0,B.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-xs text-amber-700 dark:text-amber-400",children:[(0,B.jsx)(JF.Lock,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,B.jsx)("span",{children:a("textNotStoredWarning")})]})]})}),(0,B.jsxs)(br.TabsContent,{value:"chunks",className:"mt-0",children:[!e?.store_document_text&&(0,B.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-4 py-3 mb-3 text-xs text-amber-700 dark:text-amber-400",children:[(0,B.jsx)(JF.Lock,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,B.jsx)("span",{children:a("textNotStoredWarning")})]}),ax?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("loadingChunks")})]})}):at.length>0?(0,B.jsx)("div",{className:"rounded-lg border border-border overflow-hidden divide-y divide-border",children:at.map(a=>(0,B.jsx)(JR,{chunk:a},a.chunk_id))}):az?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("noChunksFound")})]})}):(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsx)("div",{className:"text-center",children:(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("clickChunksTabToLoad")})})})]})]})]}):null]})}),(0,B.jsx)(Jc,{open:!!aG,onOpenChange:a=>!a&&aH(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:a("deleteDialogTitle")}),(0,B.jsxs)(Jx,{children:[a("deleteDialogDescription")," ",(0,B.jsxs)("span",{className:"font-mono font-semibold",children:['"',aG?.id,'"']}),"?",(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),a("deleteDialogWillDelete")," ",aG?.memoryCount!==void 0?(0,B.jsx)("span",{className:"font-semibold",children:a("deleteDialogMemoryUnits",{count:aG.memoryCount})}):a("deleteDialogAllMemoryUnits")," ",a("deleteDialogExtracted"),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),(0,B.jsx)("span",{className:"text-destructive font-semibold",children:a("deleteDialogCannotUndo")})]})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{children:a("cancelButton")}),(0,B.jsx)(Jy,{onClick:aP,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a("deleteButton")})]})]})}),(0,B.jsx)(Jc,{open:!!aI,onOpenChange:a=>!a&&aJ(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:aI?.success?a("deleteResultSuccessTitle"):a("deleteResultErrorTitle")}),(0,B.jsx)(Jx,{children:aI?.message})]}),(0,B.jsx)(Jv,{children:(0,B.jsx)(Jy,{onClick:()=>aJ(null),children:a("okButton")})})]})}),(0,B.jsx)(Jc,{open:!!aE,onOpenChange:a=>!a&&aF(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:aE?.success?"Reprocessing Started":a("deleteResultErrorTitle")}),(0,B.jsx)(Jx,{children:aE?.message})]}),(0,B.jsx)(Jv,{children:(0,B.jsx)(Jy,{onClick:()=>aF(null),children:a("okButton")})})]})})]})}function JT(){let a=(0,E.useTranslations)("entitiesView"),{currentBank:b}=(0,H.useBank)(),[c,d]=(0,C.useState)([]),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)(null),[i,j]=(0,C.useState)(!1),[k,l]=(0,C.useState)("relations"),[n,o]=(0,C.useState)(null),[p,q]=(0,C.useState)(!1),[r,s]=(0,C.useState)(1),[t,u]=(0,C.useState)(0),v=Math.ceil(t/50),w=(r-1)*50,x=async(a=1)=>{if(b){f(!0);try{let c=await V.client.listEntities({bank_id:b,limit:50,offset:(a-1)*50});d(c.items||[]),u(c.total||0)}catch(a){}finally{f(!1)}}},y=async a=>{if(b){j(!0);try{let c=await V.client.getEntity(a,b);h(c)}catch(a){}finally{j(!1)}}},z=a=>{s(a),x(a)},A=(0,C.useCallback)(async()=>{if(b){q(!0);try{let a=await V.client.getEntityGraph({bank_id:b,limit:2e3,min_count:1});o(a)}catch(a){}finally{q(!1)}}},[b]);(0,C.useEffect)(()=>{b&&(s(1),x(1),h(null),o(null))},[b]),(0,C.useEffect)(()=>{"relations"!==k||!b||n||p||A()},[k,b,n,p,A]);let D=(0,C.useMemo)(()=>n?HJ(n):{nodes:[],links:[]},[n]),F=(0,C.useMemo)(()=>{let a=new Map;for(let b of D.links){let c="number"==typeof b.weight&&b.weight>0?b.weight:1;a.set(b.source,(a.get(b.source)||0)+c),a.set(b.target,(a.get(b.target)||0)+c)}return a},[D]),G=(0,C.useMemo)(()=>{let a=1;for(let b of F.values())b>a&&(a=b);return a},[F]),I=(0,C.useCallback)(a=>3+11*Math.sqrt((F.get(a.id)||0)/G),[F,G]),J=(0,C.useMemo)(()=>{let a=n?.edges||[];if(!a.length)return null;let b=new Map,c=1/0,d=-1/0;for(let e of a){let a=e.data.lastCooccurred;if(!a)continue;let f=Date.parse(a);if(!Number.isNaN(f)){for(let a of[e.data.source,e.data.target]){let c=b.get(a);(void 0===c||f>c)&&b.set(a,f)}f<c&&(c=f),f>d&&(d=f)}}return Number.isFinite(c)&&Number.isFinite(d)&&d!==c?{times:b,minT:c,maxT:d}:null},[n]),K=(0,C.useCallback)(a=>{if(!J)return .5;let b=J.times.get(a.id);return void 0===b?0:(b-J.minT)/(J.maxT-J.minT)},[J]),L=(0,C.useCallback)(a=>{y(a.id)},[b]),M=b=>b?new Date(b).toLocaleDateString():a("na");return(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"mb-4 flex items-center justify-end",children:(0,B.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,B.jsxs)("button",{onClick:()=>l("relations"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"relations"===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(IZ,{className:"w-4 h-4"}),a("viewRelations")]}),(0,B.jsxs)("button",{onClick:()=>l("list"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"list"===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(ah,{className:"w-4 h-4"}),a("viewList")]})]})}),"relations"===k&&(0,B.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:p?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("loadingEntityGraph")})]})}):D.nodes.length>0?(0,B.jsx)(IR,{data:D,height:700,onNodeClick:L,nodeSizeFn:I,nodeHeatFn:J?K:void 0,heatLegendLabel:J?a("heatLegendLabel"):void 0,heatLegendEndpoints:J?[new Date(J.minT).toISOString().slice(0,10),new Date(J.maxT).toISOString().slice(0,10)]:void 0,sizeLegendLabel:a("sizeLegendLabel"),compactLabels:!0}):(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("noCooccurrences")}),(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:a("noCooccurrencesDescription")})]})})}),"list"===k&&(0,B.jsx)("div",{children:e?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("loadingEntities")})]})}):c.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:a("entityCount",{count:t})}),(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{children:a("colName")}),(0,B.jsx)(an,{children:a("colMentions")}),(0,B.jsx)(an,{children:a("colFirstSeen")}),(0,B.jsx)(an,{children:a("colLastSeen")})]})}),(0,B.jsx)(al,{children:c.map(a=>(0,B.jsxs)(am,{onClick:()=>y(a.id),className:`cursor-pointer hover:bg-muted/50 ${g?.id===a.id?"bg-primary/10":""}`,children:[(0,B.jsx)(ao,{className:"font-medium text-card-foreground",children:a.canonical_name}),(0,B.jsx)(ao,{className:"text-card-foreground",children:a.mention_count}),(0,B.jsx)(ao,{className:"text-card-foreground",children:M(a.first_seen)}),(0,B.jsx)(ao,{className:"text-card-foreground",children:M(a.last_seen)})]},a.id))})]})}),v>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,B.jsxs)("div",{className:"text-xs text-muted-foreground",children:[w+1,"-",Math.min(w+50,t)," of ",t]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(1),disabled:1===r||e,className:"h-7 w-7 p-0",children:(0,B.jsx)(_,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(r-1),disabled:1===r||e,className:"h-7 w-7 p-0",children:(0,B.jsx)(P,{className:"h-3 w-3"})}),(0,B.jsxs)("span",{className:"text-xs px-2",children:[r," / ",v]}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(r+1),disabled:r===v||e,className:"h-7 w-7 p-0",children:(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(v),disabled:r===v||e,className:"h-7 w-7 p-0",children:(0,B.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsxs)("div",{className:"text-center",children:[(0,B.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:a("noEntitiesFound")}),(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:a("noEntitiesDescription")})]})})}),g&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l-2 border-primary shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:(0,B.jsxs)("div",{className:"p-5",children:[(0,B.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:g.canonical_name}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a("entityDetails")})]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>h(null),className:"h-8 w-8 p-0",children:(0,B.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,B.jsxs)("div",{className:"space-y-5",children:[(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,B.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,B.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:a("mentionsLabel")}),(0,B.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:g.mention_count})]}),(0,B.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,B.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:a("firstSeenLabel")}),(0,B.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:M(g.first_seen)})]})]}),(0,B.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,B.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:a("entityIdLabel")}),(0,B.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:g.id})]})]})]})})]})}let JU=["world","experience","observation"],JV={world:{active:"bg-violet-500/15 text-violet-700 border-violet-400 dark:text-violet-300 dark:border-violet-500",inactive:"border-border text-muted-foreground hover:border-violet-300 hover:text-violet-600 dark:hover:text-violet-400",dot:"bg-violet-500"},experience:{active:"bg-pink-500/15 text-pink-700 border-pink-400 dark:text-pink-300 dark:border-pink-500",inactive:"border-border text-muted-foreground hover:border-pink-300 hover:text-pink-600 dark:hover:text-pink-400",dot:"bg-pink-500"},observation:{active:"bg-indigo-500/15 text-indigo-700 border-indigo-400 dark:text-indigo-300 dark:border-indigo-500",inactive:"border-border text-muted-foreground hover:border-indigo-300 hover:text-indigo-600 dark:hover:text-indigo-400",dot:"bg-indigo-500"}};function JW({ft:a,active:b,onToggle:c}){let d=(0,E.useTranslations)("factTypeFilter"),e=JV[a];return(0,B.jsxs)("button",{type:"button",onClick:c,className:(0,S.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-all",b?e.active:e.inactive),children:[(0,B.jsx)("span",{className:(0,S.cn)("h-1.5 w-1.5 rounded-full",b?e.dot:"bg-muted-foreground/50")}),d(a)]})}function JX({value:a,onChange:b,label:c}){let d=(0,E.useTranslations)("factTypeFilter"),e=c??d("defaultLabel");return(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[e&&(0,B.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:e}),(0,B.jsx)("div",{className:"flex gap-1.5",children:JU.map(c=>(0,B.jsx)(JW,{ft:c,active:a.includes(c),onToggle:()=>b(a.includes(c)?a.filter(a=>a!==c):[...a,c])},c))})]})}function JY({value:a,onChange:b}){return(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:JU.map(c=>(0,B.jsx)(JW,{ft:c,active:a.includes(c),onToggle:()=>b(a.includes(c)?a.filter(a=>a!==c):[...a,c])},c))})}var JZ=a.i(97063);let J$=(0,K.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),J_=(0,K.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),J0=(0,K.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),J1=(0,K.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var J2=a.i(6219);"function"==typeof SuppressedError&&SuppressedError;var J3=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var b=document.activeElement,c=[],d=0;d<a.rangeCount;d++)c.push(a.getRangeAt(d));switch(b.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":b.blur();break;default:b=null}return a.removeAllRanges(),function(){"Caret"===a.type&&a.removeAllRanges(),a.rangeCount||c.forEach(function(b){a.addRange(b)}),b&&b.focus()}},J4={"text/plain":"Text","text/html":"Url",default:"Text"},J5=function(a,b){var c,d,e,f,g,h,i,j,k=!1;b||(b={}),e=b.debug||!1;try{if(g=J3(),h=document.createRange(),i=document.getSelection(),(j=document.createElement("span")).textContent=a,j.ariaHidden="true",j.style.all="unset",j.style.position="fixed",j.style.top=0,j.style.clip="rect(0, 0, 0, 0)",j.style.whiteSpace="pre",j.style.webkitUserSelect="text",j.style.MozUserSelect="text",j.style.msUserSelect="text",j.style.userSelect="text",j.addEventListener("copy",function(c){if(c.stopPropagation(),b.format)if(c.preventDefault(),void 0===c.clipboardData){e&&console.warn("unable to use e.clipboardData"),e&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var d=J4[b.format]||J4.default;window.clipboardData.setData(d,a)}else c.clipboardData.clearData(),c.clipboardData.setData(b.format,a);b.onCopy&&(c.preventDefault(),b.onCopy(c.clipboardData))}),document.body.appendChild(j),h.selectNodeContents(j),i.addRange(h),!document.execCommand("copy"))throw Error("copy command was unsuccessful");k=!0}catch(g){e&&console.error("unable to copy using execCommand: ",g),e&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(b.format||"text",a),b.onCopy&&b.onCopy(window.clipboardData),k=!0}catch(g){e&&console.error("unable to copy using clipboardData: ",g),e&&console.error("falling back to prompt"),c="message"in b?b.message:"Copy to clipboard: #{key}, Enter",d=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",f=c.replace(/#{\s*key\s*}/g,d),window.prompt(f,a)}}finally{i&&("function"==typeof i.removeRange?i.removeRange(h):i.removeAllRanges()),j&&document.body.removeChild(j),g()}return k};function J6(a){return"[object Object]"===Object.prototype.toString.call(a)}function J7(a){return Array.isArray(a)?a.length:J6(a)?Object.keys(a).length:0}function J8(a,b,c,d,e,f){if(f&&void 0!==f.collapsed)return!!f.collapsed;if("boolean"==typeof d)return d;if("number"==typeof d&&b>d)return!0;let g=J7(a);if("function"==typeof d){let e=Kb(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||J6(a)&&g>e)}function J9(a,b,c,d,e,f){if(f&&void 0!==f.collapsed)return!!f.collapsed;if("boolean"==typeof d)return d;if("number"==typeof d&&b>d)return!0;let g=Math.ceil(a.length/100);if("function"==typeof d){let e=Kb(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||J6(a)&&g>e)}function Ka(a,b,c){return"boolean"==typeof a?a:"number"==typeof a&&!!(b>a)||"collapsed"===a&&!!c||"expanded"===a&&!c}function Kb(a,b){try{return a(...b)}catch(a){reportError(a)}}function Kc(a){if(!0===a||J6(a)&&!0===a.add)return!0}function Kd(a){if(!0===a||J6(a)&&!0===a.edit)return!0}function Ke(a){if(!0===a||J6(a)&&!0===a.delete)return!0}function Kf(a){return!a||void 0===a.add||!!a.add}function Kg(a){return!a||void 0===a.edit||!!a.edit}function Kh(a){return!a||void 0===a.delete||!!a.delete}function Ki(a){return!a||void 0===a.enableClipboard||!!a.enableClipboard}function Kj(){return(Kj=Object.assign.bind()).apply(this,arguments)}var Kk=function(a){return C.createElement("svg",Kj({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},a),l||(l=C.createElement("path",{fill:"currentColor",d:"M12.473 5.806a.666.666 0 0 0-.946 0L8.473 8.86a.667.667 0 0 1-.946 0L4.473 5.806a.667.667 0 1 0-.946.94l3.06 3.06a2 2 0 0 0 2.826 0l3.06-3.06a.667.667 0 0 0 0-.94Z"})))};function Kl(){return(Kl=Object.assign.bind()).apply(this,arguments)}var Km=function(a){return C.createElement("svg",Kl({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),n||(n=C.createElement("path",{fill:"currentColor",d:"M17.542 2.5h-4.75a3.963 3.963 0 0 0-3.959 3.958v4.75a3.963 3.963 0 0 0 3.959 3.959h4.75a3.963 3.963 0 0 0 3.958-3.959v-4.75A3.963 3.963 0 0 0 17.542 2.5Zm2.375 8.708a2.378 2.378 0 0 1-2.375 2.375h-4.75a2.378 2.378 0 0 1-2.375-2.375v-4.75a2.378 2.378 0 0 1 2.375-2.375h4.75a2.378 2.378 0 0 1 2.375 2.375v4.75Zm-4.75 6.334a3.963 3.963 0 0 1-3.959 3.958h-4.75A3.963 3.963 0 0 1 2.5 17.542v-4.75a3.963 3.963 0 0 1 3.958-3.959.791.791 0 1 1 0 1.584 2.378 2.378 0 0 0-2.375 2.375v4.75a2.378 2.378 0 0 0 2.375 2.375h4.75a2.378 2.378 0 0 0 2.375-2.375.792.792 0 1 1 1.584 0Z"})))};function Kn(){return(Kn=Object.assign.bind()).apply(this,arguments)}var Ko=function(a){return C.createElement("svg",Kn({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),o||(o=C.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.755 3.755 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.755 3.755 0 0 0 17.25 3Zm2.25 14.25a2.25 2.25 0 0 1-2.25 2.25H6.75a2.25 2.25 0 0 1-2.25-2.25V6.75A2.25 2.25 0 0 1 6.75 4.5h10.5a2.25 2.25 0 0 1 2.25 2.25v10.5Z"})),p||(p=C.createElement("path",{fill:"#14C786",d:"M10.312 14.45 7.83 11.906a.625.625 0 0 0-.896 0 .659.659 0 0 0 0 .918l2.481 2.546a1.264 1.264 0 0 0 .896.381 1.237 1.237 0 0 0 .895-.38l5.858-6.011a.658.658 0 0 0 0-.919.625.625 0 0 0-.896 0l-5.857 6.01Z"})))};function Kp({node:a,nodeMeta:b}){let{customizeCopy:c,CopyComponent:d,CopiedComponent:e}=(0,C.useContext)(KJ),[f,g]=(0,C.useState)(!1),h=d=>{d.stopPropagation();let e=c(a,b);"string"==typeof e&&e&&function(a){var b,c,d,e;b=this,c=void 0,d=void 0,e=function*(){try{yield navigator.clipboard.writeText(a)}catch(b){J5(a)}},new(d||(d=Promise))(function(a,f){function g(a){try{i(e.next(a))}catch(a){f(a)}}function h(a){try{i(e.throw(a))}catch(a){f(a)}}function i(b){var c;b.done?a(b.value):((c=b.value)instanceof d?c:new d(function(a){a(c)})).then(g,h)}i((e=e.apply(b,c||[])).next())})}(e),g(!0),setTimeout(()=>g(!1),3e3)};return f?"function"==typeof e?(0,B.jsx)(e,{className:"json-view--copy",style:{display:"inline-block"}}):(0,B.jsx)(Ko,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof d?(0,B.jsx)(d,{onClick:h,className:"json-view--copy"}):(0,B.jsx)(Km,{onClick:h,className:"json-view--copy"})}function Kq({indexOrName:a,value:b,depth:c,deleteHandle:d,editHandle:e,parent:f,parentPath:g}){let{displayArrayIndex:h}=(0,C.useContext)(KJ),i=Array.isArray(f);return(0,B.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!i||i&&h?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",Object.assign({className:"number"==typeof a?"json-view--index":"json-view--property"},{children:a})),":"," "]}):(0,B.jsx)(B.Fragment,{}),(0,B.jsx)(KH,{node:b,depth:c+1,deleteHandle:(a,b)=>d(a,b),editHandle:(a,b,c,d)=>e(a,b,c,d),parent:f,indexOrName:a,parentPath:g})]}))}function Kr(){return(Kr=Object.assign.bind()).apply(this,arguments)}var Ks=function(a){return C.createElement("svg",Kr({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),q||(q=C.createElement("path",{fill:"currentColor",d:"M18.75 6h-2.325a3.757 3.757 0 0 0-3.675-3h-1.5a3.757 3.757 0 0 0-3.675 3H5.25a.75.75 0 0 0 0 1.5H6v9.75A3.754 3.754 0 0 0 9.75 21h4.5A3.754 3.754 0 0 0 18 17.25V7.5h.75a.75.75 0 1 0 0-1.5Zm-7.5-1.5h1.5A2.255 2.255 0 0 1 14.872 6H9.128a2.255 2.255 0 0 1 2.122-1.5Zm5.25 12.75a2.25 2.25 0 0 1-2.25 2.25h-4.5a2.25 2.25 0 0 1-2.25-2.25V7.5h9v9.75Z"})),r||(r=C.createElement("path",{fill:"#DA0000",d:"M10.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75ZM13.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75Z"})))};function Kt(){return(Kt=Object.assign.bind()).apply(this,arguments)}var Ku=function(a){return C.createElement("svg",Kt({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),s||(s=C.createElement("path",{fill:"currentColor",d:"M21 6.75v10.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3h10.5A3.754 3.754 0 0 1 21 6.75Zm-1.5 0c0-1.24-1.01-2.25-2.25-2.25H6.75C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25V6.75Z"})),t||(t=C.createElement("path",{fill:"#14C786",d:"M15 12.75a.75.75 0 1 0 0-1.5h-2.25V9a.75.75 0 1 0-1.5 0v2.25H9a.75.75 0 1 0 0 1.5h2.25V15a.75.75 0 1 0 1.5 0v-2.25H15Z"})))};function Kv(){return(Kv=Object.assign.bind()).apply(this,arguments)}var Kw=function(a){return C.createElement("svg",Kv({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),u||(u=C.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})),v||(v=C.createElement("path",{fill:"#14C786",d:"m10.85 13.96-1.986-2.036a.5.5 0 0 0-.716 0 .527.527 0 0 0 0 .735l1.985 2.036a1.01 1.01 0 0 0 .717.305.99.99 0 0 0 .716-.305l4.686-4.808a.526.526 0 0 0 0-.735.5.5 0 0 0-.716 0l-4.687 4.809Z"})))};function Kx(){return(Kx=Object.assign.bind()).apply(this,arguments)}var Ky=function(a){return C.createElement("svg",Kx({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),w||(w=C.createElement("path",{fill:"#DA0000",d:"M15 9a.75.75 0 0 0-1.06 0L12 10.94 10.06 9A.75.75 0 0 0 9 10.06L10.94 12 9 13.94A.75.75 0 0 0 10.06 15L12 13.06 13.94 15A.75.75 0 0 0 15 13.94L13.06 12 15 10.06A.75.75 0 0 0 15 9Z"})),x||(x=C.createElement("path",{fill:"currentColor",d:"M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"})))};function Kz({originNode:a,node:b,depth:c,index:d,deleteHandle:e,customOptions:f,startIndex:g,parent:h,parentPath:i}){let{enableClipboard:j,src:k,onEdit:l,onChange:n,forceUpdate:o,displaySize:p,CustomOperation:q}=(0,C.useContext)(KJ),r=[...i,String(d)],[s,t]=(0,C.useState)(!0),u=(0,C.useCallback)((b,d,e)=>{a[b]=d,l&&l({newValue:d,oldValue:e,depth:c,src:k,indexOrName:b,parentType:"array",parentPath:i}),n&&n({type:"edit",depth:c,src:k,indexOrName:b,parentType:"array",parentPath:i}),o()},[b,l,n,o]),v=b=>{a.splice(b,1),e&&e(b,i),o()},w=(0,B.jsxs)(B.Fragment,{children:[!s&&(0,B.jsxs)("span",Object.assign({onClick:()=>t(!0),className:"jv-size-chevron"},{children:[Ka(p,c,s)&&(0,B.jsxs)("span",Object.assign({className:"jv-size"},{children:[J7(b)," Items"]})),(0,B.jsx)(Kk,{className:"jv-chevron"})]})),!s&&j&&Ki(f)&&(0,B.jsx)(Kp,{node:b,nodeMeta:{depth:c,indexOrName:d,parent:h,parentPath:i,currentPath:r}}),"function"==typeof q?(0,B.jsx)(q,{node:b}):null]});return(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{children:"["}),w,s?(0,B.jsxs)("button",Object.assign({onClick:()=>t(!1),className:"jv-button"},{children:[g," ... ",g+b.length-1]})):(0,B.jsx)("div",Object.assign({className:"jv-indent"},{children:b.map((a,e)=>(0,B.jsx)(Kq,{indexOrName:e+g,value:a,depth:c,parent:b,deleteHandle:v,editHandle:u,parentPath:i},String(d)+String(e)))})),(0,B.jsx)("span",{children:"]"})]})}function KA({node:a,depth:b,deleteHandle:c,indexOrName:d,customOptions:e,parent:f,parentPath:g}){let h=void 0!==d?[...g,String(d)]:g,i=[];for(let b=0;b<a.length;b+=100)i.push(a.slice(b,b+100));let{collapsed:j,enableClipboard:k,collapseObjectsAfterLength:l,editable:n,onDelete:o,src:p,onAdd:q,CustomOperation:r,onChange:s,forceUpdate:t,displaySize:u}=(0,C.useContext)(KJ),[v,w]=(0,C.useState)(J9(a,b,d,j,l,e));(0,C.useEffect)(()=>{w(J9(a,b,d,j,l,e))},[j,l]);let[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(!1),D=()=>{a.push(null),q&&q({indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:g}),s&&s({type:"add",indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:g}),t()},E=x||z,F=(0,B.jsxs)(B.Fragment,{children:[!v&&!E&&(0,B.jsxs)("span",Object.assign({onClick:()=>w(!0),className:"jv-size-chevron"},{children:[Ka(u,b,v)&&(0,B.jsxs)("span",Object.assign({className:"jv-size"},{children:[a.length," Items"]})),(0,B.jsx)(Kk,{className:"jv-chevron"})]})),E&&(0,B.jsx)(Kw,{className:"json-view--edit",style:{display:"inline-block"},onClick:z?D:()=>{y(!1),c&&c(d,g),o&&o({value:a,depth:b,src:p,indexOrName:d,parentType:"array",parentPath:g}),s&&s({type:"delete",depth:b,src:p,indexOrName:d,parentType:"array",parentPath:g})}}),E&&(0,B.jsx)(Ky,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{y(!1),A(!1)}}),!v&&!E&&k&&Ki(e)&&(0,B.jsx)(Kp,{node:a,nodeMeta:{depth:b,indexOrName:d,parent:f,parentPath:g,currentPath:h}}),!v&&!E&&Kc(n)&&Kf(e)&&(0,B.jsx)(Ku,{className:"json-view--edit",onClick:()=>{D()}}),!v&&!E&&Ke(n)&&Kh(e)&&c&&(0,B.jsx)(Ks,{className:"json-view--edit",onClick:()=>y(!0)}),"function"==typeof r?(0,B.jsx)(r,{node:a}):null]});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",{children:"["}),F,v?(0,B.jsx)("button",Object.assign({onClick:()=>w(!1),className:"jv-button"},{children:"..."})):(0,B.jsx)("div",Object.assign({className:"jv-indent"},{children:i.map((f,h)=>(0,B.jsx)(Kz,{originNode:a,node:f,depth:b,index:h,startIndex:100*h,deleteHandle:c,customOptions:e,parentPath:g},String(d)+String(h)))})),(0,B.jsx)("span",{children:"]"}),v&&Ka(u,b,v)&&(0,B.jsxs)("span",Object.assign({onClick:()=>w(!1),className:"jv-size"},{children:[a.length," Items"]}))]})}function KB({node:a,depth:b,indexOrName:c,deleteHandle:d,customOptions:e,parent:f,parentPath:g}){let{collapsed:h,onCollapse:i,enableClipboard:j,ignoreLargeArray:k,collapseObjectsAfterLength:l,editable:n,onDelete:o,src:p,onAdd:q,onEdit:r,onChange:s,forceUpdate:t,displaySize:u,CustomOperation:v}=(0,C.useContext)(KJ),w=void 0!==c?[...g,String(c)]:g;if(!k&&Array.isArray(a)&&a.length>100)return(0,B.jsx)(KA,{node:a,depth:b,indexOrName:c,deleteHandle:d,customOptions:e,parentPath:w});let x=J6(a),[y,z]=(0,C.useState)(J8(a,b,c,h,l,e)),A=d=>{null==i||i({isCollapsing:!d,node:a,depth:b,indexOrName:c}),z(d)};(0,C.useEffect)(()=>{A(J8(a,b,c,h,l,e))},[h,l]);let D=(0,C.useCallback)((c,d,e)=>{Array.isArray(a)?a[+c]=d:a&&(a[c]=d),r&&r({newValue:d,oldValue:e,depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),s&&s({type:"edit",depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),t()},[a,r,s,t]),E=b=>{Array.isArray(a)?a.splice(+b,1):a&&delete a[b],t()},[F,G]=(0,C.useState)(!1),[H,I]=(0,C.useState)(!1),J=(0,C.useRef)(null),K=()=>{var c;if(x){let d=null==(c=J.current)?void 0:c.value;d&&(a[d]=null,J.current&&(J.current.value=""),I(!1),q&&q({indexOrName:d,depth:b,src:p,parentType:"object",parentPath:w}),s&&s({type:"add",indexOrName:d,depth:b,src:p,parentType:"object",parentPath:w}))}else Array.isArray(a)&&(a.push(null),q&&q({indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:w}),s&&s({type:"add",indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:w}));t()},L=F||H,M=()=>{G(!1),I(!1)},N=(0,B.jsxs)(B.Fragment,{children:[!y&&!L&&(0,B.jsxs)("span",Object.assign({onClick:()=>A(!0),className:"jv-size-chevron"},{children:[Ka(u,b,y)&&(0,B.jsxs)("span",Object.assign({className:"jv-size"},{children:[J7(a)," Items"]})),(0,B.jsx)(Kk,{className:"jv-chevron"})]})),H&&x&&(0,B.jsx)("input",{className:"json-view--input",placeholder:"property",ref:J,onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),K()):"Escape"===a.key&&M()}}),L&&(0,B.jsx)(Kw,{className:"json-view--edit",style:{display:"inline-block"},onClick:H?K:()=>{G(!1),d&&d(c,w),o&&o({value:a,depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),s&&s({type:"delete",depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w})}}),L&&(0,B.jsx)(Ky,{className:"json-view--edit",style:{display:"inline-block"},onClick:M}),!y&&!L&&j&&Ki(e)&&(0,B.jsx)(Kp,{node:a,nodeMeta:{depth:b,indexOrName:c,parent:f,parentPath:g,currentPath:w}}),!y&&!L&&Kc(n)&&Kf(e)&&(0,B.jsx)(Ku,{className:"json-view--edit",onClick:()=>{x?(I(!0),setTimeout(()=>{var a;return null==(a=J.current)?void 0:a.focus()})):K()}}),!y&&!L&&Ke(n)&&Kh(e)&&d&&(0,B.jsx)(Ks,{className:"json-view--edit",onClick:()=>G(!0)}),"function"==typeof v?(0,B.jsx)(v,{node:a}):null]});return Array.isArray(a)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",{children:"["}),N,y?(0,B.jsx)("button",Object.assign({onClick:()=>A(!1),className:"jv-button"},{children:"..."})):(0,B.jsx)("div",Object.assign({className:"jv-indent"},{children:a.map((d,e)=>(0,B.jsx)(Kq,{indexOrName:e,value:d,depth:b,parent:a,deleteHandle:E,editHandle:D,parentPath:w},String(c)+String(e)))})),(0,B.jsx)("span",{children:"]"}),y&&Ka(u,b,y)&&(0,B.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[J7(a)," Items"]}))]}):x?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("span",{children:"{"}),N,y?(0,B.jsx)("button",Object.assign({onClick:()=>A(!1),className:"jv-button"},{children:"..."})):(0,B.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(a).map(([d,e])=>(0,B.jsx)(Kq,{indexOrName:d,value:e,depth:b,parent:a,deleteHandle:E,editHandle:D,parentPath:w},String(c)+String(d)))})),(0,B.jsx)("span",{children:"}"}),y&&Ka(u,b,y)&&(0,B.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[J7(a)," Items"]}))]}):(0,B.jsx)("span",{children:String(a)})}let KC=C.default.forwardRef(({str:a,className:b,ctrlClick:c},d)=>{let{collapseStringMode:e,collapseStringsAfterLength:f,customizeCollapseStringUI:g}=(0,C.useContext)(KJ),[h,i]=(0,C.useState)(!0),j=(0,C.useRef)(null);f=f>0?f:0;let k=a.replace(/\s+/g," "),l="function"==typeof g?g(k,h):"string"==typeof g?g:"...",n=a=>{var b;if((a.ctrlKey||a.metaKey)&&c)c(a);else{let a=window.getSelection();if(a&&a.anchorOffset!==a.focusOffset&&(null==(b=a.anchorNode)?void 0:b.parentElement)===j.current)return;i(!h)}};if(a.length<=f)return(0,B.jsxs)("span",Object.assign({ref:j,className:b,onClick:c},{children:['"',a,'"']}));if("address"===e)return a.length<=10?(0,B.jsxs)("span",Object.assign({ref:j,className:b,onClick:c},{children:['"',a,'"']})):(0,B.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[k.slice(0,6),l,k.slice(-4)]:a,'"']}));if("directly"===e)return(0,B.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[k.slice(0,f),l]:a,'"']}));if("word"===e){let c=f,d=f+1,e=k,g=1;for(;;){if(/\W/.test(a[c])){e=a.slice(0,c);break}if(/\W/.test(a[d])){e=a.slice(0,d);break}if(6===g){e=a.slice(0,f);break}g++,c--,d++}return(0,B.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[e,l]:a,'"']}))}return(0,B.jsxs)("span",Object.assign({ref:j,className:b},{children:['"',a,'"']}))});function KD(){return(KD=Object.assign.bind()).apply(this,arguments)}var KE=function(a){return C.createElement("svg",KD({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),y||(y=C.createElement("path",{fill:"currentColor",d:"M17.25 3H6.75A3.754 3.754 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.754 3.754 0 0 0 17.25 3Zm2.25 14.25c0 1.24-1.01 2.25-2.25 2.25H6.75c-1.24 0-2.25-1.01-2.25-2.25V6.75c0-1.24 1.01-2.25 2.25-2.25h10.5c1.24 0 2.25 1.01 2.25 2.25v10.5Zm-6.09-9.466-5.031 5.03a2.981 2.981 0 0 0-.879 2.121v1.19c0 .415.336.75.75.75h1.19c.8 0 1.554-.312 2.12-.879l5.03-5.03a2.252 2.252 0 0 0 0-3.182c-.85-.85-2.331-.85-3.18 0Zm-2.91 7.151c-.28.28-.666.44-1.06.44H9v-.44c0-.4.156-.777.44-1.06l3.187-3.188 1.06 1.061-3.187 3.188Zm5.03-5.03-.782.783-1.06-1.061.782-.782a.766.766 0 0 1 1.06 0 .75.75 0 0 1 0 1.06Z"})))};function KF(){return(KF=Object.assign.bind()).apply(this,arguments)}var KG=function(a){return C.createElement("svg",KF({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),z||(z=C.createElement("path",{fill:"currentColor",d:"M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"})),A||(A=C.createElement("path",{fill:"currentColor",d:"M20.013 3h-3.946a.987.987 0 0 0 0 1.973h1.564l-6.342 6.342a1.004 1.004 0 0 0 0 1.396 1.004 1.004 0 0 0 1.396 0l6.342-6.342v1.564a.987.987 0 0 0 1.973 0V3.987A.987.987 0 0 0 20.013 3Z"})))};function KH({node:a,depth:b,deleteHandle:c,indexOrName:d,parent:e,editHandle:f,parentPath:g}){let h,{collapseStringsAfterLength:i,enableClipboard:j,editable:k,src:l,onDelete:n,onChange:o,customizeNode:p,matchesURL:q,urlRegExp:r,EditComponent:s,DoneComponent:t,CancelComponent:u,CustomOperation:v}=(0,C.useContext)(KJ);if("function"==typeof p&&(h=Kb(p,[{node:a,depth:b,indexOrName:d}])),h){if((0,C.isValidElement)(h))return h;else if("function"==typeof h){let c=h;return(0,B.jsx)(c,{node:a,depth:b,indexOrName:d})}}if(Array.isArray(a)||J6(a))return(0,B.jsx)(KB,{parent:e,node:a,depth:b,indexOrName:d,deleteHandle:c,parentPath:g,customOptions:"object"==typeof h?h:void 0});{var w;let p=typeof a,x=void 0!==d?[...g,String(d)]:g,[y,z]=(0,C.useState)(!1),[A,D]=(0,C.useState)(!1),E=(0,C.useRef)(null),F=()=>{z(!0),setTimeout(()=>{var a,b;null==(a=window.getSelection())||a.selectAllChildren(E.current),null==(b=E.current)||b.focus()})},G=(0,C.useCallback)(()=>{let b=E.current.innerText;try{let c=JSON.parse(b);f&&f(d,c,a,g)}catch(e){let c="string"===p?b.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):b;f&&f(d,c,a,g)}z(!1)},[f,d,a,g,p]),H=()=>{z(!1),D(!1)},I=()=>{D(!1),c&&c(d,g),n&&n({value:a,depth:b,src:l,indexOrName:d,parentType:Array.isArray(e)?"array":"object",parentPath:g}),o&&o({depth:b,src:l,indexOrName:d,parentType:Array.isArray(e)?"array":"object",type:"delete",parentPath:g})},J=(0,C.useCallback)(a=>{"Enter"===a.key?(a.preventDefault(),G()):"Escape"===a.key&&H()},[G]),K=y||A,L=!K&&Kd(k)&&Kg(h)&&f?a=>{(a.ctrlKey||a.metaKey)&&F()}:void 0,M=(0,B.jsxs)(B.Fragment,{children:[K&&("function"==typeof t?(0,B.jsx)(t,{className:"json-view--edit",style:{display:"inline-block"},onClick:A?I:G}):(0,B.jsx)(Kw,{className:"json-view--edit",style:{display:"inline-block"},onClick:A?I:G})),K&&("function"==typeof u?(0,B.jsx)(u,{className:"json-view--edit",style:{display:"inline-block"},onClick:H}):(0,B.jsx)(Ky,{className:"json-view--edit",style:{display:"inline-block"},onClick:H})),!K&&j&&Ki(h)&&(0,B.jsx)(Kp,{node:a,nodeMeta:{depth:b,indexOrName:d,parent:e,parentPath:g,currentPath:x}}),!K&&q&&"string"===p&&r.test(a)&&(!(w=h)||void 0===w.matchesURL||!!w.matchesURL)&&(0,B.jsx)("a",Object.assign({href:a,target:"_blank",className:"json-view--link"},{children:(0,B.jsx)(KG,{})})),!K&&Kd(k)&&Kg(h)&&f&&("function"==typeof s?(0,B.jsx)(s,{className:"json-view--edit",onClick:F}):(0,B.jsx)(KE,{className:"json-view--edit",onClick:F})),!K&&Ke(k)&&Kh(h)&&c&&(0,B.jsx)(Ks,{className:"json-view--edit",onClick:()=>D(!0)}),"function"==typeof v?(0,B.jsx)(v,{node:a}):null]}),N="json-view--string";switch(p){case"number":case"bigint":N="json-view--number";break;case"boolean":N="json-view--boolean";break;case"object":N="json-view--null"}"string"==typeof(null==h?void 0:h.className)&&(N+=" "+h.className),A&&(N+=" json-view--deleting");let O=String(a);"bigint"===p&&(O+="n");let P=(0,C.useMemo)(()=>(0,B.jsx)("span",{contentEditable:!0,className:N,dangerouslySetInnerHTML:{__html:"string"===p?`"${O}"`:O},ref:E,onKeyDown:J}),[O,p,J]);return"string"===p?(0,B.jsxs)(B.Fragment,{children:[y?P:a.length>i?(0,B.jsx)(KC,{str:a,ref:E,className:N,ctrlClick:L}):(0,B.jsxs)("span",Object.assign({className:N,onClick:L},{children:['"',O,'"']})),M]}):(0,B.jsxs)(B.Fragment,{children:[y?P:(0,B.jsx)("span",Object.assign({className:N,onClick:L},{children:O})),M]})}}let KI=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,KJ=(0,C.createContext)({src:void 0,collapseStringsAfterLength:99,collapseStringMode:"directly",customizeCollapseStringUI:void 0,collapseObjectsAfterLength:20,collapsed:!1,onCollapse:void 0,enableClipboard:!0,editable:!1,onEdit:void 0,onDelete:void 0,onAdd:void 0,onChange:void 0,forceUpdate:()=>{},customizeNode:void 0,customizeCopy:()=>{},displaySize:void 0,displayArrayIndex:!0,matchesURL:!1,urlRegExp:KI,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function KK({src:a,collapseStringsAfterLength:b=99,collapseStringMode:c="directly",customizeCollapseStringUI:d,collapseObjectsAfterLength:e=99,collapsed:f,onCollapse:g,enableClipboard:h=!0,editable:i=!1,onEdit:j,onDelete:k,onAdd:l,onChange:n,dark:o=!1,theme:p="default",customizeNode:q,customizeCopy:r=a=>(function(a){if("string"==typeof a)return a;try{return JSON.stringify(a,(a,b)=>{switch(typeof b){case"bigint":return String(b)+"n";case"number":case"boolean":case"object":case"string":return b;default:return String(b)}},void 0)}catch(a){return`${a.name}: ${a.message}`||"JSON.stringify failed"}})(a),displaySize:s,displayArrayIndex:t=!0,style:u,className:v,matchesURL:w=!1,urlRegExp:x=KI,ignoreLargeArray:y=!1,CopyComponent:z,CopiedComponent:A,EditComponent:D,CancelComponent:E,DoneComponent:F,CustomOperation:G}){let[H,I]=(0,C.useState)(0),J=(0,C.useCallback)(()=>I(a=>++a),[]),[K,L]=(0,C.useState)(a);return(0,C.useEffect)(()=>L(a),[a]),(0,B.jsx)(KJ.Provider,Object.assign({value:{src:K,collapseStringsAfterLength:b,collapseStringMode:c,customizeCollapseStringUI:d,collapseObjectsAfterLength:e,collapsed:f,onCollapse:g,enableClipboard:h,editable:i,onEdit:j,onDelete:k,onAdd:l,onChange:n,forceUpdate:J,customizeNode:q,customizeCopy:r,displaySize:s,displayArrayIndex:t,matchesURL:w,urlRegExp:x,ignoreLargeArray:y,CopyComponent:z,CopiedComponent:A,EditComponent:D,CancelComponent:E,DoneComponent:F,CustomOperation:G}},{children:(0,B.jsx)("code",Object.assign({className:"json-view"+(o?" dark":"")+(p&&"default"!==p?" json-view_"+p:"")+(v?" "+v:""),style:u},{children:(0,B.jsx)(KH,{node:K,depth:1,editHandle:(a,b,c,d)=>{L(b),j&&j({newValue:b,oldValue:c,depth:1,src:K,indexOrName:a,parentType:null,parentPath:d}),n&&n({type:"edit",depth:1,src:K,indexOrName:a,parentType:null,parentPath:d})},deleteHandle:(a,b)=>{L(void 0),k&&k({value:K,depth:1,src:K,indexOrName:a,parentType:null,parentPath:b}),n&&n({depth:1,src:K,indexOrName:a,parentType:null,type:"delete",parentPath:b})},parentPath:[]})}))}))}var bh=bh;let KL=(0,K.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),KM=(0,K.default)("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]);function KN(){}function KO(){}let KP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KQ=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KR={};function KS(a,b){return((b||KR).jsx?KQ:KP).test(a)}let KT=/[ \t\n\f\r]/g;function KU(a){return""===a.replace(KT,"")}class KV{constructor(a,b){this.attribute=b,this.property=a}}KV.prototype.attribute="",KV.prototype.booleanish=!1,KV.prototype.boolean=!1,KV.prototype.commaOrSpaceSeparated=!1,KV.prototype.commaSeparated=!1,KV.prototype.defined=!1,KV.prototype.mustUseProperty=!1,KV.prototype.number=!1,KV.prototype.overloadedBoolean=!1,KV.prototype.property="",KV.prototype.spaceSeparated=!1,KV.prototype.space=void 0;let KW=0,KX=K2(),KY=K2(),KZ=K2(),K$=K2(),K_=K2(),K0=K2(),K1=K2();function K2(){return 2**++KW}a.s(["boolean",0,KX,"booleanish",0,KY,"commaOrSpaceSeparated",0,K1,"commaSeparated",0,K0,"number",0,K$,"overloadedBoolean",0,KZ,"spaceSeparated",0,K_],53427);var K3=a.i(53427);let K4=Object.keys(K3);class K5 extends KV{constructor(a,b,c,d){let e=-1;if(super(a,b),function(a,b,c){c&&(a[b]=c)}(this,"space",d),"number"==typeof c)for(;++e<K4.length;){const a=K4[e];!function(a,b,c){c&&(a[b]=c)}(this,K4[e],(c&K3[a])===K3[a])}}}function K6(a){return a.toLowerCase()}K5.prototype.defined=!0;let K7=/[A-Z]/g,K8=/-[a-z]/g,K9=/^data[-\w.:]+$/i;function La(a){return"-"+a.toLowerCase()}function Lb(a){return a.charAt(1).toUpperCase()}let Lc={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class Ld{constructor(a,b,c){this.normal=b,this.property=a,c&&(this.space=c)}}function Le(a,b){let c={},d={};for(let b of a)Object.assign(c,b.property),Object.assign(d,b.normal);return new Ld(c,d,b)}function Lf(a){let b={},c={};for(let[d,e]of Object.entries(a.properties)){let f=new K5(d,a.transform(a.attributes||{},d),e,a.space);a.mustUseProperty&&a.mustUseProperty.includes(d)&&(f.mustUseProperty=!0),b[d]=f,c[K6(d)]=d,c[K6(f.attribute)]=d}return new Ld(b,c,a.space)}Ld.prototype.normal={},Ld.prototype.property={},Ld.prototype.space=void 0;let Lg=Lf({properties:{ariaActiveDescendant:null,ariaAtomic:KY,ariaAutoComplete:null,ariaBusy:KY,ariaChecked:KY,ariaColCount:K$,ariaColIndex:K$,ariaColSpan:K$,ariaControls:K_,ariaCurrent:null,ariaDescribedBy:K_,ariaDetails:null,ariaDisabled:KY,ariaDropEffect:K_,ariaErrorMessage:null,ariaExpanded:KY,ariaFlowTo:K_,ariaGrabbed:KY,ariaHasPopup:null,ariaHidden:KY,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:K_,ariaLevel:K$,ariaLive:null,ariaModal:KY,ariaMultiLine:KY,ariaMultiSelectable:KY,ariaOrientation:null,ariaOwns:K_,ariaPlaceholder:null,ariaPosInSet:K$,ariaPressed:KY,ariaReadOnly:KY,ariaRelevant:null,ariaRequired:KY,ariaRoleDescription:K_,ariaRowCount:K$,ariaRowIndex:K$,ariaRowSpan:K$,ariaSelected:KY,ariaSetSize:K$,ariaSort:null,ariaValueMax:K$,ariaValueMin:K$,ariaValueNow:K$,ariaValueText:null,role:null},transform:(a,b)=>"role"===b?b:"aria-"+b.slice(4).toLowerCase()});function Lh(a,b){return b in a?a[b]:b}function Li(a,b){return Lh(a,b.toLowerCase())}let Lj=Lf({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:K0,acceptCharset:K_,accessKey:K_,action:null,allow:null,allowFullScreen:KX,allowPaymentRequest:KX,allowUserMedia:KX,alt:null,as:null,async:KX,autoCapitalize:null,autoComplete:K_,autoFocus:KX,autoPlay:KX,blocking:K_,capture:null,charSet:null,checked:KX,cite:null,className:K_,cols:K$,colSpan:null,content:null,contentEditable:KY,controls:KX,controlsList:K_,coords:K$|K0,crossOrigin:null,data:null,dateTime:null,decoding:null,default:KX,defer:KX,dir:null,dirName:null,disabled:KX,download:KZ,draggable:KY,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:KX,formTarget:null,headers:K_,height:K$,hidden:KZ,high:K$,href:null,hrefLang:null,htmlFor:K_,httpEquiv:K_,id:null,imageSizes:null,imageSrcSet:null,inert:KX,inputMode:null,integrity:null,is:null,isMap:KX,itemId:null,itemProp:K_,itemRef:K_,itemScope:KX,itemType:K_,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:KX,low:K$,manifest:null,max:null,maxLength:K$,media:null,method:null,min:null,minLength:K$,multiple:KX,muted:KX,name:null,nonce:null,noModule:KX,noValidate:KX,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:KX,optimum:K$,pattern:null,ping:K_,placeholder:null,playsInline:KX,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:KX,referrerPolicy:null,rel:K_,required:KX,reversed:KX,rows:K$,rowSpan:K$,sandbox:K_,scope:null,scoped:KX,seamless:KX,selected:KX,shadowRootClonable:KX,shadowRootDelegatesFocus:KX,shadowRootMode:null,shape:null,size:K$,sizes:null,slot:null,span:K$,spellCheck:KY,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K$,step:null,style:null,tabIndex:K$,target:null,title:null,translate:null,type:null,typeMustMatch:KX,useMap:null,value:KY,width:K$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:K_,axis:null,background:null,bgColor:null,border:K$,borderColor:null,bottomMargin:K$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:KX,declare:KX,event:null,face:null,frame:null,frameBorder:null,hSpace:K$,leftMargin:K$,link:null,longDesc:null,lowSrc:null,marginHeight:K$,marginWidth:K$,noResize:KX,noHref:KX,noShade:KX,noWrap:KX,object:null,profile:null,prompt:null,rev:null,rightMargin:K$,rules:null,scheme:null,scrolling:KY,standby:null,summary:null,text:null,topMargin:K$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:KX,disableRemotePlayback:KX,prefix:null,property:null,results:K$,security:null,unselectable:null},space:"html",transform:Li}),Lk=Lf({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:K1,accentHeight:K$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K$,amplitude:K$,arabicForm:null,ascent:K$,attributeName:null,attributeType:null,azimuth:K$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K$,by:null,calcMode:null,capHeight:K$,className:K_,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K$,diffuseConstant:K$,direction:null,display:null,dur:null,divisor:K$,dominantBaseline:null,download:KX,dx:null,dy:null,edgeMode:null,editable:null,elevation:K$,enableBackground:null,end:null,event:null,exponent:K$,externalResourcesRequired:null,fill:null,fillOpacity:K$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:K0,g2:K0,glyphName:K0,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K$,horizOriginX:K$,horizOriginY:K$,id:null,ideographic:K$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K$,k:K$,k1:K$,k2:K$,k3:K$,k4:K$,kernelMatrix:K1,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K$,overlineThickness:K$,paintOrder:null,panose1:null,path:null,pathLength:K$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:K_,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K$,pointsAtY:K$,pointsAtZ:K$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:K1,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:K1,rev:K1,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:K1,requiredFeatures:K1,requiredFonts:K1,requiredFormats:K1,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K$,specularExponent:K$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K$,strikethroughThickness:K$,string:null,stroke:null,strokeDashArray:K1,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K$,strokeOpacity:K$,strokeWidth:null,style:null,surfaceScale:K$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:K1,tabIndex:K$,tableValues:null,target:null,targetX:K$,targetY:K$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:K1,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K$,underlineThickness:K$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K$,values:null,vAlphabetic:K$,vMathematical:K$,vectorEffect:null,vHanging:K$,vIdeographic:K$,version:null,vertAdvY:K$,vertOriginX:K$,vertOriginY:K$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Lh}),Ll=Lf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(a,b)=>"xlink:"+b.slice(5).toLowerCase()}),Lm=Lf({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Li}),Ln=Lf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(a,b)=>"xml:"+b.slice(3).toLowerCase()}),Lo=Le([Lg,Lj,Ll,Lm,Ln],"html"),Lp=Le([Lg,Lk,Ll,Lm,Ln],"svg");var Lq=a.i(52540);let Lr=Lt("end"),Ls=Lt("start");function Lt(a){return function(b){let c=b&&b.position&&b.position[a]||{};if("number"==typeof c.line&&c.line>0&&"number"==typeof c.column&&c.column>0)return{line:c.line,column:c.column,offset:"number"==typeof c.offset&&c.offset>-1?c.offset:void 0}}}function Lu(a){return a&&"object"==typeof a?"position"in a||"type"in a?Lw(a.position):"start"in a||"end"in a?Lw(a):"line"in a||"column"in a?Lv(a):"":""}function Lv(a){return Lx(a&&a.line)+":"+Lx(a&&a.column)}function Lw(a){return Lv(a&&a.start)+"-"+Lv(a&&a.end)}function Lx(a){return a&&"number"==typeof a?a:1}class Ly extends Error{constructor(a,b,c){super(),"string"==typeof b&&(c=b,b=void 0);let d="",e={},f=!1;if(b&&(e="line"in b&&"column"in b||"start"in b&&"end"in b?{place:b}:"type"in b?{ancestors:[b],place:b.position}:{...b}),"string"==typeof a?d=a:!e.cause&&a&&(f=!0,d=a.message,e.cause=a),!e.ruleId&&!e.source&&"string"==typeof c){const a=c.indexOf(":");-1===a?e.ruleId=c:(e.source=c.slice(0,a),e.ruleId=c.slice(a+1))}if(!e.place&&e.ancestors&&e.ancestors){const a=e.ancestors[e.ancestors.length-1];a&&(e.place=a.position)}const g=e.place&&"start"in e.place?e.place.start:e.place;this.ancestors=e.ancestors||void 0,this.cause=e.cause||void 0,this.column=g?g.column:void 0,this.fatal=void 0,this.file="",this.message=d,this.line=g?g.line:void 0,this.name=Lu(e.place)||"1:1",this.place=e.place||void 0,this.reason=this.message,this.ruleId=e.ruleId||void 0,this.source=e.source||void 0,this.stack=f&&e.cause&&"string"==typeof e.cause.stack?e.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ly.prototype.file="",Ly.prototype.name="",Ly.prototype.reason="",Ly.prototype.message="",Ly.prototype.stack="",Ly.prototype.column=void 0,Ly.prototype.line=void 0,Ly.prototype.ancestors=void 0,Ly.prototype.cause=void 0,Ly.prototype.fatal=void 0,Ly.prototype.place=void 0,Ly.prototype.ruleId=void 0,Ly.prototype.source=void 0;let Lz={}.hasOwnProperty,LA=new Map,LB=/[A-Z]/g,LC=new Set(["table","tbody","thead","tfoot","tr"]),LD=new Set(["td","th"]),LE="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function LF(a,b,c){var d,e,f,g,h,i,j,k,l;let n,o,p,q,r,s,t,u,v,w,x;return"element"===b.type?(d=a,e=b,f=c,o=n=d.schema,"svg"===e.tagName.toLowerCase()&&"html"===n.space&&(d.schema=Lp),d.ancestors.push(e),p=LJ(d,e.tagName,!1),q=function(a,b){let c,d,e={};for(d in b.properties)if("children"!==d&&Lz.call(b.properties,d)){let f=function(a,b,c){let d=function(a,b){let c=K6(b),d=b,e=KV;if(c in a.normal)return a.property[a.normal[c]];if(c.length>4&&"data"===c.slice(0,4)&&K9.test(b)){if("-"===b.charAt(4)){let a=b.slice(5).replace(K8,Lb);d="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{let a=b.slice(4);if(!K8.test(a)){let c=a.replace(K7,La);"-"!==c.charAt(0)&&(c="-"+c),b="data"+c}}e=K5}return new e(d,b)}(a.schema,b);if(!(null==c||"number"==typeof c&&Number.isNaN(c))){var e;let b;if(Array.isArray(c)&&(c=d.commaSeparated?(b={},(""===(e=c)[e.length-1]?[...e,""]:e).join((b.padRight?" ":"")+","+(!1===b.padLeft?"":" ")).trim()):c.join(" ").trim()),"style"===d.property){let b="object"==typeof c?c:function(a,b){try{return(0,Lq.default)(b,{reactCompat:!0})}catch(c){if(a.ignoreInvalidStyle)return{};let b=new Ly("Cannot parse `style` attribute",{ancestors:a.ancestors,cause:c,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw b.file=a.filePath||void 0,b.url=LE+"#cannot-parse-style-attribute",b}}(a,String(c));return"css"===a.stylePropertyNameCase&&(b=function(a){let b,c={};for(b in a)Lz.call(a,b)&&(c[function(a){let b=a.replace(LB,LL);return"ms-"===b.slice(0,3)&&(b="-"+b),b}(b)]=a[b]);return c}(b)),["style",b]}return["react"===a.elementAttributeNameCase&&d.space?Lc[d.property]||d.property:d.attribute,c]}}(a,d,b.properties[d]);if(f){let[d,g]=f;a.tableCellAlignToStyle&&"align"===d&&"string"==typeof g&&LD.has(b.tagName)?c=g:e[d]=g}}return c&&((e.style||(e.style={}))["css"===a.stylePropertyNameCase?"text-align":"textAlign"]=c),e}(d,e),r=LI(d,e),LC.has(e.tagName)&&(r=r.filter(function(a){return"string"!=typeof a||!("object"==typeof a?"text"===a.type&&KU(a.value):KU(a))})),LG(d,q,p,e),LH(q,r),d.ancestors.pop(),d.schema=n,d.create(e,p,q,f)):"mdxFlowExpression"===b.type||"mdxTextExpression"===b.type?function(a,b){if(b.data&&b.data.estree&&a.evaluater){let c=b.data.estree.body[0];return KN("ExpressionStatement"===c.type),a.evaluater.evaluateExpression(c.expression)}LK(a,b.position)}(a,b):"mdxJsxFlowElement"===b.type||"mdxJsxTextElement"===b.type?(g=a,h=b,i=c,t=s=g.schema,"svg"===h.name&&"html"===s.space&&(g.schema=Lp),g.ancestors.push(h),u=null===h.name?g.Fragment:LJ(g,h.name,!0),v=function(a,b){let c={};for(let d of b.attributes)if("mdxJsxExpressionAttribute"===d.type)if(d.data&&d.data.estree&&a.evaluater){let b=d.data.estree.body[0];KN("ExpressionStatement"===b.type);let e=b.expression;KN("ObjectExpression"===e.type);let f=e.properties[0];KN("SpreadElement"===f.type),Object.assign(c,a.evaluater.evaluateExpression(f.argument))}else LK(a,b.position);else{let e,f=d.name;if(d.value&&"object"==typeof d.value)if(d.value.data&&d.value.data.estree&&a.evaluater){let b=d.value.data.estree.body[0];KN("ExpressionStatement"===b.type),e=a.evaluater.evaluateExpression(b.expression)}else LK(a,b.position);else e=null===d.value||d.value;c[f]=e}return c}(g,h),w=LI(g,h),LG(g,v,u,h),LH(v,w),g.ancestors.pop(),g.schema=s,g.create(h,u,v,i)):"mdxjsEsm"===b.type?function(a,b){if(b.data&&b.data.estree&&a.evaluater)return a.evaluater.evaluateProgram(b.data.estree);LK(a,b.position)}(a,b):"root"===b.type?(j=a,k=b,l=c,LH(x={},LI(j,k)),j.create(k,j.Fragment,x,l)):"text"===b.type?b.value:void 0}function LG(a,b,c,d){"string"!=typeof c&&c!==a.Fragment&&a.passNode&&(b.node=d)}function LH(a,b){if(b.length>0){let c=b.length>1?b:b[0];c&&(a.children=c)}}function LI(a,b){let c=[],d=-1,e=a.passKeys?new Map:LA;for(;++d<b.children.length;){let f,g=b.children[d];if(a.passKeys){let a="element"===g.type?g.tagName:"mdxJsxFlowElement"===g.type||"mdxJsxTextElement"===g.type?g.name:void 0;if(a){let b=e.get(a)||0;f=a+"-"+b,e.set(a,b+1)}}let h=LF(a,g,f);void 0!==h&&c.push(h)}return c}function LJ(a,b,c){let d;if(c)if(b.includes(".")){let a,c=b.split("."),e=-1;for(;++e<c.length;){let b=KS(c[e])?{type:"Identifier",name:c[e]}:{type:"Literal",value:c[e]};a=a?{type:"MemberExpression",object:a,property:b,computed:!!(e&&"Literal"===b.type),optional:!1}:b}KN(a,"always a result"),d=a}else d=KS(b)&&!/^[a-z]/.test(b)?{type:"Identifier",name:b}:{type:"Literal",value:b};else d={type:"Literal",value:b};if("Literal"===d.type){let b=d.value;return Lz.call(a.components,b)?a.components[b]:b}if(a.evaluater)return a.evaluater.evaluateExpression(d);LK(a)}function LK(a,b){let c=new Ly("Cannot handle MDX estrees without `createEvaluater`",{ancestors:a.ancestors,place:b,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw c.file=a.filePath||void 0,c.url=LE+"#cannot-handle-mdx-estrees-without-createevaluater",c}function LL(a){return"-"+a.toLowerCase()}let LM={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},LN={};function LO(a,b){let c=b||LN;return LP(a,"boolean"!=typeof c.includeImageAlt||c.includeImageAlt,"boolean"!=typeof c.includeHtml||c.includeHtml)}function LP(a,b,c){var d;if((d=a)&&"object"==typeof d){if("value"in a)return"html"!==a.type||c?a.value:"";if(b&&"alt"in a&&a.alt)return a.alt;if("children"in a)return LQ(a.children,b,c)}return Array.isArray(a)?LQ(a,b,c):""}function LQ(a,b,c){let d=[],e=-1;for(;++e<a.length;)d[e]=LP(a[e],b,c);return d.join("")}function LR(a,b,c,d){let e,f=a.length,g=0;if(b=b<0?-b>f?0:f+b:b>f?f:b,c=c>0?c:0,d.length<1e4)(e=Array.from(d)).unshift(b,c),a.splice(...e);else for(c&&a.splice(b,c);g<d.length;)(e=d.slice(g,g+1e4)).unshift(b,0),a.splice(...e),g+=1e4,b+=1e4}function LS(a,b){return a.length>0?(LR(a,a.length,0,b),a):b}let LT={}.hasOwnProperty;function LU(a){let b={},c=-1;for(;++c<a.length;)!function(a,b){let c;for(c in b){let d,e=(LT.call(a,c)?a[c]:void 0)||(a[c]={}),f=b[c];if(f)for(d in f){LT.call(e,d)||(e[d]=[]);let a=f[d];!function(a,b){let c=-1,d=[];for(;++c<b.length;)("after"===b[c].add?a:d).push(b[c]);LR(a,0,0,d)}(e[d],Array.isArray(a)?a:a?[a]:[])}}}(b,a[c]);return b}function LV(a){return null!==a&&a<-2}function LW(a){return -2===a||-1===a||32===a}function LX(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function LY(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return LW(d)?(a.enter(c),function d(g){return LW(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}LX(/[A-Za-z]/),LX(/[\dA-Za-z]/),LX(/[#-'*+\--9=?A-Z^-~]/),LX(/\d/),LX(/[\dA-Fa-f]/),LX(/[!-/:-@[-`{-~]/),LX(/\p{P}|\p{S}/u),LX(/\s/);let LZ={tokenize:function(a){let b,c=a.attempt(this.parser.constructs.contentInitial,function(b){return null===b?void a.consume(b):(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),LY(a,c,"linePrefix"))},function(c){return a.enter("paragraph"),function c(d){let e=a.enter("chunkText",{contentType:"text",previous:b});return b&&(b.next=e),b=e,function b(d){if(null===d){a.exit("chunkText"),a.exit("paragraph"),a.consume(d);return}return LV(d)?(a.consume(d),a.exit("chunkText"),c):(a.consume(d),b)}(d)}(c)});return c}},L$={tokenize:function(a){let b,c,d,e=this,f=[],g=0;return h;function h(b){if(g<f.length){let c=f[g];return e.containerState=c[1],a.attempt(c[0].continuation,i,j)(b)}return j(b)}function i(a){if(g++,e.containerState._closeFlow){let c;e.containerState._closeFlow=void 0,b&&s();let d=e.events.length,f=d;for(;f--;)if("exit"===e.events[f][0]&&"chunkFlow"===e.events[f][1].type){c=e.events[f][1].end;break}r(g);let h=d;for(;h<e.events.length;)e.events[h][1].end={...c},h++;return LR(e.events,f+1,0,e.events.slice(d)),e.events.length=h,j(a)}return h(a)}function j(c){if(g===f.length){if(!b)return n(c);if(b.currentConstruct&&b.currentConstruct.concrete)return p(c);e.interrupt=!!(b.currentConstruct&&!b._gfmTableDynamicInterruptHack)}return e.containerState={},a.check(L_,k,l)(c)}function k(a){return b&&s(),r(g),n(a)}function l(a){return e.parser.lazy[e.now().line]=g!==f.length,d=e.now().offset,p(a)}function n(b){return e.containerState={},a.attempt(L_,o,p)(b)}function o(a){return g++,f.push([e.currentConstruct,e.containerState]),n(a)}function p(d){if(null===d){b&&s(),r(0),a.consume(d);return}return b=b||e.parser.flow(e.now()),a.enter("chunkFlow",{_tokenizer:b,contentType:"flow",previous:c}),function b(c){if(null===c){q(a.exit("chunkFlow"),!0),r(0),a.consume(c);return}return LV(c)?(a.consume(c),q(a.exit("chunkFlow")),g=0,e.interrupt=void 0,h):(a.consume(c),b)}(d)}function q(a,f){let h=e.sliceStream(a);if(f&&h.push(null),a.previous=c,c&&(c.next=a),c=a,b.defineSkip(a.start),b.write(h),e.parser.lazy[a.start.line]){let a,c,f=b.events.length;for(;f--;)if(b.events[f][1].start.offset<d&&(!b.events[f][1].end||b.events[f][1].end.offset>d))return;let h=e.events.length,i=h;for(;i--;)if("exit"===e.events[i][0]&&"chunkFlow"===e.events[i][1].type){if(a){c=e.events[i][1].end;break}a=!0}for(r(g),f=h;f<e.events.length;)e.events[f][1].end={...c},f++;LR(e.events,i+1,0,e.events.slice(h)),e.events.length=f}}function r(b){let c=f.length;for(;c-- >b;){let b=f[c];e.containerState=b[1],b[0].exit.call(e,a)}f.length=b}function s(){b.write([null]),c=void 0,b=void 0,e.containerState._closeFlow=void 0}}},L_={tokenize:function(a,b,c){return LY(a,a.attempt(this.parser.constructs.document,b,c),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},L0=L9(/[A-Za-z]/),L1=L9(/[\dA-Za-z]/),L2=L9(/[#-'*+\--9=?A-Z^-~]/),L3=L9(/\d/),L4=L9(/[\dA-Fa-f]/),L5=L9(/[!-/:-@[-`{-~]/);function L6(a){return null!==a&&a<-2}function L7(a){return null!==a&&(a<0||32===a)}function L8(a){return -2===a||-1===a||32===a}function L9(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function Ma(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return L8(d)?(a.enter(c),function d(g){return L8(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}L9(/\p{P}|\p{S}/u),L9(/\s/);let Mb={partial:!0,tokenize:function(a,b,c){return function(b){return L8(b)?Ma(a,d,"linePrefix")(b):d(b)};function d(a){return null===a||L6(a)?b(a):c(a)}}};class Mc{constructor(a){this.left=a?[...a]:[],this.right=[]}get(a){if(a<0||a>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+a+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return a<this.left.length?this.left[a]:this.right[this.right.length-a+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(a,b){let c=null==b?1/0:b;return c<this.left.length?this.left.slice(a,c):a>this.left.length?this.right.slice(this.right.length-c+this.left.length,this.right.length-a+this.left.length).reverse():this.left.slice(a).concat(this.right.slice(this.right.length-c+this.left.length).reverse())}splice(a,b,c){this.setCursor(Math.trunc(a));let d=this.right.splice(this.right.length-(b||0),1/0);return c&&Md(this.left,c),d.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(a){this.setCursor(1/0),this.left.push(a)}pushMany(a){this.setCursor(1/0),Md(this.left,a)}unshift(a){this.setCursor(0),this.right.push(a)}unshiftMany(a){this.setCursor(0),Md(this.right,a.reverse())}setCursor(a){if(a!==this.left.length&&(!(a>this.left.length)||0!==this.right.length)&&(!(a<0)||0!==this.left.length))if(a<this.left.length){let b=this.left.splice(a,1/0);Md(this.right,b.reverse())}else{let b=this.right.splice(this.left.length+this.right.length-a,1/0);Md(this.left,b.reverse())}}}function Md(a,b){let c=0;if(b.length<1e4)a.push(...b);else for(;c<b.length;)a.push(...b.slice(c,c+1e4)),c+=1e4}function Me(a){let b,c,d,e,f,g,h,i={},j=-1,k=new Mc(a);for(;++j<k.length;){for(;j in i;)j=i[j];if(b=k.get(j),j&&"chunkFlow"===b[1].type&&"listItemPrefix"===k.get(j-1)[1].type&&((d=0)<(g=b[1]._tokenizer.events).length&&"lineEndingBlank"===g[d][1].type&&(d+=2),d<g.length&&"content"===g[d][1].type))for(;++d<g.length&&"content"!==g[d][1].type;)"chunkText"===g[d][1].type&&(g[d][1]._isInFirstContentOfListItem=!0,d++);if("enter"===b[0])b[1].contentType&&(Object.assign(i,function(a,b){let c,d,e=a.get(b)[1],f=a.get(b)[2],g=b-1,h=[],i=e._tokenizer;!i&&(i=f.parser[e.contentType](e.start),e._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));let j=i.events,k=[],l={},n=-1,o=e,p=0,q=0,r=[0];for(;o;){for(;a.get(++g)[1]!==o;);h.push(g),!o._tokenizer&&(c=f.sliceStream(o),o.next||c.push(null),d&&i.defineSkip(o.start),o._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(c),o._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=o,o=o.next}for(o=e;++n<j.length;)"exit"===j[n][0]&&"enter"===j[n-1][0]&&j[n][1].type===j[n-1][1].type&&j[n][1].start.line!==j[n][1].end.line&&(q=n+1,r.push(q),o._tokenizer=void 0,o.previous=void 0,o=o.next);for(i.events=[],o?(o._tokenizer=void 0,o.previous=void 0):r.pop(),n=r.length;n--;){let b=j.slice(r[n],r[n+1]),c=h.pop();k.push([c,c+b.length-1]),a.splice(c,2,b)}for(k.reverse(),n=-1;++n<k.length;)l[p+k[n][0]]=p+k[n][1],p+=k[n][1]-k[n][0]-1;return l}(k,j)),j=i[j],h=!0);else if(b[1]._container){for(d=j,c=void 0;d--;)if("lineEnding"===(e=k.get(d))[1].type||"lineEndingBlank"===e[1].type)"enter"===e[0]&&(c&&(k.get(c)[1].type="lineEndingBlank"),e[1].type="lineEnding",c=d);else if("linePrefix"===e[1].type||"listItemIndent"===e[1].type);else break;c&&(b[1].end={...k.get(c)[1].start},(f=k.slice(c,j)).unshift(b),k.splice(c,j-c+1,f))}}return LR(a,0,1/0,k.slice(0)),!h}let Mf={resolve:function(a){return Me(a),a},tokenize:function(a,b){let c;return function(b){return a.enter("content"),c=a.enter("chunkContent",{contentType:"content"}),d(b)};function d(b){return null===b?e(b):L6(b)?a.check(Mg,f,e)(b):(a.consume(b),d)}function e(c){return a.exit("chunkContent"),a.exit("content"),b(c)}function f(b){return a.consume(b),a.exit("chunkContent"),c.next=a.enter("chunkContent",{contentType:"content",previous:c}),c=c.next,d}}},Mg={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return a.exit("chunkContent"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),Ma(a,e,"linePrefix")};function e(e){if(null===e||L6(e))return c(e);let f=d.events[d.events.length-1];return!d.parser.constructs.disable.null.includes("codeIndented")&&f&&"linePrefix"===f[1].type&&f[2].sliceSerialize(f[1],!0).length>=4?b(e):a.interrupt(d.parser.constructs.flow,c,b)(e)}}},Mh={tokenize:function(a){let b=this,c=a.attempt(Mb,function(d){return null===d?void a.consume(d):(a.enter("lineEndingBlank"),a.consume(d),a.exit("lineEndingBlank"),b.currentConstruct=void 0,c)},a.attempt(this.parser.constructs.flowInitial,d,LY(a,a.attempt(this.parser.constructs.flow,d,a.attempt(Mf,d)),"linePrefix")));return c;function d(d){return null===d?void a.consume(d):(a.enter("lineEnding"),a.consume(d),a.exit("lineEnding"),b.currentConstruct=void 0,c)}}},Mi={resolveAll:Mm()},Mj=Ml("string"),Mk=Ml("text");function Ml(a){return{resolveAll:Mm("text"===a?Mn:void 0),tokenize:function(b){let c=this,d=this.parser.constructs[a],e=b.attempt(d,f,g);return f;function f(a){return i(a)?e(a):g(a)}function g(a){return null===a?void b.consume(a):(b.enter("data"),b.consume(a),h)}function h(a){return i(a)?(b.exit("data"),e(a)):(b.consume(a),h)}function i(a){if(null===a)return!0;let b=d[a],e=-1;if(b)for(;++e<b.length;){let a=b[e];if(!a.previous||a.previous.call(c,c.previous))return!0}return!1}}}}function Mm(a){return function(b,c){let d,e=-1;for(;++e<=b.length;)void 0===d?b[e]&&"data"===b[e][1].type&&(d=e,e++):b[e]&&"data"===b[e][1].type||(e!==d+2&&(b[d][1].end=b[e-1][1].end,b.splice(d+2,e-d-2),e=d+2),d=void 0);return a?a(b,c):b}}function Mn(a,b){let c=0;for(;++c<=a.length;)if((c===a.length||"lineEnding"===a[c][1].type)&&"data"===a[c-1][1].type){let d,e=a[c-1][1],f=b.sliceStream(e),g=f.length,h=-1,i=0;for(;g--;){let a=f[g];if("string"==typeof a){for(h=a.length;32===a.charCodeAt(h-1);)i++,h--;if(h)break;h=-1}else if(-2===a)d=!0,i++;else if(-1===a);else{g++;break}}if(b._contentTypeTextTrailing&&c===a.length&&(i=0),i){let f={type:c===a.length||d||i<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:g?h:e.start._bufferIndex+h,_index:e.start._index+g,line:e.end.line,column:e.end.column-i,offset:e.end.offset-i},end:{...e.end}};e.end={...f.start},e.start.offset===e.end.offset?Object.assign(e,f):(a.splice(c,0,["enter",f,b],["exit",f,b]),c+=2)}c++}return a}Mq(/[A-Za-z]/),Mq(/[\dA-Za-z]/),Mq(/[#-'*+\--9=?A-Z^-~]/),Mq(/\d/),Mq(/[\dA-Fa-f]/),Mq(/[!-/:-@[-`{-~]/);let Mo=Mq(/\p{P}|\p{S}/u),Mp=Mq(/\s/);function Mq(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function Mr(a){return null===a||null!==a&&(a<0||32===a)||Mp(a)?1:Mo(a)?2:void 0}function Ms(a,b,c){let d=[],e=-1;for(;++e<a.length;){let f=a[e].resolveAll;f&&!d.includes(f)&&(b=f(b,c),d.push(f))}return b}let Mt={name:"attention",resolveAll:function(a,b){let c,d,e,f,g,h,i,j,k=-1;for(;++k<a.length;)if("enter"===a[k][0]&&"attentionSequence"===a[k][1].type&&a[k][1]._close){for(c=k;c--;)if("exit"===a[c][0]&&"attentionSequence"===a[c][1].type&&a[c][1]._open&&b.sliceSerialize(a[c][1]).charCodeAt(0)===b.sliceSerialize(a[k][1]).charCodeAt(0)){if((a[c][1]._close||a[k][1]._open)&&(a[k][1].end.offset-a[k][1].start.offset)%3&&!((a[c][1].end.offset-a[c][1].start.offset+a[k][1].end.offset-a[k][1].start.offset)%3))continue;h=a[c][1].end.offset-a[c][1].start.offset>1&&a[k][1].end.offset-a[k][1].start.offset>1?2:1;let l={...a[c][1].end},n={...a[k][1].start};Mu(l,-h),Mu(n,h),f={type:h>1?"strongSequence":"emphasisSequence",start:l,end:{...a[c][1].end}},g={type:h>1?"strongSequence":"emphasisSequence",start:{...a[k][1].start},end:n},e={type:h>1?"strongText":"emphasisText",start:{...a[c][1].end},end:{...a[k][1].start}},d={type:h>1?"strong":"emphasis",start:{...f.start},end:{...g.end}},a[c][1].end={...f.start},a[k][1].start={...g.end},i=[],a[c][1].end.offset-a[c][1].start.offset&&(i=LS(i,[["enter",a[c][1],b],["exit",a[c][1],b]])),i=LS(i,[["enter",d,b],["enter",f,b],["exit",f,b],["enter",e,b]]),i=LS(i,Ms(b.parser.constructs.insideSpan.null,a.slice(c+1,k),b)),i=LS(i,[["exit",e,b],["enter",g,b],["exit",g,b],["exit",d,b]]),a[k][1].end.offset-a[k][1].start.offset?(j=2,i=LS(i,[["enter",a[k][1],b],["exit",a[k][1],b]])):j=0,LR(a,c-1,k-c+3,i),k=c+i.length-j-2;break}}for(k=-1;++k<a.length;)"attentionSequence"===a[k][1].type&&(a[k][1].type="data");return a},tokenize:function(a,b){let c,d=this.parser.constructs.attentionMarkers.null,e=this.previous,f=Mr(e);return function(g){return c=g,a.enter("attentionSequence"),function g(h){if(h===c)return a.consume(h),g;let i=a.exit("attentionSequence"),j=Mr(h),k=!j||2===j&&f||d.includes(h),l=!f||2===f&&j||d.includes(e);return i._open=!!(42===c?k:k&&(f||!l)),i._close=!!(42===c?l:l&&(j||!k)),b(h)}(g)}}};function Mu(a,b){a.column+=b,a.offset+=b,a._bufferIndex+=b}let Mv={continuation:{tokenize:function(a,b,c){let d=this;return function(b){return L8(b)?Ma(a,e,"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):e(b)};function e(d){return a.attempt(Mv,b,c)(d)}}},exit:function(a){a.exit("blockQuote")},name:"blockQuote",tokenize:function(a,b,c){let d=this;return function(b){if(62===b){let c=d.containerState;return c.open||(a.enter("blockQuote",{_container:!0}),c.open=!0),a.enter("blockQuotePrefix"),a.enter("blockQuoteMarker"),a.consume(b),a.exit("blockQuoteMarker"),e}return c(b)};function e(c){return L8(c)?(a.enter("blockQuotePrefixWhitespace"),a.consume(c),a.exit("blockQuotePrefixWhitespace"),a.exit("blockQuotePrefix"),b):(a.exit("blockQuotePrefix"),b(c))}}},Mw={name:"characterEscape",tokenize:function(a,b,c){return function(b){return a.enter("characterEscape"),a.enter("escapeMarker"),a.consume(b),a.exit("escapeMarker"),d};function d(d){return L5(d)?(a.enter("characterEscapeValue"),a.consume(d),a.exit("characterEscapeValue"),a.exit("characterEscape"),b):c(d)}}},Mx={AElig:"Æ",AMP:"&",Aacute:"Á",Abreve:"Ă",Acirc:"Â",Acy:"А",Afr:"𝔄",Agrave:"À",Alpha:"Α",Amacr:"Ā",And:"⩓",Aogon:"Ą",Aopf:"𝔸",ApplyFunction:"",Aring:"Å",Ascr:"𝒜",Assign:"≔",Atilde:"Ã",Auml:"Ä",Backslash:"∖",Barv:"⫧",Barwed:"⌆",Bcy:"Б",Because:"∵",Bernoullis:"ℬ",Beta:"Β",Bfr:"𝔅",Bopf:"𝔹",Breve:"˘",Bscr:"ℬ",Bumpeq:"≎",CHcy:"Ч",COPY:"©",Cacute:"Ć",Cap:"⋒",CapitalDifferentialD:"ⅅ",Cayleys:"ℭ",Ccaron:"Č",Ccedil:"Ç",Ccirc:"Ĉ",Cconint:"∰",Cdot:"Ċ",Cedilla:"¸",CenterDot:"·",Cfr:"ℭ",Chi:"Χ",CircleDot:"⊙",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",Colon:"∷",Colone:"⩴",Congruent:"≡",Conint:"∯",ContourIntegral:"∮",Copf:"ℂ",Coproduct:"∐",CounterClockwiseContourIntegral:"∳",Cross:"⨯",Cscr:"𝒞",Cup:"⋓",CupCap:"≍",DD:"ⅅ",DDotrahd:"⤑",DJcy:"Ђ",DScy:"Ѕ",DZcy:"Џ",Dagger:"‡",Darr:"↡",Dashv:"⫤",Dcaron:"Ď",Dcy:"Д",Del:"∇",Delta:"Δ",Dfr:"𝔇",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",Diamond:"⋄",DifferentialD:"ⅆ",Dopf:"𝔻",Dot:"¨",DotDot:"⃜",DotEqual:"≐",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",Downarrow:"⇓",Dscr:"𝒟",Dstrok:"Đ",ENG:"Ŋ",ETH:"Ð",Eacute:"É",Ecaron:"Ě",Ecirc:"Ê",Ecy:"Э",Edot:"Ė",Efr:"𝔈",Egrave:"È",Element:"∈",Emacr:"Ē",EmptySmallSquare:"◻",EmptyVerySmallSquare:"▫",Eogon:"Ę",Eopf:"𝔼",Epsilon:"Ε",Equal:"⩵",EqualTilde:"≂",Equilibrium:"⇌",Escr:"ℰ",Esim:"⩳",Eta:"Η",Euml:"Ë",Exists:"∃",ExponentialE:"ⅇ",Fcy:"Ф",Ffr:"𝔉",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",Fopf:"𝔽",ForAll:"∀",Fouriertrf:"ℱ",Fscr:"ℱ",GJcy:"Ѓ",GT:">",Gamma:"Γ",Gammad:"Ϝ",Gbreve:"Ğ",Gcedil:"Ģ",Gcirc:"Ĝ",Gcy:"Г",Gdot:"Ġ",Gfr:"𝔊",Gg:"⋙",Gopf:"𝔾",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",Gt:"≫",HARDcy:"Ъ",Hacek:"ˇ",Hat:"^",Hcirc:"Ĥ",Hfr:"ℌ",HilbertSpace:"ℋ",Hopf:"ℍ",HorizontalLine:"─",Hscr:"ℋ",Hstrok:"Ħ",HumpDownHump:"≎",HumpEqual:"≏",IEcy:"Е",IJlig:"IJ",IOcy:"Ё",Iacute:"Í",Icirc:"Î",Icy:"И",Idot:"İ",Ifr:"ℑ",Igrave:"Ì",Im:"ℑ",Imacr:"Ī",ImaginaryI:"ⅈ",Implies:"⇒",Int:"∬",Integral:"∫",Intersection:"⋂",InvisibleComma:"",InvisibleTimes:"",Iogon:"Į",Iopf:"𝕀",Iota:"Ι",Iscr:"ℐ",Itilde:"Ĩ",Iukcy:"І",Iuml:"Ï",Jcirc:"Ĵ",Jcy:"Й",Jfr:"𝔍",Jopf:"𝕁",Jscr:"𝒥",Jsercy:"Ј",Jukcy:"Є",KHcy:"Х",KJcy:"Ќ",Kappa:"Κ",Kcedil:"Ķ",Kcy:"К",Kfr:"𝔎",Kopf:"𝕂",Kscr:"𝒦",LJcy:"Љ",LT:"<",Lacute:"Ĺ",Lambda:"Λ",Lang:"⟪",Laplacetrf:"ℒ",Larr:"↞",Lcaron:"Ľ",Lcedil:"Ļ",Lcy:"Л",LeftAngleBracket:"⟨",LeftArrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",LeftRightArrow:"↔",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",Leftarrow:"⇐",Leftrightarrow:"⇔",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",LessLess:"⪡",LessSlantEqual:"⩽",LessTilde:"≲",Lfr:"𝔏",Ll:"⋘",Lleftarrow:"⇚",Lmidot:"Ŀ",LongLeftArrow:"⟵",LongLeftRightArrow:"⟷",LongRightArrow:"⟶",Longleftarrow:"⟸",Longleftrightarrow:"⟺",Longrightarrow:"⟹",Lopf:"𝕃",LowerLeftArrow:"↙",LowerRightArrow:"↘",Lscr:"ℒ",Lsh:"↰",Lstrok:"Ł",Lt:"≪",Map:"⤅",Mcy:"М",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",MinusPlus:"∓",Mopf:"𝕄",Mscr:"ℳ",Mu:"Μ",NJcy:"Њ",Nacute:"Ń",Ncaron:"Ň",Ncedil:"Ņ",Ncy:"Н",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",Nfr:"𝔑",NoBreak:"",NonBreakingSpace:" ",Nopf:"ℕ",Not:"⫬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",Nscr:"𝒩",Ntilde:"Ñ",Nu:"Ν",OElig:"Œ",Oacute:"Ó",Ocirc:"Ô",Ocy:"О",Odblac:"Ő",Ofr:"𝔒",Ograve:"Ò",Omacr:"Ō",Omega:"Ω",Omicron:"Ο",Oopf:"𝕆",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",Or:"⩔",Oscr:"𝒪",Oslash:"Ø",Otilde:"Õ",Otimes:"⨷",Ouml:"Ö",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",PartialD:"∂",Pcy:"П",Pfr:"𝔓",Phi:"Φ",Pi:"Π",PlusMinus:"±",Poincareplane:"ℌ",Popf:"ℙ",Pr:"⪻",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",Prime:"″",Product:"∏",Proportion:"∷",Proportional:"∝",Pscr:"𝒫",Psi:"Ψ",QUOT:'"',Qfr:"𝔔",Qopf:"ℚ",Qscr:"𝒬",RBarr:"⤐",REG:"®",Racute:"Ŕ",Rang:"⟫",Rarr:"↠",Rarrtl:"⤖",Rcaron:"Ř",Rcedil:"Ŗ",Rcy:"Р",Re:"ℜ",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",Rfr:"ℜ",Rho:"Ρ",RightAngleBracket:"⟩",RightArrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",Rightarrow:"⇒",Ropf:"ℝ",RoundImplies:"⥰",Rrightarrow:"⇛",Rscr:"ℛ",Rsh:"↱",RuleDelayed:"⧴",SHCHcy:"Щ",SHcy:"Ш",SOFTcy:"Ь",Sacute:"Ś",Sc:"⪼",Scaron:"Š",Scedil:"Ş",Scirc:"Ŝ",Scy:"С",Sfr:"𝔖",ShortDownArrow:"↓",ShortLeftArrow:"←",ShortRightArrow:"→",ShortUpArrow:"↑",Sigma:"Σ",SmallCircle:"∘",Sopf:"𝕊",Sqrt:"√",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",Sscr:"𝒮",Star:"⋆",Sub:"⋐",Subset:"⋐",SubsetEqual:"⊆",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",SuchThat:"∋",Sum:"∑",Sup:"⋑",Superset:"⊃",SupersetEqual:"⊇",Supset:"⋑",THORN:"Þ",TRADE:"™",TSHcy:"Ћ",TScy:"Ц",Tab:" ",Tau:"Τ",Tcaron:"Ť",Tcedil:"Ţ",Tcy:"Т",Tfr:"𝔗",Therefore:"∴",Theta:"Θ",ThickSpace:" ",ThinSpace:" ",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",Topf:"𝕋",TripleDot:"⃛",Tscr:"𝒯",Tstrok:"Ŧ",Uacute:"Ú",Uarr:"↟",Uarrocir:"⥉",Ubrcy:"Ў",Ubreve:"Ŭ",Ucirc:"Û",Ucy:"У",Udblac:"Ű",Ufr:"𝔘",Ugrave:"Ù",Umacr:"Ū",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",Uopf:"𝕌",UpArrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",UpEquilibrium:"⥮",UpTee:"⊥",UpTeeArrow:"↥",Uparrow:"⇑",Updownarrow:"⇕",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",Upsilon:"Υ",Uring:"Ů",Uscr:"𝒰",Utilde:"Ũ",Uuml:"Ü",VDash:"⊫",Vbar:"⫫",Vcy:"В",Vdash:"⊩",Vdashl:"⫦",Vee:"⋁",Verbar:"‖",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",Vopf:"𝕍",Vscr:"𝒱",Vvdash:"⊪",Wcirc:"Ŵ",Wedge:"⋀",Wfr:"𝔚",Wopf:"𝕎",Wscr:"𝒲",Xfr:"𝔛",Xi:"Ξ",Xopf:"𝕏",Xscr:"𝒳",YAcy:"Я",YIcy:"Ї",YUcy:"Ю",Yacute:"Ý",Ycirc:"Ŷ",Ycy:"Ы",Yfr:"𝔜",Yopf:"𝕐",Yscr:"𝒴",Yuml:"Ÿ",ZHcy:"Ж",Zacute:"Ź",Zcaron:"Ž",Zcy:"З",Zdot:"Ż",ZeroWidthSpace:"",Zeta:"Ζ",Zfr:"ℨ",Zopf:"ℤ",Zscr:"𝒵",aacute:"á",abreve:"ă",ac:"∾",acE:"∾̳",acd:"∿",acirc:"â",acute:"´",acy:"а",aelig:"æ",af:"",afr:"𝔞",agrave:"à",alefsym:"ℵ",aleph:"ℵ",alpha:"α",amacr:"ā",amalg:"⨿",amp:"&",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",aogon:"ą",aopf:"𝕒",ap:"≈",apE:"⩰",apacir:"⩯",ape:"≊",apid:"≋",apos:"'",approx:"≈",approxeq:"≊",aring:"å",ascr:"𝒶",ast:"*",asymp:"≈",asympeq:"≍",atilde:"ã",auml:"ä",awconint:"∳",awint:"⨑",bNot:"⫭",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",barvee:"⊽",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",beta:"β",beth:"ℶ",between:"≬",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bnot:"⌐",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxDL:"╗",boxDR:"╔",boxDl:"╖",boxDr:"╓",boxH:"═",boxHD:"╦",boxHU:"╩",boxHd:"╤",boxHu:"╧",boxUL:"╝",boxUR:"╚",boxUl:"╜",boxUr:"╙",boxV:"║",boxVH:"╬",boxVL:"╣",boxVR:"╠",boxVh:"╫",boxVl:"╢",boxVr:"╟",boxbox:"⧉",boxdL:"╕",boxdR:"╒",boxdl:"┐",boxdr:"┌",boxh:"─",boxhD:"╥",boxhU:"╨",boxhd:"┬",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxuL:"╛",boxuR:"╘",boxul:"┘",boxur:"└",boxv:"│",boxvH:"╪",boxvL:"╡",boxvR:"╞",boxvh:"┼",boxvl:"┤",boxvr:"├",bprime:"‵",breve:"˘",brvbar:"¦",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",bumpeq:"≏",cacute:"ć",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",caps:"∩︀",caret:"⁁",caron:"ˇ",ccaps:"⩍",ccaron:"č",ccedil:"ç",ccirc:"ĉ",ccups:"⩌",ccupssm:"⩐",cdot:"ċ",cedil:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",cfr:"𝔠",chcy:"ч",check:"✓",checkmark:"✓",chi:"χ",cir:"○",cirE:"⧃",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledR:"®",circledS:"Ⓢ",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",clubs:"♣",clubsuit:"♣",colon:":",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",conint:"∮",copf:"𝕔",coprod:"∐",copy:"©",copysr:"℗",crarr:"↵",cross:"✗",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cup:"∪",cupbrcap:"⩈",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dArr:"⇓",dHar:"⥥",dagger:"†",daleth:"ℸ",darr:"↓",dash:"‐",dashv:"⊣",dbkarow:"⤏",dblac:"˝",dcaron:"ď",dcy:"д",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",ddotseq:"⩷",deg:"°",delta:"δ",demptyv:"⦱",dfisht:"⥿",dfr:"𝔡",dharl:"⇃",dharr:"⇂",diam:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",dopf:"𝕕",dot:"˙",doteq:"≐",doteqdot:"≑",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",downarrow:"↓",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",dscr:"𝒹",dscy:"ѕ",dsol:"⧶",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",dzcy:"џ",dzigrarr:"⟿",eDDot:"⩷",eDot:"≑",eacute:"é",easter:"⩮",ecaron:"ě",ecir:"≖",ecirc:"ê",ecolon:"≕",ecy:"э",edot:"ė",ee:"ⅇ",efDot:"≒",efr:"𝔢",eg:"⪚",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",emacr:"ē",empty:"∅",emptyset:"∅",emptyv:"∅",emsp13:" ",emsp14:" ",emsp:" ",eng:"ŋ",ensp:" ",eogon:"ę",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",equals:"=",equest:"≟",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erDot:"≓",erarr:"⥱",escr:"ℯ",esdot:"≐",esim:"≂",eta:"η",eth:"ð",euml:"ë",euro:"€",excl:"!",exist:"∃",expectation:"ℰ",exponentiale:"ⅇ",fallingdotseq:"≒",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",ffr:"𝔣",filig:"fi",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",fopf:"𝕗",forall:"∀",fork:"⋔",forkv:"⫙",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",gE:"≧",gEl:"⪌",gacute:"ǵ",gamma:"γ",gammad:"ϝ",gap:"⪆",gbreve:"ğ",gcirc:"ĝ",gcy:"г",gdot:"ġ",ge:"≥",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",gfr:"𝔤",gg:"≫",ggg:"⋙",gimel:"ℷ",gjcy:"ѓ",gl:"≷",glE:"⪒",gla:"⪥",glj:"⪤",gnE:"≩",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",gopf:"𝕘",grave:"`",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",hArr:"⇔",hairsp:" ",half:"½",hamilt:"ℋ",hardcy:"ъ",harr:"↔",harrcir:"⥈",harrw:"↭",hbar:"ℏ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",horbar:"―",hscr:"𝒽",hslash:"ℏ",hstrok:"ħ",hybull:"⁃",hyphen:"‐",iacute:"í",ic:"",icirc:"î",icy:"и",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",ijlig:"ij",imacr:"ī",image:"ℑ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",int:"∫",intcal:"⊺",integers:"ℤ",intercal:"⊺",intlarhk:"⨗",intprod:"⨼",iocy:"ё",iogon:"į",iopf:"𝕚",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",isin:"∈",isinE:"⋹",isindot:"⋵",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",itilde:"ĩ",iukcy:"і",iuml:"ï",jcirc:"ĵ",jcy:"й",jfr:"𝔧",jmath:"ȷ",jopf:"𝕛",jscr:"𝒿",jsercy:"ј",jukcy:"є",kappa:"κ",kappav:"ϰ",kcedil:"ķ",kcy:"к",kfr:"𝔨",kgreen:"ĸ",khcy:"х",kjcy:"ќ",kopf:"𝕜",kscr:"𝓀",lAarr:"⇚",lArr:"⇐",lAtail:"⤛",lBarr:"⤎",lE:"≦",lEg:"⪋",lHar:"⥢",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",lambda:"λ",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",laquo:"«",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",latail:"⤙",late:"⪭",lates:"⪭︀",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",lcaron:"ľ",lcedil:"ļ",lceil:"⌈",lcub:"{",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",leftarrow:"←",leftarrowtail:"↢",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",leftthreetimes:"⋋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",lessgtr:"≶",lesssim:"≲",lfisht:"⥼",lfloor:"⌊",lfr:"𝔩",lg:"≶",lgE:"⪑",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",ljcy:"љ",ll:"≪",llarr:"⇇",llcorner:"⌞",llhard:"⥫",lltri:"◺",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnE:"≨",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",longleftrightarrow:"⟷",longmapsto:"⟼",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",lstrok:"ł",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltrPar:"⦖",ltri:"◃",ltrie:"⊴",ltrif:"◂",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",mDDot:"∺",macr:"¯",male:"♂",malt:"✠",maltese:"✠",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",mcy:"м",mdash:"—",measuredangle:"∡",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",mopf:"𝕞",mp:"∓",mscr:"𝓂",mstpos:"∾",mu:"μ",multimap:"⊸",mumap:"⊸",nGg:"⋙̸",nGt:"≫⃒",nGtv:"≫̸",nLeftarrow:"⇍",nLeftrightarrow:"⇎",nLl:"⋘̸",nLt:"≪⃒",nLtv:"≪̸",nRightarrow:"⇏",nVDash:"⊯",nVdash:"⊮",nabla:"∇",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",ncaron:"ň",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",ncy:"н",ndash:"–",ne:"≠",neArr:"⇗",nearhk:"⤤",nearr:"↗",nearrow:"↗",nedot:"≐̸",nequiv:"≢",nesear:"⤨",nesim:"≂̸",nexist:"∄",nexists:"∄",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",ngsim:"≵",ngt:"≯",ngtr:"≯",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",njcy:"њ",nlArr:"⇍",nlE:"≦̸",nlarr:"↚",nldr:"‥",nle:"≰",nleftarrow:"↚",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nlsim:"≴",nlt:"≮",nltri:"⋪",nltrie:"⋬",nmid:"∤",nopf:"𝕟",not:"¬",notin:"∉",notinE:"⋹̸",notindot:"⋵̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",nu:"ν",num:"#",numero:"№",numsp:" ",nvDash:"⊭",nvHarr:"⤄",nvap:"≍⃒",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwArr:"⇖",nwarhk:"⤣",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",oS:"Ⓢ",oacute:"ó",oast:"⊛",ocir:"⊚",ocirc:"ô",ocy:"о",odash:"⊝",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",oelig:"œ",ofcir:"⦿",ofr:"𝔬",ogon:"˛",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",omacr:"ō",omega:"ω",omicron:"ο",omid:"⦶",ominus:"⊖",oopf:"𝕠",opar:"⦷",operp:"⦹",oplus:"⊕",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oscr:"ℴ",oslash:"ø",osol:"⊘",otilde:"õ",otimes:"⊗",otimesas:"⨶",ouml:"ö",ovbar:"⌽",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",pfr:"𝔭",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",pointint:"⨕",popf:"𝕡",pound:"£",pr:"≺",prE:"⪳",prap:"⪷",prcue:"≼",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",prime:"′",primes:"ℙ",prnE:"⪵",prnap:"⪹",prnsim:"⋨",prod:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",propto:"∝",prsim:"≾",prurel:"⊰",pscr:"𝓅",psi:"ψ",puncsp:" ",qfr:"𝔮",qint:"⨌",qopf:"𝕢",qprime:"⁗",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',rAarr:"⇛",rArr:"⇒",rAtail:"⤜",rBarr:"⤏",rHar:"⥤",race:"∽̱",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",rarrtl:"↣",rarrw:"↝",ratail:"⤚",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",rcaron:"ř",rcedil:"ŗ",rceil:"⌉",rcub:"}",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",reg:"®",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",rhard:"⇁",rharu:"⇀",rharul:"⥬",rho:"ρ",rhov:"ϱ",rightarrow:"→",rightarrowtail:"↣",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",rightthreetimes:"⋌",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",rsaquo:"›",rscr:"𝓇",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",ruluhar:"⥨",rx:"℞",sacute:"ś",sbquo:"‚",sc:"≻",scE:"⪴",scap:"⪸",scaron:"š",sccue:"≽",sce:"⪰",scedil:"ş",scirc:"ŝ",scnE:"⪶",scnap:"⪺",scnsim:"⋩",scpolint:"⨓",scsim:"≿",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",seArr:"⇘",searhk:"⤥",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",sfr:"𝔰",sfrown:"⌢",sharp:"♯",shchcy:"щ",shcy:"ш",shortmid:"∣",shortparallel:"∥",shy:"",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",square:"□",squarf:"▪",squf:"▪",srarr:"→",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",subE:"⫅",subdot:"⪽",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",supE:"⫆",supdot:"⪾",supdsub:"⫘",supe:"⊇",supedot:"⫄",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swArr:"⇙",swarhk:"⤦",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",target:"⌖",tau:"τ",tbrk:"⎴",tcaron:"ť",tcedil:"ţ",tcy:"т",tdot:"⃛",telrec:"⌕",tfr:"𝔱",there4:"∴",therefore:"∴",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",thinsp:" ",thkap:"≈",thksim:"∼",thorn:"þ",tilde:"˜",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",tscr:"𝓉",tscy:"ц",tshcy:"ћ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",uArr:"⇑",uHar:"⥣",uacute:"ú",uarr:"↑",ubrcy:"ў",ubreve:"ŭ",ucirc:"û",ucy:"у",udarr:"⇅",udblac:"ű",udhar:"⥮",ufisht:"⥾",ufr:"𝔲",ugrave:"ù",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",umacr:"ū",uml:"¨",uogon:"ų",uopf:"𝕦",uparrow:"↑",updownarrow:"↕",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",upsi:"υ",upsih:"ϒ",upsilon:"υ",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",uring:"ů",urtri:"◹",uscr:"𝓊",utdot:"⋰",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",uuml:"ü",uwangle:"⦧",vArr:"⇕",vBar:"⫨",vBarv:"⫩",vDash:"⊨",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vcy:"в",vdash:"⊢",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",verbar:"|",vert:"|",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",vopf:"𝕧",vprop:"∝",vrtri:"⊳",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",vzigzag:"⦚",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",wedgeq:"≙",weierp:"℘",wfr:"𝔴",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",yacute:"ý",yacy:"я",ycirc:"ŷ",ycy:"ы",yen:"¥",yfr:"𝔶",yicy:"ї",yopf:"𝕪",yscr:"𝓎",yucy:"ю",yuml:"ÿ",zacute:"ź",zcaron:"ž",zcy:"з",zdot:"ż",zeetrf:"ℨ",zeta:"ζ",zfr:"𝔷",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",zscr:"𝓏",zwj:"",zwnj:""},My={}.hasOwnProperty;function Mz(a){return!!My.call(Mx,a)&&Mx[a]}let MA={name:"characterReference",tokenize:function(a,b,c){let d,e,f=this,g=0;return function(b){return a.enter("characterReference"),a.enter("characterReferenceMarker"),a.consume(b),a.exit("characterReferenceMarker"),h};function h(b){return 35===b?(a.enter("characterReferenceMarkerNumeric"),a.consume(b),a.exit("characterReferenceMarkerNumeric"),i):(a.enter("characterReferenceValue"),d=31,e=L1,j(b))}function i(b){return 88===b||120===b?(a.enter("characterReferenceMarkerHexadecimal"),a.consume(b),a.exit("characterReferenceMarkerHexadecimal"),a.enter("characterReferenceValue"),d=6,e=L4,j):(a.enter("characterReferenceValue"),d=7,e=L3,j(b))}function j(h){if(59===h&&g){let d=a.exit("characterReferenceValue");return e!==L1||Mz(f.sliceSerialize(d))?(a.enter("characterReferenceMarker"),a.consume(h),a.exit("characterReferenceMarker"),a.exit("characterReference"),b):c(h)}return e(h)&&g++<d?(a.consume(h),j):c(h)}}},MB={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return null===b?c(b):(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e)};function e(a){return d.parser.lazy[d.now().line]?c(a):b(a)}}},MC={concrete:!0,name:"codeFenced",tokenize:function(a,b,c){let d,e=this,f={partial:!0,tokenize:function(a,b,c){let f=0;return function(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),g};function g(b){return a.enter("codeFencedFence"),L8(b)?Ma(a,i,"linePrefix",e.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):i(b)}function i(b){return b===d?(a.enter("codeFencedFenceSequence"),function b(e){return e===d?(f++,a.consume(e),b):f>=h?(a.exit("codeFencedFenceSequence"),L8(e)?Ma(a,j,"whitespace")(e):j(e)):c(e)}(b)):c(b)}function j(d){return null===d||L6(d)?(a.exit("codeFencedFence"),b(d)):c(d)}}},g=0,h=0;return function(b){var f;let j;return f=b,g=(j=e.events[e.events.length-1])&&"linePrefix"===j[1].type?j[2].sliceSerialize(j[1],!0).length:0,d=f,a.enter("codeFenced"),a.enter("codeFencedFence"),a.enter("codeFencedFenceSequence"),function b(e){return e===d?(h++,a.consume(e),b):h<3?c(e):(a.exit("codeFencedFenceSequence"),L8(e)?Ma(a,i,"whitespace")(e):i(e))}(f)};function i(f){return null===f||L6(f)?(a.exit("codeFencedFence"),e.interrupt?b(f):a.check(MB,k,p)(f)):(a.enter("codeFencedFenceInfo"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||L6(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),i(e)):L8(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),Ma(a,j,"whitespace")(e)):96===e&&e===d?c(e):(a.consume(e),b)}(f))}function j(b){return null===b||L6(b)?i(b):(a.enter("codeFencedFenceMeta"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||L6(e)?(a.exit("chunkString"),a.exit("codeFencedFenceMeta"),i(e)):96===e&&e===d?c(e):(a.consume(e),b)}(b))}function k(b){return a.attempt(f,p,l)(b)}function l(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),n}function n(b){return g>0&&L8(b)?Ma(a,o,"linePrefix",g+1)(b):o(b)}function o(b){return null===b||L6(b)?a.check(MB,k,p)(b):(a.enter("codeFlowValue"),function b(c){return null===c||L6(c)?(a.exit("codeFlowValue"),o(c)):(a.consume(c),b)}(b))}function p(c){return a.exit("codeFenced"),b(c)}}},MD={name:"codeIndented",tokenize:function(a,b,c){let d=this;return function(b){return a.enter("codeIndented"),Ma(a,e,"linePrefix",5)(b)};function e(b){let e=d.events[d.events.length-1];return e&&"linePrefix"===e[1].type&&e[2].sliceSerialize(e[1],!0).length>=4?function b(c){return null===c?f(c):L6(c)?a.attempt(ME,b,f)(c):(a.enter("codeFlowValue"),function c(d){return null===d||L6(d)?(a.exit("codeFlowValue"),b(d)):(a.consume(d),c)}(c))}(b):c(b)}function f(c){return a.exit("codeIndented"),b(c)}}},ME={partial:!0,tokenize:function(a,b,c){let d=this;return e;function e(b){return d.parser.lazy[d.now().line]?c(b):L6(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e):Ma(a,f,"linePrefix",5)(b)}function f(a){let f=d.events[d.events.length-1];return f&&"linePrefix"===f[1].type&&f[2].sliceSerialize(f[1],!0).length>=4?b(a):L6(a)?e(a):c(a)}}};function MF(a){return null!==a&&(a<32||127===a)}function MG(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function MH(a,b,c,d,e,f,g,h,i){let j=i||1/0,k=0;return function(b){return 60===b?(a.enter(d),a.enter(e),a.enter(f),a.consume(b),a.exit(f),l):null===b||32===b||41===b||MF(b)?c(b):(a.enter(d),a.enter(g),a.enter(h),a.enter("chunkString",{contentType:"string"}),p(b))};function l(c){return 62===c?(a.enter(f),a.consume(c),a.exit(f),a.exit(e),a.exit(d),b):(a.enter(h),a.enter("chunkString",{contentType:"string"}),n(c))}function n(b){return 62===b?(a.exit("chunkString"),a.exit(h),l(b)):null===b||60===b||null!==b&&b<-2?c(b):(a.consume(b),92===b?o:n)}function o(b){return 60===b||62===b||92===b?(a.consume(b),n):n(b)}function p(e){return!k&&(null===e||41===e||null!==e&&(e<0||32===e))?(a.exit("chunkString"),a.exit(h),a.exit(g),a.exit(d),b(e)):k<j&&40===e?(a.consume(e),k++,p):41===e?(a.consume(e),k--,p):null===e||32===e||40===e||MF(e)?c(e):(a.consume(e),92===e?q:p)}function q(b){return 40===b||41===b||92===b?(a.consume(b),p):p(b)}}function MI(a){return null!==a&&a<-2}function MJ(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function MK(a,b,c,d,e,f){let g,h=this,i=0;return function(b){return a.enter(d),a.enter(e),a.consume(b),a.exit(e),a.enter(f),j};function j(l){return i>999||null===l||91===l||93===l&&!g||94===l&&!i&&"_hiddenFootnoteSupport"in h.parser.constructs?c(l):93===l?(a.exit(f),a.enter(e),a.consume(l),a.exit(e),a.exit(d),b):MI(l)?(a.enter("lineEnding"),a.consume(l),a.exit("lineEnding"),j):(a.enter("chunkString",{contentType:"string"}),k(l))}function k(b){return null===b||91===b||93===b||MI(b)||i++>999?(a.exit("chunkString"),j(b)):(a.consume(b),g||(g=-2!==b&&-1!==b&&32!==b),92===b?l:k)}function l(b){return 91===b||92===b||93===b?(a.consume(b),i++,k):k(b)}}function ML(a){return null!==a&&a<-2}function MM(a){return -2===a||-1===a||32===a}function MN(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function MO(a,b,c,d,e,f){let g;return function(b){return 34===b||39===b||40===b?(a.enter(d),a.enter(e),a.consume(b),a.exit(e),g=40===b?41:b,h):c(b)};function h(c){return c===g?(a.enter(e),a.consume(c),a.exit(e),a.exit(d),b):(a.enter(f),i(c))}function i(b){if(b===g)return a.exit(f),h(g);if(null===b)return c(b);if(ML(b)){var d,e;let c,f;return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),d=i,e="linePrefix",c=1/0,f=0,function(b){return MM(b)?(a.enter(e),function b(g){return MM(g)&&f++<c?(a.consume(g),b):(a.exit(e),d(g))}(b)):d(b)}}return a.enter("chunkString",{contentType:"string"}),j(b)}function j(b){return b===g||null===b||ML(b)?(a.exit("chunkString"),i(b)):(a.consume(b),92===b?k:j)}function k(b){return b===g||92===b?(a.consume(b),j):j(b)}}function MP(a){return -2===a||-1===a||32===a}function MQ(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function MR(a,b){let c;return function d(e){var f,g;if(null!==e&&e<-2)return a.enter("lineEnding"),a.consume(e),a.exit("lineEnding"),c=!0,d;if(MP(e)){let b,h;return(f=d,g=c?"linePrefix":"lineSuffix",b=1/0,h=0,function(c){return MP(c)?(a.enter(g),function c(d){return MP(d)&&h++<b?(a.consume(d),c):(a.exit(g),f(d))}(c)):f(c)})(e)}return b(e)}}function MS(a){return a.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}MG(/[A-Za-z]/),MG(/[\dA-Za-z]/),MG(/[#-'*+\--9=?A-Z^-~]/),MG(/\d/),MG(/[\dA-Fa-f]/),MG(/[!-/:-@[-`{-~]/),MG(/\p{P}|\p{S}/u),MG(/\s/),MJ(/[A-Za-z]/),MJ(/[\dA-Za-z]/),MJ(/[#-'*+\--9=?A-Z^-~]/),MJ(/\d/),MJ(/[\dA-Fa-f]/),MJ(/[!-/:-@[-`{-~]/),MJ(/\p{P}|\p{S}/u),MJ(/\s/),MN(/[A-Za-z]/),MN(/[\dA-Za-z]/),MN(/[#-'*+\--9=?A-Z^-~]/),MN(/\d/),MN(/[\dA-Fa-f]/),MN(/[!-/:-@[-`{-~]/),MN(/\p{P}|\p{S}/u),MN(/\s/),MQ(/[A-Za-z]/),MQ(/[\dA-Za-z]/),MQ(/[#-'*+\--9=?A-Z^-~]/),MQ(/\d/),MQ(/[\dA-Fa-f]/),MQ(/[!-/:-@[-`{-~]/),MQ(/\p{P}|\p{S}/u),MQ(/\s/);let MT={partial:!0,tokenize:function(a,b,c){return function(b){return L7(b)?MR(a,d)(b):c(b)};function d(b){return MO(a,e,c,"definitionTitle","definitionTitleMarker","definitionTitleString")(b)}function e(b){return L8(b)?Ma(a,f,"whitespace")(b):f(b)}function f(a){return null===a||L6(a)?b(a):c(a)}}},MU=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],MV=["pre","script","style","textarea"],MW={partial:!0,tokenize:function(a,b,c){return function(d){return a.enter("lineEnding"),a.consume(d),a.exit("lineEnding"),a.attempt(Mb,b,c)}}},MX={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return L6(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e):c(b)};function e(a){return d.parser.lazy[d.now().line]?c(a):b(a)}}},MY={name:"labelEnd",resolveAll:function(a){let b=-1,c=[];for(;++b<a.length;){let d=a[b][1];if(c.push(a[b]),"labelImage"===d.type||"labelLink"===d.type||"labelEnd"===d.type){let a="labelImage"===d.type?4:2;d.type="data",b+=a}}return a.length!==c.length&&LR(a,0,a.length,c),a},resolveTo:function(a,b){let c,d,e,f,g=a.length,h=0;for(;g--;)if(c=a[g][1],d){if("link"===c.type||"labelLink"===c.type&&c._inactive)break;"enter"===a[g][0]&&"labelLink"===c.type&&(c._inactive=!0)}else if(e){if("enter"===a[g][0]&&("labelImage"===c.type||"labelLink"===c.type)&&!c._balanced&&(d=g,"labelLink"!==c.type)){h=2;break}}else"labelEnd"===c.type&&(e=g);let i={type:"labelLink"===a[d][1].type?"link":"image",start:{...a[d][1].start},end:{...a[a.length-1][1].end}},j={type:"label",start:{...a[d][1].start},end:{...a[e][1].end}},k={type:"labelText",start:{...a[d+h+2][1].end},end:{...a[e-2][1].start}};return f=LS(f=[["enter",i,b],["enter",j,b]],a.slice(d+1,d+h+3)),f=LS(f,[["enter",k,b]]),f=LS(f,Ms(b.parser.constructs.insideSpan.null,a.slice(d+h+4,e-3),b)),f=LS(f,[["exit",k,b],a[e-2],a[e-1],["exit",j,b]]),f=LS(f,a.slice(e+1)),f=LS(f,[["exit",i,b]]),LR(a,d,a.length,f),a},tokenize:function(a,b,c){let d,e,f=this,g=f.events.length;for(;g--;)if(("labelImage"===f.events[g][1].type||"labelLink"===f.events[g][1].type)&&!f.events[g][1]._balanced){d=f.events[g][1];break}return function(b){return d?d._inactive?k(b):(e=f.parser.defined.includes(MS(f.sliceSerialize({start:d.end,end:f.now()}))),a.enter("labelEnd"),a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelEnd"),h):c(b)};function h(b){return 40===b?a.attempt(MZ,j,e?j:k)(b):91===b?a.attempt(M$,j,e?i:k)(b):e?j(b):k(b)}function i(b){return a.attempt(M_,j,k)(b)}function j(a){return b(a)}function k(a){return d._balanced=!0,c(a)}}},MZ={tokenize:function(a,b,c){return function(b){return a.enter("resource"),a.enter("resourceMarker"),a.consume(b),a.exit("resourceMarker"),d};function d(b){return L7(b)?MR(a,e)(b):e(b)}function e(b){return 41===b?j(b):MH(a,f,g,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function f(b){return L7(b)?MR(a,h)(b):j(b)}function g(a){return c(a)}function h(b){return 34===b||39===b||40===b?MO(a,i,c,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):j(b)}function i(b){return L7(b)?MR(a,j)(b):j(b)}function j(d){return 41===d?(a.enter("resourceMarker"),a.consume(d),a.exit("resourceMarker"),a.exit("resource"),b):c(d)}}},M$={tokenize:function(a,b,c){let d=this;return function(b){return MK.call(d,a,e,f,"reference","referenceMarker","referenceString")(b)};function e(a){return d.parser.defined.includes(MS(d.sliceSerialize(d.events[d.events.length-1][1]).slice(1,-1)))?b(a):c(a)}function f(a){return c(a)}}},M_={tokenize:function(a,b,c){return function(b){return a.enter("reference"),a.enter("referenceMarker"),a.consume(b),a.exit("referenceMarker"),d};function d(d){return 93===d?(a.enter("referenceMarker"),a.consume(d),a.exit("referenceMarker"),a.exit("reference"),b):c(d)}}},M0={name:"labelStartImage",resolveAll:MY.resolveAll,tokenize:function(a,b,c){let d=this;return function(b){return a.enter("labelImage"),a.enter("labelImageMarker"),a.consume(b),a.exit("labelImageMarker"),e};function e(b){return 91===b?(a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelImage"),f):c(b)}function f(a){return 94===a&&"_hiddenFootnoteSupport"in d.parser.constructs?c(a):b(a)}}},M1={name:"labelStartLink",resolveAll:MY.resolveAll,tokenize:function(a,b,c){let d=this;return function(b){return a.enter("labelLink"),a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelLink"),e};function e(a){return 94===a&&"_hiddenFootnoteSupport"in d.parser.constructs?c(a):b(a)}}},M2={name:"lineEnding",tokenize:function(a,b){return function(c){return a.enter("lineEnding"),a.consume(c),a.exit("lineEnding"),Ma(a,b,"linePrefix")}}},M3={name:"thematicBreak",tokenize:function(a,b,c){let d,e=0;return function(f){var g;return a.enter("thematicBreak"),d=g=f,function f(g){return g===d?(a.enter("thematicBreakSequence"),function b(c){return c===d?(a.consume(c),e++,b):(a.exit("thematicBreakSequence"),L8(c)?Ma(a,f,"whitespace")(c):f(c))}(g)):e>=3&&(null===g||L6(g))?(a.exit("thematicBreak"),b(g)):c(g)}(g)}}},M4={continuation:{tokenize:function(a,b,c){let d=this;return d.containerState._closeFlow=void 0,a.check(Mb,function(c){return d.containerState.furtherBlankLines=d.containerState.furtherBlankLines||d.containerState.initialBlankLine,Ma(a,b,"listItemIndent",d.containerState.size+1)(c)},function(c){return d.containerState.furtherBlankLines||!L8(c)?(d.containerState.furtherBlankLines=void 0,d.containerState.initialBlankLine=void 0,e(c)):(d.containerState.furtherBlankLines=void 0,d.containerState.initialBlankLine=void 0,a.attempt(M6,b,e)(c))});function e(e){return d.containerState._closeFlow=!0,d.interrupt=void 0,Ma(a,a.attempt(M4,b,c),"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(e)}}},exit:function(a){a.exit(this.containerState.type)},name:"list",tokenize:function(a,b,c){let d=this,e=d.events[d.events.length-1],f=e&&"linePrefix"===e[1].type?e[2].sliceSerialize(e[1],!0).length:0,g=0;return function(b){let e=d.containerState.type||(42===b||43===b||45===b?"listUnordered":"listOrdered");if("listUnordered"===e?!d.containerState.marker||b===d.containerState.marker:L3(b)){if(d.containerState.type||(d.containerState.type=e,a.enter(e,{_container:!0})),"listUnordered"===e)return a.enter("listItemPrefix"),42===b||45===b?a.check(M3,c,h)(b):h(b);if(!d.interrupt||49===b)return a.enter("listItemPrefix"),a.enter("listItemValue"),function b(e){return L3(e)&&++g<10?(a.consume(e),b):(!d.interrupt||g<2)&&(d.containerState.marker?e===d.containerState.marker:41===e||46===e)?(a.exit("listItemValue"),h(e)):c(e)}(b)}return c(b)};function h(b){return a.enter("listItemMarker"),a.consume(b),a.exit("listItemMarker"),d.containerState.marker=d.containerState.marker||b,a.check(Mb,d.interrupt?c:i,a.attempt(M5,k,j))}function i(a){return d.containerState.initialBlankLine=!0,f++,k(a)}function j(b){return L8(b)?(a.enter("listItemPrefixWhitespace"),a.consume(b),a.exit("listItemPrefixWhitespace"),k):c(b)}function k(c){return d.containerState.size=f+d.sliceSerialize(a.exit("listItemPrefix"),!0).length,b(c)}}},M5={partial:!0,tokenize:function(a,b,c){let d=this;return Ma(a,function(a){let e=d.events[d.events.length-1];return!L8(a)&&e&&"listItemPrefixWhitespace"===e[1].type?b(a):c(a)},"listItemPrefixWhitespace",d.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},M6={partial:!0,tokenize:function(a,b,c){let d=this;return Ma(a,function(a){let e=d.events[d.events.length-1];return e&&"listItemIndent"===e[1].type&&e[2].sliceSerialize(e[1],!0).length===d.containerState.size?b(a):c(a)},"listItemIndent",d.containerState.size+1)}},M7={name:"setextUnderline",resolveTo:function(a,b){let c,d,e,f=a.length;for(;f--;)if("enter"===a[f][0]){if("content"===a[f][1].type){c=f;break}"paragraph"===a[f][1].type&&(d=f)}else"content"===a[f][1].type&&a.splice(f,1),e||"definition"!==a[f][1].type||(e=f);let g={type:"setextHeading",start:{...a[c][1].start},end:{...a[a.length-1][1].end}};return a[d][1].type="setextHeadingText",e?(a.splice(d,0,["enter",g,b]),a.splice(e+1,0,["exit",a[c][1],b]),a[c][1].end={...a[e][1].end}):a[c][1]=g,a.push(["exit",g,b]),a},tokenize:function(a,b,c){let d,e=this;return function(b){var g;let h,i=e.events.length;for(;i--;)if("lineEnding"!==e.events[i][1].type&&"linePrefix"!==e.events[i][1].type&&"content"!==e.events[i][1].type){h="paragraph"===e.events[i][1].type;break}return!e.parser.lazy[e.now().line]&&(e.interrupt||h)?(a.enter("setextHeadingLine"),d=b,g=b,a.enter("setextHeadingLineSequence"),function b(c){return c===d?(a.consume(c),b):(a.exit("setextHeadingLineSequence"),L8(c)?Ma(a,f,"lineSuffix")(c):f(c))}(g)):c(b)};function f(d){return null===d||L6(d)?(a.exit("setextHeadingLine"),b(d)):c(d)}}};a.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(a,b,c){let d,e=this;return function(b){var d;return a.enter("definition"),d=b,MK.call(e,a,f,c,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)};function f(b){return(d=MS(e.sliceSerialize(e.events[e.events.length-1][1]).slice(1,-1)),58===b)?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),g):c(b)}function g(b){return L7(b)?MR(a,h)(b):h(b)}function h(b){return MH(a,i,c,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function i(b){return a.attempt(MT,j,j)(b)}function j(b){return L8(b)?Ma(a,k,"whitespace")(b):k(b)}function k(f){return null===f||L6(f)?(a.exit("definition"),e.parser.defined.push(d),b(f)):c(f)}}}},"disable",0,{null:[]},"document",0,{42:M4,43:M4,45:M4,48:M4,49:M4,50:M4,51:M4,52:M4,53:M4,54:M4,55:M4,56:M4,57:M4,62:Mv},"flow",0,{35:{name:"headingAtx",resolve:function(a,b){let c,d,e=a.length-2,f=3;return"whitespace"===a[3][1].type&&(f+=2),e-2>f&&"whitespace"===a[e][1].type&&(e-=2),"atxHeadingSequence"===a[e][1].type&&(f===e-1||e-4>f&&"whitespace"===a[e-2][1].type)&&(e-=f+1===e?2:4),e>f&&(c={type:"atxHeadingText",start:a[f][1].start,end:a[e][1].end},d={type:"chunkText",start:a[f][1].start,end:a[e][1].end,contentType:"text"},LR(a,f,e-f+1,[["enter",c,b],["enter",d,b],["exit",d,b],["exit",c,b]])),a},tokenize:function(a,b,c){let d=0;return function(e){var f;return a.enter("atxHeading"),f=e,a.enter("atxHeadingSequence"),function e(f){return 35===f&&d++<6?(a.consume(f),e):null===f||L7(f)?(a.exit("atxHeadingSequence"),function c(d){return 35===d?(a.enter("atxHeadingSequence"),function b(d){return 35===d?(a.consume(d),b):(a.exit("atxHeadingSequence"),c(d))}(d)):null===d||L6(d)?(a.exit("atxHeading"),b(d)):L8(d)?Ma(a,c,"whitespace")(d):(a.enter("atxHeadingText"),function b(d){return null===d||35===d||L7(d)?(a.exit("atxHeadingText"),c(d)):(a.consume(d),b)}(d))}(f)):c(f)}(f)}}},42:M3,45:[M7,M3],60:{concrete:!0,name:"htmlFlow",resolveTo:function(a){let b=a.length;for(;b--&&("enter"!==a[b][0]||"htmlFlow"!==a[b][1].type););return b>1&&"linePrefix"===a[b-2][1].type&&(a[b][1].start=a[b-2][1].start,a[b+1][1].start=a[b-2][1].start,a.splice(b-2,2)),a},tokenize:function(a,b,c){let d,e,f,g,h,i=this;return function(b){var c;return c=b,a.enter("htmlFlow"),a.enter("htmlFlowData"),a.consume(c),j};function j(g){return 33===g?(a.consume(g),k):47===g?(a.consume(g),e=!0,o):63===g?(a.consume(g),d=3,i.interrupt?b:H):L0(g)?(a.consume(g),f=String.fromCharCode(g),p):c(g)}function k(e){return 45===e?(a.consume(e),d=2,l):91===e?(a.consume(e),d=5,g=0,n):L0(e)?(a.consume(e),d=4,i.interrupt?b:H):c(e)}function l(d){return 45===d?(a.consume(d),i.interrupt?b:H):c(d)}function n(d){let e="CDATA[";return d===e.charCodeAt(g++)?(a.consume(d),g===e.length)?i.interrupt?b:z:n:c(d)}function o(b){return L0(b)?(a.consume(b),f=String.fromCharCode(b),p):c(b)}function p(g){if(null===g||47===g||62===g||L7(g)){let h=47===g,j=f.toLowerCase();return!h&&!e&&MV.includes(j)?(d=1,i.interrupt?b(g):z(g)):MU.includes(f.toLowerCase())?(d=6,h)?(a.consume(g),q):i.interrupt?b(g):z(g):(d=7,i.interrupt&&!i.parser.lazy[i.now().line]?c(g):e?function b(c){return L8(c)?(a.consume(c),b):x(c)}(g):r(g))}return 45===g||L1(g)?(a.consume(g),f+=String.fromCharCode(g),p):c(g)}function q(d){return 62===d?(a.consume(d),i.interrupt?b:z):c(d)}function r(b){return 47===b?(a.consume(b),x):58===b||95===b||L0(b)?(a.consume(b),s):L8(b)?(a.consume(b),r):x(b)}function s(b){return 45===b||46===b||58===b||95===b||L1(b)?(a.consume(b),s):t(b)}function t(b){return 61===b?(a.consume(b),u):L8(b)?(a.consume(b),t):r(b)}function u(b){return null===b||60===b||61===b||62===b||96===b?c(b):34===b||39===b?(a.consume(b),h=b,v):L8(b)?(a.consume(b),u):function b(c){return null===c||34===c||39===c||47===c||60===c||61===c||62===c||96===c||L7(c)?t(c):(a.consume(c),b)}(b)}function v(b){return b===h?(a.consume(b),h=null,w):null===b||L6(b)?c(b):(a.consume(b),v)}function w(a){return 47===a||62===a||L8(a)?r(a):c(a)}function x(b){return 62===b?(a.consume(b),y):c(b)}function y(b){return null===b||L6(b)?z(b):L8(b)?(a.consume(b),y):c(b)}function z(b){return 45===b&&2===d?(a.consume(b),D):60===b&&1===d?(a.consume(b),E):62===b&&4===d?(a.consume(b),I):63===b&&3===d?(a.consume(b),H):93===b&&5===d?(a.consume(b),G):L6(b)&&(6===d||7===d)?(a.exit("htmlFlowData"),a.check(MW,J,A)(b)):null===b||L6(b)?(a.exit("htmlFlowData"),A(b)):(a.consume(b),z)}function A(b){return a.check(MX,B,J)(b)}function B(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),C}function C(b){return null===b||L6(b)?A(b):(a.enter("htmlFlowData"),z(b))}function D(b){return 45===b?(a.consume(b),H):z(b)}function E(b){return 47===b?(a.consume(b),f="",F):z(b)}function F(b){if(62===b){let c=f.toLowerCase();return MV.includes(c)?(a.consume(b),I):z(b)}return L0(b)&&f.length<8?(a.consume(b),f+=String.fromCharCode(b),F):z(b)}function G(b){return 93===b?(a.consume(b),H):z(b)}function H(b){return 62===b?(a.consume(b),I):45===b&&2===d?(a.consume(b),H):z(b)}function I(b){return null===b||L6(b)?(a.exit("htmlFlowData"),J(b)):(a.consume(b),I)}function J(c){return a.exit("htmlFlow"),b(c)}}},61:M7,95:M3,96:MC,126:MC},"flowInitial",0,{[-2]:MD,[-1]:MD,32:MD},"insideSpan",0,{null:[Mt,Mi]},"string",0,{38:MA,92:Mw},"text",0,{[-5]:M2,[-4]:M2,[-3]:M2,33:M0,38:MA,42:Mt,60:[{name:"autolink",tokenize:function(a,b,c){let d=0;return function(b){return a.enter("autolink"),a.enter("autolinkMarker"),a.consume(b),a.exit("autolinkMarker"),a.enter("autolinkProtocol"),e};function e(b){return L0(b)?(a.consume(b),f):64===b?c(b):h(b)}function f(b){return 43===b||45===b||46===b||L1(b)?(d=1,function b(c){return 58===c?(a.consume(c),d=0,g):(43===c||45===c||46===c||L1(c))&&d++<32?(a.consume(c),b):(d=0,h(c))}(b)):h(b)}function g(d){return 62===d?(a.exit("autolinkProtocol"),a.enter("autolinkMarker"),a.consume(d),a.exit("autolinkMarker"),a.exit("autolink"),b):null===d||32===d||60===d||null!==d&&(d<32||127===d)?c(d):(a.consume(d),g)}function h(b){return 64===b?(a.consume(b),i):L2(b)?(a.consume(b),h):c(b)}function i(e){return L1(e)?function e(f){return 46===f?(a.consume(f),d=0,i):62===f?(a.exit("autolinkProtocol").type="autolinkEmail",a.enter("autolinkMarker"),a.consume(f),a.exit("autolinkMarker"),a.exit("autolink"),b):function b(f){if((45===f||L1(f))&&d++<63){let c=45===f?b:e;return a.consume(f),c}return c(f)}(f)}(e):c(e)}}},{name:"htmlText",tokenize:function(a,b,c){let d,e,f,g=this;return function(b){return a.enter("htmlText"),a.enter("htmlTextData"),a.consume(b),h};function h(b){return 33===b?(a.consume(b),i):47===b?(a.consume(b),v):63===b?(a.consume(b),t):L0(b)?(a.consume(b),x):c(b)}function i(b){return 45===b?(a.consume(b),j):91===b?(a.consume(b),e=0,o):L0(b)?(a.consume(b),s):c(b)}function j(b){return 45===b?(a.consume(b),n):c(b)}function k(b){return null===b?c(b):45===b?(a.consume(b),l):L6(b)?(f=k,F(b)):(a.consume(b),k)}function l(b){return 45===b?(a.consume(b),n):k(b)}function n(a){return 62===a?E(a):45===a?l(a):k(a)}function o(b){let d="CDATA[";return b===d.charCodeAt(e++)?(a.consume(b),e===d.length?p:o):c(b)}function p(b){return null===b?c(b):93===b?(a.consume(b),q):L6(b)?(f=p,F(b)):(a.consume(b),p)}function q(b){return 93===b?(a.consume(b),r):p(b)}function r(b){return 62===b?E(b):93===b?(a.consume(b),r):p(b)}function s(b){return null===b||62===b?E(b):L6(b)?(f=s,F(b)):(a.consume(b),s)}function t(b){return null===b?c(b):63===b?(a.consume(b),u):L6(b)?(f=t,F(b)):(a.consume(b),t)}function u(a){return 62===a?E(a):t(a)}function v(b){return L0(b)?(a.consume(b),w):c(b)}function w(b){return 45===b||L1(b)?(a.consume(b),w):function b(c){return L6(c)?(f=b,F(c)):L8(c)?(a.consume(c),b):E(c)}(b)}function x(b){return 45===b||L1(b)?(a.consume(b),x):47===b||62===b||L7(b)?y(b):c(b)}function y(b){return 47===b?(a.consume(b),E):58===b||95===b||L0(b)?(a.consume(b),z):L6(b)?(f=y,F(b)):L8(b)?(a.consume(b),y):E(b)}function z(b){return 45===b||46===b||58===b||95===b||L1(b)?(a.consume(b),z):function b(c){return 61===c?(a.consume(c),A):L6(c)?(f=b,F(c)):L8(c)?(a.consume(c),b):y(c)}(b)}function A(b){return null===b||60===b||61===b||62===b||96===b?c(b):34===b||39===b?(a.consume(b),d=b,B):L6(b)?(f=A,F(b)):L8(b)?(a.consume(b),A):(a.consume(b),C)}function B(b){return b===d?(a.consume(b),d=void 0,D):null===b?c(b):L6(b)?(f=B,F(b)):(a.consume(b),B)}function C(b){return null===b||34===b||39===b||60===b||61===b||96===b?c(b):47===b||62===b||L7(b)?y(b):(a.consume(b),C)}function D(a){return 47===a||62===a||L7(a)?y(a):c(a)}function E(d){return 62===d?(a.consume(d),a.exit("htmlTextData"),a.exit("htmlText"),b):c(d)}function F(b){return a.exit("htmlTextData"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),G}function G(b){return L8(b)?Ma(a,H,"linePrefix",g.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):H(b)}function H(b){return a.enter("htmlTextData"),f(b)}}}],91:M1,92:[{name:"hardBreakEscape",tokenize:function(a,b,c){return function(b){return a.enter("hardBreakEscape"),a.consume(b),d};function d(d){return L6(d)?(a.exit("hardBreakEscape"),b(d)):c(d)}}},Mw],93:MY,95:Mt,96:{name:"codeText",previous:function(a){return 96!==a||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(a){let b,c,d=a.length-4,e=3;if(("lineEnding"===a[3][1].type||"space"===a[e][1].type)&&("lineEnding"===a[d][1].type||"space"===a[d][1].type)){for(b=e;++b<d;)if("codeTextData"===a[b][1].type){a[e][1].type="codeTextPadding",a[d][1].type="codeTextPadding",e+=2,d-=2;break}}for(b=e-1,d++;++b<=d;)void 0===c?b!==d&&"lineEnding"!==a[b][1].type&&(c=b):(b===d||"lineEnding"===a[b][1].type)&&(a[c][1].type="codeTextData",b!==c+2&&(a[c][1].end=a[b-1][1].end,a.splice(c+2,b-c-2),d-=b-c-2,b=c+2),c=void 0);return a},tokenize:function(a,b,c){let d,e,f=0;return function(b){return a.enter("codeText"),a.enter("codeTextSequence"),function b(c){return 96===c?(a.consume(c),f++,b):(a.exit("codeTextSequence"),g(c))}(b)};function g(i){return null===i?c(i):32===i?(a.enter("space"),a.consume(i),a.exit("space"),g):96===i?(e=a.enter("codeTextSequence"),d=0,function c(g){return 96===g?(a.consume(g),d++,c):d===f?(a.exit("codeTextSequence"),a.exit("codeText"),b(g)):(e.type="codeTextData",h(g))}(i)):L6(i)?(a.enter("lineEnding"),a.consume(i),a.exit("lineEnding"),g):(a.enter("codeTextData"),h(i))}function h(b){return null===b||32===b||96===b||L6(b)?(a.exit("codeTextData"),g(b)):(a.consume(b),h)}}}}],35856);var M8=a.i(35856);let M9=/[\0\t\n\r]/g;function Na(a,b){let c=Number.parseInt(a,b);return c<9||11===c||c>13&&c<32||c>126&&c<160||c>55295&&c<57344||c>64975&&c<65008||(65535&c)==65535||(65535&c)==65534||c>1114111?"�":String.fromCodePoint(c)}let Nb=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Nc(a,b,c){if(b)return b;if(35===c.charCodeAt(0)){let a=c.charCodeAt(1),b=120===a||88===a;return Na(c.slice(b?2:1),b?16:10)}return Mz(c)||a}let Nd={}.hasOwnProperty;function Ne(a){return{line:a.line,column:a.column,offset:a.offset}}function Nf(a,b){if(a)throw Error("Cannot close `"+a.type+"` ("+Lu({start:a.start,end:a.end})+"): a different token (`"+b.type+"`, "+Lu({start:b.start,end:b.end})+") is open");throw Error("Cannot close document, a token (`"+b.type+"`, "+Lu({start:b.start,end:b.end})+") is still open")}function Ng(a){let b=this;b.parser=function(c){var d,e;let f,g,h,i;return"string"!=typeof(d={...b.data("settings"),...a,extensions:b.data("micromarkExtensions")||[],mdastExtensions:b.data("fromMarkdownExtensions")||[]})&&(e=d,d=void 0),(function(a){let b={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(s),autolinkProtocol:j,autolinkEmail:j,atxHeading:d(p),blockQuote:d(function(){return{type:"blockquote",children:[]}}),characterEscape:j,characterReference:j,codeFenced:d(o),codeFencedFenceInfo:e,codeFencedFenceMeta:e,codeIndented:d(o,e),codeText:d(function(){return{type:"inlineCode",value:""}},e),codeTextData:j,data:j,codeFlowValue:j,definition:d(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:e,definitionLabelString:e,definitionTitleString:e,emphasis:d(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:d(q),hardBreakTrailing:d(q),htmlFlow:d(r,e),htmlFlowData:j,htmlText:d(r,e),htmlTextData:j,image:d(function(){return{type:"image",title:null,url:"",alt:null}}),label:e,link:d(s),listItem:d(function(a){return{type:"listItem",spread:a._spread,checked:null,children:[]}}),listItemValue:function(a){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(a),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:d(t,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:d(t),paragraph:d(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:e,resourceDestinationString:e,resourceTitleString:e,setextHeading:d(p),strong:d(function(){return{type:"strong",children:[]}}),thematicBreak:d(function(){return{type:"thematicBreak"}})},exit:{atxHeading:g(),atxHeadingSequence:function(a){let b=this.stack[this.stack.length-1];b.depth||(b.depth=this.sliceSerialize(a).length)},autolink:g(),autolinkEmail:function(a){k.call(this,a),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(a)},autolinkProtocol:function(a){k.call(this,a),this.stack[this.stack.length-1].url=this.sliceSerialize(a)},blockQuote:g(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:n,characterReferenceMarkerNumeric:n,characterReferenceValue:function(a){let b,c=this.sliceSerialize(a),d=this.data.characterReferenceType;d?(b=Na(c,"characterReferenceMarkerNumeric"===d?10:16),this.data.characterReferenceType=void 0):b=Mz(c);let e=this.stack[this.stack.length-1];e.value+=b},characterReference:function(a){this.stack.pop().position.end=Ne(a.end)},codeFenced:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let a=this.resume();this.stack[this.stack.length-1].lang=a},codeFencedFenceMeta:function(){let a=this.resume();this.stack[this.stack.length-1].meta=a},codeFlowValue:k,codeIndented:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a.replace(/(\r?\n|\r)$/g,"")}),codeText:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),codeTextData:k,data:k,definition:g(),definitionDestinationString:function(){let a=this.resume();this.stack[this.stack.length-1].url=a},definitionLabelString:function(a){let b=this.resume(),c=this.stack[this.stack.length-1];c.label=b,c.identifier=MS(this.sliceSerialize(a)).toLowerCase()},definitionTitleString:function(){let a=this.resume();this.stack[this.stack.length-1].title=a},emphasis:g(),hardBreakEscape:g(l),hardBreakTrailing:g(l),htmlFlow:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),htmlFlowData:k,htmlText:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),htmlTextData:k,image:g(function(){let a=this.stack[this.stack.length-1];if(this.data.inReference){let b=this.data.referenceType||"shortcut";a.type+="Reference",a.referenceType=b,delete a.url,delete a.title}else delete a.identifier,delete a.label;this.data.referenceType=void 0}),label:function(){let a=this.stack[this.stack.length-1],b=this.resume(),c=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===c.type?c.children=a.children:c.alt=b},labelText:function(a){let b=this.sliceSerialize(a),c=this.stack[this.stack.length-2];c.label=b.replace(Nb,Nc),c.identifier=MS(b).toLowerCase()},lineEnding:function(a){let c=this.stack[this.stack.length-1];if(this.data.atHardBreak){c.children[c.children.length-1].position.end=Ne(a.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&b.canContainEols.includes(c.type)&&(j.call(this,a),k.call(this,a))},link:g(function(){let a=this.stack[this.stack.length-1];if(this.data.inReference){let b=this.data.referenceType||"shortcut";a.type+="Reference",a.referenceType=b,delete a.url,delete a.title}else delete a.identifier,delete a.label;this.data.referenceType=void 0}),listItem:g(),listOrdered:g(),listUnordered:g(),paragraph:g(),referenceString:function(a){let b=this.resume(),c=this.stack[this.stack.length-1];c.label=b,c.identifier=MS(this.sliceSerialize(a)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let a=this.resume();this.stack[this.stack.length-1].url=a},resourceTitleString:function(){let a=this.resume();this.stack[this.stack.length-1].title=a},resource:function(){this.data.inReference=void 0},setextHeading:g(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(a){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(a).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:g(),thematicBreak:g()}};!function a(b,c){let d=-1;for(;++d<c.length;){let e=c[d];Array.isArray(e)?a(b,e):function(a,b){let c;for(c in b)if(Nd.call(b,c))switch(c){case"canContainEols":{let d=b[c];d&&a[c].push(...d);break}case"transforms":{let d=b[c];d&&a[c].push(...d);break}case"enter":case"exit":{let d=b[c];d&&Object.assign(a[c],d)}}}(b,e)}}(b,(a||{}).mdastExtensions||[]);let c={};return function(a){let d={type:"root",children:[]},g={stack:[d],tokenStack:[],config:b,enter:f,exit:h,buffer:e,resume:i,data:c},j=[],k=-1;for(;++k<a.length;)("listOrdered"===a[k][1].type||"listUnordered"===a[k][1].type)&&("enter"===a[k][0]?j.push(k):k=function(a,b,c){let d,e,f,g,h=b-1,i=-1,j=!1;for(;++h<=c;){let b=a[h];switch(b[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===b[0]?i++:i--,g=void 0;break;case"lineEndingBlank":"enter"===b[0]&&(!d||g||i||f||(f=h),g=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:g=void 0}if(!i&&"enter"===b[0]&&"listItemPrefix"===b[1].type||-1===i&&"exit"===b[0]&&("listUnordered"===b[1].type||"listOrdered"===b[1].type)){if(d){let g=h;for(e=void 0;g--;){let b=a[g];if("lineEnding"===b[1].type||"lineEndingBlank"===b[1].type){if("exit"===b[0])continue;e&&(a[e][1].type="lineEndingBlank",j=!0),b[1].type="lineEnding",e=g}else if("linePrefix"===b[1].type||"blockQuotePrefix"===b[1].type||"blockQuotePrefixWhitespace"===b[1].type||"blockQuoteMarker"===b[1].type||"listItemIndent"===b[1].type);else break}f&&(!e||f<e)&&(d._spread=!0),d.end=Object.assign({},e?a[e][1].start:b[1].end),a.splice(e||h,0,["exit",d,b[2]]),h++,c++}if("listItemPrefix"===b[1].type){let e={type:"listItem",_spread:!1,start:Object.assign({},b[1].start),end:void 0};d=e,a.splice(h,0,["enter",e,b[2]]),h++,c++,f=void 0,g=!0}}}return a[b][1]._spread=j,c}(a,j.pop(),k));for(k=-1;++k<a.length;){let c=b[a[k][0]];Nd.call(c,a[k][1].type)&&c[a[k][1].type].call(Object.assign({sliceSerialize:a[k][2].sliceSerialize},g),a[k][1])}if(g.tokenStack.length>0){let a=g.tokenStack[g.tokenStack.length-1];(a[1]||Nf).call(g,void 0,a[0])}for(d.position={start:Ne(a.length>0?a[0][1].start:{line:1,column:1,offset:0}),end:Ne(a.length>0?a[a.length-2][1].end:{line:1,column:1,offset:0})},k=-1;++k<b.transforms.length;)d=b.transforms[k](d)||d;return d};function d(a,b){return function(c){f.call(this,a(c),c),b&&b.call(this,c)}}function e(){this.stack.push({type:"fragment",children:[]})}function f(a,b,c){this.stack[this.stack.length-1].children.push(a),this.stack.push(a),this.tokenStack.push([b,c||void 0]),a.position={start:Ne(b.start),end:void 0}}function g(a){return function(b){a&&a.call(this,b),h.call(this,b)}}function h(a,b){let c=this.stack.pop(),d=this.tokenStack.pop();if(d)d[0].type!==a.type&&(b?b.call(this,a,d[0]):(d[1]||Nf).call(this,a,d[0]));else throw Error("Cannot close `"+a.type+"` ("+Lu({start:a.start,end:a.end})+"): it’s not open");c.position.end=Ne(a.end)}function i(){return LO(this.stack.pop())}function j(a){let b=this.stack[this.stack.length-1].children,c=b[b.length-1];c&&"text"===c.type||((c={type:"text",value:""}).position={start:Ne(a.start),end:void 0},b.push(c)),this.stack.push(c)}function k(a){let b=this.stack.pop();b.value+=this.sliceSerialize(a),b.position.end=Ne(a.end)}function l(){this.data.atHardBreak=!0}function n(a){this.data.characterReferenceType=a.type}function o(){return{type:"code",lang:null,meta:null,value:""}}function p(){return{type:"heading",depth:0,children:[]}}function q(){return{type:"break"}}function r(){return{type:"html",value:""}}function s(){return{type:"link",title:null,url:"",children:[]}}function t(a){return{type:"list",ordered:"listOrdered"===a.type,start:null,spread:a._spread,children:[]}}})(e)(function(a){for(;!Me(a););return a}((function(a){let b={constructs:LU([M8,...(a||{}).extensions||[]]),content:c(LZ),defined:[],document:c(L$),flow:c(Mh),lazy:{},string:c(Mj),text:c(Mk)};return b;function c(a){return function(c){return function(a,b,c){let d={_bufferIndex:-1,_index:0,line:c&&c.line||1,column:c&&c.column||1,offset:c&&c.offset||0},e={},f=[],g=[],h=[],i={attempt:p(function(a,b){q(a,b.from)}),check:p(o),consume:function(a){LV(a)?(d.line++,d.column=1,d.offset+=-3===a?2:1,r()):-1!==a&&(d.column++,d.offset++),d._bufferIndex<0?d._index++:(d._bufferIndex++,d._bufferIndex===g[d._index].length&&(d._bufferIndex=-1,d._index++)),j.previous=a},enter:function(a,b){let c=b||{};return c.type=a,c.start=n(),j.events.push(["enter",c,j]),h.push(c),c},exit:function(a){let b=h.pop();return b.end=n(),j.events.push(["exit",b,j]),b},interrupt:p(o,{interrupt:!0})},j={code:null,containerState:{},defineSkip:function(a){e[a.line]=a.column,r()},events:[],now:n,parser:a,previous:null,sliceSerialize:function(a,b){return function(a,b){let c,d=-1,e=[];for(;++d<a.length;){let f,g=a[d];if("string"==typeof g)f=g;else switch(g){case -5:f="\r";break;case -4:f="\n";break;case -3:f="\r\n";break;case -2:f=b?" ":" ";break;case -1:if(!b&&c)continue;f=" ";break;default:f=String.fromCharCode(g)}c=-2===g,e.push(f)}return e.join("")}(l(a),b)},sliceStream:l,write:function(a){return(g=LS(g,a),function(){let a;for(;d._index<g.length;){let c=g[d._index];if("string"==typeof c)for(a=d._index,d._bufferIndex<0&&(d._bufferIndex=0);d._index===a&&d._bufferIndex<c.length;){var b;b=c.charCodeAt(d._bufferIndex),k=k(b)}else k=k(c)}}(),null!==g[g.length-1])?[]:(q(b,0),j.events=Ms(f,j.events,j),j.events)}},k=b.tokenize.call(j,i);return b.resolveAll&&f.push(b),j;function l(a){return function(a,b){let c,d=b.start._index,e=b.start._bufferIndex,f=b.end._index,g=b.end._bufferIndex;if(d===f)c=[a[d].slice(e,g)];else{if(c=a.slice(d,f),e>-1){let a=c[0];"string"==typeof a?c[0]=a.slice(e):c.shift()}g>0&&c.push(a[f].slice(0,g))}return c}(g,a)}function n(){let{_bufferIndex:a,_index:b,line:c,column:e,offset:f}=d;return{_bufferIndex:a,_index:b,line:c,column:e,offset:f}}function o(a,b){b.restore()}function p(a,b){return function(c,e,f){var g;let k,l,o,p;return Array.isArray(c)?q(c):"tokenize"in c?q([c]):(g=c,function(a){let b=null!==a&&g[a],c=null!==a&&g.null;return q([...Array.isArray(b)?b:b?[b]:[],...Array.isArray(c)?c:c?[c]:[]])(a)});function q(a){return(k=a,l=0,0===a.length)?f:s(a[l])}function s(a){return function(c){let e,f,g,k,l;return(e=n(),f=j.previous,g=j.currentConstruct,k=j.events.length,l=Array.from(h),p={from:k,restore:function(){d=e,j.previous=f,j.currentConstruct=g,j.events.length=k,h=l,r()}},o=a,a.partial||(j.currentConstruct=a),a.name&&j.parser.constructs.disable.null.includes(a.name))?u(c):a.tokenize.call(b?Object.assign(Object.create(j),b):j,i,t,u)(c)}}function t(b){return a(o,p),e}function u(a){return(p.restore(),++l<k.length)?s(k[l]):f}}}function q(a,b){a.resolveAll&&!f.includes(a)&&f.push(a),a.resolve&&LR(j.events,b,j.events.length-b,a.resolve(j.events.slice(b),j)),a.resolveTo&&(j.events=a.resolveTo(j.events,j))}function r(){d.line in e&&d.column<2&&(d.column=e[d.line],d.offset+=e[d.line]-1)}}(b,a,c)}}})(e).document().write((g=1,h="",i=!0,function(a,b,c){let d,e,j,k,l,n=[];for(a=h+("string"==typeof a?a.toString():new TextDecoder(b||void 0).decode(a)),j=0,h="",i&&(65279===a.charCodeAt(0)&&j++,i=void 0);j<a.length;){if(M9.lastIndex=j,k=(d=M9.exec(a))&&void 0!==d.index?d.index:a.length,l=a.charCodeAt(k),!d){h=a.slice(j);break}if(10===l&&j===k&&f)n.push(-3),f=void 0;else switch(f&&(n.push(-5),f=void 0),j<k&&(n.push(a.slice(j,k)),g+=k-j),l){case 0:n.push(65533),g++;break;case 9:for(e=4*Math.ceil(g/4),n.push(-2);g++<e;)n.push(-1);break;case 10:n.push(-4),g=1;break;default:f=!0,g=1}j=k+1}return c&&(f&&n.push(-5),h&&n.push(h),n.push(null)),n})(c,d,!0))))}}let Nh="object"==typeof self?self:globalThis,Ni=a=>{var b;let c,d;return(b=new Map,c=(a,c)=>(b.set(c,a),a),d=e=>{if(b.has(e))return b.get(e);let[f,g]=a[e];switch(f){case 0:case -1:return c(g,e);case 1:{let a=c([],e);for(let b of g)a.push(d(b));return a}case 2:{let a=c({},e);for(let[b,c]of g)a[d(b)]=d(c);return a}case 3:return c(new Date(g),e);case 4:{let{source:a,flags:b}=g;return c(new RegExp(a,b),e)}case 5:{let a=c(new Map,e);for(let[b,c]of g)a.set(d(b),d(c));return a}case 6:{let a=c(new Set,e);for(let b of g)a.add(d(b));return a}case 7:{let{name:a,message:b}=g;return c(new Nh[a](b),e)}case 8:return c(BigInt(g),e);case"BigInt":return c(Object(BigInt(g)),e);case"ArrayBuffer":return c(new Uint8Array(g).buffer,g);case"DataView":{let{buffer:a}=new Uint8Array(g);return c(new DataView(a),g)}}return c(new Nh[f](g),e)})(0)},{toString:Nj}={},{keys:Nk}=Object,Nl=a=>{let b=typeof a;if("object"!==b||!a)return[0,b];let c=Nj.call(a).slice(8,-1);switch(c){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,c]}return c.includes("Array")?[1,c]:c.includes("Error")?[7,c]:[2,c]},Nm=([a,b])=>0===a&&("function"===b||"symbol"===b),Nn=(a,{json:b,lossy:c}={})=>{var d,e,f;let g,h,i=[];return(d=!(b||c),e=!!b,f=new Map,g=(a,b)=>{let c=i.push(a)-1;return f.set(b,c),c},h=a=>{if(f.has(a))return f.get(a);let[b,c]=Nl(a);switch(b){case 0:{let e=a;switch(c){case"bigint":b=8,e=a.toString();break;case"function":case"symbol":if(d)throw TypeError("unable to serialize "+c);e=null;break;case"undefined":return g([-1],a)}return g([b,e],a)}case 1:{if(c){let b=a;return"DataView"===c?b=new Uint8Array(a.buffer):"ArrayBuffer"===c&&(b=new Uint8Array(a)),g([c,[...b]],a)}let d=[],e=g([b,d],a);for(let b of a)d.push(h(b));return e}case 2:{if(c)switch(c){case"BigInt":return g([c,a.toString()],a);case"Boolean":case"Number":case"String":return g([c,a.valueOf()],a)}if(e&&"toJSON"in a)return h(a.toJSON());let f=[],i=g([b,f],a);for(let b of Nk(a))(d||!Nm(Nl(a[b])))&&f.push([h(b),h(a[b])]);return i}case 3:return g([b,a.toISOString()],a);case 4:{let{source:c,flags:d}=a;return g([b,{source:c,flags:d}],a)}case 5:{let c=[],e=g([b,c],a);for(let[b,e]of a)(d||!(Nm(Nl(b))||Nm(Nl(e))))&&c.push([h(b),h(e)]);return e}case 6:{let c=[],e=g([b,c],a);for(let b of a)(d||!Nm(Nl(b)))&&c.push(h(b));return e}}let{message:i}=a;return g([b,{name:c,message:i}],a)})(a),i},No="function"==typeof structuredClone?(a,b)=>b&&("json"in b||"lossy"in b)?Ni(Nn(a,b)):structuredClone(a):(a,b)=>Ni(Nn(a,b));Nq(/[A-Za-z]/);let Np=Nq(/[\dA-Za-z]/);function Nq(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function Nr(a){let b=[],c=-1,d=0,e=0;for(;++c<a.length;){let f=a.charCodeAt(c),g="";if(37===f&&Np(a.charCodeAt(c+1))&&Np(a.charCodeAt(c+2)))e=2;else if(f<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(f))||(g=String.fromCharCode(f));else if(f>55295&&f<57344){let b=a.charCodeAt(c+1);f<56320&&b>56319&&b<57344?(g=String.fromCharCode(f,b),e=1):g="�"}else g=String.fromCharCode(f);g&&(b.push(a.slice(d,c),encodeURIComponent(g)),d=c+e+1,g=""),e&&(c+=e,e=0)}return b.join("")+a.slice(d)}function Ns(a,b){let c=[{type:"text",value:"↩"}];return b>1&&c.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(b)}]}),c}function Nt(a,b){return"Back to reference "+(a+1)+(b>1?"-"+b:"")}Nq(/[#-'*+\--9=?A-Z^-~]/),Nq(/\d/),Nq(/[\dA-Fa-f]/),Nq(/[!-/:-@[-`{-~]/),Nq(/\p{P}|\p{S}/u),Nq(/\s/);let Nu=function(a){var b,c;if(null==a)return Nw;if("function"==typeof a)return Nv(a);if("object"==typeof a){return Array.isArray(a)?function(a){let b=[],c=-1;for(;++c<a.length;)b[c]=Nu(a[c]);return Nv(function(...a){let c=-1;for(;++c<b.length;)if(b[c].apply(this,a))return!0;return!1})}(a):(b=a,Nv(function(a){let c;for(c in b)if(a[c]!==b[c])return!1;return!0}))}if("string"==typeof a){return c=a,Nv(function(a){return a&&a.type===c})}throw Error("Expected function, string, or object as test")};function Nv(a){return function(b,c,d){return!!(function(a){return null!==a&&"object"==typeof a&&"type"in a}(b)&&a.call(this,b,"number"==typeof c?c:void 0,d||void 0))}}function Nw(){return!0}let Nx=[];function Ny(a,b,c,d){let e;"function"==typeof b&&"function"!=typeof c?(d=c,c=b):e=b;let f=Nu(e),g=d?-1:1;(function a(e,h,i){let j=e&&"object"==typeof e?e:{};if("string"==typeof j.type){let a="string"==typeof j.tagName?j.tagName:"string"==typeof j.name?j.name:void 0;Object.defineProperty(k,"name",{value:"node (\x1b[33m"+e.type+(a?"<"+a+">":"")+"\x1b[39m)"})}return k;function k(){var j;let k,l,n,o=Nx;if((!b||f(e,h,i[i.length-1]||void 0))&&!1===(o=Array.isArray(j=c(e,i))?j:"number"==typeof j?[!0,j]:null==j?Nx:[j])[0])return o;if("children"in e&&e.children&&e.children&&"skip"!==o[0])for(l=(d?e.children.length:-1)+g,n=i.concat(e);l>-1&&l<e.children.length;){if(!1===(k=a(e.children[l],l,n)())[0])return k;l="number"==typeof k[1]?k[1]:l+g}return o}})(a,void 0,[])()}function Nz(a,b,c,d){let e,f,g;"function"==typeof b&&"function"!=typeof c?(f=void 0,g=b,e=c):(f=b,g=c,e=d),Ny(a,f,function(a,b){let c=b[b.length-1],d=c?c.children.indexOf(a):void 0;return g(a,d,c)},e)}function NA(a,b){let c=b.referenceType,d="]";if("collapsed"===c?d+="[]":"full"===c&&(d+="["+(b.label||b.identifier)+"]"),"imageReference"===b.type)return[{type:"text",value:"!["+b.alt+d}];let e=a.all(b),f=e[0];f&&"text"===f.type?f.value="["+f.value:e.unshift({type:"text",value:"["});let g=e[e.length-1];return g&&"text"===g.type?g.value+=d:e.push({type:"text",value:d}),e}function NB(a){let b=a.spread;return null==b?a.children.length>1:b}function NC(a,b,c){let d=0,e=a.length;if(b){let b=a.codePointAt(d);for(;9===b||32===b;)d++,b=a.codePointAt(d)}if(c){let b=a.codePointAt(e-1);for(;9===b||32===b;)e--,b=a.codePointAt(e-1)}return e>d?a.slice(d,e):""}let ND={blockquote:function(a,b){let c={type:"element",tagName:"blockquote",properties:{},children:a.wrap(a.all(b),!0)};return a.patch(b,c),a.applyData(b,c)},break:function(a,b){let c={type:"element",tagName:"br",properties:{},children:[]};return a.patch(b,c),[a.applyData(b,c),{type:"text",value:"\n"}]},code:function(a,b){let c=b.value?b.value+"\n":"",d={},e=b.lang?b.lang.split(/\s+/):[];e.length>0&&(d.className=["language-"+e[0]]);let f={type:"element",tagName:"code",properties:d,children:[{type:"text",value:c}]};return b.meta&&(f.data={meta:b.meta}),a.patch(b,f),f={type:"element",tagName:"pre",properties:{},children:[f=a.applyData(b,f)]},a.patch(b,f),f},delete:function(a,b){let c={type:"element",tagName:"del",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},emphasis:function(a,b){let c={type:"element",tagName:"em",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},footnoteReference:function(a,b){let c,d="string"==typeof a.options.clobberPrefix?a.options.clobberPrefix:"user-content-",e=String(b.identifier).toUpperCase(),f=Nr(e.toLowerCase()),g=a.footnoteOrder.indexOf(e),h=a.footnoteCounts.get(e);void 0===h?(h=0,a.footnoteOrder.push(e),c=a.footnoteOrder.length):c=g+1,h+=1,a.footnoteCounts.set(e,h);let i={type:"element",tagName:"a",properties:{href:"#"+d+"fn-"+f,id:d+"fnref-"+f+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};a.patch(b,i);let j={type:"element",tagName:"sup",properties:{},children:[i]};return a.patch(b,j),a.applyData(b,j)},heading:function(a,b){let c={type:"element",tagName:"h"+b.depth,properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},html:function(a,b){if(a.options.allowDangerousHtml){let c={type:"raw",value:b.value};return a.patch(b,c),a.applyData(b,c)}},imageReference:function(a,b){let c=String(b.identifier).toUpperCase(),d=a.definitionById.get(c);if(!d)return NA(a,b);let e={src:Nr(d.url||""),alt:b.alt};null!==d.title&&void 0!==d.title&&(e.title=d.title);let f={type:"element",tagName:"img",properties:e,children:[]};return a.patch(b,f),a.applyData(b,f)},image:function(a,b){let c={src:Nr(b.url)};null!==b.alt&&void 0!==b.alt&&(c.alt=b.alt),null!==b.title&&void 0!==b.title&&(c.title=b.title);let d={type:"element",tagName:"img",properties:c,children:[]};return a.patch(b,d),a.applyData(b,d)},inlineCode:function(a,b){let c={type:"text",value:b.value.replace(/\r?\n|\r/g," ")};a.patch(b,c);let d={type:"element",tagName:"code",properties:{},children:[c]};return a.patch(b,d),a.applyData(b,d)},linkReference:function(a,b){let c=String(b.identifier).toUpperCase(),d=a.definitionById.get(c);if(!d)return NA(a,b);let e={href:Nr(d.url||"")};null!==d.title&&void 0!==d.title&&(e.title=d.title);let f={type:"element",tagName:"a",properties:e,children:a.all(b)};return a.patch(b,f),a.applyData(b,f)},link:function(a,b){let c={href:Nr(b.url)};null!==b.title&&void 0!==b.title&&(c.title=b.title);let d={type:"element",tagName:"a",properties:c,children:a.all(b)};return a.patch(b,d),a.applyData(b,d)},listItem:function(a,b,c){let d=a.all(b),e=c?function(a){let b=!1;if("list"===a.type){b=a.spread||!1;let c=a.children,d=-1;for(;!b&&++d<c.length;)b=NB(c[d])}return b}(c):NB(b),f={},g=[];if("boolean"==typeof b.checked){let a,c=d[0];c&&"element"===c.type&&"p"===c.tagName?a=c:(a={type:"element",tagName:"p",properties:{},children:[]},d.unshift(a)),a.children.length>0&&a.children.unshift({type:"text",value:" "}),a.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:b.checked,disabled:!0},children:[]}),f.className=["task-list-item"]}let h=-1;for(;++h<d.length;){let a=d[h];(e||0!==h||"element"!==a.type||"p"!==a.tagName)&&g.push({type:"text",value:"\n"}),"element"!==a.type||"p"!==a.tagName||e?g.push(a):g.push(...a.children)}let i=d[d.length-1];i&&(e||"element"!==i.type||"p"!==i.tagName)&&g.push({type:"text",value:"\n"});let j={type:"element",tagName:"li",properties:f,children:g};return a.patch(b,j),a.applyData(b,j)},list:function(a,b){let c={},d=a.all(b),e=-1;for("number"==typeof b.start&&1!==b.start&&(c.start=b.start);++e<d.length;){let a=d[e];if("element"===a.type&&"li"===a.tagName&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){c.className=["contains-task-list"];break}}let f={type:"element",tagName:b.ordered?"ol":"ul",properties:c,children:a.wrap(d,!0)};return a.patch(b,f),a.applyData(b,f)},paragraph:function(a,b){let c={type:"element",tagName:"p",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},root:function(a,b){let c={type:"root",children:a.wrap(a.all(b))};return a.patch(b,c),a.applyData(b,c)},strong:function(a,b){let c={type:"element",tagName:"strong",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},table:function(a,b){let c=a.all(b),d=c.shift(),e=[];if(d){let c={type:"element",tagName:"thead",properties:{},children:a.wrap([d],!0)};a.patch(b.children[0],c),e.push(c)}if(c.length>0){let d={type:"element",tagName:"tbody",properties:{},children:a.wrap(c,!0)},f=Ls(b.children[1]),g=Lr(b.children[b.children.length-1]);f&&g&&(d.position={start:f,end:g}),e.push(d)}let f={type:"element",tagName:"table",properties:{},children:a.wrap(e,!0)};return a.patch(b,f),a.applyData(b,f)},tableCell:function(a,b){let c={type:"element",tagName:"td",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},tableRow:function(a,b,c){let d=c?c.children:void 0,e=0===(d?d.indexOf(b):1)?"th":"td",f=c&&"table"===c.type?c.align:void 0,g=f?f.length:b.children.length,h=-1,i=[];for(;++h<g;){let c=b.children[h],d={},g=f?f[h]:void 0;g&&(d.align=g);let j={type:"element",tagName:e,properties:d,children:[]};c&&(j.children=a.all(c),a.patch(c,j),j=a.applyData(c,j)),i.push(j)}let j={type:"element",tagName:"tr",properties:{},children:a.wrap(i,!0)};return a.patch(b,j),a.applyData(b,j)},text:function(a,b){let c={type:"text",value:function(a){let b=String(a),c=/\r?\n|\r/g,d=c.exec(b),e=0,f=[];for(;d;)f.push(NC(b.slice(e,d.index),e>0,!0),d[0]),e=d.index+d[0].length,d=c.exec(b);return f.push(NC(b.slice(e),e>0,!1)),f.join("")}(String(b.value))};return a.patch(b,c),a.applyData(b,c)},thematicBreak:function(a,b){let c={type:"element",tagName:"hr",properties:{},children:[]};return a.patch(b,c),a.applyData(b,c)},toml:NE,yaml:NE,definition:NE,footnoteDefinition:NE};function NE(){}let NF={}.hasOwnProperty,NG={};function NH(a,b){a.position&&(b.position=function(a){let b=Ls(a),c=Lr(a);if(b&&c)return{start:b,end:c}}(a))}function NI(a,b){let c=b;if(a&&a.data){let b=a.data.hName,d=a.data.hChildren,e=a.data.hProperties;"string"==typeof b&&("element"===c.type?c.tagName=b:c={type:"element",tagName:b,properties:{},children:"children"in c?c.children:[c]}),"element"===c.type&&e&&Object.assign(c.properties,No(e)),"children"in c&&c.children&&null!=d&&(c.children=d)}return c}function NJ(a,b){let c=[],d=-1;for(b&&c.push({type:"text",value:"\n"});++d<a.length;)d&&c.push({type:"text",value:"\n"}),c.push(a[d]);return b&&a.length>0&&c.push({type:"text",value:"\n"}),c}function NK(a){let b=0,c=a.charCodeAt(b);for(;9===c||32===c;)b++,c=a.charCodeAt(b);return a.slice(b)}function NL(a,b){let c,d,e,f,g=(c=b||NG,d=new Map,e=new Map,f={all:function(a){let b=[];if("children"in a){let c=a.children,d=-1;for(;++d<c.length;){let e=f.one(c[d],a);if(e){if(d&&"break"===c[d-1].type&&(Array.isArray(e)||"text"!==e.type||(e.value=NK(e.value)),!Array.isArray(e)&&"element"===e.type)){let a=e.children[0];a&&"text"===a.type&&(a.value=NK(a.value))}Array.isArray(e)?b.push(...e):b.push(e)}}}return b},applyData:NI,definitionById:d,footnoteById:e,footnoteCounts:new Map,footnoteOrder:[],handlers:{...ND,...c.handlers},one:function(a,b){let c=a.type,d=f.handlers[c];if(NF.call(f.handlers,c)&&d)return d(f,a,b);if(f.options.passThrough&&f.options.passThrough.includes(c)){if("children"in a){let{children:b,...c}=a,d=No(c);return d.children=f.all(a),d}return No(a)}return(f.options.unknownHandler||function(a,b){let c=b.data||{},d="value"in b&&!(NF.call(c,"hProperties")||NF.call(c,"hChildren"))?{type:"text",value:b.value}:{type:"element",tagName:"div",properties:{},children:a.all(b)};return a.patch(b,d),a.applyData(b,d)})(f,a,b)},options:c,patch:NH,wrap:NJ},Nz(a,function(a){if("definition"===a.type||"footnoteDefinition"===a.type){let b="definition"===a.type?d:e,c=String(a.identifier).toUpperCase();b.has(c)||b.set(c,a)}}),f),h=g.one(a,void 0),i=function(a){let b="string"==typeof a.options.clobberPrefix?a.options.clobberPrefix:"user-content-",c=a.options.footnoteBackContent||Ns,d=a.options.footnoteBackLabel||Nt,e=a.options.footnoteLabel||"Footnotes",f=a.options.footnoteLabelTagName||"h2",g=a.options.footnoteLabelProperties||{className:["sr-only"]},h=[],i=-1;for(;++i<a.footnoteOrder.length;){let e=a.footnoteById.get(a.footnoteOrder[i]);if(!e)continue;let f=a.all(e),g=String(e.identifier).toUpperCase(),j=Nr(g.toLowerCase()),k=0,l=[],n=a.footnoteCounts.get(g);for(;void 0!==n&&++k<=n;){l.length>0&&l.push({type:"text",value:" "});let a="string"==typeof c?c:c(i,k);"string"==typeof a&&(a={type:"text",value:a}),l.push({type:"element",tagName:"a",properties:{href:"#"+b+"fnref-"+j+(k>1?"-"+k:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof d?d:d(i,k),className:["data-footnote-backref"]},children:Array.isArray(a)?a:[a]})}let o=f[f.length-1];if(o&&"element"===o.type&&"p"===o.tagName){let a=o.children[o.children.length-1];a&&"text"===a.type?a.value+=" ":o.children.push({type:"text",value:" "}),o.children.push(...l)}else f.push(...l);let p={type:"element",tagName:"li",properties:{id:b+"fn-"+j},children:a.wrap(f,!0)};a.patch(e,p),h.push(p)}if(0!==h.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:f,properties:{...No(g),id:"footnote-label"},children:[{type:"text",value:e}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:a.wrap(h,!0)},{type:"text",value:"\n"}]}}(g),j=Array.isArray(h)?{type:"root",children:h}:h||{type:"root",children:[]};return i&&(KN("children"in j),j.children.push({type:"text",value:"\n"},i)),j}function NM(a,b){return a&&"run"in a?async function(c,d){let e=NL(c,{file:d,...b});await a.run(e,d)}:function(c,d){return NL(c,{file:d,...a||b})}}function NN(a){if(a)throw a}var NO=a.i(97599);function NP(a){if("object"!=typeof a||null===a)return!1;let b=Object.getPrototypeOf(a);return(null===b||b===Object.prototype||null===Object.getPrototypeOf(b))&&!(Symbol.toStringTag in a)&&!(Symbol.iterator in a)}var NQ=a.i(50227),NQ=NQ,NR=a.i(59639),NR=NR,NS=a.i(57764),NS=NS;function NT(a){return!!(null!==a&&"object"==typeof a&&"href"in a&&a.href&&"protocol"in a&&a.protocol&&void 0===a.auth)}let NU=["history","path","basename","stem","extname","dirname"];class NV{constructor(a){let b,c;b=a?NT(a)?{path:a}:"string"==typeof a||function(a){return!!(a&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a)}(a)?{value:a}:a:{},this.cwd="cwd"in b?"":NR.default.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let d=-1;for(;++d<NU.length;){const a=NU[d];a in b&&void 0!==b[a]&&null!==b[a]&&(this[a]="history"===a?[...b[a]]:b[a])}for(c in b)NU.includes(c)||(this[c]=b[c])}get basename(){return"string"==typeof this.path?NQ.default.basename(this.path):void 0}set basename(a){NX(a,"basename"),NW(a,"basename"),this.path=NQ.default.join(this.dirname||"",a)}get dirname(){return"string"==typeof this.path?NQ.default.dirname(this.path):void 0}set dirname(a){NY(this.basename,"dirname"),this.path=NQ.default.join(a||"",this.basename)}get extname(){return"string"==typeof this.path?NQ.default.extname(this.path):void 0}set extname(a){if(NW(a,"extname"),NY(this.dirname,"extname"),a){if(46!==a.codePointAt(0))throw Error("`extname` must start with `.`");if(a.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=NQ.default.join(this.dirname,this.stem+(a||""))}get path(){return this.history[this.history.length-1]}set path(a){NT(a)&&(a=(0,NS.fileURLToPath)(a)),NX(a,"path"),this.path!==a&&this.history.push(a)}get stem(){return"string"==typeof this.path?NQ.default.basename(this.path,this.extname):void 0}set stem(a){NX(a,"stem"),NW(a,"stem"),this.path=NQ.default.join(this.dirname||"",a+(this.extname||""))}fail(a,b,c){let d=this.message(a,b,c);throw d.fatal=!0,d}info(a,b,c){let d=this.message(a,b,c);return d.fatal=void 0,d}message(a,b,c){let d=new Ly(a,b,c);return this.path&&(d.name=this.path+":"+d.name,d.file=this.path),d.fatal=!1,this.messages.push(d),d}toString(a){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(a||void 0).decode(this.value)}}function NW(a,b){if(a&&a.includes(NQ.default.sep))throw Error("`"+b+"` cannot be a path: did not expect `"+NQ.default.sep+"`")}function NX(a,b){if(!a)throw Error("`"+b+"` cannot be empty")}function NY(a,b){if(!a)throw Error("Setting `"+b+"` requires `path` to be set too")}let NZ=function(a){let b=this.constructor.prototype,c=b[a],d=function(){return c.apply(d,arguments)};return Object.setPrototypeOf(d,b),d},N$={}.hasOwnProperty;class N_ extends NZ{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let a=[],b={run:function(...b){let c=-1,d=b.pop();if("function"!=typeof d)throw TypeError("Expected function as last argument, not "+d);!function e(f,...g){let h=a[++c],i=-1;if(f)return void d(f);for(;++i<b.length;)(null===g[i]||void 0===g[i])&&(g[i]=b[i]);b=g,h?(function(a,b){let c;return function(...b){let f,g=a.length>b.length;g&&b.push(d);try{f=a.apply(this,b)}catch(a){if(g&&c)throw a;return d(a)}g||(f&&f.then&&"function"==typeof f.then?f.then(e,d):f instanceof Error?d(f):e(f))};function d(a,...e){c||(c=!0,b(a,...e))}function e(a){d(null,a)}})(h,e)(...g):d(null,...g)}(null,...b)},use:function(c){if("function"!=typeof c)throw TypeError("Expected `middelware` to be a function, not "+c);return a.push(c),b}};return b}()}copy(){let a=new N_,b=-1;for(;++b<this.attachers.length;){let c=this.attachers[b];a.use(...c)}return a.data((0,NO.default)(!0,{},this.namespace)),a}data(a,b){return"string"==typeof a?2==arguments.length?(N3("data",this.frozen),this.namespace[a]=b,this):N$.call(this.namespace,a)&&this.namespace[a]||void 0:a?(N3("data",this.frozen),this.namespace=a,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[a,...b]=this.attachers[this.freezeIndex];if(!1===b[0])continue;!0===b[0]&&(b[0]=void 0);let c=a.call(this,...b);"function"==typeof c&&this.transformers.use(c)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(a){this.freeze();let b=N6(a),c=this.parser||this.Parser;return N1("parse",c),c(String(b),b)}process(a,b){let c=this;return this.freeze(),N1("process",this.parser||this.Parser),N2("process",this.compiler||this.Compiler),b?d(void 0,b):new Promise(d);function d(d,e){let f=N6(a),g=c.parse(f);function h(a,c){a||!c?e(a):d?d(c):(KN(b,"`done` is defined if `resolve` is not"),b(void 0,c))}c.run(g,f,function(a,b,d){var e,f;if(a||!b||!d)return h(a);let g=c.stringify(b,d);"string"==typeof(e=g)||(f=e)&&"object"==typeof f&&"byteLength"in f&&"byteOffset"in f?d.value=g:d.result=g,h(a,d)})}}processSync(a){let b,c=!1;return this.freeze(),N1("processSync",this.parser||this.Parser),N2("processSync",this.compiler||this.Compiler),this.process(a,function(a,d){c=!0,NN(a),b=d}),N5("processSync","process",c),KN(b,"we either bailed on an error or have a tree"),b}run(a,b,c){N4(a),this.freeze();let d=this.transformers;return c||"function"!=typeof b||(c=b,b=void 0),c?e(void 0,c):new Promise(e);function e(e,f){KN("function"!=typeof b,"`file` can’t be a `done` anymore, we checked");let g=N6(b);d.run(a,g,function(b,d,g){let h=d||a;b?f(b):e?e(h):(KN(c,"`done` is defined if `resolve` is not"),c(void 0,h,g))})}}runSync(a,b){let c,d=!1;return this.run(a,b,function(a,b){NN(a),c=b,d=!0}),N5("runSync","run",d),KN(c,"we either bailed on an error or have a tree"),c}stringify(a,b){this.freeze();let c=N6(b),d=this.compiler||this.Compiler;return N2("stringify",d),N4(a),d(a,c)}use(a,...b){let c=this.attachers,d=this.namespace;if(N3("use",this.frozen),null==a);else if("function"==typeof a)g(a,b);else if("object"==typeof a)Array.isArray(a)?f(a):e(a);else throw TypeError("Expected usable value, not `"+a+"`");return this;function e(a){if(!("plugins"in a)&&!("settings"in a))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(a.plugins),a.settings&&(d.settings=(0,NO.default)(!0,d.settings,a.settings))}function f(a){let b=-1;if(null==a);else if(Array.isArray(a))for(;++b<a.length;)!function(a){if("function"==typeof a)g(a,[]);else if("object"==typeof a)if(Array.isArray(a)){let[b,...c]=a;g(b,c)}else e(a);else throw TypeError("Expected usable value, not `"+a+"`")}(a[b]);else throw TypeError("Expected a list of plugins, not `"+a+"`")}function g(a,b){let d=-1,e=-1;for(;++d<c.length;)if(c[d][0]===a){e=d;break}if(-1===e)c.push([a,...b]);else if(b.length>0){let[d,...f]=b,g=c[e][1];NP(g)&&NP(d)&&(d=(0,NO.default)(!0,g,d)),c[e]=[a,d,...f]}}}}let N0=new N_().freeze();function N1(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `parser`")}function N2(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `compiler`")}function N3(a,b){if(b)throw Error("Cannot call `"+a+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function N4(a){if(!NP(a)||"string"!=typeof a.type)throw TypeError("Expected node, got `"+a+"`")}function N5(a,b,c){if(!c)throw Error("`"+a+"` finished async. Use `"+b+"` instead")}function N6(a){var b;return(b=a)&&"object"==typeof b&&"message"in b&&"messages"in b?a:new NV(a)}let N7=[],N8={allowDangerousHtml:!0},N9=/^(https?|ircs?|mailto|xmpp)$/i,Oa=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Ob(a){var b;let c,d,e,f,g,h=(c=(b=a).rehypePlugins||N7,d=b.remarkPlugins||N7,e=b.remarkRehypeOptions?{...b.remarkRehypeOptions,...N8}:N8,N0().use(Ng).use(d).use(NM,e).use(c)),i=(f=a.children||"",g=new NV,"string"==typeof f?g.value=f:KO("Unexpected value `"+f+"` for `children` prop, expected `string`"),g);return function(a,b){let c=b.allowedElements,d=b.allowElement,e=b.components,f=b.disallowedElements,g=b.skipHtml,h=b.unwrapDisallowed,i=b.urlTransform||Oc;for(let a of Oa)Object.hasOwn(b,a.from)&&KO("Unexpected `"+a.from+"` prop, "+(a.to?"use `"+a.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+a.id+"> for more info)");return c&&f&&KO("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),Nz(a,function(a,b,e){if("raw"===a.type&&e&&"number"==typeof b)return g?e.children.splice(b,1):e.children[b]={type:"text",value:a.value},b;if("element"===a.type){let b;for(b in LM)if(Object.hasOwn(LM,b)&&Object.hasOwn(a.properties,b)){let c=a.properties[b],d=LM[b];(null===d||d.includes(a.tagName))&&(a.properties[b]=i(String(c||""),b,a))}}if("element"===a.type){let g=c?!c.includes(a.tagName):!!f&&f.includes(a.tagName);if(!g&&d&&"number"==typeof b&&(g=!d(a,b,e)),g&&e&&"number"==typeof b)return h&&a.children?e.children.splice(b,1,...a.children):e.children.splice(b,1),b}}),function(a,b){var c,d,e,f;let g;if(!b||void 0===b.Fragment)throw TypeError("Expected `Fragment` in options");let h=b.filePath||void 0;if(b.development){if("function"!=typeof b.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");c=h,d=b.jsxDEV,g=function(a,b,e,f){let g=Array.isArray(e.children),h=Ls(a);return d(b,e,f,g,{columnNumber:h?h.column-1:void 0,fileName:c,lineNumber:h?h.line:void 0},void 0)}}else{if("function"!=typeof b.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof b.jsxs)throw TypeError("Expected `jsxs` in production options");e=b.jsx,f=b.jsxs,g=function(a,b,c,d){let g=Array.isArray(c.children)?f:e;return d?g(b,c,d):g(b,c)}}let i={Fragment:b.Fragment,ancestors:[],components:b.components||{},create:g,elementAttributeNameCase:b.elementAttributeNameCase||"react",evaluater:b.createEvaluater?b.createEvaluater():void 0,filePath:h,ignoreInvalidStyle:b.ignoreInvalidStyle||!1,passKeys:!1!==b.passKeys,passNode:b.passNode||!1,schema:"svg"===b.space?Lp:Lo,stylePropertyNameCase:b.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==b.tableCellAlignToStyle},j=LF(i,a,void 0);return j&&"string"!=typeof j?j:i.create(a,i.Fragment,{children:j||void 0},void 0)}(a,{Fragment:B.Fragment,components:e,ignoreInvalidStyle:!0,jsx:B.jsx,jsxs:B.jsxs,passKeys:!0,passNode:!0})}(h.runSync(h.parse(i),i),a)}function Oc(a){let b=a.indexOf(":"),c=a.indexOf("?"),d=a.indexOf("#"),e=a.indexOf("/");return -1===b||-1!==e&&b>e||-1!==c&&b>c||-1!==d&&b>d||N9.test(a.slice(0,b))?a:""}function Od(a,b){let c=String(a);if("string"!=typeof b)throw TypeError("Expected character");let d=0,e=c.indexOf(b);for(;-1!==e;)d++,e=c.indexOf(b,e+b.length);return d}Og(/[A-Za-z]/),Og(/[\dA-Za-z]/),Og(/[#-'*+\--9=?A-Z^-~]/),Og(/\d/),Og(/[\dA-Fa-f]/),Og(/[!-/:-@[-`{-~]/);let Oe=Og(/\p{P}|\p{S}/u),Of=Og(/\s/);function Og(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let Oh="phrasing",Oi=["autolink","link","image","label"];function Oj(a){this.enter({type:"link",title:null,url:"",children:[]},a)}function Ok(a){this.config.enter.autolinkProtocol.call(this,a)}function Ol(a){this.config.exit.autolinkProtocol.call(this,a)}function Om(a){this.config.exit.data.call(this,a);let b=this.stack[this.stack.length-1];KN("link"===b.type),b.url="http://"+this.sliceSerialize(a)}function On(a){this.config.exit.autolinkEmail.call(this,a)}function Oo(a){this.exit(a)}function Op(a){!function(a,b,c){let d=Nu((c||{}).ignore||[]),e=function(a){let b=[];if(!Array.isArray(a))throw TypeError("Expected find and replace tuple or list of tuples");let c=!a[0]||Array.isArray(a[0])?a:[a],d=-1;for(;++d<c.length;){var e;let a=c[d];b.push(["string"==typeof(e=a[0])?RegExp(function(a){if("string"!=typeof a)throw TypeError("Expected a string");return a.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e,function(a){return"function"==typeof a?a:function(){return a}}(a[1])])}return b}(b),f=-1;for(;++f<e.length;)Ny(a,"text",g);function g(a,b){let c,g=-1;for(;++g<b.length;){let a=b[g],e=c?c.children:void 0;if(d(a,e?e.indexOf(a):void 0,c))return;c=a}if(c)return function(a,b){let c=b[b.length-1],d=e[f][0],g=e[f][1],h=0,i=c.children.indexOf(a),j=!1,k=[];d.lastIndex=0;let l=d.exec(a.value);for(;l;){let c=l.index,e={index:l.index,input:l.input,stack:[...b,a]},f=g(...l,e);if("string"==typeof f&&(f=f.length>0?{type:"text",value:f}:void 0),!1===f?d.lastIndex=c+1:(h!==c&&k.push({type:"text",value:a.value.slice(h,c)}),Array.isArray(f)?k.push(...f):f&&k.push(f),h=c+l[0].length,j=!0),!d.global)break;l=d.exec(a.value)}return j?(h<a.value.length&&k.push({type:"text",value:a.value.slice(h)}),c.children.splice(i,1,...k)):k=[a],i+k.length}(a,b)}}(a,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Oq],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Or]],{ignore:["link","linkReference"]})}function Oq(a,b,c,d,e){let f,g="";if(!Os(e))return!1;if(/^w/i.test(b)&&(c=b+c,b="",g="http://"),(f=c.split(".")).length<2||f[f.length-1]&&(/_/.test(f[f.length-1])||!/[a-zA-Z\d]/.test(f[f.length-1]))||f[f.length-2]&&(/_/.test(f[f.length-2])||!/[a-zA-Z\d]/.test(f[f.length-2])))return!1;let h=function(a){let b=/[!"&'),.:;<>?\]}]+$/.exec(a);if(!b)return[a,void 0];a=a.slice(0,b.index);let c=b[0],d=c.indexOf(")"),e=Od(a,"("),f=Od(a,")");for(;-1!==d&&e>f;)a+=c.slice(0,d+1),d=(c=c.slice(d+1)).indexOf(")"),f++;return[a,c]}(c+d);if(!h[0])return!1;let i={type:"link",title:null,url:g+b+h[0],children:[{type:"text",value:b+h[0]}]};return h[1]?[i,{type:"text",value:h[1]}]:i}function Or(a,b,c,d){return!(!Os(d,!0)||/[-\d_]$/.test(c))&&{type:"link",title:null,url:"mailto:"+b+"@"+c,children:[{type:"text",value:b+"@"+c}]}}function Os(a,b){let c=a.input.charCodeAt(a.index-1);return(0===a.index||Of(c)||Oe(c))&&(!b||47!==c)}function Ot(){this.buffer()}function Ou(a){this.enter({type:"footnoteReference",identifier:"",label:""},a)}function Ov(){this.buffer()}function Ow(a){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},a)}function Ox(a){let b=this.resume(),c=this.stack[this.stack.length-1];KN("footnoteReference"===c.type),c.identifier=MS(this.sliceSerialize(a)).toLowerCase(),c.label=b}function Oy(a){this.exit(a)}function Oz(a){let b=this.resume(),c=this.stack[this.stack.length-1];KN("footnoteDefinition"===c.type),c.identifier=MS(this.sliceSerialize(a)).toLowerCase(),c.label=b}function OA(a){this.exit(a)}function OB(a,b,c,d){let e=c.createTracker(d),f=e.move("[^"),g=c.enter("footnoteReference"),h=c.enter("reference");return f+=e.move(c.safe(c.associationId(a),{after:"]",before:f})),h(),g(),f+=e.move("]")}function OC(a,b,c){return 0===b?a:OD(a,b,c)}function OD(a,b,c){return(c?"":" ")+a}OB.peek=function(){return"["};let OE=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function OF(a){this.enter({type:"delete",children:[]},a)}function OG(a){this.exit(a)}function OH(a,b,c,d){let e=c.createTracker(d),f=c.enter("strikethrough"),g=e.move("~~");return g+=c.containerPhrasing(a,{...e.current(),before:g,after:"~"}),g+=e.move("~~"),f(),g}function OI(a){return a.length}function OJ(a){let b="string"==typeof a?a.codePointAt(0):0;return 67===b||99===b?99:76===b||108===b?108:114*(82===b||114===b)}OH.peek=function(){return"~"};function OK(a,b,c){let d=a.value||"",e="`",f=-1;for(;RegExp("(^|[^`])"+e+"([^`]|$)").test(d);)e+="`";for(/[^ \r\n]/.test(d)&&(/^[ \r\n]/.test(d)&&/[ \r\n]$/.test(d)||/^`|`$/.test(d))&&(d=" "+d+" ");++f<c.unsafe.length;){let a,b=c.unsafe[f],e=c.compilePattern(b);if(b.atBreak)for(;a=e.exec(d);){let b=a.index;10===d.charCodeAt(b)&&13===d.charCodeAt(b-1)&&b--,d=d.slice(0,b)+" "+d.slice(a.index+1)}}return e+d+e}OK.peek=function(){return"`"};Nu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let OL=function(a,b,c,d){let e=function(a){let b=a.options.listItemIndent||"one";if("tab"!==b&&"one"!==b&&"mixed"!==b)throw Error("Cannot serialize items with `"+b+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return b}(c),f=c.bulletCurrent||function(a){let b=a.options.bullet||"*";if("*"!==b&&"+"!==b&&"-"!==b)throw Error("Cannot serialize items with `"+b+"` for `options.bullet`, expected `*`, `+`, or `-`");return b}(c);b&&"list"===b.type&&b.ordered&&(f=("number"==typeof b.start&&b.start>-1?b.start:1)+(!1===c.options.incrementListMarker?0:b.children.indexOf(a))+f);let g=f.length+1;("tab"===e||"mixed"===e&&(b&&"list"===b.type&&b.spread||a.spread))&&(g=4*Math.ceil(g/4));let h=c.createTracker(d);h.move(f+" ".repeat(g-f.length)),h.shift(g);let i=c.enter("listItem"),j=c.indentLines(c.containerFlow(a,h.current()),function(a,b,c){return b?(c?"":" ".repeat(g))+a:(c?f:f+" ".repeat(g-f.length))+a});return i(),j};function OM(a){let b=a._align;KN(b,"expected `_align` on table"),this.enter({type:"table",align:b.map(function(a){return"none"===a?null:a}),children:[]},a),this.data.inTable=!0}function ON(a){this.exit(a),this.data.inTable=void 0}function OO(a){this.enter({type:"tableRow",children:[]},a)}function OP(a){this.exit(a)}function OQ(a){this.enter({type:"tableCell",children:[]},a)}function OR(a){let b=this.resume();this.data.inTable&&(b=b.replace(/\\([\\|])/g,OS));let c=this.stack[this.stack.length-1];KN("inlineCode"===c.type),c.value=b,this.exit(a)}function OS(a,b){return"|"===b?b:a}function OT(a){let b=this.stack[this.stack.length-2];KN("listItem"===b.type),b.checked="taskListCheckValueChecked"===a.type}function OU(a){let b=this.stack[this.stack.length-2];if(b&&"listItem"===b.type&&"boolean"==typeof b.checked){let a=this.stack[this.stack.length-1];KN("paragraph"===a.type);let c=a.children[0];if(c&&"text"===c.type){let d,e=b.children,f=-1;for(;++f<e.length;){let a=e[f];if("paragraph"===a.type){d=a;break}}d===a&&(c.value=c.value.slice(1),0===c.value.length?a.children.shift():a.position&&c.position&&"number"==typeof c.position.start.offset&&(c.position.start.column++,c.position.start.offset++,a.position.start=Object.assign({},c.position.start)))}}this.exit(a)}function OV(a,b,c,d){let e=a.children[0],f="boolean"==typeof a.checked&&e&&"paragraph"===e.type,g="["+(a.checked?"x":" ")+"] ",h=c.createTracker(d);f&&h.move(g);let i=OL(a,b,c,{...d,...h.current()});return f&&(i=i.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(a){return a+g})),i}let OW=O_(/[A-Za-z]/),OX=O_(/[\dA-Za-z]/);function OY(a){return null!==a&&(a<0||32===a)}O_(/[#-'*+\--9=?A-Z^-~]/),O_(/\d/),O_(/[\dA-Fa-f]/),O_(/[!-/:-@[-`{-~]/);let OZ=O_(/\p{P}|\p{S}/u),O$=O_(/\s/);function O_(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let O0={tokenize:function(a,b,c){let d=0;return function b(f){return(87===f||119===f)&&d<3?(d++,a.consume(f),b):46===f&&3===d?(a.consume(f),e):c(f)};function e(a){return null===a?c(a):b(a)}},partial:!0},O1={tokenize:function(a,b,c){let d,e,f;return g;function g(b){return 46===b||95===b?a.check(O3,i,h)(b):null===b||OY(b)||O$(b)||45!==b&&OZ(b)?i(b):(f=!0,a.consume(b),g)}function h(b){return 95===b?d=!0:(e=d,d=void 0),a.consume(b),g}function i(a){return e||d||!f?c(a):b(a)}},partial:!0},O2={tokenize:function(a,b){let c=0,d=0;return e;function e(g){return 40===g?(c++,a.consume(g),e):41===g&&d<c?f(g):33===g||34===g||38===g||39===g||41===g||42===g||44===g||46===g||58===g||59===g||60===g||63===g||93===g||95===g||126===g?a.check(O3,b,f)(g):null===g||OY(g)||O$(g)?b(g):(a.consume(g),e)}function f(b){return 41===b&&d++,a.consume(b),e}},partial:!0},O3={tokenize:function(a,b,c){return d;function d(g){return 33===g||34===g||39===g||41===g||42===g||44===g||46===g||58===g||59===g||63===g||95===g||126===g?(a.consume(g),d):38===g?(a.consume(g),f):93===g?(a.consume(g),e):60===g||null===g||OY(g)||O$(g)?b(g):c(g)}function e(a){return null===a||40===a||91===a||OY(a)||O$(a)?b(a):d(a)}function f(b){return OW(b)?function b(e){return 59===e?(a.consume(e),d):OW(e)?(a.consume(e),b):c(e)}(b):c(b)}},partial:!0},O4={tokenize:function(a,b,c){return function(b){return a.consume(b),d};function d(a){return OX(a)?c(a):b(a)}},partial:!0},O5={name:"wwwAutolink",tokenize:function(a,b,c){let d=this;return function(b){return 87!==b&&119!==b||!Pa.call(d,d.previous)||Pe(d.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(O0,a.attempt(O1,a.attempt(O2,e),c),c)(b))};function e(c){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),b(c)}},previous:Pa},O6={name:"protocolAutolink",tokenize:function(a,b,c){let d=this,e="",f=!1;return function(b){return(72===b||104===b)&&Pb.call(d,d.previous)&&!Pe(d.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),e+=String.fromCodePoint(b),a.consume(b),g):c(b)};function g(b){if(OW(b)&&e.length<5)return e+=String.fromCodePoint(b),a.consume(b),g;if(58===b){let c=e.toLowerCase();if("http"===c||"https"===c)return a.consume(b),h}return c(b)}function h(b){return 47===b?(a.consume(b),f)?i:(f=!0,h):c(b)}function i(b){return null===b||null!==b&&(b<32||127===b)||OY(b)||O$(b)||OZ(b)?c(b):a.attempt(O1,a.attempt(O2,j),c)(b)}function j(c){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),b(c)}},previous:Pb},O7={name:"emailAutolink",tokenize:function(a,b,c){let d,e,f=this;return function(b){return!Pd(b)||!Pc.call(f,f.previous)||Pe(f.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),function b(d){return Pd(d)?(a.consume(d),b):64===d?(a.consume(d),g):c(d)}(b))};function g(b){return 46===b?a.check(O4,i,h)(b):45===b||95===b||OX(b)?(e=!0,a.consume(b),g):i(b)}function h(b){return a.consume(b),d=!0,g}function i(g){return e&&d&&OW(f.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),b(g)):c(g)}},previous:Pc},O8={},O9=48;for(;O9<123;)O8[O9]=O7,58==++O9?O9=65:91===O9&&(O9=97);function Pa(a){return null===a||40===a||42===a||95===a||91===a||93===a||126===a||OY(a)}function Pb(a){return!OW(a)}function Pc(a){return!(47===a||Pd(a))}function Pd(a){return 43===a||45===a||46===a||95===a||OX(a)}function Pe(a){let b=a.length,c=!1;for(;b--;){let d=a[b][1];if(("labelLink"===d.type||"labelImage"===d.type)&&!d._balanced){c=!0;break}if(d._gfmAutolinkLiteralWalkedInto){c=!1;break}}return a.length>0&&!c&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),c}function Pf(a){return null!==a&&(a<0||32===a)}function Pg(a){return -2===a||-1===a||32===a}function Ph(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function Pi(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return Pg(d)?(a.enter(c),function d(g){return Pg(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}O8[43]=O7,O8[45]=O7,O8[46]=O7,O8[95]=O7,O8[72]=[O7,O6],O8[104]=[O7,O6],O8[87]=[O7,O5],O8[119]=[O7,O5],Ph(/[A-Za-z]/),Ph(/[\dA-Za-z]/),Ph(/[#-'*+\--9=?A-Z^-~]/),Ph(/\d/),Ph(/[\dA-Fa-f]/),Ph(/[!-/:-@[-`{-~]/),Ph(/\p{P}|\p{S}/u),Ph(/\s/);let Pj={tokenize:function(a,b,c){let d=this;return Pi(a,function(a){let e=d.events[d.events.length-1];return e&&"gfmFootnoteDefinitionIndent"===e[1].type&&4===e[2].sliceSerialize(e[1],!0).length?b(a):c(a)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function Pk(a,b,c){let d,e=this,f=e.events.length,g=e.parser.gfmFootnotes||(e.parser.gfmFootnotes=[]);for(;f--;){let a=e.events[f][1];if("labelImage"===a.type){d=a;break}if("gfmFootnoteCall"===a.type||"labelLink"===a.type||"label"===a.type||"image"===a.type||"link"===a.type)break}return function(f){if(!d||!d._balanced)return c(f);let h=MS(e.sliceSerialize({start:d.end,end:e.now()}));return 94===h.codePointAt(0)&&g.includes(h.slice(1))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(f),a.exit("gfmFootnoteCallLabelMarker"),b(f)):c(f)}}function Pl(a,b){let c=a.length;for(;c--;)if("labelImage"===a[c][1].type&&"enter"===a[c][0]){a[c][1];break}a[c+1][1].type="data",a[c+3][1].type="gfmFootnoteCallLabelMarker";let d={type:"gfmFootnoteCall",start:Object.assign({},a[c+3][1].start),end:Object.assign({},a[a.length-1][1].end)},e={type:"gfmFootnoteCallMarker",start:Object.assign({},a[c+3][1].end),end:Object.assign({},a[c+3][1].end)};e.end.column++,e.end.offset++,e.end._bufferIndex++;let f={type:"gfmFootnoteCallString",start:Object.assign({},e.end),end:Object.assign({},a[a.length-1][1].start)},g={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},h=[a[c+1],a[c+2],["enter",d,b],a[c+3],a[c+4],["enter",e,b],["exit",e,b],["enter",f,b],["enter",g,b],["exit",g,b],["exit",f,b],a[a.length-2],a[a.length-1],["exit",d,b]];return a.splice(c,a.length-c+1,...h),a}function Pm(a,b,c){let d,e=this,f=e.parser.gfmFootnotes||(e.parser.gfmFootnotes=[]),g=0;return function(b){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(b),a.exit("gfmFootnoteCallLabelMarker"),h};function h(b){return 94!==b?c(b):(a.enter("gfmFootnoteCallMarker"),a.consume(b),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",i)}function i(h){if(g>999||93===h&&!d||null===h||91===h||Pf(h))return c(h);if(93===h){a.exit("chunkString");let d=a.exit("gfmFootnoteCallString");return f.includes(MS(e.sliceSerialize(d)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(h),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),b):c(h)}return Pf(h)||(d=!0),g++,a.consume(h),92===h?j:i}function j(b){return 91===b||92===b||93===b?(a.consume(b),g++,i):i(b)}}function Pn(a,b,c){let d,e,f=this,g=f.parser.gfmFootnotes||(f.parser.gfmFootnotes=[]),h=0;return function(b){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),i};function i(b){return 94===b?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",j):c(b)}function j(b){if(h>999||93===b&&!e||null===b||91===b||Pf(b))return c(b);if(93===b){a.exit("chunkString");let c=a.exit("gfmFootnoteDefinitionLabelString");return d=MS(f.sliceSerialize(c)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),l}return Pf(b)||(e=!0),h++,a.consume(b),92===b?k:j}function k(b){return 91===b||92===b||93===b?(a.consume(b),h++,j):j(b)}function l(b){return 58===b?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),g.includes(d)||g.push(d),Pi(a,n,"gfmFootnoteDefinitionWhitespace")):c(b)}function n(a){return b(a)}}function Po(a,b,c){return a.check(Mb,b,a.attempt(Pj,b,c))}function Pp(a){a.exit("gfmFootnoteDefinition")}function Pq(a){return null!==a&&a<-2}function Pr(a){return null!==a&&(a<0||32===a)}function Ps(a){return -2===a||-1===a||32===a}function Pt(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function Pu(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return Ps(d)?(a.enter(c),function d(g){return Ps(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}Pt(/[A-Za-z]/),Pt(/[\dA-Za-z]/),Pt(/[#-'*+\--9=?A-Z^-~]/),Pt(/\d/),Pt(/[\dA-Fa-f]/),Pt(/[!-/:-@[-`{-~]/),Pt(/\p{P}|\p{S}/u),Pt(/\s/);class Pv{constructor(){this.map=[]}add(a,b,c){!function(a,b,c,d){let e=0;if(0!==c||0!==d.length){for(;e<a.map.length;){if(a.map[e][0]===b){a.map[e][1]+=c,a.map[e][2].push(...d);return}e+=1}a.map.push([b,c,d])}}(this,a,b,c)}consume(a){if(this.map.sort(function(a,b){return a[0]-b[0]}),0===this.map.length)return;let b=this.map.length,c=[];for(;b>0;)b-=1,c.push(a.slice(this.map[b][0]+this.map[b][1]),this.map[b][2]),a.length=this.map[b][0];c.push(a.slice()),a.length=0;let d=c.pop();for(;d;){for(let b of d)a.push(b);d=c.pop()}this.map.length=0}}function Pw(a,b,c){let d,e=this,f=0,g=0;return function(a){let b=e.events.length-1;for(;b>-1;){let a=e.events[b][1].type;if("lineEnding"===a||"linePrefix"===a)b--;else break}let d=b>-1?e.events[b][1].type:null,f="tableHead"===d||"tableRow"===d?t:h;return f===t&&e.parser.lazy[e.now().line]?c(a):f(a)};function h(b){var c;return a.enter("tableHead"),a.enter("tableRow"),124===(c=b)||(d=!0,g+=1),i(c)}function i(b){return null===b?c(b):Pq(b)?g>1?(g=0,e.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),l):c(b):Ps(b)?Pu(a,i,"whitespace")(b):(g+=1,d&&(d=!1,f+=1),124===b)?(a.enter("tableCellDivider"),a.consume(b),a.exit("tableCellDivider"),d=!0,i):(a.enter("data"),j(b))}function j(b){return null===b||124===b||Pr(b)?(a.exit("data"),i(b)):(a.consume(b),92===b?k:j)}function k(b){return 92===b||124===b?(a.consume(b),j):j(b)}function l(b){return(e.interrupt=!1,e.parser.lazy[e.now().line])?c(b):(a.enter("tableDelimiterRow"),d=!1,Ps(b))?Pu(a,n,"linePrefix",e.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):n(b)}function n(b){return 45===b||58===b?p(b):124===b?(d=!0,a.enter("tableCellDivider"),a.consume(b),a.exit("tableCellDivider"),o):c(b)}function o(b){return Ps(b)?Pu(a,p,"whitespace")(b):p(b)}function p(b){return 58===b?(g+=1,d=!0,a.enter("tableDelimiterMarker"),a.consume(b),a.exit("tableDelimiterMarker"),q):45===b?(g+=1,q(b)):null===b||Pq(b)?s(b):c(b)}function q(b){return 45===b?(a.enter("tableDelimiterFiller"),function b(c){return 45===c?(a.consume(c),b):58===c?(d=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(c),a.exit("tableDelimiterMarker"),r):(a.exit("tableDelimiterFiller"),r(c))}(b)):c(b)}function r(b){return Ps(b)?Pu(a,s,"whitespace")(b):s(b)}function s(e){if(124===e)return n(e);if(null===e||Pq(e))return d&&f===g?(a.exit("tableDelimiterRow"),a.exit("tableHead"),b(e)):c(e);return c(e)}function t(b){return a.enter("tableRow"),u(b)}function u(c){return 124===c?(a.enter("tableCellDivider"),a.consume(c),a.exit("tableCellDivider"),u):null===c||Pq(c)?(a.exit("tableRow"),b(c)):Ps(c)?Pu(a,u,"whitespace")(c):(a.enter("data"),v(c))}function v(b){return null===b||124===b||Pr(b)?(a.exit("data"),u(b)):(a.consume(b),92===b?w:v)}function w(b){return 92===b||124===b?(a.consume(b),v):v(b)}}function Px(a,b){let c,d,e,f=-1,g=!0,h=0,i=[0,0,0,0],j=[0,0,0,0],k=!1,l=0,n=new Pv;for(;++f<a.length;){let o=a[f],p=o[1];"enter"===o[0]?"tableHead"===p.type?(k=!1,0!==l&&(Pz(n,b,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},n.add(f,0,[["enter",c,b]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(g=!0,e=void 0,i=[0,0,0,0],j=[0,f+1,0,0],k&&(k=!1,d={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},n.add(f,0,[["enter",d,b]])),h="tableDelimiterRow"===p.type?2:d?3:1):h&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)?(g=!1,0===j[2]&&(0!==i[1]&&(j[0]=j[1],e=Py(n,b,i,h,void 0,e),i=[0,0,0,0]),j[2]=f)):"tableCellDivider"===p.type&&(g?g=!1:(0!==i[1]&&(j[0]=j[1],e=Py(n,b,i,h,void 0,e)),j=[(i=j)[1],f,0,0])):"tableHead"===p.type?(k=!0,l=f):"tableRow"===p.type||"tableDelimiterRow"===p.type?(l=f,0!==i[1]?(j[0]=j[1],e=Py(n,b,i,h,f,e)):0!==j[1]&&(e=Py(n,b,j,h,f,e)),h=0):h&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(j[3]=f)}for(0!==l&&Pz(n,b,l,c,d),n.consume(b.events),f=-1;++f<b.events.length;){let a=b.events[f];"enter"===a[0]&&"table"===a[1].type&&(a[1]._align=function(a,b){let c=!1,d=[];for(;b<a.length;){let e=a[b];if(c){if("enter"===e[0])"tableContent"===e[1].type&&d.push("tableDelimiterMarker"===a[b+1][1].type?"left":"none");else if("tableContent"===e[1].type){if("tableDelimiterMarker"===a[b-1][1].type){let a=d.length-1;d[a]="left"===d[a]?"center":"right"}}else if("tableDelimiterRow"===e[1].type)break}else"enter"===e[0]&&"tableDelimiterRow"===e[1].type&&(c=!0);b+=1}return d}(b.events,f))}return a}function Py(a,b,c,d,e,f){0!==c[0]&&(f.end=Object.assign({},PA(b.events,c[0])),a.add(c[0],0,[["exit",f,b]]));let g=PA(b.events,c[1]);if(f={type:1===d?"tableHeader":2===d?"tableDelimiter":"tableData",start:Object.assign({},g),end:Object.assign({},g)},a.add(c[1],0,[["enter",f,b]]),0!==c[2]){let e=PA(b.events,c[2]),f=PA(b.events,c[3]),g={type:"tableContent",start:Object.assign({},e),end:Object.assign({},f)};if(a.add(c[2],0,[["enter",g,b]]),2!==d){let d=b.events[c[2]],e=b.events[c[3]];if(d[1].end=Object.assign({},e[1].end),d[1].type="chunkText",d[1].contentType="text",c[3]>c[2]+1){let b=c[2]+1,d=c[3]-c[2]-1;a.add(b,d,[])}}a.add(c[3]+1,0,[["exit",g,b]])}return void 0!==e&&(f.end=Object.assign({},PA(b.events,e)),a.add(e,0,[["exit",f,b]]),f=void 0),f}function Pz(a,b,c,d,e){let f=[],g=PA(b.events,c);e&&(e.end=Object.assign({},g),f.push(["exit",e,b])),d.end=Object.assign({},g),f.push(["exit",d,b]),a.add(c+1,0,f)}function PA(a,b){let c=a[b],d="enter"===c[0]?"start":"end";return c[1][d]}function PB(a){return -2===a||-1===a||32===a}function PC(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}PC(/[A-Za-z]/),PC(/[\dA-Za-z]/),PC(/[#-'*+\--9=?A-Z^-~]/),PC(/\d/),PC(/[\dA-Fa-f]/),PC(/[!-/:-@[-`{-~]/),PC(/\p{P}|\p{S}/u),PC(/\s/);let PD={name:"tasklistCheck",tokenize:function(a,b,c){let d=this;return function(b){return null===d.previous&&d._gfmTasklistFirstContentOfListItem?(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(b),a.exit("taskListCheckMarker"),e):c(b)};function e(b){return null!==b&&(b<0||32===b)?(a.enter("taskListCheckValueUnchecked"),a.consume(b),a.exit("taskListCheckValueUnchecked"),f):88===b||120===b?(a.enter("taskListCheckValueChecked"),a.consume(b),a.exit("taskListCheckValueChecked"),f):c(b)}function f(b){return 93===b?(a.enter("taskListCheckMarker"),a.consume(b),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),g):c(b)}function g(d){return null!==d&&d<-2?b(d):PB(d)?a.check({tokenize:PE},b,c)(d):c(d)}}};function PE(a,b,c){var d,e;let f,g;return d=function(a){return null===a?c(a):b(a)},e="whitespace",f=1/0,g=0,function(b){return PB(b)?(a.enter(e),function b(c){return PB(c)&&g++<f?(a.consume(c),b):(a.exit(e),d(c))}(b)):d(b)}}let PF={};function PG(a){let b,c,d,e=a||PF,f=this.data(),g=f.micromarkExtensions||(f.micromarkExtensions=[]),h=f.fromMarkdownExtensions||(f.fromMarkdownExtensions=[]),i=f.toMarkdownExtensions||(f.toMarkdownExtensions=[]);g.push(LU([{text:O8},{document:{91:{name:"gfmFootnoteDefinition",tokenize:Pn,continuation:{tokenize:Po},exit:Pp}},text:{91:{name:"gfmFootnoteCall",tokenize:Pm},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Pk,resolveTo:Pl}}},(b=(e||{}).singleTilde,c={name:"strikethrough",tokenize:function(a,c,d){let e=this.previous,f=this.events,g=0;return function(h){return 126===e&&"characterEscape"!==f[f.length-1][1].type?d(h):(a.enter("strikethroughSequenceTemporary"),function f(h){let i=Mr(e);if(126===h)return g>1?d(h):(a.consume(h),g++,f);if(g<2&&!b)return d(h);let j=a.exit("strikethroughSequenceTemporary"),k=Mr(h);return j._open=!k||2===k&&!!i,j._close=!i||2===i&&!!k,c(h)}(h))}},resolveAll:function(a,b){let c=-1;for(;++c<a.length;)if("enter"===a[c][0]&&"strikethroughSequenceTemporary"===a[c][1].type&&a[c][1]._close){let d=c;for(;d--;)if("exit"===a[d][0]&&"strikethroughSequenceTemporary"===a[d][1].type&&a[d][1]._open&&a[c][1].end.offset-a[c][1].start.offset==a[d][1].end.offset-a[d][1].start.offset){a[c][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";let e={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[c][1].end)},f={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[c][1].start)},g=[["enter",e,b],["enter",a[d][1],b],["exit",a[d][1],b],["enter",f,b]],h=b.parser.constructs.insideSpan.null;h&&LR(g,g.length,0,Ms(h,a.slice(d+1,c),b)),LR(g,g.length,0,[["exit",f,b],["enter",a[c][1],b],["exit",a[c][1],b],["exit",e,b]]),LR(a,d-1,c-d+3,g),c=d+g.length-2;break}}for(c=-1;++c<a.length;)"strikethroughSequenceTemporary"===a[c][1].type&&(a[c][1].type="data");return a}},null==b&&(b=!0),{text:{126:c},insideSpan:{null:[c]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:Pw,resolveAll:Px}}},{text:{91:PD}}])),h.push([{transforms:[Op],enter:{literalAutolink:Oj,literalAutolinkEmail:Ok,literalAutolinkHttp:Ok,literalAutolinkWww:Ok},exit:{literalAutolink:Oo,literalAutolinkEmail:On,literalAutolinkHttp:Ol,literalAutolinkWww:Om}},{enter:{gfmFootnoteCallString:Ot,gfmFootnoteCall:Ou,gfmFootnoteDefinitionLabelString:Ov,gfmFootnoteDefinition:Ow},exit:{gfmFootnoteCallString:Ox,gfmFootnoteCall:Oy,gfmFootnoteDefinitionLabelString:Oz,gfmFootnoteDefinition:OA}},{canContainEols:["delete"],enter:{strikethrough:OF},exit:{strikethrough:OG}},{enter:{table:OM,tableData:OQ,tableHeader:OQ,tableRow:OO},exit:{codeText:OR,table:ON,tableData:OP,tableHeader:OP,tableRow:OP}},{exit:{taskListCheckValueChecked:OT,taskListCheckValueUnchecked:OT,paragraph:OU}}]),i.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Oh,notInConstruct:Oi},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Oh,notInConstruct:Oi},{character:":",before:"[ps]",after:"\\/",inConstruct:Oh,notInConstruct:Oi}]},(d=!1,e&&e.firstLineBlank&&(d=!0),{handlers:{footnoteDefinition:function(a,b,c,e){let f=c.createTracker(e),g=f.move("[^"),h=c.enter("footnoteDefinition"),i=c.enter("label");return g+=f.move(c.safe(c.associationId(a),{before:g,after:"]"})),i(),g+=f.move("]:"),a.children&&a.children.length>0&&(f.shift(4),g+=f.move((d?"\n":" ")+c.indentLines(c.containerFlow(a,f.current()),d?OD:OC))),h(),g},footnoteReference:OB},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:OE}],handlers:{delete:OH}},function(a){let b=a||{},c=b.tableCellPadding,d=b.tablePipeAlign,e=b.stringLength,f=c?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(a,b,c){let d=OK(a,b,c);return c.stack.includes("tableCell")&&(d=d.replace(/\|/g,"\\$&")),d},table:function(a,b,c,d){return h(function(a,b,c){let d=a.children,e=-1,f=[],g=b.enter("table");for(;++e<d.length;)f[e]=i(d[e],b,c);return g(),f}(a,c,d),a.align)},tableCell:g,tableRow:function(a,b,c,d){let e=h([i(a,c,d)]);return e.slice(0,e.indexOf("\n"))}}};function g(a,b,c,d){let e=c.enter("tableCell"),g=c.enter("phrasing"),h=c.containerPhrasing(a,{...d,before:f,after:f});return g(),e(),h}function h(a,b){return function(a,b){let c=b||{},d=(c.align||[]).concat(),e=c.stringLength||OI,f=[],g=[],h=[],i=[],j=0,k=-1;for(;++k<a.length;){let b=[],d=[],f=-1;for(a[k].length>j&&(j=a[k].length);++f<a[k].length;){var l;let g=null==(l=a[k][f])?"":String(l);if(!1!==c.alignDelimiters){let a=e(g);d[f]=a,(void 0===i[f]||a>i[f])&&(i[f]=a)}b.push(g)}g[k]=b,h[k]=d}let n=-1;if("object"==typeof d&&"length"in d)for(;++n<j;)f[n]=OJ(d[n]);else{let a=OJ(d);for(;++n<j;)f[n]=a}n=-1;let o=[],p=[];for(;++n<j;){let a=f[n],b="",d="";99===a?(b=":",d=":"):108===a?b=":":114===a&&(d=":");let e=!1===c.alignDelimiters?1:Math.max(1,i[n]-b.length-d.length),g=b+"-".repeat(e)+d;!1!==c.alignDelimiters&&((e=b.length+e+d.length)>i[n]&&(i[n]=e),p[n]=e),o[n]=g}g.splice(1,0,o),h.splice(1,0,p),k=-1;let q=[];for(;++k<g.length;){let a=g[k],b=h[k];n=-1;let d=[];for(;++n<j;){let e=a[n]||"",g="",h="";if(!1!==c.alignDelimiters){let a=i[n]-(b[n]||0),c=f[n];114===c?g=" ".repeat(a):99===c?a%2?(g=" ".repeat(a/2+.5),h=" ".repeat(a/2-.5)):h=g=" ".repeat(a/2):h=" ".repeat(a)}!1===c.delimiterStart||n||d.push("|"),!1!==c.padding&&(!1!==c.alignDelimiters||""!==e)&&(!1!==c.delimiterStart||n)&&d.push(" "),!1!==c.alignDelimiters&&d.push(g),d.push(e),!1!==c.alignDelimiters&&d.push(h),!1!==c.padding&&d.push(" "),(!1!==c.delimiterEnd||n!==j-1)&&d.push("|")}q.push(!1===c.delimiterEnd?d.join("").replace(/ +$/,""):d.join(""))}return q.join("\n")}(a,{align:b,alignDelimiters:d,padding:c,stringLength:e})}function i(a,b,c){let d=a.children,e=-1,f=[],h=b.enter("tableRow");for(;++e<d.length;)f[e]=g(d[e],a,b,c);return h(),f}}(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:OV}}]})}let PH=/^\s*\|.*\|\s*$/,PI=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;function PJ({children:a,className:b}){return(0,B.jsx)("div",{className:(0,S.cn)("text-[13px] leading-6 text-foreground/90 space-y-2 [&>:first-child]:mt-0",b),children:(0,B.jsx)(Ob,{remarkPlugins:[PG],components:{h1:a=>(0,B.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...a}),h2:a=>(0,B.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...a}),h3:a=>(0,B.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...a}),h4:a=>(0,B.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...a}),p:a=>(0,B.jsx)("p",{className:"my-1.5",...a}),ul:a=>(0,B.jsx)("ul",{className:"list-disc pl-5 my-1.5 space-y-0.5",...a}),ol:a=>(0,B.jsx)("ol",{className:"list-decimal pl-5 my-1.5 space-y-0.5",...a}),li:a=>(0,B.jsx)("li",{className:"leading-6",...a}),strong:a=>(0,B.jsx)("strong",{className:"font-semibold text-foreground",...a}),code:a=>(0,B.jsx)("code",{className:"text-[12px] font-mono bg-muted/70 px-1 py-0.5 rounded",...a}),a:a=>(0,B.jsx)("a",{className:"text-primary underline",...a}),table:a=>(0,B.jsx)("div",{className:"overflow-x-auto my-3 rounded-md border border-border",children:(0,B.jsx)("table",{className:"text-[12px] w-full border-collapse",...a})}),thead:a=>(0,B.jsx)("thead",{className:"bg-muted/60",...a}),th:a=>(0,B.jsx)("th",{className:"text-left font-semibold px-3 py-1.5 border-b border-border whitespace-nowrap",...a}),td:a=>(0,B.jsx)("td",{className:"px-3 py-1.5 border-b border-border/40 align-top [tr:last-child_&]:border-b-0",...a}),hr:a=>(0,B.jsx)("hr",{className:"my-3 border-border/60",...a}),blockquote:a=>(0,B.jsx)("blockquote",{className:"border-l-2 border-border/60 pl-3 my-2 text-muted-foreground italic",...a})},children:function(a){let b=a.split("\n"),c=[],d=0;for(;d<b.length;){let a=b[d],e=b[d+1];if(a&&e&&PH.test(a)&&PI.test(e)){for(c.length>0&&""!==c[c.length-1].trim()&&c.push("");d<b.length&&PH.test(b[d]);)c.push(b[d].replace(/^\s+/,"")),d++;d<b.length&&""!==b[d].trim()&&c.push("");continue}c.push(a),d++}return c.join("\n")}(a)})})}var PK=a.i(4609),PL=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((a,b)=>{let c=(0,PK.createSlot)(`Primitive.${b}`),d=C.forwardRef((a,d)=>{let{asChild:e,...f}=a;return(0,B.jsx)(e?c:b,{...f,ref:d})});return d.displayName=`Primitive.${b}`,{...a,[b]:d}},{}),PM=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),PN=C.forwardRef((a,b)=>(0,B.jsx)(PL.span,{...a,ref:b,style:{...PM,...a.style}}));PN.displayName="VisuallyHidden";var bh=bh;function PO({directiveId:a,onClose:b}){let c,d=(0,E.useTranslations)("directiveDetailModal"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(null),[h,i]=(0,C.useState)(!1),[j,k]=(0,C.useState)(null);(0,C.useEffect)(()=>{a&&e&&(async()=>{i(!0),k(null),g(null);try{let b=await V.client.getDirective(e,a);g(b)}catch(a){console.error("Error loading directive:",a),k(a.message)}finally{i(!1)}})()},[a,e]);let l=null!==a;return(0,B.jsx)(bm.Dialog,{open:l,onOpenChange:a=>!a&&b(),children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,B.jsx)(PN,{children:(0,B.jsx)(bm.DialogTitle,{children:d("title")})}),h?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsx)(bh.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):j?(0,B.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,B.jsx)("div",{className:"text-center text-destructive",children:(0,B.jsx)("div",{className:"text-sm",children:d("errorPrefix",{error:j})})})}):f?(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,B.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-xl font-bold text-foreground",children:f.name}),!f.is_active&&(0,B.jsx)("span",{className:"px-2 py-0.5 rounded-full bg-red-500/10 text-red-600 dark:text-red-400 text-xs font-medium",children:d("inactive")})]}),(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:f.id})]}),(0,B.jsxs)("div",{className:"flex gap-8",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:d("created")}),(0,B.jsx)("div",{className:"text-sm text-foreground",children:(c=new Date(f.created_at),`${c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${c.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:d("priority")}),(0,B.jsx)("div",{className:"text-sm text-foreground",children:f.priority})]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:d("content")}),(0,B.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:f.content})})]}),f.tags&&f.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:d("tags")}),(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:f.tags.map((a,b)=>(0,B.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:a},b))})]})]}):null]})})}function PP(a){let b=new Date(a).getTime(),c=Math.round((Date.now()-b)/1e3);if(60>Math.abs(c))return c>=0?"just now":"in a moment";let d=c,e="second";for(let[a,b]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"],[4.345,"week"],[12,"month"],[1/0,"year"]]){if(Math.abs(d)<a)break;d/=a,e=b}return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(-Math.round(d),e)}function PQ(a){let b=new Date(a);return`${b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`}var PR=a.i(5500);let PS={light:{body:"#1a1a1a",removedLineBg:"#ffeef0",addedLineBg:"#e6ffec",removedWordBg:"#fdb8c0",removedWordText:"#67060c",addedWordBg:"#acf2bc",addedWordText:"#0a3622"},dark:{body:"#e6edf3",removedLineBg:"#3d1419",addedLineBg:"#0d2818",removedWordBg:"#7d2530",removedWordText:"#ffd0d6",addedWordBg:"#1a4d2c",addedWordText:"#b8e6c1"}};function PT(a,b){return"directives"===a?{label:b?b("factTypeDirective"):"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===a?{label:b?b("factTypeMentalModel"):"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===a?{label:b?b("factTypeWorld"):"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===a?{label:b?b("factTypeExperience"):"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:"observation"===a?{label:b?b("factTypeObservation"):"observation",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}:{label:a,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"}}let PU=["observation","experience","world","directives","mental-models"];function PV({based_on:a,onViewMemory:b,onViewDirective:c}){let d=(0,E.useTranslations)("mentalModelDetailModal"),e=(0,C.useMemo)(()=>{if(!a)return[];let b=Object.entries(a).map(([a,b])=>({factType:a,facts:b??[]})).filter(a=>a.facts.length>0);return b.sort((a,b)=>{let c=PU.indexOf(a.factType),d=PU.indexOf(b.factType);return(-1===c?999:c)-(-1===d?999:d)}),b},[a]);return 0===e.length?(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:d("noBasedOnData")}):(0,B.jsx)("div",{className:"space-y-4",children:e.map(a=>{let e=PT(a.factType,d);return(0,B.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,B.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${e.color}`,children:e.label}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:a.facts.length})]}),(0,B.jsx)("ul",{className:"divide-y divide-border/50",children:a.facts.map((e,f)=>{let g="directives"===a.factType&&!!c||"directives"!==a.factType&&"mental-models"!==a.factType&&!!b;return(0,B.jsxs)("li",{className:"group flex items-start gap-3 px-3 py-2 hover:bg-muted/30",children:[(0,B.jsxs)("p",{className:"text-sm text-foreground leading-relaxed flex-1 min-w-0",children:[e.text,e.context&&(0,B.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5",children:e.context})]}),g&&(0,B.jsx)("button",{className:"text-xs text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>{"directives"===a.factType?c?.(e.id):b?.(e.id)},children:d("viewArrow")})]},e.id||f)})})]},a.factType)})})}function PW(a){return a.match(/\s+|[A-Za-z0-9_]+|[^\s\w]/g)||[]}function PX(a){return/^\s+$/.test(a)?" ":a}function PY(a,b,c){let d={backgroundColor:c.removedWordBg,color:c.removedWordText,fontWeight:600,borderRadius:"2px"},e={backgroundColor:c.addedWordBg,color:c.addedWordText,fontWeight:600,borderRadius:"2px"};return a.map((a,c)=>"same"===a.type?(0,B.jsx)("span",{children:a.text},c):(0,B.jsx)("span",{style:"left"===b?d:e,children:a.text},c))}function PZ({before:a,after:b}){let c=(0,E.useTranslations)("mentalModelDetailModal"),{theme:d}=(0,PR.useTheme)(),e=PS[d],{left:f,right:g}=function(a,b){let c=a.split("\n"),d=b.split("\n"),e=c.length,f=d.length,g=Array.from({length:e+1},()=>Array(f+1).fill(0));for(let a=1;a<=e;a++)for(let b=1;b<=f;b++)g[a][b]=c[a-1]===d[b-1]?g[a-1][b-1]+1:Math.max(g[a-1][b],g[a][b-1]);let h=[],i=e,j=f;for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(h.push({type:"same",text:c[i-1]}),i--,j--):j>0&&(0===i||g[i][j-1]>=g[i-1][j])?(h.push({type:"added",text:d[j-1]}),j--):(h.push({type:"removed",text:c[i-1]}),i--);h.reverse();let k=[],l=[],n=0;for(;n<h.length;){let a=h[n];if("same"===a.type){k.push({type:"same",spans:[{type:"same",text:a.text}]}),l.push({type:"same",spans:[{type:"same",text:a.text}]}),n++;continue}let b=[],c=[];for(;n<h.length&&"same"!==h[n].type;)"removed"===h[n].type?b.push(h[n].text):c.push(h[n].text),n++;let d=Math.max(b.length,c.length);for(let a=0;a<d;a++){let d=a<b.length?b[a]:null,e=a<c.length?c[a]:null;if(null!==d&&null!==e){let a=function(a,b){let c=PW(a),d=PW(b),e=c.length,f=d.length,g=Array.from({length:e+1},()=>Array(f+1).fill(0));for(let a=1;a<=e;a++)for(let b=1;b<=f;b++)g[a][b]=PX(c[a-1])===PX(d[b-1])?g[a-1][b-1]+1:Math.max(g[a-1][b],g[a][b-1]);let h=[],i=[],j=e,k=f,l=[],n=[];for(;j>0||k>0;)if(j>0&&k>0&&PX(c[j-1])===PX(d[k-1]))l.push({type:"same",text:c[j-1]}),n.push({type:"same",text:d[k-1]}),j--,k--;else if(k>0&&(0===j||g[j][k-1]>=g[j-1][k])){let a=d[k-1];n.push({type:/^\s+$/.test(a)?"same":"added",text:a}),k--}else{let a=c[j-1];l.push({type:/^\s+$/.test(a)?"same":"removed",text:a}),j--}for(;l.length;)h.push(l.pop());for(;n.length;)i.push(n.pop());return{left:h,right:i}}(d,e),b=a.left.some(a=>"same"!==a.type)?"removed":"same",c=a.right.some(a=>"same"!==a.type)?"added":"same";k.push({type:b,spans:a.left}),l.push({type:c,spans:a.right})}else null!==d?(k.push({type:"removed",spans:[{type:"removed",text:d}]}),l.push({type:"same",spans:[{type:"same",text:""}]})):null!==e&&(k.push({type:"same",spans:[{type:"same",text:""}]}),l.push({type:"added",spans:[{type:"added",text:e}]}))}}return{left:k,right:l}}(a,b);return f.some(a=>"same"!==a.type)||g.some(a=>"same"!==a.type)?(0,B.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border border border-border rounded-md overflow-hidden text-[13px] font-mono",style:{color:e.body},children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"px-3 py-1.5 bg-muted text-foreground font-sans font-semibold text-xs uppercase tracking-wide border-b border-border",children:c("diffBefore")}),f.map((a,b)=>(0,B.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"removed"===a.type?{backgroundColor:e.removedLineBg}:void 0,children:PY(a.spans,"left",e)},b))]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"px-3 py-1.5 bg-muted text-foreground font-sans font-semibold text-xs uppercase tracking-wide border-b border-border",children:c("diffAfter")}),g.map((a,b)=>(0,B.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"added"===a.type?{backgroundColor:e.addedLineBg}:void 0,children:PY(a.spans,"right",e)},b))]})]}):(0,B.jsx)("span",{className:"text-sm text-muted-foreground italic",children:c("unchanged")})}function P$({before:a,after:b,onViewMemory:c,onViewDirective:d}){let e=(0,E.useTranslations)("mentalModelDetailModal"),f=(0,C.useMemo)(()=>{let c=new Set([...Object.keys(a??{}),...Object.keys(b??{})]),d=[];for(let e of c){let c=(a?.[e]??[]).filter(Boolean),f=(b?.[e]??[]).filter(Boolean),g=new Set(c.map(a=>a.id)),h=new Set(f.map(a=>a.id)),i=f.filter(a=>!g.has(a.id)),j=c.filter(a=>!h.has(a.id)),k=f.filter(a=>g.has(a.id));(0!==i.length||0!==j.length||0!==k.length)&&d.push({factType:e,added:i,removed:j,kept:k})}return d.sort((a,b)=>{let c=PU.indexOf(a.factType),d=PU.indexOf(b.factType);return(-1===c?999:c)-(-1===d?999:d)}),d},[a,b]);if(0===f.length)return(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:e("noBasedOnData")});let g=(a,b,f)=>(0,B.jsxs)("li",{className:`group flex items-start gap-2 px-3 py-2 ${"added"===f?"bg-green-500/15 dark:bg-green-500/10 border-l-2 border-green-600 dark:border-green-500 text-green-950 dark:text-green-100":"removed"===f?"bg-red-500/15 dark:bg-red-500/10 border-l-2 border-red-600 dark:border-red-500 text-red-950 dark:text-red-200 line-through decoration-red-700/70 dark:decoration-red-400/70":""}`,children:[(0,B.jsx)("span",{className:`font-mono text-sm shrink-0 ${"added"===f?"text-green-700 dark:text-green-400":"removed"===f?"text-red-700 dark:text-red-400":"text-muted-foreground/40"}`,children:"added"===f?"+":"removed"===f?"−":" "}),(0,B.jsxs)("p",{className:"text-sm leading-relaxed flex-1 min-w-0",children:[a.text,a.context&&(0,B.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5 no-underline",children:a.context})]}),("directives"===b&&!!d||"directives"!==b&&"mental-models"!==b&&!!c)&&"removed"!==f&&(0,B.jsx)("button",{className:"text-xs text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>{"directives"===b?d(a.id):c(a.id)},children:e("viewArrow")})]},`${f}-${a.id}`);return(0,B.jsx)("div",{className:"space-y-4",children:f.map(a=>{let b=PT(a.factType,e);return(0,B.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,B.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${b.color}`,children:b.label}),a.added.length>0&&(0,B.jsxs)("span",{className:"text-xs text-green-600 dark:text-green-400",children:["+",a.added.length]}),a.removed.length>0&&(0,B.jsxs)("span",{className:"text-xs text-red-600 dark:text-red-400",children:["−",a.removed.length]}),a.kept.length>0&&(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:e("keptCount",{count:a.kept.length})})]}),(0,B.jsxs)("ul",{className:"divide-y divide-border/40",children:[a.added.map(b=>g(b,a.factType,"added")),a.removed.map(b=>g(b,a.factType,"removed")),a.kept.map(b=>g(b,a.factType,"kept"))]})]},a.factType)})})}function P_({history:a,currentContent:b,currentBasedOn:c,onViewMemory:d,onViewDirective:e}){let f=(0,E.useTranslations)("mentalModelDetailModal"),[g,h]=(0,C.useState)(0),i=a[g],j=0===g?b:a[g-1].previous_content??"",k=i.previous_reflect_response?.based_on,l=0===g?c:a[g-1].previous_reflect_response?.based_on,n=i.previous_reflect_response??null;return(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,B.jsxs)("span",{className:"font-semibold text-foreground",children:["v",a.length-g]})," →"," ",(0,B.jsxs)("span",{className:"font-semibold text-foreground",children:["v",a.length-g+1,0===g?f("versionCurrent"):""]})," ","· ",f("changedAt",{date:new Date(i.changed_at).toLocaleString()})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:g===a.length-1,onClick:()=>h(g+1),children:(0,B.jsx)(P,{className:"h-3.5 w-3.5"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:0===g,onClick:()=>h(g-1),children:(0,B.jsx)(Q.ChevronRight,{className:"h-3.5 w-3.5"})})]})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)(P5,{children:f("contentDiff")}),null!==i.previous_content?(0,B.jsx)(PZ,{before:i.previous_content,after:j}):(0,B.jsx)("div",{className:"border border-border rounded-lg p-3",children:(0,B.jsx)("span",{className:"text-sm text-muted-foreground italic",children:f("previousContentNotAvailable")})})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)(P5,{children:f("basedOnDiff")}),n?.based_on?(0,B.jsx)(P$,{before:k,after:l,onViewMemory:d,onViewDirective:e}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:f("basedOnNotCaptured")})]})]})}function P0({mentalModelId:a,onClose:b,onEdit:c,onDelete:d,onClear:e,onRefreshed:f,initialTab:g="content"}){let h=(0,E.useTranslations)("mentalModelDetailModal"),{currentBank:i}=(0,H.useBank)(),[j,k]=(0,C.useState)(null),[l,n]=(0,C.useState)(!1),[o,p]=(0,C.useState)(null),[q,r]=(0,C.useState)(g),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(!1),[w,x]=(0,C.useState)(null),[y,z]=(0,C.useState)(null),[A,D]=(0,C.useState)(null),[G,I]=(0,C.useState)(!1);(0,C.useEffect)(()=>{a&&i&&(async()=>{n(!0),p(null),k(null),D(null),r(g);try{let b=await V.client.getMentalModel(i,a);k(b)}catch(a){console.error("Error loading mental model:",a),p(a.message)}finally{n(!1)}})()},[a,i,g]),(0,C.useEffect)(()=>{"history"===q&&j&&i&&null===A&&(async()=>{I(!0);try{let a=await V.client.getMentalModelHistory(i,j.id);D(a)}catch(a){console.error("Error loading mental model history:",a),D([])}finally{I(!1)}})()},[q,j,i,A]);let J=async()=>{if(i&&j){v(!0);try{let a=await V.client.getMentalModel(i,j.id);k(a),D(null)}catch(a){console.error("Error reloading mental model:",a)}finally{v(!1)}}},K=async()=>{if(!i||!j)return;t(!0);let a=j.last_refreshed_at;try{await V.client.refreshMentalModel(i,j.id);let b=0,c=async()=>{b++;try{let d=await V.client.getMentalModel(i,j.id);if(d.last_refreshed_at!==a){k(d),D(null),f?.(d),t(!1);return}if(b>=120){t(!1),F.toast.error(h("refreshTimeoutTitle"),{description:h("refreshTimeoutDescription")});return}setTimeout(c,1e3)}catch(a){console.error("Error polling mental model:",a),t(!1)}};setTimeout(c,1e3)}catch{t(!1)}},L=null!==a,M=j?.reflect_response?.based_on,O=M?Object.values(M).reduce((a,b)=>a+(b?.length??0),0):0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bm.Dialog,{open:L,onOpenChange:a=>!a&&b(),children:(0,B.jsxs)(bm.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,B.jsx)(bm.DialogHeader,{className:"pr-10",children:(0,B.jsxs)(bm.DialogTitle,{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"truncate",children:j?.name??h("mentalModelFallback")}),j&&(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:J,disabled:u,title:h("reloadData"),children:(0,B.jsx)(ad,{className:`h-3.5 w-3.5 ${u?"animate-spin":""}`})}),j?.trigger?.refresh_after_consolidation&&(0,B.jsxs)("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-500/10 text-green-600 dark:text-green-400 text-xs font-medium",children:[(0,B.jsx)(KL,{className:"w-3 h-3"}),h("autoRefresh")]})]})}),l?(0,B.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,B.jsx)(bh.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o?(0,B.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,B.jsx)("div",{className:"text-center text-destructive",children:(0,B.jsx)("div",{className:"text-sm",children:h("errorPrefix",{error:o})})})}):j?(0,B.jsxs)(br.Tabs,{value:q,onValueChange:a=>r(a),className:"flex-1 flex flex-col overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,B.jsxs)(br.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,B.jsxs)(br.TabsTrigger,{value:"content",className:"flex items-center gap-1.5",children:[(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),h("tabContent")]}),(0,B.jsxs)(br.TabsTrigger,{value:"configuration",className:"flex items-center gap-1.5",children:[(0,B.jsx)(R,{className:"w-3.5 h-3.5"}),h("tabConfiguration")]}),(0,B.jsxs)(br.TabsTrigger,{value:"history",className:"flex items-center gap-1.5",children:[(0,B.jsx)(bi,{className:"w-3.5 h-3.5"}),h("tabHistory")]})]}),(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:s,"aria-label":h("actionsAriaLabel"),children:(0,B.jsx)(JB,{className:"h-4 w-4"})})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",children:[c&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>c(j),children:[(0,B.jsx)(bl,{className:"h-4 w-4 mr-2"}),h("actionEdit")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:K,disabled:s,children:[(0,B.jsx)(ad,{className:"h-4 w-4 mr-2"}),h("actionRefreshManually")]}),e&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>e(j),children:[(0,B.jsx)(KM,{className:"h-4 w-4 mr-2"}),h("actionClearContent")]}),d&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>d(j),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,B.jsx)(JA,{className:"h-4 w-4 mr-2"}),h("actionDelete")]})]})]})]})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,B.jsxs)(br.TabsContent,{value:"content",className:"mt-0 space-y-6",children:[(0,B.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-2 border-b border-border bg-muted/50 text-xs text-muted-foreground",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),(0,B.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:h("storedContent")}),(0,B.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",h("charsCount",{count:j.content.length})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[!0===j.is_stale?(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide bg-amber-500/15 text-amber-700 dark:text-amber-400",title:h("staleTitle"),children:h("stale")}):!1===j.is_stale?(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide bg-green-500/15 text-green-700 dark:text-green-400",title:h("inSyncTitle"),children:h("inSync")}):null,(0,B.jsxs)("span",{title:PQ(j.last_refreshed_at),className:"flex items-center gap-1",children:[(0,B.jsx)(ad,{className:"w-3 h-3"}),h("lastRefreshed",{time:PP(j.last_refreshed_at)})]})]})]}),(0,B.jsx)(PJ,{className:"p-4",children:j.content})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)(P5,{children:O>0?h("basedOnWithCount",{count:O}):h("basedOn")}),j.reflect_response?(0,B.jsx)(PV,{based_on:M,onViewMemory:a=>x(a),onViewDirective:a=>z(a)}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:h("noSourceData")})]})]}),(0,B.jsx)(br.TabsContent,{value:"configuration",className:"mt-0",children:(0,B.jsx)(P4,{mentalModel:j})}),(0,B.jsx)(br.TabsContent,{value:"history",className:"mt-0",children:G?(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(bh.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):A&&A.length>0?(0,B.jsx)(P_,{history:A,currentContent:j.content,currentBasedOn:M,onViewMemory:a=>x(a),onViewDirective:a=>z(a)}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:h("noHistory")})})]})]}):null]})}),w&&(0,B.jsx)(bx,{memoryId:w,onClose:()=>x(null)}),y&&(0,B.jsx)(PO,{directiveId:y,onClose:()=>z(null)})]})}function P1({label:a,value:b}){return(0,B.jsxs)("div",{children:[(0,B.jsx)(P5,{children:a}),(0,B.jsx)("div",{className:"text-sm text-foreground",children:b})]})}function P2({title:a,icon:b,children:c}){return(0,B.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-border bg-muted/40 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[b,a]}),(0,B.jsx)("div",{className:"p-4 space-y-4",children:c})]})}function P3({label:a,color:b}){return(0,B.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${b??"bg-muted text-foreground border border-border/60"}`,children:a})}function P4({mentalModel:a}){let b=(0,E.useTranslations)("mentalModelDetailModal"),c=a.trigger??{refresh_after_consolidation:!1},d=c.fact_types??[],e=c.tag_groups??[],f=c.exclude_mental_model_ids??[];return(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,B.jsxs)(P2,{title:b("identityTitle"),icon:(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),children:[(0,B.jsx)(P1,{label:b("labelId"),value:(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:a.id})}),(0,B.jsx)(P1,{label:b("labelName"),value:a.name}),a.source_query&&(0,B.jsx)(P1,{label:b("labelSourceQuery"),value:(0,B.jsx)("pre",{className:"text-sm font-mono text-foreground bg-muted/30 border border-border/60 rounded p-2 leading-6 m-0",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)"},children:a.source_query})}),(0,B.jsx)(P1,{label:b("labelTags"),value:a.tags?.length>0?(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map(a=>(0,B.jsx)(P3,{label:a,color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"},a))}):(0,B.jsx)("span",{className:"text-muted-foreground italic text-sm",children:b("noTags")})})]}),(0,B.jsxs)(P2,{title:b("timingTitle"),icon:(0,B.jsx)(ad,{className:"w-3.5 h-3.5"}),children:[(0,B.jsx)(P1,{label:b("labelCreated"),value:PQ(a.created_at)}),(0,B.jsx)(P1,{label:b("labelLastRefreshed"),value:(0,B.jsx)("span",{title:PQ(a.last_refreshed_at),children:PP(a.last_refreshed_at)})}),(0,B.jsx)(P1,{label:b("labelMaxTokens"),value:a.max_tokens.toLocaleString()})]}),(0,B.jsxs)(P2,{title:b("refreshTriggerTitle"),icon:(0,B.jsx)(KL,{className:"w-3.5 h-3.5"}),children:[(0,B.jsx)(P1,{label:b("labelRefreshMode"),value:"delta"===c.mode?(0,B.jsx)(P3,{label:b("pillDelta"),color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}):(0,B.jsx)(P3,{label:b("pillFull")})}),(0,B.jsx)(P1,{label:b("labelAutoRefreshAfterConsolidation"),value:c.refresh_after_consolidation?(0,B.jsx)(P3,{label:b("pillEnabled"),color:"bg-green-500/10 text-green-600 dark:text-green-400"}):(0,B.jsx)(P3,{label:b("pillDisabled")})}),(0,B.jsx)(P1,{label:b("labelFactTypes"),value:d.length>0?(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:d.map(a=>{let c=PT(a,b);return(0,B.jsx)(P3,{label:c.label,color:c.color},a)})}):(0,B.jsx)("span",{className:"text-muted-foreground italic text-sm",children:b("factTypesAll")})}),(0,B.jsx)(P1,{label:b("labelExcludeMentalModels"),value:c.exclude_mental_models?b("valueYes"):b("valueNo")}),f.length>0&&(0,B.jsx)(P1,{label:b("labelExcludedIds"),value:(0,B.jsx)("div",{className:"flex flex-wrap gap-1.5",children:f.map(a=>(0,B.jsx)("code",{className:"text-xs font-mono px-1.5 py-0.5 rounded bg-muted border border-border/60",children:a},a))})})]}),(0,B.jsxs)(P2,{title:b("recallParamsTitle"),icon:(0,B.jsx)(R,{className:"w-3.5 h-3.5"}),children:[(0,B.jsx)(P1,{label:b("labelIncludeChunks"),value:null==c.include_chunks?b("includeChunksDefault"):c.include_chunks?b("valueYes"):b("valueNo")}),(0,B.jsx)(P1,{label:b("labelRecallMaxTokens"),value:null!=c.recall_max_tokens?c.recall_max_tokens.toLocaleString():b("recallMaxTokensDefault")}),(0,B.jsx)(P1,{label:b("labelRecallChunksMaxTokens"),value:null!=c.recall_chunks_max_tokens?c.recall_chunks_max_tokens.toLocaleString():b("recallChunksMaxTokensDefault")}),(0,B.jsx)(P1,{label:b("labelTagsMatch"),value:c.tags_match?(0,B.jsx)(P3,{label:c.tags_match}):b("tagsMatchDefault")})]}),e.length>0&&(0,B.jsx)("div",{className:"md:col-span-2",children:(0,B.jsx)(P2,{title:b("tagGroupsTitle"),icon:(0,B.jsx)(R,{className:"w-3.5 h-3.5"}),children:(0,B.jsx)("pre",{className:"text-xs font-mono bg-muted/40 rounded p-3 overflow-x-auto border border-border/60",children:JSON.stringify(e,null,2)})})})]})}function P5({children:a}){return(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:a})}function P6(){let a,b,c,d,e,f,g,h,i,j,k,l=(0,E.useTranslations)("thinkView"),{currentBank:n}=(0,H.useBank)(),[o,p]=(0,C.useState)(""),[q,r]=(0,C.useState)("mid"),[s,t]=(0,C.useState)(4096),[u,v]=(0,C.useState)(!0),[w,x]=(0,C.useState)(!0),[y,z]=(0,C.useState)("answer"),[A,D]=(0,C.useState)(null),[F,G]=(0,C.useState)(!1),[I,J]=(0,C.useState)(""),[K,N]=(0,C.useState)("any"),[O,P]=(0,C.useState)([]),[Q,R]=(0,C.useState)(!1),[S,T]=(0,C.useState)(""),[U,Y]=(0,C.useState)(""),[Z,$]=(0,C.useState)(!1),[_,aa]=(0,C.useState)(!1),[ab,ac]=(0,C.useState)(null),[ad,ae]=(0,C.useState)(null),[ag,ah]=(0,C.useState)(null),[ai,aj]=(0,C.useState)(!1),[ak,al]=(0,C.useState)(null),[am,an]=(0,C.useState)(null),[ao,ap]=(0,C.useState)(!1),[aq,ar]=(0,C.useState)(null),[as,at]=(0,C.useState)("world"),au="General Feedback",av=async a=>{if(al(a),an(null),n&&a?.id){ap(!0);try{let b=await V.client.listObservations(n),c=b.items?.find(b=>b.id===a.id);an(c||a)}catch(b){console.error("Failed to load observation:",b),an(a)}finally{ap(!1)}}},aw=async()=>{if(n&&U.trim()){$(!0);try{let a=await V.client.listDirectives(n),b=a.items?.find(a=>a.name===au);if(b){let a=b.content?`${b.content}
|
|
8
|
-
${U.trim()}`:U.trim();await V.client.updateDirective(n,b.id,{content:a})}else await V.client.createDirective(n,{name:au,content:U.trim()});Y(""),aa(!0),setTimeout(()=>aa(!1),3e3)}catch(a){}finally{$(!1)}}},ax=async()=>{if(n&&o){G(!0),z("answer");try{let a=I.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=S.split(",").map(a=>a.trim()).filter(a=>a.length>0),c=await V.client.reflect({bank_id:n,query:o,budget:q,max_tokens:s,include_facts:u,include_tool_calls:w,...a.length>0&&{tags:a,tags_match:K},...O.length>0&&{fact_types:O},...Q&&{exclude_mental_models:!0},...b.length>0&&{exclude_mental_model_ids:b}});D(c)}catch(a){}finally{G(!1)}}};return n?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"pt-6",children:[(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsxs)("div",{className:"flex-1 relative",children:[(0,B.jsx)(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:l("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&ax()})]}),(0,B.jsx)(W.Button,{onClick:ax,disabled:F||!o,className:"h-12 px-8",children:F?l("reflecting"):l("reflect")})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:l("budgetLabel")}),(0,B.jsxs)(bb.Select,{value:q,onValueChange:a=>r(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-24 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"low",children:l("budgetLow")}),(0,B.jsx)(bb.SelectItem,{value:"mid",children:l("budgetMid")}),(0,B.jsx)(bb.SelectItem,{value:"high",children:l("budgetHigh")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:l("tokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:s,onChange:a=>t(parseInt(a.target.value)||4096),className:"w-24 h-8"})]}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:u,onCheckedChange:a=>v(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("includeSource")})]}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:w,onCheckedChange:a=>x(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("includeTools")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,B.jsx)(bc,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("div",{className:"flex-1 max-w-md",children:(0,B.jsx)(X.Input,{type:"text",value:I,onChange:a=>J(a.target.value),placeholder:l("tagsPlaceholder"),className:"h-8"})}),(0,B.jsxs)(bb.Select,{value:K,onValueChange:a=>N(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-40 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"any",children:l("tagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:l("tagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:l("tagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:l("tagsMatchAllStrict")})]})]})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsx)(JX,{value:O,onChange:P}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:Q,onCheckedChange:a=>R(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("excludeMentalModels")})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:l("excludeIdsLabel")}),(0,B.jsx)(X.Input,{type:"text",value:S,onChange:a=>T(a.target.value),placeholder:l("excludeIdsPlaceholder"),className:"h-8 w-48"})]})]})]})}),F&&(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:l("reflectingOnMemories")})]})}),!F&&A&&(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[A.usage&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("inputTokensLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.usage.input_tokens?.toLocaleString()})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("outputTokensLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.usage.output_tokens?.toLocaleString()})]})]}),A.trace?.tool_calls&&(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("toolCallsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.trace.tool_calls.length}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:["(",A.trace.tool_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),A.trace?.llm_calls&&(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("llmCallsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.trace.llm_calls.length}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:["(",A.trace.llm_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),(0,B.jsx)("div",{className:"flex-1"}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(a=>(0,B.jsx)("button",{onClick:()=>z(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${y===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===a?l("viewAnswer"):"trace"===a?l("viewTrace"):l("viewJson")},a))})]}),"answer"===y&&(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{children:l("answerTitle")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:A.text})})})]}),(0,B.jsxs)(by.Card,{className:"border-blue-200 dark:border-blue-800",children:[(0,B.jsxs)(by.CardHeader,{className:"py-4",children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,B.jsx)(J_,{className:"w-4 h-4"}),l("addDirectiveTitle")]}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("addDirectiveDescription")})]}),(0,B.jsx)(by.CardContent,{className:"pt-0",children:_?(0,B.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,B.jsx)("span",{className:"text-lg",children:"✓"}),(0,B.jsx)("span",{className:"text-sm font-medium",children:l("directiveSaved",{name:au})})]}):(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsx)(J2.Textarea,{value:U,onChange:a=>Y(a.target.value),placeholder:l("directivePlaceholder"),className:"flex-1 min-h-[60px] resize-none",onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&aw()}}),(0,B.jsx)(W.Button,{onClick:aw,disabled:Z||!U.trim(),className:"self-end",children:Z?l("savingDirective"):l("saveDirective")})]})})]})]}),"trace"===y&&(0,B.jsxs)("div",{className:"space-y-4",children:[A.observations_created&&A.observations_created.length>0&&(0,B.jsxs)(by.Card,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,B.jsxs)(by.CardHeader,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,B.jsx)(J$,{className:"w-4 h-4 text-emerald-600"}),l("observationsCreatedTitle",{count:A.observations_created.length})]}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("observationsCreatedDescription")})]}),(0,B.jsx)(by.CardContent,{className:"pt-4",children:(0,B.jsx)("div",{className:"space-y-2",children:A.observations_created.map((a,b)=>(0,B.jsxs)("div",{className:"p-3 bg-emerald-50 dark:bg-emerald-950/50 rounded-lg border border-emerald-200 dark:border-emerald-800",children:[(0,B.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:a.name}),(0,B.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:a.description}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",a.id]})]},b))})})]}),(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,B.jsxs)(by.Card,{className:"h-fit",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-base",children:l("executionTraceTitle")}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("executionTraceDescription",{iterations:A.iterations||0,iterationsPlural:1!==(A.iterations||0)?"s":"",totalMs:(A.trace?.llm_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)+(A.trace?.tool_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)})})]}),(0,B.jsx)(by.CardContent,{children:w?A.trace?.llm_calls&&A.trace.llm_calls.length>0||A.trace?.tool_calls&&A.trace.tool_calls.length>0?(0,B.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(a=A.trace?.llm_calls||[],b=A.trace?.tool_calls||[],c=[],a.forEach((d,e)=>{let f=b.filter(a=>a.iteration===e+1),g=e===a.length-1,h=d.scope.includes("final")||g&&0===f.length,i=h?a.length:e+1;c.push({type:"llm",llm:d,iteration:i,isFinal:h}),f.length>0&&c.push({type:"tools",tools:f,iteration:e+1})}),c.map((a,b)=>(0,B.jsxs)("div",{className:"relative",children:[b<c.length-1&&(0,B.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===a.type?(0,B.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,B.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:a.isFinal?(0,B.jsx)(bf.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,B.jsx)("span",{className:"text-[10px] font-semibold",children:a.iteration})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("span",{className:"font-medium text-sm",children:a.isFinal?l("responseGenerated"):l("agentDecided")}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),a.llm.duration_ms,"ms"]})]}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:a.isFinal?l("finalAnswer"):l("calledToolsBelow")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,B.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-blue-500/15 text-blue-600 dark:text-blue-400 flex-shrink-0",children:(0,B.jsx)(J1,{className:"w-3 h-3",fill:"currentColor"})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,B.jsx)("div",{className:"text-xs text-muted-foreground",children:(a.tools?.length??0)!==1?l("executingToolsPlural",{count:a.tools?.length??0}):l("executingTools",{count:a.tools?.length??0})}),a.tools?.map((a,b)=>(0,B.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.tool}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),a.duration_ms,"ms"]})]}),(0,B.jsxs)("div",{className:"p-2 space-y-2",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:l("toolInputLabel")}),(0,B.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,B.jsx)(KK,{src:a.input,collapsed:1,theme:"default"})})]}),a.output&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:l("toolOutputLabel")}),(0,B.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,B.jsx)(KK,{src:a.output,collapsed:1,theme:"default"})})]})]})]},b))]})]})]},b)))}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("noOperations")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("noOperationsDescription")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("notIncluded")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("enableIncludeTools")})]})]})})]}),(0,B.jsxs)(by.Card,{className:"h-fit",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-base",children:l("basedOnTitle")}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("basedOnDescription",{count:(A.based_on?.memories?.length||0)+(A.based_on?.observations?.filter(a=>"directive"!==a.subtype)?.length||0)+(A.based_on?.directives?.length||0)})})]}),(0,B.jsx)(by.CardContent,{children:u?A.based_on?.memories&&A.based_on.memories.length>0||A.based_on?.mental_models&&A.based_on.mental_models.length>0||A.based_on?.directives&&A.based_on.directives.length>0||A.based_on?.observations&&A.based_on.observations.length>0?(e=(d=A.based_on?.memories||[]).filter(a=>"world"===a.type),f=d.filter(a=>"experience"===a.type),g=A.based_on?.mental_models||[],h=(A.based_on?.observations||[]).filter(a=>"directive"!==a.subtype),i=A.based_on?.directives||[],j=[{id:"directives",label:l("tabDirectives"),count:i.length},{id:"mental_models",label:l("tabMentalModels"),count:g.length},{id:"observations",label:l("tabObservations"),count:h.length},{id:"world",label:l("tabWorld"),count:e.length},{id:"experience",label:l("tabExperience"),count:f.length}],k=(()=>{switch(as){case"directives":return i;case"mental_models":return g;case"observations":return h;case"world":return e;case"experience":return f;default:return[]}})(),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:j.map(a=>(0,B.jsxs)("button",{onClick:()=>at(a.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${as===a.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[a.label," (",a.count,")"]},a.id))}),k.length>0?(0,B.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:k.map((a,b)=>{let c,d;return(0,B.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==as?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==as&&("observations"===as?av(a):"mental_models"===as?ar(a.id):ac(a.id))},children:"directives"===as?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"font-medium text-sm",children:a.name}),a.content&&(0,B.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:a.content})]}):"observations"===as?(0,B.jsx)("div",{className:"font-medium text-sm",children:a.name}):"mental_models"===as?(d=(c=a.text?.indexOf(": ")??-1)>0?a.text.slice(0,c):a.id,(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"font-medium text-sm",children:d}),(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:a.id})]})):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text}),a.context&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:a.context})]})},a.id||b)})}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:l("noTabItems",{tab:as})})]})):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:l("noFactsFound")}),(0,B.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:l("noFactsFoundDescription")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("notIncludedBasedOn")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("enableIncludeSource")})]})]})})]})]})]}),"json"===y&&(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{className:"text-lg",children:l("rawResponseTitle")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,B.jsx)(KK,{src:A,collapsed:2,theme:"default"})})})]})]}),!F&&!A&&(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-lg font-semibold mb-2",children:l("readyToReflect")}),(0,B.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:l("readyToReflectDescription")})]})}),(0,B.jsx)(bx,{memoryId:ab,onClose:()=>ac(null)}),ad&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(J0,{className:"w-5 h-5"}),(0,B.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{ae(null),ah(null)},children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]}),ai?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,B.jsx)("p",{className:"mt-1 font-medium",children:ag?.name||ad.name})]}),ag?.description&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,B.jsx)("p",{className:"mt-1 text-sm",children:ag.description})]}),ag?.tags&&ag.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:ag.tags.map(a=>(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(bc,{className:"w-2.5 h-2.5"}),a]},a))})]}),(ag?.content||ad.content)&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,B.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,B.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:ag?.content||ad.content})})]}),(0,B.jsxs)("div",{className:"pt-2 border-t",children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,B.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ad.id})]})]})]})}),ak&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(J$,{className:"w-5 h-5"}),(0,B.jsx)("h2",{className:"text-lg font-semibold",children:l("observationPanelTitle")})]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{al(null),an(null)},children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]}),ao?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:l("observationTextField")}),(0,B.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:am?.text||ak.text})})]}),am?.tags&&am.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:l("observationTagsField")}),(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:am.tags.map(a=>(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(bc,{className:"w-2.5 h-2.5"}),a]},a))})]}),am?.source_memories&&am.source_memories.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:l("observationSourceMemoriesField",{count:am.source_memories.length})}),(0,B.jsx)("div",{className:"space-y-2",children:am.source_memories.map((a,b)=>(0,B.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,B.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:a.text||("string"==typeof a?a:"")})},b))})]}),(0,B.jsxs)("div",{className:"pt-2 border-t",children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:l("observationIdField")}),(0,B.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ak.id})]})]})]})}),(0,B.jsx)(P0,{mentalModelId:aq,onClose:()=>ar(null)})]}):(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2",children:l("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:l("noBankSelectedDescription")})]})})}let P7=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function P8(){let a,b,c,d,e,f,g,h,i,j,k,l,n,o,p=(0,E.useTranslations)("searchDebug"),{currentBank:q}=(0,H.useBank)(),[r,s]=(0,C.useState)(""),[t,u]=(0,C.useState)(["world"]),[v,w]=(0,C.useState)("mid"),[x,y]=(0,C.useState)(4096),[z,A]=(0,C.useState)(""),[D,G]=(0,C.useState)(!1),[I,K]=(0,C.useState)(!1),[L,P]=(0,C.useState)(""),[R,S]=(0,C.useState)("any"),[T,U]=(0,C.useState)(null),[Z,$]=(0,C.useState)(null),[_,aa]=(0,C.useState)(null),[ab,ac]=(0,C.useState)(null),[ad,ae]=(0,C.useState)(null),[ag,ah]=(0,C.useState)(!1),[ai,aj]=(0,C.useState)("results"),[ak,al]=(0,C.useState)(null),[am,an]=(0,C.useState)(new Set),[ao,ap]=(0,C.useState)(new Set),aq=a=>{an(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},ar=a=>{ap(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},as=a=>{let b=a.id||a.node_id;al(T?.find(a=>a.id===b||a.node_id===b)||a)},at=async()=>{if(!q)return void F.toast.error(p("errorSelectBank"));if(r){if(0===t.length)return void F.toast.error(p("errorSelectFactType"));ah(!0);try{let a=L.split(",").map(a=>a.trim()).filter(a=>a.length>0),b={bank_id:q,query:r,types:t,budget:v,max_tokens:x,trace:!0,include:{entities:I?{max_tokens:500}:null,chunks:D?{max_tokens:8192}:null},...z&&{query_timestamp:z},...a.length>0&&{tags:a,tags_match:R}},c=await V.client.recall(b);U(c.results||[]),$(c.entities||null),aa(c.chunks||null),ac(c.observations||null),ae(c.trace||null),aj("results")}catch(a){}finally{ah(!1)}}};return q?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"pt-6",children:[(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsxs)("div",{className:"flex-1 relative",children:[(0,B.jsx)(J.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"text",value:r,onChange:a=>s(a.target.value),placeholder:p("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&at()})]}),(0,B.jsx)(W.Button,{onClick:at,disabled:ag||!r,className:"h-12 px-8",children:ag?p("searching"):p("recall")})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsx)(JX,{value:t,onChange:u,label:p("typesLabel")}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(KL,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsxs)(bb.Select,{value:v,onValueChange:a=>w(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-24 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"low",children:p("budgetLow")}),(0,B.jsx)(bb.SelectItem,{value:"mid",children:p("budgetMid")}),(0,B.jsx)(bb.SelectItem,{value:"high",children:p("budgetHigh")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:p("tokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:x,onChange:a=>y(parseInt(a.target.value)),className:"w-24 h-8"})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(af,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"datetime-local",value:z,onChange:a=>A(a.target.value),className:"h-8",placeholder:p("queryDatePlaceholder")})]}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:D,onCheckedChange:a=>G(a)}),(0,B.jsx)(N.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-sm",children:p("chunks")})]}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:I,onCheckedChange:a=>K(a)}),(0,B.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-sm",children:p("entities")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,B.jsx)(bc,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("div",{className:"flex-1 max-w-md",children:(0,B.jsx)(X.Input,{type:"text",value:L,onChange:a=>P(a.target.value),placeholder:p("tagsPlaceholder"),className:"h-8"})}),(0,B.jsxs)(bb.Select,{value:R,onValueChange:a=>S(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-40 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"any",children:p("tagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:p("tagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:p("tagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:p("tagsMatchAllStrict")})]})]})]})]})}),ag&&(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("searchingMemories")})]})}),!ag&&T&&(0,B.jsxs)("div",{className:"space-y-4",children:[ad?.summary&&(0,B.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("resultsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:T.length})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("durationLabel")}),(0,B.jsxs)("span",{className:"font-semibold",children:[ad.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("nodesVisitedLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:ad.summary.total_nodes_visited})]}),(0,B.jsx)("div",{className:"flex-1"}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(a=>(0,B.jsx)("button",{onClick:()=>aj(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ai===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===a?p("viewResults"):"trace"===a?p("viewTrace"):p("viewJson")},a))})]}),"results"===ai&&(0,B.jsxs)("div",{className:"space-y-4",children:[ab&&ab.length>0&&(0,B.jsxs)(by.Card,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,B.jsx)(by.CardHeader,{className:"py-3",children:(0,B.jsxs)(by.CardTitle,{className:"text-base flex items-center gap-2",children:[(0,B.jsx)(M,{className:"h-4 w-4 text-orange-500"}),(0,B.jsx)("span",{children:"Observations"}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",ab.length,")"]})]})}),(0,B.jsx)(by.CardContent,{className:"pt-0 space-y-2",children:ab.map((a,b)=>(0,B.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,B.jsx)("p",{className:"text-sm text-foreground",children:a.text}),(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,B.jsx)("span",{children:p("proofCount",{count:a.proof_count||1})}),(0,B.jsx)("span",{children:p("relevance",{value:(a.relevance||0).toFixed(3)})})]})]},a.id||b))})]}),(0,B.jsx)("div",{className:"space-y-3",children:0!==T.length||ab&&0!==ab.length?T.map((a,b)=>{let c=ad?.visits?.find(b=>b.node_id===a.id),d=c?c.weights.final_weight:a.score||0;return(0,B.jsx)(by.Card,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>al(a),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-start gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-semibold text-primary",children:b+1})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-foreground",children:a.text}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:a.type||"world"}),a.context&&(0,B.jsx)("span",{className:"truncate max-w-xs",children:a.context}),a.occurred_start&&(0,B.jsx)("span",{children:new Date(a.occurred_start).toLocaleDateString()})]})]}),(0,B.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,B.jsx)("div",{className:"text-sm font-semibold",children:(d??0).toFixed(3)}),(0,B.jsx)("div",{className:"text-xs text-muted-foreground",children:p("scoreLabel")})]}),(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},b)}):(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-12",children:[(0,B.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("noMemoriesFound")})]})})})]}),"trace"===ai&&ad&&(0,B.jsxs)("div",{className:"space-y-4",children:[ad.retrieval_results&&ad.retrieval_results.length>0&&(a={},ad.retrieval_results.forEach(b=>{let c=b.fact_type||"all";a[c]||(a[c]=[]),a[c].push(b)}),b=Object.keys(a),(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,B.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,B.jsx)("span",{children:p("parallelRetrieval")}),(0,B.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,B.jsx)("div",{className:"space-y-2",children:b.map((b,c)=>{let d=a[b],e=`lane-${b}`,f=am.has(e),g=d.reduce((a,b)=>a+(b.results?.length||0),0),h=Math.max(...d.map(a=>a.duration_seconds||0)),i={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},j=i[b]||i.all;return(0,B.jsx)(by.Card,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,B.jsxs)(by.CardContent,{className:"py-3 px-4",children:[(0,B.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>aq(e),children:[(0,B.jsx)("div",{className:`w-8 h-8 rounded-lg ${j.bg} flex items-center justify-center`,children:(0,B.jsx)("span",{className:`text-sm font-bold ${j.text} capitalize`,children:b.charAt(0).toUpperCase()})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground capitalize",children:b}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:p("methodsCount",{count:d.length})})]}),(0,B.jsx)("div",{className:"flex gap-1.5 mt-1",children:d.map((a,b)=>(0,B.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[a.method_name,": ",a.results?.length||0]},b))})]}),(0,B.jsxs)("div",{className:"text-right",children:[(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:g}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[h.toFixed(2),"s"]})]}),f?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),f&&(0,B.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,B.jsx)("div",{className:`grid gap-3 ${1===d.length?"grid-cols-1":2===d.length?"grid-cols-2":3===d.length?"grid-cols-3":"grid-cols-4"}`,children:d.map((a,b)=>{let c,d,f,g,h=`${e}-method-${b}`,i=am.has(h),j=a.results||[];return(0,B.jsxs)("div",{className:"flex flex-col",children:[(0,B.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${i?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:a=>{a.stopPropagation(),aq(h)},children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:a.method_name}),"temporal"===a.method_name&&a.metadata?.constraint&&(0,B.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,B.jsx)(Y,{className:"h-3 w-3"}),a.metadata.constraint.start?new Date(a.metadata.constraint.start).toLocaleDateString():"any"," → ",a.metadata.constraint.end?new Date(a.metadata.constraint.end).toLocaleDateString():"any"]})]}),i?(0,B.jsx)(JC.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,B.jsxs)("div",{className:"flex items-end justify-between",children:[(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:j.length}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[a.duration_seconds?.toFixed(2),"s"]})]})]}),i&&j.length>0&&(c=`results-${h}`,f=(d=ao.has(c))?j:j.slice(0,5),g=j.length>5,(0,B.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[f.map((a,b)=>(0,B.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-2",children:[(0,B.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:a.text}),(0,B.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,B.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(a.score||a.similarity||0).toFixed(4)})})]})]})},b)),g&&(0,B.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(c)},children:d?p("showLess"):p("viewAllResults",{count:j.length})})]}))]},h)})})})]})},e)})}),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)("div",{className:"flex items-center gap-2",children:b.map((a,b)=>{let c={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,B.jsx)("div",{className:"flex flex-col items-center",children:(0,B.jsx)("div",{className:`w-1 h-4 ${c[a]||c.all} rounded-full opacity-50`})},b)})})}),(0,B.jsx)("div",{className:"flex justify-center",children:(0,B.jsx)(P7,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ad.rrf_merged&&(c="rrf-merge",d=am.has(c),(0,B.jsxs)("div",{children:[(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>aq(c),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("rrfFusion")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rrfMerge")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("rrfDescription")})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ad.rrf_merged.length}),d?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),d&&ad.rrf_merged.length>0&&(e="results-rrf",g=(f=ao.has(e))?ad.rrf_merged:ad.rrf_merged.slice(0,5),h=ad.rrf_merged.length>5,(0,B.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[g.map((a,b)=>(0,B.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,B.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[p("rrfScore")," ",(a.rrf_score||a.score||0).toFixed(4)]})]})]})},b)),h&&(0,B.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(e)},children:f?p("showLess"):p("viewAllResults",{count:ad.rrf_merged.length})})]})),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)(P7,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ad.reranked&&(i="reranking",j=am.has(i),(0,B.jsxs)("div",{children:[(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>aq(i),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("combinedScoring")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rerank")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,B.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ad.reranked.length}),j?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),j&&ad.reranked.length>0&&(k="results-rerank",n=(l=ao.has(k))?ad.reranked:ad.reranked.slice(0,5),o=ad.reranked.length>5,(0,B.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[n.map((a,b)=>{let c=a.score_components||{};return(0,B.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,B.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,B.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(a.rerank_score||a.score||0).toFixed(4)]}),void 0!==c.cross_encoder_score_normalized&&(0,B.jsxs)("span",{title:p("tooltipCrossEncoder"),children:["CE: ",c.cross_encoder_score_normalized.toFixed(3)]}),void 0!==c.temporal&&.5!==c.temporal&&(0,B.jsxs)("span",{title:p("tooltipTemporal"),children:["Tmp: ",c.temporal.toFixed(3)]}),void 0!==c.recency&&(0,B.jsxs)("span",{title:p("tooltipRecency"),children:["Rec: ",c.recency.toFixed(3)]})]})]})]})},b)}),o&&(0,B.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(k)},children:l?p("showLess"):p("viewAllResults",{count:ad.reranked.length})})]})),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)(P7,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,B.jsx)(by.Card,{className:"border-primary bg-primary/5",children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("finalResults")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:p("output")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("finalResultsDescription")})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-primary",children:T?.length||0})]})})})]}),"json"===ai&&(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{className:"text-lg",children:p("rawResponse")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,B.jsx)(KK,{src:{results:T,...Z&&{entities:Z},..._&&{chunks:_},...ab&&{observations:ab},trace:ad},collapsed:2,theme:"default"})})})]})]}),!ag&&!T&&(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-lg font-semibold mb-2",children:p("readyToRecall")}),(0,B.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:p("readyToRecallDescription")})]})}),ak&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsx)(wu,{memory:ak,onClose:()=>al(null),inPanel:!0,bankId:q||void 0})})]}):(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2",children:p("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("noBankSelectedDescription")})]})})}let P9=(0,K.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var Qa=a.i(83604),Qa=Qa,bh=bh;let Qb=["skepticism","literalism","empathy"];function Qc(){let a=(0,E.useTranslations)("bankProfile");return{skepticism:{label:a("skepticismLabel"),shortLabel:"S",description:a("skepticismDescription"),lowLabel:a("skepticismLow"),highLabel:a("skepticismHigh")},literalism:{label:a("literalismLabel"),shortLabel:"L",description:a("literalismDescription"),lowLabel:a("literalismLow"),highLabel:a("literalismHigh")},empathy:{label:a("empathyLabel"),shortLabel:"E",description:a("empathyDescription"),lowLabel:a("empathyLow"),highLabel:a("empathyHigh")}}}function Qd({hideReflectFields:a=!1}){let b=(0,D.useRouter)(),c=(0,E.useTranslations)("bankProfile"),d=(0,E.useTranslations)("common"),e=(0,E.useTranslations)("bank"),f=Qc(),{currentBank:g,setCurrentBank:h,loadBanks:i}=(0,H.useBank)(),[j,k]=(0,C.useState)(null),[l,n]=(0,C.useState)(null),[o,p]=(0,C.useState)([]),[q,r]=(0,C.useState)(!1),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(!1),[w,x]=(0,C.useState)(!1),[y,z]=(0,C.useState)(null),[A,G]=(0,C.useState)(null),[I,J]=(0,C.useState)(!1),[K,L]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),[O,P]=(0,C.useState)(!1),[Q,R]=(0,C.useState)(!1),S=async(a=!1)=>{if(g){if(a){try{let[a,b]=await Promise.all([V.client.getBankStats(g),V.client.listDirectives(g)]);n(a),p(b.items||[])}catch(a){console.error("Error refreshing stats:",a)}return}r(!0);try{let[a,b,c]=await Promise.all([V.client.getBankProfile(g),V.client.getBankStats(g),V.client.listDirectives(g)]);k(a),n(b),p(c.items||[])}catch(a){}finally{r(!1)}}},T=async()=>{if(g){N(!0);try{await V.client.deleteBank(g),L(!1),h(null),await i(),b.push("/")}catch(a){}finally{N(!1)}}},U=async()=>{if(g){R(!0);try{let a=await V.client.clearObservations(g);P(!1),await S(),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{R(!1)}}},X=async()=>{if(g&&A){J(!0);try{await V.client.deleteDirective(g,A.id),p(a=>a.filter(a=>a.id!==A.id)),y?.id===A.id&&z(null),G(null)}catch(a){}finally{J(!1)}}};return((0,C.useEffect)(()=>{if(g){S();let a=setInterval(()=>S(!0),5e3);return()=>clearInterval(a)}},[g]),(0,C.useEffect)(()=>{let a=a=>{"Escape"===a.key&&z(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),g)?q&&!j?(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"text-center py-10",children:[(0,B.jsx)(af,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,B.jsx)("div",{className:"text-lg text-muted-foreground",children:c("loadingProfile")})]})}):(0,B.jsxs)("div",{className:"space-y-6",children:[!a&&(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)("div",{className:"flex items-start justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,B.jsx)(J$,{className:"w-5 h-5 text-primary"}),c("dispositionProfileTitle")]}),(0,B.jsx)(by.CardDescription,{children:c("editDispositionDescription")})]}),(0,B.jsx)(W.Button,{onClick:()=>t(!0),variant:"ghost",size:"sm",children:(0,B.jsx)(bl,{className:"h-4 w-4"})})]})}),(0,B.jsx)(by.CardContent,{children:j&&(0,B.jsx)("div",{className:"space-y-4",children:Qb.map(a=>(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex justify-between items-center",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:f[a].label}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:f[a].description})]}),(0,B.jsxs)("span",{className:"text-sm font-bold text-primary",children:[j.disposition[a],"/5"]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:f[a].lowLabel}),(0,B.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,B.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(j.disposition[a]-1)/4*100}%`}})}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:f[a].highLabel})]})]},a))})})]}),(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)("div",{className:"flex items-start justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,B.jsx)(P9,{className:"w-5 h-5 text-primary"}),c("missionTitle")]}),(0,B.jsx)(by.CardDescription,{children:c("editMissionDescription")})]}),(0,B.jsx)(W.Button,{onClick:()=>v(!0),variant:"ghost",size:"sm",children:(0,B.jsx)(bl,{className:"h-4 w-4"})})]})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:j?.mission||c("noMissionSet")})})]})]}),(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),c("directivesTitle")]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:c("directivesDescription")})]}),(0,B.jsxs)(W.Button,{onClick:()=>x(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-1"}),c("addDirective")]})]}),o.length>0?(0,B.jsx)("div",{className:"grid grid-cols-2 gap-3",children:o.map(a=>(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors border-rose-500/30 ${y?.id===a.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>z(a),children:(0,B.jsx)(by.CardContent,{className:"p-3",children:(0,B.jsxs)("div",{className:"flex items-start gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:a.content}),a.tags&&a.tags.length>0&&(0,B.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,B.jsx)(bc,{className:"w-3 h-3 text-muted-foreground"}),a.tags.map(a=>(0,B.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:a},a))]})]})]})})},a.id))}):(0,B.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,B.jsx)(Qa.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:c("noDirectivesMessage")})]})]}),(0,B.jsx)(Jc,{open:K,onOpenChange:L,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("deleteMemoryBank")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:e.rich("deleteBankPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:g})})}),(0,B.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:e("deleteBankWarning")}),l&&(0,B.jsx)("p",{children:e("deleteWillDeleteDetails",{memories:l.total_nodes,documents:l.total_documents,links:l.total_links})})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:M,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:T,disabled:M,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),e("deleting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),e("deleteBank")]})})]})]})}),(0,B.jsx)(Jc,{open:O,onOpenChange:P,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("clearObservationsTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:e.rich("clearObservationsPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:g})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:e("clearObservationsWarning")}),l&&l.total_observations>0&&(0,B.jsx)("p",{children:e("deleteWillDeleteObservations",{count:l.total_observations})})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:Q,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:U,disabled:Q,className:"bg-amber-500 text-white hover:bg-amber-600",children:Q?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("clearing")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),e("clearObservations")]})})]})]})}),(0,B.jsx)(Qg,{open:w,mode:"create",onClose:()=>x(!1),onCreated:a=>{p(b=>[a,...b]),x(!1)}}),(0,B.jsx)(Jc,{open:!!A,onOpenChange:a=>!a&&G(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("deleteDirectiveTitle")}),(0,B.jsxs)(Jx,{children:[c("deleteDirectiveConfirm",{name:`"${A?.name??""}"`}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),(0,B.jsx)("span",{className:"text-destructive font-semibold",children:c("deleteDirectiveWarning")})]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:d("cancel")}),(0,B.jsxs)(Jy,{onClick:X,disabled:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[I?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,d("delete")]})]})]})}),y&&(0,B.jsx)(Qh,{directive:y,onClose:()=>z(null),onDelete:()=>G({id:y.id,name:y.name}),onUpdated:a=>{p(b=>b.map(b=>b.id===a.id?a:b)),z(a)}}),s&&j&&(0,B.jsx)(Qe,{disposition:j.disposition,onClose:()=>t(!1),onSaved:async()=>{await S(),t(!1)}}),u&&j&&(0,B.jsx)(Qf,{mission:j.mission||"",onClose:()=>v(!1),onSaved:async()=>{await S(),v(!1)}})]}):(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"p-10 text-center",children:[(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:c("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:c("noBankSelectedDescription")})]})})}function Qe({disposition:a,onClose:b,onSaved:c}){let d=(0,E.useTranslations)("bankProfile"),e=Qc(),{currentBank:f}=(0,H.useBank)(),[g,h]=(0,C.useState)(!1),[i,j]=(0,C.useState)(a),k=async()=>{if(f){h(!0);try{await V.client.updateBankConfig(f,{disposition_skepticism:i.skepticism,disposition_literalism:i.literalism,disposition_empathy:i.empathy}),c()}catch(a){}finally{h(!1)}}};return(0,B.jsx)(bm.Dialog,{open:!0,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-xl",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("editDispositionTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("editDispositionDescription")})]}),(0,B.jsx)("div",{className:"space-y-4 py-4",children:Qb.map(a=>(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex justify-between items-center",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e[a].label}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e[a].description})]}),(0,B.jsxs)("span",{className:"text-sm font-bold text-primary",children:[i[a],"/5"]})]}),(0,B.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,B.jsx)("span",{children:e[a].lowLabel}),(0,B.jsx)("span",{children:e[a].highLabel})]}),(0,B.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:i[a],onChange:b=>j(c=>({...c,[a]:parseInt(b.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},a))}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{onClick:b,variant:"outline",disabled:g,children:d("cancel")}),(0,B.jsx)(W.Button,{onClick:k,disabled:g,children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),d("saving")]}):d("saveChanges")})]})]})})}function Qf({mission:a,onClose:b,onSaved:c}){let d=(0,E.useTranslations)("bankProfile"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(!1),[h,i]=(0,C.useState)(a),j=async()=>{if(e){g(!0);try{await V.client.updateBankConfig(e,{reflect_mission:h||null}),c()}catch(a){}finally{g(!1)}}};return(0,B.jsx)(bm.Dialog,{open:!0,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-xl",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("editMissionTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("editMissionDescription")})]}),(0,B.jsx)("div",{className:"space-y-2 py-4",children:(0,B.jsx)(J2.Textarea,{value:h,onChange:a=>i(a.target.value),placeholder:d("missionPlaceholder"),rows:8,className:"resize-none"})}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{onClick:b,variant:"outline",disabled:f,children:d("cancel")}),(0,B.jsx)(W.Button,{onClick:j,disabled:f,children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),d("saving")]}):d("saveChanges")})]})]})})}function Qg({open:a,mode:b,directive:c,onClose:d,onCreated:e,onSaved:f}){let g=(0,E.useTranslations)("bankProfile"),{currentBank:h}=(0,H.useBank)(),[i,j]=(0,C.useState)(!1),[k,l]=(0,C.useState)({name:"",content:"",tags:""});(0,C.useEffect)(()=>{"edit"===b&&c?l({name:c.name,content:c.content,tags:(c.tags||[]).join(", ")}):"create"===b&&l({name:"",content:"",tags:""})},[a,b,c]);let n=async()=>{if(h&&k.name.trim()&&k.content.trim()){j(!0);try{let a=k.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0);if("create"===b){let b=await V.client.createDirective(h,{name:k.name.trim(),content:k.content.trim(),tags:a.length>0?a:void 0});l({name:"",content:"",tags:""}),e?.(b)}else if(c){let b=await V.client.updateDirective(h,c.id,{name:k.name.trim(),content:k.content.trim(),tags:a});f?.(b),d()}}catch(a){}finally{j(!1)}}},o=()=>{"create"===b&&l({name:"",content:"",tags:""}),d()};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>!a&&o(),children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-lg",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsxs)(bm.DialogTitle,{className:"flex items-center gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),g("create"===b?"directiveFormCreateTitle":"directiveFormEditTitle")]}),(0,B.jsx)(bm.DialogDescription,{children:g("directiveFormDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:g("directiveNameLabel")}),(0,B.jsx)(X.Input,{value:k.name,onChange:a=>l({...k,name:a.target.value}),placeholder:g("directiveNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:g("directiveRuleLabel")}),(0,B.jsx)(J2.Textarea,{value:k.content,onChange:a=>l({...k,content:a.target.value}),placeholder:g("directiveRulePlaceholder"),className:"min-h-[120px]"})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("label",{className:"text-sm font-medium text-foreground",children:[g("directiveTagsLabel")," ",(0,B.jsx)("span",{className:"text-muted-foreground font-normal",children:g("directiveTagsOptional")})]}),(0,B.jsx)(X.Input,{value:k.tags,onChange:a=>l({...k,tags:a.target.value}),placeholder:g("directiveTagsPlaceholder")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:o,disabled:i,children:g("cancel")}),(0,B.jsxs)(W.Button,{onClick:n,disabled:i||!k.name.trim()||!k.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[i?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,g("create"===b?"create":"save")]})]})]})})}function Qh({directive:a,onClose:b,onDelete:c,onUpdated:d}){let e=(0,E.useTranslations)("bankProfile"),[f,g]=(0,C.useState)(!1);return(0,B.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l-2 border-rose-500 shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"h-7 w-7 p-0",children:(0,B.jsx)(bl,{className:"h-3.5 w-3.5"})})]}),(0,B.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:e("directiveDetailBadge")})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,B.jsx)(JA,{className:"h-4 w-4"})}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,B.jsx)(bg.X,{className:"h-4 w-4"})})]})]}),(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:e("directiveDetailRuleLabel")}),(0,B.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:e("directiveDetailTagsLabel")}),(0,B.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tags.map(a=>(0,B.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:a},a))})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:e("directiveDetailIdLabel")}),(0,B.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:a.id})]})]})]}),(0,B.jsx)(Qg,{open:f,mode:"edit",directive:a,onClose:()=>g(!1),onSaved:d})]})}let Qi=(0,ay.cva)("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Qj=C.forwardRef(({className:a,variant:b,...c},d)=>(0,B.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(Qi({variant:b}),a),...c}));Qj.displayName="Alert",C.forwardRef(({className:a,...b},c)=>(0,B.jsx)("h5",{ref:c,className:(0,S.cn)("mb-1 font-medium leading-none tracking-tight",a),...b})).displayName="AlertTitle";let Qk=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));Qk.displayName="AlertDescription";var bh=bh;let Ql=(0,K.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Qm=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT"].map(a=>({category:a,threshold:"BLOCK_NONE"})),Qn=["retain","sync_retain","recall","reflect","list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories","list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model","clear_mental_model","list_directives","create_directive","delete_directive","list_memories","get_memory","update_memory","invalidate_memory","list_documents","get_document","delete_document","list_operations","get_operation","cancel_operation","list_tags"];function Qo(a){return Array.isArray(a)?a:a&&"object"==typeof a&&Array.isArray(a.attributes)?a.attributes:null}function Qp(a){return{retain_chunk_size:a.retain_chunk_size??null,retain_extraction_mode:a.retain_extraction_mode??null,retain_mission:a.retain_mission??null,retain_custom_instructions:a.retain_custom_instructions??null,entities_allow_free_form:a.entities_allow_free_form??null,entity_labels:Qo(a.entity_labels)}}function Qq(a){return{retain_default_strategy:a.retain_default_strategy??null,retain_strategies:a.retain_strategies??null}}function Qr(a){return{enable_observations:a.enable_observations??null,consolidation_llm_batch_size:a.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:a.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:a.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:a.observations_mission??null,max_observations_per_scope:a.max_observations_per_scope??null}}function Qs(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function Qt(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let Qu={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function Qv(){let a=(0,E.useTranslations)("bankConfig"),{currentBank:b}=(0,H.useBank)(),{features:c}=(0,I3.useFeatures)(),d=c?.bank_config_api??!0,[e,f]=(0,C.useState)(!0),[g,h]=(0,C.useState)({}),[i,j]=(0,C.useState)(Qu),[k,l]=(0,C.useState)(Qp({})),[n,o]=(0,C.useState)(Qq({})),[p,q]=(0,C.useState)(Qr({})),[r,s]=(0,C.useState)(Qu),[t,u]=(0,C.useState)(Qs({})),[v,w]=(0,C.useState)(Qt({})),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(null),[N,O]=(0,C.useState)(null),[P,Q]=(0,C.useState)(null),[R,S]=(0,C.useState)(null),[T,U]=(0,C.useState)(null),W=(0,C.useMemo)(()=>JSON.stringify(k)!==JSON.stringify(Qp(g))||JSON.stringify(n)!==JSON.stringify(Qq(g)),[k,n,g]),Y=(0,C.useMemo)(()=>JSON.stringify(p)!==JSON.stringify(Qr(g)),[p,g]),Z=(0,C.useMemo)(()=>JSON.stringify(r)!==JSON.stringify(i),[r,i]),$=(0,C.useMemo)(()=>JSON.stringify(t)!==JSON.stringify(Qs(g)),[t,g]),_=(0,C.useMemo)(()=>JSON.stringify(v)!==JSON.stringify(Qt(g)),[v,g]);(0,C.useEffect)(()=>{b&&aa()},[b]);let aa=async()=>{if(b){f(!0);try{let[a,c]=await Promise.all([V.client.getBankConfig(b),V.client.getBankProfile(b)]),d=a.config,e={reflect_mission:c.mission??"",disposition_skepticism:d.disposition_skepticism??c.disposition?.skepticism??3,disposition_literalism:d.disposition_literalism??c.disposition?.literalism??3,disposition_empathy:d.disposition_empathy??c.disposition?.empathy??3};h(d),j(e),l(Qp(d)),o(Qq(d)),q(Qr(d)),s(e),u(Qs(d)),w(Qt(d))}catch(a){console.error("Failed to load bank data:",a)}finally{f(!1)}}},ab=async()=>{if(b){y(!0),M(null);try{let a={...k,...n};await V.client.updateBankConfig(b,a),h(b=>({...b,...a}))}catch(b){M(b.message||a("retainFailedToSave"))}finally{y(!1)}}},ac=async()=>{if(b){A(!0),O(null);try{await V.client.updateBankConfig(b,p),h(a=>({...a,...p}))}catch(b){O(b.message||a("observationsFailedToSave"))}finally{A(!1)}}},ad=async()=>{if(b){F(!0),Q(null);try{await V.client.updateBankConfig(b,{reflect_mission:r.reflect_mission||null,disposition_skepticism:r.disposition_skepticism,disposition_literalism:r.disposition_literalism,disposition_empathy:r.disposition_empathy}),j(r)}catch(b){Q(b.message||a("reflectFailedToSave"))}finally{F(!1)}}},ae=async()=>{if(b){I(!0),S(null);try{await V.client.updateBankConfig(b,t),h(a=>({...a,...t}))}catch(b){S(b.message||a("mcpFailedToSave"))}finally{I(!1)}}},af=async()=>{if(b){K(!0),U(null);try{await V.client.updateBankConfig(b,v),h(a=>({...a,...v}))}catch(b){U(b.message||a("geminiFailedToSave"))}finally{K(!1)}}};return b?d?e?(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(bh.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)("div",{className:"space-y-8",children:[(0,B.jsxs)(QC,{title:a("retainTitle"),description:a("retainSectionDescription"),error:L,dirty:W,saving:x,onSave:ab,children:[(0,B.jsx)(QD,{label:a("defaultStrategyLabel"),description:a("defaultStrategyDescription"),children:(0,B.jsxs)(bb.Select,{value:n.retain_default_strategy??"__none__",onValueChange:a=>o(b=>({...b,retain_default_strategy:"__none__"===a?null:a})),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-full",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"__none__",children:(0,B.jsx)("span",{className:"text-muted-foreground italic",children:a("default")})}),Object.keys(n.retain_strategies??{}).map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:a},a))]})]})}),(0,B.jsx)(QA,{defaultValues:k,onDefaultChange:a=>l(b=>({...b,...a})),strategies:n.retain_strategies,onStrategiesChange:a=>o(b=>({...b,retain_strategies:a}))})]}),(0,B.jsxs)(QC,{title:a("observationsTitle"),description:a("observationsDescription"),error:N,dirty:Y,saving:z,onSave:ac,children:[(0,B.jsx)(QD,{label:a("enableObservationsLabel"),description:a("enableObservationsDescription"),children:(0,B.jsx)("div",{className:"flex justify-end",children:(0,B.jsx)(ba.Switch,{checked:p.enable_observations??!1,onCheckedChange:a=>q(b=>({...b,enable_observations:a}))})})}),(0,B.jsx)(QE,{label:a("missionLabel"),description:a("observationsMissionDescription"),value:p.observations_mission??"",onChange:a=>q(b=>({...b,observations_mission:a||null})),placeholder:a("observationsMissionPlaceholder"),rows:3}),(0,B.jsx)(QD,{label:a("llmBatchSizeLabel"),description:a("llmBatchSizeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:1,max:64,value:p.consolidation_llm_batch_size??"",onChange:a=>q(b=>({...b,consolidation_llm_batch_size:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("sourceFactsMaxTokensLabel"),description:a("sourceFactsMaxTokensDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens??"",onChange:a=>q(b=>({...b,consolidation_source_facts_max_tokens:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("sourceFactsMaxTokensPerObservationLabel"),description:a("sourceFactsMaxTokensPerObservationDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens_per_observation??"",onChange:a=>q(b=>({...b,consolidation_source_facts_max_tokens_per_observation:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("maxObservationsPerScopeLabel"),description:a("maxObservationsPerScopeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.max_observations_per_scope??"",onChange:a=>q(b=>({...b,max_observations_per_scope:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})})]}),(0,B.jsxs)(QC,{title:a("reflectTitle"),description:a("reflectDescription"),error:P,dirty:Z,saving:D,onSave:ad,children:[(0,B.jsx)(QE,{label:a("missionLabel"),description:a("reflectMissionDescription"),value:r.reflect_mission,onChange:a=>s(b=>({...b,reflect_mission:a})),placeholder:a("reflectMissionPlaceholder"),rows:3}),(0,B.jsx)(QF,{label:a("skepticismLabel"),description:a("skepticismDescription"),lowLabel:a("skepticismLowLabel"),highLabel:a("skepticismHighLabel"),value:r.disposition_skepticism,onChange:a=>s(b=>({...b,disposition_skepticism:a}))}),(0,B.jsx)(QF,{label:a("literalismLabel"),description:a("literalismDescription"),lowLabel:a("literalismLowLabel"),highLabel:a("literalismHighLabel"),value:r.disposition_literalism,onChange:a=>s(b=>({...b,disposition_literalism:a}))}),(0,B.jsx)(QF,{label:a("empathyLabel"),description:a("empathyDescription"),lowLabel:a("empathyLowLabel"),highLabel:a("empathyHighLabel"),value:r.disposition_empathy,onChange:a=>s(b=>({...b,disposition_empathy:a}))})]}),(0,B.jsxs)(QC,{title:a("mcpToolsTitle"),description:a("mcpToolsDescription"),error:R,dirty:$,saving:G,onSave:ae,children:[(0,B.jsx)(QD,{label:a("restrictToolsLabel"),description:a("restrictToolsDescription"),children:(0,B.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,B.jsx)(ba.Switch,{checked:null!==t.mcp_enabled_tools,onCheckedChange:a=>u({mcp_enabled_tools:a?[...Qn]:null})}),(0,B.jsx)(aA,{className:"text-xs text-muted-foreground",children:null!==t.mcp_enabled_tools?a("enabled"):a("disabled")})]})}),null!==t.mcp_enabled_tools&&(0,B.jsx)(QB,{selected:t.mcp_enabled_tools,onChange:a=>u({mcp_enabled_tools:a})})]}),(0,B.jsx)(QC,{title:a("modelsTitle"),description:a("modelsDescription"),error:T,dirty:_,saving:J,onSave:af,children:(0,B.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,B.jsx)("p",{className:"text-sm font-semibold",children:a("geminiSubsectionTitle")}),(0,B.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,B.jsx)(QD,{label:a("safetySettingsLabel"),description:(0,B.jsxs)(B.Fragment,{children:[a("safetySettingsDescriptionPart1")," ",(0,B.jsx)("a",{href:"https://ai.google.dev/gemini-api/docs/safety-settings",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",children:a("safetySettingsLearnMore")})]}),children:(0,B.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,B.jsx)(ba.Switch,{checked:null!==v.llm_gemini_safety_settings,onCheckedChange:a=>w({llm_gemini_safety_settings:a?[...Qm]:null})}),(0,B.jsx)(aA,{className:"text-xs text-muted-foreground",children:null!==v.llm_gemini_safety_settings?a("custom"):a("default")})]})}),null!==v.llm_gemini_safety_settings&&(0,B.jsx)(QI,{value:v.llm_gemini_safety_settings,onChange:a=>w({llm_gemini_safety_settings:a})})]})]})})]})}):(0,B.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,B.jsx)("p",{className:"text-base font-medium text-foreground",children:a("apiDisabledTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:a.rich("apiDisabledDescription",{code:a=>(0,B.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:a})})})]}):(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)("p",{className:"text-muted-foreground",children:a("noBankSelected")})})}let Qw=["concise","verbose","verbatim","chunks","custom"],Qx="__inherit__";function Qy({values:a,onChange:b,isOverride:c=!1}){let d=(0,E.useTranslations)("bankConfig"),e=a.retain_extraction_mode??(c?Qx:""),f="custom"===a.retain_extraction_mode;return(0,B.jsxs)("div",{className:"divide-y divide-border/40",children:[(0,B.jsx)(QD,{label:d("extractionModeLabel"),description:d("extractionModeDescription"),children:(0,B.jsxs)(bb.Select,{value:e,onValueChange:a=>b({retain_extraction_mode:a===Qx?null:a||null}),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-full",children:(0,B.jsx)(bb.SelectValue,{placeholder:c?d("inherited"):void 0})}),(0,B.jsxs)(bb.SelectContent,{children:[c&&(0,B.jsx)(bb.SelectItem,{value:Qx,children:(0,B.jsx)("span",{className:"text-muted-foreground italic",children:d("inherited")})}),Qw.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:a},a))]})]})}),(0,B.jsx)(QD,{label:d("chunkSizeLabel"),description:d("chunkSizeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:500,max:8e3,value:a.retain_chunk_size??"",onChange:a=>b({retain_chunk_size:a.target.value?parseFloat(a.target.value):null}),placeholder:c?d("inherited"):void 0})}),(0,B.jsx)(QE,{label:d("missionLabel"),description:d("retainMissionDescription"),value:a.retain_mission??"",onChange:a=>b({retain_mission:a||null}),placeholder:d(c?"inherited":"retainMissionPlaceholder"),rows:3}),f&&(0,B.jsx)(QE,{label:d("customExtractionPromptLabel"),description:d("customExtractionPromptDescription"),value:a.retain_custom_instructions??"",onChange:a=>b({retain_custom_instructions:a||null}),rows:5}),(0,B.jsx)(QD,{label:d("freeFormEntitiesLabel"),description:d("freeFormEntitiesDescription"),children:(0,B.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,B.jsx)(aA,{className:"text-sm text-muted-foreground cursor-pointer select-none",children:d(a.entities_allow_free_form??!0?"enabled":"disabled")}),(0,B.jsx)(ba.Switch,{checked:a.entities_allow_free_form??!0,onCheckedChange:a=>b({entities_allow_free_form:a})})]})}),(0,B.jsx)(QH,{value:a.entity_labels??[],onChange:a=>b({entity_labels:a.length>0?a:null})})]})}function Qz(a){return a?Object.entries(a).map(([a,b],c)=>({id:c,name:a,values:{retain_extraction_mode:b.retain_extraction_mode??null,retain_chunk_size:b.retain_chunk_size??null,retain_mission:b.retain_mission??null,retain_custom_instructions:b.retain_custom_instructions??null,entities_allow_free_form:b.entities_allow_free_form??null,entity_labels:Qo(b.entity_labels)}})):[]}function QA({defaultValues:a,onDefaultChange:b,strategies:c,onStrategiesChange:d}){let e=(0,E.useTranslations)("bankConfig"),f=(0,E.useTranslations)("common"),[g,h]=(0,C.useState)(()=>Qz(c)),[i,j]=(0,C.useState)("default"),[k,l]=(0,C.useState)(null),n=(0,C.useRef)(!1),o=JSON.stringify(c);(0,C.useEffect)(()=>{if(n.current){n.current=!1;return}h(Qz(c))},[o]);let p=a=>{n.current=!0,h(a),d(function(a){let b={};for(let c of a){if(!c.name.trim())continue;let a={};null!==c.values.retain_extraction_mode&&(a.retain_extraction_mode=c.values.retain_extraction_mode),null!==c.values.retain_chunk_size&&(a.retain_chunk_size=c.values.retain_chunk_size),c.values.retain_mission&&(a.retain_mission=c.values.retain_mission),c.values.retain_custom_instructions&&(a.retain_custom_instructions=c.values.retain_custom_instructions),null!==c.values.entities_allow_free_form&&(a.entities_allow_free_form=c.values.entities_allow_free_form),null!==c.values.entity_labels&&(a.entity_labels=c.values.entity_labels),b[c.name.trim()]=a}return Object.keys(b).length>0?b:null}(a))},q=(a,b)=>{p(g.map(c=>c.id===a?{...c,...b}:c))},r="default"!==i?g.find(a=>a.id===i):null;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"border-b border-border px-6 flex items-stretch gap-1 flex-wrap",children:[(0,B.jsx)("button",{type:"button",onClick:()=>j("default"),className:`relative py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px ${"default"===i?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,children:e("default")}),g.map(a=>(0,B.jsxs)("div",{className:`relative flex items-center gap-2 py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px cursor-pointer ${i===a.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>j(a.id),children:[(0,B.jsx)("span",{className:"font-mono",children:a.name||(0,B.jsx)("span",{className:"italic font-normal opacity-50",children:e("unnamed")})}),(0,B.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),l(a)},className:"opacity-40 hover:opacity-100 hover:text-destructive transition-opacity text-base leading-none",children:"×"})]},a.id)),(0,B.jsxs)("button",{type:"button",onClick:()=>{let a=Date.now();p([...g,{id:a,name:"",values:{retain_extraction_mode:null,retain_chunk_size:null,retain_mission:null,retain_custom_instructions:null,entities_allow_free_form:null,entity_labels:null}}]),j(a)},className:"py-3 px-3 text-sm text-muted-foreground hover:text-primary transition-colors flex items-center gap-1.5",children:[(0,B.jsx)(I$.Plus,{className:"h-3.5 w-3.5"}),e("addStrategy")]})]}),(0,B.jsx)("div",{children:"default"===i?(0,B.jsx)(Qy,{values:a,onChange:b}):r?(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"px-6 py-3 flex items-center gap-3 border-b border-border/40",children:[(0,B.jsx)("label",{className:"text-xs text-muted-foreground shrink-0",children:e("nameLabel")}),(0,B.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,B.jsx)(X.Input,{value:r.name,onChange:a=>q(r.id,{name:a.target.value}),placeholder:e("strategyNamePlaceholder"),className:`h-7 text-xs font-mono max-w-[200px] ${!r.name.trim()?"border-destructive focus-visible:ring-destructive":""}`}),!r.name.trim()&&(0,B.jsx)("p",{className:"text-xs text-destructive",children:e("nameIsRequired")})]})]}),(0,B.jsx)(Qy,{values:r.values,onChange:a=>q(r.id,{values:{...r.values,...a}}),isOverride:!0})]}):null}),(0,B.jsx)(Jc,{open:null!==k,onOpenChange:a=>{a||l(null)},children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("deleteStrategyTitle",{name:k?.name||e("unnamed")})}),(0,B.jsx)(Jx,{children:e("deleteStrategyDescription")})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{children:f("cancel")}),(0,B.jsx)(Jy,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(k){var a;a=k.id,p(g.filter(b=>b.id!==a)),i===a&&j("default"),l(null)}},children:f("delete")})]})]})})]})}function QB({selected:a,onChange:b}){let c=(0,E.useTranslations)("bankConfig"),d=[{key:"core",label:c("mcpGroupCore"),tools:["retain","sync_retain","recall","reflect"]},{key:"bankManagement",label:c("mcpGroupBankManagement"),tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{key:"mentalModels",label:c("mcpGroupMentalModels"),tools:["list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model","clear_mental_model"]},{key:"directives",label:c("mcpGroupDirectives"),tools:["list_directives","create_directive","delete_directive"]},{key:"memories",label:c("mcpGroupMemories"),tools:["list_memories","get_memory","update_memory","invalidate_memory"]},{key:"documents",label:c("mcpGroupDocuments"),tools:["list_documents","get_document","delete_document"]},{key:"operations",label:c("mcpGroupOperations"),tools:["list_operations","get_operation","cancel_operation"]},{key:"tags",label:c("mcpGroupTags"),tools:["list_tags"]}],e=new Set(a),f=Qn.every(a=>e.has(a)),g=0===a.length;return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:c("toolsEnabled",{selected:a.length,total:Qn.length})}),(0,B.jsx)("button",{type:"button",onClick:()=>{b(f?[]:[...Qn])},className:"text-xs text-primary hover:underline",children:f?c("deselectAll"):c("selectAll")})]}),(0,B.jsx)("div",{className:"space-y-4",children:d.map(a=>{let d=a.tools.filter(a=>e.has(a)).length===a.tools.length;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,B.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:a.label}),(0,B.jsx)("button",{type:"button",onClick:()=>{let c=new Set(e);d?a.tools.forEach(a=>c.delete(a)):a.tools.forEach(a=>c.add(a)),b(Qn.filter(a=>c.has(a)))},className:"text-xs text-primary hover:underline",children:d?c("deselect"):c("selectAll")})]}),(0,B.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tools.map(a=>{let c=e.has(a);return(0,B.jsx)("button",{type:"button",onClick:()=>{let c;(c=new Set(e)).has(a)?c.delete(a):c.add(a),b(Qn.filter(a=>c.has(a)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${c?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:a},a)})})]},a.key)})}),g&&(0,B.jsx)("p",{className:"text-xs text-destructive",children:c("noToolsWarning")})]})}function QC({title:a,description:b,children:c,error:d,dirty:e,saving:f,onSave:g}){let h=(0,E.useTranslations)("bankConfig");return(0,B.jsxs)("section",{className:"space-y-3",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h2",{className:"text-lg font-semibold",children:a}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:b})]}),(0,B.jsxs)(by.Card,{className:"bg-muted/20 border-border/40",children:[(0,B.jsx)("div",{className:"divide-y divide-border/40",children:c}),d&&(0,B.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,B.jsxs)(Qj,{variant:"destructive",children:[(0,B.jsx)(Ql,{className:"h-4 w-4"}),(0,B.jsx)(Qk,{children:d})]})}),(0,B.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,B.jsx)(W.Button,{size:"sm",disabled:!e||f,onClick:g,children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"h-4 w-4 mr-2 animate-spin"}),h("saving")]}):h("saveChanges")})})]})]})}function QD({label:a,description:b,children:c}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsx)("div",{className:"md:w-64 shrink-0",children:c})]})})}function QE({label:a,description:b,value:c,onChange:d,placeholder:e,rows:f}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsx)(J2.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function QF({label:a,description:b,lowLabel:c,highLabel:d,value:e,onChange:f}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,B.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:c}),(0,B.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>(0,B.jsx)("button",{type:"button",onClick:()=>f(a),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${a<=e?"bg-primary":"bg-muted"}`},a))}),d&&(0,B.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:d}),(0,B.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[e,"/5"]})]})]})})}function QG({fields:a,onChange:b,depth:c,extraControls:d,examplePrefix:e}){let f=(0,E.useTranslations)("bankConfig"),g={text:f("fieldTypeText"),value:f("fieldTypeValue"),"multi-values":f("fieldTypeMultiValues"),map:f("fieldTypeMap")},[h,i]=(0,C.useState)({}),j=(c,d)=>{let e={};for(let[b,f]of Object.entries(a))e[b]=b===c?{...f,...d}:f;b(e)},k=0===c;return(0,B.jsxs)("div",{className:k?"space-y-1.5 py-1":"space-y-1.5 py-1 ml-3 border-l-2 border-border/40 pl-3",children:[0===Object.keys(a).length&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground italic",children:f("noFieldsYet")}),Object.entries(a).map(([l,n],o)=>{let p="map"===n.type,q="value"===n.type||"multi-values"===n.type,r=h[o]??!0,s=p||q;return(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[s?(0,B.jsx)("button",{type:"button",onClick:()=>i(a=>({...a,[o]:!r})),className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted/50",children:r?(0,B.jsx)(JC.ChevronDown,{className:"h-3.5 w-3.5"}):(0,B.jsx)(Q.ChevronRight,{className:"h-3.5 w-3.5"})}):(0,B.jsx)("span",{className:"w-[18px] shrink-0"}),(0,B.jsx)(X.Input,{placeholder:f("fieldNamePlaceholder"),value:l,onChange:c=>((c,d)=>{let e={};for(let[b,f]of Object.entries(a))e[b===c?d:b]=f;b(e)})(l,c.target.value),className:"h-7 text-xs font-mono w-28 shrink-0"}),(0,B.jsx)(X.Input,{placeholder:f("extractorHintWhatPlaceholder"),value:n.description,onChange:a=>j(l,{description:a.target.value}),className:"h-7 text-xs flex-1 min-w-0"}),(0,B.jsxs)(bb.Select,{value:n.type,onValueChange:a=>j(l,{type:a,..."map"===a?{fields:n.fields??{},values:void 0}:{},..."text"===a?{fields:void 0,values:void 0}:{},..."value"===a||"multi-values"===a?{fields:void 0,values:n.values??[]}:{}}),children:[(0,B.jsx)(bb.SelectTrigger,{className:"h-7 text-xs w-[120px] shrink-0 px-2 py-0",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:Object.entries(g).map(([a,b])=>(0,B.jsx)(bb.SelectItem,{value:a,className:"text-xs",children:b},a))})]}),d,(0,B.jsx)("button",{type:"button",onClick:()=>{let c;return c={...a},void(delete c[l],b(c))},className:"text-muted-foreground hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10",children:(0,B.jsx)(JA,{className:"h-3.5 w-3.5"})})]}),k&&e&&l&&(0,B.jsx)("div",{className:"ml-[18px] pl-1.5",children:(0,B.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground/60 leading-none",children:"map"===n.type&&n.fields&&Object.keys(n.fields).length>0?`e.g. ${Object.keys(n.fields).slice(0,2).map(a=>`${e}:${a}:<value>`).join(", ")}`:"text"===n.type?`e.g. ${e}:<any text>`:(n.values?.length??0)>0?`e.g. ${e}:${n.values[0].value||"<value>"}`:`e.g. ${e}:<value>`})}),r&&p&&(0,B.jsx)(QG,{fields:n.fields??{},onChange:a=>j(l,{fields:a}),depth:c+1,examplePrefix:e?`${e}:${l}`:void 0}),r&&q&&(0,B.jsxs)("div",{className:"ml-6 space-y-0.5 py-1",children:[0===(n.values??[]).length&&(0,B.jsx)("p",{className:"text-[11px] text-muted-foreground italic",children:f("noValuesYet")}),(n.values??[]).map((a,b)=>(0,B.jsxs)("div",{className:"flex items-center gap-1.5 group/val",children:[(0,B.jsx)("span",{className:"text-muted-foreground/50 text-[10px] shrink-0",children:"•"}),(0,B.jsx)(X.Input,{placeholder:f("addValueShort"),value:a.value,onChange:c=>{let d=[...n.values??[]];d[b]={...a,value:c.target.value},j(l,{values:d})},className:"h-6 text-[11px] font-mono w-24 shrink-0 border-dashed"}),(0,B.jsx)(X.Input,{placeholder:f("extractorHintWhichPlaceholder"),value:a.description,onChange:c=>{let d=[...n.values??[]];d[b]={...a,description:c.target.value},j(l,{values:d})},className:"h-6 text-[11px] flex-1 min-w-0 border-dashed"}),(0,B.jsx)("button",{type:"button",onClick:()=>{j(l,{values:(n.values??[]).filter((a,c)=>c!==b)})},className:"text-muted-foreground/40 hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10 opacity-0 group-hover/val:opacity-100 transition-opacity",children:(0,B.jsx)(JA,{className:"h-3 w-3"})})]},b)),(0,B.jsxs)("button",{type:"button",onClick:()=>{j(l,{values:[...n.values??[],{value:"",description:""}]})},className:"text-[11px] text-muted-foreground/60 hover:text-foreground inline-flex items-center gap-1 ml-2.5",children:[(0,B.jsx)(I$.Plus,{className:"h-2.5 w-2.5"}),f("addValueShort")]})]})]},o)}),(0,B.jsxs)("button",{type:"button",onClick:()=>{b({...a,"":{type:"text",description:""}})},className:"text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",children:[(0,B.jsx)(I$.Plus,{className:"h-3 w-3"}),f("addField")]})]})}function QH({value:a,onChange:b}){let c=(0,E.useTranslations)("entityLabelsEditor"),d=(c,d)=>{b(a.map((a,b)=>b===c?{...a,...d}:a))};return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:c("entityLabelsTitle")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("entityLabelsDescription")})]}),a.length>0&&(0,B.jsx)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:c("labelCount",{count:a.length})})]}),0===a.length&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground italic",children:c("noEntityLabelsDefined")}),(0,B.jsx)("div",{className:"space-y-2",children:a.map((e,f)=>(0,B.jsx)("div",{className:"border border-border/50 rounded-md bg-background",children:(0,B.jsx)(QG,{fields:{[e.key]:{type:e.type,description:e.description,values:e.values,fields:e.fields}},onChange:c=>{let e=Object.entries(c);if(0===e.length)b(a.filter((a,b)=>b!==f));else{let[a,b]=e[0];d(f,{key:a,type:b.type,description:b.description,values:b.values??[],fields:b.fields??{}})}},depth:0,extraControls:(0,B.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",title:c("alsoStoreAsTagTooltip"),children:[(0,B.jsx)(I4.Checkbox,{checked:e.tag,onCheckedChange:a=>d(f,{tag:!!a}),className:"h-4 w-4"}),c("plusTag")]}),examplePrefix:e.key})},f))}),(0,B.jsxs)("button",{type:"button",onClick:()=>{b([...a,{key:"",description:"",type:"value",optional:!0,tag:!1,values:[],fields:{}}])},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,B.jsx)(I$.Plus,{className:"h-3.5 w-3.5"}),c("addLabel")]})]})}function QI({value:a,onChange:b}){let c=(0,E.useTranslations)("bankConfig"),d=[{value:"HARM_CATEGORY_HARASSMENT",label:c("geminiCategoryHarassment")},{value:"HARM_CATEGORY_HATE_SPEECH",label:c("geminiCategoryHateSpeech")},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:c("geminiCategorySexuallyExplicit")},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:c("geminiCategoryDangerousContent")}],e=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:c("geminiThresholdUnspecified")},{value:"OFF",label:c("geminiThresholdOff")},{value:"BLOCK_NONE",label:c("geminiThresholdBlockNone")},{value:"BLOCK_LOW_AND_ABOVE",label:c("geminiThresholdBlockLowAndAbove")},{value:"BLOCK_MEDIUM_AND_ABOVE",label:c("geminiThresholdBlockMediumAndAbove")},{value:"BLOCK_ONLY_HIGH",label:c("geminiThresholdBlockOnlyHigh")}],f=b=>a.find(a=>a.category===b)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,B.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c("geminiSafetyEditorDescriptionPart1")," ",(0,B.jsx)("a",{href:"https://ai.google.dev/gemini-api/docs/safety-settings",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",children:c("geminiSafetyEditorLearnMore")})]}),(0,B.jsx)("div",{className:"space-y-2",children:d.map(a=>(0,B.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,B.jsx)("span",{className:"text-sm",children:a.label}),(0,B.jsxs)(bb.Select,{value:f(a.value),onValueChange:c=>{var e;return e=a.value,void b(d.map(a=>({category:a.value,threshold:a.value===e?c:f(a.value)})))},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:e.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}var bh=bh;let QJ="sensitive_data";function QK(){return{enabled:!1,rules:[]}}function QL(a){let b=a?.memory_defense;return b&&"object"==typeof b?{enabled:!!b.enabled,rules:Array.isArray(b.rules)?b.rules.filter(a=>a&&"string"==typeof a.on&&a.on===QJ).map(a=>{var b;return{on:a.on,action:"allow"===(b=a.action??"redact")||"redact"===b||"block"===b?b:"block"}}):[]}:QK()}function QM(a,b){return a.find(a=>a.on===b)}function QN(a,b){return[...a.filter(a=>a.on!==b.on),b]}function QO(a){return{enabled:a.enabled,rules:a.rules.map(a=>({on:a.on,action:a.action}))}}function QP({bankId:a}){let b=(0,E.useTranslations)("bankConfig"),[c,d]=(0,C.useState)(!0),[e,f]=(0,C.useState)({}),[g,h]=(0,C.useState)(QK()),[i,j]=(0,C.useState)(!1),k=(0,C.useMemo)(()=>QL(e),[e]),l=(0,C.useMemo)(()=>JSON.stringify(QO(g))!==JSON.stringify(QO(k)),[g,k]);(0,C.useEffect)(()=>{let c=!1;return(async()=>{d(!0);try{let b=await V.client.getBankConfig(a);if(c)return;f(b.config),h(QL(b.config))}catch(a){c||F.toast.error(a?.message||b("memoryDefenseFailedToSave"))}finally{c||d(!1)}})(),()=>{c=!0}},[a,b]);let n=g.enabled,o=(0,C.useRef)(null),p=(0,C.useRef)(!0);(0,C.useEffect)(()=>{if(!c){if(p.current){p.current=!1;return}if(l)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{q()},800),()=>{o.current&&clearTimeout(o.current)}}},[g,c]);let q=async()=>{j(!0);try{let b=QO(g),c=await V.client.updateBankConfig(a,{memory_defense:b});f(c.config)}catch(c){let a=c?.message||b("memoryDefenseFailedToSave");F.toast.error(a)}finally{j(!1)}},r=QM(g.rules,QJ);return c?(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(bh.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,B.jsxs)("section",{className:"space-y-6",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between gap-6",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("h2",{className:"text-lg font-semibold",children:b("memoryDefenseTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:b("memoryDefenseDescription")})]}),(0,B.jsx)("div",{className:"shrink-0 pt-1 scale-125 origin-right",children:(0,B.jsx)(ba.Switch,{checked:n,onCheckedChange:a=>h(b=>({...b,enabled:a}))})})]}),(0,B.jsx)("div",{className:n?"space-y-6":"space-y-6 opacity-40 pointer-events-none select-none","aria-disabled":!n,children:(0,B.jsx)("div",{className:"space-y-3",children:(0,B.jsx)(by.Card,{className:"bg-muted/20 border-border/40",children:(0,B.jsx)(QU,{title:b("memoryDefenseSecretLeakTitle"),description:b("memoryDefenseSecretLeakDescription"),rule:r,actions:["redact","block","allow"],onToggle:a=>h(b=>{var c;let d=QM(b.rules,QJ),e=d?.action??"redact";return{...b,rules:a?QN(b.rules,{on:QJ,action:e}):(c=b.rules,c.filter(a=>a.on!==QJ))}}),onActionChange:a=>h(b=>{let c=QM(b.rules,QJ);return c?{...b,rules:QN(b.rules,{...c,action:a})}:b}),masterEnabled:n})})})}),(0,B.jsx)(QQ,{}),i&&(0,B.jsxs)("div",{className:"flex justify-end items-center gap-2 text-xs text-muted-foreground",children:[(0,B.jsx)(bh.default,{className:"h-3.5 w-3.5 animate-spin"}),b("saving")]})]})}function QQ(){let a=(0,E.useTranslations)("bankConfig"),b=[a("memoryDefenseEnterpriseFeatureDetectSecrets"),a("memoryDefenseEnterpriseFeatureBase64"),a("memoryDefenseEnterpriseFeatureLlm"),a("memoryDefenseEnterpriseFeaturePromptInjection"),a("memoryDefenseEnterpriseFeatureSizeAnomaly"),a("memoryDefenseEnterpriseFeatureProtectedKeys")];return(0,B.jsxs)("div",{className:"rounded-xl border border-emerald-600/15 bg-emerald-500/[0.04] dark:bg-emerald-400/[0.06] p-6 flex flex-col gap-4",children:[(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("div",{className:"rounded-full bg-emerald-500/10 p-2 shrink-0",children:(0,B.jsx)(L,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("p",{className:"text-base font-semibold text-foreground",children:a("memoryDefenseEnterpriseTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a("memoryDefenseEnterpriseSubtitle")})]})]}),(0,B.jsx)("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1.5 text-sm text-foreground",children:b.map(a=>(0,B.jsxs)("li",{className:"flex items-start gap-2",children:[(0,B.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400 mt-0.5",children:"✓"}),(0,B.jsx)("span",{children:a})]},a))}),(0,B.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4",children:(0,B.jsxs)("a",{href:"https://calendly.com/d/ctw6-byb-3kg",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 rounded-md bg-emerald-600 hover:bg-emerald-700 text-white text-sm font-semibold px-4 py-2.5 transition-colors w-full sm:w-auto",children:[a("memoryDefenseEnterpriseCta"),(0,B.jsx)("span",{"aria-hidden":!0,children:"→"})]})})]})}function QR({title:a,description:b,headerSummary:c,headerControl:d,children:e}){let f=(Array.isArray(e)?e.flat(1/0).filter(Boolean):e?[e]:[]).length>0;return(0,B.jsxs)("div",{className:"px-6 py-4",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,B.jsx)("p",{className:"text-sm font-semibold",children:a}),c&&(0,B.jsx)("span",{className:"text-[10px] font-bold tracking-[0.1em] text-primary uppercase px-1.5 py-0.5 rounded bg-primary/10",children:c})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),d&&(0,B.jsx)("div",{className:"shrink-0 pt-0.5",children:d})]}),f&&(0,B.jsx)("div",{className:"mt-4 space-y-3",children:e})]})}function QS({label:a,description:b,children:c}){return(0,B.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)(aA,{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:b})]}),(0,B.jsx)("div",{className:"shrink-0",children:c})]})}function QT({value:a,onChange:b,options:c,t:d}){return(0,B.jsxs)(bb.Select,{value:a,onValueChange:a=>b(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px]",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:d(`memoryDefenseAction_${a}`)},a))})]})}function QU({title:a,description:b,rule:c,actions:d,onActionChange:e,onToggle:f,masterEnabled:g}){let h=(0,E.useTranslations)("bankConfig"),i=!!c,j=g&&i,k=j?h(`memoryDefenseAction_${c.action}`):null;return(0,B.jsx)(QR,{title:a,description:b,headerSummary:k,headerControl:(0,B.jsx)(ba.Switch,{checked:j,onCheckedChange:f}),children:j&&d.length>1&&(0,B.jsx)(QS,{label:h("memoryDefenseActionLabel"),children:(0,B.jsx)(QT,{value:c.action,onChange:e,options:d,t:h})})})}let QV=(0,K.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),QW=(0,K.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var QX=a.i(67511),QX=QX;let QY=(0,K.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),QZ=(0,K.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q$=["x1","y1","x2","y2","key"],Q_=["offset"],Q0=["xAxisId","yAxisId"],Q1=["xAxisId","yAxisId"];function Q2(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function Q3(a){for(var b=1;b<arguments.length;b++){var c=null!=arguments[b]?arguments[b]:{};b%2?Q2(Object(c),!0).forEach(function(b){var d,e,f;d=a,e=b,f=c[b],(e=function(a){var b=function(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}(a,"string");return"symbol"==typeof b?b:b+""}(e))in d?Object.defineProperty(d,e,{value:f,enumerable:!0,configurable:!0,writable:!0}):d[e]=f}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(c)):Q2(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}return a}function Q4(){return(Q4=Object.assign.bind()).apply(null,arguments)}function Q5(a,b){if(null==a)return{};var c,d,e=function(a,b){if(null==a)return{};var c={};for(var d in a)if(({}).hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&({}).propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}var Q6=a=>{var{fill:b}=a;if(!b||"none"===b)return null;var{fillOpacity:c,x:d,y:e,width:f,height:g,ry:h}=a;return C.createElement("rect",{x:d,y:e,ry:h,width:f,height:g,stroke:"none",fill:b,fillOpacity:c,className:"recharts-cartesian-grid-bg"})};function Q7(a){var{option:b,lineItemProps:c}=a;if(C.isValidElement(b))d=C.cloneElement(b,c);else if("function"==typeof b)d=b(c);else{var d,e,{x1:f,y1:g,x2:h,y2:i,key:j}=c,k=null!=(e=p5(Q5(c,Q$)))?e:{},{offset:l}=k,n=Q5(k,Q_);d=C.createElement("line",Q4({},n,{x1:f,y1:g,x2:h,y2:i,fill:"none",key:j}))}return d}function Q8(a){var{x:b,width:c,horizontal:d=!0,horizontalPoints:e}=a;if(!d||!e||!e.length)return null;var{xAxisId:f,yAxisId:g}=a,h=Q5(a,Q0),i=e.map((a,e)=>{var f=Q3(Q3({},h),{},{x1:b,y1:a,x2:b+c,y2:a,key:"line-".concat(e),index:e});return C.createElement(Q7,{key:"line-".concat(e),option:d,lineItemProps:f})});return C.createElement("g",{className:"recharts-cartesian-grid-horizontal"},i)}function Q9(a){var{y:b,height:c,vertical:d=!0,verticalPoints:e}=a;if(!d||!e||!e.length)return null;var{xAxisId:f,yAxisId:g}=a,h=Q5(a,Q1),i=e.map((a,e)=>{var f=Q3(Q3({},h),{},{x1:a,y1:b,x2:a,y2:b+c,key:"line-".concat(e),index:e});return C.createElement(Q7,{option:d,lineItemProps:f,key:"line-".concat(e)})});return C.createElement("g",{className:"recharts-cartesian-grid-vertical"},i)}function Ra(a){var{horizontalFill:b,fillOpacity:c,x:d,y:e,width:f,height:g,horizontalPoints:h,horizontal:i=!0}=a;if(!i||!b||!b.length||null==h)return null;var j=h.map(a=>Math.round(a+e-e)).sort((a,b)=>a-b);e!==j[0]&&j.unshift(0);var k=j.map((a,h)=>{var i=j[h+1]?j[h+1]-a:e+g-a;if(i<=0)return null;var k=h%b.length;return C.createElement("rect",{key:"react-".concat(h),y:a,x:d,height:i,width:f,stroke:"none",fill:b[k],fillOpacity:c,className:"recharts-cartesian-grid-bg"})});return C.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},k)}function Rb(a){var{vertical:b=!0,verticalFill:c,fillOpacity:d,x:e,y:f,width:g,height:h,verticalPoints:i}=a;if(!b||!c||!c.length)return null;var j=i.map(a=>Math.round(a+e-e)).sort((a,b)=>a-b);e!==j[0]&&j.unshift(0);var k=j.map((a,b)=>{var i=j[b+1]?j[b+1]-a:e+g-a;if(i<=0)return null;var k=b%c.length;return C.createElement("rect",{key:"react-".concat(b),x:a,y:f,width:i,height:h,stroke:"none",fill:c[k],fillOpacity:d,className:"recharts-cartesian-grid-bg"})});return C.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},k)}var Rc=(a,b)=>{var{xAxis:c,width:d,height:e,offset:f}=a;return fA(u$(Q3(Q3(Q3({},u3),c),{},{ticks:fB(c,!0),viewBox:{x:0,y:0,width:d,height:e}})),f.left,f.left+f.width,b)},Rd=(a,b)=>{var{yAxis:c,width:d,height:e,offset:f}=a;return fA(u$(Q3(Q3(Q3({},u3),c),{},{ticks:fB(c,!0),viewBox:{x:0,y:0,width:d,height:e}})),f.top,f.top+f.height,b)},Re={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:lf.grid};function Rf(a){var b=fj(fJ),c=fj(fK),d=gf(),e=Q3(Q3({},qK(a,Re)),{},{x:dN(a.x)?a.x:d.left,y:dN(a.y)?a.y:d.top,width:dN(a.width)?a.width:d.width,height:dN(a.height)?a.height:d.height}),{xAxisId:f,yAxisId:g,x:h,y:i,width:j,height:k,syncWithTicks:l,horizontalValues:n,verticalValues:o}=e,p=fV(),q=fj(a=>nc(a,"xAxis",f,p)),r=fj(a=>nc(a,"yAxis",g,p));if(!fv(j)||!fv(k)||!dN(h)||!dN(i))return null;var s=e.verticalCoordinatesGenerator||Rc,t=e.horizontalCoordinatesGenerator||Rd,{horizontalPoints:u,verticalPoints:v}=e;if((!u||!u.length)&&"function"==typeof t){var w=n&&n.length,x=t({yAxis:r?Q3(Q3({},r),{},{ticks:w?n:r.ticks}):void 0,width:null!=b?b:j,height:null!=c?c:k,offset:d},!!w||l);f$(Array.isArray(x),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof x,"]")),Array.isArray(x)&&(u=x)}if((!v||!v.length)&&"function"==typeof s){var y=o&&o.length,z=s({xAxis:q?Q3(Q3({},q),{},{ticks:y?o:q.ticks}):void 0,width:null!=b?b:j,height:null!=c?c:k,offset:d},!!y||l);f$(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof z,"]")),Array.isArray(z)&&(v=z)}return C.createElement(rn,{zIndex:e.zIndex},C.createElement("g",{className:"recharts-cartesian-grid"},C.createElement(Q6,{fill:e.fill,fillOpacity:e.fillOpacity,x:e.x,y:e.y,width:e.width,height:e.height,ry:e.ry}),C.createElement(Ra,Q4({},e,{horizontalPoints:u})),C.createElement(Rb,Q4({},e,{verticalPoints:v})),C.createElement(Q8,Q4({},e,{offset:d,horizontalPoints:u,xAxis:q,yAxis:r})),C.createElement(Q9,Q4({},e,{offset:d,verticalPoints:v,xAxis:q,yAxis:r}))))}Rf.displayName="CartesianGrid";let Rg=["1h","12h","1d","7d","30d","90d"],Rh=["created_at","mentioned_at","occurred_start"],Ri="#8b5cf6",Rj="#ec4899",Rk="#6366f1",Rl="var(--chart-5)",Rm="var(--muted-foreground)",Rn={world:{label:"World",color:Ri},experience:{label:"Experience",color:Rj},observation:{label:"Observations",color:Rk}};function Ro(a){if(a<1e3)return a.toString();if(a<1e6){let b=a/1e3;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}k`}if(a<1e9){let b=a/1e6;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}M`}let b=a/1e9;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}B`}function Rp({value:a,className:b}){return(0,B.jsx)("span",{className:b,title:a.toLocaleString(),children:Ro(a)})}function Rq({active:a,payload:b,label:c,valueLabel:d}){return a&&b&&0!==b.length?(0,B.jsxs)("div",{className:"rounded-lg border border-border/60 bg-popover/95 backdrop-blur-sm px-3 py-2 shadow-md",children:[null!=c&&(0,B.jsx)("div",{className:"text-[11px] font-medium text-foreground mb-1.5",children:c}),(0,B.jsx)("div",{className:"space-y-1",children:b.map((a,b)=>(0,B.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:a.color||a.payload?.fill}}),(0,B.jsx)("span",{className:"text-muted-foreground",children:a.name||d||"Value"}),(0,B.jsx)("span",{className:"ml-auto pl-3 font-semibold tabular-nums text-foreground",children:(a.value??0).toLocaleString()})]},b))})]}):null}function Rr({children:a}){return(0,B.jsx)("h3",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em] mb-3",children:a})}function Rs(a,b){if(!a)return b?b("relativeTimeNever"):"Never";let c=Math.floor((Date.now()-new Date(a).getTime())/6e4);if(c<1)return b?b("relativeTimeJustNow"):"just now";if(c<60)return b?b("relativeTimeMinutes",{mins:c}):`${c}m ago`;let d=Math.floor(c/60);if(d<24)return b?b("relativeTimeHours",{hours:d}):`${d}h ago`;let e=Math.floor(d/24);return b?b("relativeTimeDays",{days:e}):`${e}d ago`}function Rt(a){return new Date(/[+Z-]$/.test(a)||/[+-]\d\d:?\d\d$/.test(a)?a:`${a}Z`)}function Ru({done:a,total:b,doneColor:c}){let d=Math.round(100*(b>0?a/b:0));return(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,B.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"tabular-nums font-semibold text-foreground text-sm",children:a.toLocaleString()}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:[" / ",b.toLocaleString()]})]}),(0,B.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-foreground",children:[d,"%"]})]}),(0,B.jsx)("div",{className:"h-1.5 w-full rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${d}%`,backgroundColor:c}})})]})}function Rv({title:a,items:b,emptyLabel:c}){let d=b.reduce((a,b)=>a+b.value,0);return(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:a}),(0,B.jsx)(Rp,{value:d,className:"text-xs text-muted-foreground tabular-nums"})]}),0===d?(0,B.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:c}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:b.filter(a=>a.value>0).map(a=>(0,B.jsx)("div",{className:"h-full",style:{width:`${a.value/d*100}%`,backgroundColor:a.color},title:`${a.name}: ${a.value.toLocaleString()}`},a.name))}),(0,B.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:b.map(a=>(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:a.color}}),(0,B.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:a.name})]}),(0,B.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,B.jsx)(Rp,{value:a.value,className:"text-base font-semibold tabular-nums"}),(0,B.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:d>0?`${(a.value/d*100).toFixed(0)}%`:"0%"})]})]},a.name))})]})]})}function Rw({icon:a,label:b,value:c}){return(0,B.jsxs)("div",{className:"flex items-center gap-3 p-4",children:[(0,B.jsx)("div",{className:"p-2 rounded-md bg-muted",children:(0,B.jsx)(a,{className:"w-4 h-4 text-muted-foreground"})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:b}),(0,B.jsx)(Rp,{value:c,className:"text-2xl font-semibold text-foreground leading-tight tabular-nums block"})]})]})}let Rx=["completed","processing","pending","failed","cancelled"],Ry={completed:"#10b981",processing:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",cancelled:"#6b7280"},Rz={completed:"completed",processing:"processing",pending:"pending",failed:"failed",cancelled:"cancelled"};function RA({byStatus:a}){let b=(0,E.useTranslations)("bankStats"),c={completed:b("opsCompleted"),processing:b("opsProcessing"),pending:b("opsPending"),failed:b("opsFailed"),cancelled:b("opsCancelled")},d=Rx.map(b=>({status:b,label:c[b]??Rz[b],value:a[b]||0,color:Ry[b]}));for(let[b,c]of Object.entries(a))Rx.includes(b)||d.push({status:b,label:b,value:c,color:Rm});let e=d.reduce((a,b)=>a+b.value,0),f=d.filter(a=>a.value>0);return(0,B.jsxs)(by.Card,{children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,B.jsxs)(by.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,B.jsx)(bj,{className:"w-3.5 h-3.5 text-muted-foreground"}),b("operations")]}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,B.jsx)(Rp,{value:e})," ",b("totalSuffix")]})]}),(0,B.jsx)(by.CardContent,{children:0===e?(0,B.jsx)("div",{className:"h-[100px] flex items-center justify-center text-sm text-muted-foreground",children:b("noOperationsYet")}):(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:f.map(a=>(0,B.jsx)("div",{className:"h-full",style:{width:`${a.value/e*100}%`,backgroundColor:a.color},title:`${a.label}: ${a.value.toLocaleString()}`},a.status))}),(0,B.jsx)("div",{className:"space-y-1.5",children:f.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px] flex-shrink-0",style:{backgroundColor:a.color}}),(0,B.jsx)("span",{className:"text-muted-foreground flex-1",children:a.label}),(0,B.jsx)(Rp,{value:a.value,className:"font-semibold tabular-nums text-foreground"}),(0,B.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums w-9 text-right",children:[(a.value/e*100).toFixed(0),"%"]})]},a.status))})]})})]})}function RB({done:a,pending:b,failed:c,total:d,lastConsolidatedAt:e}){let f=(0,E.useTranslations)("bankStats"),[g,h]=(0,C.useState)(!1),i=c>0;return(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:f("consolidation")})}),(0,B.jsxs)(by.CardContent,{className:"space-y-4",children:[(0,B.jsx)(Ru,{done:a,total:d,doneColor:Rl}),(0,B.jsxs)("div",{className:"grid grid-cols-4 gap-3 pt-1",children:[(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QX.default,{className:"w-3 h-3 text-emerald-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("done")})]}),(0,B.jsx)(Rp,{value:a,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(Ql,{className:"w-3 h-3 text-amber-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("pending")})]}),(0,B.jsx)(Rp,{value:b,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,B.jsxs)("button",{type:"button",onClick:()=>i&&h(!0),disabled:!i,className:`text-left space-y-0.5 rounded-md -mx-1 px-1 py-0.5 transition-colors ${i?"cursor-pointer hover:bg-red-500/10 focus:outline-none focus:ring-2 focus:ring-red-500/40":"cursor-default"}`,title:i?f("viewFailedMemoriesLabel"):void 0,children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QY,{className:`w-3 h-3 ${i?"text-red-600 dark:text-red-400":"text-muted-foreground/50"}`}),(0,B.jsx)("span",{className:`text-[10px] uppercase tracking-wider font-medium ${i?"text-red-600 dark:text-red-400":"text-muted-foreground"}`,children:f("failed")})]}),(0,B.jsxs)("span",{className:`text-base font-semibold tabular-nums block ${i?"text-red-600 dark:text-red-400":"text-foreground"}`,children:[(0,B.jsx)(Rp,{value:c}),i&&(0,B.jsx)(QZ,{className:"inline w-3 h-3 ml-1 opacity-70"})]})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(af,{className:"w-3 h-3 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("last")})]}),(0,B.jsx)("span",{className:"text-base font-semibold text-foreground block leading-tight",children:Rs(e,f)})]})]})]}),(0,B.jsx)(RC,{open:g,onOpenChange:h})]})}function RC({open:a,onOpenChange:b}){let c=(0,E.useTranslations)("bankStats"),d=(0,E.useTranslations)("failedConsolidations"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)([]),[h,i]=(0,C.useState)(0),[j,k]=(0,C.useState)(!1),[l,n]=(0,C.useState)(!1),[o,p]=(0,C.useState)(0);(0,C.useEffect)(()=>{if(!a||!e)return;let b=!1;return k(!0),V.client.listMemories(e,{consolidationState:"failed",limit:200}).then(a=>{b||(g(a.items),i(a.total))}).catch(()=>{}).finally(()=>{b||k(!1)}),()=>{b=!0}},[a,e,o]);let q=async()=>{if(e){n(!0);try{let a=await V.client.recoverConsolidation(e);a.retried_count>0&&await V.client.triggerConsolidation(e),F.toast.success(d("recoverSuccess",{count:a.retried_count})),p(a=>a+1)}catch{}finally{n(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-4xl max-h-[80vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsxs)(bm.DialogTitle,{className:"flex items-center gap-2",children:[(0,B.jsx)(QY,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),d("title")]}),(0,B.jsx)(bm.DialogDescription,{children:d("description")})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 py-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:j?d("loading"):d("totalFailed",{total:h})}),(0,B.jsxs)(W.Button,{size:"sm",onClick:q,disabled:l||j||0===h,children:[(0,B.jsx)(ad,{className:`w-3.5 h-3.5 mr-1.5 ${l?"animate-spin":""}`}),d("recoverAll")]})]}),(0,B.jsx)("div",{className:"flex-1 min-h-0 overflow-auto border border-border rounded-md",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[140px]",children:d("colFailedAt")}),(0,B.jsx)(an,{className:"w-[100px]",children:d("colType")}),(0,B.jsx)(an,{children:d("colText")})]})}),(0,B.jsxs)(al,{children:[0===f.length&&!j&&(0,B.jsx)(am,{children:(0,B.jsx)(ao,{colSpan:3,className:"text-center text-muted-foreground py-8",children:d("noFailedConsolidations")})}),f.map(a=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"text-xs text-muted-foreground whitespace-nowrap",children:Rs(a.consolidation_failed_at,c)}),(0,B.jsx)(ao,{className:"text-xs capitalize",children:a.fact_type}),(0,B.jsxs)(ao,{className:"text-sm",children:[(0,B.jsx)("div",{className:"line-clamp-2",children:a.text}),a.context&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:a.context})]})]},a.id))]})]})})]})})}function RD({models:a,lastConsolidatedAt:b}){let c=(0,E.useTranslations)("bankStats"),d=a.length,e=b?new Date(b).getTime():0,f=a.filter(a=>!e||!!a.last_refreshed_at&&new Date(a.last_refreshed_at).getTime()>=e).length,g=d-f;return(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)(by.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,B.jsx)(J$,{className:"w-3.5 h-3.5 text-muted-foreground"}),c("mentalModels")]})}),(0,B.jsx)(by.CardContent,{className:"space-y-4",children:0===d?(0,B.jsx)("div",{className:"text-sm text-muted-foreground py-4",children:c("noMentalModels")}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ru,{done:f,total:d,doneColor:Rl}),(0,B.jsxs)("div",{className:"grid grid-cols-3 gap-3 pt-1",children:[(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QX.default,{className:"w-3 h-3 text-emerald-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("upToDate")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:f})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(Ql,{className:"w-3 h-3 text-amber-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("stale")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:g})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(J$,{className:"w-3 h-3 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("total")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:d})]})]})]})})]})}let RE={fontSize:11,fill:Rm,fontWeight:500};function RF(){let a=(0,E.useTranslations)("bankStats"),b={created_at:{short:a("timeFieldIngestedShort"),long:a("timeFieldIngestedLong")},mentioned_at:{short:a("timeFieldMentionedShort"),long:a("timeFieldMentionedLong")},occurred_start:{short:a("timeFieldOccurredShort"),long:a("timeFieldOccurredLong")}},{currentBank:c}=(0,H.useBank)(),{features:d}=(0,I3.useFeatures)(),e=d?.observations??!1,[f,g]=(0,C.useState)(null),[h,i]=(0,C.useState)([]),[j,k]=(0,C.useState)(!1),[l,n]=(0,C.useState)("7d"),[o,p]=(0,C.useState)("created_at"),[q,r]=(0,C.useState)({trunc:"day",buckets:[]}),[s,t]=(0,C.useState)({world:!0,experience:!0,observation:!0}),u=async()=>{if(c){k(!0);try{let[a,b]=await Promise.all([V.client.getBankStats(c),V.client.listMentalModels(c)]);g(a),i(b.items||[])}catch(a){console.error("Error loading bank stats:",a)}finally{k(!1)}}},v=async()=>{if(c)try{let a=await V.client.getMemoriesTimeseries(c,l,o);r({trunc:a.trunc,buckets:a.buckets||[]})}catch(a){console.error("Error loading memories timeseries:",a)}};if((0,C.useEffect)(()=>{if(c){u();let a=setInterval(u,5e3);return()=>clearInterval(a)}},[c]),(0,C.useEffect)(()=>{if(c){v();let a=setInterval(v,5e3);return()=>clearInterval(a)}},[c,l,o]),j&&!f)return(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(af,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})});if(!f)return null;let w=e?["world","experience","observation"]:["world","experience"],x=q.buckets.map(a=>{var b,c,d,e;let f,g;return{...a,label:(b=a.time,c=q.trunc,f=Rt(b),"day"===c?f.toLocaleDateString(void 0,{month:"short",day:"numeric"}):f.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})),tooltipLabel:(d=a.time,e=q.trunc,g=Rt(d),"day"===e?g.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):g.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}))}}),y=x.reduce((a,b)=>a+w.reduce((a,c)=>a+(s[c]&&b[c]||0),0),0),z=Math.max(0,f.total_nodes-f.pending_consolidation),A={world:a("world"),experience:a("experience"),observation:a("observations")};return(0,B.jsxs)("div",{className:"space-y-8",children:[(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("memoryStore")}),(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"p-0",children:[(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 md:divide-x divide-y md:divide-y-0 divide-border/60",children:[(0,B.jsx)(Rw,{icon:M,label:a("memories"),value:f.total_nodes}),(0,B.jsx)(Rw,{icon:QW,label:a("documents"),value:f.total_documents}),(0,B.jsx)(Rw,{icon:QV,label:a("links"),value:f.total_links})]}),(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 md:divide-x divide-y md:divide-y-0 divide-border/60 border-t border-border/60",children:[(0,B.jsx)("div",{className:"p-5",children:(0,B.jsx)(Rv,{title:a("memoryComposition"),items:[{name:a("world"),value:f.nodes_by_fact_type?.world||0,color:Ri},{name:a("experience"),value:f.nodes_by_fact_type?.experience||0,color:Rj},...e?[{name:a("observations"),value:f.total_observations||0,color:Rk}]:[]],emptyLabel:a("noMemoriesYet")})}),(0,B.jsx)("div",{className:"p-5",children:(0,B.jsx)(Rv,{title:a("linkTypes"),items:[{name:a("temporal"),value:f.links_by_link_type?.temporal||0,color:"#009296"},{name:a("semantic"),value:f.links_by_link_type?.semantic||0,color:"#0074d9"},{name:a("entity"),value:f.links_by_link_type?.entity||0,color:"#f59e0b"}],emptyLabel:a("noLinksYet")})})]})]})})]}),(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("consolidation")}),(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,B.jsx)(RB,{done:z,pending:f.pending_consolidation,failed:f.failed_consolidation??0,total:f.total_nodes,lastConsolidatedAt:f.last_consolidated_at}),(0,B.jsx)(RD,{models:h,lastConsolidatedAt:f.last_consolidated_at})]})]}),(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("activity")}),(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,B.jsxs)(by.Card,{className:"lg:col-span-2",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 space-y-2",children:[(0,B.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:a("memoriesByTimeChartTitle",{field:b[o].short.toLowerCase()})}),(0,B.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:Rg.map(a=>(0,B.jsx)("button",{onClick:()=>n(a),className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors tabular-nums ${l===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a},a))})]}),(0,B.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5 w-fit",children:Rh.map(a=>(0,B.jsx)("button",{onClick:()=>p(a),title:b[a].long,className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors ${o===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:b[a].short},a))}),(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("div",{className:"flex items-center gap-1.5",children:w.map(a=>{let b=Rn[a],c=s[a];return(0,B.jsxs)("button",{onClick:()=>t(b=>({...b,[a]:!b[a]})),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[11px] font-medium transition-all ${c?"bg-muted text-foreground":"bg-transparent text-muted-foreground/60 hover:text-muted-foreground"}`,children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px] transition-opacity",style:{backgroundColor:b.color,opacity:c?1:.3}}),A[a]]},a)})}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,B.jsx)(Rp,{value:y})," ",a("totalSuffix")]})]})]}),(0,B.jsx)(by.CardContent,{children:0===x.length||0===y?(0,B.jsx)("div",{className:"h-[180px] flex items-center justify-center text-sm text-muted-foreground",children:a("noMemoriesIngestedInPeriod")}):(0,B.jsx)("div",{className:"h-[180px]",children:(0,B.jsx)(gb,{width:"100%",height:"100%",children:(0,B.jsxs)(un,{data:x,margin:{top:8,right:8,bottom:0,left:-10},children:[(0,B.jsx)("defs",{children:w.map(a=>(0,B.jsxs)("linearGradient",{id:`grad-${a}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,B.jsx)("stop",{offset:"0%",stopColor:Rn[a].color,stopOpacity:.35}),(0,B.jsx)("stop",{offset:"100%",stopColor:Rn[a].color,stopOpacity:0})]},a))}),(0,B.jsx)(Rf,{vertical:!1,stroke:"var(--border)",strokeOpacity:.5,strokeDasharray:"2 4"}),(0,B.jsx)(vl,{dataKey:"label",tick:RE,axisLine:!1,tickLine:!1,dy:4,minTickGap:20}),(0,B.jsx)(vt,{tick:RE,axisLine:!1,tickLine:!1,width:40,allowDecimals:!1,tickFormatter:a=>Ro(a)}),(0,B.jsx)(v0,{content:(0,B.jsx)(Rq,{}),labelFormatter:(a,b)=>b?.[0]?.payload?.tooltipLabel||"",cursor:{stroke:Rm,strokeWidth:1,strokeDasharray:"3 3"}}),w.map(a=>s[a]?(0,B.jsx)(uT,{type:"monotone",dataKey:a,name:A[a],stackId:"a",stroke:Rn[a].color,strokeWidth:2,fill:`url(#grad-${a})`,isAnimationActive:!1},a):null)]})})})})]}),(0,B.jsx)(RA,{byStatus:f.operations_by_status||{}})]})]})]})}var bh=bh;let RG=(0,K.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),RH=(0,K.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),RI=["all","retain","consolidation","refresh_mental_model","file_convert_retain","webhook_delivery","graph_maintenance"],RJ=[null,"pending","processing","completed","failed","cancelled"];function RK(){let a,b,c,d=(0,E.useTranslations)("bankOperations"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)([]),[h,i]=(0,C.useState)(0),[j,k]=(0,C.useState)(null),[l,n]=(0,C.useState)(null),[o]=(0,C.useState)(10),[p,q]=(0,C.useState)(0),[r,s]=(0,C.useState)(null),[t,u]=(0,C.useState)(null),[v,w]=(0,C.useState)(!1),[x,y]=(0,C.useState)(null),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(null),[L,M]=(0,C.useState)(()=>Date.now()),N={all:d("status.all"),pending:d("status.pending"),processing:d("status.processing"),completed:d("status.completed"),failed:d("status.failed"),cancelled:d("status.cancelled")},O={all:d("operationType.all"),retain:d("operationType.retain"),consolidation:d("operationType.consolidation"),refresh_mental_model:d("operationType.refreshMentalModel"),file_convert_retain:d("operationType.fileConvertRetain"),webhook_delivery:d("operationType.webhookDelivery"),graph_maintenance:d("operationType.graphMaintenance")},P=a=>a?N[a]??a:d("unknown"),Q=a=>a?O[a]??a:d("notAvailable"),R=(a,b)=>{let c=P(a);return"pending"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),c]}):"processing"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:[(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}),c]}):"failed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",title:b??void 0,children:[(0,B.jsx)(Ql,{className:"w-3 h-3"}),c]}):"completed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),c]}):"cancelled"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/10 text-gray-600 dark:text-gray-400 border border-gray-500/20",children:[(0,B.jsx)(RH,{className:"w-3 h-3"}),c]}):(0,B.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:c})},S=a=>{let b=new Date(a).getTime();if(Number.isNaN(b))return"";let c=Math.max(0,Math.round((L-b)/1e3));return c<5?d("heartbeat.justNow"):c<60?d("heartbeat.secondsAgo",{secs:c}):c<3600?d("heartbeat.minutesAgo",{mins:Math.floor(c/60)}):d("heartbeat.hoursAgo",{hours:Math.floor(c/3600)})},T=(a,b)=>{if(!a)return null;let c=a.stage.replace(/[._]/g," "),e="number"==typeof a.processed&&"number"==typeof a.total&&a.total>0,f=e?Math.min(100,Math.round(a.processed/a.total*100)):null,g=a.at?S(a.at):null;return b?.compact?(0,B.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground whitespace-nowrap",title:`${c}${a.at?` — ${new Date(a.at).toLocaleString()}`:""}`,children:[null!==f&&(0,B.jsx)("span",{className:"h-1 w-14 shrink-0 rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("span",{className:"block h-full rounded-full bg-blue-500/70",style:{width:`${f}%`}})}),e&&(0,B.jsxs)("span",{className:"font-mono",children:[a.processed,"/",a.total]}),g&&(0,B.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",g]})]}):(0,B.jsxs)("div",{className:"mt-1 space-y-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,B.jsx)("span",{className:"capitalize",children:c}),e&&(0,B.jsxs)("span",{className:"font-mono",children:[a.processed,"/",a.total]})]}),null!==f&&(0,B.jsx)("div",{className:"h-1 w-24 rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("div",{className:"h-full rounded-full bg-blue-500/70",style:{width:`${f}%`}})}),a.at&&(0,B.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground/80",title:new Date(a.at).toLocaleString(),children:[(0,B.jsx)(af,{className:"w-2.5 h-2.5"}),(0,B.jsxs)("span",{children:[d("field.lastHeartbeat")," · ",S(a.at)]})]})]})},U=(0,C.useCallback)(async(a=j,b=p,c=l)=>{if(e){w(!0);try{let d=await V.client.listOperations(e,{status:a||void 0,type:c||void 0,limit:o,offset:b,excludeParents:!0});g(d.operations||[]),i(d.total||0),M(Date.now())}catch(a){console.error("Error loading operations:",a)}finally{w(!1)}}},[e,j,p,l,o]),X=a=>{q(a),U(j,a,l)},Y=async a=>{if(e){s(a);try{await V.client.cancelOperation(e,a),await U()}catch(a){}finally{s(null)}}},Z=async a=>{if(e){u(a);try{await V.client.retryOperation(e,a),await U()}catch(a){}finally{u(null)}}},$=async a=>{if(e){F(!0),A(!0),K(null);try{let b=await V.client.getOperationStatus(e,a);y(b)}catch(a){console.error("Error loading operation details:",a),y({error:d("operationDetailsLoadError")})}finally{F(!1)}}},_=async()=>{if(e&&x?.operation_id){I(!0);try{let a=x.operation_id,b=await V.client.getOperationStatus(e,a,{includePayload:!0});y(b),K(a)}catch(a){console.error("Error loading raw payload:",a)}finally{I(!1)}}},aa=f.some(a=>"processing"===a.status);(0,C.useEffect)(()=>{if(e){U(j,p,l);let a=setInterval(()=>U(j,p,l),aa?2e3:5e3);return()=>clearInterval(a)}},[e,j,p,l,aa,U]),(0,C.useEffect)(()=>{if(!aa)return;let a=setInterval(()=>M(Date.now()),1e3);return()=>clearInterval(a)},[aa]);let ab=(0,C.useRef)({}),[ac,ag]=(0,C.useState)(new Set);return((0,C.useEffect)(()=>{let a=ab.current,b=f.filter(b=>a[b.id]&&a[b.id]!==b.status&&("completed"===b.status||"failed"===b.status||"cancelled"===b.status)).map(a=>a.id);if(ab.current=Object.fromEntries(f.map(a=>[a.id,a.status])),0===b.length)return;ag(a=>new Set([...a,...b]));let c=setTimeout(()=>ag(a=>{let c=new Set(a);return b.forEach(a=>c.delete(a)),c}),1200);return()=>clearTimeout(c)},[f]),e)?(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-lg font-semibold",children:d("title")}),(0,B.jsx)("button",{onClick:()=>U(),className:"p-1 rounded hover:bg-muted transition-colors",title:d("refreshOperations"),disabled:v,children:(0,B.jsx)(ad,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${v?"animate-spin":""}`})})]}),(0,B.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d("operationCount",{count:h}),j?` (${P(j)})`:""]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsxs)(bb.Select,{value:l??"all",onValueChange:a=>{var b;n(b="all"===a?null:a),q(0),U(j,0,b)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,B.jsx)(bb.SelectValue,{placeholder:d("allTypes")})}),(0,B.jsx)(bb.SelectContent,{children:RI.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{children:O[a]}),"all"!==a&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:a})]})},a))})]}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:RJ.map(a=>(0,B.jsx)("button",{onClick:()=>{k(a),q(0),U(a,0,l)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${j===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a?P(a):N.all},a??"all"))})]})]}),(0,B.jsx)("div",{children:f.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[100px]",children:d("table.id")}),(0,B.jsx)(an,{children:d("table.type")}),(0,B.jsx)(an,{children:d("table.created")}),(0,B.jsx)(an,{children:d("field.updated")}),(0,B.jsx)(an,{className:"w-[300px]",children:d("table.status")}),(0,B.jsx)(an,{className:"w-[110px]",children:d("table.actions")})]})}),(0,B.jsx)(al,{children:f.map(a=>(0,B.jsxs)(am,{className:`cursor-pointer transition-colors duration-700 hover:bg-muted/50 ${ac.has(a.id)?"completed"===a.status?"bg-emerald-500/15":"bg-red-500/15":"failed"===a.status?"bg-red-500/5":""}`,onClick:()=>$(a.id),children:[(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.id.substring(0,8)}),(0,B.jsx)(ao,{className:"font-medium",title:a.task_type,children:Q(a.task_type)}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",children:new Date(a.created_at).toLocaleString()}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",title:a.updated_at?new Date(a.updated_at).toLocaleString():void 0,children:a.updated_at?S(a.updated_at):"—"}),(0,B.jsx)(ao,{className:"w-[300px]",children:(0,B.jsxs)("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[R(a.status,a.error_message),"processing"===a.status&&T(a.progress,{compact:!0})]})}),(0,B.jsxs)(ao,{className:"w-[110px] whitespace-nowrap",children:["pending"===a.status&&(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:b=>{b.stopPropagation(),Y(a.id)},disabled:r===a.id,children:[r===a.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(bg.X,{className:"w-3 h-3 mr-1"}),r===a.id?"":d("action.cancel")]}),("failed"===a.status||"cancelled"===a.status)&&(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:b=>{b.stopPropagation(),Z(a.id)},disabled:t===a.id,children:[t===a.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(bk,{className:"w-3 h-3 mr-1"}),t===a.id?"":d("action.retry")]})]})]},a.id))})]})}),h>o&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:d("pagination",{start:p+1,end:Math.min(p+o,h),total:h})}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>X(Math.max(0,p-o)),disabled:0===p,children:d("paginationPrevious")}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>X(p+o),disabled:p+o>=h,children:d("paginationNext")})]})]})]}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:j?d("emptyStateWithStatus",{status:P(j)}):d("emptyState")})}),(0,B.jsx)(bm.Dialog,{open:z,onOpenChange:A,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("operationDetails")}),(0,B.jsx)(bm.DialogDescription,{children:x?.operation_id&&(0,B.jsx)("span",{className:"font-mono text-xs",children:x.operation_id})})]}),D?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)(bh.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):x?(0,B.jsx)("div",{className:"space-y-4",children:x.error?(0,B.jsx)("div",{className:"text-red-600 dark:text-red-400",children:x.error}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.status")}),(0,B.jsx)("div",{className:"mt-1",children:R(x.status)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.type")}),(0,B.jsx)("div",{className:"mt-1 font-mono text-sm",title:x.operation_type??void 0,children:Q(x.operation_type)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.created")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.created_at?new Date(x.created_at).toLocaleString():d("notAvailable")})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.updated")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.updated_at?new Date(x.updated_at).toLocaleString():d("notAvailable")})]}),x.completed_at&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.completed")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:new Date(x.completed_at).toLocaleString()})]}),x.result_metadata?.items_count!==void 0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("totalItems")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.result_metadata.items_count})]})]}),"processing"===x.status&&x.progress&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:d("field.progress")}),T(x.progress),"consolidation"===x.operation_type&&(0,B.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/70",children:d("progressEstimateNote")})]}),("pending"===x.status||"failed"===x.status||"cancelled"===x.status)&&(0,B.jsxs)("div",{className:"flex gap-2",children:["pending"===x.status&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Y(x.operation_id),disabled:r===x.operation_id,children:[r===x.operation_id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,B.jsx)(bg.X,{className:"w-3 h-3 mr-1"}),d("action.cancel")]}),("failed"===x.status||"cancelled"===x.status)&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Z(x.operation_id),disabled:t===x.operation_id,children:[t===x.operation_id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,B.jsx)(bk,{className:"w-3 h-3 mr-1"}),d("action.retry")]})]}),x.result_metadata&&Object.keys(x.result_metadata).length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("metadata")}),(0,B.jsx)("pre",{className:"rounded-lg border bg-muted/30 p-3 text-xs font-mono overflow-x-auto max-h-96 whitespace-pre-wrap break-words",children:JSON.stringify(x.result_metadata,null,2)})]}),x.error_message&&(0,B.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,B.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:d("error")}),(0,B.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:x.error_message})]}),x.child_operations&&x.child_operations.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("subBatchesCount",{count:x.result_metadata?.num_sub_batches||x.child_operations.length})}),(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[60px]",children:d("table.index")}),(0,B.jsx)(an,{className:"w-[100px]",children:d("table.id")}),(0,B.jsx)(an,{className:"w-[80px]",children:d("table.items")}),(0,B.jsx)(an,{children:d("table.status")})]})}),(0,B.jsx)(al,{children:x.child_operations.map(a=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"text-sm",children:a.sub_batch_index}),(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.operation_id.substring(0,8)}),(0,B.jsx)(ao,{className:"text-sm",children:a.items_count}),(0,B.jsx)(ao,{children:R(a.status,a.error_message)})]},a.operation_id))})]})]}),(a=J===x.operation_id,b=!!x.task_payload,c=!!x.result_metadata?.is_parent,(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("rawPayload")}),!a&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:_,disabled:G,children:[G?(0,B.jsx)(bh.default,{className:"w-3 h-3 mr-1 animate-spin"}):(0,B.jsx)(RG,{className:"w-3 h-3 mr-1"}),d("loadRaw")]})]}),b?(0,B.jsx)("pre",{className:"rounded-lg border bg-muted/30 p-3 text-xs font-mono overflow-x-auto max-h-96 whitespace-pre-wrap break-words",children:JSON.stringify(x.task_payload,null,2)}):a?(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:c?d("rawPayloadParentHelp"):d("rawPayloadEmpty")}):(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("rawPayloadHelp")})]}))]})}):null]})})]}):null}var bh=bh;let RL=(0,K.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);function RM(){let a=(0,E.useTranslations)("mentalModels"),{currentBank:b}=(0,H.useBank)(),[c,d]=(0,C.useState)([]),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)("files"),[i,j]=(0,C.useState)(""),[k,l]=(0,C.useState)(1),[n,o]=(0,C.useState)(!1),[p,q]=(0,C.useState)(null),[r,s]=(0,C.useState)(null),[t,u]=(0,C.useState)([]),[v,w]=(0,C.useState)("any"),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(null),[D,G]=(0,C.useState)(null),[I,J]=(0,C.useState)(!1),[K,M]=(0,C.useState)(null),[N,O]=(0,C.useState)(!1),R=c.filter(a=>{if(!i)return!0;let b=i.toLowerCase();return a.id.toLowerCase().includes(b)||a.name.toLowerCase().includes(b)||a.source_query.toLowerCase().includes(b)||a.content.toLowerCase().includes(b)}),S=async()=>{if(b){f(!0);try{let a=await V.client.listMentalModels(b,t.length>0?t:void 0,t.length>0?v:void 0);d(a.items||[])}catch(a){console.error("Error loading mental models:",a)}finally{f(!1)}}},[T,U]=(0,C.useState)(new Set),Y=async c=>{if(!b)return;let e=c.last_refreshed_at;U(a=>new Set(a).add(c.id));try{await V.client.refreshMentalModel(b,c.id);for(let f=0;f<120;f++){await new Promise(a=>setTimeout(a,1e3));let f=await V.client.getMentalModel(b,c.id);if(f.last_refreshed_at!==e){d(a=>a.map(a=>a.id===c.id?f:a)),p?.id===c.id&&q(f),F.toast.success(a("toastRefreshed"));return}}F.toast.error(a("toastRefreshTimeout"))}catch{}finally{U(a=>{let b=new Set(a);return b.delete(c.id),b})}},Z=async()=>{if(b&&D){J(!0);try{await V.client.deleteMentalModel(b,D.id),d(a=>a.filter(a=>a.id!==D.id)),p?.id===D.id&&q(null),G(null)}catch(a){}finally{J(!1)}}},$=async()=>{if(b&&K){O(!0);try{let a=await V.client.clearMentalModel(b,K.id);d(b=>b.map(b=>b.id===a.id?a:b)),p?.id===a.id&&q(a),F.toast.success("Mental model content cleared"),M(null)}catch{}finally{O(!1)}}};if((0,C.useEffect)(()=>{b&&S()},[b,t,v]),(0,C.useEffect)(()=>{let a=a=>{"Escape"===a.key&&q(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),(0,C.useEffect)(()=>{l(1)},[i,t,v]),!b)return(0,B.jsx)(by.Card,{children:(0,B.jsx)(by.CardContent,{className:"p-10 text-center",children:(0,B.jsx)("p",{className:"text-muted-foreground",children:a("selectBankPrompt")})})});let ab=Math.ceil(R.length/100),ac=(k-1)*100,ae=ac+100,af=R.slice(ac,ae);return(0,B.jsxs)("div",{children:[e?(0,B.jsxs)("div",{className:"text-center py-12",children:[(0,B.jsx)(ad,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:a("loading")})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"mb-4 flex items-center gap-3 flex-wrap",children:[(0,B.jsx)(X.Input,{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:a("filterPlaceholder"),className:"w-80 h-9"}),(0,B.jsx)(IS,{value:t,onChange:u,fetchSuggestions:async a=>{if(!b)return[];let c=a?`${a}*`:void 0;return(await V.client.listTags(b,c,20,"mental_models")).items.map(a=>a.tag)},matchMode:v,onMatchModeChange:w,className:"flex-1 min-w-[260px]"}),(0,B.jsxs)(W.Button,{onClick:()=>o(!0),size:"sm",children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-2"}),a("addMentalModel")]})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:i||t.length>0?a("countFiltered",{filtered:R.length,total:c.length}):a("count",{count:c.length})}),(0,B.jsx)("div",{className:"flex items-center gap-3",children:(0,B.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,B.jsxs)("button",{onClick:()=>h("files"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"files"===g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(QW,{className:"w-4 h-4"}),a("viewList")]}),(0,B.jsxs)("button",{onClick:()=>h("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(RL,{className:"w-4 h-4"}),a("viewDashboard")]})]})})]}),R.length>0?(0,B.jsxs)(B.Fragment,{children:["dashboard"===g&&(0,B.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:af.map(b=>(0,B.jsx)(by.Card,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${p?.id===b.id?"border-primary shadow-md":""}`,onClick:()=>q(b),children:(0,B.jsxs)(by.CardContent,{className:"p-4",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:b.name}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:b.id}),(0,B.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${b.trigger?.refresh_after_consolidation?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-slate-500/10 text-slate-600 dark:text-slate-400"}`,children:b.trigger?.refresh_after_consolidation?a("badgeAutoRefresh"):a("badgeManual")})]})]}),(0,B.jsx)(RN,{m:b,refreshing:T.has(b.id),onEdit:a=>{A(a),y(!0)},onRefresh:Y,onClear:a=>M({id:a.id,name:a.name}),onDelete:a=>G({id:a.id,name:a.name}),triggerClassName:"h-7 w-7 ml-2 flex-shrink-0"})]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:b.source_query}),(0,B.jsxs)("div",{className:"relative mb-3 border-t border-border pt-3 max-h-40 overflow-hidden",children:[(0,B.jsx)(PJ,{children:b.content}),(0,B.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-card to-transparent"})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,B.jsx)("div",{className:"flex items-center gap-2",children:b.tags.length>0&&(0,B.jsxs)("div",{className:"flex gap-1",children:[b.tags.slice(0,2).map(a=>(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a)),b.tags.length>2&&(0,B.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",b.tags.length-2]})]})}),(0,B.jsx)("div",{className:"text-muted-foreground",title:PQ(b.last_refreshed_at),children:PP(b.last_refreshed_at)})]})]})},b.id))}),"files"===g&&(0,B.jsx)(RQ,{mentalModels:R,selectedId:r,onSelect:s,onOpenDetail:q,refreshingIds:T,onEdit:a=>{A(a),y(!0)},onRefresh:Y,onClear:a=>M({id:a.id,name:a.name}),onDelete:a=>G({id:a.id,name:a.name})}),"files"!==g&&ab>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,B.jsxs)("div",{className:"text-xs text-muted-foreground",children:[ac+1,"-",Math.min(ae,R.length)," of"," ",R.length]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(1),disabled:1===k,className:"h-7 w-7 p-0",children:(0,B.jsx)(_,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(a=>Math.max(1,a-1)),disabled:1===k,className:"h-7 w-7 p-0",children:(0,B.jsx)(P,{className:"h-3 w-3"})}),(0,B.jsxs)("span",{className:"text-xs px-2",children:[k," / ",ab]}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(a=>Math.min(ab,a+1)),disabled:k===ab,className:"h-7 w-7 p-0",children:(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(ab),disabled:k===ab,className:"h-7 w-7 p-0",children:(0,B.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,B.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,B.jsx)(L,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:i?a("emptyFilterMatch"):a("emptyNoModels")})]})]}),(0,B.jsx)(RO,{open:n,onClose:()=>o(!1),onCreated:()=>{o(!1),S()}}),(0,B.jsx)(Jc,{open:!!D,onOpenChange:a=>!a&&G(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:a("deleteDialogTitle")}),(0,B.jsxs)(Jx,{children:[a("deleteDialogDescription",{name:D?.name??""}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),(0,B.jsx)("span",{className:"text-destructive font-semibold",children:a("deleteDialogWarning")})]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:a("deleteDialogCancel")}),(0,B.jsxs)(Jy,{onClick:Z,disabled:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[I?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,a("deleteDialogConfirm")]})]})]})}),(0,B.jsx)(Jc,{open:!!K,onOpenChange:a=>!a&&M(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:a("clearDialogTitle")}),(0,B.jsxs)(Jx,{children:[a.rich("clearDialogDescription",{name:K?.name??"",bold:a=>(0,B.jsx)("span",{className:"font-semibold",children:a})}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),a("clearDialogReSynth")]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:a("cancelButton")}),(0,B.jsxs)(Jy,{onClick:$,disabled:N,children:[N?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,a("clearDialogConfirm")]})]})]})}),(0,B.jsx)(P0,{mentalModelId:p?.id??null,onClose:()=>q(null),onDelete:a=>G({id:a.id,name:a.name}),onClear:a=>M({id:a.id,name:a.name}),onEdit:a=>{A(a),y(!0)},onRefreshed:a=>{d(b=>b.map(b=>b.id===a.id?a:b)),q(a)}}),z&&(0,B.jsx)(RP,{open:x,mentalModel:z,onClose:()=>{y(!1),A(null)},onUpdated:a=>{d(b=>b.map(b=>b.id===a.id?a:b)),q(a),y(!1),A(null)}})]})}function RN({m:a,refreshing:b,onEdit:c,onRefresh:d,onClear:e,onDelete:f,triggerClassName:g}){let h=(0,E.useTranslations)("mentalModels");return(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:`p-0 text-muted-foreground ${g??"h-8 w-8"}`,onClick:a=>a.stopPropagation(),"aria-label":h("actionsAriaLabel"),children:(0,B.jsx)(JB,{className:"h-4 w-4"})})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",onClick:a=>a.stopPropagation(),children:[(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>c(a),children:[(0,B.jsx)(bl,{className:"h-4 w-4 mr-2"}),h("actionEdit")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>d(a),disabled:b,children:[(0,B.jsx)(ad,{className:`h-4 w-4 mr-2 ${b?"animate-spin":""}`}),h("actionRefresh")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>e(a),children:[(0,B.jsx)(KM,{className:"h-4 w-4 mr-2"}),h("actionClearContent")]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>f(a),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,B.jsx)(JA,{className:"h-4 w-4 mr-2"}),h("actionDelete")]})]})]})}function RO({open:a,onClose:b,onCreated:c}){let d=(0,E.useTranslations)("mentalModels"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(!1),[h,i]=(0,C.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),j=async()=>{if(e&&h.name.trim()&&h.sourceQuery.trim()){g(!0);try{let a,b=h.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),f=parseInt(h.maxTokens)||2048,g=h.excludeMentalModelIds.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(h.tagGroups.trim())try{a=JSON.parse(h.tagGroups.trim())}catch{F.toast.error(d("invalidTagGroupsJson"));return}let j=h.recallMaxTokens.trim()?parseInt(h.recallMaxTokens,10):void 0,k=h.recallChunksMaxTokens.trim()?parseInt(h.recallChunksMaxTokens,10):void 0,l="true"===h.includeChunks||"false"!==h.includeChunks&&void 0;await V.client.createMentalModel(e,{id:h.id.trim()||void 0,name:h.name.trim(),source_query:h.sourceQuery.trim(),tags:b.length>0?b:void 0,max_tokens:f,trigger:{mode:h.mode,refresh_after_consolidation:h.autoRefresh,fact_types:h.factTypes.length>0?h.factTypes:void 0,exclude_mental_models:h.excludeMentalModels||void 0,exclude_mental_model_ids:g.length>0?g:void 0,tags_match:h.tagsMatch||void 0,tag_groups:a,include_chunks:l,recall_max_tokens:j,recall_chunks_max_tokens:k}}),i({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),c()}catch(a){}finally{g(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>{a||(i({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),b())},children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("createDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("createDialogDescription")})]}),(0,B.jsxs)(br.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,B.jsxs)(br.TabsList,{className:"w-full",children:[(0,B.jsx)(br.TabsTrigger,{value:"general",className:"flex-1",children:d("tabGeneral")}),(0,B.jsx)(br.TabsTrigger,{value:"options",className:"flex-1",children:d("tabOptions")})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,B.jsxs)(br.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldId")}),(0,B.jsx)(X.Input,{value:h.id,onChange:a=>i({...h,id:a.target.value}),placeholder:d("fieldIdPlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldName")}),(0,B.jsx)(X.Input,{value:h.name,onChange:a=>i({...h,name:a.target.value}),placeholder:d("fieldNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldSourceQuery")}),(0,B.jsx)(J2.Textarea,{value:h.sourceQuery,onChange:a=>i({...h,sourceQuery:a.target.value}),placeholder:d("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldMaxTokens")}),(0,B.jsx)(X.Input,{type:"number",value:h.maxTokens,onChange:a=>i({...h,maxTokens:a.target.value}),placeholder:d("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,B.jsxs)(br.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionRefresh")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"auto-refresh",checked:h.autoRefresh,onCheckedChange:a=>i({...h,autoRefresh:!0===a})}),(0,B.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:d("optionsAutoRefreshLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRefreshModeLabel")}),(0,B.jsxs)(bb.Select,{value:h.mode,onValueChange:a=>i({...h,mode:a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"full",children:d("optionsRefreshModeFull")}),(0,B.jsx)(bb.SelectItem,{value:"delta",children:d("optionsRefreshModeDelta")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRefreshModeDeltaDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionOtherModels")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"exclude-mental-models",checked:h.excludeMentalModels,onCheckedChange:a=>i({...h,excludeMentalModels:!0===a})}),(0,B.jsx)("label",{htmlFor:"exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:d("optionsExcludeAllLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsExcludeIdsLabel")}),(0,B.jsx)(X.Input,{value:h.excludeMentalModelIds,onChange:a=>i({...h,excludeMentalModelIds:a.target.value}),placeholder:d("optionsExcludeIdsPlaceholder")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionTags")}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagsLabel")}),(0,B.jsx)(X.Input,{value:h.tags,onChange:a=>i({...h,tags:a.target.value}),placeholder:d("optionsTagsPlaceholder")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagsDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagsMatchLabel")}),(0,B.jsxs)(bb.Select,{value:h.tagsMatch,onValueChange:a=>i({...h,tagsMatch:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{placeholder:d("optionsTagsMatchDefaultPlaceholder")})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:d("optionsTagsMatchDefault")}),(0,B.jsx)(bb.SelectItem,{value:"any",children:d("optionsTagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:d("optionsTagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:d("optionsTagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:d("optionsTagsMatchAllStrict")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagsMatchDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagGroupsLabel")}),(0,B.jsx)(J2.Textarea,{value:h.tagGroups,onChange:a=>i({...h,tagGroups:a.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagGroupsDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionRecall")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallDescription")}),(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsFactTypesLabel")}),(0,B.jsx)(JY,{value:h.factTypes,onChange:a=>i({...h,factTypes:a})}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsFactTypesEmpty")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsIncludeChunksLabel")}),(0,B.jsxs)(bb.Select,{value:h.includeChunks||"default",onValueChange:a=>i({...h,includeChunks:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:d("optionsIncludeChunksDefault")}),(0,B.jsx)(bb.SelectItem,{value:"true",children:d("optionsIncludeChunksYes")}),(0,B.jsx)(bb.SelectItem,{value:"false",children:d("optionsIncludeChunksNo")})]})]})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRecallMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:h.recallMaxTokens,onChange:a=>i({...h,recallMaxTokens:a.target.value}),placeholder:d("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallMaxTokensDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRecallChunksMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:h.recallChunksMaxTokens,onChange:a=>i({...h,recallChunksMaxTokens:a.target.value}),placeholder:d("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:b,disabled:f,children:d("cancelButton")}),(0,B.jsx)(W.Button,{onClick:j,disabled:f||!h.name.trim()||!h.sourceQuery.trim(),children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}),d("creatingButton")]}):d("createButton")})]})]})})}function RP({open:a,mentalModel:b,onClose:c,onUpdated:d}){let e=(0,E.useTranslations)("mentalModels"),{currentBank:f}=(0,H.useBank)(),[g,h]=(0,C.useState)(!1),i=()=>({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1,mode:b.trigger?.mode||"full",factTypes:b.trigger?.fact_types||[],excludeMentalModels:b.trigger?.exclude_mental_models||!1,excludeMentalModelIds:(b.trigger?.exclude_mental_model_ids||[]).join(", "),tagsMatch:b.trigger?.tags_match||"",tagGroups:b.trigger?.tag_groups?JSON.stringify(b.trigger.tag_groups,null,2):"",includeChunks:b.trigger?.include_chunks===!0?"true":b.trigger?.include_chunks===!1?"false":"",recallMaxTokens:b.trigger?.recall_max_tokens!=null?String(b.trigger.recall_max_tokens):"",recallChunksMaxTokens:b.trigger?.recall_chunks_max_tokens!=null?String(b.trigger.recall_chunks_max_tokens):""}),[j,k]=(0,C.useState)(i);(0,C.useEffect)(()=>{a&&k(i())},[a,b]);let l=async()=>{if(f&&j.name.trim()&&j.sourceQuery.trim()){h(!0);try{let a,g=j.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),h=parseInt(j.maxTokens)||2048,i=j.excludeMentalModelIds.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(j.tagGroups.trim())try{a=JSON.parse(j.tagGroups.trim())}catch{F.toast.error(e("invalidTagGroupsJson"));return}let k=j.recallMaxTokens.trim()?parseInt(j.recallMaxTokens,10):void 0,l=j.recallChunksMaxTokens.trim()?parseInt(j.recallChunksMaxTokens,10):void 0,n="true"===j.includeChunks||"false"!==j.includeChunks&&void 0,o=await V.client.updateMentalModel(f,b.id,{name:j.name.trim(),source_query:j.sourceQuery.trim(),tags:g.length>0?g:void 0,max_tokens:h,trigger:{mode:j.mode,refresh_after_consolidation:j.autoRefresh,fact_types:j.factTypes.length>0?j.factTypes:void 0,exclude_mental_models:j.excludeMentalModels||void 0,exclude_mental_model_ids:i.length>0?i:void 0,tags_match:j.tagsMatch||void 0,tag_groups:a,include_chunks:n,recall_max_tokens:k,recall_chunks_max_tokens:l}});d(o),c()}catch(a){}finally{h(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:e("updateDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:e("updateDialogDescription")})]}),(0,B.jsxs)(br.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,B.jsxs)(br.TabsList,{className:"w-full",children:[(0,B.jsx)(br.TabsTrigger,{value:"general",className:"flex-1",children:e("tabGeneral")}),(0,B.jsx)(br.TabsTrigger,{value:"options",className:"flex-1",children:e("tabOptions")})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,B.jsxs)(br.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:e("fieldId")}),(0,B.jsx)(X.Input,{value:b.id,disabled:!0,className:"bg-muted"})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldName")}),(0,B.jsx)(X.Input,{value:j.name,onChange:a=>k({...j,name:a.target.value}),placeholder:e("fieldNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldSourceQuery")}),(0,B.jsx)(J2.Textarea,{value:j.sourceQuery,onChange:a=>k({...j,sourceQuery:a.target.value}),placeholder:e("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldMaxTokens")}),(0,B.jsx)(X.Input,{type:"number",value:j.maxTokens,onChange:a=>k({...j,maxTokens:a.target.value}),placeholder:e("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,B.jsxs)(br.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionRefresh")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"update-auto-refresh",checked:j.autoRefresh,onCheckedChange:a=>k({...j,autoRefresh:!0===a})}),(0,B.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:e("optionsAutoRefreshLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRefreshModeLabel")}),(0,B.jsxs)(bb.Select,{value:j.mode,onValueChange:a=>k({...j,mode:a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"full",children:e("optionsRefreshModeFull")}),(0,B.jsx)(bb.SelectItem,{value:"delta",children:e("optionsRefreshModeDelta")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRefreshModeDeltaDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionOtherModels")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"update-exclude-mental-models",checked:j.excludeMentalModels,onCheckedChange:a=>k({...j,excludeMentalModels:!0===a})}),(0,B.jsx)("label",{htmlFor:"update-exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:e("optionsExcludeAllLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsExcludeIdsLabel")}),(0,B.jsx)(X.Input,{value:j.excludeMentalModelIds,onChange:a=>k({...j,excludeMentalModelIds:a.target.value}),placeholder:e("optionsExcludeIdsPlaceholder")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionTags")}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagsLabel")}),(0,B.jsx)(X.Input,{value:j.tags,onChange:a=>k({...j,tags:a.target.value}),placeholder:e("optionsTagsPlaceholder")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagsDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagsMatchLabel")}),(0,B.jsxs)(bb.Select,{value:j.tagsMatch||"default",onValueChange:a=>k({...j,tagsMatch:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{placeholder:e("optionsTagsMatchDefaultPlaceholder")})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:e("optionsTagsMatchDefault")}),(0,B.jsx)(bb.SelectItem,{value:"any",children:e("optionsTagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:e("optionsTagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:e("optionsTagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:e("optionsTagsMatchAllStrict")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagsMatchDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagGroupsLabel")}),(0,B.jsx)(J2.Textarea,{value:j.tagGroups,onChange:a=>k({...j,tagGroups:a.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagGroupsDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionRecall")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallDescription")}),(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsFactTypesLabel")}),(0,B.jsx)(JY,{value:j.factTypes,onChange:a=>k({...j,factTypes:a})}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsFactTypesEmpty")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsIncludeChunksLabel")}),(0,B.jsxs)(bb.Select,{value:j.includeChunks||"default",onValueChange:a=>k({...j,includeChunks:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:e("optionsIncludeChunksDefault")}),(0,B.jsx)(bb.SelectItem,{value:"true",children:e("optionsIncludeChunksYes")}),(0,B.jsx)(bb.SelectItem,{value:"false",children:e("optionsIncludeChunksNo")})]})]})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRecallMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:j.recallMaxTokens,onChange:a=>k({...j,recallMaxTokens:a.target.value}),placeholder:e("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallMaxTokensDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRecallChunksMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:j.recallChunksMaxTokens,onChange:a=>k({...j,recallChunksMaxTokens:a.target.value}),placeholder:e("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:c,disabled:g,children:e("cancelButton")}),(0,B.jsx)(W.Button,{onClick:l,disabled:g||!j.name.trim()||!j.sourceQuery.trim(),children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}),e("updatingButton")]}):e("updateButton")})]})]})})}function RQ({mentalModels:a,selectedId:b,onSelect:c,onOpenDetail:d,refreshingIds:e,onEdit:f,onRefresh:g,onClear:h,onDelete:i}){let j=(0,E.useTranslations)("mentalModels"),k=b&&a.some(a=>a.id===b)?b:a[0]?.id??null,l=a.find(a=>a.id===k)??null;return(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[320px_1fr] gap-0 overflow-hidden min-h-[600px]",children:[(0,B.jsx)("aside",{className:"border-r border-border bg-muted/30 overflow-y-auto max-h-[calc(100vh-260px)]",children:(0,B.jsx)("ul",{className:"py-1",children:a.map(a=>{let b=a.id===k;return(0,B.jsx)("li",{children:(0,B.jsxs)("button",{onClick:()=>c(a.id),className:`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors border-l-2 ${b?"bg-primary/10 border-primary text-foreground":"border-transparent text-muted-foreground hover:bg-muted hover:text-foreground"}`,title:`${a.name}
|
|
9
|
-
${a.source_query}`,children:[(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),(0,B.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:`truncate text-sm font-medium ${b?"text-foreground":""}`,children:a.name}),(0,B.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",title:PQ(a.last_refreshed_at),children:PP(a.last_refreshed_at)})]}),a.source_query&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground/80 truncate italic mt-0.5",children:a.source_query})]})]})},a.id)})})}),(0,B.jsx)("section",{className:"overflow-y-auto max-h-[calc(100vh-260px)]",children:l?(0,B.jsxs)("article",{className:"p-6",children:[(0,B.jsx)("header",{className:"mb-4 pb-4 border-b border-border",children:(0,B.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,B.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,B.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:l.name}),l.source_query&&(0,B.jsxs)("p",{className:"text-sm text-muted-foreground mt-1 italic",children:["“",l.source_query,"”"]}),(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,B.jsxs)("span",{title:PQ(l.last_refreshed_at),children:["Refreshed ",PP(l.last_refreshed_at)]}),l.tags.length>0&&(0,B.jsx)("div",{className:"flex gap-1",children:l.tags.map(a=>(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a))})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>d(l),children:"Open"}),(0,B.jsx)(RN,{m:l,refreshing:e.has(l.id),onEdit:f,onRefresh:g,onClear:h,onDelete:i})]})]})}),l.content?(0,B.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:(0,B.jsx)(PJ,{children:l.content})}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("emptyContent")})]}):(0,B.jsxs)("div",{className:"p-10 text-center text-muted-foreground",children:[(0,B.jsx)(N.FileText,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,B.jsx)("p",{className:"text-sm",children:j("selectModelPrompt")})]})})]})}let RR=(0,K.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var bh=bh;let RS=["consolidation.completed","retain.completed","memory_defense.triggered"],RT={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function RU(a){return Object.fromEntries(a.filter(a=>a.key.trim()).map(a=>[a.key,a.value]))}function RV(a){return{method:a.method,timeout_seconds:a.timeout_seconds,headers:RU(a.headers),params:RU(a.params)}}function RW({label:a,pairs:b,onChange:c}){let d=(0,E.useTranslations)("webhooksView"),e=(a,d,e)=>{c(b.map((b,c)=>c===a?{...b,[d]:e}:b))};return(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)(aA,{children:a}),(0,B.jsxs)(W.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>c([...b,{key:"",value:""}]),children:[(0,B.jsx)(I$.Plus,{className:"w-3 h-3 mr-1"}),d("kvAdd")]})]}),b.length>0&&(0,B.jsx)("div",{className:"space-y-1.5",children:b.map((a,f)=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(X.Input,{placeholder:d("kvKeyPlaceholder"),value:a.key,onChange:a=>e(f,"key",a.target.value),className:"h-8 text-sm flex-1"}),(0,B.jsx)(X.Input,{placeholder:d("kvValuePlaceholder"),value:a.value,onChange:a=>e(f,"value",a.target.value),className:"h-8 text-sm flex-1"}),(0,B.jsx)("button",{type:"button",onClick:()=>c(b.filter((a,b)=>b!==f)),className:"text-muted-foreground hover:text-foreground shrink-0","aria-label":d("kvRemovePair"),children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]},f))})]})}function RX({status:a}){let b=(0,E.useTranslations)("webhooksView");return"completed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),b("deliveryStatusDelivered")]}):"pending"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),b("deliveryStatusPending")]}):"failed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,B.jsx)(Ql,{className:"w-3 h-3"}),b("deliveryStatusFailed")]}):(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:a})}function RY({delivery:a,formatDate:b}){let c=(0,E.useTranslations)("webhooksView"),[d,e]=(0,C.useState)(!1),f=a.last_response_body||a.last_error;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(am,{className:f?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>f&&e(a=>!a),children:[(0,B.jsx)(ao,{className:"w-8 pl-3 pr-0",children:f?d?(0,B.jsx)(JC.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,B.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,B.jsx)(ao,{children:(0,B.jsx)(RX,{status:a.status})}),(0,B.jsx)(ao,{children:null!=a.last_response_status?(0,B.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${a.last_response_status>=200&&a.last_response_status<300?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:a.last_response_status}):(0,B.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,B.jsx)(ao,{className:"text-center text-sm",children:a.attempts}),(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.event_type}),(0,B.jsx)(ao,{className:"text-xs text-muted-foreground whitespace-nowrap",children:b(a.created_at)})]}),d&&f&&(0,B.jsx)(am,{className:"bg-muted/20 hover:bg-muted/20",children:(0,B.jsx)(ao,{colSpan:6,className:"px-4 py-3",children:(0,B.jsxs)("div",{className:"space-y-3",children:[a.last_error&&(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c("expandedError")}),(0,B.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:a.last_error})]}),a.last_response_body&&(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:[c("expandedResponseBody"),a.last_attempt_at&&(0,B.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",b(a.last_attempt_at)]})]}),(0,B.jsx)("pre",{className:"font-mono text-xs bg-background rounded p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto border border-border",children:a.last_response_body})]})]})})})]})}function RZ(){let a=(0,E.useTranslations)("webhooksView"),{currentBank:b}=(0,H.useBank)(),[c,d]=(0,C.useState)([]),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)(!1),[i,j]=(0,C.useState)(!1),[k,l]=(0,C.useState)(null),[n,o]=(0,C.useState)(null),[p,q]=(0,C.useState)(!1),[r,s]=(0,C.useState)(RT),[t,u]=(0,C.useState)(!1),[v,w]=(0,C.useState)(null),[x,y]=(0,C.useState)(RT),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(null),[N,O]=(0,C.useState)([]),[P,Q]=(0,C.useState)(!1),[R,S]=(0,C.useState)(null),[T,U]=(0,C.useState)(!1),Y=async()=>{if(b){f(!0);try{let a=await V.client.listWebhooks(b);d(a.items||[])}catch(a){console.error("Error loading webhooks:",a)}finally{f(!1)}}};(0,C.useEffect)(()=>{b&&Y()},[b]);let Z=async()=>{if(b&&r.url){j(!0);try{await V.client.createWebhook(b,{url:r.url,secret:r.secret||void 0,event_types:r.event_types.length>0?r.event_types:void 0,enabled:r.enabled,http_config:RV(r.http_config)}),h(!1),s(RT),q(!1),await Y()}catch(a){}finally{j(!1)}}},$=async a=>{if(b){l(a),o(null);try{await V.client.deleteWebhook(b,a),await Y()}catch(a){}finally{l(null)}}},_=async()=>{if(b&&v&&x.url){I(!0);try{let a={url:x.url,event_types:x.event_types,enabled:x.enabled,http_config:RV(x.http_config)};D?a.secret=null:x.secret&&(a.secret=x.secret),await V.client.updateWebhook(b,v.id,a),u(!1),await Y()}catch{}finally{I(!1)}}},aa=async a=>{if(b){M(a),K(!0),O([]),S(null),Q(!0);try{let c=await V.client.listWebhookDeliveries(b,a.id,50);O(c.items||[]),S(c.next_cursor??null)}catch(a){console.error("Error loading deliveries:",a)}finally{Q(!1)}}},ab=async()=>{if(b&&L&&R){U(!0);try{let a=await V.client.listWebhookDeliveries(b,L.id,50,R);O(b=>[...b,...a.items||[]]),S(a.next_cursor??null)}catch(a){console.error("Error loading more deliveries:",a)}finally{U(!1)}}},af=b=>b?new Date(b).toLocaleString():a("formatDateNA");return b?(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-lg font-semibold",children:a("title")}),(0,B.jsx)("button",{onClick:()=>Y(),className:"p-1 rounded hover:bg-muted transition-colors",title:a("refreshTitle"),"aria-label":a("refreshAriaLabel"),disabled:e,children:(0,B.jsx)(ad,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${e?"animate-spin":""}`})})]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:a("webhookCount",{count:c.length})})]}),(0,B.jsxs)(W.Button,{size:"sm",onClick:()=>h(!0),children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-2"}),a("addWebhook")]})]}),c.length>0?(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{children:a("tableHeaderUrl")}),(0,B.jsx)(an,{children:a("tableHeaderMethod")}),(0,B.jsx)(an,{children:a("tableHeaderEventTypes")}),(0,B.jsx)(an,{children:a("tableHeaderStatus")}),(0,B.jsx)(an,{children:a("tableHeaderCreatedAt")}),(0,B.jsx)(an,{className:"w-[120px]"})]})}),(0,B.jsx)(al,{children:c.map(b=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,B.jsx)("span",{title:b.url,children:b.url})}),(0,B.jsx)(ao,{children:(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-mono font-medium bg-muted text-muted-foreground border border-border",children:b.http_config?.method||"POST"})}),(0,B.jsx)(ao,{children:(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:b.event_types.length>0?b.event_types.map(a=>(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:a},a)):(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:a("allEvents")})})}),(0,B.jsx)(ao,{children:b.enabled?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),a("statusEnabled")]}):(0,B.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:a("statusDisabled")})}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",children:af(b.created_at)}),(0,B.jsx)(ao,{children:(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>aa(b),title:a("viewDeliveriesTitle"),children:[(0,B.jsx)(ac,{className:"w-3 h-3 mr-1"}),a("deliveriesButton")]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let a;return w(b),void(y((a=b.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:b.url,secret:"",event_types:b.event_types,enabled:b.enabled,http_config:{method:a.method,timeout_seconds:a.timeout_seconds,headers:Object.entries(a.headers??{}).map(([a,b])=>({key:a,value:b})),params:Object.entries(a.params??{}).map(([a,b])=>({key:a,value:b}))}})),A(!1),F(!1),u(!0))},title:a("editWebhookTitle"),"aria-label":a("editWebhookAriaLabel"),children:(0,B.jsx)(bl,{className:"w-3 h-3"})}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>o(b),disabled:k===b.id,title:a("deleteWebhookTitle"),"aria-label":a("deleteWebhookAriaLabel"),children:k===b.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(JA,{className:"w-3 h-3"})})]})})]},b.id))})]})}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:a("emptyStateCanManage")}),(0,B.jsx)(bm.Dialog,{open:g,onOpenChange:a=>{a||(s(RT),q(!1)),h(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("createDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("createDialogDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-2",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formTypeLabel")}),(0,B.jsx)("div",{className:"flex items-center h-9 px-3 rounded-md border border-border bg-muted text-sm text-muted-foreground",children:"HTTP"})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"webhook-url",children:[a("formUrlLabel")," ",(0,B.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,B.jsx)(X.Input,{id:"webhook-url",type:"url",placeholder:a("formUrlPlaceholder"),value:r.url,onChange:a=>s(b=>({...b,url:a.target.value}))})]}),(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formMethodLabel")}),(0,B.jsxs)(bb.Select,{value:r.http_config.method,onValueChange:a=>s(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"POST",children:"POST"}),(0,B.jsx)(bb.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"webhook-timeout",children:a("formTimeoutLabel")}),(0,B.jsx)(X.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:r.http_config.timeout_seconds,onChange:a=>s(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"webhook-secret",children:[a("formSecretLabel")," ",(0,B.jsx)("span",{className:"text-muted-foreground text-xs",children:a("formSecretOptional")})]}),(0,B.jsxs)("div",{className:"relative",children:[(0,B.jsx)(X.Input,{id:"webhook-secret",type:p?"text":"password",placeholder:a("formSecretPlaceholderOptional"),value:r.secret,onChange:a=>s(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,B.jsx)("button",{type:"button",onClick:()=>q(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":p?a("formHideSecret"):a("formShowSecret"),children:p?(0,B.jsx)(RR,{className:"w-4 h-4"}):(0,B.jsx)(ac,{className:"w-4 h-4"})})]})]}),(0,B.jsx)(RW,{label:a("formCustomHeaders"),pairs:r.http_config.headers,onChange:a=>s(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,B.jsx)(RW,{label:a("formQueryParams"),pairs:r.http_config.params,onChange:a=>s(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)(aA,{children:a("formEventTypes")}),(0,B.jsx)("div",{className:"space-y-2",children:RS.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(I4.Checkbox,{id:`event-${a}`,checked:r.event_types.includes(a),onCheckedChange:()=>{s(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}}),(0,B.jsx)(aA,{htmlFor:`event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsx)(ba.Switch,{id:"webhook-enabled",checked:r.enabled,onCheckedChange:a=>s(b=>({...b,enabled:a}))}),(0,B.jsx)(aA,{htmlFor:"webhook-enabled",children:a("formEnabled")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>h(!1),disabled:i,children:a("cancel")}),(0,B.jsx)(W.Button,{onClick:Z,disabled:i||!r.url,children:i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("creating")]}):a("createWebhook")})]})]})}),(0,B.jsx)(bm.Dialog,{open:t,onOpenChange:a=>{a||(w(null),y(RT),A(!1),F(!1)),u(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("editDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("editDialogDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-2",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formTypeLabel")}),(0,B.jsx)("div",{className:"flex items-center h-9 px-3 rounded-md border border-border bg-muted text-sm text-muted-foreground",children:"HTTP"})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"edit-webhook-url",children:[a("formUrlLabel")," ",(0,B.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,B.jsx)(X.Input,{id:"edit-webhook-url",type:"url",placeholder:a("formUrlPlaceholder"),value:x.url,onChange:a=>y(b=>({...b,url:a.target.value}))})]}),(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formMethodLabel")}),(0,B.jsxs)(bb.Select,{value:x.http_config.method,onValueChange:a=>y(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"POST",children:"POST"}),(0,B.jsx)(bb.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"edit-webhook-timeout",children:a("formTimeoutLabel")}),(0,B.jsx)(X.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:x.http_config.timeout_seconds,onChange:a=>y(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"edit-webhook-secret",children:a("formSecretLabel")}),(0,B.jsxs)("div",{className:"relative",children:[(0,B.jsx)(X.Input,{id:"edit-webhook-secret",type:z?"text":"password",placeholder:a("formSecretPlaceholderEdit"),value:x.secret,disabled:D,onChange:a=>y(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,B.jsx)("button",{type:"button",onClick:()=>A(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":z?a("formHideSecret"):a("formShowSecret"),children:z?(0,B.jsx)(RR,{className:"w-4 h-4"}):(0,B.jsx)(ac,{className:"w-4 h-4"})})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,B.jsx)(I4.Checkbox,{id:"edit-clear-secret",checked:D,onCheckedChange:a=>{F(!!a),a&&y(a=>({...a,secret:""}))}}),(0,B.jsx)(aA,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:a("formClearSecret")})]})]}),(0,B.jsx)(RW,{label:a("formCustomHeaders"),pairs:x.http_config.headers,onChange:a=>y(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,B.jsx)(RW,{label:a("formQueryParams"),pairs:x.http_config.params,onChange:a=>y(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)(aA,{children:a("formEventTypes")}),(0,B.jsx)("div",{className:"space-y-2",children:RS.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(I4.Checkbox,{id:`edit-event-${a}`,checked:x.event_types.includes(a),onCheckedChange:()=>y(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}),(0,B.jsx)(aA,{htmlFor:`edit-event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsx)(ba.Switch,{id:"edit-webhook-enabled",checked:x.enabled,onCheckedChange:a=>y(b=>({...b,enabled:a}))}),(0,B.jsx)(aA,{htmlFor:"edit-webhook-enabled",children:a("formEnabled")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>u(!1),disabled:G,children:a("cancel")}),(0,B.jsx)(W.Button,{onClick:_,disabled:G||!x.url,children:G?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("saving")]}):a("saveChanges")})]})]})}),(0,B.jsx)(bm.Dialog,{open:!!n,onOpenChange:a=>{a||o(null)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-md",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("deleteDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("deleteDialogDescription")})]}),n&&(0,B.jsx)("div",{className:"py-2",children:(0,B.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:n.url})}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>o(null),children:a("cancel")}),(0,B.jsx)(W.Button,{variant:"destructive",onClick:()=>n&&$(n.id),disabled:!!k,children:k?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("deleting")]}):a("deleteWebhookConfirm")})]})]})}),(0,B.jsx)(bm.Dialog,{open:J,onOpenChange:a=>{a||(O([]),S(null)),K(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("deliveriesDialogTitle")}),L&&(0,B.jsx)(bm.DialogDescription,{className:"font-mono text-xs truncate",children:L.url})]}),P?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)(bh.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):N.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-8 pl-3 pr-0"}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderStatus")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderHttp")}),(0,B.jsx)(an,{className:"text-center",children:a("deliveriesTableHeaderAttempts")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderEvent")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderCreatedAt")})]})}),(0,B.jsx)(al,{children:N.map(a=>(0,B.jsx)(RY,{delivery:a,formatDate:af},a.id))})]})}),R&&(0,B.jsx)("div",{className:"flex justify-center pt-2",children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:ab,disabled:T,children:[T&&(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("loadMore")]})})]}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:a("noDeliveries")})]})})]}):null}function R$(a){return[{value:"all",label:a("actionAll")},{value:"retain",label:a("actionRetain")},{value:"recall",label:a("actionRecall")},{value:"reflect",label:a("actionReflect")},{value:"create_bank",label:a("actionCreateBank")},{value:"update_bank",label:a("actionUpdateBank")},{value:"delete_bank",label:a("actionDeleteBank")},{value:"clear_memories",label:a("actionClearMemories")},{value:"consolidation",label:a("actionConsolidation")},{value:"batch_retain",label:a("actionBatchRetain")},{value:"create_mental_model",label:a("actionCreateMentalModel")},{value:"refresh_mental_model",label:a("actionRefreshMentalModel")},{value:"delete_mental_model",label:a("actionDeleteMentalModel")},{value:"create_directive",label:a("actionCreateDirective")},{value:"delete_directive",label:a("actionDeleteDirective")},{value:"file_convert_retain",label:a("actionFileConvertRetain")},{value:"webhook_delivery",label:a("actionWebhookDelivery")},{value:"memory_defense",label:a("actionMemoryDefense")}]}function R_(a,b){if(!a||!b)return"—";let c=new Date(a).getTime(),d=new Date(b).getTime()-c;return d<1e3?`${d}ms`:d<6e4?`${(d/1e3).toFixed(1)}s`:`${(d/6e4).toFixed(1)}m`}function R0(a){return a?new Date(a).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function R1({transport:a}){let b={http:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",mcp:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300",system:"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300"};return(0,B.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${b[a]||b.system}`,children:a})}function R2({bankId:a}){let b=(0,E.useTranslations)("auditLogsView"),c=R$(b),d=[{value:"1d",label:b("periodToday")},{value:"7d",label:b("periodLast7Days")},{value:"30d",label:b("periodLast30Days")}],[e,f]=(0,C.useState)("7d"),[g,h]=(0,C.useState)(null),[i,j]=(0,C.useState)([]),[k,l]=(0,C.useState)("day"),[n,o]=(0,C.useState)(!1),p=(0,C.useCallback)(async(b=e,c=g)=>{o(!0);try{let d=await V.client.getAuditLogStats(a,{period:b,action:c||void 0});j(d.buckets||[]),l(d.trunc||"day")}catch(a){console.error("Error loading audit stats:",a)}finally{o(!1)}},[a,e,g]);(0,C.useEffect)(()=>{p()},[a]);let q=i.map(a=>{var b;let c;return{time:(b=a.time,c=new Date(b),"hour"===k?c.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):c.toLocaleDateString(void 0,{month:"short",day:"numeric"})),total:a.total}});return(0,B.jsxs)(by.Card,{children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0 gap-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:b("requestVolume")}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsxs)(bb.Select,{value:g||"all",onValueChange:a=>{let b="all"===a?null:a;h(b),p(e,b)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px] h-8 text-xs",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),d.map(a=>(0,B.jsx)(W.Button,{variant:e===a.value?"default":"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{f(a.value),p(a.value,g)},children:a.label},a.value))]})]}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"h-[120px]",children:n?(0,B.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:b("chartLoading")}):0===q.length?(0,B.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:b("chartNoData")}):(0,B.jsx)(gb,{width:"100%",height:"100%",children:(0,B.jsxs)(qP,{data:q,margin:{top:5,right:5,bottom:0,left:5},children:[(0,B.jsx)(vl,{dataKey:"time",tick:{fontSize:10},axisLine:!1,tickLine:!1,className:"text-muted-foreground"}),(0,B.jsx)(v0,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:"6px",fontSize:"12px",padding:"4px 8px"}}),(0,B.jsx)(ul,{type:"monotone",dataKey:"total",stroke:"var(--primary)",strokeWidth:2,dot:!1,activeDot:{r:3}})]})})})})]})}function R3(){let a=(0,E.useTranslations)("auditLogsView"),b=R$(a),c=[{value:"all",label:a("transportAll")},{value:"http",label:a("transportHttp")},{value:"mcp",label:a("transportMcp")},{value:"system",label:a("transportSystem")}],{currentBank:d}=(0,H.useBank)(),[e,f]=(0,C.useState)([]),[g,h]=(0,C.useState)(0),[i,j]=(0,C.useState)(null),[k,l]=(0,C.useState)(null),[n,o]=(0,C.useState)("all"),[p]=(0,C.useState)(20),[q,r]=(0,C.useState)(0),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(null),[w,x]=(0,C.useState)(!1),y=(0,C.useCallback)(a=>{if("all"===a)return{};let b=new Date,c=new Date;return"1h"===a?c.setHours(b.getHours()-1):"1d"===a?c.setDate(b.getDate()-1):"7d"===a?c.setDate(b.getDate()-7):"30d"===a&&c.setDate(b.getDate()-30),{start_date:c.toISOString()}},[]),z=(0,C.useCallback)(async(a=i,b=k,c=n,e=q)=>{if(d){t(!0);try{let g=y(c),i=await V.client.listAuditLogs(d,{action:a||void 0,transport:b||void 0,start_date:g.start_date,end_date:g.end_date,limit:p,offset:e});f(i.items||[]),h(i.total||0)}catch(a){console.error("Error loading audit logs:",a)}finally{t(!1)}}},[d,i,k,n,q,p,y]),A=a=>{r(a),z(i,k,n,a)};(0,C.useEffect)(()=>{d&&z(i,k,n,q)},[d]);let D=Math.ceil(g/p),F=Math.floor(q/p)+1;return d?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(R2,{bankId:d}),(0,B.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,B.jsxs)(bb.Select,{value:i||"all",onValueChange:a=>{let b="all"===a?null:a;j(b),r(0),z(b,k,n,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[180px]",children:(0,B.jsx)(bb.SelectValue,{placeholder:a("actionAll")})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:b.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,B.jsxs)(bb.Select,{value:k||"all",onValueChange:a=>{let b="all"===a?null:a;l(b),r(0),z(i,b,n,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px]",children:(0,B.jsx)(bb.SelectValue,{placeholder:a("transportAll")})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,B.jsxs)(bb.Select,{value:n,onValueChange:a=>{o(a),r(0),z(i,k,a,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[150px]",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{position:"popper",children:[(0,B.jsx)(bb.SelectItem,{value:"all",children:a("dateRangeAll")}),(0,B.jsx)(bb.SelectItem,{value:"1h",children:a("dateRangeLastHour")}),(0,B.jsx)(bb.SelectItem,{value:"1d",children:a("dateRangeLast24Hours")}),(0,B.jsx)(bb.SelectItem,{value:"7d",children:a("dateRangeLast7Days")}),(0,B.jsx)(bb.SelectItem,{value:"30d",children:a("dateRangeLast30Days")})]})]}),(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(i,k,n,q),disabled:s,children:[(0,B.jsx)(ad,{className:`w-4 h-4 mr-1 ${s?"animate-spin":""}`}),a("refresh")]}),(0,B.jsx)("span",{className:"text-sm text-muted-foreground ml-auto",children:a("entryCount",{count:g})})]}),(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[200px]",children:a("tableHeaderTime")}),(0,B.jsx)(an,{children:a("tableHeaderAction")}),(0,B.jsx)(an,{className:"w-[100px]",children:a("tableHeaderTransport")}),(0,B.jsx)(an,{className:"w-[100px]",children:a("tableHeaderDuration")})]})}),(0,B.jsx)(al,{children:0===e.length?(0,B.jsx)(am,{children:(0,B.jsx)(ao,{colSpan:4,className:"text-center text-muted-foreground py-8",children:a(s?"tableLoading":"tableNoLogs")})}):e.map(a=>(0,B.jsxs)(am,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>{v(a),x(!0)},children:[(0,B.jsx)(ao,{className:"text-sm font-mono",children:R0(a.started_at)}),(0,B.jsx)(ao,{className:"font-medium",children:a.action}),(0,B.jsx)(ao,{children:(0,B.jsx)(R1,{transport:a.transport})}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground font-mono",children:R_(a.started_at,a.ended_at)})]},a.id))})]}),D>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:a("paginationPage",{current:F,total:D})}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(Math.max(0,q-p)),disabled:0===q,children:[(0,B.jsx)(P,{className:"w-4 h-4 mr-1"}),a("previous")]}),(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(q+p),disabled:q+p>=g,children:[a("next"),(0,B.jsx)(Q.ChevronRight,{className:"w-4 h-4 ml-1"})]})]})]}),(0,B.jsx)(bm.Dialog,{open:w,onOpenChange:x,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsx)(bm.DialogHeader,{children:(0,B.jsx)(bm.DialogTitle,{children:a("detailDialogTitle",{action:u?.action??""})})}),u&&(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailAction")})," ",(0,B.jsx)("span",{className:"font-medium",children:u.action})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailTransport")})," ",(0,B.jsx)(R1,{transport:u.transport})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailStarted")})," ",(0,B.jsx)("span",{className:"font-mono",children:R0(u.started_at)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailDuration")})," ",(0,B.jsx)("span",{className:"font-mono",children:R_(u.started_at,u.ended_at)})]})]}),u.request&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailRequest")}),(0,B.jsx)(bz,{value:u.request,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),u.response&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailResponse")}),(0,B.jsx)(bz,{value:u.response,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),u.metadata&&Object.keys(u.metadata).length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailMetadata")}),(0,B.jsx)(bz,{value:u.metadata})]})]})]})})]}):null}let R4=(0,K.default)("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function R5({title:a,description:b,icon:c=R4}){return(0,B.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,B.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,B.jsx)(c,{width:48,height:48,strokeWidth:1.5})}),(0,B.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:a}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground max-w-md",children:b})]})}var bh=bh,bh=bh;function R6({tone:a}){return(0,B.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${"ok"===a?"bg-emerald-500":"bad"===a?"bg-red-500":"bg-muted-foreground/40"}`})}function R7({bankId:a,open:b,onOpenChange:c}){let d=(0,E.useTranslations)("bankStats"),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)(null),i=async()=>{f(!0);try{h(await V.client.testBankLlm(a))}catch{}finally{f(!1)}};(0,C.useEffect)(()=>{b?i():h(null)},[b,a]);let j={connected:d("llmConnected"),not_configured:d("llmNotConfigured"),auth_failed:d("llmAuthFailed"),unreachable:d("llmUnreachable"),timeout:d("llmTimeout")},k={retain:d("opRetain"),consolidation:d("consolidation"),reflect:d("opReflect")};return(0,B.jsx)(bm.Dialog,{open:b,onOpenChange:c,children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-md",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("llmHealthTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("llmTestHint")})]}),(0,B.jsx)("div",{className:"py-2 space-y-2",children:e&&!g?(0,B.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin"}),d("testingLlm")]}):g?.operations.map(a=>{let b;return(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 text-sm py-1.5 border-b border-border/50 last:border-0",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:k[a.operation]??a.operation}),(0,B.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,B.jsx)(R6,{tone:"connected"===(b=a.status)?"ok":"not_configured"===b?"muted":"bad"}),(0,B.jsx)("span",{className:a.ok?"text-foreground font-medium":"text-muted-foreground",children:j[a.status]??a.status}),a.ok&&null!=a.latency_ms&&(0,B.jsxs)("span",{className:"text-muted-foreground/60 tabular-nums text-xs",children:[Math.round(a.latency_ms),"ms"]})]})]},a.operation)})}),(0,B.jsx)(bm.DialogFooter,{children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:i,disabled:e,className:"gap-1.5",children:[e?(0,B.jsx)(bh.default,{className:"w-3.5 h-3.5 animate-spin"}):(0,B.jsx)(ad,{className:"w-3.5 h-3.5"}),d(e?"testingLlm":"llmRetest")]})})]})})}a.s(["default",0,function(){(0,D.useParams)();let a=(0,D.useRouter)(),b=(0,D.useSearchParams)(),c=(0,E.useTranslations)("bank"),d=(0,E.useTranslations)("common"),{features:e}=(0,I3.useFeatures)(),{currentBank:f,setCurrentBank:g,loadBanks:h}=(0,H.useBank)(),i=b.get("view")||"profile",j=b.get("subTab")||"world",k=b.get("bankConfigTab")||"general",l=e?.observations??!1,n=e?.bank_config_api??!1,o=e?.audit_log??!1,p=e?.llm_trace??!1,q=e?.bank_llm_health??!1,[r,s]=(0,C.useState)(!1),[t,u]=(0,C.useState)(!1),[v,w]=(0,C.useState)(!1),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(!1),[N,O]=(0,C.useState)(!1),[P,Q]=(0,C.useState)(!1),R=b=>{f&&a.push((0,I.bankRoute)(f,`?view=data&subTab=${b}`))},S=b=>{f&&a.push((0,I.bankRoute)(f,`?view=profile&bankConfigTab=${b}`))},T=async()=>{if(f){w(!0);try{await V.client.deleteBank(f),u(!1),g(null),await h(),a.push("/")}catch(a){}finally{w(!1)}}},X=async()=>{if(f){A(!0);try{let a=await V.client.clearObservations(f);y(!1),F.toast.success(c("observationsCleared"),{description:a.message||c("observationsClearedDefault")})}catch(a){}finally{A(!1)}}},Y=async()=>{if(f){Q(!0);try{await V.client.resetBankConfig(f),O(!1)}catch{}finally{Q(!1)}}},Z=async()=>{if(f){K(!0);try{await V.client.triggerConsolidation(f)}catch(a){}finally{K(!1)}}},$=async()=>{if(f){M(!0);try{let a=await V.client.recoverConsolidation(f);F.toast.success(c("recoveredMemories",{count:a.retried_count}))}catch(a){}finally{M(!1)}}};return(0,B.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,B.jsx)(G.BankSelector,{}),(0,B.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,B.jsx)(U,{currentTab:i,onTabChange:b=>{f&&a.push((0,I.bankRoute)(f,`?view=${b}`))}}),(0,B.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:["profile"===i&&(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("bankConfiguration")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:c("bankConfigurationDescription")})]}),(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",children:[c("actions"),(0,B.jsx)(JB,{className:"w-4 h-4 ml-2"})]})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,B.jsxs)(I5.DropdownMenuItem,{onClick:async()=>{if(f)try{let a=await V.client.exportBankTemplate(f),b=JSON.stringify(a,null,2);await navigator.clipboard.writeText(b),F.toast.success(c("templateCopied"))}catch{F.toast.error(c("failedToExportTemplate"))}},children:[(0,B.jsx)(JD,{className:"w-4 h-4 mr-2"}),c("exportTemplate")]}),q&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>s(!0),children:[(0,B.jsx)(bj,{className:"w-4 h-4 mr-2"}),c("health")]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:Z,disabled:J||!l,title:l?void 0:"Observations feature is not enabled",children:[J?(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,B.jsx)(J$,{className:"w-4 h-4 mr-2"}),J?c("consolidating"):c("runConsolidation"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:$,disabled:L||!l,title:l?void 0:"Observations feature is not enabled",children:[L?(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),L?c("recovering"):c("recoverConsolidation"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>y(!0),disabled:!l,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:l?void 0:"Observations feature is not enabled",children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("clearObservations"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>O(!0),disabled:!n,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:n?void 0:"Bank Config API is disabled",children:[(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),c("resetConfiguration"),!n&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>u(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("deleteBank")]})]})]})]}),(0,B.jsx)("div",{className:"mb-6 border-b border-border",children:(0,B.jsxs)("div",{className:"flex gap-1",children:[(0,B.jsxs)("button",{onClick:()=>S("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("general"),"general"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),n&&(0,B.jsxs)("button",{onClick:()=>S("memory-defense"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"memory-defense"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("memoryDefense"),"memory-defense"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),n&&(0,B.jsxs)("button",{onClick:()=>S("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("configuration"),"configuration"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>S("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("webhooks"),"webhooks"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>S("audit-logs"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"audit-logs"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("auditLogs"),!o&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"audit-logs"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>S("llm-requests"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"llm-requests"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("llmRequests"),!p&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"llm-requests"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,B.jsxs)("div",{children:["general"===k&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("overviewAndOperations")}),(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(RF,{}),(0,B.jsx)(RK,{}),(0,B.jsx)(Qd,{hideReflectFields:!0})]})]}),"memory-defense"===k&&n&&f&&(0,B.jsx)("div",{className:"space-y-6",children:(0,B.jsx)(QP,{bankId:f})}),"configuration"===k&&n&&(0,B.jsx)("div",{className:"space-y-6",children:(0,B.jsx)(Qv,{})}),"webhooks"===k&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("webhooksDescription")}),(0,B.jsx)(RZ,{})]}),"audit-logs"===k&&(o?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("auditLogsDescription")}),(0,B.jsx)(R3,{})]}):(0,B.jsx)(R5,{title:c("auditLogsNotEnabled"),description:c.rich("auditLogsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_AUDIT_LOG_ENABLED=true"})})})),"llm-requests"===k&&(p?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("llmRequestsDescription")}),(0,B.jsx)(ws,{})]}):(0,B.jsx)(R5,{title:c("llmRequestsNotEnabled"),description:c.rich("llmRequestsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_LLM_TRACE_ENABLED=true"})})}))]})]}),"recall"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("recallAnalyzer")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("recallAnalyzerDescription")}),(0,B.jsx)(P8,{})]}),"reflect"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("reflect")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("reflectDescription")}),(0,B.jsx)(P6,{})]}),"data"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("memories")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("memoriesDescription")}),(0,B.jsx)("div",{className:"mb-6 border-b border-border",children:(0,B.jsxs)("div",{className:"flex gap-1",children:[(0,B.jsxs)("button",{onClick:()=>R("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("worldFacts"),"world"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>R("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("experience"),"experience"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>R("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("observations"),!l&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>R("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("mentalModels"),"mental-models"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,B.jsxs)("div",{children:["world"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("worldFactsDescription")}),(0,B.jsx)(I1,{factType:"world"},"world")]}),"experience"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("experienceDescription")}),(0,B.jsx)(I1,{factType:"experience"},"experience")]}),"observations"===j&&(l?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("observationsDescription")}),(0,B.jsx)(I1,{factType:"observation"},"observations")]}):(0,B.jsx)(R5,{title:c("observationsNotEnabled"),description:c.rich("observationsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})})})),"mental-models"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("mentalModelsDescription")}),(0,B.jsx)(RM,{},"mental-models")]})]})]}),"documents"===i&&(0,B.jsx)("div",{children:(0,B.jsx)(JS,{})}),"entities"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("entities")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("entitiesDescription")}),(0,B.jsx)(JT,{})]})]})})]}),f&&(0,B.jsx)(R7,{bankId:f,open:r,onOpenChange:s}),(0,B.jsx)(Jc,{open:t,onOpenChange:u,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("deleteMemoryBank")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("deleteBankPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:c("deleteBankWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:v,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:T,disabled:v,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:v?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("deleting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("deleteBank")]})})]})]})}),(0,B.jsx)(Jc,{open:N,onOpenChange:O,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("resetConfigTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("resetConfigPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:c("resetConfigWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:P,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:Y,disabled:P,children:P?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("resetting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),c("resetConfiguration")]})})]})]})}),(0,B.jsx)(Jc,{open:x,onOpenChange:y,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("clearObservationsTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("clearObservationsPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:c("clearObservationsWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:z,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:X,disabled:z,className:"bg-amber-500 text-white hover:bg-amber-600",children:z?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("clearing")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("clearObservations")]})})]})]})})]})}],23962)}];
|
|
8
|
+
${U.trim()}`:U.trim();await V.client.updateDirective(n,b.id,{content:a})}else await V.client.createDirective(n,{name:au,content:U.trim()});Y(""),aa(!0),setTimeout(()=>aa(!1),3e3)}catch(a){}finally{$(!1)}}},ax=async()=>{if(n&&o){G(!0),z("answer");try{let a=I.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=S.split(",").map(a=>a.trim()).filter(a=>a.length>0),c=await V.client.reflect({bank_id:n,query:o,budget:q,max_tokens:s,include_facts:u,include_tool_calls:w,...a.length>0&&{tags:a,tags_match:K},...O.length>0&&{fact_types:O},...Q&&{exclude_mental_models:!0},...b.length>0&&{exclude_mental_model_ids:b}});D(c)}catch(a){}finally{G(!1)}}};return n?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"pt-6",children:[(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsxs)("div",{className:"flex-1 relative",children:[(0,B.jsx)(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:l("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&ax()})]}),(0,B.jsx)(W.Button,{onClick:ax,disabled:F||!o,className:"h-12 px-8",children:F?l("reflecting"):l("reflect")})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:l("budgetLabel")}),(0,B.jsxs)(bb.Select,{value:q,onValueChange:a=>r(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-24 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"low",children:l("budgetLow")}),(0,B.jsx)(bb.SelectItem,{value:"mid",children:l("budgetMid")}),(0,B.jsx)(bb.SelectItem,{value:"high",children:l("budgetHigh")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:l("tokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:s,onChange:a=>t(parseInt(a.target.value)||4096),className:"w-24 h-8"})]}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:u,onCheckedChange:a=>v(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("includeSource")})]}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:w,onCheckedChange:a=>x(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("includeTools")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,B.jsx)(bc,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("div",{className:"flex-1 max-w-md",children:(0,B.jsx)(X.Input,{type:"text",value:I,onChange:a=>J(a.target.value),placeholder:l("tagsPlaceholder"),className:"h-8"})}),(0,B.jsxs)(bb.Select,{value:K,onValueChange:a=>N(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-40 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"any",children:l("tagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:l("tagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:l("tagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:l("tagsMatchAllStrict")}),(0,B.jsx)(bb.SelectItem,{value:"exact",children:l("tagsMatchExact")})]})]})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsx)(JX,{value:O,onChange:P}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:Q,onCheckedChange:a=>R(a)}),(0,B.jsx)("span",{className:"text-sm",children:l("excludeMentalModels")})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:l("excludeIdsLabel")}),(0,B.jsx)(X.Input,{type:"text",value:S,onChange:a=>T(a.target.value),placeholder:l("excludeIdsPlaceholder"),className:"h-8 w-48"})]})]})]})}),F&&(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:l("reflectingOnMemories")})]})}),!F&&A&&(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[A.usage&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("inputTokensLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.usage.input_tokens?.toLocaleString()})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("outputTokensLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.usage.output_tokens?.toLocaleString()})]})]}),A.trace?.tool_calls&&(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("toolCallsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.trace.tool_calls.length}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:["(",A.trace.tool_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),A.trace?.llm_calls&&(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:l("llmCallsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:A.trace.llm_calls.length}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:["(",A.trace.llm_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),(0,B.jsx)("div",{className:"flex-1"}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(a=>(0,B.jsx)("button",{onClick:()=>z(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${y===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===a?l("viewAnswer"):"trace"===a?l("viewTrace"):l("viewJson")},a))})]}),"answer"===y&&(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{children:l("answerTitle")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:A.text})})})]}),(0,B.jsxs)(by.Card,{className:"border-blue-200 dark:border-blue-800",children:[(0,B.jsxs)(by.CardHeader,{className:"py-4",children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,B.jsx)(J_,{className:"w-4 h-4"}),l("addDirectiveTitle")]}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("addDirectiveDescription")})]}),(0,B.jsx)(by.CardContent,{className:"pt-0",children:_?(0,B.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,B.jsx)("span",{className:"text-lg",children:"✓"}),(0,B.jsx)("span",{className:"text-sm font-medium",children:l("directiveSaved",{name:au})})]}):(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsx)(J2.Textarea,{value:U,onChange:a=>Y(a.target.value),placeholder:l("directivePlaceholder"),className:"flex-1 min-h-[60px] resize-none",onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&aw()}}),(0,B.jsx)(W.Button,{onClick:aw,disabled:Z||!U.trim(),className:"self-end",children:Z?l("savingDirective"):l("saveDirective")})]})})]})]}),"trace"===y&&(0,B.jsxs)("div",{className:"space-y-4",children:[A.observations_created&&A.observations_created.length>0&&(0,B.jsxs)(by.Card,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,B.jsxs)(by.CardHeader,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,B.jsx)(J$,{className:"w-4 h-4 text-emerald-600"}),l("observationsCreatedTitle",{count:A.observations_created.length})]}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("observationsCreatedDescription")})]}),(0,B.jsx)(by.CardContent,{className:"pt-4",children:(0,B.jsx)("div",{className:"space-y-2",children:A.observations_created.map((a,b)=>(0,B.jsxs)("div",{className:"p-3 bg-emerald-50 dark:bg-emerald-950/50 rounded-lg border border-emerald-200 dark:border-emerald-800",children:[(0,B.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:a.name}),(0,B.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:a.description}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",a.id]})]},b))})})]}),(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,B.jsxs)(by.Card,{className:"h-fit",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-base",children:l("executionTraceTitle")}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("executionTraceDescription",{iterations:A.iterations||0,iterationsPlural:1!==(A.iterations||0)?"s":"",totalMs:(A.trace?.llm_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)+(A.trace?.tool_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)})})]}),(0,B.jsx)(by.CardContent,{children:w?A.trace?.llm_calls&&A.trace.llm_calls.length>0||A.trace?.tool_calls&&A.trace.tool_calls.length>0?(0,B.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(a=A.trace?.llm_calls||[],b=A.trace?.tool_calls||[],c=[],a.forEach((d,e)=>{let f=b.filter(a=>a.iteration===e+1),g=e===a.length-1,h=d.scope.includes("final")||g&&0===f.length,i=h?a.length:e+1;c.push({type:"llm",llm:d,iteration:i,isFinal:h}),f.length>0&&c.push({type:"tools",tools:f,iteration:e+1})}),c.map((a,b)=>(0,B.jsxs)("div",{className:"relative",children:[b<c.length-1&&(0,B.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===a.type?(0,B.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,B.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:a.isFinal?(0,B.jsx)(bf.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,B.jsx)("span",{className:"text-[10px] font-semibold",children:a.iteration})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("span",{className:"font-medium text-sm",children:a.isFinal?l("responseGenerated"):l("agentDecided")}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),a.llm.duration_ms,"ms"]})]}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:a.isFinal?l("finalAnswer"):l("calledToolsBelow")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,B.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-blue-500/15 text-blue-600 dark:text-blue-400 flex-shrink-0",children:(0,B.jsx)(J1,{className:"w-3 h-3",fill:"currentColor"})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,B.jsx)("div",{className:"text-xs text-muted-foreground",children:(a.tools?.length??0)!==1?l("executingToolsPlural",{count:a.tools?.length??0}):l("executingTools",{count:a.tools?.length??0})}),a.tools?.map((a,b)=>(0,B.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.tool}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),a.duration_ms,"ms"]})]}),(0,B.jsxs)("div",{className:"p-2 space-y-2",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:l("toolInputLabel")}),(0,B.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,B.jsx)(KK,{src:a.input,collapsed:1,theme:"default"})})]}),a.output&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:l("toolOutputLabel")}),(0,B.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,B.jsx)(KK,{src:a.output,collapsed:1,theme:"default"})})]})]})]},b))]})]})]},b)))}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("noOperations")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("noOperationsDescription")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("notIncluded")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("enableIncludeTools")})]})]})})]}),(0,B.jsxs)(by.Card,{className:"h-fit",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-base",children:l("basedOnTitle")}),(0,B.jsx)(by.CardDescription,{className:"text-xs",children:l("basedOnDescription",{count:(A.based_on?.memories?.length||0)+(A.based_on?.observations?.filter(a=>"directive"!==a.subtype)?.length||0)+(A.based_on?.directives?.length||0)})})]}),(0,B.jsx)(by.CardContent,{children:u?A.based_on?.memories&&A.based_on.memories.length>0||A.based_on?.mental_models&&A.based_on.mental_models.length>0||A.based_on?.directives&&A.based_on.directives.length>0||A.based_on?.observations&&A.based_on.observations.length>0?(e=(d=A.based_on?.memories||[]).filter(a=>"world"===a.type),f=d.filter(a=>"experience"===a.type),g=A.based_on?.mental_models||[],h=(A.based_on?.observations||[]).filter(a=>"directive"!==a.subtype),i=A.based_on?.directives||[],j=[{id:"directives",label:l("tabDirectives"),count:i.length},{id:"mental_models",label:l("tabMentalModels"),count:g.length},{id:"observations",label:l("tabObservations"),count:h.length},{id:"world",label:l("tabWorld"),count:e.length},{id:"experience",label:l("tabExperience"),count:f.length}],k=(()=>{switch(as){case"directives":return i;case"mental_models":return g;case"observations":return h;case"world":return e;case"experience":return f;default:return[]}})(),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:j.map(a=>(0,B.jsxs)("button",{onClick:()=>at(a.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${as===a.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[a.label," (",a.count,")"]},a.id))}),k.length>0?(0,B.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:k.map((a,b)=>{let c,d;return(0,B.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==as?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==as&&("observations"===as?av(a):"mental_models"===as?ar(a.id):ac(a.id))},children:"directives"===as?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"font-medium text-sm",children:a.name}),a.content&&(0,B.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:a.content})]}):"observations"===as?(0,B.jsx)("div",{className:"font-medium text-sm",children:a.name}):"mental_models"===as?(d=(c=a.text?.indexOf(": ")??-1)>0?a.text.slice(0,c):a.id,(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"font-medium text-sm",children:d}),(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:a.id})]})):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text}),a.context&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:a.context})]})},a.id||b)})}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:l("noTabItems",{tab:as})})]})):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:l("noFactsFound")}),(0,B.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:l("noFactsFoundDescription")})]})]}):(0,B.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,B.jsx)(JZ.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"font-medium text-sm text-foreground",children:l("notIncludedBasedOn")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("enableIncludeSource")})]})]})})]})]})]}),"json"===y&&(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{className:"text-lg",children:l("rawResponseTitle")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,B.jsx)(KK,{src:A,collapsed:2,theme:"default"})})})]})]}),!F&&!A&&(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-lg font-semibold mb-2",children:l("readyToReflect")}),(0,B.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:l("readyToReflectDescription")})]})}),(0,B.jsx)(bx,{memoryId:ab,onClose:()=>ac(null)}),ad&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(J0,{className:"w-5 h-5"}),(0,B.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{ae(null),ah(null)},children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]}),ai?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,B.jsx)("p",{className:"mt-1 font-medium",children:ag?.name||ad.name})]}),ag?.description&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,B.jsx)("p",{className:"mt-1 text-sm",children:ag.description})]}),ag?.tags&&ag.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:ag.tags.map(a=>(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(bc,{className:"w-2.5 h-2.5"}),a]},a))})]}),(ag?.content||ad.content)&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,B.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,B.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:ag?.content||ad.content})})]}),(0,B.jsxs)("div",{className:"pt-2 border-t",children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,B.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ad.id})]})]})]})}),ak&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(J$,{className:"w-5 h-5"}),(0,B.jsx)("h2",{className:"text-lg font-semibold",children:l("observationPanelTitle")})]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{al(null),an(null)},children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]}),ao?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:l("observationTextField")}),(0,B.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:am?.text||ak.text})})]}),am?.tags&&am.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:l("observationTagsField")}),(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:am.tags.map(a=>(0,B.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,B.jsx)(bc,{className:"w-2.5 h-2.5"}),a]},a))})]}),am?.source_memories&&am.source_memories.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:l("observationSourceMemoriesField",{count:am.source_memories.length})}),(0,B.jsx)("div",{className:"space-y-2",children:am.source_memories.map((a,b)=>(0,B.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,B.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:a.text||("string"==typeof a?a:"")})},b))})]}),(0,B.jsxs)("div",{className:"pt-2 border-t",children:[(0,B.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:l("observationIdField")}),(0,B.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ak.id})]})]})]})}),(0,B.jsx)(P0,{mentalModelId:aq,onClose:()=>ar(null)})]}):(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2",children:l("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:l("noBankSelectedDescription")})]})})}let P7=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function P8(){let a,b,c,d,e,f,g,h,i,j,k,l,n,o,p=(0,E.useTranslations)("searchDebug"),{currentBank:q}=(0,H.useBank)(),[r,s]=(0,C.useState)(""),[t,u]=(0,C.useState)(["world"]),[v,w]=(0,C.useState)("mid"),[x,y]=(0,C.useState)(4096),[z,A]=(0,C.useState)(""),[D,G]=(0,C.useState)(!1),[I,K]=(0,C.useState)(!1),[L,P]=(0,C.useState)(""),[R,S]=(0,C.useState)("any"),[T,U]=(0,C.useState)(null),[Z,$]=(0,C.useState)(null),[_,aa]=(0,C.useState)(null),[ab,ac]=(0,C.useState)(null),[ad,ae]=(0,C.useState)(null),[ag,ah]=(0,C.useState)(!1),[ai,aj]=(0,C.useState)("results"),[ak,al]=(0,C.useState)(null),[am,an]=(0,C.useState)(new Set),[ao,ap]=(0,C.useState)(new Set),aq=a=>{an(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},ar=a=>{ap(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},as=a=>{let b=a.id||a.node_id;al(T?.find(a=>a.id===b||a.node_id===b)||a)},at=async()=>{if(!q)return void F.toast.error(p("errorSelectBank"));if(r){if(0===t.length)return void F.toast.error(p("errorSelectFactType"));ah(!0);try{let a=L.split(",").map(a=>a.trim()).filter(a=>a.length>0),b={bank_id:q,query:r,types:t,budget:v,max_tokens:x,trace:!0,include:{entities:I?{max_tokens:500}:null,chunks:D?{max_tokens:8192}:null},...z&&{query_timestamp:z},...a.length>0&&{tags:a,tags_match:R}},c=await V.client.recall(b);U(c.results||[]),$(c.entities||null),aa(c.chunks||null),ac(c.observations||null),ae(c.trace||null),aj("results")}catch(a){}finally{ah(!1)}}};return q?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"pt-6",children:[(0,B.jsxs)("div",{className:"flex gap-3",children:[(0,B.jsxs)("div",{className:"flex-1 relative",children:[(0,B.jsx)(J.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"text",value:r,onChange:a=>s(a.target.value),placeholder:p("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&at()})]}),(0,B.jsx)(W.Button,{onClick:at,disabled:ag||!r,className:"h-12 px-8",children:ag?p("searching"):p("recall")})]}),(0,B.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,B.jsx)(JX,{value:t,onChange:u,label:p("typesLabel")}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(KL,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsxs)(bb.Select,{value:v,onValueChange:a=>w(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-24 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"low",children:p("budgetLow")}),(0,B.jsx)(bb.SelectItem,{value:"mid",children:p("budgetMid")}),(0,B.jsx)(bb.SelectItem,{value:"high",children:p("budgetHigh")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:p("tokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:x,onChange:a=>y(parseInt(a.target.value)),className:"w-24 h-8"})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(af,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)(X.Input,{type:"datetime-local",value:z,onChange:a=>A(a.target.value),className:"h-8",placeholder:p("queryDatePlaceholder")})]}),(0,B.jsx)("div",{className:"h-6 w-px bg-border"}),(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:D,onCheckedChange:a=>G(a)}),(0,B.jsx)(N.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-sm",children:p("chunks")})]}),(0,B.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,B.jsx)(I4.Checkbox,{checked:I,onCheckedChange:a=>K(a)}),(0,B.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-sm",children:p("entities")})]})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,B.jsx)(bc,{className:"h-4 w-4 text-muted-foreground"}),(0,B.jsx)("div",{className:"flex-1 max-w-md",children:(0,B.jsx)(X.Input,{type:"text",value:L,onChange:a=>P(a.target.value),placeholder:p("tagsPlaceholder"),className:"h-8"})}),(0,B.jsxs)(bb.Select,{value:R,onValueChange:a=>S(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-40 h-8",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"any",children:p("tagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:p("tagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:p("tagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:p("tagsMatchAllStrict")}),(0,B.jsx)(bb.SelectItem,{value:"exact",children:p("tagsMatchExact")})]})]})]})]})}),ag&&(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("searchingMemories")})]})}),!ag&&T&&(0,B.jsxs)("div",{className:"space-y-4",children:[ad?.summary&&(0,B.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("resultsLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:T.length})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("durationLabel")}),(0,B.jsxs)("span",{className:"font-semibold",children:[ad.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:p("nodesVisitedLabel")}),(0,B.jsx)("span",{className:"font-semibold",children:ad.summary.total_nodes_visited})]}),(0,B.jsx)("div",{className:"flex-1"}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(a=>(0,B.jsx)("button",{onClick:()=>aj(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ai===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===a?p("viewResults"):"trace"===a?p("viewTrace"):p("viewJson")},a))})]}),"results"===ai&&(0,B.jsxs)("div",{className:"space-y-4",children:[ab&&ab.length>0&&(0,B.jsxs)(by.Card,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,B.jsx)(by.CardHeader,{className:"py-3",children:(0,B.jsxs)(by.CardTitle,{className:"text-base flex items-center gap-2",children:[(0,B.jsx)(M,{className:"h-4 w-4 text-orange-500"}),(0,B.jsx)("span",{children:"Observations"}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",ab.length,")"]})]})}),(0,B.jsx)(by.CardContent,{className:"pt-0 space-y-2",children:ab.map((a,b)=>(0,B.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,B.jsx)("p",{className:"text-sm text-foreground",children:a.text}),(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,B.jsx)("span",{children:p("proofCount",{count:a.proof_count||1})}),(0,B.jsx)("span",{children:p("relevance",{value:(a.relevance||0).toFixed(3)})})]})]},a.id||b))})]}),(0,B.jsx)("div",{className:"space-y-3",children:0!==T.length||ab&&0!==ab.length?T.map((a,b)=>{let c=ad?.visits?.find(b=>b.node_id===a.id),d=c?c.weights.final_weight:a.score||0;return(0,B.jsx)(by.Card,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>al(a),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-start gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-semibold text-primary",children:b+1})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-foreground",children:a.text}),(0,B.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:a.type||"world"}),a.context&&(0,B.jsx)("span",{className:"truncate max-w-xs",children:a.context}),a.occurred_start&&(0,B.jsx)("span",{children:new Date(a.occurred_start).toLocaleDateString()})]})]}),(0,B.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,B.jsx)("div",{className:"text-sm font-semibold",children:(d??0).toFixed(3)}),(0,B.jsx)("div",{className:"text-xs text-muted-foreground",children:p("scoreLabel")})]}),(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},b)}):(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-12",children:[(0,B.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("noMemoriesFound")})]})})})]}),"trace"===ai&&ad&&(0,B.jsxs)("div",{className:"space-y-4",children:[ad.retrieval_results&&ad.retrieval_results.length>0&&(a={},ad.retrieval_results.forEach(b=>{let c=b.fact_type||"all";a[c]||(a[c]=[]),a[c].push(b)}),b=Object.keys(a),(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,B.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,B.jsx)("span",{children:p("parallelRetrieval")}),(0,B.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,B.jsx)("div",{className:"space-y-2",children:b.map((b,c)=>{let d=a[b],e=`lane-${b}`,f=am.has(e),g=d.reduce((a,b)=>a+(b.results?.length||0),0),h=Math.max(...d.map(a=>a.duration_seconds||0)),i={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},j=i[b]||i.all;return(0,B.jsx)(by.Card,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,B.jsxs)(by.CardContent,{className:"py-3 px-4",children:[(0,B.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>aq(e),children:[(0,B.jsx)("div",{className:`w-8 h-8 rounded-lg ${j.bg} flex items-center justify-center`,children:(0,B.jsx)("span",{className:`text-sm font-bold ${j.text} capitalize`,children:b.charAt(0).toUpperCase()})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground capitalize",children:b}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:p("methodsCount",{count:d.length})})]}),(0,B.jsx)("div",{className:"flex gap-1.5 mt-1",children:d.map((a,b)=>(0,B.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[a.method_name,": ",a.results?.length||0]},b))})]}),(0,B.jsxs)("div",{className:"text-right",children:[(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:g}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[h.toFixed(2),"s"]})]}),f?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),f&&(0,B.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,B.jsx)("div",{className:`grid gap-3 ${1===d.length?"grid-cols-1":2===d.length?"grid-cols-2":3===d.length?"grid-cols-3":"grid-cols-4"}`,children:d.map((a,b)=>{let c,d,f,g,h=`${e}-method-${b}`,i=am.has(h),j=a.results||[];return(0,B.jsxs)("div",{className:"flex flex-col",children:[(0,B.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${i?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:a=>{a.stopPropagation(),aq(h)},children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:a.method_name}),"temporal"===a.method_name&&a.metadata?.constraint&&(0,B.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,B.jsx)(Y,{className:"h-3 w-3"}),a.metadata.constraint.start?new Date(a.metadata.constraint.start).toLocaleDateString():"any"," → ",a.metadata.constraint.end?new Date(a.metadata.constraint.end).toLocaleDateString():"any"]})]}),i?(0,B.jsx)(JC.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,B.jsxs)("div",{className:"flex items-end justify-between",children:[(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:j.length}),(0,B.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[a.duration_seconds?.toFixed(2),"s"]})]})]}),i&&j.length>0&&(c=`results-${h}`,f=(d=ao.has(c))?j:j.slice(0,5),g=j.length>5,(0,B.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[f.map((a,b)=>(0,B.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-2",children:[(0,B.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:a.text}),(0,B.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,B.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(a.score||a.similarity||0).toFixed(4)})})]})]})},b)),g&&(0,B.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(c)},children:d?p("showLess"):p("viewAllResults",{count:j.length})})]}))]},h)})})})]})},e)})}),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)("div",{className:"flex items-center gap-2",children:b.map((a,b)=>{let c={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,B.jsx)("div",{className:"flex flex-col items-center",children:(0,B.jsx)("div",{className:`w-1 h-4 ${c[a]||c.all} rounded-full opacity-50`})},b)})})}),(0,B.jsx)("div",{className:"flex justify-center",children:(0,B.jsx)(P7,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ad.rrf_merged&&(c="rrf-merge",d=am.has(c),(0,B.jsxs)("div",{children:[(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>aq(c),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("rrfFusion")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rrfMerge")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("rrfDescription")})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ad.rrf_merged.length}),d?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),d&&ad.rrf_merged.length>0&&(e="results-rrf",g=(f=ao.has(e))?ad.rrf_merged:ad.rrf_merged.slice(0,5),h=ad.rrf_merged.length>5,(0,B.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[g.map((a,b)=>(0,B.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,B.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[p("rrfScore")," ",(a.rrf_score||a.score||0).toFixed(4)]})]})]})},b)),h&&(0,B.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(e)},children:f?p("showLess"):p("viewAllResults",{count:ad.rrf_merged.length})})]})),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)(P7,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ad.reranked&&(i="reranking",j=am.has(i),(0,B.jsxs)("div",{children:[(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>aq(i),children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("combinedScoring")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rerank")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,B.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ad.reranked.length}),j?(0,B.jsx)(JC.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),j&&ad.reranked.length>0&&(k="results-rerank",n=(l=ao.has(k))?ad.reranked:ad.reranked.slice(0,5),o=ad.reranked.length>5,(0,B.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[n.map((a,b)=>{let c=a.score_components||{};return(0,B.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),as(a)},children:(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,B.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,B.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(a.rerank_score||a.score||0).toFixed(4)]}),void 0!==c.cross_encoder_score_normalized&&(0,B.jsxs)("span",{title:p("tooltipCrossEncoder"),children:["CE: ",c.cross_encoder_score_normalized.toFixed(3)]}),void 0!==c.temporal&&.5!==c.temporal&&(0,B.jsxs)("span",{title:p("tooltipTemporal"),children:["Tmp: ",c.temporal.toFixed(3)]}),void 0!==c.recency&&(0,B.jsxs)("span",{title:p("tooltipRecency"),children:["Rec: ",c.recency.toFixed(3)]})]})]})]})},b)}),o&&(0,B.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),ar(k)},children:l?p("showLess"):p("viewAllResults",{count:ad.reranked.length})})]})),(0,B.jsx)("div",{className:"flex justify-center py-2",children:(0,B.jsx)(P7,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,B.jsx)(by.Card,{className:"border-primary bg-primary/5",children:(0,B.jsx)(by.CardContent,{className:"py-4",children:(0,B.jsxs)("div",{className:"flex items-center gap-4",children:[(0,B.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,B.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"font-semibold text-foreground",children:p("finalResults")}),(0,B.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:p("output")})]}),(0,B.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("finalResultsDescription")})]}),(0,B.jsx)("div",{className:"text-2xl font-bold text-primary",children:T?.length||0})]})})})]}),"json"===ai&&(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{children:(0,B.jsx)(by.CardTitle,{className:"text-lg",children:p("rawResponse")})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,B.jsx)(KK,{src:{results:T,...Z&&{entities:Z},..._&&{chunks:_},...ab&&{observations:ab},trace:ad},collapsed:2,theme:"default"})})})]})]}),!ag&&!T&&(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-lg font-semibold mb-2",children:p("readyToRecall")}),(0,B.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:p("readyToRecallDescription")})]})}),ak&&(0,B.jsx)("div",{className:"fixed right-0 top-0 h-screen w-[420px] bg-card border-l shadow-2xl z-50 overflow-y-auto",children:(0,B.jsx)(wu,{memory:ak,onClose:()=>al(null),inPanel:!0,bankId:q||void 0})})]}):(0,B.jsx)(by.Card,{className:"border-dashed",children:(0,B.jsxs)(by.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,B.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2",children:p("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:p("noBankSelectedDescription")})]})})}let P9=(0,K.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var Qa=a.i(83604),Qa=Qa,bh=bh;let Qb=["skepticism","literalism","empathy"];function Qc(){let a=(0,E.useTranslations)("bankProfile");return{skepticism:{label:a("skepticismLabel"),shortLabel:"S",description:a("skepticismDescription"),lowLabel:a("skepticismLow"),highLabel:a("skepticismHigh")},literalism:{label:a("literalismLabel"),shortLabel:"L",description:a("literalismDescription"),lowLabel:a("literalismLow"),highLabel:a("literalismHigh")},empathy:{label:a("empathyLabel"),shortLabel:"E",description:a("empathyDescription"),lowLabel:a("empathyLow"),highLabel:a("empathyHigh")}}}function Qd({hideReflectFields:a=!1}){let b=(0,D.useRouter)(),c=(0,E.useTranslations)("bankProfile"),d=(0,E.useTranslations)("common"),e=(0,E.useTranslations)("bank"),f=Qc(),{currentBank:g,setCurrentBank:h,loadBanks:i}=(0,H.useBank)(),[j,k]=(0,C.useState)(null),[l,n]=(0,C.useState)(null),[o,p]=(0,C.useState)([]),[q,r]=(0,C.useState)(!1),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(!1),[w,x]=(0,C.useState)(!1),[y,z]=(0,C.useState)(null),[A,G]=(0,C.useState)(null),[I,J]=(0,C.useState)(!1),[K,L]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),[O,P]=(0,C.useState)(!1),[Q,R]=(0,C.useState)(!1),S=async(a=!1)=>{if(g){if(a){try{let[a,b]=await Promise.all([V.client.getBankStats(g),V.client.listDirectives(g)]);n(a),p(b.items||[])}catch(a){console.error("Error refreshing stats:",a)}return}r(!0);try{let[a,b,c]=await Promise.all([V.client.getBankProfile(g),V.client.getBankStats(g),V.client.listDirectives(g)]);k(a),n(b),p(c.items||[])}catch(a){}finally{r(!1)}}},T=async()=>{if(g){N(!0);try{await V.client.deleteBank(g),L(!1),h(null),await i(),b.push("/")}catch(a){}finally{N(!1)}}},U=async()=>{if(g){R(!0);try{let a=await V.client.clearObservations(g);P(!1),await S(),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{R(!1)}}},X=async()=>{if(g&&A){J(!0);try{await V.client.deleteDirective(g,A.id),p(a=>a.filter(a=>a.id!==A.id)),y?.id===A.id&&z(null),G(null)}catch(a){}finally{J(!1)}}};return((0,C.useEffect)(()=>{if(g){S();let a=setInterval(()=>S(!0),5e3);return()=>clearInterval(a)}},[g]),(0,C.useEffect)(()=>{let a=a=>{"Escape"===a.key&&z(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),g)?q&&!j?(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"text-center py-10",children:[(0,B.jsx)(af,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,B.jsx)("div",{className:"text-lg text-muted-foreground",children:c("loadingProfile")})]})}):(0,B.jsxs)("div",{className:"space-y-6",children:[!a&&(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)("div",{className:"flex items-start justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,B.jsx)(J$,{className:"w-5 h-5 text-primary"}),c("dispositionProfileTitle")]}),(0,B.jsx)(by.CardDescription,{children:c("editDispositionDescription")})]}),(0,B.jsx)(W.Button,{onClick:()=>t(!0),variant:"ghost",size:"sm",children:(0,B.jsx)(bl,{className:"h-4 w-4"})})]})}),(0,B.jsx)(by.CardContent,{children:j&&(0,B.jsx)("div",{className:"space-y-4",children:Qb.map(a=>(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex justify-between items-center",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:f[a].label}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:f[a].description})]}),(0,B.jsxs)("span",{className:"text-sm font-bold text-primary",children:[j.disposition[a],"/5"]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:f[a].lowLabel}),(0,B.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,B.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(j.disposition[a]-1)/4*100}%`}})}),(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:f[a].highLabel})]})]},a))})})]}),(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)("div",{className:"flex items-start justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)(by.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,B.jsx)(P9,{className:"w-5 h-5 text-primary"}),c("missionTitle")]}),(0,B.jsx)(by.CardDescription,{children:c("editMissionDescription")})]}),(0,B.jsx)(W.Button,{onClick:()=>v(!0),variant:"ghost",size:"sm",children:(0,B.jsx)(bl,{className:"h-4 w-4"})})]})}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:j?.mission||c("noMissionSet")})})]})]}),(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),c("directivesTitle")]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:c("directivesDescription")})]}),(0,B.jsxs)(W.Button,{onClick:()=>x(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-1"}),c("addDirective")]})]}),o.length>0?(0,B.jsx)("div",{className:"grid grid-cols-2 gap-3",children:o.map(a=>(0,B.jsx)(by.Card,{className:`cursor-pointer transition-colors border-rose-500/30 ${y?.id===a.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>z(a),children:(0,B.jsx)(by.CardContent,{className:"p-3",children:(0,B.jsxs)("div",{className:"flex items-start gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:a.content}),a.tags&&a.tags.length>0&&(0,B.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,B.jsx)(bc,{className:"w-3 h-3 text-muted-foreground"}),a.tags.map(a=>(0,B.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:a},a))]})]})]})})},a.id))}):(0,B.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,B.jsx)(Qa.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:c("noDirectivesMessage")})]})]}),(0,B.jsx)(Jc,{open:K,onOpenChange:L,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("deleteMemoryBank")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:e.rich("deleteBankPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:g})})}),(0,B.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:e("deleteBankWarning")}),l&&(0,B.jsx)("p",{children:e("deleteWillDeleteDetails",{memories:l.total_nodes,documents:l.total_documents,links:l.total_links})})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:M,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:T,disabled:M,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),e("deleting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),e("deleteBank")]})})]})]})}),(0,B.jsx)(Jc,{open:O,onOpenChange:P,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("clearObservationsTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:e.rich("clearObservationsPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:g})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:e("clearObservationsWarning")}),l&&l.total_observations>0&&(0,B.jsx)("p",{children:e("deleteWillDeleteObservations",{count:l.total_observations})})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:Q,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:U,disabled:Q,className:"bg-amber-500 text-white hover:bg-amber-600",children:Q?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("clearing")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),e("clearObservations")]})})]})]})}),(0,B.jsx)(Qg,{open:w,mode:"create",onClose:()=>x(!1),onCreated:a=>{p(b=>[a,...b]),x(!1)}}),(0,B.jsx)(Jc,{open:!!A,onOpenChange:a=>!a&&G(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("deleteDirectiveTitle")}),(0,B.jsxs)(Jx,{children:[c("deleteDirectiveConfirm",{name:`"${A?.name??""}"`}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),(0,B.jsx)("span",{className:"text-destructive font-semibold",children:c("deleteDirectiveWarning")})]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:d("cancel")}),(0,B.jsxs)(Jy,{onClick:X,disabled:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[I?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,d("delete")]})]})]})}),y&&(0,B.jsx)(Qh,{directive:y,onClose:()=>z(null),onDelete:()=>G({id:y.id,name:y.name}),onUpdated:a=>{p(b=>b.map(b=>b.id===a.id?a:b)),z(a)}}),s&&j&&(0,B.jsx)(Qe,{disposition:j.disposition,onClose:()=>t(!1),onSaved:async()=>{await S(),t(!1)}}),u&&j&&(0,B.jsx)(Qf,{mission:j.mission||"",onClose:()=>v(!1),onSaved:async()=>{await S(),v(!1)}})]}):(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"p-10 text-center",children:[(0,B.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:c("noBankSelected")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:c("noBankSelectedDescription")})]})})}function Qe({disposition:a,onClose:b,onSaved:c}){let d=(0,E.useTranslations)("bankProfile"),e=Qc(),{currentBank:f}=(0,H.useBank)(),[g,h]=(0,C.useState)(!1),[i,j]=(0,C.useState)(a),k=async()=>{if(f){h(!0);try{await V.client.updateBankConfig(f,{disposition_skepticism:i.skepticism,disposition_literalism:i.literalism,disposition_empathy:i.empathy}),c()}catch(a){}finally{h(!1)}}};return(0,B.jsx)(bm.Dialog,{open:!0,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-xl",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("editDispositionTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("editDispositionDescription")})]}),(0,B.jsx)("div",{className:"space-y-4 py-4",children:Qb.map(a=>(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex justify-between items-center",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e[a].label}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e[a].description})]}),(0,B.jsxs)("span",{className:"text-sm font-bold text-primary",children:[i[a],"/5"]})]}),(0,B.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,B.jsx)("span",{children:e[a].lowLabel}),(0,B.jsx)("span",{children:e[a].highLabel})]}),(0,B.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:i[a],onChange:b=>j(c=>({...c,[a]:parseInt(b.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},a))}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{onClick:b,variant:"outline",disabled:g,children:d("cancel")}),(0,B.jsx)(W.Button,{onClick:k,disabled:g,children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),d("saving")]}):d("saveChanges")})]})]})})}function Qf({mission:a,onClose:b,onSaved:c}){let d=(0,E.useTranslations)("bankProfile"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(!1),[h,i]=(0,C.useState)(a),j=async()=>{if(e){g(!0);try{await V.client.updateBankConfig(e,{reflect_mission:h||null}),c()}catch(a){}finally{g(!1)}}};return(0,B.jsx)(bm.Dialog,{open:!0,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-xl",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("editMissionTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("editMissionDescription")})]}),(0,B.jsx)("div",{className:"space-y-2 py-4",children:(0,B.jsx)(J2.Textarea,{value:h,onChange:a=>i(a.target.value),placeholder:d("missionPlaceholder"),rows:8,className:"resize-none"})}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{onClick:b,variant:"outline",disabled:f,children:d("cancel")}),(0,B.jsx)(W.Button,{onClick:j,disabled:f,children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ad,{className:"w-4 h-4 mr-2 animate-spin"}),d("saving")]}):d("saveChanges")})]})]})})}function Qg({open:a,mode:b,directive:c,onClose:d,onCreated:e,onSaved:f}){let g=(0,E.useTranslations)("bankProfile"),{currentBank:h}=(0,H.useBank)(),[i,j]=(0,C.useState)(!1),[k,l]=(0,C.useState)({name:"",content:"",tags:""});(0,C.useEffect)(()=>{"edit"===b&&c?l({name:c.name,content:c.content,tags:(c.tags||[]).join(", ")}):"create"===b&&l({name:"",content:"",tags:""})},[a,b,c]);let n=async()=>{if(h&&k.name.trim()&&k.content.trim()){j(!0);try{let a=k.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0);if("create"===b){let b=await V.client.createDirective(h,{name:k.name.trim(),content:k.content.trim(),tags:a.length>0?a:void 0});l({name:"",content:"",tags:""}),e?.(b)}else if(c){let b=await V.client.updateDirective(h,c.id,{name:k.name.trim(),content:k.content.trim(),tags:a});f?.(b),d()}}catch(a){}finally{j(!1)}}},o=()=>{"create"===b&&l({name:"",content:"",tags:""}),d()};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>!a&&o(),children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-lg",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsxs)(bm.DialogTitle,{className:"flex items-center gap-2",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),g("create"===b?"directiveFormCreateTitle":"directiveFormEditTitle")]}),(0,B.jsx)(bm.DialogDescription,{children:g("directiveFormDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:g("directiveNameLabel")}),(0,B.jsx)(X.Input,{value:k.name,onChange:a=>l({...k,name:a.target.value}),placeholder:g("directiveNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:g("directiveRuleLabel")}),(0,B.jsx)(J2.Textarea,{value:k.content,onChange:a=>l({...k,content:a.target.value}),placeholder:g("directiveRulePlaceholder"),className:"min-h-[120px]"})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("label",{className:"text-sm font-medium text-foreground",children:[g("directiveTagsLabel")," ",(0,B.jsx)("span",{className:"text-muted-foreground font-normal",children:g("directiveTagsOptional")})]}),(0,B.jsx)(X.Input,{value:k.tags,onChange:a=>l({...k,tags:a.target.value}),placeholder:g("directiveTagsPlaceholder")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:o,disabled:i,children:g("cancel")}),(0,B.jsxs)(W.Button,{onClick:n,disabled:i||!k.name.trim()||!k.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[i?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,g("create"===b?"create":"save")]})]})]})})}function Qh({directive:a,onClose:b,onDelete:c,onUpdated:d}){let e=(0,E.useTranslations)("bankProfile"),[f,g]=(0,C.useState)(!1);return(0,B.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l-2 border-rose-500 shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,B.jsxs)("div",{className:"p-6",children:[(0,B.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)(Qa.default,{className:"w-5 h-5 text-rose-500"}),(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"h-7 w-7 p-0",children:(0,B.jsx)(bl,{className:"h-3.5 w-3.5"})})]}),(0,B.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:e("directiveDetailBadge")})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,B.jsx)(JA,{className:"h-4 w-4"})}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,B.jsx)(bg.X,{className:"h-4 w-4"})})]})]}),(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:e("directiveDetailRuleLabel")}),(0,B.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,B.jsx)(Ob,{remarkPlugins:[PG],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:e("directiveDetailTagsLabel")}),(0,B.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tags.map(a=>(0,B.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:a},a))})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:e("directiveDetailIdLabel")}),(0,B.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:a.id})]})]})]}),(0,B.jsx)(Qg,{open:f,mode:"edit",directive:a,onClose:()=>g(!1),onSaved:d})]})}let Qi=(0,ay.cva)("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Qj=C.forwardRef(({className:a,variant:b,...c},d)=>(0,B.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(Qi({variant:b}),a),...c}));Qj.displayName="Alert",C.forwardRef(({className:a,...b},c)=>(0,B.jsx)("h5",{ref:c,className:(0,S.cn)("mb-1 font-medium leading-none tracking-tight",a),...b})).displayName="AlertTitle";let Qk=C.forwardRef(({className:a,...b},c)=>(0,B.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));Qk.displayName="AlertDescription";var bh=bh;let Ql=(0,K.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Qm=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT"].map(a=>({category:a,threshold:"BLOCK_NONE"})),Qn=["retain","sync_retain","recall","reflect","list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories","list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model","clear_mental_model","list_directives","create_directive","delete_directive","list_memories","get_memory","update_memory","invalidate_memory","list_documents","get_document","delete_document","list_operations","get_operation","cancel_operation","list_tags"];function Qo(a){return Array.isArray(a)?a:a&&"object"==typeof a&&Array.isArray(a.attributes)?a.attributes:null}function Qp(a){return{retain_chunk_size:a.retain_chunk_size??null,retain_structured_chunk_size:a.retain_structured_chunk_size??null,retain_extraction_mode:a.retain_extraction_mode??null,retain_mission:a.retain_mission??null,retain_custom_instructions:a.retain_custom_instructions??null,entities_allow_free_form:a.entities_allow_free_form??null,entity_labels:Qo(a.entity_labels)}}function Qq(a){return{retain_default_strategy:a.retain_default_strategy??null,retain_strategies:a.retain_strategies??null}}function Qr(a){return{enable_observations:a.enable_observations??null,consolidation_llm_batch_size:a.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:a.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:a.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:a.observations_mission??null,max_observations_per_scope:a.max_observations_per_scope??null}}function Qs(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function Qt(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let Qu={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function Qv(){let a=(0,E.useTranslations)("bankConfig"),{currentBank:b}=(0,H.useBank)(),{features:c}=(0,I3.useFeatures)(),d=c?.bank_config_api??!0,[e,f]=(0,C.useState)(!0),[g,h]=(0,C.useState)({}),[i,j]=(0,C.useState)(Qu),[k,l]=(0,C.useState)(Qp({})),[n,o]=(0,C.useState)(Qq({})),[p,q]=(0,C.useState)(Qr({})),[r,s]=(0,C.useState)(Qu),[t,u]=(0,C.useState)(Qs({})),[v,w]=(0,C.useState)(Qt({})),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(null),[N,O]=(0,C.useState)(null),[P,Q]=(0,C.useState)(null),[R,S]=(0,C.useState)(null),[T,U]=(0,C.useState)(null),W=(0,C.useMemo)(()=>JSON.stringify(k)!==JSON.stringify(Qp(g))||JSON.stringify(n)!==JSON.stringify(Qq(g)),[k,n,g]),Y=(0,C.useMemo)(()=>JSON.stringify(p)!==JSON.stringify(Qr(g)),[p,g]),Z=(0,C.useMemo)(()=>JSON.stringify(r)!==JSON.stringify(i),[r,i]),$=(0,C.useMemo)(()=>JSON.stringify(t)!==JSON.stringify(Qs(g)),[t,g]),_=(0,C.useMemo)(()=>JSON.stringify(v)!==JSON.stringify(Qt(g)),[v,g]);(0,C.useEffect)(()=>{b&&aa()},[b]);let aa=async()=>{if(b){f(!0);try{let[a,c]=await Promise.all([V.client.getBankConfig(b),V.client.getBankProfile(b)]),d=a.config,e={reflect_mission:c.mission??"",disposition_skepticism:d.disposition_skepticism??c.disposition?.skepticism??3,disposition_literalism:d.disposition_literalism??c.disposition?.literalism??3,disposition_empathy:d.disposition_empathy??c.disposition?.empathy??3};h(d),j(e),l(Qp(d)),o(Qq(d)),q(Qr(d)),s(e),u(Qs(d)),w(Qt(d))}catch(a){console.error("Failed to load bank data:",a)}finally{f(!1)}}},ab=async()=>{if(b){y(!0),M(null);try{let a={...k,...n};await V.client.updateBankConfig(b,a),h(b=>({...b,...a}))}catch(b){M(b.message||a("retainFailedToSave"))}finally{y(!1)}}},ac=async()=>{if(b){A(!0),O(null);try{await V.client.updateBankConfig(b,p),h(a=>({...a,...p}))}catch(b){O(b.message||a("observationsFailedToSave"))}finally{A(!1)}}},ad=async()=>{if(b){F(!0),Q(null);try{await V.client.updateBankConfig(b,{reflect_mission:r.reflect_mission||null,disposition_skepticism:r.disposition_skepticism,disposition_literalism:r.disposition_literalism,disposition_empathy:r.disposition_empathy}),j(r)}catch(b){Q(b.message||a("reflectFailedToSave"))}finally{F(!1)}}},ae=async()=>{if(b){I(!0),S(null);try{await V.client.updateBankConfig(b,t),h(a=>({...a,...t}))}catch(b){S(b.message||a("mcpFailedToSave"))}finally{I(!1)}}},af=async()=>{if(b){K(!0),U(null);try{await V.client.updateBankConfig(b,v),h(a=>({...a,...v}))}catch(b){U(b.message||a("geminiFailedToSave"))}finally{K(!1)}}};return b?d?e?(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(bh.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)("div",{className:"space-y-8",children:[(0,B.jsxs)(QC,{title:a("retainTitle"),description:a("retainSectionDescription"),error:L,dirty:W,saving:x,onSave:ab,children:[(0,B.jsx)(QD,{label:a("defaultStrategyLabel"),description:a("defaultStrategyDescription"),children:(0,B.jsxs)(bb.Select,{value:n.retain_default_strategy??"__none__",onValueChange:a=>o(b=>({...b,retain_default_strategy:"__none__"===a?null:a})),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-full",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"__none__",children:(0,B.jsx)("span",{className:"text-muted-foreground italic",children:a("default")})}),Object.keys(n.retain_strategies??{}).map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:a},a))]})]})}),(0,B.jsx)(QA,{defaultValues:k,onDefaultChange:a=>l(b=>({...b,...a})),strategies:n.retain_strategies,onStrategiesChange:a=>o(b=>({...b,retain_strategies:a}))})]}),(0,B.jsxs)(QC,{title:a("observationsTitle"),description:a("observationsDescription"),error:N,dirty:Y,saving:z,onSave:ac,children:[(0,B.jsx)(QD,{label:a("enableObservationsLabel"),description:a("enableObservationsDescription"),children:(0,B.jsx)("div",{className:"flex justify-end",children:(0,B.jsx)(ba.Switch,{checked:p.enable_observations??!1,onCheckedChange:a=>q(b=>({...b,enable_observations:a}))})})}),(0,B.jsx)(QE,{label:a("missionLabel"),description:a("observationsMissionDescription"),value:p.observations_mission??"",onChange:a=>q(b=>({...b,observations_mission:a||null})),placeholder:a("observationsMissionPlaceholder"),rows:3}),(0,B.jsx)(QD,{label:a("llmBatchSizeLabel"),description:a("llmBatchSizeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:1,max:64,value:p.consolidation_llm_batch_size??"",onChange:a=>q(b=>({...b,consolidation_llm_batch_size:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("sourceFactsMaxTokensLabel"),description:a("sourceFactsMaxTokensDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens??"",onChange:a=>q(b=>({...b,consolidation_source_facts_max_tokens:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("sourceFactsMaxTokensPerObservationLabel"),description:a("sourceFactsMaxTokensPerObservationDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens_per_observation??"",onChange:a=>q(b=>({...b,consolidation_source_facts_max_tokens_per_observation:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})}),(0,B.jsx)(QD,{label:a("maxObservationsPerScopeLabel"),description:a("maxObservationsPerScopeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:-1,value:p.max_observations_per_scope??"",onChange:a=>q(b=>({...b,max_observations_per_scope:a.target.value?parseInt(a.target.value,10):null})),placeholder:a("serverDefault")})})]}),(0,B.jsxs)(QC,{title:a("reflectTitle"),description:a("reflectDescription"),error:P,dirty:Z,saving:D,onSave:ad,children:[(0,B.jsx)(QE,{label:a("missionLabel"),description:a("reflectMissionDescription"),value:r.reflect_mission,onChange:a=>s(b=>({...b,reflect_mission:a})),placeholder:a("reflectMissionPlaceholder"),rows:3}),(0,B.jsx)(QF,{label:a("skepticismLabel"),description:a("skepticismDescription"),lowLabel:a("skepticismLowLabel"),highLabel:a("skepticismHighLabel"),value:r.disposition_skepticism,onChange:a=>s(b=>({...b,disposition_skepticism:a}))}),(0,B.jsx)(QF,{label:a("literalismLabel"),description:a("literalismDescription"),lowLabel:a("literalismLowLabel"),highLabel:a("literalismHighLabel"),value:r.disposition_literalism,onChange:a=>s(b=>({...b,disposition_literalism:a}))}),(0,B.jsx)(QF,{label:a("empathyLabel"),description:a("empathyDescription"),lowLabel:a("empathyLowLabel"),highLabel:a("empathyHighLabel"),value:r.disposition_empathy,onChange:a=>s(b=>({...b,disposition_empathy:a}))})]}),(0,B.jsxs)(QC,{title:a("mcpToolsTitle"),description:a("mcpToolsDescription"),error:R,dirty:$,saving:G,onSave:ae,children:[(0,B.jsx)(QD,{label:a("restrictToolsLabel"),description:a("restrictToolsDescription"),children:(0,B.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,B.jsx)(ba.Switch,{checked:null!==t.mcp_enabled_tools,onCheckedChange:a=>u({mcp_enabled_tools:a?[...Qn]:null})}),(0,B.jsx)(aA,{className:"text-xs text-muted-foreground",children:null!==t.mcp_enabled_tools?a("enabled"):a("disabled")})]})}),null!==t.mcp_enabled_tools&&(0,B.jsx)(QB,{selected:t.mcp_enabled_tools,onChange:a=>u({mcp_enabled_tools:a})})]}),(0,B.jsx)(QC,{title:a("modelsTitle"),description:a("modelsDescription"),error:T,dirty:_,saving:J,onSave:af,children:(0,B.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,B.jsx)("p",{className:"text-sm font-semibold",children:a("geminiSubsectionTitle")}),(0,B.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,B.jsx)(QD,{label:a("safetySettingsLabel"),description:(0,B.jsxs)(B.Fragment,{children:[a("safetySettingsDescriptionPart1")," ",(0,B.jsx)("a",{href:"https://ai.google.dev/gemini-api/docs/safety-settings",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",children:a("safetySettingsLearnMore")})]}),children:(0,B.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,B.jsx)(ba.Switch,{checked:null!==v.llm_gemini_safety_settings,onCheckedChange:a=>w({llm_gemini_safety_settings:a?[...Qm]:null})}),(0,B.jsx)(aA,{className:"text-xs text-muted-foreground",children:null!==v.llm_gemini_safety_settings?a("custom"):a("default")})]})}),null!==v.llm_gemini_safety_settings&&(0,B.jsx)(QI,{value:v.llm_gemini_safety_settings,onChange:a=>w({llm_gemini_safety_settings:a})})]})]})})]})}):(0,B.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,B.jsx)("p",{className:"text-base font-medium text-foreground",children:a("apiDisabledTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:a.rich("apiDisabledDescription",{code:a=>(0,B.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:a})})})]}):(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)("p",{className:"text-muted-foreground",children:a("noBankSelected")})})}let Qw=["concise","verbose","verbatim","chunks","custom"],Qx="__inherit__";function Qy({values:a,onChange:b,isOverride:c=!1}){let d=(0,E.useTranslations)("bankConfig"),e=a.retain_extraction_mode??(c?Qx:""),f="custom"===a.retain_extraction_mode;return(0,B.jsxs)("div",{className:"divide-y divide-border/40",children:[(0,B.jsx)(QD,{label:d("extractionModeLabel"),description:d("extractionModeDescription"),children:(0,B.jsxs)(bb.Select,{value:e,onValueChange:a=>b({retain_extraction_mode:a===Qx?null:a||null}),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-full",children:(0,B.jsx)(bb.SelectValue,{placeholder:c?d("inherited"):void 0})}),(0,B.jsxs)(bb.SelectContent,{children:[c&&(0,B.jsx)(bb.SelectItem,{value:Qx,children:(0,B.jsx)("span",{className:"text-muted-foreground italic",children:d("inherited")})}),Qw.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:a},a))]})]})}),(0,B.jsx)(QD,{label:d("chunkSizeLabel"),description:d("chunkSizeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:500,max:8e3,step:1,value:a.retain_chunk_size??"",onChange:a=>b({retain_chunk_size:a.target.value?parseInt(a.target.value,10):null}),placeholder:c?d("inherited"):void 0})}),(0,B.jsx)(QD,{label:d("structuredChunkSizeLabel"),description:d("structuredChunkSizeDescription"),children:(0,B.jsx)(X.Input,{type:"number",min:1,step:1,value:a.retain_structured_chunk_size??"",onChange:a=>{b({retain_structured_chunk_size:a.target.value?parseInt(a.target.value,10):null})},placeholder:c?d("inherited"):void 0})}),(0,B.jsx)(QE,{label:d("missionLabel"),description:d("retainMissionDescription"),value:a.retain_mission??"",onChange:a=>b({retain_mission:a||null}),placeholder:d(c?"inherited":"retainMissionPlaceholder"),rows:3}),f&&(0,B.jsx)(QE,{label:d("customExtractionPromptLabel"),description:d("customExtractionPromptDescription"),value:a.retain_custom_instructions??"",onChange:a=>b({retain_custom_instructions:a||null}),rows:5}),(0,B.jsx)(QD,{label:d("freeFormEntitiesLabel"),description:d("freeFormEntitiesDescription"),children:(0,B.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,B.jsx)(aA,{className:"text-sm text-muted-foreground cursor-pointer select-none",children:d(a.entities_allow_free_form??!0?"enabled":"disabled")}),(0,B.jsx)(ba.Switch,{checked:a.entities_allow_free_form??!0,onCheckedChange:a=>b({entities_allow_free_form:a})})]})}),(0,B.jsx)(QH,{value:a.entity_labels??[],onChange:a=>b({entity_labels:a.length>0?a:null})})]})}function Qz(a){return a?Object.entries(a).map(([a,b],c)=>({id:c,name:a,values:{retain_extraction_mode:b.retain_extraction_mode??null,retain_chunk_size:b.retain_chunk_size??null,retain_structured_chunk_size:b.retain_structured_chunk_size??null,retain_mission:b.retain_mission??null,retain_custom_instructions:b.retain_custom_instructions??null,entities_allow_free_form:b.entities_allow_free_form??null,entity_labels:Qo(b.entity_labels)}})):[]}function QA({defaultValues:a,onDefaultChange:b,strategies:c,onStrategiesChange:d}){let e=(0,E.useTranslations)("bankConfig"),f=(0,E.useTranslations)("common"),[g,h]=(0,C.useState)(()=>Qz(c)),[i,j]=(0,C.useState)("default"),[k,l]=(0,C.useState)(null),n=(0,C.useRef)(!1),o=JSON.stringify(c);(0,C.useEffect)(()=>{if(n.current){n.current=!1;return}h(Qz(c))},[o]);let p=a=>{n.current=!0,h(a),d(function(a){let b={};for(let c of a){if(!c.name.trim())continue;let a={};null!==c.values.retain_extraction_mode&&(a.retain_extraction_mode=c.values.retain_extraction_mode),null!==c.values.retain_chunk_size&&(a.retain_chunk_size=c.values.retain_chunk_size),null!==c.values.retain_structured_chunk_size&&(a.retain_structured_chunk_size=c.values.retain_structured_chunk_size),c.values.retain_mission&&(a.retain_mission=c.values.retain_mission),c.values.retain_custom_instructions&&(a.retain_custom_instructions=c.values.retain_custom_instructions),null!==c.values.entities_allow_free_form&&(a.entities_allow_free_form=c.values.entities_allow_free_form),null!==c.values.entity_labels&&(a.entity_labels=c.values.entity_labels),b[c.name.trim()]=a}return Object.keys(b).length>0?b:null}(a))},q=(a,b)=>{p(g.map(c=>c.id===a?{...c,...b}:c))},r="default"!==i?g.find(a=>a.id===i):null;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"border-b border-border px-6 flex items-stretch gap-1 flex-wrap",children:[(0,B.jsx)("button",{type:"button",onClick:()=>j("default"),className:`relative py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px ${"default"===i?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,children:e("default")}),g.map(a=>(0,B.jsxs)("div",{className:`relative flex items-center gap-2 py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px cursor-pointer ${i===a.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>j(a.id),children:[(0,B.jsx)("span",{className:"font-mono",children:a.name||(0,B.jsx)("span",{className:"italic font-normal opacity-50",children:e("unnamed")})}),(0,B.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),l(a)},className:"opacity-40 hover:opacity-100 hover:text-destructive transition-opacity text-base leading-none",children:"×"})]},a.id)),(0,B.jsxs)("button",{type:"button",onClick:()=>{let a=Date.now();p([...g,{id:a,name:"",values:{retain_extraction_mode:null,retain_chunk_size:null,retain_structured_chunk_size:null,retain_mission:null,retain_custom_instructions:null,entities_allow_free_form:null,entity_labels:null}}]),j(a)},className:"py-3 px-3 text-sm text-muted-foreground hover:text-primary transition-colors flex items-center gap-1.5",children:[(0,B.jsx)(I$.Plus,{className:"h-3.5 w-3.5"}),e("addStrategy")]})]}),(0,B.jsx)("div",{children:"default"===i?(0,B.jsx)(Qy,{values:a,onChange:b}):r?(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"px-6 py-3 flex items-center gap-3 border-b border-border/40",children:[(0,B.jsx)("label",{className:"text-xs text-muted-foreground shrink-0",children:e("nameLabel")}),(0,B.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,B.jsx)(X.Input,{value:r.name,onChange:a=>q(r.id,{name:a.target.value}),placeholder:e("strategyNamePlaceholder"),className:`h-7 text-xs font-mono max-w-[200px] ${!r.name.trim()?"border-destructive focus-visible:ring-destructive":""}`}),!r.name.trim()&&(0,B.jsx)("p",{className:"text-xs text-destructive",children:e("nameIsRequired")})]})]}),(0,B.jsx)(Qy,{values:r.values,onChange:a=>q(r.id,{values:{...r.values,...a}}),isOverride:!0})]}):null}),(0,B.jsx)(Jc,{open:null!==k,onOpenChange:a=>{a||l(null)},children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:e("deleteStrategyTitle",{name:k?.name||e("unnamed")})}),(0,B.jsx)(Jx,{children:e("deleteStrategyDescription")})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{children:f("cancel")}),(0,B.jsx)(Jy,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(k){var a;a=k.id,p(g.filter(b=>b.id!==a)),i===a&&j("default"),l(null)}},children:f("delete")})]})]})})]})}function QB({selected:a,onChange:b}){let c=(0,E.useTranslations)("bankConfig"),d=[{key:"core",label:c("mcpGroupCore"),tools:["retain","sync_retain","recall","reflect"]},{key:"bankManagement",label:c("mcpGroupBankManagement"),tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{key:"mentalModels",label:c("mcpGroupMentalModels"),tools:["list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model","clear_mental_model"]},{key:"directives",label:c("mcpGroupDirectives"),tools:["list_directives","create_directive","delete_directive"]},{key:"memories",label:c("mcpGroupMemories"),tools:["list_memories","get_memory","update_memory","invalidate_memory"]},{key:"documents",label:c("mcpGroupDocuments"),tools:["list_documents","get_document","delete_document"]},{key:"operations",label:c("mcpGroupOperations"),tools:["list_operations","get_operation","cancel_operation"]},{key:"tags",label:c("mcpGroupTags"),tools:["list_tags"]}],e=new Set(a),f=Qn.every(a=>e.has(a)),g=0===a.length;return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:c("toolsEnabled",{selected:a.length,total:Qn.length})}),(0,B.jsx)("button",{type:"button",onClick:()=>{b(f?[]:[...Qn])},className:"text-xs text-primary hover:underline",children:f?c("deselectAll"):c("selectAll")})]}),(0,B.jsx)("div",{className:"space-y-4",children:d.map(a=>{let d=a.tools.filter(a=>e.has(a)).length===a.tools.length;return(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,B.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:a.label}),(0,B.jsx)("button",{type:"button",onClick:()=>{let c=new Set(e);d?a.tools.forEach(a=>c.delete(a)):a.tools.forEach(a=>c.add(a)),b(Qn.filter(a=>c.has(a)))},className:"text-xs text-primary hover:underline",children:d?c("deselect"):c("selectAll")})]}),(0,B.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tools.map(a=>{let c=e.has(a);return(0,B.jsx)("button",{type:"button",onClick:()=>{let c;(c=new Set(e)).has(a)?c.delete(a):c.add(a),b(Qn.filter(a=>c.has(a)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${c?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:a},a)})})]},a.key)})}),g&&(0,B.jsx)("p",{className:"text-xs text-destructive",children:c("noToolsWarning")})]})}function QC({title:a,description:b,children:c,error:d,dirty:e,saving:f,onSave:g}){let h=(0,E.useTranslations)("bankConfig");return(0,B.jsxs)("section",{className:"space-y-3",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h2",{className:"text-lg font-semibold",children:a}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:b})]}),(0,B.jsxs)(by.Card,{className:"bg-muted/20 border-border/40",children:[(0,B.jsx)("div",{className:"divide-y divide-border/40",children:c}),d&&(0,B.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,B.jsxs)(Qj,{variant:"destructive",children:[(0,B.jsx)(Ql,{className:"h-4 w-4"}),(0,B.jsx)(Qk,{children:d})]})}),(0,B.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,B.jsx)(W.Button,{size:"sm",disabled:!e||f,onClick:g,children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"h-4 w-4 mr-2 animate-spin"}),h("saving")]}):h("saveChanges")})})]})]})}function QD({label:a,description:b,children:c}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsx)("div",{className:"md:w-64 shrink-0",children:c})]})})}function QE({label:a,description:b,value:c,onChange:d,placeholder:e,rows:f}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsx)(J2.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function QF({label:a,description:b,lowLabel:c,highLabel:d,value:e,onChange:f}){return(0,B.jsx)("div",{className:"px-6 py-4",children:(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,B.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:c}),(0,B.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>(0,B.jsx)("button",{type:"button",onClick:()=>f(a),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${a<=e?"bg-primary":"bg-muted"}`},a))}),d&&(0,B.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:d}),(0,B.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[e,"/5"]})]})]})})}function QG({fields:a,onChange:b,depth:c,extraControls:d,examplePrefix:e}){let f=(0,E.useTranslations)("bankConfig"),g={text:f("fieldTypeText"),value:f("fieldTypeValue"),"multi-values":f("fieldTypeMultiValues"),map:f("fieldTypeMap")},[h,i]=(0,C.useState)({}),j=(c,d)=>{let e={};for(let[b,f]of Object.entries(a))e[b]=b===c?{...f,...d}:f;b(e)},k=0===c;return(0,B.jsxs)("div",{className:k?"space-y-1.5 py-1":"space-y-1.5 py-1 ml-3 border-l-2 border-border/40 pl-3",children:[0===Object.keys(a).length&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground italic",children:f("noFieldsYet")}),Object.entries(a).map(([l,n],o)=>{let p="map"===n.type,q="value"===n.type||"multi-values"===n.type,r=h[o]??!0,s=p||q;return(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[s?(0,B.jsx)("button",{type:"button",onClick:()=>i(a=>({...a,[o]:!r})),className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted/50",children:r?(0,B.jsx)(JC.ChevronDown,{className:"h-3.5 w-3.5"}):(0,B.jsx)(Q.ChevronRight,{className:"h-3.5 w-3.5"})}):(0,B.jsx)("span",{className:"w-[18px] shrink-0"}),(0,B.jsx)(X.Input,{placeholder:f("fieldNamePlaceholder"),value:l,onChange:c=>((c,d)=>{let e={};for(let[b,f]of Object.entries(a))e[b===c?d:b]=f;b(e)})(l,c.target.value),className:"h-7 text-xs font-mono w-28 shrink-0"}),(0,B.jsx)(X.Input,{placeholder:f("extractorHintWhatPlaceholder"),value:n.description,onChange:a=>j(l,{description:a.target.value}),className:"h-7 text-xs flex-1 min-w-0"}),(0,B.jsxs)(bb.Select,{value:n.type,onValueChange:a=>j(l,{type:a,..."map"===a?{fields:n.fields??{},values:void 0}:{},..."text"===a?{fields:void 0,values:void 0}:{},..."value"===a||"multi-values"===a?{fields:void 0,values:n.values??[]}:{}}),children:[(0,B.jsx)(bb.SelectTrigger,{className:"h-7 text-xs w-[120px] shrink-0 px-2 py-0",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:Object.entries(g).map(([a,b])=>(0,B.jsx)(bb.SelectItem,{value:a,className:"text-xs",children:b},a))})]}),d,(0,B.jsx)("button",{type:"button",onClick:()=>{let c;return c={...a},void(delete c[l],b(c))},className:"text-muted-foreground hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10",children:(0,B.jsx)(JA,{className:"h-3.5 w-3.5"})})]}),k&&e&&l&&(0,B.jsx)("div",{className:"ml-[18px] pl-1.5",children:(0,B.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground/60 leading-none",children:"map"===n.type&&n.fields&&Object.keys(n.fields).length>0?`e.g. ${Object.keys(n.fields).slice(0,2).map(a=>`${e}:${a}:<value>`).join(", ")}`:"text"===n.type?`e.g. ${e}:<any text>`:(n.values?.length??0)>0?`e.g. ${e}:${n.values[0].value||"<value>"}`:`e.g. ${e}:<value>`})}),r&&p&&(0,B.jsx)(QG,{fields:n.fields??{},onChange:a=>j(l,{fields:a}),depth:c+1,examplePrefix:e?`${e}:${l}`:void 0}),r&&q&&(0,B.jsxs)("div",{className:"ml-6 space-y-0.5 py-1",children:[0===(n.values??[]).length&&(0,B.jsx)("p",{className:"text-[11px] text-muted-foreground italic",children:f("noValuesYet")}),(n.values??[]).map((a,b)=>(0,B.jsxs)("div",{className:"flex items-center gap-1.5 group/val",children:[(0,B.jsx)("span",{className:"text-muted-foreground/50 text-[10px] shrink-0",children:"•"}),(0,B.jsx)(X.Input,{placeholder:f("addValueShort"),value:a.value,onChange:c=>{let d=[...n.values??[]];d[b]={...a,value:c.target.value},j(l,{values:d})},className:"h-6 text-[11px] font-mono w-24 shrink-0 border-dashed"}),(0,B.jsx)(X.Input,{placeholder:f("extractorHintWhichPlaceholder"),value:a.description,onChange:c=>{let d=[...n.values??[]];d[b]={...a,description:c.target.value},j(l,{values:d})},className:"h-6 text-[11px] flex-1 min-w-0 border-dashed"}),(0,B.jsx)("button",{type:"button",onClick:()=>{j(l,{values:(n.values??[]).filter((a,c)=>c!==b)})},className:"text-muted-foreground/40 hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10 opacity-0 group-hover/val:opacity-100 transition-opacity",children:(0,B.jsx)(JA,{className:"h-3 w-3"})})]},b)),(0,B.jsxs)("button",{type:"button",onClick:()=>{j(l,{values:[...n.values??[],{value:"",description:""}]})},className:"text-[11px] text-muted-foreground/60 hover:text-foreground inline-flex items-center gap-1 ml-2.5",children:[(0,B.jsx)(I$.Plus,{className:"h-2.5 w-2.5"}),f("addValueShort")]})]})]},o)}),(0,B.jsxs)("button",{type:"button",onClick:()=>{b({...a,"":{type:"text",description:""}})},className:"text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",children:[(0,B.jsx)(I$.Plus,{className:"h-3 w-3"}),f("addField")]})]})}function QH({value:a,onChange:b}){let c=(0,E.useTranslations)("entityLabelsEditor"),d=(c,d)=>{b(a.map((a,b)=>b===c?{...a,...d}:a))};return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm font-medium",children:c("entityLabelsTitle")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("entityLabelsDescription")})]}),a.length>0&&(0,B.jsx)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:c("labelCount",{count:a.length})})]}),0===a.length&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground italic",children:c("noEntityLabelsDefined")}),(0,B.jsx)("div",{className:"space-y-2",children:a.map((e,f)=>(0,B.jsx)("div",{className:"border border-border/50 rounded-md bg-background",children:(0,B.jsx)(QG,{fields:{[e.key]:{type:e.type,description:e.description,values:e.values,fields:e.fields}},onChange:c=>{let e=Object.entries(c);if(0===e.length)b(a.filter((a,b)=>b!==f));else{let[a,b]=e[0];d(f,{key:a,type:b.type,description:b.description,values:b.values??[],fields:b.fields??{}})}},depth:0,extraControls:(0,B.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",title:c("alsoStoreAsTagTooltip"),children:[(0,B.jsx)(I4.Checkbox,{checked:e.tag,onCheckedChange:a=>d(f,{tag:!!a}),className:"h-4 w-4"}),c("plusTag")]}),examplePrefix:e.key})},f))}),(0,B.jsxs)("button",{type:"button",onClick:()=>{b([...a,{key:"",description:"",type:"value",optional:!0,tag:!1,values:[],fields:{}}])},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,B.jsx)(I$.Plus,{className:"h-3.5 w-3.5"}),c("addLabel")]})]})}function QI({value:a,onChange:b}){let c=(0,E.useTranslations)("bankConfig"),d=[{value:"HARM_CATEGORY_HARASSMENT",label:c("geminiCategoryHarassment")},{value:"HARM_CATEGORY_HATE_SPEECH",label:c("geminiCategoryHateSpeech")},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:c("geminiCategorySexuallyExplicit")},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:c("geminiCategoryDangerousContent")}],e=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:c("geminiThresholdUnspecified")},{value:"OFF",label:c("geminiThresholdOff")},{value:"BLOCK_NONE",label:c("geminiThresholdBlockNone")},{value:"BLOCK_LOW_AND_ABOVE",label:c("geminiThresholdBlockLowAndAbove")},{value:"BLOCK_MEDIUM_AND_ABOVE",label:c("geminiThresholdBlockMediumAndAbove")},{value:"BLOCK_ONLY_HIGH",label:c("geminiThresholdBlockOnlyHigh")}],f=b=>a.find(a=>a.category===b)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,B.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,B.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c("geminiSafetyEditorDescriptionPart1")," ",(0,B.jsx)("a",{href:"https://ai.google.dev/gemini-api/docs/safety-settings",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",children:c("geminiSafetyEditorLearnMore")})]}),(0,B.jsx)("div",{className:"space-y-2",children:d.map(a=>(0,B.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,B.jsx)("span",{className:"text-sm",children:a.label}),(0,B.jsxs)(bb.Select,{value:f(a.value),onValueChange:c=>{var e;return e=a.value,void b(d.map(a=>({category:a.value,threshold:a.value===e?c:f(a.value)})))},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:e.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}var bh=bh;let QJ="sensitive_data";function QK(){return{enabled:!1,rules:[]}}function QL(a){let b=a?.memory_defense;return b&&"object"==typeof b?{enabled:!!b.enabled,rules:Array.isArray(b.rules)?b.rules.filter(a=>a&&"string"==typeof a.on&&a.on===QJ).map(a=>{var b;return{on:a.on,action:"allow"===(b=a.action??"redact")||"redact"===b||"block"===b?b:"block"}}):[]}:QK()}function QM(a,b){return a.find(a=>a.on===b)}function QN(a,b){return[...a.filter(a=>a.on!==b.on),b]}function QO(a){return{enabled:a.enabled,rules:a.rules.map(a=>({on:a.on,action:a.action}))}}function QP({bankId:a}){let b=(0,E.useTranslations)("bankConfig"),[c,d]=(0,C.useState)(!0),[e,f]=(0,C.useState)({}),[g,h]=(0,C.useState)(QK()),[i,j]=(0,C.useState)(!1),k=(0,C.useMemo)(()=>QL(e),[e]),l=(0,C.useMemo)(()=>JSON.stringify(QO(g))!==JSON.stringify(QO(k)),[g,k]);(0,C.useEffect)(()=>{let c=!1;return(async()=>{d(!0);try{let b=await V.client.getBankConfig(a);if(c)return;f(b.config),h(QL(b.config))}catch(a){c||F.toast.error(a?.message||b("memoryDefenseFailedToSave"))}finally{c||d(!1)}})(),()=>{c=!0}},[a,b]);let n=g.enabled,o=(0,C.useRef)(null),p=(0,C.useRef)(!0);(0,C.useEffect)(()=>{if(!c){if(p.current){p.current=!1;return}if(l)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{q()},800),()=>{o.current&&clearTimeout(o.current)}}},[g,c]);let q=async()=>{j(!0);try{let b=QO(g),c=await V.client.updateBankConfig(a,{memory_defense:b});f(c.config)}catch(c){let a=c?.message||b("memoryDefenseFailedToSave");F.toast.error(a)}finally{j(!1)}},r=QM(g.rules,QJ);return c?(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(bh.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,B.jsxs)("section",{className:"space-y-6",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between gap-6",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("h2",{className:"text-lg font-semibold",children:b("memoryDefenseTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:b("memoryDefenseDescription")})]}),(0,B.jsx)("div",{className:"shrink-0 pt-1 scale-125 origin-right",children:(0,B.jsx)(ba.Switch,{checked:n,onCheckedChange:a=>h(b=>({...b,enabled:a}))})})]}),(0,B.jsx)("div",{className:n?"space-y-6":"space-y-6 opacity-40 pointer-events-none select-none","aria-disabled":!n,children:(0,B.jsx)("div",{className:"space-y-3",children:(0,B.jsx)(by.Card,{className:"bg-muted/20 border-border/40",children:(0,B.jsx)(QU,{title:b("memoryDefenseSecretLeakTitle"),description:b("memoryDefenseSecretLeakDescription"),rule:r,actions:["redact","block","allow"],onToggle:a=>h(b=>{var c;let d=QM(b.rules,QJ),e=d?.action??"redact";return{...b,rules:a?QN(b.rules,{on:QJ,action:e}):(c=b.rules,c.filter(a=>a.on!==QJ))}}),onActionChange:a=>h(b=>{let c=QM(b.rules,QJ);return c?{...b,rules:QN(b.rules,{...c,action:a})}:b}),masterEnabled:n})})})}),(0,B.jsx)(QQ,{}),i&&(0,B.jsxs)("div",{className:"flex justify-end items-center gap-2 text-xs text-muted-foreground",children:[(0,B.jsx)(bh.default,{className:"h-3.5 w-3.5 animate-spin"}),b("saving")]})]})}function QQ(){let a=(0,E.useTranslations)("bankConfig"),b=[a("memoryDefenseEnterpriseFeatureDetectSecrets"),a("memoryDefenseEnterpriseFeatureBase64"),a("memoryDefenseEnterpriseFeatureLlm"),a("memoryDefenseEnterpriseFeaturePromptInjection"),a("memoryDefenseEnterpriseFeatureSizeAnomaly"),a("memoryDefenseEnterpriseFeatureProtectedKeys")];return(0,B.jsxs)("div",{className:"rounded-xl border border-emerald-600/15 bg-emerald-500/[0.04] dark:bg-emerald-400/[0.06] p-6 flex flex-col gap-4",children:[(0,B.jsxs)("div",{className:"flex items-start gap-3",children:[(0,B.jsx)("div",{className:"rounded-full bg-emerald-500/10 p-2 shrink-0",children:(0,B.jsx)(L,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"})}),(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)("p",{className:"text-base font-semibold text-foreground",children:a("memoryDefenseEnterpriseTitle")}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a("memoryDefenseEnterpriseSubtitle")})]})]}),(0,B.jsx)("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1.5 text-sm text-foreground",children:b.map(a=>(0,B.jsxs)("li",{className:"flex items-start gap-2",children:[(0,B.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400 mt-0.5",children:"✓"}),(0,B.jsx)("span",{children:a})]},a))}),(0,B.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4",children:(0,B.jsxs)("a",{href:"https://calendly.com/d/ctw6-byb-3kg",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 rounded-md bg-emerald-600 hover:bg-emerald-700 text-white text-sm font-semibold px-4 py-2.5 transition-colors w-full sm:w-auto",children:[a("memoryDefenseEnterpriseCta"),(0,B.jsx)("span",{"aria-hidden":!0,children:"→"})]})})]})}function QR({title:a,description:b,headerSummary:c,headerControl:d,children:e}){let f=(Array.isArray(e)?e.flat(1/0).filter(Boolean):e?[e]:[]).length>0;return(0,B.jsxs)("div",{className:"px-6 py-4",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,B.jsx)("p",{className:"text-sm font-semibold",children:a}),c&&(0,B.jsx)("span",{className:"text-[10px] font-bold tracking-[0.1em] text-primary uppercase px-1.5 py-0.5 rounded bg-primary/10",children:c})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),d&&(0,B.jsx)("div",{className:"shrink-0 pt-0.5",children:d})]}),f&&(0,B.jsx)("div",{className:"mt-4 space-y-3",children:e})]})}function QS({label:a,description:b,children:c}){return(0,B.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,B.jsxs)("div",{className:"flex-1",children:[(0,B.jsx)(aA,{className:"text-sm font-medium",children:a}),b&&(0,B.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:b})]}),(0,B.jsx)("div",{className:"shrink-0",children:c})]})}function QT({value:a,onChange:b,options:c,t:d}){return(0,B.jsxs)(bb.Select,{value:a,onValueChange:a=>b(a),children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px]",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:d(`memoryDefenseAction_${a}`)},a))})]})}function QU({title:a,description:b,rule:c,actions:d,onActionChange:e,onToggle:f,masterEnabled:g}){let h=(0,E.useTranslations)("bankConfig"),i=!!c,j=g&&i,k=j?h(`memoryDefenseAction_${c.action}`):null;return(0,B.jsx)(QR,{title:a,description:b,headerSummary:k,headerControl:(0,B.jsx)(ba.Switch,{checked:j,onCheckedChange:f}),children:j&&d.length>1&&(0,B.jsx)(QS,{label:h("memoryDefenseActionLabel"),children:(0,B.jsx)(QT,{value:c.action,onChange:e,options:d,t:h})})})}let QV=(0,K.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),QW=(0,K.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var QX=a.i(67511),QX=QX;let QY=(0,K.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),QZ=(0,K.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q$=["x1","y1","x2","y2","key"],Q_=["offset"],Q0=["xAxisId","yAxisId"],Q1=["xAxisId","yAxisId"];function Q2(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function Q3(a){for(var b=1;b<arguments.length;b++){var c=null!=arguments[b]?arguments[b]:{};b%2?Q2(Object(c),!0).forEach(function(b){var d,e,f;d=a,e=b,f=c[b],(e=function(a){var b=function(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}(a,"string");return"symbol"==typeof b?b:b+""}(e))in d?Object.defineProperty(d,e,{value:f,enumerable:!0,configurable:!0,writable:!0}):d[e]=f}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(c)):Q2(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}return a}function Q4(){return(Q4=Object.assign.bind()).apply(null,arguments)}function Q5(a,b){if(null==a)return{};var c,d,e=function(a,b){if(null==a)return{};var c={};for(var d in a)if(({}).hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&({}).propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}var Q6=a=>{var{fill:b}=a;if(!b||"none"===b)return null;var{fillOpacity:c,x:d,y:e,width:f,height:g,ry:h}=a;return C.createElement("rect",{x:d,y:e,ry:h,width:f,height:g,stroke:"none",fill:b,fillOpacity:c,className:"recharts-cartesian-grid-bg"})};function Q7(a){var{option:b,lineItemProps:c}=a;if(C.isValidElement(b))d=C.cloneElement(b,c);else if("function"==typeof b)d=b(c);else{var d,e,{x1:f,y1:g,x2:h,y2:i,key:j}=c,k=null!=(e=p5(Q5(c,Q$)))?e:{},{offset:l}=k,n=Q5(k,Q_);d=C.createElement("line",Q4({},n,{x1:f,y1:g,x2:h,y2:i,fill:"none",key:j}))}return d}function Q8(a){var{x:b,width:c,horizontal:d=!0,horizontalPoints:e}=a;if(!d||!e||!e.length)return null;var{xAxisId:f,yAxisId:g}=a,h=Q5(a,Q0),i=e.map((a,e)=>{var f=Q3(Q3({},h),{},{x1:b,y1:a,x2:b+c,y2:a,key:"line-".concat(e),index:e});return C.createElement(Q7,{key:"line-".concat(e),option:d,lineItemProps:f})});return C.createElement("g",{className:"recharts-cartesian-grid-horizontal"},i)}function Q9(a){var{y:b,height:c,vertical:d=!0,verticalPoints:e}=a;if(!d||!e||!e.length)return null;var{xAxisId:f,yAxisId:g}=a,h=Q5(a,Q1),i=e.map((a,e)=>{var f=Q3(Q3({},h),{},{x1:a,y1:b,x2:a,y2:b+c,key:"line-".concat(e),index:e});return C.createElement(Q7,{option:d,lineItemProps:f,key:"line-".concat(e)})});return C.createElement("g",{className:"recharts-cartesian-grid-vertical"},i)}function Ra(a){var{horizontalFill:b,fillOpacity:c,x:d,y:e,width:f,height:g,horizontalPoints:h,horizontal:i=!0}=a;if(!i||!b||!b.length||null==h)return null;var j=h.map(a=>Math.round(a+e-e)).sort((a,b)=>a-b);e!==j[0]&&j.unshift(0);var k=j.map((a,h)=>{var i=j[h+1]?j[h+1]-a:e+g-a;if(i<=0)return null;var k=h%b.length;return C.createElement("rect",{key:"react-".concat(h),y:a,x:d,height:i,width:f,stroke:"none",fill:b[k],fillOpacity:c,className:"recharts-cartesian-grid-bg"})});return C.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},k)}function Rb(a){var{vertical:b=!0,verticalFill:c,fillOpacity:d,x:e,y:f,width:g,height:h,verticalPoints:i}=a;if(!b||!c||!c.length)return null;var j=i.map(a=>Math.round(a+e-e)).sort((a,b)=>a-b);e!==j[0]&&j.unshift(0);var k=j.map((a,b)=>{var i=j[b+1]?j[b+1]-a:e+g-a;if(i<=0)return null;var k=b%c.length;return C.createElement("rect",{key:"react-".concat(b),x:a,y:f,width:i,height:h,stroke:"none",fill:c[k],fillOpacity:d,className:"recharts-cartesian-grid-bg"})});return C.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},k)}var Rc=(a,b)=>{var{xAxis:c,width:d,height:e,offset:f}=a;return fA(u$(Q3(Q3(Q3({},u3),c),{},{ticks:fB(c,!0),viewBox:{x:0,y:0,width:d,height:e}})),f.left,f.left+f.width,b)},Rd=(a,b)=>{var{yAxis:c,width:d,height:e,offset:f}=a;return fA(u$(Q3(Q3(Q3({},u3),c),{},{ticks:fB(c,!0),viewBox:{x:0,y:0,width:d,height:e}})),f.top,f.top+f.height,b)},Re={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:lf.grid};function Rf(a){var b=fj(fJ),c=fj(fK),d=gf(),e=Q3(Q3({},qK(a,Re)),{},{x:dN(a.x)?a.x:d.left,y:dN(a.y)?a.y:d.top,width:dN(a.width)?a.width:d.width,height:dN(a.height)?a.height:d.height}),{xAxisId:f,yAxisId:g,x:h,y:i,width:j,height:k,syncWithTicks:l,horizontalValues:n,verticalValues:o}=e,p=fV(),q=fj(a=>nc(a,"xAxis",f,p)),r=fj(a=>nc(a,"yAxis",g,p));if(!fv(j)||!fv(k)||!dN(h)||!dN(i))return null;var s=e.verticalCoordinatesGenerator||Rc,t=e.horizontalCoordinatesGenerator||Rd,{horizontalPoints:u,verticalPoints:v}=e;if((!u||!u.length)&&"function"==typeof t){var w=n&&n.length,x=t({yAxis:r?Q3(Q3({},r),{},{ticks:w?n:r.ticks}):void 0,width:null!=b?b:j,height:null!=c?c:k,offset:d},!!w||l);f$(Array.isArray(x),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof x,"]")),Array.isArray(x)&&(u=x)}if((!v||!v.length)&&"function"==typeof s){var y=o&&o.length,z=s({xAxis:q?Q3(Q3({},q),{},{ticks:y?o:q.ticks}):void 0,width:null!=b?b:j,height:null!=c?c:k,offset:d},!!y||l);f$(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof z,"]")),Array.isArray(z)&&(v=z)}return C.createElement(rn,{zIndex:e.zIndex},C.createElement("g",{className:"recharts-cartesian-grid"},C.createElement(Q6,{fill:e.fill,fillOpacity:e.fillOpacity,x:e.x,y:e.y,width:e.width,height:e.height,ry:e.ry}),C.createElement(Ra,Q4({},e,{horizontalPoints:u})),C.createElement(Rb,Q4({},e,{verticalPoints:v})),C.createElement(Q8,Q4({},e,{offset:d,horizontalPoints:u,xAxis:q,yAxis:r})),C.createElement(Q9,Q4({},e,{offset:d,verticalPoints:v,xAxis:q,yAxis:r}))))}Rf.displayName="CartesianGrid";let Rg=["1h","12h","1d","7d","30d","90d"],Rh=["created_at","mentioned_at","occurred_start"],Ri="#8b5cf6",Rj="#ec4899",Rk="#6366f1",Rl="var(--chart-5)",Rm="var(--muted-foreground)",Rn={world:{label:"World",color:Ri},experience:{label:"Experience",color:Rj},observation:{label:"Observations",color:Rk}};function Ro(a){if(a<1e3)return a.toString();if(a<1e6){let b=a/1e3;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}k`}if(a<1e9){let b=a/1e6;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}M`}let b=a/1e9;return`${b>=10?b.toFixed(0):b.toFixed(1).replace(/\.0$/,"")}B`}function Rp({value:a,className:b}){return(0,B.jsx)("span",{className:b,title:a.toLocaleString(),children:Ro(a)})}function Rq({active:a,payload:b,label:c,valueLabel:d}){return a&&b&&0!==b.length?(0,B.jsxs)("div",{className:"rounded-lg border border-border/60 bg-popover/95 backdrop-blur-sm px-3 py-2 shadow-md",children:[null!=c&&(0,B.jsx)("div",{className:"text-[11px] font-medium text-foreground mb-1.5",children:c}),(0,B.jsx)("div",{className:"space-y-1",children:b.map((a,b)=>(0,B.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:a.color||a.payload?.fill}}),(0,B.jsx)("span",{className:"text-muted-foreground",children:a.name||d||"Value"}),(0,B.jsx)("span",{className:"ml-auto pl-3 font-semibold tabular-nums text-foreground",children:(a.value??0).toLocaleString()})]},b))})]}):null}function Rr({children:a}){return(0,B.jsx)("h3",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em] mb-3",children:a})}function Rs(a,b){if(!a)return b?b("relativeTimeNever"):"Never";let c=Math.floor((Date.now()-new Date(a).getTime())/6e4);if(c<1)return b?b("relativeTimeJustNow"):"just now";if(c<60)return b?b("relativeTimeMinutes",{mins:c}):`${c}m ago`;let d=Math.floor(c/60);if(d<24)return b?b("relativeTimeHours",{hours:d}):`${d}h ago`;let e=Math.floor(d/24);return b?b("relativeTimeDays",{days:e}):`${e}d ago`}function Rt(a){return new Date(/[+Z-]$/.test(a)||/[+-]\d\d:?\d\d$/.test(a)?a:`${a}Z`)}function Ru({done:a,total:b,doneColor:c}){let d=Math.round(100*(b>0?a/b:0));return(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,B.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,B.jsx)("span",{className:"tabular-nums font-semibold text-foreground text-sm",children:a.toLocaleString()}),(0,B.jsxs)("span",{className:"text-muted-foreground",children:[" / ",b.toLocaleString()]})]}),(0,B.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-foreground",children:[d,"%"]})]}),(0,B.jsx)("div",{className:"h-1.5 w-full rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${d}%`,backgroundColor:c}})})]})}function Rv({title:a,items:b,emptyLabel:c}){let d=b.reduce((a,b)=>a+b.value,0);return(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:a}),(0,B.jsx)(Rp,{value:d,className:"text-xs text-muted-foreground tabular-nums"})]}),0===d?(0,B.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:c}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:b.filter(a=>a.value>0).map(a=>(0,B.jsx)("div",{className:"h-full",style:{width:`${a.value/d*100}%`,backgroundColor:a.color},title:`${a.name}: ${a.value.toLocaleString()}`},a.name))}),(0,B.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:b.map(a=>(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:a.color}}),(0,B.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:a.name})]}),(0,B.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,B.jsx)(Rp,{value:a.value,className:"text-base font-semibold tabular-nums"}),(0,B.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:d>0?`${(a.value/d*100).toFixed(0)}%`:"0%"})]})]},a.name))})]})]})}function Rw({icon:a,label:b,value:c}){return(0,B.jsxs)("div",{className:"flex items-center gap-3 p-4",children:[(0,B.jsx)("div",{className:"p-2 rounded-md bg-muted",children:(0,B.jsx)(a,{className:"w-4 h-4 text-muted-foreground"})}),(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:b}),(0,B.jsx)(Rp,{value:c,className:"text-2xl font-semibold text-foreground leading-tight tabular-nums block"})]})]})}let Rx=["completed","processing","pending","failed","cancelled"],Ry={completed:"#10b981",processing:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",cancelled:"#6b7280"},Rz={completed:"completed",processing:"processing",pending:"pending",failed:"failed",cancelled:"cancelled"};function RA({byStatus:a}){let b=(0,E.useTranslations)("bankStats"),c={completed:b("opsCompleted"),processing:b("opsProcessing"),pending:b("opsPending"),failed:b("opsFailed"),cancelled:b("opsCancelled")},d=Rx.map(b=>({status:b,label:c[b]??Rz[b],value:a[b]||0,color:Ry[b]}));for(let[b,c]of Object.entries(a))Rx.includes(b)||d.push({status:b,label:b,value:c,color:Rm});let e=d.reduce((a,b)=>a+b.value,0),f=d.filter(a=>a.value>0);return(0,B.jsxs)(by.Card,{children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,B.jsxs)(by.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,B.jsx)(bj,{className:"w-3.5 h-3.5 text-muted-foreground"}),b("operations")]}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,B.jsx)(Rp,{value:e})," ",b("totalSuffix")]})]}),(0,B.jsx)(by.CardContent,{children:0===e?(0,B.jsx)("div",{className:"h-[100px] flex items-center justify-center text-sm text-muted-foreground",children:b("noOperationsYet")}):(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:f.map(a=>(0,B.jsx)("div",{className:"h-full",style:{width:`${a.value/e*100}%`,backgroundColor:a.color},title:`${a.label}: ${a.value.toLocaleString()}`},a.status))}),(0,B.jsx)("div",{className:"space-y-1.5",children:f.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px] flex-shrink-0",style:{backgroundColor:a.color}}),(0,B.jsx)("span",{className:"text-muted-foreground flex-1",children:a.label}),(0,B.jsx)(Rp,{value:a.value,className:"font-semibold tabular-nums text-foreground"}),(0,B.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums w-9 text-right",children:[(a.value/e*100).toFixed(0),"%"]})]},a.status))})]})})]})}function RB({done:a,pending:b,failed:c,total:d,lastConsolidatedAt:e}){let f=(0,E.useTranslations)("bankStats"),[g,h]=(0,C.useState)(!1),i=c>0;return(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:f("consolidation")})}),(0,B.jsxs)(by.CardContent,{className:"space-y-4",children:[(0,B.jsx)(Ru,{done:a,total:d,doneColor:Rl}),(0,B.jsxs)("div",{className:"grid grid-cols-4 gap-3 pt-1",children:[(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QX.default,{className:"w-3 h-3 text-emerald-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("done")})]}),(0,B.jsx)(Rp,{value:a,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(Ql,{className:"w-3 h-3 text-amber-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("pending")})]}),(0,B.jsx)(Rp,{value:b,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,B.jsxs)("button",{type:"button",onClick:()=>i&&h(!0),disabled:!i,className:`text-left space-y-0.5 rounded-md -mx-1 px-1 py-0.5 transition-colors ${i?"cursor-pointer hover:bg-red-500/10 focus:outline-none focus:ring-2 focus:ring-red-500/40":"cursor-default"}`,title:i?f("viewFailedMemoriesLabel"):void 0,children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QY,{className:`w-3 h-3 ${i?"text-red-600 dark:text-red-400":"text-muted-foreground/50"}`}),(0,B.jsx)("span",{className:`text-[10px] uppercase tracking-wider font-medium ${i?"text-red-600 dark:text-red-400":"text-muted-foreground"}`,children:f("failed")})]}),(0,B.jsxs)("span",{className:`text-base font-semibold tabular-nums block ${i?"text-red-600 dark:text-red-400":"text-foreground"}`,children:[(0,B.jsx)(Rp,{value:c}),i&&(0,B.jsx)(QZ,{className:"inline w-3 h-3 ml-1 opacity-70"})]})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(af,{className:"w-3 h-3 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:f("last")})]}),(0,B.jsx)("span",{className:"text-base font-semibold text-foreground block leading-tight",children:Rs(e,f)})]})]})]}),(0,B.jsx)(RC,{open:g,onOpenChange:h})]})}function RC({open:a,onOpenChange:b}){let c=(0,E.useTranslations)("bankStats"),d=(0,E.useTranslations)("failedConsolidations"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)([]),[h,i]=(0,C.useState)(0),[j,k]=(0,C.useState)(!1),[l,n]=(0,C.useState)(!1),[o,p]=(0,C.useState)(0);(0,C.useEffect)(()=>{if(!a||!e)return;let b=!1;return k(!0),V.client.listMemories(e,{consolidationState:"failed",limit:200}).then(a=>{b||(g(a.items),i(a.total))}).catch(()=>{}).finally(()=>{b||k(!1)}),()=>{b=!0}},[a,e,o]);let q=async()=>{if(e){n(!0);try{let a=await V.client.recoverConsolidation(e);a.retried_count>0&&await V.client.triggerConsolidation(e),F.toast.success(d("recoverSuccess",{count:a.retried_count})),p(a=>a+1)}catch{}finally{n(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-4xl max-h-[80vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsxs)(bm.DialogTitle,{className:"flex items-center gap-2",children:[(0,B.jsx)(QY,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),d("title")]}),(0,B.jsx)(bm.DialogDescription,{children:d("description")})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 py-2",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:j?d("loading"):d("totalFailed",{total:h})}),(0,B.jsxs)(W.Button,{size:"sm",onClick:q,disabled:l||j||0===h,children:[(0,B.jsx)(ad,{className:`w-3.5 h-3.5 mr-1.5 ${l?"animate-spin":""}`}),d("recoverAll")]})]}),(0,B.jsx)("div",{className:"flex-1 min-h-0 overflow-auto border border-border rounded-md",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[140px]",children:d("colFailedAt")}),(0,B.jsx)(an,{className:"w-[100px]",children:d("colType")}),(0,B.jsx)(an,{children:d("colText")})]})}),(0,B.jsxs)(al,{children:[0===f.length&&!j&&(0,B.jsx)(am,{children:(0,B.jsx)(ao,{colSpan:3,className:"text-center text-muted-foreground py-8",children:d("noFailedConsolidations")})}),f.map(a=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"text-xs text-muted-foreground whitespace-nowrap",children:Rs(a.consolidation_failed_at,c)}),(0,B.jsx)(ao,{className:"text-xs capitalize",children:a.fact_type}),(0,B.jsxs)(ao,{className:"text-sm",children:[(0,B.jsx)("div",{className:"line-clamp-2",children:a.text}),a.context&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:a.context})]})]},a.id))]})]})})]})})}function RD({models:a,lastConsolidatedAt:b}){let c=(0,E.useTranslations)("bankStats"),d=a.length,e=b?new Date(b).getTime():0,f=a.filter(a=>!e||!!a.last_refreshed_at&&new Date(a.last_refreshed_at).getTime()>=e).length,g=d-f;return(0,B.jsxs)(by.Card,{children:[(0,B.jsx)(by.CardHeader,{className:"pb-2",children:(0,B.jsxs)(by.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,B.jsx)(J$,{className:"w-3.5 h-3.5 text-muted-foreground"}),c("mentalModels")]})}),(0,B.jsx)(by.CardContent,{className:"space-y-4",children:0===d?(0,B.jsx)("div",{className:"text-sm text-muted-foreground py-4",children:c("noMentalModels")}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ru,{done:f,total:d,doneColor:Rl}),(0,B.jsxs)("div",{className:"grid grid-cols-3 gap-3 pt-1",children:[(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(QX.default,{className:"w-3 h-3 text-emerald-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("upToDate")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:f})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(Ql,{className:"w-3 h-3 text-amber-500"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("stale")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:g})]}),(0,B.jsxs)("div",{className:"space-y-0.5",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,B.jsx)(J$,{className:"w-3 h-3 text-muted-foreground"}),(0,B.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:c("total")})]}),(0,B.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:d})]})]})]})})]})}let RE={fontSize:11,fill:Rm,fontWeight:500};function RF(){let a=(0,E.useTranslations)("bankStats"),b={created_at:{short:a("timeFieldIngestedShort"),long:a("timeFieldIngestedLong")},mentioned_at:{short:a("timeFieldMentionedShort"),long:a("timeFieldMentionedLong")},occurred_start:{short:a("timeFieldOccurredShort"),long:a("timeFieldOccurredLong")}},{currentBank:c}=(0,H.useBank)(),{features:d}=(0,I3.useFeatures)(),e=d?.observations??!1,[f,g]=(0,C.useState)(null),[h,i]=(0,C.useState)([]),[j,k]=(0,C.useState)(!1),[l,n]=(0,C.useState)("7d"),[o,p]=(0,C.useState)("created_at"),[q,r]=(0,C.useState)({trunc:"day",buckets:[]}),[s,t]=(0,C.useState)({world:!0,experience:!0,observation:!0}),u=async()=>{if(c){k(!0);try{let[a,b]=await Promise.all([V.client.getBankStats(c),V.client.listMentalModels(c)]);g(a),i(b.items||[])}catch(a){console.error("Error loading bank stats:",a)}finally{k(!1)}}},v=async()=>{if(c)try{let a=await V.client.getMemoriesTimeseries(c,l,o);r({trunc:a.trunc,buckets:a.buckets||[]})}catch(a){console.error("Error loading memories timeseries:",a)}};if((0,C.useEffect)(()=>{if(c){u();let a=setInterval(u,5e3);return()=>clearInterval(a)}},[c]),(0,C.useEffect)(()=>{if(c){v();let a=setInterval(v,5e3);return()=>clearInterval(a)}},[c,l,o]),j&&!f)return(0,B.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,B.jsx)(af,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})});if(!f)return null;let w=e?["world","experience","observation"]:["world","experience"],x=q.buckets.map(a=>{var b,c,d,e;let f,g;return{...a,label:(b=a.time,c=q.trunc,f=Rt(b),"day"===c?f.toLocaleDateString(void 0,{month:"short",day:"numeric"}):f.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})),tooltipLabel:(d=a.time,e=q.trunc,g=Rt(d),"day"===e?g.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):g.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}))}}),y=x.reduce((a,b)=>a+w.reduce((a,c)=>a+(s[c]&&b[c]||0),0),0),z=Math.max(0,f.total_nodes-f.pending_consolidation),A={world:a("world"),experience:a("experience"),observation:a("observations")};return(0,B.jsxs)("div",{className:"space-y-8",children:[(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("memoryStore")}),(0,B.jsx)(by.Card,{children:(0,B.jsxs)(by.CardContent,{className:"p-0",children:[(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 md:divide-x divide-y md:divide-y-0 divide-border/60",children:[(0,B.jsx)(Rw,{icon:M,label:a("memories"),value:f.total_nodes}),(0,B.jsx)(Rw,{icon:QW,label:a("documents"),value:f.total_documents}),(0,B.jsx)(Rw,{icon:QV,label:a("links"),value:f.total_links})]}),(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 md:divide-x divide-y md:divide-y-0 divide-border/60 border-t border-border/60",children:[(0,B.jsx)("div",{className:"p-5",children:(0,B.jsx)(Rv,{title:a("memoryComposition"),items:[{name:a("world"),value:f.nodes_by_fact_type?.world||0,color:Ri},{name:a("experience"),value:f.nodes_by_fact_type?.experience||0,color:Rj},...e?[{name:a("observations"),value:f.total_observations||0,color:Rk}]:[]],emptyLabel:a("noMemoriesYet")})}),(0,B.jsx)("div",{className:"p-5",children:(0,B.jsx)(Rv,{title:a("linkTypes"),items:[{name:a("temporal"),value:f.links_by_link_type?.temporal||0,color:"#009296"},{name:a("semantic"),value:f.links_by_link_type?.semantic||0,color:"#0074d9"},{name:a("entity"),value:f.links_by_link_type?.entity||0,color:"#f59e0b"}],emptyLabel:a("noLinksYet")})})]})]})})]}),(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("consolidation")}),(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,B.jsx)(RB,{done:z,pending:f.pending_consolidation,failed:f.failed_consolidation??0,total:f.total_nodes,lastConsolidatedAt:f.last_consolidated_at}),(0,B.jsx)(RD,{models:h,lastConsolidatedAt:f.last_consolidated_at})]})]}),(0,B.jsxs)("section",{children:[(0,B.jsx)(Rr,{children:a("activity")}),(0,B.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,B.jsxs)(by.Card,{className:"lg:col-span-2",children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 space-y-2",children:[(0,B.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:a("memoriesByTimeChartTitle",{field:b[o].short.toLowerCase()})}),(0,B.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:Rg.map(a=>(0,B.jsx)("button",{onClick:()=>n(a),className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors tabular-nums ${l===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a},a))})]}),(0,B.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5 w-fit",children:Rh.map(a=>(0,B.jsx)("button",{onClick:()=>p(a),title:b[a].long,className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors ${o===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:b[a].short},a))}),(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("div",{className:"flex items-center gap-1.5",children:w.map(a=>{let b=Rn[a],c=s[a];return(0,B.jsxs)("button",{onClick:()=>t(b=>({...b,[a]:!b[a]})),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[11px] font-medium transition-all ${c?"bg-muted text-foreground":"bg-transparent text-muted-foreground/60 hover:text-muted-foreground"}`,children:[(0,B.jsx)("span",{className:"w-2 h-2 rounded-[2px] transition-opacity",style:{backgroundColor:b.color,opacity:c?1:.3}}),A[a]]},a)})}),(0,B.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,B.jsx)(Rp,{value:y})," ",a("totalSuffix")]})]})]}),(0,B.jsx)(by.CardContent,{children:0===x.length||0===y?(0,B.jsx)("div",{className:"h-[180px] flex items-center justify-center text-sm text-muted-foreground",children:a("noMemoriesIngestedInPeriod")}):(0,B.jsx)("div",{className:"h-[180px]",children:(0,B.jsx)(gb,{width:"100%",height:"100%",children:(0,B.jsxs)(un,{data:x,margin:{top:8,right:8,bottom:0,left:-10},children:[(0,B.jsx)("defs",{children:w.map(a=>(0,B.jsxs)("linearGradient",{id:`grad-${a}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,B.jsx)("stop",{offset:"0%",stopColor:Rn[a].color,stopOpacity:.35}),(0,B.jsx)("stop",{offset:"100%",stopColor:Rn[a].color,stopOpacity:0})]},a))}),(0,B.jsx)(Rf,{vertical:!1,stroke:"var(--border)",strokeOpacity:.5,strokeDasharray:"2 4"}),(0,B.jsx)(vl,{dataKey:"label",tick:RE,axisLine:!1,tickLine:!1,dy:4,minTickGap:20}),(0,B.jsx)(vt,{tick:RE,axisLine:!1,tickLine:!1,width:40,allowDecimals:!1,tickFormatter:a=>Ro(a)}),(0,B.jsx)(v0,{content:(0,B.jsx)(Rq,{}),labelFormatter:(a,b)=>b?.[0]?.payload?.tooltipLabel||"",cursor:{stroke:Rm,strokeWidth:1,strokeDasharray:"3 3"}}),w.map(a=>s[a]?(0,B.jsx)(uT,{type:"monotone",dataKey:a,name:A[a],stackId:"a",stroke:Rn[a].color,strokeWidth:2,fill:`url(#grad-${a})`,isAnimationActive:!1},a):null)]})})})})]}),(0,B.jsx)(RA,{byStatus:f.operations_by_status||{}})]})]})]})}var bh=bh;let RG=(0,K.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),RH=(0,K.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),RI=["all","retain","consolidation","refresh_mental_model","file_convert_retain","webhook_delivery","graph_maintenance"],RJ=[null,"pending","processing","completed","failed","cancelled"];function RK(){let a,b,c,d=(0,E.useTranslations)("bankOperations"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)([]),[h,i]=(0,C.useState)(0),[j,k]=(0,C.useState)(null),[l,n]=(0,C.useState)(null),[o]=(0,C.useState)(10),[p,q]=(0,C.useState)(0),[r,s]=(0,C.useState)(null),[t,u]=(0,C.useState)(null),[v,w]=(0,C.useState)(!1),[x,y]=(0,C.useState)(null),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(null),[L,M]=(0,C.useState)(()=>Date.now()),N={all:d("status.all"),pending:d("status.pending"),processing:d("status.processing"),completed:d("status.completed"),failed:d("status.failed"),cancelled:d("status.cancelled")},O={all:d("operationType.all"),retain:d("operationType.retain"),consolidation:d("operationType.consolidation"),refresh_mental_model:d("operationType.refreshMentalModel"),file_convert_retain:d("operationType.fileConvertRetain"),webhook_delivery:d("operationType.webhookDelivery"),graph_maintenance:d("operationType.graphMaintenance")},P=a=>a?N[a]??a:d("unknown"),Q=a=>a?O[a]??a:d("notAvailable"),R=(a,b)=>{let c=P(a);return"pending"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),c]}):"processing"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:[(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}),c]}):"failed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",title:b??void 0,children:[(0,B.jsx)(Ql,{className:"w-3 h-3"}),c]}):"completed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),c]}):"cancelled"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-gray-500/10 text-gray-600 dark:text-gray-400 border border-gray-500/20",children:[(0,B.jsx)(RH,{className:"w-3 h-3"}),c]}):(0,B.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:c})},S=a=>{let b=new Date(a).getTime();if(Number.isNaN(b))return"";let c=Math.max(0,Math.round((L-b)/1e3));return c<5?d("heartbeat.justNow"):c<60?d("heartbeat.secondsAgo",{secs:c}):c<3600?d("heartbeat.minutesAgo",{mins:Math.floor(c/60)}):d("heartbeat.hoursAgo",{hours:Math.floor(c/3600)})},T=(a,b)=>{if(!a)return null;let c=a.stage.replace(/[._]/g," "),e="number"==typeof a.processed&&"number"==typeof a.total&&a.total>0,f=e?Math.min(100,Math.round(a.processed/a.total*100)):null,g=a.at?S(a.at):null;return b?.compact?(0,B.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground whitespace-nowrap",title:`${c}${a.at?` — ${new Date(a.at).toLocaleString()}`:""}`,children:[null!==f&&(0,B.jsx)("span",{className:"h-1 w-14 shrink-0 rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("span",{className:"block h-full rounded-full bg-blue-500/70",style:{width:`${f}%`}})}),e&&(0,B.jsxs)("span",{className:"font-mono",children:[a.processed,"/",a.total]}),g&&(0,B.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",g]})]}):(0,B.jsxs)("div",{className:"mt-1 space-y-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,B.jsx)("span",{className:"capitalize",children:c}),e&&(0,B.jsxs)("span",{className:"font-mono",children:[a.processed,"/",a.total]})]}),null!==f&&(0,B.jsx)("div",{className:"h-1 w-24 rounded-full bg-muted overflow-hidden",children:(0,B.jsx)("div",{className:"h-full rounded-full bg-blue-500/70",style:{width:`${f}%`}})}),a.at&&(0,B.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground/80",title:new Date(a.at).toLocaleString(),children:[(0,B.jsx)(af,{className:"w-2.5 h-2.5"}),(0,B.jsxs)("span",{children:[d("field.lastHeartbeat")," · ",S(a.at)]})]})]})},U=(0,C.useCallback)(async(a=j,b=p,c=l)=>{if(e){w(!0);try{let d=await V.client.listOperations(e,{status:a||void 0,type:c||void 0,limit:o,offset:b,excludeParents:!0});g(d.operations||[]),i(d.total||0),M(Date.now())}catch(a){console.error("Error loading operations:",a)}finally{w(!1)}}},[e,j,p,l,o]),X=a=>{q(a),U(j,a,l)},Y=async a=>{if(e){s(a);try{await V.client.cancelOperation(e,a),await U()}catch(a){}finally{s(null)}}},Z=async a=>{if(e){u(a);try{await V.client.retryOperation(e,a),await U()}catch(a){}finally{u(null)}}},$=async a=>{if(e){F(!0),A(!0),K(null);try{let b=await V.client.getOperationStatus(e,a);y(b)}catch(a){console.error("Error loading operation details:",a),y({error:d("operationDetailsLoadError")})}finally{F(!1)}}},_=async()=>{if(e&&x?.operation_id){I(!0);try{let a=x.operation_id,b=await V.client.getOperationStatus(e,a,{includePayload:!0});y(b),K(a)}catch(a){console.error("Error loading raw payload:",a)}finally{I(!1)}}},aa=f.some(a=>"processing"===a.status);(0,C.useEffect)(()=>{if(e){U(j,p,l);let a=setInterval(()=>U(j,p,l),aa?2e3:5e3);return()=>clearInterval(a)}},[e,j,p,l,aa,U]),(0,C.useEffect)(()=>{if(!aa)return;let a=setInterval(()=>M(Date.now()),1e3);return()=>clearInterval(a)},[aa]);let ab=(0,C.useRef)({}),[ac,ag]=(0,C.useState)(new Set);return((0,C.useEffect)(()=>{let a=ab.current,b=f.filter(b=>a[b.id]&&a[b.id]!==b.status&&("completed"===b.status||"failed"===b.status||"cancelled"===b.status)).map(a=>a.id);if(ab.current=Object.fromEntries(f.map(a=>[a.id,a.status])),0===b.length)return;ag(a=>new Set([...a,...b]));let c=setTimeout(()=>ag(a=>{let c=new Set(a);return b.forEach(a=>c.delete(a)),c}),1200);return()=>clearTimeout(c)},[f]),e)?(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-lg font-semibold",children:d("title")}),(0,B.jsx)("button",{onClick:()=>U(),className:"p-1 rounded hover:bg-muted transition-colors",title:d("refreshOperations"),disabled:v,children:(0,B.jsx)(ad,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${v?"animate-spin":""}`})})]}),(0,B.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d("operationCount",{count:h}),j?` (${P(j)})`:""]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsxs)(bb.Select,{value:l??"all",onValueChange:a=>{var b;n(b="all"===a?null:a),q(0),U(j,0,b)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,B.jsx)(bb.SelectValue,{placeholder:d("allTypes")})}),(0,B.jsx)(bb.SelectContent,{children:RI.map(a=>(0,B.jsx)(bb.SelectItem,{value:a,children:(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{children:O[a]}),"all"!==a&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:a})]})},a))})]}),(0,B.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:RJ.map(a=>(0,B.jsx)("button",{onClick:()=>{k(a),q(0),U(a,0,l)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${j===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a?P(a):N.all},a??"all"))})]})]}),(0,B.jsx)("div",{children:f.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[100px]",children:d("table.id")}),(0,B.jsx)(an,{children:d("table.type")}),(0,B.jsx)(an,{children:d("table.created")}),(0,B.jsx)(an,{children:d("field.updated")}),(0,B.jsx)(an,{className:"w-[300px]",children:d("table.status")}),(0,B.jsx)(an,{className:"w-[110px]",children:d("table.actions")})]})}),(0,B.jsx)(al,{children:f.map(a=>(0,B.jsxs)(am,{className:`cursor-pointer transition-colors duration-700 hover:bg-muted/50 ${ac.has(a.id)?"completed"===a.status?"bg-emerald-500/15":"bg-red-500/15":"failed"===a.status?"bg-red-500/5":""}`,onClick:()=>$(a.id),children:[(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.id.substring(0,8)}),(0,B.jsx)(ao,{className:"font-medium",title:a.task_type,children:Q(a.task_type)}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",children:new Date(a.created_at).toLocaleString()}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",title:a.updated_at?new Date(a.updated_at).toLocaleString():void 0,children:a.updated_at?S(a.updated_at):"—"}),(0,B.jsx)(ao,{className:"w-[300px]",children:(0,B.jsxs)("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[R(a.status,a.error_message),"processing"===a.status&&T(a.progress,{compact:!0})]})}),(0,B.jsxs)(ao,{className:"w-[110px] whitespace-nowrap",children:["pending"===a.status&&(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:b=>{b.stopPropagation(),Y(a.id)},disabled:r===a.id,children:[r===a.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(bg.X,{className:"w-3 h-3 mr-1"}),r===a.id?"":d("action.cancel")]}),("failed"===a.status||"cancelled"===a.status)&&(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:b=>{b.stopPropagation(),Z(a.id)},disabled:t===a.id,children:[t===a.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(bk,{className:"w-3 h-3 mr-1"}),t===a.id?"":d("action.retry")]})]})]},a.id))})]})}),h>o&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:d("pagination",{start:p+1,end:Math.min(p+o,h),total:h})}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>X(Math.max(0,p-o)),disabled:0===p,children:d("paginationPrevious")}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>X(p+o),disabled:p+o>=h,children:d("paginationNext")})]})]})]}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:j?d("emptyStateWithStatus",{status:P(j)}):d("emptyState")})}),(0,B.jsx)(bm.Dialog,{open:z,onOpenChange:A,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("operationDetails")}),(0,B.jsx)(bm.DialogDescription,{children:x?.operation_id&&(0,B.jsx)("span",{className:"font-mono text-xs",children:x.operation_id})})]}),D?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)(bh.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):x?(0,B.jsx)("div",{className:"space-y-4",children:x.error?(0,B.jsx)("div",{className:"text-red-600 dark:text-red-400",children:x.error}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.status")}),(0,B.jsx)("div",{className:"mt-1",children:R(x.status)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.type")}),(0,B.jsx)("div",{className:"mt-1 font-mono text-sm",title:x.operation_type??void 0,children:Q(x.operation_type)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.created")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.created_at?new Date(x.created_at).toLocaleString():d("notAvailable")})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.updated")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.updated_at?new Date(x.updated_at).toLocaleString():d("notAvailable")})]}),x.completed_at&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("field.completed")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:new Date(x.completed_at).toLocaleString()})]}),x.result_metadata?.items_count!==void 0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("totalItems")}),(0,B.jsx)("div",{className:"mt-1 text-sm",children:x.result_metadata.items_count})]})]}),"processing"===x.status&&x.progress&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:d("field.progress")}),T(x.progress),"consolidation"===x.operation_type&&(0,B.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/70",children:d("progressEstimateNote")})]}),("pending"===x.status||"failed"===x.status||"cancelled"===x.status)&&(0,B.jsxs)("div",{className:"flex gap-2",children:["pending"===x.status&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Y(x.operation_id),disabled:r===x.operation_id,children:[r===x.operation_id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,B.jsx)(bg.X,{className:"w-3 h-3 mr-1"}),d("action.cancel")]}),("failed"===x.status||"cancelled"===x.status)&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Z(x.operation_id),disabled:t===x.operation_id,children:[t===x.operation_id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,B.jsx)(bk,{className:"w-3 h-3 mr-1"}),d("action.retry")]})]}),x.result_metadata&&Object.keys(x.result_metadata).length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("metadata")}),(0,B.jsx)("pre",{className:"rounded-lg border bg-muted/30 p-3 text-xs font-mono overflow-x-auto max-h-96 whitespace-pre-wrap break-words",children:JSON.stringify(x.result_metadata,null,2)})]}),x.error_message&&(0,B.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,B.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:d("error")}),(0,B.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:x.error_message})]}),x.child_operations&&x.child_operations.length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("subBatchesCount",{count:x.result_metadata?.num_sub_batches||x.child_operations.length})}),(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[60px]",children:d("table.index")}),(0,B.jsx)(an,{className:"w-[100px]",children:d("table.id")}),(0,B.jsx)(an,{className:"w-[80px]",children:d("table.items")}),(0,B.jsx)(an,{children:d("table.status")})]})}),(0,B.jsx)(al,{children:x.child_operations.map(a=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"text-sm",children:a.sub_batch_index}),(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.operation_id.substring(0,8)}),(0,B.jsx)(ao,{className:"text-sm",children:a.items_count}),(0,B.jsx)(ao,{children:R(a.status,a.error_message)})]},a.operation_id))})]})]}),(a=J===x.operation_id,b=!!x.task_payload,c=!!x.result_metadata?.is_parent,(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,B.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:d("rawPayload")}),!a&&(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:_,disabled:G,children:[G?(0,B.jsx)(bh.default,{className:"w-3 h-3 mr-1 animate-spin"}):(0,B.jsx)(RG,{className:"w-3 h-3 mr-1"}),d("loadRaw")]})]}),b?(0,B.jsx)("pre",{className:"rounded-lg border bg-muted/30 p-3 text-xs font-mono overflow-x-auto max-h-96 whitespace-pre-wrap break-words",children:JSON.stringify(x.task_payload,null,2)}):a?(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:c?d("rawPayloadParentHelp"):d("rawPayloadEmpty")}):(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("rawPayloadHelp")})]}))]})}):null]})})]}):null}var bh=bh;let RL=(0,K.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);function RM(){let a=(0,E.useTranslations)("mentalModels"),{currentBank:b}=(0,H.useBank)(),[c,d]=(0,C.useState)([]),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)("files"),[i,j]=(0,C.useState)(""),[k,l]=(0,C.useState)(1),[n,o]=(0,C.useState)(!1),[p,q]=(0,C.useState)(null),[r,s]=(0,C.useState)(null),[t,u]=(0,C.useState)([]),[v,w]=(0,C.useState)("any"),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(null),[D,G]=(0,C.useState)(null),[I,J]=(0,C.useState)(!1),[K,M]=(0,C.useState)(null),[N,O]=(0,C.useState)(!1),R=c.filter(a=>{if(!i)return!0;let b=i.toLowerCase();return a.id.toLowerCase().includes(b)||a.name.toLowerCase().includes(b)||a.source_query.toLowerCase().includes(b)||a.content.toLowerCase().includes(b)}),S=async()=>{if(b){f(!0);try{let a=await V.client.listMentalModels(b,t.length>0?t:void 0,t.length>0?v:void 0);d(a.items||[])}catch(a){console.error("Error loading mental models:",a)}finally{f(!1)}}},[T,U]=(0,C.useState)(new Set),Y=async c=>{if(!b)return;let e=c.last_refreshed_at;U(a=>new Set(a).add(c.id));try{await V.client.refreshMentalModel(b,c.id);for(let f=0;f<120;f++){await new Promise(a=>setTimeout(a,1e3));let f=await V.client.getMentalModel(b,c.id);if(f.last_refreshed_at!==e){d(a=>a.map(a=>a.id===c.id?f:a)),p?.id===c.id&&q(f),F.toast.success(a("toastRefreshed"));return}}F.toast.error(a("toastRefreshTimeout"))}catch{}finally{U(a=>{let b=new Set(a);return b.delete(c.id),b})}},Z=async()=>{if(b&&D){J(!0);try{await V.client.deleteMentalModel(b,D.id),d(a=>a.filter(a=>a.id!==D.id)),p?.id===D.id&&q(null),G(null)}catch(a){}finally{J(!1)}}},$=async()=>{if(b&&K){O(!0);try{let a=await V.client.clearMentalModel(b,K.id);d(b=>b.map(b=>b.id===a.id?a:b)),p?.id===a.id&&q(a),F.toast.success("Mental model content cleared"),M(null)}catch{}finally{O(!1)}}};if((0,C.useEffect)(()=>{b&&S()},[b,t,v]),(0,C.useEffect)(()=>{let a=a=>{"Escape"===a.key&&q(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),(0,C.useEffect)(()=>{l(1)},[i,t,v]),!b)return(0,B.jsx)(by.Card,{children:(0,B.jsx)(by.CardContent,{className:"p-10 text-center",children:(0,B.jsx)("p",{className:"text-muted-foreground",children:a("selectBankPrompt")})})});let ab=Math.ceil(R.length/100),ac=(k-1)*100,ae=ac+100,af=R.slice(ac,ae);return(0,B.jsxs)("div",{children:[e?(0,B.jsxs)("div",{className:"text-center py-12",children:[(0,B.jsx)(ad,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,B.jsx)("p",{className:"text-muted-foreground",children:a("loading")})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("div",{className:"mb-4 flex items-center gap-3 flex-wrap",children:[(0,B.jsx)(X.Input,{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:a("filterPlaceholder"),className:"w-80 h-9"}),(0,B.jsx)(IS,{value:t,onChange:u,fetchSuggestions:async a=>{if(!b)return[];let c=a?`${a}*`:void 0;return(await V.client.listTags(b,c,20,"mental_models")).items.map(a=>a.tag)},matchMode:v,onMatchModeChange:w,className:"flex-1 min-w-[260px]"}),(0,B.jsxs)(W.Button,{onClick:()=>o(!0),size:"sm",children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-2"}),a("addMentalModel")]})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,B.jsx)("div",{className:"text-sm text-muted-foreground",children:i||t.length>0?a("countFiltered",{filtered:R.length,total:c.length}):a("count",{count:c.length})}),(0,B.jsx)("div",{className:"flex items-center gap-3",children:(0,B.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,B.jsxs)("button",{onClick:()=>h("files"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"files"===g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(QW,{className:"w-4 h-4"}),a("viewList")]}),(0,B.jsxs)("button",{onClick:()=>h("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,B.jsx)(RL,{className:"w-4 h-4"}),a("viewDashboard")]})]})})]}),R.length>0?(0,B.jsxs)(B.Fragment,{children:["dashboard"===g&&(0,B.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:af.map(b=>(0,B.jsx)(by.Card,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${p?.id===b.id?"border-primary shadow-md":""}`,onClick:()=>q(b),children:(0,B.jsxs)(by.CardContent,{className:"p-4",children:[(0,B.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,B.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,B.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:b.name}),(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:b.id}),(0,B.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${b.trigger?.refresh_after_consolidation?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-slate-500/10 text-slate-600 dark:text-slate-400"}`,children:b.trigger?.refresh_after_consolidation?a("badgeAutoRefresh"):a("badgeManual")})]})]}),(0,B.jsx)(RN,{m:b,refreshing:T.has(b.id),onEdit:a=>{A(a),y(!0)},onRefresh:Y,onClear:a=>M({id:a.id,name:a.name}),onDelete:a=>G({id:a.id,name:a.name}),triggerClassName:"h-7 w-7 ml-2 flex-shrink-0"})]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:b.source_query}),(0,B.jsxs)("div",{className:"relative mb-3 border-t border-border pt-3 max-h-40 overflow-hidden",children:[(0,B.jsx)(PJ,{children:b.content}),(0,B.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-card to-transparent"})]}),(0,B.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,B.jsx)("div",{className:"flex items-center gap-2",children:b.tags.length>0&&(0,B.jsxs)("div",{className:"flex gap-1",children:[b.tags.slice(0,2).map(a=>(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a)),b.tags.length>2&&(0,B.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",b.tags.length-2]})]})}),(0,B.jsx)("div",{className:"text-muted-foreground",title:PQ(b.last_refreshed_at),children:PP(b.last_refreshed_at)})]})]})},b.id))}),"files"===g&&(0,B.jsx)(RQ,{mentalModels:R,selectedId:r,onSelect:s,onOpenDetail:q,refreshingIds:T,onEdit:a=>{A(a),y(!0)},onRefresh:Y,onClear:a=>M({id:a.id,name:a.name}),onDelete:a=>G({id:a.id,name:a.name})}),"files"!==g&&ab>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,B.jsxs)("div",{className:"text-xs text-muted-foreground",children:[ac+1,"-",Math.min(ae,R.length)," of"," ",R.length]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(1),disabled:1===k,className:"h-7 w-7 p-0",children:(0,B.jsx)(_,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(a=>Math.max(1,a-1)),disabled:1===k,className:"h-7 w-7 p-0",children:(0,B.jsx)(P,{className:"h-3 w-3"})}),(0,B.jsxs)("span",{className:"text-xs px-2",children:[k," / ",ab]}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(a=>Math.min(ab,a+1)),disabled:k===ab,className:"h-7 w-7 p-0",children:(0,B.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>l(ab),disabled:k===ab,className:"h-7 w-7 p-0",children:(0,B.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,B.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,B.jsx)(L,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:i?a("emptyFilterMatch"):a("emptyNoModels")})]})]}),(0,B.jsx)(RO,{open:n,onClose:()=>o(!1),onCreated:()=>{o(!1),S()}}),(0,B.jsx)(Jc,{open:!!D,onOpenChange:a=>!a&&G(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:a("deleteDialogTitle")}),(0,B.jsxs)(Jx,{children:[a("deleteDialogDescription",{name:D?.name??""}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),(0,B.jsx)("span",{className:"text-destructive font-semibold",children:a("deleteDialogWarning")})]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:a("deleteDialogCancel")}),(0,B.jsxs)(Jy,{onClick:Z,disabled:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[I?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,a("deleteDialogConfirm")]})]})]})}),(0,B.jsx)(Jc,{open:!!K,onOpenChange:a=>!a&&M(null),children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:a("clearDialogTitle")}),(0,B.jsxs)(Jx,{children:[a.rich("clearDialogDescription",{name:K?.name??"",bold:a=>(0,B.jsx)("span",{className:"font-semibold",children:a})}),(0,B.jsx)("br",{}),(0,B.jsx)("br",{}),a("clearDialogReSynth")]})]}),(0,B.jsxs)(Jv,{className:"flex-row justify-end space-x-2",children:[(0,B.jsx)(Jz,{className:"mt-0",children:a("cancelButton")}),(0,B.jsxs)(Jy,{onClick:$,disabled:N,children:[N?(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}):null,a("clearDialogConfirm")]})]})]})}),(0,B.jsx)(P0,{mentalModelId:p?.id??null,onClose:()=>q(null),onDelete:a=>G({id:a.id,name:a.name}),onClear:a=>M({id:a.id,name:a.name}),onEdit:a=>{A(a),y(!0)},onRefreshed:a=>{d(b=>b.map(b=>b.id===a.id?a:b)),q(a)}}),z&&(0,B.jsx)(RP,{open:x,mentalModel:z,onClose:()=>{y(!1),A(null)},onUpdated:a=>{d(b=>b.map(b=>b.id===a.id?a:b)),q(a),y(!1),A(null)}})]})}function RN({m:a,refreshing:b,onEdit:c,onRefresh:d,onClear:e,onDelete:f,triggerClassName:g}){let h=(0,E.useTranslations)("mentalModels");return(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:`p-0 text-muted-foreground ${g??"h-8 w-8"}`,onClick:a=>a.stopPropagation(),"aria-label":h("actionsAriaLabel"),children:(0,B.jsx)(JB,{className:"h-4 w-4"})})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",onClick:a=>a.stopPropagation(),children:[(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>c(a),children:[(0,B.jsx)(bl,{className:"h-4 w-4 mr-2"}),h("actionEdit")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>d(a),disabled:b,children:[(0,B.jsx)(ad,{className:`h-4 w-4 mr-2 ${b?"animate-spin":""}`}),h("actionRefresh")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>e(a),children:[(0,B.jsx)(KM,{className:"h-4 w-4 mr-2"}),h("actionClearContent")]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>f(a),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,B.jsx)(JA,{className:"h-4 w-4 mr-2"}),h("actionDelete")]})]})]})}function RO({open:a,onClose:b,onCreated:c}){let d=(0,E.useTranslations)("mentalModels"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(!1),[h,i]=(0,C.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),j=async()=>{if(e&&h.name.trim()&&h.sourceQuery.trim()){g(!0);try{let a,b=h.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),f=parseInt(h.maxTokens)||2048,g=h.excludeMentalModelIds.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(h.tagGroups.trim())try{a=JSON.parse(h.tagGroups.trim())}catch{F.toast.error(d("invalidTagGroupsJson"));return}let j=h.recallMaxTokens.trim()?parseInt(h.recallMaxTokens,10):void 0,k=h.recallChunksMaxTokens.trim()?parseInt(h.recallChunksMaxTokens,10):void 0,l="true"===h.includeChunks||"false"!==h.includeChunks&&void 0;await V.client.createMentalModel(e,{id:h.id.trim()||void 0,name:h.name.trim(),source_query:h.sourceQuery.trim(),tags:b.length>0?b:void 0,max_tokens:f,trigger:{mode:h.mode,refresh_after_consolidation:h.autoRefresh,fact_types:h.factTypes.length>0?h.factTypes:void 0,exclude_mental_models:h.excludeMentalModels||void 0,exclude_mental_model_ids:g.length>0?g:void 0,tags_match:h.tagsMatch||void 0,tag_groups:a,include_chunks:l,recall_max_tokens:j,recall_chunks_max_tokens:k}}),i({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),c()}catch(a){}finally{g(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>{a||(i({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),b())},children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("createDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("createDialogDescription")})]}),(0,B.jsxs)(br.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,B.jsxs)(br.TabsList,{className:"w-full",children:[(0,B.jsx)(br.TabsTrigger,{value:"general",className:"flex-1",children:d("tabGeneral")}),(0,B.jsx)(br.TabsTrigger,{value:"options",className:"flex-1",children:d("tabOptions")})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,B.jsxs)(br.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldId")}),(0,B.jsx)(X.Input,{value:h.id,onChange:a=>i({...h,id:a.target.value}),placeholder:d("fieldIdPlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldName")}),(0,B.jsx)(X.Input,{value:h.name,onChange:a=>i({...h,name:a.target.value}),placeholder:d("fieldNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldSourceQuery")}),(0,B.jsx)(J2.Textarea,{value:h.sourceQuery,onChange:a=>i({...h,sourceQuery:a.target.value}),placeholder:d("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("fieldMaxTokens")}),(0,B.jsx)(X.Input,{type:"number",value:h.maxTokens,onChange:a=>i({...h,maxTokens:a.target.value}),placeholder:d("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,B.jsxs)(br.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionRefresh")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"auto-refresh",checked:h.autoRefresh,onCheckedChange:a=>i({...h,autoRefresh:!0===a})}),(0,B.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:d("optionsAutoRefreshLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRefreshModeLabel")}),(0,B.jsxs)(bb.Select,{value:h.mode,onValueChange:a=>i({...h,mode:a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"full",children:d("optionsRefreshModeFull")}),(0,B.jsx)(bb.SelectItem,{value:"delta",children:d("optionsRefreshModeDelta")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRefreshModeDeltaDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionOtherModels")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"exclude-mental-models",checked:h.excludeMentalModels,onCheckedChange:a=>i({...h,excludeMentalModels:!0===a})}),(0,B.jsx)("label",{htmlFor:"exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:d("optionsExcludeAllLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsExcludeIdsLabel")}),(0,B.jsx)(X.Input,{value:h.excludeMentalModelIds,onChange:a=>i({...h,excludeMentalModelIds:a.target.value}),placeholder:d("optionsExcludeIdsPlaceholder")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionTags")}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagsLabel")}),(0,B.jsx)(X.Input,{value:h.tags,onChange:a=>i({...h,tags:a.target.value}),placeholder:d("optionsTagsPlaceholder")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagsDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagsMatchLabel")}),(0,B.jsxs)(bb.Select,{value:h.tagsMatch,onValueChange:a=>i({...h,tagsMatch:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{placeholder:d("optionsTagsMatchDefaultPlaceholder")})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:d("optionsTagsMatchDefault")}),(0,B.jsx)(bb.SelectItem,{value:"any",children:d("optionsTagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:d("optionsTagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:d("optionsTagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:d("optionsTagsMatchAllStrict")}),(0,B.jsx)(bb.SelectItem,{value:"exact",children:d("optionsTagsMatchExact")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagsMatchDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsTagGroupsLabel")}),(0,B.jsx)(J2.Textarea,{value:h.tagGroups,onChange:a=>i({...h,tagGroups:a.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsTagGroupsDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:d("optionsSectionRecall")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallDescription")}),(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsFactTypesLabel")}),(0,B.jsx)(JY,{value:h.factTypes,onChange:a=>i({...h,factTypes:a})}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsFactTypesEmpty")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsIncludeChunksLabel")}),(0,B.jsxs)(bb.Select,{value:h.includeChunks||"default",onValueChange:a=>i({...h,includeChunks:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:d("optionsIncludeChunksDefault")}),(0,B.jsx)(bb.SelectItem,{value:"true",children:d("optionsIncludeChunksYes")}),(0,B.jsx)(bb.SelectItem,{value:"false",children:d("optionsIncludeChunksNo")})]})]})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRecallMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:h.recallMaxTokens,onChange:a=>i({...h,recallMaxTokens:a.target.value}),placeholder:d("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallMaxTokensDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:d("optionsRecallChunksMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:h.recallChunksMaxTokens,onChange:a=>i({...h,recallChunksMaxTokens:a.target.value}),placeholder:d("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:d("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:b,disabled:f,children:d("cancelButton")}),(0,B.jsx)(W.Button,{onClick:j,disabled:f||!h.name.trim()||!h.sourceQuery.trim(),children:f?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}),d("creatingButton")]}):d("createButton")})]})]})})}function RP({open:a,mentalModel:b,onClose:c,onUpdated:d}){let e=(0,E.useTranslations)("mentalModels"),{currentBank:f}=(0,H.useBank)(),[g,h]=(0,C.useState)(!1),i=()=>({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1,mode:b.trigger?.mode||"full",factTypes:b.trigger?.fact_types||[],excludeMentalModels:b.trigger?.exclude_mental_models||!1,excludeMentalModelIds:(b.trigger?.exclude_mental_model_ids||[]).join(", "),tagsMatch:b.trigger?.tags_match||"",tagGroups:b.trigger?.tag_groups?JSON.stringify(b.trigger.tag_groups,null,2):"",includeChunks:b.trigger?.include_chunks===!0?"true":b.trigger?.include_chunks===!1?"false":"",recallMaxTokens:b.trigger?.recall_max_tokens!=null?String(b.trigger.recall_max_tokens):"",recallChunksMaxTokens:b.trigger?.recall_chunks_max_tokens!=null?String(b.trigger.recall_chunks_max_tokens):""}),[j,k]=(0,C.useState)(i);(0,C.useEffect)(()=>{a&&k(i())},[a,b]);let l=async()=>{if(f&&j.name.trim()&&j.sourceQuery.trim()){h(!0);try{let a,g=j.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),h=parseInt(j.maxTokens)||2048,i=j.excludeMentalModelIds.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(j.tagGroups.trim())try{a=JSON.parse(j.tagGroups.trim())}catch{F.toast.error(e("invalidTagGroupsJson"));return}let k=j.recallMaxTokens.trim()?parseInt(j.recallMaxTokens,10):void 0,l=j.recallChunksMaxTokens.trim()?parseInt(j.recallChunksMaxTokens,10):void 0,n="true"===j.includeChunks||"false"!==j.includeChunks&&void 0,o=await V.client.updateMentalModel(f,b.id,{name:j.name.trim(),source_query:j.sourceQuery.trim(),tags:g.length>0?g:void 0,max_tokens:h,trigger:{mode:j.mode,refresh_after_consolidation:j.autoRefresh,fact_types:j.factTypes.length>0?j.factTypes:void 0,exclude_mental_models:j.excludeMentalModels||void 0,exclude_mental_model_ids:i.length>0?i:void 0,tags_match:j.tagsMatch||void 0,tag_groups:a,include_chunks:n,recall_max_tokens:k,recall_chunks_max_tokens:l}});d(o),c()}catch(a){}finally{h(!1)}}};return(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:e("updateDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:e("updateDialogDescription")})]}),(0,B.jsxs)(br.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,B.jsxs)(br.TabsList,{className:"w-full",children:[(0,B.jsx)(br.TabsTrigger,{value:"general",className:"flex-1",children:e("tabGeneral")}),(0,B.jsx)(br.TabsTrigger,{value:"options",className:"flex-1",children:e("tabOptions")})]}),(0,B.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,B.jsxs)(br.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:e("fieldId")}),(0,B.jsx)(X.Input,{value:b.id,disabled:!0,className:"bg-muted"})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldName")}),(0,B.jsx)(X.Input,{value:j.name,onChange:a=>k({...j,name:a.target.value}),placeholder:e("fieldNamePlaceholder")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldSourceQuery")}),(0,B.jsx)(J2.Textarea,{value:j.sourceQuery,onChange:a=>k({...j,sourceQuery:a.target.value}),placeholder:e("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("fieldMaxTokens")}),(0,B.jsx)(X.Input,{type:"number",value:j.maxTokens,onChange:a=>k({...j,maxTokens:a.target.value}),placeholder:e("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,B.jsxs)(br.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionRefresh")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"update-auto-refresh",checked:j.autoRefresh,onCheckedChange:a=>k({...j,autoRefresh:!0===a})}),(0,B.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:e("optionsAutoRefreshLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRefreshModeLabel")}),(0,B.jsxs)(bb.Select,{value:j.mode,onValueChange:a=>k({...j,mode:a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"full",children:e("optionsRefreshModeFull")}),(0,B.jsx)(bb.SelectItem,{value:"delta",children:e("optionsRefreshModeDelta")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRefreshModeDeltaDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionOtherModels")}),(0,B.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,B.jsx)(I4.Checkbox,{id:"update-exclude-mental-models",checked:j.excludeMentalModels,onCheckedChange:a=>k({...j,excludeMentalModels:!0===a})}),(0,B.jsx)("label",{htmlFor:"update-exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:e("optionsExcludeAllLabel")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsExcludeIdsLabel")}),(0,B.jsx)(X.Input,{value:j.excludeMentalModelIds,onChange:a=>k({...j,excludeMentalModelIds:a.target.value}),placeholder:e("optionsExcludeIdsPlaceholder")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionTags")}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagsLabel")}),(0,B.jsx)(X.Input,{value:j.tags,onChange:a=>k({...j,tags:a.target.value}),placeholder:e("optionsTagsPlaceholder")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagsDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagsMatchLabel")}),(0,B.jsxs)(bb.Select,{value:j.tagsMatch||"default",onValueChange:a=>k({...j,tagsMatch:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{placeholder:e("optionsTagsMatchDefaultPlaceholder")})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:e("optionsTagsMatchDefault")}),(0,B.jsx)(bb.SelectItem,{value:"any",children:e("optionsTagsMatchAny")}),(0,B.jsx)(bb.SelectItem,{value:"all",children:e("optionsTagsMatchAll")}),(0,B.jsx)(bb.SelectItem,{value:"any_strict",children:e("optionsTagsMatchAnyStrict")}),(0,B.jsx)(bb.SelectItem,{value:"all_strict",children:e("optionsTagsMatchAllStrict")}),(0,B.jsx)(bb.SelectItem,{value:"exact",children:e("optionsTagsMatchExact")})]})]}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagsMatchDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsTagGroupsLabel")}),(0,B.jsx)(J2.Textarea,{value:j.tagGroups,onChange:a=>k({...j,tagGroups:a.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsTagGroupsDescription")})]})]}),(0,B.jsxs)("section",{className:"space-y-4",children:[(0,B.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:e("optionsSectionRecall")}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallDescription")}),(0,B.jsxs)("div",{className:"space-y-3",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsFactTypesLabel")}),(0,B.jsx)(JY,{value:j.factTypes,onChange:a=>k({...j,factTypes:a})}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsFactTypesEmpty")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsIncludeChunksLabel")}),(0,B.jsxs)(bb.Select,{value:j.includeChunks||"default",onValueChange:a=>k({...j,includeChunks:"default"===a?"":a}),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"default",children:e("optionsIncludeChunksDefault")}),(0,B.jsx)(bb.SelectItem,{value:"true",children:e("optionsIncludeChunksYes")}),(0,B.jsx)(bb.SelectItem,{value:"false",children:e("optionsIncludeChunksNo")})]})]})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRecallMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:j.recallMaxTokens,onChange:a=>k({...j,recallMaxTokens:a.target.value}),placeholder:e("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallMaxTokensDescription")})]}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)("label",{className:"text-sm font-medium text-foreground",children:e("optionsRecallChunksMaxTokensLabel")}),(0,B.jsx)(X.Input,{type:"number",value:j.recallChunksMaxTokens,onChange:a=>k({...j,recallChunksMaxTokens:a.target.value}),placeholder:e("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,B.jsx)("p",{className:"text-xs text-muted-foreground",children:e("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:c,disabled:g,children:e("cancelButton")}),(0,B.jsx)(W.Button,{onClick:l,disabled:g||!j.name.trim()||!j.sourceQuery.trim(),children:g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin mr-1"}),e("updatingButton")]}):e("updateButton")})]})]})})}function RQ({mentalModels:a,selectedId:b,onSelect:c,onOpenDetail:d,refreshingIds:e,onEdit:f,onRefresh:g,onClear:h,onDelete:i}){let j=(0,E.useTranslations)("mentalModels"),k=b&&a.some(a=>a.id===b)?b:a[0]?.id??null,l=a.find(a=>a.id===k)??null;return(0,B.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[320px_1fr] gap-0 overflow-hidden min-h-[600px]",children:[(0,B.jsx)("aside",{className:"border-r border-border bg-muted/30 overflow-y-auto max-h-[calc(100vh-260px)]",children:(0,B.jsx)("ul",{className:"py-1",children:a.map(a=>{let b=a.id===k;return(0,B.jsx)("li",{children:(0,B.jsxs)("button",{onClick:()=>c(a.id),className:`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors border-l-2 ${b?"bg-primary/10 border-primary text-foreground":"border-transparent text-muted-foreground hover:bg-muted hover:text-foreground"}`,title:`${a.name}
|
|
9
|
+
${a.source_query}`,children:[(0,B.jsx)(N.FileText,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),(0,B.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("span",{className:`truncate text-sm font-medium ${b?"text-foreground":""}`,children:a.name}),(0,B.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",title:PQ(a.last_refreshed_at),children:PP(a.last_refreshed_at)})]}),a.source_query&&(0,B.jsx)("div",{className:"text-xs text-muted-foreground/80 truncate italic mt-0.5",children:a.source_query})]})]})},a.id)})})}),(0,B.jsx)("section",{className:"overflow-y-auto max-h-[calc(100vh-260px)]",children:l?(0,B.jsxs)("article",{className:"p-6",children:[(0,B.jsx)("header",{className:"mb-4 pb-4 border-b border-border",children:(0,B.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,B.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,B.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:l.name}),l.source_query&&(0,B.jsxs)("p",{className:"text-sm text-muted-foreground mt-1 italic",children:["“",l.source_query,"”"]}),(0,B.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,B.jsxs)("span",{title:PQ(l.last_refreshed_at),children:["Refreshed ",PP(l.last_refreshed_at)]}),l.tags.length>0&&(0,B.jsx)("div",{className:"flex gap-1",children:l.tags.map(a=>(0,B.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a))})]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,B.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>d(l),children:"Open"}),(0,B.jsx)(RN,{m:l,refreshing:e.has(l.id),onEdit:f,onRefresh:g,onClear:h,onDelete:i})]})]})}),l.content?(0,B.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:(0,B.jsx)(PJ,{children:l.content})}):(0,B.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("emptyContent")})]}):(0,B.jsxs)("div",{className:"p-10 text-center text-muted-foreground",children:[(0,B.jsx)(N.FileText,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,B.jsx)("p",{className:"text-sm",children:j("selectModelPrompt")})]})})]})}let RR=(0,K.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var bh=bh;let RS=["consolidation.completed","retain.completed","memory_defense.triggered"],RT={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function RU(a){return Object.fromEntries(a.filter(a=>a.key.trim()).map(a=>[a.key,a.value]))}function RV(a){return{method:a.method,timeout_seconds:a.timeout_seconds,headers:RU(a.headers),params:RU(a.params)}}function RW({label:a,pairs:b,onChange:c}){let d=(0,E.useTranslations)("webhooksView"),e=(a,d,e)=>{c(b.map((b,c)=>c===a?{...b,[d]:e}:b))};return(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)(aA,{children:a}),(0,B.jsxs)(W.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>c([...b,{key:"",value:""}]),children:[(0,B.jsx)(I$.Plus,{className:"w-3 h-3 mr-1"}),d("kvAdd")]})]}),b.length>0&&(0,B.jsx)("div",{className:"space-y-1.5",children:b.map((a,f)=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(X.Input,{placeholder:d("kvKeyPlaceholder"),value:a.key,onChange:a=>e(f,"key",a.target.value),className:"h-8 text-sm flex-1"}),(0,B.jsx)(X.Input,{placeholder:d("kvValuePlaceholder"),value:a.value,onChange:a=>e(f,"value",a.target.value),className:"h-8 text-sm flex-1"}),(0,B.jsx)("button",{type:"button",onClick:()=>c(b.filter((a,b)=>b!==f)),className:"text-muted-foreground hover:text-foreground shrink-0","aria-label":d("kvRemovePair"),children:(0,B.jsx)(bg.X,{className:"w-4 h-4"})})]},f))})]})}function RX({status:a}){let b=(0,E.useTranslations)("webhooksView");return"completed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),b("deliveryStatusDelivered")]}):"pending"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20",children:[(0,B.jsx)(af,{className:"w-3 h-3"}),b("deliveryStatusPending")]}):"failed"===a?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,B.jsx)(Ql,{className:"w-3 h-3"}),b("deliveryStatusFailed")]}):(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:a})}function RY({delivery:a,formatDate:b}){let c=(0,E.useTranslations)("webhooksView"),[d,e]=(0,C.useState)(!1),f=a.last_response_body||a.last_error;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(am,{className:f?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>f&&e(a=>!a),children:[(0,B.jsx)(ao,{className:"w-8 pl-3 pr-0",children:f?d?(0,B.jsx)(JC.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,B.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,B.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,B.jsx)(ao,{children:(0,B.jsx)(RX,{status:a.status})}),(0,B.jsx)(ao,{children:null!=a.last_response_status?(0,B.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${a.last_response_status>=200&&a.last_response_status<300?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:a.last_response_status}):(0,B.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,B.jsx)(ao,{className:"text-center text-sm",children:a.attempts}),(0,B.jsx)(ao,{className:"font-mono text-xs text-muted-foreground",children:a.event_type}),(0,B.jsx)(ao,{className:"text-xs text-muted-foreground whitespace-nowrap",children:b(a.created_at)})]}),d&&f&&(0,B.jsx)(am,{className:"bg-muted/20 hover:bg-muted/20",children:(0,B.jsx)(ao,{colSpan:6,className:"px-4 py-3",children:(0,B.jsxs)("div",{className:"space-y-3",children:[a.last_error&&(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c("expandedError")}),(0,B.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:a.last_error})]}),a.last_response_body&&(0,B.jsxs)("div",{className:"space-y-1",children:[(0,B.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:[c("expandedResponseBody"),a.last_attempt_at&&(0,B.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",b(a.last_attempt_at)]})]}),(0,B.jsx)("pre",{className:"font-mono text-xs bg-background rounded p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto border border-border",children:a.last_response_body})]})]})})})]})}function RZ(){let a=(0,E.useTranslations)("webhooksView"),{currentBank:b}=(0,H.useBank)(),[c,d]=(0,C.useState)([]),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)(!1),[i,j]=(0,C.useState)(!1),[k,l]=(0,C.useState)(null),[n,o]=(0,C.useState)(null),[p,q]=(0,C.useState)(!1),[r,s]=(0,C.useState)(RT),[t,u]=(0,C.useState)(!1),[v,w]=(0,C.useState)(null),[x,y]=(0,C.useState)(RT),[z,A]=(0,C.useState)(!1),[D,F]=(0,C.useState)(!1),[G,I]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(null),[N,O]=(0,C.useState)([]),[P,Q]=(0,C.useState)(!1),[R,S]=(0,C.useState)(null),[T,U]=(0,C.useState)(!1),Y=async()=>{if(b){f(!0);try{let a=await V.client.listWebhooks(b);d(a.items||[])}catch(a){console.error("Error loading webhooks:",a)}finally{f(!1)}}};(0,C.useEffect)(()=>{b&&Y()},[b]);let Z=async()=>{if(b&&r.url){j(!0);try{await V.client.createWebhook(b,{url:r.url,secret:r.secret||void 0,event_types:r.event_types.length>0?r.event_types:void 0,enabled:r.enabled,http_config:RV(r.http_config)}),h(!1),s(RT),q(!1),await Y()}catch(a){}finally{j(!1)}}},$=async a=>{if(b){l(a),o(null);try{await V.client.deleteWebhook(b,a),await Y()}catch(a){}finally{l(null)}}},_=async()=>{if(b&&v&&x.url){I(!0);try{let a={url:x.url,event_types:x.event_types,enabled:x.enabled,http_config:RV(x.http_config)};D?a.secret=null:x.secret&&(a.secret=x.secret),await V.client.updateWebhook(b,v.id,a),u(!1),await Y()}catch{}finally{I(!1)}}},aa=async a=>{if(b){M(a),K(!0),O([]),S(null),Q(!0);try{let c=await V.client.listWebhookDeliveries(b,a.id,50);O(c.items||[]),S(c.next_cursor??null)}catch(a){console.error("Error loading deliveries:",a)}finally{Q(!1)}}},ab=async()=>{if(b&&L&&R){U(!0);try{let a=await V.client.listWebhookDeliveries(b,L.id,50,R);O(b=>[...b,...a.items||[]]),S(a.next_cursor??null)}catch(a){console.error("Error loading more deliveries:",a)}finally{U(!1)}}},af=b=>b?new Date(b).toLocaleString():a("formatDateNA");return b?(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)("h3",{className:"text-lg font-semibold",children:a("title")}),(0,B.jsx)("button",{onClick:()=>Y(),className:"p-1 rounded hover:bg-muted transition-colors",title:a("refreshTitle"),"aria-label":a("refreshAriaLabel"),disabled:e,children:(0,B.jsx)(ad,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${e?"animate-spin":""}`})})]}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground",children:a("webhookCount",{count:c.length})})]}),(0,B.jsxs)(W.Button,{size:"sm",onClick:()=>h(!0),children:[(0,B.jsx)(I$.Plus,{className:"w-4 h-4 mr-2"}),a("addWebhook")]})]}),c.length>0?(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{children:a("tableHeaderUrl")}),(0,B.jsx)(an,{children:a("tableHeaderMethod")}),(0,B.jsx)(an,{children:a("tableHeaderEventTypes")}),(0,B.jsx)(an,{children:a("tableHeaderStatus")}),(0,B.jsx)(an,{children:a("tableHeaderCreatedAt")}),(0,B.jsx)(an,{className:"w-[120px]"})]})}),(0,B.jsx)(al,{children:c.map(b=>(0,B.jsxs)(am,{children:[(0,B.jsx)(ao,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,B.jsx)("span",{title:b.url,children:b.url})}),(0,B.jsx)(ao,{children:(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-mono font-medium bg-muted text-muted-foreground border border-border",children:b.http_config?.method||"POST"})}),(0,B.jsx)(ao,{children:(0,B.jsx)("div",{className:"flex flex-wrap gap-1",children:b.event_types.length>0?b.event_types.map(a=>(0,B.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:a},a)):(0,B.jsx)("span",{className:"text-xs text-muted-foreground",children:a("allEvents")})})}),(0,B.jsx)(ao,{children:b.enabled?(0,B.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20",children:[(0,B.jsx)(ae,{className:"w-3 h-3"}),a("statusEnabled")]}):(0,B.jsx)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground border border-border",children:a("statusDisabled")})}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground",children:af(b.created_at)}),(0,B.jsx)(ao,{children:(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>aa(b),title:a("viewDeliveriesTitle"),children:[(0,B.jsx)(ac,{className:"w-3 h-3 mr-1"}),a("deliveriesButton")]}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let a;return w(b),void(y((a=b.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:b.url,secret:"",event_types:b.event_types,enabled:b.enabled,http_config:{method:a.method,timeout_seconds:a.timeout_seconds,headers:Object.entries(a.headers??{}).map(([a,b])=>({key:a,value:b})),params:Object.entries(a.params??{}).map(([a,b])=>({key:a,value:b}))}})),A(!1),F(!1),u(!0))},title:a("editWebhookTitle"),"aria-label":a("editWebhookAriaLabel"),children:(0,B.jsx)(bl,{className:"w-3 h-3"})}),(0,B.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>o(b),disabled:k===b.id,title:a("deleteWebhookTitle"),"aria-label":a("deleteWebhookAriaLabel"),children:k===b.id?(0,B.jsx)(bh.default,{className:"w-3 h-3 animate-spin"}):(0,B.jsx)(JA,{className:"w-3 h-3"})})]})})]},b.id))})]})}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:a("emptyStateCanManage")}),(0,B.jsx)(bm.Dialog,{open:g,onOpenChange:a=>{a||(s(RT),q(!1)),h(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("createDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("createDialogDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-2",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formTypeLabel")}),(0,B.jsx)("div",{className:"flex items-center h-9 px-3 rounded-md border border-border bg-muted text-sm text-muted-foreground",children:"HTTP"})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"webhook-url",children:[a("formUrlLabel")," ",(0,B.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,B.jsx)(X.Input,{id:"webhook-url",type:"url",placeholder:a("formUrlPlaceholder"),value:r.url,onChange:a=>s(b=>({...b,url:a.target.value}))})]}),(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formMethodLabel")}),(0,B.jsxs)(bb.Select,{value:r.http_config.method,onValueChange:a=>s(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"POST",children:"POST"}),(0,B.jsx)(bb.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"webhook-timeout",children:a("formTimeoutLabel")}),(0,B.jsx)(X.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:r.http_config.timeout_seconds,onChange:a=>s(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"webhook-secret",children:[a("formSecretLabel")," ",(0,B.jsx)("span",{className:"text-muted-foreground text-xs",children:a("formSecretOptional")})]}),(0,B.jsxs)("div",{className:"relative",children:[(0,B.jsx)(X.Input,{id:"webhook-secret",type:p?"text":"password",placeholder:a("formSecretPlaceholderOptional"),value:r.secret,onChange:a=>s(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,B.jsx)("button",{type:"button",onClick:()=>q(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":p?a("formHideSecret"):a("formShowSecret"),children:p?(0,B.jsx)(RR,{className:"w-4 h-4"}):(0,B.jsx)(ac,{className:"w-4 h-4"})})]})]}),(0,B.jsx)(RW,{label:a("formCustomHeaders"),pairs:r.http_config.headers,onChange:a=>s(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,B.jsx)(RW,{label:a("formQueryParams"),pairs:r.http_config.params,onChange:a=>s(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)(aA,{children:a("formEventTypes")}),(0,B.jsx)("div",{className:"space-y-2",children:RS.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(I4.Checkbox,{id:`event-${a}`,checked:r.event_types.includes(a),onCheckedChange:()=>{s(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}}),(0,B.jsx)(aA,{htmlFor:`event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsx)(ba.Switch,{id:"webhook-enabled",checked:r.enabled,onCheckedChange:a=>s(b=>({...b,enabled:a}))}),(0,B.jsx)(aA,{htmlFor:"webhook-enabled",children:a("formEnabled")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>h(!1),disabled:i,children:a("cancel")}),(0,B.jsx)(W.Button,{onClick:Z,disabled:i||!r.url,children:i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("creating")]}):a("createWebhook")})]})]})}),(0,B.jsx)(bm.Dialog,{open:t,onOpenChange:a=>{a||(w(null),y(RT),A(!1),F(!1)),u(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("editDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("editDialogDescription")})]}),(0,B.jsxs)("div",{className:"space-y-4 py-2",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formTypeLabel")}),(0,B.jsx)("div",{className:"flex items-center h-9 px-3 rounded-md border border-border bg-muted text-sm text-muted-foreground",children:"HTTP"})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsxs)(aA,{htmlFor:"edit-webhook-url",children:[a("formUrlLabel")," ",(0,B.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,B.jsx)(X.Input,{id:"edit-webhook-url",type:"url",placeholder:a("formUrlPlaceholder"),value:x.url,onChange:a=>y(b=>({...b,url:a.target.value}))})]}),(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{children:a("formMethodLabel")}),(0,B.jsxs)(bb.Select,{value:x.http_config.method,onValueChange:a=>y(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,B.jsx)(bb.SelectTrigger,{children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{children:[(0,B.jsx)(bb.SelectItem,{value:"POST",children:"POST"}),(0,B.jsx)(bb.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"edit-webhook-timeout",children:a("formTimeoutLabel")}),(0,B.jsx)(X.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:x.http_config.timeout_seconds,onChange:a=>y(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)(aA,{htmlFor:"edit-webhook-secret",children:a("formSecretLabel")}),(0,B.jsxs)("div",{className:"relative",children:[(0,B.jsx)(X.Input,{id:"edit-webhook-secret",type:z?"text":"password",placeholder:a("formSecretPlaceholderEdit"),value:x.secret,disabled:D,onChange:a=>y(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,B.jsx)("button",{type:"button",onClick:()=>A(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":z?a("formHideSecret"):a("formShowSecret"),children:z?(0,B.jsx)(RR,{className:"w-4 h-4"}):(0,B.jsx)(ac,{className:"w-4 h-4"})})]}),(0,B.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,B.jsx)(I4.Checkbox,{id:"edit-clear-secret",checked:D,onCheckedChange:a=>{F(!!a),a&&y(a=>({...a,secret:""}))}}),(0,B.jsx)(aA,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:a("formClearSecret")})]})]}),(0,B.jsx)(RW,{label:a("formCustomHeaders"),pairs:x.http_config.headers,onChange:a=>y(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,B.jsx)(RW,{label:a("formQueryParams"),pairs:x.http_config.params,onChange:a=>y(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,B.jsxs)("div",{className:"space-y-2",children:[(0,B.jsx)(aA,{children:a("formEventTypes")}),(0,B.jsx)("div",{className:"space-y-2",children:RS.map(a=>(0,B.jsxs)("div",{className:"flex items-center gap-2",children:[(0,B.jsx)(I4.Checkbox,{id:`edit-event-${a}`,checked:x.event_types.includes(a),onCheckedChange:()=>y(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}),(0,B.jsx)(aA,{htmlFor:`edit-event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,B.jsxs)("div",{className:"flex items-center gap-3",children:[(0,B.jsx)(ba.Switch,{id:"edit-webhook-enabled",checked:x.enabled,onCheckedChange:a=>y(b=>({...b,enabled:a}))}),(0,B.jsx)(aA,{htmlFor:"edit-webhook-enabled",children:a("formEnabled")})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>u(!1),disabled:G,children:a("cancel")}),(0,B.jsx)(W.Button,{onClick:_,disabled:G||!x.url,children:G?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("saving")]}):a("saveChanges")})]})]})}),(0,B.jsx)(bm.Dialog,{open:!!n,onOpenChange:a=>{a||o(null)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-md",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("deleteDialogTitle")}),(0,B.jsx)(bm.DialogDescription,{children:a("deleteDialogDescription")})]}),n&&(0,B.jsx)("div",{className:"py-2",children:(0,B.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:n.url})}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"outline",onClick:()=>o(null),children:a("cancel")}),(0,B.jsx)(W.Button,{variant:"destructive",onClick:()=>n&&$(n.id),disabled:!!k,children:k?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("deleting")]}):a("deleteWebhookConfirm")})]})]})}),(0,B.jsx)(bm.Dialog,{open:J,onOpenChange:a=>{a||(O([]),S(null)),K(a)},children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:a("deliveriesDialogTitle")}),L&&(0,B.jsx)(bm.DialogDescription,{className:"font-mono text-xs truncate",children:L.url})]}),P?(0,B.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,B.jsx)(bh.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):N.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)("div",{className:"overflow-x-auto",children:(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-8 pl-3 pr-0"}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderStatus")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderHttp")}),(0,B.jsx)(an,{className:"text-center",children:a("deliveriesTableHeaderAttempts")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderEvent")}),(0,B.jsx)(an,{children:a("deliveriesTableHeaderCreatedAt")})]})}),(0,B.jsx)(al,{children:N.map(a=>(0,B.jsx)(RY,{delivery:a,formatDate:af},a.id))})]})}),R&&(0,B.jsx)("div",{className:"flex justify-center pt-2",children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:ab,disabled:T,children:[T&&(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),a("loadMore")]})})]}):(0,B.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:a("noDeliveries")})]})})]}):null}function R$(a){return[{value:"all",label:a("actionAll")},{value:"retain",label:a("actionRetain")},{value:"recall",label:a("actionRecall")},{value:"reflect",label:a("actionReflect")},{value:"create_bank",label:a("actionCreateBank")},{value:"update_bank",label:a("actionUpdateBank")},{value:"delete_bank",label:a("actionDeleteBank")},{value:"clear_memories",label:a("actionClearMemories")},{value:"consolidation",label:a("actionConsolidation")},{value:"batch_retain",label:a("actionBatchRetain")},{value:"create_mental_model",label:a("actionCreateMentalModel")},{value:"refresh_mental_model",label:a("actionRefreshMentalModel")},{value:"delete_mental_model",label:a("actionDeleteMentalModel")},{value:"create_directive",label:a("actionCreateDirective")},{value:"delete_directive",label:a("actionDeleteDirective")},{value:"file_convert_retain",label:a("actionFileConvertRetain")},{value:"webhook_delivery",label:a("actionWebhookDelivery")},{value:"memory_defense",label:a("actionMemoryDefense")}]}function R_(a,b){if(!a||!b)return"—";let c=new Date(a).getTime(),d=new Date(b).getTime()-c;return d<1e3?`${d}ms`:d<6e4?`${(d/1e3).toFixed(1)}s`:`${(d/6e4).toFixed(1)}m`}function R0(a){return a?new Date(a).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function R1({transport:a}){let b={http:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",mcp:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300",system:"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300"};return(0,B.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${b[a]||b.system}`,children:a})}function R2({bankId:a}){let b=(0,E.useTranslations)("auditLogsView"),c=R$(b),d=[{value:"1d",label:b("periodToday")},{value:"7d",label:b("periodLast7Days")},{value:"30d",label:b("periodLast30Days")}],[e,f]=(0,C.useState)("7d"),[g,h]=(0,C.useState)(null),[i,j]=(0,C.useState)([]),[k,l]=(0,C.useState)("day"),[n,o]=(0,C.useState)(!1),p=(0,C.useCallback)(async(b=e,c=g)=>{o(!0);try{let d=await V.client.getAuditLogStats(a,{period:b,action:c||void 0});j(d.buckets||[]),l(d.trunc||"day")}catch(a){console.error("Error loading audit stats:",a)}finally{o(!1)}},[a,e,g]);(0,C.useEffect)(()=>{p()},[a]);let q=i.map(a=>{var b;let c;return{time:(b=a.time,c=new Date(b),"hour"===k?c.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):c.toLocaleDateString(void 0,{month:"short",day:"numeric"})),total:a.total}});return(0,B.jsxs)(by.Card,{children:[(0,B.jsxs)(by.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0 gap-3",children:[(0,B.jsx)(by.CardTitle,{className:"text-sm font-semibold",children:b("requestVolume")}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsxs)(bb.Select,{value:g||"all",onValueChange:a=>{let b="all"===a?null:a;h(b),p(e,b)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px] h-8 text-xs",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),d.map(a=>(0,B.jsx)(W.Button,{variant:e===a.value?"default":"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{f(a.value),p(a.value,g)},children:a.label},a.value))]})]}),(0,B.jsx)(by.CardContent,{children:(0,B.jsx)("div",{className:"h-[120px]",children:n?(0,B.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:b("chartLoading")}):0===q.length?(0,B.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:b("chartNoData")}):(0,B.jsx)(gb,{width:"100%",height:"100%",children:(0,B.jsxs)(qP,{data:q,margin:{top:5,right:5,bottom:0,left:5},children:[(0,B.jsx)(vl,{dataKey:"time",tick:{fontSize:10},axisLine:!1,tickLine:!1,className:"text-muted-foreground"}),(0,B.jsx)(v0,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:"6px",fontSize:"12px",padding:"4px 8px"}}),(0,B.jsx)(ul,{type:"monotone",dataKey:"total",stroke:"var(--primary)",strokeWidth:2,dot:!1,activeDot:{r:3}})]})})})})]})}function R3(){let a=(0,E.useTranslations)("auditLogsView"),b=R$(a),c=[{value:"all",label:a("transportAll")},{value:"http",label:a("transportHttp")},{value:"mcp",label:a("transportMcp")},{value:"system",label:a("transportSystem")}],{currentBank:d}=(0,H.useBank)(),[e,f]=(0,C.useState)([]),[g,h]=(0,C.useState)(0),[i,j]=(0,C.useState)(null),[k,l]=(0,C.useState)(null),[n,o]=(0,C.useState)("all"),[p]=(0,C.useState)(20),[q,r]=(0,C.useState)(0),[s,t]=(0,C.useState)(!1),[u,v]=(0,C.useState)(null),[w,x]=(0,C.useState)(!1),y=(0,C.useCallback)(a=>{if("all"===a)return{};let b=new Date,c=new Date;return"1h"===a?c.setHours(b.getHours()-1):"1d"===a?c.setDate(b.getDate()-1):"7d"===a?c.setDate(b.getDate()-7):"30d"===a&&c.setDate(b.getDate()-30),{start_date:c.toISOString()}},[]),z=(0,C.useCallback)(async(a=i,b=k,c=n,e=q)=>{if(d){t(!0);try{let g=y(c),i=await V.client.listAuditLogs(d,{action:a||void 0,transport:b||void 0,start_date:g.start_date,end_date:g.end_date,limit:p,offset:e});f(i.items||[]),h(i.total||0)}catch(a){console.error("Error loading audit logs:",a)}finally{t(!1)}}},[d,i,k,n,q,p,y]),A=a=>{r(a),z(i,k,n,a)};(0,C.useEffect)(()=>{d&&z(i,k,n,q)},[d]);let D=Math.ceil(g/p),F=Math.floor(q/p)+1;return d?(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(R2,{bankId:d}),(0,B.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,B.jsxs)(bb.Select,{value:i||"all",onValueChange:a=>{let b="all"===a?null:a;j(b),r(0),z(b,k,n,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[180px]",children:(0,B.jsx)(bb.SelectValue,{placeholder:a("actionAll")})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:b.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,B.jsxs)(bb.Select,{value:k||"all",onValueChange:a=>{let b="all"===a?null:a;l(b),r(0),z(i,b,n,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[160px]",children:(0,B.jsx)(bb.SelectValue,{placeholder:a("transportAll")})}),(0,B.jsx)(bb.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:c.map(a=>(0,B.jsx)(bb.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,B.jsxs)(bb.Select,{value:n,onValueChange:a=>{o(a),r(0),z(i,k,a,0)},children:[(0,B.jsx)(bb.SelectTrigger,{className:"w-[150px]",children:(0,B.jsx)(bb.SelectValue,{})}),(0,B.jsxs)(bb.SelectContent,{position:"popper",children:[(0,B.jsx)(bb.SelectItem,{value:"all",children:a("dateRangeAll")}),(0,B.jsx)(bb.SelectItem,{value:"1h",children:a("dateRangeLastHour")}),(0,B.jsx)(bb.SelectItem,{value:"1d",children:a("dateRangeLast24Hours")}),(0,B.jsx)(bb.SelectItem,{value:"7d",children:a("dateRangeLast7Days")}),(0,B.jsx)(bb.SelectItem,{value:"30d",children:a("dateRangeLast30Days")})]})]}),(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>z(i,k,n,q),disabled:s,children:[(0,B.jsx)(ad,{className:`w-4 h-4 mr-1 ${s?"animate-spin":""}`}),a("refresh")]}),(0,B.jsx)("span",{className:"text-sm text-muted-foreground ml-auto",children:a("entryCount",{count:g})})]}),(0,B.jsxs)(aj,{children:[(0,B.jsx)(ak,{children:(0,B.jsxs)(am,{children:[(0,B.jsx)(an,{className:"w-[200px]",children:a("tableHeaderTime")}),(0,B.jsx)(an,{children:a("tableHeaderAction")}),(0,B.jsx)(an,{className:"w-[100px]",children:a("tableHeaderTransport")}),(0,B.jsx)(an,{className:"w-[100px]",children:a("tableHeaderDuration")})]})}),(0,B.jsx)(al,{children:0===e.length?(0,B.jsx)(am,{children:(0,B.jsx)(ao,{colSpan:4,className:"text-center text-muted-foreground py-8",children:a(s?"tableLoading":"tableNoLogs")})}):e.map(a=>(0,B.jsxs)(am,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>{v(a),x(!0)},children:[(0,B.jsx)(ao,{className:"text-sm font-mono",children:R0(a.started_at)}),(0,B.jsx)(ao,{className:"font-medium",children:a.action}),(0,B.jsx)(ao,{children:(0,B.jsx)(R1,{transport:a.transport})}),(0,B.jsx)(ao,{className:"text-sm text-muted-foreground font-mono",children:R_(a.started_at,a.ended_at)})]},a.id))})]}),D>1&&(0,B.jsxs)("div",{className:"flex items-center justify-between",children:[(0,B.jsx)("span",{className:"text-sm text-muted-foreground",children:a("paginationPage",{current:F,total:D})}),(0,B.jsxs)("div",{className:"flex gap-2",children:[(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(Math.max(0,q-p)),disabled:0===q,children:[(0,B.jsx)(P,{className:"w-4 h-4 mr-1"}),a("previous")]}),(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(q+p),disabled:q+p>=g,children:[a("next"),(0,B.jsx)(Q.ChevronRight,{className:"w-4 h-4 ml-1"})]})]})]}),(0,B.jsx)(bm.Dialog,{open:w,onOpenChange:x,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,B.jsx)(bm.DialogHeader,{children:(0,B.jsx)(bm.DialogTitle,{children:a("detailDialogTitle",{action:u?.action??""})})}),u&&(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailAction")})," ",(0,B.jsx)("span",{className:"font-medium",children:u.action})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailTransport")})," ",(0,B.jsx)(R1,{transport:u.transport})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailStarted")})," ",(0,B.jsx)("span",{className:"font-mono",children:R0(u.started_at)})]}),(0,B.jsxs)("div",{children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:a("detailDuration")})," ",(0,B.jsx)("span",{className:"font-mono",children:R_(u.started_at,u.ended_at)})]})]}),u.request&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailRequest")}),(0,B.jsx)(bz,{value:u.request,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),u.response&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailResponse")}),(0,B.jsx)(bz,{value:u.response,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),u.metadata&&Object.keys(u.metadata).length>0&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h4",{className:"text-sm font-semibold mb-2",children:a("detailMetadata")}),(0,B.jsx)(bz,{value:u.metadata})]})]})]})})]}):null}let R4=(0,K.default)("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function R5({title:a,description:b,icon:c=R4}){return(0,B.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,B.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,B.jsx)(c,{width:48,height:48,strokeWidth:1.5})}),(0,B.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:a}),(0,B.jsx)("p",{className:"text-sm text-muted-foreground max-w-md",children:b})]})}var bh=bh;let R6=(0,K.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);var bh=bh;function R7({tone:a}){return(0,B.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${"ok"===a?"bg-emerald-500":"bad"===a?"bg-red-500":"bg-muted-foreground/40"}`})}function R8({bankId:a,open:b,onOpenChange:c}){let d=(0,E.useTranslations)("bankStats"),[e,f]=(0,C.useState)(!1),[g,h]=(0,C.useState)(null),i=async()=>{f(!0);try{h(await V.client.testBankLlm(a))}catch{}finally{f(!1)}};(0,C.useEffect)(()=>{b?i():h(null)},[b,a]);let j={connected:d("llmConnected"),not_configured:d("llmNotConfigured"),auth_failed:d("llmAuthFailed"),unreachable:d("llmUnreachable"),timeout:d("llmTimeout")},k={retain:d("opRetain"),consolidation:d("consolidation"),reflect:d("opReflect")};return(0,B.jsx)(bm.Dialog,{open:b,onOpenChange:c,children:(0,B.jsxs)(bm.DialogContent,{className:"sm:max-w-md",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:d("llmHealthTitle")}),(0,B.jsx)(bm.DialogDescription,{children:d("llmTestHint")})]}),(0,B.jsx)("div",{className:"py-2 space-y-2",children:e&&!g?(0,B.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 animate-spin"}),d("testingLlm")]}):g?.operations.map(a=>{let b;return(0,B.jsxs)("div",{className:"flex items-center justify-between gap-2 text-sm py-1.5 border-b border-border/50 last:border-0",children:[(0,B.jsx)("span",{className:"text-muted-foreground",children:k[a.operation]??a.operation}),(0,B.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,B.jsx)(R7,{tone:"connected"===(b=a.status)?"ok":"not_configured"===b?"muted":"bad"}),(0,B.jsx)("span",{className:a.ok?"text-foreground font-medium":"text-muted-foreground",children:j[a.status]??a.status}),a.ok&&null!=a.latency_ms&&(0,B.jsxs)("span",{className:"text-muted-foreground/60 tabular-nums text-xs",children:[Math.round(a.latency_ms),"ms"]})]})]},a.operation)})}),(0,B.jsx)(bm.DialogFooter,{children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:i,disabled:e,className:"gap-1.5",children:[e?(0,B.jsx)(bh.default,{className:"w-3.5 h-3.5 animate-spin"}):(0,B.jsx)(ad,{className:"w-3.5 h-3.5"}),d(e?"testingLlm":"llmRetest")]})})]})})}var bh=bh;function R9({open:a,onOpenChange:b}){let c=(0,E.useTranslations)("bank"),d=(0,E.useTranslations)("common"),{currentBank:e}=(0,H.useBank)(),[f,g]=(0,C.useState)(""),[h,i]=(0,C.useState)(null),[j,k]=(0,C.useState)(!1),[l,n]=(0,C.useState)(null);async function o(){if(e){k(!0),n(null),i(null);try{let a=await fetch("/api/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bank_id:e,content:f})}),b=await a.json();if(!a.ok)throw Error(b.detail||`HTTP ${a.status}`);i(b)}catch(a){n(a instanceof Error?a.message:String(a))}finally{k(!1)}}}return(0,C.useEffect)(()=>{a&&(i(null),n(null))},[a]),(0,B.jsx)(bm.Dialog,{open:a,onOpenChange:b,children:(0,B.jsxs)(bm.DialogContent,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[(0,B.jsxs)(bm.DialogHeader,{children:[(0,B.jsx)(bm.DialogTitle,{children:c("dryRunExtraction")}),(0,B.jsx)(bm.DialogDescription,{children:c("dryRunExtractionDescription")})]}),(0,B.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,B.jsxs)("div",{className:"space-y-4",children:[(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:c("dryRunExtractionTextLabel")}),(0,B.jsx)(J2.Textarea,{className:"h-[30rem]",placeholder:c("dryRunExtractionPlaceholder"),value:f,onChange:a=>g(a.target.value)})]}),l?(0,B.jsx)("p",{className:"text-sm text-destructive",children:l}):null]}),(0,B.jsxs)("div",{className:"space-y-1.5",children:[(0,B.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:c("dryRunExtractionResponseLabel")}),(0,B.jsx)("div",{className:"h-[30rem] overflow-auto rounded-md border border-border bg-muted/30 p-3 text-sm",children:h?(0,B.jsx)(KK,{src:h,collapsed:2,theme:"default"}):(0,B.jsx)("span",{className:"text-muted-foreground",children:c("dryRunExtractionEmptyState")})})]})]}),(0,B.jsxs)(bm.DialogFooter,{children:[(0,B.jsx)(W.Button,{variant:"ghost",disabled:j,onClick:()=>b(!1),children:d("close")}),(0,B.jsxs)(W.Button,{onClick:o,disabled:j||!f.trim()||!e,children:[j?(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}):null,c("dryRunExtractionRun")]})]})]})})}a.s(["default",0,function(){(0,D.useParams)();let a=(0,D.useRouter)(),b=(0,D.useSearchParams)(),c=(0,E.useTranslations)("bank"),d=(0,E.useTranslations)("common"),{features:e}=(0,I3.useFeatures)(),{currentBank:f,setCurrentBank:g,loadBanks:h}=(0,H.useBank)(),i=b.get("view")||"profile",j=b.get("subTab")||"world",k=b.get("bankConfigTab")||"general",l=e?.observations??!1,n=e?.bank_config_api??!1,o=e?.audit_log??!1,p=e?.llm_trace??!1,q=e?.bank_llm_health??!1,[r,s]=(0,C.useState)(!1),[t,u]=(0,C.useState)(!1),[v,w]=(0,C.useState)(!1),[x,y]=(0,C.useState)(!1),[z,A]=(0,C.useState)(!1),[J,K]=(0,C.useState)(!1),[L,M]=(0,C.useState)(!1),[N,O]=(0,C.useState)(!1),[P,Q]=(0,C.useState)(!1),[R,S]=(0,C.useState)(!1),T=b=>{f&&a.push((0,I.bankRoute)(f,`?view=data&subTab=${b}`))},X=b=>{f&&a.push((0,I.bankRoute)(f,`?view=profile&bankConfigTab=${b}`))},Y=async()=>{if(f){y(!0);try{await V.client.deleteBank(f),w(!1),g(null),await h(),a.push("/")}catch(a){}finally{y(!1)}}},Z=async()=>{if(f){K(!0);try{let a=await V.client.clearObservations(f);A(!1),F.toast.success(c("observationsCleared"),{description:a.message||c("observationsClearedDefault")})}catch(a){}finally{K(!1)}}},$=async()=>{if(f){S(!0);try{await V.client.resetBankConfig(f),Q(!1)}catch{}finally{S(!1)}}},_=async()=>{if(f){M(!0);try{await V.client.triggerConsolidation(f)}catch(a){}finally{M(!1)}}},aa=async()=>{if(f){O(!0);try{let a=await V.client.recoverConsolidation(f);F.toast.success(c("recoveredMemories",{count:a.retried_count}))}catch(a){}finally{O(!1)}}};return(0,B.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,B.jsx)(G.BankSelector,{}),(0,B.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,B.jsx)(U,{currentTab:i,onTabChange:b=>{f&&a.push((0,I.bankRoute)(f,`?view=${b}`))}}),(0,B.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,B.jsxs)("div",{className:"p-6",children:["profile"===i&&(0,B.jsxs)("div",{children:[(0,B.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("bankConfiguration")}),(0,B.jsx)("p",{className:"text-muted-foreground",children:c("bankConfigurationDescription")})]}),(0,B.jsxs)(I5.DropdownMenu,{children:[(0,B.jsx)(I5.DropdownMenuTrigger,{asChild:!0,children:(0,B.jsxs)(W.Button,{variant:"outline",size:"sm",children:[c("actions"),(0,B.jsx)(JB,{className:"w-4 h-4 ml-2"})]})}),(0,B.jsxs)(I5.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,B.jsxs)(I5.DropdownMenuItem,{onClick:async()=>{if(f)try{let a=await V.client.exportBankTemplate(f),b=JSON.stringify(a,null,2);await navigator.clipboard.writeText(b),F.toast.success(c("templateCopied"))}catch{F.toast.error(c("failedToExportTemplate"))}},children:[(0,B.jsx)(JD,{className:"w-4 h-4 mr-2"}),c("exportTemplate")]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>u(!0),children:[(0,B.jsx)(R6,{className:"w-4 h-4 mr-2"}),c("dryRunExtraction")]}),q&&(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>s(!0),children:[(0,B.jsx)(bj,{className:"w-4 h-4 mr-2"}),c("health")]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:_,disabled:L||!l,title:l?void 0:"Observations feature is not enabled",children:[L?(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,B.jsx)(J$,{className:"w-4 h-4 mr-2"}),L?c("consolidating"):c("runConsolidation"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:aa,disabled:N||!l,title:l?void 0:"Observations feature is not enabled",children:[N?(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),N?c("recovering"):c("recoverConsolidation"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>A(!0),disabled:!l,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:l?void 0:"Observations feature is not enabled",children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("clearObservations"),!l&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>Q(!0),disabled:!n,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:n?void 0:"Bank Config API is disabled",children:[(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),c("resetConfiguration"),!n&&(0,B.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,B.jsx)(I5.DropdownMenuSeparator,{}),(0,B.jsxs)(I5.DropdownMenuItem,{onClick:()=>w(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("deleteBank")]})]})]})]}),(0,B.jsx)("div",{className:"mb-6 border-b border-border",children:(0,B.jsxs)("div",{className:"flex gap-1",children:[(0,B.jsxs)("button",{onClick:()=>X("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("general"),"general"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),n&&(0,B.jsxs)("button",{onClick:()=>X("memory-defense"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"memory-defense"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("memoryDefense"),"memory-defense"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),n&&(0,B.jsxs)("button",{onClick:()=>X("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("configuration"),"configuration"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>X("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("webhooks"),"webhooks"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>X("audit-logs"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"audit-logs"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("auditLogs"),!o&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"audit-logs"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>X("llm-requests"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"llm-requests"===k?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("llmRequests"),!p&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"llm-requests"===k&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,B.jsxs)("div",{children:["general"===k&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("overviewAndOperations")}),(0,B.jsxs)("div",{className:"space-y-6",children:[(0,B.jsx)(RF,{}),(0,B.jsx)(RK,{}),(0,B.jsx)(Qd,{hideReflectFields:!0})]})]}),"memory-defense"===k&&n&&f&&(0,B.jsx)("div",{className:"space-y-6",children:(0,B.jsx)(QP,{bankId:f})}),"configuration"===k&&n&&(0,B.jsx)("div",{className:"space-y-6",children:(0,B.jsx)(Qv,{})}),"webhooks"===k&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("webhooksDescription")}),(0,B.jsx)(RZ,{})]}),"audit-logs"===k&&(o?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("auditLogsDescription")}),(0,B.jsx)(R3,{})]}):(0,B.jsx)(R5,{title:c("auditLogsNotEnabled"),description:c.rich("auditLogsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_AUDIT_LOG_ENABLED=true"})})})),"llm-requests"===k&&(p?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("llmRequestsDescription")}),(0,B.jsx)(ws,{})]}):(0,B.jsx)(R5,{title:c("llmRequestsNotEnabled"),description:c.rich("llmRequestsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_LLM_TRACE_ENABLED=true"})})}))]})]}),"recall"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("recallAnalyzer")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("recallAnalyzerDescription")}),(0,B.jsx)(P8,{})]}),"reflect"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("reflect")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("reflectDescription")}),(0,B.jsx)(P6,{})]}),"data"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("memories")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("memoriesDescription")}),(0,B.jsx)("div",{className:"mb-6 border-b border-border",children:(0,B.jsxs)("div",{className:"flex gap-1",children:[(0,B.jsxs)("button",{onClick:()=>T("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("worldFacts"),"world"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>T("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("experience"),"experience"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>T("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("observations"),!l&&(0,B.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,B.jsxs)("button",{onClick:()=>T("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===j?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[c("mentalModels"),"mental-models"===j&&(0,B.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,B.jsxs)("div",{children:["world"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("worldFactsDescription")}),(0,B.jsx)(I1,{factType:"world"},"world")]}),"experience"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("experienceDescription")}),(0,B.jsx)(I1,{factType:"experience"},"experience")]}),"observations"===j&&(l?(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("observationsDescription")}),(0,B.jsx)(I1,{factType:"observation"},"observations")]}):(0,B.jsx)(R5,{title:c("observationsNotEnabled"),description:c.rich("observationsDisabledMessage",{envVar:()=>(0,B.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})})})),"mental-models"===j&&(0,B.jsxs)("div",{children:[(0,B.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:c("mentalModelsDescription")}),(0,B.jsx)(RM,{},"mental-models")]})]})]}),"documents"===i&&(0,B.jsx)("div",{children:(0,B.jsx)(JS,{})}),"entities"===i&&(0,B.jsxs)("div",{children:[(0,B.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:c("entities")}),(0,B.jsx)("p",{className:"text-muted-foreground mb-6",children:c("entitiesDescription")}),(0,B.jsx)(JT,{})]})]})})]}),f&&(0,B.jsx)(R8,{bankId:f,open:r,onOpenChange:s}),(0,B.jsx)(R9,{open:t,onOpenChange:u}),(0,B.jsx)(Jc,{open:v,onOpenChange:w,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("deleteMemoryBank")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("deleteBankPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:c("deleteBankWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:x,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:Y,disabled:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:x?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("deleting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("deleteBank")]})})]})]})}),(0,B.jsx)(Jc,{open:P,onOpenChange:Q,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("resetConfigTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("resetConfigPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:c("resetConfigWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:R,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:$,disabled:R,children:R?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("resetting")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bk,{className:"w-4 h-4 mr-2"}),c("resetConfiguration")]})})]})]})}),(0,B.jsx)(Jc,{open:z,onOpenChange:A,children:(0,B.jsxs)(Jt,{children:[(0,B.jsxs)(Ju,{children:[(0,B.jsx)(Jw,{children:c("clearObservationsTitle")}),(0,B.jsx)(Jx,{asChild:!0,children:(0,B.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,B.jsx)("p",{children:c.rich("clearObservationsPrompt",{bankName:()=>(0,B.jsx)("span",{className:"font-semibold text-foreground",children:f})})}),(0,B.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:c("clearObservationsWarning")})]})})]}),(0,B.jsxs)(Jv,{children:[(0,B.jsx)(Jz,{disabled:J,children:d("cancel")}),(0,B.jsx)(Jy,{onClick:Z,disabled:J,className:"bg-amber-500 text-white hover:bg-amber-600",children:J?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(bh.default,{className:"w-4 h-4 mr-2 animate-spin"}),c("clearing")]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(JA,{className:"w-4 h-4 mr-2"}),c("clearObservations")]})})]})]})})]})}],23962)}];
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0_x23ke._.js.map
|