@vectorize-io/hindsight-control-plane 0.8.0 → 0.8.1
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/build-manifest.json +3 -3
- package/standalone/.next/prerender-manifest.json +3 -3
- package/standalone/.next/server/app/[locale]/banks/[bankId]/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/dashboard/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/login/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/[locale]/page_client-reference-manifest.js +1 -1
- 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_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/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/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 +3 -3
- package/standalone/.next/server/chunks/ssr/_0l2o41x._.js +1 -1
- package/standalone/.next/server/chunks/ssr/_0ohntay._.js +1 -1
- package/standalone/.next/server/chunks/ssr/_1ssqeay._.js +1 -1
- package/standalone/.next/server/chunks/ssr/hindsight-control-plane_src_components_bank-selector_tsx_0b8_8lw._.js +2 -2
- 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/edge/chunks/[root-of-the-server]__0idnhrz._.js +2 -2
- package/standalone/.next/server/middleware-build-manifest.js +3 -3
- 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/16x7s96e_7nzf.js +3 -0
- package/standalone/.next/static/chunks/28t56shiu70y3.css +2 -0
- package/standalone/.next/static/chunks/2fiw5cr18t7wg.js +5 -0
- package/standalone/.next/static/chunks/{2pot5o8bw2ahn.js → 2glbol2hp_ttg.js} +1 -1
- package/standalone/.next/static/chunks/37w_hzg2bcmwe.js +3 -0
- package/standalone/.next/static/chunks/{2whmrc2crakdp.js → 3yi06qp6e0hek.js} +3 -3
- package/standalone/package.json +1 -1
- package/standalone/.next/static/chunks/14jmmb3upx561.js +0 -3
- package/standalone/.next/static/chunks/14khkrj56bsfj.css +0 -2
- package/standalone/.next/static/chunks/17z6q1_yb9kdk.js +0 -3
- package/standalone/.next/static/chunks/3ztbw8s54ctwr.js +0 -5
- /package/standalone/.next/static/{SDvVLb3hxtMQhmZ05lU6q → WNhovd8iAfbSzOLjWZbeD}/_buildManifest.js +0 -0
- /package/standalone/.next/static/{SDvVLb3hxtMQhmZ05lU6q → WNhovd8iAfbSzOLjWZbeD}/_clientMiddlewareManifest.js +0 -0
- /package/standalone/.next/static/{SDvVLb3hxtMQhmZ05lU6q → WNhovd8iAfbSzOLjWZbeD}/_ssgManifest.js +0 -0
|
@@ -4,6 +4,6 @@ You can add a description to the \`${PC}\` by passing a \`${PD}\` component as a
|
|
|
4
4
|
|
|
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 \`${PC}\`. 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
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return E.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null};let Pz=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PS,{className:(0,W.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",e),...t,ref:n}));Pz.displayName=PS.displayName;let PF=E.forwardRef(({className:e,...t},n)=>(0,_.jsxs)(Pk,{children:[(0,_.jsx)(Pz,{}),(0,_.jsx)(PM,{ref:n,className:(0,W.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",e),...t})]}));PF.displayName=PM.displayName;let PV=({className:e,...t})=>(0,_.jsx)("div",{className:(0,W.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});PV.displayName="AlertDialogHeader";let PH=({className:e,...t})=>(0,_.jsx)("div",{className:(0,W.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});PH.displayName="AlertDialogFooter";let PU=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PA,{ref:n,className:(0,W.cn)("text-lg font-semibold",e),...t}));PU.displayName=PA.displayName;let PW=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PP,{ref:n,className:(0,W.cn)("text-sm text-muted-foreground",e),...t}));PW.displayName=PP.displayName;let PY=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PL,{ref:n,className:(0,W.cn)((0,X.buttonVariants)(),e),...t}));PY.displayName=PL.displayName;let PG=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PR,{ref:n,className:(0,W.cn)((0,X.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));PG.displayName=PR.displayName;let P$=(0,I.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"}]]),PX=(0,I.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Pq=(0,I.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 PK=e.i(64659);let PZ=(0,I.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 PQ=e.i(69074);function PJ(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);if(i<30)return`${i}d ago`;let a=Math.floor(i/30);return a<12?`${a}mo ago`:`${Math.floor(a/12)}y ago`}function P0(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function P1({metadata:e}){let t=Object.entries(e);return 0===t.length?(0,_.jsx)("span",{children:"-"}):(0,_.jsxs)("div",{className:"flex flex-wrap gap-1",children:[t.slice(0,3).map(([e,t])=>(0,_.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:[e,"=",String(t)]},e)),t.length>3&&(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",t.length-3]})]})}function P2({children:e}){return(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground mb-1",children:e})}function P5({title:e,icon:t,children:n}){return(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,_.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:[t,e]}),(0,_.jsx)("div",{className:"p-4 space-y-4",children:n})]})}function P3({bankId:e,documentId:t}){let n=(0,M.useTranslations)("documentsView"),[r,i]=(0,E.useState)([]),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(null);return((0,E.useEffect)(()=>{let n=!1;return(async()=>{try{let r=await $.client.listLLMRequests(e,{document_id:t,group:!0,limit:50});if(n)return;let a=new Map;for(let e of r.items||[]){let t=e.trace_id||e.id;a.has(t)||a.set(t,[]),a.get(t).push(e)}let o=[...a.entries()].map(([e,t])=>({traceId:e,entry:t[0],calls:t.length,tokens:t.reduce((e,t)=>e+(t.total_tokens??0),0),status:t.some(e=>"error"===e.status)?"error":"success",start:t.map(e=>e.started_at).filter(Boolean).sort()[0]??null}));o.sort((e,t)=>(t.start||"").localeCompare(e.start||"")),i(o)}catch{}finally{n||o(!0)}})(),()=>{n=!0}},[e,t]),a&&0!==r.length)?(0,_.jsxs)(P5,{title:n("retainTracesTitle"),icon:(0,_.jsx)(ti,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)("div",{className:"space-y-1",children:r.map(e=>(0,_.jsxs)("button",{type:"button",onClick:()=>l(e.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,_.jsxs)("span",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,_.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${"error"===e.status?"bg-red-500":"bg-green-500"}`}),(0,_.jsx)("span",{className:"font-mono text-xs",children:e.entry.operation||"retain"}),(0,_.jsx)("span",{className:"text-muted-foreground text-xs truncate",children:e.start?new Date(e.start).toLocaleString():""})]}),(0,_.jsx)("span",{className:"text-muted-foreground text-xs font-mono shrink-0",children:n("retainTracesSummary",{calls:e.calls,tokens:e.tokens.toLocaleString()})})]},e.traceId))}),(0,_.jsx)(wL,{bankId:e,entry:s,open:!!s,onOpenChange:e=>!e&&l(null)})]}):null}function P4({label:e,value:t}){return(0,_.jsxs)("div",{children:[(0,_.jsx)(P2,{children:e}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:t})]})}function P6({nodesByFactType:e}){let t=(0,M.useTranslations)("dataView"),n=e??{world:0,experience:0,observation:0},r=n.world+n.experience+n.observation,i=[{name:"World",value:n.world,color:"#8b5cf6"},{name:"Experience",value:n.experience,color:"#ec4899"},{name:"Observations",value:n.observation,color:"#6366f1"}];return(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:t("memoryComposition")}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:r.toLocaleString()})]}),0===r?(0,_.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:t("noMemoriesYet")}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:i.filter(e=>e.value>0).map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/r*100}%`,backgroundColor:e.color},title:`${e.name}: ${e.value.toLocaleString()}`},e.name))}),(0,_.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:i.map(e=>(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:e.name})]}),(0,_.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums",children:e.value.toLocaleString()}),(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:r>0?`${(e.value/r*100).toFixed(0)}%`:"0%"})]})]},e.name))})]})]})}function P7({chunkFactType:e,setChunkFactType:t}){return(0,_.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(n=>(0,_.jsx)("button",{onClick:()=>t(n),className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors ${e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"observation"===n?"Obs":n.charAt(0).toUpperCase()+n.slice(1)},n))})}function P9({chunk:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)("world"),s=e.chunk_text??"",l=s.length>150?s.slice(0,150)+"...":s;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-left hover:bg-muted/30 transition-colors",onClick:()=>n(!t),children:[(0,_.jsx)(PK.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${t?"":"-rotate-90"}`}),(0,_.jsxs)("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["#",e.chunk_index]}),(0,_.jsxs)("span",{className:"text-[11px] text-muted-foreground/60 shrink-0",children:[s.length.toLocaleString()," chars"]}),!t&&(0,_.jsx)("span",{className:"text-xs text-foreground/50 truncate",children:l})]}),t&&(r?(0,_.jsxs)("div",{style:{height:"500px"},className:"flex flex-col border-t border-border",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/30 border-b border-border",children:[(0,_.jsx)(P7,{chunkFactType:a,setChunkFactType:o}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",onClick:()=>i(!1),className:"h-6 px-2 text-xs gap-1",children:[(0,_.jsx)(en,{className:"w-3 h-3"}),"Compact"]})]}),(0,_.jsx)("div",{className:"flex-1 min-h-0",children:(0,_.jsx)(Ph,{factType:a,chunkId:e.chunk_id},`${e.chunk_id}-${a}-full`)})]}):(0,_.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border",style:{height:"350px"},children:[(0,_.jsx)("div",{className:"overflow-y-auto",children:(0,_.jsx)("pre",{className:"px-4 py-3 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:s})}),(0,_.jsxs)("div",{className:"flex flex-col overflow-hidden",children:[(0,_.jsx)(P7,{chunkFactType:a,setChunkFactType:o}),(0,_.jsx)("div",{className:"flex-1 min-h-0",children:(0,_.jsx)(Ph,{factType:a,chunkId:e.chunk_id,compact:!0,onExpandToggle:()=>i(!0)},`${e.chunk_id}-${a}-compact`)})]})]}))]})}function P8(){let e=(0,M.useTranslations)("documentsView"),t=(0,M.useTranslations)("common"),n=(0,M.useTranslations)("bank"),{currentBank:r}=(0,D.useBank)(),{features:i}=(0,Pp.useFeatures)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(!1),[c,u]=(0,E.useState)(""),[d,h]=(0,E.useState)(0),[f,p]=(0,E.useState)(!1),[g,x]=(0,E.useState)(!1),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(!1),[k,S]=(0,E.useState)(null),[C,T]=(0,E.useState)("skip"),[A,P]=(0,E.useState)(1),L=Math.ceil(d/50),I=(A-1)*50,[R,B]=(0,E.useState)(null),[F,W]=(0,E.useState)(!1),[Y,G]=(0,E.useState)(null),[K,Z]=(0,E.useState)(!1),[Q,et]=(0,E.useState)(""),[en,ei]=(0,E.useState)(!1),[ea,es]=(0,E.useState)(!1),[ep,em]=(0,E.useState)(""),[eg,ex]=(0,E.useState)(!1),[ev,ey]=(0,E.useState)([]),[ew,ej]=(0,E.useState)(0),[eN,ek]=(0,E.useState)(!1),[eS,eC]=(0,E.useState)(!1),[e_,eE]=(0,E.useState)(!1),[eT,eM]=(0,E.useState)(null),[eO,eA]=(0,E.useState)(null),[eD,eP]=(0,E.useState)(null),eL=async(e=1)=>{if(r){l(!0);try{let t=await $.client.listDocuments({bank_id:r,q:c,limit:50,offset:(e-1)*50});o(t.items||[]),h(t.total||0)}catch(e){}finally{l(!1)}}},eI=e=>{P(e),eL(e)},eR=async e=>{if(r){W(!0),B({id:e}),Z(!1),et(""),es(!1),em(""),ey([]),ej(0),eC(!1);try{let t=await $.client.getDocument(e,r);B(t)}catch(e){B(null)}finally{W(!1)}}},eB=async e=>{if(r){ek(!0);try{let t=await $.client.listDocumentChunks({document_id:e,bank_id:r,limit:100});ey(t.items||[]),ej(t.total||0),eC(!0)}catch(e){}finally{ek(!1)}}},ez=async()=>{if(r&&R){eE(!0);try{let e=await $.client.reprocessDocument(R.id,r);eM({success:!0,message:`Reprocessing started (operation: ${e.operation_id})`})}catch(e){eM({success:!1,message:"Error reprocessing document: "+e.message})}finally{eE(!1)}}},eF=async()=>{if(!r||!eO)return;let t=eO.id;G(t),eA(null);try{let n=await $.client.deleteDocument(t,r);eP({success:!0,message:e("toastDeletedDocumentAndUnits",{count:n.memory_units_deleted})}),R?.id===t&&B(null),eL(A)}catch(t){console.error("Error deleting document:",t),eP({success:!1,message:e("toastErrorDeletingDocument")+t.message})}finally{G(null)}},eV=()=>{Z(!1),et("")},eH=async()=>{if(!r||!R||!ep.trim())return;let e=R.retain_params??{},t={content:ep,document_id:R.id};e.context&&(t.context=e.context),e.event_date&&(t.timestamp=e.event_date),e.metadata&&Object.keys(e.metadata).length>0&&(t.metadata=e.metadata),R.tags&&R.tags.length>0&&(t.tags=R.tags),ex(!0);try{await $.client.retain({bank_id:r,items:[t],async:!1});let e=await $.client.getDocument(R.id,r);B(e),es(!1),em(""),eL(A)}catch(e){console.error("Error updating document content:",e)}finally{ex(!1)}},eU=async()=>{if(!r||!R)return;let e=Q.split(",").map(e=>e.trim()).filter(e=>e.length>0);ei(!0);try{await $.client.updateDocument(R.id,r,e),B({...R,tags:e}),o(t=>t.map(t=>t.id===R.id?{...t,tags:e}:t)),Z(!1),et("")}catch(e){console.error("Error updating document tags:",e)}finally{ei(!1)}};(0,E.useEffect)(()=>{r&&(P(1),eL(1))},[r]),(0,E.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>{P(1),eL(1)},300);return()=>clearTimeout(e)},[c]);let eW=async(t,n=!1)=>{if(r&&!f){p(!0);try{var i;let a,o,s=await $.client.exportDocuments(r,t,n),l=t&&1===t.length?`-${t[0]}`:"-documents";i=`${r}${l}.zip`,a=URL.createObjectURL(s),(o=document.createElement("a")).href=a,o.download=i,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),O.toast.success(e("exportSuccess")),y(!1)}catch{}finally{p(!1)}}},eY=async t=>{if(t&&r){x(!0);try{let{operation_id:n}=await $.client.importDocuments(r,t,C),i=Date.now()+3e5,a=null;for(;Date.now()<i;){let t=await $.client.getOperationStatus(r,n);if("completed"===t.status){a=t.result_metadata??{};break}if("failed"===t.status)return void O.toast.error(t.error_message||e("importFailed"));await new Promise(e=>setTimeout(e,1e3))}if(null===a)return void O.toast.error(e("importTimeout"));O.toast.success(e("importSuccess",{imported:a.documents_imported??0,facts:a.facts_imported??0,skipped:a.documents_skipped??0})),eL(A),N(!1),S(null)}catch{}finally{x(!1)}}},eG=i?.document_export_api??!1,e$=i?.document_import_api??!1;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"mb-6 flex items-start justify-between gap-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("documents")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("documentsDescription")})]}),(eG||e$)&&(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"h-8 shrink-0",disabled:!r||f||g,children:[f?e("exporting"):g?e("importing"):e("actionsButton"),(0,_.jsx)(PK.ChevronDown,{className:"w-4 h-4 ml-1"})]})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[eG&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>{w(!1),y(!0)},children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),e("exportButton")]}),e$&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>N(!0),children:[(0,_.jsx)(PQ.Upload,{className:"h-4 w-4 mr-2"}),e("importButton")]})]})]})]}),(0,_.jsx)(ta.Dialog,{open:v,onOpenChange:y,children:(0,_.jsxs)(ta.DialogContent,{children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("exportDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("exportDialogDescription")})]}),(0,_.jsxs)("div",{className:"flex items-start gap-2 py-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"export-include-observations",checked:b,onCheckedChange:e=>w(!0===e)}),(0,_.jsxs)("div",{className:"grid gap-1 leading-none",children:[(0,_.jsx)(eb,{htmlFor:"export-include-observations",children:e("exportIncludeObservationsLabel")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:e("exportIncludeObservationsHint")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>y(!1),disabled:f,children:t("cancel")}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>eW(void 0,b),disabled:f,children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),f?e("exporting"):e("exportButton")]})]})]})}),(0,_.jsx)(ta.Dialog,{open:j,onOpenChange:e=>{N(e),e||S(null)},children:(0,_.jsxs)(ta.DialogContent,{children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("importDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("importDialogDescription")})]}),(0,_.jsxs)("div",{className:"py-2 space-y-4",children:[(0,_.jsx)("input",{type:"file",accept:".zip,application/zip",disabled:g,onChange:e=>S(e.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,_.jsxs)("div",{className:"grid gap-1.5",children:[(0,_.jsx)(eb,{htmlFor:"import-on-conflict",children:e("importConflictLabel")}),(0,_.jsxs)(e6.Select,{value:C,onValueChange:e=>T(e),disabled:g,children:[(0,_.jsx)(e6.SelectTrigger,{id:"import-on-conflict",className:"h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"skip",children:e("importConflictSkip")}),(0,_.jsx)(e6.SelectItem,{value:"replace",children:e("importConflictReplace")}),(0,_.jsx)(e6.SelectItem,{value:"new-id",children:e("importConflictNewId")})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>{N(!1),S(null)},disabled:g,children:t("cancel")}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>k&&eY(k),disabled:!k||g,children:[(0,_.jsx)(PQ.Upload,{className:"h-4 w-4 mr-2"}),g?e("importing"):e("importButton")]})]})]})}),s?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingDocuments")})]})}):a.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:e("totalDocuments",{total:d})}),(0,_.jsxs)("div",{className:"w-full",children:[(0,_.jsx)("div",{className:"px-5 mb-4",children:(0,_.jsx)(q.Input,{type:"text",value:c,onChange:e=>u(e.target.value),placeholder:e("searchPlaceholder"),className:"max-w-2xl"})}),(0,_.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("colDocumentId")}),(0,_.jsx)(eh,{children:e("colCreated")}),(0,_.jsx)(eh,{children:e("colUpdated")}),(0,_.jsx)(eh,{children:e("colTags")}),(0,_.jsx)(eh,{children:e("colMetadata")}),(0,_.jsx)(eh,{children:e("colSize")}),(0,_.jsx)(eh,{children:e("colMemoryUnits")})]})}),(0,_.jsx)(eu,{children:a.length>0?a.map(e=>(0,_.jsxs)(ed,{className:`cursor-pointer hover:bg-muted/50 ${R?.id===e.id?"bg-primary/10":""}`,onClick:()=>eR(e.id),children:[(0,_.jsx)(ef,{className:"text-card-foreground font-mono text-xs break-all",children:e.id}),(0,_.jsx)(ef,{className:"text-card-foreground",title:e.created_at?new Date(e.created_at).toLocaleString():"",children:e.created_at?PJ(e.created_at):"N/A"}),(0,_.jsx)(ef,{className:"text-card-foreground",title:e.updated_at?new Date(e.updated_at).toLocaleString():"",children:e.updated_at?PJ(e.updated_at):"N/A"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.tags&&e.tags.length>0?(0,_.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map((e,t)=>(0,_.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:e},t)),e.tags.length>3&&(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",e.tags.length-3]})]}):"-"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.document_metadata&&Object.keys(e.document_metadata).length>0?(0,_.jsx)(P1,{metadata:e.document_metadata}):"-"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:P0(e.text_length||0)}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.memory_unit_count})]},e.id)):(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:7,className:"text-center",children:e("clickLoadDocumentsToView")})})})]})}),L>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t px-5",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[I+1,"-",Math.min(I+50,d)," of ",d]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(1),disabled:1===A||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(A-1),disabled:1===A||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[A," / ",L]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(A+1),disabled:A===L||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(L),disabled:A===L||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noDocumentsFound")})]})}),(0,_.jsx)(ta.Dialog,{open:!!R,onOpenChange:e=>!e&&B(null),children:(0,_.jsxs)(ta.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,_.jsx)(ta.DialogHeader,{className:"pr-10",children:(0,_.jsx)(ta.DialogTitle,{className:"flex items-center gap-2",children:(0,_.jsx)("span",{className:"truncate font-mono text-sm",children:R?.id??"Document"})})}),F?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingDocument")})]})}):R?(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"flex-1 flex flex-col overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,_.jsxs)(ts.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,_.jsxs)(ts.TabsTrigger,{value:"general",className:"flex items-center gap-1.5",children:[(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),"General"]}),(0,_.jsxs)(ts.TabsTrigger,{value:"content",className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),"Content"]}),(0,_.jsxs)(ts.TabsTrigger,{value:"chunks",className:"flex items-center gap-1.5",onClick:()=>{!eS&&R?.id&&eB(R.id)},children:[(0,_.jsx)(tl,{className:"w-3.5 h-3.5"}),"Chunks",eS?` (${ew})`:""]})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:e_,"aria-label":t("actions"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:ez,disabled:e_,children:[(0,_.jsx)(er,{className:"h-4 w-4 mr-2"}),"Reprocess"]}),eG&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>eW([R.id]),disabled:f,children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),e("exportButton")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>{eA({id:R.id,memoryCount:R.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,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),e("deleteButton")]})]})]})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,_.jsx)(ts.TabsContent,{value:"content",className:"mt-0",children:void 0!==R.original_text&&(ea?(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("div",{className:"flex items-center justify-end mb-2",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(X.Button,{size:"sm",onClick:eH,disabled:eg||!ep.trim(),className:"h-7 px-3 gap-1 text-xs",children:[eg?(0,_.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,_.jsx)(te.Check,{className:"h-3 w-3"}),e("saveButton")]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>{es(!1),em("")},disabled:eg,className:"h-7 px-3 gap-1 text-xs",children:[(0,_.jsx)(tt.X,{className:"h-3 w-3"}),e("cancelButton")]})]})}),(0,_.jsx)("textarea",{value:ep,onChange:e=>em(e.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,_.jsx)("p",{className:"text-xs text-muted-foreground",children:e("saveHint")})]}):(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,_.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,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),(0,_.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:e("storedContent")}),(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["·"," ",R.original_text?.length?.toLocaleString()??0," chars"]})]}),(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",onClick:()=>{em(R?.original_text??""),es(!0)},className:"h-6 px-2 gap-1 text-xs",children:[(0,_.jsx)(PX,{className:"h-3 w-3"}),e("editButton")]})]}),(0,_.jsx)("pre",{className:"p-4 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:R.original_text})]}))}),(0,_.jsx)(ts.TabsContent,{value:"general",className:"mt-0",children:(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)(ts.Tabs,{defaultValue:"world",className:"flex flex-col",children:[(0,_.jsxs)(ts.TabsList,{className:"w-fit",children:[(0,_.jsx)(ts.TabsTrigger,{value:"world",children:"World"}),(0,_.jsx)(ts.TabsTrigger,{value:"experience",children:"Experience"}),(0,_.jsx)(ts.TabsTrigger,{value:"observation",children:"Observations"})]}),(0,_.jsxs)("div",{className:"mt-2",children:[(0,_.jsx)(ts.TabsContent,{value:"world",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"world",documentId:R.id,compact:!0})}),(0,_.jsx)(ts.TabsContent,{value:"experience",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"experience",documentId:R.id,compact:!0})}),(0,_.jsx)(ts.TabsContent,{value:"observation",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"observation",documentId:R.id,compact:!0})})]})]}),(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsxs)(P5,{title:"Document",icon:(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),children:[R.created_at&&(0,_.jsx)(P4,{label:e("labelCreated"),value:new Date(R.created_at).toLocaleString()}),R.updated_at&&(0,_.jsx)(P4,{label:e("labelUpdated"),value:new Date(R.updated_at).toLocaleString()}),R.original_text&&(0,_.jsx)(P4,{label:e("colSize"),value:P0(new Blob([R.original_text]).size)}),(0,_.jsx)(P4,{label:e("labelTags"),value:K?(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(q.Input,{value:Q,onChange:e=>et(e.target.value),placeholder:e("tagsInputPlaceholder"),className:"text-sm h-7 w-64",onKeyDown:e=>{"Enter"===e.key&&eU(),"Escape"===e.key&&eV()},autoFocus:!0}),(0,_.jsx)(X.Button,{size:"sm",onClick:eU,disabled:en,className:"h-7 w-7 p-0",children:en?(0,_.jsx)("span",{className:"animate-spin text-xs",children:"⏳"}):(0,_.jsx)(te.Check,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:eV,disabled:en,className:"h-7 w-7 p-0",children:(0,_.jsx)(tt.X,{className:"h-3 w-3"})})]}):(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[R.tags&&R.tags.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:R.tags.map((e,t)=>(0,_.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:e},t))}):(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:"none"}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>{et((R?.tags??[]).join(", ")),Z(!0)},className:"h-6 w-6 p-0",children:(0,_.jsx)(PX,{className:"h-3 w-3"})})]})}),R.retain_params?.context&&(0,_.jsx)(P4,{label:"Context",value:R.retain_params.context}),R.retain_params?.event_date&&(0,_.jsx)(P4,{label:e("labelEventDate"),value:new Date(R.retain_params.event_date).toLocaleString()}),R.retain_params?.metadata&&Object.keys(R.retain_params.metadata).length>0&&(0,_.jsx)(P4,{label:"Metadata",value:(0,_.jsx)(P1,{metadata:R.retain_params.metadata})})]}),(0,_.jsx)(P5,{title:e("memoryCompositionTitle"),icon:(0,_.jsx)(eo,{className:"w-3.5 h-3.5"}),children:(0,_.jsx)(P6,{nodesByFactType:R.nodes_by_fact_type})}),r&&R?.id&&(0,_.jsx)(P3,{bankId:r,documentId:R.id})]})]})}),(0,_.jsx)(ts.TabsContent,{value:"chunks",className:"mt-0",children:eN?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingChunks")})]})}):ev.length>0?(0,_.jsx)("div",{className:"rounded-lg border border-border overflow-hidden divide-y divide-border",children:ev.map(e=>(0,_.jsx)(P9,{chunk:e},e.chunk_id))}):eS?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noChunksFound")})]})}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)("div",{className:"text-center",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("clickChunksTabToLoad")})})})})]})]}):null]})}),(0,_.jsx)(PN,{open:!!eO,onOpenChange:e=>!e&&eA(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("deleteDialogTitle")}),(0,_.jsxs)(PW,{children:[e("deleteDialogDescription")," ",(0,_.jsxs)("span",{className:"font-mono font-semibold",children:['"',eO?.id,'"']}),"?",(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),e("deleteDialogWillDelete")," ",eO?.memoryCount!==void 0?(0,_.jsx)("span",{className:"font-semibold",children:e("deleteDialogMemoryUnits",{count:eO.memoryCount})}):e("deleteDialogAllMemoryUnits")," ",e("deleteDialogExtracted"),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:e("deleteDialogCannotUndo")})]})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{children:e("cancelButton")}),(0,_.jsx)(PY,{onClick:eF,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:e("deleteButton")})]})]})}),(0,_.jsx)(PN,{open:!!eD,onOpenChange:e=>!e&&eP(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:eD?.success?e("deleteResultSuccessTitle"):e("deleteResultErrorTitle")}),(0,_.jsx)(PW,{children:eD?.message})]}),(0,_.jsx)(PH,{children:(0,_.jsx)(PY,{onClick:()=>eP(null),children:e("okButton")})})]})}),(0,_.jsx)(PN,{open:!!eT,onOpenChange:e=>!e&&eM(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:eT?.success?"Reprocessing Started":e("deleteResultErrorTitle")}),(0,_.jsx)(PW,{children:eT?.message})]}),(0,_.jsx)(PH,{children:(0,_.jsx)(PY,{onClick:()=>eM(null),children:e("okButton")})})]})})]})}function Le(){let e=(0,M.useTranslations)("entitiesView"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(null),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)("relations"),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)(!1),[x,v]=(0,E.useState)(1),[y,b]=(0,E.useState)(0),w=Math.ceil(y/50),j=(x-1)*50,N=async(e=1)=>{if(t){a(!0);try{let n=await $.client.listEntities({bank_id:t,limit:50,offset:(e-1)*50});r(n.items||[]),b(n.total||0)}catch(e){}finally{a(!1)}}},k=async e=>{if(t){c(!0);try{let n=await $.client.getEntity(e,t);s(n)}catch(e){}finally{c(!1)}}},S=e=>{v(e),N(e)},C=(0,E.useCallback)(async()=>{if(t){g(!0);try{let e=await $.client.getEntityGraph({bank_id:t,limit:2e3,min_count:1});f(e)}catch(e){}finally{g(!1)}}},[t]);(0,E.useEffect)(()=>{t&&(v(1),N(1),s(null),f(null))},[t]),(0,E.useEffect)(()=>{"relations"!==u||!t||h||p||C()},[u,t,h,p,C]);let T=(0,E.useMemo)(()=>h?Dr(h):{nodes:[],links:[]},[h]),O=(0,E.useMemo)(()=>{let e=new Map;for(let t of T.links){let n="number"==typeof t.weight&&t.weight>0?t.weight:1;e.set(t.source,(e.get(t.source)||0)+n),e.set(t.target,(e.get(t.target)||0)+n)}return e},[T]),A=(0,E.useMemo)(()=>{let e=1;for(let t of O.values())t>e&&(e=t);return e},[O]),P=(0,E.useCallback)(e=>3+11*Math.sqrt((O.get(e.id)||0)/A),[O,A]),L=(0,E.useMemo)(()=>{let e=h?.edges||[];if(!e.length)return null;let t=new Map,n=1/0,r=-1/0;for(let i of e){let e=i.data.lastCooccurred;if(!e)continue;let a=Date.parse(e);if(!Number.isNaN(a)){for(let e of[i.data.source,i.data.target]){let n=t.get(e);(void 0===n||a>n)&&t.set(e,a)}a<n&&(n=a),a>r&&(r=a)}}return Number.isFinite(n)&&Number.isFinite(r)&&r!==n?{times:t,minT:n,maxT:r}:null},[h]),I=(0,E.useCallback)(e=>{if(!L)return .5;let t=L.times.get(e.id);return void 0===t?0:(t-L.minT)/(L.maxT-L.minT)},[L]),R=(0,E.useCallback)(e=>{k(e.id)},[t]),B=t=>t?new Date(t).toLocaleDateString():e("na");return(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"mb-4 flex items-center justify-end",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,_.jsxs)("button",{onClick:()=>d("relations"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"relations"===u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(Pu,{className:"w-4 h-4"}),e("viewRelations")]}),(0,_.jsxs)("button",{onClick:()=>d("list"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"list"===u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(es,{className:"w-4 h-4"}),e("viewList")]})]})}),"relations"===u&&(0,_.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:p?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingEntityGraph")})]})}):T.nodes.length>0?(0,_.jsx)(Pl,{data:T,height:700,onNodeClick:R,nodeSizeFn:P,nodeHeatFn:L?I:void 0,heatLegendLabel:L?e("heatLegendLabel"):void 0,heatLegendEndpoints:L?[new Date(L.minT).toISOString().slice(0,10),new Date(L.maxT).toISOString().slice(0,10)]:void 0,sizeLegendLabel:e("sizeLegendLabel"),compactLabels:!0}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noCooccurrences")}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:e("noCooccurrencesDescription")})]})})}),"list"===u&&(0,_.jsx)("div",{children:i?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingEntities")})]})}):n.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:e("entityCount",{count:y})}),(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("colName")}),(0,_.jsx)(eh,{children:e("colMentions")}),(0,_.jsx)(eh,{children:e("colFirstSeen")}),(0,_.jsx)(eh,{children:e("colLastSeen")})]})}),(0,_.jsx)(eu,{children:n.map(e=>(0,_.jsxs)(ed,{onClick:()=>k(e.id),className:`cursor-pointer hover:bg-muted/50 ${o?.id===e.id?"bg-primary/10":""}`,children:[(0,_.jsx)(ef,{className:"font-medium text-card-foreground",children:e.canonical_name}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.mention_count}),(0,_.jsx)(ef,{className:"text-card-foreground",children:B(e.first_seen)}),(0,_.jsx)(ef,{className:"text-card-foreground",children:B(e.last_seen)})]},e.id))})]})}),w>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j+1,"-",Math.min(j+50,y)," of ",y]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(1),disabled:1===x||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(x-1),disabled:1===x||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[x," / ",w]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(x+1),disabled:x===w||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(w),disabled:x===w||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noEntitiesFound")}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:e("noEntitiesDescription")})]})})}),o&&(0,_.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,_.jsxs)("div",{className:"p-5",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:o.canonical_name}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e("entityDetails")})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>s(null),className:"h-8 w-8 p-0",children:(0,_.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,_.jsxs)("div",{className:"space-y-5",children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("mentionsLabel")}),(0,_.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:o.mention_count})]}),(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("firstSeenLabel")}),(0,_.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:B(o.first_seen)})]})]}),(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("entityIdLabel")}),(0,_.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:o.id})]})]})]})})]})}let Lt=["world","experience","observation"],Ln={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 Lr({ft:e,active:t,onToggle:n}){let r=(0,M.useTranslations)("factTypeFilter"),i=Ln[e];return(0,_.jsxs)("button",{type:"button",onClick:n,className:(0,W.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-all",t?i.active:i.inactive),children:[(0,_.jsx)("span",{className:(0,W.cn)("h-1.5 w-1.5 rounded-full",t?i.dot:"bg-muted-foreground/50")}),r(e)]})}function Li({value:e,onChange:t,label:n}){let r=(0,M.useTranslations)("factTypeFilter"),i=n??r("defaultLabel");return(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,_.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:i}),(0,_.jsx)("div",{className:"flex gap-1.5",children:Lt.map(n=>(0,_.jsx)(Lr,{ft:n,active:e.includes(n),onToggle:()=>t(e.includes(n)?e.filter(e=>e!==n):[...e,n])},n))})]})}function La({value:e,onChange:t}){return(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:Lt.map(n=>(0,_.jsx)(Lr,{ft:n,active:e.includes(n),onToggle:()=>t(e.includes(n)?e.filter(e=>e!==n):[...e,n])},n))})}var Lo=e.i(52571);let Ls=(0,I.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"}]]),Ll=(0,I.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"}]]),Lc=(0,I.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"}]]),Lu=(0,I.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 Ld=e.i(1864);"function"==typeof SuppressedError&&SuppressedError;var Lh=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach(function(t){e.addRange(t)}),t&&t.focus()}},Lf={"text/plain":"Text","text/html":"Url",default:"Text"},Lp=function(e,t){var n,r,i,a,o,s,l,c,u=!1;t||(t={}),i=t.debug||!1;try{if(o=Lh(),s=document.createRange(),l=document.getSelection(),(c=document.createElement("span")).textContent=e,c.ariaHidden="true",c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),void 0===n.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var r=Lf[t.format]||Lf.default;window.clipboardData.setData(r,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(c),s.selectNodeContents(c),l.addRange(s),!document.execCommand("copy"))throw Error("copy command was unsuccessful");u=!0}catch(o){i&&console.error("unable to copy using execCommand: ",o),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(o){i&&console.error("unable to copy using clipboardData: ",o),i&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",r=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",a=n.replace(/#{\s*key\s*}/g,r),window.prompt(a,e)}}finally{l&&("function"==typeof l.removeRange?l.removeRange(s):l.removeAllRanges()),c&&document.body.removeChild(c),o()}return u};function Lm(e){return"[object Object]"===Object.prototype.toString.call(e)}function Lg(e){return Array.isArray(e)?e.length:Lm(e)?Object.keys(e).length:0}function Lx(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Lg(e);if("function"==typeof r){let i=Lb(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||Lm(e)&&o>i)}function Lv(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Math.ceil(e.length/100);if("function"==typeof r){let i=Lb(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||Lm(e)&&o>i)}function Ly(e,t,n){return"boolean"==typeof e?e:"number"==typeof e&&!!(t>e)||"collapsed"===e&&!!n||"expanded"===e&&!n}function Lb(e,t){try{return e(...t)}catch(e){reportError(e)}}function Lw(e){if(!0===e||Lm(e)&&!0===e.add)return!0}function Lj(e){if(!0===e||Lm(e)&&!0===e.edit)return!0}function LN(e){if(!0===e||Lm(e)&&!0===e.delete)return!0}function Lk(e){return!e||void 0===e.add||!!e.add}function LS(e){return!e||void 0===e.edit||!!e.edit}function LC(e){return!e||void 0===e.delete||!!e.delete}function L_(e){return!e||void 0===e.enableClipboard||!!e.enableClipboard}function LE(){return(LE=Object.assign.bind()).apply(this,arguments)}var LT=function(e){return E.createElement("svg",LE({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),d||(d=E.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 LM(){return(LM=Object.assign.bind()).apply(this,arguments)}var LO=function(e){return E.createElement("svg",LM({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),h||(h=E.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 LA(){return(LA=Object.assign.bind()).apply(this,arguments)}var LD=function(e){return E.createElement("svg",LA({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),f||(f=E.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=E.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 LP({node:e,nodeMeta:t}){let{customizeCopy:n,CopyComponent:r,CopiedComponent:i}=(0,E.useContext)(L0),[a,o]=(0,E.useState)(!1),s=r=>{r.stopPropagation();let i=n(e,t);"string"==typeof i&&i&&function(e){var t,n,r,i;t=this,n=void 0,r=void 0,i=function*(){try{yield navigator.clipboard.writeText(e)}catch(t){Lp(e)}},new(r||(r=Promise))(function(e,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(t){var n;t.done?e(t.value):((n=t.value)instanceof r?n:new r(function(e){e(n)})).then(o,s)}l((i=i.apply(t,n||[])).next())})}(i),o(!0),setTimeout(()=>o(!1),3e3)};return a?"function"==typeof i?(0,_.jsx)(i,{className:"json-view--copy",style:{display:"inline-block"}}):(0,_.jsx)(LD,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof r?(0,_.jsx)(r,{onClick:s,className:"json-view--copy"}):(0,_.jsx)(LO,{onClick:s,className:"json-view--copy"})}function LL({indexOrName:e,value:t,depth:n,deleteHandle:r,editHandle:i,parent:a,parentPath:o}){let{displayArrayIndex:s}=(0,E.useContext)(L0),l=Array.isArray(a);return(0,_.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!l||l&&s?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",Object.assign({className:"number"==typeof e?"json-view--index":"json-view--property"},{children:e})),":"," "]}):(0,_.jsx)(_.Fragment,{}),(0,_.jsx)(LQ,{node:t,depth:n+1,deleteHandle:(e,t)=>r(e,t),editHandle:(e,t,n,r)=>i(e,t,n,r),parent:a,indexOrName:e,parentPath:o})]}))}function LI(){return(LI=Object.assign.bind()).apply(this,arguments)}var LR=function(e){return E.createElement("svg",LI({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),g||(g=E.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"})),x||(x=E.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 LB(){return(LB=Object.assign.bind()).apply(this,arguments)}var Lz=function(e){return E.createElement("svg",LB({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),v||(v=E.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"})),y||(y=E.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 LF(){return(LF=Object.assign.bind()).apply(this,arguments)}var LV=function(e){return E.createElement("svg",LF({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),b||(b=E.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"})),w||(w=E.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 LH(){return(LH=Object.assign.bind()).apply(this,arguments)}var LU=function(e){return E.createElement("svg",LH({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),j||(j=E.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"})),N||(N=E.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 LW({originNode:e,node:t,depth:n,index:r,deleteHandle:i,customOptions:a,startIndex:o,parent:s,parentPath:l}){let{enableClipboard:c,src:u,onEdit:d,onChange:h,forceUpdate:f,displaySize:p,CustomOperation:g}=(0,E.useContext)(L0),x=[...l,String(r)],[v,y]=(0,E.useState)(!0),b=(0,E.useCallback)((t,r,i)=>{e[t]=r,d&&d({newValue:r,oldValue:i,depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),h&&h({type:"edit",depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),f()},[t,d,h,f]),w=t=>{e.splice(t,1),i&&i(t,l),f()},j=(0,_.jsxs)(_.Fragment,{children:[!v&&(0,_.jsxs)("span",Object.assign({onClick:()=>y(!0),className:"jv-size-chevron"},{children:[Ly(p,n,v)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[Lg(t)," Items"]})),(0,_.jsx)(LT,{className:"jv-chevron"})]})),!v&&c&&L_(a)&&(0,_.jsx)(LP,{node:t,nodeMeta:{depth:n,indexOrName:r,parent:s,parentPath:l,currentPath:x}}),"function"==typeof g?(0,_.jsx)(g,{node:t}):null]});return(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{children:"["}),j,v?(0,_.jsxs)("button",Object.assign({onClick:()=>y(!1),className:"jv-button"},{children:[o," ... ",o+t.length-1]})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:t.map((e,i)=>(0,_.jsx)(LL,{indexOrName:i+o,value:e,depth:n,parent:t,deleteHandle:w,editHandle:b,parentPath:l},String(r)+String(i)))})),(0,_.jsx)("span",{children:"]"})]})}function LY({node:e,depth:t,deleteHandle:n,indexOrName:r,customOptions:i,parent:a,parentPath:o}){let s=void 0!==r?[...o,String(r)]:o,l=[];for(let t=0;t<e.length;t+=100)l.push(e.slice(t,t+100));let{collapsed:c,enableClipboard:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,CustomOperation:x,onChange:v,forceUpdate:y,displaySize:b}=(0,E.useContext)(L0),[w,j]=(0,E.useState)(Lv(e,t,r,c,d,i));(0,E.useEffect)(()=>{j(Lv(e,t,r,c,d,i))},[c,d]);let[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),T=()=>{e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),v&&v({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),y()},M=N||S,O=(0,_.jsxs)(_.Fragment,{children:[!w&&!M&&(0,_.jsxs)("span",Object.assign({onClick:()=>j(!0),className:"jv-size-chevron"},{children:[Ly(b,t,w)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[e.length," Items"]})),(0,_.jsx)(LT,{className:"jv-chevron"})]})),M&&(0,_.jsx)(LV,{className:"json-view--edit",style:{display:"inline-block"},onClick:S?T:()=>{k(!1),n&&n(r,o),f&&f({value:e,depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o}),v&&v({type:"delete",depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o})}}),M&&(0,_.jsx)(LU,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{k(!1),C(!1)}}),!w&&!M&&u&&L_(i)&&(0,_.jsx)(LP,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:a,parentPath:o,currentPath:s}}),!w&&!M&&Lw(h)&&Lk(i)&&(0,_.jsx)(Lz,{className:"json-view--edit",onClick:()=>{T()}}),!w&&!M&&LN(h)&&LC(i)&&n&&(0,_.jsx)(LR,{className:"json-view--edit",onClick:()=>k(!0)}),"function"==typeof x?(0,_.jsx)(x,{node:e}):null]});return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"["}),O,w?(0,_.jsx)("button",Object.assign({onClick:()=>j(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:l.map((a,s)=>(0,_.jsx)(LW,{originNode:e,node:a,depth:t,index:s,startIndex:100*s,deleteHandle:n,customOptions:i,parentPath:o},String(r)+String(s)))})),(0,_.jsx)("span",{children:"]"}),w&&Ly(b,t,w)&&(0,_.jsxs)("span",Object.assign({onClick:()=>j(!1),className:"jv-size"},{children:[e.length," Items"]}))]})}function LG({node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parent:a,parentPath:o}){let{collapsed:s,onCollapse:l,enableClipboard:c,ignoreLargeArray:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,onEdit:x,onChange:v,forceUpdate:y,displaySize:b,CustomOperation:w}=(0,E.useContext)(L0),j=void 0!==n?[...o,String(n)]:o;if(!u&&Array.isArray(e)&&e.length>100)return(0,_.jsx)(LY,{node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parentPath:j});let N=Lm(e),[k,S]=(0,E.useState)(Lx(e,t,n,s,d,i)),C=r=>{null==l||l({isCollapsing:!r,node:e,depth:t,indexOrName:n}),S(r)};(0,E.useEffect)(()=>{C(Lx(e,t,n,s,d,i))},[s,d]);let T=(0,E.useCallback)((n,r,i)=>{Array.isArray(e)?e[+n]=r:e&&(e[n]=r),x&&x({newValue:r,oldValue:i,depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),v&&v({type:"edit",depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),y()},[e,x,v,y]),M=t=>{Array.isArray(e)?e.splice(+t,1):e&&delete e[t],y()},[O,A]=(0,E.useState)(!1),[D,P]=(0,E.useState)(!1),L=(0,E.useRef)(null),I=()=>{var n;if(N){let r=null==(n=L.current)?void 0:n.value;r&&(e[r]=null,L.current&&(L.current.value=""),P(!1),g&&g({indexOrName:r,depth:t,src:p,parentType:"object",parentPath:j}),v&&v({type:"add",indexOrName:r,depth:t,src:p,parentType:"object",parentPath:j}))}else Array.isArray(e)&&(e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:j}),v&&v({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:j}));y()},R=O||D,B=()=>{A(!1),P(!1)},z=(0,_.jsxs)(_.Fragment,{children:[!k&&!R&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!0),className:"jv-size-chevron"},{children:[Ly(b,t,k)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[Lg(e)," Items"]})),(0,_.jsx)(LT,{className:"jv-chevron"})]})),D&&N&&(0,_.jsx)("input",{className:"json-view--input",placeholder:"property",ref:L,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),I()):"Escape"===e.key&&B()}}),R&&(0,_.jsx)(LV,{className:"json-view--edit",style:{display:"inline-block"},onClick:D?I:()=>{A(!1),r&&r(n,j),f&&f({value:e,depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),v&&v({type:"delete",depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j})}}),R&&(0,_.jsx)(LU,{className:"json-view--edit",style:{display:"inline-block"},onClick:B}),!k&&!R&&c&&L_(i)&&(0,_.jsx)(LP,{node:e,nodeMeta:{depth:t,indexOrName:n,parent:a,parentPath:o,currentPath:j}}),!k&&!R&&Lw(h)&&Lk(i)&&(0,_.jsx)(Lz,{className:"json-view--edit",onClick:()=>{N?(P(!0),setTimeout(()=>{var e;return null==(e=L.current)?void 0:e.focus()})):I()}}),!k&&!R&&LN(h)&&LC(i)&&r&&(0,_.jsx)(LR,{className:"json-view--edit",onClick:()=>A(!0)}),"function"==typeof w?(0,_.jsx)(w,{node:e}):null]});return Array.isArray(e)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"["}),z,k?(0,_.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:e.map((r,i)=>(0,_.jsx)(LL,{indexOrName:i,value:r,depth:t,parent:e,deleteHandle:M,editHandle:T,parentPath:j},String(n)+String(i)))})),(0,_.jsx)("span",{children:"]"}),k&&Ly(b,t,k)&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[Lg(e)," Items"]}))]}):N?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"{"}),z,k?(0,_.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(e).map(([r,i])=>(0,_.jsx)(LL,{indexOrName:r,value:i,depth:t,parent:e,deleteHandle:M,editHandle:T,parentPath:j},String(n)+String(r)))})),(0,_.jsx)("span",{children:"}"}),k&&Ly(b,t,k)&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[Lg(e)," Items"]}))]}):(0,_.jsx)("span",{children:String(e)})}let L$=E.default.forwardRef(({str:e,className:t,ctrlClick:n},r)=>{let{collapseStringMode:i,collapseStringsAfterLength:a,customizeCollapseStringUI:o}=(0,E.useContext)(L0),[s,l]=(0,E.useState)(!0),c=(0,E.useRef)(null);a=a>0?a:0;let u=e.replace(/\s+/g," "),d="function"==typeof o?o(u,s):"string"==typeof o?o:"...",h=e=>{var t;if((e.ctrlKey||e.metaKey)&&n)n(e);else{let e=window.getSelection();if(e&&e.anchorOffset!==e.focusOffset&&(null==(t=e.anchorNode)?void 0:t.parentElement)===c.current)return;l(!s)}};if(e.length<=a)return(0,_.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']}));if("address"===i)return e.length<=10?(0,_.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']})):(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,6),d,u.slice(-4)]:e,'"']}));if("directly"===i)return(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,a),d]:e,'"']}));if("word"===i){let n=a,r=a+1,i=u,o=1;for(;;){if(/\W/.test(e[n])){i=e.slice(0,n);break}if(/\W/.test(e[r])){i=e.slice(0,r);break}if(6===o){i=e.slice(0,a);break}o++,n--,r++}return(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[i,d]:e,'"']}))}return(0,_.jsxs)("span",Object.assign({ref:c,className:t},{children:['"',e,'"']}))});function LX(){return(LX=Object.assign.bind()).apply(this,arguments)}var Lq=function(e){return E.createElement("svg",LX({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),k||(k=E.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 LK(){return(LK=Object.assign.bind()).apply(this,arguments)}var LZ=function(e){return E.createElement("svg",LK({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),S||(S=E.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"})),C||(C=E.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 LQ({node:e,depth:t,deleteHandle:n,indexOrName:r,parent:i,editHandle:a,parentPath:o}){let s,{collapseStringsAfterLength:l,enableClipboard:c,editable:u,src:d,onDelete:h,onChange:f,customizeNode:p,matchesURL:g,urlRegExp:x,EditComponent:v,DoneComponent:y,CancelComponent:b,CustomOperation:w}=(0,E.useContext)(L0);if("function"==typeof p&&(s=Lb(p,[{node:e,depth:t,indexOrName:r}])),s){if((0,E.isValidElement)(s))return s;else if("function"==typeof s){let n=s;return(0,_.jsx)(n,{node:e,depth:t,indexOrName:r})}}if(Array.isArray(e)||Lm(e))return(0,_.jsx)(LG,{parent:i,node:e,depth:t,indexOrName:r,deleteHandle:n,parentPath:o,customOptions:"object"==typeof s?s:void 0});{var j;let p=typeof e,N=void 0!==r?[...o,String(r)]:o,[k,S]=(0,E.useState)(!1),[C,T]=(0,E.useState)(!1),M=(0,E.useRef)(null),O=()=>{S(!0),setTimeout(()=>{var e,t;null==(e=window.getSelection())||e.selectAllChildren(M.current),null==(t=M.current)||t.focus()})},A=(0,E.useCallback)(()=>{let t=M.current.innerText;try{let n=JSON.parse(t);a&&a(r,n,e,o)}catch(i){let n="string"===p?t.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):t;a&&a(r,n,e,o)}S(!1)},[a,r,e,o,p]),D=()=>{S(!1),T(!1)},P=()=>{T(!1),n&&n(r,o),h&&h({value:e,depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",parentPath:o}),f&&f({depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",type:"delete",parentPath:o})},L=(0,E.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),A()):"Escape"===e.key&&D()},[A]),I=k||C,R=!I&&Lj(u)&&LS(s)&&a?e=>{(e.ctrlKey||e.metaKey)&&O()}:void 0,B=(0,_.jsxs)(_.Fragment,{children:[I&&("function"==typeof y?(0,_.jsx)(y,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A}):(0,_.jsx)(LV,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A})),I&&("function"==typeof b?(0,_.jsx)(b,{className:"json-view--edit",style:{display:"inline-block"},onClick:D}):(0,_.jsx)(LU,{className:"json-view--edit",style:{display:"inline-block"},onClick:D})),!I&&c&&L_(s)&&(0,_.jsx)(LP,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:i,parentPath:o,currentPath:N}}),!I&&g&&"string"===p&&x.test(e)&&(!(j=s)||void 0===j.matchesURL||!!j.matchesURL)&&(0,_.jsx)("a",Object.assign({href:e,target:"_blank",className:"json-view--link"},{children:(0,_.jsx)(LZ,{})})),!I&&Lj(u)&&LS(s)&&a&&("function"==typeof v?(0,_.jsx)(v,{className:"json-view--edit",onClick:O}):(0,_.jsx)(Lq,{className:"json-view--edit",onClick:O})),!I&&LN(u)&&LC(s)&&n&&(0,_.jsx)(LR,{className:"json-view--edit",onClick:()=>T(!0)}),"function"==typeof w?(0,_.jsx)(w,{node:e}):null]}),z="json-view--string";switch(p){case"number":case"bigint":z="json-view--number";break;case"boolean":z="json-view--boolean";break;case"object":z="json-view--null"}"string"==typeof(null==s?void 0:s.className)&&(z+=" "+s.className),C&&(z+=" json-view--deleting");let F=String(e);"bigint"===p&&(F+="n");let V=(0,E.useMemo)(()=>(0,_.jsx)("span",{contentEditable:!0,className:z,dangerouslySetInnerHTML:{__html:"string"===p?`"${F}"`:F},ref:M,onKeyDown:L}),[F,p,L]);return"string"===p?(0,_.jsxs)(_.Fragment,{children:[k?V:e.length>l?(0,_.jsx)(L$,{str:e,ref:M,className:z,ctrlClick:R}):(0,_.jsxs)("span",Object.assign({className:z,onClick:R},{children:['"',F,'"']})),B]}):(0,_.jsxs)(_.Fragment,{children:[k?V:(0,_.jsx)("span",Object.assign({className:z,onClick:R},{children:F})),B]})}}let LJ=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,L0=(0,E.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:LJ,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function L1({src:e,collapseStringsAfterLength:t=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:i=99,collapsed:a,onCollapse:o,enableClipboard:s=!0,editable:l=!1,onEdit:c,onDelete:u,onAdd:d,onChange:h,dark:f=!1,theme:p="default",customizeNode:g,customizeCopy:x=e=>(function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,(e,t)=>{switch(typeof t){case"bigint":return String(t)+"n";case"number":case"boolean":case"object":case"string":return t;default:return String(t)}},void 0)}catch(e){return`${e.name}: ${e.message}`||"JSON.stringify failed"}})(e),displaySize:v,displayArrayIndex:y=!0,style:b,className:w,matchesURL:j=!1,urlRegExp:N=LJ,ignoreLargeArray:k=!1,CopyComponent:S,CopiedComponent:C,EditComponent:T,CancelComponent:M,DoneComponent:O,CustomOperation:A}){let[D,P]=(0,E.useState)(0),L=(0,E.useCallback)(()=>P(e=>++e),[]),[I,R]=(0,E.useState)(e);return(0,E.useEffect)(()=>R(e),[e]),(0,_.jsx)(L0.Provider,Object.assign({value:{src:I,collapseStringsAfterLength:t,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:i,collapsed:a,onCollapse:o,enableClipboard:s,editable:l,onEdit:c,onDelete:u,onAdd:d,onChange:h,forceUpdate:L,customizeNode:g,customizeCopy:x,displaySize:v,displayArrayIndex:y,matchesURL:j,urlRegExp:N,ignoreLargeArray:k,CopyComponent:S,CopiedComponent:C,EditComponent:T,CancelComponent:M,DoneComponent:O,CustomOperation:A}},{children:(0,_.jsx)("code",Object.assign({className:"json-view"+(f?" dark":"")+(p&&"default"!==p?" json-view_"+p:"")+(w?" "+w:""),style:b},{children:(0,_.jsx)(LQ,{node:I,depth:1,editHandle:(e,t,n,r)=>{R(t),c&&c({newValue:t,oldValue:n,depth:1,src:I,indexOrName:e,parentType:null,parentPath:r}),h&&h({type:"edit",depth:1,src:I,indexOrName:e,parentType:null,parentPath:r})},deleteHandle:(e,t)=>{R(void 0),u&&u({value:I,depth:1,src:I,indexOrName:e,parentType:null,parentPath:t}),h&&h({depth:1,src:I,indexOrName:e,parentType:null,type:"delete",parentPath:t})},parentPath:[]})}))}))}var tn=tn;let L2=(0,I.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"}]]),L5=(0,I.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 L3(){}function L4(){}let L6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L9={};function L8(e,t){return((t||L9).jsx?L7:L6).test(e)}let Ie=/[ \t\n\f\r]/g;function It(e){return""===e.replace(Ie,"")}class In{constructor(e,t){this.attribute=t,this.property=e}}In.prototype.attribute="",In.prototype.booleanish=!1,In.prototype.boolean=!1,In.prototype.commaOrSpaceSeparated=!1,In.prototype.commaSeparated=!1,In.prototype.defined=!1,In.prototype.mustUseProperty=!1,In.prototype.number=!1,In.prototype.overloadedBoolean=!1,In.prototype.property="",In.prototype.spaceSeparated=!1,In.prototype.space=void 0;let Ir=0,Ii=Id(),Ia=Id(),Io=Id(),Is=Id(),Il=Id(),Ic=Id(),Iu=Id();function Id(){return 2**++Ir}e.s(["boolean",0,Ii,"booleanish",0,Ia,"commaOrSpaceSeparated",0,Iu,"commaSeparated",0,Ic,"number",0,Is,"overloadedBoolean",0,Io,"spaceSeparated",0,Il],744);var Ih=e.i(744);let If=Object.keys(Ih);class Ip extends In{constructor(e,t,n,r){let i=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++i<If.length;){const e=If[i];!function(e,t,n){n&&(e[t]=n)}(this,If[i],(n&Ih[e])===Ih[e])}}}function Im(e){return e.toLowerCase()}Ip.prototype.defined=!0;let Ig=/[A-Z]/g,Ix=/-[a-z]/g,Iv=/^data[-\w.:]+$/i;function Iy(e){return"-"+e.toLowerCase()}function Ib(e){return e.charAt(1).toUpperCase()}let Iw={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 Ij{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function IN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Ij(n,r,t)}function Ik(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Ip(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Im(r)]=r,n[Im(a.attribute)]=r}return new Ij(t,n,e.space)}Ij.prototype.normal={},Ij.prototype.property={},Ij.prototype.space=void 0;let IS=Ik({properties:{ariaActiveDescendant:null,ariaAtomic:Ia,ariaAutoComplete:null,ariaBusy:Ia,ariaChecked:Ia,ariaColCount:Is,ariaColIndex:Is,ariaColSpan:Is,ariaControls:Il,ariaCurrent:null,ariaDescribedBy:Il,ariaDetails:null,ariaDisabled:Ia,ariaDropEffect:Il,ariaErrorMessage:null,ariaExpanded:Ia,ariaFlowTo:Il,ariaGrabbed:Ia,ariaHasPopup:null,ariaHidden:Ia,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Il,ariaLevel:Is,ariaLive:null,ariaModal:Ia,ariaMultiLine:Ia,ariaMultiSelectable:Ia,ariaOrientation:null,ariaOwns:Il,ariaPlaceholder:null,ariaPosInSet:Is,ariaPressed:Ia,ariaReadOnly:Ia,ariaRelevant:null,ariaRequired:Ia,ariaRoleDescription:Il,ariaRowCount:Is,ariaRowIndex:Is,ariaRowSpan:Is,ariaSelected:Ia,ariaSetSize:Is,ariaSort:null,ariaValueMax:Is,ariaValueMin:Is,ariaValueNow:Is,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function IC(e,t){return t in e?e[t]:t}function I_(e,t){return IC(e,t.toLowerCase())}let IE=Ik({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ic,acceptCharset:Il,accessKey:Il,action:null,allow:null,allowFullScreen:Ii,allowPaymentRequest:Ii,allowUserMedia:Ii,alt:null,as:null,async:Ii,autoCapitalize:null,autoComplete:Il,autoFocus:Ii,autoPlay:Ii,blocking:Il,capture:null,charSet:null,checked:Ii,cite:null,className:Il,cols:Is,colSpan:null,content:null,contentEditable:Ia,controls:Ii,controlsList:Il,coords:Is|Ic,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ii,defer:Ii,dir:null,dirName:null,disabled:Ii,download:Io,draggable:Ia,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ii,formTarget:null,headers:Il,height:Is,hidden:Io,high:Is,href:null,hrefLang:null,htmlFor:Il,httpEquiv:Il,id:null,imageSizes:null,imageSrcSet:null,inert:Ii,inputMode:null,integrity:null,is:null,isMap:Ii,itemId:null,itemProp:Il,itemRef:Il,itemScope:Ii,itemType:Il,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ii,low:Is,manifest:null,max:null,maxLength:Is,media:null,method:null,min:null,minLength:Is,multiple:Ii,muted:Ii,name:null,nonce:null,noModule:Ii,noValidate:Ii,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:Ii,optimum:Is,pattern:null,ping:Il,placeholder:null,playsInline:Ii,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ii,referrerPolicy:null,rel:Il,required:Ii,reversed:Ii,rows:Is,rowSpan:Is,sandbox:Il,scope:null,scoped:Ii,seamless:Ii,selected:Ii,shadowRootClonable:Ii,shadowRootDelegatesFocus:Ii,shadowRootMode:null,shape:null,size:Is,sizes:null,slot:null,span:Is,spellCheck:Ia,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Is,step:null,style:null,tabIndex:Is,target:null,title:null,translate:null,type:null,typeMustMatch:Ii,useMap:null,value:Ia,width:Is,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Il,axis:null,background:null,bgColor:null,border:Is,borderColor:null,bottomMargin:Is,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ii,declare:Ii,event:null,face:null,frame:null,frameBorder:null,hSpace:Is,leftMargin:Is,link:null,longDesc:null,lowSrc:null,marginHeight:Is,marginWidth:Is,noResize:Ii,noHref:Ii,noShade:Ii,noWrap:Ii,object:null,profile:null,prompt:null,rev:null,rightMargin:Is,rules:null,scheme:null,scrolling:Ia,standby:null,summary:null,text:null,topMargin:Is,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Is,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ii,disableRemotePlayback:Ii,prefix:null,property:null,results:Is,security:null,unselectable:null},space:"html",transform:I_}),IT=Ik({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:Iu,accentHeight:Is,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Is,amplitude:Is,arabicForm:null,ascent:Is,attributeName:null,attributeType:null,azimuth:Is,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Is,by:null,calcMode:null,capHeight:Is,className:Il,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:Is,diffuseConstant:Is,direction:null,display:null,dur:null,divisor:Is,dominantBaseline:null,download:Ii,dx:null,dy:null,edgeMode:null,editable:null,elevation:Is,enableBackground:null,end:null,event:null,exponent:Is,externalResourcesRequired:null,fill:null,fillOpacity:Is,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:Ic,g2:Ic,glyphName:Ic,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Is,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Is,horizOriginX:Is,horizOriginY:Is,id:null,ideographic:Is,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Is,k:Is,k1:Is,k2:Is,k3:Is,k4:Is,kernelMatrix:Iu,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Is,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:Is,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:Is,overlineThickness:Is,paintOrder:null,panose1:null,path:null,pathLength:Is,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Il,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Is,pointsAtY:Is,pointsAtZ:Is,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Iu,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Iu,rev:Iu,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Iu,requiredFeatures:Iu,requiredFonts:Iu,requiredFormats:Iu,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:Is,specularExponent:Is,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Is,strikethroughThickness:Is,string:null,stroke:null,strokeDashArray:Iu,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Is,strokeOpacity:Is,strokeWidth:null,style:null,surfaceScale:Is,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Iu,tabIndex:Is,tableValues:null,target:null,targetX:Is,targetY:Is,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Iu,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Is,underlineThickness:Is,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Is,values:null,vAlphabetic:Is,vMathematical:Is,vectorEffect:null,vHanging:Is,vIdeographic:Is,version:null,vertAdvY:Is,vertOriginX:Is,vertOriginY:Is,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Is,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:IC}),IM=Ik({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),IO=Ik({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:I_}),IA=Ik({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),ID=IN([IS,IE,IM,IO,IA],"html"),IP=IN([IS,IT,IM,IO,IA],"svg");var IL=e.i(15511);let II=IB("end"),IR=IB("start");function IB(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function Iz(e){return e&&"object"==typeof e?"position"in e||"type"in e?IV(e.position):"start"in e||"end"in e?IV(e):"line"in e||"column"in e?IF(e):"":""}function IF(e){return IH(e&&e.line)+":"+IH(e&&e.column)}function IV(e){return IF(e&&e.start)+"-"+IF(e&&e.end)}function IH(e){return e&&"number"==typeof e?e:1}class IU extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},a=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=Iz(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}IU.prototype.file="",IU.prototype.name="",IU.prototype.reason="",IU.prototype.message="",IU.prototype.stack="",IU.prototype.column=void 0,IU.prototype.line=void 0,IU.prototype.ancestors=void 0,IU.prototype.cause=void 0,IU.prototype.fatal=void 0,IU.prototype.place=void 0,IU.prototype.ruleId=void 0,IU.prototype.source=void 0;let IW={}.hasOwnProperty,IY=new Map,IG=/[A-Z]/g,I$=new Set(["table","tbody","thead","tfoot","tr"]),IX=new Set(["td","th"]),Iq="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function IK(e,t,n){var r,i,a,o,s,l,c,u,d;let h,f,p,g,x,v,y,b,w,j,N;return"element"===t.type?(r=e,i=t,a=n,f=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=IP),r.ancestors.push(i),p=I0(r,i.tagName,!1),g=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&IW.call(t.properties,r)){let a=function(e,t,n){let r=function(e,t){let n=Im(t),r=t,i=In;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Iv.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(Ix,Ib);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ix.test(e)){let n=e.replace(Ig,Iy);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=Ip}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,IL.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new IU("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=Iq+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)IW.call(e,t)&&(n[function(e){let t=e.replace(IG,I2);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Iw[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(a){let[r,o]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof o&&IX.has(t.tagName)?n=o:i[r]=o}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),x=IJ(r,i),I$.has(i.tagName)&&(x=x.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&It(e.value):It(e))})),IZ(r,g,p,i),IQ(g,x),r.ancestors.pop(),r.schema=h,r.create(i,p,g,a)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return L3("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}I1(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(o=e,s=t,l=n,y=v=o.schema,"svg"===s.name&&"html"===v.space&&(o.schema=IP),o.ancestors.push(s),b=null===s.name?o.Fragment:I0(o,s.name,!0),w=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];L3("ExpressionStatement"===t.type);let i=t.expression;L3("ObjectExpression"===i.type);let a=i.properties[0];L3("SpreadElement"===a.type),Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else I1(e,t.position);else{let i,a=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];L3("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else I1(e,t.position);else i=null===r.value||r.value;n[a]=i}return n}(o,s),j=IJ(o,s),IZ(o,w,b,s),IQ(w,j),o.ancestors.pop(),o.schema=v,o.create(s,b,w,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);I1(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=n,IQ(N={},IJ(c,u)),c.create(u,c.Fragment,N,d)):"text"===t.type?t.value:void 0}function IZ(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function IQ(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function IJ(e,t){let n=[],r=-1,i=e.passKeys?new Map:IY;for(;++r<t.children.length;){let a,o=t.children[r];if(e.passKeys){let e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){let t=i.get(e)||0;a=e+"-"+t,i.set(e,t+1)}}let s=IK(e,o,a);void 0!==s&&n.push(s)}return n}function I0(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=L8(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}L3(e,"always a result"),r=e}else r=L8(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return IW.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);I1(e)}function I1(e,t){let n=new IU("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Iq+"#cannot-handle-mdx-estrees-without-createevaluater",n}function I2(e){return"-"+e.toLowerCase()}let I5={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"]},I3={};function I4(e,t){let n=t||I3;return I6(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function I6(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return I7(e.children,t,n)}return Array.isArray(e)?I7(e,t,n):""}function I7(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=I6(e[i],t,n);return r.join("")}function I9(e,t,n,r){let i,a=e.length,o=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)(i=r.slice(o,o+1e4)).unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function I8(e,t){return e.length>0?(I9(e,e.length,0,t),e):t}let Re={}.hasOwnProperty;function Rt(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(Re.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];if(a)for(r in a){Re.call(i,r)||(i[r]=[]);let e=a[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);I9(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}function Rn(e){return null!==e&&e<-2}function Rr(e){return -2===e||-1===e||32===e}function Ri(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Ra(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return Rr(r)?(e.enter(n),function r(o){return Rr(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Ri(/[A-Za-z]/),Ri(/[\dA-Za-z]/),Ri(/[#-'*+\--9=?A-Z^-~]/),Ri(/\d/),Ri(/[\dA-Fa-f]/),Ri(/[!-/:-@[-`{-~]/),Ri(/\p{P}|\p{S}/u),Ri(/\s/);let Ro={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Ra(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return Rn(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},Rs={tokenize:function(e){let t,n,r,i=this,a=[],o=0;return s;function s(t){if(o<a.length){let n=a[o];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(o++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&v();let r=i.events.length,a=r;for(;a--;)if("exit"===i.events[a][0]&&"chunkFlow"===i.events[a][1].type){n=i.events[a][1].end;break}x(o);let s=r;for(;s<i.events.length;)i.events[s][1].end={...n},s++;return I9(i.events,a+1,0,i.events.slice(r)),i.events.length=s,c(e)}return s(e)}function c(n){if(o===a.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return p(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(Rl,u,d)(n)}function u(e){return t&&v(),x(o),h(e)}function d(e){return i.parser.lazy[i.now().line]=o!==a.length,r=i.now().offset,p(e)}function h(t){return i.containerState={},e.attempt(Rl,f,p)(t)}function f(e){return o++,a.push([i.currentConstruct,i.containerState]),h(e)}function p(r){if(null===r){t&&v(),x(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){g(e.exit("chunkFlow"),!0),x(0),e.consume(n);return}return Rn(n)?(e.consume(n),g(e.exit("chunkFlow")),o=0,i.interrupt=void 0,s):(e.consume(n),t)}(r)}function g(e,a){let s=i.sliceStream(e);if(a&&s.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(s),i.parser.lazy[e.start.line]){let e,n,a=t.events.length;for(;a--;)if(t.events[a][1].start.offset<r&&(!t.events[a][1].end||t.events[a][1].end.offset>r))return;let s=i.events.length,l=s;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(x(o),a=s;a<i.events.length;)i.events[a][1].end={...n},a++;I9(i.events,l+1,0,i.events.slice(s)),i.events.length=a}}function x(t){let n=a.length;for(;n-- >t;){let t=a[n];i.containerState=t[1],t[0].exit.call(i,e)}a.length=t}function v(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},Rl={tokenize:function(e,t,n){return Ra(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},Rc=Rv(/[A-Za-z]/),Ru=Rv(/[\dA-Za-z]/),Rd=Rv(/[#-'*+\--9=?A-Z^-~]/),Rh=Rv(/\d/),Rf=Rv(/[\dA-Fa-f]/),Rp=Rv(/[!-/:-@[-`{-~]/);function Rm(e){return null!==e&&e<-2}function Rg(e){return null!==e&&(e<0||32===e)}function Rx(e){return -2===e||-1===e||32===e}function Rv(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Ry(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return Rx(r)?(e.enter(n),function r(o){return Rx(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Rv(/\p{P}|\p{S}/u),Rv(/\s/);let Rb={partial:!0,tokenize:function(e,t,n){return function(t){return Rx(t)?Ry(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Rm(e)?t(e):n(e)}}};class Rw{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&Rj(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Rj(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Rj(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);Rj(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Rj(this.left,t.reverse())}}}function Rj(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function RN(e){let t,n,r,i,a,o,s,l={},c=-1,u=new Rw(e);for(;++c<u.length;){for(;c in l;)c=l[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((r=0)<(o=t[1]._tokenizer.events).length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],a=e.get(t)[2],o=t-1,s=[],l=i._tokenizer;!l&&(l=a.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,u=[],d={},h=-1,f=i,p=0,g=0,x=[0];for(;f;){for(;e.get(++o)[1]!==f;);s.push(o),!f._tokenizer&&(n=a.sliceStream(f),f.next||n.push(null),r&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=f,f=f.next}for(f=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(g=h+1,x.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),h=x.length;h--;){let t=c.slice(x[h],x[h+1]),n=s.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),h=-1;++h<u.length;)d[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return d}(u,c)),c=l[c],s=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=u.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(u.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...u.get(n)[1].start},(a=u.slice(n,c)).unshift(t),u.splice(n,c-n+1,a))}}return I9(e,0,1/0,u.slice(0)),!s}let Rk={resolve:function(e){return RN(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):Rm(t)?e.check(RS,a,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},RS={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Ry(e,i,"linePrefix")};function i(i){if(null===i||Rm(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},RC={tokenize:function(e){let t=this,n=e.attempt(Rb,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,Ra(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Rk,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},R_={resolveAll:RO()},RE=RM("string"),RT=RM("text");function RM(e){return{resolveAll:RO("text"===e?RA:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return l(e)?i(e):o(e)}function o(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),s)}function s(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function RO(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function RA(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],a=t.sliceStream(i),o=a.length,s=-1,l=0;for(;o--;){let e=a[o];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let a={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}RL(/[A-Za-z]/),RL(/[\dA-Za-z]/),RL(/[#-'*+\--9=?A-Z^-~]/),RL(/\d/),RL(/[\dA-Fa-f]/),RL(/[!-/:-@[-`{-~]/);let RD=RL(/\p{P}|\p{S}/u),RP=RL(/\s/);function RL(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function RI(e){return null===e||null!==e&&(e<0||32===e)||RP(e)?1:RD(e)?2:void 0}function RR(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}let RB={name:"attention",resolveAll:function(e,t){let n,r,i,a,o,s,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[n][1].end},h={...e[u][1].start};Rz(d,-s),Rz(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},o={type:s>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},i={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:s>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[n][1].end={...a.start},e[u][1].start={...o.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=I8(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=I8(l,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",i,t]]),l=I8(l,RR(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=I8(l,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=I8(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,I9(e,n-1,u-n+3,l),u=n+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,a=RI(i);return function(o){return n=o,e.enter("attentionSequence"),function o(s){if(s===n)return e.consume(s),o;let l=e.exit("attentionSequence"),c=RI(s),u=!c||2===c&&a||r.includes(s),d=!a||2===a&&c||r.includes(i);return l._open=!!(42===n?u:u&&(a||!d)),l._close=!!(42===n?d:d&&(c||!u)),t(s)}(o)}}};function Rz(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let RF={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return Rx(t)?Ry(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(RF,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return Rx(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},RV={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return Rp(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},RH=document.createElement("i");function RU(e){let t="&"+e+";";RH.innerHTML=t;let n=RH.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let RW={name:"characterReference",tokenize:function(e,t,n){let r,i,a=this,o=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=Ru,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=Rf,c):(e.enter("characterReferenceValue"),r=7,i=Rh,c(t))}function c(s){if(59===s&&o){let r=e.exit("characterReferenceValue");return i!==Ru||RU(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return i(s)&&o++<r?(e.consume(s),c):n(s)}}},RY={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},RG={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(t){return e.enter("codeFencedFence"),Rx(t)?Ry(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a>=s?(e.exit("codeFencedFenceSequence"),Rx(i)?Ry(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||Rm(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},o=0,s=0;return function(t){var a;let c;return a=t,o=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=a,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s<3?n(i):(e.exit("codeFencedFenceSequence"),Rx(i)?Ry(e,l,"whitespace")(i):l(i))}(a)};function l(a){return null===a||Rm(a)?(e.exit("codeFencedFence"),i.interrupt?t(a):e.check(RY,u,p)(a)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||Rm(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):Rx(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ry(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(a))}function c(t){return null===t||Rm(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||Rm(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function u(t){return e.attempt(a,p,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return o>0&&Rx(t)?Ry(e,f,"linePrefix",o+1)(t):f(t)}function f(t){return null===t||Rm(t)?e.check(RY,u,p)(t):(e.enter("codeFlowValue"),function t(n){return null===n||Rm(n)?(e.exit("codeFlowValue"),f(n)):(e.consume(n),t)}(t))}function p(n){return e.exit("codeFenced"),t(n)}}},R$={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),Ry(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?a(n):Rm(n)?e.attempt(RX,t,a)(n):(e.enter("codeFlowValue"),function n(r){return null===r||Rm(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function a(n){return e.exit("codeIndented"),t(n)}}},RX={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Rm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):Ry(e,a,"linePrefix",5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Rm(e)?i(e):n(e)}}};function Rq(e){return null!==e&&(e<32||127===e)}function RK(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function RZ(e,t,n,r,i,a,o,s,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),d):null===t||32===t||41===t||Rq(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),p(t))};function d(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||null!==t&&t<-2?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function p(i){return!u&&(null===i||41===i||null!==i&&(i<0||32===i))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(i)):u<c&&40===i?(e.consume(i),u++,p):41===i?(e.consume(i),u--,p):null===i||32===i||40===i||Rq(i)?n(i):(e.consume(i),92===i?g:p)}function g(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function RQ(e){return null!==e&&e<-2}function RJ(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R0(e,t,n,r,i,a){let o,s=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),c};function c(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):RQ(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||RQ(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=-2!==t&&-1!==t&&32!==t),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function R1(e){return null!==e&&e<-2}function R2(e){return -2===e||-1===e||32===e}function R5(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R3(e,t,n,r,i,a){let o;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=40===t?41:t,s):n(t)};function s(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){if(t===o)return e.exit(a),s(o);if(null===t)return n(t);if(R1(t)){var r,i;let n,a;return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r=l,i="linePrefix",n=1/0,a=0,function(t){return R2(t)?(e.enter(i),function t(o){return R2(o)&&a++<n?(e.consume(o),t):(e.exit(i),r(o))}(t)):r(t)}}return e.enter("chunkString",{contentType:"string"}),c(t)}function c(t){return t===o||null===t||R1(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===o||92===t?(e.consume(t),c):c(t)}}function R4(e){return -2===e||-1===e||32===e}function R6(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R7(e,t){let n;return function r(i){var a,o;if(null!==i&&i<-2)return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r;if(R4(i)){let t,s;return(a=r,o=n?"linePrefix":"lineSuffix",t=1/0,s=0,function(n){return R4(n)?(e.enter(o),function n(r){return R4(r)&&s++<t?(e.consume(r),n):(e.exit(o),a(r))}(n)):a(n)})(i)}return t(i)}}function R9(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}RK(/[A-Za-z]/),RK(/[\dA-Za-z]/),RK(/[#-'*+\--9=?A-Z^-~]/),RK(/\d/),RK(/[\dA-Fa-f]/),RK(/[!-/:-@[-`{-~]/),RK(/\p{P}|\p{S}/u),RK(/\s/),RJ(/[A-Za-z]/),RJ(/[\dA-Za-z]/),RJ(/[#-'*+\--9=?A-Z^-~]/),RJ(/\d/),RJ(/[\dA-Fa-f]/),RJ(/[!-/:-@[-`{-~]/),RJ(/\p{P}|\p{S}/u),RJ(/\s/),R5(/[A-Za-z]/),R5(/[\dA-Za-z]/),R5(/[#-'*+\--9=?A-Z^-~]/),R5(/\d/),R5(/[\dA-Fa-f]/),R5(/[!-/:-@[-`{-~]/),R5(/\p{P}|\p{S}/u),R5(/\s/),R6(/[A-Za-z]/),R6(/[\dA-Za-z]/),R6(/[#-'*+\--9=?A-Z^-~]/),R6(/\d/),R6(/[\dA-Fa-f]/),R6(/[!-/:-@[-`{-~]/),R6(/\p{P}|\p{S}/u),R6(/\s/);let R8={partial:!0,tokenize:function(e,t,n){return function(t){return Rg(t)?R7(e,r)(t):n(t)};function r(t){return R3(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return Rx(t)?Ry(e,a,"whitespace")(t):a(t)}function a(e){return null===e||Rm(e)?t(e):n(e)}}},Be=["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"],Bt=["pre","script","style","textarea"],Bn={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Rb,t,n)}}},Br={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return Rm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Bi={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&I9(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,a,o=e.length,s=0;for(;o--;)if(n=e[o][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[o][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[o][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=o,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(i=o);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},u={type:"labelText",start:{...e[r+s+2][1].end},end:{...e[i-2][1].start}};return a=I8(a=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+s+3)),a=I8(a,[["enter",u,t]]),a=I8(a,RR(t.parser.constructs.insideSpan.null,e.slice(r+s+4,i-3),t)),a=I8(a,[["exit",u,t],e[i-2],e[i-1],["exit",c,t]]),a=I8(a,e.slice(i+1)),a=I8(a,[["exit",l,t]]),I9(e,r,e.length,a),e},tokenize:function(e,t,n){let r,i,a=this,o=a.events.length;for(;o--;)if(("labelImage"===a.events[o][1].type||"labelLink"===a.events[o][1].type)&&!a.events[o][1]._balanced){r=a.events[o][1];break}return function(t){return r?r._inactive?u(t):(i=a.parser.defined.includes(R9(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)};function s(t){return 40===t?e.attempt(Ba,c,i?c:u)(t):91===t?e.attempt(Bo,c,i?l:u)(t):i?c(t):u(t)}function l(t){return e.attempt(Bs,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},Ba={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return Rg(t)?R7(e,i)(t):i(t)}function i(t){return 41===t?c(t):RZ(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return Rg(t)?R7(e,s)(t):c(t)}function o(e){return n(e)}function s(t){return 34===t||39===t||40===t?R3(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Rg(t)?R7(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},Bo={tokenize:function(e,t,n){let r=this;return function(t){return R0.call(r,e,i,a,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(R9(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},Bs={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},Bl={name:"labelStartImage",resolveAll:Bi.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},Bc={name:"labelStartLink",resolveAll:Bi.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},Bu={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Ry(e,t,"linePrefix")}}},Bd={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(a){var o;return e.enter("thematicBreak"),r=o=a,function a(o){return o===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),Rx(n)?Ry(e,a,"whitespace")(n):a(n))}(o)):i>=3&&(null===o||Rm(o))?(e.exit("thematicBreak"),t(o)):n(o)}(o)}}},Bh={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Rb,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ry(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!Rx(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Bp,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ry(e,e.attempt(Bh,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,o=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:Rh(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(Bd,n,s)(t):s(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return Rh(i)&&++o<10?(e.consume(i),t):(!r.interrupt||o<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),s(i)):n(i)}(t)}return n(t)};function s(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(Rb,r.interrupt?n:l,e.attempt(Bf,u,c))}function l(e){return r.containerState.initialBlankLine=!0,a++,u(e)}function c(t){return Rx(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Bf={partial:!0,tokenize:function(e,t,n){let r=this;return Ry(e,function(e){let i=r.events[r.events.length-1];return!Rx(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Bp={partial:!0,tokenize:function(e,t,n){let r=this;return Ry(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},Bm={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(r=a)}else"content"===e[a][1].type&&e.splice(a,1),i||"definition"!==e[a][1].type||(i=a);let o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",o,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=o,e.push(["exit",o,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var o;let s,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){s="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||s)?(e.enter("setextHeadingLine"),r=t,o=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),Rx(n)?Ry(e,a,"lineSuffix")(n):a(n))}(o)):n(t)};function a(r){return null===r||Rm(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,R0.call(i,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function a(t){return(r=R9(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o):n(t)}function o(t){return Rg(t)?R7(e,s)(t):s(t)}function s(t){return RZ(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(R8,c,c)(t)}function c(t){return Rx(t)?Ry(e,u,"whitespace")(t):u(t)}function u(a){return null===a||Rm(a)?(e.exit("definition"),i.parser.defined.push(r),t(a)):n(a)}}}},"disable",0,{null:[]},"document",0,{42:Bh,43:Bh,45:Bh,48:Bh,49:Bh,50:Bh,51:Bh,52:Bh,53:Bh,54:Bh,55:Bh,56:Bh,57:Bh,62:RF},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,a=3;return"whitespace"===e[3][1].type&&(a+=2),i-2>a&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(a===i-1||i-4>a&&"whitespace"===e[i-2][1].type)&&(i-=a+1===i?2:4),i>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[i][1].end},r={type:"chunkText",start:e[a][1].start,end:e[i][1].end,contentType:"text"},I9(e,a,i-a+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var a;return e.enter("atxHeading"),a=i,e.enter("atxHeadingSequence"),function i(a){return 35===a&&r++<6?(e.consume(a),i):null===a||Rg(a)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||Rm(r)?(e.exit("atxHeading"),t(r)):Rx(r)?Ry(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||Rg(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(a)):n(a)}(a)}}},42:Bd,45:[Bm,Bd],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,a,o,s,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),i=!0,f):63===o?(e.consume(o),r=3,l.interrupt?t:D):Rc(o)?(e.consume(o),a=String.fromCharCode(o),p):n(o)}function u(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,o=0,h):Rc(i)?(e.consume(i),r=4,l.interrupt?t:D):n(i)}function d(r){return 45===r?(e.consume(r),l.interrupt?t:D):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(o++)?(e.consume(r),o===i.length)?l.interrupt?t:S:h:n(r)}function f(t){return Rc(t)?(e.consume(t),a=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Rg(o)){let s=47===o,c=a.toLowerCase();return!s&&!i&&Bt.includes(c)?(r=1,l.interrupt?t(o):S(o)):Be.includes(a.toLowerCase())?(r=6,s)?(e.consume(o),g):l.interrupt?t(o):S(o):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(o):i?function t(n){return Rx(n)?(e.consume(n),t):N(n)}(o):x(o))}return 45===o||Ru(o)?(e.consume(o),a+=String.fromCharCode(o),p):n(o)}function g(r){return 62===r?(e.consume(r),l.interrupt?t:S):n(r)}function x(t){return 47===t?(e.consume(t),N):58===t||95===t||Rc(t)?(e.consume(t),v):Rx(t)?(e.consume(t),x):N(t)}function v(t){return 45===t||46===t||58===t||95===t||Ru(t)?(e.consume(t),v):y(t)}function y(t){return 61===t?(e.consume(t),b):Rx(t)?(e.consume(t),y):x(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),s=t,w):Rx(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||Rg(n)?y(n):(e.consume(n),t)}(t)}function w(t){return t===s?(e.consume(t),s=null,j):null===t||Rm(t)?n(t):(e.consume(t),w)}function j(e){return 47===e||62===e||Rx(e)?x(e):n(e)}function N(t){return 62===t?(e.consume(t),k):n(t)}function k(t){return null===t||Rm(t)?S(t):Rx(t)?(e.consume(t),k):n(t)}function S(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),M):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),D):93===t&&5===r?(e.consume(t),A):Rm(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(Bn,L,C)(t)):null===t||Rm(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),S)}function C(t){return e.check(Br,_,L)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||Rm(t)?C(t):(e.enter("htmlFlowData"),S(t))}function T(t){return 45===t?(e.consume(t),D):S(t)}function M(t){return 47===t?(e.consume(t),a="",O):S(t)}function O(t){if(62===t){let n=a.toLowerCase();return Bt.includes(n)?(e.consume(t),P):S(t)}return Rc(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),O):S(t)}function A(t){return 93===t?(e.consume(t),D):S(t)}function D(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),D):S(t)}function P(t){return null===t||Rm(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),P)}function L(n){return e.exit("htmlFlow"),t(n)}}},61:Bm,95:Bd,96:RG,126:RG},"flowInitial",0,{[-2]:R$,[-1]:R$,32:R$},"insideSpan",0,{null:[RB,R_]},"string",0,{38:RW,92:RV},"text",0,{[-5]:Bu,[-4]:Bu,[-3]:Bu,33:Bl,38:RW,42:RB,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return Rc(t)?(e.consume(t),a):64===t?n(t):s(t)}function a(t){return 43===t||45===t||46===t||Ru(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,o):(43===n||45===n||46===n||Ru(n))&&r++<32?(e.consume(n),t):(r=0,s(n))}(t)):s(t)}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||null!==r&&(r<32||127===r)?n(r):(e.consume(r),o)}function s(t){return 64===t?(e.consume(t),l):Rd(t)?(e.consume(t),s):n(t)}function l(i){return Ru(i)?function i(a){return 46===a?(e.consume(a),r=0,l):62===a?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(a){if((45===a||Ru(a))&&r++<63){let n=45===a?t:i;return e.consume(a),n}return n(a)}(a)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,a,o=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),w):63===t?(e.consume(t),y):Rc(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,f):Rc(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):Rm(t)?(a=u,O(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?M(e):45===e?d(e):u(e)}function f(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),g):Rm(t)?(a=p,O(t)):(e.consume(t),p)}function g(t){return 93===t?(e.consume(t),x):p(t)}function x(t){return 62===t?M(t):93===t?(e.consume(t),x):p(t)}function v(t){return null===t||62===t?M(t):Rm(t)?(a=v,O(t)):(e.consume(t),v)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Rm(t)?(a=y,O(t)):(e.consume(t),y)}function b(e){return 62===e?M(e):y(e)}function w(t){return Rc(t)?(e.consume(t),j):n(t)}function j(t){return 45===t||Ru(t)?(e.consume(t),j):function t(n){return Rm(n)?(a=t,O(n)):Rx(n)?(e.consume(n),t):M(n)}(t)}function N(t){return 45===t||Ru(t)?(e.consume(t),N):47===t||62===t||Rg(t)?k(t):n(t)}function k(t){return 47===t?(e.consume(t),M):58===t||95===t||Rc(t)?(e.consume(t),S):Rm(t)?(a=k,O(t)):Rx(t)?(e.consume(t),k):M(t)}function S(t){return 45===t||46===t||58===t||95===t||Ru(t)?(e.consume(t),S):function t(n){return 61===n?(e.consume(n),C):Rm(n)?(a=t,O(n)):Rx(n)?(e.consume(n),t):k(n)}(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,_):Rm(t)?(a=C,O(t)):Rx(t)?(e.consume(t),C):(e.consume(t),E)}function _(t){return t===r?(e.consume(t),r=void 0,T):null===t?n(t):Rm(t)?(a=_,O(t)):(e.consume(t),_)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Rg(t)?k(t):(e.consume(t),E)}function T(e){return 47===e||62===e||Rg(e)?k(e):n(e)}function M(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function O(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),A}function A(t){return Rx(t)?Ry(e,D,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),a(t)}}}],91:Bc,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Rm(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},RV],93:Bi,95:RB,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),a++,t):(e.exit("codeTextSequence"),o(n))}(t)};function o(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),o):96===l?(i=e.enter("codeTextSequence"),r=0,function n(o){return 96===o?(e.consume(o),r++,n):r===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(o)):(i.type="codeTextData",s(o))}(l)):Rm(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):(e.enter("codeTextData"),s(l))}function s(t){return null===t||32===t||96===t||Rm(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),s)}}}}],4127);var Bg=e.i(4127);let Bx=/[\0\t\n\r]/g;function Bv(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let By=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Bb(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return Bv(n.slice(t?2:1),t?16:10)}return RU(n)||e}let Bw={}.hasOwnProperty;function Bj(e){return{line:e.line,column:e.column,offset:e.offset}}function BN(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+Iz({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Iz({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+Iz({start:t.start,end:t.end})+") is still open")}function Bk(e){let t=this;t.parser=function(n){var r,i;let a,o,s,l;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(p),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(f),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(f,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(g),hardBreakTrailing:r(g),htmlFlow:r(x,i),htmlFlowData:c,htmlText:r(x,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(v),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(y),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(p),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:o(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:o(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:o(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=Bv(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=RU(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=Bj(e.end)},codeFenced:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.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 e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:o(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=R9(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:o(),hardBreakEscape:o(d),hardBreakTrailing:o(d),htmlFlow:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(By,Bb),n.identifier=R9(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=Bj(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),u.call(this,e))},link:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=R9(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:o(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:o(),thematicBreak:o()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(Bw.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:a,exit:s,buffer:i,resume:l,data:n},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,n){let r,i,a,o,s=t-1,l=-1,c=!1;for(;++s<=n;){let t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,o=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||o||l||a||(a=s),o=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:o=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let o=s;for(i=void 0;o--;){let t=e[o];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=o}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}a&&(!i||a<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||s,0,["exit",r,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(s,0,["enter",i,t[2]]),s++,n++,a=void 0,o=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),u));for(u=-1;++u<e.length;){let n=t[e[u][0]];Bw.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},o),e[u][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||BN).call(o,void 0,e[0])}for(r.position={start:Bj(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Bj(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r};function r(e,t){return function(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Bj(t.start),end:void 0}}function o(e){return function(t){e&&e.call(this,t),s.call(this,t)}}function s(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||BN).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Iz({start:e.start,end:e.end})+"): it’s not open");n.position.end=Bj(e.end)}function l(){return I4(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:Bj(e.start),end:void 0},t.push(n)),this.stack.push(n)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Bj(e.end)}function d(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function p(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function x(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!RN(e););return e}((function(e){let t={constructs:Rt([Bg,...(e||{}).extensions||[]]),content:n(Ro),defined:[],document:n(Rs),flow:n(RC),lazy:{},string:n(RE),text:n(RT)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],l={attempt:p(function(e,t){g(e,t.from)}),check:p(f),consume:function(e){Rn(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,x()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){let t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:p(f,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,x()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let a,o=e[r];if("string"==typeof o)a=o;else switch(o){case -5:a="\r";break;case -4:a="\n";break;case -3:a="\r\n";break;case -2:a=t?" ":" ";break;case -1:if(!t&&n)continue;a=" ";break;default:a=String.fromCharCode(o)}n=-2===o,i.push(a)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(o=I8(o,e),function(){let e;for(;r._index<o.length;){let n=o[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==o[o.length-1])?[]:(g(t,0),c.events=RR(a,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;if(r===a)n=[e[r].slice(i,o)];else{if(n=e.slice(r,a),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}o>0&&n.push(e[a].slice(0,o))}return n}(o,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function f(e,t){t.restore()}function p(e,t){return function(n,i,a){var o;let u,d,f,p;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(o=n,function(e){let t=null!==e&&o[e],n=null!==e&&o.null;return g([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(u=e,d=0,0===e.length)?a:v(e[d])}function v(e){return function(n){let i,a,o,u,d;return(i=h(),a=c.previous,o=c.currentConstruct,u=c.events.length,d=Array.from(s),p={from:u,restore:function(){r=i,c.previous=a,c.currentConstruct=o,c.events.length=u,s=d,x()}},f=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,y,b)(n)}}function y(t){return e(f,p),i}function b(e){return(p.restore(),++d<u.length)?v(u[d]):a}}}function g(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&I9(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function x(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((o=1,s="",l=!0,function(e,t,n){let r,i,c,u,d,h=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,s="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(Bx.lastIndex=c,u=(r=Bx.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(u),!r){s=e.slice(c);break}if(10===d&&c===u&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),c<u&&(h.push(e.slice(c,u)),o+=u-c),d){case 0:h.push(65533),o++;break;case 9:for(i=4*Math.ceil(o/4),h.push(-2);o++<i;)h.push(-1);break;case 10:h.push(-4),o=1;break;default:a=!0,o=1}c=u+1}return n&&(a&&h.push(-5),s&&h.push(s),h.push(null)),h})(n,r,!0))))}}let BS="object"==typeof self?self:globalThis,BC=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[a,o]=e[i];switch(a){case 0:case -1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new BS[e](t),i)}case 8:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new BS[a](o),i)})(0)},{toString:B_}={},{keys:BE}=Object,BT=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=B_.call(e).slice(8,-1);switch(n){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,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},BM=([e,t])=>0===e&&("function"===t||"symbol"===t),BO=(e,{json:t,lossy:n}={})=>{var r,i,a;let o,s,l=[];return(r=!(t||n),i=!!t,a=new Map,o=(e,t)=>{let n=l.push(e)-1;return a.set(t,n),n},s=e=>{if(a.has(e))return a.get(e);let[t,n]=BT(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return o([-1],e)}return o([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),o([n,[...t]],e)}let r=[],i=o([t,r],e);for(let t of e)r.push(s(t));return i}case 2:{if(n)switch(n){case"BigInt":return o([n,e.toString()],e);case"Boolean":case"Number":case"String":return o([n,e.valueOf()],e)}if(i&&"toJSON"in e)return s(e.toJSON());let a=[],l=o([t,a],e);for(let t of BE(e))(r||!BM(BT(e[t])))&&a.push([s(t),s(e[t])]);return l}case 3:return o([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return o([t,{source:n,flags:r}],e)}case 5:{let n=[],i=o([t,n],e);for(let[t,i]of e)(r||!(BM(BT(t))||BM(BT(i))))&&n.push([s(t),s(i)]);return i}case 6:{let n=[],i=o([t,n],e);for(let t of e)(r||!BM(BT(t)))&&n.push(s(t));return i}}let{message:l}=e;return o([t,{name:n,message:l}],e)})(e),l},BA="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?BC(BO(e,t)):structuredClone(e):(e,t)=>BC(BO(e,t));BP(/[A-Za-z]/);let BD=BP(/[\dA-Za-z]/);function BP(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function BL(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o="";if(37===a&&BD(e.charCodeAt(n+1))&&BD(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function BI(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function BR(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}BP(/[#-'*+\--9=?A-Z^-~]/),BP(/\d/),BP(/[\dA-Fa-f]/),BP(/[!-/:-@[-`{-~]/),BP(/\p{P}|\p{S}/u),BP(/\s/);let BB=function(e){var t,n;if(null==e)return BF;if("function"==typeof e)return Bz(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=BB(e[n]);return Bz(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,Bz(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,Bz(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function Bz(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function BF(){return!0}let BV=[];function BH(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let a=BB(i),o=r?-1:1;(function e(i,s,l){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,h,f=BV;if((!t||a(i,s,l[l.length-1]||void 0))&&!1===(f=Array.isArray(c=n(i,l))?c:"number"==typeof c?[!0,c]:null==c?BV:[c])[0])return f;if("children"in i&&i.children&&i.children&&"skip"!==f[0])for(d=(r?i.children.length:-1)+o,h=l.concat(i);d>-1&&d<i.children.length;){if(!1===(u=e(i.children[d],d,h)())[0])return u;d="number"==typeof u[1]?u[1]:d+o}return f}})(e,void 0,[])()}function BU(e,t,n,r){let i,a,o;"function"==typeof t&&"function"!=typeof n?(a=void 0,o=t,i=n):(a=t,o=n,i=r),BH(e,a,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)},i)}function BW(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),a=i[0];a&&"text"===a.type?a.value="["+a.value:i.unshift({type:"text",value:"["});let o=i[i.length-1];return o&&"text"===o.type?o.value+=r:i.push({type:"text",value:r}),i}function BY(e){let t=e.spread;return null==t?e.children.length>1:t}function BG(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let B$={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a={type:"element",tagName:"pre",properties:{},children:[a=e.applyData(t,a)]},e.patch(t,a),a},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),a=BL(i.toLowerCase()),o=e.footnoteOrder.indexOf(i),s=e.footnoteCounts.get(i);void 0===s?(s=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=o+1,s+=1,e.footnoteCounts.set(i,s);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return BW(e,t);let i={src:BL(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){let n={src:BL(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return BW(e,t);let i={href:BL(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){let n={href:BL(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=BY(n[r])}return t}(n):BY(t),a={},o=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let e=r[s];(i||0!==s||"element"!==e.type||"p"!==e.tagName)&&o.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?o.push(e):o.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&o.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=IR(t.children[1]),o=II(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,o=a?a.length:t.children.length,s=-1,l=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(BG(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(BG(t.slice(i),i>0,!1)),a.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:BX,yaml:BX,definition:BX,footnoteDefinition:BX};function BX(){}let Bq={}.hasOwnProperty,BK={};function BZ(e,t){e.position&&(t.position=function(e){let t=IR(e),n=II(e);if(t&&n)return{start:t,end:n}}(e))}function BQ(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,BA(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function BJ(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function B0(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function B1(e,t){let n,r,i,a,o=(n=t||BK,r=new Map,i=new Map,a={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=B0(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=B0(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:BQ,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...B$,...n.handlers},one:function(e,t){let n=e.type,r=a.handlers[n];if(Bq.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=BA(n);return r.children=a.all(e),r}return BA(e)}return(a.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(Bq.call(n,"hProperties")||Bq.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(a,e,t)},options:n,patch:BZ,wrap:BJ},BU(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a),s=o.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||BI,r=e.options.footnoteBackLabel||BR,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),c=BL(o.toLowerCase()),u=0,d=[],h=e.footnoteCounts.get(o);for(;void 0!==h&&++u<=h;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let f=a[a.length-1];if(f&&"element"===f.type&&"p"===f.tagName){let e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...d)}else a.push(...d);let p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(i,p),s.push(p)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...BA(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(o),c=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return l&&(L3("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function B2(e,t){return e&&"run"in e?async function(n,r){let i=B1(n,{file:r,...t});await e.run(i,r)}:function(n,r){return B1(n,{file:r,...e||t})}}function B5(e){if(e)throw e}var B3=e.i(4100);function B4(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let B6=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');ze(e);let r=0,i=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else i<0&&(n=!0,i=a+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let o=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else o<0&&(n=!0,o=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(i=a):(s=-1,i=o));return r===i?i=o:i<0&&(i=e.length),e.slice(r,i)},B7=function(e){let t;if(ze(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},B9=function(e){let t;ze(e);let n=e.length,r=-1,i=0,a=-1,o=0;for(;n--;){let s=e.codePointAt(n);if(47===s){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===s?a<0?a=n:1!==o&&(o=1):a>-1&&(o=-1)}return a<0||r<0||0===o||1===o&&a===r-1&&a===i+1?"":e.slice(a,r)},B8=function(...e){var t;let n,r,i,a=-1;for(;++a<e.length;)ze(e[a]),e[a]&&(i=void 0===i?e[a]:i+"/"+e[a]);return void 0===i?".":(ze(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",a=0,o=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(o===l-1||1===s);else if(o!==l-1&&2===s){if(i.length<2||2!==a||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",a=0):a=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),o=l,s=0;continue}}else if(i.length>0){i="",a=0,o=l,s=0;continue}}t&&(i=i.length>0?i+"/..":"..",a=2)}else i.length>0?i+="/"+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else 46===n&&s>-1?s++:s=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function ze(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function zt(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let zn=["history","path","basename","stem","extname","dirname"];class zr{constructor(e){let t,n;t=e?zt(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zn.length;){const e=zn[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)zn.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?B6(this.path):void 0}set basename(e){za(e,"basename"),zi(e,"basename"),this.path=B8(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?B7(this.path):void 0}set dirname(e){zo(this.basename,"dirname"),this.path=B8(e||"",this.basename)}get extname(){return"string"==typeof this.path?B9(this.path):void 0}set extname(e){if(zi(e,"extname"),zo(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=B8(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){zt(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!zt(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),za(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?B6(this.path,this.extname):void 0}set stem(e){za(e,"stem"),zi(e,"stem"),this.path=B8(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new IU(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function zi(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function za(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function zo(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let zs=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},zl={}.hasOwnProperty;class zc extends zs{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 e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(a,...o){let s=e[++n],l=-1;if(a)return void r(a);for(;++l<t.length;)(null===o[l]||void 0===o[l])&&(o[l]=t[l]);t=o,s?(function(e,t){let n;return function(...t){let a,o=e.length>t.length;o&&t.push(r);try{a=e.apply(this,t)}catch(e){if(o&&n)throw e;return r(e)}o||(a&&a.then&&"function"==typeof a.then?a.then(i,r):a instanceof Error?r(a):i(a))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(s,i)(...o):r(null,...o)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new zc,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,B3.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(zf("data",this.frozen),this.namespace[e]=t,this):zl.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zf("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=zg(e),n=this.parser||this.Parser;return zd("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),zd("process",this.parser||this.Parser),zh("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=zg(e),o=n.parse(a);function s(e,n){e||!n?i(e):r?r(n):(L3(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(o,a,function(e,t,r){var i,a;if(e||!t||!r)return s(e);let o=n.stringify(t,r);"string"==typeof(i=o)||(a=i)&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a?r.value=o:r.result=o,s(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),zd("processSync",this.parser||this.Parser),zh("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,B5(e),t=r}),zm("processSync","process",n),L3(t,"we either bailed on an error or have a tree"),t}run(e,t,n){zp(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){L3("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let o=zg(t);r.run(e,o,function(t,r,o){let s=r||e;t?a(t):i?i(s):(L3(n,"`done` is defined if `resolve` is not"),n(void 0,s,o))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){B5(e),n=t,r=!0}),zm("runSync","run",r),L3(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=zg(t),r=this.compiler||this.Compiler;return zh("stringify",r),zp(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zf("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))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");a(e.plugins),e.settings&&(r.settings=(0,B3.default)(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)o(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;o(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function o(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];B4(o)&&B4(r)&&(r=(0,B3.default)(!0,o,r)),n[i]=[e,r,...a]}}}}let zu=new zc().freeze();function zd(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function zh(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function zf(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zp(e){if(!B4(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function zm(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function zg(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new zr(e)}let zx=[],zv={allowDangerousHtml:!0},zy=/^(https?|ircs?|mailto|xmpp)$/i,zb=[{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 zw(e){var t;let n,r,i,a,o,s=(n=(t=e).rehypePlugins||zx,r=t.remarkPlugins||zx,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...zv}:zv,zu().use(Bk).use(r).use(B2,i).use(n)),l=(a=e.children||"",o=new zr,"string"==typeof a?o.value=a:L4("Unexpected value `"+a+"` for `children` prop, expected `string`"),o);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,l=t.urlTransform||zj;for(let e of zb)Object.hasOwn(t,e.from)&&L4("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&a&&L4("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),BU(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return o?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in I5)if(Object.hasOwn(I5,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=I5[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let o=n?!n.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&r&&"number"==typeof t&&(o=!r(e,t,i)),o&&i&&"number"==typeof t)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,a;let o;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let s=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=s,r=t.jsxDEV,o=function(e,t,i,a){let o=Array.isArray(i.children),s=IR(e);return r(t,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:n,lineNumber:s?s.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,a=t.jsxs,o=function(e,t,n,r){let o=Array.isArray(n.children)?a:i;return r?o(t,n,r):o(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?IP:ID,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=IK(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:_.Fragment,components:i,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0})}(s.runSync(s.parse(l),l),e)}function zj(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||zy.test(e.slice(0,t))?e:""}function zN(e,t){let n=String(e);if("string"!=typeof t)throw TypeError("Expected character");let r=0,i=n.indexOf(t);for(;-1!==i;)r++,i=n.indexOf(t,i+t.length);return r}zC(/[A-Za-z]/),zC(/[\dA-Za-z]/),zC(/[#-'*+\--9=?A-Z^-~]/),zC(/\d/),zC(/[\dA-Fa-f]/),zC(/[!-/:-@[-`{-~]/);let zk=zC(/\p{P}|\p{S}/u),zS=zC(/\s/);function zC(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let z_="phrasing",zE=["autolink","link","image","label"];function zT(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function zM(e){this.config.enter.autolinkProtocol.call(this,e)}function zO(e){this.config.exit.autolinkProtocol.call(this,e)}function zA(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];L3("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function zD(e){this.config.exit.autolinkEmail.call(this,e)}function zP(e){this.exit(e)}function zL(e){!function(e,t,n){let r=BB((n||{}).ignore||[]),i=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){var i;let e=n[r];t.push(["string"==typeof(i=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(i),"g"):i,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),a=-1;for(;++a<i.length;)BH(e,"text",o);function o(e,t){let n,o=-1;for(;++o<t.length;){let e=t[o],i=n?n.children:void 0;if(r(e,i?i.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,l=n.children.indexOf(e),c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if("string"==typeof a&&(a=a.length>0?{type:"text",value:a}:void 0),!1===a?r.lastIndex=n+1:(s!==n&&u.push({type:"text",value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}return c?(s<e.value.length&&u.push({type:"text",value:e.value.slice(s)}),n.children.splice(l,1,...u)):u=[e],l+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,zI],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,zR]],{ignore:["link","linkReference"]})}function zI(e,t,n,r,i){let a,o="";if(!zB(i))return!1;if(/^w/i.test(t)&&(n=t+n,t="",o="http://"),(a=n.split(".")).length<2||a[a.length-1]&&(/_/.test(a[a.length-1])||!/[a-zA-Z\d]/.test(a[a.length-1]))||a[a.length-2]&&(/_/.test(a[a.length-2])||!/[a-zA-Z\d]/.test(a[a.length-2])))return!1;let s=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")"),i=zN(e,"("),a=zN(e,")");for(;-1!==r&&i>a;)e+=n.slice(0,r+1),r=(n=n.slice(r+1)).indexOf(")"),a++;return[e,n]}(n+r);if(!s[0])return!1;let l={type:"link",title:null,url:o+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}function zR(e,t,n,r){return!(!zB(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zB(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||zS(n)||zk(n))&&(!t||47!==n)}function zz(){this.buffer()}function zF(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function zV(){this.buffer()}function zH(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function zU(e){let t=this.resume(),n=this.stack[this.stack.length-1];L3("footnoteReference"===n.type),n.identifier=R9(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zW(e){this.exit(e)}function zY(e){let t=this.resume(),n=this.stack[this.stack.length-1];L3("footnoteDefinition"===n.type),n.identifier=R9(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zG(e){this.exit(e)}function z$(e,t,n,r){let i=n.createTracker(r),a=i.move("[^"),o=n.enter("footnoteReference"),s=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),s(),o(),a+=i.move("]")}function zX(e,t,n){return 0===t?e:zq(e,t,n)}function zq(e,t,n){return(n?"":" ")+e}z$.peek=function(){return"["};let zK=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function zZ(e){this.enter({type:"delete",children:[]},e)}function zQ(e){this.exit(e)}function zJ(e,t,n,r){let i=n.createTracker(r),a=n.enter("strikethrough"),o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),a(),o}function z0(e){return e.length}function z1(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}zJ.peek=function(){return"~"};function z2(e,t,n){let r=e.value||"",i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){let e,t=n.unsafe[a],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}z2.peek=function(){return"`"};BB(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let z5=function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),a=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(a=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+a);let o=a.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(o=4*Math.ceil(o/4));let s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,s.current()),function(e,t,n){return t?(n?"":" ".repeat(o))+e:(n?a:a+" ".repeat(o-a.length))+e});return l(),c};function z3(e){let t=e._align;L3(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function z4(e){this.exit(e),this.data.inTable=void 0}function z6(e){this.enter({type:"tableRow",children:[]},e)}function z7(e){this.exit(e)}function z9(e){this.enter({type:"tableCell",children:[]},e)}function z8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Fe));let n=this.stack[this.stack.length-1];L3("inlineCode"===n.type),n.value=t,this.exit(e)}function Fe(e,t){return"|"===t?t:e}function Ft(e){let t=this.stack[this.stack.length-2];L3("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function Fn(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];L3("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let r,i=t.children,a=-1;for(;++a<i.length;){let e=i[a];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Fr(e,t,n,r){let i=e.children[0],a="boolean"==typeof e.checked&&i&&"paragraph"===i.type,o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=z5(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+o})),l}let Fi=Fc(/[A-Za-z]/),Fa=Fc(/[\dA-Za-z]/);function Fo(e){return null!==e&&(e<0||32===e)}Fc(/[#-'*+\--9=?A-Z^-~]/),Fc(/\d/),Fc(/[\dA-Fa-f]/),Fc(/[!-/:-@[-`{-~]/);let Fs=Fc(/\p{P}|\p{S}/u),Fl=Fc(/\s/);function Fc(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let Fu={tokenize:function(e,t,n){let r=0;return function t(a){return(87===a||119===a)&&r<3?(r++,e.consume(a),t):46===a&&3===r?(e.consume(a),i):n(a)};function i(e){return null===e?n(e):t(e)}},partial:!0},Fd={tokenize:function(e,t,n){let r,i,a;return o;function o(t){return 46===t||95===t?e.check(Ff,l,s)(t):null===t||Fo(t)||Fl(t)||45!==t&&Fs(t)?l(t):(a=!0,e.consume(t),o)}function s(t){return 95===t?r=!0:(i=r,r=void 0),e.consume(t),o}function l(e){return i||r||!a?n(e):t(e)}},partial:!0},Fh={tokenize:function(e,t){let n=0,r=0;return i;function i(o){return 40===o?(n++,e.consume(o),i):41===o&&r<n?a(o):33===o||34===o||38===o||39===o||41===o||42===o||44===o||46===o||58===o||59===o||60===o||63===o||93===o||95===o||126===o?e.check(Ff,t,a)(o):null===o||Fo(o)||Fl(o)?t(o):(e.consume(o),i)}function a(t){return 41===t&&r++,e.consume(t),i}},partial:!0},Ff={tokenize:function(e,t,n){return r;function r(o){return 33===o||34===o||39===o||41===o||42===o||44===o||46===o||58===o||59===o||63===o||95===o||126===o?(e.consume(o),r):38===o?(e.consume(o),a):93===o?(e.consume(o),i):60===o||null===o||Fo(o)||Fl(o)?t(o):n(o)}function i(e){return null===e||40===e||91===e||Fo(e)||Fl(e)?t(e):r(e)}function a(t){return Fi(t)?function t(i){return 59===i?(e.consume(i),r):Fi(i)?(e.consume(i),t):n(i)}(t):n(t)}},partial:!0},Fp={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Fa(e)?n(e):t(e)}},partial:!0},Fm={name:"wwwAutolink",tokenize:function(e,t,n){let r=this;return function(t){return 87!==t&&119!==t||!Fb.call(r,r.previous)||Fk(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Fu,e.attempt(Fd,e.attempt(Fh,i),n),n)(t))};function i(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Fb},Fg={name:"protocolAutolink",tokenize:function(e,t,n){let r=this,i="",a=!1;return function(t){return(72===t||104===t)&&Fw.call(r,r.previous)&&!Fk(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(t),e.consume(t),o):n(t)};function o(t){if(Fi(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),o;if(58===t){let n=i.toLowerCase();if("http"===n||"https"===n)return e.consume(t),s}return n(t)}function s(t){return 47===t?(e.consume(t),a)?l:(a=!0,s):n(t)}function l(t){return null===t||null!==t&&(t<32||127===t)||Fo(t)||Fl(t)||Fs(t)?n(t):e.attempt(Fd,e.attempt(Fh,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Fw},Fx={name:"emailAutolink",tokenize:function(e,t,n){let r,i,a=this;return function(t){return!FN(t)||!Fj.call(a,a.previous)||Fk(a.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(r){return FN(r)?(e.consume(r),t):64===r?(e.consume(r),o):n(r)}(t))};function o(t){return 46===t?e.check(Fp,l,s)(t):45===t||95===t||Fa(t)?(i=!0,e.consume(t),o):l(t)}function s(t){return e.consume(t),r=!0,o}function l(o){return i&&r&&Fi(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(o)):n(o)}},previous:Fj},Fv={},Fy=48;for(;Fy<123;)Fv[Fy]=Fx,58==++Fy?Fy=65:91===Fy&&(Fy=97);function Fb(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Fo(e)}function Fw(e){return!Fi(e)}function Fj(e){return!(47===e||FN(e))}function FN(e){return 43===e||45===e||46===e||95===e||Fa(e)}function Fk(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function FS(e){return null!==e&&(e<0||32===e)}function FC(e){return -2===e||-1===e||32===e}function F_(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function FE(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return FC(r)?(e.enter(n),function r(o){return FC(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Fv[43]=Fx,Fv[45]=Fx,Fv[46]=Fx,Fv[95]=Fx,Fv[72]=[Fx,Fg],Fv[104]=[Fx,Fg],Fv[87]=[Fx,Fm],Fv[119]=[Fx,Fm],F_(/[A-Za-z]/),F_(/[\dA-Za-z]/),F_(/[#-'*+\--9=?A-Z^-~]/),F_(/\d/),F_(/[\dA-Fa-f]/),F_(/[!-/:-@[-`{-~]/),F_(/\p{P}|\p{S}/u),F_(/\s/);let FT={tokenize:function(e,t,n){let r=this;return FE(e,function(e){let i=r.events[r.events.length-1];return i&&"gfmFootnoteDefinitionIndent"===i[1].type&&4===i[2].sliceSerialize(i[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function FM(e,t,n){let r,i=this,a=i.events.length,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);for(;a--;){let e=i.events[a][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!r||!r._balanced)return n(a);let s=R9(i.sliceSerialize({start:r.end,end:i.now()}));return 94===s.codePointAt(0)&&o.includes(s.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)):n(a)}}function FO(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function FA(e,t,n){let r,i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),o=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),s};function s(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(s){if(o>999||93===s&&!r||null===s||91===s||FS(s))return n(s);if(93===s){e.exit("chunkString");let r=e.exit("gfmFootnoteCallString");return a.includes(R9(i.sliceSerialize(r)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(s)}return FS(s)||(r=!0),o++,e.consume(s),92===s?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),o++,l):l(t)}}function FD(e,t,n){let r,i,a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]),s=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(s>999||93===t&&!i||null===t||91===t||FS(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return r=R9(a.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return FS(t)||(i=!0),s++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(r)||o.push(r),FE(e,h,"gfmFootnoteDefinitionWhitespace")):n(t)}function h(e){return t(e)}}function FP(e,t,n){return e.check(Rb,t,e.attempt(FT,t,n))}function FL(e){e.exit("gfmFootnoteDefinition")}function FI(e){return null!==e&&e<-2}function FR(e){return null!==e&&(e<0||32===e)}function FB(e){return -2===e||-1===e||32===e}function Fz(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function FF(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return FB(r)?(e.enter(n),function r(o){return FB(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Fz(/[A-Za-z]/),Fz(/[\dA-Za-z]/),Fz(/[#-'*+\--9=?A-Z^-~]/),Fz(/\d/),Fz(/[\dA-Fa-f]/),Fz(/[!-/:-@[-`{-~]/),Fz(/\p{P}|\p{S}/u),Fz(/\s/);class FV{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let i=0;if(0!==n||0!==r.length){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}}function FH(e,t,n){let r,i=this,a=0,o=0;return function(e){let t=i.events.length-1;for(;t>-1;){let e=i.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let r=t>-1?i.events[t][1].type:null,a="tableHead"===r||"tableRow"===r?y:s;return a===y&&i.parser.lazy[i.now().line]?n(e):a(e)};function s(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(r=!0,o+=1),l(n)}function l(t){return null===t?n(t):FI(t)?o>1?(o=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):FB(t)?FF(e,l,"whitespace")(t):(o+=1,r&&(r=!1,a+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,l):(e.enter("data"),c(t))}function c(t){return null===t||124===t||FR(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return(i.interrupt=!1,i.parser.lazy[i.now().line])?n(t):(e.enter("tableDelimiterRow"),r=!1,FB(t))?FF(e,h,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t)}function h(t){return 45===t||58===t?p(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),f):n(t)}function f(t){return FB(t)?FF(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(o+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),g):45===t?(o+=1,g(t)):null===t||FI(t)?v(t):n(t)}function g(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(n))}(t)):n(t)}function x(t){return FB(t)?FF(e,v,"whitespace")(t):v(t)}function v(i){if(124===i)return h(i);if(null===i||FI(i))return r&&a===o?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):n(i);return n(i)}function y(t){return e.enter("tableRow"),b(t)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||FI(n)?(e.exit("tableRow"),t(n)):FB(n)?FF(e,b,"whitespace")(n):(e.enter("data"),w(n))}function w(t){return null===t||124===t||FR(t)?(e.exit("data"),b(t)):(e.consume(t),92===t?j:w)}function j(t){return 92===t||124===t?(e.consume(t),w):w(t)}}function FU(e,t){let n,r,i,a=-1,o=!0,s=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h=new FV;for(;++a<e.length;){let f=e[a],p=f[1];"enter"===f[0]?"tableHead"===p.type?(u=!1,0!==d&&(FY(h,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(o=!0,i=void 0,l=[0,0,0,0],c=[0,a+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",r,t]])),s="tableDelimiterRow"===p.type?2:r?3:1):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)?(o=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],i=FW(h,t,l,s,void 0,i),l=[0,0,0,0]),c[2]=a)):"tableCellDivider"===p.type&&(o?o=!1:(0!==l[1]&&(c[0]=c[1],i=FW(h,t,l,s,void 0,i)),c=[(l=c)[1],a,0,0])):"tableHead"===p.type?(u=!0,d=a):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=a,0!==l[1]?(c[0]=c[1],i=FW(h,t,l,s,a,i)):0!==c[1]&&(i=FW(h,t,c,s,a,i)),s=0):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(c[3]=a)}for(0!==d&&FY(h,t,d,n,r),h.consume(t.events),a=-1;++a<t.events.length;){let e=t.events[a];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if("enter"===i[0])"tableContent"===i[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===i[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===i[1].type)break}else"enter"===i[0]&&"tableDelimiterRow"===i[1].type&&(n=!0);t+=1}return r}(t.events,a))}return e}function FW(e,t,n,r,i,a){0!==n[0]&&(a.end=Object.assign({},FG(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));let o=FG(t.events,n[1]);if(a={type:1===r?"tableHeader":2===r?"tableDelimiter":"tableData",start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",a,t]]),0!==n[2]){let i=FG(t.events,n[2]),a=FG(t.events,n[3]),o={type:"tableContent",start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[["enter",o,t]]),2!==r){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",o,t]])}return void 0!==i&&(a.end=Object.assign({},FG(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function FY(e,t,n,r,i){let a=[],o=FG(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function FG(e,t){let n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}function F$(e){return -2===e||-1===e||32===e}function FX(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}FX(/[A-Za-z]/),FX(/[\dA-Za-z]/),FX(/[#-'*+\--9=?A-Z^-~]/),FX(/\d/),FX(/[\dA-Fa-f]/),FX(/[!-/:-@[-`{-~]/),FX(/\p{P}|\p{S}/u),FX(/\s/);let Fq={name:"tasklistCheck",tokenize:function(e,t,n){let r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),i):n(t)};function i(t){return null!==t&&(t<0||32===t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),a):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),a):n(t)}function a(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(t)}function o(r){return null!==r&&r<-2?t(r):F$(r)?e.check({tokenize:FK},t,n)(r):n(r)}}};function FK(e,t,n){var r,i;let a,o;return r=function(e){return null===e?n(e):t(e)},i="whitespace",a=1/0,o=0,function(t){return F$(t)?(e.enter(i),function t(n){return F$(n)&&o++<a?(e.consume(n),t):(e.exit(i),r(n))}(t)):r(t)}}let FZ={};function FQ(e){let t,n,r,i=e||FZ,a=this.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),s=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),l=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(Rt([{text:Fv},{document:{91:{name:"gfmFootnoteDefinition",tokenize:FD,continuation:{tokenize:FP},exit:FL}},text:{91:{name:"gfmFootnoteCall",tokenize:FA},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FM,resolveTo:FO}}},(t=(i||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,r){let i=this.previous,a=this.events,o=0;return function(s){return 126===i&&"characterEscape"!==a[a.length-1][1].type?r(s):(e.enter("strikethroughSequenceTemporary"),function a(s){let l=RI(i);if(126===s)return o>1?r(s):(e.consume(s),o++,a);if(o<2&&!t)return r(s);let c=e.exit("strikethroughSequenceTemporary"),u=RI(s);return c._open=!u||2===u&&!!l,c._close=!l||2===l&&!!u,n(s)}(s))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";let i={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[["enter",i,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",a,t]],s=t.parser.constructs.insideSpan.null;s&&I9(o,o.length,0,RR(s,e.slice(r+1,n),t)),I9(o,o.length,0,[["exit",a,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",i,t]]),I9(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:FH,resolveAll:FU}}},{text:{91:Fq}}])),s.push([{transforms:[zL],enter:{literalAutolink:zT,literalAutolinkEmail:zM,literalAutolinkHttp:zM,literalAutolinkWww:zM},exit:{literalAutolink:zP,literalAutolinkEmail:zD,literalAutolinkHttp:zO,literalAutolinkWww:zA}},{enter:{gfmFootnoteCallString:zz,gfmFootnoteCall:zF,gfmFootnoteDefinitionLabelString:zV,gfmFootnoteDefinition:zH},exit:{gfmFootnoteCallString:zU,gfmFootnoteCall:zW,gfmFootnoteDefinitionLabelString:zY,gfmFootnoteDefinition:zG}},{canContainEols:["delete"],enter:{strikethrough:zZ},exit:{strikethrough:zQ}},{enter:{table:z3,tableData:z9,tableHeader:z9,tableRow:z6},exit:{codeText:z8,table:z4,tableData:z7,tableHeader:z7,tableRow:z7}},{exit:{taskListCheckValueChecked:Ft,taskListCheckValueUnchecked:Ft,paragraph:Fn}}]),l.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:z_,notInConstruct:zE},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:z_,notInConstruct:zE},{character:":",before:"[ps]",after:"\\/",inConstruct:z_,notInConstruct:zE}]},(r=!1,i&&i.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:function(e,t,n,i){let a=n.createTracker(i),o=a.move("[^"),s=n.enter("footnoteDefinition"),l=n.enter("label");return o+=a.move(n.safe(n.associationId(e),{before:o,after:"]"})),l(),o+=a.move("]:"),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((r?"\n":" ")+n.indentLines(n.containerFlow(e,a.current()),r?zq:zX))),s(),o},footnoteReference:z$},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:zK}],handlers:{delete:zJ}},function(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";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(e,t,n){let r=z2(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return s(function(e,t,n){let r=e.children,i=-1,a=[],o=t.enter("table");for(;++i<r.length;)a[i]=l(r[i],t,n);return o(),a}(e,n,r),e.align)},tableCell:o,tableRow:function(e,t,n,r){let i=s([l(e,n,r)]);return i.slice(0,i.indexOf("\n"))}}};function o(e,t,n,r){let i=n.enter("tableCell"),o=n.enter("phrasing"),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function s(e,t){return function(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||z0,a=[],o=[],s=[],l=[],c=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>c&&(c=e[u].length);++a<e[u].length;){var d;let o=null==(d=e[u][a])?"":String(d);if(!1!==n.alignDelimiters){let e=i(o);r[a]=e,(void 0===l[a]||e>l[a])&&(l[a]=e)}t.push(o)}o[u]=t,s[u]=r}let h=-1;if("object"==typeof r&&"length"in r)for(;++h<c;)a[h]=z1(r[h]);else{let e=z1(r);for(;++h<c;)a[h]=e}h=-1;let f=[],p=[];for(;++h<c;){let e=a[h],t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let i=!1===n.alignDelimiters?1:Math.max(1,l[h]-t.length-r.length),o=t+"-".repeat(i)+r;!1!==n.alignDelimiters&&((i=t.length+i+r.length)>l[h]&&(l[h]=i),p[h]=i),f[h]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let g=[];for(;++u<o.length;){let e=o[u],t=s[u];h=-1;let r=[];for(;++h<c;){let i=e[h]||"",o="",s="";if(!1!==n.alignDelimiters){let e=l[h]-(t[h]||0),n=a[h];114===n?o=" ".repeat(e):99===n?e%2?(o=" ".repeat(e/2+.5),s=" ".repeat(e/2-.5)):s=o=" ".repeat(e/2):s=" ".repeat(e)}!1===n.delimiterStart||h||r.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==i)&&(!1!==n.delimiterStart||h)&&r.push(" "),!1!==n.alignDelimiters&&r.push(o),r.push(i),!1!==n.alignDelimiters&&r.push(s),!1!==n.padding&&r.push(" "),(!1!==n.delimiterEnd||h!==c-1)&&r.push("|")}g.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return g.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function l(e,t,n){let r=e.children,i=-1,a=[],s=t.enter("tableRow");for(;++i<r.length;)a[i]=o(r[i],e,t,n);return s(),a}}(i),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Fr}}]})}let FJ=/^\s*\|.*\|\s*$/,F0=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;function F1({children:e,className:t}){return(0,_.jsx)("div",{className:(0,W.cn)("text-[13px] leading-6 text-foreground/90 space-y-2 [&>:first-child]:mt-0",t),children:(0,_.jsx)(zw,{remarkPlugins:[FQ],components:{h1:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...e}),h2:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...e}),h3:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...e}),h4:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...e}),p:e=>(0,_.jsx)("p",{className:"my-1.5",...e}),ul:e=>(0,_.jsx)("ul",{className:"list-disc pl-5 my-1.5 space-y-0.5",...e}),ol:e=>(0,_.jsx)("ol",{className:"list-decimal pl-5 my-1.5 space-y-0.5",...e}),li:e=>(0,_.jsx)("li",{className:"leading-6",...e}),strong:e=>(0,_.jsx)("strong",{className:"font-semibold text-foreground",...e}),code:e=>(0,_.jsx)("code",{className:"text-[12px] font-mono bg-muted/70 px-1 py-0.5 rounded",...e}),a:e=>(0,_.jsx)("a",{className:"text-primary underline",...e}),table:e=>(0,_.jsx)("div",{className:"overflow-x-auto my-3 rounded-md border border-border",children:(0,_.jsx)("table",{className:"text-[12px] w-full border-collapse",...e})}),thead:e=>(0,_.jsx)("thead",{className:"bg-muted/60",...e}),th:e=>(0,_.jsx)("th",{className:"text-left font-semibold px-3 py-1.5 border-b border-border whitespace-nowrap",...e}),td:e=>(0,_.jsx)("td",{className:"px-3 py-1.5 border-b border-border/40 align-top [tr:last-child_&]:border-b-0",...e}),hr:e=>(0,_.jsx)("hr",{className:"my-3 border-border/60",...e}),blockquote:e=>(0,_.jsx)("blockquote",{className:"border-l-2 border-border/60 pl-3 my-2 text-muted-foreground italic",...e})},children:function(e){let t=e.split("\n"),n=[],r=0;for(;r<t.length;){let e=t[r],i=t[r+1];if(e&&i&&FJ.test(e)&&F0.test(i)){for(n.length>0&&""!==n[n.length-1].trim()&&n.push("");r<t.length&&FJ.test(t[r]);)n.push(t[r].replace(/^\s+/,"")),r++;r<t.length&&""!==t[r].trim()&&n.push("");continue}n.push(e),r++}return n.join("\n")}(e)})})}var F2=e.i(59411),tn=tn;function F5({directiveId:e,onClose:t}){let n,r=(0,M.useTranslations)("directiveDetailModal"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(null),[s,l]=(0,E.useState)(!1),[c,u]=(0,E.useState)(null);(0,E.useEffect)(()=>{e&&i&&(async()=>{l(!0),u(null),o(null);try{let t=await $.client.getDirective(i,e);o(t)}catch(e){console.error("Error loading directive:",e),u(e.message)}finally{l(!1)}})()},[e,i]);let d=null!==e;return(0,_.jsx)(ta.Dialog,{open:d,onOpenChange:e=>!e&&t(),children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,_.jsx)(F2.VisuallyHidden,{children:(0,_.jsx)(ta.DialogTitle,{children:r("title")})}),s?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)(tn.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):c?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)("div",{className:"text-center text-destructive",children:(0,_.jsx)("div",{className:"text-sm",children:r("errorPrefix",{error:c})})})}):a?(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,_.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),!a.is_active&&(0,_.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:r("inactive")})]}),(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:a.id})]}),(0,_.jsxs)("div",{className:"flex gap-8",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:r("created")}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:(n=new Date(a.created_at),`${n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:r("priority")}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:a.priority})]})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:r("content")}),(0,_.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,_.jsx)(zw,{remarkPlugins:[FQ],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:r("tags")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map((e,t)=>(0,_.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:e},t))})]})]}):null]})})}function F3(e){let t=new Date(e).getTime(),n=Math.round((Date.now()-t)/1e3);if(60>Math.abs(n))return n>=0?"just now":"in a moment";let r=n,i="second";for(let[e,t]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"],[4.345,"week"],[12,"month"],[1/0,"year"]]){if(Math.abs(r)<e)break;r/=e,i=t}return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(-Math.round(r),i)}function F4(e){let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`}var F6=e.i(42408);let F7={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 F9(e,t){return"directives"===e?{label:t?t("factTypeDirective"):"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===e?{label:t?t("factTypeMentalModel"):"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===e?{label:t?t("factTypeWorld"):"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===e?{label:t?t("factTypeExperience"):"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:"observation"===e?{label:t?t("factTypeObservation"):"observation",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}:{label:e,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"}}let F8=["observation","experience","world","directives","mental-models"];function Ve({based_on:e,onViewMemory:t,onViewDirective:n}){let r=(0,M.useTranslations)("mentalModelDetailModal"),i=(0,E.useMemo)(()=>{if(!e)return[];let t=Object.entries(e).map(([e,t])=>({factType:e,facts:t??[]})).filter(e=>e.facts.length>0);return t.sort((e,t)=>{let n=F8.indexOf(e.factType),r=F8.indexOf(t.factType);return(-1===n?999:n)-(-1===r?999:r)}),t},[e]);return 0===i.length?(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:r("noBasedOnData")}):(0,_.jsx)("div",{className:"space-y-4",children:i.map(e=>{let i=F9(e.factType,r);return(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${i.color}`,children:i.label}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e.facts.length})]}),(0,_.jsx)("ul",{className:"divide-y divide-border/50",children:e.facts.map((i,a)=>{let o="directives"===e.factType&&!!n||"directives"!==e.factType&&"mental-models"!==e.factType&&!!t;return(0,_.jsxs)("li",{className:"group flex items-start gap-3 px-3 py-2 hover:bg-muted/30",children:[(0,_.jsxs)("p",{className:"text-sm text-foreground leading-relaxed flex-1 min-w-0",children:[i.text,i.context&&(0,_.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5",children:i.context})]}),o&&(0,_.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"===e.factType?n?.(i.id):t?.(i.id)},children:r("viewArrow")})]},i.id||a)})})]},e.factType)})})}function Vt(e){return e.match(/\s+|[A-Za-z0-9_]+|[^\s\w]/g)||[]}function Vn(e){return/^\s+$/.test(e)?" ":e}function Vr(e,t,n){let r={backgroundColor:n.removedWordBg,color:n.removedWordText,fontWeight:600,borderRadius:"2px"},i={backgroundColor:n.addedWordBg,color:n.addedWordText,fontWeight:600,borderRadius:"2px"};return e.map((e,n)=>"same"===e.type?(0,_.jsx)("span",{children:e.text},n):(0,_.jsx)("span",{style:"left"===t?r:i,children:e.text},n))}function Vi({before:e,after:t}){let n=(0,M.useTranslations)("mentalModelDetailModal"),{theme:r}=(0,F6.useTheme)(),i=F7[r],{left:a,right:o}=function(e,t){let n=e.split("\n"),r=t.split("\n"),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=n[e-1]===r[t-1]?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],l=i,c=a;for(;l>0||c>0;)l>0&&c>0&&n[l-1]===r[c-1]?(s.push({type:"same",text:n[l-1]}),l--,c--):c>0&&(0===l||o[l][c-1]>=o[l-1][c])?(s.push({type:"added",text:r[c-1]}),c--):(s.push({type:"removed",text:n[l-1]}),l--);s.reverse();let u=[],d=[],h=0;for(;h<s.length;){let e=s[h];if("same"===e.type){u.push({type:"same",spans:[{type:"same",text:e.text}]}),d.push({type:"same",spans:[{type:"same",text:e.text}]}),h++;continue}let t=[],n=[];for(;h<s.length&&"same"!==s[h].type;)"removed"===s[h].type?t.push(s[h].text):n.push(s[h].text),h++;let r=Math.max(t.length,n.length);for(let e=0;e<r;e++){let r=e<t.length?t[e]:null,i=e<n.length?n[e]:null;if(null!==r&&null!==i){let e=function(e,t){let n=Vt(e),r=Vt(t),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=Vn(n[e-1])===Vn(r[t-1])?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],l=[],c=i,u=a,d=[],h=[];for(;c>0||u>0;)if(c>0&&u>0&&Vn(n[c-1])===Vn(r[u-1]))d.push({type:"same",text:n[c-1]}),h.push({type:"same",text:r[u-1]}),c--,u--;else if(u>0&&(0===c||o[c][u-1]>=o[c-1][u])){let e=r[u-1];h.push({type:/^\s+$/.test(e)?"same":"added",text:e}),u--}else{let e=n[c-1];d.push({type:/^\s+$/.test(e)?"same":"removed",text:e}),c--}for(;d.length;)s.push(d.pop());for(;h.length;)l.push(h.pop());return{left:s,right:l}}(r,i),t=e.left.some(e=>"same"!==e.type)?"removed":"same",n=e.right.some(e=>"same"!==e.type)?"added":"same";u.push({type:t,spans:e.left}),d.push({type:n,spans:e.right})}else null!==r?(u.push({type:"removed",spans:[{type:"removed",text:r}]}),d.push({type:"same",spans:[{type:"same",text:""}]})):null!==i&&(u.push({type:"same",spans:[{type:"same",text:""}]}),d.push({type:"added",spans:[{type:"added",text:i}]}))}}return{left:u,right:d}}(e,t);return a.some(e=>"same"!==e.type)||o.some(e=>"same"!==e.type)?(0,_.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border border border-border rounded-md overflow-hidden text-[13px] font-mono",style:{color:i.body},children:[(0,_.jsxs)("div",{children:[(0,_.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:n("diffBefore")}),a.map((e,t)=>(0,_.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"removed"===e.type?{backgroundColor:i.removedLineBg}:void 0,children:Vr(e.spans,"left",i)},t))]}),(0,_.jsxs)("div",{children:[(0,_.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:n("diffAfter")}),o.map((e,t)=>(0,_.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"added"===e.type?{backgroundColor:i.addedLineBg}:void 0,children:Vr(e.spans,"right",i)},t))]})]}):(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:n("unchanged")})}function Va({before:e,after:t,onViewMemory:n,onViewDirective:r}){let i=(0,M.useTranslations)("mentalModelDetailModal"),a=(0,E.useMemo)(()=>{let n=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),r=[];for(let i of n){let n=(e?.[i]??[]).filter(Boolean),a=(t?.[i]??[]).filter(Boolean),o=new Set(n.map(e=>e.id)),s=new Set(a.map(e=>e.id)),l=a.filter(e=>!o.has(e.id)),c=n.filter(e=>!s.has(e.id)),u=a.filter(e=>o.has(e.id));(0!==l.length||0!==c.length||0!==u.length)&&r.push({factType:i,added:l,removed:c,kept:u})}return r.sort((e,t)=>{let n=F8.indexOf(e.factType),r=F8.indexOf(t.factType);return(-1===n?999:n)-(-1===r?999:r)}),r},[e,t]);if(0===a.length)return(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:i("noBasedOnData")});let o=(e,t,a)=>(0,_.jsxs)("li",{className:`group flex items-start gap-2 px-3 py-2 ${"added"===a?"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"===a?"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,_.jsx)("span",{className:`font-mono text-sm shrink-0 ${"added"===a?"text-green-700 dark:text-green-400":"removed"===a?"text-red-700 dark:text-red-400":"text-muted-foreground/40"}`,children:"added"===a?"+":"removed"===a?"−":" "}),(0,_.jsxs)("p",{className:"text-sm leading-relaxed flex-1 min-w-0",children:[e.text,e.context&&(0,_.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5 no-underline",children:e.context})]}),("directives"===t&&!!r||"directives"!==t&&"mental-models"!==t&&!!n)&&"removed"!==a&&(0,_.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"===t?r(e.id):n(e.id)},children:i("viewArrow")})]},`${a}-${e.id}`);return(0,_.jsx)("div",{className:"space-y-4",children:a.map(e=>{let t=F9(e.factType,i);return(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${t.color}`,children:t.label}),e.added.length>0&&(0,_.jsxs)("span",{className:"text-xs text-green-600 dark:text-green-400",children:["+",e.added.length]}),e.removed.length>0&&(0,_.jsxs)("span",{className:"text-xs text-red-600 dark:text-red-400",children:["−",e.removed.length]}),e.kept.length>0&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:i("keptCount",{count:e.kept.length})})]}),(0,_.jsxs)("ul",{className:"divide-y divide-border/40",children:[e.added.map(t=>o(t,e.factType,"added")),e.removed.map(t=>o(t,e.factType,"removed")),e.kept.map(t=>o(t,e.factType,"kept"))]})]},e.factType)})})}function Vo({history:e,currentContent:t,currentBasedOn:n,onViewMemory:r,onViewDirective:i}){let a=(0,M.useTranslations)("mentalModelDetailModal"),[o,s]=(0,E.useState)(0),l=e[o],c=0===o?t:e[o-1].previous_content??"",u=l.previous_reflect_response?.based_on,d=0===o?n:e[o-1].previous_reflect_response?.based_on,h=l.previous_reflect_response??null;return(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["v",e.length-o]})," →"," ",(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["v",e.length-o+1,0===o?a("versionCurrent"):""]})," ","· ",a("changedAt",{date:new Date(l.changed_at).toLocaleString()})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:o===e.length-1,onClick:()=>s(o+1),children:(0,_.jsx)(V,{className:"h-3.5 w-3.5"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:0===o,onClick:()=>s(o-1),children:(0,_.jsx)(H.ChevronRight,{className:"h-3.5 w-3.5"})})]})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vh,{children:a("contentDiff")}),null!==l.previous_content?(0,_.jsx)(Vi,{before:l.previous_content,after:c}):(0,_.jsx)("div",{className:"border border-border rounded-lg p-3",children:(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:a("previousContentNotAvailable")})})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vh,{children:a("basedOnDiff")}),h?.based_on?(0,_.jsx)(Va,{before:u,after:d,onViewMemory:r,onViewDirective:i}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:a("basedOnNotCaptured")})]})]})}function Vs({mentalModelId:e,onClose:t,onEdit:n,onDelete:r,onClear:i,onRefreshed:a,initialTab:o="content"}){let s=(0,M.useTranslations)("mentalModelDetailModal"),{currentBank:l}=(0,D.useBank)(),[c,u]=(0,E.useState)(null),[d,h]=(0,E.useState)(!1),[f,p]=(0,E.useState)(null),[g,x]=(0,E.useState)(o),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(null),[k,S]=(0,E.useState)(null),[C,T]=(0,E.useState)(null),[A,P]=(0,E.useState)(!1);(0,E.useEffect)(()=>{e&&l&&(async()=>{h(!0),p(null),u(null),T(null),x(o);try{let t=await $.client.getMentalModel(l,e);u(t)}catch(e){console.error("Error loading mental model:",e),p(e.message)}finally{h(!1)}})()},[e,l,o]),(0,E.useEffect)(()=>{"history"===g&&c&&l&&null===C&&(async()=>{P(!0);try{let e=await $.client.getMentalModelHistory(l,c.id);T(e)}catch(e){console.error("Error loading mental model history:",e),T([])}finally{P(!1)}})()},[g,c,l,C]);let L=async()=>{if(l&&c){w(!0);try{let e=await $.client.getMentalModel(l,c.id);u(e),T(null)}catch(e){console.error("Error reloading mental model:",e)}finally{w(!1)}}},I=async()=>{if(!l||!c)return;y(!0);let e=c.last_refreshed_at;try{await $.client.refreshMentalModel(l,c.id);let t=0,n=async()=>{t++;try{let r=await $.client.getMentalModel(l,c.id);if(r.last_refreshed_at!==e){u(r),T(null),a?.(r),y(!1);return}if(t>=120){y(!1),O.toast.error(s("refreshTimeoutTitle"),{description:s("refreshTimeoutDescription")});return}setTimeout(n,1e3)}catch(e){console.error("Error polling mental model:",e),y(!1)}};setTimeout(n,1e3)}catch{y(!1)}},R=null!==e,B=c?.reflect_response?.based_on,F=B?Object.values(B).reduce((e,t)=>e+(t?.length??0),0):0;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ta.Dialog,{open:R,onOpenChange:e=>!e&&t(),children:(0,_.jsxs)(ta.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,_.jsx)(ta.DialogHeader,{className:"pr-10",children:(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"truncate",children:c?.name??s("mentalModelFallback")}),c&&(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:L,disabled:b,title:s("reloadData"),children:(0,_.jsx)(er,{className:`h-3.5 w-3.5 ${b?"animate-spin":""}`})}),c?.trigger?.refresh_after_consolidation&&(0,_.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,_.jsx)(L2,{className:"w-3 h-3"}),s("autoRefresh")]})]})}),d?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsx)(tn.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):f?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsx)("div",{className:"text-center text-destructive",children:(0,_.jsx)("div",{className:"text-sm",children:s("errorPrefix",{error:f})})})}):c?(0,_.jsxs)(ts.Tabs,{value:g,onValueChange:e=>x(e),className:"flex-1 flex flex-col overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,_.jsxs)(ts.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,_.jsxs)(ts.TabsTrigger,{value:"content",className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),s("tabContent")]}),(0,_.jsxs)(ts.TabsTrigger,{value:"configuration",className:"flex items-center gap-1.5",children:[(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),s("tabConfiguration")]}),(0,_.jsxs)(ts.TabsTrigger,{value:"history",className:"flex items-center gap-1.5",children:[(0,_.jsx)(tr,{className:"w-3.5 h-3.5"}),s("tabHistory")]})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:v,"aria-label":s("actionsAriaLabel"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[n&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>n(c),children:[(0,_.jsx)(PX,{className:"h-4 w-4 mr-2"}),s("actionEdit")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:I,disabled:v,children:[(0,_.jsx)(er,{className:"h-4 w-4 mr-2"}),s("actionRefreshManually")]}),i&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>i(c),children:[(0,_.jsx)(L5,{className:"h-4 w-4 mr-2"}),s("actionClearContent")]}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>r(c),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),s("actionDelete")]})]})]})]})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,_.jsxs)(ts.TabsContent,{value:"content",className:"mt-0 space-y-6",children:[(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,_.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,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),(0,_.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:s("storedContent")}),(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",s("charsCount",{count:c.content.length})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[!0===c.is_stale?(0,_.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:s("staleTitle"),children:s("stale")}):!1===c.is_stale?(0,_.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:s("inSyncTitle"),children:s("inSync")}):null,(0,_.jsxs)("span",{title:F4(c.last_refreshed_at),className:"flex items-center gap-1",children:[(0,_.jsx)(er,{className:"w-3 h-3"}),s("lastRefreshed",{time:F3(c.last_refreshed_at)})]})]})]}),(0,_.jsx)(F1,{className:"p-4",children:c.content})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vh,{children:F>0?s("basedOnWithCount",{count:F}):s("basedOn")}),c.reflect_response?(0,_.jsx)(Ve,{based_on:B,onViewMemory:e=>N(e),onViewDirective:e=>S(e)}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:s("noSourceData")})]})]}),(0,_.jsx)(ts.TabsContent,{value:"configuration",className:"mt-0",children:(0,_.jsx)(Vd,{mentalModel:c})}),(0,_.jsx)(ts.TabsContent,{value:"history",className:"mt-0",children:A?(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):C&&C.length>0?(0,_.jsx)(Vo,{history:C,currentContent:c.content,currentBasedOn:B,onViewMemory:e=>N(e),onViewDirective:e=>S(e)}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("noHistory")})})]})]}):null]})}),j&&(0,_.jsx)(tp,{memoryId:j,onClose:()=>N(null)}),k&&(0,_.jsx)(F5,{directiveId:k,onClose:()=>S(null)})]})}function Vl({label:e,value:t}){return(0,_.jsxs)("div",{children:[(0,_.jsx)(Vh,{children:e}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:t})]})}function Vc({title:e,icon:t,children:n}){return(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,_.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:[t,e]}),(0,_.jsx)("div",{className:"p-4 space-y-4",children:n})]})}function Vu({label:e,color:t}){return(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${t??"bg-muted text-foreground border border-border/60"}`,children:e})}function Vd({mentalModel:e}){let t=(0,M.useTranslations)("mentalModelDetailModal"),n=e.trigger??{refresh_after_consolidation:!1},r=n.fact_types??[],i=n.tag_groups??[],a=n.exclude_mental_model_ids??[];return(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsxs)(Vc,{title:t("identityTitle"),icon:(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vl,{label:t("labelId"),value:(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:e.id})}),(0,_.jsx)(Vl,{label:t("labelName"),value:e.name}),e.source_query&&(0,_.jsx)(Vl,{label:t("labelSourceQuery"),value:(0,_.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:e.source_query})}),(0,_.jsx)(Vl,{label:t("labelTags"),value:e.tags?.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(e=>(0,_.jsx)(Vu,{label:e,color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"},e))}):(0,_.jsx)("span",{className:"text-muted-foreground italic text-sm",children:t("noTags")})})]}),(0,_.jsxs)(Vc,{title:t("timingTitle"),icon:(0,_.jsx)(er,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vl,{label:t("labelCreated"),value:F4(e.created_at)}),(0,_.jsx)(Vl,{label:t("labelLastRefreshed"),value:(0,_.jsx)("span",{title:F4(e.last_refreshed_at),children:F3(e.last_refreshed_at)})}),(0,_.jsx)(Vl,{label:t("labelMaxTokens"),value:e.max_tokens.toLocaleString()})]}),(0,_.jsxs)(Vc,{title:t("refreshTriggerTitle"),icon:(0,_.jsx)(L2,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vl,{label:t("labelRefreshMode"),value:"delta"===n.mode?(0,_.jsx)(Vu,{label:t("pillDelta"),color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}):(0,_.jsx)(Vu,{label:t("pillFull")})}),(0,_.jsx)(Vl,{label:t("labelAutoRefreshAfterConsolidation"),value:n.refresh_after_consolidation?(0,_.jsx)(Vu,{label:t("pillEnabled"),color:"bg-green-500/10 text-green-600 dark:text-green-400"}):(0,_.jsx)(Vu,{label:t("pillDisabled")})}),(0,_.jsx)(Vl,{label:t("labelFactTypes"),value:r.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>{let n=F9(e,t);return(0,_.jsx)(Vu,{label:n.label,color:n.color},e)})}):(0,_.jsx)("span",{className:"text-muted-foreground italic text-sm",children:t("factTypesAll")})}),(0,_.jsx)(Vl,{label:t("labelExcludeMentalModels"),value:n.exclude_mental_models?t("valueYes"):t("valueNo")}),a.length>0&&(0,_.jsx)(Vl,{label:t("labelExcludedIds"),value:(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(e=>(0,_.jsx)("code",{className:"text-xs font-mono px-1.5 py-0.5 rounded bg-muted border border-border/60",children:e},e))})})]}),(0,_.jsxs)(Vc,{title:t("recallParamsTitle"),icon:(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vl,{label:t("labelIncludeChunks"),value:null==n.include_chunks?t("includeChunksDefault"):n.include_chunks?t("valueYes"):t("valueNo")}),(0,_.jsx)(Vl,{label:t("labelRecallMaxTokens"),value:null!=n.recall_max_tokens?n.recall_max_tokens.toLocaleString():t("recallMaxTokensDefault")}),(0,_.jsx)(Vl,{label:t("labelRecallChunksMaxTokens"),value:null!=n.recall_chunks_max_tokens?n.recall_chunks_max_tokens.toLocaleString():t("recallChunksMaxTokensDefault")}),(0,_.jsx)(Vl,{label:t("labelTagsMatch"),value:n.tags_match?(0,_.jsx)(Vu,{label:n.tags_match}):t("tagsMatchDefault")})]}),i.length>0&&(0,_.jsx)("div",{className:"md:col-span-2",children:(0,_.jsx)(Vc,{title:t("tagGroupsTitle"),icon:(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),children:(0,_.jsx)("pre",{className:"text-xs font-mono bg-muted/40 rounded p-3 overflow-x-auto border border-border/60",children:JSON.stringify(i,null,2)})})})]})}function Vh({children:e}){return(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:e})}function Vf(){let e,t,n,r,i,a,o,s,l,c,u,d=(0,M.useTranslations)("thinkView"),{currentBank:h}=(0,D.useBank)(),[f,p]=(0,E.useState)(""),[g,x]=(0,E.useState)("mid"),[v,y]=(0,E.useState)(4096),[b,w]=(0,E.useState)(!0),[j,N]=(0,E.useState)(!0),[k,S]=(0,E.useState)("answer"),[C,T]=(0,E.useState)(null),[O,A]=(0,E.useState)(!1),[P,L]=(0,E.useState)(""),[I,z]=(0,E.useState)("any"),[F,V]=(0,E.useState)([]),[H,U]=(0,E.useState)(!1),[W,Y]=(0,E.useState)(""),[G,K]=(0,E.useState)(""),[Z,Q]=(0,E.useState)(!1),[J,ee]=(0,E.useState)(!1),[et,en]=(0,E.useState)(null),[er,ei]=(0,E.useState)(null),[eo,es]=(0,E.useState)(null),[el,ec]=(0,E.useState)(!1),[eu,ed]=(0,E.useState)(null),[eh,ef]=(0,E.useState)(null),[ep,em]=(0,E.useState)(!1),[eg,ex]=(0,E.useState)(null),[ev,ey]=(0,E.useState)("world"),eb="General Feedback",ew=async e=>{if(ed(e),ef(null),h&&e?.id){em(!0);try{let t=await $.client.listObservations(h),n=t.items?.find(t=>t.id===e.id);ef(n||e)}catch(t){console.error("Failed to load observation:",t),ef(e)}finally{em(!1)}}},ej=async()=>{if(h&&G.trim()){Q(!0);try{let e=await $.client.listDirectives(h),t=e.items?.find(e=>e.name===eb);if(t){let e=t.content?`${t.content}
|
|
8
|
-
${G.trim()}`:G.trim();await $.client.updateDirective(h,t.id,{content:e})}else await $.client.createDirective(h,{name:eb,content:G.trim()});K(""),ee(!0),setTimeout(()=>ee(!1),3e3)}catch(e){}finally{Q(!1)}}},eN=async()=>{if(h&&f){A(!0),S("answer");try{let e=P.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=W.split(",").map(e=>e.trim()).filter(e=>e.length>0),n=await $.client.reflect({bank_id:h,query:f,budget:g,max_tokens:v,include_facts:b,include_tool_calls:j,...e.length>0&&{tags:e,tags_match:I},...F.length>0&&{fact_types:F},...H&&{exclude_mental_models:!0},...t.length>0&&{exclude_mental_model_ids:t}});T(n)}catch(e){}finally{A(!1)}}};return h?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"pt-6",children:[(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsxs)("div",{className:"flex-1 relative",children:[(0,_.jsx)(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"text",value:f,onChange:e=>p(e.target.value),placeholder:d("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&eN()})]}),(0,_.jsx)(X.Button,{onClick:eN,disabled:O||!f,className:"h-12 px-8",children:O?d("reflecting"):d("reflect")})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:d("budgetLabel")}),(0,_.jsxs)(e6.Select,{value:g,onValueChange:e=>x(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-24 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"low",children:d("budgetLow")}),(0,_.jsx)(e6.SelectItem,{value:"mid",children:d("budgetMid")}),(0,_.jsx)(e6.SelectItem,{value:"high",children:d("budgetHigh")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:d("tokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:v,onChange:e=>y(parseInt(e.target.value)||4096),className:"w-24 h-8"})]}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:b,onCheckedChange:e=>w(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("includeSource")})]}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:j,onCheckedChange:e=>N(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("includeTools")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,_.jsx)(e7,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("div",{className:"flex-1 max-w-md",children:(0,_.jsx)(q.Input,{type:"text",value:P,onChange:e=>L(e.target.value),placeholder:d("tagsPlaceholder"),className:"h-8"})}),(0,_.jsxs)(e6.Select,{value:I,onValueChange:e=>z(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-40 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"any",children:d("tagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:d("tagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:d("tagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:d("tagsMatchAllStrict")})]})]})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsx)(Li,{value:F,onChange:V}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:H,onCheckedChange:e=>U(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("excludeMentalModels")})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:d("excludeIdsLabel")}),(0,_.jsx)(q.Input,{type:"text",value:W,onChange:e=>Y(e.target.value),placeholder:d("excludeIdsPlaceholder"),className:"h-8 w-48"})]})]})]})}),O&&(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:d("reflectingOnMemories")})]})}),!O&&C&&(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[C.usage&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("inputTokensLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.usage.input_tokens?.toLocaleString()})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("outputTokensLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.usage.output_tokens?.toLocaleString()})]})]}),C.trace?.tool_calls&&(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("toolCallsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.trace.tool_calls.length}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.tool_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),C.trace?.llm_calls&&(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("llmCallsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.trace.llm_calls.length}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.llm_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(e=>(0,_.jsx)("button",{onClick:()=>S(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${k===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===e?d("viewAnswer"):"trace"===e?d("viewTrace"):d("viewJson")},e))})]}),"answer"===k&&(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{children:d("answerTitle")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,_.jsx)(zw,{remarkPlugins:[FQ],children:C.text})})})]}),(0,_.jsxs)(tm.Card,{className:"border-blue-200 dark:border-blue-800",children:[(0,_.jsxs)(tm.CardHeader,{className:"py-4",children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,_.jsx)(Ll,{className:"w-4 h-4"}),d("addDirectiveTitle")]}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("addDirectiveDescription")})]}),(0,_.jsx)(tm.CardContent,{className:"pt-0",children:J?(0,_.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,_.jsx)("span",{className:"text-lg",children:"✓"}),(0,_.jsx)("span",{className:"text-sm font-medium",children:d("directiveSaved",{name:eb})})]}):(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsx)(Ld.Textarea,{value:G,onChange:e=>K(e.target.value),placeholder:d("directivePlaceholder"),className:"flex-1 min-h-[60px] resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ej()}}),(0,_.jsx)(X.Button,{onClick:ej,disabled:Z||!G.trim(),className:"self-end",children:Z?d("savingDirective"):d("saveDirective")})]})})]})]}),"trace"===k&&(0,_.jsxs)("div",{className:"space-y-4",children:[C.observations_created&&C.observations_created.length>0&&(0,_.jsxs)(tm.Card,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,_.jsxs)(tm.CardHeader,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,_.jsx)(Ls,{className:"w-4 h-4 text-emerald-600"}),d("observationsCreatedTitle",{count:C.observations_created.length})]}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("observationsCreatedDescription")})]}),(0,_.jsx)(tm.CardContent,{className:"pt-4",children:(0,_.jsx)("div",{className:"space-y-2",children:C.observations_created.map((e,t)=>(0,_.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,_.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:e.name}),(0,_.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:e.description}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",e.id]})]},t))})})]}),(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,_.jsxs)(tm.Card,{className:"h-fit",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-base",children:d("executionTraceTitle")}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("executionTraceDescription",{iterations:C.iterations||0,iterationsPlural:1!==(C.iterations||0)?"s":"",totalMs:(C.trace?.llm_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)+(C.trace?.tool_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)})})]}),(0,_.jsx)(tm.CardContent,{children:j?C.trace?.llm_calls&&C.trace.llm_calls.length>0||C.trace?.tool_calls&&C.trace.tool_calls.length>0?(0,_.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(e=C.trace?.llm_calls||[],t=C.trace?.tool_calls||[],n=[],e.forEach((r,i)=>{let a=t.filter(e=>e.iteration===i+1),o=i===e.length-1,s=r.scope.includes("final")||o&&0===a.length,l=s?e.length:i+1;n.push({type:"llm",llm:r,iteration:l,isFinal:s}),a.length>0&&n.push({type:"tools",tools:a,iteration:i+1})}),n.map((e,t)=>(0,_.jsxs)("div",{className:"relative",children:[t<n.length-1&&(0,_.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===e.type?(0,_.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,_.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${e.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:e.isFinal?(0,_.jsx)(te.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,_.jsx)("span",{className:"text-[10px] font-semibold",children:e.iteration})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("span",{className:"font-medium text-sm",children:e.isFinal?d("responseGenerated"):d("agentDecided")}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(ea,{className:"w-3 h-3"}),e.llm.duration_ms,"ms"]})]}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e.isFinal?d("finalAnswer"):d("calledToolsBelow")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,_.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,_.jsx)(Lu,{className:"w-3 h-3",fill:"currentColor"})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,_.jsx)("div",{className:"text-xs text-muted-foreground",children:(e.tools?.length??0)!==1?d("executingToolsPlural",{count:e.tools?.length??0}):d("executingTools",{count:e.tools?.length??0})}),e.tools?.map((e,t)=>(0,_.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.tool}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(ea,{className:"w-3 h-3"}),e.duration_ms,"ms"]})]}),(0,_.jsxs)("div",{className:"p-2 space-y-2",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:d("toolInputLabel")}),(0,_.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,_.jsx)(L1,{src:e.input,collapsed:1,theme:"default"})})]}),e.output&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:d("toolOutputLabel")}),(0,_.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,_.jsx)(L1,{src:e.output,collapsed:1,theme:"default"})})]})]})]},t))]})]})]},t)))}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Lo.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("noOperations")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("noOperationsDescription")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Lo.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("notIncluded")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("enableIncludeTools")})]})]})})]}),(0,_.jsxs)(tm.Card,{className:"h-fit",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-base",children:d("basedOnTitle")}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("basedOnDescription",{count:(C.based_on?.memories?.length||0)+(C.based_on?.observations?.filter(e=>"directive"!==e.subtype)?.length||0)+(C.based_on?.directives?.length||0)})})]}),(0,_.jsx)(tm.CardContent,{children:b?C.based_on?.memories&&C.based_on.memories.length>0||C.based_on?.mental_models&&C.based_on.mental_models.length>0||C.based_on?.directives&&C.based_on.directives.length>0||C.based_on?.observations&&C.based_on.observations.length>0?(i=(r=C.based_on?.memories||[]).filter(e=>"world"===e.type),a=r.filter(e=>"experience"===e.type),o=C.based_on?.mental_models||[],s=(C.based_on?.observations||[]).filter(e=>"directive"!==e.subtype),l=C.based_on?.directives||[],c=[{id:"directives",label:d("tabDirectives"),count:l.length},{id:"mental_models",label:d("tabMentalModels"),count:o.length},{id:"observations",label:d("tabObservations"),count:s.length},{id:"world",label:d("tabWorld"),count:i.length},{id:"experience",label:d("tabExperience"),count:a.length}],u=(()=>{switch(ev){case"directives":return l;case"mental_models":return o;case"observations":return s;case"world":return i;case"experience":return a;default:return[]}})(),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:c.map(e=>(0,_.jsxs)("button",{onClick:()=>ey(e.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${ev===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.label," (",e.count,")"]},e.id))}),u.length>0?(0,_.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:u.map((e,t)=>{let n,r;return(0,_.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==ev?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==ev&&("observations"===ev?ew(e):"mental_models"===ev?ex(e.id):en(e.id))},children:"directives"===ev?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.content&&(0,_.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.content})]}):"observations"===ev?(0,_.jsx)("div",{className:"font-medium text-sm",children:e.name}):"mental_models"===ev?(r=(n=e.text?.indexOf(": ")??-1)>0?e.text.slice(0,n):e.id,(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"font-medium text-sm",children:r}),(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.id})]})):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text}),e.context&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:e.context})]})},e.id||t)})}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:d("noTabItems",{tab:ev})})]})):(0,_.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,_.jsx)(Lo.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:d("noFactsFound")}),(0,_.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:d("noFactsFoundDescription")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Lo.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("notIncludedBasedOn")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("enableIncludeSource")})]})]})})]})]})]}),"json"===k&&(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{className:"text-lg",children:d("rawResponseTitle")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,_.jsx)(L1,{src:C,collapsed:2,theme:"default"})})})]})]}),!O&&!C&&(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(R,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-lg font-semibold mb-2",children:d("readyToReflect")}),(0,_.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:d("readyToReflectDescription")})]})}),(0,_.jsx)(tp,{memoryId:et,onClose:()=>en(null)}),er&&(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Lc,{className:"w-5 h-5"}),(0,_.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"icon",onClick:()=>{ei(null),es(null)},children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]}),el?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,_.jsx)("p",{className:"mt-1 font-medium",children:eo?.name||er.name})]}),eo?.description&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,_.jsx)("p",{className:"mt-1 text-sm",children:eo.description})]}),eo?.tags&&eo.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:eo.tags.map(e=>(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(e7,{className:"w-2.5 h-2.5"}),e]},e))})]}),(eo?.content||er.content)&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,_.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:eo?.content||er.content})})]}),(0,_.jsxs)("div",{className:"pt-2 border-t",children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,_.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:er.id})]})]})]})}),eu&&(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Ls,{className:"w-5 h-5"}),(0,_.jsx)("h2",{className:"text-lg font-semibold",children:d("observationPanelTitle")})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"icon",onClick:()=>{ed(null),ef(null)},children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]}),ep?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:d("observationTextField")}),(0,_.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,_.jsx)(zw,{remarkPlugins:[FQ],children:eh?.text||eu.text})})]}),eh?.tags&&eh.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:d("observationTagsField")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:eh.tags.map(e=>(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(e7,{className:"w-2.5 h-2.5"}),e]},e))})]}),eh?.source_memories&&eh.source_memories.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("observationSourceMemoriesField",{count:eh.source_memories.length})}),(0,_.jsx)("div",{className:"space-y-2",children:eh.source_memories.map((e,t)=>(0,_.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.text||("string"==typeof e?e:"")})},t))})]}),(0,_.jsxs)("div",{className:"pt-2 border-t",children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:d("observationIdField")}),(0,_.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:eu.id})]})]})]})}),(0,_.jsx)(Vs,{mentalModelId:eg,onClose:()=>ex(null)})]}):(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2",children:d("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:d("noBankSelectedDescription")})]})})}let Vp=(0,I.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function Vm(){let e,t,n,r,i,a,o,s,l,c,u,d,h,f,p=(0,M.useTranslations)("searchDebug"),{currentBank:g}=(0,D.useBank)(),[x,v]=(0,E.useState)(""),[y,b]=(0,E.useState)(["world"]),[w,j]=(0,E.useState)("mid"),[N,k]=(0,E.useState)(4096),[S,C]=(0,E.useState)(""),[T,A]=(0,E.useState)(!1),[P,I]=(0,E.useState)(!1),[R,V]=(0,E.useState)(""),[U,W]=(0,E.useState)("any"),[Y,G]=(0,E.useState)(null),[Z,Q]=(0,E.useState)(null),[J,ee]=(0,E.useState)(null),[et,en]=(0,E.useState)(null),[er,ei]=(0,E.useState)(null),[eo,es]=(0,E.useState)(!1),[el,ec]=(0,E.useState)("results"),[eu,ed]=(0,E.useState)(null),[eh,ef]=(0,E.useState)(new Set),[ep,em]=(0,E.useState)(new Set),eg=e=>{ef(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ex=e=>{em(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ev=e=>{let t=e.id||e.node_id;ed(Y?.find(e=>e.id===t||e.node_id===t)||e)},ey=async()=>{if(!g)return void O.toast.error(p("errorSelectBank"));if(x){if(0===y.length)return void O.toast.error(p("errorSelectFactType"));es(!0);try{let e=R.split(",").map(e=>e.trim()).filter(e=>e.length>0),t={bank_id:g,query:x,types:y,budget:w,max_tokens:N,trace:!0,include:{entities:P?{max_tokens:500}:null,chunks:T?{max_tokens:8192}:null},...S&&{query_timestamp:S},...e.length>0&&{tags:e,tags_match:U}},n=await $.client.recall(t);G(n.results||[]),Q(n.entities||null),ee(n.chunks||null),en(n.observations||null),ei(n.trace||null),ec("results")}catch(e){}finally{es(!1)}}};return g?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"pt-6",children:[(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsxs)("div",{className:"flex-1 relative",children:[(0,_.jsx)(L.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"text",value:x,onChange:e=>v(e.target.value),placeholder:p("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&ey()})]}),(0,_.jsx)(X.Button,{onClick:ey,disabled:eo||!x,className:"h-12 px-8",children:eo?p("searching"):p("recall")})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsx)(Li,{value:y,onChange:b,label:p("typesLabel")}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(L2,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsxs)(e6.Select,{value:w,onValueChange:e=>j(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-24 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"low",children:p("budgetLow")}),(0,_.jsx)(e6.SelectItem,{value:"mid",children:p("budgetMid")}),(0,_.jsx)(e6.SelectItem,{value:"high",children:p("budgetHigh")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:p("tokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:N,onChange:e=>k(parseInt(e.target.value)),className:"w-24 h-8"})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(ea,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"datetime-local",value:S,onChange:e=>C(e.target.value),className:"h-8",placeholder:p("queryDatePlaceholder")})]}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:T,onCheckedChange:e=>A(e)}),(0,_.jsx)(z.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-sm",children:p("chunks")})]}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:P,onCheckedChange:e=>I(e)}),(0,_.jsx)(F,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-sm",children:p("entities")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,_.jsx)(e7,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("div",{className:"flex-1 max-w-md",children:(0,_.jsx)(q.Input,{type:"text",value:R,onChange:e=>V(e.target.value),placeholder:p("tagsPlaceholder"),className:"h-8"})}),(0,_.jsxs)(e6.Select,{value:U,onValueChange:e=>W(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-40 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"any",children:p("tagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:p("tagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:p("tagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:p("tagsMatchAllStrict")})]})]})]})]})}),eo&&(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("searchingMemories")})]})}),!eo&&Y&&(0,_.jsxs)("div",{className:"space-y-4",children:[er?.summary&&(0,_.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("resultsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:Y.length})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("durationLabel")}),(0,_.jsxs)("span",{className:"font-semibold",children:[er.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("nodesVisitedLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:er.summary.total_nodes_visited})]}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(e=>(0,_.jsx)("button",{onClick:()=>ec(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${el===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===e?p("viewResults"):"trace"===e?p("viewTrace"):p("viewJson")},e))})]}),"results"===el&&(0,_.jsxs)("div",{className:"space-y-4",children:[et&&et.length>0&&(0,_.jsxs)(tm.Card,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,_.jsx)(tm.CardHeader,{className:"py-3",children:(0,_.jsxs)(tm.CardTitle,{className:"text-base flex items-center gap-2",children:[(0,_.jsx)(B,{className:"h-4 w-4 text-orange-500"}),(0,_.jsx)("span",{children:"Observations"}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",et.length,")"]})]})}),(0,_.jsx)(tm.CardContent,{className:"pt-0 space-y-2",children:et.map((e,t)=>(0,_.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,_.jsx)("p",{className:"text-sm text-foreground",children:e.text}),(0,_.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,_.jsx)("span",{children:p("proofCount",{count:e.proof_count||1})}),(0,_.jsx)("span",{children:p("relevance",{value:(e.relevance||0).toFixed(3)})})]})]},e.id||t))})]}),(0,_.jsx)("div",{className:"space-y-3",children:0!==Y.length||et&&0!==et.length?Y.map((e,t)=>{let n=er?.visits?.find(t=>t.node_id===e.id),r=n?n.weights.final_weight:e.score||0;return(0,_.jsx)(tm.Card,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ed(e),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-start gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-semibold text-primary",children:t+1})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-foreground",children:e.text}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:e.type||"world"}),e.context&&(0,_.jsx)("span",{className:"truncate max-w-xs",children:e.context}),e.occurred_start&&(0,_.jsx)("span",{children:new Date(e.occurred_start).toLocaleDateString()})]})]}),(0,_.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,_.jsx)("div",{className:"text-sm font-semibold",children:(r??0).toFixed(3)}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground",children:p("scoreLabel")})]}),(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},t)}):(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-12",children:[(0,_.jsx)(L.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("noMemoriesFound")})]})})})]}),"trace"===el&&er&&(0,_.jsxs)("div",{className:"space-y-4",children:[er.retrieval_results&&er.retrieval_results.length>0&&(e={},er.retrieval_results.forEach(t=>{let n=t.fact_type||"all";e[n]||(e[n]=[]),e[n].push(t)}),t=Object.keys(e),(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,_.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,_.jsx)("span",{children:p("parallelRetrieval")}),(0,_.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,_.jsx)("div",{className:"space-y-2",children:t.map((t,n)=>{let r=e[t],i=`lane-${t}`,a=eh.has(i),o=r.reduce((e,t)=>e+(t.results?.length||0),0),s=Math.max(...r.map(e=>e.duration_seconds||0)),l={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"}},c=l[t]||l.all;return(0,_.jsx)(tm.Card,{className:`transition-colors ${a?"border-primary":c.border}`,children:(0,_.jsxs)(tm.CardContent,{className:"py-3 px-4",children:[(0,_.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>eg(i),children:[(0,_.jsx)("div",{className:`w-8 h-8 rounded-lg ${c.bg} flex items-center justify-center`,children:(0,_.jsx)("span",{className:`text-sm font-bold ${c.text} capitalize`,children:t.charAt(0).toUpperCase()})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground capitalize",children:t}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:p("methodsCount",{count:r.length})})]}),(0,_.jsx)("div",{className:"flex gap-1.5 mt-1",children:r.map((e,t)=>(0,_.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[e.method_name,": ",e.results?.length||0]},t))})]}),(0,_.jsxs)("div",{className:"text-right",children:[(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:o}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[s.toFixed(2),"s"]})]}),a?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),a&&(0,_.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,_.jsx)("div",{className:`grid gap-3 ${1===r.length?"grid-cols-1":2===r.length?"grid-cols-2":3===r.length?"grid-cols-3":"grid-cols-4"}`,children:r.map((e,t)=>{let n,r,a,o,s=`${i}-method-${t}`,l=eh.has(s),c=e.results||[];return(0,_.jsxs)("div",{className:"flex flex-col",children:[(0,_.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${l?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:e=>{e.stopPropagation(),eg(s)},children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:e.method_name}),"temporal"===e.method_name&&e.metadata?.constraint&&(0,_.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,_.jsx)(K,{className:"h-3 w-3"}),e.metadata.constraint.start?new Date(e.metadata.constraint.start).toLocaleDateString():"any"," → ",e.metadata.constraint.end?new Date(e.metadata.constraint.end).toLocaleDateString():"any"]})]}),l?(0,_.jsx)(PK.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,_.jsxs)("div",{className:"flex items-end justify-between",children:[(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:c.length}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[e.duration_seconds?.toFixed(2),"s"]})]})]}),l&&c.length>0&&(n=`results-${s}`,a=(r=ep.has(n))?c:c.slice(0,5),o=c.length>5,(0,_.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[a.map((e,t)=>(0,_.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-2",children:[(0,_.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:e.text}),(0,_.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(e.score||e.similarity||0).toFixed(4)})})]})]})},t)),o&&(0,_.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(n)},children:r?p("showLess"):p("viewAllResults",{count:c.length})})]}))]},s)})})})]})},i)})}),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)("div",{className:"flex items-center gap-2",children:t.map((e,t)=>{let n={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,_.jsx)("div",{className:"flex flex-col items-center",children:(0,_.jsx)("div",{className:`w-1 h-4 ${n[e]||n.all} rounded-full opacity-50`})},t)})})}),(0,_.jsx)("div",{className:"flex justify-center",children:(0,_.jsx)(Vp,{className:"h-5 w-5 text-muted-foreground/50"})})]})),er.rrf_merged&&(n="rrf-merge",r=eh.has(n),(0,_.jsxs)("div",{children:[(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors ${r?"border-primary":"hover:border-primary/50"}`,onClick:()=>eg(n),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("rrfFusion")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rrfMerge")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("rrfDescription")})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:er.rrf_merged.length}),r?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),r&&er.rrf_merged.length>0&&(i="results-rrf",o=(a=ep.has(i))?er.rrf_merged:er.rrf_merged.slice(0,5),s=er.rrf_merged.length>5,(0,_.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[o.map((e,t)=>(0,_.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,_.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[p("rrfScore")," ",(e.rrf_score||e.score||0).toFixed(4)]})]})]})},t)),s&&(0,_.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(i)},children:a?p("showLess"):p("viewAllResults",{count:er.rrf_merged.length})})]})),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)(Vp,{className:"h-4 w-4 text-muted-foreground/50"})})]})),er.reranked&&(l="reranking",c=eh.has(l),(0,_.jsxs)("div",{children:[(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors ${c?"border-primary":"hover:border-primary/50"}`,onClick:()=>eg(l),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("combinedScoring")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rerank")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,_.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:er.reranked.length}),c?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),c&&er.reranked.length>0&&(u="results-rerank",h=(d=ep.has(u))?er.reranked:er.reranked.slice(0,5),f=er.reranked.length>5,(0,_.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[h.map((e,t)=>{let n=e.score_components||{};return(0,_.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,_.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(e.rerank_score||e.score||0).toFixed(4)]}),void 0!==n.cross_encoder_score_normalized&&(0,_.jsxs)("span",{title:p("tooltipCrossEncoder"),children:["CE: ",n.cross_encoder_score_normalized.toFixed(3)]}),void 0!==n.temporal&&.5!==n.temporal&&(0,_.jsxs)("span",{title:p("tooltipTemporal"),children:["Tmp: ",n.temporal.toFixed(3)]}),void 0!==n.recency&&(0,_.jsxs)("span",{title:p("tooltipRecency"),children:["Rec: ",n.recency.toFixed(3)]})]})]})]})},t)}),f&&(0,_.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(u)},children:d?p("showLess"):p("viewAllResults",{count:er.reranked.length})})]})),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)(Vp,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,_.jsx)(tm.Card,{className:"border-primary bg-primary/5",children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("finalResults")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:p("output")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("finalResultsDescription")})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-primary",children:Y?.length||0})]})})})]}),"json"===el&&(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{className:"text-lg",children:p("rawResponse")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,_.jsx)(L1,{src:{results:Y,...Z&&{entities:Z},...J&&{chunks:J},...et&&{observations:et},trace:er},collapsed:2,theme:"default"})})})]})]}),!eo&&!Y&&(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(L.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-lg font-semibold mb-2",children:p("readyToRecall")}),(0,_.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:p("readyToRecallDescription")})]})}),eu&&(0,_.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,_.jsx)(wz,{memory:eu,onClose:()=>ed(null),inPanel:!0,bankId:g||void 0})})]}):(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2",children:p("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("noBankSelectedDescription")})]})})}let Vg=(0,I.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 Vx=e.i(82458),Vx=Vx,tn=tn;let Vv=["skepticism","literalism","empathy"];function Vy(){let e=(0,M.useTranslations)("bankProfile");return{skepticism:{label:e("skepticismLabel"),shortLabel:"S",description:e("skepticismDescription"),lowLabel:e("skepticismLow"),highLabel:e("skepticismHigh")},literalism:{label:e("literalismLabel"),shortLabel:"L",description:e("literalismDescription"),lowLabel:e("literalismLow"),highLabel:e("literalismHigh")},empathy:{label:e("empathyLabel"),shortLabel:"E",description:e("empathyDescription"),lowLabel:e("empathyLow"),highLabel:e("empathyHigh")}}}function Vb({hideReflectFields:e=!1}){let t=(0,T.useRouter)(),n=(0,M.useTranslations)("bankProfile"),r=(0,M.useTranslations)("common"),i=(0,M.useTranslations)("bank"),a=Vy(),{currentBank:o,setCurrentBank:s,loadBanks:l}=(0,D.useBank)(),{features:c}=(0,Pp.useFeatures)();c?.observations;let[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)([]),[x,v]=(0,E.useState)(0),[y,b]=(0,E.useState)([]),[w,j]=(0,E.useState)(0),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(null),[V,H]=(0,E.useState)(!1),[U,W]=(0,E.useState)(!1),[Y,G]=(0,E.useState)(!1),[q,K]=(0,E.useState)(!1),[Z,Q]=(0,E.useState)(!1),[J,ee]=(0,E.useState)(!1),[et,en]=(0,E.useState)(null),[ei]=(0,E.useState)(10),[eo,es]=(0,E.useState)(0),[el,ec]=(0,E.useState)(null),eu=async(e=et,t=eo)=>{if(o)try{let n=await $.client.listOperations(o,{status:e||void 0,limit:ei,offset:t});g(n.operations||[]),v(n.total||0)}catch(e){console.error("Error loading operations:",e)}},ed=async(e=!1)=>{if(o){if(e){try{let[e,t,n]=await Promise.all([$.client.getBankStats(o),$.client.listDirectives(o),$.client.listMentalModels(o)]);f(e),b(t.items||[]),j(n.items?.length||0)}catch(e){console.error("Error refreshing stats:",e)}return}k(!0);try{let[e,t,n,r]=await Promise.all([$.client.getBankProfile(o),$.client.getBankStats(o),$.client.listDirectives(o),$.client.listMentalModels(o)]);d(e),f(t),b(n.items||[]),j(r.items?.length||0),await eu()}catch(e){}finally{k(!1)}}},eh=async()=>{if(o){G(!0);try{await $.client.deleteBank(o),W(!1),s(null),await l(),t.push("/")}catch(e){}finally{G(!1)}}},ef=async()=>{if(o){Q(!0);try{let e=await $.client.clearObservations(o);K(!1),await ed(),O.toast.success("Success",{description:e.message||"Observations cleared successfully"})}catch(e){}finally{Q(!1)}}},ep=async()=>{if(o&&z){H(!0);try{await $.client.deleteDirective(o,z.id),b(e=>e.filter(e=>e.id!==z.id)),R?.id===z.id&&B(null),F(null)}catch(e){}finally{H(!1)}}};return((0,E.useEffect)(()=>{if(o){ed();let e=setInterval(()=>ed(!0),5e3);return()=>clearInterval(e)}},[o]),(0,E.useEffect)(()=>{let e=e=>{"Escape"===e.key&&B(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),o)?N&&!u?(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"text-center py-10",children:[(0,_.jsx)(ea,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,_.jsx)("div",{className:"text-lg text-muted-foreground",children:n("loadingProfile")})]})}):(0,_.jsxs)("div",{className:"space-y-6",children:[!e&&(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)("div",{className:"flex items-start justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(Ls,{className:"w-5 h-5 text-primary"}),n("dispositionProfileTitle")]}),(0,_.jsx)(tm.CardDescription,{children:n("editDispositionDescription")})]}),(0,_.jsx)(X.Button,{onClick:()=>C(!0),variant:"ghost",size:"sm",children:(0,_.jsx)(PX,{className:"h-4 w-4"})})]})}),(0,_.jsx)(tm.CardContent,{children:u&&(0,_.jsx)("div",{className:"space-y-4",children:Vv.map(e=>(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:a[e].label}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:a[e].description})]}),(0,_.jsxs)("span",{className:"text-sm font-bold text-primary",children:[u.disposition[e],"/5"]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:a[e].lowLabel}),(0,_.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,_.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(u.disposition[e]-1)/4*100}%`}})}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:a[e].highLabel})]})]},e))})})]}),(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)("div",{className:"flex items-start justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(Vg,{className:"w-5 h-5 text-primary"}),n("missionTitle")]}),(0,_.jsx)(tm.CardDescription,{children:n("editMissionDescription")})]}),(0,_.jsx)(X.Button,{onClick:()=>P(!0),variant:"ghost",size:"sm",children:(0,_.jsx)(PX,{className:"h-4 w-4"})})]})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:u?.mission||n("noMissionSet")})})]})]}),(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,_.jsx)(Vx.default,{className:"w-5 h-5 text-rose-500"}),n("directivesTitle")]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:n("directivesDescription")})]}),(0,_.jsxs)(X.Button,{onClick:()=>I(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-1"}),n("addDirective")]})]}),y.length>0?(0,_.jsx)("div",{className:"grid grid-cols-2 gap-3",children:y.map(e=>(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors border-rose-500/30 ${R?.id===e.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>B(e),children:(0,_.jsx)(tm.CardContent,{className:"p-3",children:(0,_.jsxs)("div",{className:"flex items-start gap-2",children:[(0,_.jsx)(Vx.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:e.content}),e.tags&&e.tags.length>0&&(0,_.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,_.jsx)(e7,{className:"w-3 h-3 text-muted-foreground"}),e.tags.map(e=>(0,_.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e},e))]})]})]})})},e.id))}):(0,_.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,_.jsx)(Vx.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:n("noDirectivesMessage")})]})]}),(0,_.jsx)(PN,{open:U,onOpenChange:W,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("deleteMemoryBank")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:i.rich("deleteBankPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:o})})}),(0,_.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:i("deleteBankWarning")}),h&&(0,_.jsx)("p",{children:i("deleteWillDeleteDetails",{memories:h.total_nodes,documents:h.total_documents,links:h.total_links})})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:Y,children:r("cancel")}),(0,_.jsx)(PY,{onClick:eh,disabled:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Y?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),i("deleting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),i("deleteBank")]})})]})]})}),(0,_.jsx)(PN,{open:q,onOpenChange:K,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("clearObservationsTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:i.rich("clearObservationsPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:o})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:i("clearObservationsWarning")}),h&&h.total_observations>0&&(0,_.jsx)("p",{children:i("deleteWillDeleteObservations",{count:h.total_observations})})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:Z,children:r("cancel")}),(0,_.jsx)(PY,{onClick:ef,disabled:Z,className:"bg-amber-500 text-white hover:bg-amber-600",children:Z?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),i("clearing")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),i("clearObservations")]})})]})]})}),(0,_.jsx)(VN,{open:L,mode:"create",onClose:()=>I(!1),onCreated:e=>{b(t=>[e,...t]),I(!1)}}),(0,_.jsx)(PN,{open:!!z,onOpenChange:e=>!e&&F(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("deleteDirectiveTitle")}),(0,_.jsxs)(PW,{children:[n("deleteDirectiveConfirm",{name:`"${z?.name??""}"`}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:n("deleteDirectiveWarning")})]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:r("cancel")}),(0,_.jsxs)(PY,{onClick:ep,disabled:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[V?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,r("delete")]})]})]})}),R&&(0,_.jsx)(Vk,{directive:R,onClose:()=>B(null),onDelete:()=>F({id:R.id,name:R.name}),onUpdated:e=>{b(t=>t.map(t=>t.id===e.id?e:t)),B(e)}}),S&&u&&(0,_.jsx)(Vw,{disposition:u.disposition,onClose:()=>C(!1),onSaved:async()=>{await ed(),C(!1)}}),A&&u&&(0,_.jsx)(Vj,{mission:u.mission||"",onClose:()=>P(!1),onSaved:async()=>{await ed(),P(!1)}})]}):(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"p-10 text-center",children:[(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:n("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("noBankSelectedDescription")})]})})}function Vw({disposition:e,onClose:t,onSaved:n}){let r=(0,M.useTranslations)("bankProfile"),i=Vy(),{currentBank:a}=(0,D.useBank)(),[o,s]=(0,E.useState)(!1),[l,c]=(0,E.useState)(e),u=async()=>{if(a){s(!0);try{await $.client.updateBankConfig(a,{disposition_skepticism:l.skepticism,disposition_literalism:l.literalism,disposition_empathy:l.empathy}),n()}catch(e){}finally{s(!1)}}};return(0,_.jsx)(ta.Dialog,{open:!0,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-xl",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("editDispositionTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("editDispositionDescription")})]}),(0,_.jsx)("div",{className:"space-y-4 py-4",children:Vv.map(e=>(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i[e].label}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i[e].description})]}),(0,_.jsxs)("span",{className:"text-sm font-bold text-primary",children:[l[e],"/5"]})]}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,_.jsx)("span",{children:i[e].lowLabel}),(0,_.jsx)("span",{children:i[e].highLabel})]}),(0,_.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:l[e],onChange:t=>c(n=>({...n,[e]:parseInt(t.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},e))}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{onClick:t,variant:"outline",disabled:o,children:r("cancel")}),(0,_.jsx)(X.Button,{onClick:u,disabled:o,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),r("saving")]}):r("saveChanges")})]})]})})}function Vj({mission:e,onClose:t,onSaved:n}){let r=(0,M.useTranslations)("bankProfile"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(e),c=async()=>{if(i){o(!0);try{await $.client.updateBankConfig(i,{reflect_mission:s||null}),n()}catch(e){}finally{o(!1)}}};return(0,_.jsx)(ta.Dialog,{open:!0,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-xl",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("editMissionTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("editMissionDescription")})]}),(0,_.jsx)("div",{className:"space-y-2 py-4",children:(0,_.jsx)(Ld.Textarea,{value:s,onChange:e=>l(e.target.value),placeholder:r("missionPlaceholder"),rows:8,className:"resize-none"})}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{onClick:t,variant:"outline",disabled:a,children:r("cancel")}),(0,_.jsx)(X.Button,{onClick:c,disabled:a,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),r("saving")]}):r("saveChanges")})]})]})})}function VN({open:e,mode:t,directive:n,onClose:r,onCreated:i,onSaved:a}){let o=(0,M.useTranslations)("bankProfile"),{currentBank:s}=(0,D.useBank)(),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)({name:"",content:"",tags:""});(0,E.useEffect)(()=>{"edit"===t&&n?d({name:n.name,content:n.content,tags:(n.tags||[]).join(", ")}):"create"===t&&d({name:"",content:"",tags:""})},[e,t,n]);let h=async()=>{if(s&&u.name.trim()&&u.content.trim()){c(!0);try{let e=u.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0);if("create"===t){let t=await $.client.createDirective(s,{name:u.name.trim(),content:u.content.trim(),tags:e.length>0?e:void 0});d({name:"",content:"",tags:""}),i?.(t)}else if(n){let t=await $.client.updateDirective(s,n.id,{name:u.name.trim(),content:u.content.trim(),tags:e});a?.(t),r()}}catch(e){}finally{c(!1)}}},f=()=>{"create"===t&&d({name:"",content:"",tags:""}),r()};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>!e&&f(),children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-lg",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)(Vx.default,{className:"w-5 h-5 text-rose-500"}),o("create"===t?"directiveFormCreateTitle":"directiveFormEditTitle")]}),(0,_.jsx)(ta.DialogDescription,{children:o("directiveFormDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:o("directiveNameLabel")}),(0,_.jsx)(q.Input,{value:u.name,onChange:e=>d({...u,name:e.target.value}),placeholder:o("directiveNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:o("directiveRuleLabel")}),(0,_.jsx)(Ld.Textarea,{value:u.content,onChange:e=>d({...u,content:e.target.value}),placeholder:o("directiveRulePlaceholder"),className:"min-h-[120px]"})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("label",{className:"text-sm font-medium text-foreground",children:[o("directiveTagsLabel")," ",(0,_.jsx)("span",{className:"text-muted-foreground font-normal",children:o("directiveTagsOptional")})]}),(0,_.jsx)(q.Input,{value:u.tags,onChange:e=>d({...u,tags:e.target.value}),placeholder:o("directiveTagsPlaceholder")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:f,disabled:l,children:o("cancel")}),(0,_.jsxs)(X.Button,{onClick:h,disabled:l||!u.name.trim()||!u.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[l?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,o("create"===t?"create":"save")]})]})]})})}function Vk({directive:e,onClose:t,onDelete:n,onUpdated:r}){let i=(0,M.useTranslations)("bankProfile"),[a,o]=(0,E.useState)(!1);return(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)(Vx.default,{className:"w-5 h-5 text-rose-500"}),(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>o(!0),className:"h-7 w-7 p-0",children:(0,_.jsx)(PX,{className:"h-3.5 w-3.5"})})]}),(0,_.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:i("directiveDetailBadge")})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,_.jsx)(P$,{className:"h-4 w-4"})}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,_.jsx)(tt.X,{className:"h-4 w-4"})})]})]}),(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:i("directiveDetailRuleLabel")}),(0,_.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,_.jsx)(zw,{remarkPlugins:[FQ],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:i("directiveDetailTagsLabel")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,_.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:i("directiveDetailIdLabel")}),(0,_.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]})]})]}),(0,_.jsx)(VN,{open:a,mode:"edit",directive:e,onClose:()=>o(!1),onSaved:r})]})}let VS=(0,ev.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"}}),VC=E.forwardRef(({className:e,variant:t,...n},r)=>(0,_.jsx)("div",{ref:r,role:"alert",className:(0,W.cn)(VS({variant:t}),e),...n}));VC.displayName="Alert",E.forwardRef(({className:e,...t},n)=>(0,_.jsx)("h5",{ref:n,className:(0,W.cn)("mb-1 font-medium leading-none tracking-tight",e),...t})).displayName="AlertTitle";let V_=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)("div",{ref:n,className:(0,W.cn)("text-sm [&_p]:leading-relaxed",e),...t}));V_.displayName="AlertDescription";var tn=tn;let VE=(0,I.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"}]]),VT=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT"].map(e=>({category:e,threshold:"BLOCK_NONE"})),VM=["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","list_documents","get_document","delete_document","list_operations","get_operation","cancel_operation","list_tags"];function VO(e){return Array.isArray(e)?e:e&&"object"==typeof e&&Array.isArray(e.attributes)?e.attributes:null}function VA(e){return{retain_chunk_size:e.retain_chunk_size??null,retain_extraction_mode:e.retain_extraction_mode??null,retain_mission:e.retain_mission??null,retain_custom_instructions:e.retain_custom_instructions??null,entities_allow_free_form:e.entities_allow_free_form??null,entity_labels:VO(e.entity_labels)}}function VD(e){return{retain_default_strategy:e.retain_default_strategy??null,retain_strategies:e.retain_strategies??null}}function VP(e){return{enable_observations:e.enable_observations??null,consolidation_llm_batch_size:e.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:e.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:e.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:e.observations_mission??null,max_observations_per_scope:e.max_observations_per_scope??null}}function VL(e){return{mcp_enabled_tools:e.mcp_enabled_tools??null}}function VI(e){return{llm_gemini_safety_settings:e.llm_gemini_safety_settings??null}}let VR={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function VB(){let e=(0,M.useTranslations)("bankConfig"),{currentBank:t}=(0,D.useBank)(),{features:n}=(0,Pp.useFeatures)(),r=n?.bank_config_api??!0,[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)({}),[l,c]=(0,E.useState)(VR),[u,d]=(0,E.useState)(VA({})),[h,f]=(0,E.useState)(VD({})),[p,g]=(0,E.useState)(VP({})),[x,v]=(0,E.useState)(VR),[y,b]=(0,E.useState)(VL({})),[w,j]=(0,E.useState)(VI({})),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(null),[V,H]=(0,E.useState)(null),[U,W]=(0,E.useState)(null),[Y,G]=(0,E.useState)(null),X=(0,E.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(VA(o))||JSON.stringify(h)!==JSON.stringify(VD(o)),[u,h,o]),K=(0,E.useMemo)(()=>JSON.stringify(p)!==JSON.stringify(VP(o)),[p,o]),Z=(0,E.useMemo)(()=>JSON.stringify(x)!==JSON.stringify(l),[x,l]),Q=(0,E.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(VL(o)),[y,o]),J=(0,E.useMemo)(()=>JSON.stringify(w)!==JSON.stringify(VI(o)),[w,o]);(0,E.useEffect)(()=>{t&&ee()},[t]);let ee=async()=>{if(t){a(!0);try{let[e,n]=await Promise.all([$.client.getBankConfig(t),$.client.getBankProfile(t)]),r=e.config,i={reflect_mission:n.mission??"",disposition_skepticism:r.disposition_skepticism??n.disposition?.skepticism??3,disposition_literalism:r.disposition_literalism??n.disposition?.literalism??3,disposition_empathy:r.disposition_empathy??n.disposition?.empathy??3};s(r),c(i),d(VA(r)),f(VD(r)),g(VP(r)),v(i),b(VL(r)),j(VI(r))}catch(e){console.error("Failed to load bank data:",e)}finally{a(!1)}}},et=async()=>{if(t){k(!0),B(null);try{let e={...u,...h};await $.client.updateBankConfig(t,e),s(t=>({...t,...e}))}catch(t){B(t.message||e("retainFailedToSave"))}finally{k(!1)}}},en=async()=>{if(t){C(!0),F(null);try{await $.client.updateBankConfig(t,p),s(e=>({...e,...p}))}catch(t){F(t.message||e("observationsFailedToSave"))}finally{C(!1)}}},er=async()=>{if(t){O(!0),H(null);try{await $.client.updateBankConfig(t,{reflect_mission:x.reflect_mission||null,disposition_skepticism:x.disposition_skepticism,disposition_literalism:x.disposition_literalism,disposition_empathy:x.disposition_empathy}),c(x)}catch(t){H(t.message||e("reflectFailedToSave"))}finally{O(!1)}}},ei=async()=>{if(t){P(!0),W(null);try{await $.client.updateBankConfig(t,y),s(e=>({...e,...y}))}catch(t){W(t.message||e("mcpFailedToSave"))}finally{P(!1)}}},ea=async()=>{if(t){I(!0),G(null);try{await $.client.updateBankConfig(t,w),s(e=>({...e,...w}))}catch(t){G(t.message||e("geminiFailedToSave"))}finally{I(!1)}}};return t?r?i?(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(tn.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)("div",{className:"space-y-8",children:[(0,_.jsxs)(VY,{title:e("retainTitle"),description:e("retainSectionDescription"),error:R,dirty:X,saving:N,onSave:et,children:[(0,_.jsx)(VG,{label:e("defaultStrategyLabel"),description:e("defaultStrategyDescription"),children:(0,_.jsxs)(e6.Select,{value:h.retain_default_strategy??"__none__",onValueChange:e=>f(t=>({...t,retain_default_strategy:"__none__"===e?null:e})),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-full",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"__none__",children:(0,_.jsx)("span",{className:"text-muted-foreground italic",children:e("default")})}),Object.keys(h.retain_strategies??{}).map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:e},e))]})]})}),(0,_.jsx)(VU,{defaultValues:u,onDefaultChange:e=>d(t=>({...t,...e})),strategies:h.retain_strategies,onStrategiesChange:e=>f(t=>({...t,retain_strategies:e}))})]}),(0,_.jsxs)(VY,{title:e("observationsTitle"),description:e("observationsDescription"),error:z,dirty:K,saving:S,onSave:en,children:[(0,_.jsx)(VG,{label:e("enableObservationsLabel"),description:e("enableObservationsDescription"),children:(0,_.jsx)("div",{className:"flex justify-end",children:(0,_.jsx)(e4.Switch,{checked:p.enable_observations??!1,onCheckedChange:e=>g(t=>({...t,enable_observations:e}))})})}),(0,_.jsx)(V$,{label:e("missionLabel"),description:e("observationsMissionDescription"),value:p.observations_mission??"",onChange:e=>g(t=>({...t,observations_mission:e||null})),placeholder:e("observationsMissionPlaceholder"),rows:3}),(0,_.jsx)(VG,{label:e("llmBatchSizeLabel"),description:e("llmBatchSizeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:1,max:64,value:p.consolidation_llm_batch_size??"",onChange:e=>g(t=>({...t,consolidation_llm_batch_size:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(VG,{label:e("sourceFactsMaxTokensLabel"),description:e("sourceFactsMaxTokensDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens??"",onChange:e=>g(t=>({...t,consolidation_source_facts_max_tokens:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(VG,{label:e("sourceFactsMaxTokensPerObservationLabel"),description:e("sourceFactsMaxTokensPerObservationDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens_per_observation??"",onChange:e=>g(t=>({...t,consolidation_source_facts_max_tokens_per_observation:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(VG,{label:e("maxObservationsPerScopeLabel"),description:e("maxObservationsPerScopeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.max_observations_per_scope??"",onChange:e=>g(t=>({...t,max_observations_per_scope:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})})]}),(0,_.jsxs)(VY,{title:e("reflectTitle"),description:e("reflectDescription"),error:V,dirty:Z,saving:T,onSave:er,children:[(0,_.jsx)(V$,{label:e("missionLabel"),description:e("reflectMissionDescription"),value:x.reflect_mission,onChange:e=>v(t=>({...t,reflect_mission:e})),placeholder:e("reflectMissionPlaceholder"),rows:3}),(0,_.jsx)(VX,{label:e("skepticismLabel"),description:e("skepticismDescription"),lowLabel:e("skepticismLowLabel"),highLabel:e("skepticismHighLabel"),value:x.disposition_skepticism,onChange:e=>v(t=>({...t,disposition_skepticism:e}))}),(0,_.jsx)(VX,{label:e("literalismLabel"),description:e("literalismDescription"),lowLabel:e("literalismLowLabel"),highLabel:e("literalismHighLabel"),value:x.disposition_literalism,onChange:e=>v(t=>({...t,disposition_literalism:e}))}),(0,_.jsx)(VX,{label:e("empathyLabel"),description:e("empathyDescription"),lowLabel:e("empathyLowLabel"),highLabel:e("empathyHighLabel"),value:x.disposition_empathy,onChange:e=>v(t=>({...t,disposition_empathy:e}))})]}),(0,_.jsxs)(VY,{title:e("mcpToolsTitle"),description:e("mcpToolsDescription"),error:U,dirty:Q,saving:A,onSave:ei,children:[(0,_.jsx)(VG,{label:e("restrictToolsLabel"),description:e("restrictToolsDescription"),children:(0,_.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,_.jsx)(e4.Switch,{checked:null!==y.mcp_enabled_tools,onCheckedChange:e=>b({mcp_enabled_tools:e?[...VM]:null})}),(0,_.jsx)(eb,{className:"text-xs text-muted-foreground",children:null!==y.mcp_enabled_tools?e("enabled"):e("disabled")})]})}),null!==y.mcp_enabled_tools&&(0,_.jsx)(VW,{selected:y.mcp_enabled_tools,onChange:e=>b({mcp_enabled_tools:e})})]}),(0,_.jsx)(VY,{title:e("modelsTitle"),description:e("modelsDescription"),error:Y,dirty:J,saving:L,onSave:ea,children:(0,_.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,_.jsx)("p",{className:"text-sm font-semibold",children:e("geminiSubsectionTitle")}),(0,_.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,_.jsx)(VG,{label:e("safetySettingsLabel"),description:(0,_.jsxs)(_.Fragment,{children:[e("safetySettingsDescriptionPart1")," ",(0,_.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:e("safetySettingsLearnMore")})]}),children:(0,_.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,_.jsx)(e4.Switch,{checked:null!==w.llm_gemini_safety_settings,onCheckedChange:e=>j({llm_gemini_safety_settings:e?[...VT]:null})}),(0,_.jsx)(eb,{className:"text-xs text-muted-foreground",children:null!==w.llm_gemini_safety_settings?e("custom"):e("default")})]})}),null!==w.llm_gemini_safety_settings&&(0,_.jsx)(VZ,{value:w.llm_gemini_safety_settings,onChange:e=>j({llm_gemini_safety_settings:e})})]})]})})]})}):(0,_.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,_.jsx)("p",{className:"text-base font-medium text-foreground",children:e("apiDisabledTitle")}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:e.rich("apiDisabledDescription",{code:e=>(0,_.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:e})})})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)("p",{className:"text-muted-foreground",children:e("noBankSelected")})})}let Vz=["concise","verbose","verbatim","chunks","custom"],VF="__inherit__";function VV({values:e,onChange:t,isOverride:n=!1}){let r=(0,M.useTranslations)("bankConfig"),i=e.retain_extraction_mode??(n?VF:""),a="custom"===e.retain_extraction_mode;return(0,_.jsxs)("div",{className:"divide-y divide-border/40",children:[(0,_.jsx)(VG,{label:r("extractionModeLabel"),description:r("extractionModeDescription"),children:(0,_.jsxs)(e6.Select,{value:i,onValueChange:e=>t({retain_extraction_mode:e===VF?null:e||null}),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-full",children:(0,_.jsx)(e6.SelectValue,{placeholder:n?r("inherited"):void 0})}),(0,_.jsxs)(e6.SelectContent,{children:[n&&(0,_.jsx)(e6.SelectItem,{value:VF,children:(0,_.jsx)("span",{className:"text-muted-foreground italic",children:r("inherited")})}),Vz.map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:e},e))]})]})}),(0,_.jsx)(VG,{label:r("chunkSizeLabel"),description:r("chunkSizeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:500,max:8e3,value:e.retain_chunk_size??"",onChange:e=>t({retain_chunk_size:e.target.value?parseFloat(e.target.value):null}),placeholder:n?r("inherited"):void 0})}),(0,_.jsx)(V$,{label:r("missionLabel"),description:r("retainMissionDescription"),value:e.retain_mission??"",onChange:e=>t({retain_mission:e||null}),placeholder:r(n?"inherited":"retainMissionPlaceholder"),rows:3}),a&&(0,_.jsx)(V$,{label:r("customExtractionPromptLabel"),description:r("customExtractionPromptDescription"),value:e.retain_custom_instructions??"",onChange:e=>t({retain_custom_instructions:e||null}),rows:5}),(0,_.jsx)(VG,{label:r("freeFormEntitiesLabel"),description:r("freeFormEntitiesDescription"),children:(0,_.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,_.jsx)(eb,{className:"text-sm text-muted-foreground cursor-pointer select-none",children:r(e.entities_allow_free_form??!0?"enabled":"disabled")}),(0,_.jsx)(e4.Switch,{checked:e.entities_allow_free_form??!0,onCheckedChange:e=>t({entities_allow_free_form:e})})]})}),(0,_.jsx)(VK,{value:e.entity_labels??[],onChange:e=>t({entity_labels:e.length>0?e:null})})]})}function VH(e){return e?Object.entries(e).map(([e,t],n)=>({id:n,name:e,values:{retain_extraction_mode:t.retain_extraction_mode??null,retain_chunk_size:t.retain_chunk_size??null,retain_mission:t.retain_mission??null,retain_custom_instructions:t.retain_custom_instructions??null,entities_allow_free_form:t.entities_allow_free_form??null,entity_labels:VO(t.entity_labels)}})):[]}function VU({defaultValues:e,onDefaultChange:t,strategies:n,onStrategiesChange:r}){let i=(0,M.useTranslations)("bankConfig"),a=(0,M.useTranslations)("common"),[o,s]=(0,E.useState)(()=>VH(n)),[l,c]=(0,E.useState)("default"),[u,d]=(0,E.useState)(null),h=(0,E.useRef)(!1),f=JSON.stringify(n);(0,E.useEffect)(()=>{if(h.current){h.current=!1;return}s(VH(n))},[f]);let p=e=>{h.current=!0,s(e),r(function(e){let t={};for(let n of e){if(!n.name.trim())continue;let e={};null!==n.values.retain_extraction_mode&&(e.retain_extraction_mode=n.values.retain_extraction_mode),null!==n.values.retain_chunk_size&&(e.retain_chunk_size=n.values.retain_chunk_size),n.values.retain_mission&&(e.retain_mission=n.values.retain_mission),n.values.retain_custom_instructions&&(e.retain_custom_instructions=n.values.retain_custom_instructions),null!==n.values.entities_allow_free_form&&(e.entities_allow_free_form=n.values.entities_allow_free_form),null!==n.values.entity_labels&&(e.entity_labels=n.values.entity_labels),t[n.name.trim()]=e}return Object.keys(t).length>0?t:null}(e))},g=(e,t)=>{p(o.map(n=>n.id===e?{...n,...t}:n))},x="default"!==l?o.find(e=>e.id===l):null;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"border-b border-border px-6 flex items-stretch gap-1 flex-wrap",children:[(0,_.jsx)("button",{type:"button",onClick:()=>c("default"),className:`relative py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px ${"default"===l?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,children:i("default")}),o.map(e=>(0,_.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 ${l===e.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>c(e.id),children:[(0,_.jsx)("span",{className:"font-mono",children:e.name||(0,_.jsx)("span",{className:"italic font-normal opacity-50",children:i("unnamed")})}),(0,_.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),d(e)},className:"opacity-40 hover:opacity-100 hover:text-destructive transition-opacity text-base leading-none",children:"×"})]},e.id)),(0,_.jsxs)("button",{type:"button",onClick:()=>{let e=Date.now();p([...o,{id:e,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}}]),c(e)},className:"py-3 px-3 text-sm text-muted-foreground hover:text-primary transition-colors flex items-center gap-1.5",children:[(0,_.jsx)(Pd.Plus,{className:"h-3.5 w-3.5"}),i("addStrategy")]})]}),(0,_.jsx)("div",{children:"default"===l?(0,_.jsx)(VV,{values:e,onChange:t}):x?(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"px-6 py-3 flex items-center gap-3 border-b border-border/40",children:[(0,_.jsx)("label",{className:"text-xs text-muted-foreground shrink-0",children:i("nameLabel")}),(0,_.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,_.jsx)(q.Input,{value:x.name,onChange:e=>g(x.id,{name:e.target.value}),placeholder:i("strategyNamePlaceholder"),className:`h-7 text-xs font-mono max-w-[200px] ${!x.name.trim()?"border-destructive focus-visible:ring-destructive":""}`}),!x.name.trim()&&(0,_.jsx)("p",{className:"text-xs text-destructive",children:i("nameIsRequired")})]})]}),(0,_.jsx)(VV,{values:x.values,onChange:e=>g(x.id,{values:{...x.values,...e}}),isOverride:!0})]}):null}),(0,_.jsx)(PN,{open:null!==u,onOpenChange:e=>{e||d(null)},children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("deleteStrategyTitle",{name:u?.name||i("unnamed")})}),(0,_.jsx)(PW,{children:i("deleteStrategyDescription")})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{children:a("cancel")}),(0,_.jsx)(PY,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(u){var e;e=u.id,p(o.filter(t=>t.id!==e)),l===e&&c("default"),d(null)}},children:a("delete")})]})]})})]})}function VW({selected:e,onChange:t}){let n=(0,M.useTranslations)("bankConfig"),r=[{key:"core",label:n("mcpGroupCore"),tools:["retain","sync_retain","recall","reflect"]},{key:"bankManagement",label:n("mcpGroupBankManagement"),tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{key:"mentalModels",label:n("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:n("mcpGroupDirectives"),tools:["list_directives","create_directive","delete_directive"]},{key:"memories",label:n("mcpGroupMemories"),tools:["list_memories","get_memory"]},{key:"documents",label:n("mcpGroupDocuments"),tools:["list_documents","get_document","delete_document"]},{key:"operations",label:n("mcpGroupOperations"),tools:["list_operations","get_operation","cancel_operation"]},{key:"tags",label:n("mcpGroupTags"),tools:["list_tags"]}],i=new Set(e),a=VM.every(e=>i.has(e)),o=0===e.length;return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:n("toolsEnabled",{selected:e.length,total:VM.length})}),(0,_.jsx)("button",{type:"button",onClick:()=>{t(a?[]:[...VM])},className:"text-xs text-primary hover:underline",children:a?n("deselectAll"):n("selectAll")})]}),(0,_.jsx)("div",{className:"space-y-4",children:r.map(e=>{let r=e.tools.filter(e=>i.has(e)).length===e.tools.length;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,_.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:e.label}),(0,_.jsx)("button",{type:"button",onClick:()=>{let n=new Set(i);r?e.tools.forEach(e=>n.delete(e)):e.tools.forEach(e=>n.add(e)),t(VM.filter(e=>n.has(e)))},className:"text-xs text-primary hover:underline",children:r?n("deselect"):n("selectAll")})]}),(0,_.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tools.map(e=>{let n=i.has(e);return(0,_.jsx)("button",{type:"button",onClick:()=>{let n;(n=new Set(i)).has(e)?n.delete(e):n.add(e),t(VM.filter(e=>n.has(e)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${n?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:e},e)})})]},e.key)})}),o&&(0,_.jsx)("p",{className:"text-xs text-destructive",children:n("noToolsWarning")})]})}function VY({title:e,description:t,children:n,error:r,dirty:i,saving:a,onSave:o}){let s=(0,M.useTranslations)("bankConfig");return(0,_.jsxs)("section",{className:"space-y-3",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h2",{className:"text-lg font-semibold",children:e}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:t})]}),(0,_.jsxs)(tm.Card,{className:"bg-muted/20 border-border/40",children:[(0,_.jsx)("div",{className:"divide-y divide-border/40",children:n}),r&&(0,_.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,_.jsxs)(VC,{variant:"destructive",children:[(0,_.jsx)(VE,{className:"h-4 w-4"}),(0,_.jsx)(V_,{children:r})]})}),(0,_.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,_.jsx)(X.Button,{size:"sm",disabled:!i||a,onClick:o,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"h-4 w-4 mr-2 animate-spin"}),s("saving")]}):s("saveChanges")})})]})]})}function VG({label:e,description:t,children:n}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsx)("div",{className:"md:w-64 shrink-0",children:n})]})})}function V$({label:e,description:t,value:n,onChange:r,placeholder:i,rows:a}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsx)(Ld.Textarea,{value:n,onChange:e=>r(e.target.value),placeholder:i,rows:a??3,className:"font-mono text-sm"})]})})}function VX({label:e,description:t,lowLabel:n,highLabel:r,value:i,onChange:a}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[n&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:n}),(0,_.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(e=>(0,_.jsx)("button",{type:"button",onClick:()=>a(e),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${e<=i?"bg-primary":"bg-muted"}`},e))}),r&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:r}),(0,_.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[i,"/5"]})]})]})})}function Vq({fields:e,onChange:t,depth:n,extraControls:r,examplePrefix:i}){let a=(0,M.useTranslations)("bankConfig"),o={text:a("fieldTypeText"),value:a("fieldTypeValue"),"multi-values":a("fieldTypeMultiValues"),map:a("fieldTypeMap")},[s,l]=(0,E.useState)({}),c=(n,r)=>{let i={};for(let[t,a]of Object.entries(e))i[t]=t===n?{...a,...r}:a;t(i)},u=0===n;return(0,_.jsxs)("div",{className:u?"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(e).length&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground italic",children:a("noFieldsYet")}),Object.entries(e).map(([d,h],f)=>{let p="map"===h.type,g="value"===h.type||"multi-values"===h.type,x=s[f]??!0,v=p||g;return(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[v?(0,_.jsx)("button",{type:"button",onClick:()=>l(e=>({...e,[f]:!x})),className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted/50",children:x?(0,_.jsx)(PK.ChevronDown,{className:"h-3.5 w-3.5"}):(0,_.jsx)(H.ChevronRight,{className:"h-3.5 w-3.5"})}):(0,_.jsx)("span",{className:"w-[18px] shrink-0"}),(0,_.jsx)(q.Input,{placeholder:a("fieldNamePlaceholder"),value:d,onChange:n=>((n,r)=>{let i={};for(let[t,a]of Object.entries(e))i[t===n?r:t]=a;t(i)})(d,n.target.value),className:"h-7 text-xs font-mono w-28 shrink-0"}),(0,_.jsx)(q.Input,{placeholder:a("extractorHintWhatPlaceholder"),value:h.description,onChange:e=>c(d,{description:e.target.value}),className:"h-7 text-xs flex-1 min-w-0"}),(0,_.jsxs)(e6.Select,{value:h.type,onValueChange:e=>c(d,{type:e,..."map"===e?{fields:h.fields??{},values:void 0}:{},..."text"===e?{fields:void 0,values:void 0}:{},..."value"===e||"multi-values"===e?{fields:void 0,values:h.values??[]}:{}}),children:[(0,_.jsx)(e6.SelectTrigger,{className:"h-7 text-xs w-[120px] shrink-0 px-2 py-0",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{children:Object.entries(o).map(([e,t])=>(0,_.jsx)(e6.SelectItem,{value:e,className:"text-xs",children:t},e))})]}),r,(0,_.jsx)("button",{type:"button",onClick:()=>{let n;return n={...e},void(delete n[d],t(n))},className:"text-muted-foreground hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10",children:(0,_.jsx)(P$,{className:"h-3.5 w-3.5"})})]}),u&&i&&d&&(0,_.jsx)("div",{className:"ml-[18px] pl-1.5",children:(0,_.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground/60 leading-none",children:"map"===h.type&&h.fields&&Object.keys(h.fields).length>0?`e.g. ${Object.keys(h.fields).slice(0,2).map(e=>`${i}:${e}:<value>`).join(", ")}`:"text"===h.type?`e.g. ${i}:<any text>`:(h.values?.length??0)>0?`e.g. ${i}:${h.values[0].value||"<value>"}`:`e.g. ${i}:<value>`})}),x&&p&&(0,_.jsx)(Vq,{fields:h.fields??{},onChange:e=>c(d,{fields:e}),depth:n+1,examplePrefix:i?`${i}:${d}`:void 0}),x&&g&&(0,_.jsxs)("div",{className:"ml-6 space-y-0.5 py-1",children:[0===(h.values??[]).length&&(0,_.jsx)("p",{className:"text-[11px] text-muted-foreground italic",children:a("noValuesYet")}),(h.values??[]).map((e,t)=>(0,_.jsxs)("div",{className:"flex items-center gap-1.5 group/val",children:[(0,_.jsx)("span",{className:"text-muted-foreground/50 text-[10px] shrink-0",children:"•"}),(0,_.jsx)(q.Input,{placeholder:a("addValueShort"),value:e.value,onChange:n=>{let r=[...h.values??[]];r[t]={...e,value:n.target.value},c(d,{values:r})},className:"h-6 text-[11px] font-mono w-24 shrink-0 border-dashed"}),(0,_.jsx)(q.Input,{placeholder:a("extractorHintWhichPlaceholder"),value:e.description,onChange:n=>{let r=[...h.values??[]];r[t]={...e,description:n.target.value},c(d,{values:r})},className:"h-6 text-[11px] flex-1 min-w-0 border-dashed"}),(0,_.jsx)("button",{type:"button",onClick:()=>{c(d,{values:(h.values??[]).filter((e,n)=>n!==t)})},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,_.jsx)(P$,{className:"h-3 w-3"})})]},t)),(0,_.jsxs)("button",{type:"button",onClick:()=>{c(d,{values:[...h.values??[],{value:"",description:""}]})},className:"text-[11px] text-muted-foreground/60 hover:text-foreground inline-flex items-center gap-1 ml-2.5",children:[(0,_.jsx)(Pd.Plus,{className:"h-2.5 w-2.5"}),a("addValueShort")]})]})]},f)}),(0,_.jsxs)("button",{type:"button",onClick:()=>{t({...e,"":{type:"text",description:""}})},className:"text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",children:[(0,_.jsx)(Pd.Plus,{className:"h-3 w-3"}),a("addField")]})]})}function VK({value:e,onChange:t}){let n=(0,M.useTranslations)("entityLabelsEditor"),r=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))};return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:n("entityLabelsTitle")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:n("entityLabelsDescription")})]}),e.length>0&&(0,_.jsx)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:n("labelCount",{count:e.length})})]}),0===e.length&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground italic",children:n("noEntityLabelsDefined")}),(0,_.jsx)("div",{className:"space-y-2",children:e.map((i,a)=>(0,_.jsx)("div",{className:"border border-border/50 rounded-md bg-background",children:(0,_.jsx)(Vq,{fields:{[i.key]:{type:i.type,description:i.description,values:i.values,fields:i.fields}},onChange:n=>{let i=Object.entries(n);if(0===i.length)t(e.filter((e,t)=>t!==a));else{let[e,t]=i[0];r(a,{key:e,type:t.type,description:t.description,values:t.values??[],fields:t.fields??{}})}},depth:0,extraControls:(0,_.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",title:n("alsoStoreAsTagTooltip"),children:[(0,_.jsx)(Pm.Checkbox,{checked:i.tag,onCheckedChange:e=>r(a,{tag:!!e}),className:"h-4 w-4"}),n("plusTag")]}),examplePrefix:i.key})},a))}),(0,_.jsxs)("button",{type:"button",onClick:()=>{t([...e,{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,_.jsx)(Pd.Plus,{className:"h-3.5 w-3.5"}),n("addLabel")]})]})}function VZ({value:e,onChange:t}){let n=(0,M.useTranslations)("bankConfig"),r=[{value:"HARM_CATEGORY_HARASSMENT",label:n("geminiCategoryHarassment")},{value:"HARM_CATEGORY_HATE_SPEECH",label:n("geminiCategoryHateSpeech")},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:n("geminiCategorySexuallyExplicit")},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:n("geminiCategoryDangerousContent")}],i=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:n("geminiThresholdUnspecified")},{value:"OFF",label:n("geminiThresholdOff")},{value:"BLOCK_NONE",label:n("geminiThresholdBlockNone")},{value:"BLOCK_LOW_AND_ABOVE",label:n("geminiThresholdBlockLowAndAbove")},{value:"BLOCK_MEDIUM_AND_ABOVE",label:n("geminiThresholdBlockMediumAndAbove")},{value:"BLOCK_ONLY_HIGH",label:n("geminiThresholdBlockOnlyHigh")}],a=t=>e.find(e=>e.category===t)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,_.jsxs)("p",{className:"text-xs text-muted-foreground",children:[n("geminiSafetyEditorDescriptionPart1")," ",(0,_.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:n("geminiSafetyEditorLearnMore")})]}),(0,_.jsx)("div",{className:"space-y-2",children:r.map(e=>(0,_.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,_.jsx)("span",{className:"text-sm",children:e.label}),(0,_.jsxs)(e6.Select,{value:a(e.value),onValueChange:n=>{var i;return i=e.value,void t(r.map(e=>({category:e.value,threshold:e.value===i?n:a(e.value)})))},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{children:i.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,className:"text-xs",children:e.label},e.value))})]})]},e.value))})]})}let VQ=(0,I.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"}]]),VJ=(0,I.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 V0=e.i(23287),V0=V0;let V1=(0,I.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"}]]),V2=(0,I.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 V5=["x1","y1","x2","y2","key"],V3=["offset"],V4=["xAxisId","yAxisId"],V6=["xAxisId","yAxisId"];function V7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function V9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V7(Object(n),!0).forEach(function(t){var r,i,a;r=e,i=t,a=n[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(i))in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function V8(){return(V8=Object.assign.bind()).apply(null,arguments)}function He(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Ht=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return E.createElement("rect",{x:r,y:i,ry:s,width:a,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Hn(e){var{option:t,lineItemProps:n}=e;if(E.isValidElement(t))r=E.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,i,{x1:a,y1:o,x2:s,y2:l,key:c}=n,u=null!=(i=mp(He(n,V5)))?i:{},{offset:d}=u,h=He(u,V3);r=E.createElement("line",V8({},h,{x1:a,y1:o,x2:s,y2:l,fill:"none",key:c}))}return r}function Hr(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=He(e,V4),l=i.map((e,i)=>{var a=V9(V9({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(i),index:i});return E.createElement(Hn,{key:"line-".concat(i),option:r,lineItemProps:a})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Hi(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=He(e,V6),l=i.map((e,i)=>{var a=V9(V9({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(i),index:i});return E.createElement(Hn,{option:r,lineItemProps:a,key:"line-".concat(i)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Ha(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:l=!0}=e;if(!l||!t||!t.length||null==s)return null;var c=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==c[0]&&c.unshift(0);var u=c.map((e,s)=>{var l=c[s+1]?c[s+1]-e:i+o-e;if(l<=0)return null;var u=s%t.length;return E.createElement("rect",{key:"react-".concat(s),y:e,x:r,height:l,width:a,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function Ho(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:l}=e;if(!t||!n||!n.length)return null;var c=l.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==c[0]&&c.unshift(0);var u=c.map((e,t)=>{var l=c[t+1]?c[t+1]-e:i+o-e;if(l<=0)return null;var u=t%n.length;return E.createElement("rect",{key:"react-".concat(t),x:e,y:a,width:l,height:s,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var Hs=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return ay(bs(V9(V9(V9({},bh),n),{},{ticks:ab(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},Hl=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return ay(bs(V9(V9(V9({},bh),n),{},{ticks:ab(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},Hc={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:uk.grid};function Hu(e){var t=an(aE),n=an(aT),r=a9(),i=V9(V9({},m1(e,Hc)),{},{x:rT(e.x)?e.x:r.left,y:rT(e.y)?e.y:r.top,width:rT(e.width)?e.width:r.width,height:rT(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:l,width:c,height:u,syncWithTicks:d,horizontalValues:h,verticalValues:f}=i,p=aF(),g=an(e=>hj(e,"xAxis",a,p)),x=an(e=>hj(e,"yAxis",o,p));if(!ap(c)||!ap(u)||!rT(s)||!rT(l))return null;var v=i.verticalCoordinatesGenerator||Hs,y=i.horizontalCoordinatesGenerator||Hl,{horizontalPoints:b,verticalPoints:w}=i;if((!b||!b.length)&&"function"==typeof y){var j=h&&h.length,N=y({yAxis:x?V9(V9({},x),{},{ticks:j?h:x.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:u,offset:r},!!j||d);aY(Array.isArray(N),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof N,"]")),Array.isArray(N)&&(b=N)}if((!w||!w.length)&&"function"==typeof v){var k=f&&f.length,S=v({xAxis:g?V9(V9({},g),{},{ticks:k?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:u,offset:r},!!k||d);aY(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(w=S)}return E.createElement(gA,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(Ht,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(Ha,V8({},i,{horizontalPoints:b})),E.createElement(Ho,V8({},i,{verticalPoints:w})),E.createElement(Hr,V8({},i,{offset:r,horizontalPoints:b,xAxis:g,yAxis:x})),E.createElement(Hi,V8({},i,{offset:r,verticalPoints:w,xAxis:g,yAxis:x}))))}Hu.displayName="CartesianGrid";let Hd=["1h","12h","1d","7d","30d","90d"],Hh=["created_at","mentioned_at","occurred_start"],Hf="#8b5cf6",Hp="#ec4899",Hm="#6366f1",Hg="var(--chart-5)",Hx="var(--muted-foreground)",Hv={world:{label:"World",color:Hf},experience:{label:"Experience",color:Hp},observation:{label:"Observations",color:Hm}};function Hy(e){if(e<1e3)return e.toString();if(e<1e6){let t=e/1e3;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}k`}if(e<1e9){let t=e/1e6;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}M`}let t=e/1e9;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}B`}function Hb({value:e,className:t}){return(0,_.jsx)("span",{className:t,title:e.toLocaleString(),children:Hy(e)})}function Hw({active:e,payload:t,label:n,valueLabel:r}){return e&&t&&0!==t.length?(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 bg-popover/95 backdrop-blur-sm px-3 py-2 shadow-md",children:[null!=n&&(0,_.jsx)("div",{className:"text-[11px] font-medium text-foreground mb-1.5",children:n}),(0,_.jsx)("div",{className:"space-y-1",children:t.map((e,t)=>(0,_.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color||e.payload?.fill}}),(0,_.jsx)("span",{className:"text-muted-foreground",children:e.name||r||"Value"}),(0,_.jsx)("span",{className:"ml-auto pl-3 font-semibold tabular-nums text-foreground",children:(e.value??0).toLocaleString()})]},t))})]}):null}function Hj({children:e}){return(0,_.jsx)("h3",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em] mb-3",children:e})}function HN(e,t){if(!e)return t?t("relativeTimeNever"):"Never";let n=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(n<1)return t?t("relativeTimeJustNow"):"just now";if(n<60)return t?t("relativeTimeMinutes",{mins:n}):`${n}m ago`;let r=Math.floor(n/60);if(r<24)return t?t("relativeTimeHours",{hours:r}):`${r}h ago`;let i=Math.floor(r/24);return t?t("relativeTimeDays",{days:i}):`${i}d ago`}function Hk(e){return new Date(/[+Z-]$/.test(e)||/[+-]\d\d:?\d\d$/.test(e)?e:`${e}Z`)}function HS({done:e,total:t,doneColor:n}){let r=Math.round(100*(t>0?e/t:0));return(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"tabular-nums font-semibold text-foreground text-sm",children:e.toLocaleString()}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:[" / ",t.toLocaleString()]})]}),(0,_.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-foreground",children:[r,"%"]})]}),(0,_.jsx)("div",{className:"h-1.5 w-full rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r}%`,backgroundColor:n}})})]})}function HC({title:e,items:t,emptyLabel:n}){let r=t.reduce((e,t)=>e+t.value,0);return(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:e}),(0,_.jsx)(Hb,{value:r,className:"text-xs text-muted-foreground tabular-nums"})]}),0===r?(0,_.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:n}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:t.filter(e=>e.value>0).map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/r*100}%`,backgroundColor:e.color},title:`${e.name}: ${e.value.toLocaleString()}`},e.name))}),(0,_.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:t.map(e=>(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:e.name})]}),(0,_.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,_.jsx)(Hb,{value:e.value,className:"text-base font-semibold tabular-nums"}),(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:r>0?`${(e.value/r*100).toFixed(0)}%`:"0%"})]})]},e.name))})]})]})}function H_({icon:e,label:t,value:n}){return(0,_.jsxs)("div",{className:"flex items-center gap-3 p-4",children:[(0,_.jsx)("div",{className:"p-2 rounded-md bg-muted",children:(0,_.jsx)(e,{className:"w-4 h-4 text-muted-foreground"})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:t}),(0,_.jsx)(Hb,{value:n,className:"text-2xl font-semibold text-foreground leading-tight tabular-nums block"})]})]})}let HE=["completed","processing","pending","failed","cancelled"],HT={completed:"#10b981",processing:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",cancelled:"#6b7280"},HM={completed:"completed",processing:"processing",pending:"pending",failed:"failed",cancelled:"cancelled"};function HO({byStatus:e}){let t=(0,M.useTranslations)("bankStats"),n={completed:t("opsCompleted"),processing:t("opsProcessing"),pending:t("opsPending"),failed:t("opsFailed"),cancelled:t("opsCancelled")},r=HE.map(t=>({status:t,label:n[t]??HM[t],value:e[t]||0,color:HT[t]}));for(let[t,n]of Object.entries(e))HE.includes(t)||r.push({status:t,label:t,value:n,color:Hx});let i=r.reduce((e,t)=>e+t.value,0),a=r.filter(e=>e.value>0);return(0,_.jsxs)(tm.Card,{children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,_.jsxs)(tm.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,_.jsx)(ti,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("operations")]}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,_.jsx)(Hb,{value:i})," ",t("totalSuffix")]})]}),(0,_.jsx)(tm.CardContent,{children:0===i?(0,_.jsx)("div",{className:"h-[100px] flex items-center justify-center text-sm text-muted-foreground",children:t("noOperationsYet")}):(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:a.map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/i*100}%`,backgroundColor:e.color},title:`${e.label}: ${e.value.toLocaleString()}`},e.status))}),(0,_.jsx)("div",{className:"space-y-1.5",children:a.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px] flex-shrink-0",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-muted-foreground flex-1",children:e.label}),(0,_.jsx)(Hb,{value:e.value,className:"font-semibold tabular-nums text-foreground"}),(0,_.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums w-9 text-right",children:[(e.value/i*100).toFixed(0),"%"]})]},e.status))})]})})]})}function HA({done:e,pending:t,failed:n,total:r,lastConsolidatedAt:i}){let a=(0,M.useTranslations)("bankStats"),[o,s]=(0,E.useState)(!1),l=n>0;return(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:a("consolidation")})}),(0,_.jsxs)(tm.CardContent,{className:"space-y-4",children:[(0,_.jsx)(HS,{done:e,total:r,doneColor:Hg}),(0,_.jsxs)("div",{className:"grid grid-cols-4 gap-3 pt-1",children:[(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V0.default,{className:"w-3 h-3 text-emerald-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("done")})]}),(0,_.jsx)(Hb,{value:e,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(VE,{className:"w-3 h-3 text-amber-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("pending")})]}),(0,_.jsx)(Hb,{value:t,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,_.jsxs)("button",{type:"button",onClick:()=>l&&s(!0),disabled:!l,className:`text-left space-y-0.5 rounded-md -mx-1 px-1 py-0.5 transition-colors ${l?"cursor-pointer hover:bg-red-500/10 focus:outline-none focus:ring-2 focus:ring-red-500/40":"cursor-default"}`,title:l?a("viewFailedMemoriesLabel"):void 0,children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V1,{className:`w-3 h-3 ${l?"text-red-600 dark:text-red-400":"text-muted-foreground/50"}`}),(0,_.jsx)("span",{className:`text-[10px] uppercase tracking-wider font-medium ${l?"text-red-600 dark:text-red-400":"text-muted-foreground"}`,children:a("failed")})]}),(0,_.jsxs)("span",{className:`text-base font-semibold tabular-nums block ${l?"text-red-600 dark:text-red-400":"text-foreground"}`,children:[(0,_.jsx)(Hb,{value:n}),l&&(0,_.jsx)(V2,{className:"inline w-3 h-3 ml-1 opacity-70"})]})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(ea,{className:"w-3 h-3 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("last")})]}),(0,_.jsx)("span",{className:"text-base font-semibold text-foreground block leading-tight",children:HN(i,a)})]})]})]}),(0,_.jsx)(HD,{open:o,onOpenChange:s})]})}function HD({open:e,onOpenChange:t}){let n=(0,M.useTranslations)("bankStats"),r=(0,M.useTranslations)("failedConsolidations"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(0),[c,u]=(0,E.useState)(!1),[d,h]=(0,E.useState)(!1),[f,p]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(!e||!i)return;let t=!1;return u(!0),$.client.listMemories(i,{consolidationState:"failed",limit:200}).then(e=>{t||(o(e.items),l(e.total))}).catch(()=>{}).finally(()=>{t||u(!1)}),()=>{t=!0}},[e,i,f]);let g=async()=>{if(i){h(!0);try{let e=await $.client.recoverConsolidation(i);e.retried_count>0&&await $.client.triggerConsolidation(i),O.toast.success(r("recoverSuccess",{count:e.retried_count})),p(e=>e+1)}catch{}finally{h(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-4xl max-h-[80vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)(V1,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),r("title")]}),(0,_.jsx)(ta.DialogDescription,{children:r("description")})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2 py-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:c?r("loading"):r("totalFailed",{total:s})}),(0,_.jsxs)(X.Button,{size:"sm",onClick:g,disabled:d||c||0===s,children:[(0,_.jsx)(er,{className:`w-3.5 h-3.5 mr-1.5 ${d?"animate-spin":""}`}),r("recoverAll")]})]}),(0,_.jsx)("div",{className:"flex-1 min-h-0 overflow-auto border border-border rounded-md",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[140px]",children:r("colFailedAt")}),(0,_.jsx)(eh,{className:"w-[100px]",children:r("colType")}),(0,_.jsx)(eh,{children:r("colText")})]})}),(0,_.jsxs)(eu,{children:[0===a.length&&!c&&(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:3,className:"text-center text-muted-foreground py-8",children:r("noFailedConsolidations")})}),a.map(e=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"text-xs text-muted-foreground whitespace-nowrap",children:HN(e.consolidation_failed_at,n)}),(0,_.jsx)(ef,{className:"text-xs capitalize",children:e.fact_type}),(0,_.jsxs)(ef,{className:"text-sm",children:[(0,_.jsx)("div",{className:"line-clamp-2",children:e.text}),e.context&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:e.context})]})]},e.id))]})]})})]})})}function HP({models:e,lastConsolidatedAt:t}){let n=(0,M.useTranslations)("bankStats"),r=e.length,i=t?new Date(t).getTime():0,a=e.filter(e=>!i||!!e.last_refreshed_at&&new Date(e.last_refreshed_at).getTime()>=i).length,o=r-a;return(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)(tm.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,_.jsx)(Ls,{className:"w-3.5 h-3.5 text-muted-foreground"}),n("mentalModels")]})}),(0,_.jsx)(tm.CardContent,{className:"space-y-4",children:0===r?(0,_.jsx)("div",{className:"text-sm text-muted-foreground py-4",children:n("noMentalModels")}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(HS,{done:a,total:r,doneColor:Hg}),(0,_.jsxs)("div",{className:"grid grid-cols-3 gap-3 pt-1",children:[(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V0.default,{className:"w-3 h-3 text-emerald-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("upToDate")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:a})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(VE,{className:"w-3 h-3 text-amber-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("stale")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:o})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(Ls,{className:"w-3 h-3 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("total")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:r})]})]})]})})]})}let HL={fontSize:11,fill:Hx,fontWeight:500};function HI(){let e=(0,M.useTranslations)("bankStats"),t={created_at:{short:e("timeFieldIngestedShort"),long:e("timeFieldIngestedLong")},mentioned_at:{short:e("timeFieldMentionedShort"),long:e("timeFieldMentionedLong")},occurred_start:{short:e("timeFieldOccurredShort"),long:e("timeFieldOccurredLong")}},{currentBank:n}=(0,D.useBank)(),{features:r}=(0,Pp.useFeatures)(),i=r?.observations??!1,[a,o]=(0,E.useState)(null),[s,l]=(0,E.useState)([]),[c,u]=(0,E.useState)(!1),[d,h]=(0,E.useState)("7d"),[f,p]=(0,E.useState)("created_at"),[g,x]=(0,E.useState)({trunc:"day",buckets:[]}),[v,y]=(0,E.useState)({world:!0,experience:!0,observation:!0}),b=async()=>{if(n){u(!0);try{let[e,t]=await Promise.all([$.client.getBankStats(n),$.client.listMentalModels(n)]);o(e),l(t.items||[])}catch(e){console.error("Error loading bank stats:",e)}finally{u(!1)}}},w=async()=>{if(n)try{let e=await $.client.getMemoriesTimeseries(n,d,f);x({trunc:e.trunc,buckets:e.buckets||[]})}catch(e){console.error("Error loading memories timeseries:",e)}};if((0,E.useEffect)(()=>{if(n){b();let e=setInterval(b,5e3);return()=>clearInterval(e)}},[n]),(0,E.useEffect)(()=>{if(n){w();let e=setInterval(w,5e3);return()=>clearInterval(e)}},[n,d,f]),c&&!a)return(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(ea,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})});if(!a)return null;let j=i?["world","experience","observation"]:["world","experience"],N=g.buckets.map(e=>{var t,n,r,i;let a,o;return{...e,label:(t=e.time,n=g.trunc,a=Hk(t),"day"===n?a.toLocaleDateString(void 0,{month:"short",day:"numeric"}):a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})),tooltipLabel:(r=e.time,i=g.trunc,o=Hk(r),"day"===i?o.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):o.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}))}}),k=N.reduce((e,t)=>e+j.reduce((e,n)=>e+(v[n]&&t[n]||0),0),0),S=Math.max(0,a.total_nodes-a.pending_consolidation),C={world:e("world"),experience:e("experience"),observation:e("observations")};return(0,_.jsxs)("div",{className:"space-y-8",children:[(0,_.jsxs)("section",{children:[(0,_.jsx)(Hj,{children:e("memoryStore")}),(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"p-0",children:[(0,_.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,_.jsx)(H_,{icon:B,label:e("memories"),value:a.total_nodes}),(0,_.jsx)(H_,{icon:VJ,label:e("documents"),value:a.total_documents}),(0,_.jsx)(H_,{icon:VQ,label:e("links"),value:a.total_links})]}),(0,_.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,_.jsx)("div",{className:"p-5",children:(0,_.jsx)(HC,{title:e("memoryComposition"),items:[{name:e("world"),value:a.nodes_by_fact_type?.world||0,color:Hf},{name:e("experience"),value:a.nodes_by_fact_type?.experience||0,color:Hp},...i?[{name:e("observations"),value:a.total_observations||0,color:Hm}]:[]],emptyLabel:e("noMemoriesYet")})}),(0,_.jsx)("div",{className:"p-5",children:(0,_.jsx)(HC,{title:e("linkTypes"),items:[{name:e("temporal"),value:a.links_by_link_type?.temporal||0,color:"#009296"},{name:e("semantic"),value:a.links_by_link_type?.semantic||0,color:"#0074d9"},{name:e("entity"),value:a.links_by_link_type?.entity||0,color:"#f59e0b"}],emptyLabel:e("noLinksYet")})})]})]})})]}),(0,_.jsxs)("section",{children:[(0,_.jsx)(Hj,{children:e("consolidation")}),(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsx)(HA,{done:S,pending:a.pending_consolidation,failed:a.failed_consolidation??0,total:a.total_nodes,lastConsolidatedAt:a.last_consolidated_at}),(0,_.jsx)(HP,{models:s,lastConsolidatedAt:a.last_consolidated_at})]})]}),(0,_.jsxs)("section",{children:[(0,_.jsx)(Hj,{children:e("activity")}),(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,_.jsxs)(tm.Card,{className:"lg:col-span-2",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 space-y-2",children:[(0,_.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:e("memoriesByTimeChartTitle",{field:t[f].short.toLowerCase()})}),(0,_.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:Hd.map(e=>(0,_.jsx)("button",{onClick:()=>h(e),className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors tabular-nums ${d===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e},e))})]}),(0,_.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5 w-fit",children:Hh.map(e=>(0,_.jsx)("button",{onClick:()=>p(e),title:t[e].long,className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors ${f===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:t[e].short},e))}),(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("div",{className:"flex items-center gap-1.5",children:j.map(e=>{let t=Hv[e],n=v[e];return(0,_.jsxs)("button",{onClick:()=>y(t=>({...t,[e]:!t[e]})),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[11px] font-medium transition-all ${n?"bg-muted text-foreground":"bg-transparent text-muted-foreground/60 hover:text-muted-foreground"}`,children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px] transition-opacity",style:{backgroundColor:t.color,opacity:n?1:.3}}),C[e]]},e)})}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,_.jsx)(Hb,{value:k})," ",e("totalSuffix")]})]})]}),(0,_.jsx)(tm.CardContent,{children:0===N.length||0===k?(0,_.jsx)("div",{className:"h-[180px] flex items-center justify-center text-sm text-muted-foreground",children:e("noMemoriesIngestedInPeriod")}):(0,_.jsx)("div",{className:"h-[180px]",children:(0,_.jsx)(a3,{width:"100%",height:"100%",children:(0,_.jsxs)(yA,{data:N,margin:{top:8,right:8,bottom:0,left:-10},children:[(0,_.jsx)("defs",{children:j.map(e=>(0,_.jsxs)("linearGradient",{id:`grad-${e}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,_.jsx)("stop",{offset:"0%",stopColor:Hv[e].color,stopOpacity:.35}),(0,_.jsx)("stop",{offset:"100%",stopColor:Hv[e].color,stopOpacity:0})]},e))}),(0,_.jsx)(Hu,{vertical:!1,stroke:"var(--border)",strokeOpacity:.5,strokeDasharray:"2 4"}),(0,_.jsx)(bM,{dataKey:"label",tick:HL,axisLine:!1,tickLine:!1,dy:4,minTickGap:20}),(0,_.jsx)(bB,{tick:HL,axisLine:!1,tickLine:!1,width:40,allowDecimals:!1,tickFormatter:e=>Hy(e)}),(0,_.jsx)(wc,{content:(0,_.jsx)(Hw,{}),labelFormatter:(e,t)=>t?.[0]?.payload?.tooltipLabel||"",cursor:{stroke:Hx,strokeWidth:1,strokeDasharray:"3 3"}}),j.map(e=>v[e]?(0,_.jsx)(be,{type:"monotone",dataKey:e,name:C[e],stackId:"a",stroke:Hv[e].color,strokeWidth:2,fill:`url(#grad-${e})`,isAnimationActive:!1},e):null)]})})})})]}),(0,_.jsx)(HO,{byStatus:a.operations_by_status||{}})]})]})]})}var tn=tn;let HR=(0,I.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),HB=(0,I.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),Hz=(0,I.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),HF=["all","retain","consolidation","refresh_mental_model","file_convert_retain","webhook_delivery","graph_maintenance"],HV=[null,"pending","processing","completed","failed","cancelled"];function HH(){let e,t,n,r=(0,M.useTranslations)("bankOperations"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(0),[c,u]=(0,E.useState)(null),[d,h]=(0,E.useState)(null),[f]=(0,E.useState)(10),[p,g]=(0,E.useState)(0),[x,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),[w,j]=(0,E.useState)(!1),[N,k]=(0,E.useState)(null),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(null),[R,B]=(0,E.useState)(()=>Date.now()),z={all:r("status.all"),pending:r("status.pending"),processing:r("status.processing"),completed:r("status.completed"),failed:r("status.failed"),cancelled:r("status.cancelled")},F={all:r("operationType.all"),retain:r("operationType.retain"),consolidation:r("operationType.consolidation"),refresh_mental_model:r("operationType.refreshMentalModel"),file_convert_retain:r("operationType.fileConvertRetain"),webhook_delivery:r("operationType.webhookDelivery"),graph_maintenance:r("operationType.graphMaintenance")},V=e=>e?z[e]??e:r("unknown"),H=e=>e?F[e]??e:r("notAvailable"),U=(e,t)=>{let n=V(e);return"pending"===e?(0,_.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,_.jsx)(ea,{className:"w-3 h-3"}),n]}):"processing"===e?(0,_.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,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}),n]}):"failed"===e?(0,_.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:t??void 0,children:[(0,_.jsx)(VE,{className:"w-3 h-3"}),n]}):"completed"===e?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),n]}):"cancelled"===e?(0,_.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,_.jsx)(Hz,{className:"w-3 h-3"}),n]}):(0,_.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:n})},W=e=>{let t=new Date(e).getTime();if(Number.isNaN(t))return"";let n=Math.max(0,Math.round((R-t)/1e3));return n<5?r("heartbeat.justNow"):n<60?r("heartbeat.secondsAgo",{secs:n}):n<3600?r("heartbeat.minutesAgo",{mins:Math.floor(n/60)}):r("heartbeat.hoursAgo",{hours:Math.floor(n/3600)})},Y=(e,t)=>{if(!e)return null;let n=e.stage.replace(/[._]/g," "),i="number"==typeof e.processed&&"number"==typeof e.total&&e.total>0,a=i?Math.min(100,Math.round(e.processed/e.total*100)):null,o=e.at?W(e.at):null;return t?.compact?(0,_.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground whitespace-nowrap",title:`${n}${e.at?` — ${new Date(e.at).toLocaleString()}`:""}`,children:[null!==a&&(0,_.jsx)("span",{className:"h-1 w-14 shrink-0 rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("span",{className:"block h-full rounded-full bg-blue-500/70",style:{width:`${a}%`}})}),i&&(0,_.jsxs)("span",{className:"font-mono",children:[e.processed,"/",e.total]}),o&&(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",o]})]}):(0,_.jsxs)("div",{className:"mt-1 space-y-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,_.jsx)("span",{className:"capitalize",children:n}),i&&(0,_.jsxs)("span",{className:"font-mono",children:[e.processed,"/",e.total]})]}),null!==a&&(0,_.jsx)("div",{className:"h-1 w-24 rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("div",{className:"h-full rounded-full bg-blue-500/70",style:{width:`${a}%`}})}),e.at&&(0,_.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground/80",title:new Date(e.at).toLocaleString(),children:[(0,_.jsx)(ea,{className:"w-2.5 h-2.5"}),(0,_.jsxs)("span",{children:[r("field.lastHeartbeat")," · ",W(e.at)]})]})]})},G=(0,E.useCallback)(async(e=c,t=p,n=d)=>{if(i){j(!0);try{let r=await $.client.listOperations(i,{status:e||void 0,type:n||void 0,limit:f,offset:t,excludeParents:!0});o(r.operations||[]),l(r.total||0),B(Date.now())}catch(e){console.error("Error loading operations:",e)}finally{j(!1)}}},[i,c,p,d,f]),q=e=>{g(e),G(c,e,d)},K=async e=>{if(i){v(e);try{await $.client.cancelOperation(i,e),await G()}catch(e){}finally{v(null)}}},Z=async e=>{if(i){b(e);try{await $.client.retryOperation(i,e),await G()}catch(e){}finally{b(null)}}},Q=async e=>{if(i){O(!0),C(!0),I(null);try{let t=await $.client.getOperationStatus(i,e);k(t)}catch(e){console.error("Error loading operation details:",e),k({error:r("operationDetailsLoadError")})}finally{O(!1)}}},J=async()=>{if(i&&N?.operation_id){P(!0);try{let e=N.operation_id,t=await $.client.getOperationStatus(i,e,{includePayload:!0});k(t),I(e)}catch(e){console.error("Error loading raw payload:",e)}finally{P(!1)}}},ee=a.some(e=>"processing"===e.status);(0,E.useEffect)(()=>{if(i){G(c,p,d);let e=setInterval(()=>G(c,p,d),ee?2e3:5e3);return()=>clearInterval(e)}},[i,c,p,d,ee,G]),(0,E.useEffect)(()=>{if(!ee)return;let e=setInterval(()=>B(Date.now()),1e3);return()=>clearInterval(e)},[ee]);let et=(0,E.useRef)({}),[en,eo]=(0,E.useState)(new Set);return((0,E.useEffect)(()=>{let e=et.current,t=a.filter(t=>e[t.id]&&e[t.id]!==t.status&&("completed"===t.status||"failed"===t.status||"cancelled"===t.status)).map(e=>e.id);if(et.current=Object.fromEntries(a.map(e=>[e.id,e.status])),0===t.length)return;eo(e=>new Set([...e,...t]));let n=setTimeout(()=>eo(e=>{let n=new Set(e);return t.forEach(e=>n.delete(e)),n}),1200);return()=>clearTimeout(n)},[a]),i)?(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-lg font-semibold",children:r("title")}),(0,_.jsx)("button",{onClick:()=>G(),className:"p-1 rounded hover:bg-muted transition-colors",title:r("refreshOperations"),disabled:w,children:(0,_.jsx)(er,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${w?"animate-spin":""}`})})]}),(0,_.jsxs)("p",{className:"text-sm text-muted-foreground",children:[r("operationCount",{count:s}),c?` (${V(c)})`:""]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsxs)(e6.Select,{value:d??"all",onValueChange:e=>{var t;h(t="all"===e?null:e),g(0),G(c,0,t)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,_.jsx)(e6.SelectValue,{placeholder:r("allTypes")})}),(0,_.jsx)(e6.SelectContent,{children:HF.map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{children:F[e]}),"all"!==e&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:e})]})},e))})]}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:HV.map(e=>(0,_.jsx)("button",{onClick:()=>{u(e),g(0),G(e,0,d)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${c===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e?V(e):z.all},e??"all"))})]})]}),(0,_.jsx)("div",{children:a.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[100px]",children:r("table.id")}),(0,_.jsx)(eh,{children:r("table.type")}),(0,_.jsx)(eh,{children:r("table.created")}),(0,_.jsx)(eh,{children:r("field.updated")}),(0,_.jsx)(eh,{className:"w-[300px]",children:r("table.status")}),(0,_.jsx)(eh,{className:"w-[110px]",children:r("table.actions")})]})}),(0,_.jsx)(eu,{children:a.map(e=>(0,_.jsxs)(ed,{className:`cursor-pointer transition-colors duration-700 hover:bg-muted/50 ${en.has(e.id)?"completed"===e.status?"bg-emerald-500/15":"bg-red-500/15":"failed"===e.status?"bg-red-500/5":""}`,onClick:()=>Q(e.id),children:[(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.id.substring(0,8)}),(0,_.jsx)(ef,{className:"font-medium",title:e.task_type,children:H(e.task_type)}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",children:new Date(e.created_at).toLocaleString()}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",title:e.updated_at?new Date(e.updated_at).toLocaleString():void 0,children:e.updated_at?W(e.updated_at):"—"}),(0,_.jsx)(ef,{className:"w-[300px]",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[U(e.status,e.error_message),"processing"===e.status&&Y(e.progress,{compact:!0})]})}),(0,_.jsxs)(ef,{className:"w-[110px] whitespace-nowrap",children:["pending"===e.status&&(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:t=>{t.stopPropagation(),K(e.id)},disabled:x===e.id,children:[x===e.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(tt.X,{className:"w-3 h-3 mr-1"}),x===e.id?"":r("action.cancel")]}),("failed"===e.status||"cancelled"===e.status)&&(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:t=>{t.stopPropagation(),Z(e.id)},disabled:y===e.id,children:[y===e.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(HR,{className:"w-3 h-3 mr-1"}),y===e.id?"":r("action.retry")]})]})]},e.id))})]})}),s>f&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:r("pagination",{start:p+1,end:Math.min(p+f,s),total:s})}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>q(Math.max(0,p-f)),disabled:0===p,children:r("paginationPrevious")}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>q(p+f),disabled:p+f>=s,children:r("paginationNext")})]})]})]}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:c?r("emptyStateWithStatus",{status:V(c)}):r("emptyState")})}),(0,_.jsx)(ta.Dialog,{open:S,onOpenChange:C,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("operationDetails")}),(0,_.jsx)(ta.DialogDescription,{children:N?.operation_id&&(0,_.jsx)("span",{className:"font-mono text-xs",children:N.operation_id})})]}),T?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):N?(0,_.jsx)("div",{className:"space-y-4",children:N.error?(0,_.jsx)("div",{className:"text-red-600 dark:text-red-400",children:N.error}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.status")}),(0,_.jsx)("div",{className:"mt-1",children:U(N.status)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.type")}),(0,_.jsx)("div",{className:"mt-1 font-mono text-sm",title:N.operation_type??void 0,children:H(N.operation_type)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.created")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.created_at?new Date(N.created_at).toLocaleString():r("notAvailable")})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.updated")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.updated_at?new Date(N.updated_at).toLocaleString():r("notAvailable")})]}),N.completed_at&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.completed")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:new Date(N.completed_at).toLocaleString()})]}),N.result_metadata?.items_count!==void 0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("totalItems")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.result_metadata.items_count})]})]}),"processing"===N.status&&N.progress&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:r("field.progress")}),Y(N.progress),"consolidation"===N.operation_type&&(0,_.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/70",children:r("progressEstimateNote")})]}),("pending"===N.status||"failed"===N.status||"cancelled"===N.status)&&(0,_.jsxs)("div",{className:"flex gap-2",children:["pending"===N.status&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>K(N.operation_id),disabled:x===N.operation_id,children:[x===N.operation_id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,_.jsx)(tt.X,{className:"w-3 h-3 mr-1"}),r("action.cancel")]}),("failed"===N.status||"cancelled"===N.status)&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Z(N.operation_id),disabled:y===N.operation_id,children:[y===N.operation_id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,_.jsx)(HR,{className:"w-3 h-3 mr-1"}),r("action.retry")]})]}),N.result_metadata&&Object.keys(N.result_metadata).length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:r("metadata")}),(0,_.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(N.result_metadata,null,2)})]}),N.error_message&&(0,_.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,_.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:r("error")}),(0,_.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:N.error_message})]}),N.child_operations&&N.child_operations.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:r("subBatchesCount",{count:N.result_metadata?.num_sub_batches||N.child_operations.length})}),(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[60px]",children:r("table.index")}),(0,_.jsx)(eh,{className:"w-[100px]",children:r("table.id")}),(0,_.jsx)(eh,{className:"w-[80px]",children:r("table.items")}),(0,_.jsx)(eh,{children:r("table.status")})]})}),(0,_.jsx)(eu,{children:N.child_operations.map(e=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"text-sm",children:e.sub_batch_index}),(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.operation_id.substring(0,8)}),(0,_.jsx)(ef,{className:"text-sm",children:e.items_count}),(0,_.jsx)(ef,{children:U(e.status,e.error_message)})]},e.operation_id))})]})]}),(e=L===N.operation_id,t=!!N.task_payload,n=!!N.result_metadata?.is_parent,(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("rawPayload")}),!e&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:J,disabled:A,children:[A?(0,_.jsx)(tn.default,{className:"w-3 h-3 mr-1 animate-spin"}):(0,_.jsx)(HB,{className:"w-3 h-3 mr-1"}),r("loadRaw")]})]}),t?(0,_.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(N.task_payload,null,2)}):e?(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:n?r("rawPayloadParentHelp"):r("rawPayloadEmpty")}):(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("rawPayloadHelp")})]}))]})}):null]})})]}):null}var tn=tn;let HU=(0,I.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 HW(){let e=(0,M.useTranslations)("mentalModels"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)("files"),[l,c]=(0,E.useState)(""),[u,d]=(0,E.useState)(1),[h,f]=(0,E.useState)(!1),[p,g]=(0,E.useState)(null),[x,v]=(0,E.useState)(null),[y,b]=(0,E.useState)([]),[w,j]=(0,E.useState)("any"),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(null),[T,A]=(0,E.useState)(null),[P,L]=(0,E.useState)(!1),[I,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(!1),U=n.filter(e=>{if(!l)return!0;let t=l.toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.source_query.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),W=async()=>{if(t){a(!0);try{let e=await $.client.listMentalModels(t,y.length>0?y:void 0,y.length>0?w:void 0);r(e.items||[])}catch(e){console.error("Error loading mental models:",e)}finally{a(!1)}}},[Y,G]=(0,E.useState)(new Set),K=async n=>{if(!t)return;let i=n.last_refreshed_at;G(e=>new Set(e).add(n.id));try{await $.client.refreshMentalModel(t,n.id);for(let a=0;a<120;a++){await new Promise(e=>setTimeout(e,1e3));let a=await $.client.getMentalModel(t,n.id);if(a.last_refreshed_at!==i){r(e=>e.map(e=>e.id===n.id?a:e)),p?.id===n.id&&g(a),O.toast.success(e("toastRefreshed"));return}}O.toast.error(e("toastRefreshTimeout"))}catch{}finally{G(e=>{let t=new Set(e);return t.delete(n.id),t})}},Z=async()=>{if(t&&T){L(!0);try{await $.client.deleteMentalModel(t,T.id),r(e=>e.filter(e=>e.id!==T.id)),p?.id===T.id&&g(null),A(null)}catch(e){}finally{L(!1)}}},Q=async()=>{if(t&&I){F(!0);try{let e=await $.client.clearMentalModel(t,I.id);r(t=>t.map(t=>t.id===e.id?e:t)),p?.id===e.id&&g(e),O.toast.success("Mental model content cleared"),B(null)}catch{}finally{F(!1)}}};if((0,E.useEffect)(()=>{t&&W()},[t,y,w]),(0,E.useEffect)(()=>{let e=e=>{"Escape"===e.key&&g(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,E.useEffect)(()=>{d(1)},[l,y,w]),!t)return(0,_.jsx)(tm.Card,{children:(0,_.jsx)(tm.CardContent,{className:"p-10 text-center",children:(0,_.jsx)("p",{className:"text-muted-foreground",children:e("selectBankPrompt")})})});let et=Math.ceil(U.length/100),en=(u-1)*100,ei=en+100,ea=U.slice(en,ei);return(0,_.jsxs)("div",{children:[i?(0,_.jsxs)("div",{className:"text-center py-12",children:[(0,_.jsx)(er,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:e("loading")})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"mb-4 flex items-center gap-3 flex-wrap",children:[(0,_.jsx)(q.Input,{type:"text",value:l,onChange:e=>c(e.target.value),placeholder:e("filterPlaceholder"),className:"w-80 h-9"}),(0,_.jsx)(Pc,{value:y,onChange:b,fetchSuggestions:async e=>{if(!t)return[];let n=e?`${e}*`:void 0;return(await $.client.listTags(t,n,20,"mental_models")).items.map(e=>e.tag)},matchMode:w,onMatchModeChange:j,className:"flex-1 min-w-[260px]"}),(0,_.jsxs)(X.Button,{onClick:()=>f(!0),size:"sm",children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-2"}),e("addMentalModel")]})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:l||y.length>0?e("countFiltered",{filtered:U.length,total:n.length}):e("count",{count:n.length})}),(0,_.jsx)("div",{className:"flex items-center gap-3",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,_.jsxs)("button",{onClick:()=>s("files"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"files"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(VJ,{className:"w-4 h-4"}),e("viewList")]}),(0,_.jsxs)("button",{onClick:()=>s("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(HU,{className:"w-4 h-4"}),e("viewDashboard")]})]})})]}),U.length>0?(0,_.jsxs)(_.Fragment,{children:["dashboard"===o&&(0,_.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ea.map(t=>(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${p?.id===t.id?"border-primary shadow-md":""}`,onClick:()=>g(t),children:(0,_.jsxs)(tm.CardContent,{className:"p-4",children:[(0,_.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:t.name}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:t.id}),(0,_.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${t.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:t.trigger?.refresh_after_consolidation?e("badgeAutoRefresh"):e("badgeManual")})]})]}),(0,_.jsx)(HY,{m:t,refreshing:Y.has(t.id),onEdit:e=>{C(e),k(!0)},onRefresh:K,onClear:e=>B({id:e.id,name:e.name}),onDelete:e=>A({id:e.id,name:e.name}),triggerClassName:"h-7 w-7 ml-2 flex-shrink-0"})]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:t.source_query}),(0,_.jsxs)("div",{className:"relative mb-3 border-t border-border pt-3 max-h-40 overflow-hidden",children:[(0,_.jsx)(F1,{children:t.content}),(0,_.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-card to-transparent"})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,_.jsx)("div",{className:"flex items-center gap-2",children:t.tags.length>0&&(0,_.jsxs)("div",{className:"flex gap-1",children:[t.tags.slice(0,2).map(e=>(0,_.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e)),t.tags.length>2&&(0,_.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",t.tags.length-2]})]})}),(0,_.jsx)("div",{className:"text-muted-foreground",title:F4(t.last_refreshed_at),children:F3(t.last_refreshed_at)})]})]})},t.id))}),"files"===o&&(0,_.jsx)(HX,{mentalModels:U,selectedId:x,onSelect:v,onOpenDetail:g,refreshingIds:Y,onEdit:e=>{C(e),k(!0)},onRefresh:K,onClear:e=>B({id:e.id,name:e.name}),onDelete:e=>A({id:e.id,name:e.name})}),"files"!==o&&et>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[en+1,"-",Math.min(ei,U.length)," of"," ",U.length]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(1),disabled:1===u,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(e=>Math.max(1,e-1)),disabled:1===u,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[u," / ",et]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(e=>Math.min(et,e+1)),disabled:u===et,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(et),disabled:u===et,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]}):(0,_.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,_.jsx)(R,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:l?e("emptyFilterMatch"):e("emptyNoModels")})]})]}),(0,_.jsx)(HG,{open:h,onClose:()=>f(!1),onCreated:()=>{f(!1),W()}}),(0,_.jsx)(PN,{open:!!T,onOpenChange:e=>!e&&A(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("deleteDialogTitle")}),(0,_.jsxs)(PW,{children:[e("deleteDialogDescription",{name:T?.name??""}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:e("deleteDialogWarning")})]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:e("deleteDialogCancel")}),(0,_.jsxs)(PY,{onClick:Z,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[P?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,e("deleteDialogConfirm")]})]})]})}),(0,_.jsx)(PN,{open:!!I,onOpenChange:e=>!e&&B(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("clearDialogTitle")}),(0,_.jsxs)(PW,{children:[e.rich("clearDialogDescription",{name:I?.name??"",bold:e=>(0,_.jsx)("span",{className:"font-semibold",children:e})}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),e("clearDialogReSynth")]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:e("cancelButton")}),(0,_.jsxs)(PY,{onClick:Q,disabled:z,children:[z?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,e("clearDialogConfirm")]})]})]})}),(0,_.jsx)(Vs,{mentalModelId:p?.id??null,onClose:()=>g(null),onDelete:e=>A({id:e.id,name:e.name}),onClear:e=>B({id:e.id,name:e.name}),onEdit:e=>{C(e),k(!0)},onRefreshed:e=>{r(t=>t.map(t=>t.id===e.id?e:t)),g(e)}}),S&&(0,_.jsx)(H$,{open:N,mentalModel:S,onClose:()=>{k(!1),C(null)},onUpdated:e=>{r(t=>t.map(t=>t.id===e.id?e:t)),g(e),k(!1),C(null)}})]})}function HY({m:e,refreshing:t,onEdit:n,onRefresh:r,onClear:i,onDelete:a,triggerClassName:o}){let s=(0,M.useTranslations)("mentalModels");return(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:`p-0 text-muted-foreground ${o??"h-8 w-8"}`,onClick:e=>e.stopPropagation(),"aria-label":s("actionsAriaLabel"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>n(e),children:[(0,_.jsx)(PX,{className:"h-4 w-4 mr-2"}),s("actionEdit")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>r(e),disabled:t,children:[(0,_.jsx)(er,{className:`h-4 w-4 mr-2 ${t?"animate-spin":""}`}),s("actionRefresh")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>i(e),children:[(0,_.jsx)(L5,{className:"h-4 w-4 mr-2"}),s("actionClearContent")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>a(e),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),s("actionDelete")]})]})]})}function HG({open:e,onClose:t,onCreated:n}){let r=(0,M.useTranslations)("mentalModels"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),c=async()=>{if(i&&s.name.trim()&&s.sourceQuery.trim()){o(!0);try{let e,t=s.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),a=parseInt(s.maxTokens)||2048,o=s.excludeMentalModelIds.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(s.tagGroups.trim())try{e=JSON.parse(s.tagGroups.trim())}catch{O.toast.error(r("invalidTagGroupsJson"));return}let c=s.recallMaxTokens.trim()?parseInt(s.recallMaxTokens,10):void 0,u=s.recallChunksMaxTokens.trim()?parseInt(s.recallChunksMaxTokens,10):void 0,d="true"===s.includeChunks||"false"!==s.includeChunks&&void 0;await $.client.createMentalModel(i,{id:s.id.trim()||void 0,name:s.name.trim(),source_query:s.sourceQuery.trim(),tags:t.length>0?t:void 0,max_tokens:a,trigger:{mode:s.mode,refresh_after_consolidation:s.autoRefresh,fact_types:s.factTypes.length>0?s.factTypes:void 0,exclude_mental_models:s.excludeMentalModels||void 0,exclude_mental_model_ids:o.length>0?o:void 0,tags_match:s.tagsMatch||void 0,tag_groups:e,include_chunks:d,recall_max_tokens:c,recall_chunks_max_tokens:u}}),l({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),n()}catch(e){}finally{o(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>{e||(l({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),t())},children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("createDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("createDialogDescription")})]}),(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,_.jsxs)(ts.TabsList,{className:"w-full",children:[(0,_.jsx)(ts.TabsTrigger,{value:"general",className:"flex-1",children:r("tabGeneral")}),(0,_.jsx)(ts.TabsTrigger,{value:"options",className:"flex-1",children:r("tabOptions")})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,_.jsxs)(ts.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldId")}),(0,_.jsx)(q.Input,{value:s.id,onChange:e=>l({...s,id:e.target.value}),placeholder:r("fieldIdPlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldName")}),(0,_.jsx)(q.Input,{value:s.name,onChange:e=>l({...s,name:e.target.value}),placeholder:r("fieldNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldSourceQuery")}),(0,_.jsx)(Ld.Textarea,{value:s.sourceQuery,onChange:e=>l({...s,sourceQuery:e.target.value}),placeholder:r("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldMaxTokens")}),(0,_.jsx)(q.Input,{type:"number",value:s.maxTokens,onChange:e=>l({...s,maxTokens:e.target.value}),placeholder:r("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,_.jsxs)(ts.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionRefresh")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"auto-refresh",checked:s.autoRefresh,onCheckedChange:e=>l({...s,autoRefresh:!0===e})}),(0,_.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:r("optionsAutoRefreshLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRefreshModeLabel")}),(0,_.jsxs)(e6.Select,{value:s.mode,onValueChange:e=>l({...s,mode:e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"full",children:r("optionsRefreshModeFull")}),(0,_.jsx)(e6.SelectItem,{value:"delta",children:r("optionsRefreshModeDelta")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRefreshModeDeltaDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionOtherModels")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"exclude-mental-models",checked:s.excludeMentalModels,onCheckedChange:e=>l({...s,excludeMentalModels:!0===e})}),(0,_.jsx)("label",{htmlFor:"exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:r("optionsExcludeAllLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsExcludeIdsLabel")}),(0,_.jsx)(q.Input,{value:s.excludeMentalModelIds,onChange:e=>l({...s,excludeMentalModelIds:e.target.value}),placeholder:r("optionsExcludeIdsPlaceholder")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionTags")}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagsLabel")}),(0,_.jsx)(q.Input,{value:s.tags,onChange:e=>l({...s,tags:e.target.value}),placeholder:r("optionsTagsPlaceholder")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagsDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagsMatchLabel")}),(0,_.jsxs)(e6.Select,{value:s.tagsMatch,onValueChange:e=>l({...s,tagsMatch:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{placeholder:r("optionsTagsMatchDefaultPlaceholder")})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:r("optionsTagsMatchDefault")}),(0,_.jsx)(e6.SelectItem,{value:"any",children:r("optionsTagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:r("optionsTagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:r("optionsTagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:r("optionsTagsMatchAllStrict")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagsMatchDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagGroupsLabel")}),(0,_.jsx)(Ld.Textarea,{value:s.tagGroups,onChange:e=>l({...s,tagGroups:e.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagGroupsDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionRecall")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallDescription")}),(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsFactTypesLabel")}),(0,_.jsx)(La,{value:s.factTypes,onChange:e=>l({...s,factTypes:e})}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsFactTypesEmpty")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsIncludeChunksLabel")}),(0,_.jsxs)(e6.Select,{value:s.includeChunks||"default",onValueChange:e=>l({...s,includeChunks:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:r("optionsIncludeChunksDefault")}),(0,_.jsx)(e6.SelectItem,{value:"true",children:r("optionsIncludeChunksYes")}),(0,_.jsx)(e6.SelectItem,{value:"false",children:r("optionsIncludeChunksNo")})]})]})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRecallMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:s.recallMaxTokens,onChange:e=>l({...s,recallMaxTokens:e.target.value}),placeholder:r("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallMaxTokensDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRecallChunksMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:s.recallChunksMaxTokens,onChange:e=>l({...s,recallChunksMaxTokens:e.target.value}),placeholder:r("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:t,disabled:a,children:r("cancelButton")}),(0,_.jsx)(X.Button,{onClick:c,disabled:a||!s.name.trim()||!s.sourceQuery.trim(),children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}),r("creatingButton")]}):r("createButton")})]})]})})}function H$({open:e,mentalModel:t,onClose:n,onUpdated:r}){let i=(0,M.useTranslations)("mentalModels"),{currentBank:a}=(0,D.useBank)(),[o,s]=(0,E.useState)(!1),l=()=>({name:t.name,sourceQuery:t.source_query,maxTokens:String(t.max_tokens||2048),tags:t.tags.join(", "),autoRefresh:t.trigger?.refresh_after_consolidation||!1,mode:t.trigger?.mode||"full",factTypes:t.trigger?.fact_types||[],excludeMentalModels:t.trigger?.exclude_mental_models||!1,excludeMentalModelIds:(t.trigger?.exclude_mental_model_ids||[]).join(", "),tagsMatch:t.trigger?.tags_match||"",tagGroups:t.trigger?.tag_groups?JSON.stringify(t.trigger.tag_groups,null,2):"",includeChunks:t.trigger?.include_chunks===!0?"true":t.trigger?.include_chunks===!1?"false":"",recallMaxTokens:t.trigger?.recall_max_tokens!=null?String(t.trigger.recall_max_tokens):"",recallChunksMaxTokens:t.trigger?.recall_chunks_max_tokens!=null?String(t.trigger.recall_chunks_max_tokens):""}),[c,u]=(0,E.useState)(l);(0,E.useEffect)(()=>{e&&u(l())},[e,t]);let d=async()=>{if(a&&c.name.trim()&&c.sourceQuery.trim()){s(!0);try{let e,o=c.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),s=parseInt(c.maxTokens)||2048,l=c.excludeMentalModelIds.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(c.tagGroups.trim())try{e=JSON.parse(c.tagGroups.trim())}catch{O.toast.error(i("invalidTagGroupsJson"));return}let u=c.recallMaxTokens.trim()?parseInt(c.recallMaxTokens,10):void 0,d=c.recallChunksMaxTokens.trim()?parseInt(c.recallChunksMaxTokens,10):void 0,h="true"===c.includeChunks||"false"!==c.includeChunks&&void 0,f=await $.client.updateMentalModel(a,t.id,{name:c.name.trim(),source_query:c.sourceQuery.trim(),tags:o.length>0?o:void 0,max_tokens:s,trigger:{mode:c.mode,refresh_after_consolidation:c.autoRefresh,fact_types:c.factTypes.length>0?c.factTypes:void 0,exclude_mental_models:c.excludeMentalModels||void 0,exclude_mental_model_ids:l.length>0?l:void 0,tags_match:c.tagsMatch||void 0,tag_groups:e,include_chunks:h,recall_max_tokens:u,recall_chunks_max_tokens:d}});r(f),n()}catch(e){}finally{s(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:i("updateDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:i("updateDialogDescription")})]}),(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,_.jsxs)(ts.TabsList,{className:"w-full",children:[(0,_.jsx)(ts.TabsTrigger,{value:"general",className:"flex-1",children:i("tabGeneral")}),(0,_.jsx)(ts.TabsTrigger,{value:"options",className:"flex-1",children:i("tabOptions")})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,_.jsxs)(ts.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:i("fieldId")}),(0,_.jsx)(q.Input,{value:t.id,disabled:!0,className:"bg-muted"})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldName")}),(0,_.jsx)(q.Input,{value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:i("fieldNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldSourceQuery")}),(0,_.jsx)(Ld.Textarea,{value:c.sourceQuery,onChange:e=>u({...c,sourceQuery:e.target.value}),placeholder:i("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldMaxTokens")}),(0,_.jsx)(q.Input,{type:"number",value:c.maxTokens,onChange:e=>u({...c,maxTokens:e.target.value}),placeholder:i("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,_.jsxs)(ts.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionRefresh")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"update-auto-refresh",checked:c.autoRefresh,onCheckedChange:e=>u({...c,autoRefresh:!0===e})}),(0,_.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:i("optionsAutoRefreshLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRefreshModeLabel")}),(0,_.jsxs)(e6.Select,{value:c.mode,onValueChange:e=>u({...c,mode:e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"full",children:i("optionsRefreshModeFull")}),(0,_.jsx)(e6.SelectItem,{value:"delta",children:i("optionsRefreshModeDelta")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRefreshModeDeltaDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionOtherModels")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"update-exclude-mental-models",checked:c.excludeMentalModels,onCheckedChange:e=>u({...c,excludeMentalModels:!0===e})}),(0,_.jsx)("label",{htmlFor:"update-exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:i("optionsExcludeAllLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsExcludeIdsLabel")}),(0,_.jsx)(q.Input,{value:c.excludeMentalModelIds,onChange:e=>u({...c,excludeMentalModelIds:e.target.value}),placeholder:i("optionsExcludeIdsPlaceholder")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionTags")}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagsLabel")}),(0,_.jsx)(q.Input,{value:c.tags,onChange:e=>u({...c,tags:e.target.value}),placeholder:i("optionsTagsPlaceholder")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagsDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagsMatchLabel")}),(0,_.jsxs)(e6.Select,{value:c.tagsMatch||"default",onValueChange:e=>u({...c,tagsMatch:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{placeholder:i("optionsTagsMatchDefaultPlaceholder")})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:i("optionsTagsMatchDefault")}),(0,_.jsx)(e6.SelectItem,{value:"any",children:i("optionsTagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:i("optionsTagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:i("optionsTagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:i("optionsTagsMatchAllStrict")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagsMatchDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagGroupsLabel")}),(0,_.jsx)(Ld.Textarea,{value:c.tagGroups,onChange:e=>u({...c,tagGroups:e.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagGroupsDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionRecall")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallDescription")}),(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsFactTypesLabel")}),(0,_.jsx)(La,{value:c.factTypes,onChange:e=>u({...c,factTypes:e})}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsFactTypesEmpty")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsIncludeChunksLabel")}),(0,_.jsxs)(e6.Select,{value:c.includeChunks||"default",onValueChange:e=>u({...c,includeChunks:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:i("optionsIncludeChunksDefault")}),(0,_.jsx)(e6.SelectItem,{value:"true",children:i("optionsIncludeChunksYes")}),(0,_.jsx)(e6.SelectItem,{value:"false",children:i("optionsIncludeChunksNo")})]})]})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRecallMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:c.recallMaxTokens,onChange:e=>u({...c,recallMaxTokens:e.target.value}),placeholder:i("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallMaxTokensDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRecallChunksMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:c.recallChunksMaxTokens,onChange:e=>u({...c,recallChunksMaxTokens:e.target.value}),placeholder:i("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:n,disabled:o,children:i("cancelButton")}),(0,_.jsx)(X.Button,{onClick:d,disabled:o||!c.name.trim()||!c.sourceQuery.trim(),children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}),i("updatingButton")]}):i("updateButton")})]})]})})}function HX({mentalModels:e,selectedId:t,onSelect:n,onOpenDetail:r,refreshingIds:i,onEdit:a,onRefresh:o,onClear:s,onDelete:l}){let c=(0,M.useTranslations)("mentalModels"),u=t&&e.some(e=>e.id===t)?t:e[0]?.id??null,d=e.find(e=>e.id===u)??null;return(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[320px_1fr] gap-0 overflow-hidden min-h-[600px]",children:[(0,_.jsx)("aside",{className:"border-r border-border bg-muted/30 overflow-y-auto max-h-[calc(100vh-260px)]",children:(0,_.jsx)("ul",{className:"py-1",children:e.map(e=>{let t=e.id===u;return(0,_.jsx)("li",{children:(0,_.jsxs)("button",{onClick:()=>n(e.id),className:`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors border-l-2 ${t?"bg-primary/10 border-primary text-foreground":"border-transparent text-muted-foreground hover:bg-muted hover:text-foreground"}`,title:`${e.name}
|
|
9
|
-
${e.source_query}`,children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),(0,_.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:`truncate text-sm font-medium ${t?"text-foreground":""}`,children:e.name}),(0,_.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",title:F4(e.last_refreshed_at),children:F3(e.last_refreshed_at)})]}),e.source_query&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground/80 truncate italic mt-0.5",children:e.source_query})]})]})},e.id)})})}),(0,_.jsx)("section",{className:"overflow-y-auto max-h-[calc(100vh-260px)]",children:d?(0,_.jsxs)("article",{className:"p-6",children:[(0,_.jsx)("header",{className:"mb-4 pb-4 border-b border-border",children:(0,_.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,_.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,_.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:d.name}),d.source_query&&(0,_.jsxs)("p",{className:"text-sm text-muted-foreground mt-1 italic",children:["“",d.source_query,"”"]}),(0,_.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,_.jsxs)("span",{title:F4(d.last_refreshed_at),children:["Refreshed ",F3(d.last_refreshed_at)]}),d.tags.length>0&&(0,_.jsx)("div",{className:"flex gap-1",children:d.tags.map(e=>(0,_.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e))})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>r(d),children:"Open"}),(0,_.jsx)(HY,{m:d,refreshing:i.has(d.id),onEdit:a,onRefresh:o,onClear:s,onDelete:l})]})]})}),d.content?(0,_.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:(0,_.jsx)(F1,{children:d.content})}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:c("emptyContent")})]}):(0,_.jsxs)("div",{className:"p-10 text-center text-muted-foreground",children:[(0,_.jsx)(z.FileText,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,_.jsx)("p",{className:"text-sm",children:c("selectModelPrompt")})]})})]})}let Hq=(0,I.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 tn=tn;let HK=["consolidation.completed","retain.completed"],HZ={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function HQ(e){return Object.fromEntries(e.filter(e=>e.key.trim()).map(e=>[e.key,e.value]))}function HJ(e){return{method:e.method,timeout_seconds:e.timeout_seconds,headers:HQ(e.headers),params:HQ(e.params)}}function H0({label:e,pairs:t,onChange:n}){let r=(0,M.useTranslations)("webhooksView"),i=(e,r,i)=>{n(t.map((t,n)=>n===e?{...t,[r]:i}:t))};return(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)(eb,{children:e}),(0,_.jsxs)(X.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>n([...t,{key:"",value:""}]),children:[(0,_.jsx)(Pd.Plus,{className:"w-3 h-3 mr-1"}),r("kvAdd")]})]}),t.length>0&&(0,_.jsx)("div",{className:"space-y-1.5",children:t.map((e,a)=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(q.Input,{placeholder:r("kvKeyPlaceholder"),value:e.key,onChange:e=>i(a,"key",e.target.value),className:"h-8 text-sm flex-1"}),(0,_.jsx)(q.Input,{placeholder:r("kvValuePlaceholder"),value:e.value,onChange:e=>i(a,"value",e.target.value),className:"h-8 text-sm flex-1"}),(0,_.jsx)("button",{type:"button",onClick:()=>n(t.filter((e,t)=>t!==a)),className:"text-muted-foreground hover:text-foreground shrink-0","aria-label":r("kvRemovePair"),children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]},a))})]})}function H1({status:e}){let t=(0,M.useTranslations)("webhooksView");return"completed"===e?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),t("deliveryStatusDelivered")]}):"pending"===e?(0,_.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,_.jsx)(ea,{className:"w-3 h-3"}),t("deliveryStatusPending")]}):"failed"===e?(0,_.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,_.jsx)(VE,{className:"w-3 h-3"}),t("deliveryStatusFailed")]}):(0,_.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:e})}function H2({delivery:e,formatDate:t}){let n=(0,M.useTranslations)("webhooksView"),[r,i]=(0,E.useState)(!1),a=e.last_response_body||e.last_error;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(ed,{className:a?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>a&&i(e=>!e),children:[(0,_.jsx)(ef,{className:"w-8 pl-3 pr-0",children:a?r?(0,_.jsx)(PK.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,_.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,_.jsx)(ef,{children:(0,_.jsx)(H1,{status:e.status})}),(0,_.jsx)(ef,{children:null!=e.last_response_status?(0,_.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${e.last_response_status>=200&&e.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:e.last_response_status}):(0,_.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,_.jsx)(ef,{className:"text-center text-sm",children:e.attempts}),(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.event_type}),(0,_.jsx)(ef,{className:"text-xs text-muted-foreground whitespace-nowrap",children:t(e.created_at)})]}),r&&a&&(0,_.jsx)(ed,{className:"bg-muted/20 hover:bg-muted/20",children:(0,_.jsx)(ef,{colSpan:6,className:"px-4 py-3",children:(0,_.jsxs)("div",{className:"space-y-3",children:[e.last_error&&(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("expandedError")}),(0,_.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:e.last_error})]}),e.last_response_body&&(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:[n("expandedResponseBody"),e.last_attempt_at&&(0,_.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",t(e.last_attempt_at)]})]}),(0,_.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:e.last_response_body})]})]})})})]})}function H5(){let e=(0,M.useTranslations)("webhooksView"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(!1),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)(!1),[x,v]=(0,E.useState)(HZ),[y,b]=(0,E.useState)(!1),[w,j]=(0,E.useState)(null),[N,k]=(0,E.useState)(HZ),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)([]),[V,H]=(0,E.useState)(!1),[U,W]=(0,E.useState)(null),[Y,G]=(0,E.useState)(!1),K=async()=>{if(t){a(!0);try{let e=await $.client.listWebhooks(t);r(e.items||[])}catch(e){console.error("Error loading webhooks:",e)}finally{a(!1)}}};(0,E.useEffect)(()=>{t&&K()},[t]);let Z=async()=>{if(t&&x.url){c(!0);try{await $.client.createWebhook(t,{url:x.url,secret:x.secret||void 0,event_types:x.event_types.length>0?x.event_types:void 0,enabled:x.enabled,http_config:HJ(x.http_config)}),s(!1),v(HZ),g(!1),await K()}catch(e){}finally{c(!1)}}},Q=async e=>{if(t){d(e),f(null);try{await $.client.deleteWebhook(t,e),await K()}catch(e){}finally{d(null)}}},J=async()=>{if(t&&w&&N.url){P(!0);try{let e={url:N.url,event_types:N.event_types,enabled:N.enabled,http_config:HJ(N.http_config)};T?e.secret=null:N.secret&&(e.secret=N.secret),await $.client.updateWebhook(t,w.id,e),b(!1),await K()}catch{}finally{P(!1)}}},ee=async e=>{if(t){B(e),I(!0),F([]),W(null),H(!0);try{let n=await $.client.listWebhookDeliveries(t,e.id,50);F(n.items||[]),W(n.next_cursor??null)}catch(e){console.error("Error loading deliveries:",e)}finally{H(!1)}}},et=async()=>{if(t&&R&&U){G(!0);try{let e=await $.client.listWebhookDeliveries(t,R.id,50,U);F(t=>[...t,...e.items||[]]),W(e.next_cursor??null)}catch(e){console.error("Error loading more deliveries:",e)}finally{G(!1)}}},ea=t=>t?new Date(t).toLocaleString():e("formatDateNA");return t?(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-lg font-semibold",children:e("title")}),(0,_.jsx)("button",{onClick:()=>K(),className:"p-1 rounded hover:bg-muted transition-colors",title:e("refreshTitle"),"aria-label":e("refreshAriaLabel"),disabled:i,children:(0,_.jsx)(er,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${i?"animate-spin":""}`})})]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:e("webhookCount",{count:n.length})})]}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>s(!0),children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-2"}),e("addWebhook")]})]}),n.length>0?(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("tableHeaderUrl")}),(0,_.jsx)(eh,{children:e("tableHeaderMethod")}),(0,_.jsx)(eh,{children:e("tableHeaderEventTypes")}),(0,_.jsx)(eh,{children:e("tableHeaderStatus")}),(0,_.jsx)(eh,{children:e("tableHeaderCreatedAt")}),(0,_.jsx)(eh,{className:"w-[120px]"})]})}),(0,_.jsx)(eu,{children:n.map(t=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,_.jsx)("span",{title:t.url,children:t.url})}),(0,_.jsx)(ef,{children:(0,_.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:t.http_config?.method||"POST"})}),(0,_.jsx)(ef,{children:(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:t.event_types.length>0?t.event_types.map(e=>(0,_.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:e},e)):(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e("allEvents")})})}),(0,_.jsx)(ef,{children:t.enabled?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),e("statusEnabled")]}):(0,_.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:e("statusDisabled")})}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",children:ea(t.created_at)}),(0,_.jsx)(ef,{children:(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>ee(t),title:e("viewDeliveriesTitle"),children:[(0,_.jsx)(en,{className:"w-3 h-3 mr-1"}),e("deliveriesButton")]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let e;return j(t),void(k((e=t.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:t.url,secret:"",event_types:t.event_types,enabled:t.enabled,http_config:{method:e.method,timeout_seconds:e.timeout_seconds,headers:Object.entries(e.headers??{}).map(([e,t])=>({key:e,value:t})),params:Object.entries(e.params??{}).map(([e,t])=>({key:e,value:t}))}})),C(!1),O(!1),b(!0))},title:e("editWebhookTitle"),"aria-label":e("editWebhookAriaLabel"),children:(0,_.jsx)(PX,{className:"w-3 h-3"})}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>f(t),disabled:u===t.id,title:e("deleteWebhookTitle"),"aria-label":e("deleteWebhookAriaLabel"),children:u===t.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(P$,{className:"w-3 h-3"})})]})})]},t.id))})]})}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:e("emptyStateCanManage")}),(0,_.jsx)(ta.Dialog,{open:o,onOpenChange:e=>{e||(v(HZ),g(!1)),s(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("createDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("createDialogDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-2",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formTypeLabel")}),(0,_.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,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"webhook-url",children:[e("formUrlLabel")," ",(0,_.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,_.jsx)(q.Input,{id:"webhook-url",type:"url",placeholder:e("formUrlPlaceholder"),value:x.url,onChange:e=>v(t=>({...t,url:e.target.value}))})]}),(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formMethodLabel")}),(0,_.jsxs)(e6.Select,{value:x.http_config.method,onValueChange:e=>v(t=>({...t,http_config:{...t.http_config,method:e}})),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"POST",children:"POST"}),(0,_.jsx)(e6.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"webhook-timeout",children:e("formTimeoutLabel")}),(0,_.jsx)(q.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:x.http_config.timeout_seconds,onChange:e=>v(t=>({...t,http_config:{...t.http_config,timeout_seconds:parseInt(e.target.value)||30}}))})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"webhook-secret",children:[e("formSecretLabel")," ",(0,_.jsx)("span",{className:"text-muted-foreground text-xs",children:e("formSecretOptional")})]}),(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)(q.Input,{id:"webhook-secret",type:p?"text":"password",placeholder:e("formSecretPlaceholderOptional"),value:x.secret,onChange:e=>v(t=>({...t,secret:e.target.value})),className:"pr-10"}),(0,_.jsx)("button",{type:"button",onClick:()=>g(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":p?e("formHideSecret"):e("formShowSecret"),children:p?(0,_.jsx)(Hq,{className:"w-4 h-4"}):(0,_.jsx)(en,{className:"w-4 h-4"})})]})]}),(0,_.jsx)(H0,{label:e("formCustomHeaders"),pairs:x.http_config.headers,onChange:e=>v(t=>({...t,http_config:{...t.http_config,headers:e}}))}),(0,_.jsx)(H0,{label:e("formQueryParams"),pairs:x.http_config.params,onChange:e=>v(t=>({...t,http_config:{...t.http_config,params:e}}))}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)(eb,{children:e("formEventTypes")}),(0,_.jsx)("div",{className:"space-y-2",children:HK.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Pm.Checkbox,{id:`event-${e}`,checked:x.event_types.includes(e),onCheckedChange:()=>{v(t=>({...t,event_types:t.event_types.includes(e)?t.event_types.filter(t=>t!==e):[...t.event_types,e]}))}}),(0,_.jsx)(eb,{htmlFor:`event-${e}`,className:"font-mono text-sm cursor-pointer",children:e})]},e))})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsx)(e4.Switch,{id:"webhook-enabled",checked:x.enabled,onCheckedChange:e=>v(t=>({...t,enabled:e}))}),(0,_.jsx)(eb,{htmlFor:"webhook-enabled",children:e("formEnabled")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>s(!1),disabled:l,children:e("cancel")}),(0,_.jsx)(X.Button,{onClick:Z,disabled:l||!x.url,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("creating")]}):e("createWebhook")})]})]})}),(0,_.jsx)(ta.Dialog,{open:y,onOpenChange:e=>{e||(j(null),k(HZ),C(!1),O(!1)),b(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("editDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("editDialogDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-2",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formTypeLabel")}),(0,_.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,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"edit-webhook-url",children:[e("formUrlLabel")," ",(0,_.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,_.jsx)(q.Input,{id:"edit-webhook-url",type:"url",placeholder:e("formUrlPlaceholder"),value:N.url,onChange:e=>k(t=>({...t,url:e.target.value}))})]}),(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formMethodLabel")}),(0,_.jsxs)(e6.Select,{value:N.http_config.method,onValueChange:e=>k(t=>({...t,http_config:{...t.http_config,method:e}})),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"POST",children:"POST"}),(0,_.jsx)(e6.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"edit-webhook-timeout",children:e("formTimeoutLabel")}),(0,_.jsx)(q.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:N.http_config.timeout_seconds,onChange:e=>k(t=>({...t,http_config:{...t.http_config,timeout_seconds:parseInt(e.target.value)||30}}))})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"edit-webhook-secret",children:e("formSecretLabel")}),(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)(q.Input,{id:"edit-webhook-secret",type:S?"text":"password",placeholder:e("formSecretPlaceholderEdit"),value:N.secret,disabled:T,onChange:e=>k(t=>({...t,secret:e.target.value})),className:"pr-10"}),(0,_.jsx)("button",{type:"button",onClick:()=>C(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":S?e("formHideSecret"):e("formShowSecret"),children:S?(0,_.jsx)(Hq,{className:"w-4 h-4"}):(0,_.jsx)(en,{className:"w-4 h-4"})})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,_.jsx)(Pm.Checkbox,{id:"edit-clear-secret",checked:T,onCheckedChange:e=>{O(!!e),e&&k(e=>({...e,secret:""}))}}),(0,_.jsx)(eb,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:e("formClearSecret")})]})]}),(0,_.jsx)(H0,{label:e("formCustomHeaders"),pairs:N.http_config.headers,onChange:e=>k(t=>({...t,http_config:{...t.http_config,headers:e}}))}),(0,_.jsx)(H0,{label:e("formQueryParams"),pairs:N.http_config.params,onChange:e=>k(t=>({...t,http_config:{...t.http_config,params:e}}))}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)(eb,{children:e("formEventTypes")}),(0,_.jsx)("div",{className:"space-y-2",children:HK.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Pm.Checkbox,{id:`edit-event-${e}`,checked:N.event_types.includes(e),onCheckedChange:()=>k(t=>({...t,event_types:t.event_types.includes(e)?t.event_types.filter(t=>t!==e):[...t.event_types,e]}))}),(0,_.jsx)(eb,{htmlFor:`edit-event-${e}`,className:"font-mono text-sm cursor-pointer",children:e})]},e))})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsx)(e4.Switch,{id:"edit-webhook-enabled",checked:N.enabled,onCheckedChange:e=>k(t=>({...t,enabled:e}))}),(0,_.jsx)(eb,{htmlFor:"edit-webhook-enabled",children:e("formEnabled")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>b(!1),disabled:A,children:e("cancel")}),(0,_.jsx)(X.Button,{onClick:J,disabled:A||!N.url,children:A?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("saving")]}):e("saveChanges")})]})]})}),(0,_.jsx)(ta.Dialog,{open:!!h,onOpenChange:e=>{e||f(null)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-md",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("deleteDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("deleteDialogDescription")})]}),h&&(0,_.jsx)("div",{className:"py-2",children:(0,_.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:h.url})}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>f(null),children:e("cancel")}),(0,_.jsx)(X.Button,{variant:"destructive",onClick:()=>h&&Q(h.id),disabled:!!u,children:u?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("deleting")]}):e("deleteWebhookConfirm")})]})]})}),(0,_.jsx)(ta.Dialog,{open:L,onOpenChange:e=>{e||(F([]),W(null)),I(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("deliveriesDialogTitle")}),R&&(0,_.jsx)(ta.DialogDescription,{className:"font-mono text-xs truncate",children:R.url})]}),V?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):z.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-8 pl-3 pr-0"}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderStatus")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderHttp")}),(0,_.jsx)(eh,{className:"text-center",children:e("deliveriesTableHeaderAttempts")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderEvent")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderCreatedAt")})]})}),(0,_.jsx)(eu,{children:z.map(e=>(0,_.jsx)(H2,{delivery:e,formatDate:ea},e.id))})]})}),U&&(0,_.jsx)("div",{className:"flex justify-center pt-2",children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:et,disabled:Y,children:[Y&&(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("loadMore")]})})]}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:e("noDeliveries")})]})})]}):null}function H3(e){return[{value:"all",label:e("actionAll")},{value:"retain",label:e("actionRetain")},{value:"recall",label:e("actionRecall")},{value:"reflect",label:e("actionReflect")},{value:"create_bank",label:e("actionCreateBank")},{value:"update_bank",label:e("actionUpdateBank")},{value:"delete_bank",label:e("actionDeleteBank")},{value:"clear_memories",label:e("actionClearMemories")},{value:"consolidation",label:e("actionConsolidation")},{value:"batch_retain",label:e("actionBatchRetain")},{value:"create_mental_model",label:e("actionCreateMentalModel")},{value:"refresh_mental_model",label:e("actionRefreshMentalModel")},{value:"delete_mental_model",label:e("actionDeleteMentalModel")},{value:"create_directive",label:e("actionCreateDirective")},{value:"delete_directive",label:e("actionDeleteDirective")},{value:"file_convert_retain",label:e("actionFileConvertRetain")},{value:"webhook_delivery",label:e("actionWebhookDelivery")}]}function H4(e,t){if(!e||!t)return"—";let n=new Date(e).getTime(),r=new Date(t).getTime()-n;return r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${(r/6e4).toFixed(1)}m`}function H6(e){return e?new Date(e).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function H7({transport:e}){let t={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,_.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${t[e]||t.system}`,children:e})}function H9({bankId:e}){let t=(0,M.useTranslations)("auditLogsView"),n=H3(t),r=[{value:"1d",label:t("periodToday")},{value:"7d",label:t("periodLast7Days")},{value:"30d",label:t("periodLast30Days")}],[i,a]=(0,E.useState)("7d"),[o,s]=(0,E.useState)(null),[l,c]=(0,E.useState)([]),[u,d]=(0,E.useState)("day"),[h,f]=(0,E.useState)(!1),p=(0,E.useCallback)(async(t=i,n=o)=>{f(!0);try{let r=await $.client.getAuditLogStats(e,{period:t,action:n||void 0});c(r.buckets||[]),d(r.trunc||"day")}catch(e){console.error("Error loading audit stats:",e)}finally{f(!1)}},[e,i,o]);(0,E.useEffect)(()=>{p()},[e]);let g=l.map(e=>{var t;let n;return{time:(t=e.time,n=new Date(t),"hour"===u?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"short",day:"numeric"})),total:e.total}});return(0,_.jsxs)(tm.Card,{children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0 gap-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:t("requestVolume")}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(e6.Select,{value:o||"all",onValueChange:e=>{let t="all"===e?null:e;s(t),p(i,t)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[160px] h-8 text-xs",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:n.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),r.map(e=>(0,_.jsx)(X.Button,{variant:i===e.value?"default":"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{a(e.value),p(e.value,o)},children:e.label},e.value))]})]}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"h-[120px]",children:h?(0,_.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("chartLoading")}):0===g.length?(0,_.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("chartNoData")}):(0,_.jsx)(a3,{width:"100%",height:"100%",children:(0,_.jsxs)(m6,{data:g,margin:{top:5,right:5,bottom:0,left:5},children:[(0,_.jsx)(bM,{dataKey:"time",tick:{fontSize:10},axisLine:!1,tickLine:!1,className:"text-muted-foreground"}),(0,_.jsx)(wc,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:"6px",fontSize:"12px",padding:"4px 8px"}}),(0,_.jsx)(yM,{type:"monotone",dataKey:"total",stroke:"var(--primary)",strokeWidth:2,dot:!1,activeDot:{r:3}})]})})})})]})}function H8(){let e=(0,M.useTranslations)("auditLogsView"),t=H3(e),n=[{value:"all",label:e("transportAll")},{value:"http",label:e("transportHttp")},{value:"mcp",label:e("transportMcp")},{value:"system",label:e("transportSystem")}],{currentBank:r}=(0,D.useBank)(),[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(0),[l,c]=(0,E.useState)(null),[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)("all"),[p]=(0,E.useState)(20),[g,x]=(0,E.useState)(0),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(null),[j,N]=(0,E.useState)(!1),k=(0,E.useCallback)(e=>{if("all"===e)return{};let t=new Date,n=new Date;return"1h"===e?n.setHours(t.getHours()-1):"1d"===e?n.setDate(t.getDate()-1):"7d"===e?n.setDate(t.getDate()-7):"30d"===e&&n.setDate(t.getDate()-30),{start_date:n.toISOString()}},[]),S=(0,E.useCallback)(async(e=l,t=u,n=h,i=g)=>{if(r){y(!0);try{let o=k(n),l=await $.client.listAuditLogs(r,{action:e||void 0,transport:t||void 0,start_date:o.start_date,end_date:o.end_date,limit:p,offset:i});a(l.items||[]),s(l.total||0)}catch(e){console.error("Error loading audit logs:",e)}finally{y(!1)}}},[r,l,u,h,g,p,k]),C=e=>{x(e),S(l,u,h,e)};(0,E.useEffect)(()=>{r&&S(l,u,h,g)},[r]);let T=Math.ceil(o/p),O=Math.floor(g/p)+1;return r?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(H9,{bankId:r}),(0,_.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,_.jsxs)(e6.Select,{value:l||"all",onValueChange:e=>{let t="all"===e?null:e;c(t),x(0),S(t,u,h,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[180px]",children:(0,_.jsx)(e6.SelectValue,{placeholder:e("actionAll")})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:t.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),(0,_.jsxs)(e6.Select,{value:u||"all",onValueChange:e=>{let t="all"===e?null:e;d(t),x(0),S(l,t,h,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[160px]",children:(0,_.jsx)(e6.SelectValue,{placeholder:e("transportAll")})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:n.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),(0,_.jsxs)(e6.Select,{value:h,onValueChange:e=>{f(e),x(0),S(l,u,e,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[150px]",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{position:"popper",children:[(0,_.jsx)(e6.SelectItem,{value:"all",children:e("dateRangeAll")}),(0,_.jsx)(e6.SelectItem,{value:"1h",children:e("dateRangeLastHour")}),(0,_.jsx)(e6.SelectItem,{value:"1d",children:e("dateRangeLast24Hours")}),(0,_.jsx)(e6.SelectItem,{value:"7d",children:e("dateRangeLast7Days")}),(0,_.jsx)(e6.SelectItem,{value:"30d",children:e("dateRangeLast30Days")})]})]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(l,u,h,g),disabled:v,children:[(0,_.jsx)(er,{className:`w-4 h-4 mr-1 ${v?"animate-spin":""}`}),e("refresh")]}),(0,_.jsx)("span",{className:"text-sm text-muted-foreground ml-auto",children:e("entryCount",{count:o})})]}),(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[200px]",children:e("tableHeaderTime")}),(0,_.jsx)(eh,{children:e("tableHeaderAction")}),(0,_.jsx)(eh,{className:"w-[100px]",children:e("tableHeaderTransport")}),(0,_.jsx)(eh,{className:"w-[100px]",children:e("tableHeaderDuration")})]})}),(0,_.jsx)(eu,{children:0===i.length?(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:4,className:"text-center text-muted-foreground py-8",children:e(v?"tableLoading":"tableNoLogs")})}):i.map(e=>(0,_.jsxs)(ed,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>{w(e),N(!0)},children:[(0,_.jsx)(ef,{className:"text-sm font-mono",children:H6(e.started_at)}),(0,_.jsx)(ef,{className:"font-medium",children:e.action}),(0,_.jsx)(ef,{children:(0,_.jsx)(H7,{transport:e.transport})}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground font-mono",children:H4(e.started_at,e.ended_at)})]},e.id))})]}),T>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:e("paginationPage",{current:O,total:T})}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>C(Math.max(0,g-p)),disabled:0===g,children:[(0,_.jsx)(V,{className:"w-4 h-4 mr-1"}),e("previous")]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>C(g+p),disabled:g+p>=o,children:[e("next"),(0,_.jsx)(H.ChevronRight,{className:"w-4 h-4 ml-1"})]})]})]}),(0,_.jsx)(ta.Dialog,{open:j,onOpenChange:N,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsx)(ta.DialogHeader,{children:(0,_.jsx)(ta.DialogTitle,{children:e("detailDialogTitle",{action:b?.action??""})})}),b&&(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailAction")})," ",(0,_.jsx)("span",{className:"font-medium",children:b.action})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailTransport")})," ",(0,_.jsx)(H7,{transport:b.transport})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailStarted")})," ",(0,_.jsx)("span",{className:"font-mono",children:H6(b.started_at)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailDuration")})," ",(0,_.jsx)("span",{className:"font-mono",children:H4(b.started_at,b.ended_at)})]})]}),b.request&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailRequest")}),(0,_.jsx)(tg,{value:b.request,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),b.response&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailResponse")}),(0,_.jsx)(tg,{value:b.response,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),b.metadata&&Object.keys(b.metadata).length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailMetadata")}),(0,_.jsx)(tg,{value:b.metadata})]})]})]})})]}):null}let Ue=(0,I.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 Ut({title:e,description:t,icon:n=Ue}){return(0,_.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,_.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,_.jsx)(n,{width:48,height:48,strokeWidth:1.5})}),(0,_.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:e}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground max-w-md",children:t})]})}var tn=tn;e.s(["default",0,function(){(0,T.useParams)();let e=(0,T.useRouter)(),t=(0,T.useSearchParams)(),n=(0,M.useTranslations)("bank"),r=(0,M.useTranslations)("common"),{features:i}=(0,Pp.useFeatures)(),{currentBank:a,setCurrentBank:o,loadBanks:s}=(0,D.useBank)(),l=t.get("view")||"profile",c=t.get("subTab")||"world",u=t.get("bankConfigTab")||"general",d=i?.observations??!1,h=i?.bank_config_api??!1,f=i?.audit_log??!1,p=i?.llm_trace??!1,[g,x]=(0,E.useState)(!1),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(!1),[k,S]=(0,E.useState)(!1),[C,L]=(0,E.useState)(!1),[I,R]=(0,E.useState)(!1),[B,z]=(0,E.useState)(!1),F=t=>{a&&e.push((0,P.bankRoute)(a,`?view=data&subTab=${t}`))},V=t=>{a&&e.push((0,P.bankRoute)(a,`?view=profile&bankConfigTab=${t}`))},H=async()=>{if(a){y(!0);try{await $.client.deleteBank(a),x(!1),o(null),await s(),e.push("/")}catch(e){}finally{y(!1)}}},U=async()=>{if(a){N(!0);try{let e=await $.client.clearObservations(a);w(!1),O.toast.success(n("observationsCleared"),{description:e.message||n("observationsClearedDefault")})}catch(e){}finally{N(!1)}}},W=async()=>{if(a){z(!0);try{await $.client.resetBankConfig(a),R(!1)}catch{}finally{z(!1)}}},Y=async()=>{if(a){S(!0);try{await $.client.triggerConsolidation(a)}catch(e){}finally{S(!1)}}},q=async()=>{if(a){L(!0);try{let e=await $.client.recoverConsolidation(a);O.toast.success(n("recoveredMemories",{count:e.retried_count}))}catch(e){}finally{L(!1)}}};return(0,_.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,_.jsx)(A.BankSelector,{}),(0,_.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,_.jsx)(G,{currentTab:l,onTabChange:t=>{a&&e.push((0,P.bankRoute)(a,`?view=${t}`))}}),(0,_.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,_.jsxs)("div",{className:"p-6",children:["profile"===l&&(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("bankConfiguration")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("bankConfigurationDescription")})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",children:[n("actions"),(0,_.jsx)(Pq,{className:"w-4 h-4 ml-2"})]})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:async()=>{if(a)try{let e=await $.client.exportBankTemplate(a),t=JSON.stringify(e,null,2);await navigator.clipboard.writeText(t),O.toast.success(n("templateCopied"))}catch{O.toast.error(n("failedToExportTemplate"))}},children:[(0,_.jsx)(PZ,{className:"w-4 h-4 mr-2"}),n("exportTemplate")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:Y,disabled:k||!d,title:d?void 0:"Observations feature is not enabled",children:[k?(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,_.jsx)(Ls,{className:"w-4 h-4 mr-2"}),k?n("consolidating"):n("runConsolidation"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:q,disabled:C||!d,title:d?void 0:"Observations feature is not enabled",children:[C?(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,_.jsx)(HR,{className:"w-4 h-4 mr-2"}),C?n("recovering"):n("recoverConsolidation"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>w(!0),disabled:!d,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:d?void 0:"Observations feature is not enabled",children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("clearObservations"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>R(!0),disabled:!h,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:h?void 0:"Bank Config API is disabled",children:[(0,_.jsx)(HR,{className:"w-4 h-4 mr-2"}),n("resetConfiguration"),!h&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>x(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("deleteBank")]})]})]})]}),(0,_.jsx)("div",{className:"mb-6 border-b border-border",children:(0,_.jsxs)("div",{className:"flex gap-1",children:[(0,_.jsxs)("button",{onClick:()=>V("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("general"),"general"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),h&&(0,_.jsxs)("button",{onClick:()=>V("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("configuration"),"configuration"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("webhooks"),"webhooks"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("audit-logs"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"audit-logs"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("auditLogs"),!f&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"audit-logs"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("llm-requests"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"llm-requests"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("llmRequests"),!p&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"llm-requests"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,_.jsxs)("div",{children:["general"===u&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("overviewAndOperations")}),(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(HI,{}),(0,_.jsx)(HH,{}),(0,_.jsx)(Vb,{hideReflectFields:!0})]})]}),"configuration"===u&&h&&(0,_.jsx)("div",{className:"space-y-6",children:(0,_.jsx)(VB,{})}),"webhooks"===u&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("webhooksDescription")}),(0,_.jsx)(H5,{})]}),"audit-logs"===u&&(f?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("auditLogsDescription")}),(0,_.jsx)(H8,{})]}):(0,_.jsx)(Ut,{title:n("auditLogsNotEnabled"),description:n.rich("auditLogsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_AUDIT_LOG_ENABLED=true"})})})),"llm-requests"===u&&(p?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("llmRequestsDescription")}),(0,_.jsx)(wR,{})]}):(0,_.jsx)(Ut,{title:n("llmRequestsNotEnabled"),description:n.rich("llmRequestsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_LLM_TRACE_ENABLED=true"})})}))]})]}),"recall"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("recallAnalyzer")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("recallAnalyzerDescription")}),(0,_.jsx)(Vm,{})]}),"reflect"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("reflect")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("reflectDescription")}),(0,_.jsx)(Vf,{})]}),"data"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("memories")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("memoriesDescription")}),(0,_.jsx)("div",{className:"mb-6 border-b border-border",children:(0,_.jsxs)("div",{className:"flex gap-1",children:[(0,_.jsxs)("button",{onClick:()=>F("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("worldFacts"),"world"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("experience"),"experience"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("observations"),!d&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("mentalModels"),"mental-models"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,_.jsxs)("div",{children:["world"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("worldFactsDescription")}),(0,_.jsx)(Ph,{factType:"world"},"world")]}),"experience"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("experienceDescription")}),(0,_.jsx)(Ph,{factType:"experience"},"experience")]}),"observations"===c&&(d?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("observationsDescription")}),(0,_.jsx)(Ph,{factType:"observation"},"observations")]}):(0,_.jsx)(Ut,{title:n("observationsNotEnabled"),description:n.rich("observationsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})})})),"mental-models"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("mentalModelsDescription")}),(0,_.jsx)(HW,{},"mental-models")]})]})]}),"documents"===l&&(0,_.jsx)("div",{children:(0,_.jsx)(P8,{})}),"entities"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("entities")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("entitiesDescription")}),(0,_.jsx)(Le,{})]})]})})]}),(0,_.jsx)(PN,{open:g,onOpenChange:x,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("deleteMemoryBank")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("deleteBankPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:n("deleteBankWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:v,children:r("cancel")}),(0,_.jsx)(PY,{onClick:H,disabled:v,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:v?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("deleting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("deleteBank")]})})]})]})}),(0,_.jsx)(PN,{open:I,onOpenChange:R,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("resetConfigTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("resetConfigPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:n("resetConfigWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:B,children:r("cancel")}),(0,_.jsx)(PY,{onClick:W,disabled:B,children:B?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("resetting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(HR,{className:"w-4 h-4 mr-2"}),n("resetConfiguration")]})})]})]})}),(0,_.jsx)(PN,{open:b,onOpenChange:w,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("clearObservationsTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("clearObservationsPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:n("clearObservationsWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:j,children:r("cancel")}),(0,_.jsx)(PY,{onClick:U,disabled:j,className:"bg-amber-500 text-white hover:bg-amber-600",children:j?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("clearing")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("clearObservations")]})})]})]})})]})}],8004)}]);
|
|
7
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return E.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null};let Pz=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PS,{className:(0,W.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",e),...t,ref:n}));Pz.displayName=PS.displayName;let PF=E.forwardRef(({className:e,...t},n)=>(0,_.jsxs)(Pk,{children:[(0,_.jsx)(Pz,{}),(0,_.jsx)(PM,{ref:n,className:(0,W.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",e),...t})]}));PF.displayName=PM.displayName;let PV=({className:e,...t})=>(0,_.jsx)("div",{className:(0,W.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});PV.displayName="AlertDialogHeader";let PH=({className:e,...t})=>(0,_.jsx)("div",{className:(0,W.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});PH.displayName="AlertDialogFooter";let PU=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PA,{ref:n,className:(0,W.cn)("text-lg font-semibold",e),...t}));PU.displayName=PA.displayName;let PW=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PP,{ref:n,className:(0,W.cn)("text-sm text-muted-foreground",e),...t}));PW.displayName=PP.displayName;let PY=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PL,{ref:n,className:(0,W.cn)((0,X.buttonVariants)(),e),...t}));PY.displayName=PL.displayName;let PG=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)(PR,{ref:n,className:(0,W.cn)((0,X.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));PG.displayName=PR.displayName;let P$=(0,I.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"}]]),PX=(0,I.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Pq=(0,I.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 PK=e.i(64659);let PZ=(0,I.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 PQ=e.i(69074),PJ=e.i(70756);function P0(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);if(i<30)return`${i}d ago`;let a=Math.floor(i/30);return a<12?`${a}mo ago`:`${Math.floor(a/12)}y ago`}function P1(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function P2({metadata:e}){let t=Object.entries(e);return 0===t.length?(0,_.jsx)("span",{children:"-"}):(0,_.jsxs)("div",{className:"flex flex-wrap gap-1",children:[t.slice(0,3).map(([e,t])=>(0,_.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:[e,"=",String(t)]},e)),t.length>3&&(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",t.length-3]})]})}function P5({children:e}){return(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground mb-1",children:e})}function P3({title:e,icon:t,children:n}){return(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,_.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:[t,e]}),(0,_.jsx)("div",{className:"p-4 space-y-4",children:n})]})}function P4({bankId:e,documentId:t}){let n=(0,M.useTranslations)("documentsView"),[r,i]=(0,E.useState)([]),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(null);return((0,E.useEffect)(()=>{let n=!1;return(async()=>{try{let r=await $.client.listLLMRequests(e,{document_id:t,group:!0,limit:50});if(n)return;let a=new Map;for(let e of r.items||[]){let t=e.trace_id||e.id;a.has(t)||a.set(t,[]),a.get(t).push(e)}let o=[...a.entries()].map(([e,t])=>({traceId:e,entry:t[0],calls:t.length,tokens:t.reduce((e,t)=>e+(t.total_tokens??0),0),status:t.some(e=>"error"===e.status)?"error":"success",start:t.map(e=>e.started_at).filter(Boolean).sort()[0]??null}));o.sort((e,t)=>(t.start||"").localeCompare(e.start||"")),i(o)}catch{}finally{n||o(!0)}})(),()=>{n=!0}},[e,t]),a&&0!==r.length)?(0,_.jsxs)(P3,{title:n("retainTracesTitle"),icon:(0,_.jsx)(ti,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)("div",{className:"space-y-1",children:r.map(e=>(0,_.jsxs)("button",{type:"button",onClick:()=>l(e.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,_.jsxs)("span",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,_.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${"error"===e.status?"bg-red-500":"bg-green-500"}`}),(0,_.jsx)("span",{className:"font-mono text-xs",children:e.entry.operation||"retain"}),(0,_.jsx)("span",{className:"text-muted-foreground text-xs truncate",children:e.start?new Date(e.start).toLocaleString():""})]}),(0,_.jsx)("span",{className:"text-muted-foreground text-xs font-mono shrink-0",children:n("retainTracesSummary",{calls:e.calls,tokens:e.tokens.toLocaleString()})})]},e.traceId))}),(0,_.jsx)(wL,{bankId:e,entry:s,open:!!s,onOpenChange:e=>!e&&l(null)})]}):null}function P6({label:e,value:t}){return(0,_.jsxs)("div",{children:[(0,_.jsx)(P5,{children:e}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:t})]})}function P7({nodesByFactType:e}){let t=(0,M.useTranslations)("dataView"),n=e??{world:0,experience:0,observation:0},r=n.world+n.experience+n.observation,i=[{name:"World",value:n.world,color:"#8b5cf6"},{name:"Experience",value:n.experience,color:"#ec4899"},{name:"Observations",value:n.observation,color:"#6366f1"}];return(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:t("memoryComposition")}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:r.toLocaleString()})]}),0===r?(0,_.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:t("noMemoriesYet")}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:i.filter(e=>e.value>0).map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/r*100}%`,backgroundColor:e.color},title:`${e.name}: ${e.value.toLocaleString()}`},e.name))}),(0,_.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:i.map(e=>(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:e.name})]}),(0,_.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums",children:e.value.toLocaleString()}),(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:r>0?`${(e.value/r*100).toFixed(0)}%`:"0%"})]})]},e.name))})]})]})}function P9({chunkFactType:e,setChunkFactType:t}){return(0,_.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(n=>(0,_.jsx)("button",{onClick:()=>t(n),className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors ${e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"observation"===n?"Obs":n.charAt(0).toUpperCase()+n.slice(1)},n))})}function P8({chunk:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)("world"),s=e.chunk_text??"",l=s.length>150?s.slice(0,150)+"...":s;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-left hover:bg-muted/30 transition-colors",onClick:()=>n(!t),children:[(0,_.jsx)(PK.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${t?"":"-rotate-90"}`}),(0,_.jsxs)("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["#",e.chunk_index]}),(0,_.jsxs)("span",{className:"text-[11px] text-muted-foreground/60 shrink-0",children:[s.length.toLocaleString()," chars"]}),!t&&(0,_.jsx)("span",{className:"text-xs text-foreground/50 truncate",children:l})]}),t&&(r?(0,_.jsxs)("div",{style:{height:"500px"},className:"flex flex-col border-t border-border",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/30 border-b border-border",children:[(0,_.jsx)(P9,{chunkFactType:a,setChunkFactType:o}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",onClick:()=>i(!1),className:"h-6 px-2 text-xs gap-1",children:[(0,_.jsx)(en,{className:"w-3 h-3"}),"Compact"]})]}),(0,_.jsx)("div",{className:"flex-1 min-h-0",children:(0,_.jsx)(Ph,{factType:a,chunkId:e.chunk_id},`${e.chunk_id}-${a}-full`)})]}):(0,_.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border",style:{height:"350px"},children:[(0,_.jsx)("div",{className:"overflow-y-auto",children:(0,_.jsx)("pre",{className:"px-4 py-3 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:s})}),(0,_.jsxs)("div",{className:"flex flex-col overflow-hidden",children:[(0,_.jsx)(P9,{chunkFactType:a,setChunkFactType:o}),(0,_.jsx)("div",{className:"flex-1 min-h-0",children:(0,_.jsx)(Ph,{factType:a,chunkId:e.chunk_id,compact:!0,onExpandToggle:()=>i(!0)},`${e.chunk_id}-${a}-compact`)})]})]}))]})}function Le(){let e=(0,M.useTranslations)("documentsView"),t=(0,M.useTranslations)("common"),n=(0,M.useTranslations)("bank"),{currentBank:r}=(0,D.useBank)(),{features:i}=(0,Pp.useFeatures)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(!1),[c,u]=(0,E.useState)(""),[d,h]=(0,E.useState)(0),[f,p]=(0,E.useState)(!1),[g,x]=(0,E.useState)(!1),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(!1),[k,S]=(0,E.useState)(null),[C,T]=(0,E.useState)("skip"),[A,P]=(0,E.useState)(1),L=Math.ceil(d/50),I=(A-1)*50,[R,B]=(0,E.useState)(null),[F,W]=(0,E.useState)(!1),[Y,G]=(0,E.useState)(null),[K,Z]=(0,E.useState)(!1),[Q,et]=(0,E.useState)(""),[en,ei]=(0,E.useState)(!1),[ea,es]=(0,E.useState)(!1),[ep,em]=(0,E.useState)(""),[eg,ex]=(0,E.useState)(!1),[ev,ey]=(0,E.useState)([]),[ew,ej]=(0,E.useState)(0),[eN,ek]=(0,E.useState)(!1),[eS,eC]=(0,E.useState)(!1),[e_,eE]=(0,E.useState)(!1),[eT,eM]=(0,E.useState)(null),[eO,eA]=(0,E.useState)(null),[eD,eP]=(0,E.useState)(null),eL=async(e=1)=>{if(r){l(!0);try{let t=await $.client.listDocuments({bank_id:r,q:c,limit:50,offset:(e-1)*50});o(t.items||[]),h(t.total||0)}catch(e){}finally{l(!1)}}},eI=e=>{P(e),eL(e)},eR=async e=>{if(r){W(!0),B({id:e}),Z(!1),et(""),es(!1),em(""),ey([]),ej(0),eC(!1);try{let t=await $.client.getDocument(e,r);B(t)}catch(e){B(null)}finally{W(!1)}}},eB=async e=>{if(r){ek(!0);try{let t=await $.client.listDocumentChunks({document_id:e,bank_id:r,limit:100});ey(t.items||[]),ej(t.total||0),eC(!0)}catch(e){}finally{ek(!1)}}},ez=async()=>{if(r&&R){eE(!0);try{let e=await $.client.reprocessDocument(R.id,r);eM({success:!0,message:`Reprocessing started (operation: ${e.operation_id})`})}catch(e){eM({success:!1,message:"Error reprocessing document: "+e.message})}finally{eE(!1)}}},eF=async()=>{if(!r||!eO)return;let t=eO.id;G(t),eA(null);try{let n=await $.client.deleteDocument(t,r);eP({success:!0,message:e("toastDeletedDocumentAndUnits",{count:n.memory_units_deleted})}),R?.id===t&&B(null),eL(A)}catch(t){console.error("Error deleting document:",t),eP({success:!1,message:e("toastErrorDeletingDocument")+t.message})}finally{G(null)}},eV=()=>{Z(!1),et("")},eH=async()=>{if(!r||!R||!ep.trim())return;let e=R.retain_params??{},t={content:ep,document_id:R.id};e.context&&(t.context=e.context),e.event_date&&(t.timestamp=e.event_date),e.metadata&&Object.keys(e.metadata).length>0&&(t.metadata=e.metadata),R.tags&&R.tags.length>0&&(t.tags=R.tags),ex(!0);try{await $.client.retain({bank_id:r,items:[t],async:!1});let e=await $.client.getDocument(R.id,r);B(e),es(!1),em(""),eL(A)}catch(e){console.error("Error updating document content:",e)}finally{ex(!1)}},eU=async()=>{if(!r||!R)return;let e=Q.split(",").map(e=>e.trim()).filter(e=>e.length>0);ei(!0);try{await $.client.updateDocument(R.id,r,e),B({...R,tags:e}),o(t=>t.map(t=>t.id===R.id?{...t,tags:e}:t)),Z(!1),et("")}catch(e){console.error("Error updating document tags:",e)}finally{ei(!1)}};(0,E.useEffect)(()=>{r&&(P(1),eL(1))},[r]),(0,E.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>{P(1),eL(1)},300);return()=>clearTimeout(e)},[c]);let eW=async(t,n=!1)=>{if(r&&!f){p(!0);try{var i;let a,o,s=await $.client.exportDocuments(r,t,n),l=t&&1===t.length?`-${t[0]}`:"-documents";i=`${r}${l}.zip`,a=URL.createObjectURL(s),(o=document.createElement("a")).href=a,o.download=i,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),O.toast.success(e("exportSuccess")),y(!1)}catch{}finally{p(!1)}}},eY=async t=>{if(t&&r){x(!0);try{let{operation_id:n}=await $.client.importDocuments(r,t,C),i=Date.now()+3e5,a=null;for(;Date.now()<i;){let t=await $.client.getOperationStatus(r,n);if("completed"===t.status){a=t.result_metadata??{};break}if("failed"===t.status)return void O.toast.error(t.error_message||e("importFailed"));await new Promise(e=>setTimeout(e,1e3))}if(null===a)return void O.toast.error(e("importTimeout"));O.toast.success(e("importSuccess",{imported:a.documents_imported??0,facts:a.facts_imported??0,skipped:a.documents_skipped??0})),eL(A),N(!1),S(null)}catch{}finally{x(!1)}}},eG=i?.document_export_api??!1,e$=i?.document_import_api??!1;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"mb-6 flex items-start justify-between gap-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("documents")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("documentsDescription")})]}),(eG||e$)&&(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"h-8 shrink-0",disabled:!r||f||g,children:[f?e("exporting"):g?e("importing"):e("actionsButton"),(0,_.jsx)(PK.ChevronDown,{className:"w-4 h-4 ml-1"})]})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[eG&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>{w(!1),y(!0)},children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),e("exportButton")]}),e$&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>N(!0),children:[(0,_.jsx)(PQ.Upload,{className:"h-4 w-4 mr-2"}),e("importButton")]})]})]})]}),(0,_.jsx)(ta.Dialog,{open:v,onOpenChange:y,children:(0,_.jsxs)(ta.DialogContent,{children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("exportDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("exportDialogDescription")})]}),(0,_.jsxs)("div",{className:"flex items-start gap-2 py-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"export-include-observations",checked:b,onCheckedChange:e=>w(!0===e)}),(0,_.jsxs)("div",{className:"grid gap-1 leading-none",children:[(0,_.jsx)(eb,{htmlFor:"export-include-observations",children:e("exportIncludeObservationsLabel")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:e("exportIncludeObservationsHint")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>y(!1),disabled:f,children:t("cancel")}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>eW(void 0,b),disabled:f,children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),f?e("exporting"):e("exportButton")]})]})]})}),(0,_.jsx)(ta.Dialog,{open:j,onOpenChange:e=>{N(e),e||S(null)},children:(0,_.jsxs)(ta.DialogContent,{children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("importDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("importDialogDescription")})]}),(0,_.jsxs)("div",{className:"py-2 space-y-4",children:[(0,_.jsx)("input",{type:"file",accept:".zip,application/zip",disabled:g,onChange:e=>S(e.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,_.jsxs)("div",{className:"grid gap-1.5",children:[(0,_.jsx)(eb,{htmlFor:"import-on-conflict",children:e("importConflictLabel")}),(0,_.jsxs)(e6.Select,{value:C,onValueChange:e=>T(e),disabled:g,children:[(0,_.jsx)(e6.SelectTrigger,{id:"import-on-conflict",className:"h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"skip",children:e("importConflictSkip")}),(0,_.jsx)(e6.SelectItem,{value:"replace",children:e("importConflictReplace")}),(0,_.jsx)(e6.SelectItem,{value:"new-id",children:e("importConflictNewId")})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>{N(!1),S(null)},disabled:g,children:t("cancel")}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>k&&eY(k),disabled:!k||g,children:[(0,_.jsx)(PQ.Upload,{className:"h-4 w-4 mr-2"}),g?e("importing"):e("importButton")]})]})]})}),s?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingDocuments")})]})}):a.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:e("totalDocuments",{total:d})}),(0,_.jsxs)("div",{className:"w-full",children:[(0,_.jsx)("div",{className:"px-5 mb-4",children:(0,_.jsx)(q.Input,{type:"text",value:c,onChange:e=>u(e.target.value),placeholder:e("searchPlaceholder"),className:"max-w-2xl"})}),(0,_.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("colDocumentId")}),(0,_.jsx)(eh,{children:e("colCreated")}),(0,_.jsx)(eh,{children:e("colUpdated")}),(0,_.jsx)(eh,{children:e("colTags")}),(0,_.jsx)(eh,{children:e("colMetadata")}),(0,_.jsx)(eh,{children:e("colSize")}),(0,_.jsx)(eh,{children:e("colMemoryUnits")})]})}),(0,_.jsx)(eu,{children:a.length>0?a.map(e=>(0,_.jsxs)(ed,{className:`cursor-pointer hover:bg-muted/50 ${R?.id===e.id?"bg-primary/10":""}`,onClick:()=>eR(e.id),children:[(0,_.jsx)(ef,{className:"text-card-foreground font-mono text-xs break-all",children:e.id}),(0,_.jsx)(ef,{className:"text-card-foreground",title:e.created_at?new Date(e.created_at).toLocaleString():"",children:e.created_at?P0(e.created_at):"N/A"}),(0,_.jsx)(ef,{className:"text-card-foreground",title:e.updated_at?new Date(e.updated_at).toLocaleString():"",children:e.updated_at?P0(e.updated_at):"N/A"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.tags&&e.tags.length>0?(0,_.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map((e,t)=>(0,_.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:e},t)),e.tags.length>3&&(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",e.tags.length-3]})]}):"-"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.document_metadata&&Object.keys(e.document_metadata).length>0?(0,_.jsx)(P2,{metadata:e.document_metadata}):"-"}),(0,_.jsx)(ef,{className:"text-card-foreground",children:P1(e.text_length||0)}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.memory_unit_count})]},e.id)):(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:7,className:"text-center",children:e("clickLoadDocumentsToView")})})})]})}),L>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t px-5",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[I+1,"-",Math.min(I+50,d)," of ",d]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(1),disabled:1===A||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(A-1),disabled:1===A||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[A," / ",L]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(A+1),disabled:A===L||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>eI(L),disabled:A===L||s,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noDocumentsFound")})]})}),(0,_.jsx)(ta.Dialog,{open:!!R,onOpenChange:e=>!e&&B(null),children:(0,_.jsxs)(ta.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,_.jsx)(ta.DialogHeader,{className:"pr-10",children:(0,_.jsx)(ta.DialogTitle,{className:"flex items-center gap-2",children:(0,_.jsx)("span",{className:"truncate font-mono text-sm",children:R?.id??"Document"})})}),F?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingDocument")})]})}):R?(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"flex-1 flex flex-col overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,_.jsxs)(ts.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,_.jsxs)(ts.TabsTrigger,{value:"general",className:"flex items-center gap-1.5",children:[(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),"General"]}),(0,_.jsxs)(ts.TabsTrigger,{value:"content",className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),"Content"]}),(0,_.jsxs)(ts.TabsTrigger,{value:"chunks",className:"flex items-center gap-1.5",onClick:()=>{!eS&&R?.id&&eB(R.id)},children:[(0,_.jsx)(tl,{className:"w-3.5 h-3.5"}),"Chunks",eS?` (${ew})`:""]})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:e_,"aria-label":t("actions"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:ez,disabled:e_,children:[(0,_.jsx)(er,{className:"h-4 w-4 mr-2"}),"Reprocess"]}),eG&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>eW([R.id]),disabled:f,children:[(0,_.jsx)(PZ,{className:"h-4 w-4 mr-2"}),e("exportButton")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>{eA({id:R.id,memoryCount:R.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,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),e("deleteButton")]})]})]})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,_.jsx)(ts.TabsContent,{value:"content",className:"mt-0",children:i?.store_document_text||R.original_text?void 0!==R.original_text?ea?(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("div",{className:"flex items-center justify-end mb-2",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(X.Button,{size:"sm",onClick:eH,disabled:eg||!ep.trim(),className:"h-7 px-3 gap-1 text-xs",children:[eg?(0,_.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,_.jsx)(te.Check,{className:"h-3 w-3"}),e("saveButton")]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>{es(!1),em("")},disabled:eg,className:"h-7 px-3 gap-1 text-xs",children:[(0,_.jsx)(tt.X,{className:"h-3 w-3"}),e("cancelButton")]})]})}),(0,_.jsx)("textarea",{value:ep,onChange:e=>em(e.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,_.jsx)("p",{className:"text-xs text-muted-foreground",children:e("saveHint")})]}):(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,_.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,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),(0,_.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:e("storedContent")}),(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["·"," ",R.original_text?.length?.toLocaleString()??0," chars"]})]}),(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",onClick:()=>{em(R?.original_text??""),es(!0)},className:"h-6 px-2 gap-1 text-xs",children:[(0,_.jsx)(PX,{className:"h-3 w-3"}),e("editButton")]})]}),(0,_.jsx)("pre",{className:"p-4 text-[11px] leading-5 text-foreground/80 whitespace-pre-wrap font-mono",children:R.original_text})]}):null:(0,_.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,_.jsx)(PJ.Lock,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,_.jsx)("span",{children:e("textNotStoredWarning")})]})}),(0,_.jsx)(ts.TabsContent,{value:"general",className:"mt-0",children:(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)(ts.Tabs,{defaultValue:"world",className:"flex flex-col",children:[(0,_.jsxs)(ts.TabsList,{className:"w-fit",children:[(0,_.jsx)(ts.TabsTrigger,{value:"world",children:"World"}),(0,_.jsx)(ts.TabsTrigger,{value:"experience",children:"Experience"}),(0,_.jsx)(ts.TabsTrigger,{value:"observation",children:"Observations"})]}),(0,_.jsxs)("div",{className:"mt-2",children:[(0,_.jsx)(ts.TabsContent,{value:"world",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"world",documentId:R.id,compact:!0})}),(0,_.jsx)(ts.TabsContent,{value:"experience",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"experience",documentId:R.id,compact:!0})}),(0,_.jsx)(ts.TabsContent,{value:"observation",className:"mt-0",children:(0,_.jsx)(Ph,{factType:"observation",documentId:R.id,compact:!0})})]})]}),(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsxs)(P3,{title:"Document",icon:(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),children:[R.created_at&&(0,_.jsx)(P6,{label:e("labelCreated"),value:new Date(R.created_at).toLocaleString()}),R.updated_at&&(0,_.jsx)(P6,{label:e("labelUpdated"),value:new Date(R.updated_at).toLocaleString()}),R.original_text&&(0,_.jsx)(P6,{label:e("colSize"),value:P1(new Blob([R.original_text]).size)}),(0,_.jsx)(P6,{label:e("labelTags"),value:K?(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(q.Input,{value:Q,onChange:e=>et(e.target.value),placeholder:e("tagsInputPlaceholder"),className:"text-sm h-7 w-64",onKeyDown:e=>{"Enter"===e.key&&eU(),"Escape"===e.key&&eV()},autoFocus:!0}),(0,_.jsx)(X.Button,{size:"sm",onClick:eU,disabled:en,className:"h-7 w-7 p-0",children:en?(0,_.jsx)("span",{className:"animate-spin text-xs",children:"⏳"}):(0,_.jsx)(te.Check,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:eV,disabled:en,className:"h-7 w-7 p-0",children:(0,_.jsx)(tt.X,{className:"h-3 w-3"})})]}):(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[R.tags&&R.tags.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:R.tags.map((e,t)=>(0,_.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:e},t))}):(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:"none"}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>{et((R?.tags??[]).join(", ")),Z(!0)},className:"h-6 w-6 p-0",children:(0,_.jsx)(PX,{className:"h-3 w-3"})})]})}),R.retain_params?.context&&(0,_.jsx)(P6,{label:"Context",value:R.retain_params.context}),R.retain_params?.event_date&&(0,_.jsx)(P6,{label:e("labelEventDate"),value:new Date(R.retain_params.event_date).toLocaleString()}),R.retain_params?.metadata&&Object.keys(R.retain_params.metadata).length>0&&(0,_.jsx)(P6,{label:"Metadata",value:(0,_.jsx)(P2,{metadata:R.retain_params.metadata})})]}),(0,_.jsx)(P3,{title:e("memoryCompositionTitle"),icon:(0,_.jsx)(eo,{className:"w-3.5 h-3.5"}),children:(0,_.jsx)(P7,{nodesByFactType:R.nodes_by_fact_type})}),r&&R?.id&&(0,_.jsx)(P4,{bankId:r,documentId:R.id})]})]})}),(0,_.jsxs)(ts.TabsContent,{value:"chunks",className:"mt-0",children:[!i?.store_document_text&&(0,_.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,_.jsx)(PJ.Lock,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,_.jsx)("span",{children:e("textNotStoredWarning")})]}),eN?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingChunks")})]})}):ev.length>0?(0,_.jsx)("div",{className:"rounded-lg border border-border overflow-hidden divide-y divide-border",children:ev.map(e=>(0,_.jsx)(P8,{chunk:e},e.chunk_id))}):eS?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noChunksFound")})]})}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)("div",{className:"text-center",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("clickChunksTabToLoad")})})})]})]})]}):null]})}),(0,_.jsx)(PN,{open:!!eO,onOpenChange:e=>!e&&eA(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("deleteDialogTitle")}),(0,_.jsxs)(PW,{children:[e("deleteDialogDescription")," ",(0,_.jsxs)("span",{className:"font-mono font-semibold",children:['"',eO?.id,'"']}),"?",(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),e("deleteDialogWillDelete")," ",eO?.memoryCount!==void 0?(0,_.jsx)("span",{className:"font-semibold",children:e("deleteDialogMemoryUnits",{count:eO.memoryCount})}):e("deleteDialogAllMemoryUnits")," ",e("deleteDialogExtracted"),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:e("deleteDialogCannotUndo")})]})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{children:e("cancelButton")}),(0,_.jsx)(PY,{onClick:eF,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:e("deleteButton")})]})]})}),(0,_.jsx)(PN,{open:!!eD,onOpenChange:e=>!e&&eP(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:eD?.success?e("deleteResultSuccessTitle"):e("deleteResultErrorTitle")}),(0,_.jsx)(PW,{children:eD?.message})]}),(0,_.jsx)(PH,{children:(0,_.jsx)(PY,{onClick:()=>eP(null),children:e("okButton")})})]})}),(0,_.jsx)(PN,{open:!!eT,onOpenChange:e=>!e&&eM(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:eT?.success?"Reprocessing Started":e("deleteResultErrorTitle")}),(0,_.jsx)(PW,{children:eT?.message})]}),(0,_.jsx)(PH,{children:(0,_.jsx)(PY,{onClick:()=>eM(null),children:e("okButton")})})]})})]})}function Lt(){let e=(0,M.useTranslations)("entitiesView"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(null),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)("relations"),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)(!1),[x,v]=(0,E.useState)(1),[y,b]=(0,E.useState)(0),w=Math.ceil(y/50),j=(x-1)*50,N=async(e=1)=>{if(t){a(!0);try{let n=await $.client.listEntities({bank_id:t,limit:50,offset:(e-1)*50});r(n.items||[]),b(n.total||0)}catch(e){}finally{a(!1)}}},k=async e=>{if(t){c(!0);try{let n=await $.client.getEntity(e,t);s(n)}catch(e){}finally{c(!1)}}},S=e=>{v(e),N(e)},C=(0,E.useCallback)(async()=>{if(t){g(!0);try{let e=await $.client.getEntityGraph({bank_id:t,limit:2e3,min_count:1});f(e)}catch(e){}finally{g(!1)}}},[t]);(0,E.useEffect)(()=>{t&&(v(1),N(1),s(null),f(null))},[t]),(0,E.useEffect)(()=>{"relations"!==u||!t||h||p||C()},[u,t,h,p,C]);let T=(0,E.useMemo)(()=>h?Dr(h):{nodes:[],links:[]},[h]),O=(0,E.useMemo)(()=>{let e=new Map;for(let t of T.links){let n="number"==typeof t.weight&&t.weight>0?t.weight:1;e.set(t.source,(e.get(t.source)||0)+n),e.set(t.target,(e.get(t.target)||0)+n)}return e},[T]),A=(0,E.useMemo)(()=>{let e=1;for(let t of O.values())t>e&&(e=t);return e},[O]),P=(0,E.useCallback)(e=>3+11*Math.sqrt((O.get(e.id)||0)/A),[O,A]),L=(0,E.useMemo)(()=>{let e=h?.edges||[];if(!e.length)return null;let t=new Map,n=1/0,r=-1/0;for(let i of e){let e=i.data.lastCooccurred;if(!e)continue;let a=Date.parse(e);if(!Number.isNaN(a)){for(let e of[i.data.source,i.data.target]){let n=t.get(e);(void 0===n||a>n)&&t.set(e,a)}a<n&&(n=a),a>r&&(r=a)}}return Number.isFinite(n)&&Number.isFinite(r)&&r!==n?{times:t,minT:n,maxT:r}:null},[h]),I=(0,E.useCallback)(e=>{if(!L)return .5;let t=L.times.get(e.id);return void 0===t?0:(t-L.minT)/(L.maxT-L.minT)},[L]),R=(0,E.useCallback)(e=>{k(e.id)},[t]),B=t=>t?new Date(t).toLocaleDateString():e("na");return(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"mb-4 flex items-center justify-end",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,_.jsxs)("button",{onClick:()=>d("relations"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"relations"===u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(Pu,{className:"w-4 h-4"}),e("viewRelations")]}),(0,_.jsxs)("button",{onClick:()=>d("list"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"list"===u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(es,{className:"w-4 h-4"}),e("viewList")]})]})}),"relations"===u&&(0,_.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:p?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingEntityGraph")})]})}):T.nodes.length>0?(0,_.jsx)(Pl,{data:T,height:700,onNodeClick:R,nodeSizeFn:P,nodeHeatFn:L?I:void 0,heatLegendLabel:L?e("heatLegendLabel"):void 0,heatLegendEndpoints:L?[new Date(L.minT).toISOString().slice(0,10),new Date(L.maxT).toISOString().slice(0,10)]:void 0,sizeLegendLabel:e("sizeLegendLabel"),compactLabels:!0}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noCooccurrences")}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:e("noCooccurrencesDescription")})]})})}),"list"===u&&(0,_.jsx)("div",{children:i?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("loadingEntities")})]})}):n.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"mb-4 text-sm text-muted-foreground",children:e("entityCount",{count:y})}),(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("colName")}),(0,_.jsx)(eh,{children:e("colMentions")}),(0,_.jsx)(eh,{children:e("colFirstSeen")}),(0,_.jsx)(eh,{children:e("colLastSeen")})]})}),(0,_.jsx)(eu,{children:n.map(e=>(0,_.jsxs)(ed,{onClick:()=>k(e.id),className:`cursor-pointer hover:bg-muted/50 ${o?.id===e.id?"bg-primary/10":""}`,children:[(0,_.jsx)(ef,{className:"font-medium text-card-foreground",children:e.canonical_name}),(0,_.jsx)(ef,{className:"text-card-foreground",children:e.mention_count}),(0,_.jsx)(ef,{className:"text-card-foreground",children:B(e.first_seen)}),(0,_.jsx)(ef,{className:"text-card-foreground",children:B(e.last_seen)})]},e.id))})]})}),w>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[j+1,"-",Math.min(j+50,y)," of ",y]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(1),disabled:1===x||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(x-1),disabled:1===x||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[x," / ",w]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(x+1),disabled:x===w||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(w),disabled:x===w||i,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsxs)("div",{className:"text-center",children:[(0,_.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:e("noEntitiesFound")}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:e("noEntitiesDescription")})]})})}),o&&(0,_.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,_.jsxs)("div",{className:"p-5",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:o.canonical_name}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e("entityDetails")})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>s(null),className:"h-8 w-8 p-0",children:(0,_.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,_.jsxs)("div",{className:"space-y-5",children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("mentionsLabel")}),(0,_.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:o.mention_count})]}),(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("firstSeenLabel")}),(0,_.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:B(o.first_seen)})]})]}),(0,_.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,_.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:e("entityIdLabel")}),(0,_.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:o.id})]})]})]})})]})}let Ln=["world","experience","observation"],Lr={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 Li({ft:e,active:t,onToggle:n}){let r=(0,M.useTranslations)("factTypeFilter"),i=Lr[e];return(0,_.jsxs)("button",{type:"button",onClick:n,className:(0,W.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-all",t?i.active:i.inactive),children:[(0,_.jsx)("span",{className:(0,W.cn)("h-1.5 w-1.5 rounded-full",t?i.dot:"bg-muted-foreground/50")}),r(e)]})}function La({value:e,onChange:t,label:n}){let r=(0,M.useTranslations)("factTypeFilter"),i=n??r("defaultLabel");return(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[i&&(0,_.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:i}),(0,_.jsx)("div",{className:"flex gap-1.5",children:Ln.map(n=>(0,_.jsx)(Li,{ft:n,active:e.includes(n),onToggle:()=>t(e.includes(n)?e.filter(e=>e!==n):[...e,n])},n))})]})}function Lo({value:e,onChange:t}){return(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:Ln.map(n=>(0,_.jsx)(Li,{ft:n,active:e.includes(n),onToggle:()=>t(e.includes(n)?e.filter(e=>e!==n):[...e,n])},n))})}var Ls=e.i(52571);let Ll=(0,I.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"}]]),Lc=(0,I.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"}]]),Lu=(0,I.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"}]]),Ld=(0,I.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 Lh=e.i(1864);"function"==typeof SuppressedError&&SuppressedError;var Lf=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach(function(t){e.addRange(t)}),t&&t.focus()}},Lp={"text/plain":"Text","text/html":"Url",default:"Text"},Lm=function(e,t){var n,r,i,a,o,s,l,c,u=!1;t||(t={}),i=t.debug||!1;try{if(o=Lf(),s=document.createRange(),l=document.getSelection(),(c=document.createElement("span")).textContent=e,c.ariaHidden="true",c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),void 0===n.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var r=Lp[t.format]||Lp.default;window.clipboardData.setData(r,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(c),s.selectNodeContents(c),l.addRange(s),!document.execCommand("copy"))throw Error("copy command was unsuccessful");u=!0}catch(o){i&&console.error("unable to copy using execCommand: ",o),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(o){i&&console.error("unable to copy using clipboardData: ",o),i&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",r=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",a=n.replace(/#{\s*key\s*}/g,r),window.prompt(a,e)}}finally{l&&("function"==typeof l.removeRange?l.removeRange(s):l.removeAllRanges()),c&&document.body.removeChild(c),o()}return u};function Lg(e){return"[object Object]"===Object.prototype.toString.call(e)}function Lx(e){return Array.isArray(e)?e.length:Lg(e)?Object.keys(e).length:0}function Lv(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Lx(e);if("function"==typeof r){let i=Lw(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||Lg(e)&&o>i)}function Ly(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Math.ceil(e.length/100);if("function"==typeof r){let i=Lw(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||Lg(e)&&o>i)}function Lb(e,t,n){return"boolean"==typeof e?e:"number"==typeof e&&!!(t>e)||"collapsed"===e&&!!n||"expanded"===e&&!n}function Lw(e,t){try{return e(...t)}catch(e){reportError(e)}}function Lj(e){if(!0===e||Lg(e)&&!0===e.add)return!0}function LN(e){if(!0===e||Lg(e)&&!0===e.edit)return!0}function Lk(e){if(!0===e||Lg(e)&&!0===e.delete)return!0}function LS(e){return!e||void 0===e.add||!!e.add}function LC(e){return!e||void 0===e.edit||!!e.edit}function L_(e){return!e||void 0===e.delete||!!e.delete}function LE(e){return!e||void 0===e.enableClipboard||!!e.enableClipboard}function LT(){return(LT=Object.assign.bind()).apply(this,arguments)}var LM=function(e){return E.createElement("svg",LT({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),d||(d=E.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 LO(){return(LO=Object.assign.bind()).apply(this,arguments)}var LA=function(e){return E.createElement("svg",LO({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),h||(h=E.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 LD(){return(LD=Object.assign.bind()).apply(this,arguments)}var LP=function(e){return E.createElement("svg",LD({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),f||(f=E.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=E.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 LL({node:e,nodeMeta:t}){let{customizeCopy:n,CopyComponent:r,CopiedComponent:i}=(0,E.useContext)(L1),[a,o]=(0,E.useState)(!1),s=r=>{r.stopPropagation();let i=n(e,t);"string"==typeof i&&i&&function(e){var t,n,r,i;t=this,n=void 0,r=void 0,i=function*(){try{yield navigator.clipboard.writeText(e)}catch(t){Lm(e)}},new(r||(r=Promise))(function(e,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(t){var n;t.done?e(t.value):((n=t.value)instanceof r?n:new r(function(e){e(n)})).then(o,s)}l((i=i.apply(t,n||[])).next())})}(i),o(!0),setTimeout(()=>o(!1),3e3)};return a?"function"==typeof i?(0,_.jsx)(i,{className:"json-view--copy",style:{display:"inline-block"}}):(0,_.jsx)(LP,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof r?(0,_.jsx)(r,{onClick:s,className:"json-view--copy"}):(0,_.jsx)(LA,{onClick:s,className:"json-view--copy"})}function LI({indexOrName:e,value:t,depth:n,deleteHandle:r,editHandle:i,parent:a,parentPath:o}){let{displayArrayIndex:s}=(0,E.useContext)(L1),l=Array.isArray(a);return(0,_.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!l||l&&s?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",Object.assign({className:"number"==typeof e?"json-view--index":"json-view--property"},{children:e})),":"," "]}):(0,_.jsx)(_.Fragment,{}),(0,_.jsx)(LJ,{node:t,depth:n+1,deleteHandle:(e,t)=>r(e,t),editHandle:(e,t,n,r)=>i(e,t,n,r),parent:a,indexOrName:e,parentPath:o})]}))}function LR(){return(LR=Object.assign.bind()).apply(this,arguments)}var LB=function(e){return E.createElement("svg",LR({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),g||(g=E.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"})),x||(x=E.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 Lz(){return(Lz=Object.assign.bind()).apply(this,arguments)}var LF=function(e){return E.createElement("svg",Lz({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),v||(v=E.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"})),y||(y=E.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 LV(){return(LV=Object.assign.bind()).apply(this,arguments)}var LH=function(e){return E.createElement("svg",LV({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),b||(b=E.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"})),w||(w=E.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 LU(){return(LU=Object.assign.bind()).apply(this,arguments)}var LW=function(e){return E.createElement("svg",LU({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),j||(j=E.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"})),N||(N=E.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 LY({originNode:e,node:t,depth:n,index:r,deleteHandle:i,customOptions:a,startIndex:o,parent:s,parentPath:l}){let{enableClipboard:c,src:u,onEdit:d,onChange:h,forceUpdate:f,displaySize:p,CustomOperation:g}=(0,E.useContext)(L1),x=[...l,String(r)],[v,y]=(0,E.useState)(!0),b=(0,E.useCallback)((t,r,i)=>{e[t]=r,d&&d({newValue:r,oldValue:i,depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),h&&h({type:"edit",depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),f()},[t,d,h,f]),w=t=>{e.splice(t,1),i&&i(t,l),f()},j=(0,_.jsxs)(_.Fragment,{children:[!v&&(0,_.jsxs)("span",Object.assign({onClick:()=>y(!0),className:"jv-size-chevron"},{children:[Lb(p,n,v)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[Lx(t)," Items"]})),(0,_.jsx)(LM,{className:"jv-chevron"})]})),!v&&c&&LE(a)&&(0,_.jsx)(LL,{node:t,nodeMeta:{depth:n,indexOrName:r,parent:s,parentPath:l,currentPath:x}}),"function"==typeof g?(0,_.jsx)(g,{node:t}):null]});return(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{children:"["}),j,v?(0,_.jsxs)("button",Object.assign({onClick:()=>y(!1),className:"jv-button"},{children:[o," ... ",o+t.length-1]})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:t.map((e,i)=>(0,_.jsx)(LI,{indexOrName:i+o,value:e,depth:n,parent:t,deleteHandle:w,editHandle:b,parentPath:l},String(r)+String(i)))})),(0,_.jsx)("span",{children:"]"})]})}function LG({node:e,depth:t,deleteHandle:n,indexOrName:r,customOptions:i,parent:a,parentPath:o}){let s=void 0!==r?[...o,String(r)]:o,l=[];for(let t=0;t<e.length;t+=100)l.push(e.slice(t,t+100));let{collapsed:c,enableClipboard:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,CustomOperation:x,onChange:v,forceUpdate:y,displaySize:b}=(0,E.useContext)(L1),[w,j]=(0,E.useState)(Ly(e,t,r,c,d,i));(0,E.useEffect)(()=>{j(Ly(e,t,r,c,d,i))},[c,d]);let[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),T=()=>{e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),v&&v({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:o}),y()},M=N||S,O=(0,_.jsxs)(_.Fragment,{children:[!w&&!M&&(0,_.jsxs)("span",Object.assign({onClick:()=>j(!0),className:"jv-size-chevron"},{children:[Lb(b,t,w)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[e.length," Items"]})),(0,_.jsx)(LM,{className:"jv-chevron"})]})),M&&(0,_.jsx)(LH,{className:"json-view--edit",style:{display:"inline-block"},onClick:S?T:()=>{k(!1),n&&n(r,o),f&&f({value:e,depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o}),v&&v({type:"delete",depth:t,src:p,indexOrName:r,parentType:"array",parentPath:o})}}),M&&(0,_.jsx)(LW,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{k(!1),C(!1)}}),!w&&!M&&u&&LE(i)&&(0,_.jsx)(LL,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:a,parentPath:o,currentPath:s}}),!w&&!M&&Lj(h)&&LS(i)&&(0,_.jsx)(LF,{className:"json-view--edit",onClick:()=>{T()}}),!w&&!M&&Lk(h)&&L_(i)&&n&&(0,_.jsx)(LB,{className:"json-view--edit",onClick:()=>k(!0)}),"function"==typeof x?(0,_.jsx)(x,{node:e}):null]});return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"["}),O,w?(0,_.jsx)("button",Object.assign({onClick:()=>j(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:l.map((a,s)=>(0,_.jsx)(LY,{originNode:e,node:a,depth:t,index:s,startIndex:100*s,deleteHandle:n,customOptions:i,parentPath:o},String(r)+String(s)))})),(0,_.jsx)("span",{children:"]"}),w&&Lb(b,t,w)&&(0,_.jsxs)("span",Object.assign({onClick:()=>j(!1),className:"jv-size"},{children:[e.length," Items"]}))]})}function L$({node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parent:a,parentPath:o}){let{collapsed:s,onCollapse:l,enableClipboard:c,ignoreLargeArray:u,collapseObjectsAfterLength:d,editable:h,onDelete:f,src:p,onAdd:g,onEdit:x,onChange:v,forceUpdate:y,displaySize:b,CustomOperation:w}=(0,E.useContext)(L1),j=void 0!==n?[...o,String(n)]:o;if(!u&&Array.isArray(e)&&e.length>100)return(0,_.jsx)(LG,{node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parentPath:j});let N=Lg(e),[k,S]=(0,E.useState)(Lv(e,t,n,s,d,i)),C=r=>{null==l||l({isCollapsing:!r,node:e,depth:t,indexOrName:n}),S(r)};(0,E.useEffect)(()=>{C(Lv(e,t,n,s,d,i))},[s,d]);let T=(0,E.useCallback)((n,r,i)=>{Array.isArray(e)?e[+n]=r:e&&(e[n]=r),x&&x({newValue:r,oldValue:i,depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),v&&v({type:"edit",depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),y()},[e,x,v,y]),M=t=>{Array.isArray(e)?e.splice(+t,1):e&&delete e[t],y()},[O,A]=(0,E.useState)(!1),[D,P]=(0,E.useState)(!1),L=(0,E.useRef)(null),I=()=>{var n;if(N){let r=null==(n=L.current)?void 0:n.value;r&&(e[r]=null,L.current&&(L.current.value=""),P(!1),g&&g({indexOrName:r,depth:t,src:p,parentType:"object",parentPath:j}),v&&v({type:"add",indexOrName:r,depth:t,src:p,parentType:"object",parentPath:j}))}else Array.isArray(e)&&(e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:j}),v&&v({type:"add",indexOrName:e.length-1,depth:t,src:p,parentType:"array",parentPath:j}));y()},R=O||D,B=()=>{A(!1),P(!1)},z=(0,_.jsxs)(_.Fragment,{children:[!k&&!R&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!0),className:"jv-size-chevron"},{children:[Lb(b,t,k)&&(0,_.jsxs)("span",Object.assign({className:"jv-size"},{children:[Lx(e)," Items"]})),(0,_.jsx)(LM,{className:"jv-chevron"})]})),D&&N&&(0,_.jsx)("input",{className:"json-view--input",placeholder:"property",ref:L,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),I()):"Escape"===e.key&&B()}}),R&&(0,_.jsx)(LH,{className:"json-view--edit",style:{display:"inline-block"},onClick:D?I:()=>{A(!1),r&&r(n,j),f&&f({value:e,depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j}),v&&v({type:"delete",depth:t,src:p,indexOrName:n,parentType:N?"object":"array",parentPath:j})}}),R&&(0,_.jsx)(LW,{className:"json-view--edit",style:{display:"inline-block"},onClick:B}),!k&&!R&&c&&LE(i)&&(0,_.jsx)(LL,{node:e,nodeMeta:{depth:t,indexOrName:n,parent:a,parentPath:o,currentPath:j}}),!k&&!R&&Lj(h)&&LS(i)&&(0,_.jsx)(LF,{className:"json-view--edit",onClick:()=>{N?(P(!0),setTimeout(()=>{var e;return null==(e=L.current)?void 0:e.focus()})):I()}}),!k&&!R&&Lk(h)&&L_(i)&&r&&(0,_.jsx)(LB,{className:"json-view--edit",onClick:()=>A(!0)}),"function"==typeof w?(0,_.jsx)(w,{node:e}):null]});return Array.isArray(e)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"["}),z,k?(0,_.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:e.map((r,i)=>(0,_.jsx)(LI,{indexOrName:i,value:r,depth:t,parent:e,deleteHandle:M,editHandle:T,parentPath:j},String(n)+String(i)))})),(0,_.jsx)("span",{children:"]"}),k&&Lb(b,t,k)&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[Lx(e)," Items"]}))]}):N?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:"{"}),z,k?(0,_.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,_.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(e).map(([r,i])=>(0,_.jsx)(LI,{indexOrName:r,value:i,depth:t,parent:e,deleteHandle:M,editHandle:T,parentPath:j},String(n)+String(r)))})),(0,_.jsx)("span",{children:"}"}),k&&Lb(b,t,k)&&(0,_.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[Lx(e)," Items"]}))]}):(0,_.jsx)("span",{children:String(e)})}let LX=E.default.forwardRef(({str:e,className:t,ctrlClick:n},r)=>{let{collapseStringMode:i,collapseStringsAfterLength:a,customizeCollapseStringUI:o}=(0,E.useContext)(L1),[s,l]=(0,E.useState)(!0),c=(0,E.useRef)(null);a=a>0?a:0;let u=e.replace(/\s+/g," "),d="function"==typeof o?o(u,s):"string"==typeof o?o:"...",h=e=>{var t;if((e.ctrlKey||e.metaKey)&&n)n(e);else{let e=window.getSelection();if(e&&e.anchorOffset!==e.focusOffset&&(null==(t=e.anchorNode)?void 0:t.parentElement)===c.current)return;l(!s)}};if(e.length<=a)return(0,_.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']}));if("address"===i)return e.length<=10?(0,_.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']})):(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,6),d,u.slice(-4)]:e,'"']}));if("directly"===i)return(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,a),d]:e,'"']}));if("word"===i){let n=a,r=a+1,i=u,o=1;for(;;){if(/\W/.test(e[n])){i=e.slice(0,n);break}if(/\W/.test(e[r])){i=e.slice(0,r);break}if(6===o){i=e.slice(0,a);break}o++,n--,r++}return(0,_.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[i,d]:e,'"']}))}return(0,_.jsxs)("span",Object.assign({ref:c,className:t},{children:['"',e,'"']}))});function Lq(){return(Lq=Object.assign.bind()).apply(this,arguments)}var LK=function(e){return E.createElement("svg",Lq({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),k||(k=E.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 LZ(){return(LZ=Object.assign.bind()).apply(this,arguments)}var LQ=function(e){return E.createElement("svg",LZ({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),S||(S=E.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"})),C||(C=E.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 LJ({node:e,depth:t,deleteHandle:n,indexOrName:r,parent:i,editHandle:a,parentPath:o}){let s,{collapseStringsAfterLength:l,enableClipboard:c,editable:u,src:d,onDelete:h,onChange:f,customizeNode:p,matchesURL:g,urlRegExp:x,EditComponent:v,DoneComponent:y,CancelComponent:b,CustomOperation:w}=(0,E.useContext)(L1);if("function"==typeof p&&(s=Lw(p,[{node:e,depth:t,indexOrName:r}])),s){if((0,E.isValidElement)(s))return s;else if("function"==typeof s){let n=s;return(0,_.jsx)(n,{node:e,depth:t,indexOrName:r})}}if(Array.isArray(e)||Lg(e))return(0,_.jsx)(L$,{parent:i,node:e,depth:t,indexOrName:r,deleteHandle:n,parentPath:o,customOptions:"object"==typeof s?s:void 0});{var j;let p=typeof e,N=void 0!==r?[...o,String(r)]:o,[k,S]=(0,E.useState)(!1),[C,T]=(0,E.useState)(!1),M=(0,E.useRef)(null),O=()=>{S(!0),setTimeout(()=>{var e,t;null==(e=window.getSelection())||e.selectAllChildren(M.current),null==(t=M.current)||t.focus()})},A=(0,E.useCallback)(()=>{let t=M.current.innerText;try{let n=JSON.parse(t);a&&a(r,n,e,o)}catch(i){let n="string"===p?t.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):t;a&&a(r,n,e,o)}S(!1)},[a,r,e,o,p]),D=()=>{S(!1),T(!1)},P=()=>{T(!1),n&&n(r,o),h&&h({value:e,depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",parentPath:o}),f&&f({depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",type:"delete",parentPath:o})},L=(0,E.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),A()):"Escape"===e.key&&D()},[A]),I=k||C,R=!I&&LN(u)&&LC(s)&&a?e=>{(e.ctrlKey||e.metaKey)&&O()}:void 0,B=(0,_.jsxs)(_.Fragment,{children:[I&&("function"==typeof y?(0,_.jsx)(y,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A}):(0,_.jsx)(LH,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A})),I&&("function"==typeof b?(0,_.jsx)(b,{className:"json-view--edit",style:{display:"inline-block"},onClick:D}):(0,_.jsx)(LW,{className:"json-view--edit",style:{display:"inline-block"},onClick:D})),!I&&c&&LE(s)&&(0,_.jsx)(LL,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:i,parentPath:o,currentPath:N}}),!I&&g&&"string"===p&&x.test(e)&&(!(j=s)||void 0===j.matchesURL||!!j.matchesURL)&&(0,_.jsx)("a",Object.assign({href:e,target:"_blank",className:"json-view--link"},{children:(0,_.jsx)(LQ,{})})),!I&&LN(u)&&LC(s)&&a&&("function"==typeof v?(0,_.jsx)(v,{className:"json-view--edit",onClick:O}):(0,_.jsx)(LK,{className:"json-view--edit",onClick:O})),!I&&Lk(u)&&L_(s)&&n&&(0,_.jsx)(LB,{className:"json-view--edit",onClick:()=>T(!0)}),"function"==typeof w?(0,_.jsx)(w,{node:e}):null]}),z="json-view--string";switch(p){case"number":case"bigint":z="json-view--number";break;case"boolean":z="json-view--boolean";break;case"object":z="json-view--null"}"string"==typeof(null==s?void 0:s.className)&&(z+=" "+s.className),C&&(z+=" json-view--deleting");let F=String(e);"bigint"===p&&(F+="n");let V=(0,E.useMemo)(()=>(0,_.jsx)("span",{contentEditable:!0,className:z,dangerouslySetInnerHTML:{__html:"string"===p?`"${F}"`:F},ref:M,onKeyDown:L}),[F,p,L]);return"string"===p?(0,_.jsxs)(_.Fragment,{children:[k?V:e.length>l?(0,_.jsx)(LX,{str:e,ref:M,className:z,ctrlClick:R}):(0,_.jsxs)("span",Object.assign({className:z,onClick:R},{children:['"',F,'"']})),B]}):(0,_.jsxs)(_.Fragment,{children:[k?V:(0,_.jsx)("span",Object.assign({className:z,onClick:R},{children:F})),B]})}}let L0=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,L1=(0,E.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:L0,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function L2({src:e,collapseStringsAfterLength:t=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:i=99,collapsed:a,onCollapse:o,enableClipboard:s=!0,editable:l=!1,onEdit:c,onDelete:u,onAdd:d,onChange:h,dark:f=!1,theme:p="default",customizeNode:g,customizeCopy:x=e=>(function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,(e,t)=>{switch(typeof t){case"bigint":return String(t)+"n";case"number":case"boolean":case"object":case"string":return t;default:return String(t)}},void 0)}catch(e){return`${e.name}: ${e.message}`||"JSON.stringify failed"}})(e),displaySize:v,displayArrayIndex:y=!0,style:b,className:w,matchesURL:j=!1,urlRegExp:N=L0,ignoreLargeArray:k=!1,CopyComponent:S,CopiedComponent:C,EditComponent:T,CancelComponent:M,DoneComponent:O,CustomOperation:A}){let[D,P]=(0,E.useState)(0),L=(0,E.useCallback)(()=>P(e=>++e),[]),[I,R]=(0,E.useState)(e);return(0,E.useEffect)(()=>R(e),[e]),(0,_.jsx)(L1.Provider,Object.assign({value:{src:I,collapseStringsAfterLength:t,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:i,collapsed:a,onCollapse:o,enableClipboard:s,editable:l,onEdit:c,onDelete:u,onAdd:d,onChange:h,forceUpdate:L,customizeNode:g,customizeCopy:x,displaySize:v,displayArrayIndex:y,matchesURL:j,urlRegExp:N,ignoreLargeArray:k,CopyComponent:S,CopiedComponent:C,EditComponent:T,CancelComponent:M,DoneComponent:O,CustomOperation:A}},{children:(0,_.jsx)("code",Object.assign({className:"json-view"+(f?" dark":"")+(p&&"default"!==p?" json-view_"+p:"")+(w?" "+w:""),style:b},{children:(0,_.jsx)(LJ,{node:I,depth:1,editHandle:(e,t,n,r)=>{R(t),c&&c({newValue:t,oldValue:n,depth:1,src:I,indexOrName:e,parentType:null,parentPath:r}),h&&h({type:"edit",depth:1,src:I,indexOrName:e,parentType:null,parentPath:r})},deleteHandle:(e,t)=>{R(void 0),u&&u({value:I,depth:1,src:I,indexOrName:e,parentType:null,parentPath:t}),h&&h({depth:1,src:I,indexOrName:e,parentType:null,type:"delete",parentPath:t})},parentPath:[]})}))}))}var tn=tn;let L5=(0,I.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"}]]),L3=(0,I.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 L4(){}function L6(){}let L7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L9=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L8={};function Ie(e,t){return((t||L8).jsx?L9:L7).test(e)}let It=/[ \t\n\f\r]/g;function In(e){return""===e.replace(It,"")}class Ir{constructor(e,t){this.attribute=t,this.property=e}}Ir.prototype.attribute="",Ir.prototype.booleanish=!1,Ir.prototype.boolean=!1,Ir.prototype.commaOrSpaceSeparated=!1,Ir.prototype.commaSeparated=!1,Ir.prototype.defined=!1,Ir.prototype.mustUseProperty=!1,Ir.prototype.number=!1,Ir.prototype.overloadedBoolean=!1,Ir.prototype.property="",Ir.prototype.spaceSeparated=!1,Ir.prototype.space=void 0;let Ii=0,Ia=Ih(),Io=Ih(),Is=Ih(),Il=Ih(),Ic=Ih(),Iu=Ih(),Id=Ih();function Ih(){return 2**++Ii}e.s(["boolean",0,Ia,"booleanish",0,Io,"commaOrSpaceSeparated",0,Id,"commaSeparated",0,Iu,"number",0,Il,"overloadedBoolean",0,Is,"spaceSeparated",0,Ic],744);var If=e.i(744);let Ip=Object.keys(If);class Im extends Ir{constructor(e,t,n,r){let i=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++i<Ip.length;){const e=Ip[i];!function(e,t,n){n&&(e[t]=n)}(this,Ip[i],(n&If[e])===If[e])}}}function Ig(e){return e.toLowerCase()}Im.prototype.defined=!0;let Ix=/[A-Z]/g,Iv=/-[a-z]/g,Iy=/^data[-\w.:]+$/i;function Ib(e){return"-"+e.toLowerCase()}function Iw(e){return e.charAt(1).toUpperCase()}let Ij={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 IN{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Ik(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new IN(n,r,t)}function IS(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Im(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ig(r)]=r,n[Ig(a.attribute)]=r}return new IN(t,n,e.space)}IN.prototype.normal={},IN.prototype.property={},IN.prototype.space=void 0;let IC=IS({properties:{ariaActiveDescendant:null,ariaAtomic:Io,ariaAutoComplete:null,ariaBusy:Io,ariaChecked:Io,ariaColCount:Il,ariaColIndex:Il,ariaColSpan:Il,ariaControls:Ic,ariaCurrent:null,ariaDescribedBy:Ic,ariaDetails:null,ariaDisabled:Io,ariaDropEffect:Ic,ariaErrorMessage:null,ariaExpanded:Io,ariaFlowTo:Ic,ariaGrabbed:Io,ariaHasPopup:null,ariaHidden:Io,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ic,ariaLevel:Il,ariaLive:null,ariaModal:Io,ariaMultiLine:Io,ariaMultiSelectable:Io,ariaOrientation:null,ariaOwns:Ic,ariaPlaceholder:null,ariaPosInSet:Il,ariaPressed:Io,ariaReadOnly:Io,ariaRelevant:null,ariaRequired:Io,ariaRoleDescription:Ic,ariaRowCount:Il,ariaRowIndex:Il,ariaRowSpan:Il,ariaSelected:Io,ariaSetSize:Il,ariaSort:null,ariaValueMax:Il,ariaValueMin:Il,ariaValueNow:Il,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function I_(e,t){return t in e?e[t]:t}function IE(e,t){return I_(e,t.toLowerCase())}let IT=IS({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Iu,acceptCharset:Ic,accessKey:Ic,action:null,allow:null,allowFullScreen:Ia,allowPaymentRequest:Ia,allowUserMedia:Ia,alt:null,as:null,async:Ia,autoCapitalize:null,autoComplete:Ic,autoFocus:Ia,autoPlay:Ia,blocking:Ic,capture:null,charSet:null,checked:Ia,cite:null,className:Ic,cols:Il,colSpan:null,content:null,contentEditable:Io,controls:Ia,controlsList:Ic,coords:Il|Iu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ia,defer:Ia,dir:null,dirName:null,disabled:Ia,download:Is,draggable:Io,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ia,formTarget:null,headers:Ic,height:Il,hidden:Is,high:Il,href:null,hrefLang:null,htmlFor:Ic,httpEquiv:Ic,id:null,imageSizes:null,imageSrcSet:null,inert:Ia,inputMode:null,integrity:null,is:null,isMap:Ia,itemId:null,itemProp:Ic,itemRef:Ic,itemScope:Ia,itemType:Ic,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ia,low:Il,manifest:null,max:null,maxLength:Il,media:null,method:null,min:null,minLength:Il,multiple:Ia,muted:Ia,name:null,nonce:null,noModule:Ia,noValidate:Ia,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:Ia,optimum:Il,pattern:null,ping:Ic,placeholder:null,playsInline:Ia,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ia,referrerPolicy:null,rel:Ic,required:Ia,reversed:Ia,rows:Il,rowSpan:Il,sandbox:Ic,scope:null,scoped:Ia,seamless:Ia,selected:Ia,shadowRootClonable:Ia,shadowRootDelegatesFocus:Ia,shadowRootMode:null,shape:null,size:Il,sizes:null,slot:null,span:Il,spellCheck:Io,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Il,step:null,style:null,tabIndex:Il,target:null,title:null,translate:null,type:null,typeMustMatch:Ia,useMap:null,value:Io,width:Il,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ic,axis:null,background:null,bgColor:null,border:Il,borderColor:null,bottomMargin:Il,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ia,declare:Ia,event:null,face:null,frame:null,frameBorder:null,hSpace:Il,leftMargin:Il,link:null,longDesc:null,lowSrc:null,marginHeight:Il,marginWidth:Il,noResize:Ia,noHref:Ia,noShade:Ia,noWrap:Ia,object:null,profile:null,prompt:null,rev:null,rightMargin:Il,rules:null,scheme:null,scrolling:Io,standby:null,summary:null,text:null,topMargin:Il,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Il,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ia,disableRemotePlayback:Ia,prefix:null,property:null,results:Il,security:null,unselectable:null},space:"html",transform:IE}),IM=IS({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:Id,accentHeight:Il,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Il,amplitude:Il,arabicForm:null,ascent:Il,attributeName:null,attributeType:null,azimuth:Il,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Il,by:null,calcMode:null,capHeight:Il,className:Ic,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:Il,diffuseConstant:Il,direction:null,display:null,dur:null,divisor:Il,dominantBaseline:null,download:Ia,dx:null,dy:null,edgeMode:null,editable:null,elevation:Il,enableBackground:null,end:null,event:null,exponent:Il,externalResourcesRequired:null,fill:null,fillOpacity:Il,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:Iu,g2:Iu,glyphName:Iu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Il,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Il,horizOriginX:Il,horizOriginY:Il,id:null,ideographic:Il,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Il,k:Il,k1:Il,k2:Il,k3:Il,k4:Il,kernelMatrix:Id,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Il,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:Il,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:Il,overlineThickness:Il,paintOrder:null,panose1:null,path:null,pathLength:Il,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ic,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Il,pointsAtY:Il,pointsAtZ:Il,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Id,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Id,rev:Id,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Id,requiredFeatures:Id,requiredFonts:Id,requiredFormats:Id,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:Il,specularExponent:Il,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Il,strikethroughThickness:Il,string:null,stroke:null,strokeDashArray:Id,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Il,strokeOpacity:Il,strokeWidth:null,style:null,surfaceScale:Il,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Id,tabIndex:Il,tableValues:null,target:null,targetX:Il,targetY:Il,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Id,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Il,underlineThickness:Il,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Il,values:null,vAlphabetic:Il,vMathematical:Il,vectorEffect:null,vHanging:Il,vIdeographic:Il,version:null,vertAdvY:Il,vertOriginX:Il,vertOriginY:Il,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Il,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:I_}),IO=IS({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),IA=IS({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:IE}),ID=IS({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),IP=Ik([IC,IT,IO,IA,ID],"html"),IL=Ik([IC,IM,IO,IA,ID],"svg");var II=e.i(15511);let IR=Iz("end"),IB=Iz("start");function Iz(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function IF(e){return e&&"object"==typeof e?"position"in e||"type"in e?IH(e.position):"start"in e||"end"in e?IH(e):"line"in e||"column"in e?IV(e):"":""}function IV(e){return IU(e&&e.line)+":"+IU(e&&e.column)}function IH(e){return IV(e&&e.start)+"-"+IV(e&&e.end)}function IU(e){return e&&"number"==typeof e?e:1}class IW extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},a=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=IF(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}IW.prototype.file="",IW.prototype.name="",IW.prototype.reason="",IW.prototype.message="",IW.prototype.stack="",IW.prototype.column=void 0,IW.prototype.line=void 0,IW.prototype.ancestors=void 0,IW.prototype.cause=void 0,IW.prototype.fatal=void 0,IW.prototype.place=void 0,IW.prototype.ruleId=void 0,IW.prototype.source=void 0;let IY={}.hasOwnProperty,IG=new Map,I$=/[A-Z]/g,IX=new Set(["table","tbody","thead","tfoot","tr"]),Iq=new Set(["td","th"]),IK="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function IZ(e,t,n){var r,i,a,o,s,l,c,u,d;let h,f,p,g,x,v,y,b,w,j,N;return"element"===t.type?(r=e,i=t,a=n,f=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=IL),r.ancestors.push(i),p=I1(r,i.tagName,!1),g=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&IY.call(t.properties,r)){let a=function(e,t,n){let r=function(e,t){let n=Ig(t),r=t,i=Ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Iy.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(Iv,Iw);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Iv.test(e)){let n=e.replace(Ix,Ib);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=Im}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,II.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new IW("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=IK+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)IY.call(e,t)&&(n[function(e){let t=e.replace(I$,I5);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Ij[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(a){let[r,o]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof o&&Iq.has(t.tagName)?n=o:i[r]=o}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),x=I0(r,i),IX.has(i.tagName)&&(x=x.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&In(e.value):In(e))})),IQ(r,g,p,i),IJ(g,x),r.ancestors.pop(),r.schema=h,r.create(i,p,g,a)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return L4("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}I2(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(o=e,s=t,l=n,y=v=o.schema,"svg"===s.name&&"html"===v.space&&(o.schema=IL),o.ancestors.push(s),b=null===s.name?o.Fragment:I1(o,s.name,!0),w=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];L4("ExpressionStatement"===t.type);let i=t.expression;L4("ObjectExpression"===i.type);let a=i.properties[0];L4("SpreadElement"===a.type),Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else I2(e,t.position);else{let i,a=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];L4("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else I2(e,t.position);else i=null===r.value||r.value;n[a]=i}return n}(o,s),j=I0(o,s),IQ(o,w,b,s),IJ(w,j),o.ancestors.pop(),o.schema=v,o.create(s,b,w,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);I2(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=n,IJ(N={},I0(c,u)),c.create(u,c.Fragment,N,d)):"text"===t.type?t.value:void 0}function IQ(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function IJ(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function I0(e,t){let n=[],r=-1,i=e.passKeys?new Map:IG;for(;++r<t.children.length;){let a,o=t.children[r];if(e.passKeys){let e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){let t=i.get(e)||0;a=e+"-"+t,i.set(e,t+1)}}let s=IZ(e,o,a);void 0!==s&&n.push(s)}return n}function I1(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=Ie(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}L4(e,"always a result"),r=e}else r=Ie(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return IY.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);I2(e)}function I2(e,t){let n=new IW("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=IK+"#cannot-handle-mdx-estrees-without-createevaluater",n}function I5(e){return"-"+e.toLowerCase()}let I3={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"]},I4={};function I6(e,t){let n=t||I4;return I7(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function I7(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return I9(e.children,t,n)}return Array.isArray(e)?I9(e,t,n):""}function I9(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=I7(e[i],t,n);return r.join("")}function I8(e,t,n,r){let i,a=e.length,o=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)(i=r.slice(o,o+1e4)).unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function Re(e,t){return e.length>0?(I8(e,e.length,0,t),e):t}let Rt={}.hasOwnProperty;function Rn(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(Rt.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];if(a)for(r in a){Rt.call(i,r)||(i[r]=[]);let e=a[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);I8(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}function Rr(e){return null!==e&&e<-2}function Ri(e){return -2===e||-1===e||32===e}function Ra(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Ro(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return Ri(r)?(e.enter(n),function r(o){return Ri(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Ra(/[A-Za-z]/),Ra(/[\dA-Za-z]/),Ra(/[#-'*+\--9=?A-Z^-~]/),Ra(/\d/),Ra(/[\dA-Fa-f]/),Ra(/[!-/:-@[-`{-~]/),Ra(/\p{P}|\p{S}/u),Ra(/\s/);let Rs={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Ro(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return Rr(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},Rl={tokenize:function(e){let t,n,r,i=this,a=[],o=0;return s;function s(t){if(o<a.length){let n=a[o];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(o++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&v();let r=i.events.length,a=r;for(;a--;)if("exit"===i.events[a][0]&&"chunkFlow"===i.events[a][1].type){n=i.events[a][1].end;break}x(o);let s=r;for(;s<i.events.length;)i.events[s][1].end={...n},s++;return I8(i.events,a+1,0,i.events.slice(r)),i.events.length=s,c(e)}return s(e)}function c(n){if(o===a.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return p(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(Rc,u,d)(n)}function u(e){return t&&v(),x(o),h(e)}function d(e){return i.parser.lazy[i.now().line]=o!==a.length,r=i.now().offset,p(e)}function h(t){return i.containerState={},e.attempt(Rc,f,p)(t)}function f(e){return o++,a.push([i.currentConstruct,i.containerState]),h(e)}function p(r){if(null===r){t&&v(),x(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){g(e.exit("chunkFlow"),!0),x(0),e.consume(n);return}return Rr(n)?(e.consume(n),g(e.exit("chunkFlow")),o=0,i.interrupt=void 0,s):(e.consume(n),t)}(r)}function g(e,a){let s=i.sliceStream(e);if(a&&s.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(s),i.parser.lazy[e.start.line]){let e,n,a=t.events.length;for(;a--;)if(t.events[a][1].start.offset<r&&(!t.events[a][1].end||t.events[a][1].end.offset>r))return;let s=i.events.length,l=s;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(x(o),a=s;a<i.events.length;)i.events[a][1].end={...n},a++;I8(i.events,l+1,0,i.events.slice(s)),i.events.length=a}}function x(t){let n=a.length;for(;n-- >t;){let t=a[n];i.containerState=t[1],t[0].exit.call(i,e)}a.length=t}function v(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},Rc={tokenize:function(e,t,n){return Ro(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},Ru=Ry(/[A-Za-z]/),Rd=Ry(/[\dA-Za-z]/),Rh=Ry(/[#-'*+\--9=?A-Z^-~]/),Rf=Ry(/\d/),Rp=Ry(/[\dA-Fa-f]/),Rm=Ry(/[!-/:-@[-`{-~]/);function Rg(e){return null!==e&&e<-2}function Rx(e){return null!==e&&(e<0||32===e)}function Rv(e){return -2===e||-1===e||32===e}function Ry(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Rb(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return Rv(r)?(e.enter(n),function r(o){return Rv(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Ry(/\p{P}|\p{S}/u),Ry(/\s/);let Rw={partial:!0,tokenize:function(e,t,n){return function(t){return Rv(t)?Rb(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Rg(e)?t(e):n(e)}}};class Rj{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&RN(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),RN(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),RN(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);RN(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);RN(this.left,t.reverse())}}}function RN(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Rk(e){let t,n,r,i,a,o,s,l={},c=-1,u=new Rj(e);for(;++c<u.length;){for(;c in l;)c=l[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((r=0)<(o=t[1]._tokenizer.events).length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],a=e.get(t)[2],o=t-1,s=[],l=i._tokenizer;!l&&(l=a.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,u=[],d={},h=-1,f=i,p=0,g=0,x=[0];for(;f;){for(;e.get(++o)[1]!==f;);s.push(o),!f._tokenizer&&(n=a.sliceStream(f),f.next||n.push(null),r&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=f,f=f.next}for(f=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(g=h+1,x.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),h=x.length;h--;){let t=c.slice(x[h],x[h+1]),n=s.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),h=-1;++h<u.length;)d[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return d}(u,c)),c=l[c],s=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=u.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(u.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...u.get(n)[1].start},(a=u.slice(n,c)).unshift(t),u.splice(n,c-n+1,a))}}return I8(e,0,1/0,u.slice(0)),!s}let RS={resolve:function(e){return Rk(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):Rg(t)?e.check(RC,a,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},RC={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Rb(e,i,"linePrefix")};function i(i){if(null===i||Rg(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},R_={tokenize:function(e){let t=this,n=e.attempt(Rw,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,Ro(e,e.attempt(this.parser.constructs.flow,r,e.attempt(RS,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},RE={resolveAll:RA()},RT=RO("string"),RM=RO("text");function RO(e){return{resolveAll:RA("text"===e?RD:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return l(e)?i(e):o(e)}function o(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),s)}function s(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function RA(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function RD(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],a=t.sliceStream(i),o=a.length,s=-1,l=0;for(;o--;){let e=a[o];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let a={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}RI(/[A-Za-z]/),RI(/[\dA-Za-z]/),RI(/[#-'*+\--9=?A-Z^-~]/),RI(/\d/),RI(/[\dA-Fa-f]/),RI(/[!-/:-@[-`{-~]/);let RP=RI(/\p{P}|\p{S}/u),RL=RI(/\s/);function RI(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function RR(e){return null===e||null!==e&&(e<0||32===e)||RL(e)?1:RP(e)?2:void 0}function RB(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}let Rz={name:"attention",resolveAll:function(e,t){let n,r,i,a,o,s,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[n][1].end},h={...e[u][1].start};RF(d,-s),RF(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},o={type:s>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},i={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:s>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[n][1].end={...a.start},e[u][1].start={...o.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=Re(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=Re(l,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",i,t]]),l=Re(l,RB(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=Re(l,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=Re(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,I8(e,n-1,u-n+3,l),u=n+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,a=RR(i);return function(o){return n=o,e.enter("attentionSequence"),function o(s){if(s===n)return e.consume(s),o;let l=e.exit("attentionSequence"),c=RR(s),u=!c||2===c&&a||r.includes(s),d=!a||2===a&&c||r.includes(i);return l._open=!!(42===n?u:u&&(a||!d)),l._close=!!(42===n?d:d&&(c||!u)),t(s)}(o)}}};function RF(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let RV={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return Rv(t)?Rb(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(RV,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return Rv(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},RH={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return Rm(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},RU=document.createElement("i");function RW(e){let t="&"+e+";";RU.innerHTML=t;let n=RU.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let RY={name:"characterReference",tokenize:function(e,t,n){let r,i,a=this,o=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=Rd,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=Rp,c):(e.enter("characterReferenceValue"),r=7,i=Rf,c(t))}function c(s){if(59===s&&o){let r=e.exit("characterReferenceValue");return i!==Rd||RW(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return i(s)&&o++<r?(e.consume(s),c):n(s)}}},RG={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},R$={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(t){return e.enter("codeFencedFence"),Rv(t)?Rb(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a>=s?(e.exit("codeFencedFenceSequence"),Rv(i)?Rb(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||Rg(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},o=0,s=0;return function(t){var a;let c;return a=t,o=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=a,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s<3?n(i):(e.exit("codeFencedFenceSequence"),Rv(i)?Rb(e,l,"whitespace")(i):l(i))}(a)};function l(a){return null===a||Rg(a)?(e.exit("codeFencedFence"),i.interrupt?t(a):e.check(RG,u,p)(a)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||Rg(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):Rv(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Rb(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(a))}function c(t){return null===t||Rg(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||Rg(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function u(t){return e.attempt(a,p,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return o>0&&Rv(t)?Rb(e,f,"linePrefix",o+1)(t):f(t)}function f(t){return null===t||Rg(t)?e.check(RG,u,p)(t):(e.enter("codeFlowValue"),function t(n){return null===n||Rg(n)?(e.exit("codeFlowValue"),f(n)):(e.consume(n),t)}(t))}function p(n){return e.exit("codeFenced"),t(n)}}},RX={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),Rb(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?a(n):Rg(n)?e.attempt(Rq,t,a)(n):(e.enter("codeFlowValue"),function n(r){return null===r||Rg(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function a(n){return e.exit("codeIndented"),t(n)}}},Rq={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Rg(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):Rb(e,a,"linePrefix",5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Rg(e)?i(e):n(e)}}};function RK(e){return null!==e&&(e<32||127===e)}function RZ(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function RQ(e,t,n,r,i,a,o,s,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),d):null===t||32===t||41===t||RK(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),p(t))};function d(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||null!==t&&t<-2?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function p(i){return!u&&(null===i||41===i||null!==i&&(i<0||32===i))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(i)):u<c&&40===i?(e.consume(i),u++,p):41===i?(e.consume(i),u--,p):null===i||32===i||40===i||RK(i)?n(i):(e.consume(i),92===i?g:p)}function g(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function RJ(e){return null!==e&&e<-2}function R0(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R1(e,t,n,r,i,a){let o,s=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),c};function c(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):RJ(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||RJ(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=-2!==t&&-1!==t&&32!==t),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function R2(e){return null!==e&&e<-2}function R5(e){return -2===e||-1===e||32===e}function R3(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R4(e,t,n,r,i,a){let o;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=40===t?41:t,s):n(t)};function s(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){if(t===o)return e.exit(a),s(o);if(null===t)return n(t);if(R2(t)){var r,i;let n,a;return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r=l,i="linePrefix",n=1/0,a=0,function(t){return R5(t)?(e.enter(i),function t(o){return R5(o)&&a++<n?(e.consume(o),t):(e.exit(i),r(o))}(t)):r(t)}}return e.enter("chunkString",{contentType:"string"}),c(t)}function c(t){return t===o||null===t||R2(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===o||92===t?(e.consume(t),c):c(t)}}function R6(e){return -2===e||-1===e||32===e}function R7(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function R9(e,t){let n;return function r(i){var a,o;if(null!==i&&i<-2)return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r;if(R6(i)){let t,s;return(a=r,o=n?"linePrefix":"lineSuffix",t=1/0,s=0,function(n){return R6(n)?(e.enter(o),function n(r){return R6(r)&&s++<t?(e.consume(r),n):(e.exit(o),a(r))}(n)):a(n)})(i)}return t(i)}}function R8(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}RZ(/[A-Za-z]/),RZ(/[\dA-Za-z]/),RZ(/[#-'*+\--9=?A-Z^-~]/),RZ(/\d/),RZ(/[\dA-Fa-f]/),RZ(/[!-/:-@[-`{-~]/),RZ(/\p{P}|\p{S}/u),RZ(/\s/),R0(/[A-Za-z]/),R0(/[\dA-Za-z]/),R0(/[#-'*+\--9=?A-Z^-~]/),R0(/\d/),R0(/[\dA-Fa-f]/),R0(/[!-/:-@[-`{-~]/),R0(/\p{P}|\p{S}/u),R0(/\s/),R3(/[A-Za-z]/),R3(/[\dA-Za-z]/),R3(/[#-'*+\--9=?A-Z^-~]/),R3(/\d/),R3(/[\dA-Fa-f]/),R3(/[!-/:-@[-`{-~]/),R3(/\p{P}|\p{S}/u),R3(/\s/),R7(/[A-Za-z]/),R7(/[\dA-Za-z]/),R7(/[#-'*+\--9=?A-Z^-~]/),R7(/\d/),R7(/[\dA-Fa-f]/),R7(/[!-/:-@[-`{-~]/),R7(/\p{P}|\p{S}/u),R7(/\s/);let Be={partial:!0,tokenize:function(e,t,n){return function(t){return Rx(t)?R9(e,r)(t):n(t)};function r(t){return R4(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return Rv(t)?Rb(e,a,"whitespace")(t):a(t)}function a(e){return null===e||Rg(e)?t(e):n(e)}}},Bt=["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"],Bn=["pre","script","style","textarea"],Br={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Rw,t,n)}}},Bi={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return Rg(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Ba={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&I8(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,a,o=e.length,s=0;for(;o--;)if(n=e[o][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[o][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[o][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=o,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(i=o);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},u={type:"labelText",start:{...e[r+s+2][1].end},end:{...e[i-2][1].start}};return a=Re(a=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+s+3)),a=Re(a,[["enter",u,t]]),a=Re(a,RB(t.parser.constructs.insideSpan.null,e.slice(r+s+4,i-3),t)),a=Re(a,[["exit",u,t],e[i-2],e[i-1],["exit",c,t]]),a=Re(a,e.slice(i+1)),a=Re(a,[["exit",l,t]]),I8(e,r,e.length,a),e},tokenize:function(e,t,n){let r,i,a=this,o=a.events.length;for(;o--;)if(("labelImage"===a.events[o][1].type||"labelLink"===a.events[o][1].type)&&!a.events[o][1]._balanced){r=a.events[o][1];break}return function(t){return r?r._inactive?u(t):(i=a.parser.defined.includes(R8(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)};function s(t){return 40===t?e.attempt(Bo,c,i?c:u)(t):91===t?e.attempt(Bs,c,i?l:u)(t):i?c(t):u(t)}function l(t){return e.attempt(Bl,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},Bo={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return Rx(t)?R9(e,i)(t):i(t)}function i(t){return 41===t?c(t):RQ(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return Rx(t)?R9(e,s)(t):c(t)}function o(e){return n(e)}function s(t){return 34===t||39===t||40===t?R4(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Rx(t)?R9(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},Bs={tokenize:function(e,t,n){let r=this;return function(t){return R1.call(r,e,i,a,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(R8(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},Bl={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},Bc={name:"labelStartImage",resolveAll:Ba.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},Bu={name:"labelStartLink",resolveAll:Ba.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},Bd={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Rb(e,t,"linePrefix")}}},Bh={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(a){var o;return e.enter("thematicBreak"),r=o=a,function a(o){return o===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),Rv(n)?Rb(e,a,"whitespace")(n):a(n))}(o)):i>=3&&(null===o||Rg(o))?(e.exit("thematicBreak"),t(o)):n(o)}(o)}}},Bf={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Rw,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Rb(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!Rv(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Bm,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Rb(e,e.attempt(Bf,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,o=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:Rf(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(Bh,n,s)(t):s(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return Rf(i)&&++o<10?(e.consume(i),t):(!r.interrupt||o<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),s(i)):n(i)}(t)}return n(t)};function s(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(Rw,r.interrupt?n:l,e.attempt(Bp,u,c))}function l(e){return r.containerState.initialBlankLine=!0,a++,u(e)}function c(t){return Rv(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Bp={partial:!0,tokenize:function(e,t,n){let r=this;return Rb(e,function(e){let i=r.events[r.events.length-1];return!Rv(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Bm={partial:!0,tokenize:function(e,t,n){let r=this;return Rb(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},Bg={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(r=a)}else"content"===e[a][1].type&&e.splice(a,1),i||"definition"!==e[a][1].type||(i=a);let o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",o,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=o,e.push(["exit",o,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var o;let s,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){s="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||s)?(e.enter("setextHeadingLine"),r=t,o=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),Rv(n)?Rb(e,a,"lineSuffix")(n):a(n))}(o)):n(t)};function a(r){return null===r||Rg(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,R1.call(i,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function a(t){return(r=R8(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o):n(t)}function o(t){return Rx(t)?R9(e,s)(t):s(t)}function s(t){return RQ(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Be,c,c)(t)}function c(t){return Rv(t)?Rb(e,u,"whitespace")(t):u(t)}function u(a){return null===a||Rg(a)?(e.exit("definition"),i.parser.defined.push(r),t(a)):n(a)}}}},"disable",0,{null:[]},"document",0,{42:Bf,43:Bf,45:Bf,48:Bf,49:Bf,50:Bf,51:Bf,52:Bf,53:Bf,54:Bf,55:Bf,56:Bf,57:Bf,62:RV},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,a=3;return"whitespace"===e[3][1].type&&(a+=2),i-2>a&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(a===i-1||i-4>a&&"whitespace"===e[i-2][1].type)&&(i-=a+1===i?2:4),i>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[i][1].end},r={type:"chunkText",start:e[a][1].start,end:e[i][1].end,contentType:"text"},I8(e,a,i-a+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var a;return e.enter("atxHeading"),a=i,e.enter("atxHeadingSequence"),function i(a){return 35===a&&r++<6?(e.consume(a),i):null===a||Rx(a)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||Rg(r)?(e.exit("atxHeading"),t(r)):Rv(r)?Rb(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||Rx(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(a)):n(a)}(a)}}},42:Bh,45:[Bg,Bh],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,a,o,s,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),i=!0,f):63===o?(e.consume(o),r=3,l.interrupt?t:D):Ru(o)?(e.consume(o),a=String.fromCharCode(o),p):n(o)}function u(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,o=0,h):Ru(i)?(e.consume(i),r=4,l.interrupt?t:D):n(i)}function d(r){return 45===r?(e.consume(r),l.interrupt?t:D):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(o++)?(e.consume(r),o===i.length)?l.interrupt?t:S:h:n(r)}function f(t){return Ru(t)?(e.consume(t),a=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Rx(o)){let s=47===o,c=a.toLowerCase();return!s&&!i&&Bn.includes(c)?(r=1,l.interrupt?t(o):S(o)):Bt.includes(a.toLowerCase())?(r=6,s)?(e.consume(o),g):l.interrupt?t(o):S(o):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(o):i?function t(n){return Rv(n)?(e.consume(n),t):N(n)}(o):x(o))}return 45===o||Rd(o)?(e.consume(o),a+=String.fromCharCode(o),p):n(o)}function g(r){return 62===r?(e.consume(r),l.interrupt?t:S):n(r)}function x(t){return 47===t?(e.consume(t),N):58===t||95===t||Ru(t)?(e.consume(t),v):Rv(t)?(e.consume(t),x):N(t)}function v(t){return 45===t||46===t||58===t||95===t||Rd(t)?(e.consume(t),v):y(t)}function y(t){return 61===t?(e.consume(t),b):Rv(t)?(e.consume(t),y):x(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),s=t,w):Rv(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||Rx(n)?y(n):(e.consume(n),t)}(t)}function w(t){return t===s?(e.consume(t),s=null,j):null===t||Rg(t)?n(t):(e.consume(t),w)}function j(e){return 47===e||62===e||Rv(e)?x(e):n(e)}function N(t){return 62===t?(e.consume(t),k):n(t)}function k(t){return null===t||Rg(t)?S(t):Rv(t)?(e.consume(t),k):n(t)}function S(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),M):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),D):93===t&&5===r?(e.consume(t),A):Rg(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(Br,L,C)(t)):null===t||Rg(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),S)}function C(t){return e.check(Bi,_,L)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||Rg(t)?C(t):(e.enter("htmlFlowData"),S(t))}function T(t){return 45===t?(e.consume(t),D):S(t)}function M(t){return 47===t?(e.consume(t),a="",O):S(t)}function O(t){if(62===t){let n=a.toLowerCase();return Bn.includes(n)?(e.consume(t),P):S(t)}return Ru(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),O):S(t)}function A(t){return 93===t?(e.consume(t),D):S(t)}function D(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),D):S(t)}function P(t){return null===t||Rg(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),P)}function L(n){return e.exit("htmlFlow"),t(n)}}},61:Bg,95:Bh,96:R$,126:R$},"flowInitial",0,{[-2]:RX,[-1]:RX,32:RX},"insideSpan",0,{null:[Rz,RE]},"string",0,{38:RY,92:RH},"text",0,{[-5]:Bd,[-4]:Bd,[-3]:Bd,33:Bc,38:RY,42:Rz,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return Ru(t)?(e.consume(t),a):64===t?n(t):s(t)}function a(t){return 43===t||45===t||46===t||Rd(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,o):(43===n||45===n||46===n||Rd(n))&&r++<32?(e.consume(n),t):(r=0,s(n))}(t)):s(t)}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||null!==r&&(r<32||127===r)?n(r):(e.consume(r),o)}function s(t){return 64===t?(e.consume(t),l):Rh(t)?(e.consume(t),s):n(t)}function l(i){return Rd(i)?function i(a){return 46===a?(e.consume(a),r=0,l):62===a?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(a){if((45===a||Rd(a))&&r++<63){let n=45===a?t:i;return e.consume(a),n}return n(a)}(a)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,a,o=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),w):63===t?(e.consume(t),y):Ru(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,f):Ru(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):Rg(t)?(a=u,O(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?M(e):45===e?d(e):u(e)}function f(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),g):Rg(t)?(a=p,O(t)):(e.consume(t),p)}function g(t){return 93===t?(e.consume(t),x):p(t)}function x(t){return 62===t?M(t):93===t?(e.consume(t),x):p(t)}function v(t){return null===t||62===t?M(t):Rg(t)?(a=v,O(t)):(e.consume(t),v)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Rg(t)?(a=y,O(t)):(e.consume(t),y)}function b(e){return 62===e?M(e):y(e)}function w(t){return Ru(t)?(e.consume(t),j):n(t)}function j(t){return 45===t||Rd(t)?(e.consume(t),j):function t(n){return Rg(n)?(a=t,O(n)):Rv(n)?(e.consume(n),t):M(n)}(t)}function N(t){return 45===t||Rd(t)?(e.consume(t),N):47===t||62===t||Rx(t)?k(t):n(t)}function k(t){return 47===t?(e.consume(t),M):58===t||95===t||Ru(t)?(e.consume(t),S):Rg(t)?(a=k,O(t)):Rv(t)?(e.consume(t),k):M(t)}function S(t){return 45===t||46===t||58===t||95===t||Rd(t)?(e.consume(t),S):function t(n){return 61===n?(e.consume(n),C):Rg(n)?(a=t,O(n)):Rv(n)?(e.consume(n),t):k(n)}(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,_):Rg(t)?(a=C,O(t)):Rv(t)?(e.consume(t),C):(e.consume(t),E)}function _(t){return t===r?(e.consume(t),r=void 0,T):null===t?n(t):Rg(t)?(a=_,O(t)):(e.consume(t),_)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Rx(t)?k(t):(e.consume(t),E)}function T(e){return 47===e||62===e||Rx(e)?k(e):n(e)}function M(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function O(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),A}function A(t){return Rv(t)?Rb(e,D,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),a(t)}}}],91:Bu,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Rg(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},RH],93:Ba,95:Rz,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),a++,t):(e.exit("codeTextSequence"),o(n))}(t)};function o(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),o):96===l?(i=e.enter("codeTextSequence"),r=0,function n(o){return 96===o?(e.consume(o),r++,n):r===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(o)):(i.type="codeTextData",s(o))}(l)):Rg(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):(e.enter("codeTextData"),s(l))}function s(t){return null===t||32===t||96===t||Rg(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),s)}}}}],4127);var Bx=e.i(4127);let Bv=/[\0\t\n\r]/g;function By(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let Bb=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Bw(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return By(n.slice(t?2:1),t?16:10)}return RW(n)||e}let Bj={}.hasOwnProperty;function BN(e){return{line:e.line,column:e.column,offset:e.offset}}function Bk(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+IF({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+IF({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+IF({start:t.start,end:t.end})+") is still open")}function BS(e){let t=this;t.parser=function(n){var r,i;let a,o,s,l;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(v),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(p),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(f),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(f,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(g),hardBreakTrailing:r(g),htmlFlow:r(x,i),htmlFlowData:c,htmlText:r(x,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(v),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(y),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(p),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:o(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:o(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:o(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=By(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=RW(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=BN(e.end)},codeFenced:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.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 e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:o(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=R8(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:o(),hardBreakEscape:o(d),hardBreakTrailing:o(d),htmlFlow:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(Bb,Bw),n.identifier=R8(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=BN(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),u.call(this,e))},link:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=R8(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:o(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:o(),thematicBreak:o()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(Bj.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:a,exit:s,buffer:i,resume:l,data:n},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,n){let r,i,a,o,s=t-1,l=-1,c=!1;for(;++s<=n;){let t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,o=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||o||l||a||(a=s),o=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:o=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let o=s;for(i=void 0;o--;){let t=e[o];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=o}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}a&&(!i||a<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||s,0,["exit",r,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(s,0,["enter",i,t[2]]),s++,n++,a=void 0,o=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),u));for(u=-1;++u<e.length;){let n=t[e[u][0]];Bj.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},o),e[u][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||Bk).call(o,void 0,e[0])}for(r.position={start:BN(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:BN(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r};function r(e,t){return function(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:BN(t.start),end:void 0}}function o(e){return function(t){e&&e.call(this,t),s.call(this,t)}}function s(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Bk).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+IF({start:e.start,end:e.end})+"): it’s not open");n.position.end=BN(e.end)}function l(){return I6(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:BN(e.start),end:void 0},t.push(n)),this.stack.push(n)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=BN(e.end)}function d(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function p(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function x(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!Rk(e););return e}((function(e){let t={constructs:Rn([Bx,...(e||{}).extensions||[]]),content:n(Rs),defined:[],document:n(Rl),flow:n(R_),lazy:{},string:n(RT),text:n(RM)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],l={attempt:p(function(e,t){g(e,t.from)}),check:p(f),consume:function(e){Rr(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,x()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){let t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:p(f,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,x()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let a,o=e[r];if("string"==typeof o)a=o;else switch(o){case -5:a="\r";break;case -4:a="\n";break;case -3:a="\r\n";break;case -2:a=t?" ":" ";break;case -1:if(!t&&n)continue;a=" ";break;default:a=String.fromCharCode(o)}n=-2===o,i.push(a)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(o=Re(o,e),function(){let e;for(;r._index<o.length;){let n=o[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==o[o.length-1])?[]:(g(t,0),c.events=RB(a,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;if(r===a)n=[e[r].slice(i,o)];else{if(n=e.slice(r,a),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}o>0&&n.push(e[a].slice(0,o))}return n}(o,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function f(e,t){t.restore()}function p(e,t){return function(n,i,a){var o;let u,d,f,p;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(o=n,function(e){let t=null!==e&&o[e],n=null!==e&&o.null;return g([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(u=e,d=0,0===e.length)?a:v(e[d])}function v(e){return function(n){let i,a,o,u,d;return(i=h(),a=c.previous,o=c.currentConstruct,u=c.events.length,d=Array.from(s),p={from:u,restore:function(){r=i,c.previous=a,c.currentConstruct=o,c.events.length=u,s=d,x()}},f=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,y,b)(n)}}function y(t){return e(f,p),i}function b(e){return(p.restore(),++d<u.length)?v(u[d]):a}}}function g(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&I8(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function x(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((o=1,s="",l=!0,function(e,t,n){let r,i,c,u,d,h=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,s="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(Bv.lastIndex=c,u=(r=Bv.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(u),!r){s=e.slice(c);break}if(10===d&&c===u&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),c<u&&(h.push(e.slice(c,u)),o+=u-c),d){case 0:h.push(65533),o++;break;case 9:for(i=4*Math.ceil(o/4),h.push(-2);o++<i;)h.push(-1);break;case 10:h.push(-4),o=1;break;default:a=!0,o=1}c=u+1}return n&&(a&&h.push(-5),s&&h.push(s),h.push(null)),h})(n,r,!0))))}}let BC="object"==typeof self?self:globalThis,B_=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[a,o]=e[i];switch(a){case 0:case -1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new BC[e](t),i)}case 8:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new BC[a](o),i)})(0)},{toString:BE}={},{keys:BT}=Object,BM=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=BE.call(e).slice(8,-1);switch(n){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,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},BO=([e,t])=>0===e&&("function"===t||"symbol"===t),BA=(e,{json:t,lossy:n}={})=>{var r,i,a;let o,s,l=[];return(r=!(t||n),i=!!t,a=new Map,o=(e,t)=>{let n=l.push(e)-1;return a.set(t,n),n},s=e=>{if(a.has(e))return a.get(e);let[t,n]=BM(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return o([-1],e)}return o([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),o([n,[...t]],e)}let r=[],i=o([t,r],e);for(let t of e)r.push(s(t));return i}case 2:{if(n)switch(n){case"BigInt":return o([n,e.toString()],e);case"Boolean":case"Number":case"String":return o([n,e.valueOf()],e)}if(i&&"toJSON"in e)return s(e.toJSON());let a=[],l=o([t,a],e);for(let t of BT(e))(r||!BO(BM(e[t])))&&a.push([s(t),s(e[t])]);return l}case 3:return o([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return o([t,{source:n,flags:r}],e)}case 5:{let n=[],i=o([t,n],e);for(let[t,i]of e)(r||!(BO(BM(t))||BO(BM(i))))&&n.push([s(t),s(i)]);return i}case 6:{let n=[],i=o([t,n],e);for(let t of e)(r||!BO(BM(t)))&&n.push(s(t));return i}}let{message:l}=e;return o([t,{name:n,message:l}],e)})(e),l},BD="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?B_(BA(e,t)):structuredClone(e):(e,t)=>B_(BA(e,t));BL(/[A-Za-z]/);let BP=BL(/[\dA-Za-z]/);function BL(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function BI(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o="";if(37===a&&BP(e.charCodeAt(n+1))&&BP(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function BR(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function BB(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}BL(/[#-'*+\--9=?A-Z^-~]/),BL(/\d/),BL(/[\dA-Fa-f]/),BL(/[!-/:-@[-`{-~]/),BL(/\p{P}|\p{S}/u),BL(/\s/);let Bz=function(e){var t,n;if(null==e)return BV;if("function"==typeof e)return BF(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Bz(e[n]);return BF(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,BF(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,BF(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function BF(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function BV(){return!0}let BH=[];function BU(e,t,n,r){let i;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):i=t;let a=Bz(i),o=r?-1:1;(function e(i,s,l){let c=i&&"object"==typeof i?i:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+i.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,h,f=BH;if((!t||a(i,s,l[l.length-1]||void 0))&&!1===(f=Array.isArray(c=n(i,l))?c:"number"==typeof c?[!0,c]:null==c?BH:[c])[0])return f;if("children"in i&&i.children&&i.children&&"skip"!==f[0])for(d=(r?i.children.length:-1)+o,h=l.concat(i);d>-1&&d<i.children.length;){if(!1===(u=e(i.children[d],d,h)())[0])return u;d="number"==typeof u[1]?u[1]:d+o}return f}})(e,void 0,[])()}function BW(e,t,n,r){let i,a,o;"function"==typeof t&&"function"!=typeof n?(a=void 0,o=t,i=n):(a=t,o=n,i=r),BU(e,a,function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)},i)}function BY(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),a=i[0];a&&"text"===a.type?a.value="["+a.value:i.unshift({type:"text",value:"["});let o=i[i.length-1];return o&&"text"===o.type?o.value+=r:i.push({type:"text",value:r}),i}function BG(e){let t=e.spread;return null==t?e.children.length>1:t}function B$(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let BX={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a={type:"element",tagName:"pre",properties:{},children:[a=e.applyData(t,a)]},e.patch(t,a),a},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),a=BI(i.toLowerCase()),o=e.footnoteOrder.indexOf(i),s=e.footnoteCounts.get(i);void 0===s?(s=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=o+1,s+=1,e.footnoteCounts.set(i,s);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return BY(e,t);let i={src:BI(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){let n={src:BI(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return BY(e,t);let i={href:BI(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){let n={href:BI(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=BG(n[r])}return t}(n):BG(t),a={},o=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let e=r[s];(i||0!==s||"element"!==e.type||"p"!==e.tagName)&&o.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?o.push(e):o.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&o.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=IB(t.children[1]),o=IR(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,o=a?a.length:t.children.length,s=-1,l=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(B$(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(B$(t.slice(i),i>0,!1)),a.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Bq,yaml:Bq,definition:Bq,footnoteDefinition:Bq};function Bq(){}let BK={}.hasOwnProperty,BZ={};function BQ(e,t){e.position&&(t.position=function(e){let t=IB(e),n=IR(e);if(t&&n)return{start:t,end:n}}(e))}function BJ(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,BD(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function B0(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function B1(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function B2(e,t){let n,r,i,a,o=(n=t||BZ,r=new Map,i=new Map,a={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=B1(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=B1(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:BJ,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...BX,...n.handlers},one:function(e,t){let n=e.type,r=a.handlers[n];if(BK.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=BD(n);return r.children=a.all(e),r}return BD(e)}return(a.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(BK.call(n,"hProperties")||BK.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(a,e,t)},options:n,patch:BQ,wrap:B0},BW(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a),s=o.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||BR,r=e.options.footnoteBackLabel||BB,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),c=BI(o.toLowerCase()),u=0,d=[],h=e.footnoteCounts.get(o);for(;void 0!==h&&++u<=h;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let f=a[a.length-1];if(f&&"element"===f.type&&"p"===f.tagName){let e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...d)}else a.push(...d);let p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(i,p),s.push(p)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...BD(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(o),c=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return l&&(L4("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function B5(e,t){return e&&"run"in e?async function(n,r){let i=B2(n,{file:r,...t});await e.run(i,r)}:function(n,r){return B2(n,{file:r,...e||t})}}function B3(e){if(e)throw e}var B4=e.i(4100);function B6(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let B7=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');zt(e);let r=0,i=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else i<0&&(n=!0,i=a+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let o=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else o<0&&(n=!0,o=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(i=a):(s=-1,i=o));return r===i?i=o:i<0&&(i=e.length),e.slice(r,i)},B9=function(e){let t;if(zt(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},B8=function(e){let t;zt(e);let n=e.length,r=-1,i=0,a=-1,o=0;for(;n--;){let s=e.codePointAt(n);if(47===s){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===s?a<0?a=n:1!==o&&(o=1):a>-1&&(o=-1)}return a<0||r<0||0===o||1===o&&a===r-1&&a===i+1?"":e.slice(a,r)},ze=function(...e){var t;let n,r,i,a=-1;for(;++a<e.length;)zt(e[a]),e[a]&&(i=void 0===i?e[a]:i+"/"+e[a]);return void 0===i?".":(zt(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",a=0,o=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(o===l-1||1===s);else if(o!==l-1&&2===s){if(i.length<2||2!==a||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",a=0):a=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),o=l,s=0;continue}}else if(i.length>0){i="",a=0,o=l,s=0;continue}}t&&(i=i.length>0?i+"/..":"..",a=2)}else i.length>0?i+="/"+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else 46===n&&s>-1?s++:s=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function zt(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function zn(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let zr=["history","path","basename","stem","extname","dirname"];class zi{constructor(e){let t,n;t=e?zn(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zr.length;){const e=zr[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)zr.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?B7(this.path):void 0}set basename(e){zo(e,"basename"),za(e,"basename"),this.path=ze(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?B9(this.path):void 0}set dirname(e){zs(this.basename,"dirname"),this.path=ze(e||"",this.basename)}get extname(){return"string"==typeof this.path?B8(this.path):void 0}set extname(e){if(za(e,"extname"),zs(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=ze(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){zn(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!zn(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),zo(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?B7(this.path,this.extname):void 0}set stem(e){zo(e,"stem"),za(e,"stem"),this.path=ze(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new IW(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function za(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function zo(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function zs(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let zl=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},zc={}.hasOwnProperty;class zu extends zl{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 e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(a,...o){let s=e[++n],l=-1;if(a)return void r(a);for(;++l<t.length;)(null===o[l]||void 0===o[l])&&(o[l]=t[l]);t=o,s?(function(e,t){let n;return function(...t){let a,o=e.length>t.length;o&&t.push(r);try{a=e.apply(this,t)}catch(e){if(o&&n)throw e;return r(e)}o||(a&&a.then&&"function"==typeof a.then?a.then(i,r):a instanceof Error?r(a):i(a))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(s,i)(...o):r(null,...o)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new zu,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,B4.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(zp("data",this.frozen),this.namespace[e]=t,this):zc.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zp("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=zx(e),n=this.parser||this.Parser;return zh("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),zh("process",this.parser||this.Parser),zf("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=zx(e),o=n.parse(a);function s(e,n){e||!n?i(e):r?r(n):(L4(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(o,a,function(e,t,r){var i,a;if(e||!t||!r)return s(e);let o=n.stringify(t,r);"string"==typeof(i=o)||(a=i)&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a?r.value=o:r.result=o,s(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),zh("processSync",this.parser||this.Parser),zf("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,B3(e),t=r}),zg("processSync","process",n),L4(t,"we either bailed on an error or have a tree"),t}run(e,t,n){zm(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){L4("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let o=zx(t);r.run(e,o,function(t,r,o){let s=r||e;t?a(t):i?i(s):(L4(n,"`done` is defined if `resolve` is not"),n(void 0,s,o))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){B3(e),n=t,r=!0}),zg("runSync","run",r),L4(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=zx(t),r=this.compiler||this.Compiler;return zf("stringify",r),zm(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zp("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))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");a(e.plugins),e.settings&&(r.settings=(0,B4.default)(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)o(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;o(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function o(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];B6(o)&&B6(r)&&(r=(0,B4.default)(!0,o,r)),n[i]=[e,r,...a]}}}}let zd=new zu().freeze();function zh(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function zf(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function zp(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zm(e){if(!B6(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function zg(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function zx(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new zi(e)}let zv=[],zy={allowDangerousHtml:!0},zb=/^(https?|ircs?|mailto|xmpp)$/i,zw=[{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 zj(e){var t;let n,r,i,a,o,s=(n=(t=e).rehypePlugins||zv,r=t.remarkPlugins||zv,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...zy}:zy,zd().use(BS).use(r).use(B5,i).use(n)),l=(a=e.children||"",o=new zi,"string"==typeof a?o.value=a:L6("Unexpected value `"+a+"` for `children` prop, expected `string`"),o);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,l=t.urlTransform||zN;for(let e of zw)Object.hasOwn(t,e.from)&&L6("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&a&&L6("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),BW(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return o?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in I3)if(Object.hasOwn(I3,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=I3[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let o=n?!n.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&r&&"number"==typeof t&&(o=!r(e,t,i)),o&&i&&"number"==typeof t)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,a;let o;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let s=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=s,r=t.jsxDEV,o=function(e,t,i,a){let o=Array.isArray(i.children),s=IB(e);return r(t,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:n,lineNumber:s?s.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,a=t.jsxs,o=function(e,t,n,r){let o=Array.isArray(n.children)?a:i;return r?o(t,n,r):o(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?IL:IP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=IZ(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:_.Fragment,components:i,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0})}(s.runSync(s.parse(l),l),e)}function zN(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||zb.test(e.slice(0,t))?e:""}function zk(e,t){let n=String(e);if("string"!=typeof t)throw TypeError("Expected character");let r=0,i=n.indexOf(t);for(;-1!==i;)r++,i=n.indexOf(t,i+t.length);return r}z_(/[A-Za-z]/),z_(/[\dA-Za-z]/),z_(/[#-'*+\--9=?A-Z^-~]/),z_(/\d/),z_(/[\dA-Fa-f]/),z_(/[!-/:-@[-`{-~]/);let zS=z_(/\p{P}|\p{S}/u),zC=z_(/\s/);function z_(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let zE="phrasing",zT=["autolink","link","image","label"];function zM(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function zO(e){this.config.enter.autolinkProtocol.call(this,e)}function zA(e){this.config.exit.autolinkProtocol.call(this,e)}function zD(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];L4("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function zP(e){this.config.exit.autolinkEmail.call(this,e)}function zL(e){this.exit(e)}function zI(e){!function(e,t,n){let r=Bz((n||{}).ignore||[]),i=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){var i;let e=n[r];t.push(["string"==typeof(i=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(i),"g"):i,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),a=-1;for(;++a<i.length;)BU(e,"text",o);function o(e,t){let n,o=-1;for(;++o<t.length;){let e=t[o],i=n?n.children:void 0;if(r(e,i?i.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,l=n.children.indexOf(e),c=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if("string"==typeof a&&(a=a.length>0?{type:"text",value:a}:void 0),!1===a?r.lastIndex=n+1:(s!==n&&u.push({type:"text",value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}return c?(s<e.value.length&&u.push({type:"text",value:e.value.slice(s)}),n.children.splice(l,1,...u)):u=[e],l+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,zR],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,zB]],{ignore:["link","linkReference"]})}function zR(e,t,n,r,i){let a,o="";if(!zz(i))return!1;if(/^w/i.test(t)&&(n=t+n,t="",o="http://"),(a=n.split(".")).length<2||a[a.length-1]&&(/_/.test(a[a.length-1])||!/[a-zA-Z\d]/.test(a[a.length-1]))||a[a.length-2]&&(/_/.test(a[a.length-2])||!/[a-zA-Z\d]/.test(a[a.length-2])))return!1;let s=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")"),i=zk(e,"("),a=zk(e,")");for(;-1!==r&&i>a;)e+=n.slice(0,r+1),r=(n=n.slice(r+1)).indexOf(")"),a++;return[e,n]}(n+r);if(!s[0])return!1;let l={type:"link",title:null,url:o+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}function zB(e,t,n,r){return!(!zz(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zz(e,t){let n=e.input.charCodeAt(e.index-1);return(0===e.index||zC(n)||zS(n))&&(!t||47!==n)}function zF(){this.buffer()}function zV(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function zH(){this.buffer()}function zU(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function zW(e){let t=this.resume(),n=this.stack[this.stack.length-1];L4("footnoteReference"===n.type),n.identifier=R8(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zY(e){this.exit(e)}function zG(e){let t=this.resume(),n=this.stack[this.stack.length-1];L4("footnoteDefinition"===n.type),n.identifier=R8(this.sliceSerialize(e)).toLowerCase(),n.label=t}function z$(e){this.exit(e)}function zX(e,t,n,r){let i=n.createTracker(r),a=i.move("[^"),o=n.enter("footnoteReference"),s=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),s(),o(),a+=i.move("]")}function zq(e,t,n){return 0===t?e:zK(e,t,n)}function zK(e,t,n){return(n?"":" ")+e}zX.peek=function(){return"["};let zZ=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function zQ(e){this.enter({type:"delete",children:[]},e)}function zJ(e){this.exit(e)}function z0(e,t,n,r){let i=n.createTracker(r),a=n.enter("strikethrough"),o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),a(),o}function z1(e){return e.length}function z2(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}z0.peek=function(){return"~"};function z5(e,t,n){let r=e.value||"",i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){let e,t=n.unsafe[a],i=n.compilePattern(t);if(t.atBreak)for(;e=i.exec(r);){let t=e.index;10===r.charCodeAt(t)&&13===r.charCodeAt(t-1)&&t--,r=r.slice(0,t)+" "+r.slice(e.index+1)}}return i+r+i}z5.peek=function(){return"`"};Bz(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let z3=function(e,t,n,r){let i=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n),a=n.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(n);t&&"list"===t.type&&t.ordered&&(a=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+a);let o=a.length+1;("tab"===i||"mixed"===i&&(t&&"list"===t.type&&t.spread||e.spread))&&(o=4*Math.ceil(o/4));let s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,s.current()),function(e,t,n){return t?(n?"":" ".repeat(o))+e:(n?a:a+" ".repeat(o-a.length))+e});return l(),c};function z4(e){let t=e._align;L4(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function z6(e){this.exit(e),this.data.inTable=void 0}function z7(e){this.enter({type:"tableRow",children:[]},e)}function z9(e){this.exit(e)}function z8(e){this.enter({type:"tableCell",children:[]},e)}function Fe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ft));let n=this.stack[this.stack.length-1];L4("inlineCode"===n.type),n.value=t,this.exit(e)}function Ft(e,t){return"|"===t?t:e}function Fn(e){let t=this.stack[this.stack.length-2];L4("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function Fr(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];L4("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let r,i=t.children,a=-1;for(;++a<i.length;){let e=i[a];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Fi(e,t,n,r){let i=e.children[0],a="boolean"==typeof e.checked&&i&&"paragraph"===i.type,o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=z3(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+o})),l}let Fa=Fu(/[A-Za-z]/),Fo=Fu(/[\dA-Za-z]/);function Fs(e){return null!==e&&(e<0||32===e)}Fu(/[#-'*+\--9=?A-Z^-~]/),Fu(/\d/),Fu(/[\dA-Fa-f]/),Fu(/[!-/:-@[-`{-~]/);let Fl=Fu(/\p{P}|\p{S}/u),Fc=Fu(/\s/);function Fu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}let Fd={tokenize:function(e,t,n){let r=0;return function t(a){return(87===a||119===a)&&r<3?(r++,e.consume(a),t):46===a&&3===r?(e.consume(a),i):n(a)};function i(e){return null===e?n(e):t(e)}},partial:!0},Fh={tokenize:function(e,t,n){let r,i,a;return o;function o(t){return 46===t||95===t?e.check(Fp,l,s)(t):null===t||Fs(t)||Fc(t)||45!==t&&Fl(t)?l(t):(a=!0,e.consume(t),o)}function s(t){return 95===t?r=!0:(i=r,r=void 0),e.consume(t),o}function l(e){return i||r||!a?n(e):t(e)}},partial:!0},Ff={tokenize:function(e,t){let n=0,r=0;return i;function i(o){return 40===o?(n++,e.consume(o),i):41===o&&r<n?a(o):33===o||34===o||38===o||39===o||41===o||42===o||44===o||46===o||58===o||59===o||60===o||63===o||93===o||95===o||126===o?e.check(Fp,t,a)(o):null===o||Fs(o)||Fc(o)?t(o):(e.consume(o),i)}function a(t){return 41===t&&r++,e.consume(t),i}},partial:!0},Fp={tokenize:function(e,t,n){return r;function r(o){return 33===o||34===o||39===o||41===o||42===o||44===o||46===o||58===o||59===o||63===o||95===o||126===o?(e.consume(o),r):38===o?(e.consume(o),a):93===o?(e.consume(o),i):60===o||null===o||Fs(o)||Fc(o)?t(o):n(o)}function i(e){return null===e||40===e||91===e||Fs(e)||Fc(e)?t(e):r(e)}function a(t){return Fa(t)?function t(i){return 59===i?(e.consume(i),r):Fa(i)?(e.consume(i),t):n(i)}(t):n(t)}},partial:!0},Fm={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Fo(e)?n(e):t(e)}},partial:!0},Fg={name:"wwwAutolink",tokenize:function(e,t,n){let r=this;return function(t){return 87!==t&&119!==t||!Fw.call(r,r.previous)||FS(r.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Fd,e.attempt(Fh,e.attempt(Ff,i),n),n)(t))};function i(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Fw},Fx={name:"protocolAutolink",tokenize:function(e,t,n){let r=this,i="",a=!1;return function(t){return(72===t||104===t)&&Fj.call(r,r.previous)&&!FS(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(t),e.consume(t),o):n(t)};function o(t){if(Fa(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),o;if(58===t){let n=i.toLowerCase();if("http"===n||"https"===n)return e.consume(t),s}return n(t)}function s(t){return 47===t?(e.consume(t),a)?l:(a=!0,s):n(t)}function l(t){return null===t||null!==t&&(t<32||127===t)||Fs(t)||Fc(t)||Fl(t)?n(t):e.attempt(Fh,e.attempt(Ff,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Fj},Fv={name:"emailAutolink",tokenize:function(e,t,n){let r,i,a=this;return function(t){return!Fk(t)||!FN.call(a,a.previous)||FS(a.events)?n(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(r){return Fk(r)?(e.consume(r),t):64===r?(e.consume(r),o):n(r)}(t))};function o(t){return 46===t?e.check(Fm,l,s)(t):45===t||95===t||Fo(t)?(i=!0,e.consume(t),o):l(t)}function s(t){return e.consume(t),r=!0,o}function l(o){return i&&r&&Fa(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(o)):n(o)}},previous:FN},Fy={},Fb=48;for(;Fb<123;)Fy[Fb]=Fv,58==++Fb?Fb=65:91===Fb&&(Fb=97);function Fw(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Fs(e)}function Fj(e){return!Fa(e)}function FN(e){return!(47===e||Fk(e))}function Fk(e){return 43===e||45===e||46===e||95===e||Fo(e)}function FS(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function FC(e){return null!==e&&(e<0||32===e)}function F_(e){return -2===e||-1===e||32===e}function FE(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function FT(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return F_(r)?(e.enter(n),function r(o){return F_(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}Fy[43]=Fv,Fy[45]=Fv,Fy[46]=Fv,Fy[95]=Fv,Fy[72]=[Fv,Fx],Fy[104]=[Fv,Fx],Fy[87]=[Fv,Fg],Fy[119]=[Fv,Fg],FE(/[A-Za-z]/),FE(/[\dA-Za-z]/),FE(/[#-'*+\--9=?A-Z^-~]/),FE(/\d/),FE(/[\dA-Fa-f]/),FE(/[!-/:-@[-`{-~]/),FE(/\p{P}|\p{S}/u),FE(/\s/);let FM={tokenize:function(e,t,n){let r=this;return FT(e,function(e){let i=r.events[r.events.length-1];return i&&"gfmFootnoteDefinitionIndent"===i[1].type&&4===i[2].sliceSerialize(i[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function FO(e,t,n){let r,i=this,a=i.events.length,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);for(;a--;){let e=i.events[a][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!r||!r._balanced)return n(a);let s=R8(i.sliceSerialize({start:r.end,end:i.now()}));return 94===s.codePointAt(0)&&o.includes(s.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)):n(a)}}function FA(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function FD(e,t,n){let r,i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),o=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),s};function s(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(s){if(o>999||93===s&&!r||null===s||91===s||FC(s))return n(s);if(93===s){e.exit("chunkString");let r=e.exit("gfmFootnoteCallString");return a.includes(R8(i.sliceSerialize(r)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(s)}return FC(s)||(r=!0),o++,e.consume(s),92===s?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),o++,l):l(t)}}function FP(e,t,n){let r,i,a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]),s=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(s>999||93===t&&!i||null===t||91===t||FC(t))return n(t);if(93===t){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return r=R8(a.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return FC(t)||(i=!0),s++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(r)||o.push(r),FT(e,h,"gfmFootnoteDefinitionWhitespace")):n(t)}function h(e){return t(e)}}function FL(e,t,n){return e.check(Rw,t,e.attempt(FM,t,n))}function FI(e){e.exit("gfmFootnoteDefinition")}function FR(e){return null!==e&&e<-2}function FB(e){return null!==e&&(e<0||32===e)}function Fz(e){return -2===e||-1===e||32===e}function FF(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function FV(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return Fz(r)?(e.enter(n),function r(o){return Fz(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}FF(/[A-Za-z]/),FF(/[\dA-Za-z]/),FF(/[#-'*+\--9=?A-Z^-~]/),FF(/\d/),FF(/[\dA-Fa-f]/),FF(/[!-/:-@[-`{-~]/),FF(/\p{P}|\p{S}/u),FF(/\s/);class FH{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let i=0;if(0!==n||0!==r.length){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}}function FU(e,t,n){let r,i=this,a=0,o=0;return function(e){let t=i.events.length-1;for(;t>-1;){let e=i.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let r=t>-1?i.events[t][1].type:null,a="tableHead"===r||"tableRow"===r?y:s;return a===y&&i.parser.lazy[i.now().line]?n(e):a(e)};function s(t){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=t)||(r=!0,o+=1),l(n)}function l(t){return null===t?n(t):FR(t)?o>1?(o=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):Fz(t)?FV(e,l,"whitespace")(t):(o+=1,r&&(r=!1,a+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,l):(e.enter("data"),c(t))}function c(t){return null===t||124===t||FB(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return(i.interrupt=!1,i.parser.lazy[i.now().line])?n(t):(e.enter("tableDelimiterRow"),r=!1,Fz(t))?FV(e,h,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t)}function h(t){return 45===t||58===t?p(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),f):n(t)}function f(t){return Fz(t)?FV(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(o+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),g):45===t?(o+=1,g(t)):null===t||FR(t)?v(t):n(t)}function g(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(n){return 45===n?(e.consume(n),t):58===n?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(n))}(t)):n(t)}function x(t){return Fz(t)?FV(e,v,"whitespace")(t):v(t)}function v(i){if(124===i)return h(i);if(null===i||FR(i))return r&&a===o?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):n(i);return n(i)}function y(t){return e.enter("tableRow"),b(t)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||FR(n)?(e.exit("tableRow"),t(n)):Fz(n)?FV(e,b,"whitespace")(n):(e.enter("data"),w(n))}function w(t){return null===t||124===t||FB(t)?(e.exit("data"),b(t)):(e.consume(t),92===t?j:w)}function j(t){return 92===t||124===t?(e.consume(t),w):w(t)}}function FW(e,t){let n,r,i,a=-1,o=!0,s=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h=new FH;for(;++a<e.length;){let f=e[a],p=f[1];"enter"===f[0]?"tableHead"===p.type?(u=!1,0!==d&&(FG(h,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(o=!0,i=void 0,l=[0,0,0,0],c=[0,a+1,0,0],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(a,0,[["enter",r,t]])),s="tableDelimiterRow"===p.type?2:r?3:1):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)?(o=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],i=FY(h,t,l,s,void 0,i),l=[0,0,0,0]),c[2]=a)):"tableCellDivider"===p.type&&(o?o=!1:(0!==l[1]&&(c[0]=c[1],i=FY(h,t,l,s,void 0,i)),c=[(l=c)[1],a,0,0])):"tableHead"===p.type?(u=!0,d=a):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=a,0!==l[1]?(c[0]=c[1],i=FY(h,t,l,s,a,i)):0!==c[1]&&(i=FY(h,t,c,s,a,i)),s=0):s&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(c[3]=a)}for(0!==d&&FG(h,t,d,n,r),h.consume(t.events),a=-1;++a<t.events.length;){let e=t.events[a];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if("enter"===i[0])"tableContent"===i[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===i[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===i[1].type)break}else"enter"===i[0]&&"tableDelimiterRow"===i[1].type&&(n=!0);t+=1}return r}(t.events,a))}return e}function FY(e,t,n,r,i,a){0!==n[0]&&(a.end=Object.assign({},F$(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));let o=F$(t.events,n[1]);if(a={type:1===r?"tableHeader":2===r?"tableDelimiter":"tableData",start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",a,t]]),0!==n[2]){let i=F$(t.events,n[2]),a=F$(t.events,n[3]),o={type:"tableContent",start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[["enter",o,t]]),2!==r){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",o,t]])}return void 0!==i&&(a.end=Object.assign({},F$(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function FG(e,t,n,r,i){let a=[],o=F$(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function F$(e,t){let n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}function FX(e){return -2===e||-1===e||32===e}function Fq(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}Fq(/[A-Za-z]/),Fq(/[\dA-Za-z]/),Fq(/[#-'*+\--9=?A-Z^-~]/),Fq(/\d/),Fq(/[\dA-Fa-f]/),Fq(/[!-/:-@[-`{-~]/),Fq(/\p{P}|\p{S}/u),Fq(/\s/);let FK={name:"tasklistCheck",tokenize:function(e,t,n){let r=this;return function(t){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),i):n(t)};function i(t){return null!==t&&(t<0||32===t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),a):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),a):n(t)}function a(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(t)}function o(r){return null!==r&&r<-2?t(r):FX(r)?e.check({tokenize:FZ},t,n)(r):n(r)}}};function FZ(e,t,n){var r,i;let a,o;return r=function(e){return null===e?n(e):t(e)},i="whitespace",a=1/0,o=0,function(t){return FX(t)?(e.enter(i),function t(n){return FX(n)&&o++<a?(e.consume(n),t):(e.exit(i),r(n))}(t)):r(t)}}let FQ={};function FJ(e){let t,n,r,i=e||FQ,a=this.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),s=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),l=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push(Rn([{text:Fy},{document:{91:{name:"gfmFootnoteDefinition",tokenize:FP,continuation:{tokenize:FL},exit:FI}},text:{91:{name:"gfmFootnoteCall",tokenize:FD},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FO,resolveTo:FA}}},(t=(i||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,r){let i=this.previous,a=this.events,o=0;return function(s){return 126===i&&"characterEscape"!==a[a.length-1][1].type?r(s):(e.enter("strikethroughSequenceTemporary"),function a(s){let l=RR(i);if(126===s)return o>1?r(s):(e.consume(s),o++,a);if(o<2&&!t)return r(s);let c=e.exit("strikethroughSequenceTemporary"),u=RR(s);return c._open=!u||2===u&&!!l,c._close=!l||2===l&&!!u,n(s)}(s))}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";let i={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[["enter",i,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",a,t]],s=t.parser.constructs.insideSpan.null;s&&I8(o,o.length,0,RB(s,e.slice(r+1,n),t)),I8(o,o.length,0,[["exit",a,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",i,t]]),I8(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:FU,resolveAll:FW}}},{text:{91:FK}}])),s.push([{transforms:[zI],enter:{literalAutolink:zM,literalAutolinkEmail:zO,literalAutolinkHttp:zO,literalAutolinkWww:zO},exit:{literalAutolink:zL,literalAutolinkEmail:zP,literalAutolinkHttp:zA,literalAutolinkWww:zD}},{enter:{gfmFootnoteCallString:zF,gfmFootnoteCall:zV,gfmFootnoteDefinitionLabelString:zH,gfmFootnoteDefinition:zU},exit:{gfmFootnoteCallString:zW,gfmFootnoteCall:zY,gfmFootnoteDefinitionLabelString:zG,gfmFootnoteDefinition:z$}},{canContainEols:["delete"],enter:{strikethrough:zQ},exit:{strikethrough:zJ}},{enter:{table:z4,tableData:z8,tableHeader:z8,tableRow:z7},exit:{codeText:Fe,table:z6,tableData:z9,tableHeader:z9,tableRow:z9}},{exit:{taskListCheckValueChecked:Fn,taskListCheckValueUnchecked:Fn,paragraph:Fr}}]),l.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:zE,notInConstruct:zT},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:zE,notInConstruct:zT},{character:":",before:"[ps]",after:"\\/",inConstruct:zE,notInConstruct:zT}]},(r=!1,i&&i.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:function(e,t,n,i){let a=n.createTracker(i),o=a.move("[^"),s=n.enter("footnoteDefinition"),l=n.enter("label");return o+=a.move(n.safe(n.associationId(e),{before:o,after:"]"})),l(),o+=a.move("]:"),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((r?"\n":" ")+n.indentLines(n.containerFlow(e,a.current()),r?zK:zq))),s(),o},footnoteReference:zX},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:zZ}],handlers:{delete:z0}},function(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";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(e,t,n){let r=z5(e,t,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,t,n,r){return s(function(e,t,n){let r=e.children,i=-1,a=[],o=t.enter("table");for(;++i<r.length;)a[i]=l(r[i],t,n);return o(),a}(e,n,r),e.align)},tableCell:o,tableRow:function(e,t,n,r){let i=s([l(e,n,r)]);return i.slice(0,i.indexOf("\n"))}}};function o(e,t,n,r){let i=n.enter("tableCell"),o=n.enter("phrasing"),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function s(e,t){return function(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||z1,a=[],o=[],s=[],l=[],c=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>c&&(c=e[u].length);++a<e[u].length;){var d;let o=null==(d=e[u][a])?"":String(d);if(!1!==n.alignDelimiters){let e=i(o);r[a]=e,(void 0===l[a]||e>l[a])&&(l[a]=e)}t.push(o)}o[u]=t,s[u]=r}let h=-1;if("object"==typeof r&&"length"in r)for(;++h<c;)a[h]=z2(r[h]);else{let e=z2(r);for(;++h<c;)a[h]=e}h=-1;let f=[],p=[];for(;++h<c;){let e=a[h],t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let i=!1===n.alignDelimiters?1:Math.max(1,l[h]-t.length-r.length),o=t+"-".repeat(i)+r;!1!==n.alignDelimiters&&((i=t.length+i+r.length)>l[h]&&(l[h]=i),p[h]=i),f[h]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let g=[];for(;++u<o.length;){let e=o[u],t=s[u];h=-1;let r=[];for(;++h<c;){let i=e[h]||"",o="",s="";if(!1!==n.alignDelimiters){let e=l[h]-(t[h]||0),n=a[h];114===n?o=" ".repeat(e):99===n?e%2?(o=" ".repeat(e/2+.5),s=" ".repeat(e/2-.5)):s=o=" ".repeat(e/2):s=" ".repeat(e)}!1===n.delimiterStart||h||r.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==i)&&(!1!==n.delimiterStart||h)&&r.push(" "),!1!==n.alignDelimiters&&r.push(o),r.push(i),!1!==n.alignDelimiters&&r.push(s),!1!==n.padding&&r.push(" "),(!1!==n.delimiterEnd||h!==c-1)&&r.push("|")}g.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return g.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function l(e,t,n){let r=e.children,i=-1,a=[],s=t.enter("tableRow");for(;++i<r.length;)a[i]=o(r[i],e,t,n);return s(),a}}(i),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Fi}}]})}let F0=/^\s*\|.*\|\s*$/,F1=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;function F2({children:e,className:t}){return(0,_.jsx)("div",{className:(0,W.cn)("text-[13px] leading-6 text-foreground/90 space-y-2 [&>:first-child]:mt-0",t),children:(0,_.jsx)(zj,{remarkPlugins:[FJ],components:{h1:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...e}),h2:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-4 mb-1",...e}),h3:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...e}),h4:e=>(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground mt-3 mb-1",...e}),p:e=>(0,_.jsx)("p",{className:"my-1.5",...e}),ul:e=>(0,_.jsx)("ul",{className:"list-disc pl-5 my-1.5 space-y-0.5",...e}),ol:e=>(0,_.jsx)("ol",{className:"list-decimal pl-5 my-1.5 space-y-0.5",...e}),li:e=>(0,_.jsx)("li",{className:"leading-6",...e}),strong:e=>(0,_.jsx)("strong",{className:"font-semibold text-foreground",...e}),code:e=>(0,_.jsx)("code",{className:"text-[12px] font-mono bg-muted/70 px-1 py-0.5 rounded",...e}),a:e=>(0,_.jsx)("a",{className:"text-primary underline",...e}),table:e=>(0,_.jsx)("div",{className:"overflow-x-auto my-3 rounded-md border border-border",children:(0,_.jsx)("table",{className:"text-[12px] w-full border-collapse",...e})}),thead:e=>(0,_.jsx)("thead",{className:"bg-muted/60",...e}),th:e=>(0,_.jsx)("th",{className:"text-left font-semibold px-3 py-1.5 border-b border-border whitespace-nowrap",...e}),td:e=>(0,_.jsx)("td",{className:"px-3 py-1.5 border-b border-border/40 align-top [tr:last-child_&]:border-b-0",...e}),hr:e=>(0,_.jsx)("hr",{className:"my-3 border-border/60",...e}),blockquote:e=>(0,_.jsx)("blockquote",{className:"border-l-2 border-border/60 pl-3 my-2 text-muted-foreground italic",...e})},children:function(e){let t=e.split("\n"),n=[],r=0;for(;r<t.length;){let e=t[r],i=t[r+1];if(e&&i&&F0.test(e)&&F1.test(i)){for(n.length>0&&""!==n[n.length-1].trim()&&n.push("");r<t.length&&F0.test(t[r]);)n.push(t[r].replace(/^\s+/,"")),r++;r<t.length&&""!==t[r].trim()&&n.push("");continue}n.push(e),r++}return n.join("\n")}(e)})})}var F5=e.i(59411),tn=tn;function F3({directiveId:e,onClose:t}){let n,r=(0,M.useTranslations)("directiveDetailModal"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(null),[s,l]=(0,E.useState)(!1),[c,u]=(0,E.useState)(null);(0,E.useEffect)(()=>{e&&i&&(async()=>{l(!0),u(null),o(null);try{let t=await $.client.getDirective(i,e);o(t)}catch(e){console.error("Error loading directive:",e),u(e.message)}finally{l(!1)}})()},[e,i]);let d=null!==e;return(0,_.jsx)(ta.Dialog,{open:d,onOpenChange:e=>!e&&t(),children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,_.jsx)(F5.VisuallyHidden,{children:(0,_.jsx)(ta.DialogTitle,{children:r("title")})}),s?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)(tn.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):c?(0,_.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,_.jsx)("div",{className:"text-center text-destructive",children:(0,_.jsx)("div",{className:"text-sm",children:r("errorPrefix",{error:c})})})}):a?(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,_.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),!a.is_active&&(0,_.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:r("inactive")})]}),(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:a.id})]}),(0,_.jsxs)("div",{className:"flex gap-8",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:r("created")}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:(n=new Date(a.created_at),`${n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:r("priority")}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:a.priority})]})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:r("content")}),(0,_.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,_.jsx)(zj,{remarkPlugins:[FJ],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:r("tags")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map((e,t)=>(0,_.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:e},t))})]})]}):null]})})}function F4(e){let t=new Date(e).getTime(),n=Math.round((Date.now()-t)/1e3);if(60>Math.abs(n))return n>=0?"just now":"in a moment";let r=n,i="second";for(let[e,t]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"],[4.345,"week"],[12,"month"],[1/0,"year"]]){if(Math.abs(r)<e)break;r/=e,i=t}return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(-Math.round(r),i)}function F6(e){let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`}var F7=e.i(42408);let F9={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 F8(e,t){return"directives"===e?{label:t?t("factTypeDirective"):"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===e?{label:t?t("factTypeMentalModel"):"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===e?{label:t?t("factTypeWorld"):"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===e?{label:t?t("factTypeExperience"):"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:"observation"===e?{label:t?t("factTypeObservation"):"observation",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}:{label:e,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"}}let Ve=["observation","experience","world","directives","mental-models"];function Vt({based_on:e,onViewMemory:t,onViewDirective:n}){let r=(0,M.useTranslations)("mentalModelDetailModal"),i=(0,E.useMemo)(()=>{if(!e)return[];let t=Object.entries(e).map(([e,t])=>({factType:e,facts:t??[]})).filter(e=>e.facts.length>0);return t.sort((e,t)=>{let n=Ve.indexOf(e.factType),r=Ve.indexOf(t.factType);return(-1===n?999:n)-(-1===r?999:r)}),t},[e]);return 0===i.length?(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:r("noBasedOnData")}):(0,_.jsx)("div",{className:"space-y-4",children:i.map(e=>{let i=F8(e.factType,r);return(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${i.color}`,children:i.label}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e.facts.length})]}),(0,_.jsx)("ul",{className:"divide-y divide-border/50",children:e.facts.map((i,a)=>{let o="directives"===e.factType&&!!n||"directives"!==e.factType&&"mental-models"!==e.factType&&!!t;return(0,_.jsxs)("li",{className:"group flex items-start gap-3 px-3 py-2 hover:bg-muted/30",children:[(0,_.jsxs)("p",{className:"text-sm text-foreground leading-relaxed flex-1 min-w-0",children:[i.text,i.context&&(0,_.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5",children:i.context})]}),o&&(0,_.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"===e.factType?n?.(i.id):t?.(i.id)},children:r("viewArrow")})]},i.id||a)})})]},e.factType)})})}function Vn(e){return e.match(/\s+|[A-Za-z0-9_]+|[^\s\w]/g)||[]}function Vr(e){return/^\s+$/.test(e)?" ":e}function Vi(e,t,n){let r={backgroundColor:n.removedWordBg,color:n.removedWordText,fontWeight:600,borderRadius:"2px"},i={backgroundColor:n.addedWordBg,color:n.addedWordText,fontWeight:600,borderRadius:"2px"};return e.map((e,n)=>"same"===e.type?(0,_.jsx)("span",{children:e.text},n):(0,_.jsx)("span",{style:"left"===t?r:i,children:e.text},n))}function Va({before:e,after:t}){let n=(0,M.useTranslations)("mentalModelDetailModal"),{theme:r}=(0,F7.useTheme)(),i=F9[r],{left:a,right:o}=function(e,t){let n=e.split("\n"),r=t.split("\n"),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=n[e-1]===r[t-1]?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],l=i,c=a;for(;l>0||c>0;)l>0&&c>0&&n[l-1]===r[c-1]?(s.push({type:"same",text:n[l-1]}),l--,c--):c>0&&(0===l||o[l][c-1]>=o[l-1][c])?(s.push({type:"added",text:r[c-1]}),c--):(s.push({type:"removed",text:n[l-1]}),l--);s.reverse();let u=[],d=[],h=0;for(;h<s.length;){let e=s[h];if("same"===e.type){u.push({type:"same",spans:[{type:"same",text:e.text}]}),d.push({type:"same",spans:[{type:"same",text:e.text}]}),h++;continue}let t=[],n=[];for(;h<s.length&&"same"!==s[h].type;)"removed"===s[h].type?t.push(s[h].text):n.push(s[h].text),h++;let r=Math.max(t.length,n.length);for(let e=0;e<r;e++){let r=e<t.length?t[e]:null,i=e<n.length?n[e]:null;if(null!==r&&null!==i){let e=function(e,t){let n=Vn(e),r=Vn(t),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=Vr(n[e-1])===Vr(r[t-1])?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],l=[],c=i,u=a,d=[],h=[];for(;c>0||u>0;)if(c>0&&u>0&&Vr(n[c-1])===Vr(r[u-1]))d.push({type:"same",text:n[c-1]}),h.push({type:"same",text:r[u-1]}),c--,u--;else if(u>0&&(0===c||o[c][u-1]>=o[c-1][u])){let e=r[u-1];h.push({type:/^\s+$/.test(e)?"same":"added",text:e}),u--}else{let e=n[c-1];d.push({type:/^\s+$/.test(e)?"same":"removed",text:e}),c--}for(;d.length;)s.push(d.pop());for(;h.length;)l.push(h.pop());return{left:s,right:l}}(r,i),t=e.left.some(e=>"same"!==e.type)?"removed":"same",n=e.right.some(e=>"same"!==e.type)?"added":"same";u.push({type:t,spans:e.left}),d.push({type:n,spans:e.right})}else null!==r?(u.push({type:"removed",spans:[{type:"removed",text:r}]}),d.push({type:"same",spans:[{type:"same",text:""}]})):null!==i&&(u.push({type:"same",spans:[{type:"same",text:""}]}),d.push({type:"added",spans:[{type:"added",text:i}]}))}}return{left:u,right:d}}(e,t);return a.some(e=>"same"!==e.type)||o.some(e=>"same"!==e.type)?(0,_.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border border border-border rounded-md overflow-hidden text-[13px] font-mono",style:{color:i.body},children:[(0,_.jsxs)("div",{children:[(0,_.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:n("diffBefore")}),a.map((e,t)=>(0,_.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"removed"===e.type?{backgroundColor:i.removedLineBg}:void 0,children:Vi(e.spans,"left",i)},t))]}),(0,_.jsxs)("div",{children:[(0,_.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:n("diffAfter")}),o.map((e,t)=>(0,_.jsx)("div",{className:"px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem]",style:"added"===e.type?{backgroundColor:i.addedLineBg}:void 0,children:Vi(e.spans,"right",i)},t))]})]}):(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:n("unchanged")})}function Vo({before:e,after:t,onViewMemory:n,onViewDirective:r}){let i=(0,M.useTranslations)("mentalModelDetailModal"),a=(0,E.useMemo)(()=>{let n=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),r=[];for(let i of n){let n=(e?.[i]??[]).filter(Boolean),a=(t?.[i]??[]).filter(Boolean),o=new Set(n.map(e=>e.id)),s=new Set(a.map(e=>e.id)),l=a.filter(e=>!o.has(e.id)),c=n.filter(e=>!s.has(e.id)),u=a.filter(e=>o.has(e.id));(0!==l.length||0!==c.length||0!==u.length)&&r.push({factType:i,added:l,removed:c,kept:u})}return r.sort((e,t)=>{let n=Ve.indexOf(e.factType),r=Ve.indexOf(t.factType);return(-1===n?999:n)-(-1===r?999:r)}),r},[e,t]);if(0===a.length)return(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:i("noBasedOnData")});let o=(e,t,a)=>(0,_.jsxs)("li",{className:`group flex items-start gap-2 px-3 py-2 ${"added"===a?"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"===a?"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,_.jsx)("span",{className:`font-mono text-sm shrink-0 ${"added"===a?"text-green-700 dark:text-green-400":"removed"===a?"text-red-700 dark:text-red-400":"text-muted-foreground/40"}`,children:"added"===a?"+":"removed"===a?"−":" "}),(0,_.jsxs)("p",{className:"text-sm leading-relaxed flex-1 min-w-0",children:[e.text,e.context&&(0,_.jsx)("span",{className:"block text-xs text-muted-foreground italic mt-0.5 no-underline",children:e.context})]}),("directives"===t&&!!r||"directives"!==t&&"mental-models"!==t&&!!n)&&"removed"!==a&&(0,_.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"===t?r(e.id):n(e.id)},children:i("viewArrow")})]},`${a}-${e.id}`);return(0,_.jsx)("div",{className:"space-y-4",children:a.map(e=>{let t=F8(e.factType,i);return(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b border-border/60",children:[(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ${t.color}`,children:t.label}),e.added.length>0&&(0,_.jsxs)("span",{className:"text-xs text-green-600 dark:text-green-400",children:["+",e.added.length]}),e.removed.length>0&&(0,_.jsxs)("span",{className:"text-xs text-red-600 dark:text-red-400",children:["−",e.removed.length]}),e.kept.length>0&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:i("keptCount",{count:e.kept.length})})]}),(0,_.jsxs)("ul",{className:"divide-y divide-border/40",children:[e.added.map(t=>o(t,e.factType,"added")),e.removed.map(t=>o(t,e.factType,"removed")),e.kept.map(t=>o(t,e.factType,"kept"))]})]},e.factType)})})}function Vs({history:e,currentContent:t,currentBasedOn:n,onViewMemory:r,onViewDirective:i}){let a=(0,M.useTranslations)("mentalModelDetailModal"),[o,s]=(0,E.useState)(0),l=e[o],c=0===o?t:e[o-1].previous_content??"",u=l.previous_reflect_response?.based_on,d=0===o?n:e[o-1].previous_reflect_response?.based_on,h=l.previous_reflect_response??null;return(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["v",e.length-o]})," →"," ",(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["v",e.length-o+1,0===o?a("versionCurrent"):""]})," ","· ",a("changedAt",{date:new Date(l.changed_at).toLocaleString()})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:o===e.length-1,onClick:()=>s(o+1),children:(0,_.jsx)(V,{className:"h-3.5 w-3.5"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:0===o,onClick:()=>s(o-1),children:(0,_.jsx)(H.ChevronRight,{className:"h-3.5 w-3.5"})})]})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vf,{children:a("contentDiff")}),null!==l.previous_content?(0,_.jsx)(Va,{before:l.previous_content,after:c}):(0,_.jsx)("div",{className:"border border-border rounded-lg p-3",children:(0,_.jsx)("span",{className:"text-sm text-muted-foreground italic",children:a("previousContentNotAvailable")})})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vf,{children:a("basedOnDiff")}),h?.based_on?(0,_.jsx)(Vo,{before:u,after:d,onViewMemory:r,onViewDirective:i}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:a("basedOnNotCaptured")})]})]})}function Vl({mentalModelId:e,onClose:t,onEdit:n,onDelete:r,onClear:i,onRefreshed:a,initialTab:o="content"}){let s=(0,M.useTranslations)("mentalModelDetailModal"),{currentBank:l}=(0,D.useBank)(),[c,u]=(0,E.useState)(null),[d,h]=(0,E.useState)(!1),[f,p]=(0,E.useState)(null),[g,x]=(0,E.useState)(o),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(null),[k,S]=(0,E.useState)(null),[C,T]=(0,E.useState)(null),[A,P]=(0,E.useState)(!1);(0,E.useEffect)(()=>{e&&l&&(async()=>{h(!0),p(null),u(null),T(null),x(o);try{let t=await $.client.getMentalModel(l,e);u(t)}catch(e){console.error("Error loading mental model:",e),p(e.message)}finally{h(!1)}})()},[e,l,o]),(0,E.useEffect)(()=>{"history"===g&&c&&l&&null===C&&(async()=>{P(!0);try{let e=await $.client.getMentalModelHistory(l,c.id);T(e)}catch(e){console.error("Error loading mental model history:",e),T([])}finally{P(!1)}})()},[g,c,l,C]);let L=async()=>{if(l&&c){w(!0);try{let e=await $.client.getMentalModel(l,c.id);u(e),T(null)}catch(e){console.error("Error reloading mental model:",e)}finally{w(!1)}}},I=async()=>{if(!l||!c)return;y(!0);let e=c.last_refreshed_at;try{await $.client.refreshMentalModel(l,c.id);let t=0,n=async()=>{t++;try{let r=await $.client.getMentalModel(l,c.id);if(r.last_refreshed_at!==e){u(r),T(null),a?.(r),y(!1);return}if(t>=120){y(!1),O.toast.error(s("refreshTimeoutTitle"),{description:s("refreshTimeoutDescription")});return}setTimeout(n,1e3)}catch(e){console.error("Error polling mental model:",e),y(!1)}};setTimeout(n,1e3)}catch{y(!1)}},R=null!==e,B=c?.reflect_response?.based_on,F=B?Object.values(B).reduce((e,t)=>e+(t?.length??0),0):0;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ta.Dialog,{open:R,onOpenChange:e=>!e&&t(),children:(0,_.jsxs)(ta.DialogContent,{className:"w-[95vw] max-w-[95vw] h-[92vh] sm:max-w-[95vw] flex flex-col overflow-hidden",children:[(0,_.jsx)(ta.DialogHeader,{className:"pr-10",children:(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"truncate",children:c?.name??s("mentalModelFallback")}),c&&(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:L,disabled:b,title:s("reloadData"),children:(0,_.jsx)(er,{className:`h-3.5 w-3.5 ${b?"animate-spin":""}`})}),c?.trigger?.refresh_after_consolidation&&(0,_.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,_.jsx)(L5,{className:"w-3 h-3"}),s("autoRefresh")]})]})}),d?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsx)(tn.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):f?(0,_.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,_.jsx)("div",{className:"text-center text-destructive",children:(0,_.jsx)("div",{className:"text-sm",children:s("errorPrefix",{error:f})})})}):c?(0,_.jsxs)(ts.Tabs,{value:g,onValueChange:e=>x(e),className:"flex-1 flex flex-col overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,_.jsxs)(ts.TabsList,{className:"grid grid-cols-3 w-full max-w-md",children:[(0,_.jsxs)(ts.TabsTrigger,{value:"content",className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),s("tabContent")]}),(0,_.jsxs)(ts.TabsTrigger,{value:"configuration",className:"flex items-center gap-1.5",children:[(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),s("tabConfiguration")]}),(0,_.jsxs)(ts.TabsTrigger,{value:"history",className:"flex items-center gap-1.5",children:[(0,_.jsx)(tr,{className:"w-3.5 h-3.5"}),s("tabHistory")]})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 shrink-0",disabled:v,"aria-label":s("actionsAriaLabel"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",children:[n&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>n(c),children:[(0,_.jsx)(PX,{className:"h-4 w-4 mr-2"}),s("actionEdit")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:I,disabled:v,children:[(0,_.jsx)(er,{className:"h-4 w-4 mr-2"}),s("actionRefreshManually")]}),i&&(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>i(c),children:[(0,_.jsx)(L3,{className:"h-4 w-4 mr-2"}),s("actionClearContent")]}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>r(c),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),s("actionDelete")]})]})]})]})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,_.jsxs)(ts.TabsContent,{value:"content",className:"mt-0 space-y-6",children:[(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 overflow-hidden",children:[(0,_.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,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),(0,_.jsx)("span",{className:"font-semibold uppercase tracking-wide",children:s("storedContent")}),(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",s("charsCount",{count:c.content.length})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[!0===c.is_stale?(0,_.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:s("staleTitle"),children:s("stale")}):!1===c.is_stale?(0,_.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:s("inSyncTitle"),children:s("inSync")}):null,(0,_.jsxs)("span",{title:F6(c.last_refreshed_at),className:"flex items-center gap-1",children:[(0,_.jsx)(er,{className:"w-3 h-3"}),s("lastRefreshed",{time:F4(c.last_refreshed_at)})]})]})]}),(0,_.jsx)(F2,{className:"p-4",children:c.content})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)(Vf,{children:F>0?s("basedOnWithCount",{count:F}):s("basedOn")}),c.reflect_response?(0,_.jsx)(Vt,{based_on:B,onViewMemory:e=>N(e),onViewDirective:e=>S(e)}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:s("noSourceData")})]})]}),(0,_.jsx)(ts.TabsContent,{value:"configuration",className:"mt-0",children:(0,_.jsx)(Vh,{mentalModel:c})}),(0,_.jsx)(ts.TabsContent,{value:"history",className:"mt-0",children:A?(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):C&&C.length>0?(0,_.jsx)(Vs,{history:C,currentContent:c.content,currentBasedOn:B,onViewMemory:e=>N(e),onViewDirective:e=>S(e)}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:s("noHistory")})})]})]}):null]})}),j&&(0,_.jsx)(tp,{memoryId:j,onClose:()=>N(null)}),k&&(0,_.jsx)(F3,{directiveId:k,onClose:()=>S(null)})]})}function Vc({label:e,value:t}){return(0,_.jsxs)("div",{children:[(0,_.jsx)(Vf,{children:e}),(0,_.jsx)("div",{className:"text-sm text-foreground",children:t})]})}function Vu({title:e,icon:t,children:n}){return(0,_.jsxs)("div",{className:"rounded-lg border border-border bg-muted/20 overflow-hidden",children:[(0,_.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:[t,e]}),(0,_.jsx)("div",{className:"p-4 space-y-4",children:n})]})}function Vd({label:e,color:t}){return(0,_.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${t??"bg-muted text-foreground border border-border/60"}`,children:e})}function Vh({mentalModel:e}){let t=(0,M.useTranslations)("mentalModelDetailModal"),n=e.trigger??{refresh_after_consolidation:!1},r=n.fact_types??[],i=n.tag_groups??[],a=n.exclude_mental_model_ids??[];return(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsxs)(Vu,{title:t("identityTitle"),icon:(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vc,{label:t("labelId"),value:(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground break-all",children:e.id})}),(0,_.jsx)(Vc,{label:t("labelName"),value:e.name}),e.source_query&&(0,_.jsx)(Vc,{label:t("labelSourceQuery"),value:(0,_.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:e.source_query})}),(0,_.jsx)(Vc,{label:t("labelTags"),value:e.tags?.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(e=>(0,_.jsx)(Vd,{label:e,color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"},e))}):(0,_.jsx)("span",{className:"text-muted-foreground italic text-sm",children:t("noTags")})})]}),(0,_.jsxs)(Vu,{title:t("timingTitle"),icon:(0,_.jsx)(er,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vc,{label:t("labelCreated"),value:F6(e.created_at)}),(0,_.jsx)(Vc,{label:t("labelLastRefreshed"),value:(0,_.jsx)("span",{title:F6(e.last_refreshed_at),children:F4(e.last_refreshed_at)})}),(0,_.jsx)(Vc,{label:t("labelMaxTokens"),value:e.max_tokens.toLocaleString()})]}),(0,_.jsxs)(Vu,{title:t("refreshTriggerTitle"),icon:(0,_.jsx)(L5,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vc,{label:t("labelRefreshMode"),value:"delta"===n.mode?(0,_.jsx)(Vd,{label:t("pillDelta"),color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}):(0,_.jsx)(Vd,{label:t("pillFull")})}),(0,_.jsx)(Vc,{label:t("labelAutoRefreshAfterConsolidation"),value:n.refresh_after_consolidation?(0,_.jsx)(Vd,{label:t("pillEnabled"),color:"bg-green-500/10 text-green-600 dark:text-green-400"}):(0,_.jsx)(Vd,{label:t("pillDisabled")})}),(0,_.jsx)(Vc,{label:t("labelFactTypes"),value:r.length>0?(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>{let n=F8(e,t);return(0,_.jsx)(Vd,{label:n.label,color:n.color},e)})}):(0,_.jsx)("span",{className:"text-muted-foreground italic text-sm",children:t("factTypesAll")})}),(0,_.jsx)(Vc,{label:t("labelExcludeMentalModels"),value:n.exclude_mental_models?t("valueYes"):t("valueNo")}),a.length>0&&(0,_.jsx)(Vc,{label:t("labelExcludedIds"),value:(0,_.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(e=>(0,_.jsx)("code",{className:"text-xs font-mono px-1.5 py-0.5 rounded bg-muted border border-border/60",children:e},e))})})]}),(0,_.jsxs)(Vu,{title:t("recallParamsTitle"),icon:(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),children:[(0,_.jsx)(Vc,{label:t("labelIncludeChunks"),value:null==n.include_chunks?t("includeChunksDefault"):n.include_chunks?t("valueYes"):t("valueNo")}),(0,_.jsx)(Vc,{label:t("labelRecallMaxTokens"),value:null!=n.recall_max_tokens?n.recall_max_tokens.toLocaleString():t("recallMaxTokensDefault")}),(0,_.jsx)(Vc,{label:t("labelRecallChunksMaxTokens"),value:null!=n.recall_chunks_max_tokens?n.recall_chunks_max_tokens.toLocaleString():t("recallChunksMaxTokensDefault")}),(0,_.jsx)(Vc,{label:t("labelTagsMatch"),value:n.tags_match?(0,_.jsx)(Vd,{label:n.tags_match}):t("tagsMatchDefault")})]}),i.length>0&&(0,_.jsx)("div",{className:"md:col-span-2",children:(0,_.jsx)(Vu,{title:t("tagGroupsTitle"),icon:(0,_.jsx)(U,{className:"w-3.5 h-3.5"}),children:(0,_.jsx)("pre",{className:"text-xs font-mono bg-muted/40 rounded p-3 overflow-x-auto border border-border/60",children:JSON.stringify(i,null,2)})})})]})}function Vf({children:e}){return(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:e})}function Vp(){let e,t,n,r,i,a,o,s,l,c,u,d=(0,M.useTranslations)("thinkView"),{currentBank:h}=(0,D.useBank)(),[f,p]=(0,E.useState)(""),[g,x]=(0,E.useState)("mid"),[v,y]=(0,E.useState)(4096),[b,w]=(0,E.useState)(!0),[j,N]=(0,E.useState)(!0),[k,S]=(0,E.useState)("answer"),[C,T]=(0,E.useState)(null),[O,A]=(0,E.useState)(!1),[P,L]=(0,E.useState)(""),[I,z]=(0,E.useState)("any"),[F,V]=(0,E.useState)([]),[H,U]=(0,E.useState)(!1),[W,Y]=(0,E.useState)(""),[G,K]=(0,E.useState)(""),[Z,Q]=(0,E.useState)(!1),[J,ee]=(0,E.useState)(!1),[et,en]=(0,E.useState)(null),[er,ei]=(0,E.useState)(null),[eo,es]=(0,E.useState)(null),[el,ec]=(0,E.useState)(!1),[eu,ed]=(0,E.useState)(null),[eh,ef]=(0,E.useState)(null),[ep,em]=(0,E.useState)(!1),[eg,ex]=(0,E.useState)(null),[ev,ey]=(0,E.useState)("world"),eb="General Feedback",ew=async e=>{if(ed(e),ef(null),h&&e?.id){em(!0);try{let t=await $.client.listObservations(h),n=t.items?.find(t=>t.id===e.id);ef(n||e)}catch(t){console.error("Failed to load observation:",t),ef(e)}finally{em(!1)}}},ej=async()=>{if(h&&G.trim()){Q(!0);try{let e=await $.client.listDirectives(h),t=e.items?.find(e=>e.name===eb);if(t){let e=t.content?`${t.content}
|
|
8
|
+
${G.trim()}`:G.trim();await $.client.updateDirective(h,t.id,{content:e})}else await $.client.createDirective(h,{name:eb,content:G.trim()});K(""),ee(!0),setTimeout(()=>ee(!1),3e3)}catch(e){}finally{Q(!1)}}},eN=async()=>{if(h&&f){A(!0),S("answer");try{let e=P.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=W.split(",").map(e=>e.trim()).filter(e=>e.length>0),n=await $.client.reflect({bank_id:h,query:f,budget:g,max_tokens:v,include_facts:b,include_tool_calls:j,...e.length>0&&{tags:e,tags_match:I},...F.length>0&&{fact_types:F},...H&&{exclude_mental_models:!0},...t.length>0&&{exclude_mental_model_ids:t}});T(n)}catch(e){}finally{A(!1)}}};return h?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"pt-6",children:[(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsxs)("div",{className:"flex-1 relative",children:[(0,_.jsx)(R,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"text",value:f,onChange:e=>p(e.target.value),placeholder:d("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&eN()})]}),(0,_.jsx)(X.Button,{onClick:eN,disabled:O||!f,className:"h-12 px-8",children:O?d("reflecting"):d("reflect")})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:d("budgetLabel")}),(0,_.jsxs)(e6.Select,{value:g,onValueChange:e=>x(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-24 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"low",children:d("budgetLow")}),(0,_.jsx)(e6.SelectItem,{value:"mid",children:d("budgetMid")}),(0,_.jsx)(e6.SelectItem,{value:"high",children:d("budgetHigh")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:d("tokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:v,onChange:e=>y(parseInt(e.target.value)||4096),className:"w-24 h-8"})]}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:b,onCheckedChange:e=>w(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("includeSource")})]}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:j,onCheckedChange:e=>N(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("includeTools")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,_.jsx)(e7,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("div",{className:"flex-1 max-w-md",children:(0,_.jsx)(q.Input,{type:"text",value:P,onChange:e=>L(e.target.value),placeholder:d("tagsPlaceholder"),className:"h-8"})}),(0,_.jsxs)(e6.Select,{value:I,onValueChange:e=>z(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-40 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"any",children:d("tagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:d("tagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:d("tagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:d("tagsMatchAllStrict")})]})]})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsx)(La,{value:F,onChange:V}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:H,onCheckedChange:e=>U(e)}),(0,_.jsx)("span",{className:"text-sm",children:d("excludeMentalModels")})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:d("excludeIdsLabel")}),(0,_.jsx)(q.Input,{type:"text",value:W,onChange:e=>Y(e.target.value),placeholder:d("excludeIdsPlaceholder"),className:"h-8 w-48"})]})]})]})}),O&&(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:d("reflectingOnMemories")})]})}),!O&&C&&(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[C.usage&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("inputTokensLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.usage.input_tokens?.toLocaleString()})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("outputTokensLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.usage.output_tokens?.toLocaleString()})]})]}),C.trace?.tool_calls&&(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("toolCallsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.trace.tool_calls.length}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.tool_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),C.trace?.llm_calls&&(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:d("llmCallsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:C.trace.llm_calls.length}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:["(",C.trace.llm_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(e=>(0,_.jsx)("button",{onClick:()=>S(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${k===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===e?d("viewAnswer"):"trace"===e?d("viewTrace"):d("viewJson")},e))})]}),"answer"===k&&(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{children:d("answerTitle")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,_.jsx)(zj,{remarkPlugins:[FJ],children:C.text})})})]}),(0,_.jsxs)(tm.Card,{className:"border-blue-200 dark:border-blue-800",children:[(0,_.jsxs)(tm.CardHeader,{className:"py-4",children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,_.jsx)(Lc,{className:"w-4 h-4"}),d("addDirectiveTitle")]}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("addDirectiveDescription")})]}),(0,_.jsx)(tm.CardContent,{className:"pt-0",children:J?(0,_.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,_.jsx)("span",{className:"text-lg",children:"✓"}),(0,_.jsx)("span",{className:"text-sm font-medium",children:d("directiveSaved",{name:eb})})]}):(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsx)(Lh.Textarea,{value:G,onChange:e=>K(e.target.value),placeholder:d("directivePlaceholder"),className:"flex-1 min-h-[60px] resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ej()}}),(0,_.jsx)(X.Button,{onClick:ej,disabled:Z||!G.trim(),className:"self-end",children:Z?d("savingDirective"):d("saveDirective")})]})})]})]}),"trace"===k&&(0,_.jsxs)("div",{className:"space-y-4",children:[C.observations_created&&C.observations_created.length>0&&(0,_.jsxs)(tm.Card,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,_.jsxs)(tm.CardHeader,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-base",children:[(0,_.jsx)(Ll,{className:"w-4 h-4 text-emerald-600"}),d("observationsCreatedTitle",{count:C.observations_created.length})]}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("observationsCreatedDescription")})]}),(0,_.jsx)(tm.CardContent,{className:"pt-4",children:(0,_.jsx)("div",{className:"space-y-2",children:C.observations_created.map((e,t)=>(0,_.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,_.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:e.name}),(0,_.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:e.description}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",e.id]})]},t))})})]}),(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,_.jsxs)(tm.Card,{className:"h-fit",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-base",children:d("executionTraceTitle")}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("executionTraceDescription",{iterations:C.iterations||0,iterationsPlural:1!==(C.iterations||0)?"s":"",totalMs:(C.trace?.llm_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)+(C.trace?.tool_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)})})]}),(0,_.jsx)(tm.CardContent,{children:j?C.trace?.llm_calls&&C.trace.llm_calls.length>0||C.trace?.tool_calls&&C.trace.tool_calls.length>0?(0,_.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(e=C.trace?.llm_calls||[],t=C.trace?.tool_calls||[],n=[],e.forEach((r,i)=>{let a=t.filter(e=>e.iteration===i+1),o=i===e.length-1,s=r.scope.includes("final")||o&&0===a.length,l=s?e.length:i+1;n.push({type:"llm",llm:r,iteration:l,isFinal:s}),a.length>0&&n.push({type:"tools",tools:a,iteration:i+1})}),n.map((e,t)=>(0,_.jsxs)("div",{className:"relative",children:[t<n.length-1&&(0,_.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===e.type?(0,_.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,_.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${e.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:e.isFinal?(0,_.jsx)(te.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,_.jsx)("span",{className:"text-[10px] font-semibold",children:e.iteration})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("span",{className:"font-medium text-sm",children:e.isFinal?d("responseGenerated"):d("agentDecided")}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(ea,{className:"w-3 h-3"}),e.llm.duration_ms,"ms"]})]}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e.isFinal?d("finalAnswer"):d("calledToolsBelow")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,_.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,_.jsx)(Ld,{className:"w-3 h-3",fill:"currentColor"})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,_.jsx)("div",{className:"text-xs text-muted-foreground",children:(e.tools?.length??0)!==1?d("executingToolsPlural",{count:e.tools?.length??0}):d("executingTools",{count:e.tools?.length??0})}),e.tools?.map((e,t)=>(0,_.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.tool}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(ea,{className:"w-3 h-3"}),e.duration_ms,"ms"]})]}),(0,_.jsxs)("div",{className:"p-2 space-y-2",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:d("toolInputLabel")}),(0,_.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,_.jsx)(L2,{src:e.input,collapsed:1,theme:"default"})})]}),e.output&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:d("toolOutputLabel")}),(0,_.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,_.jsx)(L2,{src:e.output,collapsed:1,theme:"default"})})]})]})]},t))]})]})]},t)))}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Ls.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("noOperations")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("noOperationsDescription")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Ls.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("notIncluded")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("enableIncludeTools")})]})]})})]}),(0,_.jsxs)(tm.Card,{className:"h-fit",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-base",children:d("basedOnTitle")}),(0,_.jsx)(tm.CardDescription,{className:"text-xs",children:d("basedOnDescription",{count:(C.based_on?.memories?.length||0)+(C.based_on?.observations?.filter(e=>"directive"!==e.subtype)?.length||0)+(C.based_on?.directives?.length||0)})})]}),(0,_.jsx)(tm.CardContent,{children:b?C.based_on?.memories&&C.based_on.memories.length>0||C.based_on?.mental_models&&C.based_on.mental_models.length>0||C.based_on?.directives&&C.based_on.directives.length>0||C.based_on?.observations&&C.based_on.observations.length>0?(i=(r=C.based_on?.memories||[]).filter(e=>"world"===e.type),a=r.filter(e=>"experience"===e.type),o=C.based_on?.mental_models||[],s=(C.based_on?.observations||[]).filter(e=>"directive"!==e.subtype),l=C.based_on?.directives||[],c=[{id:"directives",label:d("tabDirectives"),count:l.length},{id:"mental_models",label:d("tabMentalModels"),count:o.length},{id:"observations",label:d("tabObservations"),count:s.length},{id:"world",label:d("tabWorld"),count:i.length},{id:"experience",label:d("tabExperience"),count:a.length}],u=(()=>{switch(ev){case"directives":return l;case"mental_models":return o;case"observations":return s;case"world":return i;case"experience":return a;default:return[]}})(),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:c.map(e=>(0,_.jsxs)("button",{onClick:()=>ey(e.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${ev===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.label," (",e.count,")"]},e.id))}),u.length>0?(0,_.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:u.map((e,t)=>{let n,r;return(0,_.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==ev?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==ev&&("observations"===ev?ew(e):"mental_models"===ev?ex(e.id):en(e.id))},children:"directives"===ev?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.content&&(0,_.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.content})]}):"observations"===ev?(0,_.jsx)("div",{className:"font-medium text-sm",children:e.name}):"mental_models"===ev?(r=(n=e.text?.indexOf(": ")??-1)>0?e.text.slice(0,n):e.id,(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"font-medium text-sm",children:r}),(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.id})]})):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text}),e.context&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:e.context})]})},e.id||t)})}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:d("noTabItems",{tab:ev})})]})):(0,_.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,_.jsx)(Ls.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:d("noFactsFound")}),(0,_.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:d("noFactsFoundDescription")})]})]}):(0,_.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,_.jsx)(Ls.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"font-medium text-sm text-foreground",children:d("notIncludedBasedOn")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:d("enableIncludeSource")})]})]})})]})]})]}),"json"===k&&(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{className:"text-lg",children:d("rawResponseTitle")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,_.jsx)(L2,{src:C,collapsed:2,theme:"default"})})})]})]}),!O&&!C&&(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(R,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-lg font-semibold mb-2",children:d("readyToReflect")}),(0,_.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:d("readyToReflectDescription")})]})}),(0,_.jsx)(tp,{memoryId:et,onClose:()=>en(null)}),er&&(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Lu,{className:"w-5 h-5"}),(0,_.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"icon",onClick:()=>{ei(null),es(null)},children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]}),el?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,_.jsx)("p",{className:"mt-1 font-medium",children:eo?.name||er.name})]}),eo?.description&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,_.jsx)("p",{className:"mt-1 text-sm",children:eo.description})]}),eo?.tags&&eo.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:eo.tags.map(e=>(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(e7,{className:"w-2.5 h-2.5"}),e]},e))})]}),(eo?.content||er.content)&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,_.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:eo?.content||er.content})})]}),(0,_.jsxs)("div",{className:"pt-2 border-t",children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,_.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:er.id})]})]})]})}),eu&&(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Ll,{className:"w-5 h-5"}),(0,_.jsx)("h2",{className:"text-lg font-semibold",children:d("observationPanelTitle")})]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"icon",onClick:()=>{ed(null),ef(null)},children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]}),ep?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:d("observationTextField")}),(0,_.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,_.jsx)(zj,{remarkPlugins:[FJ],children:eh?.text||eu.text})})]}),eh?.tags&&eh.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:d("observationTagsField")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:eh.tags.map(e=>(0,_.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,_.jsx)(e7,{className:"w-2.5 h-2.5"}),e]},e))})]}),eh?.source_memories&&eh.source_memories.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:d("observationSourceMemoriesField",{count:eh.source_memories.length})}),(0,_.jsx)("div",{className:"space-y-2",children:eh.source_memories.map((e,t)=>(0,_.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,_.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.text||("string"==typeof e?e:"")})},t))})]}),(0,_.jsxs)("div",{className:"pt-2 border-t",children:[(0,_.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:d("observationIdField")}),(0,_.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:eu.id})]})]})]})}),(0,_.jsx)(Vl,{mentalModelId:eg,onClose:()=>ex(null)})]}):(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2",children:d("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:d("noBankSelectedDescription")})]})})}let Vm=(0,I.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function Vg(){let e,t,n,r,i,a,o,s,l,c,u,d,h,f,p=(0,M.useTranslations)("searchDebug"),{currentBank:g}=(0,D.useBank)(),[x,v]=(0,E.useState)(""),[y,b]=(0,E.useState)(["world"]),[w,j]=(0,E.useState)("mid"),[N,k]=(0,E.useState)(4096),[S,C]=(0,E.useState)(""),[T,A]=(0,E.useState)(!1),[P,I]=(0,E.useState)(!1),[R,V]=(0,E.useState)(""),[U,W]=(0,E.useState)("any"),[Y,G]=(0,E.useState)(null),[Z,Q]=(0,E.useState)(null),[J,ee]=(0,E.useState)(null),[et,en]=(0,E.useState)(null),[er,ei]=(0,E.useState)(null),[eo,es]=(0,E.useState)(!1),[el,ec]=(0,E.useState)("results"),[eu,ed]=(0,E.useState)(null),[eh,ef]=(0,E.useState)(new Set),[ep,em]=(0,E.useState)(new Set),eg=e=>{ef(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ex=e=>{em(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ev=e=>{let t=e.id||e.node_id;ed(Y?.find(e=>e.id===t||e.node_id===t)||e)},ey=async()=>{if(!g)return void O.toast.error(p("errorSelectBank"));if(x){if(0===y.length)return void O.toast.error(p("errorSelectFactType"));es(!0);try{let e=R.split(",").map(e=>e.trim()).filter(e=>e.length>0),t={bank_id:g,query:x,types:y,budget:w,max_tokens:N,trace:!0,include:{entities:P?{max_tokens:500}:null,chunks:T?{max_tokens:8192}:null},...S&&{query_timestamp:S},...e.length>0&&{tags:e,tags_match:U}},n=await $.client.recall(t);G(n.results||[]),Q(n.entities||null),ee(n.chunks||null),en(n.observations||null),ei(n.trace||null),ec("results")}catch(e){}finally{es(!1)}}};return g?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"pt-6",children:[(0,_.jsxs)("div",{className:"flex gap-3",children:[(0,_.jsxs)("div",{className:"flex-1 relative",children:[(0,_.jsx)(L.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"text",value:x,onChange:e=>v(e.target.value),placeholder:p("queryPlaceholder"),className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&ey()})]}),(0,_.jsx)(X.Button,{onClick:ey,disabled:eo||!x,className:"h-12 px-8",children:eo?p("searching"):p("recall")})]}),(0,_.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,_.jsx)(La,{value:y,onChange:b,label:p("typesLabel")}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(L5,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsxs)(e6.Select,{value:w,onValueChange:e=>j(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-24 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"low",children:p("budgetLow")}),(0,_.jsx)(e6.SelectItem,{value:"mid",children:p("budgetMid")}),(0,_.jsx)(e6.SelectItem,{value:"high",children:p("budgetHigh")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:p("tokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:N,onChange:e=>k(parseInt(e.target.value)),className:"w-24 h-8"})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(ea,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)(q.Input,{type:"datetime-local",value:S,onChange:e=>C(e.target.value),className:"h-8",placeholder:p("queryDatePlaceholder")})]}),(0,_.jsx)("div",{className:"h-6 w-px bg-border"}),(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:T,onCheckedChange:e=>A(e)}),(0,_.jsx)(z.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-sm",children:p("chunks")})]}),(0,_.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,_.jsx)(Pm.Checkbox,{checked:P,onCheckedChange:e=>I(e)}),(0,_.jsx)(F,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-sm",children:p("entities")})]})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,_.jsx)(e7,{className:"h-4 w-4 text-muted-foreground"}),(0,_.jsx)("div",{className:"flex-1 max-w-md",children:(0,_.jsx)(q.Input,{type:"text",value:R,onChange:e=>V(e.target.value),placeholder:p("tagsPlaceholder"),className:"h-8"})}),(0,_.jsxs)(e6.Select,{value:U,onValueChange:e=>W(e),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-40 h-8",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"any",children:p("tagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:p("tagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:p("tagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:p("tagsMatchAllStrict")})]})]})]})]})}),eo&&(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("searchingMemories")})]})}),!eo&&Y&&(0,_.jsxs)("div",{className:"space-y-4",children:[er?.summary&&(0,_.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("resultsLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:Y.length})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("durationLabel")}),(0,_.jsxs)("span",{className:"font-semibold",children:[er.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:p("nodesVisitedLabel")}),(0,_.jsx)("span",{className:"font-semibold",children:er.summary.total_nodes_visited})]}),(0,_.jsx)("div",{className:"flex-1"}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(e=>(0,_.jsx)("button",{onClick:()=>ec(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${el===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===e?p("viewResults"):"trace"===e?p("viewTrace"):p("viewJson")},e))})]}),"results"===el&&(0,_.jsxs)("div",{className:"space-y-4",children:[et&&et.length>0&&(0,_.jsxs)(tm.Card,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,_.jsx)(tm.CardHeader,{className:"py-3",children:(0,_.jsxs)(tm.CardTitle,{className:"text-base flex items-center gap-2",children:[(0,_.jsx)(B,{className:"h-4 w-4 text-orange-500"}),(0,_.jsx)("span",{children:"Observations"}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",et.length,")"]})]})}),(0,_.jsx)(tm.CardContent,{className:"pt-0 space-y-2",children:et.map((e,t)=>(0,_.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,_.jsx)("p",{className:"text-sm text-foreground",children:e.text}),(0,_.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,_.jsx)("span",{children:p("proofCount",{count:e.proof_count||1})}),(0,_.jsx)("span",{children:p("relevance",{value:(e.relevance||0).toFixed(3)})})]})]},e.id||t))})]}),(0,_.jsx)("div",{className:"space-y-3",children:0!==Y.length||et&&0!==et.length?Y.map((e,t)=>{let n=er?.visits?.find(t=>t.node_id===e.id),r=n?n.weights.final_weight:e.score||0;return(0,_.jsx)(tm.Card,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ed(e),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-start gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-semibold text-primary",children:t+1})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-foreground",children:e.text}),(0,_.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:e.type||"world"}),e.context&&(0,_.jsx)("span",{className:"truncate max-w-xs",children:e.context}),e.occurred_start&&(0,_.jsx)("span",{children:new Date(e.occurred_start).toLocaleDateString()})]})]}),(0,_.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,_.jsx)("div",{className:"text-sm font-semibold",children:(r??0).toFixed(3)}),(0,_.jsx)("div",{className:"text-xs text-muted-foreground",children:p("scoreLabel")})]}),(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},t)}):(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-12",children:[(0,_.jsx)(L.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("noMemoriesFound")})]})})})]}),"trace"===el&&er&&(0,_.jsxs)("div",{className:"space-y-4",children:[er.retrieval_results&&er.retrieval_results.length>0&&(e={},er.retrieval_results.forEach(t=>{let n=t.fact_type||"all";e[n]||(e[n]=[]),e[n].push(t)}),t=Object.keys(e),(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,_.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,_.jsx)("span",{children:p("parallelRetrieval")}),(0,_.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,_.jsx)("div",{className:"space-y-2",children:t.map((t,n)=>{let r=e[t],i=`lane-${t}`,a=eh.has(i),o=r.reduce((e,t)=>e+(t.results?.length||0),0),s=Math.max(...r.map(e=>e.duration_seconds||0)),l={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"}},c=l[t]||l.all;return(0,_.jsx)(tm.Card,{className:`transition-colors ${a?"border-primary":c.border}`,children:(0,_.jsxs)(tm.CardContent,{className:"py-3 px-4",children:[(0,_.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>eg(i),children:[(0,_.jsx)("div",{className:`w-8 h-8 rounded-lg ${c.bg} flex items-center justify-center`,children:(0,_.jsx)("span",{className:`text-sm font-bold ${c.text} capitalize`,children:t.charAt(0).toUpperCase()})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground capitalize",children:t}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:p("methodsCount",{count:r.length})})]}),(0,_.jsx)("div",{className:"flex gap-1.5 mt-1",children:r.map((e,t)=>(0,_.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[e.method_name,": ",e.results?.length||0]},t))})]}),(0,_.jsxs)("div",{className:"text-right",children:[(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:o}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[s.toFixed(2),"s"]})]}),a?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),a&&(0,_.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,_.jsx)("div",{className:`grid gap-3 ${1===r.length?"grid-cols-1":2===r.length?"grid-cols-2":3===r.length?"grid-cols-3":"grid-cols-4"}`,children:r.map((e,t)=>{let n,r,a,o,s=`${i}-method-${t}`,l=eh.has(s),c=e.results||[];return(0,_.jsxs)("div",{className:"flex flex-col",children:[(0,_.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${l?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:e=>{e.stopPropagation(),eg(s)},children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:e.method_name}),"temporal"===e.method_name&&e.metadata?.constraint&&(0,_.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,_.jsx)(K,{className:"h-3 w-3"}),e.metadata.constraint.start?new Date(e.metadata.constraint.start).toLocaleDateString():"any"," → ",e.metadata.constraint.end?new Date(e.metadata.constraint.end).toLocaleDateString():"any"]})]}),l?(0,_.jsx)(PK.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,_.jsxs)("div",{className:"flex items-end justify-between",children:[(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:c.length}),(0,_.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[e.duration_seconds?.toFixed(2),"s"]})]})]}),l&&c.length>0&&(n=`results-${s}`,a=(r=ep.has(n))?c:c.slice(0,5),o=c.length>5,(0,_.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[a.map((e,t)=>(0,_.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-2",children:[(0,_.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:e.text}),(0,_.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(e.score||e.similarity||0).toFixed(4)})})]})]})},t)),o&&(0,_.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(n)},children:r?p("showLess"):p("viewAllResults",{count:c.length})})]}))]},s)})})})]})},i)})}),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)("div",{className:"flex items-center gap-2",children:t.map((e,t)=>{let n={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,_.jsx)("div",{className:"flex flex-col items-center",children:(0,_.jsx)("div",{className:`w-1 h-4 ${n[e]||n.all} rounded-full opacity-50`})},t)})})}),(0,_.jsx)("div",{className:"flex justify-center",children:(0,_.jsx)(Vm,{className:"h-5 w-5 text-muted-foreground/50"})})]})),er.rrf_merged&&(n="rrf-merge",r=eh.has(n),(0,_.jsxs)("div",{children:[(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors ${r?"border-primary":"hover:border-primary/50"}`,onClick:()=>eg(n),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("rrfFusion")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rrfMerge")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("rrfDescription")})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:er.rrf_merged.length}),r?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),r&&er.rrf_merged.length>0&&(i="results-rrf",o=(a=ep.has(i))?er.rrf_merged:er.rrf_merged.slice(0,5),s=er.rrf_merged.length>5,(0,_.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[o.map((e,t)=>(0,_.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,_.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[p("rrfScore")," ",(e.rrf_score||e.score||0).toFixed(4)]})]})]})},t)),s&&(0,_.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(i)},children:a?p("showLess"):p("viewAllResults",{count:er.rrf_merged.length})})]})),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)(Vm,{className:"h-4 w-4 text-muted-foreground/50"})})]})),er.reranked&&(l="reranking",c=eh.has(l),(0,_.jsxs)("div",{children:[(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors ${c?"border-primary":"hover:border-primary/50"}`,onClick:()=>eg(l),children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("combinedScoring")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:p("rerank")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,_.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-foreground",children:er.reranked.length}),c?(0,_.jsx)(PK.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),c&&er.reranked.length>0&&(u="results-rerank",h=(d=ep.has(u))?er.reranked:er.reranked.slice(0,5),f=er.reranked.length>5,(0,_.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[h.map((e,t)=>{let n=e.score_components||{};return(0,_.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),ev(e)},children:(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,_.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,_.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(e.rerank_score||e.score||0).toFixed(4)]}),void 0!==n.cross_encoder_score_normalized&&(0,_.jsxs)("span",{title:p("tooltipCrossEncoder"),children:["CE: ",n.cross_encoder_score_normalized.toFixed(3)]}),void 0!==n.temporal&&.5!==n.temporal&&(0,_.jsxs)("span",{title:p("tooltipTemporal"),children:["Tmp: ",n.temporal.toFixed(3)]}),void 0!==n.recency&&(0,_.jsxs)("span",{title:p("tooltipRecency"),children:["Rec: ",n.recency.toFixed(3)]})]})]})]})},t)}),f&&(0,_.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ex(u)},children:d?p("showLess"):p("viewAllResults",{count:er.reranked.length})})]})),(0,_.jsx)("div",{className:"flex justify-center py-2",children:(0,_.jsx)(Vm,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,_.jsx)(tm.Card,{className:"border-primary bg-primary/5",children:(0,_.jsx)(tm.CardContent,{className:"py-4",children:(0,_.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,_.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"font-semibold text-foreground",children:p("finalResults")}),(0,_.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:p("output")})]}),(0,_.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:p("finalResultsDescription")})]}),(0,_.jsx)("div",{className:"text-2xl font-bold text-primary",children:Y?.length||0})]})})})]}),"json"===el&&(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{children:(0,_.jsx)(tm.CardTitle,{className:"text-lg",children:p("rawResponse")})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,_.jsx)(L2,{src:{results:Y,...Z&&{entities:Z},...J&&{chunks:J},...et&&{observations:et},trace:er},collapsed:2,theme:"default"})})})]})]}),!eo&&!Y&&(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(L.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-lg font-semibold mb-2",children:p("readyToRecall")}),(0,_.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:p("readyToRecallDescription")})]})}),eu&&(0,_.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,_.jsx)(wz,{memory:eu,onClose:()=>ed(null),inPanel:!0,bankId:g||void 0})})]}):(0,_.jsx)(tm.Card,{className:"border-dashed",children:(0,_.jsxs)(tm.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,_.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2",children:p("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:p("noBankSelectedDescription")})]})})}let Vx=(0,I.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 Vv=e.i(82458),Vv=Vv,tn=tn;let Vy=["skepticism","literalism","empathy"];function Vb(){let e=(0,M.useTranslations)("bankProfile");return{skepticism:{label:e("skepticismLabel"),shortLabel:"S",description:e("skepticismDescription"),lowLabel:e("skepticismLow"),highLabel:e("skepticismHigh")},literalism:{label:e("literalismLabel"),shortLabel:"L",description:e("literalismDescription"),lowLabel:e("literalismLow"),highLabel:e("literalismHigh")},empathy:{label:e("empathyLabel"),shortLabel:"E",description:e("empathyDescription"),lowLabel:e("empathyLow"),highLabel:e("empathyHigh")}}}function Vw({hideReflectFields:e=!1}){let t=(0,T.useRouter)(),n=(0,M.useTranslations)("bankProfile"),r=(0,M.useTranslations)("common"),i=(0,M.useTranslations)("bank"),a=Vb(),{currentBank:o,setCurrentBank:s,loadBanks:l}=(0,D.useBank)(),{features:c}=(0,Pp.useFeatures)();c?.observations;let[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)([]),[x,v]=(0,E.useState)(0),[y,b]=(0,E.useState)([]),[w,j]=(0,E.useState)(0),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(null),[V,H]=(0,E.useState)(!1),[U,W]=(0,E.useState)(!1),[Y,G]=(0,E.useState)(!1),[q,K]=(0,E.useState)(!1),[Z,Q]=(0,E.useState)(!1),[J,ee]=(0,E.useState)(!1),[et,en]=(0,E.useState)(null),[ei]=(0,E.useState)(10),[eo,es]=(0,E.useState)(0),[el,ec]=(0,E.useState)(null),eu=async(e=et,t=eo)=>{if(o)try{let n=await $.client.listOperations(o,{status:e||void 0,limit:ei,offset:t});g(n.operations||[]),v(n.total||0)}catch(e){console.error("Error loading operations:",e)}},ed=async(e=!1)=>{if(o){if(e){try{let[e,t,n]=await Promise.all([$.client.getBankStats(o),$.client.listDirectives(o),$.client.listMentalModels(o)]);f(e),b(t.items||[]),j(n.items?.length||0)}catch(e){console.error("Error refreshing stats:",e)}return}k(!0);try{let[e,t,n,r]=await Promise.all([$.client.getBankProfile(o),$.client.getBankStats(o),$.client.listDirectives(o),$.client.listMentalModels(o)]);d(e),f(t),b(n.items||[]),j(r.items?.length||0),await eu()}catch(e){}finally{k(!1)}}},eh=async()=>{if(o){G(!0);try{await $.client.deleteBank(o),W(!1),s(null),await l(),t.push("/")}catch(e){}finally{G(!1)}}},ef=async()=>{if(o){Q(!0);try{let e=await $.client.clearObservations(o);K(!1),await ed(),O.toast.success("Success",{description:e.message||"Observations cleared successfully"})}catch(e){}finally{Q(!1)}}},ep=async()=>{if(o&&z){H(!0);try{await $.client.deleteDirective(o,z.id),b(e=>e.filter(e=>e.id!==z.id)),R?.id===z.id&&B(null),F(null)}catch(e){}finally{H(!1)}}};return((0,E.useEffect)(()=>{if(o){ed();let e=setInterval(()=>ed(!0),5e3);return()=>clearInterval(e)}},[o]),(0,E.useEffect)(()=>{let e=e=>{"Escape"===e.key&&B(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),o)?N&&!u?(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"text-center py-10",children:[(0,_.jsx)(ea,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,_.jsx)("div",{className:"text-lg text-muted-foreground",children:n("loadingProfile")})]})}):(0,_.jsxs)("div",{className:"space-y-6",children:[!e&&(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)("div",{className:"flex items-start justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(Ll,{className:"w-5 h-5 text-primary"}),n("dispositionProfileTitle")]}),(0,_.jsx)(tm.CardDescription,{children:n("editDispositionDescription")})]}),(0,_.jsx)(X.Button,{onClick:()=>C(!0),variant:"ghost",size:"sm",children:(0,_.jsx)(PX,{className:"h-4 w-4"})})]})}),(0,_.jsx)(tm.CardContent,{children:u&&(0,_.jsx)("div",{className:"space-y-4",children:Vy.map(e=>(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:a[e].label}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:a[e].description})]}),(0,_.jsxs)("span",{className:"text-sm font-bold text-primary",children:[u.disposition[e],"/5"]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:a[e].lowLabel}),(0,_.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,_.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(u.disposition[e]-1)/4*100}%`}})}),(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:a[e].highLabel})]})]},e))})})]}),(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)("div",{className:"flex items-start justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)(tm.CardTitle,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(Vx,{className:"w-5 h-5 text-primary"}),n("missionTitle")]}),(0,_.jsx)(tm.CardDescription,{children:n("editMissionDescription")})]}),(0,_.jsx)(X.Button,{onClick:()=>P(!0),variant:"ghost",size:"sm",children:(0,_.jsx)(PX,{className:"h-4 w-4"})})]})}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:u?.mission||n("noMissionSet")})})]})]}),(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,_.jsx)(Vv.default,{className:"w-5 h-5 text-rose-500"}),n("directivesTitle")]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:n("directivesDescription")})]}),(0,_.jsxs)(X.Button,{onClick:()=>I(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-1"}),n("addDirective")]})]}),y.length>0?(0,_.jsx)("div",{className:"grid grid-cols-2 gap-3",children:y.map(e=>(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-colors border-rose-500/30 ${R?.id===e.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>B(e),children:(0,_.jsx)(tm.CardContent,{className:"p-3",children:(0,_.jsxs)("div",{className:"flex items-start gap-2",children:[(0,_.jsx)(Vv.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:e.content}),e.tags&&e.tags.length>0&&(0,_.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,_.jsx)(e7,{className:"w-3 h-3 text-muted-foreground"}),e.tags.map(e=>(0,_.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e},e))]})]})]})})},e.id))}):(0,_.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,_.jsx)(Vv.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:n("noDirectivesMessage")})]})]}),(0,_.jsx)(PN,{open:U,onOpenChange:W,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("deleteMemoryBank")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:i.rich("deleteBankPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:o})})}),(0,_.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:i("deleteBankWarning")}),h&&(0,_.jsx)("p",{children:i("deleteWillDeleteDetails",{memories:h.total_nodes,documents:h.total_documents,links:h.total_links})})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:Y,children:r("cancel")}),(0,_.jsx)(PY,{onClick:eh,disabled:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Y?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),i("deleting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),i("deleteBank")]})})]})]})}),(0,_.jsx)(PN,{open:q,onOpenChange:K,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("clearObservationsTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:i.rich("clearObservationsPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:o})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:i("clearObservationsWarning")}),h&&h.total_observations>0&&(0,_.jsx)("p",{children:i("deleteWillDeleteObservations",{count:h.total_observations})})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:Z,children:r("cancel")}),(0,_.jsx)(PY,{onClick:ef,disabled:Z,className:"bg-amber-500 text-white hover:bg-amber-600",children:Z?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),i("clearing")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),i("clearObservations")]})})]})]})}),(0,_.jsx)(Vk,{open:L,mode:"create",onClose:()=>I(!1),onCreated:e=>{b(t=>[e,...t]),I(!1)}}),(0,_.jsx)(PN,{open:!!z,onOpenChange:e=>!e&&F(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("deleteDirectiveTitle")}),(0,_.jsxs)(PW,{children:[n("deleteDirectiveConfirm",{name:`"${z?.name??""}"`}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:n("deleteDirectiveWarning")})]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:r("cancel")}),(0,_.jsxs)(PY,{onClick:ep,disabled:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[V?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,r("delete")]})]})]})}),R&&(0,_.jsx)(VS,{directive:R,onClose:()=>B(null),onDelete:()=>F({id:R.id,name:R.name}),onUpdated:e=>{b(t=>t.map(t=>t.id===e.id?e:t)),B(e)}}),S&&u&&(0,_.jsx)(Vj,{disposition:u.disposition,onClose:()=>C(!1),onSaved:async()=>{await ed(),C(!1)}}),A&&u&&(0,_.jsx)(VN,{mission:u.mission||"",onClose:()=>P(!1),onSaved:async()=>{await ed(),P(!1)}})]}):(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"p-10 text-center",children:[(0,_.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:n("noBankSelected")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("noBankSelectedDescription")})]})})}function Vj({disposition:e,onClose:t,onSaved:n}){let r=(0,M.useTranslations)("bankProfile"),i=Vb(),{currentBank:a}=(0,D.useBank)(),[o,s]=(0,E.useState)(!1),[l,c]=(0,E.useState)(e),u=async()=>{if(a){s(!0);try{await $.client.updateBankConfig(a,{disposition_skepticism:l.skepticism,disposition_literalism:l.literalism,disposition_empathy:l.empathy}),n()}catch(e){}finally{s(!1)}}};return(0,_.jsx)(ta.Dialog,{open:!0,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-xl",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("editDispositionTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("editDispositionDescription")})]}),(0,_.jsx)("div",{className:"space-y-4 py-4",children:Vy.map(e=>(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex justify-between items-center",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i[e].label}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i[e].description})]}),(0,_.jsxs)("span",{className:"text-sm font-bold text-primary",children:[l[e],"/5"]})]}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,_.jsx)("span",{children:i[e].lowLabel}),(0,_.jsx)("span",{children:i[e].highLabel})]}),(0,_.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:l[e],onChange:t=>c(n=>({...n,[e]:parseInt(t.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},e))}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{onClick:t,variant:"outline",disabled:o,children:r("cancel")}),(0,_.jsx)(X.Button,{onClick:u,disabled:o,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),r("saving")]}):r("saveChanges")})]})]})})}function VN({mission:e,onClose:t,onSaved:n}){let r=(0,M.useTranslations)("bankProfile"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(e),c=async()=>{if(i){o(!0);try{await $.client.updateBankConfig(i,{reflect_mission:s||null}),n()}catch(e){}finally{o(!1)}}};return(0,_.jsx)(ta.Dialog,{open:!0,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-xl",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("editMissionTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("editMissionDescription")})]}),(0,_.jsx)("div",{className:"space-y-2 py-4",children:(0,_.jsx)(Lh.Textarea,{value:s,onChange:e=>l(e.target.value),placeholder:r("missionPlaceholder"),rows:8,className:"resize-none"})}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{onClick:t,variant:"outline",disabled:a,children:r("cancel")}),(0,_.jsx)(X.Button,{onClick:c,disabled:a,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(er,{className:"w-4 h-4 mr-2 animate-spin"}),r("saving")]}):r("saveChanges")})]})]})})}function Vk({open:e,mode:t,directive:n,onClose:r,onCreated:i,onSaved:a}){let o=(0,M.useTranslations)("bankProfile"),{currentBank:s}=(0,D.useBank)(),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)({name:"",content:"",tags:""});(0,E.useEffect)(()=>{"edit"===t&&n?d({name:n.name,content:n.content,tags:(n.tags||[]).join(", ")}):"create"===t&&d({name:"",content:"",tags:""})},[e,t,n]);let h=async()=>{if(s&&u.name.trim()&&u.content.trim()){c(!0);try{let e=u.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0);if("create"===t){let t=await $.client.createDirective(s,{name:u.name.trim(),content:u.content.trim(),tags:e.length>0?e:void 0});d({name:"",content:"",tags:""}),i?.(t)}else if(n){let t=await $.client.updateDirective(s,n.id,{name:u.name.trim(),content:u.content.trim(),tags:e});a?.(t),r()}}catch(e){}finally{c(!1)}}},f=()=>{"create"===t&&d({name:"",content:"",tags:""}),r()};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>!e&&f(),children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-lg",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)(Vv.default,{className:"w-5 h-5 text-rose-500"}),o("create"===t?"directiveFormCreateTitle":"directiveFormEditTitle")]}),(0,_.jsx)(ta.DialogDescription,{children:o("directiveFormDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:o("directiveNameLabel")}),(0,_.jsx)(q.Input,{value:u.name,onChange:e=>d({...u,name:e.target.value}),placeholder:o("directiveNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:o("directiveRuleLabel")}),(0,_.jsx)(Lh.Textarea,{value:u.content,onChange:e=>d({...u,content:e.target.value}),placeholder:o("directiveRulePlaceholder"),className:"min-h-[120px]"})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("label",{className:"text-sm font-medium text-foreground",children:[o("directiveTagsLabel")," ",(0,_.jsx)("span",{className:"text-muted-foreground font-normal",children:o("directiveTagsOptional")})]}),(0,_.jsx)(q.Input,{value:u.tags,onChange:e=>d({...u,tags:e.target.value}),placeholder:o("directiveTagsPlaceholder")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:f,disabled:l,children:o("cancel")}),(0,_.jsxs)(X.Button,{onClick:h,disabled:l||!u.name.trim()||!u.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[l?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,o("create"===t?"create":"save")]})]})]})})}function VS({directive:e,onClose:t,onDelete:n,onUpdated:r}){let i=(0,M.useTranslations)("bankProfile"),[a,o]=(0,E.useState)(!1);return(0,_.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,_.jsxs)("div",{className:"p-6",children:[(0,_.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,_.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_.jsx)(Vv.default,{className:"w-5 h-5 text-rose-500"}),(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:()=>o(!0),className:"h-7 w-7 p-0",children:(0,_.jsx)(PX,{className:"h-3.5 w-3.5"})})]}),(0,_.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:i("directiveDetailBadge")})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,_.jsx)(P$,{className:"h-4 w-4"})}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,_.jsx)(tt.X,{className:"h-4 w-4"})})]})]}),(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:i("directiveDetailRuleLabel")}),(0,_.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,_.jsx)(zj,{remarkPlugins:[FJ],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:i("directiveDetailTagsLabel")}),(0,_.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,_.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:i("directiveDetailIdLabel")}),(0,_.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]})]})]}),(0,_.jsx)(Vk,{open:a,mode:"edit",directive:e,onClose:()=>o(!1),onSaved:r})]})}let VC=(0,ev.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"}}),V_=E.forwardRef(({className:e,variant:t,...n},r)=>(0,_.jsx)("div",{ref:r,role:"alert",className:(0,W.cn)(VC({variant:t}),e),...n}));V_.displayName="Alert",E.forwardRef(({className:e,...t},n)=>(0,_.jsx)("h5",{ref:n,className:(0,W.cn)("mb-1 font-medium leading-none tracking-tight",e),...t})).displayName="AlertTitle";let VE=E.forwardRef(({className:e,...t},n)=>(0,_.jsx)("div",{ref:n,className:(0,W.cn)("text-sm [&_p]:leading-relaxed",e),...t}));VE.displayName="AlertDescription";var tn=tn;let VT=(0,I.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"}]]),VM=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT"].map(e=>({category:e,threshold:"BLOCK_NONE"})),VO=["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","list_documents","get_document","delete_document","list_operations","get_operation","cancel_operation","list_tags"];function VA(e){return Array.isArray(e)?e:e&&"object"==typeof e&&Array.isArray(e.attributes)?e.attributes:null}function VD(e){return{retain_chunk_size:e.retain_chunk_size??null,retain_extraction_mode:e.retain_extraction_mode??null,retain_mission:e.retain_mission??null,retain_custom_instructions:e.retain_custom_instructions??null,entities_allow_free_form:e.entities_allow_free_form??null,entity_labels:VA(e.entity_labels)}}function VP(e){return{retain_default_strategy:e.retain_default_strategy??null,retain_strategies:e.retain_strategies??null}}function VL(e){return{enable_observations:e.enable_observations??null,consolidation_llm_batch_size:e.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:e.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:e.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:e.observations_mission??null,max_observations_per_scope:e.max_observations_per_scope??null}}function VI(e){return{mcp_enabled_tools:e.mcp_enabled_tools??null}}function VR(e){return{llm_gemini_safety_settings:e.llm_gemini_safety_settings??null}}let VB={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function Vz(){let e=(0,M.useTranslations)("bankConfig"),{currentBank:t}=(0,D.useBank)(),{features:n}=(0,Pp.useFeatures)(),r=n?.bank_config_api??!0,[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)({}),[l,c]=(0,E.useState)(VB),[u,d]=(0,E.useState)(VD({})),[h,f]=(0,E.useState)(VP({})),[p,g]=(0,E.useState)(VL({})),[x,v]=(0,E.useState)(VB),[y,b]=(0,E.useState)(VI({})),[w,j]=(0,E.useState)(VR({})),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(null),[V,H]=(0,E.useState)(null),[U,W]=(0,E.useState)(null),[Y,G]=(0,E.useState)(null),X=(0,E.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(VD(o))||JSON.stringify(h)!==JSON.stringify(VP(o)),[u,h,o]),K=(0,E.useMemo)(()=>JSON.stringify(p)!==JSON.stringify(VL(o)),[p,o]),Z=(0,E.useMemo)(()=>JSON.stringify(x)!==JSON.stringify(l),[x,l]),Q=(0,E.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(VI(o)),[y,o]),J=(0,E.useMemo)(()=>JSON.stringify(w)!==JSON.stringify(VR(o)),[w,o]);(0,E.useEffect)(()=>{t&&ee()},[t]);let ee=async()=>{if(t){a(!0);try{let[e,n]=await Promise.all([$.client.getBankConfig(t),$.client.getBankProfile(t)]),r=e.config,i={reflect_mission:n.mission??"",disposition_skepticism:r.disposition_skepticism??n.disposition?.skepticism??3,disposition_literalism:r.disposition_literalism??n.disposition?.literalism??3,disposition_empathy:r.disposition_empathy??n.disposition?.empathy??3};s(r),c(i),d(VD(r)),f(VP(r)),g(VL(r)),v(i),b(VI(r)),j(VR(r))}catch(e){console.error("Failed to load bank data:",e)}finally{a(!1)}}},et=async()=>{if(t){k(!0),B(null);try{let e={...u,...h};await $.client.updateBankConfig(t,e),s(t=>({...t,...e}))}catch(t){B(t.message||e("retainFailedToSave"))}finally{k(!1)}}},en=async()=>{if(t){C(!0),F(null);try{await $.client.updateBankConfig(t,p),s(e=>({...e,...p}))}catch(t){F(t.message||e("observationsFailedToSave"))}finally{C(!1)}}},er=async()=>{if(t){O(!0),H(null);try{await $.client.updateBankConfig(t,{reflect_mission:x.reflect_mission||null,disposition_skepticism:x.disposition_skepticism,disposition_literalism:x.disposition_literalism,disposition_empathy:x.disposition_empathy}),c(x)}catch(t){H(t.message||e("reflectFailedToSave"))}finally{O(!1)}}},ei=async()=>{if(t){P(!0),W(null);try{await $.client.updateBankConfig(t,y),s(e=>({...e,...y}))}catch(t){W(t.message||e("mcpFailedToSave"))}finally{P(!1)}}},ea=async()=>{if(t){I(!0),G(null);try{await $.client.updateBankConfig(t,w),s(e=>({...e,...w}))}catch(t){G(t.message||e("geminiFailedToSave"))}finally{I(!1)}}};return t?r?i?(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(tn.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)("div",{className:"space-y-8",children:[(0,_.jsxs)(VG,{title:e("retainTitle"),description:e("retainSectionDescription"),error:R,dirty:X,saving:N,onSave:et,children:[(0,_.jsx)(V$,{label:e("defaultStrategyLabel"),description:e("defaultStrategyDescription"),children:(0,_.jsxs)(e6.Select,{value:h.retain_default_strategy??"__none__",onValueChange:e=>f(t=>({...t,retain_default_strategy:"__none__"===e?null:e})),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-full",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"__none__",children:(0,_.jsx)("span",{className:"text-muted-foreground italic",children:e("default")})}),Object.keys(h.retain_strategies??{}).map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:e},e))]})]})}),(0,_.jsx)(VW,{defaultValues:u,onDefaultChange:e=>d(t=>({...t,...e})),strategies:h.retain_strategies,onStrategiesChange:e=>f(t=>({...t,retain_strategies:e}))})]}),(0,_.jsxs)(VG,{title:e("observationsTitle"),description:e("observationsDescription"),error:z,dirty:K,saving:S,onSave:en,children:[(0,_.jsx)(V$,{label:e("enableObservationsLabel"),description:e("enableObservationsDescription"),children:(0,_.jsx)("div",{className:"flex justify-end",children:(0,_.jsx)(e4.Switch,{checked:p.enable_observations??!1,onCheckedChange:e=>g(t=>({...t,enable_observations:e}))})})}),(0,_.jsx)(VX,{label:e("missionLabel"),description:e("observationsMissionDescription"),value:p.observations_mission??"",onChange:e=>g(t=>({...t,observations_mission:e||null})),placeholder:e("observationsMissionPlaceholder"),rows:3}),(0,_.jsx)(V$,{label:e("llmBatchSizeLabel"),description:e("llmBatchSizeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:1,max:64,value:p.consolidation_llm_batch_size??"",onChange:e=>g(t=>({...t,consolidation_llm_batch_size:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(V$,{label:e("sourceFactsMaxTokensLabel"),description:e("sourceFactsMaxTokensDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens??"",onChange:e=>g(t=>({...t,consolidation_source_facts_max_tokens:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(V$,{label:e("sourceFactsMaxTokensPerObservationLabel"),description:e("sourceFactsMaxTokensPerObservationDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.consolidation_source_facts_max_tokens_per_observation??"",onChange:e=>g(t=>({...t,consolidation_source_facts_max_tokens_per_observation:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})}),(0,_.jsx)(V$,{label:e("maxObservationsPerScopeLabel"),description:e("maxObservationsPerScopeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:-1,value:p.max_observations_per_scope??"",onChange:e=>g(t=>({...t,max_observations_per_scope:e.target.value?parseInt(e.target.value,10):null})),placeholder:e("serverDefault")})})]}),(0,_.jsxs)(VG,{title:e("reflectTitle"),description:e("reflectDescription"),error:V,dirty:Z,saving:T,onSave:er,children:[(0,_.jsx)(VX,{label:e("missionLabel"),description:e("reflectMissionDescription"),value:x.reflect_mission,onChange:e=>v(t=>({...t,reflect_mission:e})),placeholder:e("reflectMissionPlaceholder"),rows:3}),(0,_.jsx)(Vq,{label:e("skepticismLabel"),description:e("skepticismDescription"),lowLabel:e("skepticismLowLabel"),highLabel:e("skepticismHighLabel"),value:x.disposition_skepticism,onChange:e=>v(t=>({...t,disposition_skepticism:e}))}),(0,_.jsx)(Vq,{label:e("literalismLabel"),description:e("literalismDescription"),lowLabel:e("literalismLowLabel"),highLabel:e("literalismHighLabel"),value:x.disposition_literalism,onChange:e=>v(t=>({...t,disposition_literalism:e}))}),(0,_.jsx)(Vq,{label:e("empathyLabel"),description:e("empathyDescription"),lowLabel:e("empathyLowLabel"),highLabel:e("empathyHighLabel"),value:x.disposition_empathy,onChange:e=>v(t=>({...t,disposition_empathy:e}))})]}),(0,_.jsxs)(VG,{title:e("mcpToolsTitle"),description:e("mcpToolsDescription"),error:U,dirty:Q,saving:A,onSave:ei,children:[(0,_.jsx)(V$,{label:e("restrictToolsLabel"),description:e("restrictToolsDescription"),children:(0,_.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,_.jsx)(e4.Switch,{checked:null!==y.mcp_enabled_tools,onCheckedChange:e=>b({mcp_enabled_tools:e?[...VO]:null})}),(0,_.jsx)(eb,{className:"text-xs text-muted-foreground",children:null!==y.mcp_enabled_tools?e("enabled"):e("disabled")})]})}),null!==y.mcp_enabled_tools&&(0,_.jsx)(VY,{selected:y.mcp_enabled_tools,onChange:e=>b({mcp_enabled_tools:e})})]}),(0,_.jsx)(VG,{title:e("modelsTitle"),description:e("modelsDescription"),error:Y,dirty:J,saving:L,onSave:ea,children:(0,_.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,_.jsx)("p",{className:"text-sm font-semibold",children:e("geminiSubsectionTitle")}),(0,_.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,_.jsx)(V$,{label:e("safetySettingsLabel"),description:(0,_.jsxs)(_.Fragment,{children:[e("safetySettingsDescriptionPart1")," ",(0,_.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:e("safetySettingsLearnMore")})]}),children:(0,_.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,_.jsx)(e4.Switch,{checked:null!==w.llm_gemini_safety_settings,onCheckedChange:e=>j({llm_gemini_safety_settings:e?[...VM]:null})}),(0,_.jsx)(eb,{className:"text-xs text-muted-foreground",children:null!==w.llm_gemini_safety_settings?e("custom"):e("default")})]})}),null!==w.llm_gemini_safety_settings&&(0,_.jsx)(VQ,{value:w.llm_gemini_safety_settings,onChange:e=>j({llm_gemini_safety_settings:e})})]})]})})]})}):(0,_.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,_.jsx)("p",{className:"text-base font-medium text-foreground",children:e("apiDisabledTitle")}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:e.rich("apiDisabledDescription",{code:e=>(0,_.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:e})})})]}):(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)("p",{className:"text-muted-foreground",children:e("noBankSelected")})})}let VF=["concise","verbose","verbatim","chunks","custom"],VV="__inherit__";function VH({values:e,onChange:t,isOverride:n=!1}){let r=(0,M.useTranslations)("bankConfig"),i=e.retain_extraction_mode??(n?VV:""),a="custom"===e.retain_extraction_mode;return(0,_.jsxs)("div",{className:"divide-y divide-border/40",children:[(0,_.jsx)(V$,{label:r("extractionModeLabel"),description:r("extractionModeDescription"),children:(0,_.jsxs)(e6.Select,{value:i,onValueChange:e=>t({retain_extraction_mode:e===VV?null:e||null}),children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-full",children:(0,_.jsx)(e6.SelectValue,{placeholder:n?r("inherited"):void 0})}),(0,_.jsxs)(e6.SelectContent,{children:[n&&(0,_.jsx)(e6.SelectItem,{value:VV,children:(0,_.jsx)("span",{className:"text-muted-foreground italic",children:r("inherited")})}),VF.map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:e},e))]})]})}),(0,_.jsx)(V$,{label:r("chunkSizeLabel"),description:r("chunkSizeDescription"),children:(0,_.jsx)(q.Input,{type:"number",min:500,max:8e3,value:e.retain_chunk_size??"",onChange:e=>t({retain_chunk_size:e.target.value?parseFloat(e.target.value):null}),placeholder:n?r("inherited"):void 0})}),(0,_.jsx)(VX,{label:r("missionLabel"),description:r("retainMissionDescription"),value:e.retain_mission??"",onChange:e=>t({retain_mission:e||null}),placeholder:r(n?"inherited":"retainMissionPlaceholder"),rows:3}),a&&(0,_.jsx)(VX,{label:r("customExtractionPromptLabel"),description:r("customExtractionPromptDescription"),value:e.retain_custom_instructions??"",onChange:e=>t({retain_custom_instructions:e||null}),rows:5}),(0,_.jsx)(V$,{label:r("freeFormEntitiesLabel"),description:r("freeFormEntitiesDescription"),children:(0,_.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,_.jsx)(eb,{className:"text-sm text-muted-foreground cursor-pointer select-none",children:r(e.entities_allow_free_form??!0?"enabled":"disabled")}),(0,_.jsx)(e4.Switch,{checked:e.entities_allow_free_form??!0,onCheckedChange:e=>t({entities_allow_free_form:e})})]})}),(0,_.jsx)(VZ,{value:e.entity_labels??[],onChange:e=>t({entity_labels:e.length>0?e:null})})]})}function VU(e){return e?Object.entries(e).map(([e,t],n)=>({id:n,name:e,values:{retain_extraction_mode:t.retain_extraction_mode??null,retain_chunk_size:t.retain_chunk_size??null,retain_mission:t.retain_mission??null,retain_custom_instructions:t.retain_custom_instructions??null,entities_allow_free_form:t.entities_allow_free_form??null,entity_labels:VA(t.entity_labels)}})):[]}function VW({defaultValues:e,onDefaultChange:t,strategies:n,onStrategiesChange:r}){let i=(0,M.useTranslations)("bankConfig"),a=(0,M.useTranslations)("common"),[o,s]=(0,E.useState)(()=>VU(n)),[l,c]=(0,E.useState)("default"),[u,d]=(0,E.useState)(null),h=(0,E.useRef)(!1),f=JSON.stringify(n);(0,E.useEffect)(()=>{if(h.current){h.current=!1;return}s(VU(n))},[f]);let p=e=>{h.current=!0,s(e),r(function(e){let t={};for(let n of e){if(!n.name.trim())continue;let e={};null!==n.values.retain_extraction_mode&&(e.retain_extraction_mode=n.values.retain_extraction_mode),null!==n.values.retain_chunk_size&&(e.retain_chunk_size=n.values.retain_chunk_size),n.values.retain_mission&&(e.retain_mission=n.values.retain_mission),n.values.retain_custom_instructions&&(e.retain_custom_instructions=n.values.retain_custom_instructions),null!==n.values.entities_allow_free_form&&(e.entities_allow_free_form=n.values.entities_allow_free_form),null!==n.values.entity_labels&&(e.entity_labels=n.values.entity_labels),t[n.name.trim()]=e}return Object.keys(t).length>0?t:null}(e))},g=(e,t)=>{p(o.map(n=>n.id===e?{...n,...t}:n))},x="default"!==l?o.find(e=>e.id===l):null;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"border-b border-border px-6 flex items-stretch gap-1 flex-wrap",children:[(0,_.jsx)("button",{type:"button",onClick:()=>c("default"),className:`relative py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px ${"default"===l?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,children:i("default")}),o.map(e=>(0,_.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 ${l===e.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>c(e.id),children:[(0,_.jsx)("span",{className:"font-mono",children:e.name||(0,_.jsx)("span",{className:"italic font-normal opacity-50",children:i("unnamed")})}),(0,_.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),d(e)},className:"opacity-40 hover:opacity-100 hover:text-destructive transition-opacity text-base leading-none",children:"×"})]},e.id)),(0,_.jsxs)("button",{type:"button",onClick:()=>{let e=Date.now();p([...o,{id:e,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}}]),c(e)},className:"py-3 px-3 text-sm text-muted-foreground hover:text-primary transition-colors flex items-center gap-1.5",children:[(0,_.jsx)(Pd.Plus,{className:"h-3.5 w-3.5"}),i("addStrategy")]})]}),(0,_.jsx)("div",{children:"default"===l?(0,_.jsx)(VH,{values:e,onChange:t}):x?(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"px-6 py-3 flex items-center gap-3 border-b border-border/40",children:[(0,_.jsx)("label",{className:"text-xs text-muted-foreground shrink-0",children:i("nameLabel")}),(0,_.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,_.jsx)(q.Input,{value:x.name,onChange:e=>g(x.id,{name:e.target.value}),placeholder:i("strategyNamePlaceholder"),className:`h-7 text-xs font-mono max-w-[200px] ${!x.name.trim()?"border-destructive focus-visible:ring-destructive":""}`}),!x.name.trim()&&(0,_.jsx)("p",{className:"text-xs text-destructive",children:i("nameIsRequired")})]})]}),(0,_.jsx)(VH,{values:x.values,onChange:e=>g(x.id,{values:{...x.values,...e}}),isOverride:!0})]}):null}),(0,_.jsx)(PN,{open:null!==u,onOpenChange:e=>{e||d(null)},children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:i("deleteStrategyTitle",{name:u?.name||i("unnamed")})}),(0,_.jsx)(PW,{children:i("deleteStrategyDescription")})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{children:a("cancel")}),(0,_.jsx)(PY,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(u){var e;e=u.id,p(o.filter(t=>t.id!==e)),l===e&&c("default"),d(null)}},children:a("delete")})]})]})})]})}function VY({selected:e,onChange:t}){let n=(0,M.useTranslations)("bankConfig"),r=[{key:"core",label:n("mcpGroupCore"),tools:["retain","sync_retain","recall","reflect"]},{key:"bankManagement",label:n("mcpGroupBankManagement"),tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{key:"mentalModels",label:n("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:n("mcpGroupDirectives"),tools:["list_directives","create_directive","delete_directive"]},{key:"memories",label:n("mcpGroupMemories"),tools:["list_memories","get_memory"]},{key:"documents",label:n("mcpGroupDocuments"),tools:["list_documents","get_document","delete_document"]},{key:"operations",label:n("mcpGroupOperations"),tools:["list_operations","get_operation","cancel_operation"]},{key:"tags",label:n("mcpGroupTags"),tools:["list_tags"]}],i=new Set(e),a=VO.every(e=>i.has(e)),o=0===e.length;return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:n("toolsEnabled",{selected:e.length,total:VO.length})}),(0,_.jsx)("button",{type:"button",onClick:()=>{t(a?[]:[...VO])},className:"text-xs text-primary hover:underline",children:a?n("deselectAll"):n("selectAll")})]}),(0,_.jsx)("div",{className:"space-y-4",children:r.map(e=>{let r=e.tools.filter(e=>i.has(e)).length===e.tools.length;return(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,_.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:e.label}),(0,_.jsx)("button",{type:"button",onClick:()=>{let n=new Set(i);r?e.tools.forEach(e=>n.delete(e)):e.tools.forEach(e=>n.add(e)),t(VO.filter(e=>n.has(e)))},className:"text-xs text-primary hover:underline",children:r?n("deselect"):n("selectAll")})]}),(0,_.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tools.map(e=>{let n=i.has(e);return(0,_.jsx)("button",{type:"button",onClick:()=>{let n;(n=new Set(i)).has(e)?n.delete(e):n.add(e),t(VO.filter(e=>n.has(e)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${n?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:e},e)})})]},e.key)})}),o&&(0,_.jsx)("p",{className:"text-xs text-destructive",children:n("noToolsWarning")})]})}function VG({title:e,description:t,children:n,error:r,dirty:i,saving:a,onSave:o}){let s=(0,M.useTranslations)("bankConfig");return(0,_.jsxs)("section",{className:"space-y-3",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h2",{className:"text-lg font-semibold",children:e}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:t})]}),(0,_.jsxs)(tm.Card,{className:"bg-muted/20 border-border/40",children:[(0,_.jsx)("div",{className:"divide-y divide-border/40",children:n}),r&&(0,_.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,_.jsxs)(V_,{variant:"destructive",children:[(0,_.jsx)(VT,{className:"h-4 w-4"}),(0,_.jsx)(VE,{children:r})]})}),(0,_.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,_.jsx)(X.Button,{size:"sm",disabled:!i||a,onClick:o,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"h-4 w-4 mr-2 animate-spin"}),s("saving")]}):s("saveChanges")})})]})]})}function V$({label:e,description:t,children:n}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,_.jsxs)("div",{className:"flex-1",children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsx)("div",{className:"md:w-64 shrink-0",children:n})]})})}function VX({label:e,description:t,value:n,onChange:r,placeholder:i,rows:a}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsx)(Lh.Textarea,{value:n,onChange:e=>r(e.target.value),placeholder:i,rows:a??3,className:"font-mono text-sm"})]})})}function Vq({label:e,description:t,lowLabel:n,highLabel:r,value:i,onChange:a}){return(0,_.jsx)("div",{className:"px-6 py-4",children:(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:e}),t&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[n&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:n}),(0,_.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(e=>(0,_.jsx)("button",{type:"button",onClick:()=>a(e),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${e<=i?"bg-primary":"bg-muted"}`},e))}),r&&(0,_.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:r}),(0,_.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[i,"/5"]})]})]})})}function VK({fields:e,onChange:t,depth:n,extraControls:r,examplePrefix:i}){let a=(0,M.useTranslations)("bankConfig"),o={text:a("fieldTypeText"),value:a("fieldTypeValue"),"multi-values":a("fieldTypeMultiValues"),map:a("fieldTypeMap")},[s,l]=(0,E.useState)({}),c=(n,r)=>{let i={};for(let[t,a]of Object.entries(e))i[t]=t===n?{...a,...r}:a;t(i)},u=0===n;return(0,_.jsxs)("div",{className:u?"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(e).length&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground italic",children:a("noFieldsYet")}),Object.entries(e).map(([d,h],f)=>{let p="map"===h.type,g="value"===h.type||"multi-values"===h.type,x=s[f]??!0,v=p||g;return(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[v?(0,_.jsx)("button",{type:"button",onClick:()=>l(e=>({...e,[f]:!x})),className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted/50",children:x?(0,_.jsx)(PK.ChevronDown,{className:"h-3.5 w-3.5"}):(0,_.jsx)(H.ChevronRight,{className:"h-3.5 w-3.5"})}):(0,_.jsx)("span",{className:"w-[18px] shrink-0"}),(0,_.jsx)(q.Input,{placeholder:a("fieldNamePlaceholder"),value:d,onChange:n=>((n,r)=>{let i={};for(let[t,a]of Object.entries(e))i[t===n?r:t]=a;t(i)})(d,n.target.value),className:"h-7 text-xs font-mono w-28 shrink-0"}),(0,_.jsx)(q.Input,{placeholder:a("extractorHintWhatPlaceholder"),value:h.description,onChange:e=>c(d,{description:e.target.value}),className:"h-7 text-xs flex-1 min-w-0"}),(0,_.jsxs)(e6.Select,{value:h.type,onValueChange:e=>c(d,{type:e,..."map"===e?{fields:h.fields??{},values:void 0}:{},..."text"===e?{fields:void 0,values:void 0}:{},..."value"===e||"multi-values"===e?{fields:void 0,values:h.values??[]}:{}}),children:[(0,_.jsx)(e6.SelectTrigger,{className:"h-7 text-xs w-[120px] shrink-0 px-2 py-0",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{children:Object.entries(o).map(([e,t])=>(0,_.jsx)(e6.SelectItem,{value:e,className:"text-xs",children:t},e))})]}),r,(0,_.jsx)("button",{type:"button",onClick:()=>{let n;return n={...e},void(delete n[d],t(n))},className:"text-muted-foreground hover:text-destructive shrink-0 p-0.5 rounded hover:bg-destructive/10",children:(0,_.jsx)(P$,{className:"h-3.5 w-3.5"})})]}),u&&i&&d&&(0,_.jsx)("div",{className:"ml-[18px] pl-1.5",children:(0,_.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground/60 leading-none",children:"map"===h.type&&h.fields&&Object.keys(h.fields).length>0?`e.g. ${Object.keys(h.fields).slice(0,2).map(e=>`${i}:${e}:<value>`).join(", ")}`:"text"===h.type?`e.g. ${i}:<any text>`:(h.values?.length??0)>0?`e.g. ${i}:${h.values[0].value||"<value>"}`:`e.g. ${i}:<value>`})}),x&&p&&(0,_.jsx)(VK,{fields:h.fields??{},onChange:e=>c(d,{fields:e}),depth:n+1,examplePrefix:i?`${i}:${d}`:void 0}),x&&g&&(0,_.jsxs)("div",{className:"ml-6 space-y-0.5 py-1",children:[0===(h.values??[]).length&&(0,_.jsx)("p",{className:"text-[11px] text-muted-foreground italic",children:a("noValuesYet")}),(h.values??[]).map((e,t)=>(0,_.jsxs)("div",{className:"flex items-center gap-1.5 group/val",children:[(0,_.jsx)("span",{className:"text-muted-foreground/50 text-[10px] shrink-0",children:"•"}),(0,_.jsx)(q.Input,{placeholder:a("addValueShort"),value:e.value,onChange:n=>{let r=[...h.values??[]];r[t]={...e,value:n.target.value},c(d,{values:r})},className:"h-6 text-[11px] font-mono w-24 shrink-0 border-dashed"}),(0,_.jsx)(q.Input,{placeholder:a("extractorHintWhichPlaceholder"),value:e.description,onChange:n=>{let r=[...h.values??[]];r[t]={...e,description:n.target.value},c(d,{values:r})},className:"h-6 text-[11px] flex-1 min-w-0 border-dashed"}),(0,_.jsx)("button",{type:"button",onClick:()=>{c(d,{values:(h.values??[]).filter((e,n)=>n!==t)})},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,_.jsx)(P$,{className:"h-3 w-3"})})]},t)),(0,_.jsxs)("button",{type:"button",onClick:()=>{c(d,{values:[...h.values??[],{value:"",description:""}]})},className:"text-[11px] text-muted-foreground/60 hover:text-foreground inline-flex items-center gap-1 ml-2.5",children:[(0,_.jsx)(Pd.Plus,{className:"h-2.5 w-2.5"}),a("addValueShort")]})]})]},f)}),(0,_.jsxs)("button",{type:"button",onClick:()=>{t({...e,"":{type:"text",description:""}})},className:"text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",children:[(0,_.jsx)(Pd.Plus,{className:"h-3 w-3"}),a("addField")]})]})}function VZ({value:e,onChange:t}){let n=(0,M.useTranslations)("entityLabelsEditor"),r=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))};return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm font-medium",children:n("entityLabelsTitle")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:n("entityLabelsDescription")})]}),e.length>0&&(0,_.jsx)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:n("labelCount",{count:e.length})})]}),0===e.length&&(0,_.jsx)("p",{className:"text-xs text-muted-foreground italic",children:n("noEntityLabelsDefined")}),(0,_.jsx)("div",{className:"space-y-2",children:e.map((i,a)=>(0,_.jsx)("div",{className:"border border-border/50 rounded-md bg-background",children:(0,_.jsx)(VK,{fields:{[i.key]:{type:i.type,description:i.description,values:i.values,fields:i.fields}},onChange:n=>{let i=Object.entries(n);if(0===i.length)t(e.filter((e,t)=>t!==a));else{let[e,t]=i[0];r(a,{key:e,type:t.type,description:t.description,values:t.values??[],fields:t.fields??{}})}},depth:0,extraControls:(0,_.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",title:n("alsoStoreAsTagTooltip"),children:[(0,_.jsx)(Pm.Checkbox,{checked:i.tag,onCheckedChange:e=>r(a,{tag:!!e}),className:"h-4 w-4"}),n("plusTag")]}),examplePrefix:i.key})},a))}),(0,_.jsxs)("button",{type:"button",onClick:()=>{t([...e,{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,_.jsx)(Pd.Plus,{className:"h-3.5 w-3.5"}),n("addLabel")]})]})}function VQ({value:e,onChange:t}){let n=(0,M.useTranslations)("bankConfig"),r=[{value:"HARM_CATEGORY_HARASSMENT",label:n("geminiCategoryHarassment")},{value:"HARM_CATEGORY_HATE_SPEECH",label:n("geminiCategoryHateSpeech")},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:n("geminiCategorySexuallyExplicit")},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:n("geminiCategoryDangerousContent")}],i=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:n("geminiThresholdUnspecified")},{value:"OFF",label:n("geminiThresholdOff")},{value:"BLOCK_NONE",label:n("geminiThresholdBlockNone")},{value:"BLOCK_LOW_AND_ABOVE",label:n("geminiThresholdBlockLowAndAbove")},{value:"BLOCK_MEDIUM_AND_ABOVE",label:n("geminiThresholdBlockMediumAndAbove")},{value:"BLOCK_ONLY_HIGH",label:n("geminiThresholdBlockOnlyHigh")}],a=t=>e.find(e=>e.category===t)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,_.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,_.jsxs)("p",{className:"text-xs text-muted-foreground",children:[n("geminiSafetyEditorDescriptionPart1")," ",(0,_.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:n("geminiSafetyEditorLearnMore")})]}),(0,_.jsx)("div",{className:"space-y-2",children:r.map(e=>(0,_.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,_.jsx)("span",{className:"text-sm",children:e.label}),(0,_.jsxs)(e6.Select,{value:a(e.value),onValueChange:n=>{var i;return i=e.value,void t(r.map(e=>({category:e.value,threshold:e.value===i?n:a(e.value)})))},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{children:i.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,className:"text-xs",children:e.label},e.value))})]})]},e.value))})]})}let VJ=(0,I.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"}]]),V0=(0,I.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 V1=e.i(23287),V1=V1;let V2=(0,I.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"}]]),V5=(0,I.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 V3=["x1","y1","x2","y2","key"],V4=["offset"],V6=["xAxisId","yAxisId"],V7=["xAxisId","yAxisId"];function V9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function V8(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V9(Object(n),!0).forEach(function(t){var r,i,a;r=e,i=t,a=n[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(i))in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V9(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(){return(He=Object.assign.bind()).apply(null,arguments)}function Ht(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Hn=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return E.createElement("rect",{x:r,y:i,ry:s,width:a,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Hr(e){var{option:t,lineItemProps:n}=e;if(E.isValidElement(t))r=E.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,i,{x1:a,y1:o,x2:s,y2:l,key:c}=n,u=null!=(i=mp(Ht(n,V3)))?i:{},{offset:d}=u,h=Ht(u,V4);r=E.createElement("line",He({},h,{x1:a,y1:o,x2:s,y2:l,fill:"none",key:c}))}return r}function Hi(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=Ht(e,V6),l=i.map((e,i)=>{var a=V8(V8({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(i),index:i});return E.createElement(Hr,{key:"line-".concat(i),option:r,lineItemProps:a})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Ha(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=Ht(e,V7),l=i.map((e,i)=>{var a=V8(V8({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(i),index:i});return E.createElement(Hr,{option:r,lineItemProps:a,key:"line-".concat(i)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Ho(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:l=!0}=e;if(!l||!t||!t.length||null==s)return null;var c=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==c[0]&&c.unshift(0);var u=c.map((e,s)=>{var l=c[s+1]?c[s+1]-e:i+o-e;if(l<=0)return null;var u=s%t.length;return E.createElement("rect",{key:"react-".concat(s),y:e,x:r,height:l,width:a,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function Hs(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:l}=e;if(!t||!n||!n.length)return null;var c=l.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==c[0]&&c.unshift(0);var u=c.map((e,t)=>{var l=c[t+1]?c[t+1]-e:i+o-e;if(l<=0)return null;var u=t%n.length;return E.createElement("rect",{key:"react-".concat(t),x:e,y:a,width:l,height:s,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var Hl=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return ay(bs(V8(V8(V8({},bh),n),{},{ticks:ab(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},Hc=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return ay(bs(V8(V8(V8({},bh),n),{},{ticks:ab(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},Hu={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:uk.grid};function Hd(e){var t=an(aE),n=an(aT),r=a9(),i=V8(V8({},m1(e,Hu)),{},{x:rT(e.x)?e.x:r.left,y:rT(e.y)?e.y:r.top,width:rT(e.width)?e.width:r.width,height:rT(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:l,width:c,height:u,syncWithTicks:d,horizontalValues:h,verticalValues:f}=i,p=aF(),g=an(e=>hj(e,"xAxis",a,p)),x=an(e=>hj(e,"yAxis",o,p));if(!ap(c)||!ap(u)||!rT(s)||!rT(l))return null;var v=i.verticalCoordinatesGenerator||Hl,y=i.horizontalCoordinatesGenerator||Hc,{horizontalPoints:b,verticalPoints:w}=i;if((!b||!b.length)&&"function"==typeof y){var j=h&&h.length,N=y({yAxis:x?V8(V8({},x),{},{ticks:j?h:x.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:u,offset:r},!!j||d);aY(Array.isArray(N),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof N,"]")),Array.isArray(N)&&(b=N)}if((!w||!w.length)&&"function"==typeof v){var k=f&&f.length,S=v({xAxis:g?V8(V8({},g),{},{ticks:k?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:u,offset:r},!!k||d);aY(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(w=S)}return E.createElement(gA,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(Hn,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(Ho,He({},i,{horizontalPoints:b})),E.createElement(Hs,He({},i,{verticalPoints:w})),E.createElement(Hi,He({},i,{offset:r,horizontalPoints:b,xAxis:g,yAxis:x})),E.createElement(Ha,He({},i,{offset:r,verticalPoints:w,xAxis:g,yAxis:x}))))}Hd.displayName="CartesianGrid";let Hh=["1h","12h","1d","7d","30d","90d"],Hf=["created_at","mentioned_at","occurred_start"],Hp="#8b5cf6",Hm="#ec4899",Hg="#6366f1",Hx="var(--chart-5)",Hv="var(--muted-foreground)",Hy={world:{label:"World",color:Hp},experience:{label:"Experience",color:Hm},observation:{label:"Observations",color:Hg}};function Hb(e){if(e<1e3)return e.toString();if(e<1e6){let t=e/1e3;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}k`}if(e<1e9){let t=e/1e6;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}M`}let t=e/1e9;return`${t>=10?t.toFixed(0):t.toFixed(1).replace(/\.0$/,"")}B`}function Hw({value:e,className:t}){return(0,_.jsx)("span",{className:t,title:e.toLocaleString(),children:Hb(e)})}function Hj({active:e,payload:t,label:n,valueLabel:r}){return e&&t&&0!==t.length?(0,_.jsxs)("div",{className:"rounded-lg border border-border/60 bg-popover/95 backdrop-blur-sm px-3 py-2 shadow-md",children:[null!=n&&(0,_.jsx)("div",{className:"text-[11px] font-medium text-foreground mb-1.5",children:n}),(0,_.jsx)("div",{className:"space-y-1",children:t.map((e,t)=>(0,_.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color||e.payload?.fill}}),(0,_.jsx)("span",{className:"text-muted-foreground",children:e.name||r||"Value"}),(0,_.jsx)("span",{className:"ml-auto pl-3 font-semibold tabular-nums text-foreground",children:(e.value??0).toLocaleString()})]},t))})]}):null}function HN({children:e}){return(0,_.jsx)("h3",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em] mb-3",children:e})}function Hk(e,t){if(!e)return t?t("relativeTimeNever"):"Never";let n=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(n<1)return t?t("relativeTimeJustNow"):"just now";if(n<60)return t?t("relativeTimeMinutes",{mins:n}):`${n}m ago`;let r=Math.floor(n/60);if(r<24)return t?t("relativeTimeHours",{hours:r}):`${r}h ago`;let i=Math.floor(r/24);return t?t("relativeTimeDays",{days:i}):`${i}d ago`}function HS(e){return new Date(/[+Z-]$/.test(e)||/[+-]\d\d:?\d\d$/.test(e)?e:`${e}Z`)}function HC({done:e,total:t,doneColor:n}){let r=Math.round(100*(t>0?e/t:0));return(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,_.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,_.jsx)("span",{className:"tabular-nums font-semibold text-foreground text-sm",children:e.toLocaleString()}),(0,_.jsxs)("span",{className:"text-muted-foreground",children:[" / ",t.toLocaleString()]})]}),(0,_.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-foreground",children:[r,"%"]})]}),(0,_.jsx)("div",{className:"h-1.5 w-full rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r}%`,backgroundColor:n}})})]})}function H_({title:e,items:t,emptyLabel:n}){let r=t.reduce((e,t)=>e+t.value,0);return(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("h4",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-[0.08em]",children:e}),(0,_.jsx)(Hw,{value:r,className:"text-xs text-muted-foreground tabular-nums"})]}),0===r?(0,_.jsx)("div",{className:"text-xs text-muted-foreground py-2",children:n}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:t.filter(e=>e.value>0).map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/r*100}%`,backgroundColor:e.color},title:`${e.name}: ${e.value.toLocaleString()}`},e.name))}),(0,_.jsx)("div",{className:"grid grid-cols-3 gap-3 text-sm",children:t.map(e=>(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:e.name})]}),(0,_.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,_.jsx)(Hw,{value:e.value,className:"text-base font-semibold tabular-nums"}),(0,_.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:r>0?`${(e.value/r*100).toFixed(0)}%`:"0%"})]})]},e.name))})]})]})}function HE({icon:e,label:t,value:n}){return(0,_.jsxs)("div",{className:"flex items-center gap-3 p-4",children:[(0,_.jsx)("div",{className:"p-2 rounded-md bg-muted",children:(0,_.jsx)(e,{className:"w-4 h-4 text-muted-foreground"})}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:t}),(0,_.jsx)(Hw,{value:n,className:"text-2xl font-semibold text-foreground leading-tight tabular-nums block"})]})]})}let HT=["completed","processing","pending","failed","cancelled"],HM={completed:"#10b981",processing:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",cancelled:"#6b7280"},HO={completed:"completed",processing:"processing",pending:"pending",failed:"failed",cancelled:"cancelled"};function HA({byStatus:e}){let t=(0,M.useTranslations)("bankStats"),n={completed:t("opsCompleted"),processing:t("opsProcessing"),pending:t("opsPending"),failed:t("opsFailed"),cancelled:t("opsCancelled")},r=HT.map(t=>({status:t,label:n[t]??HO[t],value:e[t]||0,color:HM[t]}));for(let[t,n]of Object.entries(e))HT.includes(t)||r.push({status:t,label:t,value:n,color:Hv});let i=r.reduce((e,t)=>e+t.value,0),a=r.filter(e=>e.value>0);return(0,_.jsxs)(tm.Card,{children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,_.jsxs)(tm.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,_.jsx)(ti,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("operations")]}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,_.jsx)(Hw,{value:i})," ",t("totalSuffix")]})]}),(0,_.jsx)(tm.CardContent,{children:0===i?(0,_.jsx)("div",{className:"h-[100px] flex items-center justify-center text-sm text-muted-foreground",children:t("noOperationsYet")}):(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("div",{className:"h-1.5 flex w-full rounded-full overflow-hidden bg-muted",children:a.map(e=>(0,_.jsx)("div",{className:"h-full",style:{width:`${e.value/i*100}%`,backgroundColor:e.color},title:`${e.label}: ${e.value.toLocaleString()}`},e.status))}),(0,_.jsx)("div",{className:"space-y-1.5",children:a.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px] flex-shrink-0",style:{backgroundColor:e.color}}),(0,_.jsx)("span",{className:"text-muted-foreground flex-1",children:e.label}),(0,_.jsx)(Hw,{value:e.value,className:"font-semibold tabular-nums text-foreground"}),(0,_.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums w-9 text-right",children:[(e.value/i*100).toFixed(0),"%"]})]},e.status))})]})})]})}function HD({done:e,pending:t,failed:n,total:r,lastConsolidatedAt:i}){let a=(0,M.useTranslations)("bankStats"),[o,s]=(0,E.useState)(!1),l=n>0;return(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:a("consolidation")})}),(0,_.jsxs)(tm.CardContent,{className:"space-y-4",children:[(0,_.jsx)(HC,{done:e,total:r,doneColor:Hx}),(0,_.jsxs)("div",{className:"grid grid-cols-4 gap-3 pt-1",children:[(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V1.default,{className:"w-3 h-3 text-emerald-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("done")})]}),(0,_.jsx)(Hw,{value:e,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(VT,{className:"w-3 h-3 text-amber-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("pending")})]}),(0,_.jsx)(Hw,{value:t,className:"text-base font-semibold tabular-nums text-foreground block"})]}),(0,_.jsxs)("button",{type:"button",onClick:()=>l&&s(!0),disabled:!l,className:`text-left space-y-0.5 rounded-md -mx-1 px-1 py-0.5 transition-colors ${l?"cursor-pointer hover:bg-red-500/10 focus:outline-none focus:ring-2 focus:ring-red-500/40":"cursor-default"}`,title:l?a("viewFailedMemoriesLabel"):void 0,children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V2,{className:`w-3 h-3 ${l?"text-red-600 dark:text-red-400":"text-muted-foreground/50"}`}),(0,_.jsx)("span",{className:`text-[10px] uppercase tracking-wider font-medium ${l?"text-red-600 dark:text-red-400":"text-muted-foreground"}`,children:a("failed")})]}),(0,_.jsxs)("span",{className:`text-base font-semibold tabular-nums block ${l?"text-red-600 dark:text-red-400":"text-foreground"}`,children:[(0,_.jsx)(Hw,{value:n}),l&&(0,_.jsx)(V5,{className:"inline w-3 h-3 ml-1 opacity-70"})]})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(ea,{className:"w-3 h-3 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:a("last")})]}),(0,_.jsx)("span",{className:"text-base font-semibold text-foreground block leading-tight",children:Hk(i,a)})]})]})]}),(0,_.jsx)(HP,{open:o,onOpenChange:s})]})}function HP({open:e,onOpenChange:t}){let n=(0,M.useTranslations)("bankStats"),r=(0,M.useTranslations)("failedConsolidations"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(0),[c,u]=(0,E.useState)(!1),[d,h]=(0,E.useState)(!1),[f,p]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(!e||!i)return;let t=!1;return u(!0),$.client.listMemories(i,{consolidationState:"failed",limit:200}).then(e=>{t||(o(e.items),l(e.total))}).catch(()=>{}).finally(()=>{t||u(!1)}),()=>{t=!0}},[e,i,f]);let g=async()=>{if(i){h(!0);try{let e=await $.client.recoverConsolidation(i);e.retried_count>0&&await $.client.triggerConsolidation(i),O.toast.success(r("recoverSuccess",{count:e.retried_count})),p(e=>e+1)}catch{}finally{h(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:t,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-4xl max-h-[80vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsxs)(ta.DialogTitle,{className:"flex items-center gap-2",children:[(0,_.jsx)(V2,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),r("title")]}),(0,_.jsx)(ta.DialogDescription,{children:r("description")})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between gap-2 py-2",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:c?r("loading"):r("totalFailed",{total:s})}),(0,_.jsxs)(X.Button,{size:"sm",onClick:g,disabled:d||c||0===s,children:[(0,_.jsx)(er,{className:`w-3.5 h-3.5 mr-1.5 ${d?"animate-spin":""}`}),r("recoverAll")]})]}),(0,_.jsx)("div",{className:"flex-1 min-h-0 overflow-auto border border-border rounded-md",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[140px]",children:r("colFailedAt")}),(0,_.jsx)(eh,{className:"w-[100px]",children:r("colType")}),(0,_.jsx)(eh,{children:r("colText")})]})}),(0,_.jsxs)(eu,{children:[0===a.length&&!c&&(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:3,className:"text-center text-muted-foreground py-8",children:r("noFailedConsolidations")})}),a.map(e=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"text-xs text-muted-foreground whitespace-nowrap",children:Hk(e.consolidation_failed_at,n)}),(0,_.jsx)(ef,{className:"text-xs capitalize",children:e.fact_type}),(0,_.jsxs)(ef,{className:"text-sm",children:[(0,_.jsx)("div",{className:"line-clamp-2",children:e.text}),e.context&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:e.context})]})]},e.id))]})]})})]})})}function HL({models:e,lastConsolidatedAt:t}){let n=(0,M.useTranslations)("bankStats"),r=e.length,i=t?new Date(t).getTime():0,a=e.filter(e=>!i||!!e.last_refreshed_at&&new Date(e.last_refreshed_at).getTime()>=i).length,o=r-a;return(0,_.jsxs)(tm.Card,{children:[(0,_.jsx)(tm.CardHeader,{className:"pb-2",children:(0,_.jsxs)(tm.CardTitle,{className:"text-sm font-semibold flex items-center gap-2",children:[(0,_.jsx)(Ll,{className:"w-3.5 h-3.5 text-muted-foreground"}),n("mentalModels")]})}),(0,_.jsx)(tm.CardContent,{className:"space-y-4",children:0===r?(0,_.jsx)("div",{className:"text-sm text-muted-foreground py-4",children:n("noMentalModels")}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(HC,{done:a,total:r,doneColor:Hx}),(0,_.jsxs)("div",{className:"grid grid-cols-3 gap-3 pt-1",children:[(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(V1.default,{className:"w-3 h-3 text-emerald-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("upToDate")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:a})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(VT,{className:"w-3 h-3 text-amber-500"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("stale")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:o})]}),(0,_.jsxs)("div",{className:"space-y-0.5",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)(Ll,{className:"w-3 h-3 text-muted-foreground"}),(0,_.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:n("total")})]}),(0,_.jsx)("span",{className:"text-base font-semibold tabular-nums text-foreground block",children:r})]})]})]})})]})}let HI={fontSize:11,fill:Hv,fontWeight:500};function HR(){let e=(0,M.useTranslations)("bankStats"),t={created_at:{short:e("timeFieldIngestedShort"),long:e("timeFieldIngestedLong")},mentioned_at:{short:e("timeFieldMentionedShort"),long:e("timeFieldMentionedLong")},occurred_start:{short:e("timeFieldOccurredShort"),long:e("timeFieldOccurredLong")}},{currentBank:n}=(0,D.useBank)(),{features:r}=(0,Pp.useFeatures)(),i=r?.observations??!1,[a,o]=(0,E.useState)(null),[s,l]=(0,E.useState)([]),[c,u]=(0,E.useState)(!1),[d,h]=(0,E.useState)("7d"),[f,p]=(0,E.useState)("created_at"),[g,x]=(0,E.useState)({trunc:"day",buckets:[]}),[v,y]=(0,E.useState)({world:!0,experience:!0,observation:!0}),b=async()=>{if(n){u(!0);try{let[e,t]=await Promise.all([$.client.getBankStats(n),$.client.listMentalModels(n)]);o(e),l(t.items||[])}catch(e){console.error("Error loading bank stats:",e)}finally{u(!1)}}},w=async()=>{if(n)try{let e=await $.client.getMemoriesTimeseries(n,d,f);x({trunc:e.trunc,buckets:e.buckets||[]})}catch(e){console.error("Error loading memories timeseries:",e)}};if((0,E.useEffect)(()=>{if(n){b();let e=setInterval(b,5e3);return()=>clearInterval(e)}},[n]),(0,E.useEffect)(()=>{if(n){w();let e=setInterval(w,5e3);return()=>clearInterval(e)}},[n,d,f]),c&&!a)return(0,_.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,_.jsx)(ea,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})});if(!a)return null;let j=i?["world","experience","observation"]:["world","experience"],N=g.buckets.map(e=>{var t,n,r,i;let a,o;return{...e,label:(t=e.time,n=g.trunc,a=HS(t),"day"===n?a.toLocaleDateString(void 0,{month:"short",day:"numeric"}):a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})),tooltipLabel:(r=e.time,i=g.trunc,o=HS(r),"day"===i?o.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):o.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}))}}),k=N.reduce((e,t)=>e+j.reduce((e,n)=>e+(v[n]&&t[n]||0),0),0),S=Math.max(0,a.total_nodes-a.pending_consolidation),C={world:e("world"),experience:e("experience"),observation:e("observations")};return(0,_.jsxs)("div",{className:"space-y-8",children:[(0,_.jsxs)("section",{children:[(0,_.jsx)(HN,{children:e("memoryStore")}),(0,_.jsx)(tm.Card,{children:(0,_.jsxs)(tm.CardContent,{className:"p-0",children:[(0,_.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,_.jsx)(HE,{icon:B,label:e("memories"),value:a.total_nodes}),(0,_.jsx)(HE,{icon:V0,label:e("documents"),value:a.total_documents}),(0,_.jsx)(HE,{icon:VJ,label:e("links"),value:a.total_links})]}),(0,_.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,_.jsx)("div",{className:"p-5",children:(0,_.jsx)(H_,{title:e("memoryComposition"),items:[{name:e("world"),value:a.nodes_by_fact_type?.world||0,color:Hp},{name:e("experience"),value:a.nodes_by_fact_type?.experience||0,color:Hm},...i?[{name:e("observations"),value:a.total_observations||0,color:Hg}]:[]],emptyLabel:e("noMemoriesYet")})}),(0,_.jsx)("div",{className:"p-5",children:(0,_.jsx)(H_,{title:e("linkTypes"),items:[{name:e("temporal"),value:a.links_by_link_type?.temporal||0,color:"#009296"},{name:e("semantic"),value:a.links_by_link_type?.semantic||0,color:"#0074d9"},{name:e("entity"),value:a.links_by_link_type?.entity||0,color:"#f59e0b"}],emptyLabel:e("noLinksYet")})})]})]})})]}),(0,_.jsxs)("section",{children:[(0,_.jsx)(HN,{children:e("consolidation")}),(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,_.jsx)(HD,{done:S,pending:a.pending_consolidation,failed:a.failed_consolidation??0,total:a.total_nodes,lastConsolidatedAt:a.last_consolidated_at}),(0,_.jsx)(HL,{models:s,lastConsolidatedAt:a.last_consolidated_at})]})]}),(0,_.jsxs)("section",{children:[(0,_.jsx)(HN,{children:e("activity")}),(0,_.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,_.jsxs)(tm.Card,{className:"lg:col-span-2",children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 space-y-2",children:[(0,_.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:e("memoriesByTimeChartTitle",{field:t[f].short.toLowerCase()})}),(0,_.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5",children:Hh.map(e=>(0,_.jsx)("button",{onClick:()=>h(e),className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors tabular-nums ${d===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e},e))})]}),(0,_.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/60 p-0.5 w-fit",children:Hf.map(e=>(0,_.jsx)("button",{onClick:()=>p(e),title:t[e].long,className:`px-2 py-0.5 text-[11px] font-medium rounded transition-colors ${f===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:t[e].short},e))}),(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("div",{className:"flex items-center gap-1.5",children:j.map(e=>{let t=Hy[e],n=v[e];return(0,_.jsxs)("button",{onClick:()=>y(t=>({...t,[e]:!t[e]})),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[11px] font-medium transition-all ${n?"bg-muted text-foreground":"bg-transparent text-muted-foreground/60 hover:text-muted-foreground"}`,children:[(0,_.jsx)("span",{className:"w-2 h-2 rounded-[2px] transition-opacity",style:{backgroundColor:t.color,opacity:n?1:.3}}),C[e]]},e)})}),(0,_.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(0,_.jsx)(Hw,{value:k})," ",e("totalSuffix")]})]})]}),(0,_.jsx)(tm.CardContent,{children:0===N.length||0===k?(0,_.jsx)("div",{className:"h-[180px] flex items-center justify-center text-sm text-muted-foreground",children:e("noMemoriesIngestedInPeriod")}):(0,_.jsx)("div",{className:"h-[180px]",children:(0,_.jsx)(a3,{width:"100%",height:"100%",children:(0,_.jsxs)(yA,{data:N,margin:{top:8,right:8,bottom:0,left:-10},children:[(0,_.jsx)("defs",{children:j.map(e=>(0,_.jsxs)("linearGradient",{id:`grad-${e}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,_.jsx)("stop",{offset:"0%",stopColor:Hy[e].color,stopOpacity:.35}),(0,_.jsx)("stop",{offset:"100%",stopColor:Hy[e].color,stopOpacity:0})]},e))}),(0,_.jsx)(Hd,{vertical:!1,stroke:"var(--border)",strokeOpacity:.5,strokeDasharray:"2 4"}),(0,_.jsx)(bM,{dataKey:"label",tick:HI,axisLine:!1,tickLine:!1,dy:4,minTickGap:20}),(0,_.jsx)(bB,{tick:HI,axisLine:!1,tickLine:!1,width:40,allowDecimals:!1,tickFormatter:e=>Hb(e)}),(0,_.jsx)(wc,{content:(0,_.jsx)(Hj,{}),labelFormatter:(e,t)=>t?.[0]?.payload?.tooltipLabel||"",cursor:{stroke:Hv,strokeWidth:1,strokeDasharray:"3 3"}}),j.map(e=>v[e]?(0,_.jsx)(be,{type:"monotone",dataKey:e,name:C[e],stackId:"a",stroke:Hy[e].color,strokeWidth:2,fill:`url(#grad-${e})`,isAnimationActive:!1},e):null)]})})})})]}),(0,_.jsx)(HA,{byStatus:a.operations_by_status||{}})]})]})]})}var tn=tn;let HB=(0,I.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Hz=(0,I.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),HF=(0,I.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),HV=["all","retain","consolidation","refresh_mental_model","file_convert_retain","webhook_delivery","graph_maintenance"],HH=[null,"pending","processing","completed","failed","cancelled"];function HU(){let e,t,n,r=(0,M.useTranslations)("bankOperations"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)([]),[s,l]=(0,E.useState)(0),[c,u]=(0,E.useState)(null),[d,h]=(0,E.useState)(null),[f]=(0,E.useState)(10),[p,g]=(0,E.useState)(0),[x,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),[w,j]=(0,E.useState)(!1),[N,k]=(0,E.useState)(null),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(null),[R,B]=(0,E.useState)(()=>Date.now()),z={all:r("status.all"),pending:r("status.pending"),processing:r("status.processing"),completed:r("status.completed"),failed:r("status.failed"),cancelled:r("status.cancelled")},F={all:r("operationType.all"),retain:r("operationType.retain"),consolidation:r("operationType.consolidation"),refresh_mental_model:r("operationType.refreshMentalModel"),file_convert_retain:r("operationType.fileConvertRetain"),webhook_delivery:r("operationType.webhookDelivery"),graph_maintenance:r("operationType.graphMaintenance")},V=e=>e?z[e]??e:r("unknown"),H=e=>e?F[e]??e:r("notAvailable"),U=(e,t)=>{let n=V(e);return"pending"===e?(0,_.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,_.jsx)(ea,{className:"w-3 h-3"}),n]}):"processing"===e?(0,_.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,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}),n]}):"failed"===e?(0,_.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:t??void 0,children:[(0,_.jsx)(VT,{className:"w-3 h-3"}),n]}):"completed"===e?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),n]}):"cancelled"===e?(0,_.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,_.jsx)(HF,{className:"w-3 h-3"}),n]}):(0,_.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:n})},W=e=>{let t=new Date(e).getTime();if(Number.isNaN(t))return"";let n=Math.max(0,Math.round((R-t)/1e3));return n<5?r("heartbeat.justNow"):n<60?r("heartbeat.secondsAgo",{secs:n}):n<3600?r("heartbeat.minutesAgo",{mins:Math.floor(n/60)}):r("heartbeat.hoursAgo",{hours:Math.floor(n/3600)})},Y=(e,t)=>{if(!e)return null;let n=e.stage.replace(/[._]/g," "),i="number"==typeof e.processed&&"number"==typeof e.total&&e.total>0,a=i?Math.min(100,Math.round(e.processed/e.total*100)):null,o=e.at?W(e.at):null;return t?.compact?(0,_.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground whitespace-nowrap",title:`${n}${e.at?` — ${new Date(e.at).toLocaleString()}`:""}`,children:[null!==a&&(0,_.jsx)("span",{className:"h-1 w-14 shrink-0 rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("span",{className:"block h-full rounded-full bg-blue-500/70",style:{width:`${a}%`}})}),i&&(0,_.jsxs)("span",{className:"font-mono",children:[e.processed,"/",e.total]}),o&&(0,_.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",o]})]}):(0,_.jsxs)("div",{className:"mt-1 space-y-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,_.jsx)("span",{className:"capitalize",children:n}),i&&(0,_.jsxs)("span",{className:"font-mono",children:[e.processed,"/",e.total]})]}),null!==a&&(0,_.jsx)("div",{className:"h-1 w-24 rounded-full bg-muted overflow-hidden",children:(0,_.jsx)("div",{className:"h-full rounded-full bg-blue-500/70",style:{width:`${a}%`}})}),e.at&&(0,_.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground/80",title:new Date(e.at).toLocaleString(),children:[(0,_.jsx)(ea,{className:"w-2.5 h-2.5"}),(0,_.jsxs)("span",{children:[r("field.lastHeartbeat")," · ",W(e.at)]})]})]})},G=(0,E.useCallback)(async(e=c,t=p,n=d)=>{if(i){j(!0);try{let r=await $.client.listOperations(i,{status:e||void 0,type:n||void 0,limit:f,offset:t,excludeParents:!0});o(r.operations||[]),l(r.total||0),B(Date.now())}catch(e){console.error("Error loading operations:",e)}finally{j(!1)}}},[i,c,p,d,f]),q=e=>{g(e),G(c,e,d)},K=async e=>{if(i){v(e);try{await $.client.cancelOperation(i,e),await G()}catch(e){}finally{v(null)}}},Z=async e=>{if(i){b(e);try{await $.client.retryOperation(i,e),await G()}catch(e){}finally{b(null)}}},Q=async e=>{if(i){O(!0),C(!0),I(null);try{let t=await $.client.getOperationStatus(i,e);k(t)}catch(e){console.error("Error loading operation details:",e),k({error:r("operationDetailsLoadError")})}finally{O(!1)}}},J=async()=>{if(i&&N?.operation_id){P(!0);try{let e=N.operation_id,t=await $.client.getOperationStatus(i,e,{includePayload:!0});k(t),I(e)}catch(e){console.error("Error loading raw payload:",e)}finally{P(!1)}}},ee=a.some(e=>"processing"===e.status);(0,E.useEffect)(()=>{if(i){G(c,p,d);let e=setInterval(()=>G(c,p,d),ee?2e3:5e3);return()=>clearInterval(e)}},[i,c,p,d,ee,G]),(0,E.useEffect)(()=>{if(!ee)return;let e=setInterval(()=>B(Date.now()),1e3);return()=>clearInterval(e)},[ee]);let et=(0,E.useRef)({}),[en,eo]=(0,E.useState)(new Set);return((0,E.useEffect)(()=>{let e=et.current,t=a.filter(t=>e[t.id]&&e[t.id]!==t.status&&("completed"===t.status||"failed"===t.status||"cancelled"===t.status)).map(e=>e.id);if(et.current=Object.fromEntries(a.map(e=>[e.id,e.status])),0===t.length)return;eo(e=>new Set([...e,...t]));let n=setTimeout(()=>eo(e=>{let n=new Set(e);return t.forEach(e=>n.delete(e)),n}),1200);return()=>clearTimeout(n)},[a]),i)?(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-lg font-semibold",children:r("title")}),(0,_.jsx)("button",{onClick:()=>G(),className:"p-1 rounded hover:bg-muted transition-colors",title:r("refreshOperations"),disabled:w,children:(0,_.jsx)(er,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${w?"animate-spin":""}`})})]}),(0,_.jsxs)("p",{className:"text-sm text-muted-foreground",children:[r("operationCount",{count:s}),c?` (${V(c)})`:""]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsxs)(e6.Select,{value:d??"all",onValueChange:e=>{var t;h(t="all"===e?null:e),g(0),G(c,0,t)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,_.jsx)(e6.SelectValue,{placeholder:r("allTypes")})}),(0,_.jsx)(e6.SelectContent,{children:HV.map(e=>(0,_.jsx)(e6.SelectItem,{value:e,children:(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{children:F[e]}),"all"!==e&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:e})]})},e))})]}),(0,_.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:HH.map(e=>(0,_.jsx)("button",{onClick:()=>{u(e),g(0),G(e,0,d)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${c===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e?V(e):z.all},e??"all"))})]})]}),(0,_.jsx)("div",{children:a.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[100px]",children:r("table.id")}),(0,_.jsx)(eh,{children:r("table.type")}),(0,_.jsx)(eh,{children:r("table.created")}),(0,_.jsx)(eh,{children:r("field.updated")}),(0,_.jsx)(eh,{className:"w-[300px]",children:r("table.status")}),(0,_.jsx)(eh,{className:"w-[110px]",children:r("table.actions")})]})}),(0,_.jsx)(eu,{children:a.map(e=>(0,_.jsxs)(ed,{className:`cursor-pointer transition-colors duration-700 hover:bg-muted/50 ${en.has(e.id)?"completed"===e.status?"bg-emerald-500/15":"bg-red-500/15":"failed"===e.status?"bg-red-500/5":""}`,onClick:()=>Q(e.id),children:[(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.id.substring(0,8)}),(0,_.jsx)(ef,{className:"font-medium",title:e.task_type,children:H(e.task_type)}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",children:new Date(e.created_at).toLocaleString()}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",title:e.updated_at?new Date(e.updated_at).toLocaleString():void 0,children:e.updated_at?W(e.updated_at):"—"}),(0,_.jsx)(ef,{className:"w-[300px]",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[U(e.status,e.error_message),"processing"===e.status&&Y(e.progress,{compact:!0})]})}),(0,_.jsxs)(ef,{className:"w-[110px] whitespace-nowrap",children:["pending"===e.status&&(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:t=>{t.stopPropagation(),K(e.id)},disabled:x===e.id,children:[x===e.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(tt.X,{className:"w-3 h-3 mr-1"}),x===e.id?"":r("action.cancel")]}),("failed"===e.status||"cancelled"===e.status)&&(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:t=>{t.stopPropagation(),Z(e.id)},disabled:y===e.id,children:[y===e.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(HB,{className:"w-3 h-3 mr-1"}),y===e.id?"":r("action.retry")]})]})]},e.id))})]})}),s>f&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:r("pagination",{start:p+1,end:Math.min(p+f,s),total:s})}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>q(Math.max(0,p-f)),disabled:0===p,children:r("paginationPrevious")}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>q(p+f),disabled:p+f>=s,children:r("paginationNext")})]})]})]}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:c?r("emptyStateWithStatus",{status:V(c)}):r("emptyState")})}),(0,_.jsx)(ta.Dialog,{open:S,onOpenChange:C,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("operationDetails")}),(0,_.jsx)(ta.DialogDescription,{children:N?.operation_id&&(0,_.jsx)("span",{className:"font-mono text-xs",children:N.operation_id})})]}),T?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):N?(0,_.jsx)("div",{className:"space-y-4",children:N.error?(0,_.jsx)("div",{className:"text-red-600 dark:text-red-400",children:N.error}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.status")}),(0,_.jsx)("div",{className:"mt-1",children:U(N.status)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.type")}),(0,_.jsx)("div",{className:"mt-1 font-mono text-sm",title:N.operation_type??void 0,children:H(N.operation_type)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.created")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.created_at?new Date(N.created_at).toLocaleString():r("notAvailable")})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.updated")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.updated_at?new Date(N.updated_at).toLocaleString():r("notAvailable")})]}),N.completed_at&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("field.completed")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:new Date(N.completed_at).toLocaleString()})]}),N.result_metadata?.items_count!==void 0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("totalItems")}),(0,_.jsx)("div",{className:"mt-1 text-sm",children:N.result_metadata.items_count})]})]}),"processing"===N.status&&N.progress&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:r("field.progress")}),Y(N.progress),"consolidation"===N.operation_type&&(0,_.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/70",children:r("progressEstimateNote")})]}),("pending"===N.status||"failed"===N.status||"cancelled"===N.status)&&(0,_.jsxs)("div",{className:"flex gap-2",children:["pending"===N.status&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>K(N.operation_id),disabled:x===N.operation_id,children:[x===N.operation_id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,_.jsx)(tt.X,{className:"w-3 h-3 mr-1"}),r("action.cancel")]}),("failed"===N.status||"cancelled"===N.status)&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>Z(N.operation_id),disabled:y===N.operation_id,children:[y===N.operation_id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin mr-1"}):(0,_.jsx)(HB,{className:"w-3 h-3 mr-1"}),r("action.retry")]})]}),N.result_metadata&&Object.keys(N.result_metadata).length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:r("metadata")}),(0,_.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(N.result_metadata,null,2)})]}),N.error_message&&(0,_.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,_.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:r("error")}),(0,_.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:N.error_message})]}),N.child_operations&&N.child_operations.length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:r("subBatchesCount",{count:N.result_metadata?.num_sub_batches||N.child_operations.length})}),(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[60px]",children:r("table.index")}),(0,_.jsx)(eh,{className:"w-[100px]",children:r("table.id")}),(0,_.jsx)(eh,{className:"w-[80px]",children:r("table.items")}),(0,_.jsx)(eh,{children:r("table.status")})]})}),(0,_.jsx)(eu,{children:N.child_operations.map(e=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"text-sm",children:e.sub_batch_index}),(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.operation_id.substring(0,8)}),(0,_.jsx)(ef,{className:"text-sm",children:e.items_count}),(0,_.jsx)(ef,{children:U(e.status,e.error_message)})]},e.operation_id))})]})]}),(e=L===N.operation_id,t=!!N.task_payload,n=!!N.result_metadata?.is_parent,(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,_.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:r("rawPayload")}),!e&&(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:J,disabled:A,children:[A?(0,_.jsx)(tn.default,{className:"w-3 h-3 mr-1 animate-spin"}):(0,_.jsx)(Hz,{className:"w-3 h-3 mr-1"}),r("loadRaw")]})]}),t?(0,_.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(N.task_payload,null,2)}):e?(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:n?r("rawPayloadParentHelp"):r("rawPayloadEmpty")}):(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("rawPayloadHelp")})]}))]})}):null]})})]}):null}var tn=tn;let HW=(0,I.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 HY(){let e=(0,M.useTranslations)("mentalModels"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)("files"),[l,c]=(0,E.useState)(""),[u,d]=(0,E.useState)(1),[h,f]=(0,E.useState)(!1),[p,g]=(0,E.useState)(null),[x,v]=(0,E.useState)(null),[y,b]=(0,E.useState)([]),[w,j]=(0,E.useState)("any"),[N,k]=(0,E.useState)(!1),[S,C]=(0,E.useState)(null),[T,A]=(0,E.useState)(null),[P,L]=(0,E.useState)(!1),[I,B]=(0,E.useState)(null),[z,F]=(0,E.useState)(!1),U=n.filter(e=>{if(!l)return!0;let t=l.toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.source_query.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),W=async()=>{if(t){a(!0);try{let e=await $.client.listMentalModels(t,y.length>0?y:void 0,y.length>0?w:void 0);r(e.items||[])}catch(e){console.error("Error loading mental models:",e)}finally{a(!1)}}},[Y,G]=(0,E.useState)(new Set),K=async n=>{if(!t)return;let i=n.last_refreshed_at;G(e=>new Set(e).add(n.id));try{await $.client.refreshMentalModel(t,n.id);for(let a=0;a<120;a++){await new Promise(e=>setTimeout(e,1e3));let a=await $.client.getMentalModel(t,n.id);if(a.last_refreshed_at!==i){r(e=>e.map(e=>e.id===n.id?a:e)),p?.id===n.id&&g(a),O.toast.success(e("toastRefreshed"));return}}O.toast.error(e("toastRefreshTimeout"))}catch{}finally{G(e=>{let t=new Set(e);return t.delete(n.id),t})}},Z=async()=>{if(t&&T){L(!0);try{await $.client.deleteMentalModel(t,T.id),r(e=>e.filter(e=>e.id!==T.id)),p?.id===T.id&&g(null),A(null)}catch(e){}finally{L(!1)}}},Q=async()=>{if(t&&I){F(!0);try{let e=await $.client.clearMentalModel(t,I.id);r(t=>t.map(t=>t.id===e.id?e:t)),p?.id===e.id&&g(e),O.toast.success("Mental model content cleared"),B(null)}catch{}finally{F(!1)}}};if((0,E.useEffect)(()=>{t&&W()},[t,y,w]),(0,E.useEffect)(()=>{let e=e=>{"Escape"===e.key&&g(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,E.useEffect)(()=>{d(1)},[l,y,w]),!t)return(0,_.jsx)(tm.Card,{children:(0,_.jsx)(tm.CardContent,{className:"p-10 text-center",children:(0,_.jsx)("p",{className:"text-muted-foreground",children:e("selectBankPrompt")})})});let et=Math.ceil(U.length/100),en=(u-1)*100,ei=en+100,ea=U.slice(en,ei);return(0,_.jsxs)("div",{children:[i?(0,_.jsxs)("div",{className:"text-center py-12",children:[(0,_.jsx)(er,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,_.jsx)("p",{className:"text-muted-foreground",children:e("loading")})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"mb-4 flex items-center gap-3 flex-wrap",children:[(0,_.jsx)(q.Input,{type:"text",value:l,onChange:e=>c(e.target.value),placeholder:e("filterPlaceholder"),className:"w-80 h-9"}),(0,_.jsx)(Pc,{value:y,onChange:b,fetchSuggestions:async e=>{if(!t)return[];let n=e?`${e}*`:void 0;return(await $.client.listTags(t,n,20,"mental_models")).items.map(e=>e.tag)},matchMode:w,onMatchModeChange:j,className:"flex-1 min-w-[260px]"}),(0,_.jsxs)(X.Button,{onClick:()=>f(!0),size:"sm",children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-2"}),e("addMentalModel")]})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,_.jsx)("div",{className:"text-sm text-muted-foreground",children:l||y.length>0?e("countFiltered",{filtered:U.length,total:n.length}):e("count",{count:n.length})}),(0,_.jsx)("div",{className:"flex items-center gap-3",children:(0,_.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,_.jsxs)("button",{onClick:()=>s("files"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"files"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(V0,{className:"w-4 h-4"}),e("viewList")]}),(0,_.jsxs)("button",{onClick:()=>s("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,_.jsx)(HW,{className:"w-4 h-4"}),e("viewDashboard")]})]})})]}),U.length>0?(0,_.jsxs)(_.Fragment,{children:["dashboard"===o&&(0,_.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ea.map(t=>(0,_.jsx)(tm.Card,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${p?.id===t.id?"border-primary shadow-md":""}`,onClick:()=>g(t),children:(0,_.jsxs)(tm.CardContent,{className:"p-4",children:[(0,_.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:t.name}),(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:t.id}),(0,_.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${t.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:t.trigger?.refresh_after_consolidation?e("badgeAutoRefresh"):e("badgeManual")})]})]}),(0,_.jsx)(HG,{m:t,refreshing:Y.has(t.id),onEdit:e=>{C(e),k(!0)},onRefresh:K,onClear:e=>B({id:e.id,name:e.name}),onDelete:e=>A({id:e.id,name:e.name}),triggerClassName:"h-7 w-7 ml-2 flex-shrink-0"})]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:t.source_query}),(0,_.jsxs)("div",{className:"relative mb-3 border-t border-border pt-3 max-h-40 overflow-hidden",children:[(0,_.jsx)(F2,{children:t.content}),(0,_.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-card to-transparent"})]}),(0,_.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,_.jsx)("div",{className:"flex items-center gap-2",children:t.tags.length>0&&(0,_.jsxs)("div",{className:"flex gap-1",children:[t.tags.slice(0,2).map(e=>(0,_.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e)),t.tags.length>2&&(0,_.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",t.tags.length-2]})]})}),(0,_.jsx)("div",{className:"text-muted-foreground",title:F6(t.last_refreshed_at),children:F4(t.last_refreshed_at)})]})]})},t.id))}),"files"===o&&(0,_.jsx)(Hq,{mentalModels:U,selectedId:x,onSelect:v,onOpenDetail:g,refreshingIds:Y,onEdit:e=>{C(e),k(!0)},onRefresh:K,onClear:e=>B({id:e.id,name:e.name}),onDelete:e=>A({id:e.id,name:e.name})}),"files"!==o&&et>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[en+1,"-",Math.min(ei,U.length)," of"," ",U.length]}),(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(1),disabled:1===u,className:"h-7 w-7 p-0",children:(0,_.jsx)(J,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(e=>Math.max(1,e-1)),disabled:1===u,className:"h-7 w-7 p-0",children:(0,_.jsx)(V,{className:"h-3 w-3"})}),(0,_.jsxs)("span",{className:"text-xs px-2",children:[u," / ",et]}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(e=>Math.min(et,e+1)),disabled:u===et,className:"h-7 w-7 p-0",children:(0,_.jsx)(H.ChevronRight,{className:"h-3 w-3"})}),(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>d(et),disabled:u===et,className:"h-7 w-7 p-0",children:(0,_.jsx)(ee,{className:"h-3 w-3"})})]})]})]}):(0,_.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,_.jsx)(R,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:l?e("emptyFilterMatch"):e("emptyNoModels")})]})]}),(0,_.jsx)(H$,{open:h,onClose:()=>f(!1),onCreated:()=>{f(!1),W()}}),(0,_.jsx)(PN,{open:!!T,onOpenChange:e=>!e&&A(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("deleteDialogTitle")}),(0,_.jsxs)(PW,{children:[e("deleteDialogDescription",{name:T?.name??""}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{className:"text-destructive font-semibold",children:e("deleteDialogWarning")})]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:e("deleteDialogCancel")}),(0,_.jsxs)(PY,{onClick:Z,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[P?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,e("deleteDialogConfirm")]})]})]})}),(0,_.jsx)(PN,{open:!!I,onOpenChange:e=>!e&&B(null),children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:e("clearDialogTitle")}),(0,_.jsxs)(PW,{children:[e.rich("clearDialogDescription",{name:I?.name??"",bold:e=>(0,_.jsx)("span",{className:"font-semibold",children:e})}),(0,_.jsx)("br",{}),(0,_.jsx)("br",{}),e("clearDialogReSynth")]})]}),(0,_.jsxs)(PH,{className:"flex-row justify-end space-x-2",children:[(0,_.jsx)(PG,{className:"mt-0",children:e("cancelButton")}),(0,_.jsxs)(PY,{onClick:Q,disabled:z,children:[z?(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}):null,e("clearDialogConfirm")]})]})]})}),(0,_.jsx)(Vl,{mentalModelId:p?.id??null,onClose:()=>g(null),onDelete:e=>A({id:e.id,name:e.name}),onClear:e=>B({id:e.id,name:e.name}),onEdit:e=>{C(e),k(!0)},onRefreshed:e=>{r(t=>t.map(t=>t.id===e.id?e:t)),g(e)}}),S&&(0,_.jsx)(HX,{open:N,mentalModel:S,onClose:()=>{k(!1),C(null)},onUpdated:e=>{r(t=>t.map(t=>t.id===e.id?e:t)),g(e),k(!1),C(null)}})]})}function HG({m:e,refreshing:t,onEdit:n,onRefresh:r,onClear:i,onDelete:a,triggerClassName:o}){let s=(0,M.useTranslations)("mentalModels");return(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:`p-0 text-muted-foreground ${o??"h-8 w-8"}`,onClick:e=>e.stopPropagation(),"aria-label":s("actionsAriaLabel"),children:(0,_.jsx)(Pq,{className:"h-4 w-4"})})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>n(e),children:[(0,_.jsx)(PX,{className:"h-4 w-4 mr-2"}),s("actionEdit")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>r(e),disabled:t,children:[(0,_.jsx)(er,{className:`h-4 w-4 mr-2 ${t?"animate-spin":""}`}),s("actionRefresh")]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>i(e),children:[(0,_.jsx)(L3,{className:"h-4 w-4 mr-2"}),s("actionClearContent")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>a(e),className:"text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400 focus:bg-red-500/10",children:[(0,_.jsx)(P$,{className:"h-4 w-4 mr-2"}),s("actionDelete")]})]})]})}function H$({open:e,onClose:t,onCreated:n}){let r=(0,M.useTranslations)("mentalModels"),{currentBank:i}=(0,D.useBank)(),[a,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),c=async()=>{if(i&&s.name.trim()&&s.sourceQuery.trim()){o(!0);try{let e,t=s.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),a=parseInt(s.maxTokens)||2048,o=s.excludeMentalModelIds.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(s.tagGroups.trim())try{e=JSON.parse(s.tagGroups.trim())}catch{O.toast.error(r("invalidTagGroupsJson"));return}let c=s.recallMaxTokens.trim()?parseInt(s.recallMaxTokens,10):void 0,u=s.recallChunksMaxTokens.trim()?parseInt(s.recallChunksMaxTokens,10):void 0,d="true"===s.includeChunks||"false"!==s.includeChunks&&void 0;await $.client.createMentalModel(i,{id:s.id.trim()||void 0,name:s.name.trim(),source_query:s.sourceQuery.trim(),tags:t.length>0?t:void 0,max_tokens:a,trigger:{mode:s.mode,refresh_after_consolidation:s.autoRefresh,fact_types:s.factTypes.length>0?s.factTypes:void 0,exclude_mental_models:s.excludeMentalModels||void 0,exclude_mental_model_ids:o.length>0?o:void 0,tags_match:s.tagsMatch||void 0,tag_groups:e,include_chunks:d,recall_max_tokens:c,recall_chunks_max_tokens:u}}),l({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),n()}catch(e){}finally{o(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>{e||(l({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1,mode:"full",factTypes:[],excludeMentalModels:!1,excludeMentalModelIds:"",tagsMatch:"",tagGroups:"",includeChunks:"",recallMaxTokens:"",recallChunksMaxTokens:""}),t())},children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:r("createDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:r("createDialogDescription")})]}),(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,_.jsxs)(ts.TabsList,{className:"w-full",children:[(0,_.jsx)(ts.TabsTrigger,{value:"general",className:"flex-1",children:r("tabGeneral")}),(0,_.jsx)(ts.TabsTrigger,{value:"options",className:"flex-1",children:r("tabOptions")})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,_.jsxs)(ts.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldId")}),(0,_.jsx)(q.Input,{value:s.id,onChange:e=>l({...s,id:e.target.value}),placeholder:r("fieldIdPlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldName")}),(0,_.jsx)(q.Input,{value:s.name,onChange:e=>l({...s,name:e.target.value}),placeholder:r("fieldNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldSourceQuery")}),(0,_.jsx)(Lh.Textarea,{value:s.sourceQuery,onChange:e=>l({...s,sourceQuery:e.target.value}),placeholder:r("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("fieldMaxTokens")}),(0,_.jsx)(q.Input,{type:"number",value:s.maxTokens,onChange:e=>l({...s,maxTokens:e.target.value}),placeholder:r("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,_.jsxs)(ts.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionRefresh")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"auto-refresh",checked:s.autoRefresh,onCheckedChange:e=>l({...s,autoRefresh:!0===e})}),(0,_.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:r("optionsAutoRefreshLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRefreshModeLabel")}),(0,_.jsxs)(e6.Select,{value:s.mode,onValueChange:e=>l({...s,mode:e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"full",children:r("optionsRefreshModeFull")}),(0,_.jsx)(e6.SelectItem,{value:"delta",children:r("optionsRefreshModeDelta")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRefreshModeDeltaDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionOtherModels")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"exclude-mental-models",checked:s.excludeMentalModels,onCheckedChange:e=>l({...s,excludeMentalModels:!0===e})}),(0,_.jsx)("label",{htmlFor:"exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:r("optionsExcludeAllLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsExcludeIdsLabel")}),(0,_.jsx)(q.Input,{value:s.excludeMentalModelIds,onChange:e=>l({...s,excludeMentalModelIds:e.target.value}),placeholder:r("optionsExcludeIdsPlaceholder")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionTags")}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagsLabel")}),(0,_.jsx)(q.Input,{value:s.tags,onChange:e=>l({...s,tags:e.target.value}),placeholder:r("optionsTagsPlaceholder")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagsDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagsMatchLabel")}),(0,_.jsxs)(e6.Select,{value:s.tagsMatch,onValueChange:e=>l({...s,tagsMatch:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{placeholder:r("optionsTagsMatchDefaultPlaceholder")})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:r("optionsTagsMatchDefault")}),(0,_.jsx)(e6.SelectItem,{value:"any",children:r("optionsTagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:r("optionsTagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:r("optionsTagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:r("optionsTagsMatchAllStrict")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagsMatchDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsTagGroupsLabel")}),(0,_.jsx)(Lh.Textarea,{value:s.tagGroups,onChange:e=>l({...s,tagGroups:e.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsTagGroupsDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:r("optionsSectionRecall")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallDescription")}),(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsFactTypesLabel")}),(0,_.jsx)(Lo,{value:s.factTypes,onChange:e=>l({...s,factTypes:e})}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsFactTypesEmpty")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsIncludeChunksLabel")}),(0,_.jsxs)(e6.Select,{value:s.includeChunks||"default",onValueChange:e=>l({...s,includeChunks:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:r("optionsIncludeChunksDefault")}),(0,_.jsx)(e6.SelectItem,{value:"true",children:r("optionsIncludeChunksYes")}),(0,_.jsx)(e6.SelectItem,{value:"false",children:r("optionsIncludeChunksNo")})]})]})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRecallMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:s.recallMaxTokens,onChange:e=>l({...s,recallMaxTokens:e.target.value}),placeholder:r("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallMaxTokensDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:r("optionsRecallChunksMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:s.recallChunksMaxTokens,onChange:e=>l({...s,recallChunksMaxTokens:e.target.value}),placeholder:r("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:r("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:t,disabled:a,children:r("cancelButton")}),(0,_.jsx)(X.Button,{onClick:c,disabled:a||!s.name.trim()||!s.sourceQuery.trim(),children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}),r("creatingButton")]}):r("createButton")})]})]})})}function HX({open:e,mentalModel:t,onClose:n,onUpdated:r}){let i=(0,M.useTranslations)("mentalModels"),{currentBank:a}=(0,D.useBank)(),[o,s]=(0,E.useState)(!1),l=()=>({name:t.name,sourceQuery:t.source_query,maxTokens:String(t.max_tokens||2048),tags:t.tags.join(", "),autoRefresh:t.trigger?.refresh_after_consolidation||!1,mode:t.trigger?.mode||"full",factTypes:t.trigger?.fact_types||[],excludeMentalModels:t.trigger?.exclude_mental_models||!1,excludeMentalModelIds:(t.trigger?.exclude_mental_model_ids||[]).join(", "),tagsMatch:t.trigger?.tags_match||"",tagGroups:t.trigger?.tag_groups?JSON.stringify(t.trigger.tag_groups,null,2):"",includeChunks:t.trigger?.include_chunks===!0?"true":t.trigger?.include_chunks===!1?"false":"",recallMaxTokens:t.trigger?.recall_max_tokens!=null?String(t.trigger.recall_max_tokens):"",recallChunksMaxTokens:t.trigger?.recall_chunks_max_tokens!=null?String(t.trigger.recall_chunks_max_tokens):""}),[c,u]=(0,E.useState)(l);(0,E.useEffect)(()=>{e&&u(l())},[e,t]);let d=async()=>{if(a&&c.name.trim()&&c.sourceQuery.trim()){s(!0);try{let e,o=c.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),s=parseInt(c.maxTokens)||2048,l=c.excludeMentalModelIds.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(c.tagGroups.trim())try{e=JSON.parse(c.tagGroups.trim())}catch{O.toast.error(i("invalidTagGroupsJson"));return}let u=c.recallMaxTokens.trim()?parseInt(c.recallMaxTokens,10):void 0,d=c.recallChunksMaxTokens.trim()?parseInt(c.recallChunksMaxTokens,10):void 0,h="true"===c.includeChunks||"false"!==c.includeChunks&&void 0,f=await $.client.updateMentalModel(a,t.id,{name:c.name.trim(),source_query:c.sourceQuery.trim(),tags:o.length>0?o:void 0,max_tokens:s,trigger:{mode:c.mode,refresh_after_consolidation:c.autoRefresh,fact_types:c.factTypes.length>0?c.factTypes:void 0,exclude_mental_models:c.excludeMentalModels||void 0,exclude_mental_model_ids:l.length>0?l:void 0,tags_match:c.tagsMatch||void 0,tag_groups:e,include_chunks:h,recall_max_tokens:u,recall_chunks_max_tokens:d}});r(f),n()}catch(e){}finally{s(!1)}}};return(0,_.jsx)(ta.Dialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,_.jsxs)(ta.DialogContent,{className:"sm:max-w-2xl max-h-[90vh] flex flex-col",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:i("updateDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:i("updateDialogDescription")})]}),(0,_.jsxs)(ts.Tabs,{defaultValue:"general",className:"py-2 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,_.jsxs)(ts.TabsList,{className:"w-full",children:[(0,_.jsx)(ts.TabsTrigger,{value:"general",className:"flex-1",children:i("tabGeneral")}),(0,_.jsx)(ts.TabsTrigger,{value:"options",className:"flex-1",children:i("tabOptions")})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto mt-2 px-1.5",children:[(0,_.jsxs)(ts.TabsContent,{value:"general",className:"space-y-4 pt-4",children:[(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:i("fieldId")}),(0,_.jsx)(q.Input,{value:t.id,disabled:!0,className:"bg-muted"})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldName")}),(0,_.jsx)(q.Input,{value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:i("fieldNamePlaceholder")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldSourceQuery")}),(0,_.jsx)(Lh.Textarea,{value:c.sourceQuery,onChange:e=>u({...c,sourceQuery:e.target.value}),placeholder:i("fieldSourceQueryPlaceholder"),className:"min-h-[140px] font-mono text-sm leading-6 whitespace-pre-wrap",spellCheck:!1})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("fieldMaxTokens")}),(0,_.jsx)(q.Input,{type:"number",value:c.maxTokens,onChange:e=>u({...c,maxTokens:e.target.value}),placeholder:i("fieldMaxTokensPlaceholder"),min:"256",max:"8192"})]})]}),(0,_.jsxs)(ts.TabsContent,{value:"options",className:"space-y-6 pt-4",children:[(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionRefresh")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"update-auto-refresh",checked:c.autoRefresh,onCheckedChange:e=>u({...c,autoRefresh:!0===e})}),(0,_.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:i("optionsAutoRefreshLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRefreshModeLabel")}),(0,_.jsxs)(e6.Select,{value:c.mode,onValueChange:e=>u({...c,mode:e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"full",children:i("optionsRefreshModeFull")}),(0,_.jsx)(e6.SelectItem,{value:"delta",children:i("optionsRefreshModeDelta")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRefreshModeDeltaDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionOtherModels")}),(0,_.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,_.jsx)(Pm.Checkbox,{id:"update-exclude-mental-models",checked:c.excludeMentalModels,onCheckedChange:e=>u({...c,excludeMentalModels:!0===e})}),(0,_.jsx)("label",{htmlFor:"update-exclude-mental-models",className:"text-sm font-medium text-foreground cursor-pointer",children:i("optionsExcludeAllLabel")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsExcludeIdsLabel")}),(0,_.jsx)(q.Input,{value:c.excludeMentalModelIds,onChange:e=>u({...c,excludeMentalModelIds:e.target.value}),placeholder:i("optionsExcludeIdsPlaceholder")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionTags")}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagsLabel")}),(0,_.jsx)(q.Input,{value:c.tags,onChange:e=>u({...c,tags:e.target.value}),placeholder:i("optionsTagsPlaceholder")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagsDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagsMatchLabel")}),(0,_.jsxs)(e6.Select,{value:c.tagsMatch||"default",onValueChange:e=>u({...c,tagsMatch:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{placeholder:i("optionsTagsMatchDefaultPlaceholder")})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:i("optionsTagsMatchDefault")}),(0,_.jsx)(e6.SelectItem,{value:"any",children:i("optionsTagsMatchAny")}),(0,_.jsx)(e6.SelectItem,{value:"all",children:i("optionsTagsMatchAll")}),(0,_.jsx)(e6.SelectItem,{value:"any_strict",children:i("optionsTagsMatchAnyStrict")}),(0,_.jsx)(e6.SelectItem,{value:"all_strict",children:i("optionsTagsMatchAllStrict")})]})]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagsMatchDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsTagGroupsLabel")}),(0,_.jsx)(Lh.Textarea,{value:c.tagGroups,onChange:e=>u({...c,tagGroups:e.target.value}),placeholder:'e.g., [{"or": [{"tags": ["user:alice"], "match": "all_strict"}, {"tags": ["shared"]}]}]',rows:3,className:"font-mono text-xs"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsTagGroupsDescription")})]})]}),(0,_.jsxs)("section",{className:"space-y-4",children:[(0,_.jsx)("h3",{className:"text-sm font-semibold text-foreground border-b pb-1",children:i("optionsSectionRecall")}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallDescription")}),(0,_.jsxs)("div",{className:"space-y-3",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsFactTypesLabel")}),(0,_.jsx)(Lo,{value:c.factTypes,onChange:e=>u({...c,factTypes:e})}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsFactTypesEmpty")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsIncludeChunksLabel")}),(0,_.jsxs)(e6.Select,{value:c.includeChunks||"default",onValueChange:e=>u({...c,includeChunks:"default"===e?"":e}),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"default",children:i("optionsIncludeChunksDefault")}),(0,_.jsx)(e6.SelectItem,{value:"true",children:i("optionsIncludeChunksYes")}),(0,_.jsx)(e6.SelectItem,{value:"false",children:i("optionsIncludeChunksNo")})]})]})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRecallMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:c.recallMaxTokens,onChange:e=>u({...c,recallMaxTokens:e.target.value}),placeholder:i("optionsRecallMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallMaxTokensDescription")})]}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)("label",{className:"text-sm font-medium text-foreground",children:i("optionsRecallChunksMaxTokensLabel")}),(0,_.jsx)(q.Input,{type:"number",value:c.recallChunksMaxTokens,onChange:e=>u({...c,recallChunksMaxTokens:e.target.value}),placeholder:i("optionsRecallChunksMaxTokensPlaceholder"),min:"0"}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:i("optionsRecallChunksMaxTokensDescription")})]})]})]})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:n,disabled:o,children:i("cancelButton")}),(0,_.jsx)(X.Button,{onClick:d,disabled:o||!c.name.trim()||!c.sourceQuery.trim(),children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 animate-spin mr-1"}),i("updatingButton")]}):i("updateButton")})]})]})})}function Hq({mentalModels:e,selectedId:t,onSelect:n,onOpenDetail:r,refreshingIds:i,onEdit:a,onRefresh:o,onClear:s,onDelete:l}){let c=(0,M.useTranslations)("mentalModels"),u=t&&e.some(e=>e.id===t)?t:e[0]?.id??null,d=e.find(e=>e.id===u)??null;return(0,_.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[320px_1fr] gap-0 overflow-hidden min-h-[600px]",children:[(0,_.jsx)("aside",{className:"border-r border-border bg-muted/30 overflow-y-auto max-h-[calc(100vh-260px)]",children:(0,_.jsx)("ul",{className:"py-1",children:e.map(e=>{let t=e.id===u;return(0,_.jsx)("li",{children:(0,_.jsxs)("button",{onClick:()=>n(e.id),className:`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors border-l-2 ${t?"bg-primary/10 border-primary text-foreground":"border-transparent text-muted-foreground hover:bg-muted hover:text-foreground"}`,title:`${e.name}
|
|
9
|
+
${e.source_query}`,children:[(0,_.jsx)(z.FileText,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),(0,_.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("span",{className:`truncate text-sm font-medium ${t?"text-foreground":""}`,children:e.name}),(0,_.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",title:F6(e.last_refreshed_at),children:F4(e.last_refreshed_at)})]}),e.source_query&&(0,_.jsx)("div",{className:"text-xs text-muted-foreground/80 truncate italic mt-0.5",children:e.source_query})]})]})},e.id)})})}),(0,_.jsx)("section",{className:"overflow-y-auto max-h-[calc(100vh-260px)]",children:d?(0,_.jsxs)("article",{className:"p-6",children:[(0,_.jsx)("header",{className:"mb-4 pb-4 border-b border-border",children:(0,_.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,_.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,_.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:d.name}),d.source_query&&(0,_.jsxs)("p",{className:"text-sm text-muted-foreground mt-1 italic",children:["“",d.source_query,"”"]}),(0,_.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,_.jsxs)("span",{title:F6(d.last_refreshed_at),children:["Refreshed ",F4(d.last_refreshed_at)]}),d.tags.length>0&&(0,_.jsx)("div",{className:"flex gap-1",children:d.tags.map(e=>(0,_.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:e},e))})]})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,_.jsx)(X.Button,{variant:"outline",size:"sm",onClick:()=>r(d),children:"Open"}),(0,_.jsx)(HG,{m:d,refreshing:i.has(d.id),onEdit:a,onRefresh:o,onClear:s,onDelete:l})]})]})}),d.content?(0,_.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:(0,_.jsx)(F2,{children:d.content})}):(0,_.jsx)("p",{className:"text-sm text-muted-foreground italic",children:c("emptyContent")})]}):(0,_.jsxs)("div",{className:"p-10 text-center text-muted-foreground",children:[(0,_.jsx)(z.FileText,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,_.jsx)("p",{className:"text-sm",children:c("selectModelPrompt")})]})})]})}let HK=(0,I.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 tn=tn;let HZ=["consolidation.completed","retain.completed"],HQ={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function HJ(e){return Object.fromEntries(e.filter(e=>e.key.trim()).map(e=>[e.key,e.value]))}function H0(e){return{method:e.method,timeout_seconds:e.timeout_seconds,headers:HJ(e.headers),params:HJ(e.params)}}function H1({label:e,pairs:t,onChange:n}){let r=(0,M.useTranslations)("webhooksView"),i=(e,r,i)=>{n(t.map((t,n)=>n===e?{...t,[r]:i}:t))};return(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)(eb,{children:e}),(0,_.jsxs)(X.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>n([...t,{key:"",value:""}]),children:[(0,_.jsx)(Pd.Plus,{className:"w-3 h-3 mr-1"}),r("kvAdd")]})]}),t.length>0&&(0,_.jsx)("div",{className:"space-y-1.5",children:t.map((e,a)=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(q.Input,{placeholder:r("kvKeyPlaceholder"),value:e.key,onChange:e=>i(a,"key",e.target.value),className:"h-8 text-sm flex-1"}),(0,_.jsx)(q.Input,{placeholder:r("kvValuePlaceholder"),value:e.value,onChange:e=>i(a,"value",e.target.value),className:"h-8 text-sm flex-1"}),(0,_.jsx)("button",{type:"button",onClick:()=>n(t.filter((e,t)=>t!==a)),className:"text-muted-foreground hover:text-foreground shrink-0","aria-label":r("kvRemovePair"),children:(0,_.jsx)(tt.X,{className:"w-4 h-4"})})]},a))})]})}function H2({status:e}){let t=(0,M.useTranslations)("webhooksView");return"completed"===e?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),t("deliveryStatusDelivered")]}):"pending"===e?(0,_.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,_.jsx)(ea,{className:"w-3 h-3"}),t("deliveryStatusPending")]}):"failed"===e?(0,_.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,_.jsx)(VT,{className:"w-3 h-3"}),t("deliveryStatusFailed")]}):(0,_.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:e})}function H5({delivery:e,formatDate:t}){let n=(0,M.useTranslations)("webhooksView"),[r,i]=(0,E.useState)(!1),a=e.last_response_body||e.last_error;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(ed,{className:a?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>a&&i(e=>!e),children:[(0,_.jsx)(ef,{className:"w-8 pl-3 pr-0",children:a?r?(0,_.jsx)(PK.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,_.jsx)(H.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,_.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,_.jsx)(ef,{children:(0,_.jsx)(H2,{status:e.status})}),(0,_.jsx)(ef,{children:null!=e.last_response_status?(0,_.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${e.last_response_status>=200&&e.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:e.last_response_status}):(0,_.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,_.jsx)(ef,{className:"text-center text-sm",children:e.attempts}),(0,_.jsx)(ef,{className:"font-mono text-xs text-muted-foreground",children:e.event_type}),(0,_.jsx)(ef,{className:"text-xs text-muted-foreground whitespace-nowrap",children:t(e.created_at)})]}),r&&a&&(0,_.jsx)(ed,{className:"bg-muted/20 hover:bg-muted/20",children:(0,_.jsx)(ef,{colSpan:6,className:"px-4 py-3",children:(0,_.jsxs)("div",{className:"space-y-3",children:[e.last_error&&(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("expandedError")}),(0,_.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:e.last_error})]}),e.last_response_body&&(0,_.jsxs)("div",{className:"space-y-1",children:[(0,_.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:[n("expandedResponseBody"),e.last_attempt_at&&(0,_.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",t(e.last_attempt_at)]})]}),(0,_.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:e.last_response_body})]})]})})})]})}function H3(){let e=(0,M.useTranslations)("webhooksView"),{currentBank:t}=(0,D.useBank)(),[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(!1),[l,c]=(0,E.useState)(!1),[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)(null),[p,g]=(0,E.useState)(!1),[x,v]=(0,E.useState)(HQ),[y,b]=(0,E.useState)(!1),[w,j]=(0,E.useState)(null),[N,k]=(0,E.useState)(HQ),[S,C]=(0,E.useState)(!1),[T,O]=(0,E.useState)(!1),[A,P]=(0,E.useState)(!1),[L,I]=(0,E.useState)(!1),[R,B]=(0,E.useState)(null),[z,F]=(0,E.useState)([]),[V,H]=(0,E.useState)(!1),[U,W]=(0,E.useState)(null),[Y,G]=(0,E.useState)(!1),K=async()=>{if(t){a(!0);try{let e=await $.client.listWebhooks(t);r(e.items||[])}catch(e){console.error("Error loading webhooks:",e)}finally{a(!1)}}};(0,E.useEffect)(()=>{t&&K()},[t]);let Z=async()=>{if(t&&x.url){c(!0);try{await $.client.createWebhook(t,{url:x.url,secret:x.secret||void 0,event_types:x.event_types.length>0?x.event_types:void 0,enabled:x.enabled,http_config:H0(x.http_config)}),s(!1),v(HQ),g(!1),await K()}catch(e){}finally{c(!1)}}},Q=async e=>{if(t){d(e),f(null);try{await $.client.deleteWebhook(t,e),await K()}catch(e){}finally{d(null)}}},J=async()=>{if(t&&w&&N.url){P(!0);try{let e={url:N.url,event_types:N.event_types,enabled:N.enabled,http_config:H0(N.http_config)};T?e.secret=null:N.secret&&(e.secret=N.secret),await $.client.updateWebhook(t,w.id,e),b(!1),await K()}catch{}finally{P(!1)}}},ee=async e=>{if(t){B(e),I(!0),F([]),W(null),H(!0);try{let n=await $.client.listWebhookDeliveries(t,e.id,50);F(n.items||[]),W(n.next_cursor??null)}catch(e){console.error("Error loading deliveries:",e)}finally{H(!1)}}},et=async()=>{if(t&&R&&U){G(!0);try{let e=await $.client.listWebhookDeliveries(t,R.id,50,U);F(t=>[...t,...e.items||[]]),W(e.next_cursor??null)}catch(e){console.error("Error loading more deliveries:",e)}finally{G(!1)}}},ea=t=>t?new Date(t).toLocaleString():e("formatDateNA");return t?(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("h3",{className:"text-lg font-semibold",children:e("title")}),(0,_.jsx)("button",{onClick:()=>K(),className:"p-1 rounded hover:bg-muted transition-colors",title:e("refreshTitle"),"aria-label":e("refreshAriaLabel"),disabled:i,children:(0,_.jsx)(er,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${i?"animate-spin":""}`})})]}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground",children:e("webhookCount",{count:n.length})})]}),(0,_.jsxs)(X.Button,{size:"sm",onClick:()=>s(!0),children:[(0,_.jsx)(Pd.Plus,{className:"w-4 h-4 mr-2"}),e("addWebhook")]})]}),n.length>0?(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{children:e("tableHeaderUrl")}),(0,_.jsx)(eh,{children:e("tableHeaderMethod")}),(0,_.jsx)(eh,{children:e("tableHeaderEventTypes")}),(0,_.jsx)(eh,{children:e("tableHeaderStatus")}),(0,_.jsx)(eh,{children:e("tableHeaderCreatedAt")}),(0,_.jsx)(eh,{className:"w-[120px]"})]})}),(0,_.jsx)(eu,{children:n.map(t=>(0,_.jsxs)(ed,{children:[(0,_.jsx)(ef,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,_.jsx)("span",{title:t.url,children:t.url})}),(0,_.jsx)(ef,{children:(0,_.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:t.http_config?.method||"POST"})}),(0,_.jsx)(ef,{children:(0,_.jsx)("div",{className:"flex flex-wrap gap-1",children:t.event_types.length>0?t.event_types.map(e=>(0,_.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:e},e)):(0,_.jsx)("span",{className:"text-xs text-muted-foreground",children:e("allEvents")})})}),(0,_.jsx)(ef,{children:t.enabled?(0,_.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,_.jsx)(ei,{className:"w-3 h-3"}),e("statusEnabled")]}):(0,_.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:e("statusDisabled")})}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground",children:ea(t.created_at)}),(0,_.jsx)(ef,{children:(0,_.jsxs)("div",{className:"flex items-center gap-1",children:[(0,_.jsxs)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>ee(t),title:e("viewDeliveriesTitle"),children:[(0,_.jsx)(en,{className:"w-3 h-3 mr-1"}),e("deliveriesButton")]}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let e;return j(t),void(k((e=t.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:t.url,secret:"",event_types:t.event_types,enabled:t.enabled,http_config:{method:e.method,timeout_seconds:e.timeout_seconds,headers:Object.entries(e.headers??{}).map(([e,t])=>({key:e,value:t})),params:Object.entries(e.params??{}).map(([e,t])=>({key:e,value:t}))}})),C(!1),O(!1),b(!0))},title:e("editWebhookTitle"),"aria-label":e("editWebhookAriaLabel"),children:(0,_.jsx)(PX,{className:"w-3 h-3"})}),(0,_.jsx)(X.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>f(t),disabled:u===t.id,title:e("deleteWebhookTitle"),"aria-label":e("deleteWebhookAriaLabel"),children:u===t.id?(0,_.jsx)(tn.default,{className:"w-3 h-3 animate-spin"}):(0,_.jsx)(P$,{className:"w-3 h-3"})})]})})]},t.id))})]})}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:e("emptyStateCanManage")}),(0,_.jsx)(ta.Dialog,{open:o,onOpenChange:e=>{e||(v(HQ),g(!1)),s(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("createDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("createDialogDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-2",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formTypeLabel")}),(0,_.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,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"webhook-url",children:[e("formUrlLabel")," ",(0,_.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,_.jsx)(q.Input,{id:"webhook-url",type:"url",placeholder:e("formUrlPlaceholder"),value:x.url,onChange:e=>v(t=>({...t,url:e.target.value}))})]}),(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formMethodLabel")}),(0,_.jsxs)(e6.Select,{value:x.http_config.method,onValueChange:e=>v(t=>({...t,http_config:{...t.http_config,method:e}})),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"POST",children:"POST"}),(0,_.jsx)(e6.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"webhook-timeout",children:e("formTimeoutLabel")}),(0,_.jsx)(q.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:x.http_config.timeout_seconds,onChange:e=>v(t=>({...t,http_config:{...t.http_config,timeout_seconds:parseInt(e.target.value)||30}}))})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"webhook-secret",children:[e("formSecretLabel")," ",(0,_.jsx)("span",{className:"text-muted-foreground text-xs",children:e("formSecretOptional")})]}),(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)(q.Input,{id:"webhook-secret",type:p?"text":"password",placeholder:e("formSecretPlaceholderOptional"),value:x.secret,onChange:e=>v(t=>({...t,secret:e.target.value})),className:"pr-10"}),(0,_.jsx)("button",{type:"button",onClick:()=>g(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":p?e("formHideSecret"):e("formShowSecret"),children:p?(0,_.jsx)(HK,{className:"w-4 h-4"}):(0,_.jsx)(en,{className:"w-4 h-4"})})]})]}),(0,_.jsx)(H1,{label:e("formCustomHeaders"),pairs:x.http_config.headers,onChange:e=>v(t=>({...t,http_config:{...t.http_config,headers:e}}))}),(0,_.jsx)(H1,{label:e("formQueryParams"),pairs:x.http_config.params,onChange:e=>v(t=>({...t,http_config:{...t.http_config,params:e}}))}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)(eb,{children:e("formEventTypes")}),(0,_.jsx)("div",{className:"space-y-2",children:HZ.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Pm.Checkbox,{id:`event-${e}`,checked:x.event_types.includes(e),onCheckedChange:()=>{v(t=>({...t,event_types:t.event_types.includes(e)?t.event_types.filter(t=>t!==e):[...t.event_types,e]}))}}),(0,_.jsx)(eb,{htmlFor:`event-${e}`,className:"font-mono text-sm cursor-pointer",children:e})]},e))})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsx)(e4.Switch,{id:"webhook-enabled",checked:x.enabled,onCheckedChange:e=>v(t=>({...t,enabled:e}))}),(0,_.jsx)(eb,{htmlFor:"webhook-enabled",children:e("formEnabled")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>s(!1),disabled:l,children:e("cancel")}),(0,_.jsx)(X.Button,{onClick:Z,disabled:l||!x.url,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("creating")]}):e("createWebhook")})]})]})}),(0,_.jsx)(ta.Dialog,{open:y,onOpenChange:e=>{e||(j(null),k(HQ),C(!1),O(!1)),b(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("editDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("editDialogDescription")})]}),(0,_.jsxs)("div",{className:"space-y-4 py-2",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formTypeLabel")}),(0,_.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,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsxs)(eb,{htmlFor:"edit-webhook-url",children:[e("formUrlLabel")," ",(0,_.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,_.jsx)(q.Input,{id:"edit-webhook-url",type:"url",placeholder:e("formUrlPlaceholder"),value:N.url,onChange:e=>k(t=>({...t,url:e.target.value}))})]}),(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{children:e("formMethodLabel")}),(0,_.jsxs)(e6.Select,{value:N.http_config.method,onValueChange:e=>k(t=>({...t,http_config:{...t.http_config,method:e}})),children:[(0,_.jsx)(e6.SelectTrigger,{children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{children:[(0,_.jsx)(e6.SelectItem,{value:"POST",children:"POST"}),(0,_.jsx)(e6.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"edit-webhook-timeout",children:e("formTimeoutLabel")}),(0,_.jsx)(q.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:N.http_config.timeout_seconds,onChange:e=>k(t=>({...t,http_config:{...t.http_config,timeout_seconds:parseInt(e.target.value)||30}}))})]})]}),(0,_.jsxs)("div",{className:"space-y-1.5",children:[(0,_.jsx)(eb,{htmlFor:"edit-webhook-secret",children:e("formSecretLabel")}),(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)(q.Input,{id:"edit-webhook-secret",type:S?"text":"password",placeholder:e("formSecretPlaceholderEdit"),value:N.secret,disabled:T,onChange:e=>k(t=>({...t,secret:e.target.value})),className:"pr-10"}),(0,_.jsx)("button",{type:"button",onClick:()=>C(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":S?e("formHideSecret"):e("formShowSecret"),children:S?(0,_.jsx)(HK,{className:"w-4 h-4"}):(0,_.jsx)(en,{className:"w-4 h-4"})})]}),(0,_.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,_.jsx)(Pm.Checkbox,{id:"edit-clear-secret",checked:T,onCheckedChange:e=>{O(!!e),e&&k(e=>({...e,secret:""}))}}),(0,_.jsx)(eb,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:e("formClearSecret")})]})]}),(0,_.jsx)(H1,{label:e("formCustomHeaders"),pairs:N.http_config.headers,onChange:e=>k(t=>({...t,http_config:{...t.http_config,headers:e}}))}),(0,_.jsx)(H1,{label:e("formQueryParams"),pairs:N.http_config.params,onChange:e=>k(t=>({...t,http_config:{...t.http_config,params:e}}))}),(0,_.jsxs)("div",{className:"space-y-2",children:[(0,_.jsx)(eb,{children:e("formEventTypes")}),(0,_.jsx)("div",{className:"space-y-2",children:HZ.map(e=>(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)(Pm.Checkbox,{id:`edit-event-${e}`,checked:N.event_types.includes(e),onCheckedChange:()=>k(t=>({...t,event_types:t.event_types.includes(e)?t.event_types.filter(t=>t!==e):[...t.event_types,e]}))}),(0,_.jsx)(eb,{htmlFor:`edit-event-${e}`,className:"font-mono text-sm cursor-pointer",children:e})]},e))})]}),(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsx)(e4.Switch,{id:"edit-webhook-enabled",checked:N.enabled,onCheckedChange:e=>k(t=>({...t,enabled:e}))}),(0,_.jsx)(eb,{htmlFor:"edit-webhook-enabled",children:e("formEnabled")})]})]}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>b(!1),disabled:A,children:e("cancel")}),(0,_.jsx)(X.Button,{onClick:J,disabled:A||!N.url,children:A?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("saving")]}):e("saveChanges")})]})]})}),(0,_.jsx)(ta.Dialog,{open:!!h,onOpenChange:e=>{e||f(null)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-md",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("deleteDialogTitle")}),(0,_.jsx)(ta.DialogDescription,{children:e("deleteDialogDescription")})]}),h&&(0,_.jsx)("div",{className:"py-2",children:(0,_.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:h.url})}),(0,_.jsxs)(ta.DialogFooter,{children:[(0,_.jsx)(X.Button,{variant:"outline",onClick:()=>f(null),children:e("cancel")}),(0,_.jsx)(X.Button,{variant:"destructive",onClick:()=>h&&Q(h.id),disabled:!!u,children:u?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("deleting")]}):e("deleteWebhookConfirm")})]})]})}),(0,_.jsx)(ta.Dialog,{open:L,onOpenChange:e=>{e||(F([]),W(null)),I(e)},children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsxs)(ta.DialogHeader,{children:[(0,_.jsx)(ta.DialogTitle,{children:e("deliveriesDialogTitle")}),R&&(0,_.jsx)(ta.DialogDescription,{className:"font-mono text-xs truncate",children:R.url})]}),V?(0,_.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,_.jsx)(tn.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):z.length>0?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"overflow-x-auto",children:(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-8 pl-3 pr-0"}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderStatus")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderHttp")}),(0,_.jsx)(eh,{className:"text-center",children:e("deliveriesTableHeaderAttempts")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderEvent")}),(0,_.jsx)(eh,{children:e("deliveriesTableHeaderCreatedAt")})]})}),(0,_.jsx)(eu,{children:z.map(e=>(0,_.jsx)(H5,{delivery:e,formatDate:ea},e.id))})]})}),U&&(0,_.jsx)("div",{className:"flex justify-center pt-2",children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:et,disabled:Y,children:[Y&&(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),e("loadMore")]})})]}):(0,_.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:e("noDeliveries")})]})})]}):null}function H4(e){return[{value:"all",label:e("actionAll")},{value:"retain",label:e("actionRetain")},{value:"recall",label:e("actionRecall")},{value:"reflect",label:e("actionReflect")},{value:"create_bank",label:e("actionCreateBank")},{value:"update_bank",label:e("actionUpdateBank")},{value:"delete_bank",label:e("actionDeleteBank")},{value:"clear_memories",label:e("actionClearMemories")},{value:"consolidation",label:e("actionConsolidation")},{value:"batch_retain",label:e("actionBatchRetain")},{value:"create_mental_model",label:e("actionCreateMentalModel")},{value:"refresh_mental_model",label:e("actionRefreshMentalModel")},{value:"delete_mental_model",label:e("actionDeleteMentalModel")},{value:"create_directive",label:e("actionCreateDirective")},{value:"delete_directive",label:e("actionDeleteDirective")},{value:"file_convert_retain",label:e("actionFileConvertRetain")},{value:"webhook_delivery",label:e("actionWebhookDelivery")}]}function H6(e,t){if(!e||!t)return"—";let n=new Date(e).getTime(),r=new Date(t).getTime()-n;return r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${(r/6e4).toFixed(1)}m`}function H7(e){return e?new Date(e).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function H9({transport:e}){let t={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,_.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${t[e]||t.system}`,children:e})}function H8({bankId:e}){let t=(0,M.useTranslations)("auditLogsView"),n=H4(t),r=[{value:"1d",label:t("periodToday")},{value:"7d",label:t("periodLast7Days")},{value:"30d",label:t("periodLast30Days")}],[i,a]=(0,E.useState)("7d"),[o,s]=(0,E.useState)(null),[l,c]=(0,E.useState)([]),[u,d]=(0,E.useState)("day"),[h,f]=(0,E.useState)(!1),p=(0,E.useCallback)(async(t=i,n=o)=>{f(!0);try{let r=await $.client.getAuditLogStats(e,{period:t,action:n||void 0});c(r.buckets||[]),d(r.trunc||"day")}catch(e){console.error("Error loading audit stats:",e)}finally{f(!1)}},[e,i,o]);(0,E.useEffect)(()=>{p()},[e]);let g=l.map(e=>{var t;let n;return{time:(t=e.time,n=new Date(t),"hour"===u?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"short",day:"numeric"})),total:e.total}});return(0,_.jsxs)(tm.Card,{children:[(0,_.jsxs)(tm.CardHeader,{className:"pb-2 flex flex-row items-center justify-between space-y-0 gap-3",children:[(0,_.jsx)(tm.CardTitle,{className:"text-sm font-semibold",children:t("requestVolume")}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(e6.Select,{value:o||"all",onValueChange:e=>{let t="all"===e?null:e;s(t),p(i,t)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[160px] h-8 text-xs",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:n.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),r.map(e=>(0,_.jsx)(X.Button,{variant:i===e.value?"default":"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{a(e.value),p(e.value,o)},children:e.label},e.value))]})]}),(0,_.jsx)(tm.CardContent,{children:(0,_.jsx)("div",{className:"h-[120px]",children:h?(0,_.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("chartLoading")}):0===g.length?(0,_.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("chartNoData")}):(0,_.jsx)(a3,{width:"100%",height:"100%",children:(0,_.jsxs)(m6,{data:g,margin:{top:5,right:5,bottom:0,left:5},children:[(0,_.jsx)(bM,{dataKey:"time",tick:{fontSize:10},axisLine:!1,tickLine:!1,className:"text-muted-foreground"}),(0,_.jsx)(wc,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:"6px",fontSize:"12px",padding:"4px 8px"}}),(0,_.jsx)(yM,{type:"monotone",dataKey:"total",stroke:"var(--primary)",strokeWidth:2,dot:!1,activeDot:{r:3}})]})})})})]})}function Ue(){let e=(0,M.useTranslations)("auditLogsView"),t=H4(e),n=[{value:"all",label:e("transportAll")},{value:"http",label:e("transportHttp")},{value:"mcp",label:e("transportMcp")},{value:"system",label:e("transportSystem")}],{currentBank:r}=(0,D.useBank)(),[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(0),[l,c]=(0,E.useState)(null),[u,d]=(0,E.useState)(null),[h,f]=(0,E.useState)("all"),[p]=(0,E.useState)(20),[g,x]=(0,E.useState)(0),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(null),[j,N]=(0,E.useState)(!1),k=(0,E.useCallback)(e=>{if("all"===e)return{};let t=new Date,n=new Date;return"1h"===e?n.setHours(t.getHours()-1):"1d"===e?n.setDate(t.getDate()-1):"7d"===e?n.setDate(t.getDate()-7):"30d"===e&&n.setDate(t.getDate()-30),{start_date:n.toISOString()}},[]),S=(0,E.useCallback)(async(e=l,t=u,n=h,i=g)=>{if(r){y(!0);try{let o=k(n),l=await $.client.listAuditLogs(r,{action:e||void 0,transport:t||void 0,start_date:o.start_date,end_date:o.end_date,limit:p,offset:i});a(l.items||[]),s(l.total||0)}catch(e){console.error("Error loading audit logs:",e)}finally{y(!1)}}},[r,l,u,h,g,p,k]),C=e=>{x(e),S(l,u,h,e)};(0,E.useEffect)(()=>{r&&S(l,u,h,g)},[r]);let T=Math.ceil(o/p),O=Math.floor(g/p)+1;return r?(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(H8,{bankId:r}),(0,_.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,_.jsxs)(e6.Select,{value:l||"all",onValueChange:e=>{let t="all"===e?null:e;c(t),x(0),S(t,u,h,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[180px]",children:(0,_.jsx)(e6.SelectValue,{placeholder:e("actionAll")})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:t.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),(0,_.jsxs)(e6.Select,{value:u||"all",onValueChange:e=>{let t="all"===e?null:e;d(t),x(0),S(l,t,h,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[160px]",children:(0,_.jsx)(e6.SelectValue,{placeholder:e("transportAll")})}),(0,_.jsx)(e6.SelectContent,{position:"popper",className:"max-h-[300px] overflow-y-auto",children:n.map(e=>(0,_.jsx)(e6.SelectItem,{value:e.value,children:e.label},e.value))})]}),(0,_.jsxs)(e6.Select,{value:h,onValueChange:e=>{f(e),x(0),S(l,u,e,0)},children:[(0,_.jsx)(e6.SelectTrigger,{className:"w-[150px]",children:(0,_.jsx)(e6.SelectValue,{})}),(0,_.jsxs)(e6.SelectContent,{position:"popper",children:[(0,_.jsx)(e6.SelectItem,{value:"all",children:e("dateRangeAll")}),(0,_.jsx)(e6.SelectItem,{value:"1h",children:e("dateRangeLastHour")}),(0,_.jsx)(e6.SelectItem,{value:"1d",children:e("dateRangeLast24Hours")}),(0,_.jsx)(e6.SelectItem,{value:"7d",children:e("dateRangeLast7Days")}),(0,_.jsx)(e6.SelectItem,{value:"30d",children:e("dateRangeLast30Days")})]})]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>S(l,u,h,g),disabled:v,children:[(0,_.jsx)(er,{className:`w-4 h-4 mr-1 ${v?"animate-spin":""}`}),e("refresh")]}),(0,_.jsx)("span",{className:"text-sm text-muted-foreground ml-auto",children:e("entryCount",{count:o})})]}),(0,_.jsxs)(el,{children:[(0,_.jsx)(ec,{children:(0,_.jsxs)(ed,{children:[(0,_.jsx)(eh,{className:"w-[200px]",children:e("tableHeaderTime")}),(0,_.jsx)(eh,{children:e("tableHeaderAction")}),(0,_.jsx)(eh,{className:"w-[100px]",children:e("tableHeaderTransport")}),(0,_.jsx)(eh,{className:"w-[100px]",children:e("tableHeaderDuration")})]})}),(0,_.jsx)(eu,{children:0===i.length?(0,_.jsx)(ed,{children:(0,_.jsx)(ef,{colSpan:4,className:"text-center text-muted-foreground py-8",children:e(v?"tableLoading":"tableNoLogs")})}):i.map(e=>(0,_.jsxs)(ed,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>{w(e),N(!0)},children:[(0,_.jsx)(ef,{className:"text-sm font-mono",children:H7(e.started_at)}),(0,_.jsx)(ef,{className:"font-medium",children:e.action}),(0,_.jsx)(ef,{children:(0,_.jsx)(H9,{transport:e.transport})}),(0,_.jsx)(ef,{className:"text-sm text-muted-foreground font-mono",children:H6(e.started_at,e.ended_at)})]},e.id))})]}),T>1&&(0,_.jsxs)("div",{className:"flex items-center justify-between",children:[(0,_.jsx)("span",{className:"text-sm text-muted-foreground",children:e("paginationPage",{current:O,total:T})}),(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>C(Math.max(0,g-p)),disabled:0===g,children:[(0,_.jsx)(V,{className:"w-4 h-4 mr-1"}),e("previous")]}),(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",onClick:()=>C(g+p),disabled:g+p>=o,children:[e("next"),(0,_.jsx)(H.ChevronRight,{className:"w-4 h-4 ml-1"})]})]})]}),(0,_.jsx)(ta.Dialog,{open:j,onOpenChange:N,children:(0,_.jsxs)(ta.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,_.jsx)(ta.DialogHeader,{children:(0,_.jsx)(ta.DialogTitle,{children:e("detailDialogTitle",{action:b?.action??""})})}),b&&(0,_.jsxs)("div",{className:"space-y-4",children:[(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailAction")})," ",(0,_.jsx)("span",{className:"font-medium",children:b.action})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailTransport")})," ",(0,_.jsx)(H9,{transport:b.transport})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailStarted")})," ",(0,_.jsx)("span",{className:"font-mono",children:H7(b.started_at)})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:e("detailDuration")})," ",(0,_.jsx)("span",{className:"font-mono",children:H6(b.started_at,b.ended_at)})]})]}),b.request&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailRequest")}),(0,_.jsx)(tg,{value:b.request,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),b.response&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailResponse")}),(0,_.jsx)(tg,{value:b.response,className:"bg-muted max-h-[300px] overflow-y-auto"})]}),b.metadata&&Object.keys(b.metadata).length>0&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h4",{className:"text-sm font-semibold mb-2",children:e("detailMetadata")}),(0,_.jsx)(tg,{value:b.metadata})]})]})]})})]}):null}let Ut=(0,I.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 Un({title:e,description:t,icon:n=Ut}){return(0,_.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,_.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,_.jsx)(n,{width:48,height:48,strokeWidth:1.5})}),(0,_.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:e}),(0,_.jsx)("p",{className:"text-sm text-muted-foreground max-w-md",children:t})]})}var tn=tn;e.s(["default",0,function(){(0,T.useParams)();let e=(0,T.useRouter)(),t=(0,T.useSearchParams)(),n=(0,M.useTranslations)("bank"),r=(0,M.useTranslations)("common"),{features:i}=(0,Pp.useFeatures)(),{currentBank:a,setCurrentBank:o,loadBanks:s}=(0,D.useBank)(),l=t.get("view")||"profile",c=t.get("subTab")||"world",u=t.get("bankConfigTab")||"general",d=i?.observations??!1,h=i?.bank_config_api??!1,f=i?.audit_log??!1,p=i?.llm_trace??!1,[g,x]=(0,E.useState)(!1),[v,y]=(0,E.useState)(!1),[b,w]=(0,E.useState)(!1),[j,N]=(0,E.useState)(!1),[k,S]=(0,E.useState)(!1),[C,L]=(0,E.useState)(!1),[I,R]=(0,E.useState)(!1),[B,z]=(0,E.useState)(!1),F=t=>{a&&e.push((0,P.bankRoute)(a,`?view=data&subTab=${t}`))},V=t=>{a&&e.push((0,P.bankRoute)(a,`?view=profile&bankConfigTab=${t}`))},H=async()=>{if(a){y(!0);try{await $.client.deleteBank(a),x(!1),o(null),await s(),e.push("/")}catch(e){}finally{y(!1)}}},U=async()=>{if(a){N(!0);try{let e=await $.client.clearObservations(a);w(!1),O.toast.success(n("observationsCleared"),{description:e.message||n("observationsClearedDefault")})}catch(e){}finally{N(!1)}}},W=async()=>{if(a){z(!0);try{await $.client.resetBankConfig(a),R(!1)}catch{}finally{z(!1)}}},Y=async()=>{if(a){S(!0);try{await $.client.triggerConsolidation(a)}catch(e){}finally{S(!1)}}},q=async()=>{if(a){L(!0);try{let e=await $.client.recoverConsolidation(a);O.toast.success(n("recoveredMemories",{count:e.retried_count}))}catch(e){}finally{L(!1)}}};return(0,_.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,_.jsx)(A.BankSelector,{}),(0,_.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,_.jsx)(G,{currentTab:l,onTabChange:t=>{a&&e.push((0,P.bankRoute)(a,`?view=${t}`))}}),(0,_.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,_.jsxs)("div",{className:"p-6",children:["profile"===l&&(0,_.jsxs)("div",{children:[(0,_.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("bankConfiguration")}),(0,_.jsx)("p",{className:"text-muted-foreground",children:n("bankConfigurationDescription")})]}),(0,_.jsxs)(Pg.DropdownMenu,{children:[(0,_.jsx)(Pg.DropdownMenuTrigger,{asChild:!0,children:(0,_.jsxs)(X.Button,{variant:"outline",size:"sm",children:[n("actions"),(0,_.jsx)(Pq,{className:"w-4 h-4 ml-2"})]})}),(0,_.jsxs)(Pg.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:async()=>{if(a)try{let e=await $.client.exportBankTemplate(a),t=JSON.stringify(e,null,2);await navigator.clipboard.writeText(t),O.toast.success(n("templateCopied"))}catch{O.toast.error(n("failedToExportTemplate"))}},children:[(0,_.jsx)(PZ,{className:"w-4 h-4 mr-2"}),n("exportTemplate")]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:Y,disabled:k||!d,title:d?void 0:"Observations feature is not enabled",children:[k?(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,_.jsx)(Ll,{className:"w-4 h-4 mr-2"}),k?n("consolidating"):n("runConsolidation"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:q,disabled:C||!d,title:d?void 0:"Observations feature is not enabled",children:[C?(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,_.jsx)(HB,{className:"w-4 h-4 mr-2"}),C?n("recovering"):n("recoverConsolidation"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>w(!0),disabled:!d,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:d?void 0:"Observations feature is not enabled",children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("clearObservations"),!d&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>R(!0),disabled:!h,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:h?void 0:"Bank Config API is disabled",children:[(0,_.jsx)(HB,{className:"w-4 h-4 mr-2"}),n("resetConfiguration"),!h&&(0,_.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,_.jsx)(Pg.DropdownMenuSeparator,{}),(0,_.jsxs)(Pg.DropdownMenuItem,{onClick:()=>x(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("deleteBank")]})]})]})]}),(0,_.jsx)("div",{className:"mb-6 border-b border-border",children:(0,_.jsxs)("div",{className:"flex gap-1",children:[(0,_.jsxs)("button",{onClick:()=>V("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("general"),"general"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),h&&(0,_.jsxs)("button",{onClick:()=>V("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("configuration"),"configuration"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("webhooks"),"webhooks"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("audit-logs"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"audit-logs"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("auditLogs"),!f&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"audit-logs"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>V("llm-requests"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"llm-requests"===u?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("llmRequests"),!p&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"llm-requests"===u&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,_.jsxs)("div",{children:["general"===u&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("overviewAndOperations")}),(0,_.jsxs)("div",{className:"space-y-6",children:[(0,_.jsx)(HR,{}),(0,_.jsx)(HU,{}),(0,_.jsx)(Vw,{hideReflectFields:!0})]})]}),"configuration"===u&&h&&(0,_.jsx)("div",{className:"space-y-6",children:(0,_.jsx)(Vz,{})}),"webhooks"===u&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("webhooksDescription")}),(0,_.jsx)(H3,{})]}),"audit-logs"===u&&(f?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("auditLogsDescription")}),(0,_.jsx)(Ue,{})]}):(0,_.jsx)(Un,{title:n("auditLogsNotEnabled"),description:n.rich("auditLogsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_AUDIT_LOG_ENABLED=true"})})})),"llm-requests"===u&&(p?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("llmRequestsDescription")}),(0,_.jsx)(wR,{})]}):(0,_.jsx)(Un,{title:n("llmRequestsNotEnabled"),description:n.rich("llmRequestsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_LLM_TRACE_ENABLED=true"})})}))]})]}),"recall"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("recallAnalyzer")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("recallAnalyzerDescription")}),(0,_.jsx)(Vg,{})]}),"reflect"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("reflect")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("reflectDescription")}),(0,_.jsx)(Vp,{})]}),"data"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("memories")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("memoriesDescription")}),(0,_.jsx)("div",{className:"mb-6 border-b border-border",children:(0,_.jsxs)("div",{className:"flex gap-1",children:[(0,_.jsxs)("button",{onClick:()=>F("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("worldFacts"),"world"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("experience"),"experience"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("observations"),!d&&(0,_.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,_.jsxs)("button",{onClick:()=>F("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===c?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:[n("mentalModels"),"mental-models"===c&&(0,_.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,_.jsxs)("div",{children:["world"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("worldFactsDescription")}),(0,_.jsx)(Ph,{factType:"world"},"world")]}),"experience"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("experienceDescription")}),(0,_.jsx)(Ph,{factType:"experience"},"experience")]}),"observations"===c&&(d?(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("observationsDescription")}),(0,_.jsx)(Ph,{factType:"observation"},"observations")]}):(0,_.jsx)(Un,{title:n("observationsNotEnabled"),description:n.rich("observationsDisabledMessage",{envVar:()=>(0,_.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})})})),"mental-models"===c&&(0,_.jsxs)("div",{children:[(0,_.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:n("mentalModelsDescription")}),(0,_.jsx)(HY,{},"mental-models")]})]})]}),"documents"===l&&(0,_.jsx)("div",{children:(0,_.jsx)(Le,{})}),"entities"===l&&(0,_.jsxs)("div",{children:[(0,_.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:n("entities")}),(0,_.jsx)("p",{className:"text-muted-foreground mb-6",children:n("entitiesDescription")}),(0,_.jsx)(Lt,{})]})]})})]}),(0,_.jsx)(PN,{open:g,onOpenChange:x,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("deleteMemoryBank")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("deleteBankPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:n("deleteBankWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:v,children:r("cancel")}),(0,_.jsx)(PY,{onClick:H,disabled:v,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:v?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("deleting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("deleteBank")]})})]})]})}),(0,_.jsx)(PN,{open:I,onOpenChange:R,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("resetConfigTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("resetConfigPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:n("resetConfigWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:B,children:r("cancel")}),(0,_.jsx)(PY,{onClick:W,disabled:B,children:B?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("resetting")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(HB,{className:"w-4 h-4 mr-2"}),n("resetConfiguration")]})})]})]})}),(0,_.jsx)(PN,{open:b,onOpenChange:w,children:(0,_.jsxs)(PF,{children:[(0,_.jsxs)(PV,{children:[(0,_.jsx)(PU,{children:n("clearObservationsTitle")}),(0,_.jsx)(PW,{asChild:!0,children:(0,_.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,_.jsx)("p",{children:n.rich("clearObservationsPrompt",{bankName:()=>(0,_.jsx)("span",{className:"font-semibold text-foreground",children:a})})}),(0,_.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:n("clearObservationsWarning")})]})})]}),(0,_.jsxs)(PH,{children:[(0,_.jsx)(PG,{disabled:j,children:r("cancel")}),(0,_.jsx)(PY,{onClick:U,disabled:j,className:"bg-amber-500 text-white hover:bg-amber-600",children:j?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(tn.default,{className:"w-4 h-4 mr-2 animate-spin"}),n("clearing")]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P$,{className:"w-4 h-4 mr-2"}),n("clearObservations")]})})]})]})})]})}],8004)}]);
|