@vectorize-io/hindsight-control-plane 0.4.17 → 0.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/standalone/.next/BUILD_ID +1 -1
- package/standalone/.next/app-path-routes-manifest.json +1 -0
- package/standalone/.next/build-manifest.json +2 -2
- package/standalone/.next/prerender-manifest.json +3 -3
- package/standalone/.next/routes-manifest.json +8 -0
- package/standalone/.next/server/app/_global-error.html +2 -2
- 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 +13 -13
- package/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +13 -13
- package/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +8 -8
- package/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/api/banks/[bankId]/config/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/config/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/consolidate/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/consolidate/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route/app-paths-manifest.json +3 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route/build-manifest.json +11 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route/server-reference-manifest.json +4 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route.js +6 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route.js.map +5 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route.js.nft.json +1 -0
- package/standalone/.next/server/app/api/banks/[bankId]/consolidation-recover/route_client-reference-manifest.js +2 -0
- package/standalone/.next/server/app/api/banks/[bankId]/directives/[directiveId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/directives/[directiveId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/directives/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/directives/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/history/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/history/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/refresh/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/refresh/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/mental-models/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/observations/[modelId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/observations/[modelId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/observations/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/observations/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/operations/[operationId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/operations/[operationId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route.js +1 -1
- package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/banks/route.js +1 -1
- package/standalone/.next/server/app/api/banks/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/chunks/[chunkId]/route.js +1 -1
- package/standalone/.next/server/app/api/chunks/[chunkId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/documents/[documentId]/route.js +1 -1
- package/standalone/.next/server/app/api/documents/[documentId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/documents/route.js +1 -1
- package/standalone/.next/server/app/api/documents/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/entities/[entityId]/regenerate/route.js +1 -1
- package/standalone/.next/server/app/api/entities/[entityId]/regenerate/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/entities/[entityId]/route.js +1 -1
- package/standalone/.next/server/app/api/entities/[entityId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/entities/route.js +1 -1
- package/standalone/.next/server/app/api/entities/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/files/retain/route.js +1 -1
- package/standalone/.next/server/app/api/files/retain/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/graph/route.js +1 -1
- package/standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/health/route.js +1 -1
- package/standalone/.next/server/app/api/health/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/list/route.js +1 -1
- package/standalone/.next/server/app/api/list/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/memories/[memoryId]/history/route.js +1 -1
- package/standalone/.next/server/app/api/memories/[memoryId]/history/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/memories/[memoryId]/route.js +1 -1
- package/standalone/.next/server/app/api/memories/[memoryId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/memories/retain/route.js +1 -1
- package/standalone/.next/server/app/api/memories/retain/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/memories/retain_async/route.js +1 -1
- package/standalone/.next/server/app/api/memories/retain_async/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/operations/[agentId]/route.js +1 -1
- package/standalone/.next/server/app/api/operations/[agentId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/profile/[bankId]/route.js +1 -1
- package/standalone/.next/server/app/api/profile/[bankId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/recall/route.js +1 -1
- package/standalone/.next/server/app/api/recall/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/reflect/route.js +1 -1
- package/standalone/.next/server/app/api/reflect/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/stats/[agentId]/route.js +1 -1
- package/standalone/.next/server/app/api/stats/[agentId]/route.js.nft.json +1 -1
- package/standalone/.next/server/app/api/version/route.js +1 -1
- package/standalone/.next/server/app/api/version/route.js.nft.json +1 -1
- package/standalone/.next/server/app/banks/[bankId]/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app/dashboard.html +1 -1
- package/standalone/.next/server/app/dashboard.rsc +7 -7
- package/standalone/.next/server/app/dashboard.segments/_full.segment.rsc +7 -7
- package/standalone/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/dashboard.segments/_index.segment.rsc +6 -6
- package/standalone/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/dashboard.segments/dashboard/__PAGE__.segment.rsc +2 -2
- package/standalone/.next/server/app/dashboard.segments/dashboard.segment.rsc +1 -1
- package/standalone/.next/server/app/index.html +1 -1
- package/standalone/.next/server/app/index.rsc +6 -6
- package/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/standalone/.next/server/app/index.segments/_full.segment.rsc +6 -6
- package/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/standalone/.next/server/app/index.segments/_index.segment.rsc +6 -6
- package/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/standalone/.next/server/app-paths-manifest.json +1 -0
- package/standalone/.next/server/chunks/[root-of-the-server]__00f576e1._.js +3 -0
- package/standalone/.next/server/chunks/[root-of-the-server]__2382d378._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__292b0698._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__452b2327._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__51ee396a._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__55ac8836._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__631bd6ec._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__6680ef3a._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__6927a12a._.js +1 -1
- package/standalone/.next/server/chunks/{[root-of-the-server]__f91a8834._.js → [root-of-the-server]__70002a37._.js} +6 -6
- package/standalone/.next/server/chunks/[root-of-the-server]__703c53ad._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__753186a7._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__817863c1._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__8f909cd1._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__a53f0ad4._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__a6b65147._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__a8fdd1d4._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__cb9928bd._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__d04f3011._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__d4f61da7._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__dab310ad._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__edeec8c1._.js +1 -1
- package/standalone/.next/server/chunks/[root-of-the-server]__f93edf8b._.js +1 -1
- package/standalone/.next/server/chunks/a6ea4_server_app_api_banks_[bankId]_consolidation-recover_route_actions_a6207e64.js +3 -0
- package/standalone/.next/server/chunks/ssr/[root-of-the-server]__d9fd2a9b._.js +1 -1
- package/standalone/.next/server/chunks/ssr/_29833292._.js +1 -1
- package/standalone/.next/server/chunks/ssr/_3b0b29a6._.js +1 -1
- package/standalone/.next/server/pages/404.html +1 -1
- package/standalone/.next/server/pages/500.html +2 -2
- 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/{07990944179445fa.js → c0fbf65a88b3da4e.js} +3 -3
- package/standalone/.next/static/chunks/c74a7e9c0b009083.css +2 -0
- package/standalone/.next/static/chunks/{8bdae5fbee506af4.js → d1ba061af94ae5b9.js} +1 -1
- package/standalone/.next/static/chunks/{4b55bedec7b62fa2.js → ec879bb3721bee10.js} +4 -4
- package/standalone/package.json +1 -1
- package/standalone/.next/static/chunks/823ce62ea6cdec3c.css +0 -2
- /package/standalone/.next/static/{a2mBPNyqrIdH0XcenXxph → R6vjDnKl5rOWlU3TdV0Y0}/_buildManifest.js +0 -0
- /package/standalone/.next/static/{a2mBPNyqrIdH0XcenXxph → R6vjDnKl5rOWlU3TdV0Y0}/_clientMiddlewareManifest.json +0 -0
- /package/standalone/.next/static/{a2mBPNyqrIdH0XcenXxph → R6vjDnKl5rOWlU3TdV0Y0}/_ssgManifest.js +0 -0
|
@@ -5,6 +5,6 @@ You can add a description to the \`${mv}\` by passing a \`${mC}\` component as a
|
|
|
5
5
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${mv}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
6
6
|
|
|
7
7
|
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return D.useEffect(()=>{document.getElementById(a.current?.getAttribute("aria-describedby"))||console.warn(b)},[b,a]),null};let mI=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mu,{className:(0,S.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...b,ref:c}));mI.displayName=mu.displayName;let mJ=D.forwardRef(({className:a,...b},c)=>(0,C.jsxs)(mt,{children:[(0,C.jsx)(mI,{}),(0,C.jsx)(mz,{ref:c,className:(0,S.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...b})]}));mJ.displayName=mz.displayName;let mK=({className:a,...b})=>(0,C.jsx)("div",{className:(0,S.cn)("flex flex-col space-y-2 text-center sm:text-left",a),...b});mK.displayName="AlertDialogHeader";let mL=({className:a,...b})=>(0,C.jsx)("div",{className:(0,S.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...b});mL.displayName="AlertDialogFooter";let mM=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mB,{ref:c,className:(0,S.cn)("text-lg font-semibold",a),...b}));mM.displayName=mB.displayName;let mN=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mD,{ref:c,className:(0,S.cn)("text-sm text-muted-foreground",a),...b}));mN.displayName=mD.displayName;let mO=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mE,{ref:c,className:(0,S.cn)((0,W.buttonVariants)(),a),...b}));mO.displayName=mE.displayName;let mP=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mG,{ref:c,className:(0,S.cn)((0,W.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",a),...b}));mP.displayName=mG.displayName;let mQ=(0,K.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),mR=(0,K.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"}]]);function mS(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)(""),[h,i]=(0,D.useState)(0),[j,k]=(0,D.useState)(1),l=Math.ceil(h/50),n=(j-1)*50,[o,p]=(0,D.useState)(null),[q,r]=(0,D.useState)(!1),[s,t]=(0,D.useState)(null),[u,v]=(0,D.useState)(!1),[w,x]=(0,D.useState)(""),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(null),[E,F]=(0,D.useState)(null),G=async(b=1)=>{if(a){e(!0);try{let d=await V.client.listDocuments({bank_id:a,q:f,limit:50,offset:(b-1)*50});c(d.items||[]),i(d.total||0)}catch(a){}finally{e(!1)}}},I=a=>{k(a),G(a)},J=async b=>{if(a){r(!0),p({id:b}),v(!1),x("");try{let c=await V.client.getDocument(b,a);p(c)}catch(a){p(null)}finally{r(!1)}}},K=async()=>{if(!a||!A)return;let b=A.id;t(b),B(null);try{let c=await V.client.deleteDocument(b,a);F({success:!0,message:`Deleted document and ${c.memory_units_deleted} memory units.`}),o?.id===b&&p(null),G(j)}catch(a){console.error("Error deleting document:",a),F({success:!1,message:"Error deleting document: "+a.message})}finally{t(null)}},L=()=>{v(!1),x("")},M=async()=>{if(!a||!o)return;let b=w.split(",").map(a=>a.trim()).filter(a=>a.length>0);z(!0);try{await V.client.updateDocument(o.id,a,b),p({...o,tags:b}),c(a=>a.map(a=>a.id===o.id?{...a,tags:b}:a)),v(!1),x("")}catch(a){console.error("Error updating document tags:",a)}finally{z(!1)}};return(0,D.useEffect)(()=>{a&&(k(1),G(1))},[a]),(0,D.useEffect)(()=>{if(!a)return;let b=setTimeout(()=>{k(1),G(1)},300);return()=>clearTimeout(b)},[f]),(0,C.jsxs)("div",{children:[d?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsxs)("div",{className:"text-center",children:[(0,C.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading documents..."})]})}):b.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[h," ",1===h?"document":"documents"]}),(0,C.jsxs)("div",{className:"w-full",children:[(0,C.jsx)("div",{className:"px-5 mb-4",children:(0,C.jsx)(X.Input,{type:"text",value:f,onChange:a=>g(a.target.value),placeholder:"Search documents (ID)...",className:"max-w-2xl"})}),(0,C.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{children:"Document ID"}),(0,C.jsx)(am,{children:"Created"}),(0,C.jsx)(am,{children:"Tags"}),(0,C.jsx)(am,{children:"Context"}),(0,C.jsx)(am,{children:"Text Length"}),(0,C.jsx)(am,{children:"Memory Units"})]})}),(0,C.jsx)(ak,{children:b.length>0?b.map(a=>(0,C.jsxs)(al,{className:`cursor-pointer hover:bg-muted/50 ${o?.id===a.id?"bg-primary/10":""}`,onClick:()=>J(a.id),children:[(0,C.jsx)(an,{title:a.id,className:"text-card-foreground",children:a.id.length>30?a.id.substring(0,30)+"...":a.id}),(0,C.jsx)(an,{className:"text-card-foreground",children:a.created_at?new Date(a.created_at).toLocaleString():"N/A"}),(0,C.jsx)(an,{className:"text-card-foreground",children:a.tags&&a.tags.length>0?(0,C.jsxs)("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map((a,b)=>(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:a},b)),a.tags.length>3&&(0,C.jsxs)("span",{className:"text-xs px-2 py-0.5 text-muted-foreground",children:["+",a.tags.length-3]})]}):"-"}),(0,C.jsx)(an,{className:"text-card-foreground",children:a.retain_params?.context||"-"}),(0,C.jsxs)(an,{className:"text-card-foreground",children:[a.text_length?.toLocaleString()," chars"]}),(0,C.jsx)(an,{className:"text-card-foreground",children:a.memory_unit_count})]},a.id)):(0,C.jsx)(al,{children:(0,C.jsx)(an,{colSpan:6,className:"text-center",children:'Click "Load Documents" to view data'})})})]})}),l>1&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t px-5",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:[n+1,"-",Math.min(n+50,h)," of ",h]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>I(1),disabled:1===j||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(_,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>I(j-1),disabled:1===j||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(P,{className:"h-3 w-3"})}),(0,C.jsxs)("span",{className:"text-xs px-2",children:[j," / ",l]}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>I(j+1),disabled:j===l||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>I(l),disabled:j===l||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(aa,{className:"h-3 w-3"})})]})]})]})]}):(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsxs)("div",{className:"text-center",children:[(0,C.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"No documents found"})]})}),b.length>0&&o&&(0,C.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,C.jsxs)("div",{className:"p-5",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:"Document Details"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Original document text and metadata"})]}),(0,C.jsxs)(W.Button,{variant:"secondary",size:"sm",onClick:()=>p(null),className:"h-9 px-3 gap-2",children:[(0,C.jsx)(ah.X,{className:"h-4 w-4"}),"Close"]})]}),q?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsxs)("div",{className:"text-center",children:[(0,C.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading document..."})]})}):(0,C.jsxs)("div",{className:"space-y-5",children:[(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Document ID"}),(0,C.jsx)("div",{className:"text-sm font-mono break-all text-card-foreground",children:o.id})]}),o.created_at&&(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,C.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:new Date(o.created_at).toLocaleString()})]}),(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Memory Units"}),(0,C.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:o.memory_unit_count})]})]}),o.original_text&&(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text Length"}),(0,C.jsxs)("div",{className:"text-sm font-medium text-card-foreground",children:[o.original_text.length.toLocaleString()," characters"]})]}),o.retain_params&&(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Retain Parameters"}),(0,C.jsxs)("div",{className:"text-sm space-y-2 text-card-foreground",children:[o.retain_params.context&&(0,C.jsxs)("div",{children:[(0,C.jsx)("span",{className:"font-semibold",children:"Context:"})," ",o.retain_params.context]}),o.retain_params.event_date&&(0,C.jsxs)("div",{children:[(0,C.jsx)("span",{className:"font-semibold",children:"Event Date:"})," ",new Date(o.retain_params.event_date).toLocaleString()]}),o.retain_params.metadata&&(0,C.jsxs)("div",{className:"mt-2",children:[(0,C.jsx)("span",{className:"font-semibold",children:"Metadata:"}),(0,C.jsx)("pre",{className:"mt-1 text-xs bg-background p-2 rounded text-card-foreground",children:JSON.stringify(o.retain_params.metadata,null,2)})]})]})]}),(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase",children:"Tags"}),!u&&(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{x((o?.tags??[]).join(", ")),v(!0)},className:"h-6 px-2 gap-1 text-xs",children:[(0,C.jsx)(mR,{className:"h-3 w-3"}),"Edit"]})]}),u?(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)(X.Input,{value:w,onChange:a=>x(a.target.value),placeholder:"tag1, tag2, tag3",className:"text-sm h-8",onKeyDown:a=>{"Enter"===a.key&&M(),"Escape"===a.key&&L()},autoFocus:!0}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Comma-separated. Leave empty to remove all tags."}),(0,C.jsxs)("div",{className:"flex gap-2",children:[(0,C.jsxs)(W.Button,{size:"sm",onClick:M,disabled:y,className:"h-7 px-3 gap-1 text-xs",children:[y?(0,C.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,C.jsx)(bh.Check,{className:"h-3 w-3"}),"Save"]}),(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:L,disabled:y,className:"h-7 px-3 gap-1 text-xs",children:[(0,C.jsx)(ah.X,{className:"h-3 w-3"}),"Cancel"]})]})]}):o.tags&&o.tags.length>0?(0,C.jsx)("div",{className:"flex flex-wrap gap-2",children:o.tags.map((a,b)=>(0,C.jsx)("span",{className:"text-sm px-3 py-1.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",children:a},b))}):(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"No tags"})]}),(0,C.jsx)("div",{className:"pt-2 border-t border-border",children:(0,C.jsxs)(W.Button,{variant:"destructive",size:"sm",onClick:()=>{B({id:o.id,memoryCount:o.memory_unit_count})},className:"w-full gap-2",disabled:s===o.id,children:[s===o.id?(0,C.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,C.jsx)(mQ,{className:"h-4 w-4"}),"Delete Document"]})}),o.original_text&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Original Text"}),(0,C.jsx)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border max-h-[400px] overflow-y-auto",children:(0,C.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono leading-relaxed text-card-foreground",children:o.original_text})})]})]})]})}),(0,C.jsx)(ms,{open:!!A,onOpenChange:a=>!a&&B(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Document"}),(0,C.jsxs)(mN,{children:["Are you sure you want to delete document"," ",(0,C.jsxs)("span",{className:"font-mono font-semibold",children:['"',A?.id,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),"This will also delete"," ",A?.memoryCount!==void 0?(0,C.jsxs)("span",{className:"font-semibold",children:[A.memoryCount," memory units"]}):"all memory units"," ","extracted from this document.",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),(0,C.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{children:"Cancel"}),(0,C.jsx)(mO,{onClick:K,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),(0,C.jsx)(ms,{open:!!E,onOpenChange:a=>!a&&F(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:E?.success?"Document Deleted":"Error"}),(0,C.jsx)(mN,{children:E?.message})]}),(0,C.jsx)(mL,{children:(0,C.jsx)(mO,{onClick:()=>F(null),children:"OK"})})]})})]})}function mT(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)(null),[h,i]=(0,D.useState)(!1),[j,k]=(0,D.useState)(1),[l,n]=(0,D.useState)(0),o=Math.ceil(l/50),p=(j-1)*50,q=async(b=1)=>{if(a){e(!0);try{let d=await V.client.listEntities({bank_id:a,limit:50,offset:(b-1)*50});c(d.items||[]),n(d.total||0)}catch(a){}finally{e(!1)}}},r=async b=>{if(a){i(!0);try{let c=await V.client.getEntity(b,a);g(c)}catch(a){}finally{i(!1)}}},s=a=>{k(a),q(a)};(0,D.useEffect)(()=>{a&&(k(1),q(1),g(null))},[a]);let t=a=>a?new Date(a).toLocaleDateString():"N/A";return(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{children:d?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsxs)("div",{className:"text-center",children:[(0,C.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading entities..."})]})}):b.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[l," ",1===l?"entity":"entities"]}),(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{children:"Name"}),(0,C.jsx)(am,{children:"Mentions"}),(0,C.jsx)(am,{children:"First Seen"}),(0,C.jsx)(am,{children:"Last Seen"})]})}),(0,C.jsx)(ak,{children:b.map(a=>(0,C.jsxs)(al,{onClick:()=>r(a.id),className:`cursor-pointer hover:bg-muted/50 ${f?.id===a.id?"bg-primary/10":""}`,children:[(0,C.jsx)(an,{className:"font-medium text-card-foreground",children:a.canonical_name}),(0,C.jsx)(an,{className:"text-card-foreground",children:a.mention_count}),(0,C.jsx)(an,{className:"text-card-foreground",children:t(a.first_seen)}),(0,C.jsx)(an,{className:"text-card-foreground",children:t(a.last_seen)})]},a.id))})]})}),o>1&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:[p+1,"-",Math.min(p+50,l)," of ",l]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>s(1),disabled:1===j||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(_,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>s(j-1),disabled:1===j||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(P,{className:"h-3 w-3"})}),(0,C.jsxs)("span",{className:"text-xs px-2",children:[j," / ",o]}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>s(j+1),disabled:j===o||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>s(o),disabled:j===o||d,className:"h-7 w-7 p-0",children:(0,C.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsxs)("div",{className:"text-center",children:[(0,C.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:"No entities found"}),(0,C.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Entities are extracted from facts when memories are added."})]})})}),f&&(0,C.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,C.jsxs)("div",{className:"p-5",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:f.canonical_name}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Entity details"})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>g(null),className:"h-8 w-8 p-0",children:(0,C.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,C.jsxs)("div",{className:"space-y-5",children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentions"}),(0,C.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:f.mention_count})]}),(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"First Seen"}),(0,C.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:t(f.first_seen)})]})]}),(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Entity ID"}),(0,C.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:f.id})]})]})]})})]})}var mU=a.i(99295),mV=a.i(4212);let mW=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",a),...b}));mW.displayName="Card";let mX=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("flex flex-col space-y-1.5 p-6",a),...b}));mX.displayName="CardHeader";let mY=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-2xl font-semibold leading-none tracking-tight",a),...b}));mY.displayName="CardTitle";let mZ=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm text-muted-foreground",a),...b}));mZ.displayName="CardDescription";let m$=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("p-6 pt-0",a),...b}));m$.displayName="CardContent",D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("flex items-center p-6 pt-0",a),...b})).displayName="CardFooter";var m_=a.i(97063);let m0=(0,K.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),m1=(0,K.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),m2=(0,K.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),m3=(0,K.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var m4=a.i(6219);"function"==typeof SuppressedError&&SuppressedError;var m5=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var b=document.activeElement,c=[],d=0;d<a.rangeCount;d++)c.push(a.getRangeAt(d));switch(b.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":b.blur();break;default:b=null}return a.removeAllRanges(),function(){"Caret"===a.type&&a.removeAllRanges(),a.rangeCount||c.forEach(function(b){a.addRange(b)}),b&&b.focus()}},m6={"text/plain":"Text","text/html":"Url",default:"Text"},m7=function(a,b){var c,d,e,f,g,h,i,j,k=!1;b||(b={}),e=b.debug||!1;try{if(g=m5(),h=document.createRange(),i=document.getSelection(),(j=document.createElement("span")).textContent=a,j.ariaHidden="true",j.style.all="unset",j.style.position="fixed",j.style.top=0,j.style.clip="rect(0, 0, 0, 0)",j.style.whiteSpace="pre",j.style.webkitUserSelect="text",j.style.MozUserSelect="text",j.style.msUserSelect="text",j.style.userSelect="text",j.addEventListener("copy",function(c){if(c.stopPropagation(),b.format)if(c.preventDefault(),void 0===c.clipboardData){e&&console.warn("unable to use e.clipboardData"),e&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var d=m6[b.format]||m6.default;window.clipboardData.setData(d,a)}else c.clipboardData.clearData(),c.clipboardData.setData(b.format,a);b.onCopy&&(c.preventDefault(),b.onCopy(c.clipboardData))}),document.body.appendChild(j),h.selectNodeContents(j),i.addRange(h),!document.execCommand("copy"))throw Error("copy command was unsuccessful");k=!0}catch(g){e&&console.error("unable to copy using execCommand: ",g),e&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(b.format||"text",a),b.onCopy&&b.onCopy(window.clipboardData),k=!0}catch(g){e&&console.error("unable to copy using clipboardData: ",g),e&&console.error("falling back to prompt"),c="message"in b?b.message:"Copy to clipboard: #{key}, Enter",d=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",f=c.replace(/#{\s*key\s*}/g,d),window.prompt(f,a)}}finally{i&&("function"==typeof i.removeRange?i.removeRange(h):i.removeAllRanges()),j&&document.body.removeChild(j),g()}return k};function m8(a){return"[object Object]"===Object.prototype.toString.call(a)}function m9(a){return Array.isArray(a)?a.length:m8(a)?Object.keys(a).length:0}function na(a,b,c,d,e,f){if(f&&void 0!==f.collapsed)return!!f.collapsed;if("boolean"==typeof d)return d;if("number"==typeof d&&b>d)return!0;let g=m9(a);if("function"==typeof d){let e=nd(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||m8(a)&&g>e)}function nb(a,b,c,d,e,f){if(f&&void 0!==f.collapsed)return!!f.collapsed;if("boolean"==typeof d)return d;if("number"==typeof d&&b>d)return!0;let g=Math.ceil(a.length/100);if("function"==typeof d){let e=nd(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||m8(a)&&g>e)}function nc(a,b,c){return"boolean"==typeof a?a:"number"==typeof a&&!!(b>a)||"collapsed"===a&&!!c||"expanded"===a&&!c}function nd(a,b){try{return a(...b)}catch(a){reportError(a)}}function ne(a){if(!0===a||m8(a)&&!0===a.add)return!0}function nf(a){if(!0===a||m8(a)&&!0===a.edit)return!0}function ng(a){if(!0===a||m8(a)&&!0===a.delete)return!0}function nh(a){return!a||void 0===a.add||!!a.add}function ni(a){return!a||void 0===a.edit||!!a.edit}function nj(a){return!a||void 0===a.delete||!!a.delete}function nk(a){return!a||void 0===a.enableClipboard||!!a.enableClipboard}function nl(){return(nl=Object.assign.bind()).apply(this,arguments)}var nm=function(a){return D.createElement("svg",nl({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},a),n||(n=D.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 nn(){return(nn=Object.assign.bind()).apply(this,arguments)}var no=function(a){return D.createElement("svg",nn({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),o||(o=D.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 np(){return(np=Object.assign.bind()).apply(this,arguments)}var nq=function(a){return D.createElement("svg",np({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),p||(p=D.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"})),q||(q=D.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 nr({node:a,nodeMeta:b}){let{customizeCopy:c,CopyComponent:d,CopiedComponent:e}=(0,D.useContext)(nL),[f,g]=(0,D.useState)(!1),h=d=>{d.stopPropagation();let e=c(a,b);"string"==typeof e&&e&&function(a){var b,c,d,e;b=this,c=void 0,d=void 0,e=function*(){try{yield navigator.clipboard.writeText(a)}catch(b){m7(a)}},new(d||(d=Promise))(function(a,f){function g(a){try{i(e.next(a))}catch(a){f(a)}}function h(a){try{i(e.throw(a))}catch(a){f(a)}}function i(b){var c;b.done?a(b.value):((c=b.value)instanceof d?c:new d(function(a){a(c)})).then(g,h)}i((e=e.apply(b,c||[])).next())})}(e),g(!0),setTimeout(()=>g(!1),3e3)};return f?"function"==typeof e?(0,C.jsx)(e,{className:"json-view--copy",style:{display:"inline-block"}}):(0,C.jsx)(nq,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof d?(0,C.jsx)(d,{onClick:h,className:"json-view--copy"}):(0,C.jsx)(no,{onClick:h,className:"json-view--copy"})}function ns({indexOrName:a,value:b,depth:c,deleteHandle:d,editHandle:e,parent:f,parentPath:g}){let{displayArrayIndex:h}=(0,D.useContext)(nL),i=Array.isArray(f);return(0,C.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!i||i&&h?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",Object.assign({className:"number"==typeof a?"json-view--index":"json-view--property"},{children:a})),":"," "]}):(0,C.jsx)(C.Fragment,{}),(0,C.jsx)(nJ,{node:b,depth:c+1,deleteHandle:(a,b)=>d(a,b),editHandle:(a,b,c,d)=>e(a,b,c,d),parent:f,indexOrName:a,parentPath:g})]}))}function nt(){return(nt=Object.assign.bind()).apply(this,arguments)}var nu=function(a){return D.createElement("svg",nt({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),r||(r=D.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"})),s||(s=D.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 nv(){return(nv=Object.assign.bind()).apply(this,arguments)}var nw=function(a){return D.createElement("svg",nv({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),t||(t=D.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"})),u||(u=D.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 nx(){return(nx=Object.assign.bind()).apply(this,arguments)}var ny=function(a){return D.createElement("svg",nx({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),v||(v=D.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=D.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 nz(){return(nz=Object.assign.bind()).apply(this,arguments)}var nA=function(a){return D.createElement("svg",nz({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),x||(x=D.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"})),y||(y=D.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 nB({originNode:a,node:b,depth:c,index:d,deleteHandle:e,customOptions:f,startIndex:g,parent:h,parentPath:i}){let{enableClipboard:j,src:k,onEdit:l,onChange:n,forceUpdate:o,displaySize:p,CustomOperation:q}=(0,D.useContext)(nL),r=[...i,String(d)],[s,t]=(0,D.useState)(!0),u=(0,D.useCallback)((b,d,e)=>{a[b]=d,l&&l({newValue:d,oldValue:e,depth:c,src:k,indexOrName:b,parentType:"array",parentPath:i}),n&&n({type:"edit",depth:c,src:k,indexOrName:b,parentType:"array",parentPath:i}),o()},[b,l,n,o]),v=b=>{a.splice(b,1),e&&e(b,i),o()},w=(0,C.jsxs)(C.Fragment,{children:[!s&&(0,C.jsxs)("span",Object.assign({onClick:()=>t(!0),className:"jv-size-chevron"},{children:[nc(p,c,s)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[m9(b)," Items"]})),(0,C.jsx)(nm,{className:"jv-chevron"})]})),!s&&j&&nk(f)&&(0,C.jsx)(nr,{node:b,nodeMeta:{depth:c,indexOrName:d,parent:h,parentPath:i,currentPath:r}}),"function"==typeof q?(0,C.jsx)(q,{node:b}):null]});return(0,C.jsxs)("div",{children:[(0,C.jsx)("span",{children:"["}),w,s?(0,C.jsxs)("button",Object.assign({onClick:()=>t(!1),className:"jv-button"},{children:[g," ... ",g+b.length-1]})):(0,C.jsx)("div",Object.assign({className:"jv-indent"},{children:b.map((a,e)=>(0,C.jsx)(ns,{indexOrName:e+g,value:a,depth:c,parent:b,deleteHandle:v,editHandle:u,parentPath:i},String(d)+String(e)))})),(0,C.jsx)("span",{children:"]"})]})}function nC({node:a,depth:b,deleteHandle:c,indexOrName:d,customOptions:e,parent:f,parentPath:g}){let h=void 0!==d?[...g,String(d)]:g,i=[];for(let b=0;b<a.length;b+=100)i.push(a.slice(b,b+100));let{collapsed:j,enableClipboard:k,collapseObjectsAfterLength:l,editable:n,onDelete:o,src:p,onAdd:q,CustomOperation:r,onChange:s,forceUpdate:t,displaySize:u}=(0,D.useContext)(nL),[v,w]=(0,D.useState)(nb(a,b,d,j,l,e));(0,D.useEffect)(()=>{w(nb(a,b,d,j,l,e))},[j,l]);let[x,y]=(0,D.useState)(!1),[z,A]=(0,D.useState)(!1),B=()=>{a.push(null),q&&q({indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:g}),s&&s({type:"add",indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:g}),t()},E=x||z,F=(0,C.jsxs)(C.Fragment,{children:[!v&&!E&&(0,C.jsxs)("span",Object.assign({onClick:()=>w(!0),className:"jv-size-chevron"},{children:[nc(u,b,v)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[a.length," Items"]})),(0,C.jsx)(nm,{className:"jv-chevron"})]})),E&&(0,C.jsx)(ny,{className:"json-view--edit",style:{display:"inline-block"},onClick:z?B:()=>{y(!1),c&&c(d,g),o&&o({value:a,depth:b,src:p,indexOrName:d,parentType:"array",parentPath:g}),s&&s({type:"delete",depth:b,src:p,indexOrName:d,parentType:"array",parentPath:g})}}),E&&(0,C.jsx)(nA,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{y(!1),A(!1)}}),!v&&!E&&k&&nk(e)&&(0,C.jsx)(nr,{node:a,nodeMeta:{depth:b,indexOrName:d,parent:f,parentPath:g,currentPath:h}}),!v&&!E&&ne(n)&&nh(e)&&(0,C.jsx)(nw,{className:"json-view--edit",onClick:()=>{B()}}),!v&&!E&&ng(n)&&nj(e)&&c&&(0,C.jsx)(nu,{className:"json-view--edit",onClick:()=>y(!0)}),"function"==typeof r?(0,C.jsx)(r,{node:a}):null]});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{children:"["}),F,v?(0,C.jsx)("button",Object.assign({onClick:()=>w(!1),className:"jv-button"},{children:"..."})):(0,C.jsx)("div",Object.assign({className:"jv-indent"},{children:i.map((f,h)=>(0,C.jsx)(nB,{originNode:a,node:f,depth:b,index:h,startIndex:100*h,deleteHandle:c,customOptions:e,parentPath:g},String(d)+String(h)))})),(0,C.jsx)("span",{children:"]"}),v&&nc(u,b,v)&&(0,C.jsxs)("span",Object.assign({onClick:()=>w(!1),className:"jv-size"},{children:[a.length," Items"]}))]})}function nD({node:a,depth:b,indexOrName:c,deleteHandle:d,customOptions:e,parent:f,parentPath:g}){let{collapsed:h,onCollapse:i,enableClipboard:j,ignoreLargeArray:k,collapseObjectsAfterLength:l,editable:n,onDelete:o,src:p,onAdd:q,onEdit:r,onChange:s,forceUpdate:t,displaySize:u,CustomOperation:v}=(0,D.useContext)(nL),w=void 0!==c?[...g,String(c)]:g;if(!k&&Array.isArray(a)&&a.length>100)return(0,C.jsx)(nC,{node:a,depth:b,indexOrName:c,deleteHandle:d,customOptions:e,parentPath:w});let x=m8(a),[y,z]=(0,D.useState)(na(a,b,c,h,l,e)),A=d=>{null==i||i({isCollapsing:!d,node:a,depth:b,indexOrName:c}),z(d)};(0,D.useEffect)(()=>{A(na(a,b,c,h,l,e))},[h,l]);let B=(0,D.useCallback)((c,d,e)=>{Array.isArray(a)?a[+c]=d:a&&(a[c]=d),r&&r({newValue:d,oldValue:e,depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),s&&s({type:"edit",depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),t()},[a,r,s,t]),E=b=>{Array.isArray(a)?a.splice(+b,1):a&&delete a[b],t()},[F,G]=(0,D.useState)(!1),[H,I]=(0,D.useState)(!1),J=(0,D.useRef)(null),K=()=>{var c;if(x){let d=null==(c=J.current)?void 0:c.value;d&&(a[d]=null,J.current&&(J.current.value=""),I(!1),q&&q({indexOrName:d,depth:b,src:p,parentType:"object",parentPath:w}),s&&s({type:"add",indexOrName:d,depth:b,src:p,parentType:"object",parentPath:w}))}else Array.isArray(a)&&(a.push(null),q&&q({indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:w}),s&&s({type:"add",indexOrName:a.length-1,depth:b,src:p,parentType:"array",parentPath:w}));t()},L=F||H,M=()=>{G(!1),I(!1)},N=(0,C.jsxs)(C.Fragment,{children:[!y&&!L&&(0,C.jsxs)("span",Object.assign({onClick:()=>A(!0),className:"jv-size-chevron"},{children:[nc(u,b,y)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[m9(a)," Items"]})),(0,C.jsx)(nm,{className:"jv-chevron"})]})),H&&x&&(0,C.jsx)("input",{className:"json-view--input",placeholder:"property",ref:J,onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),K()):"Escape"===a.key&&M()}}),L&&(0,C.jsx)(ny,{className:"json-view--edit",style:{display:"inline-block"},onClick:H?K:()=>{G(!1),d&&d(c,w),o&&o({value:a,depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w}),s&&s({type:"delete",depth:b,src:p,indexOrName:c,parentType:x?"object":"array",parentPath:w})}}),L&&(0,C.jsx)(nA,{className:"json-view--edit",style:{display:"inline-block"},onClick:M}),!y&&!L&&j&&nk(e)&&(0,C.jsx)(nr,{node:a,nodeMeta:{depth:b,indexOrName:c,parent:f,parentPath:g,currentPath:w}}),!y&&!L&&ne(n)&&nh(e)&&(0,C.jsx)(nw,{className:"json-view--edit",onClick:()=>{x?(I(!0),setTimeout(()=>{var a;return null==(a=J.current)?void 0:a.focus()})):K()}}),!y&&!L&&ng(n)&&nj(e)&&d&&(0,C.jsx)(nu,{className:"json-view--edit",onClick:()=>G(!0)}),"function"==typeof v?(0,C.jsx)(v,{node:a}):null]});return Array.isArray(a)?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{children:"["}),N,y?(0,C.jsx)("button",Object.assign({onClick:()=>A(!1),className:"jv-button"},{children:"..."})):(0,C.jsx)("div",Object.assign({className:"jv-indent"},{children:a.map((d,e)=>(0,C.jsx)(ns,{indexOrName:e,value:d,depth:b,parent:a,deleteHandle:E,editHandle:B,parentPath:w},String(c)+String(e)))})),(0,C.jsx)("span",{children:"]"}),y&&nc(u,b,y)&&(0,C.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[m9(a)," Items"]}))]}):x?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{children:"{"}),N,y?(0,C.jsx)("button",Object.assign({onClick:()=>A(!1),className:"jv-button"},{children:"..."})):(0,C.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(a).map(([d,e])=>(0,C.jsx)(ns,{indexOrName:d,value:e,depth:b,parent:a,deleteHandle:E,editHandle:B,parentPath:w},String(c)+String(d)))})),(0,C.jsx)("span",{children:"}"}),y&&nc(u,b,y)&&(0,C.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[m9(a)," Items"]}))]}):(0,C.jsx)("span",{children:String(a)})}let nE=D.default.forwardRef(({str:a,className:b,ctrlClick:c},d)=>{let{collapseStringMode:e,collapseStringsAfterLength:f,customizeCollapseStringUI:g}=(0,D.useContext)(nL),[h,i]=(0,D.useState)(!0),j=(0,D.useRef)(null);f=f>0?f:0;let k=a.replace(/\s+/g," "),l="function"==typeof g?g(k,h):"string"==typeof g?g:"...",n=a=>{var b;if((a.ctrlKey||a.metaKey)&&c)c(a);else{let a=window.getSelection();if(a&&a.anchorOffset!==a.focusOffset&&(null==(b=a.anchorNode)?void 0:b.parentElement)===j.current)return;i(!h)}};if(a.length<=f)return(0,C.jsxs)("span",Object.assign({ref:j,className:b,onClick:c},{children:['"',a,'"']}));if("address"===e)return a.length<=10?(0,C.jsxs)("span",Object.assign({ref:j,className:b,onClick:c},{children:['"',a,'"']})):(0,C.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[k.slice(0,6),l,k.slice(-4)]:a,'"']}));if("directly"===e)return(0,C.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[k.slice(0,f),l]:a,'"']}));if("word"===e){let c=f,d=f+1,e=k,g=1;for(;;){if(/\W/.test(a[c])){e=a.slice(0,c);break}if(/\W/.test(a[d])){e=a.slice(0,d);break}if(6===g){e=a.slice(0,f);break}g++,c--,d++}return(0,C.jsxs)("span",Object.assign({ref:j,onClick:n,className:b+" cursor-pointer"},{children:['"',h?[e,l]:a,'"']}))}return(0,C.jsxs)("span",Object.assign({ref:j,className:b},{children:['"',a,'"']}))});function nF(){return(nF=Object.assign.bind()).apply(this,arguments)}var nG=function(a){return D.createElement("svg",nF({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),z||(z=D.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 nH(){return(nH=Object.assign.bind()).apply(this,arguments)}var nI=function(a){return D.createElement("svg",nH({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},a),A||(A=D.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"})),B||(B=D.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 nJ({node:a,depth:b,deleteHandle:c,indexOrName:d,parent:e,editHandle:f,parentPath:g}){let h,{collapseStringsAfterLength:i,enableClipboard:j,editable:k,src:l,onDelete:n,onChange:o,customizeNode:p,matchesURL:q,urlRegExp:r,EditComponent:s,DoneComponent:t,CancelComponent:u,CustomOperation:v}=(0,D.useContext)(nL);if("function"==typeof p&&(h=nd(p,[{node:a,depth:b,indexOrName:d}])),h){if((0,D.isValidElement)(h))return h;else if("function"==typeof h){let c=h;return(0,C.jsx)(c,{node:a,depth:b,indexOrName:d})}}if(Array.isArray(a)||m8(a))return(0,C.jsx)(nD,{parent:e,node:a,depth:b,indexOrName:d,deleteHandle:c,parentPath:g,customOptions:"object"==typeof h?h:void 0});{var w;let p=typeof a,x=void 0!==d?[...g,String(d)]:g,[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),E=(0,D.useRef)(null),F=()=>{z(!0),setTimeout(()=>{var a,b;null==(a=window.getSelection())||a.selectAllChildren(E.current),null==(b=E.current)||b.focus()})},G=(0,D.useCallback)(()=>{let b=E.current.innerText;try{let c=JSON.parse(b);f&&f(d,c,a,g)}catch(e){let c="string"===p?b.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):b;f&&f(d,c,a,g)}z(!1)},[f,d,a,g,p]),H=()=>{z(!1),B(!1)},I=()=>{B(!1),c&&c(d,g),n&&n({value:a,depth:b,src:l,indexOrName:d,parentType:Array.isArray(e)?"array":"object",parentPath:g}),o&&o({depth:b,src:l,indexOrName:d,parentType:Array.isArray(e)?"array":"object",type:"delete",parentPath:g})},J=(0,D.useCallback)(a=>{"Enter"===a.key?(a.preventDefault(),G()):"Escape"===a.key&&H()},[G]),K=y||A,L=!K&&nf(k)&&ni(h)&&f?a=>{(a.ctrlKey||a.metaKey)&&F()}:void 0,M=(0,C.jsxs)(C.Fragment,{children:[K&&("function"==typeof t?(0,C.jsx)(t,{className:"json-view--edit",style:{display:"inline-block"},onClick:A?I:G}):(0,C.jsx)(ny,{className:"json-view--edit",style:{display:"inline-block"},onClick:A?I:G})),K&&("function"==typeof u?(0,C.jsx)(u,{className:"json-view--edit",style:{display:"inline-block"},onClick:H}):(0,C.jsx)(nA,{className:"json-view--edit",style:{display:"inline-block"},onClick:H})),!K&&j&&nk(h)&&(0,C.jsx)(nr,{node:a,nodeMeta:{depth:b,indexOrName:d,parent:e,parentPath:g,currentPath:x}}),!K&&q&&"string"===p&&r.test(a)&&(!(w=h)||void 0===w.matchesURL||!!w.matchesURL)&&(0,C.jsx)("a",Object.assign({href:a,target:"_blank",className:"json-view--link"},{children:(0,C.jsx)(nI,{})})),!K&&nf(k)&&ni(h)&&f&&("function"==typeof s?(0,C.jsx)(s,{className:"json-view--edit",onClick:F}):(0,C.jsx)(nG,{className:"json-view--edit",onClick:F})),!K&&ng(k)&&nj(h)&&c&&(0,C.jsx)(nu,{className:"json-view--edit",onClick:()=>B(!0)}),"function"==typeof v?(0,C.jsx)(v,{node:a}):null]}),N="json-view--string";switch(p){case"number":case"bigint":N="json-view--number";break;case"boolean":N="json-view--boolean";break;case"object":N="json-view--null"}"string"==typeof(null==h?void 0:h.className)&&(N+=" "+h.className),A&&(N+=" json-view--deleting");let O=String(a);"bigint"===p&&(O+="n");let P=(0,D.useMemo)(()=>(0,C.jsx)("span",{contentEditable:!0,className:N,dangerouslySetInnerHTML:{__html:"string"===p?`"${O}"`:O},ref:E,onKeyDown:J}),[O,p,J]);return"string"===p?(0,C.jsxs)(C.Fragment,{children:[y?P:a.length>i?(0,C.jsx)(nE,{str:a,ref:E,className:N,ctrlClick:L}):(0,C.jsxs)("span",Object.assign({className:N,onClick:L},{children:['"',O,'"']})),M]}):(0,C.jsxs)(C.Fragment,{children:[y?P:(0,C.jsx)("span",Object.assign({className:N,onClick:L},{children:O})),M]})}}let nK=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,nL=(0,D.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:nK,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function nM({src:a,collapseStringsAfterLength:b=99,collapseStringMode:c="directly",customizeCollapseStringUI:d,collapseObjectsAfterLength:e=99,collapsed:f,onCollapse:g,enableClipboard:h=!0,editable:i=!1,onEdit:j,onDelete:k,onAdd:l,onChange:n,dark:o=!1,theme:p="default",customizeNode:q,customizeCopy:r=a=>(function(a,b){if("string"==typeof a)return a;try{return JSON.stringify(a,(a,b)=>{switch(typeof b){case"bigint":return String(b)+"n";case"number":case"boolean":case"object":case"string":return b;default:return String(b)}},void 0)}catch(a){return`${a.name}: ${a.message}`||"JSON.stringify failed"}})(a),displaySize:s,displayArrayIndex:t=!0,style:u,className:v,matchesURL:w=!1,urlRegExp:x=nK,ignoreLargeArray:y=!1,CopyComponent:z,CopiedComponent:A,EditComponent:B,CancelComponent:E,DoneComponent:F,CustomOperation:G}){let[H,I]=(0,D.useState)(0),J=(0,D.useCallback)(()=>I(a=>++a),[]),[K,L]=(0,D.useState)(a);return(0,D.useEffect)(()=>L(a),[a]),(0,C.jsx)(nL.Provider,Object.assign({value:{src:K,collapseStringsAfterLength:b,collapseStringMode:c,customizeCollapseStringUI:d,collapseObjectsAfterLength:e,collapsed:f,onCollapse:g,enableClipboard:h,editable:i,onEdit:j,onDelete:k,onAdd:l,onChange:n,forceUpdate:J,customizeNode:q,customizeCopy:r,displaySize:s,displayArrayIndex:t,matchesURL:w,urlRegExp:x,ignoreLargeArray:y,CopyComponent:z,CopiedComponent:A,EditComponent:B,CancelComponent:E,DoneComponent:F,CustomOperation:G}},{children:(0,C.jsx)("code",Object.assign({className:"json-view"+(o?" dark":"")+(p&&"default"!==p?" json-view_"+p:"")+(v?" "+v:""),style:u},{children:(0,C.jsx)(nJ,{node:K,depth:1,editHandle:(a,b,c,d)=>{L(b),j&&j({newValue:b,oldValue:c,depth:1,src:K,indexOrName:a,parentType:null,parentPath:d}),n&&n({type:"edit",depth:1,src:K,indexOrName:a,parentType:null,parentPath:d})},deleteHandle:(a,b)=>{L(void 0),k&&k({value:K,depth:1,src:K,indexOrName:a,parentType:null,parentPath:b}),n&&n({depth:1,src:K,indexOrName:a,parentType:null,type:"delete",parentPath:b})},parentPath:[]})}))}))}var nN=a.i(28094),bi=bi;let nO=(0,K.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function nP(){}function nQ(){}let nR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nT={};function nU(a,b){return((b||nT).jsx?nS:nR).test(a)}let nV=/[ \t\n\f\r]/g;function nW(a){return""===a.replace(nV,"")}class nX{constructor(a,b){this.attribute=b,this.property=a}}nX.prototype.attribute="",nX.prototype.booleanish=!1,nX.prototype.boolean=!1,nX.prototype.commaOrSpaceSeparated=!1,nX.prototype.commaSeparated=!1,nX.prototype.defined=!1,nX.prototype.mustUseProperty=!1,nX.prototype.number=!1,nX.prototype.overloadedBoolean=!1,nX.prototype.property="",nX.prototype.spaceSeparated=!1,nX.prototype.space=void 0;let nY=0,nZ=n4(),n$=n4(),n_=n4(),n0=n4(),n1=n4(),n2=n4(),n3=n4();function n4(){return 2**++nY}a.s(["boolean",0,nZ,"booleanish",0,n$,"commaOrSpaceSeparated",0,n3,"commaSeparated",0,n2,"number",0,n0,"overloadedBoolean",0,n_,"spaceSeparated",0,n1],53427);var n5=a.i(53427);let n6=Object.keys(n5);class n7 extends nX{constructor(a,b,c,d){let e=-1;if(super(a,b),function(a,b,c){c&&(a[b]=c)}(this,"space",d),"number"==typeof c)for(;++e<n6.length;){const a=n6[e];!function(a,b,c){c&&(a[b]=c)}(this,n6[e],(c&n5[a])===n5[a])}}}function n8(a){return a.toLowerCase()}n7.prototype.defined=!0;let n9=/[A-Z]/g,oa=/-[a-z]/g,ob=/^data[-\w.:]+$/i;function oc(a){return"-"+a.toLowerCase()}function od(a){return a.charAt(1).toUpperCase()}let oe={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 of{constructor(a,b,c){this.normal=b,this.property=a,c&&(this.space=c)}}function og(a,b){let c={},d={};for(let b of a)Object.assign(c,b.property),Object.assign(d,b.normal);return new of(c,d,b)}function oh(a){let b={},c={};for(let[d,e]of Object.entries(a.properties)){let f=new n7(d,a.transform(a.attributes||{},d),e,a.space);a.mustUseProperty&&a.mustUseProperty.includes(d)&&(f.mustUseProperty=!0),b[d]=f,c[n8(d)]=d,c[n8(f.attribute)]=d}return new of(b,c,a.space)}of.prototype.normal={},of.prototype.property={},of.prototype.space=void 0;let oi=oh({properties:{ariaActiveDescendant:null,ariaAtomic:n$,ariaAutoComplete:null,ariaBusy:n$,ariaChecked:n$,ariaColCount:n0,ariaColIndex:n0,ariaColSpan:n0,ariaControls:n1,ariaCurrent:null,ariaDescribedBy:n1,ariaDetails:null,ariaDisabled:n$,ariaDropEffect:n1,ariaErrorMessage:null,ariaExpanded:n$,ariaFlowTo:n1,ariaGrabbed:n$,ariaHasPopup:null,ariaHidden:n$,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:n1,ariaLevel:n0,ariaLive:null,ariaModal:n$,ariaMultiLine:n$,ariaMultiSelectable:n$,ariaOrientation:null,ariaOwns:n1,ariaPlaceholder:null,ariaPosInSet:n0,ariaPressed:n$,ariaReadOnly:n$,ariaRelevant:null,ariaRequired:n$,ariaRoleDescription:n1,ariaRowCount:n0,ariaRowIndex:n0,ariaRowSpan:n0,ariaSelected:n$,ariaSetSize:n0,ariaSort:null,ariaValueMax:n0,ariaValueMin:n0,ariaValueNow:n0,ariaValueText:null,role:null},transform:(a,b)=>"role"===b?b:"aria-"+b.slice(4).toLowerCase()});function oj(a,b){return b in a?a[b]:b}function ok(a,b){return oj(a,b.toLowerCase())}let ol=oh({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:n2,acceptCharset:n1,accessKey:n1,action:null,allow:null,allowFullScreen:nZ,allowPaymentRequest:nZ,allowUserMedia:nZ,alt:null,as:null,async:nZ,autoCapitalize:null,autoComplete:n1,autoFocus:nZ,autoPlay:nZ,blocking:n1,capture:null,charSet:null,checked:nZ,cite:null,className:n1,cols:n0,colSpan:null,content:null,contentEditable:n$,controls:nZ,controlsList:n1,coords:n0|n2,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nZ,defer:nZ,dir:null,dirName:null,disabled:nZ,download:n_,draggable:n$,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nZ,formTarget:null,headers:n1,height:n0,hidden:n_,high:n0,href:null,hrefLang:null,htmlFor:n1,httpEquiv:n1,id:null,imageSizes:null,imageSrcSet:null,inert:nZ,inputMode:null,integrity:null,is:null,isMap:nZ,itemId:null,itemProp:n1,itemRef:n1,itemScope:nZ,itemType:n1,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nZ,low:n0,manifest:null,max:null,maxLength:n0,media:null,method:null,min:null,minLength:n0,multiple:nZ,muted:nZ,name:null,nonce:null,noModule:nZ,noValidate:nZ,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:nZ,optimum:n0,pattern:null,ping:n1,placeholder:null,playsInline:nZ,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nZ,referrerPolicy:null,rel:n1,required:nZ,reversed:nZ,rows:n0,rowSpan:n0,sandbox:n1,scope:null,scoped:nZ,seamless:nZ,selected:nZ,shadowRootClonable:nZ,shadowRootDelegatesFocus:nZ,shadowRootMode:null,shape:null,size:n0,sizes:null,slot:null,span:n0,spellCheck:n$,src:null,srcDoc:null,srcLang:null,srcSet:null,start:n0,step:null,style:null,tabIndex:n0,target:null,title:null,translate:null,type:null,typeMustMatch:nZ,useMap:null,value:n$,width:n0,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:n1,axis:null,background:null,bgColor:null,border:n0,borderColor:null,bottomMargin:n0,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nZ,declare:nZ,event:null,face:null,frame:null,frameBorder:null,hSpace:n0,leftMargin:n0,link:null,longDesc:null,lowSrc:null,marginHeight:n0,marginWidth:n0,noResize:nZ,noHref:nZ,noShade:nZ,noWrap:nZ,object:null,profile:null,prompt:null,rev:null,rightMargin:n0,rules:null,scheme:null,scrolling:n$,standby:null,summary:null,text:null,topMargin:n0,valueType:null,version:null,vAlign:null,vLink:null,vSpace:n0,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nZ,disableRemotePlayback:nZ,prefix:null,property:null,results:n0,security:null,unselectable:null},space:"html",transform:ok}),om=oh({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:n3,accentHeight:n0,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:n0,amplitude:n0,arabicForm:null,ascent:n0,attributeName:null,attributeType:null,azimuth:n0,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:n0,by:null,calcMode:null,capHeight:n0,className:n1,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:n0,diffuseConstant:n0,direction:null,display:null,dur:null,divisor:n0,dominantBaseline:null,download:nZ,dx:null,dy:null,edgeMode:null,editable:null,elevation:n0,enableBackground:null,end:null,event:null,exponent:n0,externalResourcesRequired:null,fill:null,fillOpacity:n0,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:n2,g2:n2,glyphName:n2,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:n0,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:n0,horizOriginX:n0,horizOriginY:n0,id:null,ideographic:n0,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:n0,k:n0,k1:n0,k2:n0,k3:n0,k4:n0,kernelMatrix:n3,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:n0,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:n0,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:n0,overlineThickness:n0,paintOrder:null,panose1:null,path:null,pathLength:n0,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:n1,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:n0,pointsAtY:n0,pointsAtZ:n0,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:n3,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:n3,rev:n3,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:n3,requiredFeatures:n3,requiredFonts:n3,requiredFormats:n3,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:n0,specularExponent:n0,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:n0,strikethroughThickness:n0,string:null,stroke:null,strokeDashArray:n3,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:n0,strokeOpacity:n0,strokeWidth:null,style:null,surfaceScale:n0,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:n3,tabIndex:n0,tableValues:null,target:null,targetX:n0,targetY:n0,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:n3,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:n0,underlineThickness:n0,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:n0,values:null,vAlphabetic:n0,vMathematical:n0,vectorEffect:null,vHanging:n0,vIdeographic:n0,version:null,vertAdvY:n0,vertOriginX:n0,vertOriginY:n0,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:n0,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oj}),on=oh({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(a,b)=>"xlink:"+b.slice(5).toLowerCase()}),oo=oh({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ok}),op=oh({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(a,b)=>"xml:"+b.slice(3).toLowerCase()}),oq=og([oi,ol,on,oo,op],"html"),or=og([oi,om,on,oo,op],"svg");var os=a.i(52540);let ot=ov("end"),ou=ov("start");function ov(a){return function(b){let c=b&&b.position&&b.position[a]||{};if("number"==typeof c.line&&c.line>0&&"number"==typeof c.column&&c.column>0)return{line:c.line,column:c.column,offset:"number"==typeof c.offset&&c.offset>-1?c.offset:void 0}}}function ow(a){return a&&"object"==typeof a?"position"in a||"type"in a?oy(a.position):"start"in a||"end"in a?oy(a):"line"in a||"column"in a?ox(a):"":""}function ox(a){return oz(a&&a.line)+":"+oz(a&&a.column)}function oy(a){return ox(a&&a.start)+"-"+ox(a&&a.end)}function oz(a){return a&&"number"==typeof a?a:1}class oA extends Error{constructor(a,b,c){super(),"string"==typeof b&&(c=b,b=void 0);let d="",e={},f=!1;if(b&&(e="line"in b&&"column"in b||"start"in b&&"end"in b?{place:b}:"type"in b?{ancestors:[b],place:b.position}:{...b}),"string"==typeof a?d=a:!e.cause&&a&&(f=!0,d=a.message,e.cause=a),!e.ruleId&&!e.source&&"string"==typeof c){const a=c.indexOf(":");-1===a?e.ruleId=c:(e.source=c.slice(0,a),e.ruleId=c.slice(a+1))}if(!e.place&&e.ancestors&&e.ancestors){const a=e.ancestors[e.ancestors.length-1];a&&(e.place=a.position)}const g=e.place&&"start"in e.place?e.place.start:e.place;this.ancestors=e.ancestors||void 0,this.cause=e.cause||void 0,this.column=g?g.column:void 0,this.fatal=void 0,this.file="",this.message=d,this.line=g?g.line:void 0,this.name=ow(e.place)||"1:1",this.place=e.place||void 0,this.reason=this.message,this.ruleId=e.ruleId||void 0,this.source=e.source||void 0,this.stack=f&&e.cause&&"string"==typeof e.cause.stack?e.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}oA.prototype.file="",oA.prototype.name="",oA.prototype.reason="",oA.prototype.message="",oA.prototype.stack="",oA.prototype.column=void 0,oA.prototype.line=void 0,oA.prototype.ancestors=void 0,oA.prototype.cause=void 0,oA.prototype.fatal=void 0,oA.prototype.place=void 0,oA.prototype.ruleId=void 0,oA.prototype.source=void 0;let oB={}.hasOwnProperty,oC=new Map,oD=/[A-Z]/g,oE=new Set(["table","tbody","thead","tfoot","tr"]),oF=new Set(["td","th"]),oG="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function oH(a,b,c){var d,e,f,g,h,i,j,k,l;let n,o,p,q,r,s,t,u,v,w,x;return"element"===b.type?(d=a,e=b,f=c,o=n=d.schema,"svg"===e.tagName.toLowerCase()&&"html"===n.space&&(d.schema=or),d.ancestors.push(e),p=oL(d,e.tagName,!1),q=function(a,b){let c,d,e={};for(d in b.properties)if("children"!==d&&oB.call(b.properties,d)){let f=function(a,b,c){let d=function(a,b){let c=n8(b),d=b,e=nX;if(c in a.normal)return a.property[a.normal[c]];if(c.length>4&&"data"===c.slice(0,4)&&ob.test(b)){if("-"===b.charAt(4)){let a=b.slice(5).replace(oa,od);d="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{let a=b.slice(4);if(!oa.test(a)){let c=a.replace(n9,oc);"-"!==c.charAt(0)&&(c="-"+c),b="data"+c}}e=n7}return new e(d,b)}(a.schema,b);if(!(null==c||"number"==typeof c&&Number.isNaN(c))){var e;let b;if(Array.isArray(c)&&(c=d.commaSeparated?(b={},(""===(e=c)[e.length-1]?[...e,""]:e).join((b.padRight?" ":"")+","+(!1===b.padLeft?"":" ")).trim()):c.join(" ").trim()),"style"===d.property){let b="object"==typeof c?c:function(a,b){try{return(0,os.default)(b,{reactCompat:!0})}catch(c){if(a.ignoreInvalidStyle)return{};let b=new oA("Cannot parse `style` attribute",{ancestors:a.ancestors,cause:c,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw b.file=a.filePath||void 0,b.url=oG+"#cannot-parse-style-attribute",b}}(a,String(c));return"css"===a.stylePropertyNameCase&&(b=function(a){let b,c={};for(b in a)oB.call(a,b)&&(c[function(a){let b=a.replace(oD,oN);return"ms-"===b.slice(0,3)&&(b="-"+b),b}(b)]=a[b]);return c}(b)),["style",b]}return["react"===a.elementAttributeNameCase&&d.space?oe[d.property]||d.property:d.attribute,c]}}(a,d,b.properties[d]);if(f){let[d,g]=f;a.tableCellAlignToStyle&&"align"===d&&"string"==typeof g&&oF.has(b.tagName)?c=g:e[d]=g}}return c&&((e.style||(e.style={}))["css"===a.stylePropertyNameCase?"text-align":"textAlign"]=c),e}(d,e),r=oK(d,e),oE.has(e.tagName)&&(r=r.filter(function(a){return"string"!=typeof a||!("object"==typeof a?"text"===a.type&&nW(a.value):nW(a))})),oI(d,q,p,e),oJ(q,r),d.ancestors.pop(),d.schema=n,d.create(e,p,q,f)):"mdxFlowExpression"===b.type||"mdxTextExpression"===b.type?function(a,b){if(b.data&&b.data.estree&&a.evaluater){let c=b.data.estree.body[0];return nP("ExpressionStatement"===c.type),a.evaluater.evaluateExpression(c.expression)}oM(a,b.position)}(a,b):"mdxJsxFlowElement"===b.type||"mdxJsxTextElement"===b.type?(g=a,h=b,i=c,t=s=g.schema,"svg"===h.name&&"html"===s.space&&(g.schema=or),g.ancestors.push(h),u=null===h.name?g.Fragment:oL(g,h.name,!0),v=function(a,b){let c={};for(let d of b.attributes)if("mdxJsxExpressionAttribute"===d.type)if(d.data&&d.data.estree&&a.evaluater){let b=d.data.estree.body[0];nP("ExpressionStatement"===b.type);let e=b.expression;nP("ObjectExpression"===e.type);let f=e.properties[0];nP("SpreadElement"===f.type),Object.assign(c,a.evaluater.evaluateExpression(f.argument))}else oM(a,b.position);else{let e,f=d.name;if(d.value&&"object"==typeof d.value)if(d.value.data&&d.value.data.estree&&a.evaluater){let b=d.value.data.estree.body[0];nP("ExpressionStatement"===b.type),e=a.evaluater.evaluateExpression(b.expression)}else oM(a,b.position);else e=null===d.value||d.value;c[f]=e}return c}(g,h),w=oK(g,h),oI(g,v,u,h),oJ(v,w),g.ancestors.pop(),g.schema=s,g.create(h,u,v,i)):"mdxjsEsm"===b.type?function(a,b){if(b.data&&b.data.estree&&a.evaluater)return a.evaluater.evaluateProgram(b.data.estree);oM(a,b.position)}(a,b):"root"===b.type?(j=a,k=b,l=c,oJ(x={},oK(j,k)),j.create(k,j.Fragment,x,l)):"text"===b.type?b.value:void 0}function oI(a,b,c,d){"string"!=typeof c&&c!==a.Fragment&&a.passNode&&(b.node=d)}function oJ(a,b){if(b.length>0){let c=b.length>1?b:b[0];c&&(a.children=c)}}function oK(a,b){let c=[],d=-1,e=a.passKeys?new Map:oC;for(;++d<b.children.length;){let f,g=b.children[d];if(a.passKeys){let a="element"===g.type?g.tagName:"mdxJsxFlowElement"===g.type||"mdxJsxTextElement"===g.type?g.name:void 0;if(a){let b=e.get(a)||0;f=a+"-"+b,e.set(a,b+1)}}let h=oH(a,g,f);void 0!==h&&c.push(h)}return c}function oL(a,b,c){let d;if(c)if(b.includes(".")){let a,c=b.split("."),e=-1;for(;++e<c.length;){let b=nU(c[e])?{type:"Identifier",name:c[e]}:{type:"Literal",value:c[e]};a=a?{type:"MemberExpression",object:a,property:b,computed:!!(e&&"Literal"===b.type),optional:!1}:b}nP(a,"always a result"),d=a}else d=nU(b)&&!/^[a-z]/.test(b)?{type:"Identifier",name:b}:{type:"Literal",value:b};else d={type:"Literal",value:b};if("Literal"===d.type){let b=d.value;return oB.call(a.components,b)?a.components[b]:b}if(a.evaluater)return a.evaluater.evaluateExpression(d);oM(a)}function oM(a,b){let c=new oA("Cannot handle MDX estrees without `createEvaluater`",{ancestors:a.ancestors,place:b,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw c.file=a.filePath||void 0,c.url=oG+"#cannot-handle-mdx-estrees-without-createevaluater",c}function oN(a){return"-"+a.toLowerCase()}let oO={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"]},oP={};function oQ(a,b){let c=b||oP;return oR(a,"boolean"!=typeof c.includeImageAlt||c.includeImageAlt,"boolean"!=typeof c.includeHtml||c.includeHtml)}function oR(a,b,c){var d;if((d=a)&&"object"==typeof d){if("value"in a)return"html"!==a.type||c?a.value:"";if(b&&"alt"in a&&a.alt)return a.alt;if("children"in a)return oS(a.children,b,c)}return Array.isArray(a)?oS(a,b,c):""}function oS(a,b,c){let d=[],e=-1;for(;++e<a.length;)d[e]=oR(a[e],b,c);return d.join("")}function oT(a,b,c,d){let e,f=a.length,g=0;if(b=b<0?-b>f?0:f+b:b>f?f:b,c=c>0?c:0,d.length<1e4)(e=Array.from(d)).unshift(b,c),a.splice(...e);else for(c&&a.splice(b,c);g<d.length;)(e=d.slice(g,g+1e4)).unshift(b,0),a.splice(...e),g+=1e4,b+=1e4}function oU(a,b){return a.length>0?(oT(a,a.length,0,b),a):b}let oV={}.hasOwnProperty;function oW(a){let b={},c=-1;for(;++c<a.length;)!function(a,b){let c;for(c in b){let d,e=(oV.call(a,c)?a[c]:void 0)||(a[c]={}),f=b[c];if(f)for(d in f){oV.call(e,d)||(e[d]=[]);let a=f[d];!function(a,b){let c=-1,d=[];for(;++c<b.length;)("after"===b[c].add?a:d).push(b[c]);oT(a,0,0,d)}(e[d],Array.isArray(a)?a:a?[a]:[])}}}(b,a[c]);return b}function oX(a){return null!==a&&a<-2}function oY(a){return -2===a||-1===a||32===a}function oZ(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function o$(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return oY(d)?(a.enter(c),function d(g){return oY(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}oZ(/[A-Za-z]/),oZ(/[\dA-Za-z]/),oZ(/[#-'*+\--9=?A-Z^-~]/),oZ(/\d/),oZ(/[\dA-Fa-f]/),oZ(/[!-/:-@[-`{-~]/),oZ(/\p{P}|\p{S}/u),oZ(/\s/);let o_={tokenize:function(a){let b,c=a.attempt(this.parser.constructs.contentInitial,function(b){return null===b?void a.consume(b):(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),o$(a,c,"linePrefix"))},function(c){return a.enter("paragraph"),function c(d){let e=a.enter("chunkText",{contentType:"text",previous:b});return b&&(b.next=e),b=e,function b(d){if(null===d){a.exit("chunkText"),a.exit("paragraph"),a.consume(d);return}return oX(d)?(a.consume(d),a.exit("chunkText"),c):(a.consume(d),b)}(d)}(c)});return c}},o0={tokenize:function(a){let b,c,d,e=this,f=[],g=0;return h;function h(b){if(g<f.length){let c=f[g];return e.containerState=c[1],a.attempt(c[0].continuation,i,j)(b)}return j(b)}function i(a){if(g++,e.containerState._closeFlow){let c;e.containerState._closeFlow=void 0,b&&s();let d=e.events.length,f=d;for(;f--;)if("exit"===e.events[f][0]&&"chunkFlow"===e.events[f][1].type){c=e.events[f][1].end;break}r(g);let h=d;for(;h<e.events.length;)e.events[h][1].end={...c},h++;return oT(e.events,f+1,0,e.events.slice(d)),e.events.length=h,j(a)}return h(a)}function j(c){if(g===f.length){if(!b)return n(c);if(b.currentConstruct&&b.currentConstruct.concrete)return p(c);e.interrupt=!!(b.currentConstruct&&!b._gfmTableDynamicInterruptHack)}return e.containerState={},a.check(o1,k,l)(c)}function k(a){return b&&s(),r(g),n(a)}function l(a){return e.parser.lazy[e.now().line]=g!==f.length,d=e.now().offset,p(a)}function n(b){return e.containerState={},a.attempt(o1,o,p)(b)}function o(a){return g++,f.push([e.currentConstruct,e.containerState]),n(a)}function p(d){if(null===d){b&&s(),r(0),a.consume(d);return}return b=b||e.parser.flow(e.now()),a.enter("chunkFlow",{_tokenizer:b,contentType:"flow",previous:c}),function b(c){if(null===c){q(a.exit("chunkFlow"),!0),r(0),a.consume(c);return}return oX(c)?(a.consume(c),q(a.exit("chunkFlow")),g=0,e.interrupt=void 0,h):(a.consume(c),b)}(d)}function q(a,f){let h=e.sliceStream(a);if(f&&h.push(null),a.previous=c,c&&(c.next=a),c=a,b.defineSkip(a.start),b.write(h),e.parser.lazy[a.start.line]){let a,c,f=b.events.length;for(;f--;)if(b.events[f][1].start.offset<d&&(!b.events[f][1].end||b.events[f][1].end.offset>d))return;let h=e.events.length,i=h;for(;i--;)if("exit"===e.events[i][0]&&"chunkFlow"===e.events[i][1].type){if(a){c=e.events[i][1].end;break}a=!0}for(r(g),f=h;f<e.events.length;)e.events[f][1].end={...c},f++;oT(e.events,i+1,0,e.events.slice(h)),e.events.length=f}}function r(b){let c=f.length;for(;c-- >b;){let b=f[c];e.containerState=b[1],b[0].exit.call(e,a)}f.length=b}function s(){b.write([null]),c=void 0,b=void 0,e.containerState._closeFlow=void 0}}},o1={tokenize:function(a,b,c){return o$(a,a.attempt(this.parser.constructs.document,b,c),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},o2=pb(/[A-Za-z]/),o3=pb(/[\dA-Za-z]/),o4=pb(/[#-'*+\--9=?A-Z^-~]/),o5=pb(/\d/),o6=pb(/[\dA-Fa-f]/),o7=pb(/[!-/:-@[-`{-~]/);function o8(a){return null!==a&&a<-2}function o9(a){return null!==a&&(a<0||32===a)}function pa(a){return -2===a||-1===a||32===a}function pb(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pc(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return pa(d)?(a.enter(c),function d(g){return pa(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}pb(/\p{P}|\p{S}/u),pb(/\s/);let pd={partial:!0,tokenize:function(a,b,c){return function(b){return pa(b)?pc(a,d,"linePrefix")(b):d(b)};function d(a){return null===a||o8(a)?b(a):c(a)}}};class pe{constructor(a){this.left=a?[...a]:[],this.right=[]}get(a){if(a<0||a>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+a+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return a<this.left.length?this.left[a]:this.right[this.right.length-a+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(a,b){let c=null==b?1/0:b;return c<this.left.length?this.left.slice(a,c):a>this.left.length?this.right.slice(this.right.length-c+this.left.length,this.right.length-a+this.left.length).reverse():this.left.slice(a).concat(this.right.slice(this.right.length-c+this.left.length).reverse())}splice(a,b,c){this.setCursor(Math.trunc(a));let d=this.right.splice(this.right.length-(b||0),1/0);return c&&pf(this.left,c),d.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(a){this.setCursor(1/0),this.left.push(a)}pushMany(a){this.setCursor(1/0),pf(this.left,a)}unshift(a){this.setCursor(0),this.right.push(a)}unshiftMany(a){this.setCursor(0),pf(this.right,a.reverse())}setCursor(a){if(a!==this.left.length&&(!(a>this.left.length)||0!==this.right.length)&&(!(a<0)||0!==this.left.length))if(a<this.left.length){let b=this.left.splice(a,1/0);pf(this.right,b.reverse())}else{let b=this.right.splice(this.left.length+this.right.length-a,1/0);pf(this.left,b.reverse())}}}function pf(a,b){let c=0;if(b.length<1e4)a.push(...b);else for(;c<b.length;)a.push(...b.slice(c,c+1e4)),c+=1e4}function pg(a){let b,c,d,e,f,g,h,i={},j=-1,k=new pe(a);for(;++j<k.length;){for(;j in i;)j=i[j];if(b=k.get(j),j&&"chunkFlow"===b[1].type&&"listItemPrefix"===k.get(j-1)[1].type&&((d=0)<(g=b[1]._tokenizer.events).length&&"lineEndingBlank"===g[d][1].type&&(d+=2),d<g.length&&"content"===g[d][1].type))for(;++d<g.length&&"content"!==g[d][1].type;)"chunkText"===g[d][1].type&&(g[d][1]._isInFirstContentOfListItem=!0,d++);if("enter"===b[0])b[1].contentType&&(Object.assign(i,function(a,b){let c,d,e=a.get(b)[1],f=a.get(b)[2],g=b-1,h=[],i=e._tokenizer;!i&&(i=f.parser[e.contentType](e.start),e._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));let j=i.events,k=[],l={},n=-1,o=e,p=0,q=0,r=[0];for(;o;){for(;a.get(++g)[1]!==o;);h.push(g),!o._tokenizer&&(c=f.sliceStream(o),o.next||c.push(null),d&&i.defineSkip(o.start),o._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(c),o._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=o,o=o.next}for(o=e;++n<j.length;)"exit"===j[n][0]&&"enter"===j[n-1][0]&&j[n][1].type===j[n-1][1].type&&j[n][1].start.line!==j[n][1].end.line&&(q=n+1,r.push(q),o._tokenizer=void 0,o.previous=void 0,o=o.next);for(i.events=[],o?(o._tokenizer=void 0,o.previous=void 0):r.pop(),n=r.length;n--;){let b=j.slice(r[n],r[n+1]),c=h.pop();k.push([c,c+b.length-1]),a.splice(c,2,b)}for(k.reverse(),n=-1;++n<k.length;)l[p+k[n][0]]=p+k[n][1],p+=k[n][1]-k[n][0]-1;return l}(k,j)),j=i[j],h=!0);else if(b[1]._container){for(d=j,c=void 0;d--;)if("lineEnding"===(e=k.get(d))[1].type||"lineEndingBlank"===e[1].type)"enter"===e[0]&&(c&&(k.get(c)[1].type="lineEndingBlank"),e[1].type="lineEnding",c=d);else if("linePrefix"===e[1].type||"listItemIndent"===e[1].type);else break;c&&(b[1].end={...k.get(c)[1].start},(f=k.slice(c,j)).unshift(b),k.splice(c,j-c+1,f))}}return oT(a,0,1/0,k.slice(0)),!h}let ph={resolve:function(a){return pg(a),a},tokenize:function(a,b){let c;return function(b){return a.enter("content"),c=a.enter("chunkContent",{contentType:"content"}),d(b)};function d(b){return null===b?e(b):o8(b)?a.check(pi,f,e)(b):(a.consume(b),d)}function e(c){return a.exit("chunkContent"),a.exit("content"),b(c)}function f(b){return a.consume(b),a.exit("chunkContent"),c.next=a.enter("chunkContent",{contentType:"content",previous:c}),c=c.next,d}}},pi={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return a.exit("chunkContent"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),pc(a,e,"linePrefix")};function e(e){if(null===e||o8(e))return c(e);let f=d.events[d.events.length-1];return!d.parser.constructs.disable.null.includes("codeIndented")&&f&&"linePrefix"===f[1].type&&f[2].sliceSerialize(f[1],!0).length>=4?b(e):a.interrupt(d.parser.constructs.flow,c,b)(e)}}},pj={tokenize:function(a){let b=this,c=a.attempt(pd,function(d){return null===d?void a.consume(d):(a.enter("lineEndingBlank"),a.consume(d),a.exit("lineEndingBlank"),b.currentConstruct=void 0,c)},a.attempt(this.parser.constructs.flowInitial,d,o$(a,a.attempt(this.parser.constructs.flow,d,a.attempt(ph,d)),"linePrefix")));return c;function d(d){return null===d?void a.consume(d):(a.enter("lineEnding"),a.consume(d),a.exit("lineEnding"),b.currentConstruct=void 0,c)}}},pk={resolveAll:po()},pl=pn("string"),pm=pn("text");function pn(a){return{resolveAll:po("text"===a?pp:void 0),tokenize:function(b){let c=this,d=this.parser.constructs[a],e=b.attempt(d,f,g);return f;function f(a){return i(a)?e(a):g(a)}function g(a){return null===a?void b.consume(a):(b.enter("data"),b.consume(a),h)}function h(a){return i(a)?(b.exit("data"),e(a)):(b.consume(a),h)}function i(a){if(null===a)return!0;let b=d[a],e=-1;if(b)for(;++e<b.length;){let a=b[e];if(!a.previous||a.previous.call(c,c.previous))return!0}return!1}}}}function po(a){return function(b,c){let d,e=-1;for(;++e<=b.length;)void 0===d?b[e]&&"data"===b[e][1].type&&(d=e,e++):b[e]&&"data"===b[e][1].type||(e!==d+2&&(b[d][1].end=b[e-1][1].end,b.splice(d+2,e-d-2),e=d+2),d=void 0);return a?a(b,c):b}}function pp(a,b){let c=0;for(;++c<=a.length;)if((c===a.length||"lineEnding"===a[c][1].type)&&"data"===a[c-1][1].type){let d,e=a[c-1][1],f=b.sliceStream(e),g=f.length,h=-1,i=0;for(;g--;){let a=f[g];if("string"==typeof a){for(h=a.length;32===a.charCodeAt(h-1);)i++,h--;if(h)break;h=-1}else if(-2===a)d=!0,i++;else if(-1===a);else{g++;break}}if(b._contentTypeTextTrailing&&c===a.length&&(i=0),i){let f={type:c===a.length||d||i<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:g?h:e.start._bufferIndex+h,_index:e.start._index+g,line:e.end.line,column:e.end.column-i,offset:e.end.offset-i},end:{...e.end}};e.end={...f.start},e.start.offset===e.end.offset?Object.assign(e,f):(a.splice(c,0,["enter",f,b],["exit",f,b]),c+=2)}c++}return a}ps(/[A-Za-z]/),ps(/[\dA-Za-z]/),ps(/[#-'*+\--9=?A-Z^-~]/),ps(/\d/),ps(/[\dA-Fa-f]/),ps(/[!-/:-@[-`{-~]/);let pq=ps(/\p{P}|\p{S}/u),pr=ps(/\s/);function ps(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pt(a){return null===a||null!==a&&(a<0||32===a)||pr(a)?1:pq(a)?2:void 0}function pu(a,b,c){let d=[],e=-1;for(;++e<a.length;){let f=a[e].resolveAll;f&&!d.includes(f)&&(b=f(b,c),d.push(f))}return b}let pv={name:"attention",resolveAll:function(a,b){let c,d,e,f,g,h,i,j,k=-1;for(;++k<a.length;)if("enter"===a[k][0]&&"attentionSequence"===a[k][1].type&&a[k][1]._close){for(c=k;c--;)if("exit"===a[c][0]&&"attentionSequence"===a[c][1].type&&a[c][1]._open&&b.sliceSerialize(a[c][1]).charCodeAt(0)===b.sliceSerialize(a[k][1]).charCodeAt(0)){if((a[c][1]._close||a[k][1]._open)&&(a[k][1].end.offset-a[k][1].start.offset)%3&&!((a[c][1].end.offset-a[c][1].start.offset+a[k][1].end.offset-a[k][1].start.offset)%3))continue;h=a[c][1].end.offset-a[c][1].start.offset>1&&a[k][1].end.offset-a[k][1].start.offset>1?2:1;let l={...a[c][1].end},n={...a[k][1].start};pw(l,-h),pw(n,h),f={type:h>1?"strongSequence":"emphasisSequence",start:l,end:{...a[c][1].end}},g={type:h>1?"strongSequence":"emphasisSequence",start:{...a[k][1].start},end:n},e={type:h>1?"strongText":"emphasisText",start:{...a[c][1].end},end:{...a[k][1].start}},d={type:h>1?"strong":"emphasis",start:{...f.start},end:{...g.end}},a[c][1].end={...f.start},a[k][1].start={...g.end},i=[],a[c][1].end.offset-a[c][1].start.offset&&(i=oU(i,[["enter",a[c][1],b],["exit",a[c][1],b]])),i=oU(i,[["enter",d,b],["enter",f,b],["exit",f,b],["enter",e,b]]),i=oU(i,pu(b.parser.constructs.insideSpan.null,a.slice(c+1,k),b)),i=oU(i,[["exit",e,b],["enter",g,b],["exit",g,b],["exit",d,b]]),a[k][1].end.offset-a[k][1].start.offset?(j=2,i=oU(i,[["enter",a[k][1],b],["exit",a[k][1],b]])):j=0,oT(a,c-1,k-c+3,i),k=c+i.length-j-2;break}}for(k=-1;++k<a.length;)"attentionSequence"===a[k][1].type&&(a[k][1].type="data");return a},tokenize:function(a,b){let c,d=this.parser.constructs.attentionMarkers.null,e=this.previous,f=pt(e);return function(g){return c=g,a.enter("attentionSequence"),function g(h){if(h===c)return a.consume(h),g;let i=a.exit("attentionSequence"),j=pt(h),k=!j||2===j&&f||d.includes(h),l=!f||2===f&&j||d.includes(e);return i._open=!!(42===c?k:k&&(f||!l)),i._close=!!(42===c?l:l&&(j||!k)),b(h)}(g)}}};function pw(a,b){a.column+=b,a.offset+=b,a._bufferIndex+=b}let px={continuation:{tokenize:function(a,b,c){let d=this;return function(b){return pa(b)?pc(a,e,"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):e(b)};function e(d){return a.attempt(px,b,c)(d)}}},exit:function(a){a.exit("blockQuote")},name:"blockQuote",tokenize:function(a,b,c){let d=this;return function(b){if(62===b){let c=d.containerState;return c.open||(a.enter("blockQuote",{_container:!0}),c.open=!0),a.enter("blockQuotePrefix"),a.enter("blockQuoteMarker"),a.consume(b),a.exit("blockQuoteMarker"),e}return c(b)};function e(c){return pa(c)?(a.enter("blockQuotePrefixWhitespace"),a.consume(c),a.exit("blockQuotePrefixWhitespace"),a.exit("blockQuotePrefix"),b):(a.exit("blockQuotePrefix"),b(c))}}},py={name:"characterEscape",tokenize:function(a,b,c){return function(b){return a.enter("characterEscape"),a.enter("escapeMarker"),a.consume(b),a.exit("escapeMarker"),d};function d(d){return o7(d)?(a.enter("characterEscapeValue"),a.consume(d),a.exit("characterEscapeValue"),a.exit("characterEscape"),b):c(d)}}},pz={AElig:"Æ",AMP:"&",Aacute:"Á",Abreve:"Ă",Acirc:"Â",Acy:"А",Afr:"𝔄",Agrave:"À",Alpha:"Α",Amacr:"Ā",And:"⩓",Aogon:"Ą",Aopf:"𝔸",ApplyFunction:"",Aring:"Å",Ascr:"𝒜",Assign:"≔",Atilde:"Ã",Auml:"Ä",Backslash:"∖",Barv:"⫧",Barwed:"⌆",Bcy:"Б",Because:"∵",Bernoullis:"ℬ",Beta:"Β",Bfr:"𝔅",Bopf:"𝔹",Breve:"˘",Bscr:"ℬ",Bumpeq:"≎",CHcy:"Ч",COPY:"©",Cacute:"Ć",Cap:"⋒",CapitalDifferentialD:"ⅅ",Cayleys:"ℭ",Ccaron:"Č",Ccedil:"Ç",Ccirc:"Ĉ",Cconint:"∰",Cdot:"Ċ",Cedilla:"¸",CenterDot:"·",Cfr:"ℭ",Chi:"Χ",CircleDot:"⊙",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",Colon:"∷",Colone:"⩴",Congruent:"≡",Conint:"∯",ContourIntegral:"∮",Copf:"ℂ",Coproduct:"∐",CounterClockwiseContourIntegral:"∳",Cross:"⨯",Cscr:"𝒞",Cup:"⋓",CupCap:"≍",DD:"ⅅ",DDotrahd:"⤑",DJcy:"Ђ",DScy:"Ѕ",DZcy:"Џ",Dagger:"‡",Darr:"↡",Dashv:"⫤",Dcaron:"Ď",Dcy:"Д",Del:"∇",Delta:"Δ",Dfr:"𝔇",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",Diamond:"⋄",DifferentialD:"ⅆ",Dopf:"𝔻",Dot:"¨",DotDot:"⃜",DotEqual:"≐",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",Downarrow:"⇓",Dscr:"𝒟",Dstrok:"Đ",ENG:"Ŋ",ETH:"Ð",Eacute:"É",Ecaron:"Ě",Ecirc:"Ê",Ecy:"Э",Edot:"Ė",Efr:"𝔈",Egrave:"È",Element:"∈",Emacr:"Ē",EmptySmallSquare:"◻",EmptyVerySmallSquare:"▫",Eogon:"Ę",Eopf:"𝔼",Epsilon:"Ε",Equal:"⩵",EqualTilde:"≂",Equilibrium:"⇌",Escr:"ℰ",Esim:"⩳",Eta:"Η",Euml:"Ë",Exists:"∃",ExponentialE:"ⅇ",Fcy:"Ф",Ffr:"𝔉",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",Fopf:"𝔽",ForAll:"∀",Fouriertrf:"ℱ",Fscr:"ℱ",GJcy:"Ѓ",GT:">",Gamma:"Γ",Gammad:"Ϝ",Gbreve:"Ğ",Gcedil:"Ģ",Gcirc:"Ĝ",Gcy:"Г",Gdot:"Ġ",Gfr:"𝔊",Gg:"⋙",Gopf:"𝔾",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",Gt:"≫",HARDcy:"Ъ",Hacek:"ˇ",Hat:"^",Hcirc:"Ĥ",Hfr:"ℌ",HilbertSpace:"ℋ",Hopf:"ℍ",HorizontalLine:"─",Hscr:"ℋ",Hstrok:"Ħ",HumpDownHump:"≎",HumpEqual:"≏",IEcy:"Е",IJlig:"IJ",IOcy:"Ё",Iacute:"Í",Icirc:"Î",Icy:"И",Idot:"İ",Ifr:"ℑ",Igrave:"Ì",Im:"ℑ",Imacr:"Ī",ImaginaryI:"ⅈ",Implies:"⇒",Int:"∬",Integral:"∫",Intersection:"⋂",InvisibleComma:"",InvisibleTimes:"",Iogon:"Į",Iopf:"𝕀",Iota:"Ι",Iscr:"ℐ",Itilde:"Ĩ",Iukcy:"І",Iuml:"Ï",Jcirc:"Ĵ",Jcy:"Й",Jfr:"𝔍",Jopf:"𝕁",Jscr:"𝒥",Jsercy:"Ј",Jukcy:"Є",KHcy:"Х",KJcy:"Ќ",Kappa:"Κ",Kcedil:"Ķ",Kcy:"К",Kfr:"𝔎",Kopf:"𝕂",Kscr:"𝒦",LJcy:"Љ",LT:"<",Lacute:"Ĺ",Lambda:"Λ",Lang:"⟪",Laplacetrf:"ℒ",Larr:"↞",Lcaron:"Ľ",Lcedil:"Ļ",Lcy:"Л",LeftAngleBracket:"⟨",LeftArrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",LeftRightArrow:"↔",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",Leftarrow:"⇐",Leftrightarrow:"⇔",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",LessLess:"⪡",LessSlantEqual:"⩽",LessTilde:"≲",Lfr:"𝔏",Ll:"⋘",Lleftarrow:"⇚",Lmidot:"Ŀ",LongLeftArrow:"⟵",LongLeftRightArrow:"⟷",LongRightArrow:"⟶",Longleftarrow:"⟸",Longleftrightarrow:"⟺",Longrightarrow:"⟹",Lopf:"𝕃",LowerLeftArrow:"↙",LowerRightArrow:"↘",Lscr:"ℒ",Lsh:"↰",Lstrok:"Ł",Lt:"≪",Map:"⤅",Mcy:"М",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",MinusPlus:"∓",Mopf:"𝕄",Mscr:"ℳ",Mu:"Μ",NJcy:"Њ",Nacute:"Ń",Ncaron:"Ň",Ncedil:"Ņ",Ncy:"Н",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",Nfr:"𝔑",NoBreak:"",NonBreakingSpace:" ",Nopf:"ℕ",Not:"⫬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",Nscr:"𝒩",Ntilde:"Ñ",Nu:"Ν",OElig:"Œ",Oacute:"Ó",Ocirc:"Ô",Ocy:"О",Odblac:"Ő",Ofr:"𝔒",Ograve:"Ò",Omacr:"Ō",Omega:"Ω",Omicron:"Ο",Oopf:"𝕆",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",Or:"⩔",Oscr:"𝒪",Oslash:"Ø",Otilde:"Õ",Otimes:"⨷",Ouml:"Ö",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",PartialD:"∂",Pcy:"П",Pfr:"𝔓",Phi:"Φ",Pi:"Π",PlusMinus:"±",Poincareplane:"ℌ",Popf:"ℙ",Pr:"⪻",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",Prime:"″",Product:"∏",Proportion:"∷",Proportional:"∝",Pscr:"𝒫",Psi:"Ψ",QUOT:'"',Qfr:"𝔔",Qopf:"ℚ",Qscr:"𝒬",RBarr:"⤐",REG:"®",Racute:"Ŕ",Rang:"⟫",Rarr:"↠",Rarrtl:"⤖",Rcaron:"Ř",Rcedil:"Ŗ",Rcy:"Р",Re:"ℜ",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",Rfr:"ℜ",Rho:"Ρ",RightAngleBracket:"⟩",RightArrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",Rightarrow:"⇒",Ropf:"ℝ",RoundImplies:"⥰",Rrightarrow:"⇛",Rscr:"ℛ",Rsh:"↱",RuleDelayed:"⧴",SHCHcy:"Щ",SHcy:"Ш",SOFTcy:"Ь",Sacute:"Ś",Sc:"⪼",Scaron:"Š",Scedil:"Ş",Scirc:"Ŝ",Scy:"С",Sfr:"𝔖",ShortDownArrow:"↓",ShortLeftArrow:"←",ShortRightArrow:"→",ShortUpArrow:"↑",Sigma:"Σ",SmallCircle:"∘",Sopf:"𝕊",Sqrt:"√",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",Sscr:"𝒮",Star:"⋆",Sub:"⋐",Subset:"⋐",SubsetEqual:"⊆",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",SuchThat:"∋",Sum:"∑",Sup:"⋑",Superset:"⊃",SupersetEqual:"⊇",Supset:"⋑",THORN:"Þ",TRADE:"™",TSHcy:"Ћ",TScy:"Ц",Tab:" ",Tau:"Τ",Tcaron:"Ť",Tcedil:"Ţ",Tcy:"Т",Tfr:"𝔗",Therefore:"∴",Theta:"Θ",ThickSpace:" ",ThinSpace:" ",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",Topf:"𝕋",TripleDot:"⃛",Tscr:"𝒯",Tstrok:"Ŧ",Uacute:"Ú",Uarr:"↟",Uarrocir:"⥉",Ubrcy:"Ў",Ubreve:"Ŭ",Ucirc:"Û",Ucy:"У",Udblac:"Ű",Ufr:"𝔘",Ugrave:"Ù",Umacr:"Ū",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",Uopf:"𝕌",UpArrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",UpEquilibrium:"⥮",UpTee:"⊥",UpTeeArrow:"↥",Uparrow:"⇑",Updownarrow:"⇕",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",Upsilon:"Υ",Uring:"Ů",Uscr:"𝒰",Utilde:"Ũ",Uuml:"Ü",VDash:"⊫",Vbar:"⫫",Vcy:"В",Vdash:"⊩",Vdashl:"⫦",Vee:"⋁",Verbar:"‖",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",Vopf:"𝕍",Vscr:"𝒱",Vvdash:"⊪",Wcirc:"Ŵ",Wedge:"⋀",Wfr:"𝔚",Wopf:"𝕎",Wscr:"𝒲",Xfr:"𝔛",Xi:"Ξ",Xopf:"𝕏",Xscr:"𝒳",YAcy:"Я",YIcy:"Ї",YUcy:"Ю",Yacute:"Ý",Ycirc:"Ŷ",Ycy:"Ы",Yfr:"𝔜",Yopf:"𝕐",Yscr:"𝒴",Yuml:"Ÿ",ZHcy:"Ж",Zacute:"Ź",Zcaron:"Ž",Zcy:"З",Zdot:"Ż",ZeroWidthSpace:"",Zeta:"Ζ",Zfr:"ℨ",Zopf:"ℤ",Zscr:"𝒵",aacute:"á",abreve:"ă",ac:"∾",acE:"∾̳",acd:"∿",acirc:"â",acute:"´",acy:"а",aelig:"æ",af:"",afr:"𝔞",agrave:"à",alefsym:"ℵ",aleph:"ℵ",alpha:"α",amacr:"ā",amalg:"⨿",amp:"&",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",aogon:"ą",aopf:"𝕒",ap:"≈",apE:"⩰",apacir:"⩯",ape:"≊",apid:"≋",apos:"'",approx:"≈",approxeq:"≊",aring:"å",ascr:"𝒶",ast:"*",asymp:"≈",asympeq:"≍",atilde:"ã",auml:"ä",awconint:"∳",awint:"⨑",bNot:"⫭",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",barvee:"⊽",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",beta:"β",beth:"ℶ",between:"≬",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bnot:"⌐",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxDL:"╗",boxDR:"╔",boxDl:"╖",boxDr:"╓",boxH:"═",boxHD:"╦",boxHU:"╩",boxHd:"╤",boxHu:"╧",boxUL:"╝",boxUR:"╚",boxUl:"╜",boxUr:"╙",boxV:"║",boxVH:"╬",boxVL:"╣",boxVR:"╠",boxVh:"╫",boxVl:"╢",boxVr:"╟",boxbox:"⧉",boxdL:"╕",boxdR:"╒",boxdl:"┐",boxdr:"┌",boxh:"─",boxhD:"╥",boxhU:"╨",boxhd:"┬",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxuL:"╛",boxuR:"╘",boxul:"┘",boxur:"└",boxv:"│",boxvH:"╪",boxvL:"╡",boxvR:"╞",boxvh:"┼",boxvl:"┤",boxvr:"├",bprime:"‵",breve:"˘",brvbar:"¦",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",bumpeq:"≏",cacute:"ć",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",caps:"∩︀",caret:"⁁",caron:"ˇ",ccaps:"⩍",ccaron:"č",ccedil:"ç",ccirc:"ĉ",ccups:"⩌",ccupssm:"⩐",cdot:"ċ",cedil:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",cfr:"𝔠",chcy:"ч",check:"✓",checkmark:"✓",chi:"χ",cir:"○",cirE:"⧃",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledR:"®",circledS:"Ⓢ",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",clubs:"♣",clubsuit:"♣",colon:":",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",conint:"∮",copf:"𝕔",coprod:"∐",copy:"©",copysr:"℗",crarr:"↵",cross:"✗",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cup:"∪",cupbrcap:"⩈",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dArr:"⇓",dHar:"⥥",dagger:"†",daleth:"ℸ",darr:"↓",dash:"‐",dashv:"⊣",dbkarow:"⤏",dblac:"˝",dcaron:"ď",dcy:"д",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",ddotseq:"⩷",deg:"°",delta:"δ",demptyv:"⦱",dfisht:"⥿",dfr:"𝔡",dharl:"⇃",dharr:"⇂",diam:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",dopf:"𝕕",dot:"˙",doteq:"≐",doteqdot:"≑",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",downarrow:"↓",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",dscr:"𝒹",dscy:"ѕ",dsol:"⧶",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",dzcy:"џ",dzigrarr:"⟿",eDDot:"⩷",eDot:"≑",eacute:"é",easter:"⩮",ecaron:"ě",ecir:"≖",ecirc:"ê",ecolon:"≕",ecy:"э",edot:"ė",ee:"ⅇ",efDot:"≒",efr:"𝔢",eg:"⪚",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",emacr:"ē",empty:"∅",emptyset:"∅",emptyv:"∅",emsp13:" ",emsp14:" ",emsp:" ",eng:"ŋ",ensp:" ",eogon:"ę",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",equals:"=",equest:"≟",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erDot:"≓",erarr:"⥱",escr:"ℯ",esdot:"≐",esim:"≂",eta:"η",eth:"ð",euml:"ë",euro:"€",excl:"!",exist:"∃",expectation:"ℰ",exponentiale:"ⅇ",fallingdotseq:"≒",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",ffr:"𝔣",filig:"fi",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",fopf:"𝕗",forall:"∀",fork:"⋔",forkv:"⫙",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",gE:"≧",gEl:"⪌",gacute:"ǵ",gamma:"γ",gammad:"ϝ",gap:"⪆",gbreve:"ğ",gcirc:"ĝ",gcy:"г",gdot:"ġ",ge:"≥",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",gfr:"𝔤",gg:"≫",ggg:"⋙",gimel:"ℷ",gjcy:"ѓ",gl:"≷",glE:"⪒",gla:"⪥",glj:"⪤",gnE:"≩",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",gopf:"𝕘",grave:"`",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",hArr:"⇔",hairsp:" ",half:"½",hamilt:"ℋ",hardcy:"ъ",harr:"↔",harrcir:"⥈",harrw:"↭",hbar:"ℏ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",horbar:"―",hscr:"𝒽",hslash:"ℏ",hstrok:"ħ",hybull:"⁃",hyphen:"‐",iacute:"í",ic:"",icirc:"î",icy:"и",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",ijlig:"ij",imacr:"ī",image:"ℑ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",int:"∫",intcal:"⊺",integers:"ℤ",intercal:"⊺",intlarhk:"⨗",intprod:"⨼",iocy:"ё",iogon:"į",iopf:"𝕚",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",isin:"∈",isinE:"⋹",isindot:"⋵",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",itilde:"ĩ",iukcy:"і",iuml:"ï",jcirc:"ĵ",jcy:"й",jfr:"𝔧",jmath:"ȷ",jopf:"𝕛",jscr:"𝒿",jsercy:"ј",jukcy:"є",kappa:"κ",kappav:"ϰ",kcedil:"ķ",kcy:"к",kfr:"𝔨",kgreen:"ĸ",khcy:"х",kjcy:"ќ",kopf:"𝕜",kscr:"𝓀",lAarr:"⇚",lArr:"⇐",lAtail:"⤛",lBarr:"⤎",lE:"≦",lEg:"⪋",lHar:"⥢",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",lambda:"λ",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",laquo:"«",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",latail:"⤙",late:"⪭",lates:"⪭︀",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",lcaron:"ľ",lcedil:"ļ",lceil:"⌈",lcub:"{",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",leftarrow:"←",leftarrowtail:"↢",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",leftthreetimes:"⋋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",lessgtr:"≶",lesssim:"≲",lfisht:"⥼",lfloor:"⌊",lfr:"𝔩",lg:"≶",lgE:"⪑",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",ljcy:"љ",ll:"≪",llarr:"⇇",llcorner:"⌞",llhard:"⥫",lltri:"◺",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnE:"≨",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",longleftrightarrow:"⟷",longmapsto:"⟼",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",lstrok:"ł",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltrPar:"⦖",ltri:"◃",ltrie:"⊴",ltrif:"◂",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",mDDot:"∺",macr:"¯",male:"♂",malt:"✠",maltese:"✠",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",mcy:"м",mdash:"—",measuredangle:"∡",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",mopf:"𝕞",mp:"∓",mscr:"𝓂",mstpos:"∾",mu:"μ",multimap:"⊸",mumap:"⊸",nGg:"⋙̸",nGt:"≫⃒",nGtv:"≫̸",nLeftarrow:"⇍",nLeftrightarrow:"⇎",nLl:"⋘̸",nLt:"≪⃒",nLtv:"≪̸",nRightarrow:"⇏",nVDash:"⊯",nVdash:"⊮",nabla:"∇",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",ncaron:"ň",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",ncy:"н",ndash:"–",ne:"≠",neArr:"⇗",nearhk:"⤤",nearr:"↗",nearrow:"↗",nedot:"≐̸",nequiv:"≢",nesear:"⤨",nesim:"≂̸",nexist:"∄",nexists:"∄",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",ngsim:"≵",ngt:"≯",ngtr:"≯",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",njcy:"њ",nlArr:"⇍",nlE:"≦̸",nlarr:"↚",nldr:"‥",nle:"≰",nleftarrow:"↚",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nlsim:"≴",nlt:"≮",nltri:"⋪",nltrie:"⋬",nmid:"∤",nopf:"𝕟",not:"¬",notin:"∉",notinE:"⋹̸",notindot:"⋵̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",nu:"ν",num:"#",numero:"№",numsp:" ",nvDash:"⊭",nvHarr:"⤄",nvap:"≍⃒",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwArr:"⇖",nwarhk:"⤣",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",oS:"Ⓢ",oacute:"ó",oast:"⊛",ocir:"⊚",ocirc:"ô",ocy:"о",odash:"⊝",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",oelig:"œ",ofcir:"⦿",ofr:"𝔬",ogon:"˛",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",omacr:"ō",omega:"ω",omicron:"ο",omid:"⦶",ominus:"⊖",oopf:"𝕠",opar:"⦷",operp:"⦹",oplus:"⊕",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oscr:"ℴ",oslash:"ø",osol:"⊘",otilde:"õ",otimes:"⊗",otimesas:"⨶",ouml:"ö",ovbar:"⌽",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",pfr:"𝔭",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",pointint:"⨕",popf:"𝕡",pound:"£",pr:"≺",prE:"⪳",prap:"⪷",prcue:"≼",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",prime:"′",primes:"ℙ",prnE:"⪵",prnap:"⪹",prnsim:"⋨",prod:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",propto:"∝",prsim:"≾",prurel:"⊰",pscr:"𝓅",psi:"ψ",puncsp:" ",qfr:"𝔮",qint:"⨌",qopf:"𝕢",qprime:"⁗",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',rAarr:"⇛",rArr:"⇒",rAtail:"⤜",rBarr:"⤏",rHar:"⥤",race:"∽̱",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",rarrtl:"↣",rarrw:"↝",ratail:"⤚",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",rcaron:"ř",rcedil:"ŗ",rceil:"⌉",rcub:"}",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",reg:"®",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",rhard:"⇁",rharu:"⇀",rharul:"⥬",rho:"ρ",rhov:"ϱ",rightarrow:"→",rightarrowtail:"↣",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",rightthreetimes:"⋌",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",rsaquo:"›",rscr:"𝓇",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",ruluhar:"⥨",rx:"℞",sacute:"ś",sbquo:"‚",sc:"≻",scE:"⪴",scap:"⪸",scaron:"š",sccue:"≽",sce:"⪰",scedil:"ş",scirc:"ŝ",scnE:"⪶",scnap:"⪺",scnsim:"⋩",scpolint:"⨓",scsim:"≿",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",seArr:"⇘",searhk:"⤥",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",sfr:"𝔰",sfrown:"⌢",sharp:"♯",shchcy:"щ",shcy:"ш",shortmid:"∣",shortparallel:"∥",shy:"",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",square:"□",squarf:"▪",squf:"▪",srarr:"→",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",subE:"⫅",subdot:"⪽",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",supE:"⫆",supdot:"⪾",supdsub:"⫘",supe:"⊇",supedot:"⫄",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swArr:"⇙",swarhk:"⤦",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",target:"⌖",tau:"τ",tbrk:"⎴",tcaron:"ť",tcedil:"ţ",tcy:"т",tdot:"⃛",telrec:"⌕",tfr:"𝔱",there4:"∴",therefore:"∴",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",thinsp:" ",thkap:"≈",thksim:"∼",thorn:"þ",tilde:"˜",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",tscr:"𝓉",tscy:"ц",tshcy:"ћ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",uArr:"⇑",uHar:"⥣",uacute:"ú",uarr:"↑",ubrcy:"ў",ubreve:"ŭ",ucirc:"û",ucy:"у",udarr:"⇅",udblac:"ű",udhar:"⥮",ufisht:"⥾",ufr:"𝔲",ugrave:"ù",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",umacr:"ū",uml:"¨",uogon:"ų",uopf:"𝕦",uparrow:"↑",updownarrow:"↕",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",upsi:"υ",upsih:"ϒ",upsilon:"υ",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",uring:"ů",urtri:"◹",uscr:"𝓊",utdot:"⋰",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",uuml:"ü",uwangle:"⦧",vArr:"⇕",vBar:"⫨",vBarv:"⫩",vDash:"⊨",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vcy:"в",vdash:"⊢",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",verbar:"|",vert:"|",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",vopf:"𝕧",vprop:"∝",vrtri:"⊳",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",vzigzag:"⦚",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",wedgeq:"≙",weierp:"℘",wfr:"𝔴",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",yacute:"ý",yacy:"я",ycirc:"ŷ",ycy:"ы",yen:"¥",yfr:"𝔶",yicy:"ї",yopf:"𝕪",yscr:"𝓎",yucy:"ю",yuml:"ÿ",zacute:"ź",zcaron:"ž",zcy:"з",zdot:"ż",zeetrf:"ℨ",zeta:"ζ",zfr:"𝔷",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",zscr:"𝓏",zwj:"",zwnj:""},pA={}.hasOwnProperty;function pB(a){return!!pA.call(pz,a)&&pz[a]}let pC={name:"characterReference",tokenize:function(a,b,c){let d,e,f=this,g=0;return function(b){return a.enter("characterReference"),a.enter("characterReferenceMarker"),a.consume(b),a.exit("characterReferenceMarker"),h};function h(b){return 35===b?(a.enter("characterReferenceMarkerNumeric"),a.consume(b),a.exit("characterReferenceMarkerNumeric"),i):(a.enter("characterReferenceValue"),d=31,e=o3,j(b))}function i(b){return 88===b||120===b?(a.enter("characterReferenceMarkerHexadecimal"),a.consume(b),a.exit("characterReferenceMarkerHexadecimal"),a.enter("characterReferenceValue"),d=6,e=o6,j):(a.enter("characterReferenceValue"),d=7,e=o5,j(b))}function j(h){if(59===h&&g){let d=a.exit("characterReferenceValue");return e!==o3||pB(f.sliceSerialize(d))?(a.enter("characterReferenceMarker"),a.consume(h),a.exit("characterReferenceMarker"),a.exit("characterReference"),b):c(h)}return e(h)&&g++<d?(a.consume(h),j):c(h)}}},pD={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return null===b?c(b):(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e)};function e(a){return d.parser.lazy[d.now().line]?c(a):b(a)}}},pE={concrete:!0,name:"codeFenced",tokenize:function(a,b,c){let d,e=this,f={partial:!0,tokenize:function(a,b,c){let f=0;return function(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),g};function g(b){return a.enter("codeFencedFence"),pa(b)?pc(a,i,"linePrefix",e.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):i(b)}function i(b){return b===d?(a.enter("codeFencedFenceSequence"),function b(e){return e===d?(f++,a.consume(e),b):f>=h?(a.exit("codeFencedFenceSequence"),pa(e)?pc(a,j,"whitespace")(e):j(e)):c(e)}(b)):c(b)}function j(d){return null===d||o8(d)?(a.exit("codeFencedFence"),b(d)):c(d)}}},g=0,h=0;return function(b){var f;let j;return f=b,g=(j=e.events[e.events.length-1])&&"linePrefix"===j[1].type?j[2].sliceSerialize(j[1],!0).length:0,d=f,a.enter("codeFenced"),a.enter("codeFencedFence"),a.enter("codeFencedFenceSequence"),function b(e){return e===d?(h++,a.consume(e),b):h<3?c(e):(a.exit("codeFencedFenceSequence"),pa(e)?pc(a,i,"whitespace")(e):i(e))}(f)};function i(f){return null===f||o8(f)?(a.exit("codeFencedFence"),e.interrupt?b(f):a.check(pD,k,p)(f)):(a.enter("codeFencedFenceInfo"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||o8(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),i(e)):pa(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),pc(a,j,"whitespace")(e)):96===e&&e===d?c(e):(a.consume(e),b)}(f))}function j(b){return null===b||o8(b)?i(b):(a.enter("codeFencedFenceMeta"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||o8(e)?(a.exit("chunkString"),a.exit("codeFencedFenceMeta"),i(e)):96===e&&e===d?c(e):(a.consume(e),b)}(b))}function k(b){return a.attempt(f,p,l)(b)}function l(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),n}function n(b){return g>0&&pa(b)?pc(a,o,"linePrefix",g+1)(b):o(b)}function o(b){return null===b||o8(b)?a.check(pD,k,p)(b):(a.enter("codeFlowValue"),function b(c){return null===c||o8(c)?(a.exit("codeFlowValue"),o(c)):(a.consume(c),b)}(b))}function p(c){return a.exit("codeFenced"),b(c)}}},pF={name:"codeIndented",tokenize:function(a,b,c){let d=this;return function(b){return a.enter("codeIndented"),pc(a,e,"linePrefix",5)(b)};function e(b){let e=d.events[d.events.length-1];return e&&"linePrefix"===e[1].type&&e[2].sliceSerialize(e[1],!0).length>=4?function b(c){return null===c?f(c):o8(c)?a.attempt(pG,b,f)(c):(a.enter("codeFlowValue"),function c(d){return null===d||o8(d)?(a.exit("codeFlowValue"),b(d)):(a.consume(d),c)}(c))}(b):c(b)}function f(c){return a.exit("codeIndented"),b(c)}}},pG={partial:!0,tokenize:function(a,b,c){let d=this;return e;function e(b){return d.parser.lazy[d.now().line]?c(b):o8(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e):pc(a,f,"linePrefix",5)(b)}function f(a){let f=d.events[d.events.length-1];return f&&"linePrefix"===f[1].type&&f[2].sliceSerialize(f[1],!0).length>=4?b(a):o8(a)?e(a):c(a)}}};function pH(a){return null!==a&&(a<32||127===a)}function pI(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pJ(a,b,c,d,e,f,g,h,i){let j=i||1/0,k=0;return function(b){return 60===b?(a.enter(d),a.enter(e),a.enter(f),a.consume(b),a.exit(f),l):null===b||32===b||41===b||pH(b)?c(b):(a.enter(d),a.enter(g),a.enter(h),a.enter("chunkString",{contentType:"string"}),p(b))};function l(c){return 62===c?(a.enter(f),a.consume(c),a.exit(f),a.exit(e),a.exit(d),b):(a.enter(h),a.enter("chunkString",{contentType:"string"}),n(c))}function n(b){return 62===b?(a.exit("chunkString"),a.exit(h),l(b)):null===b||60===b||null!==b&&b<-2?c(b):(a.consume(b),92===b?o:n)}function o(b){return 60===b||62===b||92===b?(a.consume(b),n):n(b)}function p(e){return!k&&(null===e||41===e||null!==e&&(e<0||32===e))?(a.exit("chunkString"),a.exit(h),a.exit(g),a.exit(d),b(e)):k<j&&40===e?(a.consume(e),k++,p):41===e?(a.consume(e),k--,p):null===e||32===e||40===e||pH(e)?c(e):(a.consume(e),92===e?q:p)}function q(b){return 40===b||41===b||92===b?(a.consume(b),p):p(b)}}function pK(a){return null!==a&&a<-2}function pL(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pM(a,b,c,d,e,f){let g,h=this,i=0;return function(b){return a.enter(d),a.enter(e),a.consume(b),a.exit(e),a.enter(f),j};function j(l){return i>999||null===l||91===l||93===l&&!g||94===l&&!i&&"_hiddenFootnoteSupport"in h.parser.constructs?c(l):93===l?(a.exit(f),a.enter(e),a.consume(l),a.exit(e),a.exit(d),b):pK(l)?(a.enter("lineEnding"),a.consume(l),a.exit("lineEnding"),j):(a.enter("chunkString",{contentType:"string"}),k(l))}function k(b){return null===b||91===b||93===b||pK(b)||i++>999?(a.exit("chunkString"),j(b)):(a.consume(b),g||(g=-2!==b&&-1!==b&&32!==b),92===b?l:k)}function l(b){return 91===b||92===b||93===b?(a.consume(b),i++,k):k(b)}}function pN(a){return null!==a&&a<-2}function pO(a){return -2===a||-1===a||32===a}function pP(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pQ(a,b,c,d,e,f){let g;return function(b){return 34===b||39===b||40===b?(a.enter(d),a.enter(e),a.consume(b),a.exit(e),g=40===b?41:b,h):c(b)};function h(c){return c===g?(a.enter(e),a.consume(c),a.exit(e),a.exit(d),b):(a.enter(f),i(c))}function i(b){if(b===g)return a.exit(f),h(g);if(null===b)return c(b);if(pN(b)){var d,e;let c,f;return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),d=i,e="linePrefix",c=1/0,f=0,function(b){return pO(b)?(a.enter(e),function b(g){return pO(g)&&f++<c?(a.consume(g),b):(a.exit(e),d(g))}(b)):d(b)}}return a.enter("chunkString",{contentType:"string"}),j(b)}function j(b){return b===g||null===b||pN(b)?(a.exit("chunkString"),i(b)):(a.consume(b),92===b?k:j)}function k(b){return b===g||92===b?(a.consume(b),j):j(b)}}function pR(a){return -2===a||-1===a||32===a}function pS(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pT(a,b){let c;return function d(e){var f,g;if(null!==e&&e<-2)return a.enter("lineEnding"),a.consume(e),a.exit("lineEnding"),c=!0,d;if(pR(e)){let b,h;return(f=d,g=c?"linePrefix":"lineSuffix",b=1/0,h=0,function(c){return pR(c)?(a.enter(g),function c(d){return pR(d)&&h++<b?(a.consume(d),c):(a.exit(g),f(d))}(c)):f(c)})(e)}return b(e)}}function pU(a){return a.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}pI(/[A-Za-z]/),pI(/[\dA-Za-z]/),pI(/[#-'*+\--9=?A-Z^-~]/),pI(/\d/),pI(/[\dA-Fa-f]/),pI(/[!-/:-@[-`{-~]/),pI(/\p{P}|\p{S}/u),pI(/\s/),pL(/[A-Za-z]/),pL(/[\dA-Za-z]/),pL(/[#-'*+\--9=?A-Z^-~]/),pL(/\d/),pL(/[\dA-Fa-f]/),pL(/[!-/:-@[-`{-~]/),pL(/\p{P}|\p{S}/u),pL(/\s/),pP(/[A-Za-z]/),pP(/[\dA-Za-z]/),pP(/[#-'*+\--9=?A-Z^-~]/),pP(/\d/),pP(/[\dA-Fa-f]/),pP(/[!-/:-@[-`{-~]/),pP(/\p{P}|\p{S}/u),pP(/\s/),pS(/[A-Za-z]/),pS(/[\dA-Za-z]/),pS(/[#-'*+\--9=?A-Z^-~]/),pS(/\d/),pS(/[\dA-Fa-f]/),pS(/[!-/:-@[-`{-~]/),pS(/\p{P}|\p{S}/u),pS(/\s/);let pV={partial:!0,tokenize:function(a,b,c){return function(b){return o9(b)?pT(a,d)(b):c(b)};function d(b){return pQ(a,e,c,"definitionTitle","definitionTitleMarker","definitionTitleString")(b)}function e(b){return pa(b)?pc(a,f,"whitespace")(b):f(b)}function f(a){return null===a||o8(a)?b(a):c(a)}}},pW=["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"],pX=["pre","script","style","textarea"],pY={partial:!0,tokenize:function(a,b,c){return function(d){return a.enter("lineEnding"),a.consume(d),a.exit("lineEnding"),a.attempt(pd,b,c)}}},pZ={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return o8(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e):c(b)};function e(a){return d.parser.lazy[d.now().line]?c(a):b(a)}}},p$={name:"labelEnd",resolveAll:function(a){let b=-1,c=[];for(;++b<a.length;){let d=a[b][1];if(c.push(a[b]),"labelImage"===d.type||"labelLink"===d.type||"labelEnd"===d.type){let a="labelImage"===d.type?4:2;d.type="data",b+=a}}return a.length!==c.length&&oT(a,0,a.length,c),a},resolveTo:function(a,b){let c,d,e,f,g=a.length,h=0;for(;g--;)if(c=a[g][1],d){if("link"===c.type||"labelLink"===c.type&&c._inactive)break;"enter"===a[g][0]&&"labelLink"===c.type&&(c._inactive=!0)}else if(e){if("enter"===a[g][0]&&("labelImage"===c.type||"labelLink"===c.type)&&!c._balanced&&(d=g,"labelLink"!==c.type)){h=2;break}}else"labelEnd"===c.type&&(e=g);let i={type:"labelLink"===a[d][1].type?"link":"image",start:{...a[d][1].start},end:{...a[a.length-1][1].end}},j={type:"label",start:{...a[d][1].start},end:{...a[e][1].end}},k={type:"labelText",start:{...a[d+h+2][1].end},end:{...a[e-2][1].start}};return f=oU(f=[["enter",i,b],["enter",j,b]],a.slice(d+1,d+h+3)),f=oU(f,[["enter",k,b]]),f=oU(f,pu(b.parser.constructs.insideSpan.null,a.slice(d+h+4,e-3),b)),f=oU(f,[["exit",k,b],a[e-2],a[e-1],["exit",j,b]]),f=oU(f,a.slice(e+1)),f=oU(f,[["exit",i,b]]),oT(a,d,a.length,f),a},tokenize:function(a,b,c){let d,e,f=this,g=f.events.length;for(;g--;)if(("labelImage"===f.events[g][1].type||"labelLink"===f.events[g][1].type)&&!f.events[g][1]._balanced){d=f.events[g][1];break}return function(b){return d?d._inactive?k(b):(e=f.parser.defined.includes(pU(f.sliceSerialize({start:d.end,end:f.now()}))),a.enter("labelEnd"),a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelEnd"),h):c(b)};function h(b){return 40===b?a.attempt(p_,j,e?j:k)(b):91===b?a.attempt(p0,j,e?i:k)(b):e?j(b):k(b)}function i(b){return a.attempt(p1,j,k)(b)}function j(a){return b(a)}function k(a){return d._balanced=!0,c(a)}}},p_={tokenize:function(a,b,c){return function(b){return a.enter("resource"),a.enter("resourceMarker"),a.consume(b),a.exit("resourceMarker"),d};function d(b){return o9(b)?pT(a,e)(b):e(b)}function e(b){return 41===b?j(b):pJ(a,f,g,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function f(b){return o9(b)?pT(a,h)(b):j(b)}function g(a){return c(a)}function h(b){return 34===b||39===b||40===b?pQ(a,i,c,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):j(b)}function i(b){return o9(b)?pT(a,j)(b):j(b)}function j(d){return 41===d?(a.enter("resourceMarker"),a.consume(d),a.exit("resourceMarker"),a.exit("resource"),b):c(d)}}},p0={tokenize:function(a,b,c){let d=this;return function(b){return pM.call(d,a,e,f,"reference","referenceMarker","referenceString")(b)};function e(a){return d.parser.defined.includes(pU(d.sliceSerialize(d.events[d.events.length-1][1]).slice(1,-1)))?b(a):c(a)}function f(a){return c(a)}}},p1={tokenize:function(a,b,c){return function(b){return a.enter("reference"),a.enter("referenceMarker"),a.consume(b),a.exit("referenceMarker"),d};function d(d){return 93===d?(a.enter("referenceMarker"),a.consume(d),a.exit("referenceMarker"),a.exit("reference"),b):c(d)}}},p2={name:"labelStartImage",resolveAll:p$.resolveAll,tokenize:function(a,b,c){let d=this;return function(b){return a.enter("labelImage"),a.enter("labelImageMarker"),a.consume(b),a.exit("labelImageMarker"),e};function e(b){return 91===b?(a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelImage"),f):c(b)}function f(a){return 94===a&&"_hiddenFootnoteSupport"in d.parser.constructs?c(a):b(a)}}},p3={name:"labelStartLink",resolveAll:p$.resolveAll,tokenize:function(a,b,c){let d=this;return function(b){return a.enter("labelLink"),a.enter("labelMarker"),a.consume(b),a.exit("labelMarker"),a.exit("labelLink"),e};function e(a){return 94===a&&"_hiddenFootnoteSupport"in d.parser.constructs?c(a):b(a)}}},p4={name:"lineEnding",tokenize:function(a,b){return function(c){return a.enter("lineEnding"),a.consume(c),a.exit("lineEnding"),pc(a,b,"linePrefix")}}},p5={name:"thematicBreak",tokenize:function(a,b,c){let d,e=0;return function(f){var g;return a.enter("thematicBreak"),d=g=f,function f(g){return g===d?(a.enter("thematicBreakSequence"),function b(c){return c===d?(a.consume(c),e++,b):(a.exit("thematicBreakSequence"),pa(c)?pc(a,f,"whitespace")(c):f(c))}(g)):e>=3&&(null===g||o8(g))?(a.exit("thematicBreak"),b(g)):c(g)}(g)}}},p6={continuation:{tokenize:function(a,b,c){let d=this;return d.containerState._closeFlow=void 0,a.check(pd,function(c){return d.containerState.furtherBlankLines=d.containerState.furtherBlankLines||d.containerState.initialBlankLine,pc(a,b,"listItemIndent",d.containerState.size+1)(c)},function(c){return d.containerState.furtherBlankLines||!pa(c)?(d.containerState.furtherBlankLines=void 0,d.containerState.initialBlankLine=void 0,e(c)):(d.containerState.furtherBlankLines=void 0,d.containerState.initialBlankLine=void 0,a.attempt(p8,b,e)(c))});function e(e){return d.containerState._closeFlow=!0,d.interrupt=void 0,pc(a,a.attempt(p6,b,c),"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(e)}}},exit:function(a){a.exit(this.containerState.type)},name:"list",tokenize:function(a,b,c){let d=this,e=d.events[d.events.length-1],f=e&&"linePrefix"===e[1].type?e[2].sliceSerialize(e[1],!0).length:0,g=0;return function(b){let e=d.containerState.type||(42===b||43===b||45===b?"listUnordered":"listOrdered");if("listUnordered"===e?!d.containerState.marker||b===d.containerState.marker:o5(b)){if(d.containerState.type||(d.containerState.type=e,a.enter(e,{_container:!0})),"listUnordered"===e)return a.enter("listItemPrefix"),42===b||45===b?a.check(p5,c,h)(b):h(b);if(!d.interrupt||49===b)return a.enter("listItemPrefix"),a.enter("listItemValue"),function b(e){return o5(e)&&++g<10?(a.consume(e),b):(!d.interrupt||g<2)&&(d.containerState.marker?e===d.containerState.marker:41===e||46===e)?(a.exit("listItemValue"),h(e)):c(e)}(b)}return c(b)};function h(b){return a.enter("listItemMarker"),a.consume(b),a.exit("listItemMarker"),d.containerState.marker=d.containerState.marker||b,a.check(pd,d.interrupt?c:i,a.attempt(p7,k,j))}function i(a){return d.containerState.initialBlankLine=!0,f++,k(a)}function j(b){return pa(b)?(a.enter("listItemPrefixWhitespace"),a.consume(b),a.exit("listItemPrefixWhitespace"),k):c(b)}function k(c){return d.containerState.size=f+d.sliceSerialize(a.exit("listItemPrefix"),!0).length,b(c)}}},p7={partial:!0,tokenize:function(a,b,c){let d=this;return pc(a,function(a){let e=d.events[d.events.length-1];return!pa(a)&&e&&"listItemPrefixWhitespace"===e[1].type?b(a):c(a)},"listItemPrefixWhitespace",d.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},p8={partial:!0,tokenize:function(a,b,c){let d=this;return pc(a,function(a){let e=d.events[d.events.length-1];return e&&"listItemIndent"===e[1].type&&e[2].sliceSerialize(e[1],!0).length===d.containerState.size?b(a):c(a)},"listItemIndent",d.containerState.size+1)}},p9={name:"setextUnderline",resolveTo:function(a,b){let c,d,e,f=a.length;for(;f--;)if("enter"===a[f][0]){if("content"===a[f][1].type){c=f;break}"paragraph"===a[f][1].type&&(d=f)}else"content"===a[f][1].type&&a.splice(f,1),e||"definition"!==a[f][1].type||(e=f);let g={type:"setextHeading",start:{...a[c][1].start},end:{...a[a.length-1][1].end}};return a[d][1].type="setextHeadingText",e?(a.splice(d,0,["enter",g,b]),a.splice(e+1,0,["exit",a[c][1],b]),a[c][1].end={...a[e][1].end}):a[c][1]=g,a.push(["exit",g,b]),a},tokenize:function(a,b,c){let d,e=this;return function(b){var g;let h,i=e.events.length;for(;i--;)if("lineEnding"!==e.events[i][1].type&&"linePrefix"!==e.events[i][1].type&&"content"!==e.events[i][1].type){h="paragraph"===e.events[i][1].type;break}return!e.parser.lazy[e.now().line]&&(e.interrupt||h)?(a.enter("setextHeadingLine"),d=b,g=b,a.enter("setextHeadingLineSequence"),function b(c){return c===d?(a.consume(c),b):(a.exit("setextHeadingLineSequence"),pa(c)?pc(a,f,"lineSuffix")(c):f(c))}(g)):c(b)};function f(d){return null===d||o8(d)?(a.exit("setextHeadingLine"),b(d)):c(d)}}};a.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(a,b,c){let d,e=this;return function(b){var d;return a.enter("definition"),d=b,pM.call(e,a,f,c,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)};function f(b){return(d=pU(e.sliceSerialize(e.events[e.events.length-1][1]).slice(1,-1)),58===b)?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),g):c(b)}function g(b){return o9(b)?pT(a,h)(b):h(b)}function h(b){return pJ(a,i,c,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function i(b){return a.attempt(pV,j,j)(b)}function j(b){return pa(b)?pc(a,k,"whitespace")(b):k(b)}function k(f){return null===f||o8(f)?(a.exit("definition"),e.parser.defined.push(d),b(f)):c(f)}}}},"disable",0,{null:[]},"document",0,{42:p6,43:p6,45:p6,48:p6,49:p6,50:p6,51:p6,52:p6,53:p6,54:p6,55:p6,56:p6,57:p6,62:px},"flow",0,{35:{name:"headingAtx",resolve:function(a,b){let c,d,e=a.length-2,f=3;return"whitespace"===a[3][1].type&&(f+=2),e-2>f&&"whitespace"===a[e][1].type&&(e-=2),"atxHeadingSequence"===a[e][1].type&&(f===e-1||e-4>f&&"whitespace"===a[e-2][1].type)&&(e-=f+1===e?2:4),e>f&&(c={type:"atxHeadingText",start:a[f][1].start,end:a[e][1].end},d={type:"chunkText",start:a[f][1].start,end:a[e][1].end,contentType:"text"},oT(a,f,e-f+1,[["enter",c,b],["enter",d,b],["exit",d,b],["exit",c,b]])),a},tokenize:function(a,b,c){let d=0;return function(e){var f;return a.enter("atxHeading"),f=e,a.enter("atxHeadingSequence"),function e(f){return 35===f&&d++<6?(a.consume(f),e):null===f||o9(f)?(a.exit("atxHeadingSequence"),function c(d){return 35===d?(a.enter("atxHeadingSequence"),function b(d){return 35===d?(a.consume(d),b):(a.exit("atxHeadingSequence"),c(d))}(d)):null===d||o8(d)?(a.exit("atxHeading"),b(d)):pa(d)?pc(a,c,"whitespace")(d):(a.enter("atxHeadingText"),function b(d){return null===d||35===d||o9(d)?(a.exit("atxHeadingText"),c(d)):(a.consume(d),b)}(d))}(f)):c(f)}(f)}}},42:p5,45:[p9,p5],60:{concrete:!0,name:"htmlFlow",resolveTo:function(a){let b=a.length;for(;b--&&("enter"!==a[b][0]||"htmlFlow"!==a[b][1].type););return b>1&&"linePrefix"===a[b-2][1].type&&(a[b][1].start=a[b-2][1].start,a[b+1][1].start=a[b-2][1].start,a.splice(b-2,2)),a},tokenize:function(a,b,c){let d,e,f,g,h,i=this;return function(b){var c;return c=b,a.enter("htmlFlow"),a.enter("htmlFlowData"),a.consume(c),j};function j(g){return 33===g?(a.consume(g),k):47===g?(a.consume(g),e=!0,o):63===g?(a.consume(g),d=3,i.interrupt?b:H):o2(g)?(a.consume(g),f=String.fromCharCode(g),p):c(g)}function k(e){return 45===e?(a.consume(e),d=2,l):91===e?(a.consume(e),d=5,g=0,n):o2(e)?(a.consume(e),d=4,i.interrupt?b:H):c(e)}function l(d){return 45===d?(a.consume(d),i.interrupt?b:H):c(d)}function n(d){let e="CDATA[";return d===e.charCodeAt(g++)?(a.consume(d),g===e.length)?i.interrupt?b:z:n:c(d)}function o(b){return o2(b)?(a.consume(b),f=String.fromCharCode(b),p):c(b)}function p(g){if(null===g||47===g||62===g||o9(g)){let h=47===g,j=f.toLowerCase();return!h&&!e&&pX.includes(j)?(d=1,i.interrupt?b(g):z(g)):pW.includes(f.toLowerCase())?(d=6,h)?(a.consume(g),q):i.interrupt?b(g):z(g):(d=7,i.interrupt&&!i.parser.lazy[i.now().line]?c(g):e?function b(c){return pa(c)?(a.consume(c),b):x(c)}(g):r(g))}return 45===g||o3(g)?(a.consume(g),f+=String.fromCharCode(g),p):c(g)}function q(d){return 62===d?(a.consume(d),i.interrupt?b:z):c(d)}function r(b){return 47===b?(a.consume(b),x):58===b||95===b||o2(b)?(a.consume(b),s):pa(b)?(a.consume(b),r):x(b)}function s(b){return 45===b||46===b||58===b||95===b||o3(b)?(a.consume(b),s):t(b)}function t(b){return 61===b?(a.consume(b),u):pa(b)?(a.consume(b),t):r(b)}function u(b){return null===b||60===b||61===b||62===b||96===b?c(b):34===b||39===b?(a.consume(b),h=b,v):pa(b)?(a.consume(b),u):function b(c){return null===c||34===c||39===c||47===c||60===c||61===c||62===c||96===c||o9(c)?t(c):(a.consume(c),b)}(b)}function v(b){return b===h?(a.consume(b),h=null,w):null===b||o8(b)?c(b):(a.consume(b),v)}function w(a){return 47===a||62===a||pa(a)?r(a):c(a)}function x(b){return 62===b?(a.consume(b),y):c(b)}function y(b){return null===b||o8(b)?z(b):pa(b)?(a.consume(b),y):c(b)}function z(b){return 45===b&&2===d?(a.consume(b),D):60===b&&1===d?(a.consume(b),E):62===b&&4===d?(a.consume(b),I):63===b&&3===d?(a.consume(b),H):93===b&&5===d?(a.consume(b),G):o8(b)&&(6===d||7===d)?(a.exit("htmlFlowData"),a.check(pY,J,A)(b)):null===b||o8(b)?(a.exit("htmlFlowData"),A(b)):(a.consume(b),z)}function A(b){return a.check(pZ,B,J)(b)}function B(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),C}function C(b){return null===b||o8(b)?A(b):(a.enter("htmlFlowData"),z(b))}function D(b){return 45===b?(a.consume(b),H):z(b)}function E(b){return 47===b?(a.consume(b),f="",F):z(b)}function F(b){if(62===b){let c=f.toLowerCase();return pX.includes(c)?(a.consume(b),I):z(b)}return o2(b)&&f.length<8?(a.consume(b),f+=String.fromCharCode(b),F):z(b)}function G(b){return 93===b?(a.consume(b),H):z(b)}function H(b){return 62===b?(a.consume(b),I):45===b&&2===d?(a.consume(b),H):z(b)}function I(b){return null===b||o8(b)?(a.exit("htmlFlowData"),J(b)):(a.consume(b),I)}function J(c){return a.exit("htmlFlow"),b(c)}}},61:p9,95:p5,96:pE,126:pE},"flowInitial",0,{[-2]:pF,[-1]:pF,32:pF},"insideSpan",0,{null:[pv,pk]},"string",0,{38:pC,92:py},"text",0,{[-5]:p4,[-4]:p4,[-3]:p4,33:p2,38:pC,42:pv,60:[{name:"autolink",tokenize:function(a,b,c){let d=0;return function(b){return a.enter("autolink"),a.enter("autolinkMarker"),a.consume(b),a.exit("autolinkMarker"),a.enter("autolinkProtocol"),e};function e(b){return o2(b)?(a.consume(b),f):64===b?c(b):h(b)}function f(b){return 43===b||45===b||46===b||o3(b)?(d=1,function b(c){return 58===c?(a.consume(c),d=0,g):(43===c||45===c||46===c||o3(c))&&d++<32?(a.consume(c),b):(d=0,h(c))}(b)):h(b)}function g(d){return 62===d?(a.exit("autolinkProtocol"),a.enter("autolinkMarker"),a.consume(d),a.exit("autolinkMarker"),a.exit("autolink"),b):null===d||32===d||60===d||null!==d&&(d<32||127===d)?c(d):(a.consume(d),g)}function h(b){return 64===b?(a.consume(b),i):o4(b)?(a.consume(b),h):c(b)}function i(e){return o3(e)?function e(f){return 46===f?(a.consume(f),d=0,i):62===f?(a.exit("autolinkProtocol").type="autolinkEmail",a.enter("autolinkMarker"),a.consume(f),a.exit("autolinkMarker"),a.exit("autolink"),b):function b(f){if((45===f||o3(f))&&d++<63){let c=45===f?b:e;return a.consume(f),c}return c(f)}(f)}(e):c(e)}}},{name:"htmlText",tokenize:function(a,b,c){let d,e,f,g=this;return function(b){return a.enter("htmlText"),a.enter("htmlTextData"),a.consume(b),h};function h(b){return 33===b?(a.consume(b),i):47===b?(a.consume(b),v):63===b?(a.consume(b),t):o2(b)?(a.consume(b),x):c(b)}function i(b){return 45===b?(a.consume(b),j):91===b?(a.consume(b),e=0,o):o2(b)?(a.consume(b),s):c(b)}function j(b){return 45===b?(a.consume(b),n):c(b)}function k(b){return null===b?c(b):45===b?(a.consume(b),l):o8(b)?(f=k,F(b)):(a.consume(b),k)}function l(b){return 45===b?(a.consume(b),n):k(b)}function n(a){return 62===a?E(a):45===a?l(a):k(a)}function o(b){let d="CDATA[";return b===d.charCodeAt(e++)?(a.consume(b),e===d.length?p:o):c(b)}function p(b){return null===b?c(b):93===b?(a.consume(b),q):o8(b)?(f=p,F(b)):(a.consume(b),p)}function q(b){return 93===b?(a.consume(b),r):p(b)}function r(b){return 62===b?E(b):93===b?(a.consume(b),r):p(b)}function s(b){return null===b||62===b?E(b):o8(b)?(f=s,F(b)):(a.consume(b),s)}function t(b){return null===b?c(b):63===b?(a.consume(b),u):o8(b)?(f=t,F(b)):(a.consume(b),t)}function u(a){return 62===a?E(a):t(a)}function v(b){return o2(b)?(a.consume(b),w):c(b)}function w(b){return 45===b||o3(b)?(a.consume(b),w):function b(c){return o8(c)?(f=b,F(c)):pa(c)?(a.consume(c),b):E(c)}(b)}function x(b){return 45===b||o3(b)?(a.consume(b),x):47===b||62===b||o9(b)?y(b):c(b)}function y(b){return 47===b?(a.consume(b),E):58===b||95===b||o2(b)?(a.consume(b),z):o8(b)?(f=y,F(b)):pa(b)?(a.consume(b),y):E(b)}function z(b){return 45===b||46===b||58===b||95===b||o3(b)?(a.consume(b),z):function b(c){return 61===c?(a.consume(c),A):o8(c)?(f=b,F(c)):pa(c)?(a.consume(c),b):y(c)}(b)}function A(b){return null===b||60===b||61===b||62===b||96===b?c(b):34===b||39===b?(a.consume(b),d=b,B):o8(b)?(f=A,F(b)):pa(b)?(a.consume(b),A):(a.consume(b),C)}function B(b){return b===d?(a.consume(b),d=void 0,D):null===b?c(b):o8(b)?(f=B,F(b)):(a.consume(b),B)}function C(b){return null===b||34===b||39===b||60===b||61===b||96===b?c(b):47===b||62===b||o9(b)?y(b):(a.consume(b),C)}function D(a){return 47===a||62===a||o9(a)?y(a):c(a)}function E(d){return 62===d?(a.consume(d),a.exit("htmlTextData"),a.exit("htmlText"),b):c(d)}function F(b){return a.exit("htmlTextData"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),G}function G(b){return pa(b)?pc(a,H,"linePrefix",g.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):H(b)}function H(b){return a.enter("htmlTextData"),f(b)}}}],91:p3,92:[{name:"hardBreakEscape",tokenize:function(a,b,c){return function(b){return a.enter("hardBreakEscape"),a.consume(b),d};function d(d){return o8(d)?(a.exit("hardBreakEscape"),b(d)):c(d)}}},py],93:p$,95:pv,96:{name:"codeText",previous:function(a){return 96!==a||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(a){let b,c,d=a.length-4,e=3;if(("lineEnding"===a[3][1].type||"space"===a[e][1].type)&&("lineEnding"===a[d][1].type||"space"===a[d][1].type)){for(b=e;++b<d;)if("codeTextData"===a[b][1].type){a[e][1].type="codeTextPadding",a[d][1].type="codeTextPadding",e+=2,d-=2;break}}for(b=e-1,d++;++b<=d;)void 0===c?b!==d&&"lineEnding"!==a[b][1].type&&(c=b):(b===d||"lineEnding"===a[b][1].type)&&(a[c][1].type="codeTextData",b!==c+2&&(a[c][1].end=a[b-1][1].end,a.splice(c+2,b-c-2),d-=b-c-2,b=c+2),c=void 0);return a},tokenize:function(a,b,c){let d,e,f=0;return function(b){return a.enter("codeText"),a.enter("codeTextSequence"),function b(c){return 96===c?(a.consume(c),f++,b):(a.exit("codeTextSequence"),g(c))}(b)};function g(i){return null===i?c(i):32===i?(a.enter("space"),a.consume(i),a.exit("space"),g):96===i?(e=a.enter("codeTextSequence"),d=0,function c(g){return 96===g?(a.consume(g),d++,c):d===f?(a.exit("codeTextSequence"),a.exit("codeText"),b(g)):(e.type="codeTextData",h(g))}(i)):o8(i)?(a.enter("lineEnding"),a.consume(i),a.exit("lineEnding"),g):(a.enter("codeTextData"),h(i))}function h(b){return null===b||32===b||96===b||o8(b)?(a.exit("codeTextData"),g(b)):(a.consume(b),h)}}}}],48293);var qa=a.i(48293);let qb=/[\0\t\n\r]/g;function qc(a,b){let c=Number.parseInt(a,b);return c<9||11===c||c>13&&c<32||c>126&&c<160||c>55295&&c<57344||c>64975&&c<65008||(65535&c)==65535||(65535&c)==65534||c>1114111?"�":String.fromCodePoint(c)}let qd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function qe(a,b,c){if(b)return b;if(35===c.charCodeAt(0)){let a=c.charCodeAt(1),b=120===a||88===a;return qc(c.slice(b?2:1),b?16:10)}return pB(c)||a}let qf={}.hasOwnProperty;function qg(a){return{line:a.line,column:a.column,offset:a.offset}}function qh(a,b){if(a)throw Error("Cannot close `"+a.type+"` ("+ow({start:a.start,end:a.end})+"): a different token (`"+b.type+"`, "+ow({start:b.start,end:b.end})+") is open");throw Error("Cannot close document, a token (`"+b.type+"`, "+ow({start:b.start,end:b.end})+") is still open")}function qi(a){let b=this;b.parser=function(c){var d,e;let f,g,h,i;return"string"!=typeof(d={...b.data("settings"),...a,extensions:b.data("micromarkExtensions")||[],mdastExtensions:b.data("fromMarkdownExtensions")||[]})&&(e=d,d=void 0),(function(a){let b={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(s),autolinkProtocol:j,autolinkEmail:j,atxHeading:d(p),blockQuote:d(function(){return{type:"blockquote",children:[]}}),characterEscape:j,characterReference:j,codeFenced:d(o),codeFencedFenceInfo:e,codeFencedFenceMeta:e,codeIndented:d(o,e),codeText:d(function(){return{type:"inlineCode",value:""}},e),codeTextData:j,data:j,codeFlowValue:j,definition:d(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:e,definitionLabelString:e,definitionTitleString:e,emphasis:d(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:d(q),hardBreakTrailing:d(q),htmlFlow:d(r,e),htmlFlowData:j,htmlText:d(r,e),htmlTextData:j,image:d(function(){return{type:"image",title:null,url:"",alt:null}}),label:e,link:d(s),listItem:d(function(a){return{type:"listItem",spread:a._spread,checked:null,children:[]}}),listItemValue:function(a){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(a),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:d(t,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:d(t),paragraph:d(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:e,resourceDestinationString:e,resourceTitleString:e,setextHeading:d(p),strong:d(function(){return{type:"strong",children:[]}}),thematicBreak:d(function(){return{type:"thematicBreak"}})},exit:{atxHeading:g(),atxHeadingSequence:function(a){let b=this.stack[this.stack.length-1];b.depth||(b.depth=this.sliceSerialize(a).length)},autolink:g(),autolinkEmail:function(a){k.call(this,a),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(a)},autolinkProtocol:function(a){k.call(this,a),this.stack[this.stack.length-1].url=this.sliceSerialize(a)},blockQuote:g(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:n,characterReferenceMarkerNumeric:n,characterReferenceValue:function(a){let b,c=this.sliceSerialize(a),d=this.data.characterReferenceType;d?(b=qc(c,"characterReferenceMarkerNumeric"===d?10:16),this.data.characterReferenceType=void 0):b=pB(c);let e=this.stack[this.stack.length-1];e.value+=b},characterReference:function(a){this.stack.pop().position.end=qg(a.end)},codeFenced:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let a=this.resume();this.stack[this.stack.length-1].lang=a},codeFencedFenceMeta:function(){let a=this.resume();this.stack[this.stack.length-1].meta=a},codeFlowValue:k,codeIndented:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a.replace(/(\r?\n|\r)$/g,"")}),codeText:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),codeTextData:k,data:k,definition:g(),definitionDestinationString:function(){let a=this.resume();this.stack[this.stack.length-1].url=a},definitionLabelString:function(a){let b=this.resume(),c=this.stack[this.stack.length-1];c.label=b,c.identifier=pU(this.sliceSerialize(a)).toLowerCase()},definitionTitleString:function(){let a=this.resume();this.stack[this.stack.length-1].title=a},emphasis:g(),hardBreakEscape:g(l),hardBreakTrailing:g(l),htmlFlow:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),htmlFlowData:k,htmlText:g(function(){let a=this.resume();this.stack[this.stack.length-1].value=a}),htmlTextData:k,image:g(function(){let a=this.stack[this.stack.length-1];if(this.data.inReference){let b=this.data.referenceType||"shortcut";a.type+="Reference",a.referenceType=b,delete a.url,delete a.title}else delete a.identifier,delete a.label;this.data.referenceType=void 0}),label:function(){let a=this.stack[this.stack.length-1],b=this.resume(),c=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===c.type?c.children=a.children:c.alt=b},labelText:function(a){let b=this.sliceSerialize(a),c=this.stack[this.stack.length-2];c.label=b.replace(qd,qe),c.identifier=pU(b).toLowerCase()},lineEnding:function(a){let c=this.stack[this.stack.length-1];if(this.data.atHardBreak){c.children[c.children.length-1].position.end=qg(a.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&b.canContainEols.includes(c.type)&&(j.call(this,a),k.call(this,a))},link:g(function(){let a=this.stack[this.stack.length-1];if(this.data.inReference){let b=this.data.referenceType||"shortcut";a.type+="Reference",a.referenceType=b,delete a.url,delete a.title}else delete a.identifier,delete a.label;this.data.referenceType=void 0}),listItem:g(),listOrdered:g(),listUnordered:g(),paragraph:g(),referenceString:function(a){let b=this.resume(),c=this.stack[this.stack.length-1];c.label=b,c.identifier=pU(this.sliceSerialize(a)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let a=this.resume();this.stack[this.stack.length-1].url=a},resourceTitleString:function(){let a=this.resume();this.stack[this.stack.length-1].title=a},resource:function(){this.data.inReference=void 0},setextHeading:g(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(a){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(a).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:g(),thematicBreak:g()}};!function a(b,c){let d=-1;for(;++d<c.length;){let e=c[d];Array.isArray(e)?a(b,e):function(a,b){let c;for(c in b)if(qf.call(b,c))switch(c){case"canContainEols":{let d=b[c];d&&a[c].push(...d);break}case"transforms":{let d=b[c];d&&a[c].push(...d);break}case"enter":case"exit":{let d=b[c];d&&Object.assign(a[c],d)}}}(b,e)}}(b,(a||{}).mdastExtensions||[]);let c={};return function(a){let d={type:"root",children:[]},g={stack:[d],tokenStack:[],config:b,enter:f,exit:h,buffer:e,resume:i,data:c},j=[],k=-1;for(;++k<a.length;)("listOrdered"===a[k][1].type||"listUnordered"===a[k][1].type)&&("enter"===a[k][0]?j.push(k):k=function(a,b,c){let d,e,f,g,h=b-1,i=-1,j=!1;for(;++h<=c;){let b=a[h];switch(b[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===b[0]?i++:i--,g=void 0;break;case"lineEndingBlank":"enter"===b[0]&&(!d||g||i||f||(f=h),g=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:g=void 0}if(!i&&"enter"===b[0]&&"listItemPrefix"===b[1].type||-1===i&&"exit"===b[0]&&("listUnordered"===b[1].type||"listOrdered"===b[1].type)){if(d){let g=h;for(e=void 0;g--;){let b=a[g];if("lineEnding"===b[1].type||"lineEndingBlank"===b[1].type){if("exit"===b[0])continue;e&&(a[e][1].type="lineEndingBlank",j=!0),b[1].type="lineEnding",e=g}else if("linePrefix"===b[1].type||"blockQuotePrefix"===b[1].type||"blockQuotePrefixWhitespace"===b[1].type||"blockQuoteMarker"===b[1].type||"listItemIndent"===b[1].type);else break}f&&(!e||f<e)&&(d._spread=!0),d.end=Object.assign({},e?a[e][1].start:b[1].end),a.splice(e||h,0,["exit",d,b[2]]),h++,c++}if("listItemPrefix"===b[1].type){let e={type:"listItem",_spread:!1,start:Object.assign({},b[1].start),end:void 0};d=e,a.splice(h,0,["enter",e,b[2]]),h++,c++,f=void 0,g=!0}}}return a[b][1]._spread=j,c}(a,j.pop(),k));for(k=-1;++k<a.length;){let c=b[a[k][0]];qf.call(c,a[k][1].type)&&c[a[k][1].type].call(Object.assign({sliceSerialize:a[k][2].sliceSerialize},g),a[k][1])}if(g.tokenStack.length>0){let a=g.tokenStack[g.tokenStack.length-1];(a[1]||qh).call(g,void 0,a[0])}for(d.position={start:qg(a.length>0?a[0][1].start:{line:1,column:1,offset:0}),end:qg(a.length>0?a[a.length-2][1].end:{line:1,column:1,offset:0})},k=-1;++k<b.transforms.length;)d=b.transforms[k](d)||d;return d};function d(a,b){return function(c){f.call(this,a(c),c),b&&b.call(this,c)}}function e(){this.stack.push({type:"fragment",children:[]})}function f(a,b,c){this.stack[this.stack.length-1].children.push(a),this.stack.push(a),this.tokenStack.push([b,c||void 0]),a.position={start:qg(b.start),end:void 0}}function g(a){return function(b){a&&a.call(this,b),h.call(this,b)}}function h(a,b){let c=this.stack.pop(),d=this.tokenStack.pop();if(d)d[0].type!==a.type&&(b?b.call(this,a,d[0]):(d[1]||qh).call(this,a,d[0]));else throw Error("Cannot close `"+a.type+"` ("+ow({start:a.start,end:a.end})+"): it’s not open");c.position.end=qg(a.end)}function i(){return oQ(this.stack.pop())}function j(a){let b=this.stack[this.stack.length-1].children,c=b[b.length-1];c&&"text"===c.type||((c={type:"text",value:""}).position={start:qg(a.start),end:void 0},b.push(c)),this.stack.push(c)}function k(a){let b=this.stack.pop();b.value+=this.sliceSerialize(a),b.position.end=qg(a.end)}function l(){this.data.atHardBreak=!0}function n(a){this.data.characterReferenceType=a.type}function o(){return{type:"code",lang:null,meta:null,value:""}}function p(){return{type:"heading",depth:0,children:[]}}function q(){return{type:"break"}}function r(){return{type:"html",value:""}}function s(){return{type:"link",title:null,url:"",children:[]}}function t(a){return{type:"list",ordered:"listOrdered"===a.type,start:null,spread:a._spread,children:[]}}})(e)(function(a){for(;!pg(a););return a}((function(a){let b={constructs:oW([qa,...(a||{}).extensions||[]]),content:c(o_),defined:[],document:c(o0),flow:c(pj),lazy:{},string:c(pl),text:c(pm)};return b;function c(a){return function(c){return function(a,b,c){let d={_bufferIndex:-1,_index:0,line:c&&c.line||1,column:c&&c.column||1,offset:c&&c.offset||0},e={},f=[],g=[],h=[],i={attempt:p(function(a,b){q(a,b.from)}),check:p(o),consume:function(a){oX(a)?(d.line++,d.column=1,d.offset+=-3===a?2:1,r()):-1!==a&&(d.column++,d.offset++),d._bufferIndex<0?d._index++:(d._bufferIndex++,d._bufferIndex===g[d._index].length&&(d._bufferIndex=-1,d._index++)),j.previous=a},enter:function(a,b){let c=b||{};return c.type=a,c.start=n(),j.events.push(["enter",c,j]),h.push(c),c},exit:function(a){let b=h.pop();return b.end=n(),j.events.push(["exit",b,j]),b},interrupt:p(o,{interrupt:!0})},j={code:null,containerState:{},defineSkip:function(a){e[a.line]=a.column,r()},events:[],now:n,parser:a,previous:null,sliceSerialize:function(a,b){return function(a,b){let c,d=-1,e=[];for(;++d<a.length;){let f,g=a[d];if("string"==typeof g)f=g;else switch(g){case -5:f="\r";break;case -4:f="\n";break;case -3:f="\r\n";break;case -2:f=b?" ":" ";break;case -1:if(!b&&c)continue;f=" ";break;default:f=String.fromCharCode(g)}c=-2===g,e.push(f)}return e.join("")}(l(a),b)},sliceStream:l,write:function(a){return(g=oU(g,a),function(){let a;for(;d._index<g.length;){let c=g[d._index];if("string"==typeof c)for(a=d._index,d._bufferIndex<0&&(d._bufferIndex=0);d._index===a&&d._bufferIndex<c.length;){var b;b=c.charCodeAt(d._bufferIndex),k=k(b)}else k=k(c)}}(),null!==g[g.length-1])?[]:(q(b,0),j.events=pu(f,j.events,j),j.events)}},k=b.tokenize.call(j,i);return b.resolveAll&&f.push(b),j;function l(a){return function(a,b){let c,d=b.start._index,e=b.start._bufferIndex,f=b.end._index,g=b.end._bufferIndex;if(d===f)c=[a[d].slice(e,g)];else{if(c=a.slice(d,f),e>-1){let a=c[0];"string"==typeof a?c[0]=a.slice(e):c.shift()}g>0&&c.push(a[f].slice(0,g))}return c}(g,a)}function n(){let{_bufferIndex:a,_index:b,line:c,column:e,offset:f}=d;return{_bufferIndex:a,_index:b,line:c,column:e,offset:f}}function o(a,b){b.restore()}function p(a,b){return function(c,e,f){var g;let k,l,o,p;return Array.isArray(c)?q(c):"tokenize"in c?q([c]):(g=c,function(a){let b=null!==a&&g[a],c=null!==a&&g.null;return q([...Array.isArray(b)?b:b?[b]:[],...Array.isArray(c)?c:c?[c]:[]])(a)});function q(a){return(k=a,l=0,0===a.length)?f:s(a[l])}function s(a){return function(c){let e,f,g,k,l;return(e=n(),f=j.previous,g=j.currentConstruct,k=j.events.length,l=Array.from(h),p={from:k,restore:function(){d=e,j.previous=f,j.currentConstruct=g,j.events.length=k,h=l,r()}},o=a,a.partial||(j.currentConstruct=a),a.name&&j.parser.constructs.disable.null.includes(a.name))?u(c):a.tokenize.call(b?Object.assign(Object.create(j),b):j,i,t,u)(c)}}function t(b){return a(o,p),e}function u(a){return(p.restore(),++l<k.length)?s(k[l]):f}}}function q(a,b){a.resolveAll&&!f.includes(a)&&f.push(a),a.resolve&&oT(j.events,b,j.events.length-b,a.resolve(j.events.slice(b),j)),a.resolveTo&&(j.events=a.resolveTo(j.events,j))}function r(){d.line in e&&d.column<2&&(d.column=e[d.line],d.offset+=e[d.line]-1)}}(b,a,c)}}})(e).document().write((g=1,h="",i=!0,function(a,b,c){let d,e,j,k,l,n=[];for(a=h+("string"==typeof a?a.toString():new TextDecoder(b||void 0).decode(a)),j=0,h="",i&&(65279===a.charCodeAt(0)&&j++,i=void 0);j<a.length;){if(qb.lastIndex=j,k=(d=qb.exec(a))&&void 0!==d.index?d.index:a.length,l=a.charCodeAt(k),!d){h=a.slice(j);break}if(10===l&&j===k&&f)n.push(-3),f=void 0;else switch(f&&(n.push(-5),f=void 0),j<k&&(n.push(a.slice(j,k)),g+=k-j),l){case 0:n.push(65533),g++;break;case 9:for(e=4*Math.ceil(g/4),n.push(-2);g++<e;)n.push(-1);break;case 10:n.push(-4),g=1;break;default:f=!0,g=1}j=k+1}return c&&(f&&n.push(-5),h&&n.push(h),n.push(null)),n})(c,d,!0))))}}let qj="object"==typeof self?self:globalThis,qk=a=>{var b;let c,d;return(b=new Map,c=(a,c)=>(b.set(c,a),a),d=e=>{if(b.has(e))return b.get(e);let[f,g]=a[e];switch(f){case 0:case -1:return c(g,e);case 1:{let a=c([],e);for(let b of g)a.push(d(b));return a}case 2:{let a=c({},e);for(let[b,c]of g)a[d(b)]=d(c);return a}case 3:return c(new Date(g),e);case 4:{let{source:a,flags:b}=g;return c(new RegExp(a,b),e)}case 5:{let a=c(new Map,e);for(let[b,c]of g)a.set(d(b),d(c));return a}case 6:{let a=c(new Set,e);for(let b of g)a.add(d(b));return a}case 7:{let{name:a,message:b}=g;return c(new qj[a](b),e)}case 8:return c(BigInt(g),e);case"BigInt":return c(Object(BigInt(g)),e);case"ArrayBuffer":return c(new Uint8Array(g).buffer,g);case"DataView":{let{buffer:a}=new Uint8Array(g);return c(new DataView(a),g)}}return c(new qj[f](g),e)})(0)},{toString:ql}={},{keys:qm}=Object,qn=a=>{let b=typeof a;if("object"!==b||!a)return[0,b];let c=ql.call(a).slice(8,-1);switch(c){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,c]}return c.includes("Array")?[1,c]:c.includes("Error")?[7,c]:[2,c]},qo=([a,b])=>0===a&&("function"===b||"symbol"===b),qp=(a,{json:b,lossy:c}={})=>{var d,e,f;let g,h,i=[];return(d=!(b||c),e=!!b,f=new Map,g=(a,b)=>{let c=i.push(a)-1;return f.set(b,c),c},h=a=>{if(f.has(a))return f.get(a);let[b,c]=qn(a);switch(b){case 0:{let e=a;switch(c){case"bigint":b=8,e=a.toString();break;case"function":case"symbol":if(d)throw TypeError("unable to serialize "+c);e=null;break;case"undefined":return g([-1],a)}return g([b,e],a)}case 1:{if(c){let b=a;return"DataView"===c?b=new Uint8Array(a.buffer):"ArrayBuffer"===c&&(b=new Uint8Array(a)),g([c,[...b]],a)}let d=[],e=g([b,d],a);for(let b of a)d.push(h(b));return e}case 2:{if(c)switch(c){case"BigInt":return g([c,a.toString()],a);case"Boolean":case"Number":case"String":return g([c,a.valueOf()],a)}if(e&&"toJSON"in a)return h(a.toJSON());let f=[],i=g([b,f],a);for(let b of qm(a))(d||!qo(qn(a[b])))&&f.push([h(b),h(a[b])]);return i}case 3:return g([b,a.toISOString()],a);case 4:{let{source:c,flags:d}=a;return g([b,{source:c,flags:d}],a)}case 5:{let c=[],e=g([b,c],a);for(let[b,e]of a)(d||!(qo(qn(b))||qo(qn(e))))&&c.push([h(b),h(e)]);return e}case 6:{let c=[],e=g([b,c],a);for(let b of a)(d||!qo(qn(b)))&&c.push(h(b));return e}}let{message:i}=a;return g([b,{name:c,message:i}],a)})(a),i},qq="function"==typeof structuredClone?(a,b)=>b&&("json"in b||"lossy"in b)?qk(qp(a,b)):structuredClone(a):(a,b)=>qk(qp(a,b));qs(/[A-Za-z]/);let qr=qs(/[\dA-Za-z]/);function qs(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function qt(a){let b=[],c=-1,d=0,e=0;for(;++c<a.length;){let f=a.charCodeAt(c),g="";if(37===f&&qr(a.charCodeAt(c+1))&&qr(a.charCodeAt(c+2)))e=2;else if(f<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(f))||(g=String.fromCharCode(f));else if(f>55295&&f<57344){let b=a.charCodeAt(c+1);f<56320&&b>56319&&b<57344?(g=String.fromCharCode(f,b),e=1):g="�"}else g=String.fromCharCode(f);g&&(b.push(a.slice(d,c),encodeURIComponent(g)),d=c+e+1,g=""),e&&(c+=e,e=0)}return b.join("")+a.slice(d)}function qu(a,b){let c=[{type:"text",value:"↩"}];return b>1&&c.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(b)}]}),c}function qv(a,b){return"Back to reference "+(a+1)+(b>1?"-"+b:"")}qs(/[#-'*+\--9=?A-Z^-~]/),qs(/\d/),qs(/[\dA-Fa-f]/),qs(/[!-/:-@[-`{-~]/),qs(/\p{P}|\p{S}/u),qs(/\s/);let qw=function(a){var b,c;if(null==a)return qy;if("function"==typeof a)return qx(a);if("object"==typeof a){return Array.isArray(a)?function(a){let b=[],c=-1;for(;++c<a.length;)b[c]=qw(a[c]);return qx(function(...a){let c=-1;for(;++c<b.length;)if(b[c].apply(this,a))return!0;return!1})}(a):(b=a,qx(function(a){let c;for(c in b)if(a[c]!==b[c])return!1;return!0}))}if("string"==typeof a){return c=a,qx(function(a){return a&&a.type===c})}throw Error("Expected function, string, or object as test")};function qx(a){return function(b,c,d){return!!(function(a){return null!==a&&"object"==typeof a&&"type"in a}(b)&&a.call(this,b,"number"==typeof c?c:void 0,d||void 0))}}function qy(){return!0}let qz=[];function qA(a,b,c,d){let e;"function"==typeof b&&"function"!=typeof c?(d=c,c=b):e=b;let f=qw(e),g=d?-1:1;(function a(e,h,i){let j=e&&"object"==typeof e?e:{};if("string"==typeof j.type){let a="string"==typeof j.tagName?j.tagName:"string"==typeof j.name?j.name:void 0;Object.defineProperty(k,"name",{value:"node (\x1b[33m"+e.type+(a?"<"+a+">":"")+"\x1b[39m)"})}return k;function k(){var j;let k,l,n,o=qz;if((!b||f(e,h,i[i.length-1]||void 0))&&!1===(o=Array.isArray(j=c(e,i))?j:"number"==typeof j?[!0,j]:null==j?qz:[j])[0])return o;if("children"in e&&e.children&&e.children&&"skip"!==o[0])for(l=(d?e.children.length:-1)+g,n=i.concat(e);l>-1&&l<e.children.length;){if(!1===(k=a(e.children[l],l,n)())[0])return k;l="number"==typeof k[1]?k[1]:l+g}return o}})(a,void 0,[])()}function qB(a,b,c,d){let e,f,g;"function"==typeof b&&"function"!=typeof c?(f=void 0,g=b,e=c):(f=b,g=c,e=d),qA(a,f,function(a,b){let c=b[b.length-1],d=c?c.children.indexOf(a):void 0;return g(a,d,c)},e)}function qC(a,b){let c=b.referenceType,d="]";if("collapsed"===c?d+="[]":"full"===c&&(d+="["+(b.label||b.identifier)+"]"),"imageReference"===b.type)return[{type:"text",value:"!["+b.alt+d}];let e=a.all(b),f=e[0];f&&"text"===f.type?f.value="["+f.value:e.unshift({type:"text",value:"["});let g=e[e.length-1];return g&&"text"===g.type?g.value+=d:e.push({type:"text",value:d}),e}function qD(a){let b=a.spread;return null==b?a.children.length>1:b}function qE(a,b,c){let d=0,e=a.length;if(b){let b=a.codePointAt(d);for(;9===b||32===b;)d++,b=a.codePointAt(d)}if(c){let b=a.codePointAt(e-1);for(;9===b||32===b;)e--,b=a.codePointAt(e-1)}return e>d?a.slice(d,e):""}let qF={blockquote:function(a,b){let c={type:"element",tagName:"blockquote",properties:{},children:a.wrap(a.all(b),!0)};return a.patch(b,c),a.applyData(b,c)},break:function(a,b){let c={type:"element",tagName:"br",properties:{},children:[]};return a.patch(b,c),[a.applyData(b,c),{type:"text",value:"\n"}]},code:function(a,b){let c=b.value?b.value+"\n":"",d={},e=b.lang?b.lang.split(/\s+/):[];e.length>0&&(d.className=["language-"+e[0]]);let f={type:"element",tagName:"code",properties:d,children:[{type:"text",value:c}]};return b.meta&&(f.data={meta:b.meta}),a.patch(b,f),f={type:"element",tagName:"pre",properties:{},children:[f=a.applyData(b,f)]},a.patch(b,f),f},delete:function(a,b){let c={type:"element",tagName:"del",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},emphasis:function(a,b){let c={type:"element",tagName:"em",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},footnoteReference:function(a,b){let c,d="string"==typeof a.options.clobberPrefix?a.options.clobberPrefix:"user-content-",e=String(b.identifier).toUpperCase(),f=qt(e.toLowerCase()),g=a.footnoteOrder.indexOf(e),h=a.footnoteCounts.get(e);void 0===h?(h=0,a.footnoteOrder.push(e),c=a.footnoteOrder.length):c=g+1,h+=1,a.footnoteCounts.set(e,h);let i={type:"element",tagName:"a",properties:{href:"#"+d+"fn-"+f,id:d+"fnref-"+f+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};a.patch(b,i);let j={type:"element",tagName:"sup",properties:{},children:[i]};return a.patch(b,j),a.applyData(b,j)},heading:function(a,b){let c={type:"element",tagName:"h"+b.depth,properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},html:function(a,b){if(a.options.allowDangerousHtml){let c={type:"raw",value:b.value};return a.patch(b,c),a.applyData(b,c)}},imageReference:function(a,b){let c=String(b.identifier).toUpperCase(),d=a.definitionById.get(c);if(!d)return qC(a,b);let e={src:qt(d.url||""),alt:b.alt};null!==d.title&&void 0!==d.title&&(e.title=d.title);let f={type:"element",tagName:"img",properties:e,children:[]};return a.patch(b,f),a.applyData(b,f)},image:function(a,b){let c={src:qt(b.url)};null!==b.alt&&void 0!==b.alt&&(c.alt=b.alt),null!==b.title&&void 0!==b.title&&(c.title=b.title);let d={type:"element",tagName:"img",properties:c,children:[]};return a.patch(b,d),a.applyData(b,d)},inlineCode:function(a,b){let c={type:"text",value:b.value.replace(/\r?\n|\r/g," ")};a.patch(b,c);let d={type:"element",tagName:"code",properties:{},children:[c]};return a.patch(b,d),a.applyData(b,d)},linkReference:function(a,b){let c=String(b.identifier).toUpperCase(),d=a.definitionById.get(c);if(!d)return qC(a,b);let e={href:qt(d.url||"")};null!==d.title&&void 0!==d.title&&(e.title=d.title);let f={type:"element",tagName:"a",properties:e,children:a.all(b)};return a.patch(b,f),a.applyData(b,f)},link:function(a,b){let c={href:qt(b.url)};null!==b.title&&void 0!==b.title&&(c.title=b.title);let d={type:"element",tagName:"a",properties:c,children:a.all(b)};return a.patch(b,d),a.applyData(b,d)},listItem:function(a,b,c){let d=a.all(b),e=c?function(a){let b=!1;if("list"===a.type){b=a.spread||!1;let c=a.children,d=-1;for(;!b&&++d<c.length;)b=qD(c[d])}return b}(c):qD(b),f={},g=[];if("boolean"==typeof b.checked){let a,c=d[0];c&&"element"===c.type&&"p"===c.tagName?a=c:(a={type:"element",tagName:"p",properties:{},children:[]},d.unshift(a)),a.children.length>0&&a.children.unshift({type:"text",value:" "}),a.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:b.checked,disabled:!0},children:[]}),f.className=["task-list-item"]}let h=-1;for(;++h<d.length;){let a=d[h];(e||0!==h||"element"!==a.type||"p"!==a.tagName)&&g.push({type:"text",value:"\n"}),"element"!==a.type||"p"!==a.tagName||e?g.push(a):g.push(...a.children)}let i=d[d.length-1];i&&(e||"element"!==i.type||"p"!==i.tagName)&&g.push({type:"text",value:"\n"});let j={type:"element",tagName:"li",properties:f,children:g};return a.patch(b,j),a.applyData(b,j)},list:function(a,b){let c={},d=a.all(b),e=-1;for("number"==typeof b.start&&1!==b.start&&(c.start=b.start);++e<d.length;){let a=d[e];if("element"===a.type&&"li"===a.tagName&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){c.className=["contains-task-list"];break}}let f={type:"element",tagName:b.ordered?"ol":"ul",properties:c,children:a.wrap(d,!0)};return a.patch(b,f),a.applyData(b,f)},paragraph:function(a,b){let c={type:"element",tagName:"p",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},root:function(a,b){let c={type:"root",children:a.wrap(a.all(b))};return a.patch(b,c),a.applyData(b,c)},strong:function(a,b){let c={type:"element",tagName:"strong",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},table:function(a,b){let c=a.all(b),d=c.shift(),e=[];if(d){let c={type:"element",tagName:"thead",properties:{},children:a.wrap([d],!0)};a.patch(b.children[0],c),e.push(c)}if(c.length>0){let d={type:"element",tagName:"tbody",properties:{},children:a.wrap(c,!0)},f=ou(b.children[1]),g=ot(b.children[b.children.length-1]);f&&g&&(d.position={start:f,end:g}),e.push(d)}let f={type:"element",tagName:"table",properties:{},children:a.wrap(e,!0)};return a.patch(b,f),a.applyData(b,f)},tableCell:function(a,b){let c={type:"element",tagName:"td",properties:{},children:a.all(b)};return a.patch(b,c),a.applyData(b,c)},tableRow:function(a,b,c){let d=c?c.children:void 0,e=0===(d?d.indexOf(b):1)?"th":"td",f=c&&"table"===c.type?c.align:void 0,g=f?f.length:b.children.length,h=-1,i=[];for(;++h<g;){let c=b.children[h],d={},g=f?f[h]:void 0;g&&(d.align=g);let j={type:"element",tagName:e,properties:d,children:[]};c&&(j.children=a.all(c),a.patch(c,j),j=a.applyData(c,j)),i.push(j)}let j={type:"element",tagName:"tr",properties:{},children:a.wrap(i,!0)};return a.patch(b,j),a.applyData(b,j)},text:function(a,b){let c={type:"text",value:function(a){let b=String(a),c=/\r?\n|\r/g,d=c.exec(b),e=0,f=[];for(;d;)f.push(qE(b.slice(e,d.index),e>0,!0),d[0]),e=d.index+d[0].length,d=c.exec(b);return f.push(qE(b.slice(e),e>0,!1)),f.join("")}(String(b.value))};return a.patch(b,c),a.applyData(b,c)},thematicBreak:function(a,b){let c={type:"element",tagName:"hr",properties:{},children:[]};return a.patch(b,c),a.applyData(b,c)},toml:qG,yaml:qG,definition:qG,footnoteDefinition:qG};function qG(){}let qH={}.hasOwnProperty,qI={};function qJ(a,b){a.position&&(b.position=function(a){let b=ou(a),c=ot(a);if(b&&c)return{start:b,end:c}}(a))}function qK(a,b){let c=b;if(a&&a.data){let b=a.data.hName,d=a.data.hChildren,e=a.data.hProperties;"string"==typeof b&&("element"===c.type?c.tagName=b:c={type:"element",tagName:b,properties:{},children:"children"in c?c.children:[c]}),"element"===c.type&&e&&Object.assign(c.properties,qq(e)),"children"in c&&c.children&&null!=d&&(c.children=d)}return c}function qL(a,b){let c=[],d=-1;for(b&&c.push({type:"text",value:"\n"});++d<a.length;)d&&c.push({type:"text",value:"\n"}),c.push(a[d]);return b&&a.length>0&&c.push({type:"text",value:"\n"}),c}function qM(a){let b=0,c=a.charCodeAt(b);for(;9===c||32===c;)b++,c=a.charCodeAt(b);return a.slice(b)}function qN(a,b){let c,d,e,f,g=(c=b||qI,d=new Map,e=new Map,f={all:function(a){let b=[];if("children"in a){let c=a.children,d=-1;for(;++d<c.length;){let e=f.one(c[d],a);if(e){if(d&&"break"===c[d-1].type&&(Array.isArray(e)||"text"!==e.type||(e.value=qM(e.value)),!Array.isArray(e)&&"element"===e.type)){let a=e.children[0];a&&"text"===a.type&&(a.value=qM(a.value))}Array.isArray(e)?b.push(...e):b.push(e)}}}return b},applyData:qK,definitionById:d,footnoteById:e,footnoteCounts:new Map,footnoteOrder:[],handlers:{...qF,...c.handlers},one:function(a,b){let c=a.type,d=f.handlers[c];if(qH.call(f.handlers,c)&&d)return d(f,a,b);if(f.options.passThrough&&f.options.passThrough.includes(c)){if("children"in a){let{children:b,...c}=a,d=qq(c);return d.children=f.all(a),d}return qq(a)}return(f.options.unknownHandler||function(a,b){let c=b.data||{},d="value"in b&&!(qH.call(c,"hProperties")||qH.call(c,"hChildren"))?{type:"text",value:b.value}:{type:"element",tagName:"div",properties:{},children:a.all(b)};return a.patch(b,d),a.applyData(b,d)})(f,a,b)},options:c,patch:qJ,wrap:qL},qB(a,function(a){if("definition"===a.type||"footnoteDefinition"===a.type){let b="definition"===a.type?d:e,c=String(a.identifier).toUpperCase();b.has(c)||b.set(c,a)}}),f),h=g.one(a,void 0),i=function(a){let b="string"==typeof a.options.clobberPrefix?a.options.clobberPrefix:"user-content-",c=a.options.footnoteBackContent||qu,d=a.options.footnoteBackLabel||qv,e=a.options.footnoteLabel||"Footnotes",f=a.options.footnoteLabelTagName||"h2",g=a.options.footnoteLabelProperties||{className:["sr-only"]},h=[],i=-1;for(;++i<a.footnoteOrder.length;){let e=a.footnoteById.get(a.footnoteOrder[i]);if(!e)continue;let f=a.all(e),g=String(e.identifier).toUpperCase(),j=qt(g.toLowerCase()),k=0,l=[],n=a.footnoteCounts.get(g);for(;void 0!==n&&++k<=n;){l.length>0&&l.push({type:"text",value:" "});let a="string"==typeof c?c:c(i,k);"string"==typeof a&&(a={type:"text",value:a}),l.push({type:"element",tagName:"a",properties:{href:"#"+b+"fnref-"+j+(k>1?"-"+k:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof d?d:d(i,k),className:["data-footnote-backref"]},children:Array.isArray(a)?a:[a]})}let o=f[f.length-1];if(o&&"element"===o.type&&"p"===o.tagName){let a=o.children[o.children.length-1];a&&"text"===a.type?a.value+=" ":o.children.push({type:"text",value:" "}),o.children.push(...l)}else f.push(...l);let p={type:"element",tagName:"li",properties:{id:b+"fn-"+j},children:a.wrap(f,!0)};a.patch(e,p),h.push(p)}if(0!==h.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:f,properties:{...qq(g),id:"footnote-label"},children:[{type:"text",value:e}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:a.wrap(h,!0)},{type:"text",value:"\n"}]}}(g),j=Array.isArray(h)?{type:"root",children:h}:h||{type:"root",children:[]};return i&&(nP("children"in j),j.children.push({type:"text",value:"\n"},i)),j}function qO(a,b){return a&&"run"in a?async function(c,d){let e=qN(c,{file:d,...b});await a.run(e,d)}:function(c,d){return qN(c,{file:d,...a||b})}}function qP(a){if(a)throw a}var qQ=a.i(97599);function qR(a){if("object"!=typeof a||null===a)return!1;let b=Object.getPrototypeOf(a);return(null===b||b===Object.prototype||null===Object.getPrototypeOf(b))&&!(Symbol.toStringTag in a)&&!(Symbol.iterator in a)}var qS=a.i(50227),qS=qS,qT=a.i(59639),qT=qT,qU=a.i(57764),qU=qU;function qV(a){return!!(null!==a&&"object"==typeof a&&"href"in a&&a.href&&"protocol"in a&&a.protocol&&void 0===a.auth)}let qW=["history","path","basename","stem","extname","dirname"];class qX{constructor(a){let b,c;b=a?qV(a)?{path:a}:"string"==typeof a||function(a){return!!(a&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a)}(a)?{value:a}:a:{},this.cwd="cwd"in b?"":qT.default.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let d=-1;for(;++d<qW.length;){const a=qW[d];a in b&&void 0!==b[a]&&null!==b[a]&&(this[a]="history"===a?[...b[a]]:b[a])}for(c in b)qW.includes(c)||(this[c]=b[c])}get basename(){return"string"==typeof this.path?qS.default.basename(this.path):void 0}set basename(a){qZ(a,"basename"),qY(a,"basename"),this.path=qS.default.join(this.dirname||"",a)}get dirname(){return"string"==typeof this.path?qS.default.dirname(this.path):void 0}set dirname(a){q$(this.basename,"dirname"),this.path=qS.default.join(a||"",this.basename)}get extname(){return"string"==typeof this.path?qS.default.extname(this.path):void 0}set extname(a){if(qY(a,"extname"),q$(this.dirname,"extname"),a){if(46!==a.codePointAt(0))throw Error("`extname` must start with `.`");if(a.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=qS.default.join(this.dirname,this.stem+(a||""))}get path(){return this.history[this.history.length-1]}set path(a){qV(a)&&(a=(0,qU.fileURLToPath)(a)),qZ(a,"path"),this.path!==a&&this.history.push(a)}get stem(){return"string"==typeof this.path?qS.default.basename(this.path,this.extname):void 0}set stem(a){qZ(a,"stem"),qY(a,"stem"),this.path=qS.default.join(this.dirname||"",a+(this.extname||""))}fail(a,b,c){let d=this.message(a,b,c);throw d.fatal=!0,d}info(a,b,c){let d=this.message(a,b,c);return d.fatal=void 0,d}message(a,b,c){let d=new oA(a,b,c);return this.path&&(d.name=this.path+":"+d.name,d.file=this.path),d.fatal=!1,this.messages.push(d),d}toString(a){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(a||void 0).decode(this.value)}}function qY(a,b){if(a&&a.includes(qS.default.sep))throw Error("`"+b+"` cannot be a path: did not expect `"+qS.default.sep+"`")}function qZ(a,b){if(!a)throw Error("`"+b+"` cannot be empty")}function q$(a,b){if(!a)throw Error("Setting `"+b+"` requires `path` to be set too")}let q_=function(a){let b=this.constructor.prototype,c=b[a],d=function(){return c.apply(d,arguments)};return Object.setPrototypeOf(d,b),d},q0={}.hasOwnProperty;class q1 extends q_{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let a=[],b={run:function(...b){let c=-1,d=b.pop();if("function"!=typeof d)throw TypeError("Expected function as last argument, not "+d);!function e(f,...g){let h=a[++c],i=-1;if(f)return void d(f);for(;++i<b.length;)(null===g[i]||void 0===g[i])&&(g[i]=b[i]);b=g,h?(function(a,b){let c;return function(...b){let f,g=a.length>b.length;g&&b.push(d);try{f=a.apply(this,b)}catch(a){if(g&&c)throw a;return d(a)}g||(f&&f.then&&"function"==typeof f.then?f.then(e,d):f instanceof Error?d(f):e(f))};function d(a,...e){c||(c=!0,b(a,...e))}function e(a){d(null,a)}})(h,e)(...g):d(null,...g)}(null,...b)},use:function(c){if("function"!=typeof c)throw TypeError("Expected `middelware` to be a function, not "+c);return a.push(c),b}};return b}()}copy(){let a=new q1,b=-1;for(;++b<this.attachers.length;){let c=this.attachers[b];a.use(...c)}return a.data((0,qQ.default)(!0,{},this.namespace)),a}data(a,b){return"string"==typeof a?2==arguments.length?(q5("data",this.frozen),this.namespace[a]=b,this):q0.call(this.namespace,a)&&this.namespace[a]||void 0:a?(q5("data",this.frozen),this.namespace=a,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[a,...b]=this.attachers[this.freezeIndex];if(!1===b[0])continue;!0===b[0]&&(b[0]=void 0);let c=a.call(this,...b);"function"==typeof c&&this.transformers.use(c)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(a){this.freeze();let b=q8(a),c=this.parser||this.Parser;return q3("parse",c),c(String(b),b)}process(a,b){let c=this;return this.freeze(),q3("process",this.parser||this.Parser),q4("process",this.compiler||this.Compiler),b?d(void 0,b):new Promise(d);function d(d,e){let f=q8(a),g=c.parse(f);function h(a,c){a||!c?e(a):d?d(c):(nP(b,"`done` is defined if `resolve` is not"),b(void 0,c))}c.run(g,f,function(a,b,d){var e,f;if(a||!b||!d)return h(a);let g=c.stringify(b,d);"string"==typeof(e=g)||(f=e)&&"object"==typeof f&&"byteLength"in f&&"byteOffset"in f?d.value=g:d.result=g,h(a,d)})}}processSync(a){let b,c=!1;return this.freeze(),q3("processSync",this.parser||this.Parser),q4("processSync",this.compiler||this.Compiler),this.process(a,function(a,d){c=!0,qP(a),b=d}),q7("processSync","process",c),nP(b,"we either bailed on an error or have a tree"),b}run(a,b,c){q6(a),this.freeze();let d=this.transformers;return c||"function"!=typeof b||(c=b,b=void 0),c?e(void 0,c):new Promise(e);function e(e,f){nP("function"!=typeof b,"`file` can’t be a `done` anymore, we checked");let g=q8(b);d.run(a,g,function(b,d,g){let h=d||a;b?f(b):e?e(h):(nP(c,"`done` is defined if `resolve` is not"),c(void 0,h,g))})}}runSync(a,b){let c,d=!1;return this.run(a,b,function(a,b){qP(a),c=b,d=!0}),q7("runSync","run",d),nP(c,"we either bailed on an error or have a tree"),c}stringify(a,b){this.freeze();let c=q8(b),d=this.compiler||this.Compiler;return q4("stringify",d),q6(a),d(a,c)}use(a,...b){let c=this.attachers,d=this.namespace;if(q5("use",this.frozen),null==a);else if("function"==typeof a)g(a,b);else if("object"==typeof a)Array.isArray(a)?f(a):e(a);else throw TypeError("Expected usable value, not `"+a+"`");return this;function e(a){if(!("plugins"in a)&&!("settings"in a))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(a.plugins),a.settings&&(d.settings=(0,qQ.default)(!0,d.settings,a.settings))}function f(a){let b=-1;if(null==a);else if(Array.isArray(a))for(;++b<a.length;)!function(a){if("function"==typeof a)g(a,[]);else if("object"==typeof a)if(Array.isArray(a)){let[b,...c]=a;g(b,c)}else e(a);else throw TypeError("Expected usable value, not `"+a+"`")}(a[b]);else throw TypeError("Expected a list of plugins, not `"+a+"`")}function g(a,b){let d=-1,e=-1;for(;++d<c.length;)if(c[d][0]===a){e=d;break}if(-1===e)c.push([a,...b]);else if(b.length>0){let[d,...f]=b,g=c[e][1];qR(g)&&qR(d)&&(d=(0,qQ.default)(!0,g,d)),c[e]=[a,d,...f]}}}}let q2=new q1().freeze();function q3(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `parser`")}function q4(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `compiler`")}function q5(a,b){if(b)throw Error("Cannot call `"+a+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function q6(a){if(!qR(a)||"string"!=typeof a.type)throw TypeError("Expected node, got `"+a+"`")}function q7(a,b,c){if(!c)throw Error("`"+a+"` finished async. Use `"+b+"` instead")}function q8(a){var b;return(b=a)&&"object"==typeof b&&"message"in b&&"messages"in b?a:new qX(a)}let q9=[],ra={allowDangerousHtml:!0},rb=/^(https?|ircs?|mailto|xmpp)$/i,rc=[{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 rd(a){var b;let c,d,e,f,g,h=(c=(b=a).rehypePlugins||q9,d=b.remarkPlugins||q9,e=b.remarkRehypeOptions?{...b.remarkRehypeOptions,...ra}:ra,q2().use(qi).use(d).use(qO,e).use(c)),i=(f=a.children||"",g=new qX,"string"==typeof f?g.value=f:nQ("Unexpected value `"+f+"` for `children` prop, expected `string`"),g);return function(a,b){let c=b.allowedElements,d=b.allowElement,e=b.components,f=b.disallowedElements,g=b.skipHtml,h=b.unwrapDisallowed,i=b.urlTransform||re;for(let a of rc)Object.hasOwn(b,a.from)&&nQ("Unexpected `"+a.from+"` prop, "+(a.to?"use `"+a.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+a.id+"> for more info)");return c&&f&&nQ("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),qB(a,function(a,b,e){if("raw"===a.type&&e&&"number"==typeof b)return g?e.children.splice(b,1):e.children[b]={type:"text",value:a.value},b;if("element"===a.type){let b;for(b in oO)if(Object.hasOwn(oO,b)&&Object.hasOwn(a.properties,b)){let c=a.properties[b],d=oO[b];(null===d||d.includes(a.tagName))&&(a.properties[b]=i(String(c||""),b,a))}}if("element"===a.type){let g=c?!c.includes(a.tagName):!!f&&f.includes(a.tagName);if(!g&&d&&"number"==typeof b&&(g=!d(a,b,e)),g&&e&&"number"==typeof b)return h&&a.children?e.children.splice(b,1,...a.children):e.children.splice(b,1),b}}),function(a,b){var c,d,e,f;let g;if(!b||void 0===b.Fragment)throw TypeError("Expected `Fragment` in options");let h=b.filePath||void 0;if(b.development){if("function"!=typeof b.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");c=h,d=b.jsxDEV,g=function(a,b,e,f){let g=Array.isArray(e.children),h=ou(a);return d(b,e,f,g,{columnNumber:h?h.column-1:void 0,fileName:c,lineNumber:h?h.line:void 0},void 0)}}else{if("function"!=typeof b.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof b.jsxs)throw TypeError("Expected `jsxs` in production options");e=b.jsx,f=b.jsxs,g=function(a,b,c,d){let g=Array.isArray(c.children)?f:e;return d?g(b,c,d):g(b,c)}}let i={Fragment:b.Fragment,ancestors:[],components:b.components||{},create:g,elementAttributeNameCase:b.elementAttributeNameCase||"react",evaluater:b.createEvaluater?b.createEvaluater():void 0,filePath:h,ignoreInvalidStyle:b.ignoreInvalidStyle||!1,passKeys:!1!==b.passKeys,passNode:b.passNode||!1,schema:"svg"===b.space?or:oq,stylePropertyNameCase:b.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==b.tableCellAlignToStyle},j=oH(i,a,void 0);return j&&"string"!=typeof j?j:i.create(a,i.Fragment,{children:j||void 0},void 0)}(a,{Fragment:C.Fragment,components:e,ignoreInvalidStyle:!0,jsx:C.jsx,jsxs:C.jsxs,passKeys:!0,passNode:!0})}(h.runSync(h.parse(i),i),a)}function re(a){let b=a.indexOf(":"),c=a.indexOf("?"),d=a.indexOf("#"),e=a.indexOf("/");return -1===b||-1!==e&&b>e||-1!==c&&b>c||-1!==d&&b>d||rb.test(a.slice(0,b))?a:""}function rf(a,b){let c=String(a);if("string"!=typeof b)throw TypeError("Expected character");let d=0,e=c.indexOf(b);for(;-1!==e;)d++,e=c.indexOf(b,e+b.length);return d}ri(/[A-Za-z]/),ri(/[\dA-Za-z]/),ri(/[#-'*+\--9=?A-Z^-~]/),ri(/\d/),ri(/[\dA-Fa-f]/),ri(/[!-/:-@[-`{-~]/);let rg=ri(/\p{P}|\p{S}/u),rh=ri(/\s/);function ri(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let rj="phrasing",rk=["autolink","link","image","label"];function rl(a){this.enter({type:"link",title:null,url:"",children:[]},a)}function rm(a){this.config.enter.autolinkProtocol.call(this,a)}function rn(a){this.config.exit.autolinkProtocol.call(this,a)}function ro(a){this.config.exit.data.call(this,a);let b=this.stack[this.stack.length-1];nP("link"===b.type),b.url="http://"+this.sliceSerialize(a)}function rp(a){this.config.exit.autolinkEmail.call(this,a)}function rq(a){this.exit(a)}function rr(a){!function(a,b,c){let d=qw((c||{}).ignore||[]),e=function(a){let b=[];if(!Array.isArray(a))throw TypeError("Expected find and replace tuple or list of tuples");let c=!a[0]||Array.isArray(a[0])?a:[a],d=-1;for(;++d<c.length;){var e;let a=c[d];b.push(["string"==typeof(e=a[0])?RegExp(function(a){if("string"!=typeof a)throw TypeError("Expected a string");return a.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e,function(a){return"function"==typeof a?a:function(){return a}}(a[1])])}return b}(b),f=-1;for(;++f<e.length;)qA(a,"text",g);function g(a,b){let c,g=-1;for(;++g<b.length;){let a=b[g],e=c?c.children:void 0;if(d(a,e?e.indexOf(a):void 0,c))return;c=a}if(c)return function(a,b){let c=b[b.length-1],d=e[f][0],g=e[f][1],h=0,i=c.children.indexOf(a),j=!1,k=[];d.lastIndex=0;let l=d.exec(a.value);for(;l;){let c=l.index,e={index:l.index,input:l.input,stack:[...b,a]},f=g(...l,e);if("string"==typeof f&&(f=f.length>0?{type:"text",value:f}:void 0),!1===f?d.lastIndex=c+1:(h!==c&&k.push({type:"text",value:a.value.slice(h,c)}),Array.isArray(f)?k.push(...f):f&&k.push(f),h=c+l[0].length,j=!0),!d.global)break;l=d.exec(a.value)}return j?(h<a.value.length&&k.push({type:"text",value:a.value.slice(h)}),c.children.splice(i,1,...k)):k=[a],i+k.length}(a,b)}}(a,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,rs],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,rt]],{ignore:["link","linkReference"]})}function rs(a,b,c,d,e){let f,g="";if(!ru(e))return!1;if(/^w/i.test(b)&&(c=b+c,b="",g="http://"),(f=c.split(".")).length<2||f[f.length-1]&&(/_/.test(f[f.length-1])||!/[a-zA-Z\d]/.test(f[f.length-1]))||f[f.length-2]&&(/_/.test(f[f.length-2])||!/[a-zA-Z\d]/.test(f[f.length-2])))return!1;let h=function(a){let b=/[!"&'),.:;<>?\]}]+$/.exec(a);if(!b)return[a,void 0];a=a.slice(0,b.index);let c=b[0],d=c.indexOf(")"),e=rf(a,"("),f=rf(a,")");for(;-1!==d&&e>f;)a+=c.slice(0,d+1),d=(c=c.slice(d+1)).indexOf(")"),f++;return[a,c]}(c+d);if(!h[0])return!1;let i={type:"link",title:null,url:g+b+h[0],children:[{type:"text",value:b+h[0]}]};return h[1]?[i,{type:"text",value:h[1]}]:i}function rt(a,b,c,d){return!(!ru(d,!0)||/[-\d_]$/.test(c))&&{type:"link",title:null,url:"mailto:"+b+"@"+c,children:[{type:"text",value:b+"@"+c}]}}function ru(a,b){let c=a.input.charCodeAt(a.index-1);return(0===a.index||rh(c)||rg(c))&&(!b||47!==c)}function rv(){this.buffer()}function rw(a){this.enter({type:"footnoteReference",identifier:"",label:""},a)}function rx(){this.buffer()}function ry(a){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},a)}function rz(a){let b=this.resume(),c=this.stack[this.stack.length-1];nP("footnoteReference"===c.type),c.identifier=pU(this.sliceSerialize(a)).toLowerCase(),c.label=b}function rA(a){this.exit(a)}function rB(a){let b=this.resume(),c=this.stack[this.stack.length-1];nP("footnoteDefinition"===c.type),c.identifier=pU(this.sliceSerialize(a)).toLowerCase(),c.label=b}function rC(a){this.exit(a)}function rD(a,b,c,d){let e=c.createTracker(d),f=e.move("[^"),g=c.enter("footnoteReference"),h=c.enter("reference");return f+=e.move(c.safe(c.associationId(a),{after:"]",before:f})),h(),g(),f+=e.move("]")}function rE(a,b,c){return 0===b?a:rF(a,b,c)}function rF(a,b,c){return(c?"":" ")+a}rD.peek=function(){return"["};let rG=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function rH(a){this.enter({type:"delete",children:[]},a)}function rI(a){this.exit(a)}function rJ(a,b,c,d){let e=c.createTracker(d),f=c.enter("strikethrough"),g=e.move("~~");return g+=c.containerPhrasing(a,{...e.current(),before:g,after:"~"}),g+=e.move("~~"),f(),g}function rK(a){return a.length}function rL(a){let b="string"==typeof a?a.codePointAt(0):0;return 67===b||99===b?99:76===b||108===b?108:114*(82===b||114===b)}rJ.peek=function(){return"~"};function rM(a,b,c){let d=a.value||"",e="`",f=-1;for(;RegExp("(^|[^`])"+e+"([^`]|$)").test(d);)e+="`";for(/[^ \r\n]/.test(d)&&(/^[ \r\n]/.test(d)&&/[ \r\n]$/.test(d)||/^`|`$/.test(d))&&(d=" "+d+" ");++f<c.unsafe.length;){let a,b=c.unsafe[f],e=c.compilePattern(b);if(b.atBreak)for(;a=e.exec(d);){let b=a.index;10===d.charCodeAt(b)&&13===d.charCodeAt(b-1)&&b--,d=d.slice(0,b)+" "+d.slice(a.index+1)}}return e+d+e}rM.peek=function(){return"`"};qw(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let rN=function(a,b,c,d){let e=function(a){let b=a.options.listItemIndent||"one";if("tab"!==b&&"one"!==b&&"mixed"!==b)throw Error("Cannot serialize items with `"+b+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return b}(c),f=c.bulletCurrent||function(a){let b=a.options.bullet||"*";if("*"!==b&&"+"!==b&&"-"!==b)throw Error("Cannot serialize items with `"+b+"` for `options.bullet`, expected `*`, `+`, or `-`");return b}(c);b&&"list"===b.type&&b.ordered&&(f=("number"==typeof b.start&&b.start>-1?b.start:1)+(!1===c.options.incrementListMarker?0:b.children.indexOf(a))+f);let g=f.length+1;("tab"===e||"mixed"===e&&(b&&"list"===b.type&&b.spread||a.spread))&&(g=4*Math.ceil(g/4));let h=c.createTracker(d);h.move(f+" ".repeat(g-f.length)),h.shift(g);let i=c.enter("listItem"),j=c.indentLines(c.containerFlow(a,h.current()),function(a,b,c){return b?(c?"":" ".repeat(g))+a:(c?f:f+" ".repeat(g-f.length))+a});return i(),j};function rO(a){let b=a._align;nP(b,"expected `_align` on table"),this.enter({type:"table",align:b.map(function(a){return"none"===a?null:a}),children:[]},a),this.data.inTable=!0}function rP(a){this.exit(a),this.data.inTable=void 0}function rQ(a){this.enter({type:"tableRow",children:[]},a)}function rR(a){this.exit(a)}function rS(a){this.enter({type:"tableCell",children:[]},a)}function rT(a){let b=this.resume();this.data.inTable&&(b=b.replace(/\\([\\|])/g,rU));let c=this.stack[this.stack.length-1];nP("inlineCode"===c.type),c.value=b,this.exit(a)}function rU(a,b){return"|"===b?b:a}function rV(a){let b=this.stack[this.stack.length-2];nP("listItem"===b.type),b.checked="taskListCheckValueChecked"===a.type}function rW(a){let b=this.stack[this.stack.length-2];if(b&&"listItem"===b.type&&"boolean"==typeof b.checked){let a=this.stack[this.stack.length-1];nP("paragraph"===a.type);let c=a.children[0];if(c&&"text"===c.type){let d,e=b.children,f=-1;for(;++f<e.length;){let a=e[f];if("paragraph"===a.type){d=a;break}}d===a&&(c.value=c.value.slice(1),0===c.value.length?a.children.shift():a.position&&c.position&&"number"==typeof c.position.start.offset&&(c.position.start.column++,c.position.start.offset++,a.position.start=Object.assign({},c.position.start)))}}this.exit(a)}function rX(a,b,c,d){let e=a.children[0],f="boolean"==typeof a.checked&&e&&"paragraph"===e.type,g="["+(a.checked?"x":" ")+"] ",h=c.createTracker(d);f&&h.move(g);let i=rN(a,b,c,{...d,...h.current()});return f&&(i=i.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(a){return a+g})),i}let rY=r1(/[A-Za-z]/),rZ=r1(/[\dA-Za-z]/);function r$(a){return null!==a&&(a<0||32===a)}r1(/[#-'*+\--9=?A-Z^-~]/),r1(/\d/),r1(/[\dA-Fa-f]/),r1(/[!-/:-@[-`{-~]/);let r_=r1(/\p{P}|\p{S}/u),r0=r1(/\s/);function r1(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let r2={tokenize:function(a,b,c){let d=0;return function b(f){return(87===f||119===f)&&d<3?(d++,a.consume(f),b):46===f&&3===d?(a.consume(f),e):c(f)};function e(a){return null===a?c(a):b(a)}},partial:!0},r3={tokenize:function(a,b,c){let d,e,f;return g;function g(b){return 46===b||95===b?a.check(r5,i,h)(b):null===b||r$(b)||r0(b)||45!==b&&r_(b)?i(b):(f=!0,a.consume(b),g)}function h(b){return 95===b?d=!0:(e=d,d=void 0),a.consume(b),g}function i(a){return e||d||!f?c(a):b(a)}},partial:!0},r4={tokenize:function(a,b){let c=0,d=0;return e;function e(g){return 40===g?(c++,a.consume(g),e):41===g&&d<c?f(g):33===g||34===g||38===g||39===g||41===g||42===g||44===g||46===g||58===g||59===g||60===g||63===g||93===g||95===g||126===g?a.check(r5,b,f)(g):null===g||r$(g)||r0(g)?b(g):(a.consume(g),e)}function f(b){return 41===b&&d++,a.consume(b),e}},partial:!0},r5={tokenize:function(a,b,c){return d;function d(g){return 33===g||34===g||39===g||41===g||42===g||44===g||46===g||58===g||59===g||63===g||95===g||126===g?(a.consume(g),d):38===g?(a.consume(g),f):93===g?(a.consume(g),e):60===g||null===g||r$(g)||r0(g)?b(g):c(g)}function e(a){return null===a||40===a||91===a||r$(a)||r0(a)?b(a):d(a)}function f(b){return rY(b)?function b(e){return 59===e?(a.consume(e),d):rY(e)?(a.consume(e),b):c(e)}(b):c(b)}},partial:!0},r6={tokenize:function(a,b,c){return function(b){return a.consume(b),d};function d(a){return rZ(a)?c(a):b(a)}},partial:!0},r7={name:"wwwAutolink",tokenize:function(a,b,c){let d=this;return function(b){return 87!==b&&119!==b||!sc.call(d,d.previous)||sg(d.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(r2,a.attempt(r3,a.attempt(r4,e),c),c)(b))};function e(c){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),b(c)}},previous:sc},r8={name:"protocolAutolink",tokenize:function(a,b,c){let d=this,e="",f=!1;return function(b){return(72===b||104===b)&&sd.call(d,d.previous)&&!sg(d.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),e+=String.fromCodePoint(b),a.consume(b),g):c(b)};function g(b){if(rY(b)&&e.length<5)return e+=String.fromCodePoint(b),a.consume(b),g;if(58===b){let c=e.toLowerCase();if("http"===c||"https"===c)return a.consume(b),h}return c(b)}function h(b){return 47===b?(a.consume(b),f)?i:(f=!0,h):c(b)}function i(b){return null===b||null!==b&&(b<32||127===b)||r$(b)||r0(b)||r_(b)?c(b):a.attempt(r3,a.attempt(r4,j),c)(b)}function j(c){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),b(c)}},previous:sd},r9={name:"emailAutolink",tokenize:function(a,b,c){let d,e,f=this;return function(b){return!sf(b)||!se.call(f,f.previous)||sg(f.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),function b(d){return sf(d)?(a.consume(d),b):64===d?(a.consume(d),g):c(d)}(b))};function g(b){return 46===b?a.check(r6,i,h)(b):45===b||95===b||rZ(b)?(e=!0,a.consume(b),g):i(b)}function h(b){return a.consume(b),d=!0,g}function i(g){return e&&d&&rY(f.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),b(g)):c(g)}},previous:se},sa={},sb=48;for(;sb<123;)sa[sb]=r9,58==++sb?sb=65:91===sb&&(sb=97);function sc(a){return null===a||40===a||42===a||95===a||91===a||93===a||126===a||r$(a)}function sd(a){return!rY(a)}function se(a){return!(47===a||sf(a))}function sf(a){return 43===a||45===a||46===a||95===a||rZ(a)}function sg(a){let b=a.length,c=!1;for(;b--;){let d=a[b][1];if(("labelLink"===d.type||"labelImage"===d.type)&&!d._balanced){c=!0;break}if(d._gfmAutolinkLiteralWalkedInto){c=!1;break}}return a.length>0&&!c&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),c}function sh(a){return null!==a&&(a<0||32===a)}function si(a){return -2===a||-1===a||32===a}function sj(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function sk(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return si(d)?(a.enter(c),function d(g){return si(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}sa[43]=r9,sa[45]=r9,sa[46]=r9,sa[95]=r9,sa[72]=[r9,r8],sa[104]=[r9,r8],sa[87]=[r9,r7],sa[119]=[r9,r7],sj(/[A-Za-z]/),sj(/[\dA-Za-z]/),sj(/[#-'*+\--9=?A-Z^-~]/),sj(/\d/),sj(/[\dA-Fa-f]/),sj(/[!-/:-@[-`{-~]/),sj(/\p{P}|\p{S}/u),sj(/\s/);let sl={tokenize:function(a,b,c){let d=this;return sk(a,function(a){let e=d.events[d.events.length-1];return e&&"gfmFootnoteDefinitionIndent"===e[1].type&&4===e[2].sliceSerialize(e[1],!0).length?b(a):c(a)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function sm(a,b,c){let d,e=this,f=e.events.length,g=e.parser.gfmFootnotes||(e.parser.gfmFootnotes=[]);for(;f--;){let a=e.events[f][1];if("labelImage"===a.type){d=a;break}if("gfmFootnoteCall"===a.type||"labelLink"===a.type||"label"===a.type||"image"===a.type||"link"===a.type)break}return function(f){if(!d||!d._balanced)return c(f);let h=pU(e.sliceSerialize({start:d.end,end:e.now()}));return 94===h.codePointAt(0)&&g.includes(h.slice(1))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(f),a.exit("gfmFootnoteCallLabelMarker"),b(f)):c(f)}}function sn(a,b){let c=a.length;for(;c--;)if("labelImage"===a[c][1].type&&"enter"===a[c][0]){a[c][1];break}a[c+1][1].type="data",a[c+3][1].type="gfmFootnoteCallLabelMarker";let d={type:"gfmFootnoteCall",start:Object.assign({},a[c+3][1].start),end:Object.assign({},a[a.length-1][1].end)},e={type:"gfmFootnoteCallMarker",start:Object.assign({},a[c+3][1].end),end:Object.assign({},a[c+3][1].end)};e.end.column++,e.end.offset++,e.end._bufferIndex++;let f={type:"gfmFootnoteCallString",start:Object.assign({},e.end),end:Object.assign({},a[a.length-1][1].start)},g={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},h=[a[c+1],a[c+2],["enter",d,b],a[c+3],a[c+4],["enter",e,b],["exit",e,b],["enter",f,b],["enter",g,b],["exit",g,b],["exit",f,b],a[a.length-2],a[a.length-1],["exit",d,b]];return a.splice(c,a.length-c+1,...h),a}function so(a,b,c){let d,e=this,f=e.parser.gfmFootnotes||(e.parser.gfmFootnotes=[]),g=0;return function(b){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(b),a.exit("gfmFootnoteCallLabelMarker"),h};function h(b){return 94!==b?c(b):(a.enter("gfmFootnoteCallMarker"),a.consume(b),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",i)}function i(h){if(g>999||93===h&&!d||null===h||91===h||sh(h))return c(h);if(93===h){a.exit("chunkString");let d=a.exit("gfmFootnoteCallString");return f.includes(pU(e.sliceSerialize(d)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(h),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),b):c(h)}return sh(h)||(d=!0),g++,a.consume(h),92===h?j:i}function j(b){return 91===b||92===b||93===b?(a.consume(b),g++,i):i(b)}}function sp(a,b,c){let d,e,f=this,g=f.parser.gfmFootnotes||(f.parser.gfmFootnotes=[]),h=0;return function(b){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),i};function i(b){return 94===b?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",j):c(b)}function j(b){if(h>999||93===b&&!e||null===b||91===b||sh(b))return c(b);if(93===b){a.exit("chunkString");let c=a.exit("gfmFootnoteDefinitionLabelString");return d=pU(f.sliceSerialize(c)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),l}return sh(b)||(e=!0),h++,a.consume(b),92===b?k:j}function k(b){return 91===b||92===b||93===b?(a.consume(b),h++,j):j(b)}function l(b){return 58===b?(a.enter("definitionMarker"),a.consume(b),a.exit("definitionMarker"),g.includes(d)||g.push(d),sk(a,n,"gfmFootnoteDefinitionWhitespace")):c(b)}function n(a){return b(a)}}function sq(a,b,c){return a.check(pd,b,a.attempt(sl,b,c))}function sr(a){a.exit("gfmFootnoteDefinition")}function ss(a){return null!==a&&a<-2}function st(a){return null!==a&&(a<0||32===a)}function su(a){return -2===a||-1===a||32===a}function sv(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function sw(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return su(d)?(a.enter(c),function d(g){return su(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}sv(/[A-Za-z]/),sv(/[\dA-Za-z]/),sv(/[#-'*+\--9=?A-Z^-~]/),sv(/\d/),sv(/[\dA-Fa-f]/),sv(/[!-/:-@[-`{-~]/),sv(/\p{P}|\p{S}/u),sv(/\s/);class sx{constructor(){this.map=[]}add(a,b,c){!function(a,b,c,d){let e=0;if(0!==c||0!==d.length){for(;e<a.map.length;){if(a.map[e][0]===b){a.map[e][1]+=c,a.map[e][2].push(...d);return}e+=1}a.map.push([b,c,d])}}(this,a,b,c)}consume(a){if(this.map.sort(function(a,b){return a[0]-b[0]}),0===this.map.length)return;let b=this.map.length,c=[];for(;b>0;)b-=1,c.push(a.slice(this.map[b][0]+this.map[b][1]),this.map[b][2]),a.length=this.map[b][0];c.push(a.slice()),a.length=0;let d=c.pop();for(;d;){for(let b of d)a.push(b);d=c.pop()}this.map.length=0}}function sy(a,b,c){let d,e=this,f=0,g=0;return function(a){let b=e.events.length-1;for(;b>-1;){let a=e.events[b][1].type;if("lineEnding"===a||"linePrefix"===a)b--;else break}let d=b>-1?e.events[b][1].type:null,f="tableHead"===d||"tableRow"===d?t:h;return f===t&&e.parser.lazy[e.now().line]?c(a):f(a)};function h(b){var c;return a.enter("tableHead"),a.enter("tableRow"),124===(c=b)||(d=!0,g+=1),i(c)}function i(b){return null===b?c(b):ss(b)?g>1?(g=0,e.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),l):c(b):su(b)?sw(a,i,"whitespace")(b):(g+=1,d&&(d=!1,f+=1),124===b)?(a.enter("tableCellDivider"),a.consume(b),a.exit("tableCellDivider"),d=!0,i):(a.enter("data"),j(b))}function j(b){return null===b||124===b||st(b)?(a.exit("data"),i(b)):(a.consume(b),92===b?k:j)}function k(b){return 92===b||124===b?(a.consume(b),j):j(b)}function l(b){return(e.interrupt=!1,e.parser.lazy[e.now().line])?c(b):(a.enter("tableDelimiterRow"),d=!1,su(b))?sw(a,n,"linePrefix",e.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):n(b)}function n(b){return 45===b||58===b?p(b):124===b?(d=!0,a.enter("tableCellDivider"),a.consume(b),a.exit("tableCellDivider"),o):c(b)}function o(b){return su(b)?sw(a,p,"whitespace")(b):p(b)}function p(b){return 58===b?(g+=1,d=!0,a.enter("tableDelimiterMarker"),a.consume(b),a.exit("tableDelimiterMarker"),q):45===b?(g+=1,q(b)):null===b||ss(b)?s(b):c(b)}function q(b){return 45===b?(a.enter("tableDelimiterFiller"),function b(c){return 45===c?(a.consume(c),b):58===c?(d=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(c),a.exit("tableDelimiterMarker"),r):(a.exit("tableDelimiterFiller"),r(c))}(b)):c(b)}function r(b){return su(b)?sw(a,s,"whitespace")(b):s(b)}function s(e){if(124===e)return n(e);if(null===e||ss(e))return d&&f===g?(a.exit("tableDelimiterRow"),a.exit("tableHead"),b(e)):c(e);return c(e)}function t(b){return a.enter("tableRow"),u(b)}function u(c){return 124===c?(a.enter("tableCellDivider"),a.consume(c),a.exit("tableCellDivider"),u):null===c||ss(c)?(a.exit("tableRow"),b(c)):su(c)?sw(a,u,"whitespace")(c):(a.enter("data"),v(c))}function v(b){return null===b||124===b||st(b)?(a.exit("data"),u(b)):(a.consume(b),92===b?w:v)}function w(b){return 92===b||124===b?(a.consume(b),v):v(b)}}function sz(a,b){let c,d,e,f=-1,g=!0,h=0,i=[0,0,0,0],j=[0,0,0,0],k=!1,l=0,n=new sx;for(;++f<a.length;){let o=a[f],p=o[1];"enter"===o[0]?"tableHead"===p.type?(k=!1,0!==l&&(sB(n,b,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},n.add(f,0,[["enter",c,b]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(g=!0,e=void 0,i=[0,0,0,0],j=[0,f+1,0,0],k&&(k=!1,d={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},n.add(f,0,[["enter",d,b]])),h="tableDelimiterRow"===p.type?2:d?3:1):h&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)?(g=!1,0===j[2]&&(0!==i[1]&&(j[0]=j[1],e=sA(n,b,i,h,void 0,e),i=[0,0,0,0]),j[2]=f)):"tableCellDivider"===p.type&&(g?g=!1:(0!==i[1]&&(j[0]=j[1],e=sA(n,b,i,h,void 0,e)),j=[(i=j)[1],f,0,0])):"tableHead"===p.type?(k=!0,l=f):"tableRow"===p.type||"tableDelimiterRow"===p.type?(l=f,0!==i[1]?(j[0]=j[1],e=sA(n,b,i,h,f,e)):0!==j[1]&&(e=sA(n,b,j,h,f,e)),h=0):h&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(j[3]=f)}for(0!==l&&sB(n,b,l,c,d),n.consume(b.events),f=-1;++f<b.events.length;){let a=b.events[f];"enter"===a[0]&&"table"===a[1].type&&(a[1]._align=function(a,b){let c=!1,d=[];for(;b<a.length;){let e=a[b];if(c){if("enter"===e[0])"tableContent"===e[1].type&&d.push("tableDelimiterMarker"===a[b+1][1].type?"left":"none");else if("tableContent"===e[1].type){if("tableDelimiterMarker"===a[b-1][1].type){let a=d.length-1;d[a]="left"===d[a]?"center":"right"}}else if("tableDelimiterRow"===e[1].type)break}else"enter"===e[0]&&"tableDelimiterRow"===e[1].type&&(c=!0);b+=1}return d}(b.events,f))}return a}function sA(a,b,c,d,e,f){0!==c[0]&&(f.end=Object.assign({},sC(b.events,c[0])),a.add(c[0],0,[["exit",f,b]]));let g=sC(b.events,c[1]);if(f={type:1===d?"tableHeader":2===d?"tableDelimiter":"tableData",start:Object.assign({},g),end:Object.assign({},g)},a.add(c[1],0,[["enter",f,b]]),0!==c[2]){let e=sC(b.events,c[2]),f=sC(b.events,c[3]),g={type:"tableContent",start:Object.assign({},e),end:Object.assign({},f)};if(a.add(c[2],0,[["enter",g,b]]),2!==d){let d=b.events[c[2]],e=b.events[c[3]];if(d[1].end=Object.assign({},e[1].end),d[1].type="chunkText",d[1].contentType="text",c[3]>c[2]+1){let b=c[2]+1,d=c[3]-c[2]-1;a.add(b,d,[])}}a.add(c[3]+1,0,[["exit",g,b]])}return void 0!==e&&(f.end=Object.assign({},sC(b.events,e)),a.add(e,0,[["exit",f,b]]),f=void 0),f}function sB(a,b,c,d,e){let f=[],g=sC(b.events,c);e&&(e.end=Object.assign({},g),f.push(["exit",e,b])),d.end=Object.assign({},g),f.push(["exit",d,b]),a.add(c+1,0,f)}function sC(a,b){let c=a[b],d="enter"===c[0]?"start":"end";return c[1][d]}function sD(a){return -2===a||-1===a||32===a}function sE(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}sE(/[A-Za-z]/),sE(/[\dA-Za-z]/),sE(/[#-'*+\--9=?A-Z^-~]/),sE(/\d/),sE(/[\dA-Fa-f]/),sE(/[!-/:-@[-`{-~]/),sE(/\p{P}|\p{S}/u),sE(/\s/);let sF={name:"tasklistCheck",tokenize:function(a,b,c){let d=this;return function(b){return null===d.previous&&d._gfmTasklistFirstContentOfListItem?(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(b),a.exit("taskListCheckMarker"),e):c(b)};function e(b){return null!==b&&(b<0||32===b)?(a.enter("taskListCheckValueUnchecked"),a.consume(b),a.exit("taskListCheckValueUnchecked"),f):88===b||120===b?(a.enter("taskListCheckValueChecked"),a.consume(b),a.exit("taskListCheckValueChecked"),f):c(b)}function f(b){return 93===b?(a.enter("taskListCheckMarker"),a.consume(b),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),g):c(b)}function g(d){return null!==d&&d<-2?b(d):sD(d)?a.check({tokenize:sG},b,c)(d):c(d)}}};function sG(a,b,c){var d,e;let f,g;return d=function(a){return null===a?c(a):b(a)},e="whitespace",f=1/0,g=0,function(b){return sD(b)?(a.enter(e),function b(c){return sD(c)&&g++<f?(a.consume(c),b):(a.exit(e),d(c))}(b)):d(b)}}let sH={};function sI(a){let b,c,d,e=a||sH,f=this.data(),g=f.micromarkExtensions||(f.micromarkExtensions=[]),h=f.fromMarkdownExtensions||(f.fromMarkdownExtensions=[]),i=f.toMarkdownExtensions||(f.toMarkdownExtensions=[]);g.push(oW([{text:sa},{document:{91:{name:"gfmFootnoteDefinition",tokenize:sp,continuation:{tokenize:sq},exit:sr}},text:{91:{name:"gfmFootnoteCall",tokenize:so},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sm,resolveTo:sn}}},(b=(e||{}).singleTilde,c={name:"strikethrough",tokenize:function(a,c,d){let e=this.previous,f=this.events,g=0;return function(h){return 126===e&&"characterEscape"!==f[f.length-1][1].type?d(h):(a.enter("strikethroughSequenceTemporary"),function f(h){let i=pt(e);if(126===h)return g>1?d(h):(a.consume(h),g++,f);if(g<2&&!b)return d(h);let j=a.exit("strikethroughSequenceTemporary"),k=pt(h);return j._open=!k||2===k&&!!i,j._close=!i||2===i&&!!k,c(h)}(h))}},resolveAll:function(a,b){let c=-1;for(;++c<a.length;)if("enter"===a[c][0]&&"strikethroughSequenceTemporary"===a[c][1].type&&a[c][1]._close){let d=c;for(;d--;)if("exit"===a[d][0]&&"strikethroughSequenceTemporary"===a[d][1].type&&a[d][1]._open&&a[c][1].end.offset-a[c][1].start.offset==a[d][1].end.offset-a[d][1].start.offset){a[c][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";let e={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[c][1].end)},f={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[c][1].start)},g=[["enter",e,b],["enter",a[d][1],b],["exit",a[d][1],b],["enter",f,b]],h=b.parser.constructs.insideSpan.null;h&&oT(g,g.length,0,pu(h,a.slice(d+1,c),b)),oT(g,g.length,0,[["exit",f,b],["enter",a[c][1],b],["exit",a[c][1],b],["exit",e,b]]),oT(a,d-1,c-d+3,g),c=d+g.length-2;break}}for(c=-1;++c<a.length;)"strikethroughSequenceTemporary"===a[c][1].type&&(a[c][1].type="data");return a}},null==b&&(b=!0),{text:{126:c},insideSpan:{null:[c]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:sy,resolveAll:sz}}},{text:{91:sF}}])),h.push([{transforms:[rr],enter:{literalAutolink:rl,literalAutolinkEmail:rm,literalAutolinkHttp:rm,literalAutolinkWww:rm},exit:{literalAutolink:rq,literalAutolinkEmail:rp,literalAutolinkHttp:rn,literalAutolinkWww:ro}},{enter:{gfmFootnoteCallString:rv,gfmFootnoteCall:rw,gfmFootnoteDefinitionLabelString:rx,gfmFootnoteDefinition:ry},exit:{gfmFootnoteCallString:rz,gfmFootnoteCall:rA,gfmFootnoteDefinitionLabelString:rB,gfmFootnoteDefinition:rC}},{canContainEols:["delete"],enter:{strikethrough:rH},exit:{strikethrough:rI}},{enter:{table:rO,tableData:rS,tableHeader:rS,tableRow:rQ},exit:{codeText:rT,table:rP,tableData:rR,tableHeader:rR,tableRow:rR}},{exit:{taskListCheckValueChecked:rV,taskListCheckValueUnchecked:rV,paragraph:rW}}]),i.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:rj,notInConstruct:rk},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:rj,notInConstruct:rk},{character:":",before:"[ps]",after:"\\/",inConstruct:rj,notInConstruct:rk}]},(d=!1,e&&e.firstLineBlank&&(d=!0),{handlers:{footnoteDefinition:function(a,b,c,e){let f=c.createTracker(e),g=f.move("[^"),h=c.enter("footnoteDefinition"),i=c.enter("label");return g+=f.move(c.safe(c.associationId(a),{before:g,after:"]"})),i(),g+=f.move("]:"),a.children&&a.children.length>0&&(f.shift(4),g+=f.move((d?"\n":" ")+c.indentLines(c.containerFlow(a,f.current()),d?rF:rE))),h(),g},footnoteReference:rD},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rG}],handlers:{delete:rJ}},function(a){let b=a||{},c=b.tableCellPadding,d=b.tablePipeAlign,e=b.stringLength,f=c?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(a,b,c){let d=rM(a,b,c);return c.stack.includes("tableCell")&&(d=d.replace(/\|/g,"\\$&")),d},table:function(a,b,c,d){return h(function(a,b,c){let d=a.children,e=-1,f=[],g=b.enter("table");for(;++e<d.length;)f[e]=i(d[e],b,c);return g(),f}(a,c,d),a.align)},tableCell:g,tableRow:function(a,b,c,d){let e=h([i(a,c,d)]);return e.slice(0,e.indexOf("\n"))}}};function g(a,b,c,d){let e=c.enter("tableCell"),g=c.enter("phrasing"),h=c.containerPhrasing(a,{...d,before:f,after:f});return g(),e(),h}function h(a,b){return function(a,b){let c=b||{},d=(c.align||[]).concat(),e=c.stringLength||rK,f=[],g=[],h=[],i=[],j=0,k=-1;for(;++k<a.length;){let b=[],d=[],f=-1;for(a[k].length>j&&(j=a[k].length);++f<a[k].length;){var l;let g=null==(l=a[k][f])?"":String(l);if(!1!==c.alignDelimiters){let a=e(g);d[f]=a,(void 0===i[f]||a>i[f])&&(i[f]=a)}b.push(g)}g[k]=b,h[k]=d}let n=-1;if("object"==typeof d&&"length"in d)for(;++n<j;)f[n]=rL(d[n]);else{let a=rL(d);for(;++n<j;)f[n]=a}n=-1;let o=[],p=[];for(;++n<j;){let a=f[n],b="",d="";99===a?(b=":",d=":"):108===a?b=":":114===a&&(d=":");let e=!1===c.alignDelimiters?1:Math.max(1,i[n]-b.length-d.length),g=b+"-".repeat(e)+d;!1!==c.alignDelimiters&&((e=b.length+e+d.length)>i[n]&&(i[n]=e),p[n]=e),o[n]=g}g.splice(1,0,o),h.splice(1,0,p),k=-1;let q=[];for(;++k<g.length;){let a=g[k],b=h[k];n=-1;let d=[];for(;++n<j;){let e=a[n]||"",g="",h="";if(!1!==c.alignDelimiters){let a=i[n]-(b[n]||0),c=f[n];114===c?g=" ".repeat(a):99===c?a%2?(g=" ".repeat(a/2+.5),h=" ".repeat(a/2-.5)):h=g=" ".repeat(a/2):h=" ".repeat(a)}!1===c.delimiterStart||n||d.push("|"),!1!==c.padding&&(!1!==c.alignDelimiters||""!==e)&&(!1!==c.delimiterStart||n)&&d.push(" "),!1!==c.alignDelimiters&&d.push(g),d.push(e),!1!==c.alignDelimiters&&d.push(h),!1!==c.padding&&d.push(" "),(!1!==c.delimiterEnd||n!==j-1)&&d.push("|")}q.push(!1===c.delimiterEnd?d.join("").replace(/ +$/,""):d.join(""))}return q.join("\n")}(a,{align:b,alignDelimiters:d,padding:c,stringLength:e})}function i(a,b,c){let d=a.children,e=-1,f=[],h=b.enter("tableRow");for(;++e<d.length;)f[e]=g(d[e],a,b,c);return h(),f}}(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rX}}]})}let sJ=a=>{let b=new Date(a);return`${b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`};function sK({mentalModel:a}){return(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),a.trigger?.refresh_after_consolidation&&(0,C.jsxs)("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 text-xs font-medium",children:[(0,C.jsx)(nO,{className:"w-3 h-3"}),"Auto refresh"]})]}),(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:a.id}),a.source_query&&(0,C.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a.source_query})]}),(0,C.jsxs)("div",{className:"flex gap-8",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:sJ(a.created_at)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Last Refreshed"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:sJ(a.last_refreshed_at)})]})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map((a,b)=>(0,C.jsx)("span",{className:"px-2 py-0.5 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded text-xs",children:a},b))})]})]})}function sL({before:a,after:b}){let{left:c,right:d}=function(a,b){let c=a.split("\n"),d=b.split("\n"),e=c.length,f=d.length,g=Array.from({length:e+1},()=>Array(f+1).fill(0));for(let a=1;a<=e;a++)for(let b=1;b<=f;b++)g[a][b]=c[a-1]===d[b-1]?g[a-1][b-1]+1:Math.max(g[a-1][b],g[a][b-1]);let h=[],i=e,j=f;for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(h.push({type:"same",text:c[i-1]}),i--,j--):j>0&&(0===i||g[i][j-1]>=g[i-1][j])?(h.push({type:"added",text:d[j-1]}),j--):(h.push({type:"removed",text:c[i-1]}),i--);h.reverse();let k=[],l=[],n=0;for(;n<h.length;){let a=h[n];if("same"===a.type)k.push(a),l.push(a),n++;else{let a=[],b=[];for(;n<h.length&&"same"!==h[n].type;)"removed"===h[n].type?a.push(h[n].text):b.push(h[n].text),n++;let c=Math.max(a.length,b.length);for(let d=0;d<c;d++)k.push(d<a.length?{type:"removed",text:a[d]}:{type:"same",text:""}),l.push(d<b.length?{type:"added",text:b[d]}:{type:"same",text:""})}}return{left:k,right:l}}(a,b);return c.some(a=>"same"!==a.type)||d.some(a=>"same"!==a.type)?(0,C.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-border border border-border rounded-md overflow-hidden text-xs font-mono",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"px-3 py-1.5 bg-muted text-muted-foreground font-sans font-semibold text-xs uppercase tracking-wide border-b border-border",children:"Before"}),c.map((a,b)=>(0,C.jsx)("div",{className:`px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem] ${"removed"===a.type?"bg-red-500/10 text-red-700 dark:text-red-400":"text-foreground"}`,children:a.text},b))]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"px-3 py-1.5 bg-muted text-muted-foreground font-sans font-semibold text-xs uppercase tracking-wide border-b border-border",children:"After"}),d.map((a,b)=>(0,C.jsx)("div",{className:`px-3 py-0.5 whitespace-pre-wrap leading-5 min-h-[1.25rem] ${"added"===a.type?"bg-green-500/10 text-green-700 dark:text-green-400":"text-foreground"}`,children:a.text},b))]})]}):(0,C.jsx)("span",{className:"text-sm text-muted-foreground italic",children:"unchanged"})}function sM({history:a,currentContent:b}){let[c,d]=(0,D.useState)(0),e=a[c],f=0===c?b:a[c-1].previous_content??"";return(0,C.jsxs)("div",{className:"space-y-3",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Change ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:a.length-c})," of"," ",a.length," · ",new Date(e.changed_at).toLocaleString()]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:c===a.length-1,onClick:()=>d(c+1),children:(0,C.jsx)(P,{className:"h-3.5 w-3.5"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-7 w-7 p-0",disabled:0===c,onClick:()=>d(c-1),children:(0,C.jsx)(Q.ChevronRight,{className:"h-3.5 w-3.5"})})]})]}),null!==e.previous_content?(0,C.jsx)(sL,{before:e.previous_content,after:f}):(0,C.jsx)("div",{className:"border border-border rounded-lg p-3",children:(0,C.jsx)("span",{className:"text-sm text-muted-foreground italic",children:"Previous content not available"})})]})}function sN({mentalModelId:a,onClose:b,initialTab:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(null),[g,h]=(0,D.useState)(!1),[i,j]=(0,D.useState)(null),[k,l]=(0,D.useState)(c??"model"),[n,o]=(0,D.useState)(null),[p,q]=(0,D.useState)(!1);(0,D.useEffect)(()=>{a&&d&&(async()=>{h(!0),j(null),f(null),o(null),l(c??"model");try{let b=await V.client.getMentalModel(d,a);f(b)}catch(a){console.error("Error loading mental model:",a),j(a.message)}finally{h(!1)}})()},[a,d]),(0,D.useEffect)(()=>{"history"===k&&e&&d&&null===n&&(async()=>{q(!0);try{let a=await V.client.getMentalModelHistory(d,e.id);o(a)}catch(a){console.error("Error loading mental model history:",a),o([])}finally{q(!1)}})()},[k,e,d,n]);let r=null!==a;return(0,C.jsx)(bk.Dialog,{open:r,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nN.VisuallyHidden,{children:(0,C.jsx)(bk.DialogTitle,{children:"Mental Model Details"})}),g?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)(bi.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):i?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)("div",{className:"text-center text-destructive",children:(0,C.jsxs)("div",{className:"text-sm",children:["Error: ",i]})})}):e?(0,C.jsxs)(bm.Tabs,{value:k,onValueChange:l,className:"flex-1 flex flex-col overflow-hidden",children:[(0,C.jsxs)(bm.TabsList,{className:"grid w-full grid-cols-2",children:[(0,C.jsxs)(bm.TabsTrigger,{value:"model",className:"flex items-center gap-1.5",children:[(0,C.jsx)(N.FileText,{className:"w-3.5 h-3.5"}),"Mental Model"]}),(0,C.jsxs)(bm.TabsTrigger,{value:"history",className:"flex items-center gap-1.5",children:[(0,C.jsx)(bj,{className:"w-3.5 h-3.5"}),"History",n&&n.length>0?` (${n.length})`:""]})]}),(0,C.jsxs)("div",{className:"flex-1 overflow-y-auto mt-4",children:[(0,C.jsx)(bm.TabsContent,{value:"model",className:"mt-0",children:(0,C.jsx)(sK,{mentalModel:e})}),(0,C.jsx)(bm.TabsContent,{value:"history",className:"mt-0",children:p?(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)(bi.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):n&&n.length>0?(0,C.jsx)(sM,{history:n,currentContent:e.content}):(0,C.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No history recorded yet."})})]})]}):null]})})}function sO(){let a,b,c,d,e,f,g,h,i,j,k,{currentBank:l}=(0,H.useBank)(),[n,o]=(0,D.useState)(""),[p,q]=(0,D.useState)("mid"),[r,s]=(0,D.useState)(4096),[t,u]=(0,D.useState)(!0),[v,w]=(0,D.useState)(!0),[x,y]=(0,D.useState)("answer"),[z,A]=(0,D.useState)(null),[B,E]=(0,D.useState)(!1),[F,G]=(0,D.useState)(""),[I,J]=(0,D.useState)("any"),[K,N]=(0,D.useState)(""),[O,P]=(0,D.useState)(!1),[Q,R]=(0,D.useState)(!1),[S,T]=(0,D.useState)(null),[U,Y]=(0,D.useState)(null),[Z,$]=(0,D.useState)(null),[_,aa]=(0,D.useState)(!1),[ab,ac]=(0,D.useState)(null),[ae,af]=(0,D.useState)(null),[ai,aj]=(0,D.useState)(!1),[ak,al]=(0,D.useState)(null),[am,an]=(0,D.useState)("world"),ao="General Feedback",ap=async a=>{if(ac(a),af(null),l&&a?.id){aj(!0);try{let b=await V.client.listObservations(l),c=b.items?.find(b=>b.id===a.id);af(c||a)}catch(b){console.error("Failed to load observation:",b),af(a)}finally{aj(!1)}}},aq=async()=>{if(l&&K.trim()){P(!0);try{let a=await V.client.listDirectives(l),b=a.items?.find(a=>a.name===ao);if(b){let a=b.content?`${b.content}
|
|
8
|
-
${K.trim()}`:K.trim();await V.client.updateDirective(l,b.id,{content:a})}else await V.client.createDirective(l,{name:ao,content:K.trim()});N(""),R(!0),setTimeout(()=>R(!1),3e3)}catch(a){}finally{P(!1)}}},ar=async()=>{if(l&&n){E(!0),y("answer");try{let a=F.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=await V.client.reflect({bank_id:l,query:n,budget:p,max_tokens:r,include_facts:t,include_tool_calls:v,...a.length>0&&{tags:a,tags_match:I}});A(b)}catch(a){}finally{E(!1)}}};return l?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"pt-6",children:[(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsxs)("div",{className:"flex-1 relative",children:[(0,C.jsx)(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:"What would you like to reflect on?",className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&ar()})]}),(0,C.jsx)(W.Button,{onClick:ar,disabled:B||!n,className:"h-12 px-8",children:B?"Reflecting...":"Reflect"})]}),(0,C.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Budget:"}),(0,C.jsxs)(mU.Select,{value:p,onValueChange:a=>q(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mU.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mU.SelectItem,{value:"high",children:"High"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,C.jsx)(X.Input,{type:"number",value:r,onChange:a=>s(parseInt(a.target.value)||4096),className:"w-24 h-8"})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:t,onCheckedChange:a=>u(a)}),(0,C.jsx)("span",{className:"text-sm",children:"Include Source"})]}),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:v,onCheckedChange:a=>w(a)}),(0,C.jsx)("span",{className:"text-sm",children:"Include Tools"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,C.jsx)(ag,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("div",{className:"flex-1 max-w-md",children:(0,C.jsx)(X.Input,{type:"text",value:F,onChange:a=>G(a.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,C.jsxs)(mU.Select,{value:I,onValueChange:a=>J(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mU.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),B&&(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Reflecting on memories..."})]})}),!B&&z&&(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[z.usage&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Input tokens:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.usage.input_tokens?.toLocaleString()})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Output tokens:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.usage.output_tokens?.toLocaleString()})]})]}),z.trace?.tool_calls&&(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Tool calls:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.trace.tool_calls.length}),(0,C.jsxs)("span",{className:"text-muted-foreground",children:["(",z.trace.tool_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),z.trace?.llm_calls&&(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"LLM calls:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.trace.llm_calls.length}),(0,C.jsxs)("span",{className:"text-muted-foreground",children:["(",z.trace.llm_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),(0,C.jsx)("div",{className:"flex-1"}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(a=>(0,C.jsx)("button",{onClick:()=>y(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${x===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===a?"Answer":"trace"===a?"Trace":"JSON"},a))})]}),"answer"===x&&(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{children:"Answer"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:z.text})})})]}),(0,C.jsxs)(mW,{className:"border-blue-200 dark:border-blue-800",children:[(0,C.jsxs)(mX,{className:"py-4",children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(m1,{className:"w-4 h-4"}),"Add Directive"]}),(0,C.jsx)(mZ,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,C.jsx)(m$,{className:"pt-0",children:Q?(0,C.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,C.jsx)("span",{className:"text-lg",children:"✓"}),(0,C.jsxs)("span",{className:"text-sm font-medium",children:["Directive saved to ",ao]})]}):(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsx)(m4.Textarea,{value:K,onChange:a=>N(a.target.value),placeholder:"e.g., Always respond in formal English...",className:"flex-1 min-h-[60px] resize-none",onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&aq()}}),(0,C.jsx)(W.Button,{onClick:aq,disabled:O||!K.trim(),className:"self-end",children:O?"Saving...":"Save"})]})})]})]}),"trace"===x&&(0,C.jsxs)("div",{className:"space-y-4",children:[z.observations_created&&z.observations_created.length>0&&(0,C.jsxs)(mW,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,C.jsxs)(mX,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(m0,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",z.observations_created.length,")"]}),(0,C.jsx)(mZ,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,C.jsx)(m$,{className:"pt-4",children:(0,C.jsx)("div",{className:"space-y-2",children:z.observations_created.map((a,b)=>(0,C.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,C.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:a.name}),(0,C.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:a.description}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",a.id]})]},b))})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,C.jsxs)(mW,{className:"h-fit",children:[(0,C.jsxs)(mX,{className:"pb-3",children:[(0,C.jsx)(mY,{className:"text-base",children:"Execution Trace"}),(0,C.jsxs)(mZ,{className:"text-xs",children:[z.iterations||0," iteration",1!==(z.iterations||0)?"s":""," •"," ",(z.trace?.llm_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)+(z.trace?.tool_calls?.reduce((a,b)=>a+b.duration_ms,0)||0),"ms total"]})]}),(0,C.jsx)(m$,{children:v?z.trace?.llm_calls&&z.trace.llm_calls.length>0||z.trace?.tool_calls&&z.trace.tool_calls.length>0?(0,C.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(a=z.trace?.llm_calls||[],b=z.trace?.tool_calls||[],c=[],a.forEach((d,e)=>{let f=b.filter(a=>a.iteration===e+1),g=e===a.length-1,h=d.scope.includes("final")||g&&0===f.length,i=h?a.length:e+1;c.push({type:"llm",llm:d,iteration:i,isFinal:h}),f.length>0&&c.push({type:"tools",tools:f,iteration:e+1})}),c.map((a,b)=>(0,C.jsxs)("div",{className:"relative",children:[b<c.length-1&&(0,C.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===a.type?(0,C.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,C.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:a.isFinal?(0,C.jsx)(bh.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,C.jsx)("span",{className:"text-[10px] font-semibold",children:a.iteration})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsx)("span",{className:"font-medium text-sm",children:a.isFinal?"Response generated":"Agent decided"}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),a.llm.duration_ms,"ms"]})]}),(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:a.isFinal?"Final answer":"Called tools below"})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,C.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,C.jsx)(m3,{className:"w-3 h-3",fill:"currentColor"})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Executing ",a.tools?.length," tool",a.tools?.length!==1?"s":""]}),a.tools?.map((a,b)=>(0,C.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.tool}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),a.duration_ms,"ms"]})]}),(0,C.jsxs)("div",{className:"p-2 space-y-2",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Input:"}),(0,C.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,C.jsx)(nM,{src:a.input,collapsed:1,theme:"default"})})]}),a.output&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Output:"}),(0,C.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,C.jsx)(nM,{src:a.output,collapsed:1,theme:"default"})})]})]})]},b))]})]})]},b)))}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"No operations"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No LLM or tool calls were made during this reflection."})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Tool Calls" to see trace.'})]})]})})]}),(0,C.jsxs)(mW,{className:"h-fit",children:[(0,C.jsxs)(mX,{className:"pb-3",children:[(0,C.jsx)(mY,{className:"text-base",children:"Based On"}),(0,C.jsxs)(mZ,{className:"text-xs",children:[(z.based_on?.memories?.length||0)+(z.based_on?.observations?.filter(a=>"directive"!==a.subtype)?.length||0)+(z.based_on?.directives?.length||0)," ","items used"]})]}),(0,C.jsx)(m$,{children:t?z.based_on?.memories&&z.based_on.memories.length>0||z.based_on?.mental_models&&z.based_on.mental_models.length>0||z.based_on?.directives&&z.based_on.directives.length>0||z.based_on?.observations&&z.based_on.observations.length>0?(e=(d=z.based_on?.memories||[]).filter(a=>"world"===a.type),f=d.filter(a=>"experience"===a.type),g=z.based_on?.mental_models||[],h=(z.based_on?.observations||[]).filter(a=>"directive"!==a.subtype),j=[{id:"directives",label:"Directives",count:(i=z.based_on?.directives||[]).length},{id:"mental_models",label:"Mental Models",count:g.length},{id:"observations",label:"Observations",count:h.length},{id:"world",label:"World",count:e.length},{id:"experience",label:"Experience",count:f.length}],k=(()=>{switch(am){case"directives":return i;case"mental_models":return g;case"observations":return h;case"world":return e;case"experience":return f;default:return[]}})(),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:j.map(a=>(0,C.jsxs)("button",{onClick:()=>an(a.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${am===a.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[a.label," (",a.count,")"]},a.id))}),k.length>0?(0,C.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:k.map((a,b)=>{let c,d;return(0,C.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==am?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==am&&("observations"===am?ap(a):"mental_models"===am?al(a.id):T(a.id))},children:"directives"===am?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"font-medium text-sm",children:a.name}),a.content&&(0,C.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:a.content})]}):"observations"===am?(0,C.jsx)("div",{className:"font-medium text-sm",children:a.name}):"mental_models"===am?(d=(c=a.text?.indexOf(": ")??-1)>0?a.text.slice(0,c):a.id,(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"font-medium text-sm",children:d}),(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:a.id})]})):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text}),a.context&&(0,C.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:a.context})]})},a.id||b)})}):(0,C.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:["No ",am," items"]})]})):(0,C.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,C.jsx)(m_.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:"No facts found"}),(0,C.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:"No memories were used to generate this answer."})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Source" to see memories.'})]})]})})]})]})]}),"json"===x&&(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nM,{src:z,collapsed:2,theme:"default"})})})]})]}),!B&&!z&&(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Reflect"}),(0,C.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a question above to query the memory bank and generate a disposition-aware response."})]})}),(0,C.jsx)(bt,{memoryId:S,onClose:()=>T(null)}),U&&(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(m2,{className:"w-5 h-5"}),(0,C.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{Y(null),$(null)},children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]}),_?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,C.jsx)("p",{className:"mt-1 font-medium",children:Z?.name||U.name})]}),Z?.description&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,C.jsx)("p",{className:"mt-1 text-sm",children:Z.description})]}),Z?.tags&&Z.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.tags.map(a=>(0,C.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ag,{className:"w-2.5 h-2.5"}),a]},a))})]}),(Z?.content||U.content)&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,C.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:Z?.content||U.content})})]}),(0,C.jsxs)("div",{className:"pt-2 border-t",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:U.id})]})]})]})}),ab&&(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(m0,{className:"w-5 h-5"}),(0,C.jsx)("h2",{className:"text-lg font-semibold",children:"Observation"})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{ac(null),af(null)},children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]}),ai?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Text"}),(0,C.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:ae?.text||ab.text})})]}),ae?.tags&&ae.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:ae.tags.map(a=>(0,C.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ag,{className:"w-2.5 h-2.5"}),a]},a))})]}),ae?.source_memories&&ae.source_memories.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Source Memories (",ae.source_memories.length,")"]}),(0,C.jsx)("div",{className:"space-y-2",children:ae.source_memories.map((a,b)=>(0,C.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:a.text||("string"==typeof a?a:"")})},b))})]}),(0,C.jsxs)("div",{className:"pt-2 border-t",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ab.id})]})]})]})}),(0,C.jsx)(sN,{mentalModelId:ak,onClose:()=>al(null)})]}):(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start reflecting."})]})})}var sP=a.i(5784);let sQ=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function sR(){let a,b,c,d,e,f,g,h,i,j,k,l,n,o,{currentBank:p}=(0,H.useBank)(),[q,r]=(0,D.useState)(""),[s,t]=(0,D.useState)(["world"]),[u,v]=(0,D.useState)("mid"),[w,x]=(0,D.useState)(4096),[y,z]=(0,D.useState)(""),[A,B]=(0,D.useState)(!1),[E,G]=(0,D.useState)(!1),[I,K]=(0,D.useState)(""),[L,P]=(0,D.useState)("any"),[R,S]=(0,D.useState)(null),[T,U]=(0,D.useState)(null),[Z,$]=(0,D.useState)(null),[_,aa]=(0,D.useState)(null),[ab,ac]=(0,D.useState)(null),[ae,af]=(0,D.useState)(!1),[ah,ai]=(0,D.useState)("results"),[aj,ak]=(0,D.useState)(null),[al,am]=(0,D.useState)(new Set),[an,ao]=(0,D.useState)(new Set),ap=a=>{am(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},aq=a=>{ao(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},ar=a=>{let b=a.id||a.node_id;ak(R?.find(a=>a.id===b||a.node_id===b)||a)},as=async()=>{if(!p)return void F.toast.error("Validation error",{description:"Please select a memory bank first"});if(q){if(0===s.length)return void F.toast.error("Validation error",{description:"Please select at least one type (World, Experience, or Observations)"});af(!0);try{let a=I.split(",").map(a=>a.trim()).filter(a=>a.length>0),b={bank_id:p,query:q,types:s,budget:u,max_tokens:w,trace:!0,include:{entities:E?{max_tokens:500}:null,chunks:A?{max_tokens:8192}:null},...y&&{query_timestamp:y},...a.length>0&&{tags:a,tags_match:L}},c=await V.client.recall(b);S(c.results||[]),U(c.entities||null),$(c.chunks||null),aa(c.observations||null),ac(c.trace||null),ai("results")}catch(a){}finally{af(!1)}}},at=a=>{t(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])};return p?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"pt-6",children:[(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsxs)("div",{className:"flex-1 relative",children:[(0,C.jsx)(J.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:"What would you like to recall?",className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&as()})]}),(0,C.jsx)(W.Button,{onClick:as,disabled:ae||!q,className:"h-12 px-8",children:ae?"Searching...":"Recall"})]}),(0,C.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Types:"}),(0,C.jsxs)("div",{className:"flex gap-3",children:[["world","experience"].map(a=>(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:s.includes(a),onCheckedChange:()=>at(a)}),(0,C.jsx)("span",{className:"text-sm capitalize",children:a})]},a)),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:s.includes("observation"),onCheckedChange:()=>at("observation")}),(0,C.jsx)("span",{className:"text-sm",children:"Observations"})]})]})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(nO,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsxs)(mU.Select,{value:u,onValueChange:a=>v(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mU.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mU.SelectItem,{value:"high",children:"High"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,C.jsx)(X.Input,{type:"number",value:w,onChange:a=>x(parseInt(a.target.value)),className:"w-24 h-8"})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(ad,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"datetime-local",value:y,onChange:a=>z(a.target.value),className:"h-8",placeholder:"Query date"})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:A,onCheckedChange:a=>B(a)}),(0,C.jsx)(N.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("span",{className:"text-sm",children:"Chunks"})]}),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:E,onCheckedChange:a=>G(a)}),(0,C.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("span",{className:"text-sm",children:"Entities"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,C.jsx)(ag,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("div",{className:"flex-1 max-w-md",children:(0,C.jsx)(X.Input,{type:"text",value:I,onChange:a=>K(a.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,C.jsxs)(mU.Select,{value:L,onValueChange:a=>P(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mU.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),ae&&(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Searching memories..."})]})}),!ae&&R&&(0,C.jsxs)("div",{className:"space-y-4",children:[ab?.summary&&(0,C.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Results:"}),(0,C.jsx)("span",{className:"font-semibold",children:R.length})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Duration:"}),(0,C.jsxs)("span",{className:"font-semibold",children:[ab.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Nodes visited:"}),(0,C.jsx)("span",{className:"font-semibold",children:ab.summary.total_nodes_visited})]}),(0,C.jsx)("div",{className:"flex-1"}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(a=>(0,C.jsx)("button",{onClick:()=>ai(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ah===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===a?"Results":"trace"===a?"Trace":"JSON"},a))})]}),"results"===ah&&(0,C.jsxs)("div",{className:"space-y-4",children:[_&&_.length>0&&(0,C.jsxs)(mW,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,C.jsx)(mX,{className:"py-3",children:(0,C.jsxs)(mY,{className:"text-base flex items-center gap-2",children:[(0,C.jsx)(M,{className:"h-4 w-4 text-orange-500"}),(0,C.jsx)("span",{children:"Observations"}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",_.length,")"]})]})}),(0,C.jsx)(m$,{className:"pt-0 space-y-2",children:_.map((a,b)=>(0,C.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,C.jsx)("p",{className:"text-sm text-foreground",children:a.text}),(0,C.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,C.jsxs)("span",{children:["Proof count: ",a.proof_count||1]}),(0,C.jsxs)("span",{children:["Relevance: ",(a.relevance||0).toFixed(3)]})]})]},a.id||b))})]}),(0,C.jsx)("div",{className:"space-y-3",children:0!==R.length||_&&0!==_.length?R.map((a,b)=>{let c=ab?.visits?.find(b=>b.node_id===a.id),d=c?c.weights.final_weight:a.score||0;return(0,C.jsx)(mW,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ak(a),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-start gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-semibold text-primary",children:b+1})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-foreground",children:a.text}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:a.type||"world"}),a.context&&(0,C.jsx)("span",{className:"truncate max-w-xs",children:a.context}),a.occurred_start&&(0,C.jsx)("span",{children:new Date(a.occurred_start).toLocaleDateString()})]})]}),(0,C.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,C.jsx)("div",{className:"text-sm font-semibold",children:d.toFixed(3)}),(0,C.jsx)("div",{className:"text-xs text-muted-foreground",children:"score"})]}),(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},b)}):(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-12",children:[(0,C.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"No memories found for this query."})]})})})]}),"trace"===ah&&ab&&(0,C.jsxs)("div",{className:"space-y-4",children:[ab.retrieval_results&&ab.retrieval_results.length>0&&(a={},ab.retrieval_results.forEach(b=>{let c=b.fact_type||"all";a[c]||(a[c]=[]),a[c].push(b)}),b=Object.keys(a),(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,C.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,C.jsx)("span",{children:"PARALLEL RETRIEVAL"}),(0,C.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,C.jsx)("div",{className:"space-y-2",children:b.map((b,c)=>{let d=a[b],e=`lane-${b}`,f=al.has(e),g=d.reduce((a,b)=>a+(b.results?.length||0),0),h=Math.max(...d.map(a=>a.duration_seconds||0)),i={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},j=i[b]||i.all;return(0,C.jsx)(mW,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,C.jsxs)(m$,{className:"py-3 px-4",children:[(0,C.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>ap(e),children:[(0,C.jsx)("div",{className:`w-8 h-8 rounded-lg ${j.bg} flex items-center justify-center`,children:(0,C.jsx)("span",{className:`text-sm font-bold ${j.text} capitalize`,children:b.charAt(0).toUpperCase()})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground capitalize",children:b}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," methods"]})]}),(0,C.jsx)("div",{className:"flex gap-1.5 mt-1",children:d.map((a,b)=>(0,C.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[a.method_name,": ",a.results?.length||0]},b))})]}),(0,C.jsxs)("div",{className:"text-right",children:[(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:g}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[h.toFixed(2),"s"]})]}),f?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),f&&(0,C.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,C.jsx)("div",{className:`grid gap-3 ${1===d.length?"grid-cols-1":2===d.length?"grid-cols-2":3===d.length?"grid-cols-3":"grid-cols-4"}`,children:d.map((a,b)=>{let c,d,f,g,h=`${e}-method-${b}`,i=al.has(h),j=a.results||[];return(0,C.jsxs)("div",{className:"flex flex-col",children:[(0,C.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${i?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:a=>{a.stopPropagation(),ap(h)},children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:a.method_name}),"temporal"===a.method_name&&a.metadata?.constraint&&(0,C.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,C.jsx)(Y,{className:"h-3 w-3"}),a.metadata.constraint.start?new Date(a.metadata.constraint.start).toLocaleDateString():"any"," → ",a.metadata.constraint.end?new Date(a.metadata.constraint.end).toLocaleDateString():"any"]})]}),i?(0,C.jsx)(sP.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,C.jsxs)("div",{className:"flex items-end justify-between",children:[(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:j.length}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[a.duration_seconds?.toFixed(2),"s"]})]})]}),i&&j.length>0&&(c=`results-${h}`,f=(d=an.has(c))?j:j.slice(0,5),g=j.length>5,(0,C.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[f.map((a,b)=>(0,C.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:a.text}),(0,C.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,C.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(a.score||a.similarity||0).toFixed(4)})})]})]})},b)),g&&(0,C.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(c)},children:d?"Show less":`View all ${j.length} results`})]}))]},h)})})})]})},e)})}),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)("div",{className:"flex items-center gap-2",children:b.map((a,b)=>{let c={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,C.jsx)("div",{className:"flex flex-col items-center",children:(0,C.jsx)("div",{className:`w-1 h-4 ${c[a]||c.all} rounded-full opacity-50`})},b)})})}),(0,C.jsx)("div",{className:"flex justify-center",children:(0,C.jsx)(sQ,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ab.rrf_merged&&(c="rrf-merge",d=al.has(c),(0,C.jsxs)("div",{children:[(0,C.jsx)(mW,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(c),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"RRF Fusion"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"merge"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Reciprocal Rank Fusion of all retrieval results"})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ab.rrf_merged.length}),d?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),d&&ab.rrf_merged.length>0&&(e="results-rrf",g=(f=an.has(e))?ab.rrf_merged:ab.rrf_merged.slice(0,5),h=ab.rrf_merged.length>5,(0,C.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[g.map((a,b)=>(0,C.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,C.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["RRF Score: ",(a.rrf_score||a.score||0).toFixed(4)]})]})]})},b)),h&&(0,C.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(e)},children:f?"Show less":`View all ${ab.rrf_merged.length} results`})]})),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)(sQ,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ab.reranked&&(i="reranking",j=al.has(i),(0,C.jsxs)("div",{children:[(0,C.jsx)(mW,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(i),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"Combined Scoring"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"rerank"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,C.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ab.reranked.length}),j?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),j&&ab.reranked.length>0&&(k="results-rerank",n=(l=an.has(k))?ab.reranked:ab.reranked.slice(0,5),o=ab.reranked.length>5,(0,C.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[n.map((a,b)=>{let c=a.score_components||{};return(0,C.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,C.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,C.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(a.rerank_score||a.score||0).toFixed(4)]}),void 0!==c.cross_encoder_score_normalized&&(0,C.jsxs)("span",{title:"Cross-encoder score (primary relevance signal)",children:["CE: ",c.cross_encoder_score_normalized.toFixed(3)]}),void 0!==c.temporal&&.5!==c.temporal&&(0,C.jsxs)("span",{title:"Temporal proximity boost (±10% — only active for temporal queries)",children:["Tmp: ",c.temporal.toFixed(3)]}),void 0!==c.recency&&(0,C.jsxs)("span",{title:"Recency boost (±10% — based on memory age)",children:["Rec: ",c.recency.toFixed(3)]})]})]})]})},b)}),o&&(0,C.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(k)},children:l?"Show less":`View all ${ab.reranked.length} results`})]})),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)(sQ,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,C.jsx)(mW,{className:"border-primary bg-primary/5",children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"Final Results"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:"output"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Top results after all processing steps"})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-primary",children:R?.length||0})]})})})]}),"json"===ah&&(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nM,{src:{results:R,...T&&{entities:T},...Z&&{chunks:Z},..._&&{observations:_},trace:ab},collapsed:2,theme:"default"})})})]})]}),!ae&&!R&&(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Recall"}),(0,C.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a query above to search through your memories. Use filters to narrow down by fact type, budget, and more."})]})}),aj&&(0,C.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,C.jsx)(bu,{memory:aj,onClose:()=>ak(null),inPanel:!0,bankId:p||void 0})})]}):(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start recalling."})]})})}let sS=(0,K.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var sT=a.i(83604),sT=sT,sU=a.i(15618),bi=bi;let sV={skepticism:{label:"Skepticism",shortLabel:"S",description:"How skeptical vs trusting when forming observations",lowLabel:"Trusting",highLabel:"Skeptical"},literalism:{label:"Literalism",shortLabel:"L",description:"How literally to interpret information when forming observations",lowLabel:"Flexible",highLabel:"Literal"},empathy:{label:"Empathy",shortLabel:"E",description:"How much to consider emotional context when forming observations",lowLabel:"Detached",highLabel:"Empathetic"}};function sW({hideReflectFields:a=!1}){let b=(0,E.useRouter)(),{currentBank:c,setCurrentBank:d,loadBanks:e}=(0,H.useBank)(),{features:f}=(0,I.useFeatures)();f?.observations;let[g,h]=(0,D.useState)(null),[i,j]=(0,D.useState)(null),[k,l]=(0,D.useState)([]),[n,o]=(0,D.useState)(0),[p,q]=(0,D.useState)([]),[r,s]=(0,D.useState)(0),[t,u]=(0,D.useState)(!1),[v,w]=(0,D.useState)(!1),[x,y]=(0,D.useState)(!1),[z,A]=(0,D.useState)(!1),[B,G]=(0,D.useState)(null),[J,K]=(0,D.useState)(null),[L,M]=(0,D.useState)(!1),[N,O]=(0,D.useState)(!1),[P,Q]=(0,D.useState)(!1),[R,S]=(0,D.useState)(!1),[T,U]=(0,D.useState)(!1),[X,Y]=(0,D.useState)(!1),[Z,$]=(0,D.useState)(null),[_]=(0,D.useState)(10),[aa,ac]=(0,D.useState)(0),[ae,af]=(0,D.useState)(null),ah=async(a=Z,b=aa)=>{if(c)try{let d=await V.client.listOperations(c,{status:a||void 0,limit:_,offset:b});l(d.operations||[]),o(d.total||0)}catch(a){console.error("Error loading operations:",a)}},ai=async(a=!1)=>{if(c){if(a){try{let[a,b,d]=await Promise.all([V.client.getBankStats(c),V.client.listDirectives(c),V.client.listMentalModels(c)]);j(a),q(b.items||[]),s(d.items?.length||0)}catch(a){console.error("Error refreshing stats:",a)}return}u(!0);try{let[a,b,d,e]=await Promise.all([V.client.getBankProfile(c),V.client.getBankStats(c),V.client.listDirectives(c),V.client.listMentalModels(c)]);h(a),j(b),q(d.items||[]),s(e.items?.length||0),await ah()}catch(a){}finally{u(!1)}}},aj=async()=>{if(c){Q(!0);try{await V.client.deleteBank(c),O(!1),d(null),await e(),b.push("/")}catch(a){}finally{Q(!1)}}},ak=async()=>{if(c){U(!0);try{let a=await V.client.clearObservations(c);S(!1),await ai(),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{U(!1)}}},al=async()=>{if(c&&J){M(!0);try{await V.client.deleteDirective(c,J.id),q(a=>a.filter(a=>a.id!==J.id)),B?.id===J.id&&G(null),K(null)}catch(a){}finally{M(!1)}}};return((0,D.useEffect)(()=>{if(c){ai();let a=setInterval(()=>ai(!0),5e3);return()=>clearInterval(a)}},[c]),(0,D.useEffect)(()=>{let a=a=>{"Escape"===a.key&&G(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),c)?t&&!g?(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"text-center py-10",children:[(0,C.jsx)(ad,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,C.jsx)("div",{className:"text-lg text-muted-foreground",children:"Loading profile..."})]})}):(0,C.jsxs)("div",{className:"space-y-6",children:[!a&&(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(m0,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,C.jsx)(mZ,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)(W.Button,{onClick:()=>w(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(mR,{className:"h-4 w-4"})})]})}),(0,C.jsx)(m$,{children:g&&(0,C.jsx)("div",{className:"space-y-4",children:Object.keys(sV).map(a=>(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:sV[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sV[a].description})]}),(0,C.jsxs)("span",{className:"text-sm font-bold text-primary",children:[g.disposition[a],"/5"]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:sV[a].lowLabel}),(0,C.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,C.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(g.disposition[a]-1)/4*100}%`}})}),(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:sV[a].highLabel})]})]},a))})})]}),(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(sS,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,C.jsx)(mZ,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,C.jsx)(W.Button,{onClick:()=>y(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(mR,{className:"h-4 w-4"})})]})}),(0,C.jsx)(m$,{children:(0,C.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:g?.mission||"No mission set. Set a mission to derive structural mental models and personalize reflect responses."})})]})]}),(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),"Directives"]}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:"Hard rules that must be followed during reflect"})]}),(0,C.jsxs)(W.Button,{onClick:()=>A(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-1"}),"Add"]})]}),p.length>0?(0,C.jsx)("div",{className:"grid grid-cols-2 gap-3",children:p.map(a=>(0,C.jsx)(mW,{className:`cursor-pointer transition-colors border-rose-500/30 ${B?.id===a.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>G(a),children:(0,C.jsx)(m$,{className:"p-3",children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)(sT.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:a.content}),a.tags&&a.tags.length>0&&(0,C.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,C.jsx)(ag,{className:"w-3 h-3 text-muted-foreground"}),a.tags.map(a=>(0,C.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:a},a))]})]})]})})},a.id))}):(0,C.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,C.jsx)(sT.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:"No directives yet. Directives are hard rules that must be followed during reflect."})]})]}),(0,C.jsx)(ms,{open:N,onOpenChange:O,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Memory Bank"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:c}),"?"]}),(0,C.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."}),i&&(0,C.jsxs)("p",{children:["This will delete ",i.total_nodes," memories, ",i.total_documents," ","documents, and ",i.total_links," links."]})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:P,children:"Cancel"}),(0,C.jsx)(mO,{onClick:aj,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:P?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(ms,{open:R,onOpenChange:S,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Clear Observations"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:c}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."}),i&&i.total_observations>0&&(0,C.jsxs)("p",{children:["This will delete ",i.total_observations," observations."]})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:T,children:"Cancel"}),(0,C.jsx)(mO,{onClick:ak,disabled:T,className:"bg-amber-500 text-white hover:bg-amber-600",children:T?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,C.jsx)(sZ,{open:z,mode:"create",onClose:()=>A(!1),onCreated:a=>{q(b=>[a,...b]),A(!1)}}),(0,C.jsx)(ms,{open:!!J,onOpenChange:a=>!a&&K(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Directive"}),(0,C.jsxs)(mN,{children:["Are you sure you want to delete"," ",(0,C.jsxs)("span",{className:"font-semibold",children:['"',J?.name,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),(0,C.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,C.jsxs)(mL,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mP,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mO,{onClick:al,disabled:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[L?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),B&&(0,C.jsx)(s$,{directive:B,onClose:()=>G(null),onDelete:()=>K({id:B.id,name:B.name}),onUpdated:a=>{q(b=>b.map(b=>b.id===a.id?a:b)),G(a)}}),v&&g&&(0,C.jsx)(sX,{disposition:g.disposition,onClose:()=>w(!1),onSaved:async()=>{await ai(),w(!1)}}),x&&g&&(0,C.jsx)(sY,{mission:g.mission||"",onClose:()=>y(!1),onSaved:async()=>{await ai(),y(!1)}})]}):(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"p-10 text-center",children:[(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Please select a memory bank from the dropdown above to view its profile."})]})})}function sX({disposition:a,onClose:b,onSaved:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)(a),i=async()=>{if(d){f(!0);try{await V.client.updateBankConfig(d,{disposition_skepticism:g.skepticism,disposition_literalism:g.literalism,disposition_empathy:g.empathy}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Disposition Traits"}),(0,C.jsx)(bk.DialogDescription,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)("div",{className:"space-y-4 py-4",children:Object.keys(sV).map(a=>(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:sV[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sV[a].description})]}),(0,C.jsxs)("span",{className:"text-sm font-bold text-primary",children:[g[a],"/5"]})]}),(0,C.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,C.jsx)("span",{children:sV[a].lowLabel}),(0,C.jsx)("span",{children:sV[a].highLabel})]}),(0,C.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:g[a],onChange:b=>h(c=>({...c,[a]:parseInt(b.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},a))}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{onClick:b,variant:"outline",disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e,children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function sY({mission:a,onClose:b,onSaved:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)(a),i=async()=>{if(d){f(!0);try{await V.client.updateBankConfig(d,{reflect_mission:g||null}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Mission"}),(0,C.jsx)(bk.DialogDescription,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,C.jsx)("div",{className:"space-y-2 py-4",children:(0,C.jsx)(m4.Textarea,{value:g,onChange:a=>h(a.target.value),placeholder:"e.g., I am a PM for the engineering team. I help coordinate sprints and track project progress...",rows:8,className:"resize-none"})}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{onClick:b,variant:"outline",disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e,children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function sZ({open:a,mode:b,directive:c,onClose:d,onCreated:e,onSaved:f}){let{currentBank:g}=(0,H.useBank)(),[h,i]=(0,D.useState)(!1),[j,k]=(0,D.useState)({name:"",content:"",tags:""});(0,D.useEffect)(()=>{"edit"===b&&c?k({name:c.name,content:c.content,tags:(c.tags||[]).join(", ")}):"create"===b&&k({name:"",content:"",tags:""})},[a,b,c]);let l=async()=>{if(g&&j.name.trim()&&j.content.trim()){i(!0);try{let a=j.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0);if("create"===b){let b=await V.client.createDirective(g,{name:j.name.trim(),content:j.content.trim(),tags:a.length>0?a:void 0});k({name:"",content:"",tags:""}),e?.(b)}else if(c){let b=await V.client.updateDirective(g,c.id,{name:j.name.trim(),content:j.content.trim(),tags:a});f?.(b),d()}}catch(a){}finally{i(!1)}}},n=()=>{"create"===b&&k({name:"",content:"",tags:""}),d()};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>!a&&n(),children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsxs)(bk.DialogTitle,{className:"flex items-center gap-2",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),"create"===b?"Create":"Edit"," Directive"]}),(0,C.jsx)(bk.DialogDescription,{children:"Directives are hard rules that must be followed during reflect."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:j.name,onChange:a=>k({...j,name:a.target.value}),placeholder:"e.g., Competitor Policy"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Rule *"}),(0,C.jsx)(m4.Textarea,{value:j.content,onChange:a=>k({...j,content:a.target.value}),placeholder:"e.g., Never mention competitor products directly.",className:"min-h-[120px]"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:j.tags,onChange:a=>k({...j,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:n,disabled:h,children:"Cancel"}),(0,C.jsxs)(W.Button,{onClick:l,disabled:h||!j.name.trim()||!j.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[h?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"create"===b?"Create":"Save"]})]})]})})}function s$({directive:a,onClose:b,onDelete:c,onUpdated:d}){let[e,f]=(0,D.useState)(!1);return(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>f(!0),className:"h-7 w-7 p-0",children:(0,C.jsx)(mR,{className:"h-3.5 w-3.5"})})]}),(0,C.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:"directive"})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,C.jsx)(mQ,{className:"h-4 w-4"})}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,C.jsx)(ah.X,{className:"h-4 w-4"})})]})]}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Rule"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tags.map(a=>(0,C.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:a},a))})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,C.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:a.id})]})]})]}),(0,C.jsx)(sZ,{open:e,mode:"edit",directive:a,onClose:()=>f(!1),onSaved:d})]})}let s_=(0,ar.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"}}),s0=D.forwardRef(({className:a,variant:b,...c},d)=>(0,C.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(s_({variant:b}),a),...c}));s0.displayName="Alert",D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("h5",{ref:c,className:(0,S.cn)("mb-1 font-medium leading-none tracking-tight",a),...b})).displayName="AlertTitle";let s1=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));s1.displayName="AlertDescription";var bi=bi;let s2=(0,K.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),s3=[{value:"HARM_CATEGORY_HARASSMENT",label:"Harassment"},{value:"HARM_CATEGORY_HATE_SPEECH",label:"Hate Speech"},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:"Sexually Explicit"},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:"Dangerous Content"}],s4=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:"Unspecified (use Gemini default)"},{value:"OFF",label:"Off (filter disabled)"},{value:"BLOCK_NONE",label:"Block none"},{value:"BLOCK_LOW_AND_ABOVE",label:"Block low & above"},{value:"BLOCK_MEDIUM_AND_ABOVE",label:"Block medium & above"},{value:"BLOCK_ONLY_HIGH",label:"Block only high"}],s5=s3.map(a=>({category:a.value,threshold:"BLOCK_NONE"})),s6=[{label:"Core",tools:["retain","recall","reflect"]},{label:"Bank management",tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{label:"Mental models",tools:["list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model"]},{label:"Directives",tools:["list_directives","create_directive","delete_directive"]},{label:"Memories",tools:["list_memories","get_memory","delete_memory"]},{label:"Documents",tools:["list_documents","get_document","delete_document"]},{label:"Operations",tools:["list_operations","get_operation","cancel_operation"]},{label:"Tags",tools:["list_tags"]}],s7=s6.flatMap(a=>a.tools);function s8(a){return{retain_chunk_size:a.retain_chunk_size??null,retain_extraction_mode:a.retain_extraction_mode??null,retain_mission:a.retain_mission??null,retain_custom_instructions:a.retain_custom_instructions??null}}function s9(a){return{enable_observations:a.enable_observations??null,consolidation_llm_batch_size:a.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:a.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:a.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:a.observations_mission??null}}function ta(a){let b=a.entity_labels,c=null;return Array.isArray(b)?c=b:b&&"object"==typeof b&&Array.isArray(b.attributes)&&(c=b.attributes),{entity_labels:c,entities_allow_free_form:a.entities_allow_free_form??!0}}function tb(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function tc(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let td={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function te(){let{currentBank:a}=(0,H.useBank)(),{features:b}=(0,I.useFeatures)(),c=b?.bank_config_api??!0,[d,e]=(0,D.useState)(!0),[f,g]=(0,D.useState)({}),[h,i]=(0,D.useState)(td),[j,k]=(0,D.useState)(s8({})),[l,n]=(0,D.useState)(s9({})),[o,p]=(0,D.useState)(ta({})),[q,r]=(0,D.useState)(td),[s,t]=(0,D.useState)(tb({})),[u,v]=(0,D.useState)(tc({})),[w,x]=(0,D.useState)(!1),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),[E,F]=(0,D.useState)(!1),[G,J]=(0,D.useState)(!1),[K,L]=(0,D.useState)(!1),[M,N]=(0,D.useState)(null),[O,P]=(0,D.useState)(null),[Q,R]=(0,D.useState)(null),[S,T]=(0,D.useState)(null),[U,W]=(0,D.useState)(null),[Y,Z]=(0,D.useState)(null),$=(0,D.useMemo)(()=>JSON.stringify(j)!==JSON.stringify(s8(f)),[j,f]),_=(0,D.useMemo)(()=>JSON.stringify(l)!==JSON.stringify(s9(f)),[l,f]),aa=(0,D.useMemo)(()=>JSON.stringify(o)!==JSON.stringify(ta(f)),[o,f]),ab=(0,D.useMemo)(()=>JSON.stringify(q)!==JSON.stringify(h),[q,h]),ac=(0,D.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(tb(f)),[s,f]),ad=(0,D.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(tc(f)),[u,f]);(0,D.useEffect)(()=>{a&&ae()},[a]);let ae=async()=>{if(a){e(!0);try{let[b,c]=await Promise.all([V.client.getBankConfig(a),V.client.getBankProfile(a)]),d=b.config,e={reflect_mission:c.mission??"",disposition_skepticism:d.disposition_skepticism??c.disposition?.skepticism??3,disposition_literalism:d.disposition_literalism??c.disposition?.literalism??3,disposition_empathy:d.disposition_empathy??c.disposition?.empathy??3};g(d),i(e),k(s8(d)),n(s9(d)),p(ta(d)),r(e),t(tb(d)),v(tc(d))}catch(a){console.error("Failed to load bank data:",a)}finally{e(!1)}}},af=async()=>{if(a){x(!0),N(null);try{await V.client.updateBankConfig(a,j),g(a=>({...a,...j}))}catch(a){N(a.message||"Failed to save retain settings")}finally{x(!1)}}},ag=async()=>{if(a){z(!0),P(null);try{await V.client.updateBankConfig(a,l),g(a=>({...a,...l}))}catch(a){P(a.message||"Failed to save observations settings")}finally{z(!1)}}},ah=async()=>{if(a){B(!0),R(null);try{let b={entity_labels:o.entity_labels,entities_allow_free_form:o.entities_allow_free_form};await V.client.updateBankConfig(a,b),g(a=>({...a,...b}))}catch(a){R(a.message||"Failed to save entity labels settings")}finally{B(!1)}}},ai=async()=>{if(a){F(!0),T(null);try{await V.client.updateBankConfig(a,{reflect_mission:q.reflect_mission||null,disposition_skepticism:q.disposition_skepticism,disposition_literalism:q.disposition_literalism,disposition_empathy:q.disposition_empathy}),i(q)}catch(a){T(a.message||"Failed to save reflect settings")}finally{F(!1)}}},aj=async()=>{if(a){J(!0),W(null);try{await V.client.updateBankConfig(a,s),g(a=>({...a,...s}))}catch(a){W(a.message||"Failed to save MCP settings")}finally{J(!1)}}},ak=async()=>{if(a){L(!0),Z(null);try{await V.client.updateBankConfig(a,u),g(a=>({...a,...u}))}catch(a){Z(a.message||"Failed to save Gemini settings")}finally{L(!1)}}};return a?c?d?(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)(bi.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,C.jsx)(C.Fragment,{children:(0,C.jsxs)("div",{className:"space-y-8",children:[(0,C.jsxs)(tg,{title:"Retain",description:"Control what gets extracted and stored from content",error:M,dirty:$,saving:w,onSave:af,children:[(0,C.jsx)(th,{label:"Chunk Size",description:"Size of text chunks for processing (characters)",children:(0,C.jsx)(X.Input,{type:"number",min:500,max:8e3,value:j.retain_chunk_size??"",onChange:a=>k(b=>({...b,retain_chunk_size:a.target.value?parseFloat(a.target.value):null}))})}),(0,C.jsx)(ti,{label:"Mission",description:"What this bank should pay attention to during extraction. Steers the LLM without replacing the extraction rules — works alongside any extraction mode.",value:j.retain_mission??"",onChange:a=>k(b=>({...b,retain_mission:a||null})),placeholder:"e.g. Always include technical decisions, API design choices, and architectural trade-offs. Ignore meeting logistics, greetings, and social exchanges.",rows:3}),(0,C.jsx)(th,{label:"Extraction Mode",description:"How aggressively to extract facts: concise (default, selective), verbose (capture everything), custom (write your own extraction rules)",children:(0,C.jsxs)(mU.Select,{value:j.retain_extraction_mode??"",onValueChange:a=>k(b=>({...b,retain_extraction_mode:a})),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-full",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsx)(mU.SelectContent,{children:["concise","verbose","custom"].map(a=>(0,C.jsx)(mU.SelectItem,{value:a,children:a},a))})]})}),"custom"===j.retain_extraction_mode&&(0,C.jsx)(ti,{label:"Custom Extraction Prompt",description:"Replaces the built-in extraction rules entirely. Only active when Extraction Mode is set to custom.",value:j.retain_custom_instructions??"",onChange:a=>k(b=>({...b,retain_custom_instructions:a||null})),rows:5})]}),(0,C.jsxs)(tg,{title:"Entities",description:"Control entity extraction and define a controlled vocabulary of key:value classification labels (e.g. pedagogy:scaffolding, interest:active)",error:Q,dirty:aa,saving:A,onSave:ah,children:[(0,C.jsx)(th,{label:"Free Form Entities",description:"Extract regular named entities (people, places, concepts) alongside entity labels. Disable to restrict extraction to entity labels only.",children:(0,C.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,C.jsx)(at,{htmlFor:"entities-allow-free-form",className:"text-sm text-muted-foreground cursor-pointer select-none",children:o.entities_allow_free_form?"Enabled":"Disabled"}),(0,C.jsx)(be,{id:"entities-allow-free-form",checked:o.entities_allow_free_form,onCheckedChange:a=>p(b=>({...b,entities_allow_free_form:a}))})]})}),(0,C.jsx)(tk,{value:o.entity_labels??[],onChange:a=>p(b=>({...b,entity_labels:a.length>0?a:null}))})]}),(0,C.jsxs)(tg,{title:"Observations",description:"Control how facts are synthesized into durable observations",error:O,dirty:_,saving:y,onSave:ag,children:[(0,C.jsx)(th,{label:"Enable Observations",description:"Enable automatic consolidation of facts into observations",children:(0,C.jsx)("div",{className:"flex justify-end",children:(0,C.jsx)(be,{checked:l.enable_observations??!1,onCheckedChange:a=>n(b=>({...b,enable_observations:a}))})})}),(0,C.jsx)(ti,{label:"Mission",description:"What this bank should synthesise into durable observations. Replaces the built-in consolidation rules — leave blank to use the server default.",value:l.observations_mission??"",onChange:a=>n(b=>({...b,observations_mission:a||null})),placeholder:"e.g. Observations are stable facts about people and projects. Always include preferences, skills, and recurring patterns. Ignore one-off events and ephemeral state.",rows:3}),(0,C.jsx)(th,{label:"LLM Batch Size",description:"Number of facts sent to the LLM in a single consolidation call. Higher values reduce LLM calls at the cost of larger prompts. Leave blank to use the server default.",children:(0,C.jsx)(X.Input,{type:"number",min:1,max:64,value:l.consolidation_llm_batch_size??"",onChange:a=>n(b=>({...b,consolidation_llm_batch_size:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})}),(0,C.jsx)(th,{label:"Source Facts Max Tokens",description:"Total token budget for source facts included with observations during consolidation. -1 = unlimited.",children:(0,C.jsx)(X.Input,{type:"number",min:-1,value:l.consolidation_source_facts_max_tokens??"",onChange:a=>n(b=>({...b,consolidation_source_facts_max_tokens:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})}),(0,C.jsx)(th,{label:"Source Facts Max Tokens Per Observation",description:"Per-observation token cap for source facts during consolidation. Each observation gets at most this many tokens of source facts. -1 = unlimited.",children:(0,C.jsx)(X.Input,{type:"number",min:-1,value:l.consolidation_source_facts_max_tokens_per_observation??"",onChange:a=>n(b=>({...b,consolidation_source_facts_max_tokens_per_observation:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})})]}),(0,C.jsxs)(tg,{title:"Reflect",description:"Shape how the bank reasons and responds in reflect operations",error:S,dirty:ab,saving:E,onSave:ai,children:[(0,C.jsx)(ti,{label:"Mission",description:"Agent identity and purpose. Used as framing context in reflect.",value:q.reflect_mission,onChange:a=>r(b=>({...b,reflect_mission:a})),placeholder:"e.g. You are a senior engineering assistant. Always ground answers in documented decisions and rationale. Ignore speculation. Be direct and precise.",rows:3}),(0,C.jsx)(tj,{label:"Skepticism",description:"How skeptical vs trusting when evaluating claims",lowLabel:"Trusting",highLabel:"Skeptical",value:q.disposition_skepticism,onChange:a=>r(b=>({...b,disposition_skepticism:a}))}),(0,C.jsx)(tj,{label:"Literalism",description:"How literally to interpret information",lowLabel:"Flexible",highLabel:"Literal",value:q.disposition_literalism,onChange:a=>r(b=>({...b,disposition_literalism:a}))}),(0,C.jsx)(tj,{label:"Empathy",description:"How much to weight emotional context",lowLabel:"Detached",highLabel:"Empathetic",value:q.disposition_empathy,onChange:a=>r(b=>({...b,disposition_empathy:a}))})]}),(0,C.jsxs)(tg,{title:"MCP Tools",description:"Restrict which MCP tools this bank exposes to agents",error:U,dirty:ac,saving:G,onSave:aj,children:[(0,C.jsx)(th,{label:"Restrict tools",description:"When off, all tools are available. When on, only the selected tools can be invoked for this bank.",children:(0,C.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,C.jsx)(be,{checked:null!==s.mcp_enabled_tools,onCheckedChange:a=>t({mcp_enabled_tools:a?[...s7]:null})}),(0,C.jsx)(at,{className:"text-xs text-muted-foreground",children:null!==s.mcp_enabled_tools?"Enabled":"Disabled"})]})}),null!==s.mcp_enabled_tools&&(0,C.jsx)(tf,{selected:s.mcp_enabled_tools,onChange:a=>t({mcp_enabled_tools:a})})]}),(0,C.jsx)(tg,{title:"Models",description:"Provider-specific model settings",error:Y,dirty:ad,saving:K,onSave:ak,children:(0,C.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,C.jsx)("p",{className:"text-sm font-semibold",children:"Gemini / Vertex AI"}),(0,C.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,C.jsx)(th,{label:"Safety settings",description:(0,C.jsxs)(C.Fragment,{children:["When off, Gemini's default safety thresholds are used. When on, configure thresholds per harm category."," ",(0,C.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:"Learn more"})]}),children:(0,C.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,C.jsx)(be,{checked:null!==u.llm_gemini_safety_settings,onCheckedChange:a=>v({llm_gemini_safety_settings:a?[...s5]:null})}),(0,C.jsx)(at,{className:"text-xs text-muted-foreground",children:null!==u.llm_gemini_safety_settings?"Custom":"Default"})]})}),null!==u.llm_gemini_safety_settings&&(0,C.jsx)(tl,{value:u.llm_gemini_safety_settings,onChange:a=>v({llm_gemini_safety_settings:a})})]})]})})]})}):(0,C.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,C.jsx)("p",{className:"text-base font-medium text-foreground",children:"Bank configuration is disabled"}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground max-w-sm",children:["Set"," ",(0,C.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:"HINDSIGHT_API_ENABLE_BANK_CONFIG_API=true"})," ","to enable per-bank configuration."]})]}):(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)("p",{className:"text-muted-foreground",children:"No bank selected"})})}function tf({selected:a,onChange:b}){let c=new Set(a),d=s7.every(a=>c.has(a)),e=0===a.length;return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("p",{className:"text-xs text-muted-foreground",children:[a.length," of ",s7.length," tools enabled"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(d?[]:[...s7])},className:"text-xs text-primary hover:underline",children:d?"Deselect all":"Select all"})]}),(0,C.jsx)("div",{className:"space-y-4",children:s6.map(a=>{let d=a.tools.filter(a=>c.has(a)).length===a.tools.length;return(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,C.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:a.label}),(0,C.jsx)("button",{type:"button",onClick:()=>{let e=new Set(c);d?a.tools.forEach(a=>e.delete(a)):a.tools.forEach(a=>e.add(a)),b(s7.filter(a=>e.has(a)))},className:"text-xs text-primary hover:underline",children:d?"Deselect":"Select all"})]}),(0,C.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tools.map(a=>{let d=c.has(a);return(0,C.jsx)("button",{type:"button",onClick:()=>{let d;(d=new Set(c)).has(a)?d.delete(a):d.add(a),b(s7.filter(a=>d.has(a)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${d?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:a},a)})})]},a.label)})}),e&&(0,C.jsx)("p",{className:"text-xs text-destructive",children:"Warning: no tools selected — agents will be blocked from all MCP calls for this bank."})]})}function tg({title:a,description:b,children:c,error:d,dirty:e,saving:f,onSave:g}){return(0,C.jsxs)("section",{className:"space-y-3",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h2",{className:"text-lg font-semibold",children:a}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:b})]}),(0,C.jsxs)(mW,{className:"bg-muted/20 border-border/40",children:[(0,C.jsx)("div",{className:"divide-y divide-border/40",children:c}),d&&(0,C.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,C.jsxs)(s0,{variant:"destructive",children:[(0,C.jsx)(s2,{className:"h-4 w-4"}),(0,C.jsx)(s1,{children:d})]})}),(0,C.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,C.jsx)(W.Button,{size:"sm",disabled:!e||f,onClick:g,children:f?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save changes"})})]})]})}function th({label:a,description:b,children:c}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsx)("div",{className:"md:w-64 shrink-0",children:c})]})})}function ti({label:a,description:b,value:c,onChange:d,placeholder:e,rows:f}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsx)(m4.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function tj({label:a,description:b,lowLabel:c,highLabel:d,value:e,onChange:f}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"space-y-3",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,C.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:c}),(0,C.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>(0,C.jsx)("button",{type:"button",onClick:()=>f(a),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${a<=e?"bg-primary":"bg-muted"}`},a))}),d&&(0,C.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:d}),(0,C.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[e,"/5"]})]})]})})}function tk({value:a,onChange:b}){let[c,d]=(0,D.useState)({}),e=(c,d)=>{b(a.map((a,b)=>b===c?{...a,...d}:a))},f=(b,c,d)=>{let f=a[b].values.map((a,b)=>b===c?{...a,...d}:a);e(b,{values:f})};return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:"Entity Labels"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Classification labels extracted at retain time. Leave empty to disable."})]}),a.length>0&&(0,C.jsxs)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:[a.length," group",1!==a.length?"s":""]})]}),0===a.length&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No entity labels defined."}),(0,C.jsx)("div",{className:"space-y-2",children:a.map((g,h)=>{let i=c[h]??!1,j="text"===g.type,k=!j;return(0,C.jsxs)("div",{className:"border border-border/50 rounded-md bg-background",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,C.jsx)("button",{type:"button",onClick:()=>d(a=>({...a,[h]:!i})),className:"text-muted-foreground hover:text-foreground shrink-0",disabled:j,children:i&&k?(0,C.jsx)(sP.ChevronDown,{className:"h-4 w-4"}):(0,C.jsx)(Q.ChevronRight,{className:`h-4 w-4 ${j?"opacity-30":""}`})}),(0,C.jsx)(X.Input,{placeholder:"key (e.g. pedagogy)",value:g.key,onChange:a=>e(h,{key:a.target.value}),className:"h-8 text-xs font-mono w-36 shrink-0"}),(0,C.jsx)(X.Input,{placeholder:j?"description / examples":"description",value:g.description,onChange:a=>e(h,{description:a.target.value}),className:"h-8 text-xs flex-1 min-w-0"}),(0,C.jsxs)(mU.Select,{value:g.type,onValueChange:a=>e(h,{type:a,..."text"===a?{values:[]}:{}}),children:[(0,C.jsx)(mU.SelectTrigger,{className:"h-8 text-xs w-32 shrink-0",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"value",className:"text-xs",children:"Single value"}),(0,C.jsx)(mU.SelectItem,{value:"multi-values",className:"text-xs",children:"Multi-values"}),(0,C.jsx)(mU.SelectItem,{value:"text",className:"text-xs",children:"Free text"})]})]}),(0,C.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",children:[(0,C.jsx)(mV.Checkbox,{checked:g.tag,onCheckedChange:a=>e(h,{tag:!!a}),className:"h-4 w-4"}),"tag"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(a.filter((a,b)=>b!==h)),d(a=>{let b={...a};return delete b[h],b})},className:"text-muted-foreground hover:text-destructive shrink-0",children:(0,C.jsx)(mQ,{className:"h-3.5 w-3.5"})})]}),i&&k&&(0,C.jsxs)("div",{className:"px-3 pb-3 space-y-1 border-t border-border/30 pt-2",children:[0===g.values.length&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground italic pl-5",children:"No values yet."}),g.values.map((b,c)=>(0,C.jsxs)("div",{className:"flex items-center gap-2 pl-5",children:[(0,C.jsx)(X.Input,{placeholder:"value",value:b.value,onChange:a=>f(h,c,{value:a.target.value}),className:"h-8 text-xs font-mono w-32 shrink-0"}),(0,C.jsx)(X.Input,{placeholder:"description",value:b.description,onChange:a=>f(h,c,{description:a.target.value}),className:"h-8 text-xs flex-1 min-w-0"}),(0,C.jsx)("button",{type:"button",onClick:()=>{e(h,{values:a[h].values.filter((a,b)=>b!==c)})},className:"text-muted-foreground hover:text-destructive shrink-0",children:(0,C.jsx)(mQ,{className:"h-3.5 w-3.5"})})]},c)),(0,C.jsxs)("button",{type:"button",onClick:()=>{e(h,{values:[...a[h].values,{value:"",description:""}]})},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground pl-5 mt-1",children:[(0,C.jsx)(sU.Plus,{className:"h-3 w-3"}),"Add value"]})]})]},h)})}),(0,C.jsxs)("button",{type:"button",onClick:()=>{let c=[...a,{key:"",description:"",type:"value",optional:!0,tag:!1,values:[]}];b(c),d(a=>({...a,[c.length-1]:!0}))},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,C.jsx)(sU.Plus,{className:"h-3.5 w-3.5"}),"Add attribute"]})]})}function tl({value:a,onChange:b}){let c=b=>a.find(a=>a.category===b)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,C.jsxs)("p",{className:"text-xs text-muted-foreground",children:['Set the blocking threshold for each harm category. "Off" disables the filter entirely (default for Gemini 2.5+). Lower thresholds block more content.'," ",(0,C.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:"Learn more"})]}),(0,C.jsx)("div",{className:"space-y-2",children:s3.map(a=>(0,C.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,C.jsx)("span",{className:"text-sm",children:a.label}),(0,C.jsxs)(mU.Select,{value:c(a.value),onValueChange:d=>{var e;return e=a.value,void b(s3.map(a=>({category:a.value,threshold:a.value===e?d:c(a.value)})))},children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsx)(mU.SelectContent,{children:s4.map(a=>(0,C.jsx)(mU.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}let tm=(0,K.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),tn=(0,K.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),to=(0,K.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);function tp(){let{currentBank:a}=(0,H.useBank)(),{features:b}=(0,I.useFeatures)(),c=b?.observations??!1,[d,e]=(0,D.useState)(null),[f,g]=(0,D.useState)(0),[h,i]=(0,D.useState)(0),[j,k]=(0,D.useState)(!1),l=async()=>{if(a){k(!0);try{let[b,c,d]=await Promise.all([V.client.getBankStats(a),V.client.listMentalModels(a),V.client.listDirectives(a)]);e(b),g(c.items?.length||0),i(d.items?.length||0)}catch(a){console.error("Error loading bank stats:",a)}finally{k(!1)}}};return((0,D.useEffect)(()=>{if(a){l();let a=setInterval(l,5e3);return()=>clearInterval(a)}},[a]),j&&!d)?(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)(ad,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})}):d?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,C.jsx)(mW,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/20",children:(0,C.jsx)(M,{className:"w-5 h-5 text-blue-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Memories"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_nodes})]})]})})}),(0,C.jsx)(mW,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/20",children:(0,C.jsx)(tm,{className:"w-5 h-5 text-purple-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Links"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_links})]})]})})}),(0,C.jsx)(mW,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/20",children:(0,C.jsx)(tn,{className:"w-5 h-5 text-emerald-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Documents"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_documents})]})]})})}),(0,C.jsx)(mW,{className:`bg-gradient-to-br ${d.pending_operations>0?"from-amber-500/10 to-amber-600/5 border-amber-500/20":"from-slate-500/10 to-slate-600/5 border-slate-500/20"}`,children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:`p-2 rounded-lg ${d.pending_operations>0?"bg-amber-500/20":"bg-slate-500/20"}`,children:(0,C.jsx)(to,{className:`w-5 h-5 ${d.pending_operations>0?"text-amber-500 animate-pulse":"text-slate-500"}`})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Pending"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.pending_operations})]})]})})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,C.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-semibold uppercase tracking-wide",children:"World Facts"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:d.nodes_by_fact_type?.world||0})]}),(0,C.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-semibold uppercase tracking-wide",children:"Experience"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-purple-600 dark:text-purple-400 mt-1",children:d.nodes_by_fact_type?.experience||0})]}),(0,C.jsxs)("div",{className:`rounded-xl p-4 text-center ${c?"bg-amber-500/10 border border-amber-500/20":"bg-muted/50 border border-muted"}`,title:c?void 0:"Observations feature is not enabled",children:[(0,C.jsxs)("p",{className:`text-xs font-semibold uppercase tracking-wide ${c?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:["Observations",!c&&(0,C.jsx)("span",{className:"ml-1 normal-case",children:"(Off)"})]}),(0,C.jsx)("p",{className:`text-2xl font-bold mt-1 ${c?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:c?d.total_observations||0:"—"})]}),(0,C.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-semibold uppercase tracking-wide",children:"Mental Models"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-cyan-600 dark:text-cyan-400 mt-1",children:f})]}),(0,C.jsxs)("div",{className:"bg-rose-500/10 border border-rose-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-semibold uppercase tracking-wide",children:"Directives"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-rose-600 dark:text-rose-400 mt-1",children:h})]})]})]}):null}var bi=bi;let tq=(0,K.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"}]]),tr=[{value:"all",label:"All types"},{value:"retain",label:"Retain"},{value:"consolidation",label:"Consolidation"},{value:"refresh_mental_model",label:"Mental Model Refresh"},{value:"file_convert_retain",label:"File Convert & Retain"},{value:"webhook_delivery",label:"Webhook Delivery"}];function ts(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(0),[f,g]=(0,D.useState)(null),[h,i]=(0,D.useState)(null),[j]=(0,D.useState)(10),[k,l]=(0,D.useState)(0),[n,o]=(0,D.useState)(null),[p,q]=(0,D.useState)(null),[r,s]=(0,D.useState)(!1),[t,u]=(0,D.useState)(null),[v,w]=(0,D.useState)(!1),[x,y]=(0,D.useState)(!1),z=(0,D.useCallback)(async(b=f,d=k,g=h)=>{if(a){s(!0);try{let f=await V.client.listOperations(a,{status:b||void 0,type:g||void 0,limit:j,offset:d});c(f.operations||[]),e(f.total||0)}catch(a){console.error("Error loading operations:",a)}finally{s(!1)}}},[a,f,k,h,j]),A=a=>{l(a),z(f,a,h)},B=async b=>{if(a){o(b);try{await V.client.cancelOperation(a,b),await z()}catch(a){}finally{o(null)}}},E=async b=>{if(a){q(b);try{await V.client.retryOperation(a,b),await z()}catch(a){}finally{q(null)}}},F=async b=>{if(a){y(!0),w(!0);try{let c=await V.client.getOperationStatus(a,b);u(c)}catch(a){console.error("Error loading operation details:",a),u({error:"Failed to load operation details"})}finally{y(!1)}}};return((0,D.useEffect)(()=>{if(a){z(f,k,h);let a=setInterval(()=>z(f,k,h),5e3);return()=>clearInterval(a)}},[a,f,k,h]),a)?(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-lg font-semibold",children:"Background Operations"}),(0,C.jsx)("button",{onClick:()=>z(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",disabled:r,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${r?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d," operation",1!==d?"s":"",f?` (${f})`:""]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsxs)(mU.Select,{value:h??"all",onValueChange:a=>{var b;i(b="all"===a?null:a),l(0),z(f,0,b)},children:[(0,C.jsx)(mU.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,C.jsx)(mU.SelectValue,{placeholder:"All types"})}),(0,C.jsx)(mU.SelectContent,{children:tr.map(a=>(0,C.jsx)(mU.SelectItem,{value:a.value,children:(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{children:a.label}),"all"!==a.value&&(0,C.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:a.value})]})},a.value))})]}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:[{value:null,label:"All"},{value:"pending",label:"Pending"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map(a=>(0,C.jsx)("button",{onClick:()=>{var b;g(b=a.value),l(0),z(b,0,h)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${f===a.value?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a.label},a.value??"all"))})]})]}),(0,C.jsx)("div",{children:b.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-[100px]",children:"ID"}),(0,C.jsx)(am,{children:"Type"}),(0,C.jsx)(am,{children:"Created"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{className:"w-[80px]"})]})}),(0,C.jsx)(ak,{children:b.map(a=>(0,C.jsxs)(al,{className:`cursor-pointer hover:bg-muted/50 ${"failed"===a.status?"bg-red-500/5":""}`,onClick:()=>F(a.id),children:[(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.id.substring(0,8)}),(0,C.jsx)(an,{className:"font-medium",children:a.task_type}),(0,C.jsx)(an,{className:"text-sm text-muted-foreground",children:new Date(a.created_at).toLocaleString()}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===a.status&&(0,C.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:a.error_message??void 0,children:[(0,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===a.status&&(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:b=>{b.stopPropagation(),B(a.id)},disabled:n===a.id,children:[n===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(ah.X,{className:"w-3 h-3 mr-1"}),n===a.id?"":"Cancel"]}),"failed"===a.status&&(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:b=>{b.stopPropagation(),E(a.id)},disabled:p===a.id,children:[p===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(tq,{className:"w-3 h-3 mr-1"}),p===a.id?"":"Retry"]})]})]},a.id))})]})}),d>j&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",k+1,"-",Math.min(k+j,d)," of"," ",d]}),(0,C.jsxs)("div",{className:"flex gap-2",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(Math.max(0,k-j)),disabled:0===k,children:"Previous"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(k+j),disabled:k+j>=d,children:"Next"})]})]})]}):(0,C.jsxs)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:["No ",f?`${f} `:"","operations"]})}),(0,C.jsx)(bk.Dialog,{open:v,onOpenChange:w,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Operation Details"}),(0,C.jsx)(bk.DialogDescription,{children:t?.operation_id&&(0,C.jsx)("span",{className:"font-mono text-xs",children:t.operation_id})})]}),x?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)(bi.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t?(0,C.jsx)("div",{className:"space-y-4",children:t.error?(0,C.jsx)("div",{className:"text-red-600 dark:text-red-400",children:t.error}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),(0,C.jsxs)("div",{className:"mt-1",children:["pending"===t.status&&(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===t.status&&(0,C.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,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===t.status&&(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Type"}),(0,C.jsx)("div",{className:"mt-1 font-mono text-sm",children:t.operation_type})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Created"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.created_at?new Date(t.created_at).toLocaleString():"N/A"})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Updated"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.updated_at?new Date(t.updated_at).toLocaleString():"N/A"})]}),t.completed_at&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Completed"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:new Date(t.completed_at).toLocaleString()})]}),t.result_metadata?.items_count!==void 0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Total Items"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.result_metadata.items_count})]})]}),t.error_message&&(0,C.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,C.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:"Error"}),(0,C.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:t.error_message})]}),t.child_operations&&t.child_operations.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Sub-batches (",t.result_metadata?.num_sub_batches||t.child_operations.length,")"]}),(0,C.jsx)("div",{className:"rounded-lg border",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-[60px]",children:"Index"}),(0,C.jsx)(am,{className:"w-[100px]",children:"ID"}),(0,C.jsx)(am,{className:"w-[80px]",children:"Items"}),(0,C.jsx)(am,{children:"Status"})]})}),(0,C.jsx)(ak,{children:t.child_operations.map(a=>(0,C.jsxs)(al,{children:[(0,C.jsx)(an,{className:"text-sm",children:a.sub_batch_index}),(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.operation_id.substring(0,8)}),(0,C.jsx)(an,{className:"text-sm",children:a.items_count}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400",title:a.error_message??void 0,children:[(0,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:[(0,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]})]},a.operation_id))})]})})]})]})}):null]})})]}):null}var bi=bi;let tt=(0,K.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),tu=(0,K.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);var tv=a.i(96743),tw=a.i(86228),tx=a.i(22297),ty=a.i(92843),tz=a.i(4691),tA=a.i(92616),tB=a.i(77192),tC=a.i(24050),tD=Symbol("radix.slottable");function tE(a){return D.isValidElement(a)&&"function"==typeof a.type&&"__radixId"in a.type&&a.type.__radixId===tD}var tF=a.i(46872),tG=a.i(41852),tH=a.i(52081),tI=["Enter"," "],tJ=["ArrowUp","PageDown","End"],tK=["ArrowDown","PageUp","Home",...tJ],tL={ltr:[...tI,"ArrowRight"],rtl:[...tI,"ArrowLeft"]},tM={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tN="Menu",[tO,tP,tQ]=(0,aD.createCollection)(tN),[tR,tS]=(0,ax.createContextScope)(tN,[tQ,tz.createPopperScope,tC.createRovingFocusGroupScope]),tT=(0,tz.createPopperScope)(),tU=(0,tC.createRovingFocusGroupScope)(),[tV,tW]=tR(tN),[tX,tY]=tR(tN),tZ=a=>{let{__scopeMenu:b,open:c=!1,children:d,dir:e,onOpenChange:f,modal:g=!0}=a,h=tT(b),[i,j]=D.useState(null),k=D.useRef(!1),l=(0,tF.useCallbackRef)(f),n=(0,az.useDirection)(e);return D.useEffect(()=>{let a=()=>{k.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>k.current=!1;return document.addEventListener("keydown",a,{capture:!0}),()=>{document.removeEventListener("keydown",a,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),(0,C.jsx)(tz.Root,{...h,children:(0,C.jsx)(tV,{scope:b,open:c,onOpenChange:l,content:i,onContentChange:j,children:(0,C.jsx)(tX,{scope:b,onClose:D.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:k,dir:n,modal:g,children:d})})})};tZ.displayName=tN;var t$=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tT(c);return(0,C.jsx)(tz.Anchor,{...e,...d,ref:b})});t$.displayName="MenuAnchor";var t_="MenuPortal",[t0,t1]=tR(t_,{forceMount:void 0}),t2=a=>{let{__scopeMenu:b,forceMount:c,children:d,container:e}=a,f=tW(t_,b);return(0,C.jsx)(t0,{scope:b,forceMount:c,children:(0,C.jsx)(tB.Presence,{present:c||f.open,children:(0,C.jsx)(tA.Portal,{asChild:!0,container:e,children:d})})})};t2.displayName=t_;var t3="MenuContent",[t4,t5]=tR(t3),t6=D.forwardRef((a,b)=>{let c=t1(t3,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tW(t3,a.__scopeMenu),g=tY(t3,a.__scopeMenu);return(0,C.jsx)(tO.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tB.Presence,{present:d||f.open,children:(0,C.jsx)(tO.Slot,{scope:a.__scopeMenu,children:g.modal?(0,C.jsx)(t7,{...e,ref:b}):(0,C.jsx)(t8,{...e,ref:b})})})})}),t7=D.forwardRef((a,b)=>{let c=tW(t3,a.__scopeMenu),d=D.useRef(null),e=(0,aw.useComposedRefs)(b,d);return D.useEffect(()=>{let a=d.current;if(a)return(0,tG.hideOthers)(a)},[]),(0,C.jsx)(ua,{...a,ref:e,trapFocus:c.open,disableOutsidePointerEvents:c.open,disableOutsideScroll:!0,onFocusOutside:(0,av.composeEventHandlers)(a.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>c.onOpenChange(!1)})}),t8=D.forwardRef((a,b)=>{let c=tW(t3,a.__scopeMenu);return(0,C.jsx)(ua,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>c.onOpenChange(!1)})}),t9=((e=D.forwardRef((a,b)=>{let{children:c,...d}=a;if(D.isValidElement(c)){var e;let a,f,g=(e=c,(f=(a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get)&&"isReactWarning"in a&&a.isReactWarning)?e.ref:(f=(a=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in a&&a.isReactWarning)?e.props.ref:e.props.ref||e.ref),h=function(a,b){let c={...b};for(let d in b){let e=a[d],f=b[d];/^on[A-Z]/.test(d)?e&&f?c[d]=(...a)=>{let b=f(...a);return e(...a),b}:e&&(c[d]=e):"style"===d?c[d]={...e,...f}:"className"===d&&(c[d]=[e,f].filter(Boolean).join(" "))}return{...a,...c}}(d,c.props);return c.type!==D.Fragment&&(h.ref=b?(0,aw.composeRefs)(b,g):g),D.cloneElement(c,h)}return D.Children.count(c)>1?D.Children.only(null):null})).displayName="MenuContent.ScrollLock.SlotClone",c=e,(d=D.forwardRef((a,b)=>{let{children:d,...e}=a,f=D.Children.toArray(d),g=f.find(tE);if(g){let a=g.props.children,d=f.map(b=>b!==g?b:D.Children.count(a)>1?D.Children.only(null):D.isValidElement(a)?a.props.children:null);return(0,C.jsx)(c,{...e,ref:b,children:D.isValidElement(a)?D.cloneElement(a,void 0,d):null})}return(0,C.jsx)(c,{...e,ref:b,children:d})})).displayName="MenuContent.ScrollLock.Slot",d),ua=D.forwardRef((a,b)=>{let{__scopeMenu:c,loop:d=!1,trapFocus:e,onOpenAutoFocus:f,onCloseAutoFocus:g,disableOutsidePointerEvents:h,onEntryFocus:i,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,disableOutsideScroll:p,...q}=a,r=tW(t3,c),s=tY(t3,c),t=tT(c),u=tU(c),v=tP(c),[w,x]=D.useState(null),y=D.useRef(null),z=(0,aw.useComposedRefs)(b,y,r.onContentChange),A=D.useRef(0),B=D.useRef(""),E=D.useRef(0),F=D.useRef(null),G=D.useRef("right"),H=D.useRef(0),I=p?tH.RemoveScroll:D.Fragment;D.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,tw.useFocusGuards)();let J=D.useCallback(a=>{var b,c;return G.current===F.current?.side&&(b=a,!!(c=F.current?.area)&&function(a,b){let{x:c,y:d}=a,e=!1;for(let a=0,f=b.length-1;a<b.length;f=a++){let g=b[a],h=b[f],i=g.x,j=g.y,k=h.x,l=h.y;j>d!=l>d&&c<(k-i)*(d-j)/(l-j)+i&&(e=!e)}return e}({x:b.clientX,y:b.clientY},c))},[]);return(0,C.jsx)(t4,{scope:c,searchRef:B,onItemEnter:D.useCallback(a=>{J(a)&&a.preventDefault()},[J]),onItemLeave:D.useCallback(a=>{J(a)||(y.current?.focus(),x(null))},[J]),onTriggerLeave:D.useCallback(a=>{J(a)&&a.preventDefault()},[J]),pointerGraceTimerRef:E,onPointerGraceIntentChange:D.useCallback(a=>{F.current=a},[]),children:(0,C.jsx)(I,{...p?{as:t9,allowPinchZoom:!0}:void 0,children:(0,C.jsx)(tx.FocusScope,{asChild:!0,trapped:e,onMountAutoFocus:(0,av.composeEventHandlers)(f,a=>{a.preventDefault(),y.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:g,children:(0,C.jsx)(tv.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,children:(0,C.jsx)(tC.Root,{asChild:!0,...u,dir:s.dir,orientation:"vertical",loop:d,currentTabStopId:w,onCurrentTabStopIdChange:x,onEntryFocus:(0,av.composeEventHandlers)(i,a=>{s.isUsingKeyboardRef.current||a.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,C.jsx)(tz.Content,{role:"menu","aria-orientation":"vertical","data-state":uA(r.open),"data-radix-menu-content":"",dir:s.dir,...t,...q,ref:z,style:{outline:"none",...q.style},onKeyDown:(0,av.composeEventHandlers)(q.onKeyDown,a=>{let b=a.target.closest("[data-radix-menu-content]")===a.currentTarget,c=a.ctrlKey||a.altKey||a.metaKey,d=1===a.key.length;if(b){var e;let b,f,g,h,i,j;"Tab"===a.key&&a.preventDefault(),!c&&d&&(e=a.key,b=B.current+e,f=v().filter(a=>!a.disabled),g=document.activeElement,h=f.find(a=>a.ref.current===g)?.textValue,i=function(a,b,c){var d;let e=b.length>1&&Array.from(b).every(a=>a===b[0])?b[0]:b,f=c?a.indexOf(c):-1,g=(d=Math.max(f,0),a.map((b,c)=>a[(d+c)%a.length]));1===e.length&&(g=g.filter(a=>a!==c));let h=g.find(a=>a.toLowerCase().startsWith(e.toLowerCase()));return h!==c?h:void 0}(f.map(a=>a.textValue),b,h),j=f.find(a=>a.textValue===i)?.ref.current,function a(b){B.current=b,window.clearTimeout(A.current),""!==b&&(A.current=window.setTimeout(()=>a(""),1e3))}(b),j&&setTimeout(()=>j.focus()))}let f=y.current;if(a.target!==f||!tK.includes(a.key))return;a.preventDefault();let g=v().filter(a=>!a.disabled).map(a=>a.ref.current);tJ.includes(a.key)&&g.reverse(),function(a){let b=document.activeElement;for(let c of a)if(c===b||(c.focus(),document.activeElement!==b))return}(g)}),onBlur:(0,av.composeEventHandlers)(a.onBlur,a=>{a.currentTarget.contains(a.target)||(window.clearTimeout(A.current),B.current="")}),onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uD(a=>{let b=a.target,c=H.current!==a.clientX;a.currentTarget.contains(b)&&c&&(G.current=a.clientX>H.current?"right":"left",H.current=a.clientX)}))})})})})})})});t6.displayName=t3;var ub=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"group",...d,ref:b})});ub.displayName="MenuGroup";var uc=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{...d,ref:b})});uc.displayName="MenuLabel";var ud="MenuItem",ue="menu.itemSelect",uf=D.forwardRef((a,b)=>{let{disabled:c=!1,onSelect:d,...e}=a,f=D.useRef(null),g=tY(ud,a.__scopeMenu),h=t5(ud,a.__scopeMenu),i=(0,aw.useComposedRefs)(b,f),j=D.useRef(!1);return(0,C.jsx)(ug,{...e,ref:i,disabled:c,onClick:(0,av.composeEventHandlers)(a.onClick,()=>{let a=f.current;if(!c&&a){let b=new CustomEvent(ue,{bubbles:!0,cancelable:!0});a.addEventListener(ue,a=>d?.(a),{once:!0}),(0,aC.dispatchDiscreteCustomEvent)(a,b),b.defaultPrevented?j.current=!1:g.onClose()}}),onPointerDown:b=>{a.onPointerDown?.(b),j.current=!0},onPointerUp:(0,av.composeEventHandlers)(a.onPointerUp,a=>{j.current||a.currentTarget?.click()}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{let b=""!==h.searchRef.current;c||b&&" "===a.key||tI.includes(a.key)&&(a.currentTarget.click(),a.preventDefault())})})});uf.displayName=ud;var ug=D.forwardRef((a,b)=>{let{__scopeMenu:c,disabled:d=!1,textValue:e,...f}=a,g=t5(ud,c),h=tU(c),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i),[k,l]=D.useState(!1),[n,o]=D.useState("");return D.useEffect(()=>{let a=i.current;a&&o((a.textContent??"").trim())},[f.children]),(0,C.jsx)(tO.ItemSlot,{scope:c,disabled:d,textValue:e??n,children:(0,C.jsx)(tC.Item,{asChild:!0,...h,focusable:!d,children:(0,C.jsx)(aC.Primitive.div,{role:"menuitem","data-highlighted":k?"":void 0,"aria-disabled":d||void 0,"data-disabled":d?"":void 0,...f,ref:j,onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uD(a=>{d?g.onItemLeave(a):(g.onItemEnter(a),a.defaultPrevented||a.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,uD(a=>g.onItemLeave(a))),onFocus:(0,av.composeEventHandlers)(a.onFocus,()=>l(!0)),onBlur:(0,av.composeEventHandlers)(a.onBlur,()=>l(!1))})})})}),uh=D.forwardRef((a,b)=>{let{checked:c=!1,onCheckedChange:d,...e}=a;return(0,C.jsx)(up,{scope:a.__scopeMenu,checked:c,children:(0,C.jsx)(uf,{role:"menuitemcheckbox","aria-checked":uB(c)?"mixed":c,...e,ref:b,"data-state":uC(c),onSelect:(0,av.composeEventHandlers)(e.onSelect,()=>d?.(!!uB(c)||!c),{checkForDefaultPrevented:!1})})})});uh.displayName="MenuCheckboxItem";var ui="MenuRadioGroup",[uj,uk]=tR(ui,{value:void 0,onValueChange:()=>{}}),ul=D.forwardRef((a,b)=>{let{value:c,onValueChange:d,...e}=a,f=(0,tF.useCallbackRef)(d);return(0,C.jsx)(uj,{scope:a.__scopeMenu,value:c,onValueChange:f,children:(0,C.jsx)(ub,{...e,ref:b})})});ul.displayName=ui;var um="MenuRadioItem",un=D.forwardRef((a,b)=>{let{value:c,...d}=a,e=uk(um,a.__scopeMenu),f=c===e.value;return(0,C.jsx)(up,{scope:a.__scopeMenu,checked:f,children:(0,C.jsx)(uf,{role:"menuitemradio","aria-checked":f,...d,ref:b,"data-state":uC(f),onSelect:(0,av.composeEventHandlers)(d.onSelect,()=>e.onValueChange?.(c),{checkForDefaultPrevented:!1})})})});un.displayName=um;var uo="MenuItemIndicator",[up,uq]=tR(uo,{checked:!1}),ur=D.forwardRef((a,b)=>{let{__scopeMenu:c,forceMount:d,...e}=a,f=uq(uo,c);return(0,C.jsx)(tB.Presence,{present:d||uB(f.checked)||!0===f.checked,children:(0,C.jsx)(aC.Primitive.span,{...e,ref:b,"data-state":uC(f.checked)})})});ur.displayName=uo;var us=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"separator","aria-orientation":"horizontal",...d,ref:b})});us.displayName="MenuSeparator";var ut=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tT(c);return(0,C.jsx)(tz.Arrow,{...e,...d,ref:b})});ut.displayName="MenuArrow";var[uu,uv]=tR("MenuSub"),uw="MenuSubTrigger",ux=D.forwardRef((a,b)=>{let c=tW(uw,a.__scopeMenu),d=tY(uw,a.__scopeMenu),e=uv(uw,a.__scopeMenu),f=t5(uw,a.__scopeMenu),g=D.useRef(null),{pointerGraceTimerRef:h,onPointerGraceIntentChange:i}=f,j={__scopeMenu:a.__scopeMenu},k=D.useCallback(()=>{g.current&&window.clearTimeout(g.current),g.current=null},[]);return D.useEffect(()=>k,[k]),D.useEffect(()=>{let a=h.current;return()=>{window.clearTimeout(a),i(null)}},[h,i]),(0,C.jsx)(t$,{asChild:!0,...j,children:(0,C.jsx)(ug,{id:e.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":e.contentId,"data-state":uA(c.open),...a,ref:(0,aw.composeRefs)(b,e.onTriggerChange),onClick:b=>{a.onClick?.(b),a.disabled||b.defaultPrevented||(b.currentTarget.focus(),c.open||c.onOpenChange(!0))},onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uD(b=>{f.onItemEnter(b),!b.defaultPrevented&&(a.disabled||c.open||g.current||(f.onPointerGraceIntentChange(null),g.current=window.setTimeout(()=>{c.onOpenChange(!0),k()},100)))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,uD(a=>{k();let b=c.content?.getBoundingClientRect();if(b){let d=c.content?.dataset.side,e="right"===d,g=b[e?"left":"right"],i=b[e?"right":"left"];f.onPointerGraceIntentChange({area:[{x:a.clientX+(e?-5:5),y:a.clientY},{x:g,y:b.top},{x:i,y:b.top},{x:i,y:b.bottom},{x:g,y:b.bottom}],side:d}),window.clearTimeout(h.current),h.current=window.setTimeout(()=>f.onPointerGraceIntentChange(null),300)}else{if(f.onTriggerLeave(a),a.defaultPrevented)return;f.onPointerGraceIntentChange(null)}})),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,b=>{let e=""!==f.searchRef.current;a.disabled||e&&" "===b.key||tL[d.dir].includes(b.key)&&(c.onOpenChange(!0),c.content?.focus(),b.preventDefault())})})})});ux.displayName=uw;var uy="MenuSubContent",uz=D.forwardRef((a,b)=>{let c=t1(t3,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tW(t3,a.__scopeMenu),g=tY(t3,a.__scopeMenu),h=uv(uy,a.__scopeMenu),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i);return(0,C.jsx)(tO.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tB.Presence,{present:d||f.open,children:(0,C.jsx)(tO.Slot,{scope:a.__scopeMenu,children:(0,C.jsx)(ua,{id:h.contentId,"aria-labelledby":h.triggerId,...e,ref:j,align:"start",side:"rtl"===g.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:a=>{g.isUsingKeyboardRef.current&&i.current?.focus(),a.preventDefault()},onCloseAutoFocus:a=>a.preventDefault(),onFocusOutside:(0,av.composeEventHandlers)(a.onFocusOutside,a=>{a.target!==h.trigger&&f.onOpenChange(!1)}),onEscapeKeyDown:(0,av.composeEventHandlers)(a.onEscapeKeyDown,a=>{g.onClose(),a.preventDefault()}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{let b=a.currentTarget.contains(a.target),c=tM[g.dir].includes(a.key);b&&c&&(f.onOpenChange(!1),h.trigger?.focus(),a.preventDefault())})})})})})});function uA(a){return a?"open":"closed"}function uB(a){return"indeterminate"===a}function uC(a){return uB(a)?"indeterminate":a?"checked":"unchecked"}function uD(a){return b=>"mouse"===b.pointerType?a(b):void 0}uz.displayName=uy;var uE="DropdownMenu",[uF,uG]=(0,ax.createContextScope)(uE,[tS]),uH=tS(),[uI,uJ]=uF(uE),uK=a=>{let{__scopeDropdownMenu:b,children:c,dir:d,open:e,defaultOpen:f,onOpenChange:g,modal:h=!0}=a,i=uH(b),j=D.useRef(null),[k,l]=(0,ay.useControllableState)({prop:e,defaultProp:f??!1,onChange:g,caller:uE});return(0,C.jsx)(uI,{scope:b,triggerId:(0,ty.useId)(),triggerRef:j,contentId:(0,ty.useId)(),open:k,onOpenChange:l,onOpenToggle:D.useCallback(()=>l(a=>!a),[l]),modal:h,children:(0,C.jsx)(tZ,{...i,open:k,onOpenChange:l,dir:d,modal:h,children:c})})};uK.displayName=uE;var uL="DropdownMenuTrigger",uM=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,disabled:d=!1,...e}=a,f=uJ(uL,c),g=uH(c);return(0,C.jsx)(t$,{asChild:!0,...g,children:(0,C.jsx)(aC.Primitive.button,{type:"button",id:f.triggerId,"aria-haspopup":"menu","aria-expanded":f.open,"aria-controls":f.open?f.contentId:void 0,"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,disabled:d,...e,ref:(0,aw.composeRefs)(b,f.triggerRef),onPointerDown:(0,av.composeEventHandlers)(a.onPointerDown,a=>{!d&&0===a.button&&!1===a.ctrlKey&&(f.onOpenToggle(),f.open||a.preventDefault())}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{!d&&(["Enter"," "].includes(a.key)&&f.onOpenToggle(),"ArrowDown"===a.key&&f.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});uM.displayName=uL;var uN=a=>{let{__scopeDropdownMenu:b,...c}=a,d=uH(b);return(0,C.jsx)(t2,{...d,...c})};uN.displayName="DropdownMenuPortal";var uO="DropdownMenuContent",uP=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uJ(uO,c),f=uH(c),g=D.useRef(!1);return(0,C.jsx)(t6,{id:e.contentId,"aria-labelledby":e.triggerId,...f,...d,ref:b,onCloseAutoFocus:(0,av.composeEventHandlers)(a.onCloseAutoFocus,a=>{g.current||e.triggerRef.current?.focus(),g.current=!1,a.preventDefault()}),onInteractOutside:(0,av.composeEventHandlers)(a.onInteractOutside,a=>{let b=a.detail.originalEvent,c=0===b.button&&!0===b.ctrlKey,d=2===b.button||c;(!e.modal||d)&&(g.current=!0)}),style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uP.displayName=uO,D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(ub,{...e,...d,ref:b})}).displayName="DropdownMenuGroup";var uQ=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(uc,{...e,...d,ref:b})});uQ.displayName="DropdownMenuLabel";var uR=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(uf,{...e,...d,ref:b})});uR.displayName="DropdownMenuItem";var uS=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(uh,{...e,...d,ref:b})});uS.displayName="DropdownMenuCheckboxItem",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(ul,{...e,...d,ref:b})}).displayName="DropdownMenuRadioGroup";var uT=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(un,{...e,...d,ref:b})});uT.displayName="DropdownMenuRadioItem";var uU=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(ur,{...e,...d,ref:b})});uU.displayName="DropdownMenuItemIndicator";var uV=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(us,{...e,...d,ref:b})});uV.displayName="DropdownMenuSeparator",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(ut,{...e,...d,ref:b})}).displayName="DropdownMenuArrow";var uW=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(ux,{...e,...d,ref:b})});uW.displayName="DropdownMenuSubTrigger";var uX=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uH(c);return(0,C.jsx)(uz,{...e,...d,ref:b,style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uX.displayName="DropdownMenuSubContent";let uY=(0,K.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);D.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,C.jsxs)(uW,{ref:e,className:(0,S.cn)("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",b&&"pl-8",a),...d,children:[c,(0,C.jsx)(Q.ChevronRight,{className:"ml-auto"})]})).displayName=uW.displayName,D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(uX,{ref:c,className:(0,S.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...b})).displayName=uX.displayName;let uZ=D.forwardRef(({className:a,sideOffset:b=4,...c},d)=>(0,C.jsx)(uN,{children:(0,C.jsx)(uP,{ref:d,sideOffset:b,className:(0,S.cn)("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...c})}));uZ.displayName=uP.displayName;let u$=D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uR,{ref:d,className:(0,S.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",b&&"pl-8",a),...c}));u$.displayName=uR.displayName,D.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,C.jsxs)(uS,{ref:e,className:(0,S.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,C.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,C.jsx)(uU,{children:(0,C.jsx)(bh.Check,{className:"h-4 w-4"})})}),b]})).displayName=uS.displayName,D.forwardRef(({className:a,children:b,...c},d)=>(0,C.jsxs)(uT,{ref:d,className:(0,S.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,C.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,C.jsx)(uU,{children:(0,C.jsx)(uY,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=uT.displayName,D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uQ,{ref:d,className:(0,S.cn)("px-2 py-1.5 text-sm font-semibold",b&&"pl-8",a),...c})).displayName=uQ.displayName;let u_=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(uV,{ref:c,className:(0,S.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));u_.displayName=uV.displayName;var bi=bi;function u0({directiveId:a,onClose:b}){let c,{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(null),[g,h]=(0,D.useState)(!1),[i,j]=(0,D.useState)(null);(0,D.useEffect)(()=>{a&&d&&(async()=>{h(!0),j(null),f(null);try{let b=await V.client.getDirective(d,a);f(b)}catch(a){console.error("Error loading directive:",a),j(a.message)}finally{h(!1)}})()},[a,d]);let k=null!==a;return(0,C.jsx)(bk.Dialog,{open:k,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nN.VisuallyHidden,{children:(0,C.jsx)(bk.DialogTitle,{children:"Directive Details"})}),g?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)(bi.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):i?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)("div",{className:"text-center text-destructive",children:(0,C.jsxs)("div",{className:"text-sm",children:["Error: ",i]})})}):e?(0,C.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,C.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),!e.is_active&&(0,C.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:"Inactive"})]}),(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:e.id})]}),(0,C.jsxs)("div",{className:"flex gap-8",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:(c=new Date(e.created_at),`${c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${c.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Priority"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:e.priority})]})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map((a,b)=>(0,C.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:a},b))})]})]}):null]})})}function u1(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)("dashboard"),[h,i]=(0,D.useState)(""),[j,k]=(0,D.useState)(1),[l,n]=(0,D.useState)(!1),[o,p]=(0,D.useState)(null),[q,r]=(0,D.useState)(!1),[s,t]=(0,D.useState)(null),[u,v]=(0,D.useState)(null),[w,x]=(0,D.useState)(!1),y=b.filter(a=>{if(!h)return!0;let b=h.toLowerCase();return a.id.toLowerCase().includes(b)||a.name.toLowerCase().includes(b)||a.source_query.toLowerCase().includes(b)||a.content.toLowerCase().includes(b)}),z=async()=>{if(a){e(!0);try{let b=await V.client.listMentalModels(a);c(b.items||[])}catch(a){console.error("Error loading mental models:",a)}finally{e(!1)}}},A=async()=>{if(a&&u){x(!0);try{await V.client.deleteMentalModel(a,u.id),c(a=>a.filter(a=>a.id!==u.id)),o?.id===u.id&&p(null),v(null)}catch(a){}finally{x(!1)}}};if((0,D.useEffect)(()=>{a&&z()},[a]),(0,D.useEffect)(()=>{let a=a=>{"Escape"===a.key&&p(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),(0,D.useEffect)(()=>{k(1)},[h]),!a)return(0,C.jsx)(mW,{children:(0,C.jsx)(m$,{className:"p-10 text-center",children:(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to view mental models."})})});let B=Math.ceil(y.length/100),E=(j-1)*100,F=E+100,G=y.slice(E,F);return(0,C.jsxs)("div",{children:[d?(0,C.jsxs)("div",{className:"text-center py-12",children:[(0,C.jsx)(ab,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"mb-4",children:(0,C.jsx)(X.Input,{type:"text",value:h,onChange:a=>i(a.target.value),placeholder:"Filter mental models by name, query, or content...",className:"max-w-md"})}),(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:h?`${y.length} of ${b.length} mental models`:`${b.length} mental model${1!==b.length?"s":""}`}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsxs)(W.Button,{onClick:()=>n(!0),size:"sm",children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-2"}),"Add Mental Model"]}),(0,C.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,C.jsxs)("button",{onClick:()=>g("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===f?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,C.jsx)(tt,{className:"w-4 h-4"}),"Dashboard"]}),(0,C.jsxs)("button",{onClick:()=>g("table"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"table"===f?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,C.jsx)(af,{className:"w-4 h-4"}),"Table"]})]})]})]}),y.length>0?(0,C.jsxs)(C.Fragment,{children:["dashboard"===f&&(0,C.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:G.map(a=>{let b=new Date(a.last_refreshed_at),c=b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),d=b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,C.jsx)(mW,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${o?.id===a.id?"border-primary shadow-md":""}`,onClick:()=>p(a),children:(0,C.jsxs)(m$,{className:"p-4",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:a.name}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:a.id}),(0,C.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${a.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:a.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 ml-2 text-muted-foreground hover:text-destructive flex-shrink-0",onClick:b=>{b.stopPropagation(),v({id:a.id,name:a.name})},children:(0,C.jsx)(mQ,{className:"h-4 w-4"})})]}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:a.source_query}),(0,C.jsx)("div",{className:"text-sm text-foreground mb-3 border-t border-border pt-3",children:a.content.includes("|")||a.content.includes("```")||a.content.includes("\n\n")?(0,C.jsxs)("div",{className:"line-clamp-3 text-muted-foreground italic",children:[a.content.substring(0,150),"..."," ",(0,C.jsx)("span",{className:"text-primary",children:"Click to view full content"})]}):(0,C.jsx)("div",{className:"line-clamp-6 prose prose-sm dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})}),(0,C.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,C.jsx)("div",{className:"flex items-center gap-2",children:a.tags.length>0&&(0,C.jsxs)("div",{className:"flex gap-1",children:[a.tags.slice(0,2).map(a=>(0,C.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a)),a.tags.length>2&&(0,C.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",a.tags.length-2]})]})}),(0,C.jsxs)("div",{className:"text-muted-foreground",children:[c," ",d]})]})]})},a.id)})}),"table"===f&&(0,C.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,C.jsxs)(ai,{className:"table-fixed",children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{className:"bg-muted/50",children:[(0,C.jsx)(am,{className:"w-[20%]",children:"ID"}),(0,C.jsx)(am,{className:"w-[20%]",children:"Name"}),(0,C.jsx)(am,{className:"w-[35%]",children:"Source Query"}),(0,C.jsx)(am,{className:"w-[15%]",children:"Last Refreshed"}),(0,C.jsx)(am,{className:"w-[10%]"})]})}),(0,C.jsx)(ak,{children:G.map(a=>{let b=new Date(a.last_refreshed_at),c=b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),d=b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,C.jsxs)(al,{className:`cursor-pointer hover:bg-muted/50 ${o?.id===a.id?"bg-primary/10":""}`,onClick:()=>p(a),children:[(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate block",children:a.id})}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("div",{className:"font-medium text-foreground",children:a.name})}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground truncate",children:a.source_query})}),(0,C.jsxs)(an,{className:"py-2 text-sm text-foreground",children:[(0,C.jsx)("div",{children:c}),(0,C.jsx)("div",{className:"text-xs text-muted-foreground",children:d})]}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:b=>{b.stopPropagation(),v({id:a.id,name:a.name})},children:(0,C.jsx)(mQ,{className:"h-4 w-4"})})})]},a.id)})})]})}),B>1&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:[E+1,"-",Math.min(F,y.length)," of"," ",y.length]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(1),disabled:1===j,className:"h-7 w-7 p-0",children:(0,C.jsx)(_,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(a=>Math.max(1,a-1)),disabled:1===j,className:"h-7 w-7 p-0",children:(0,C.jsx)(P,{className:"h-3 w-3"})}),(0,C.jsxs)("span",{className:"text-xs px-2",children:[j," / ",B]}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(a=>Math.min(B,a+1)),disabled:j===B,className:"h-7 w-7 p-0",children:(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(B),disabled:j===B,className:"h-7 w-7 p-0",children:(0,C.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,C.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,C.jsx)(L,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:h?"No mental models match your filter":"No mental models yet. Create a mental model to generate and save a summary from your memories."})]})]}),(0,C.jsx)(u2,{open:l,onClose:()=>n(!1),onCreated:()=>{n(!1),z()}}),(0,C.jsx)(ms,{open:!!u,onOpenChange:a=>!a&&v(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Mental Model"}),(0,C.jsxs)(mN,{children:["Are you sure you want to delete"," ",(0,C.jsxs)("span",{className:"font-semibold",children:['"',u?.name,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),(0,C.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,C.jsxs)(mL,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mP,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mO,{onClick:A,disabled:w,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[w?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),o&&(0,C.jsx)(u4,{mentalModel:o,onClose:()=>p(null),onDelete:()=>v({id:o.id,name:o.name}),onEdit:()=>{t(o),r(!0)},onRefreshed:a=>{c(b=>b.map(b=>b.id===a.id?a:b)),p(a)}}),s&&(0,C.jsx)(u3,{open:q,mentalModel:s,onClose:()=>{r(!1),t(null)},onUpdated:a=>{c(b=>b.map(b=>b.id===a.id?a:b)),p(a),r(!1),t(null)}})]})}function u2({open:a,onClose:b,onCreated:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),i=async()=>{if(d&&g.name.trim()&&g.sourceQuery.trim()){f(!0);try{let a=g.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=parseInt(g.maxTokens)||2048;await V.client.createMentalModel(d,{id:g.id.trim()||void 0,name:g.name.trim(),source_query:g.sourceQuery.trim(),tags:a.length>0?a:void 0,max_tokens:b,trigger:{refresh_after_consolidation:g.autoRefresh}}),h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>{a||(h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),b())},children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Create Mental Model"}),(0,C.jsx)(bk.DialogDescription,{children:"Create a mental model by running a query. The content will be auto-generated and can be refreshed later."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["ID ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:g.id,onChange:a=>h({...g,id:a.target.value}),placeholder:"e.g., team-communication"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Custom ID for the mental model. If not provided, a UUID will be generated."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:g.name,onChange:a=>h({...g,name:a.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,C.jsx)(X.Input,{value:g.sourceQuery,onChange:a=>h({...g,sourceQuery:a.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,C.jsx)(X.Input,{type:"number",value:g.maxTokens,onChange:a=>h({...g,maxTokens:a.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:g.tags,onChange:a=>h({...g,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,C.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,C.jsx)(mV.Checkbox,{id:"auto-refresh",checked:g.autoRefresh,onCheckedChange:a=>h({...g,autoRefresh:!0===a})}),(0,C.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:b,disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e||!g.name.trim()||!g.sourceQuery.trim(),children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}),"Generating..."]}):"Create"})]})]})})}function u3({open:a,mentalModel:b,onClose:c,onUpdated:d}){let{currentBank:e}=(0,H.useBank)(),[f,g]=(0,D.useState)(!1),[h,i]=(0,D.useState)({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1});(0,D.useEffect)(()=>{a&&i({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1})},[a,b]);let j=async()=>{if(e&&h.name.trim()&&h.sourceQuery.trim()){g(!0);try{let a=h.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),f=parseInt(h.maxTokens)||2048,g=await V.client.updateMentalModel(e,b.id,{name:h.name.trim(),source_query:h.sourceQuery.trim(),tags:a.length>0?a:void 0,max_tokens:f,trigger:{refresh_after_consolidation:h.autoRefresh}});d(g),c()}catch(a){}finally{g(!1)}}};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Update Mental Model"}),(0,C.jsx)(bk.DialogDescription,{children:"Update the mental model configuration. Changes will take effect immediately."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)(X.Input,{value:b.id,disabled:!0,className:"bg-muted"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"ID cannot be changed after creation."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:h.name,onChange:a=>i({...h,name:a.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,C.jsx)(X.Input,{value:h.sourceQuery,onChange:a=>i({...h,sourceQuery:a.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,C.jsx)(X.Input,{type:"number",value:h.maxTokens,onChange:a=>i({...h,maxTokens:a.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:h.tags,onChange:a=>i({...h,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,C.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,C.jsx)(mV.Checkbox,{id:"update-auto-refresh",checked:h.autoRefresh,onCheckedChange:a=>i({...h,autoRefresh:!0===a})}),(0,C.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:c,disabled:f,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:j,disabled:f||!h.name.trim()||!h.sourceQuery.trim(),children:f?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}),"Updating..."]}):"Update"})]})]})})}function u4({mentalModel:a,onClose:b,onDelete:c,onEdit:d,onRefreshed:e}){let{currentBank:f}=(0,H.useBank)(),[g,h]=(0,D.useState)(!1),[i,j]=(0,D.useState)(null),[k,l]=(0,D.useState)(null),[n,o]=(0,D.useState)(!1),p=async()=>{if(!f)return;h(!0);let b=a.last_refreshed_at;try{await V.client.refreshMentalModel(f,a.id);let c=0,d=async()=>{c++;try{let g=await V.client.getMentalModel(f,a.id);if(g.last_refreshed_at!==b){e(g),h(!1);return}if(c>=120){h(!1),F.toast.error("Refresh timeout",{description:"Refresh is taking longer than expected. Check the operations list for status."});return}setTimeout(d,1e3)}catch(a){console.error("Error polling mental model:",a),h(!1)}};setTimeout(d,1e3)}catch(a){h(!1)}},q=a=>{let b=new Date(a);return`${b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`},r=a.reflect_response?.based_on?Object.entries(a.reflect_response.based_on).filter(([a])=>"observation"!==a).flatMap(([a,b])=>b.map(b=>({...b,factType:a}))):[],s=a.reflect_response?.based_on?.observation||[];return(0,C.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex-1 mr-4",children:[(0,C.jsx)("div",{className:"flex items-center gap-2",children:(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name})}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a.source_query})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsxs)(uK,{children:[(0,C.jsx)(uM,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",disabled:g,children:[g?(0,C.jsx)(bi.default,{className:"h-4 w-4 animate-spin"}):(0,C.jsx)(tu,{className:"h-4 w-4"}),(0,C.jsx)("span",{className:"text-xs",children:"Actions"})]})}),(0,C.jsxs)(uZ,{align:"end",children:[(0,C.jsxs)(u$,{onClick:d,children:[(0,C.jsx)(mR,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,C.jsxs)(u$,{onClick:p,children:[(0,C.jsx)(ab,{className:"h-4 w-4 mr-2"}),"Refresh"]}),(0,C.jsxs)(u$,{onClick:()=>o(!0),children:[(0,C.jsx)(bj,{className:"h-4 w-4 mr-2"}),"View History"]}),(0,C.jsx)(u_,{}),(0,C.jsxs)(u$,{onClick:c,className:"text-destructive focus:text-destructive",children:[(0,C.jsx)(mQ,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,C.jsx)(ah.X,{className:"h-4 w-4"})})]})]}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"ID"}),(0,C.jsx)("div",{className:"text-sm text-foreground font-mono",children:a.id})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Name"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.name})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Source Query"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.source_query})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Max Tokens"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.max_tokens})]}),a.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map(a=>(0,C.jsx)("span",{className:"px-2 py-1 rounded text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a))})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Auto-refresh"}),(0,C.jsx)("span",{className:`inline-block text-xs px-2 py-1 rounded-full font-medium ${a.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:a.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]}),a.last_refreshed_at&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Last Refreshed"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:q(a.last_refreshed_at)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:q(a.created_at)})]})]}),(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})]}),r.length>0&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Based On (",r.length," ",1===r.length?"fact":"facts",")"]}),(0,C.jsx)("div",{className:"space-y-3",children:r.map((a,b)=>{let c="directives"===a.factType?{label:"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===a.factType?{label:"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===a.factType?{label:"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===a.factType?{label:"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:a.factType,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"};return(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,C.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${c.color}`,children:c.label}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>{"directives"===a.factType?l(a.id):j(a.id)},children:"View"})]}),(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text})]},a.id||b)})})]}),s.length>0&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Observations Used (",s.length,")"]}),(0,C.jsx)("div",{className:"space-y-3",children:s.map((a,b)=>(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:"observation"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>j(a.id),children:"View"})]}),(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text})]},a.id||b))})]}),!a.reflect_response&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Based On"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:'No source data available. Click "Refresh" to regenerate with source tracking.'})]})]})]}),i&&f&&(0,C.jsx)(bt,{memoryId:i,onClose:()=>j(null)}),k&&f&&(0,C.jsx)(u0,{directiveId:k,onClose:()=>l(null)}),(0,C.jsx)(sN,{mentalModelId:n?a.id:null,onClose:()=>o(!1),initialTab:"history"})]})}let u5=(0,K.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),u6=(0,K.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var bi=bi;let u7=["consolidation.completed","retain.completed"],u8={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function u9(a){return Object.fromEntries(a.filter(a=>a.key.trim()).map(a=>[a.key,a.value]))}function va(a){return{method:a.method,timeout_seconds:a.timeout_seconds,headers:u9(a.headers),params:u9(a.params)}}function vb({label:a,pairs:b,onChange:c}){let d=(a,d,e)=>{c(b.map((b,c)=>c===a?{...b,[d]:e}:b))};return(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsx)(at,{children:a}),(0,C.jsxs)(W.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>c([...b,{key:"",value:""}]),children:[(0,C.jsx)(sU.Plus,{className:"w-3 h-3 mr-1"}),"Add"]})]}),b.length>0&&(0,C.jsx)("div",{className:"space-y-1.5",children:b.map((a,e)=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(X.Input,{placeholder:"Key",value:a.key,onChange:a=>d(e,"key",a.target.value),className:"h-8 text-sm flex-1"}),(0,C.jsx)(X.Input,{placeholder:"Value",value:a.value,onChange:a=>d(e,"value",a.target.value),className:"h-8 text-sm flex-1"}),(0,C.jsx)("button",{type:"button",onClick:()=>c(b.filter((a,b)=>b!==e)),className:"text-muted-foreground hover:text-foreground shrink-0",children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]},e))})]})}function vc({delivery:a,formatDate:b}){var c;let[d,e]=(0,D.useState)(!1),f=a.last_response_body||a.last_error;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(al,{className:f?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>f&&e(a=>!a),children:[(0,C.jsx)(an,{className:"w-8 pl-3 pr-0",children:f?d?(0,C.jsx)(sP.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,C.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,C.jsx)(an,{children:"completed"===(c=a.status)?(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"delivered"]}):"pending"===c?(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}):"failed"===c?(0,C.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,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}):(0,C.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:c})}),(0,C.jsx)(an,{children:null!=a.last_response_status?(0,C.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${a.last_response_status>=200&&a.last_response_status<300?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:a.last_response_status}):(0,C.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,C.jsx)(an,{className:"text-center text-sm",children:a.attempts}),(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.event_type}),(0,C.jsx)(an,{className:"text-xs text-muted-foreground whitespace-nowrap",children:b(a.created_at)})]}),d&&f&&(0,C.jsx)(al,{className:"bg-muted/20 hover:bg-muted/20",children:(0,C.jsx)(an,{colSpan:6,className:"px-4 py-3",children:(0,C.jsxs)("div",{className:"space-y-3",children:[a.last_error&&(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Error"}),(0,C.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:a.last_error})]}),a.last_response_body&&(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Response Body",a.last_attempt_at&&(0,C.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",b(a.last_attempt_at)]})]}),(0,C.jsx)("pre",{className:"font-mono text-xs bg-background rounded p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto border border-border",children:a.last_response_body})]})]})})})]})}function vd(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)(!1),[h,i]=(0,D.useState)(!1),[j,k]=(0,D.useState)(null),[l,n]=(0,D.useState)(null),[o,p]=(0,D.useState)(!1),[q,r]=(0,D.useState)(u8),[s,t]=(0,D.useState)(!1),[u,v]=(0,D.useState)(null),[w,x]=(0,D.useState)(u8),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),[E,F]=(0,D.useState)(!1),[G,I]=(0,D.useState)(!1),[J,K]=(0,D.useState)(null),[L,M]=(0,D.useState)([]),[N,O]=(0,D.useState)(!1),[P,Q]=(0,D.useState)(null),[R,S]=(0,D.useState)(!1),T=async()=>{if(a){e(!0);try{let b=await V.client.listWebhooks(a);c(b.items||[])}catch(a){console.error("Error loading webhooks:",a)}finally{e(!1)}}};(0,D.useEffect)(()=>{a&&T()},[a]);let U=async()=>{if(a&&q.url){i(!0);try{await V.client.createWebhook(a,{url:q.url,secret:q.secret||void 0,event_types:q.event_types.length>0?q.event_types:void 0,enabled:q.enabled,http_config:va(q.http_config)}),g(!1),r(u8),p(!1),await T()}catch(a){}finally{i(!1)}}},Y=async b=>{if(a){k(b),n(null);try{await V.client.deleteWebhook(a,b),await T()}catch(a){}finally{k(null)}}},Z=async()=>{if(a&&u&&w.url){F(!0);try{let b={url:w.url,event_types:w.event_types,enabled:w.enabled,http_config:va(w.http_config)};A?b.secret=null:w.secret&&(b.secret=w.secret),await V.client.updateWebhook(a,u.id,b),t(!1),await T()}catch{}finally{F(!1)}}},$=async b=>{if(a){K(b),I(!0),M([]),Q(null),O(!0);try{let c=await V.client.listWebhookDeliveries(a,b.id,50);M(c.items||[]),Q(c.next_cursor??null)}catch(a){console.error("Error loading deliveries:",a)}finally{O(!1)}}},_=async()=>{if(a&&J&&P){S(!0);try{let b=await V.client.listWebhookDeliveries(a,J.id,50,P);M(a=>[...a,...b.items||[]]),Q(b.next_cursor??null)}catch(a){console.error("Error loading more deliveries:",a)}finally{S(!1)}}},aa=a=>a?new Date(a).toLocaleString():"N/A";return a?(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-lg font-semibold",children:"Webhooks"}),(0,C.jsx)("button",{onClick:()=>T(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh webhooks",disabled:d,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${d?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[b.length," webhook",1!==b.length?"s":""]})]}),(0,C.jsxs)(W.Button,{size:"sm",onClick:()=>g(!0),children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-2"}),"Add Webhook"]})]}),b.length>0?(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{children:"URL"}),(0,C.jsx)(am,{children:"Method"}),(0,C.jsx)(am,{children:"Event Types"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{children:"Created At"}),(0,C.jsx)(am,{className:"w-[120px]"})]})}),(0,C.jsx)(ak,{children:b.map(a=>(0,C.jsxs)(al,{children:[(0,C.jsx)(an,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,C.jsx)("span",{title:a.url,children:a.url})}),(0,C.jsx)(an,{children:(0,C.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:a.http_config?.method||"POST"})}),(0,C.jsx)(an,{children:(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:a.event_types.length>0?a.event_types.map(a=>(0,C.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:a},a)):(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:"All events"})})}),(0,C.jsx)(an,{children:a.enabled?(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"Enabled"]}):(0,C.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:"Disabled"})}),(0,C.jsx)(an,{className:"text-sm text-muted-foreground",children:aa(a.created_at)}),(0,C.jsx)(an,{children:(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>$(a),title:"View deliveries",children:[(0,C.jsx)(u5,{className:"w-3 h-3 mr-1"}),"Deliveries"]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let b;return v(a),void(x((b=a.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:a.url,secret:"",event_types:a.event_types,enabled:a.enabled,http_config:{method:b.method,timeout_seconds:b.timeout_seconds,headers:Object.entries(b.headers??{}).map(([a,b])=>({key:a,value:b})),params:Object.entries(b.params??{}).map(([a,b])=>({key:a,value:b}))}})),z(!1),B(!1),t(!0))},title:"Edit webhook",children:(0,C.jsx)(mR,{className:"w-3 h-3"})}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>n(a),disabled:j===a.id,title:"Delete webhook",children:j===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(mQ,{className:"w-3 h-3"})})]})})]},a.id))})]})}):(0,C.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:"No webhooks configured. Add a webhook to receive event notifications."}),(0,C.jsx)(bk.Dialog,{open:f,onOpenChange:a=>{a||(r(u8),p(!1)),g(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Add Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Configure a webhook endpoint to receive event notifications."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-2",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Type"}),(0,C.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,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"webhook-url",children:["URL ",(0,C.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,C.jsx)(X.Input,{id:"webhook-url",type:"url",placeholder:"https://example.com/webhook",value:q.url,onChange:a=>r(b=>({...b,url:a.target.value}))})]}),(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Method"}),(0,C.jsxs)(mU.Select,{value:q.http_config.method,onValueChange:a=>r(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mU.SelectTrigger,{children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mU.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"webhook-timeout",children:"Timeout (seconds)"}),(0,C.jsx)(X.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:q.http_config.timeout_seconds,onChange:a=>r(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"webhook-secret",children:["Secret ",(0,C.jsx)("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),(0,C.jsxs)("div",{className:"relative",children:[(0,C.jsx)(X.Input,{id:"webhook-secret",type:o?"text":"password",placeholder:"Signing secret",value:q.secret,onChange:a=>r(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,C.jsx)("button",{type:"button",onClick:()=>p(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,children:o?(0,C.jsx)(u6,{className:"w-4 h-4"}):(0,C.jsx)(u5,{className:"w-4 h-4"})})]})]}),(0,C.jsx)(vb,{label:"Custom Headers",pairs:q.http_config.headers,onChange:a=>r(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(vb,{label:"Query Parameters",pairs:q.http_config.params,onChange:a=>r(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)(at,{children:"Event Types"}),(0,C.jsx)("div",{className:"space-y-2",children:u7.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mV.Checkbox,{id:`event-${a}`,checked:q.event_types.includes(a),onCheckedChange:()=>{r(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}}),(0,C.jsx)(at,{htmlFor:`event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)(be,{id:"webhook-enabled",checked:q.enabled,onCheckedChange:a=>r(b=>({...b,enabled:a}))}),(0,C.jsx)(at,{htmlFor:"webhook-enabled",children:"Enabled"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>g(!1),disabled:h,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:U,disabled:h||!q.url,children:h?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):"Create Webhook"})]})]})}),(0,C.jsx)(bk.Dialog,{open:s,onOpenChange:a=>{a||(v(null),x(u8),z(!1),B(!1)),t(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Update the webhook configuration."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-2",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Type"}),(0,C.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,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"edit-webhook-url",children:["URL ",(0,C.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,C.jsx)(X.Input,{id:"edit-webhook-url",type:"url",placeholder:"https://example.com/webhook",value:w.url,onChange:a=>x(b=>({...b,url:a.target.value}))})]}),(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Method"}),(0,C.jsxs)(mU.Select,{value:w.http_config.method,onValueChange:a=>x(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mU.SelectTrigger,{children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mU.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"edit-webhook-timeout",children:"Timeout (seconds)"}),(0,C.jsx)(X.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:w.http_config.timeout_seconds,onChange:a=>x(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"edit-webhook-secret",children:"Secret"}),(0,C.jsxs)("div",{className:"relative",children:[(0,C.jsx)(X.Input,{id:"edit-webhook-secret",type:y?"text":"password",placeholder:"Leave blank to keep existing",value:w.secret,disabled:A,onChange:a=>x(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,C.jsx)("button",{type:"button",onClick:()=>z(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,children:y?(0,C.jsx)(u6,{className:"w-4 h-4"}):(0,C.jsx)(u5,{className:"w-4 h-4"})})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,C.jsx)(mV.Checkbox,{id:"edit-clear-secret",checked:A,onCheckedChange:a=>{B(!!a),a&&x(a=>({...a,secret:""}))}}),(0,C.jsx)(at,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:"Clear existing secret"})]})]}),(0,C.jsx)(vb,{label:"Custom Headers",pairs:w.http_config.headers,onChange:a=>x(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(vb,{label:"Query Parameters",pairs:w.http_config.params,onChange:a=>x(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)(at,{children:"Event Types"}),(0,C.jsx)("div",{className:"space-y-2",children:u7.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mV.Checkbox,{id:`edit-event-${a}`,checked:w.event_types.includes(a),onCheckedChange:()=>x(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}),(0,C.jsx)(at,{htmlFor:`edit-event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)(be,{id:"edit-webhook-enabled",checked:w.enabled,onCheckedChange:a=>x(b=>({...b,enabled:a}))}),(0,C.jsx)(at,{htmlFor:"edit-webhook-enabled",children:"Enabled"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>t(!1),disabled:E,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:Z,disabled:E||!w.url,children:E?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})}),(0,C.jsx)(bk.Dialog,{open:!!l,onOpenChange:a=>{a||n(null)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-md",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Delete Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Are you sure you want to delete this webhook? This action cannot be undone and all pending deliveries will be cancelled."})]}),l&&(0,C.jsx)("div",{className:"py-2",children:(0,C.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:l.url})}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>n(null),children:"Cancel"}),(0,C.jsx)(W.Button,{variant:"destructive",onClick:()=>l&&Y(l.id),disabled:!!j,children:j?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete Webhook"})]})]})}),(0,C.jsx)(bk.Dialog,{open:G,onOpenChange:a=>{a||(M([]),Q(null)),I(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Webhook Deliveries"}),J&&(0,C.jsx)(bk.DialogDescription,{className:"font-mono text-xs truncate",children:J.url})]}),N?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)(bi.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):L.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-8 pl-3 pr-0"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{children:"HTTP"}),(0,C.jsx)(am,{className:"text-center",children:"Attempts"}),(0,C.jsx)(am,{children:"Event"}),(0,C.jsx)(am,{children:"Created At"})]})}),(0,C.jsx)(ak,{children:L.map(a=>(0,C.jsx)(vc,{delivery:a,formatDate:aa},a.id))})]})}),P&&(0,C.jsx)("div",{className:"flex justify-center pt-2",children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:_,disabled:R,children:[R&&(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Load more"]})})]}):(0,C.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:"No deliveries yet for this webhook."})]})})]}):null}var bi=bi;function ve(){(0,E.useParams)();let a=(0,E.useRouter)(),b=(0,E.useSearchParams)(),{features:c}=(0,I.useFeatures)(),{currentBank:d,setCurrentBank:e,loadBanks:f}=(0,H.useBank)(),g=b.get("view")||"profile",h=b.get("subTab")||"world",i=b.get("bankConfigTab")||"general",j=c?.observations??!1,k=c?.bank_config_api??!1,[l,n]=(0,D.useState)(!1),[o,p]=(0,D.useState)(!1),[q,r]=(0,D.useState)(!1),[s,t]=(0,D.useState)(!1),[u,v]=(0,D.useState)(!1),[w,x]=(0,D.useState)(!1),[y,z]=(0,D.useState)(!1),A=b=>{a.push(`/banks/${d}?view=data&subTab=${b}`)},B=b=>{a.push(`/banks/${d}?view=profile&bankConfigTab=${b}`)},J=async()=>{if(d){p(!0);try{await V.client.deleteBank(d),n(!1),e(null),await f(),a.push("/")}catch(a){}finally{p(!1)}}},K=async()=>{if(d){t(!0);try{let a=await V.client.clearObservations(d);r(!1),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{t(!1)}}},L=async()=>{if(d){z(!0);try{await V.client.resetBankConfig(d),x(!1)}catch{}finally{z(!1)}}},M=async()=>{if(d){v(!0);try{await V.client.triggerConsolidation(d)}catch(a){}finally{v(!1)}}};return(0,C.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,C.jsx)(G.BankSelector,{}),(0,C.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,C.jsx)(U,{currentTab:g,onTabChange:b=>{a.push(`/banks/${d}?view=${b}`)}}),(0,C.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,C.jsxs)("div",{className:"p-6",children:["profile"===g&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Bank Configuration"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Manage bank settings, profile, and operations."})]}),(0,C.jsxs)(uK,{children:[(0,C.jsx)(uM,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",children:["Actions",(0,C.jsx)(tu,{className:"w-4 h-4 ml-2"})]})}),(0,C.jsxs)(uZ,{align:"end",className:"w-48",children:[(0,C.jsxs)(u$,{onClick:M,disabled:u||!j,title:j?void 0:"Observations feature is not enabled",children:[u?(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,C.jsx)(m0,{className:"w-4 h-4 mr-2"}),u?"Consolidating...":"Run Consolidation",!j&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsxs)(u$,{onClick:()=>r(!0),disabled:!j,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:j?void 0:"Observations feature is not enabled",children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations",!j&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsx)(u_,{}),(0,C.jsxs)(u$,{onClick:()=>x(!0),disabled:!k,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:k?void 0:"Bank Config API is disabled",children:[(0,C.jsx)(tq,{className:"w-4 h-4 mr-2"}),"Reset Configuration",!k&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsx)(u_,{}),(0,C.jsxs)(u$,{onClick:()=>n(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})]})]})]}),(0,C.jsx)("div",{className:"mb-6 border-b border-border",children:(0,C.jsxs)("div",{className:"flex gap-1",children:[(0,C.jsxs)("button",{onClick:()=>B("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["General","general"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),k&&(0,C.jsxs)("button",{onClick:()=>B("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Configuration","configuration"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>B("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Webhooks","webhooks"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,C.jsxs)("div",{children:["general"===i&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview statistics and background operations for this memory bank."}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(tp,{}),(0,C.jsx)(ts,{}),(0,C.jsx)(sW,{hideReflectFields:!0})]})]}),"configuration"===i&&k&&(0,C.jsx)("div",{className:"space-y-6",children:(0,C.jsx)(te,{})}),"webhooks"===i&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage webhook endpoints to receive event notifications from this memory bank."}),(0,C.jsx)(vd,{})]})]})]}),"recall"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Recall"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Analyze memory recall with detailed trace information and retrieval methods."}),(0,C.jsx)(sR,{})]}),"reflect"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Reflect"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Run an agentic loop that autonomously gathers evidence and reasons through the lens of the bank's disposition to generate contextual responses."}),(0,C.jsx)(sO,{})]}),"data"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Memories"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and explore different types of memories stored in this memory bank."}),(0,C.jsx)("div",{className:"mb-6 border-b border-border",children:(0,C.jsxs)("div",{className:"flex gap-1",children:[(0,C.jsxs)("button",{onClick:()=>A("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["World Facts","world"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>A("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Experience","experience"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>A("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Observations",!j&&(0,C.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>A("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Mental Models","mental-models"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,C.jsxs)("div",{children:["world"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Objective facts about the world received from external sources."}),(0,C.jsx)(mk,{factType:"world"},"world")]}),"experience"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"The bank's own actions, interactions, and first-person experiences."}),(0,C.jsx)(mk,{factType:"experience"},"experience")]}),"observations"===h&&(j?(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Consolidated knowledge synthesized from facts — patterns, preferences, and learnings that emerge from accumulated evidence."}),(0,C.jsx)(mk,{factType:"observation"},"observations")]}):(0,C.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,C.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,C.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,C.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Z"}),(0,C.jsx)("path",{d:"M12 8v4"}),(0,C.jsx)("path",{d:"M12 16h.01"})]})}),(0,C.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"Observations Not Enabled"}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md",children:["Observations consolidation is disabled on this server. Set"," ",(0,C.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})," ","to enable."]})]})),"mental-models"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"User-curated summaries generated from queries — reusable knowledge snapshots that can be refreshed as memories evolve."}),(0,C.jsx)(u1,{},"mental-models")]})]})]}),"documents"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Documents"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Manage documents and retain new memories."}),(0,C.jsx)(mS,{})]}),"entities"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Entities"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Explore entities (people, organizations, places) mentioned in memories."}),(0,C.jsx)(mT,{})]})]})})]}),(0,C.jsx)(ms,{open:l,onOpenChange:n,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Memory Bank"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:o,children:"Cancel"}),(0,C.jsx)(mO,{onClick:J,disabled:o,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:o?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(ms,{open:w,onOpenChange:x,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Reset Configuration"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to reset all configuration overrides for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"All per-bank settings (retain, observations, reflect) will revert to server defaults. This does not affect memories, entities, or the bank profile."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:y,children:"Cancel"}),(0,C.jsx)(mO,{onClick:L,disabled:y,children:y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Resetting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(tq,{className:"w-4 h-4 mr-2"}),"Reset Configuration"]})})]})]})}),(0,C.jsx)(ms,{open:q,onOpenChange:r,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Clear Observations"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:s,children:"Cancel"}),(0,C.jsx)(mO,{onClick:K,disabled:s,className:"bg-amber-500 text-white hover:bg-amber-600",children:s?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})})]})}a.s(["default",()=>ve],73101)}];
|
|
8
|
+
${K.trim()}`:K.trim();await V.client.updateDirective(l,b.id,{content:a})}else await V.client.createDirective(l,{name:ao,content:K.trim()});N(""),R(!0),setTimeout(()=>R(!1),3e3)}catch(a){}finally{P(!1)}}},ar=async()=>{if(l&&n){E(!0),y("answer");try{let a=F.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=await V.client.reflect({bank_id:l,query:n,budget:p,max_tokens:r,include_facts:t,include_tool_calls:v,...a.length>0&&{tags:a,tags_match:I}});A(b)}catch(a){}finally{E(!1)}}};return l?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"pt-6",children:[(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsxs)("div",{className:"flex-1 relative",children:[(0,C.jsx)(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:"What would you like to reflect on?",className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&ar()})]}),(0,C.jsx)(W.Button,{onClick:ar,disabled:B||!n,className:"h-12 px-8",children:B?"Reflecting...":"Reflect"})]}),(0,C.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Budget:"}),(0,C.jsxs)(mU.Select,{value:p,onValueChange:a=>q(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mU.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mU.SelectItem,{value:"high",children:"High"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,C.jsx)(X.Input,{type:"number",value:r,onChange:a=>s(parseInt(a.target.value)||4096),className:"w-24 h-8"})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:t,onCheckedChange:a=>u(a)}),(0,C.jsx)("span",{className:"text-sm",children:"Include Source"})]}),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:v,onCheckedChange:a=>w(a)}),(0,C.jsx)("span",{className:"text-sm",children:"Include Tools"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,C.jsx)(ag,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("div",{className:"flex-1 max-w-md",children:(0,C.jsx)(X.Input,{type:"text",value:F,onChange:a=>G(a.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,C.jsxs)(mU.Select,{value:I,onValueChange:a=>J(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mU.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),B&&(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Reflecting on memories..."})]})}),!B&&z&&(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[z.usage&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Input tokens:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.usage.input_tokens?.toLocaleString()})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Output tokens:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.usage.output_tokens?.toLocaleString()})]})]}),z.trace?.tool_calls&&(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Tool calls:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.trace.tool_calls.length}),(0,C.jsxs)("span",{className:"text-muted-foreground",children:["(",z.trace.tool_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),z.trace?.llm_calls&&(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"LLM calls:"}),(0,C.jsx)("span",{className:"font-semibold",children:z.trace.llm_calls.length}),(0,C.jsxs)("span",{className:"text-muted-foreground",children:["(",z.trace.llm_calls.reduce((a,b)=>a+b.duration_ms,0),"ms)"]})]}),(0,C.jsx)("div",{className:"flex-1"}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(a=>(0,C.jsx)("button",{onClick:()=>y(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${x===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===a?"Answer":"trace"===a?"Trace":"JSON"},a))})]}),"answer"===x&&(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{children:"Answer"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:z.text})})})]}),(0,C.jsxs)(mW,{className:"border-blue-200 dark:border-blue-800",children:[(0,C.jsxs)(mX,{className:"py-4",children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(m1,{className:"w-4 h-4"}),"Add Directive"]}),(0,C.jsx)(mZ,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,C.jsx)(m$,{className:"pt-0",children:Q?(0,C.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,C.jsx)("span",{className:"text-lg",children:"✓"}),(0,C.jsxs)("span",{className:"text-sm font-medium",children:["Directive saved to ",ao]})]}):(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsx)(m4.Textarea,{value:K,onChange:a=>N(a.target.value),placeholder:"e.g., Always respond in formal English...",className:"flex-1 min-h-[60px] resize-none",onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&aq()}}),(0,C.jsx)(W.Button,{onClick:aq,disabled:O||!K.trim(),className:"self-end",children:O?"Saving...":"Save"})]})})]})]}),"trace"===x&&(0,C.jsxs)("div",{className:"space-y-4",children:[z.observations_created&&z.observations_created.length>0&&(0,C.jsxs)(mW,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,C.jsxs)(mX,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(m0,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",z.observations_created.length,")"]}),(0,C.jsx)(mZ,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,C.jsx)(m$,{className:"pt-4",children:(0,C.jsx)("div",{className:"space-y-2",children:z.observations_created.map((a,b)=>(0,C.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,C.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:a.name}),(0,C.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:a.description}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",a.id]})]},b))})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,C.jsxs)(mW,{className:"h-fit",children:[(0,C.jsxs)(mX,{className:"pb-3",children:[(0,C.jsx)(mY,{className:"text-base",children:"Execution Trace"}),(0,C.jsxs)(mZ,{className:"text-xs",children:[z.iterations||0," iteration",1!==(z.iterations||0)?"s":""," •"," ",(z.trace?.llm_calls?.reduce((a,b)=>a+b.duration_ms,0)||0)+(z.trace?.tool_calls?.reduce((a,b)=>a+b.duration_ms,0)||0),"ms total"]})]}),(0,C.jsx)(m$,{children:v?z.trace?.llm_calls&&z.trace.llm_calls.length>0||z.trace?.tool_calls&&z.trace.tool_calls.length>0?(0,C.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(a=z.trace?.llm_calls||[],b=z.trace?.tool_calls||[],c=[],a.forEach((d,e)=>{let f=b.filter(a=>a.iteration===e+1),g=e===a.length-1,h=d.scope.includes("final")||g&&0===f.length,i=h?a.length:e+1;c.push({type:"llm",llm:d,iteration:i,isFinal:h}),f.length>0&&c.push({type:"tools",tools:f,iteration:e+1})}),c.map((a,b)=>(0,C.jsxs)("div",{className:"relative",children:[b<c.length-1&&(0,C.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===a.type?(0,C.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,C.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:a.isFinal?(0,C.jsx)(bh.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,C.jsx)("span",{className:"text-[10px] font-semibold",children:a.iteration})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsx)("span",{className:"font-medium text-sm",children:a.isFinal?"Response generated":"Agent decided"}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),a.llm.duration_ms,"ms"]})]}),(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:a.isFinal?"Final answer":"Called tools below"})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,C.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,C.jsx)(m3,{className:"w-3 h-3",fill:"currentColor"})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Executing ",a.tools?.length," tool",a.tools?.length!==1?"s":""]}),a.tools?.map((a,b)=>(0,C.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.tool}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),a.duration_ms,"ms"]})]}),(0,C.jsxs)("div",{className:"p-2 space-y-2",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Input:"}),(0,C.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,C.jsx)(nM,{src:a.input,collapsed:1,theme:"default"})})]}),a.output&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Output:"}),(0,C.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,C.jsx)(nM,{src:a.output,collapsed:1,theme:"default"})})]})]})]},b))]})]})]},b)))}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"No operations"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No LLM or tool calls were made during this reflection."})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Tool Calls" to see trace.'})]})]})})]}),(0,C.jsxs)(mW,{className:"h-fit",children:[(0,C.jsxs)(mX,{className:"pb-3",children:[(0,C.jsx)(mY,{className:"text-base",children:"Based On"}),(0,C.jsxs)(mZ,{className:"text-xs",children:[(z.based_on?.memories?.length||0)+(z.based_on?.observations?.filter(a=>"directive"!==a.subtype)?.length||0)+(z.based_on?.directives?.length||0)," ","items used"]})]}),(0,C.jsx)(m$,{children:t?z.based_on?.memories&&z.based_on.memories.length>0||z.based_on?.mental_models&&z.based_on.mental_models.length>0||z.based_on?.directives&&z.based_on.directives.length>0||z.based_on?.observations&&z.based_on.observations.length>0?(e=(d=z.based_on?.memories||[]).filter(a=>"world"===a.type),f=d.filter(a=>"experience"===a.type),g=z.based_on?.mental_models||[],h=(z.based_on?.observations||[]).filter(a=>"directive"!==a.subtype),j=[{id:"directives",label:"Directives",count:(i=z.based_on?.directives||[]).length},{id:"mental_models",label:"Mental Models",count:g.length},{id:"observations",label:"Observations",count:h.length},{id:"world",label:"World",count:e.length},{id:"experience",label:"Experience",count:f.length}],k=(()=>{switch(am){case"directives":return i;case"mental_models":return g;case"observations":return h;case"world":return e;case"experience":return f;default:return[]}})(),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:j.map(a=>(0,C.jsxs)("button",{onClick:()=>an(a.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${am===a.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[a.label," (",a.count,")"]},a.id))}),k.length>0?(0,C.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:k.map((a,b)=>{let c,d;return(0,C.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==am?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==am&&("observations"===am?ap(a):"mental_models"===am?al(a.id):T(a.id))},children:"directives"===am?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"font-medium text-sm",children:a.name}),a.content&&(0,C.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:a.content})]}):"observations"===am?(0,C.jsx)("div",{className:"font-medium text-sm",children:a.name}):"mental_models"===am?(d=(c=a.text?.indexOf(": ")??-1)>0?a.text.slice(0,c):a.id,(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"font-medium text-sm",children:d}),(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:a.id})]})):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text}),a.context&&(0,C.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:a.context})]})},a.id||b)})}):(0,C.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:["No ",am," items"]})]})):(0,C.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,C.jsx)(m_.Info,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:"No facts found"}),(0,C.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:"No memories were used to generate this answer."})]})]}):(0,C.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,C.jsx)(m_.Info,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Source" to see memories.'})]})]})})]})]})]}),"json"===x&&(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nM,{src:z,collapsed:2,theme:"default"})})})]})]}),!B&&!z&&(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Reflect"}),(0,C.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a question above to query the memory bank and generate a disposition-aware response."})]})}),(0,C.jsx)(bt,{memoryId:S,onClose:()=>T(null)}),U&&(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(m2,{className:"w-5 h-5"}),(0,C.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{Y(null),$(null)},children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]}),_?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,C.jsx)("p",{className:"mt-1 font-medium",children:Z?.name||U.name})]}),Z?.description&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,C.jsx)("p",{className:"mt-1 text-sm",children:Z.description})]}),Z?.tags&&Z.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.tags.map(a=>(0,C.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ag,{className:"w-2.5 h-2.5"}),a]},a))})]}),(Z?.content||U.content)&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,C.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:Z?.content||U.content})})]}),(0,C.jsxs)("div",{className:"pt-2 border-t",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:U.id})]})]})]})}),ab&&(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(m0,{className:"w-5 h-5"}),(0,C.jsx)("h2",{className:"text-lg font-semibold",children:"Observation"})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{ac(null),af(null)},children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]}),ai?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Text"}),(0,C.jsx)("div",{className:"mt-1 prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:ae?.text||ab.text})})]}),ae?.tags&&ae.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:ae.tags.map(a=>(0,C.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,C.jsx)(ag,{className:"w-2.5 h-2.5"}),a]},a))})]}),ae?.source_memories&&ae.source_memories.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Source Memories (",ae.source_memories.length,")"]}),(0,C.jsx)("div",{className:"space-y-2",children:ae.source_memories.map((a,b)=>(0,C.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:a.text||("string"==typeof a?a:"")})},b))})]}),(0,C.jsxs)("div",{className:"pt-2 border-t",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:ab.id})]})]})]})}),(0,C.jsx)(sN,{mentalModelId:ak,onClose:()=>al(null)})]}):(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start reflecting."})]})})}var sP=a.i(5784);let sQ=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function sR(){let a,b,c,d,e,f,g,h,i,j,k,l,n,o,{currentBank:p}=(0,H.useBank)(),[q,r]=(0,D.useState)(""),[s,t]=(0,D.useState)(["world"]),[u,v]=(0,D.useState)("mid"),[w,x]=(0,D.useState)(4096),[y,z]=(0,D.useState)(""),[A,B]=(0,D.useState)(!1),[E,G]=(0,D.useState)(!1),[I,K]=(0,D.useState)(""),[L,P]=(0,D.useState)("any"),[R,S]=(0,D.useState)(null),[T,U]=(0,D.useState)(null),[Z,$]=(0,D.useState)(null),[_,aa]=(0,D.useState)(null),[ab,ac]=(0,D.useState)(null),[ae,af]=(0,D.useState)(!1),[ah,ai]=(0,D.useState)("results"),[aj,ak]=(0,D.useState)(null),[al,am]=(0,D.useState)(new Set),[an,ao]=(0,D.useState)(new Set),ap=a=>{am(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},aq=a=>{ao(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},ar=a=>{let b=a.id||a.node_id;ak(R?.find(a=>a.id===b||a.node_id===b)||a)},as=async()=>{if(!p)return void F.toast.error("Validation error",{description:"Please select a memory bank first"});if(q){if(0===s.length)return void F.toast.error("Validation error",{description:"Please select at least one type (World, Experience, or Observations)"});af(!0);try{let a=I.split(",").map(a=>a.trim()).filter(a=>a.length>0),b={bank_id:p,query:q,types:s,budget:u,max_tokens:w,trace:!0,include:{entities:E?{max_tokens:500}:null,chunks:A?{max_tokens:8192}:null},...y&&{query_timestamp:y},...a.length>0&&{tags:a,tags_match:L}},c=await V.client.recall(b);S(c.results||[]),U(c.entities||null),$(c.chunks||null),aa(c.observations||null),ac(c.trace||null),ai("results")}catch(a){}finally{af(!1)}}},at=a=>{t(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])};return p?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"pt-6",children:[(0,C.jsxs)("div",{className:"flex gap-3",children:[(0,C.jsxs)("div",{className:"flex-1 relative",children:[(0,C.jsx)(J.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:"What would you like to recall?",className:"pl-10 h-12 text-lg",onKeyDown:a=>"Enter"===a.key&&as()})]}),(0,C.jsx)(W.Button,{onClick:as,disabled:ae||!q,className:"h-12 px-8",children:ae?"Searching...":"Recall"})]}),(0,C.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Types:"}),(0,C.jsxs)("div",{className:"flex gap-3",children:[["world","experience"].map(a=>(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:s.includes(a),onCheckedChange:()=>at(a)}),(0,C.jsx)("span",{className:"text-sm capitalize",children:a})]},a)),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:s.includes("observation"),onCheckedChange:()=>at("observation")}),(0,C.jsx)("span",{className:"text-sm",children:"Observations"})]})]})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(nO,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsxs)(mU.Select,{value:u,onValueChange:a=>v(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mU.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mU.SelectItem,{value:"high",children:"High"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,C.jsx)(X.Input,{type:"number",value:w,onChange:a=>x(parseInt(a.target.value)),className:"w-24 h-8"})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(ad,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)(X.Input,{type:"datetime-local",value:y,onChange:a=>z(a.target.value),className:"h-8",placeholder:"Query date"})]}),(0,C.jsx)("div",{className:"h-6 w-px bg-border"}),(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:A,onCheckedChange:a=>B(a)}),(0,C.jsx)(N.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("span",{className:"text-sm",children:"Chunks"})]}),(0,C.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,C.jsx)(mV.Checkbox,{checked:E,onCheckedChange:a=>G(a)}),(0,C.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("span",{className:"text-sm",children:"Entities"})]})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,C.jsx)(ag,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsx)("div",{className:"flex-1 max-w-md",children:(0,C.jsx)(X.Input,{type:"text",value:I,onChange:a=>K(a.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,C.jsxs)(mU.Select,{value:L,onValueChange:a=>P(a),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mU.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mU.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),ae&&(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Searching memories..."})]})}),!ae&&R&&(0,C.jsxs)("div",{className:"space-y-4",children:[ab?.summary&&(0,C.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Results:"}),(0,C.jsx)("span",{className:"font-semibold",children:R.length})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Duration:"}),(0,C.jsxs)("span",{className:"font-semibold",children:[ab.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-muted-foreground",children:"Nodes visited:"}),(0,C.jsx)("span",{className:"font-semibold",children:ab.summary.total_nodes_visited})]}),(0,C.jsx)("div",{className:"flex-1"}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(a=>(0,C.jsx)("button",{onClick:()=>ai(a),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ah===a?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===a?"Results":"trace"===a?"Trace":"JSON"},a))})]}),"results"===ah&&(0,C.jsxs)("div",{className:"space-y-4",children:[_&&_.length>0&&(0,C.jsxs)(mW,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,C.jsx)(mX,{className:"py-3",children:(0,C.jsxs)(mY,{className:"text-base flex items-center gap-2",children:[(0,C.jsx)(M,{className:"h-4 w-4 text-orange-500"}),(0,C.jsx)("span",{children:"Observations"}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",_.length,")"]})]})}),(0,C.jsx)(m$,{className:"pt-0 space-y-2",children:_.map((a,b)=>(0,C.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,C.jsx)("p",{className:"text-sm text-foreground",children:a.text}),(0,C.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,C.jsxs)("span",{children:["Proof count: ",a.proof_count||1]}),(0,C.jsxs)("span",{children:["Relevance: ",(a.relevance||0).toFixed(3)]})]})]},a.id||b))})]}),(0,C.jsx)("div",{className:"space-y-3",children:0!==R.length||_&&0!==_.length?R.map((a,b)=>{let c=ab?.visits?.find(b=>b.node_id===a.id),d=c?c.weights.final_weight:a.score||0;return(0,C.jsx)(mW,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ak(a),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-start gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-semibold text-primary",children:b+1})}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-foreground",children:a.text}),(0,C.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:a.type||"world"}),a.context&&(0,C.jsx)("span",{className:"truncate max-w-xs",children:a.context}),a.occurred_start&&(0,C.jsx)("span",{children:new Date(a.occurred_start).toLocaleDateString()})]})]}),(0,C.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,C.jsx)("div",{className:"text-sm font-semibold",children:d.toFixed(3)}),(0,C.jsx)("div",{className:"text-xs text-muted-foreground",children:"score"})]}),(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},b)}):(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-12",children:[(0,C.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"No memories found for this query."})]})})})]}),"trace"===ah&&ab&&(0,C.jsxs)("div",{className:"space-y-4",children:[ab.retrieval_results&&ab.retrieval_results.length>0&&(a={},ab.retrieval_results.forEach(b=>{let c=b.fact_type||"all";a[c]||(a[c]=[]),a[c].push(b)}),b=Object.keys(a),(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,C.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,C.jsx)("span",{children:"PARALLEL RETRIEVAL"}),(0,C.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,C.jsx)("div",{className:"space-y-2",children:b.map((b,c)=>{let d=a[b],e=`lane-${b}`,f=al.has(e),g=d.reduce((a,b)=>a+(b.results?.length||0),0),h=Math.max(...d.map(a=>a.duration_seconds||0)),i={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},j=i[b]||i.all;return(0,C.jsx)(mW,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,C.jsxs)(m$,{className:"py-3 px-4",children:[(0,C.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>ap(e),children:[(0,C.jsx)("div",{className:`w-8 h-8 rounded-lg ${j.bg} flex items-center justify-center`,children:(0,C.jsx)("span",{className:`text-sm font-bold ${j.text} capitalize`,children:b.charAt(0).toUpperCase()})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground capitalize",children:b}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," methods"]})]}),(0,C.jsx)("div",{className:"flex gap-1.5 mt-1",children:d.map((a,b)=>(0,C.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[a.method_name,": ",a.results?.length||0]},b))})]}),(0,C.jsxs)("div",{className:"text-right",children:[(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:g}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[h.toFixed(2),"s"]})]}),f?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]}),f&&(0,C.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,C.jsx)("div",{className:`grid gap-3 ${1===d.length?"grid-cols-1":2===d.length?"grid-cols-2":3===d.length?"grid-cols-3":"grid-cols-4"}`,children:d.map((a,b)=>{let c,d,f,g,h=`${e}-method-${b}`,i=al.has(h),j=a.results||[];return(0,C.jsxs)("div",{className:"flex flex-col",children:[(0,C.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${i?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:a=>{a.stopPropagation(),ap(h)},children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:a.method_name}),"temporal"===a.method_name&&a.metadata?.constraint&&(0,C.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,C.jsx)(Y,{className:"h-3 w-3"}),a.metadata.constraint.start?new Date(a.metadata.constraint.start).toLocaleDateString():"any"," → ",a.metadata.constraint.end?new Date(a.metadata.constraint.end).toLocaleDateString():"any"]})]}),i?(0,C.jsx)(sP.ChevronDown,{className:"h-3 w-3 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3 text-muted-foreground"})]}),(0,C.jsxs)("div",{className:"flex items-end justify-between",children:[(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:j.length}),(0,C.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[a.duration_seconds?.toFixed(2),"s"]})]})]}),i&&j.length>0&&(c=`results-${h}`,f=(d=an.has(c))?j:j.slice(0,5),g=j.length>5,(0,C.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[f.map((a,b)=>(0,C.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:a.text}),(0,C.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,C.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(a.score||a.similarity||0).toFixed(4)})})]})]})},b)),g&&(0,C.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(c)},children:d?"Show less":`View all ${j.length} results`})]}))]},h)})})})]})},e)})}),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)("div",{className:"flex items-center gap-2",children:b.map((a,b)=>{let c={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,C.jsx)("div",{className:"flex flex-col items-center",children:(0,C.jsx)("div",{className:`w-1 h-4 ${c[a]||c.all} rounded-full opacity-50`})},b)})})}),(0,C.jsx)("div",{className:"flex justify-center",children:(0,C.jsx)(sQ,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ab.rrf_merged&&(c="rrf-merge",d=al.has(c),(0,C.jsxs)("div",{children:[(0,C.jsx)(mW,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(c),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"RRF Fusion"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"merge"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Reciprocal Rank Fusion of all retrieval results"})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ab.rrf_merged.length}),d?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),d&&ab.rrf_merged.length>0&&(e="results-rrf",g=(f=an.has(e))?ab.rrf_merged:ab.rrf_merged.slice(0,5),h=ab.rrf_merged.length>5,(0,C.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[g.map((a,b)=>(0,C.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,C.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["RRF Score: ",(a.rrf_score||a.score||0).toFixed(4)]})]})]})},b)),h&&(0,C.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(e)},children:f?"Show less":`View all ${ab.rrf_merged.length} results`})]})),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)(sQ,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ab.reranked&&(i="reranking",j=al.has(i),(0,C.jsxs)("div",{children:[(0,C.jsx)(mW,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(i),children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"Combined Scoring"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"rerank"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,C.jsx)("span",{className:"font-mono text-xs",children:"ce × recency_boost(±10%) × temporal_boost(±10%)"})})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ab.reranked.length}),j?(0,C.jsx)(sP.ChevronDown,{className:"h-5 w-5 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"h-5 w-5 text-muted-foreground"})]})})}),j&&ab.reranked.length>0&&(k="results-rerank",n=(l=an.has(k))?ab.reranked:ab.reranked.slice(0,5),o=ab.reranked.length>5,(0,C.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[n.map((a,b)=>{let c=a.score_components||{};return(0,C.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:b=>{b.stopPropagation(),ar(a)},children:(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:b+1}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.text}),(0,C.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,C.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(a.rerank_score||a.score||0).toFixed(4)]}),void 0!==c.cross_encoder_score_normalized&&(0,C.jsxs)("span",{title:"Cross-encoder score (primary relevance signal)",children:["CE: ",c.cross_encoder_score_normalized.toFixed(3)]}),void 0!==c.temporal&&.5!==c.temporal&&(0,C.jsxs)("span",{title:"Temporal proximity boost (±10% — only active for temporal queries)",children:["Tmp: ",c.temporal.toFixed(3)]}),void 0!==c.recency&&(0,C.jsxs)("span",{title:"Recency boost (±10% — based on memory age)",children:["Rec: ",c.recency.toFixed(3)]})]})]})]})},b)}),o&&(0,C.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:a=>{a.stopPropagation(),aq(k)},children:l?"Show less":`View all ${ab.reranked.length} results`})]})),(0,C.jsx)("div",{className:"flex justify-center py-2",children:(0,C.jsx)(sQ,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,C.jsx)(mW,{className:"border-primary bg-primary/5",children:(0,C.jsx)(m$,{className:"py-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-4",children:[(0,C.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,C.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"font-semibold text-foreground",children:"Final Results"}),(0,C.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:"output"})]}),(0,C.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Top results after all processing steps"})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-primary",children:R?.length||0})]})})})]}),"json"===ah&&(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{children:(0,C.jsx)(mY,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(m$,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nM,{src:{results:R,...T&&{entities:T},...Z&&{chunks:Z},..._&&{observations:_},trace:ab},collapsed:2,theme:"default"})})})]})]}),!ae&&!R&&(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(J.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Recall"}),(0,C.jsx)("p",{className:"text-muted-foreground text-center max-w-md",children:"Enter a query above to search through your memories. Use filters to narrow down by fact type, budget, and more."})]})}),aj&&(0,C.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,C.jsx)(bu,{memory:aj,onClose:()=>ak(null),inPanel:!0,bankId:p||void 0})})]}):(0,C.jsx)(mW,{className:"border-dashed",children:(0,C.jsxs)(m$,{className:"flex flex-col items-center justify-center py-16",children:[(0,C.jsx)(M,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start recalling."})]})})}let sS=(0,K.default)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var sT=a.i(83604),sT=sT,sU=a.i(15618),bi=bi;let sV={skepticism:{label:"Skepticism",shortLabel:"S",description:"How skeptical vs trusting when forming observations",lowLabel:"Trusting",highLabel:"Skeptical"},literalism:{label:"Literalism",shortLabel:"L",description:"How literally to interpret information when forming observations",lowLabel:"Flexible",highLabel:"Literal"},empathy:{label:"Empathy",shortLabel:"E",description:"How much to consider emotional context when forming observations",lowLabel:"Detached",highLabel:"Empathetic"}};function sW({hideReflectFields:a=!1}){let b=(0,E.useRouter)(),{currentBank:c,setCurrentBank:d,loadBanks:e}=(0,H.useBank)(),{features:f}=(0,I.useFeatures)();f?.observations;let[g,h]=(0,D.useState)(null),[i,j]=(0,D.useState)(null),[k,l]=(0,D.useState)([]),[n,o]=(0,D.useState)(0),[p,q]=(0,D.useState)([]),[r,s]=(0,D.useState)(0),[t,u]=(0,D.useState)(!1),[v,w]=(0,D.useState)(!1),[x,y]=(0,D.useState)(!1),[z,A]=(0,D.useState)(!1),[B,G]=(0,D.useState)(null),[J,K]=(0,D.useState)(null),[L,M]=(0,D.useState)(!1),[N,O]=(0,D.useState)(!1),[P,Q]=(0,D.useState)(!1),[R,S]=(0,D.useState)(!1),[T,U]=(0,D.useState)(!1),[X,Y]=(0,D.useState)(!1),[Z,$]=(0,D.useState)(null),[_]=(0,D.useState)(10),[aa,ac]=(0,D.useState)(0),[ae,af]=(0,D.useState)(null),ah=async(a=Z,b=aa)=>{if(c)try{let d=await V.client.listOperations(c,{status:a||void 0,limit:_,offset:b});l(d.operations||[]),o(d.total||0)}catch(a){console.error("Error loading operations:",a)}},ai=async(a=!1)=>{if(c){if(a){try{let[a,b,d]=await Promise.all([V.client.getBankStats(c),V.client.listDirectives(c),V.client.listMentalModels(c)]);j(a),q(b.items||[]),s(d.items?.length||0)}catch(a){console.error("Error refreshing stats:",a)}return}u(!0);try{let[a,b,d,e]=await Promise.all([V.client.getBankProfile(c),V.client.getBankStats(c),V.client.listDirectives(c),V.client.listMentalModels(c)]);h(a),j(b),q(d.items||[]),s(e.items?.length||0),await ah()}catch(a){}finally{u(!1)}}},aj=async()=>{if(c){Q(!0);try{await V.client.deleteBank(c),O(!1),d(null),await e(),b.push("/")}catch(a){}finally{Q(!1)}}},ak=async()=>{if(c){U(!0);try{let a=await V.client.clearObservations(c);S(!1),await ai(),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{U(!1)}}},al=async()=>{if(c&&J){M(!0);try{await V.client.deleteDirective(c,J.id),q(a=>a.filter(a=>a.id!==J.id)),B?.id===J.id&&G(null),K(null)}catch(a){}finally{M(!1)}}};return((0,D.useEffect)(()=>{if(c){ai();let a=setInterval(()=>ai(!0),5e3);return()=>clearInterval(a)}},[c]),(0,D.useEffect)(()=>{let a=a=>{"Escape"===a.key&&G(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),c)?t&&!g?(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"text-center py-10",children:[(0,C.jsx)(ad,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,C.jsx)("div",{className:"text-lg text-muted-foreground",children:"Loading profile..."})]})}):(0,C.jsxs)("div",{className:"space-y-6",children:[!a&&(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(m0,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,C.jsx)(mZ,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)(W.Button,{onClick:()=>w(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(mR,{className:"h-4 w-4"})})]})}),(0,C.jsx)(m$,{children:g&&(0,C.jsx)("div",{className:"space-y-4",children:Object.keys(sV).map(a=>(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:sV[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sV[a].description})]}),(0,C.jsxs)("span",{className:"text-sm font-bold text-primary",children:[g.disposition[a],"/5"]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:sV[a].lowLabel}),(0,C.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,C.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(g.disposition[a]-1)/4*100}%`}})}),(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:sV[a].highLabel})]})]},a))})})]}),(0,C.jsxs)(mW,{children:[(0,C.jsx)(mX,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mY,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(sS,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,C.jsx)(mZ,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,C.jsx)(W.Button,{onClick:()=>y(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(mR,{className:"h-4 w-4"})})]})}),(0,C.jsx)(m$,{children:(0,C.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:g?.mission||"No mission set. Set a mission to derive structural mental models and personalize reflect responses."})})]})]}),(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),"Directives"]}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:"Hard rules that must be followed during reflect"})]}),(0,C.jsxs)(W.Button,{onClick:()=>A(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-1"}),"Add"]})]}),p.length>0?(0,C.jsx)("div",{className:"grid grid-cols-2 gap-3",children:p.map(a=>(0,C.jsx)(mW,{className:`cursor-pointer transition-colors border-rose-500/30 ${B?.id===a.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>G(a),children:(0,C.jsx)(m$,{className:"p-3",children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)(sT.default,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("span",{className:"font-medium text-sm text-foreground",children:a.name}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:a.content}),a.tags&&a.tags.length>0&&(0,C.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,C.jsx)(ag,{className:"w-3 h-3 text-muted-foreground"}),a.tags.map(a=>(0,C.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:a},a))]})]})]})})},a.id))}):(0,C.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,C.jsx)(sT.default,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:"No directives yet. Directives are hard rules that must be followed during reflect."})]})]}),(0,C.jsx)(ms,{open:N,onOpenChange:O,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Memory Bank"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:c}),"?"]}),(0,C.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."}),i&&(0,C.jsxs)("p",{children:["This will delete ",i.total_nodes," memories, ",i.total_documents," ","documents, and ",i.total_links," links."]})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:P,children:"Cancel"}),(0,C.jsx)(mO,{onClick:aj,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:P?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(ms,{open:R,onOpenChange:S,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Clear Observations"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:c}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."}),i&&i.total_observations>0&&(0,C.jsxs)("p",{children:["This will delete ",i.total_observations," observations."]})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:T,children:"Cancel"}),(0,C.jsx)(mO,{onClick:ak,disabled:T,className:"bg-amber-500 text-white hover:bg-amber-600",children:T?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,C.jsx)(sZ,{open:z,mode:"create",onClose:()=>A(!1),onCreated:a=>{q(b=>[a,...b]),A(!1)}}),(0,C.jsx)(ms,{open:!!J,onOpenChange:a=>!a&&K(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Directive"}),(0,C.jsxs)(mN,{children:["Are you sure you want to delete"," ",(0,C.jsxs)("span",{className:"font-semibold",children:['"',J?.name,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),(0,C.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,C.jsxs)(mL,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mP,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mO,{onClick:al,disabled:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[L?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),B&&(0,C.jsx)(s$,{directive:B,onClose:()=>G(null),onDelete:()=>K({id:B.id,name:B.name}),onUpdated:a=>{q(b=>b.map(b=>b.id===a.id?a:b)),G(a)}}),v&&g&&(0,C.jsx)(sX,{disposition:g.disposition,onClose:()=>w(!1),onSaved:async()=>{await ai(),w(!1)}}),x&&g&&(0,C.jsx)(sY,{mission:g.mission||"",onClose:()=>y(!1),onSaved:async()=>{await ai(),y(!1)}})]}):(0,C.jsx)(mW,{children:(0,C.jsxs)(m$,{className:"p-10 text-center",children:[(0,C.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:"No Bank Selected"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Please select a memory bank from the dropdown above to view its profile."})]})})}function sX({disposition:a,onClose:b,onSaved:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)(a),i=async()=>{if(d){f(!0);try{await V.client.updateBankConfig(d,{disposition_skepticism:g.skepticism,disposition_literalism:g.literalism,disposition_empathy:g.empathy}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Disposition Traits"}),(0,C.jsx)(bk.DialogDescription,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)("div",{className:"space-y-4 py-4",children:Object.keys(sV).map(a=>(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex justify-between items-center",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:sV[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sV[a].description})]}),(0,C.jsxs)("span",{className:"text-sm font-bold text-primary",children:[g[a],"/5"]})]}),(0,C.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,C.jsx)("span",{children:sV[a].lowLabel}),(0,C.jsx)("span",{children:sV[a].highLabel})]}),(0,C.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:g[a],onChange:b=>h(c=>({...c,[a]:parseInt(b.target.value)})),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]},a))}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{onClick:b,variant:"outline",disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e,children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function sY({mission:a,onClose:b,onSaved:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)(a),i=async()=>{if(d){f(!0);try{await V.client.updateBankConfig(d,{reflect_mission:g||null}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Mission"}),(0,C.jsx)(bk.DialogDescription,{children:"Affects how observations, reflect, and mental models are created"})]}),(0,C.jsx)("div",{className:"space-y-2 py-4",children:(0,C.jsx)(m4.Textarea,{value:g,onChange:a=>h(a.target.value),placeholder:"e.g., I am a PM for the engineering team. I help coordinate sprints and track project progress...",rows:8,className:"resize-none"})}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{onClick:b,variant:"outline",disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e,children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(ab,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})}function sZ({open:a,mode:b,directive:c,onClose:d,onCreated:e,onSaved:f}){let{currentBank:g}=(0,H.useBank)(),[h,i]=(0,D.useState)(!1),[j,k]=(0,D.useState)({name:"",content:"",tags:""});(0,D.useEffect)(()=>{"edit"===b&&c?k({name:c.name,content:c.content,tags:(c.tags||[]).join(", ")}):"create"===b&&k({name:"",content:"",tags:""})},[a,b,c]);let l=async()=>{if(g&&j.name.trim()&&j.content.trim()){i(!0);try{let a=j.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0);if("create"===b){let b=await V.client.createDirective(g,{name:j.name.trim(),content:j.content.trim(),tags:a.length>0?a:void 0});k({name:"",content:"",tags:""}),e?.(b)}else if(c){let b=await V.client.updateDirective(g,c.id,{name:j.name.trim(),content:j.content.trim(),tags:a});f?.(b),d()}}catch(a){}finally{i(!1)}}},n=()=>{"create"===b&&k({name:"",content:"",tags:""}),d()};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>!a&&n(),children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsxs)(bk.DialogTitle,{className:"flex items-center gap-2",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),"create"===b?"Create":"Edit"," Directive"]}),(0,C.jsx)(bk.DialogDescription,{children:"Directives are hard rules that must be followed during reflect."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:j.name,onChange:a=>k({...j,name:a.target.value}),placeholder:"e.g., Competitor Policy"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Rule *"}),(0,C.jsx)(m4.Textarea,{value:j.content,onChange:a=>k({...j,content:a.target.value}),placeholder:"e.g., Never mention competitor products directly.",className:"min-h-[120px]"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:j.tags,onChange:a=>k({...j,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:n,disabled:h,children:"Cancel"}),(0,C.jsxs)(W.Button,{onClick:l,disabled:h||!j.name.trim()||!j.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[h?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"create"===b?"Create":"Save"]})]})]})})}function s$({directive:a,onClose:b,onDelete:c,onUpdated:d}){let[e,f]=(0,D.useState)(!1);return(0,C.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,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex items-start gap-3",children:[(0,C.jsx)(sT.default,{className:"w-5 h-5 text-rose-500"}),(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>f(!0),className:"h-7 w-7 p-0",children:(0,C.jsx)(mR,{className:"h-3.5 w-3.5"})})]}),(0,C.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-rose-500/10 text-rose-600 dark:text-rose-400",children:"directive"})]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,C.jsx)(mQ,{className:"h-4 w-4"})}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,C.jsx)(ah.X,{className:"h-4 w-4"})})]})]}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Rule"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})]}),a.tags&&a.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tags.map(a=>(0,C.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:a},a))})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,C.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:a.id})]})]})]}),(0,C.jsx)(sZ,{open:e,mode:"edit",directive:a,onClose:()=>f(!1),onSaved:d})]})}let s_=(0,ar.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"}}),s0=D.forwardRef(({className:a,variant:b,...c},d)=>(0,C.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(s_({variant:b}),a),...c}));s0.displayName="Alert",D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("h5",{ref:c,className:(0,S.cn)("mb-1 font-medium leading-none tracking-tight",a),...b})).displayName="AlertTitle";let s1=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));s1.displayName="AlertDescription";var bi=bi;let s2=(0,K.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),s3=[{value:"HARM_CATEGORY_HARASSMENT",label:"Harassment"},{value:"HARM_CATEGORY_HATE_SPEECH",label:"Hate Speech"},{value:"HARM_CATEGORY_SEXUALLY_EXPLICIT",label:"Sexually Explicit"},{value:"HARM_CATEGORY_DANGEROUS_CONTENT",label:"Dangerous Content"}],s4=[{value:"HARM_BLOCK_THRESHOLD_UNSPECIFIED",label:"Unspecified (use Gemini default)"},{value:"OFF",label:"Off (filter disabled)"},{value:"BLOCK_NONE",label:"Block none"},{value:"BLOCK_LOW_AND_ABOVE",label:"Block low & above"},{value:"BLOCK_MEDIUM_AND_ABOVE",label:"Block medium & above"},{value:"BLOCK_ONLY_HIGH",label:"Block only high"}],s5=s3.map(a=>({category:a.value,threshold:"BLOCK_NONE"})),s6=[{label:"Core",tools:["retain","recall","reflect"]},{label:"Bank management",tools:["list_banks","create_bank","get_bank","get_bank_stats","update_bank","delete_bank","clear_memories"]},{label:"Mental models",tools:["list_mental_models","get_mental_model","create_mental_model","update_mental_model","delete_mental_model","refresh_mental_model"]},{label:"Directives",tools:["list_directives","create_directive","delete_directive"]},{label:"Memories",tools:["list_memories","get_memory","delete_memory"]},{label:"Documents",tools:["list_documents","get_document","delete_document"]},{label:"Operations",tools:["list_operations","get_operation","cancel_operation"]},{label:"Tags",tools:["list_tags"]}],s7=s6.flatMap(a=>a.tools);function s8(a){return Array.isArray(a)?a:a&&"object"==typeof a&&Array.isArray(a.attributes)?a.attributes:null}function s9(a){return{retain_chunk_size:a.retain_chunk_size??null,retain_extraction_mode:a.retain_extraction_mode??null,retain_mission:a.retain_mission??null,retain_custom_instructions:a.retain_custom_instructions??null,entities_allow_free_form:a.entities_allow_free_form??null,entity_labels:s8(a.entity_labels)}}function ta(a){return{retain_default_strategy:a.retain_default_strategy??null,retain_strategies:a.retain_strategies??null}}function tb(a){return{enable_observations:a.enable_observations??null,consolidation_llm_batch_size:a.consolidation_llm_batch_size??null,consolidation_source_facts_max_tokens:a.consolidation_source_facts_max_tokens??null,consolidation_source_facts_max_tokens_per_observation:a.consolidation_source_facts_max_tokens_per_observation??null,observations_mission:a.observations_mission??null}}function tc(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function td(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let te={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function tf(){let{currentBank:a}=(0,H.useBank)(),{features:b}=(0,I.useFeatures)(),c=b?.bank_config_api??!0,[d,e]=(0,D.useState)(!0),[f,g]=(0,D.useState)({}),[h,i]=(0,D.useState)(te),[j,k]=(0,D.useState)(s9({})),[l,n]=(0,D.useState)(ta({})),[o,p]=(0,D.useState)(tb({})),[q,r]=(0,D.useState)(te),[s,t]=(0,D.useState)(tc({})),[u,v]=(0,D.useState)(td({})),[w,x]=(0,D.useState)(!1),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),[E,F]=(0,D.useState)(!1),[G,J]=(0,D.useState)(!1),[K,L]=(0,D.useState)(null),[M,N]=(0,D.useState)(null),[O,P]=(0,D.useState)(null),[Q,R]=(0,D.useState)(null),[S,T]=(0,D.useState)(null),U=(0,D.useMemo)(()=>JSON.stringify(j)!==JSON.stringify(s9(f))||JSON.stringify(l)!==JSON.stringify(ta(f)),[j,l,f]),W=(0,D.useMemo)(()=>JSON.stringify(o)!==JSON.stringify(tb(f)),[o,f]),Y=(0,D.useMemo)(()=>JSON.stringify(q)!==JSON.stringify(h),[q,h]),Z=(0,D.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(tc(f)),[s,f]),$=(0,D.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(td(f)),[u,f]);(0,D.useEffect)(()=>{a&&_()},[a]);let _=async()=>{if(a){e(!0);try{let[b,c]=await Promise.all([V.client.getBankConfig(a),V.client.getBankProfile(a)]),d=b.config,e={reflect_mission:c.mission??"",disposition_skepticism:d.disposition_skepticism??c.disposition?.skepticism??3,disposition_literalism:d.disposition_literalism??c.disposition?.literalism??3,disposition_empathy:d.disposition_empathy??c.disposition?.empathy??3};g(d),i(e),k(s9(d)),n(ta(d)),p(tb(d)),r(e),t(tc(d)),v(td(d))}catch(a){console.error("Failed to load bank data:",a)}finally{e(!1)}}},aa=async()=>{if(a){x(!0),L(null);try{let b={...j,...l};await V.client.updateBankConfig(a,b),g(a=>({...a,...b}))}catch(a){L(a.message||"Failed to save retain settings")}finally{x(!1)}}},ab=async()=>{if(a){z(!0),N(null);try{await V.client.updateBankConfig(a,o),g(a=>({...a,...o}))}catch(a){N(a.message||"Failed to save observations settings")}finally{z(!1)}}},ac=async()=>{if(a){B(!0),P(null);try{await V.client.updateBankConfig(a,{reflect_mission:q.reflect_mission||null,disposition_skepticism:q.disposition_skepticism,disposition_literalism:q.disposition_literalism,disposition_empathy:q.disposition_empathy}),i(q)}catch(a){P(a.message||"Failed to save reflect settings")}finally{B(!1)}}},ad=async()=>{if(a){F(!0),R(null);try{await V.client.updateBankConfig(a,s),g(a=>({...a,...s}))}catch(a){R(a.message||"Failed to save MCP settings")}finally{F(!1)}}},ae=async()=>{if(a){J(!0),T(null);try{await V.client.updateBankConfig(a,u),g(a=>({...a,...u}))}catch(a){T(a.message||"Failed to save Gemini settings")}finally{J(!1)}}};return a?c?d?(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)(bi.default,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,C.jsx)(C.Fragment,{children:(0,C.jsxs)("div",{className:"space-y-8",children:[(0,C.jsxs)(tm,{title:"Retain",description:"Default extraction settings and named strategies. Pass a strategy name on retain requests to override defaults per-item.",error:K,dirty:U,saving:w,onSave:aa,children:[(0,C.jsx)(tn,{label:"Default strategy",description:"Applied automatically when no strategy is specified on a request.",children:(0,C.jsxs)(mU.Select,{value:l.retain_default_strategy??"__none__",onValueChange:a=>n(b=>({...b,retain_default_strategy:"__none__"===a?null:a})),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-full",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"__none__",children:(0,C.jsx)("span",{className:"text-muted-foreground italic",children:"Default"})}),Object.keys(l.retain_strategies??{}).map(a=>(0,C.jsx)(mU.SelectItem,{value:a,children:a},a))]})]})}),(0,C.jsx)(tk,{defaultValues:j,onDefaultChange:a=>k(b=>({...b,...a})),strategies:l.retain_strategies,onStrategiesChange:a=>n(b=>({...b,retain_strategies:a}))})]}),(0,C.jsxs)(tm,{title:"Observations",description:"Control how facts are synthesized into durable observations",error:M,dirty:W,saving:y,onSave:ab,children:[(0,C.jsx)(tn,{label:"Enable Observations",description:"Enable automatic consolidation of facts into observations",children:(0,C.jsx)("div",{className:"flex justify-end",children:(0,C.jsx)(be,{checked:o.enable_observations??!1,onCheckedChange:a=>p(b=>({...b,enable_observations:a}))})})}),(0,C.jsx)(to,{label:"Mission",description:"What this bank should synthesise into durable observations. Replaces the built-in consolidation rules — leave blank to use the server default.",value:o.observations_mission??"",onChange:a=>p(b=>({...b,observations_mission:a||null})),placeholder:"e.g. Observations are stable facts about people and projects. Always include preferences, skills, and recurring patterns. Ignore one-off events and ephemeral state.",rows:3}),(0,C.jsx)(tn,{label:"LLM Batch Size",description:"Number of facts sent to the LLM in a single consolidation call. Higher values reduce LLM calls at the cost of larger prompts. Leave blank to use the server default.",children:(0,C.jsx)(X.Input,{type:"number",min:1,max:64,value:o.consolidation_llm_batch_size??"",onChange:a=>p(b=>({...b,consolidation_llm_batch_size:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})}),(0,C.jsx)(tn,{label:"Source Facts Max Tokens",description:"Total token budget for source facts included with observations during consolidation. -1 = unlimited.",children:(0,C.jsx)(X.Input,{type:"number",min:-1,value:o.consolidation_source_facts_max_tokens??"",onChange:a=>p(b=>({...b,consolidation_source_facts_max_tokens:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})}),(0,C.jsx)(tn,{label:"Source Facts Max Tokens Per Observation",description:"Per-observation token cap for source facts during consolidation. Each observation gets at most this many tokens of source facts. -1 = unlimited.",children:(0,C.jsx)(X.Input,{type:"number",min:-1,value:o.consolidation_source_facts_max_tokens_per_observation??"",onChange:a=>p(b=>({...b,consolidation_source_facts_max_tokens_per_observation:a.target.value?parseInt(a.target.value,10):null})),placeholder:"Server default"})})]}),(0,C.jsxs)(tm,{title:"Reflect",description:"Shape how the bank reasons and responds in reflect operations",error:O,dirty:Y,saving:A,onSave:ac,children:[(0,C.jsx)(to,{label:"Mission",description:"Agent identity and purpose. Used as framing context in reflect.",value:q.reflect_mission,onChange:a=>r(b=>({...b,reflect_mission:a})),placeholder:"e.g. You are a senior engineering assistant. Always ground answers in documented decisions and rationale. Ignore speculation. Be direct and precise.",rows:3}),(0,C.jsx)(tp,{label:"Skepticism",description:"How skeptical vs trusting when evaluating claims",lowLabel:"Trusting",highLabel:"Skeptical",value:q.disposition_skepticism,onChange:a=>r(b=>({...b,disposition_skepticism:a}))}),(0,C.jsx)(tp,{label:"Literalism",description:"How literally to interpret information",lowLabel:"Flexible",highLabel:"Literal",value:q.disposition_literalism,onChange:a=>r(b=>({...b,disposition_literalism:a}))}),(0,C.jsx)(tp,{label:"Empathy",description:"How much to weight emotional context",lowLabel:"Detached",highLabel:"Empathetic",value:q.disposition_empathy,onChange:a=>r(b=>({...b,disposition_empathy:a}))})]}),(0,C.jsxs)(tm,{title:"MCP Tools",description:"Restrict which MCP tools this bank exposes to agents",error:Q,dirty:Z,saving:E,onSave:ad,children:[(0,C.jsx)(tn,{label:"Restrict tools",description:"When off, all tools are available. When on, only the selected tools can be invoked for this bank.",children:(0,C.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,C.jsx)(be,{checked:null!==s.mcp_enabled_tools,onCheckedChange:a=>t({mcp_enabled_tools:a?[...s7]:null})}),(0,C.jsx)(at,{className:"text-xs text-muted-foreground",children:null!==s.mcp_enabled_tools?"Enabled":"Disabled"})]})}),null!==s.mcp_enabled_tools&&(0,C.jsx)(tl,{selected:s.mcp_enabled_tools,onChange:a=>t({mcp_enabled_tools:a})})]}),(0,C.jsx)(tm,{title:"Models",description:"Provider-specific model settings",error:S,dirty:$,saving:G,onSave:ae,children:(0,C.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,C.jsx)("p",{className:"text-sm font-semibold",children:"Gemini / Vertex AI"}),(0,C.jsxs)("div",{className:"pl-4 border-l-2 border-border/40 space-y-4",children:[(0,C.jsx)(tn,{label:"Safety settings",description:(0,C.jsxs)(C.Fragment,{children:["When off, Gemini's default safety thresholds are used. When on, configure thresholds per harm category."," ",(0,C.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:"Learn more"})]}),children:(0,C.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,C.jsx)(be,{checked:null!==u.llm_gemini_safety_settings,onCheckedChange:a=>v({llm_gemini_safety_settings:a?[...s5]:null})}),(0,C.jsx)(at,{className:"text-xs text-muted-foreground",children:null!==u.llm_gemini_safety_settings?"Custom":"Default"})]})}),null!==u.llm_gemini_safety_settings&&(0,C.jsx)(tr,{value:u.llm_gemini_safety_settings,onChange:a=>v({llm_gemini_safety_settings:a})})]})]})})]})}):(0,C.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 text-center",children:[(0,C.jsx)("p",{className:"text-base font-medium text-foreground",children:"Bank configuration is disabled"}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground max-w-sm",children:["Set"," ",(0,C.jsx)("code",{className:"font-mono text-xs bg-muted px-1 py-0.5 rounded",children:"HINDSIGHT_API_ENABLE_BANK_CONFIG_API=true"})," ","to enable per-bank configuration."]})]}):(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)("p",{className:"text-muted-foreground",children:"No bank selected"})})}let tg=["concise","verbose","verbatim","chunks","custom"],th="__inherit__";function ti({values:a,onChange:b,isOverride:c=!1}){let d=a.retain_extraction_mode??(c?th:""),e="custom"===a.retain_extraction_mode;return(0,C.jsxs)("div",{className:"divide-y divide-border/40",children:[(0,C.jsx)(tn,{label:"Extraction Mode",description:"How aggressively to extract facts. concise = selective, verbose = capture everything, verbatim = store chunks as-is (still extract entities/time), chunks = no LLM, custom = write your own rules.",children:(0,C.jsxs)(mU.Select,{value:d,onValueChange:a=>b({retain_extraction_mode:a===th?null:a||null}),children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-full",children:(0,C.jsx)(mU.SelectValue,{placeholder:c?"Inherited from default":void 0})}),(0,C.jsxs)(mU.SelectContent,{children:[c&&(0,C.jsx)(mU.SelectItem,{value:th,children:(0,C.jsx)("span",{className:"text-muted-foreground italic",children:"inherited"})}),tg.map(a=>(0,C.jsx)(mU.SelectItem,{value:a,children:a},a))]})]})}),(0,C.jsx)(tn,{label:"Chunk Size",description:"Size of text chunks for processing (characters)",children:(0,C.jsx)(X.Input,{type:"number",min:500,max:8e3,value:a.retain_chunk_size??"",onChange:a=>b({retain_chunk_size:a.target.value?parseFloat(a.target.value):null}),placeholder:c?"Inherited from default":void 0})}),(0,C.jsx)(to,{label:"Mission",description:"What this bank should pay attention to during extraction. Steers the LLM without replacing the extraction rules.",value:a.retain_mission??"",onChange:a=>b({retain_mission:a||null}),placeholder:c?"Inherited from default":"e.g. Always include technical decisions, API design choices, and architectural trade-offs.",rows:3}),e&&(0,C.jsx)(to,{label:"Custom Extraction Prompt",description:"Replaces the built-in extraction rules entirely. Only active when Extraction Mode is set to custom.",value:a.retain_custom_instructions??"",onChange:a=>b({retain_custom_instructions:a||null}),rows:5}),(0,C.jsx)(tn,{label:"Free Form Entities",description:"Extract regular named entities (people, places, concepts) alongside entity labels. Disable to restrict extraction to entity labels only.",children:(0,C.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,C.jsx)(at,{className:"text-sm text-muted-foreground cursor-pointer select-none",children:a.entities_allow_free_form??!0?"Enabled":"Disabled"}),(0,C.jsx)(be,{checked:a.entities_allow_free_form??!0,onCheckedChange:a=>b({entities_allow_free_form:a})})]})}),(0,C.jsx)(tq,{value:a.entity_labels??[],onChange:a=>b({entity_labels:a.length>0?a:null})})]})}function tj(a){return a?Object.entries(a).map(([a,b],c)=>({id:c,name:a,values:{retain_extraction_mode:b.retain_extraction_mode??null,retain_chunk_size:b.retain_chunk_size??null,retain_mission:b.retain_mission??null,retain_custom_instructions:b.retain_custom_instructions??null,entities_allow_free_form:b.entities_allow_free_form??null,entity_labels:s8(b.entity_labels)}})):[]}function tk({defaultValues:a,onDefaultChange:b,strategies:c,onStrategiesChange:d}){let[e,f]=(0,D.useState)(()=>tj(c)),[g,h]=(0,D.useState)("default"),[i,j]=(0,D.useState)(null),k=(0,D.useRef)(!1),l=JSON.stringify(c);(0,D.useEffect)(()=>{if(k.current){k.current=!1;return}f(tj(c))},[l]);let n=a=>{k.current=!0,f(a),d(function(a){let b={};for(let c of a){if(!c.name.trim())continue;let a={};null!==c.values.retain_extraction_mode&&(a.retain_extraction_mode=c.values.retain_extraction_mode),null!==c.values.retain_chunk_size&&(a.retain_chunk_size=c.values.retain_chunk_size),c.values.retain_mission&&(a.retain_mission=c.values.retain_mission),c.values.retain_custom_instructions&&(a.retain_custom_instructions=c.values.retain_custom_instructions),null!==c.values.entities_allow_free_form&&(a.entities_allow_free_form=c.values.entities_allow_free_form),null!==c.values.entity_labels&&(a.entity_labels=c.values.entity_labels),b[c.name.trim()]=a}return Object.keys(b).length>0?b:null}(a))},o=(a,b)=>{n(e.map(c=>c.id===a?{...c,...b}:c))},p="default"!==g?e.find(a=>a.id===g):null;return(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"border-b border-border px-6 flex items-stretch gap-1 flex-wrap",children:[(0,C.jsx)("button",{type:"button",onClick:()=>h("default"),className:`relative py-3 px-4 text-sm font-semibold transition-colors border-b-2 -mb-px ${"default"===g?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,children:"Default"}),e.map(a=>(0,C.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 ${g===a.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>h(a.id),children:[(0,C.jsx)("span",{className:"font-mono",children:a.name||(0,C.jsx)("span",{className:"italic font-normal opacity-50",children:"unnamed"})}),(0,C.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),j(a)},className:"opacity-40 hover:opacity-100 hover:text-destructive transition-opacity text-base leading-none",children:"×"})]},a.id)),(0,C.jsxs)("button",{type:"button",onClick:()=>{let a=Date.now();n([...e,{id:a,name:"",values:{retain_extraction_mode:null,retain_chunk_size:null,retain_mission:null,retain_custom_instructions:null,entities_allow_free_form:null,entity_labels:null}}]),h(a)},className:"py-3 px-3 text-sm text-muted-foreground hover:text-primary transition-colors flex items-center gap-1.5",children:[(0,C.jsx)(sU.Plus,{className:"h-3.5 w-3.5"}),"Add strategy"]})]}),(0,C.jsx)("div",{children:"default"===g?(0,C.jsx)(ti,{values:a,onChange:b}):p?(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"px-6 py-3 flex items-center gap-3 border-b border-border/40",children:[(0,C.jsx)("label",{className:"text-xs text-muted-foreground shrink-0",children:"Name"}),(0,C.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,C.jsx)(X.Input,{value:p.name,onChange:a=>o(p.id,{name:a.target.value}),placeholder:"strategy name (e.g. fast)",className:`h-7 text-xs font-mono max-w-[200px] ${!p.name.trim()?"border-destructive focus-visible:ring-destructive":""}`}),!p.name.trim()&&(0,C.jsx)("p",{className:"text-xs text-destructive",children:"Name is required"})]})]}),(0,C.jsx)(ti,{values:p.values,onChange:a=>o(p.id,{values:{...p.values,...a}}),isOverride:!0})]}):null}),(0,C.jsx)(ms,{open:null!==i,onOpenChange:a=>{a||j(null)},children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsxs)(mM,{children:["Delete strategy “",i?.name||"unnamed","”?"]}),(0,C.jsx)(mN,{children:"This will remove the strategy and all its overrides. This cannot be undone."})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{children:"Cancel"}),(0,C.jsx)(mO,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(i){var a;a=i.id,n(e.filter(b=>b.id!==a)),g===a&&h("default"),j(null)}},children:"Delete"})]})]})})]})}function tl({selected:a,onChange:b}){let c=new Set(a),d=s7.every(a=>c.has(a)),e=0===a.length;return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("p",{className:"text-xs text-muted-foreground",children:[a.length," of ",s7.length," tools enabled"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(d?[]:[...s7])},className:"text-xs text-primary hover:underline",children:d?"Deselect all":"Select all"})]}),(0,C.jsx)("div",{className:"space-y-4",children:s6.map(a=>{let d=a.tools.filter(a=>c.has(a)).length===a.tools.length;return(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,C.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:a.label}),(0,C.jsx)("button",{type:"button",onClick:()=>{let e=new Set(c);d?a.tools.forEach(a=>e.delete(a)):a.tools.forEach(a=>e.add(a)),b(s7.filter(a=>e.has(a)))},className:"text-xs text-primary hover:underline",children:d?"Deselect":"Select all"})]}),(0,C.jsx)("div",{className:"flex flex-wrap gap-2",children:a.tools.map(a=>{let d=c.has(a);return(0,C.jsx)("button",{type:"button",onClick:()=>{let d;(d=new Set(c)).has(a)?d.delete(a):d.add(a),b(s7.filter(a=>d.has(a)))},className:`px-2.5 py-1 rounded text-xs font-mono transition-colors border ${d?"bg-primary text-primary-foreground border-primary":"bg-muted/30 text-muted-foreground border-border/40 hover:border-primary/40"}`,children:a},a)})})]},a.label)})}),e&&(0,C.jsx)("p",{className:"text-xs text-destructive",children:"Warning: no tools selected — agents will be blocked from all MCP calls for this bank."})]})}function tm({title:a,description:b,children:c,error:d,dirty:e,saving:f,onSave:g}){return(0,C.jsxs)("section",{className:"space-y-3",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h2",{className:"text-lg font-semibold",children:a}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:b})]}),(0,C.jsxs)(mW,{className:"bg-muted/20 border-border/40",children:[(0,C.jsx)("div",{className:"divide-y divide-border/40",children:c}),d&&(0,C.jsx)("div",{className:"px-6 pb-2 pt-2",children:(0,C.jsxs)(s0,{variant:"destructive",children:[(0,C.jsx)(s2,{className:"h-4 w-4"}),(0,C.jsx)(s1,{children:d})]})}),(0,C.jsx)("div",{className:"px-6 py-4 flex justify-end border-t border-border/40",children:(0,C.jsx)(W.Button,{size:"sm",disabled:!e||f,onClick:g,children:f?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save changes"})})]})]})}function tn({label:a,description:b,children:c}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,C.jsxs)("div",{className:"flex-1",children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsx)("div",{className:"md:w-64 shrink-0",children:c})]})})}function to({label:a,description:b,value:c,onChange:d,placeholder:e,rows:f}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsx)(m4.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function tp({label:a,description:b,lowLabel:c,highLabel:d,value:e,onChange:f}){return(0,C.jsx)("div",{className:"px-6 py-4",children:(0,C.jsxs)("div",{className:"space-y-3",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:a}),b&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b})]}),(0,C.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,C.jsx)("span",{className:"text-xs text-muted-foreground w-16 text-right shrink-0",children:c}),(0,C.jsx)("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>(0,C.jsx)("button",{type:"button",onClick:()=>f(a),className:`w-4 h-4 rounded-full transition-colors hover:opacity-80 ${a<=e?"bg-primary":"bg-muted"}`},a))}),d&&(0,C.jsx)("span",{className:"text-xs text-muted-foreground w-20 shrink-0",children:d}),(0,C.jsxs)("span",{className:"text-xs font-mono text-muted-foreground ml-1 shrink-0",children:[e,"/5"]})]})]})})}function tq({value:a,onChange:b}){let[c,d]=(0,D.useState)({}),e=(c,d)=>{b(a.map((a,b)=>b===c?{...a,...d}:a))},f=(b,c,d)=>{let f=a[b].values.map((a,b)=>b===c?{...a,...d}:a);e(b,{values:f})};return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm font-medium",children:"Entity Labels"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Classification labels extracted at retain time. Leave empty to disable."})]}),a.length>0&&(0,C.jsxs)("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full shrink-0",children:[a.length," group",1!==a.length?"s":""]})]}),0===a.length&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No entity labels defined."}),(0,C.jsx)("div",{className:"space-y-2",children:a.map((g,h)=>{let i=c[h]??!1,j="text"===g.type,k=!j;return(0,C.jsxs)("div",{className:"border border-border/50 rounded-md bg-background",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,C.jsx)("button",{type:"button",onClick:()=>d(a=>({...a,[h]:!i})),className:"text-muted-foreground hover:text-foreground shrink-0",disabled:j,children:i&&k?(0,C.jsx)(sP.ChevronDown,{className:"h-4 w-4"}):(0,C.jsx)(Q.ChevronRight,{className:`h-4 w-4 ${j?"opacity-30":""}`})}),(0,C.jsx)(X.Input,{placeholder:"key (e.g. pedagogy)",value:g.key,onChange:a=>e(h,{key:a.target.value}),className:"h-8 text-xs font-mono w-36 shrink-0"}),(0,C.jsx)(X.Input,{placeholder:j?"description / examples":"description",value:g.description,onChange:a=>e(h,{description:a.target.value}),className:"h-8 text-xs flex-1 min-w-0"}),(0,C.jsxs)(mU.Select,{value:g.type,onValueChange:a=>e(h,{type:a,..."text"===a?{values:[]}:{}}),children:[(0,C.jsx)(mU.SelectTrigger,{className:"h-8 text-xs w-32 shrink-0",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"value",className:"text-xs",children:"Single value"}),(0,C.jsx)(mU.SelectItem,{value:"multi-values",className:"text-xs",children:"Multi-values"}),(0,C.jsx)(mU.SelectItem,{value:"text",className:"text-xs",children:"Free text"})]})]}),(0,C.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-pointer select-none",children:[(0,C.jsx)(mV.Checkbox,{checked:g.tag,onCheckedChange:a=>e(h,{tag:!!a}),className:"h-4 w-4"}),"tag"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(a.filter((a,b)=>b!==h)),d(a=>{let b={...a};return delete b[h],b})},className:"text-muted-foreground hover:text-destructive shrink-0",children:(0,C.jsx)(mQ,{className:"h-3.5 w-3.5"})})]}),i&&k&&(0,C.jsxs)("div",{className:"px-3 pb-3 space-y-1 border-t border-border/30 pt-2",children:[0===g.values.length&&(0,C.jsx)("p",{className:"text-xs text-muted-foreground italic pl-5",children:"No values yet."}),g.values.map((b,c)=>(0,C.jsxs)("div",{className:"flex items-center gap-2 pl-5",children:[(0,C.jsx)(X.Input,{placeholder:"value",value:b.value,onChange:a=>f(h,c,{value:a.target.value}),className:"h-8 text-xs font-mono w-32 shrink-0"}),(0,C.jsx)(X.Input,{placeholder:"description",value:b.description,onChange:a=>f(h,c,{description:a.target.value}),className:"h-8 text-xs flex-1 min-w-0"}),(0,C.jsx)("button",{type:"button",onClick:()=>{e(h,{values:a[h].values.filter((a,b)=>b!==c)})},className:"text-muted-foreground hover:text-destructive shrink-0",children:(0,C.jsx)(mQ,{className:"h-3.5 w-3.5"})})]},c)),(0,C.jsxs)("button",{type:"button",onClick:()=>{e(h,{values:[...a[h].values,{value:"",description:""}]})},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground pl-5 mt-1",children:[(0,C.jsx)(sU.Plus,{className:"h-3 w-3"}),"Add value"]})]})]},h)})}),(0,C.jsxs)("button",{type:"button",onClick:()=>{let c=[...a,{key:"",description:"",type:"value",optional:!0,tag:!1,values:[]}];b(c),d(a=>({...a,[c.length-1]:!0}))},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,C.jsx)(sU.Plus,{className:"h-3.5 w-3.5"}),"Add attribute"]})]})}function tr({value:a,onChange:b}){let c=b=>a.find(a=>a.category===b)?.threshold??"BLOCK_MEDIUM_AND_ABOVE";return(0,C.jsxs)("div",{className:"px-6 py-4 space-y-3",children:[(0,C.jsxs)("p",{className:"text-xs text-muted-foreground",children:['Set the blocking threshold for each harm category. "Off" disables the filter entirely (default for Gemini 2.5+). Lower thresholds block more content.'," ",(0,C.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:"Learn more"})]}),(0,C.jsx)("div",{className:"space-y-2",children:s3.map(a=>(0,C.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,C.jsx)("span",{className:"text-sm",children:a.label}),(0,C.jsxs)(mU.Select,{value:c(a.value),onValueChange:d=>{var e;return e=a.value,void b(s3.map(a=>({category:a.value,threshold:a.value===e?d:c(a.value)})))},children:[(0,C.jsx)(mU.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsx)(mU.SelectContent,{children:s4.map(a=>(0,C.jsx)(mU.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}let ts=(0,K.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),tt=(0,K.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),tu=(0,K.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);function tv(){let{currentBank:a}=(0,H.useBank)(),{features:b}=(0,I.useFeatures)(),c=b?.observations??!1,[d,e]=(0,D.useState)(null),[f,g]=(0,D.useState)(0),[h,i]=(0,D.useState)(0),[j,k]=(0,D.useState)(!1),l=async()=>{if(a){k(!0);try{let[b,c,d]=await Promise.all([V.client.getBankStats(a),V.client.listMentalModels(a),V.client.listDirectives(a)]);e(b),g(c.items?.length||0),i(d.items?.length||0)}catch(a){console.error("Error loading bank stats:",a)}finally{k(!1)}}};return((0,D.useEffect)(()=>{if(a){l();let a=setInterval(l,5e3);return()=>clearInterval(a)}},[a]),j&&!d)?(0,C.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,C.jsx)(ad,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"})}):d?(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,C.jsx)(mW,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/20",children:(0,C.jsx)(M,{className:"w-5 h-5 text-blue-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Memories"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_nodes})]})]})})}),(0,C.jsx)(mW,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/20",children:(0,C.jsx)(ts,{className:"w-5 h-5 text-purple-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Links"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_links})]})]})})}),(0,C.jsx)(mW,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/20",children:(0,C.jsx)(tt,{className:"w-5 h-5 text-emerald-500"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Documents"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.total_documents})]})]})})}),(0,C.jsx)(mW,{className:`bg-gradient-to-br ${d.pending_operations>0?"from-amber-500/10 to-amber-600/5 border-amber-500/20":"from-slate-500/10 to-slate-600/5 border-slate-500/20"}`,children:(0,C.jsx)(m$,{className:"p-4",children:(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("div",{className:`p-2 rounded-lg ${d.pending_operations>0?"bg-amber-500/20":"bg-slate-500/20"}`,children:(0,C.jsx)(tu,{className:`w-5 h-5 ${d.pending_operations>0?"text-amber-500 animate-pulse":"text-slate-500"}`})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Pending"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-foreground",children:d.pending_operations})]})]})})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,C.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-semibold uppercase tracking-wide",children:"World Facts"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:d.nodes_by_fact_type?.world||0})]}),(0,C.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-semibold uppercase tracking-wide",children:"Experience"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-purple-600 dark:text-purple-400 mt-1",children:d.nodes_by_fact_type?.experience||0})]}),(0,C.jsxs)("div",{className:`rounded-xl p-4 text-center ${c?"bg-amber-500/10 border border-amber-500/20":"bg-muted/50 border border-muted"}`,title:c?void 0:"Observations feature is not enabled",children:[(0,C.jsxs)("p",{className:`text-xs font-semibold uppercase tracking-wide ${c?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:["Observations",!c&&(0,C.jsx)("span",{className:"ml-1 normal-case",children:"(Off)"})]}),(0,C.jsx)("p",{className:`text-2xl font-bold mt-1 ${c?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:c?d.total_observations||0:"—"})]}),(0,C.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-semibold uppercase tracking-wide",children:"Mental Models"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-cyan-600 dark:text-cyan-400 mt-1",children:f})]}),(0,C.jsxs)("div",{className:"bg-rose-500/10 border border-rose-500/20 rounded-xl p-4 text-center",children:[(0,C.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-semibold uppercase tracking-wide",children:"Directives"}),(0,C.jsx)("p",{className:"text-2xl font-bold text-rose-600 dark:text-rose-400 mt-1",children:h})]})]})]}):null}var bi=bi;let tw=(0,K.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"}]]),tx=[{value:"all",label:"All types"},{value:"retain",label:"Retain"},{value:"consolidation",label:"Consolidation"},{value:"refresh_mental_model",label:"Mental Model Refresh"},{value:"file_convert_retain",label:"File Convert & Retain"},{value:"webhook_delivery",label:"Webhook Delivery"}];function ty(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(0),[f,g]=(0,D.useState)(null),[h,i]=(0,D.useState)(null),[j]=(0,D.useState)(10),[k,l]=(0,D.useState)(0),[n,o]=(0,D.useState)(null),[p,q]=(0,D.useState)(null),[r,s]=(0,D.useState)(!1),[t,u]=(0,D.useState)(null),[v,w]=(0,D.useState)(!1),[x,y]=(0,D.useState)(!1),z=(0,D.useCallback)(async(b=f,d=k,g=h)=>{if(a){s(!0);try{let f=await V.client.listOperations(a,{status:b||void 0,type:g||void 0,limit:j,offset:d});c(f.operations||[]),e(f.total||0)}catch(a){console.error("Error loading operations:",a)}finally{s(!1)}}},[a,f,k,h,j]),A=a=>{l(a),z(f,a,h)},B=async b=>{if(a){o(b);try{await V.client.cancelOperation(a,b),await z()}catch(a){}finally{o(null)}}},E=async b=>{if(a){q(b);try{await V.client.retryOperation(a,b),await z()}catch(a){}finally{q(null)}}},F=async b=>{if(a){y(!0),w(!0);try{let c=await V.client.getOperationStatus(a,b);u(c)}catch(a){console.error("Error loading operation details:",a),u({error:"Failed to load operation details"})}finally{y(!1)}}};return((0,D.useEffect)(()=>{if(a){z(f,k,h);let a=setInterval(()=>z(f,k,h),5e3);return()=>clearInterval(a)}},[a,f,k,h]),a)?(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-lg font-semibold",children:"Background Operations"}),(0,C.jsx)("button",{onClick:()=>z(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",disabled:r,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${r?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d," operation",1!==d?"s":"",f?` (${f})`:""]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsxs)(mU.Select,{value:h??"all",onValueChange:a=>{var b;i(b="all"===a?null:a),l(0),z(f,0,b)},children:[(0,C.jsx)(mU.SelectTrigger,{className:"h-9 w-[180px] text-sm",children:(0,C.jsx)(mU.SelectValue,{placeholder:"All types"})}),(0,C.jsx)(mU.SelectContent,{children:tx.map(a=>(0,C.jsx)(mU.SelectItem,{value:a.value,children:(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{children:a.label}),"all"!==a.value&&(0,C.jsx)("div",{className:"text-xs text-muted-foreground font-mono",children:a.value})]})},a.value))})]}),(0,C.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:[{value:null,label:"All"},{value:"pending",label:"Pending"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map(a=>(0,C.jsx)("button",{onClick:()=>{var b;g(b=a.value),l(0),z(b,0,h)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${f===a.value?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a.label},a.value??"all"))})]})]}),(0,C.jsx)("div",{children:b.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-[100px]",children:"ID"}),(0,C.jsx)(am,{children:"Type"}),(0,C.jsx)(am,{children:"Created"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{className:"w-[80px]"})]})}),(0,C.jsx)(ak,{children:b.map(a=>(0,C.jsxs)(al,{className:`cursor-pointer hover:bg-muted/50 ${"failed"===a.status?"bg-red-500/5":""}`,onClick:()=>F(a.id),children:[(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.id.substring(0,8)}),(0,C.jsx)(an,{className:"font-medium",children:a.task_type}),(0,C.jsx)(an,{className:"text-sm text-muted-foreground",children:new Date(a.created_at).toLocaleString()}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===a.status&&(0,C.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:a.error_message??void 0,children:[(0,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===a.status&&(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:b=>{b.stopPropagation(),B(a.id)},disabled:n===a.id,children:[n===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(ah.X,{className:"w-3 h-3 mr-1"}),n===a.id?"":"Cancel"]}),"failed"===a.status&&(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400",onClick:b=>{b.stopPropagation(),E(a.id)},disabled:p===a.id,children:[p===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(tw,{className:"w-3 h-3 mr-1"}),p===a.id?"":"Retry"]})]})]},a.id))})]})}),d>j&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",k+1,"-",Math.min(k+j,d)," of"," ",d]}),(0,C.jsxs)("div",{className:"flex gap-2",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(Math.max(0,k-j)),disabled:0===k,children:"Previous"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>A(k+j),disabled:k+j>=d,children:"Next"})]})]})]}):(0,C.jsxs)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:["No ",f?`${f} `:"","operations"]})}),(0,C.jsx)(bk.Dialog,{open:v,onOpenChange:w,children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Operation Details"}),(0,C.jsx)(bk.DialogDescription,{children:t?.operation_id&&(0,C.jsx)("span",{className:"font-mono text-xs",children:t.operation_id})})]}),x?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)(bi.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t?(0,C.jsx)("div",{className:"space-y-4",children:t.error?(0,C.jsx)("div",{className:"text-red-600 dark:text-red-400",children:t.error}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),(0,C.jsxs)("div",{className:"mt-1",children:["pending"===t.status&&(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===t.status&&(0,C.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,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===t.status&&(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Type"}),(0,C.jsx)("div",{className:"mt-1 font-mono text-sm",children:t.operation_type})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Created"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.created_at?new Date(t.created_at).toLocaleString():"N/A"})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Updated"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.updated_at?new Date(t.updated_at).toLocaleString():"N/A"})]}),t.completed_at&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Completed"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:new Date(t.completed_at).toLocaleString()})]}),t.result_metadata?.items_count!==void 0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-sm font-medium text-muted-foreground",children:"Total Items"}),(0,C.jsx)("div",{className:"mt-1 text-sm",children:t.result_metadata.items_count})]})]}),t.error_message&&(0,C.jsxs)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:[(0,C.jsx)("div",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-1",children:"Error"}),(0,C.jsx)("div",{className:"text-sm text-red-600/80 dark:text-red-400/80 font-mono",children:t.error_message})]}),t.child_operations&&t.child_operations.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Sub-batches (",t.result_metadata?.num_sub_batches||t.child_operations.length,")"]}),(0,C.jsx)("div",{className:"rounded-lg border",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-[60px]",children:"Index"}),(0,C.jsx)(am,{className:"w-[100px]",children:"ID"}),(0,C.jsx)(am,{className:"w-[80px]",children:"Items"}),(0,C.jsx)(am,{children:"Status"})]})}),(0,C.jsx)(ak,{children:t.child_operations.map(a=>(0,C.jsxs)(al,{children:[(0,C.jsx)(an,{className:"text-sm",children:a.sub_batch_index}),(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.operation_id.substring(0,8)}),(0,C.jsx)(an,{className:"text-sm",children:a.items_count}),(0,C.jsxs)(an,{children:["pending"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:[(0,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}),"failed"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400",title:a.error_message??void 0,children:[(0,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}),"completed"===a.status&&(0,C.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:[(0,C.jsx)(ac,{className:"w-3 h-3"}),"completed"]})]})]},a.operation_id))})]})})]})]})}):null]})})]}):null}var bi=bi;let tz=(0,K.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),tA=(0,K.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);var tB=a.i(96743),tC=a.i(86228),tD=a.i(22297),tE=a.i(92843),tF=a.i(4691),tG=a.i(92616),tH=a.i(77192),tI=a.i(24050),tJ=Symbol("radix.slottable");function tK(a){return D.isValidElement(a)&&"function"==typeof a.type&&"__radixId"in a.type&&a.type.__radixId===tJ}var tL=a.i(46872),tM=a.i(41852),tN=a.i(52081),tO=["Enter"," "],tP=["ArrowUp","PageDown","End"],tQ=["ArrowDown","PageUp","Home",...tP],tR={ltr:[...tO,"ArrowRight"],rtl:[...tO,"ArrowLeft"]},tS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tT="Menu",[tU,tV,tW]=(0,aD.createCollection)(tT),[tX,tY]=(0,ax.createContextScope)(tT,[tW,tF.createPopperScope,tI.createRovingFocusGroupScope]),tZ=(0,tF.createPopperScope)(),t$=(0,tI.createRovingFocusGroupScope)(),[t_,t0]=tX(tT),[t1,t2]=tX(tT),t3=a=>{let{__scopeMenu:b,open:c=!1,children:d,dir:e,onOpenChange:f,modal:g=!0}=a,h=tZ(b),[i,j]=D.useState(null),k=D.useRef(!1),l=(0,tL.useCallbackRef)(f),n=(0,az.useDirection)(e);return D.useEffect(()=>{let a=()=>{k.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>k.current=!1;return document.addEventListener("keydown",a,{capture:!0}),()=>{document.removeEventListener("keydown",a,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),(0,C.jsx)(tF.Root,{...h,children:(0,C.jsx)(t_,{scope:b,open:c,onOpenChange:l,content:i,onContentChange:j,children:(0,C.jsx)(t1,{scope:b,onClose:D.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:k,dir:n,modal:g,children:d})})})};t3.displayName=tT;var t4=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tZ(c);return(0,C.jsx)(tF.Anchor,{...e,...d,ref:b})});t4.displayName="MenuAnchor";var t5="MenuPortal",[t6,t7]=tX(t5,{forceMount:void 0}),t8=a=>{let{__scopeMenu:b,forceMount:c,children:d,container:e}=a,f=t0(t5,b);return(0,C.jsx)(t6,{scope:b,forceMount:c,children:(0,C.jsx)(tH.Presence,{present:c||f.open,children:(0,C.jsx)(tG.Portal,{asChild:!0,container:e,children:d})})})};t8.displayName=t5;var t9="MenuContent",[ua,ub]=tX(t9),uc=D.forwardRef((a,b)=>{let c=t7(t9,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=t0(t9,a.__scopeMenu),g=t2(t9,a.__scopeMenu);return(0,C.jsx)(tU.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tH.Presence,{present:d||f.open,children:(0,C.jsx)(tU.Slot,{scope:a.__scopeMenu,children:g.modal?(0,C.jsx)(ud,{...e,ref:b}):(0,C.jsx)(ue,{...e,ref:b})})})})}),ud=D.forwardRef((a,b)=>{let c=t0(t9,a.__scopeMenu),d=D.useRef(null),e=(0,aw.useComposedRefs)(b,d);return D.useEffect(()=>{let a=d.current;if(a)return(0,tM.hideOthers)(a)},[]),(0,C.jsx)(ug,{...a,ref:e,trapFocus:c.open,disableOutsidePointerEvents:c.open,disableOutsideScroll:!0,onFocusOutside:(0,av.composeEventHandlers)(a.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>c.onOpenChange(!1)})}),ue=D.forwardRef((a,b)=>{let c=t0(t9,a.__scopeMenu);return(0,C.jsx)(ug,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>c.onOpenChange(!1)})}),uf=((e=D.forwardRef((a,b)=>{let{children:c,...d}=a;if(D.isValidElement(c)){var e;let a,f,g=(e=c,(f=(a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get)&&"isReactWarning"in a&&a.isReactWarning)?e.ref:(f=(a=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in a&&a.isReactWarning)?e.props.ref:e.props.ref||e.ref),h=function(a,b){let c={...b};for(let d in b){let e=a[d],f=b[d];/^on[A-Z]/.test(d)?e&&f?c[d]=(...a)=>{let b=f(...a);return e(...a),b}:e&&(c[d]=e):"style"===d?c[d]={...e,...f}:"className"===d&&(c[d]=[e,f].filter(Boolean).join(" "))}return{...a,...c}}(d,c.props);return c.type!==D.Fragment&&(h.ref=b?(0,aw.composeRefs)(b,g):g),D.cloneElement(c,h)}return D.Children.count(c)>1?D.Children.only(null):null})).displayName="MenuContent.ScrollLock.SlotClone",c=e,(d=D.forwardRef((a,b)=>{let{children:d,...e}=a,f=D.Children.toArray(d),g=f.find(tK);if(g){let a=g.props.children,d=f.map(b=>b!==g?b:D.Children.count(a)>1?D.Children.only(null):D.isValidElement(a)?a.props.children:null);return(0,C.jsx)(c,{...e,ref:b,children:D.isValidElement(a)?D.cloneElement(a,void 0,d):null})}return(0,C.jsx)(c,{...e,ref:b,children:d})})).displayName="MenuContent.ScrollLock.Slot",d),ug=D.forwardRef((a,b)=>{let{__scopeMenu:c,loop:d=!1,trapFocus:e,onOpenAutoFocus:f,onCloseAutoFocus:g,disableOutsidePointerEvents:h,onEntryFocus:i,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,disableOutsideScroll:p,...q}=a,r=t0(t9,c),s=t2(t9,c),t=tZ(c),u=t$(c),v=tV(c),[w,x]=D.useState(null),y=D.useRef(null),z=(0,aw.useComposedRefs)(b,y,r.onContentChange),A=D.useRef(0),B=D.useRef(""),E=D.useRef(0),F=D.useRef(null),G=D.useRef("right"),H=D.useRef(0),I=p?tN.RemoveScroll:D.Fragment;D.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,tC.useFocusGuards)();let J=D.useCallback(a=>{var b,c;return G.current===F.current?.side&&(b=a,!!(c=F.current?.area)&&function(a,b){let{x:c,y:d}=a,e=!1;for(let a=0,f=b.length-1;a<b.length;f=a++){let g=b[a],h=b[f],i=g.x,j=g.y,k=h.x,l=h.y;j>d!=l>d&&c<(k-i)*(d-j)/(l-j)+i&&(e=!e)}return e}({x:b.clientX,y:b.clientY},c))},[]);return(0,C.jsx)(ua,{scope:c,searchRef:B,onItemEnter:D.useCallback(a=>{J(a)&&a.preventDefault()},[J]),onItemLeave:D.useCallback(a=>{J(a)||(y.current?.focus(),x(null))},[J]),onTriggerLeave:D.useCallback(a=>{J(a)&&a.preventDefault()},[J]),pointerGraceTimerRef:E,onPointerGraceIntentChange:D.useCallback(a=>{F.current=a},[]),children:(0,C.jsx)(I,{...p?{as:uf,allowPinchZoom:!0}:void 0,children:(0,C.jsx)(tD.FocusScope,{asChild:!0,trapped:e,onMountAutoFocus:(0,av.composeEventHandlers)(f,a=>{a.preventDefault(),y.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:g,children:(0,C.jsx)(tB.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,children:(0,C.jsx)(tI.Root,{asChild:!0,...u,dir:s.dir,orientation:"vertical",loop:d,currentTabStopId:w,onCurrentTabStopIdChange:x,onEntryFocus:(0,av.composeEventHandlers)(i,a=>{s.isUsingKeyboardRef.current||a.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,C.jsx)(tF.Content,{role:"menu","aria-orientation":"vertical","data-state":uG(r.open),"data-radix-menu-content":"",dir:s.dir,...t,...q,ref:z,style:{outline:"none",...q.style},onKeyDown:(0,av.composeEventHandlers)(q.onKeyDown,a=>{let b=a.target.closest("[data-radix-menu-content]")===a.currentTarget,c=a.ctrlKey||a.altKey||a.metaKey,d=1===a.key.length;if(b){var e;let b,f,g,h,i,j;"Tab"===a.key&&a.preventDefault(),!c&&d&&(e=a.key,b=B.current+e,f=v().filter(a=>!a.disabled),g=document.activeElement,h=f.find(a=>a.ref.current===g)?.textValue,i=function(a,b,c){var d;let e=b.length>1&&Array.from(b).every(a=>a===b[0])?b[0]:b,f=c?a.indexOf(c):-1,g=(d=Math.max(f,0),a.map((b,c)=>a[(d+c)%a.length]));1===e.length&&(g=g.filter(a=>a!==c));let h=g.find(a=>a.toLowerCase().startsWith(e.toLowerCase()));return h!==c?h:void 0}(f.map(a=>a.textValue),b,h),j=f.find(a=>a.textValue===i)?.ref.current,function a(b){B.current=b,window.clearTimeout(A.current),""!==b&&(A.current=window.setTimeout(()=>a(""),1e3))}(b),j&&setTimeout(()=>j.focus()))}let f=y.current;if(a.target!==f||!tQ.includes(a.key))return;a.preventDefault();let g=v().filter(a=>!a.disabled).map(a=>a.ref.current);tP.includes(a.key)&&g.reverse(),function(a){let b=document.activeElement;for(let c of a)if(c===b||(c.focus(),document.activeElement!==b))return}(g)}),onBlur:(0,av.composeEventHandlers)(a.onBlur,a=>{a.currentTarget.contains(a.target)||(window.clearTimeout(A.current),B.current="")}),onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uJ(a=>{let b=a.target,c=H.current!==a.clientX;a.currentTarget.contains(b)&&c&&(G.current=a.clientX>H.current?"right":"left",H.current=a.clientX)}))})})})})})})});uc.displayName=t9;var uh=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"group",...d,ref:b})});uh.displayName="MenuGroup";var ui=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{...d,ref:b})});ui.displayName="MenuLabel";var uj="MenuItem",uk="menu.itemSelect",ul=D.forwardRef((a,b)=>{let{disabled:c=!1,onSelect:d,...e}=a,f=D.useRef(null),g=t2(uj,a.__scopeMenu),h=ub(uj,a.__scopeMenu),i=(0,aw.useComposedRefs)(b,f),j=D.useRef(!1);return(0,C.jsx)(um,{...e,ref:i,disabled:c,onClick:(0,av.composeEventHandlers)(a.onClick,()=>{let a=f.current;if(!c&&a){let b=new CustomEvent(uk,{bubbles:!0,cancelable:!0});a.addEventListener(uk,a=>d?.(a),{once:!0}),(0,aC.dispatchDiscreteCustomEvent)(a,b),b.defaultPrevented?j.current=!1:g.onClose()}}),onPointerDown:b=>{a.onPointerDown?.(b),j.current=!0},onPointerUp:(0,av.composeEventHandlers)(a.onPointerUp,a=>{j.current||a.currentTarget?.click()}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{let b=""!==h.searchRef.current;c||b&&" "===a.key||tO.includes(a.key)&&(a.currentTarget.click(),a.preventDefault())})})});ul.displayName=uj;var um=D.forwardRef((a,b)=>{let{__scopeMenu:c,disabled:d=!1,textValue:e,...f}=a,g=ub(uj,c),h=t$(c),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i),[k,l]=D.useState(!1),[n,o]=D.useState("");return D.useEffect(()=>{let a=i.current;a&&o((a.textContent??"").trim())},[f.children]),(0,C.jsx)(tU.ItemSlot,{scope:c,disabled:d,textValue:e??n,children:(0,C.jsx)(tI.Item,{asChild:!0,...h,focusable:!d,children:(0,C.jsx)(aC.Primitive.div,{role:"menuitem","data-highlighted":k?"":void 0,"aria-disabled":d||void 0,"data-disabled":d?"":void 0,...f,ref:j,onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uJ(a=>{d?g.onItemLeave(a):(g.onItemEnter(a),a.defaultPrevented||a.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,uJ(a=>g.onItemLeave(a))),onFocus:(0,av.composeEventHandlers)(a.onFocus,()=>l(!0)),onBlur:(0,av.composeEventHandlers)(a.onBlur,()=>l(!1))})})})}),un=D.forwardRef((a,b)=>{let{checked:c=!1,onCheckedChange:d,...e}=a;return(0,C.jsx)(uv,{scope:a.__scopeMenu,checked:c,children:(0,C.jsx)(ul,{role:"menuitemcheckbox","aria-checked":uH(c)?"mixed":c,...e,ref:b,"data-state":uI(c),onSelect:(0,av.composeEventHandlers)(e.onSelect,()=>d?.(!!uH(c)||!c),{checkForDefaultPrevented:!1})})})});un.displayName="MenuCheckboxItem";var uo="MenuRadioGroup",[up,uq]=tX(uo,{value:void 0,onValueChange:()=>{}}),ur=D.forwardRef((a,b)=>{let{value:c,onValueChange:d,...e}=a,f=(0,tL.useCallbackRef)(d);return(0,C.jsx)(up,{scope:a.__scopeMenu,value:c,onValueChange:f,children:(0,C.jsx)(uh,{...e,ref:b})})});ur.displayName=uo;var us="MenuRadioItem",ut=D.forwardRef((a,b)=>{let{value:c,...d}=a,e=uq(us,a.__scopeMenu),f=c===e.value;return(0,C.jsx)(uv,{scope:a.__scopeMenu,checked:f,children:(0,C.jsx)(ul,{role:"menuitemradio","aria-checked":f,...d,ref:b,"data-state":uI(f),onSelect:(0,av.composeEventHandlers)(d.onSelect,()=>e.onValueChange?.(c),{checkForDefaultPrevented:!1})})})});ut.displayName=us;var uu="MenuItemIndicator",[uv,uw]=tX(uu,{checked:!1}),ux=D.forwardRef((a,b)=>{let{__scopeMenu:c,forceMount:d,...e}=a,f=uw(uu,c);return(0,C.jsx)(tH.Presence,{present:d||uH(f.checked)||!0===f.checked,children:(0,C.jsx)(aC.Primitive.span,{...e,ref:b,"data-state":uI(f.checked)})})});ux.displayName=uu;var uy=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"separator","aria-orientation":"horizontal",...d,ref:b})});uy.displayName="MenuSeparator";var uz=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tZ(c);return(0,C.jsx)(tF.Arrow,{...e,...d,ref:b})});uz.displayName="MenuArrow";var[uA,uB]=tX("MenuSub"),uC="MenuSubTrigger",uD=D.forwardRef((a,b)=>{let c=t0(uC,a.__scopeMenu),d=t2(uC,a.__scopeMenu),e=uB(uC,a.__scopeMenu),f=ub(uC,a.__scopeMenu),g=D.useRef(null),{pointerGraceTimerRef:h,onPointerGraceIntentChange:i}=f,j={__scopeMenu:a.__scopeMenu},k=D.useCallback(()=>{g.current&&window.clearTimeout(g.current),g.current=null},[]);return D.useEffect(()=>k,[k]),D.useEffect(()=>{let a=h.current;return()=>{window.clearTimeout(a),i(null)}},[h,i]),(0,C.jsx)(t4,{asChild:!0,...j,children:(0,C.jsx)(um,{id:e.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":e.contentId,"data-state":uG(c.open),...a,ref:(0,aw.composeRefs)(b,e.onTriggerChange),onClick:b=>{a.onClick?.(b),a.disabled||b.defaultPrevented||(b.currentTarget.focus(),c.open||c.onOpenChange(!0))},onPointerMove:(0,av.composeEventHandlers)(a.onPointerMove,uJ(b=>{f.onItemEnter(b),!b.defaultPrevented&&(a.disabled||c.open||g.current||(f.onPointerGraceIntentChange(null),g.current=window.setTimeout(()=>{c.onOpenChange(!0),k()},100)))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,uJ(a=>{k();let b=c.content?.getBoundingClientRect();if(b){let d=c.content?.dataset.side,e="right"===d,g=b[e?"left":"right"],i=b[e?"right":"left"];f.onPointerGraceIntentChange({area:[{x:a.clientX+(e?-5:5),y:a.clientY},{x:g,y:b.top},{x:i,y:b.top},{x:i,y:b.bottom},{x:g,y:b.bottom}],side:d}),window.clearTimeout(h.current),h.current=window.setTimeout(()=>f.onPointerGraceIntentChange(null),300)}else{if(f.onTriggerLeave(a),a.defaultPrevented)return;f.onPointerGraceIntentChange(null)}})),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,b=>{let e=""!==f.searchRef.current;a.disabled||e&&" "===b.key||tR[d.dir].includes(b.key)&&(c.onOpenChange(!0),c.content?.focus(),b.preventDefault())})})})});uD.displayName=uC;var uE="MenuSubContent",uF=D.forwardRef((a,b)=>{let c=t7(t9,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=t0(t9,a.__scopeMenu),g=t2(t9,a.__scopeMenu),h=uB(uE,a.__scopeMenu),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i);return(0,C.jsx)(tU.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tH.Presence,{present:d||f.open,children:(0,C.jsx)(tU.Slot,{scope:a.__scopeMenu,children:(0,C.jsx)(ug,{id:h.contentId,"aria-labelledby":h.triggerId,...e,ref:j,align:"start",side:"rtl"===g.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:a=>{g.isUsingKeyboardRef.current&&i.current?.focus(),a.preventDefault()},onCloseAutoFocus:a=>a.preventDefault(),onFocusOutside:(0,av.composeEventHandlers)(a.onFocusOutside,a=>{a.target!==h.trigger&&f.onOpenChange(!1)}),onEscapeKeyDown:(0,av.composeEventHandlers)(a.onEscapeKeyDown,a=>{g.onClose(),a.preventDefault()}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{let b=a.currentTarget.contains(a.target),c=tS[g.dir].includes(a.key);b&&c&&(f.onOpenChange(!1),h.trigger?.focus(),a.preventDefault())})})})})})});function uG(a){return a?"open":"closed"}function uH(a){return"indeterminate"===a}function uI(a){return uH(a)?"indeterminate":a?"checked":"unchecked"}function uJ(a){return b=>"mouse"===b.pointerType?a(b):void 0}uF.displayName=uE;var uK="DropdownMenu",[uL,uM]=(0,ax.createContextScope)(uK,[tY]),uN=tY(),[uO,uP]=uL(uK),uQ=a=>{let{__scopeDropdownMenu:b,children:c,dir:d,open:e,defaultOpen:f,onOpenChange:g,modal:h=!0}=a,i=uN(b),j=D.useRef(null),[k,l]=(0,ay.useControllableState)({prop:e,defaultProp:f??!1,onChange:g,caller:uK});return(0,C.jsx)(uO,{scope:b,triggerId:(0,tE.useId)(),triggerRef:j,contentId:(0,tE.useId)(),open:k,onOpenChange:l,onOpenToggle:D.useCallback(()=>l(a=>!a),[l]),modal:h,children:(0,C.jsx)(t3,{...i,open:k,onOpenChange:l,dir:d,modal:h,children:c})})};uQ.displayName=uK;var uR="DropdownMenuTrigger",uS=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,disabled:d=!1,...e}=a,f=uP(uR,c),g=uN(c);return(0,C.jsx)(t4,{asChild:!0,...g,children:(0,C.jsx)(aC.Primitive.button,{type:"button",id:f.triggerId,"aria-haspopup":"menu","aria-expanded":f.open,"aria-controls":f.open?f.contentId:void 0,"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,disabled:d,...e,ref:(0,aw.composeRefs)(b,f.triggerRef),onPointerDown:(0,av.composeEventHandlers)(a.onPointerDown,a=>{!d&&0===a.button&&!1===a.ctrlKey&&(f.onOpenToggle(),f.open||a.preventDefault())}),onKeyDown:(0,av.composeEventHandlers)(a.onKeyDown,a=>{!d&&(["Enter"," "].includes(a.key)&&f.onOpenToggle(),"ArrowDown"===a.key&&f.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});uS.displayName=uR;var uT=a=>{let{__scopeDropdownMenu:b,...c}=a,d=uN(b);return(0,C.jsx)(t8,{...d,...c})};uT.displayName="DropdownMenuPortal";var uU="DropdownMenuContent",uV=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uP(uU,c),f=uN(c),g=D.useRef(!1);return(0,C.jsx)(uc,{id:e.contentId,"aria-labelledby":e.triggerId,...f,...d,ref:b,onCloseAutoFocus:(0,av.composeEventHandlers)(a.onCloseAutoFocus,a=>{g.current||e.triggerRef.current?.focus(),g.current=!1,a.preventDefault()}),onInteractOutside:(0,av.composeEventHandlers)(a.onInteractOutside,a=>{let b=a.detail.originalEvent,c=0===b.button&&!0===b.ctrlKey,d=2===b.button||c;(!e.modal||d)&&(g.current=!0)}),style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uV.displayName=uU,D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(uh,{...e,...d,ref:b})}).displayName="DropdownMenuGroup";var uW=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(ui,{...e,...d,ref:b})});uW.displayName="DropdownMenuLabel";var uX=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(ul,{...e,...d,ref:b})});uX.displayName="DropdownMenuItem";var uY=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(un,{...e,...d,ref:b})});uY.displayName="DropdownMenuCheckboxItem",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(ur,{...e,...d,ref:b})}).displayName="DropdownMenuRadioGroup";var uZ=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(ut,{...e,...d,ref:b})});uZ.displayName="DropdownMenuRadioItem";var u$=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(ux,{...e,...d,ref:b})});u$.displayName="DropdownMenuItemIndicator";var u_=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(uy,{...e,...d,ref:b})});u_.displayName="DropdownMenuSeparator",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(uz,{...e,...d,ref:b})}).displayName="DropdownMenuArrow";var u0=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(uD,{...e,...d,ref:b})});u0.displayName="DropdownMenuSubTrigger";var u1=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uN(c);return(0,C.jsx)(uF,{...e,...d,ref:b,style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});u1.displayName="DropdownMenuSubContent";let u2=(0,K.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);D.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,C.jsxs)(u0,{ref:e,className:(0,S.cn)("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",b&&"pl-8",a),...d,children:[c,(0,C.jsx)(Q.ChevronRight,{className:"ml-auto"})]})).displayName=u0.displayName,D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(u1,{ref:c,className:(0,S.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...b})).displayName=u1.displayName;let u3=D.forwardRef(({className:a,sideOffset:b=4,...c},d)=>(0,C.jsx)(uT,{children:(0,C.jsx)(uV,{ref:d,sideOffset:b,className:(0,S.cn)("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",a),...c})}));u3.displayName=uV.displayName;let u4=D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uX,{ref:d,className:(0,S.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",b&&"pl-8",a),...c}));u4.displayName=uX.displayName,D.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,C.jsxs)(uY,{ref:e,className:(0,S.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,C.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,C.jsx)(u$,{children:(0,C.jsx)(bh.Check,{className:"h-4 w-4"})})}),b]})).displayName=uY.displayName,D.forwardRef(({className:a,children:b,...c},d)=>(0,C.jsxs)(uZ,{ref:d,className:(0,S.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,C.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,C.jsx)(u$,{children:(0,C.jsx)(u2,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=uZ.displayName,D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uW,{ref:d,className:(0,S.cn)("px-2 py-1.5 text-sm font-semibold",b&&"pl-8",a),...c})).displayName=uW.displayName;let u5=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(u_,{ref:c,className:(0,S.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));u5.displayName=u_.displayName;var bi=bi;function u6({directiveId:a,onClose:b}){let c,{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(null),[g,h]=(0,D.useState)(!1),[i,j]=(0,D.useState)(null);(0,D.useEffect)(()=>{a&&d&&(async()=>{h(!0),j(null),f(null);try{let b=await V.client.getDirective(d,a);f(b)}catch(a){console.error("Error loading directive:",a),j(a.message)}finally{h(!1)}})()},[a,d]);let k=null!==a;return(0,C.jsx)(bk.Dialog,{open:k,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nN.VisuallyHidden,{children:(0,C.jsx)(bk.DialogTitle,{children:"Directive Details"})}),g?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)(bi.default,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):i?(0,C.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,C.jsx)("div",{className:"text-center text-destructive",children:(0,C.jsxs)("div",{className:"text-sm",children:["Error: ",i]})})}):e?(0,C.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6",children:[(0,C.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),!e.is_active&&(0,C.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:"Inactive"})]}),(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:e.id})]}),(0,C.jsxs)("div",{className:"flex gap-8",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:(c=new Date(e.created_at),`${c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${c.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Priority"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:e.priority})]})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:e.content})})]}),e.tags&&e.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map((a,b)=>(0,C.jsx)("span",{className:"px-2 py-0.5 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded text-xs",children:a},b))})]})]}):null]})})}function u7(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)("dashboard"),[h,i]=(0,D.useState)(""),[j,k]=(0,D.useState)(1),[l,n]=(0,D.useState)(!1),[o,p]=(0,D.useState)(null),[q,r]=(0,D.useState)(!1),[s,t]=(0,D.useState)(null),[u,v]=(0,D.useState)(null),[w,x]=(0,D.useState)(!1),y=b.filter(a=>{if(!h)return!0;let b=h.toLowerCase();return a.id.toLowerCase().includes(b)||a.name.toLowerCase().includes(b)||a.source_query.toLowerCase().includes(b)||a.content.toLowerCase().includes(b)}),z=async()=>{if(a){e(!0);try{let b=await V.client.listMentalModels(a);c(b.items||[])}catch(a){console.error("Error loading mental models:",a)}finally{e(!1)}}},A=async()=>{if(a&&u){x(!0);try{await V.client.deleteMentalModel(a,u.id),c(a=>a.filter(a=>a.id!==u.id)),o?.id===u.id&&p(null),v(null)}catch(a){}finally{x(!1)}}};if((0,D.useEffect)(()=>{a&&z()},[a]),(0,D.useEffect)(()=>{let a=a=>{"Escape"===a.key&&p(null)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),(0,D.useEffect)(()=>{k(1)},[h]),!a)return(0,C.jsx)(mW,{children:(0,C.jsx)(m$,{className:"p-10 text-center",children:(0,C.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to view mental models."})})});let B=Math.ceil(y.length/100),E=(j-1)*100,F=E+100,G=y.slice(E,F);return(0,C.jsxs)("div",{children:[d?(0,C.jsxs)("div",{className:"text-center py-12",children:[(0,C.jsx)(ab,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"mb-4",children:(0,C.jsx)(X.Input,{type:"text",value:h,onChange:a=>i(a.target.value),placeholder:"Filter mental models by name, query, or content...",className:"max-w-md"})}),(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsx)("div",{className:"text-sm text-muted-foreground",children:h?`${y.length} of ${b.length} mental models`:`${b.length} mental model${1!==b.length?"s":""}`}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsxs)(W.Button,{onClick:()=>n(!0),size:"sm",children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-2"}),"Add Mental Model"]}),(0,C.jsxs)("div",{className:"flex items-center gap-2 bg-muted rounded-lg p-1",children:[(0,C.jsxs)("button",{onClick:()=>g("dashboard"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"dashboard"===f?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,C.jsx)(tz,{className:"w-4 h-4"}),"Dashboard"]}),(0,C.jsxs)("button",{onClick:()=>g("table"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-all flex items-center gap-1.5 ${"table"===f?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[(0,C.jsx)(af,{className:"w-4 h-4"}),"Table"]})]})]})]}),y.length>0?(0,C.jsxs)(C.Fragment,{children:["dashboard"===f&&(0,C.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:G.map(a=>{let b=new Date(a.last_refreshed_at),c=b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),d=b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,C.jsx)(mW,{className:`cursor-pointer transition-all hover:shadow-md hover:border-primary/50 ${o?.id===a.id?"border-primary shadow-md":""}`,onClick:()=>p(a),children:(0,C.jsxs)(m$,{className:"p-4",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,C.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,C.jsx)("h3",{className:"font-semibold text-foreground mb-1 truncate",children:a.name}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate",children:a.id}),(0,C.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium flex-shrink-0 ${a.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:a.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 ml-2 text-muted-foreground hover:text-destructive flex-shrink-0",onClick:b=>{b.stopPropagation(),v({id:a.id,name:a.name})},children:(0,C.jsx)(mQ,{className:"h-4 w-4"})})]}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:a.source_query}),(0,C.jsx)("div",{className:"text-sm text-foreground mb-3 border-t border-border pt-3",children:a.content.includes("|")||a.content.includes("```")||a.content.includes("\n\n")?(0,C.jsxs)("div",{className:"line-clamp-3 text-muted-foreground italic",children:[a.content.substring(0,150),"..."," ",(0,C.jsx)("span",{className:"text-primary",children:"Click to view full content"})]}):(0,C.jsx)("div",{className:"line-clamp-6 prose prose-sm dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})}),(0,C.jsxs)("div",{className:"flex items-center justify-between text-xs border-t border-border pt-3",children:[(0,C.jsx)("div",{className:"flex items-center gap-2",children:a.tags.length>0&&(0,C.jsxs)("div",{className:"flex gap-1",children:[a.tags.slice(0,2).map(a=>(0,C.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a)),a.tags.length>2&&(0,C.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-xs bg-muted text-muted-foreground",children:["+",a.tags.length-2]})]})}),(0,C.jsxs)("div",{className:"text-muted-foreground",children:[c," ",d]})]})]})},a.id)})}),"table"===f&&(0,C.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,C.jsxs)(ai,{className:"table-fixed",children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{className:"bg-muted/50",children:[(0,C.jsx)(am,{className:"w-[20%]",children:"ID"}),(0,C.jsx)(am,{className:"w-[20%]",children:"Name"}),(0,C.jsx)(am,{className:"w-[35%]",children:"Source Query"}),(0,C.jsx)(am,{className:"w-[15%]",children:"Last Refreshed"}),(0,C.jsx)(am,{className:"w-[10%]"})]})}),(0,C.jsx)(ak,{children:G.map(a=>{let b=new Date(a.last_refreshed_at),c=b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),d=b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,C.jsxs)(al,{className:`cursor-pointer hover:bg-muted/50 ${o?.id===a.id?"bg-primary/10":""}`,onClick:()=>p(a),children:[(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate block",children:a.id})}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("div",{className:"font-medium text-foreground",children:a.name})}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)("div",{className:"text-sm text-muted-foreground truncate",children:a.source_query})}),(0,C.jsxs)(an,{className:"py-2 text-sm text-foreground",children:[(0,C.jsx)("div",{children:c}),(0,C.jsx)("div",{className:"text-xs text-muted-foreground",children:d})]}),(0,C.jsx)(an,{className:"py-2",children:(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:b=>{b.stopPropagation(),v({id:a.id,name:a.name})},children:(0,C.jsx)(mQ,{className:"h-4 w-4"})})})]},a.id)})})]})}),B>1&&(0,C.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,C.jsxs)("div",{className:"text-xs text-muted-foreground",children:[E+1,"-",Math.min(F,y.length)," of"," ",y.length]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(1),disabled:1===j,className:"h-7 w-7 p-0",children:(0,C.jsx)(_,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(a=>Math.max(1,a-1)),disabled:1===j,className:"h-7 w-7 p-0",children:(0,C.jsx)(P,{className:"h-3 w-3"})}),(0,C.jsxs)("span",{className:"text-xs px-2",children:[j," / ",B]}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(a=>Math.min(B,a+1)),disabled:j===B,className:"h-7 w-7 p-0",children:(0,C.jsx)(Q.ChevronRight,{className:"h-3 w-3"})}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>k(B),disabled:j===B,className:"h-7 w-7 p-0",children:(0,C.jsx)(aa,{className:"h-3 w-3"})})]})]})]}):(0,C.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,C.jsx)(L,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:h?"No mental models match your filter":"No mental models yet. Create a mental model to generate and save a summary from your memories."})]})]}),(0,C.jsx)(u8,{open:l,onClose:()=>n(!1),onCreated:()=>{n(!1),z()}}),(0,C.jsx)(ms,{open:!!u,onOpenChange:a=>!a&&v(null),children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Mental Model"}),(0,C.jsxs)(mN,{children:["Are you sure you want to delete"," ",(0,C.jsxs)("span",{className:"font-semibold",children:['"',u?.name,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),(0,C.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,C.jsxs)(mL,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mP,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mO,{onClick:A,disabled:w,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[w?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),o&&(0,C.jsx)(va,{mentalModel:o,onClose:()=>p(null),onDelete:()=>v({id:o.id,name:o.name}),onEdit:()=>{t(o),r(!0)},onRefreshed:a=>{c(b=>b.map(b=>b.id===a.id?a:b)),p(a)}}),s&&(0,C.jsx)(u9,{open:q,mentalModel:s,onClose:()=>{r(!1),t(null)},onUpdated:a=>{c(b=>b.map(b=>b.id===a.id?a:b)),p(a),r(!1),t(null)}})]})}function u8({open:a,onClose:b,onCreated:c}){let{currentBank:d}=(0,H.useBank)(),[e,f]=(0,D.useState)(!1),[g,h]=(0,D.useState)({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),i=async()=>{if(d&&g.name.trim()&&g.sourceQuery.trim()){f(!0);try{let a=g.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),b=parseInt(g.maxTokens)||2048;await V.client.createMentalModel(d,{id:g.id.trim()||void 0,name:g.name.trim(),source_query:g.sourceQuery.trim(),tags:a.length>0?a:void 0,max_tokens:b,trigger:{refresh_after_consolidation:g.autoRefresh}}),h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),c()}catch(a){}finally{f(!1)}}};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>{a||(h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),b())},children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Create Mental Model"}),(0,C.jsx)(bk.DialogDescription,{children:"Create a mental model by running a query. The content will be auto-generated and can be refreshed later."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["ID ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:g.id,onChange:a=>h({...g,id:a.target.value}),placeholder:"e.g., team-communication"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Custom ID for the mental model. If not provided, a UUID will be generated."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:g.name,onChange:a=>h({...g,name:a.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,C.jsx)(X.Input,{value:g.sourceQuery,onChange:a=>h({...g,sourceQuery:a.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,C.jsx)(X.Input,{type:"number",value:g.maxTokens,onChange:a=>h({...g,maxTokens:a.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:g.tags,onChange:a=>h({...g,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,C.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,C.jsx)(mV.Checkbox,{id:"auto-refresh",checked:g.autoRefresh,onCheckedChange:a=>h({...g,autoRefresh:!0===a})}),(0,C.jsx)("label",{htmlFor:"auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:b,disabled:e,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:i,disabled:e||!g.name.trim()||!g.sourceQuery.trim(),children:e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}),"Generating..."]}):"Create"})]})]})})}function u9({open:a,mentalModel:b,onClose:c,onUpdated:d}){let{currentBank:e}=(0,H.useBank)(),[f,g]=(0,D.useState)(!1),[h,i]=(0,D.useState)({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1});(0,D.useEffect)(()=>{a&&i({name:b.name,sourceQuery:b.source_query,maxTokens:String(b.max_tokens||2048),tags:b.tags.join(", "),autoRefresh:b.trigger?.refresh_after_consolidation||!1})},[a,b]);let j=async()=>{if(e&&h.name.trim()&&h.sourceQuery.trim()){g(!0);try{let a=h.tags.split(",").map(a=>a.trim()).filter(a=>a.length>0),f=parseInt(h.maxTokens)||2048,g=await V.client.updateMentalModel(e,b.id,{name:h.name.trim(),source_query:h.sourceQuery.trim(),tags:a.length>0?a:void 0,max_tokens:f,trigger:{refresh_after_consolidation:h.autoRefresh}});d(g),c()}catch(a){}finally{g(!1)}}};return(0,C.jsx)(bk.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,C.jsxs)(bk.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Update Mental Model"}),(0,C.jsx)(bk.DialogDescription,{children:"Update the mental model configuration. Changes will take effect immediately."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-4",children:[(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,C.jsx)(X.Input,{value:b.id,disabled:!0,className:"bg-muted"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"ID cannot be changed after creation."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,C.jsx)(X.Input,{value:h.name,onChange:a=>i({...h,name:a.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,C.jsx)(X.Input,{value:h.sourceQuery,onChange:a=>i({...h,sourceQuery:a.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"This query will be run to generate the initial content, and re-run when you refresh."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,C.jsx)(X.Input,{type:"number",value:h.maxTokens,onChange:a=>i({...h,maxTokens:a.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,C.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,C.jsx)(X.Input,{value:h.tags,onChange:a=>i({...h,tags:a.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]}),(0,C.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,C.jsx)(mV.Checkbox,{id:"update-auto-refresh",checked:h.autoRefresh,onCheckedChange:a=>i({...h,autoRefresh:!0===a})}),(0,C.jsx)("label",{htmlFor:"update-auto-refresh",className:"text-sm font-medium text-foreground cursor-pointer",children:"Auto-refresh after consolidation"})]}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground -mt-2 ml-6",children:"Automatically refresh this mental model when memories are consolidated."})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:c,disabled:f,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:j,disabled:f||!h.name.trim()||!h.sourceQuery.trim(),children:f?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}),"Updating..."]}):"Update"})]})]})})}function va({mentalModel:a,onClose:b,onDelete:c,onEdit:d,onRefreshed:e}){let{currentBank:f}=(0,H.useBank)(),[g,h]=(0,D.useState)(!1),[i,j]=(0,D.useState)(null),[k,l]=(0,D.useState)(null),[n,o]=(0,D.useState)(!1),p=async()=>{if(!f)return;h(!0);let b=a.last_refreshed_at;try{await V.client.refreshMentalModel(f,a.id);let c=0,d=async()=>{c++;try{let g=await V.client.getMentalModel(f,a.id);if(g.last_refreshed_at!==b){e(g),h(!1);return}if(c>=120){h(!1),F.toast.error("Refresh timeout",{description:"Refresh is taking longer than expected. Check the operations list for status."});return}setTimeout(d,1e3)}catch(a){console.error("Error polling mental model:",a),h(!1)}};setTimeout(d,1e3)}catch(a){h(!1)}},q=a=>{let b=new Date(a);return`${b.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${b.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`},r=a.reflect_response?.based_on?Object.entries(a.reflect_response.based_on).filter(([a])=>"observation"!==a).flatMap(([a,b])=>b.map(b=>({...b,factType:a}))):[],s=a.reflect_response?.based_on?.observation||[];return(0,C.jsxs)("div",{className:"fixed right-0 top-0 h-screen w-1/2 bg-card border-l shadow-2xl z-50 overflow-y-auto animate-in slide-in-from-right duration-300 ease-out",children:[(0,C.jsxs)("div",{className:"p-6",children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,C.jsxs)("div",{className:"flex-1 mr-4",children:[(0,C.jsx)("div",{className:"flex items-center gap-2",children:(0,C.jsx)("h3",{className:"text-xl font-bold text-foreground",children:a.name})}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:a.source_query})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsxs)(uQ,{children:[(0,C.jsx)(uS,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",disabled:g,children:[g?(0,C.jsx)(bi.default,{className:"h-4 w-4 animate-spin"}):(0,C.jsx)(tA,{className:"h-4 w-4"}),(0,C.jsx)("span",{className:"text-xs",children:"Actions"})]})}),(0,C.jsxs)(u3,{align:"end",children:[(0,C.jsxs)(u4,{onClick:d,children:[(0,C.jsx)(mR,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,C.jsxs)(u4,{onClick:p,children:[(0,C.jsx)(ab,{className:"h-4 w-4 mr-2"}),"Refresh"]}),(0,C.jsxs)(u4,{onClick:()=>o(!0),children:[(0,C.jsx)(bj,{className:"h-4 w-4 mr-2"}),"View History"]}),(0,C.jsx)(u5,{}),(0,C.jsxs)(u4,{onClick:c,className:"text-destructive focus:text-destructive",children:[(0,C.jsx)(mQ,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:b,className:"h-8 w-8 p-0",children:(0,C.jsx)(ah.X,{className:"h-4 w-4"})})]})]}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"ID"}),(0,C.jsx)("div",{className:"text-sm text-foreground font-mono",children:a.id})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Name"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.name})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Source Query"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.source_query})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Max Tokens"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:a.max_tokens})]}),a.tags.length>0&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Tags"}),(0,C.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.tags.map(a=>(0,C.jsx)("span",{className:"px-2 py-1 rounded text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400",children:a},a))})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Auto-refresh"}),(0,C.jsx)("span",{className:`inline-block text-xs px-2 py-1 rounded-full font-medium ${a.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:a.trigger?.refresh_after_consolidation?"Auto Refresh":"Manual"})]}),a.last_refreshed_at&&(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Last Refreshed"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:q(a.last_refreshed_at)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,C.jsx)("div",{className:"text-sm text-foreground",children:q(a.created_at)})]})]}),(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,C.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,C.jsx)(rd,{remarkPlugins:[sI],children:a.content})})]}),r.length>0&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Based On (",r.length," ",1===r.length?"fact":"facts",")"]}),(0,C.jsx)("div",{className:"space-y-3",children:r.map((a,b)=>{let c="directives"===a.factType?{label:"directive",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"}:"mental-models"===a.factType?{label:"mental model",color:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400"}:"world"===a.factType?{label:"world",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}:"experience"===a.factType?{label:"experience",color:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:a.factType,color:"bg-slate-500/10 text-slate-600 dark:text-slate-400"};return(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,C.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${c.color}`,children:c.label}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>{"directives"===a.factType?l(a.id):j(a.id)},children:"View"})]}),(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text})]},a.id||b)})})]}),s.length>0&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Observations Used (",s.length,")"]}),(0,C.jsx)("div",{className:"space-y-3",children:s.map((a,b)=>(0,C.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,C.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,C.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:"observation"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>j(a.id),children:"View"})]}),(0,C.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:a.text})]},a.id||b))})]}),!a.reflect_response&&(0,C.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,C.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Based On"}),(0,C.jsx)("p",{className:"text-sm text-muted-foreground",children:'No source data available. Click "Refresh" to regenerate with source tracking.'})]})]})]}),i&&f&&(0,C.jsx)(bt,{memoryId:i,onClose:()=>j(null)}),k&&f&&(0,C.jsx)(u6,{directiveId:k,onClose:()=>l(null)}),(0,C.jsx)(sN,{mentalModelId:n?a.id:null,onClose:()=>o(!1),initialTab:"history"})]})}let vb=(0,K.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),vc=(0,K.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var bi=bi;let vd=["consolidation.completed","retain.completed"],ve={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function vf(a){return Object.fromEntries(a.filter(a=>a.key.trim()).map(a=>[a.key,a.value]))}function vg(a){return{method:a.method,timeout_seconds:a.timeout_seconds,headers:vf(a.headers),params:vf(a.params)}}function vh({label:a,pairs:b,onChange:c}){let d=(a,d,e)=>{c(b.map((b,c)=>c===a?{...b,[d]:e}:b))};return(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsx)(at,{children:a}),(0,C.jsxs)(W.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>c([...b,{key:"",value:""}]),children:[(0,C.jsx)(sU.Plus,{className:"w-3 h-3 mr-1"}),"Add"]})]}),b.length>0&&(0,C.jsx)("div",{className:"space-y-1.5",children:b.map((a,e)=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(X.Input,{placeholder:"Key",value:a.key,onChange:a=>d(e,"key",a.target.value),className:"h-8 text-sm flex-1"}),(0,C.jsx)(X.Input,{placeholder:"Value",value:a.value,onChange:a=>d(e,"value",a.target.value),className:"h-8 text-sm flex-1"}),(0,C.jsx)("button",{type:"button",onClick:()=>c(b.filter((a,b)=>b!==e)),className:"text-muted-foreground hover:text-foreground shrink-0",children:(0,C.jsx)(ah.X,{className:"w-4 h-4"})})]},e))})]})}function vi({delivery:a,formatDate:b}){var c;let[d,e]=(0,D.useState)(!1),f=a.last_response_body||a.last_error;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(al,{className:f?"cursor-pointer hover:bg-muted/40":void 0,onClick:()=>f&&e(a=>!a),children:[(0,C.jsx)(an,{className:"w-8 pl-3 pr-0",children:f?d?(0,C.jsx)(sP.ChevronDown,{className:"w-4 h-4 text-muted-foreground"}):(0,C.jsx)(Q.ChevronRight,{className:"w-4 h-4 text-muted-foreground"}):(0,C.jsx)("span",{className:"w-4 h-4 inline-block"})}),(0,C.jsx)(an,{children:"completed"===(c=a.status)?(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"delivered"]}):"pending"===c?(0,C.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,C.jsx)(ad,{className:"w-3 h-3"}),"pending"]}):"failed"===c?(0,C.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,C.jsx)(s2,{className:"w-3 h-3"}),"failed"]}):(0,C.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:c})}),(0,C.jsx)(an,{children:null!=a.last_response_status?(0,C.jsx)("span",{className:`font-mono text-xs px-1.5 py-0.5 rounded border ${a.last_response_status>=200&&a.last_response_status<300?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:a.last_response_status}):(0,C.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,C.jsx)(an,{className:"text-center text-sm",children:a.attempts}),(0,C.jsx)(an,{className:"font-mono text-xs text-muted-foreground",children:a.event_type}),(0,C.jsx)(an,{className:"text-xs text-muted-foreground whitespace-nowrap",children:b(a.created_at)})]}),d&&f&&(0,C.jsx)(al,{className:"bg-muted/20 hover:bg-muted/20",children:(0,C.jsx)(an,{colSpan:6,className:"px-4 py-3",children:(0,C.jsxs)("div",{className:"space-y-3",children:[a.last_error&&(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Error"}),(0,C.jsx)("p",{className:"font-mono text-xs text-red-600 dark:text-red-400 break-all",children:a.last_error})]}),a.last_response_body&&(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Response Body",a.last_attempt_at&&(0,C.jsxs)("span",{className:"ml-2 normal-case font-normal",children:["· ",b(a.last_attempt_at)]})]}),(0,C.jsx)("pre",{className:"font-mono text-xs bg-background rounded p-2 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto border border-border",children:a.last_response_body})]})]})})})]})}function vj(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(!1),[f,g]=(0,D.useState)(!1),[h,i]=(0,D.useState)(!1),[j,k]=(0,D.useState)(null),[l,n]=(0,D.useState)(null),[o,p]=(0,D.useState)(!1),[q,r]=(0,D.useState)(ve),[s,t]=(0,D.useState)(!1),[u,v]=(0,D.useState)(null),[w,x]=(0,D.useState)(ve),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),[E,F]=(0,D.useState)(!1),[G,I]=(0,D.useState)(!1),[J,K]=(0,D.useState)(null),[L,M]=(0,D.useState)([]),[N,O]=(0,D.useState)(!1),[P,Q]=(0,D.useState)(null),[R,S]=(0,D.useState)(!1),T=async()=>{if(a){e(!0);try{let b=await V.client.listWebhooks(a);c(b.items||[])}catch(a){console.error("Error loading webhooks:",a)}finally{e(!1)}}};(0,D.useEffect)(()=>{a&&T()},[a]);let U=async()=>{if(a&&q.url){i(!0);try{await V.client.createWebhook(a,{url:q.url,secret:q.secret||void 0,event_types:q.event_types.length>0?q.event_types:void 0,enabled:q.enabled,http_config:vg(q.http_config)}),g(!1),r(ve),p(!1),await T()}catch(a){}finally{i(!1)}}},Y=async b=>{if(a){k(b),n(null);try{await V.client.deleteWebhook(a,b),await T()}catch(a){}finally{k(null)}}},Z=async()=>{if(a&&u&&w.url){F(!0);try{let b={url:w.url,event_types:w.event_types,enabled:w.enabled,http_config:vg(w.http_config)};A?b.secret=null:w.secret&&(b.secret=w.secret),await V.client.updateWebhook(a,u.id,b),t(!1),await T()}catch{}finally{F(!1)}}},$=async b=>{if(a){K(b),I(!0),M([]),Q(null),O(!0);try{let c=await V.client.listWebhookDeliveries(a,b.id,50);M(c.items||[]),Q(c.next_cursor??null)}catch(a){console.error("Error loading deliveries:",a)}finally{O(!1)}}},_=async()=>{if(a&&J&&P){S(!0);try{let b=await V.client.listWebhookDeliveries(a,J.id,50,P);M(a=>[...a,...b.items||[]]),Q(b.next_cursor??null)}catch(a){console.error("Error loading more deliveries:",a)}finally{S(!1)}}},aa=a=>a?new Date(a).toLocaleString():"N/A";return a?(0,C.jsxs)("div",{className:"space-y-4",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("h3",{className:"text-lg font-semibold",children:"Webhooks"}),(0,C.jsx)("button",{onClick:()=>T(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh webhooks",disabled:d,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${d?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[b.length," webhook",1!==b.length?"s":""]})]}),(0,C.jsxs)(W.Button,{size:"sm",onClick:()=>g(!0),children:[(0,C.jsx)(sU.Plus,{className:"w-4 h-4 mr-2"}),"Add Webhook"]})]}),b.length>0?(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{children:"URL"}),(0,C.jsx)(am,{children:"Method"}),(0,C.jsx)(am,{children:"Event Types"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{children:"Created At"}),(0,C.jsx)(am,{className:"w-[120px]"})]})}),(0,C.jsx)(ak,{children:b.map(a=>(0,C.jsxs)(al,{children:[(0,C.jsx)(an,{className:"font-mono text-sm max-w-[300px] truncate",children:(0,C.jsx)("span",{title:a.url,children:a.url})}),(0,C.jsx)(an,{children:(0,C.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:a.http_config?.method||"POST"})}),(0,C.jsx)(an,{children:(0,C.jsx)("div",{className:"flex flex-wrap gap-1",children:a.event_types.length>0?a.event_types.map(a=>(0,C.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20",children:a},a)):(0,C.jsx)("span",{className:"text-xs text-muted-foreground",children:"All events"})})}),(0,C.jsx)(an,{children:a.enabled?(0,C.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,C.jsx)(ac,{className:"w-3 h-3"}),"Enabled"]}):(0,C.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:"Disabled"})}),(0,C.jsx)(an,{className:"text-sm text-muted-foreground",children:aa(a.created_at)}),(0,C.jsx)(an,{children:(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsxs)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>$(a),title:"View deliveries",children:[(0,C.jsx)(vb,{className:"w-3 h-3 mr-1"}),"Deliveries"]}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{let b;return v(a),void(x((b=a.http_config??{method:"POST",timeout_seconds:30,headers:{},params:{}},{url:a.url,secret:"",event_types:a.event_types,enabled:a.enabled,http_config:{method:b.method,timeout_seconds:b.timeout_seconds,headers:Object.entries(b.headers??{}).map(([a,b])=>({key:a,value:b})),params:Object.entries(b.params??{}).map(([a,b])=>({key:a,value:b}))}})),z(!1),B(!1),t(!0))},title:"Edit webhook",children:(0,C.jsx)(mR,{className:"w-3 h-3"})}),(0,C.jsx)(W.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>n(a),disabled:j===a.id,title:"Delete webhook",children:j===a.id?(0,C.jsx)(bi.default,{className:"w-3 h-3 animate-spin"}):(0,C.jsx)(mQ,{className:"w-3 h-3"})})]})})]},a.id))})]})}):(0,C.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:"No webhooks configured. Add a webhook to receive event notifications."}),(0,C.jsx)(bk.Dialog,{open:f,onOpenChange:a=>{a||(r(ve),p(!1)),g(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Add Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Configure a webhook endpoint to receive event notifications."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-2",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Type"}),(0,C.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,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"webhook-url",children:["URL ",(0,C.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,C.jsx)(X.Input,{id:"webhook-url",type:"url",placeholder:"https://example.com/webhook",value:q.url,onChange:a=>r(b=>({...b,url:a.target.value}))})]}),(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Method"}),(0,C.jsxs)(mU.Select,{value:q.http_config.method,onValueChange:a=>r(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mU.SelectTrigger,{children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mU.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"webhook-timeout",children:"Timeout (seconds)"}),(0,C.jsx)(X.Input,{id:"webhook-timeout",type:"number",min:1,max:300,value:q.http_config.timeout_seconds,onChange:a=>r(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"webhook-secret",children:["Secret ",(0,C.jsx)("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),(0,C.jsxs)("div",{className:"relative",children:[(0,C.jsx)(X.Input,{id:"webhook-secret",type:o?"text":"password",placeholder:"Signing secret",value:q.secret,onChange:a=>r(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,C.jsx)("button",{type:"button",onClick:()=>p(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,children:o?(0,C.jsx)(vc,{className:"w-4 h-4"}):(0,C.jsx)(vb,{className:"w-4 h-4"})})]})]}),(0,C.jsx)(vh,{label:"Custom Headers",pairs:q.http_config.headers,onChange:a=>r(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(vh,{label:"Query Parameters",pairs:q.http_config.params,onChange:a=>r(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)(at,{children:"Event Types"}),(0,C.jsx)("div",{className:"space-y-2",children:vd.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mV.Checkbox,{id:`event-${a}`,checked:q.event_types.includes(a),onCheckedChange:()=>{r(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}}),(0,C.jsx)(at,{htmlFor:`event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)(be,{id:"webhook-enabled",checked:q.enabled,onCheckedChange:a=>r(b=>({...b,enabled:a}))}),(0,C.jsx)(at,{htmlFor:"webhook-enabled",children:"Enabled"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>g(!1),disabled:h,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:U,disabled:h||!q.url,children:h?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):"Create Webhook"})]})]})}),(0,C.jsx)(bk.Dialog,{open:s,onOpenChange:a=>{a||(v(null),x(ve),z(!1),B(!1)),t(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Edit Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Update the webhook configuration."})]}),(0,C.jsxs)("div",{className:"space-y-4 py-2",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Type"}),(0,C.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,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsxs)(at,{htmlFor:"edit-webhook-url",children:["URL ",(0,C.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,C.jsx)(X.Input,{id:"edit-webhook-url",type:"url",placeholder:"https://example.com/webhook",value:w.url,onChange:a=>x(b=>({...b,url:a.target.value}))})]}),(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{children:"Method"}),(0,C.jsxs)(mU.Select,{value:w.http_config.method,onValueChange:a=>x(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mU.SelectTrigger,{children:(0,C.jsx)(mU.SelectValue,{})}),(0,C.jsxs)(mU.SelectContent,{children:[(0,C.jsx)(mU.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mU.SelectItem,{value:"GET",children:"GET"})]})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"edit-webhook-timeout",children:"Timeout (seconds)"}),(0,C.jsx)(X.Input,{id:"edit-webhook-timeout",type:"number",min:1,max:300,value:w.http_config.timeout_seconds,onChange:a=>x(b=>({...b,http_config:{...b.http_config,timeout_seconds:parseInt(a.target.value)||30}}))})]})]}),(0,C.jsxs)("div",{className:"space-y-1.5",children:[(0,C.jsx)(at,{htmlFor:"edit-webhook-secret",children:"Secret"}),(0,C.jsxs)("div",{className:"relative",children:[(0,C.jsx)(X.Input,{id:"edit-webhook-secret",type:y?"text":"password",placeholder:"Leave blank to keep existing",value:w.secret,disabled:A,onChange:a=>x(b=>({...b,secret:a.target.value})),className:"pr-10"}),(0,C.jsx)("button",{type:"button",onClick:()=>z(a=>!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,children:y?(0,C.jsx)(vc,{className:"w-4 h-4"}):(0,C.jsx)(vb,{className:"w-4 h-4"})})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,C.jsx)(mV.Checkbox,{id:"edit-clear-secret",checked:A,onCheckedChange:a=>{B(!!a),a&&x(a=>({...a,secret:""}))}}),(0,C.jsx)(at,{htmlFor:"edit-clear-secret",className:"text-xs text-muted-foreground cursor-pointer",children:"Clear existing secret"})]})]}),(0,C.jsx)(vh,{label:"Custom Headers",pairs:w.http_config.headers,onChange:a=>x(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(vh,{label:"Query Parameters",pairs:w.http_config.params,onChange:a=>x(b=>({...b,http_config:{...b.http_config,params:a}}))}),(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsx)(at,{children:"Event Types"}),(0,C.jsx)("div",{className:"space-y-2",children:vd.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mV.Checkbox,{id:`edit-event-${a}`,checked:w.event_types.includes(a),onCheckedChange:()=>x(b=>({...b,event_types:b.event_types.includes(a)?b.event_types.filter(b=>b!==a):[...b.event_types,a]}))}),(0,C.jsx)(at,{htmlFor:`edit-event-${a}`,className:"font-mono text-sm cursor-pointer",children:a})]},a))})]}),(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)(be,{id:"edit-webhook-enabled",checked:w.enabled,onCheckedChange:a=>x(b=>({...b,enabled:a}))}),(0,C.jsx)(at,{htmlFor:"edit-webhook-enabled",children:"Enabled"})]})]}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>t(!1),disabled:E,children:"Cancel"}),(0,C.jsx)(W.Button,{onClick:Z,disabled:E||!w.url,children:E?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})}),(0,C.jsx)(bk.Dialog,{open:!!l,onOpenChange:a=>{a||n(null)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-md",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Delete Webhook"}),(0,C.jsx)(bk.DialogDescription,{children:"Are you sure you want to delete this webhook? This action cannot be undone and all pending deliveries will be cancelled."})]}),l&&(0,C.jsx)("div",{className:"py-2",children:(0,C.jsx)("p",{className:"font-mono text-sm truncate text-muted-foreground bg-muted px-3 py-2 rounded-md border border-border",children:l.url})}),(0,C.jsxs)(bk.DialogFooter,{children:[(0,C.jsx)(W.Button,{variant:"outline",onClick:()=>n(null),children:"Cancel"}),(0,C.jsx)(W.Button,{variant:"destructive",onClick:()=>l&&Y(l.id),disabled:!!j,children:j?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete Webhook"})]})]})}),(0,C.jsx)(bk.Dialog,{open:G,onOpenChange:a=>{a||(M([]),Q(null)),I(a)},children:(0,C.jsxs)(bk.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bk.DialogHeader,{children:[(0,C.jsx)(bk.DialogTitle,{children:"Webhook Deliveries"}),J&&(0,C.jsx)(bk.DialogDescription,{className:"font-mono text-xs truncate",children:J.url})]}),N?(0,C.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,C.jsx)(bi.default,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):L.length>0?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(ai,{children:[(0,C.jsx)(aj,{children:(0,C.jsxs)(al,{children:[(0,C.jsx)(am,{className:"w-8 pl-3 pr-0"}),(0,C.jsx)(am,{children:"Status"}),(0,C.jsx)(am,{children:"HTTP"}),(0,C.jsx)(am,{className:"text-center",children:"Attempts"}),(0,C.jsx)(am,{children:"Event"}),(0,C.jsx)(am,{children:"Created At"})]})}),(0,C.jsx)(ak,{children:L.map(a=>(0,C.jsx)(vi,{delivery:a,formatDate:aa},a.id))})]})}),P&&(0,C.jsx)("div",{className:"flex justify-center pt-2",children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:_,disabled:R,children:[R&&(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Load more"]})})]}):(0,C.jsx)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:"No deliveries yet for this webhook."})]})})]}):null}var bi=bi;function vk(){(0,E.useParams)();let a=(0,E.useRouter)(),b=(0,E.useSearchParams)(),{features:c}=(0,I.useFeatures)(),{currentBank:d,setCurrentBank:e,loadBanks:f}=(0,H.useBank)(),g=b.get("view")||"profile",h=b.get("subTab")||"world",i=b.get("bankConfigTab")||"general",j=c?.observations??!1,k=c?.bank_config_api??!1,[l,n]=(0,D.useState)(!1),[o,p]=(0,D.useState)(!1),[q,r]=(0,D.useState)(!1),[s,t]=(0,D.useState)(!1),[u,v]=(0,D.useState)(!1),[w,x]=(0,D.useState)(!1),[y,z]=(0,D.useState)(!1),[A,B]=(0,D.useState)(!1),J=b=>{a.push(`/banks/${d}?view=data&subTab=${b}`)},K=b=>{a.push(`/banks/${d}?view=profile&bankConfigTab=${b}`)},L=async()=>{if(d){p(!0);try{await V.client.deleteBank(d),n(!1),e(null),await f(),a.push("/")}catch(a){}finally{p(!1)}}},M=async()=>{if(d){t(!0);try{let a=await V.client.clearObservations(d);r(!1),F.toast.success("Success",{description:a.message||"Observations cleared successfully"})}catch(a){}finally{t(!1)}}},N=async()=>{if(d){B(!0);try{await V.client.resetBankConfig(d),z(!1)}catch{}finally{B(!1)}}},O=async()=>{if(d){v(!0);try{await V.client.triggerConsolidation(d)}catch(a){}finally{v(!1)}}},P=async()=>{if(d){x(!0);try{let a=await V.client.recoverConsolidation(d);F.toast.success(`Recovered ${a.retried_count} failed ${1===a.retried_count?"memory":"memories"} for re-consolidation`)}catch(a){}finally{x(!1)}}};return(0,C.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,C.jsx)(G.BankSelector,{}),(0,C.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,C.jsx)(U,{currentTab:g,onTabChange:b=>{a.push(`/banks/${d}?view=${b}`)}}),(0,C.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,C.jsxs)("div",{className:"p-6",children:["profile"===g&&(0,C.jsxs)("div",{children:[(0,C.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Bank Configuration"}),(0,C.jsx)("p",{className:"text-muted-foreground",children:"Manage bank settings, profile, and operations."})]}),(0,C.jsxs)(uQ,{children:[(0,C.jsx)(uS,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",children:["Actions",(0,C.jsx)(tA,{className:"w-4 h-4 ml-2"})]})}),(0,C.jsxs)(u3,{align:"end",className:"w-48",children:[(0,C.jsxs)(u4,{onClick:O,disabled:u||!j,title:j?void 0:"Observations feature is not enabled",children:[u?(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,C.jsx)(m0,{className:"w-4 h-4 mr-2"}),u?"Consolidating...":"Run Consolidation",!j&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsxs)(u4,{onClick:P,disabled:w||!j,title:j?void 0:"Observations feature is not enabled",children:[w?(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}):(0,C.jsx)(tw,{className:"w-4 h-4 mr-2"}),w?"Recovering...":"Recover Consolidation",!j&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsxs)(u4,{onClick:()=>r(!0),disabled:!j,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:j?void 0:"Observations feature is not enabled",children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations",!j&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsx)(u5,{}),(0,C.jsxs)(u4,{onClick:()=>z(!0),disabled:!k,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:k?void 0:"Bank Config API is disabled",children:[(0,C.jsx)(tw,{className:"w-4 h-4 mr-2"}),"Reset Configuration",!k&&(0,C.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,C.jsx)(u5,{}),(0,C.jsxs)(u4,{onClick:()=>n(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})]})]})]}),(0,C.jsx)("div",{className:"mb-6 border-b border-border",children:(0,C.jsxs)("div",{className:"flex gap-1",children:[(0,C.jsxs)("button",{onClick:()=>K("general"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"general"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["General","general"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),k&&(0,C.jsxs)("button",{onClick:()=>K("configuration"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"configuration"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Configuration","configuration"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>K("webhooks"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"webhooks"===i?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Webhooks","webhooks"===i&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,C.jsxs)("div",{children:["general"===i&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview statistics and background operations for this memory bank."}),(0,C.jsxs)("div",{className:"space-y-6",children:[(0,C.jsx)(tv,{}),(0,C.jsx)(ty,{}),(0,C.jsx)(sW,{hideReflectFields:!0})]})]}),"configuration"===i&&k&&(0,C.jsx)("div",{className:"space-y-6",children:(0,C.jsx)(tf,{})}),"webhooks"===i&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage webhook endpoints to receive event notifications from this memory bank."}),(0,C.jsx)(vj,{})]})]})]}),"recall"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Recall"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Analyze memory recall with detailed trace information and retrieval methods."}),(0,C.jsx)(sR,{})]}),"reflect"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Reflect"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Run an agentic loop that autonomously gathers evidence and reasons through the lens of the bank's disposition to generate contextual responses."}),(0,C.jsx)(sO,{})]}),"data"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Memories"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and explore different types of memories stored in this memory bank."}),(0,C.jsx)("div",{className:"mb-6 border-b border-border",children:(0,C.jsxs)("div",{className:"flex gap-1",children:[(0,C.jsxs)("button",{onClick:()=>J("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["World Facts","world"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>J("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Experience","experience"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>J("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Observations",!j&&(0,C.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,C.jsxs)("button",{onClick:()=>J("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===h?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Mental Models","mental-models"===h&&(0,C.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,C.jsxs)("div",{children:["world"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Objective facts about the world received from external sources."}),(0,C.jsx)(mk,{factType:"world"},"world")]}),"experience"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"The bank's own actions, interactions, and first-person experiences."}),(0,C.jsx)(mk,{factType:"experience"},"experience")]}),"observations"===h&&(j?(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Consolidated knowledge synthesized from facts — patterns, preferences, and learnings that emerge from accumulated evidence."}),(0,C.jsx)(mk,{factType:"observation"},"observations")]}):(0,C.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,C.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,C.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,C.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Z"}),(0,C.jsx)("path",{d:"M12 8v4"}),(0,C.jsx)("path",{d:"M12 16h.01"})]})}),(0,C.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"Observations Not Enabled"}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md",children:["Observations consolidation is disabled on this server. Set"," ",(0,C.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})," ","to enable."]})]})),"mental-models"===h&&(0,C.jsxs)("div",{children:[(0,C.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"User-curated summaries generated from queries — reusable knowledge snapshots that can be refreshed as memories evolve."}),(0,C.jsx)(u7,{},"mental-models")]})]})]}),"documents"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Documents"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Manage documents and retain new memories."}),(0,C.jsx)(mS,{})]}),"entities"===g&&(0,C.jsxs)("div",{children:[(0,C.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Entities"}),(0,C.jsx)("p",{className:"text-muted-foreground mb-6",children:"Explore entities (people, organizations, places) mentioned in memories."}),(0,C.jsx)(mT,{})]})]})})]}),(0,C.jsx)(ms,{open:l,onOpenChange:n,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Delete Memory Bank"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-red-600 dark:text-red-400 font-medium",children:"This action cannot be undone. All memories, entities, documents, and the bank profile will be permanently deleted."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:o,children:"Cancel"}),(0,C.jsx)(mO,{onClick:L,disabled:o,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:o?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(ms,{open:y,onOpenChange:z,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Reset Configuration"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to reset all configuration overrides for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"All per-bank settings (retain, observations, reflect) will revert to server defaults. This does not affect memories, entities, or the bank profile."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:A,children:"Cancel"}),(0,C.jsx)(mO,{onClick:N,disabled:A,children:A?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Resetting..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(tw,{className:"w-4 h-4 mr-2"}),"Reset Configuration"]})})]})]})}),(0,C.jsx)(ms,{open:q,onOpenChange:r,children:(0,C.jsxs)(mJ,{children:[(0,C.jsxs)(mK,{children:[(0,C.jsx)(mM,{children:"Clear Observations"}),(0,C.jsx)(mN,{asChild:!0,children:(0,C.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,C.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,C.jsx)("span",{className:"font-semibold text-foreground",children:d}),"?"]}),(0,C.jsx)("p",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"This will delete all consolidated knowledge. Observations will be regenerated the next time consolidation runs."})]})})]}),(0,C.jsxs)(mL,{children:[(0,C.jsx)(mP,{disabled:s,children:"Cancel"}),(0,C.jsx)(mO,{onClick:M,disabled:s,className:"bg-amber-500 text-white hover:bg-amber-600",children:s?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(bi.default,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(mQ,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})})]})}a.s(["default",()=>vk],73101)}];
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=%5Broot-of-the-server%5D__d9fd2a9b._.js.map
|