@vectorize-io/hindsight-control-plane 0.4.15 → 0.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/package.json +1 -1
  2. package/standalone/.next/BUILD_ID +1 -1
  3. package/standalone/.next/app-path-routes-manifest.json +3 -0
  4. package/standalone/.next/build-manifest.json +2 -2
  5. package/standalone/.next/prerender-manifest.json +3 -3
  6. package/standalone/.next/routes-manifest.json +26 -0
  7. package/standalone/.next/server/app/_global-error.html +2 -2
  8. package/standalone/.next/server/app/_global-error.rsc +1 -1
  9. package/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/standalone/.next/server/app/_not-found.html +1 -1
  16. package/standalone/.next/server/app/_not-found.rsc +13 -13
  17. package/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +13 -13
  18. package/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  19. package/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +8 -8
  20. package/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  21. package/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  22. package/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route/app-paths-manifest.json +3 -0
  24. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route/build-manifest.json +11 -0
  25. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route/server-reference-manifest.json +4 -0
  26. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route.js +6 -0
  27. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route.js.map +5 -0
  28. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route.js.nft.json +1 -0
  29. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/deliveries/route_client-reference-manifest.js +2 -0
  30. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route/app-paths-manifest.json +3 -0
  31. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route/build-manifest.json +11 -0
  32. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route/server-reference-manifest.json +4 -0
  33. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route.js +6 -0
  34. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route.js.map +5 -0
  35. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route.js.nft.json +1 -0
  36. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/[webhookId]/route_client-reference-manifest.js +2 -0
  37. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route/app-paths-manifest.json +3 -0
  38. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route/build-manifest.json +11 -0
  39. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route/server-reference-manifest.json +4 -0
  40. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route.js +6 -0
  41. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route.js.map +5 -0
  42. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route.js.nft.json +1 -0
  43. package/standalone/.next/server/app/api/banks/[bankId]/webhooks/route_client-reference-manifest.js +2 -0
  44. package/standalone/.next/server/app/banks/[bankId]/page_client-reference-manifest.js +1 -1
  45. package/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  46. package/standalone/.next/server/app/dashboard.html +1 -1
  47. package/standalone/.next/server/app/dashboard.rsc +7 -7
  48. package/standalone/.next/server/app/dashboard.segments/_full.segment.rsc +7 -7
  49. package/standalone/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  50. package/standalone/.next/server/app/dashboard.segments/_index.segment.rsc +6 -6
  51. package/standalone/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  52. package/standalone/.next/server/app/dashboard.segments/dashboard/__PAGE__.segment.rsc +2 -2
  53. package/standalone/.next/server/app/dashboard.segments/dashboard.segment.rsc +1 -1
  54. package/standalone/.next/server/app/index.html +1 -1
  55. package/standalone/.next/server/app/index.rsc +6 -6
  56. package/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  57. package/standalone/.next/server/app/index.segments/_full.segment.rsc +6 -6
  58. package/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  59. package/standalone/.next/server/app/index.segments/_index.segment.rsc +6 -6
  60. package/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  61. package/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  62. package/standalone/.next/server/app-paths-manifest.json +3 -0
  63. package/standalone/.next/server/chunks/[root-of-the-server]__9899ee92._.js +3 -0
  64. package/standalone/.next/server/chunks/[root-of-the-server]__c401e902._.js +3 -0
  65. package/standalone/.next/server/chunks/[root-of-the-server]__ddce25e9._.js +3 -0
  66. package/standalone/.next/server/chunks/[root-of-the-server]__f91a8834._.js +5 -5
  67. package/standalone/.next/server/chunks/a6ea4_server_app_api_banks_[bankId]_webhooks_[webhookId]_route_actions_54940b89.js +3 -0
  68. package/standalone/.next/server/chunks/e51bf__next-internal_server_app_api_banks_[bankId]_webhooks_route_actions_ca7022e3.js +3 -0
  69. package/standalone/.next/server/chunks/ffeca_app_api_banks_[bankId]_webhooks_[webhookId]_deliveries_route_actions_1de3bafc.js +3 -0
  70. package/standalone/.next/server/chunks/ssr/[root-of-the-server]__d9fd2a9b._.js +1 -1
  71. package/standalone/.next/server/chunks/ssr/_3b0b29a6._.js +1 -1
  72. package/standalone/.next/server/pages/404.html +1 -1
  73. package/standalone/.next/server/pages/500.html +2 -2
  74. package/standalone/.next/server/server-reference-manifest.js +1 -1
  75. package/standalone/.next/server/server-reference-manifest.json +1 -1
  76. package/standalone/.next/static/chunks/{2debaaba29d9e00b.js → 1a824b1a56fffa21.js} +1 -1
  77. package/standalone/.next/static/chunks/f8e18a628e7f917d.css +2 -0
  78. package/standalone/.next/static/chunks/{067bba6d015ee116.js → fdd6af635b34c0ef.js} +3 -3
  79. package/standalone/package.json +1 -1
  80. package/standalone/.next/static/chunks/437466268dbf3b1d.css +0 -2
  81. /package/standalone/.next/static/{oZpZ9tNdrBrqWP5oDlSXO → HHahG_j7euhQF4EjActW1}/_buildManifest.js +0 -0
  82. /package/standalone/.next/static/{oZpZ9tNdrBrqWP5oDlSXO → HHahG_j7euhQF4EjActW1}/_clientMiddlewareManifest.json +0 -0
  83. /package/standalone/.next/static/{oZpZ9tNdrBrqWP5oDlSXO → HHahG_j7euhQF4EjActW1}/_ssgManifest.js +0 -0
@@ -5,6 +5,6 @@ You can add a description to the \`${mp}\` by passing a \`${mw}\` 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 \`${mp}\`. 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 mC=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mo,{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}));mC.displayName=mo.displayName;let mD=D.forwardRef(({className:a,...b},c)=>(0,C.jsxs)(mn,{children:[(0,C.jsx)(mC,{}),(0,C.jsx)(mt,{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})]}));mD.displayName=mt.displayName;let mE=({className:a,...b})=>(0,C.jsx)("div",{className:(0,S.cn)("flex flex-col space-y-2 text-center sm:text-left",a),...b});mE.displayName="AlertDialogHeader";let mF=({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});mF.displayName="AlertDialogFooter";let mG=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mv,{ref:c,className:(0,S.cn)("text-lg font-semibold",a),...b}));mG.displayName=mv.displayName;let mH=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mx,{ref:c,className:(0,S.cn)("text-sm text-muted-foreground",a),...b}));mH.displayName=mx.displayName;let mI=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(my,{ref:c,className:(0,S.cn)((0,W.buttonVariants)(),a),...b}));mI.displayName=my.displayName;let mJ=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(mA,{ref:c,className:(0,S.cn)((0,W.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",a),...b}));mJ.displayName=mA.displayName;let mK=(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"}]]);function mL(){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)(null),[w,x]=(0,D.useState)(null),y=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)}}},z=a=>{k(a),y(a)},A=async b=>{if(a){r(!0),p({id:b});try{let c=await V.client.getDocument(b,a);p(c)}catch(a){p(null)}finally{r(!1)}}},B=async()=>{if(!a||!u)return;let b=u.id;t(b),v(null);try{let c=await V.client.deleteDocument(b,a);x({success:!0,message:`Deleted document and ${c.memory_units_deleted} memory units.`}),o?.id===b&&p(null),y(j)}catch(a){console.error("Error deleting document:",a),x({success:!1,message:"Error deleting document: "+a.message})}finally{t(null)}};return(0,D.useEffect)(()=>{a&&(k(1),y(1))},[a]),(0,D.useEffect)(()=>{if(!a)return;let b=setTimeout(()=>{k(1),y(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:()=>A(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:()=>z(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:()=>z(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:()=>z(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:()=>z(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)})]})]})]}),o.tags&&o.tags.length>0&&(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:"Tags"}),(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:"pt-2 border-t border-border",children:(0,C.jsxs)(W.Button,{variant:"destructive",size:"sm",onClick:()=>{v({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)(mK,{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)(mm,{open:!!u,onOpenChange:a=>!a&&v(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Document"}),(0,C.jsxs)(mH,{children:["Are you sure you want to delete document"," ",(0,C.jsxs)("span",{className:"font-mono font-semibold",children:['"',u?.id,'"']}),"?",(0,C.jsx)("br",{}),(0,C.jsx)("br",{}),"This will also delete"," ",u?.memoryCount!==void 0?(0,C.jsxs)("span",{className:"font-semibold",children:[u.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)(mF,{children:[(0,C.jsx)(mJ,{children:"Cancel"}),(0,C.jsx)(mI,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),(0,C.jsx)(mm,{open:!!w,onOpenChange:a=>!a&&x(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:w?.success?"Document Deleted":"Error"}),(0,C.jsx)(mH,{children:w?.message})]}),(0,C.jsx)(mF,{children:(0,C.jsx)(mI,{onClick:()=>x(null),children:"OK"})})]})})]})}function mM(){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 mN=a.i(99295),mO=a.i(4212);let mP=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}));mP.displayName="Card";let mQ=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}));mQ.displayName="CardHeader";let mR=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}));mR.displayName="CardTitle";let mS=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm text-muted-foreground",a),...b}));mS.displayName="CardDescription";let mT=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("p-6 pt-0",a),...b}));mT.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 mU=a.i(97063);let mV=(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"}]]),mW=(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"}]]),mX=(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"}]]),mY=(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 mZ=a.i(6219);"function"==typeof SuppressedError&&SuppressedError;var m$=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()}},m_={"text/plain":"Text","text/html":"Url",default:"Text"},m0=function(a,b){var c,d,e,f,g,h,i,j,k=!1;b||(b={}),e=b.debug||!1;try{if(g=m$(),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=m_[b.format]||m_.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 m1(a){return"[object Object]"===Object.prototype.toString.call(a)}function m2(a){return Array.isArray(a)?a.length:m1(a)?Object.keys(a).length:0}function m3(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=m2(a);if("function"==typeof d){let e=m6(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||m1(a)&&g>e)}function m4(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=m6(d,[{node:a,depth:b,indexOrName:c,size:g}]);if("boolean"==typeof e)return e}return!!(Array.isArray(a)&&g>e||m1(a)&&g>e)}function m5(a,b,c){return"boolean"==typeof a?a:"number"==typeof a&&!!(b>a)||"collapsed"===a&&!!c||"expanded"===a&&!c}function m6(a,b){try{return a(...b)}catch(a){reportError(a)}}function m7(a){if(!0===a||m1(a)&&!0===a.add)return!0}function m8(a){if(!0===a||m1(a)&&!0===a.edit)return!0}function m9(a){if(!0===a||m1(a)&&!0===a.delete)return!0}function na(a){return!a||void 0===a.add||!!a.add}function nb(a){return!a||void 0===a.edit||!!a.edit}function nc(a){return!a||void 0===a.delete||!!a.delete}function nd(a){return!a||void 0===a.enableClipboard||!!a.enableClipboard}function ne(){return(ne=Object.assign.bind()).apply(this,arguments)}var nf=function(a){return D.createElement("svg",ne({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 ng(){return(ng=Object.assign.bind()).apply(this,arguments)}var nh=function(a){return D.createElement("svg",ng({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 ni(){return(ni=Object.assign.bind()).apply(this,arguments)}var nj=function(a){return D.createElement("svg",ni({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 nk({node:a,nodeMeta:b}){let{customizeCopy:c,CopyComponent:d,CopiedComponent:e}=(0,D.useContext)(nE),[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){m0(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)(nj,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof d?(0,C.jsx)(d,{onClick:h,className:"json-view--copy"}):(0,C.jsx)(nh,{onClick:h,className:"json-view--copy"})}function nl({indexOrName:a,value:b,depth:c,deleteHandle:d,editHandle:e,parent:f,parentPath:g}){let{displayArrayIndex:h}=(0,D.useContext)(nE),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)(nC,{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 nm(){return(nm=Object.assign.bind()).apply(this,arguments)}var nn=function(a){return D.createElement("svg",nm({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 no(){return(no=Object.assign.bind()).apply(this,arguments)}var np=function(a){return D.createElement("svg",no({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 nq(){return(nq=Object.assign.bind()).apply(this,arguments)}var nr=function(a){return D.createElement("svg",nq({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 ns(){return(ns=Object.assign.bind()).apply(this,arguments)}var nt=function(a){return D.createElement("svg",ns({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 nu({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)(nE),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:[m5(p,c,s)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[m2(b)," Items"]})),(0,C.jsx)(nf,{className:"jv-chevron"})]})),!s&&j&&nd(f)&&(0,C.jsx)(nk,{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)(nl,{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 nv({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)(nE),[v,w]=(0,D.useState)(m4(a,b,d,j,l,e));(0,D.useEffect)(()=>{w(m4(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:[m5(u,b,v)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[a.length," Items"]})),(0,C.jsx)(nf,{className:"jv-chevron"})]})),E&&(0,C.jsx)(nr,{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)(nt,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{y(!1),A(!1)}}),!v&&!E&&k&&nd(e)&&(0,C.jsx)(nk,{node:a,nodeMeta:{depth:b,indexOrName:d,parent:f,parentPath:g,currentPath:h}}),!v&&!E&&m7(n)&&na(e)&&(0,C.jsx)(np,{className:"json-view--edit",onClick:()=>{B()}}),!v&&!E&&m9(n)&&nc(e)&&c&&(0,C.jsx)(nn,{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)(nu,{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&&m5(u,b,v)&&(0,C.jsxs)("span",Object.assign({onClick:()=>w(!1),className:"jv-size"},{children:[a.length," Items"]}))]})}function nw({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)(nE),w=void 0!==c?[...g,String(c)]:g;if(!k&&Array.isArray(a)&&a.length>100)return(0,C.jsx)(nv,{node:a,depth:b,indexOrName:c,deleteHandle:d,customOptions:e,parentPath:w});let x=m1(a),[y,z]=(0,D.useState)(m3(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(m3(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:[m5(u,b,y)&&(0,C.jsxs)("span",Object.assign({className:"jv-size"},{children:[m2(a)," Items"]})),(0,C.jsx)(nf,{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)(nr,{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)(nt,{className:"json-view--edit",style:{display:"inline-block"},onClick:M}),!y&&!L&&j&&nd(e)&&(0,C.jsx)(nk,{node:a,nodeMeta:{depth:b,indexOrName:c,parent:f,parentPath:g,currentPath:w}}),!y&&!L&&m7(n)&&na(e)&&(0,C.jsx)(np,{className:"json-view--edit",onClick:()=>{x?(I(!0),setTimeout(()=>{var a;return null==(a=J.current)?void 0:a.focus()})):K()}}),!y&&!L&&m9(n)&&nc(e)&&d&&(0,C.jsx)(nn,{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)(nl,{indexOrName:e,value:d,depth:b,parent:a,deleteHandle:E,editHandle:B,parentPath:w},String(c)+String(e)))})),(0,C.jsx)("span",{children:"]"}),y&&m5(u,b,y)&&(0,C.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[m2(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)(nl,{indexOrName:d,value:e,depth:b,parent:a,deleteHandle:E,editHandle:B,parentPath:w},String(c)+String(d)))})),(0,C.jsx)("span",{children:"}"}),y&&m5(u,b,y)&&(0,C.jsxs)("span",Object.assign({onClick:()=>A(!1),className:"jv-size"},{children:[m2(a)," Items"]}))]}):(0,C.jsx)("span",{children:String(a)})}let nx=D.default.forwardRef(({str:a,className:b,ctrlClick:c},d)=>{let{collapseStringMode:e,collapseStringsAfterLength:f,customizeCollapseStringUI:g}=(0,D.useContext)(nE),[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 ny(){return(ny=Object.assign.bind()).apply(this,arguments)}var nz=function(a){return D.createElement("svg",ny({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 nA(){return(nA=Object.assign.bind()).apply(this,arguments)}var nB=function(a){return D.createElement("svg",nA({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 nC({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)(nE);if("function"==typeof p&&(h=m6(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)||m1(a))return(0,C.jsx)(nw,{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&&m8(k)&&nb(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)(nr,{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)(nt,{className:"json-view--edit",style:{display:"inline-block"},onClick:H})),!K&&j&&nd(h)&&(0,C.jsx)(nk,{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)(nB,{})})),!K&&m8(k)&&nb(h)&&f&&("function"==typeof s?(0,C.jsx)(s,{className:"json-view--edit",onClick:F}):(0,C.jsx)(nz,{className:"json-view--edit",onClick:F})),!K&&m9(k)&&nc(h)&&c&&(0,C.jsx)(nn,{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)(nx,{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 nD=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,nE=(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:nD,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function nF({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=nD,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)(nE.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)(nC,{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 nG=a.i(28094),bi=bi;let nH=(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 nI(){}function nJ(){}let nK=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nM={};function nN(a,b){return((b||nM).jsx?nL:nK).test(a)}let nO=/[ \t\n\f\r]/g;function nP(a){return""===a.replace(nO,"")}class nQ{constructor(a,b){this.attribute=b,this.property=a}}nQ.prototype.attribute="",nQ.prototype.booleanish=!1,nQ.prototype.boolean=!1,nQ.prototype.commaOrSpaceSeparated=!1,nQ.prototype.commaSeparated=!1,nQ.prototype.defined=!1,nQ.prototype.mustUseProperty=!1,nQ.prototype.number=!1,nQ.prototype.overloadedBoolean=!1,nQ.prototype.property="",nQ.prototype.spaceSeparated=!1,nQ.prototype.space=void 0;let nR=0,nS=nZ(),nT=nZ(),nU=nZ(),nV=nZ(),nW=nZ(),nX=nZ(),nY=nZ();function nZ(){return 2**++nR}a.s(["boolean",0,nS,"booleanish",0,nT,"commaOrSpaceSeparated",0,nY,"commaSeparated",0,nX,"number",0,nV,"overloadedBoolean",0,nU,"spaceSeparated",0,nW],53427);var n$=a.i(53427);let n_=Object.keys(n$);class n0 extends nQ{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<n_.length;){const a=n_[e];!function(a,b,c){c&&(a[b]=c)}(this,n_[e],(c&n$[a])===n$[a])}}}function n1(a){return a.toLowerCase()}n0.prototype.defined=!0;let n2=/[A-Z]/g,n3=/-[a-z]/g,n4=/^data[-\w.:]+$/i;function n5(a){return"-"+a.toLowerCase()}function n6(a){return a.charAt(1).toUpperCase()}let n7={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 n8{constructor(a,b,c){this.normal=b,this.property=a,c&&(this.space=c)}}function n9(a,b){let c={},d={};for(let b of a)Object.assign(c,b.property),Object.assign(d,b.normal);return new n8(c,d,b)}function oa(a){let b={},c={};for(let[d,e]of Object.entries(a.properties)){let f=new n0(d,a.transform(a.attributes||{},d),e,a.space);a.mustUseProperty&&a.mustUseProperty.includes(d)&&(f.mustUseProperty=!0),b[d]=f,c[n1(d)]=d,c[n1(f.attribute)]=d}return new n8(b,c,a.space)}n8.prototype.normal={},n8.prototype.property={},n8.prototype.space=void 0;let ob=oa({properties:{ariaActiveDescendant:null,ariaAtomic:nT,ariaAutoComplete:null,ariaBusy:nT,ariaChecked:nT,ariaColCount:nV,ariaColIndex:nV,ariaColSpan:nV,ariaControls:nW,ariaCurrent:null,ariaDescribedBy:nW,ariaDetails:null,ariaDisabled:nT,ariaDropEffect:nW,ariaErrorMessage:null,ariaExpanded:nT,ariaFlowTo:nW,ariaGrabbed:nT,ariaHasPopup:null,ariaHidden:nT,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nW,ariaLevel:nV,ariaLive:null,ariaModal:nT,ariaMultiLine:nT,ariaMultiSelectable:nT,ariaOrientation:null,ariaOwns:nW,ariaPlaceholder:null,ariaPosInSet:nV,ariaPressed:nT,ariaReadOnly:nT,ariaRelevant:null,ariaRequired:nT,ariaRoleDescription:nW,ariaRowCount:nV,ariaRowIndex:nV,ariaRowSpan:nV,ariaSelected:nT,ariaSetSize:nV,ariaSort:null,ariaValueMax:nV,ariaValueMin:nV,ariaValueNow:nV,ariaValueText:null,role:null},transform:(a,b)=>"role"===b?b:"aria-"+b.slice(4).toLowerCase()});function oc(a,b){return b in a?a[b]:b}function od(a,b){return oc(a,b.toLowerCase())}let oe=oa({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:nX,acceptCharset:nW,accessKey:nW,action:null,allow:null,allowFullScreen:nS,allowPaymentRequest:nS,allowUserMedia:nS,alt:null,as:null,async:nS,autoCapitalize:null,autoComplete:nW,autoFocus:nS,autoPlay:nS,blocking:nW,capture:null,charSet:null,checked:nS,cite:null,className:nW,cols:nV,colSpan:null,content:null,contentEditable:nT,controls:nS,controlsList:nW,coords:nV|nX,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nS,defer:nS,dir:null,dirName:null,disabled:nS,download:nU,draggable:nT,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nS,formTarget:null,headers:nW,height:nV,hidden:nU,high:nV,href:null,hrefLang:null,htmlFor:nW,httpEquiv:nW,id:null,imageSizes:null,imageSrcSet:null,inert:nS,inputMode:null,integrity:null,is:null,isMap:nS,itemId:null,itemProp:nW,itemRef:nW,itemScope:nS,itemType:nW,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nS,low:nV,manifest:null,max:null,maxLength:nV,media:null,method:null,min:null,minLength:nV,multiple:nS,muted:nS,name:null,nonce:null,noModule:nS,noValidate:nS,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:nS,optimum:nV,pattern:null,ping:nW,placeholder:null,playsInline:nS,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nS,referrerPolicy:null,rel:nW,required:nS,reversed:nS,rows:nV,rowSpan:nV,sandbox:nW,scope:null,scoped:nS,seamless:nS,selected:nS,shadowRootClonable:nS,shadowRootDelegatesFocus:nS,shadowRootMode:null,shape:null,size:nV,sizes:null,slot:null,span:nV,spellCheck:nT,src:null,srcDoc:null,srcLang:null,srcSet:null,start:nV,step:null,style:null,tabIndex:nV,target:null,title:null,translate:null,type:null,typeMustMatch:nS,useMap:null,value:nT,width:nV,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nW,axis:null,background:null,bgColor:null,border:nV,borderColor:null,bottomMargin:nV,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nS,declare:nS,event:null,face:null,frame:null,frameBorder:null,hSpace:nV,leftMargin:nV,link:null,longDesc:null,lowSrc:null,marginHeight:nV,marginWidth:nV,noResize:nS,noHref:nS,noShade:nS,noWrap:nS,object:null,profile:null,prompt:null,rev:null,rightMargin:nV,rules:null,scheme:null,scrolling:nT,standby:null,summary:null,text:null,topMargin:nV,valueType:null,version:null,vAlign:null,vLink:null,vSpace:nV,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nS,disableRemotePlayback:nS,prefix:null,property:null,results:nV,security:null,unselectable:null},space:"html",transform:od}),of=oa({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:nY,accentHeight:nV,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:nV,amplitude:nV,arabicForm:null,ascent:nV,attributeName:null,attributeType:null,azimuth:nV,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:nV,by:null,calcMode:null,capHeight:nV,className:nW,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:nV,diffuseConstant:nV,direction:null,display:null,dur:null,divisor:nV,dominantBaseline:null,download:nS,dx:null,dy:null,edgeMode:null,editable:null,elevation:nV,enableBackground:null,end:null,event:null,exponent:nV,externalResourcesRequired:null,fill:null,fillOpacity:nV,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:nX,g2:nX,glyphName:nX,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:nV,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:nV,horizOriginX:nV,horizOriginY:nV,id:null,ideographic:nV,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:nV,k:nV,k1:nV,k2:nV,k3:nV,k4:nV,kernelMatrix:nY,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:nV,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:nV,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:nV,overlineThickness:nV,paintOrder:null,panose1:null,path:null,pathLength:nV,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nW,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:nV,pointsAtY:nV,pointsAtZ:nV,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:nY,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:nY,rev:nY,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:nY,requiredFeatures:nY,requiredFonts:nY,requiredFormats:nY,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:nV,specularExponent:nV,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:nV,strikethroughThickness:nV,string:null,stroke:null,strokeDashArray:nY,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:nV,strokeOpacity:nV,strokeWidth:null,style:null,surfaceScale:nV,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:nY,tabIndex:nV,tableValues:null,target:null,targetX:nV,targetY:nV,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:nY,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:nV,underlineThickness:nV,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:nV,values:null,vAlphabetic:nV,vMathematical:nV,vectorEffect:null,vHanging:nV,vIdeographic:nV,version:null,vertAdvY:nV,vertOriginX:nV,vertOriginY:nV,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:nV,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oc}),og=oa({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()}),oh=oa({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:od}),oi=oa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(a,b)=>"xml:"+b.slice(3).toLowerCase()}),oj=n9([ob,oe,og,oh,oi],"html"),ok=n9([ob,of,og,oh,oi],"svg");var ol=a.i(52540);let om=oo("end"),on=oo("start");function oo(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 op(a){return a&&"object"==typeof a?"position"in a||"type"in a?or(a.position):"start"in a||"end"in a?or(a):"line"in a||"column"in a?oq(a):"":""}function oq(a){return os(a&&a.line)+":"+os(a&&a.column)}function or(a){return oq(a&&a.start)+"-"+oq(a&&a.end)}function os(a){return a&&"number"==typeof a?a:1}class ot 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=op(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}}ot.prototype.file="",ot.prototype.name="",ot.prototype.reason="",ot.prototype.message="",ot.prototype.stack="",ot.prototype.column=void 0,ot.prototype.line=void 0,ot.prototype.ancestors=void 0,ot.prototype.cause=void 0,ot.prototype.fatal=void 0,ot.prototype.place=void 0,ot.prototype.ruleId=void 0,ot.prototype.source=void 0;let ou={}.hasOwnProperty,ov=new Map,ow=/[A-Z]/g,ox=new Set(["table","tbody","thead","tfoot","tr"]),oy=new Set(["td","th"]),oz="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function oA(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=ok),d.ancestors.push(e),p=oE(d,e.tagName,!1),q=function(a,b){let c,d,e={};for(d in b.properties)if("children"!==d&&ou.call(b.properties,d)){let f=function(a,b,c){let d=function(a,b){let c=n1(b),d=b,e=nQ;if(c in a.normal)return a.property[a.normal[c]];if(c.length>4&&"data"===c.slice(0,4)&&n4.test(b)){if("-"===b.charAt(4)){let a=b.slice(5).replace(n3,n6);d="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{let a=b.slice(4);if(!n3.test(a)){let c=a.replace(n2,n5);"-"!==c.charAt(0)&&(c="-"+c),b="data"+c}}e=n0}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,ol.default)(b,{reactCompat:!0})}catch(c){if(a.ignoreInvalidStyle)return{};let b=new ot("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=oz+"#cannot-parse-style-attribute",b}}(a,String(c));return"css"===a.stylePropertyNameCase&&(b=function(a){let b,c={};for(b in a)ou.call(a,b)&&(c[function(a){let b=a.replace(ow,oG);return"ms-"===b.slice(0,3)&&(b="-"+b),b}(b)]=a[b]);return c}(b)),["style",b]}return["react"===a.elementAttributeNameCase&&d.space?n7[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&&oy.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=oD(d,e),ox.has(e.tagName)&&(r=r.filter(function(a){return"string"!=typeof a||!("object"==typeof a?"text"===a.type&&nP(a.value):nP(a))})),oB(d,q,p,e),oC(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 nI("ExpressionStatement"===c.type),a.evaluater.evaluateExpression(c.expression)}oF(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=ok),g.ancestors.push(h),u=null===h.name?g.Fragment:oE(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];nI("ExpressionStatement"===b.type);let e=b.expression;nI("ObjectExpression"===e.type);let f=e.properties[0];nI("SpreadElement"===f.type),Object.assign(c,a.evaluater.evaluateExpression(f.argument))}else oF(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];nI("ExpressionStatement"===b.type),e=a.evaluater.evaluateExpression(b.expression)}else oF(a,b.position);else e=null===d.value||d.value;c[f]=e}return c}(g,h),w=oD(g,h),oB(g,v,u,h),oC(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);oF(a,b.position)}(a,b):"root"===b.type?(j=a,k=b,l=c,oC(x={},oD(j,k)),j.create(k,j.Fragment,x,l)):"text"===b.type?b.value:void 0}function oB(a,b,c,d){"string"!=typeof c&&c!==a.Fragment&&a.passNode&&(b.node=d)}function oC(a,b){if(b.length>0){let c=b.length>1?b:b[0];c&&(a.children=c)}}function oD(a,b){let c=[],d=-1,e=a.passKeys?new Map:ov;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=oA(a,g,f);void 0!==h&&c.push(h)}return c}function oE(a,b,c){let d;if(c)if(b.includes(".")){let a,c=b.split("."),e=-1;for(;++e<c.length;){let b=nN(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}nI(a,"always a result"),d=a}else d=nN(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 ou.call(a.components,b)?a.components[b]:b}if(a.evaluater)return a.evaluater.evaluateExpression(d);oF(a)}function oF(a,b){let c=new ot("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=oz+"#cannot-handle-mdx-estrees-without-createevaluater",c}function oG(a){return"-"+a.toLowerCase()}let oH={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"]},oI={};function oJ(a,b){let c=b||oI;return oK(a,"boolean"!=typeof c.includeImageAlt||c.includeImageAlt,"boolean"!=typeof c.includeHtml||c.includeHtml)}function oK(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 oL(a.children,b,c)}return Array.isArray(a)?oL(a,b,c):""}function oL(a,b,c){let d=[],e=-1;for(;++e<a.length;)d[e]=oK(a[e],b,c);return d.join("")}function oM(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 oN(a,b){return a.length>0?(oM(a,a.length,0,b),a):b}let oO={}.hasOwnProperty;function oP(a){let b={},c=-1;for(;++c<a.length;)!function(a,b){let c;for(c in b){let d,e=(oO.call(a,c)?a[c]:void 0)||(a[c]={}),f=b[c];if(f)for(d in f){oO.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]);oM(a,0,0,d)}(e[d],Array.isArray(a)?a:a?[a]:[])}}}(b,a[c]);return b}function oQ(a){return null!==a&&a<-2}function oR(a){return -2===a||-1===a||32===a}function oS(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function oT(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return oR(d)?(a.enter(c),function d(g){return oR(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}oS(/[A-Za-z]/),oS(/[\dA-Za-z]/),oS(/[#-'*+\--9=?A-Z^-~]/),oS(/\d/),oS(/[\dA-Fa-f]/),oS(/[!-/:-@[-`{-~]/),oS(/\p{P}|\p{S}/u),oS(/\s/);let oU={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"),oT(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 oQ(d)?(a.consume(d),a.exit("chunkText"),c):(a.consume(d),b)}(d)}(c)});return c}},oV={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 oM(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(oW,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(oW,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 oQ(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++;oM(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}}},oW={tokenize:function(a,b,c){return oT(a,a.attempt(this.parser.constructs.document,b,c),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},oX=o4(/[A-Za-z]/),oY=o4(/[\dA-Za-z]/),oZ=o4(/[#-'*+\--9=?A-Z^-~]/),o$=o4(/\d/),o_=o4(/[\dA-Fa-f]/),o0=o4(/[!-/:-@[-`{-~]/);function o1(a){return null!==a&&a<-2}function o2(a){return null!==a&&(a<0||32===a)}function o3(a){return -2===a||-1===a||32===a}function o4(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function o5(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return o3(d)?(a.enter(c),function d(g){return o3(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}o4(/\p{P}|\p{S}/u),o4(/\s/);let o6={partial:!0,tokenize:function(a,b,c){return function(b){return o3(b)?o5(a,d,"linePrefix")(b):d(b)};function d(a){return null===a||o1(a)?b(a):c(a)}}};class o7{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&&o8(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),o8(this.left,a)}unshift(a){this.setCursor(0),this.right.push(a)}unshiftMany(a){this.setCursor(0),o8(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);o8(this.right,b.reverse())}else{let b=this.right.splice(this.left.length+this.right.length-a,1/0);o8(this.left,b.reverse())}}}function o8(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 o9(a){let b,c,d,e,f,g,h,i={},j=-1,k=new o7(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 oM(a,0,1/0,k.slice(0)),!h}let pa={resolve:function(a){return o9(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):o1(b)?a.check(pb,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}}},pb={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"),o5(a,e,"linePrefix")};function e(e){if(null===e||o1(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)}}},pc={tokenize:function(a){let b=this,c=a.attempt(o6,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,oT(a,a.attempt(this.parser.constructs.flow,d,a.attempt(pa,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)}}},pd={resolveAll:ph()},pe=pg("string"),pf=pg("text");function pg(a){return{resolveAll:ph("text"===a?pi: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 ph(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 pi(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}pl(/[A-Za-z]/),pl(/[\dA-Za-z]/),pl(/[#-'*+\--9=?A-Z^-~]/),pl(/\d/),pl(/[\dA-Fa-f]/),pl(/[!-/:-@[-`{-~]/);let pj=pl(/\p{P}|\p{S}/u),pk=pl(/\s/);function pl(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pm(a){return null===a||null!==a&&(a<0||32===a)||pk(a)?1:pj(a)?2:void 0}function pn(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 po={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};pp(l,-h),pp(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=oN(i,[["enter",a[c][1],b],["exit",a[c][1],b]])),i=oN(i,[["enter",d,b],["enter",f,b],["exit",f,b],["enter",e,b]]),i=oN(i,pn(b.parser.constructs.insideSpan.null,a.slice(c+1,k),b)),i=oN(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=oN(i,[["enter",a[k][1],b],["exit",a[k][1],b]])):j=0,oM(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=pm(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=pm(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 pp(a,b){a.column+=b,a.offset+=b,a._bufferIndex+=b}let pq={continuation:{tokenize:function(a,b,c){let d=this;return function(b){return o3(b)?o5(a,e,"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):e(b)};function e(d){return a.attempt(pq,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 o3(c)?(a.enter("blockQuotePrefixWhitespace"),a.consume(c),a.exit("blockQuotePrefixWhitespace"),a.exit("blockQuotePrefix"),b):(a.exit("blockQuotePrefix"),b(c))}}},pr={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 o0(d)?(a.enter("characterEscapeValue"),a.consume(d),a.exit("characterEscapeValue"),a.exit("characterEscape"),b):c(d)}}},ps={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:"‌"},pt={}.hasOwnProperty;function pu(a){return!!pt.call(ps,a)&&ps[a]}let pv={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=oY,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=o_,j):(a.enter("characterReferenceValue"),d=7,e=o$,j(b))}function j(h){if(59===h&&g){let d=a.exit("characterReferenceValue");return e!==oY||pu(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)}}},pw={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)}}},px={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"),o3(b)?o5(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"),o3(e)?o5(a,j,"whitespace")(e):j(e)):c(e)}(b)):c(b)}function j(d){return null===d||o1(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"),o3(e)?o5(a,i,"whitespace")(e):i(e))}(f)};function i(f){return null===f||o1(f)?(a.exit("codeFencedFence"),e.interrupt?b(f):a.check(pw,k,p)(f)):(a.enter("codeFencedFenceInfo"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||o1(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),i(e)):o3(e)?(a.exit("chunkString"),a.exit("codeFencedFenceInfo"),o5(a,j,"whitespace")(e)):96===e&&e===d?c(e):(a.consume(e),b)}(f))}function j(b){return null===b||o1(b)?i(b):(a.enter("codeFencedFenceMeta"),a.enter("chunkString",{contentType:"string"}),function b(e){return null===e||o1(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&&o3(b)?o5(a,o,"linePrefix",g+1)(b):o(b)}function o(b){return null===b||o1(b)?a.check(pw,k,p)(b):(a.enter("codeFlowValue"),function b(c){return null===c||o1(c)?(a.exit("codeFlowValue"),o(c)):(a.consume(c),b)}(b))}function p(c){return a.exit("codeFenced"),b(c)}}},py={name:"codeIndented",tokenize:function(a,b,c){let d=this;return function(b){return a.enter("codeIndented"),o5(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):o1(c)?a.attempt(pz,b,f)(c):(a.enter("codeFlowValue"),function c(d){return null===d||o1(d)?(a.exit("codeFlowValue"),b(d)):(a.consume(d),c)}(c))}(b):c(b)}function f(c){return a.exit("codeIndented"),b(c)}}},pz={partial:!0,tokenize:function(a,b,c){let d=this;return e;function e(b){return d.parser.lazy[d.now().line]?c(b):o1(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),e):o5(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):o1(a)?e(a):c(a)}}};function pA(a){return null!==a&&(a<32||127===a)}function pB(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pC(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||pA(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||pA(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 pD(a){return null!==a&&a<-2}function pE(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pF(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):pD(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||pD(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 pG(a){return null!==a&&a<-2}function pH(a){return -2===a||-1===a||32===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){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(pG(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 pH(b)?(a.enter(e),function b(g){return pH(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||pG(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 pK(a){return -2===a||-1===a||32===a}function pL(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function pM(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(pK(e)){let b,h;return(f=d,g=c?"linePrefix":"lineSuffix",b=1/0,h=0,function(c){return pK(c)?(a.enter(g),function c(d){return pK(d)&&h++<b?(a.consume(d),c):(a.exit(g),f(d))}(c)):f(c)})(e)}return b(e)}}function pN(a){return a.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}pB(/[A-Za-z]/),pB(/[\dA-Za-z]/),pB(/[#-'*+\--9=?A-Z^-~]/),pB(/\d/),pB(/[\dA-Fa-f]/),pB(/[!-/:-@[-`{-~]/),pB(/\p{P}|\p{S}/u),pB(/\s/),pE(/[A-Za-z]/),pE(/[\dA-Za-z]/),pE(/[#-'*+\--9=?A-Z^-~]/),pE(/\d/),pE(/[\dA-Fa-f]/),pE(/[!-/:-@[-`{-~]/),pE(/\p{P}|\p{S}/u),pE(/\s/),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/);let pO={partial:!0,tokenize:function(a,b,c){return function(b){return o2(b)?pM(a,d)(b):c(b)};function d(b){return pJ(a,e,c,"definitionTitle","definitionTitleMarker","definitionTitleString")(b)}function e(b){return o3(b)?o5(a,f,"whitespace")(b):f(b)}function f(a){return null===a||o1(a)?b(a):c(a)}}},pP=["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"],pQ=["pre","script","style","textarea"],pR={partial:!0,tokenize:function(a,b,c){return function(d){return a.enter("lineEnding"),a.consume(d),a.exit("lineEnding"),a.attempt(o6,b,c)}}},pS={partial:!0,tokenize:function(a,b,c){let d=this;return function(b){return o1(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)}}},pT={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&&oM(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=oN(f=[["enter",i,b],["enter",j,b]],a.slice(d+1,d+h+3)),f=oN(f,[["enter",k,b]]),f=oN(f,pn(b.parser.constructs.insideSpan.null,a.slice(d+h+4,e-3),b)),f=oN(f,[["exit",k,b],a[e-2],a[e-1],["exit",j,b]]),f=oN(f,a.slice(e+1)),f=oN(f,[["exit",i,b]]),oM(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(pN(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(pU,j,e?j:k)(b):91===b?a.attempt(pV,j,e?i:k)(b):e?j(b):k(b)}function i(b){return a.attempt(pW,j,k)(b)}function j(a){return b(a)}function k(a){return d._balanced=!0,c(a)}}},pU={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 o2(b)?pM(a,e)(b):e(b)}function e(b){return 41===b?j(b):pC(a,f,g,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function f(b){return o2(b)?pM(a,h)(b):j(b)}function g(a){return c(a)}function h(b){return 34===b||39===b||40===b?pJ(a,i,c,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):j(b)}function i(b){return o2(b)?pM(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)}}},pV={tokenize:function(a,b,c){let d=this;return function(b){return pF.call(d,a,e,f,"reference","referenceMarker","referenceString")(b)};function e(a){return d.parser.defined.includes(pN(d.sliceSerialize(d.events[d.events.length-1][1]).slice(1,-1)))?b(a):c(a)}function f(a){return c(a)}}},pW={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)}}},pX={name:"labelStartImage",resolveAll:pT.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)}}},pY={name:"labelStartLink",resolveAll:pT.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)}}},pZ={name:"lineEnding",tokenize:function(a,b){return function(c){return a.enter("lineEnding"),a.consume(c),a.exit("lineEnding"),o5(a,b,"linePrefix")}}},p$={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"),o3(c)?o5(a,f,"whitespace")(c):f(c))}(g)):e>=3&&(null===g||o1(g))?(a.exit("thematicBreak"),b(g)):c(g)}(g)}}},p_={continuation:{tokenize:function(a,b,c){let d=this;return d.containerState._closeFlow=void 0,a.check(o6,function(c){return d.containerState.furtherBlankLines=d.containerState.furtherBlankLines||d.containerState.initialBlankLine,o5(a,b,"listItemIndent",d.containerState.size+1)(c)},function(c){return d.containerState.furtherBlankLines||!o3(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(p1,b,e)(c))});function e(e){return d.containerState._closeFlow=!0,d.interrupt=void 0,o5(a,a.attempt(p_,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:o$(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(p$,c,h)(b):h(b);if(!d.interrupt||49===b)return a.enter("listItemPrefix"),a.enter("listItemValue"),function b(e){return o$(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(o6,d.interrupt?c:i,a.attempt(p0,k,j))}function i(a){return d.containerState.initialBlankLine=!0,f++,k(a)}function j(b){return o3(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)}}},p0={partial:!0,tokenize:function(a,b,c){let d=this;return o5(a,function(a){let e=d.events[d.events.length-1];return!o3(a)&&e&&"listItemPrefixWhitespace"===e[1].type?b(a):c(a)},"listItemPrefixWhitespace",d.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},p1={partial:!0,tokenize:function(a,b,c){let d=this;return o5(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)}},p2={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"),o3(c)?o5(a,f,"lineSuffix")(c):f(c))}(g)):c(b)};function f(d){return null===d||o1(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,pF.call(e,a,f,c,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)};function f(b){return(d=pN(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 o2(b)?pM(a,h)(b):h(b)}function h(b){return pC(a,i,c,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function i(b){return a.attempt(pO,j,j)(b)}function j(b){return o3(b)?o5(a,k,"whitespace")(b):k(b)}function k(f){return null===f||o1(f)?(a.exit("definition"),e.parser.defined.push(d),b(f)):c(f)}}}},"disable",0,{null:[]},"document",0,{42:p_,43:p_,45:p_,48:p_,49:p_,50:p_,51:p_,52:p_,53:p_,54:p_,55:p_,56:p_,57:p_,62:pq},"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"},oM(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||o2(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||o1(d)?(a.exit("atxHeading"),b(d)):o3(d)?o5(a,c,"whitespace")(d):(a.enter("atxHeadingText"),function b(d){return null===d||35===d||o2(d)?(a.exit("atxHeadingText"),c(d)):(a.consume(d),b)}(d))}(f)):c(f)}(f)}}},42:p$,45:[p2,p$],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):oX(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):oX(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 oX(b)?(a.consume(b),f=String.fromCharCode(b),p):c(b)}function p(g){if(null===g||47===g||62===g||o2(g)){let h=47===g,j=f.toLowerCase();return!h&&!e&&pQ.includes(j)?(d=1,i.interrupt?b(g):z(g)):pP.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 o3(c)?(a.consume(c),b):x(c)}(g):r(g))}return 45===g||oY(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||oX(b)?(a.consume(b),s):o3(b)?(a.consume(b),r):x(b)}function s(b){return 45===b||46===b||58===b||95===b||oY(b)?(a.consume(b),s):t(b)}function t(b){return 61===b?(a.consume(b),u):o3(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):o3(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||o2(c)?t(c):(a.consume(c),b)}(b)}function v(b){return b===h?(a.consume(b),h=null,w):null===b||o1(b)?c(b):(a.consume(b),v)}function w(a){return 47===a||62===a||o3(a)?r(a):c(a)}function x(b){return 62===b?(a.consume(b),y):c(b)}function y(b){return null===b||o1(b)?z(b):o3(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):o1(b)&&(6===d||7===d)?(a.exit("htmlFlowData"),a.check(pR,J,A)(b)):null===b||o1(b)?(a.exit("htmlFlowData"),A(b)):(a.consume(b),z)}function A(b){return a.check(pS,B,J)(b)}function B(b){return a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),C}function C(b){return null===b||o1(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 pQ.includes(c)?(a.consume(b),I):z(b)}return oX(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||o1(b)?(a.exit("htmlFlowData"),J(b)):(a.consume(b),I)}function J(c){return a.exit("htmlFlow"),b(c)}}},61:p2,95:p$,96:px,126:px},"flowInitial",0,{[-2]:py,[-1]:py,32:py},"insideSpan",0,{null:[po,pd]},"string",0,{38:pv,92:pr},"text",0,{[-5]:pZ,[-4]:pZ,[-3]:pZ,33:pX,38:pv,42:po,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 oX(b)?(a.consume(b),f):64===b?c(b):h(b)}function f(b){return 43===b||45===b||46===b||oY(b)?(d=1,function b(c){return 58===c?(a.consume(c),d=0,g):(43===c||45===c||46===c||oY(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):oZ(b)?(a.consume(b),h):c(b)}function i(e){return oY(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||oY(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):oX(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):oX(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):o1(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):o1(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):o1(b)?(f=s,F(b)):(a.consume(b),s)}function t(b){return null===b?c(b):63===b?(a.consume(b),u):o1(b)?(f=t,F(b)):(a.consume(b),t)}function u(a){return 62===a?E(a):t(a)}function v(b){return oX(b)?(a.consume(b),w):c(b)}function w(b){return 45===b||oY(b)?(a.consume(b),w):function b(c){return o1(c)?(f=b,F(c)):o3(c)?(a.consume(c),b):E(c)}(b)}function x(b){return 45===b||oY(b)?(a.consume(b),x):47===b||62===b||o2(b)?y(b):c(b)}function y(b){return 47===b?(a.consume(b),E):58===b||95===b||oX(b)?(a.consume(b),z):o1(b)?(f=y,F(b)):o3(b)?(a.consume(b),y):E(b)}function z(b){return 45===b||46===b||58===b||95===b||oY(b)?(a.consume(b),z):function b(c){return 61===c?(a.consume(c),A):o1(c)?(f=b,F(c)):o3(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):o1(b)?(f=A,F(b)):o3(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):o1(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||o2(b)?y(b):(a.consume(b),C)}function D(a){return 47===a||62===a||o2(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 o3(b)?o5(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:pY,92:[{name:"hardBreakEscape",tokenize:function(a,b,c){return function(b){return a.enter("hardBreakEscape"),a.consume(b),d};function d(d){return o1(d)?(a.exit("hardBreakEscape"),b(d)):c(d)}}},pr],93:pT,95:po,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)):o1(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||o1(b)?(a.exit("codeTextData"),g(b)):(a.consume(b),h)}}}}],48293);var p3=a.i(48293);let p4=/[\0\t\n\r]/g;function p5(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 p6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function p7(a,b,c){if(b)return b;if(35===c.charCodeAt(0)){let a=c.charCodeAt(1),b=120===a||88===a;return p5(c.slice(b?2:1),b?16:10)}return pu(c)||a}let p8={}.hasOwnProperty;function p9(a){return{line:a.line,column:a.column,offset:a.offset}}function qa(a,b){if(a)throw Error("Cannot close `"+a.type+"` ("+op({start:a.start,end:a.end})+"): a different token (`"+b.type+"`, "+op({start:b.start,end:b.end})+") is open");throw Error("Cannot close document, a token (`"+b.type+"`, "+op({start:b.start,end:b.end})+") is still open")}function qb(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=p5(c,"characterReferenceMarkerNumeric"===d?10:16),this.data.characterReferenceType=void 0):b=pu(c);let e=this.stack[this.stack.length-1];e.value+=b},characterReference:function(a){this.stack.pop().position.end=p9(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=pN(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(p6,p7),c.identifier=pN(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=p9(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=pN(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(p8.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]];p8.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]||qa).call(g,void 0,a[0])}for(d.position={start:p9(a.length>0?a[0][1].start:{line:1,column:1,offset:0}),end:p9(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:p9(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]||qa).call(this,a,d[0]));else throw Error("Cannot close `"+a.type+"` ("+op({start:a.start,end:a.end})+"): it’s not open");c.position.end=p9(a.end)}function i(){return oJ(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:p9(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=p9(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(;!o9(a););return a}((function(a){let b={constructs:oP([p3,...(a||{}).extensions||[]]),content:c(oU),defined:[],document:c(oV),flow:c(pc),lazy:{},string:c(pe),text:c(pf)};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){oQ(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=oN(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=pn(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&&oM(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(p4.lastIndex=j,k=(d=p4.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 qc="object"==typeof self?self:globalThis,qd=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 qc[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 qc[f](g),e)})(0)},{toString:qe}={},{keys:qf}=Object,qg=a=>{let b=typeof a;if("object"!==b||!a)return[0,b];let c=qe.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]},qh=([a,b])=>0===a&&("function"===b||"symbol"===b),qi=(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]=qg(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 qf(a))(d||!qh(qg(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||!(qh(qg(b))||qh(qg(e))))&&c.push([h(b),h(e)]);return e}case 6:{let c=[],e=g([b,c],a);for(let b of a)(d||!qh(qg(b)))&&c.push(h(b));return e}}let{message:i}=a;return g([b,{name:c,message:i}],a)})(a),i},qj="function"==typeof structuredClone?(a,b)=>b&&("json"in b||"lossy"in b)?qd(qi(a,b)):structuredClone(a):(a,b)=>qd(qi(a,b));ql(/[A-Za-z]/);let qk=ql(/[\dA-Za-z]/);function ql(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function qm(a){let b=[],c=-1,d=0,e=0;for(;++c<a.length;){let f=a.charCodeAt(c),g="";if(37===f&&qk(a.charCodeAt(c+1))&&qk(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 qn(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 qo(a,b){return"Back to reference "+(a+1)+(b>1?"-"+b:"")}ql(/[#-'*+\--9=?A-Z^-~]/),ql(/\d/),ql(/[\dA-Fa-f]/),ql(/[!-/:-@[-`{-~]/),ql(/\p{P}|\p{S}/u),ql(/\s/);let qp=function(a){var b,c;if(null==a)return qr;if("function"==typeof a)return qq(a);if("object"==typeof a){return Array.isArray(a)?function(a){let b=[],c=-1;for(;++c<a.length;)b[c]=qp(a[c]);return qq(function(...a){let c=-1;for(;++c<b.length;)if(b[c].apply(this,a))return!0;return!1})}(a):(b=a,qq(function(a){let c;for(c in b)if(a[c]!==b[c])return!1;return!0}))}if("string"==typeof a){return c=a,qq(function(a){return a&&a.type===c})}throw Error("Expected function, string, or object as test")};function qq(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 qr(){return!0}let qs=[];function qt(a,b,c,d){let e;"function"==typeof b&&"function"!=typeof c?(d=c,c=b):e=b;let f=qp(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=qs;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?qs:[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 qu(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),qt(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 qv(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 qw(a){let b=a.spread;return null==b?a.children.length>1:b}function qx(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 qy={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=qm(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 qv(a,b);let e={src:qm(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:qm(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 qv(a,b);let e={href:qm(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:qm(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=qw(c[d])}return b}(c):qw(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=on(b.children[1]),g=om(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(qx(b.slice(e,d.index),e>0,!0),d[0]),e=d.index+d[0].length,d=c.exec(b);return f.push(qx(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:qz,yaml:qz,definition:qz,footnoteDefinition:qz};function qz(){}let qA={}.hasOwnProperty,qB={};function qC(a,b){a.position&&(b.position=function(a){let b=on(a),c=om(a);if(b&&c)return{start:b,end:c}}(a))}function qD(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,qj(e)),"children"in c&&c.children&&null!=d&&(c.children=d)}return c}function qE(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 qF(a){let b=0,c=a.charCodeAt(b);for(;9===c||32===c;)b++,c=a.charCodeAt(b);return a.slice(b)}function qG(a,b){let c,d,e,f,g=(c=b||qB,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=qF(e.value)),!Array.isArray(e)&&"element"===e.type)){let a=e.children[0];a&&"text"===a.type&&(a.value=qF(a.value))}Array.isArray(e)?b.push(...e):b.push(e)}}}return b},applyData:qD,definitionById:d,footnoteById:e,footnoteCounts:new Map,footnoteOrder:[],handlers:{...qy,...c.handlers},one:function(a,b){let c=a.type,d=f.handlers[c];if(qA.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=qj(c);return d.children=f.all(a),d}return qj(a)}return(f.options.unknownHandler||function(a,b){let c=b.data||{},d="value"in b&&!(qA.call(c,"hProperties")||qA.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:qC,wrap:qE},qu(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||qn,d=a.options.footnoteBackLabel||qo,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=qm(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:{...qj(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&&(nI("children"in j),j.children.push({type:"text",value:"\n"},i)),j}function qH(a,b){return a&&"run"in a?async function(c,d){let e=qG(c,{file:d,...b});await a.run(e,d)}:function(c,d){return qG(c,{file:d,...a||b})}}function qI(a){if(a)throw a}var qJ=a.i(97599);function qK(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 qL=a.i(50227),qL=qL,qM=a.i(59639),qM=qM,qN=a.i(57764),qN=qN;function qO(a){return!!(null!==a&&"object"==typeof a&&"href"in a&&a.href&&"protocol"in a&&a.protocol&&void 0===a.auth)}let qP=["history","path","basename","stem","extname","dirname"];class qQ{constructor(a){let b,c;b=a?qO(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?"":qM.default.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let d=-1;for(;++d<qP.length;){const a=qP[d];a in b&&void 0!==b[a]&&null!==b[a]&&(this[a]="history"===a?[...b[a]]:b[a])}for(c in b)qP.includes(c)||(this[c]=b[c])}get basename(){return"string"==typeof this.path?qL.default.basename(this.path):void 0}set basename(a){qS(a,"basename"),qR(a,"basename"),this.path=qL.default.join(this.dirname||"",a)}get dirname(){return"string"==typeof this.path?qL.default.dirname(this.path):void 0}set dirname(a){qT(this.basename,"dirname"),this.path=qL.default.join(a||"",this.basename)}get extname(){return"string"==typeof this.path?qL.default.extname(this.path):void 0}set extname(a){if(qR(a,"extname"),qT(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=qL.default.join(this.dirname,this.stem+(a||""))}get path(){return this.history[this.history.length-1]}set path(a){qO(a)&&(a=(0,qN.fileURLToPath)(a)),qS(a,"path"),this.path!==a&&this.history.push(a)}get stem(){return"string"==typeof this.path?qL.default.basename(this.path,this.extname):void 0}set stem(a){qS(a,"stem"),qR(a,"stem"),this.path=qL.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 ot(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 qR(a,b){if(a&&a.includes(qL.default.sep))throw Error("`"+b+"` cannot be a path: did not expect `"+qL.default.sep+"`")}function qS(a,b){if(!a)throw Error("`"+b+"` cannot be empty")}function qT(a,b){if(!a)throw Error("Setting `"+b+"` requires `path` to be set too")}let qU=function(a){let b=this.constructor.prototype,c=b[a],d=function(){return c.apply(d,arguments)};return Object.setPrototypeOf(d,b),d},qV={}.hasOwnProperty;class qW extends qU{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 qW,b=-1;for(;++b<this.attachers.length;){let c=this.attachers[b];a.use(...c)}return a.data((0,qJ.default)(!0,{},this.namespace)),a}data(a,b){return"string"==typeof a?2==arguments.length?(q$("data",this.frozen),this.namespace[a]=b,this):qV.call(this.namespace,a)&&this.namespace[a]||void 0:a?(q$("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=q1(a),c=this.parser||this.Parser;return qY("parse",c),c(String(b),b)}process(a,b){let c=this;return this.freeze(),qY("process",this.parser||this.Parser),qZ("process",this.compiler||this.Compiler),b?d(void 0,b):new Promise(d);function d(d,e){let f=q1(a),g=c.parse(f);function h(a,c){a||!c?e(a):d?d(c):(nI(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(),qY("processSync",this.parser||this.Parser),qZ("processSync",this.compiler||this.Compiler),this.process(a,function(a,d){c=!0,qI(a),b=d}),q0("processSync","process",c),nI(b,"we either bailed on an error or have a tree"),b}run(a,b,c){q_(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){nI("function"!=typeof b,"`file` can’t be a `done` anymore, we checked");let g=q1(b);d.run(a,g,function(b,d,g){let h=d||a;b?f(b):e?e(h):(nI(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){qI(a),c=b,d=!0}),q0("runSync","run",d),nI(c,"we either bailed on an error or have a tree"),c}stringify(a,b){this.freeze();let c=q1(b),d=this.compiler||this.Compiler;return qZ("stringify",d),q_(a),d(a,c)}use(a,...b){let c=this.attachers,d=this.namespace;if(q$("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,qJ.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];qK(g)&&qK(d)&&(d=(0,qJ.default)(!0,g,d)),c[e]=[a,d,...f]}}}}let qX=new qW().freeze();function qY(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `parser`")}function qZ(a,b){if("function"!=typeof b)throw TypeError("Cannot `"+a+"` without `compiler`")}function q$(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 q_(a){if(!qK(a)||"string"!=typeof a.type)throw TypeError("Expected node, got `"+a+"`")}function q0(a,b,c){if(!c)throw Error("`"+a+"` finished async. Use `"+b+"` instead")}function q1(a){var b;return(b=a)&&"object"==typeof b&&"message"in b&&"messages"in b?a:new qQ(a)}let q2=[],q3={allowDangerousHtml:!0},q4=/^(https?|ircs?|mailto|xmpp)$/i,q5=[{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 q6(a){var b;let c,d,e,f,g,h=(c=(b=a).rehypePlugins||q2,d=b.remarkPlugins||q2,e=b.remarkRehypeOptions?{...b.remarkRehypeOptions,...q3}:q3,qX().use(qb).use(d).use(qH,e).use(c)),i=(f=a.children||"",g=new qQ,"string"==typeof f?g.value=f:nJ("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||q7;for(let a of q5)Object.hasOwn(b,a.from)&&nJ("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&&nJ("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),qu(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 oH)if(Object.hasOwn(oH,b)&&Object.hasOwn(a.properties,b)){let c=a.properties[b],d=oH[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=on(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?ok:oj,stylePropertyNameCase:b.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==b.tableCellAlignToStyle},j=oA(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 q7(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||q4.test(a.slice(0,b))?a:""}function q8(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}rb(/[A-Za-z]/),rb(/[\dA-Za-z]/),rb(/[#-'*+\--9=?A-Z^-~]/),rb(/\d/),rb(/[\dA-Fa-f]/),rb(/[!-/:-@[-`{-~]/);let q9=rb(/\p{P}|\p{S}/u),ra=rb(/\s/);function rb(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let rc="phrasing",rd=["autolink","link","image","label"];function re(a){this.enter({type:"link",title:null,url:"",children:[]},a)}function rf(a){this.config.enter.autolinkProtocol.call(this,a)}function rg(a){this.config.exit.autolinkProtocol.call(this,a)}function rh(a){this.config.exit.data.call(this,a);let b=this.stack[this.stack.length-1];nI("link"===b.type),b.url="http://"+this.sliceSerialize(a)}function ri(a){this.config.exit.autolinkEmail.call(this,a)}function rj(a){this.exit(a)}function rk(a){!function(a,b,c){let d=qp((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;)qt(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,rl],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,rm]],{ignore:["link","linkReference"]})}function rl(a,b,c,d,e){let f,g="";if(!rn(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=q8(a,"("),f=q8(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 rm(a,b,c,d){return!(!rn(d,!0)||/[-\d_]$/.test(c))&&{type:"link",title:null,url:"mailto:"+b+"@"+c,children:[{type:"text",value:b+"@"+c}]}}function rn(a,b){let c=a.input.charCodeAt(a.index-1);return(0===a.index||ra(c)||q9(c))&&(!b||47!==c)}function ro(){this.buffer()}function rp(a){this.enter({type:"footnoteReference",identifier:"",label:""},a)}function rq(){this.buffer()}function rr(a){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},a)}function rs(a){let b=this.resume(),c=this.stack[this.stack.length-1];nI("footnoteReference"===c.type),c.identifier=pN(this.sliceSerialize(a)).toLowerCase(),c.label=b}function rt(a){this.exit(a)}function ru(a){let b=this.resume(),c=this.stack[this.stack.length-1];nI("footnoteDefinition"===c.type),c.identifier=pN(this.sliceSerialize(a)).toLowerCase(),c.label=b}function rv(a){this.exit(a)}function rw(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 rx(a,b,c){return 0===b?a:ry(a,b,c)}function ry(a,b,c){return(c?"":" ")+a}rw.peek=function(){return"["};let rz=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function rA(a){this.enter({type:"delete",children:[]},a)}function rB(a){this.exit(a)}function rC(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 rD(a){return a.length}function rE(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)}rC.peek=function(){return"~"};function rF(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}rF.peek=function(){return"`"};qp(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let rG=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 rH(a){let b=a._align;nI(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 rI(a){this.exit(a),this.data.inTable=void 0}function rJ(a){this.enter({type:"tableRow",children:[]},a)}function rK(a){this.exit(a)}function rL(a){this.enter({type:"tableCell",children:[]},a)}function rM(a){let b=this.resume();this.data.inTable&&(b=b.replace(/\\([\\|])/g,rN));let c=this.stack[this.stack.length-1];nI("inlineCode"===c.type),c.value=b,this.exit(a)}function rN(a,b){return"|"===b?b:a}function rO(a){let b=this.stack[this.stack.length-2];nI("listItem"===b.type),b.checked="taskListCheckValueChecked"===a.type}function rP(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];nI("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 rQ(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=rG(a,b,c,{...d,...h.current()});return f&&(i=i.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(a){return a+g})),i}let rR=rW(/[A-Za-z]/),rS=rW(/[\dA-Za-z]/);function rT(a){return null!==a&&(a<0||32===a)}rW(/[#-'*+\--9=?A-Z^-~]/),rW(/\d/),rW(/[\dA-Fa-f]/),rW(/[!-/:-@[-`{-~]/);let rU=rW(/\p{P}|\p{S}/u),rV=rW(/\s/);function rW(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}let rX={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},rY={tokenize:function(a,b,c){let d,e,f;return g;function g(b){return 46===b||95===b?a.check(r$,i,h)(b):null===b||rT(b)||rV(b)||45!==b&&rU(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},rZ={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(r$,b,f)(g):null===g||rT(g)||rV(g)?b(g):(a.consume(g),e)}function f(b){return 41===b&&d++,a.consume(b),e}},partial:!0},r$={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||rT(g)||rV(g)?b(g):c(g)}function e(a){return null===a||40===a||91===a||rT(a)||rV(a)?b(a):d(a)}function f(b){return rR(b)?function b(e){return 59===e?(a.consume(e),d):rR(e)?(a.consume(e),b):c(e)}(b):c(b)}},partial:!0},r_={tokenize:function(a,b,c){return function(b){return a.consume(b),d};function d(a){return rS(a)?c(a):b(a)}},partial:!0},r0={name:"wwwAutolink",tokenize:function(a,b,c){let d=this;return function(b){return 87!==b&&119!==b||!r5.call(d,d.previous)||r9(d.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(rX,a.attempt(rY,a.attempt(rZ,e),c),c)(b))};function e(c){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),b(c)}},previous:r5},r1={name:"protocolAutolink",tokenize:function(a,b,c){let d=this,e="",f=!1;return function(b){return(72===b||104===b)&&r6.call(d,d.previous)&&!r9(d.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),e+=String.fromCodePoint(b),a.consume(b),g):c(b)};function g(b){if(rR(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)||rT(b)||rV(b)||rU(b)?c(b):a.attempt(rY,a.attempt(rZ,j),c)(b)}function j(c){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),b(c)}},previous:r6},r2={name:"emailAutolink",tokenize:function(a,b,c){let d,e,f=this;return function(b){return!r8(b)||!r7.call(f,f.previous)||r9(f.events)?c(b):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),function b(d){return r8(d)?(a.consume(d),b):64===d?(a.consume(d),g):c(d)}(b))};function g(b){return 46===b?a.check(r_,i,h)(b):45===b||95===b||rS(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&&rR(f.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),b(g)):c(g)}},previous:r7},r3={},r4=48;for(;r4<123;)r3[r4]=r2,58==++r4?r4=65:91===r4&&(r4=97);function r5(a){return null===a||40===a||42===a||95===a||91===a||93===a||126===a||rT(a)}function r6(a){return!rR(a)}function r7(a){return!(47===a||r8(a))}function r8(a){return 43===a||45===a||46===a||95===a||rS(a)}function r9(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 sa(a){return null!==a&&(a<0||32===a)}function sb(a){return -2===a||-1===a||32===a}function sc(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function sd(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return sb(d)?(a.enter(c),function d(g){return sb(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}r3[43]=r2,r3[45]=r2,r3[46]=r2,r3[95]=r2,r3[72]=[r2,r1],r3[104]=[r2,r1],r3[87]=[r2,r0],r3[119]=[r2,r0],sc(/[A-Za-z]/),sc(/[\dA-Za-z]/),sc(/[#-'*+\--9=?A-Z^-~]/),sc(/\d/),sc(/[\dA-Fa-f]/),sc(/[!-/:-@[-`{-~]/),sc(/\p{P}|\p{S}/u),sc(/\s/);let se={tokenize:function(a,b,c){let d=this;return sd(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 sf(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=pN(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 sg(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 sh(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||sa(h))return c(h);if(93===h){a.exit("chunkString");let d=a.exit("gfmFootnoteCallString");return f.includes(pN(e.sliceSerialize(d)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(h),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),b):c(h)}return sa(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 si(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||sa(b))return c(b);if(93===b){a.exit("chunkString");let c=a.exit("gfmFootnoteDefinitionLabelString");return d=pN(f.sliceSerialize(c)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(b),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),l}return sa(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),sd(a,n,"gfmFootnoteDefinitionWhitespace")):c(b)}function n(a){return b(a)}}function sj(a,b,c){return a.check(o6,b,a.attempt(se,b,c))}function sk(a){a.exit("gfmFootnoteDefinition")}function sl(a){return null!==a&&a<-2}function sm(a){return null!==a&&(a<0||32===a)}function sn(a){return -2===a||-1===a||32===a}function so(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}function sp(a,b,c,d){let e=d?d-1:1/0,f=0;return function(d){return sn(d)?(a.enter(c),function d(g){return sn(g)&&f++<e?(a.consume(g),d):(a.exit(c),b(g))}(d)):b(d)}}so(/[A-Za-z]/),so(/[\dA-Za-z]/),so(/[#-'*+\--9=?A-Z^-~]/),so(/\d/),so(/[\dA-Fa-f]/),so(/[!-/:-@[-`{-~]/),so(/\p{P}|\p{S}/u),so(/\s/);class sq{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 sr(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):sl(b)?g>1?(g=0,e.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),l):c(b):sn(b)?sp(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||sm(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,sn(b))?sp(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 sn(b)?sp(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||sl(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 sn(b)?sp(a,s,"whitespace")(b):s(b)}function s(e){if(124===e)return n(e);if(null===e||sl(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||sl(c)?(a.exit("tableRow"),b(c)):sn(c)?sp(a,u,"whitespace")(c):(a.enter("data"),v(c))}function v(b){return null===b||124===b||sm(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 ss(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 sq;for(;++f<a.length;){let o=a[f],p=o[1];"enter"===o[0]?"tableHead"===p.type?(k=!1,0!==l&&(su(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=st(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=st(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=st(n,b,i,h,f,e)):0!==j[1]&&(e=st(n,b,j,h,f,e)),h=0):h&&("data"===p.type||"tableDelimiterMarker"===p.type||"tableDelimiterFiller"===p.type)&&(j[3]=f)}for(0!==l&&su(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 st(a,b,c,d,e,f){0!==c[0]&&(f.end=Object.assign({},sv(b.events,c[0])),a.add(c[0],0,[["exit",f,b]]));let g=sv(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=sv(b.events,c[2]),f=sv(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({},sv(b.events,e)),a.add(e,0,[["exit",f,b]]),f=void 0),f}function su(a,b,c,d,e){let f=[],g=sv(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 sv(a,b){let c=a[b],d="enter"===c[0]?"start":"end";return c[1][d]}function sw(a){return -2===a||-1===a||32===a}function sx(a){return function(b){return null!==b&&b>-1&&a.test(String.fromCharCode(b))}}sx(/[A-Za-z]/),sx(/[\dA-Za-z]/),sx(/[#-'*+\--9=?A-Z^-~]/),sx(/\d/),sx(/[\dA-Fa-f]/),sx(/[!-/:-@[-`{-~]/),sx(/\p{P}|\p{S}/u),sx(/\s/);let sy={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):sw(d)?a.check({tokenize:sz},b,c)(d):c(d)}}};function sz(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 sw(b)?(a.enter(e),function b(c){return sw(c)&&g++<f?(a.consume(c),b):(a.exit(e),d(c))}(b)):d(b)}}let sA={};function sB(a){let b,c,d,e=a||sA,f=this.data(),g=f.micromarkExtensions||(f.micromarkExtensions=[]),h=f.fromMarkdownExtensions||(f.fromMarkdownExtensions=[]),i=f.toMarkdownExtensions||(f.toMarkdownExtensions=[]);g.push(oP([{text:r3},{document:{91:{name:"gfmFootnoteDefinition",tokenize:si,continuation:{tokenize:sj},exit:sk}},text:{91:{name:"gfmFootnoteCall",tokenize:sh},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sf,resolveTo:sg}}},(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=pm(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=pm(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&&oM(g,g.length,0,pn(h,a.slice(d+1,c),b)),oM(g,g.length,0,[["exit",f,b],["enter",a[c][1],b],["exit",a[c][1],b],["exit",e,b]]),oM(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:sr,resolveAll:ss}}},{text:{91:sy}}])),h.push([{transforms:[rk],enter:{literalAutolink:re,literalAutolinkEmail:rf,literalAutolinkHttp:rf,literalAutolinkWww:rf},exit:{literalAutolink:rj,literalAutolinkEmail:ri,literalAutolinkHttp:rg,literalAutolinkWww:rh}},{enter:{gfmFootnoteCallString:ro,gfmFootnoteCall:rp,gfmFootnoteDefinitionLabelString:rq,gfmFootnoteDefinition:rr},exit:{gfmFootnoteCallString:rs,gfmFootnoteCall:rt,gfmFootnoteDefinitionLabelString:ru,gfmFootnoteDefinition:rv}},{canContainEols:["delete"],enter:{strikethrough:rA},exit:{strikethrough:rB}},{enter:{table:rH,tableData:rL,tableHeader:rL,tableRow:rJ},exit:{codeText:rM,table:rI,tableData:rK,tableHeader:rK,tableRow:rK}},{exit:{taskListCheckValueChecked:rO,taskListCheckValueUnchecked:rO,paragraph:rP}}]),i.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:rc,notInConstruct:rd},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:rc,notInConstruct:rd},{character:":",before:"[ps]",after:"\\/",inConstruct:rc,notInConstruct:rd}]},(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?ry:rx))),h(),g},footnoteReference:rw},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rz}],handlers:{delete:rC}},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=rF(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||rD,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]=rE(d[n]);else{let a=rE(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:rQ}}]})}let sC=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 sD({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)(nH,{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:sC(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:sC(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)(q6,{remarkPlugins:[sB],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 sE({mentalModelId:a,onClose:b}){let{currentBank:c}=(0,H.useBank)(),[d,e]=(0,D.useState)(null),[f,g]=(0,D.useState)(!1),[h,i]=(0,D.useState)(null);(0,D.useEffect)(()=>{a&&c&&(async()=>{g(!0),i(null),e(null);try{let b=await V.client.getMentalModel(c,a);e(b)}catch(a){console.error("Error loading mental model:",a),i(a.message)}finally{g(!1)}})()},[a,c]);let j=null!==a;return(0,C.jsx)(bj.Dialog,{open:j,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nG.VisuallyHidden,{children:(0,C.jsx)(bj.DialogTitle,{children:"Mental Model Details"})}),f?(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"})}):h?(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: ",h]})})}):d?(0,C.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,C.jsx)(sD,{mentalModel:d})}):null]})})}function sF(){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)(mP,{children:(0,C.jsxs)(mT,{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)(mN.Select,{value:p,onValueChange:a=>q(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mN.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mN.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)(mO.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)(mO.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)(mN.Select,{value:I,onValueChange:a=>J(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mN.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),B&&(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{children:"Answer"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(q6,{remarkPlugins:[sB],children:z.text})})})]}),(0,C.jsxs)(mP,{className:"border-blue-200 dark:border-blue-800",children:[(0,C.jsxs)(mQ,{className:"py-4",children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(mW,{className:"w-4 h-4"}),"Add Directive"]}),(0,C.jsx)(mS,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,C.jsx)(mT,{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)(mZ.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)(mP,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,C.jsxs)(mQ,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(mV,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",z.observations_created.length,")"]}),(0,C.jsx)(mS,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,C.jsx)(mT,{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)(mP,{className:"h-fit",children:[(0,C.jsxs)(mQ,{className:"pb-3",children:[(0,C.jsx)(mR,{className:"text-base",children:"Execution Trace"}),(0,C.jsxs)(mS,{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)(mT,{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)(mY,{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)(nF,{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)(nF,{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)(mU.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)(mU.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)(mP,{className:"h-fit",children:[(0,C.jsxs)(mQ,{className:"pb-3",children:[(0,C.jsx)(mR,{className:"text-base",children:"Based On"}),(0,C.jsxs)(mS,{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)(mT,{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)(mU.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)(mU.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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nF,{src:z,collapsed:2,theme:"default"})})})]})]}),!B&&!z&&(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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)(bn,{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)(mX,{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)(mV,{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)(q6,{remarkPlugins:[sB],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)(sE,{mentalModelId:ak,onClose:()=>al(null)})]}):(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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 sG=a.i(5784);let sH=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function sI(){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)(mP,{children:(0,C.jsxs)(mT,{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)(mO.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)(mO.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)(nH,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsxs)(mN.Select,{value:u,onValueChange:a=>v(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mN.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mN.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)(mO.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)(mO.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)(mN.Select,{value:L,onValueChange:a=>P(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mN.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),ae&&(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,C.jsx)(mQ,{className:"py-3",children:(0,C.jsxs)(mR,{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)(mT,{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)(mP,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ak(a),children:(0,C.jsx)(mT,{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)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,C.jsxs)(mT,{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)(sG.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)(sG.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)(sH,{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)(mP,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(c),children:(0,C.jsx)(mT,{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)(sG.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)(sH,{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)(mP,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(i),children:(0,C.jsx)(mT,{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:"0.6×cross_encoder + 0.2×rrf + 0.1×temporal + 0.1×recency"})})]}),(0,C.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ab.reranked.length}),j?(0,C.jsx)(sG.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 (60%)",children:["CE: ",c.cross_encoder_score_normalized.toFixed(3)]}),void 0!==c.rrf_normalized&&(0,C.jsxs)("span",{title:`RRF normalized (20%) - raw: ${c.rrf_score?.toFixed(4)||"N/A"}`,children:["RRF: ",c.rrf_normalized.toFixed(3)]}),void 0!==c.temporal&&(0,C.jsxs)("span",{title:"Temporal proximity (10%)",children:["Tmp: ",c.temporal.toFixed(3)]}),void 0!==c.recency&&(0,C.jsxs)("span",{title:"Recency (10%)",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)(sH,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,C.jsx)(mP,{className:"border-primary bg-primary/5",children:(0,C.jsx)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nF,{src:{results:R,...T&&{entities:T},...Z&&{chunks:Z},..._&&{observations:_},trace:ab},collapsed:2,theme:"default"})})})]})]}),!ae&&!R&&(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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)(bo,{memory:aj,onClose:()=>ak(null),inPanel:!0,bankId:p||void 0})})]}):(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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 sJ=(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 sK=a.i(83604),sK=sK,sL=a.i(15618),bi=bi;let sM=(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"}]]),sN={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 sO({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)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(mV,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,C.jsx)(mS,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)(W.Button,{onClick:()=>w(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(sM,{className:"h-4 w-4"})})]})}),(0,C.jsx)(mT,{children:g&&(0,C.jsx)("div",{className:"space-y-4",children:Object.keys(sN).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:sN[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sN[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:sN[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:sN[a].highLabel})]})]},a))})})]}),(0,C.jsxs)(mP,{children:[(0,C.jsx)(mQ,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(sJ,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,C.jsx)(mS,{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)(sM,{className:"h-4 w-4"})})]})}),(0,C.jsx)(mT,{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)(sK.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)(sL.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)(mP,{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)(mT,{className:"p-3",children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)(sK.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)(sK.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)(mm,{open:N,onOpenChange:O,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Memory Bank"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:P,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(mm,{open:R,onOpenChange:S,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Clear Observations"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:T,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,C.jsx)(sR,{open:z,mode:"create",onClose:()=>A(!1),onCreated:a=>{q(b=>[a,...b]),A(!1)}}),(0,C.jsx)(mm,{open:!!J,onOpenChange:a=>!a&&K(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Directive"}),(0,C.jsxs)(mH,{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)(mF,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mJ,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mI,{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)(sS,{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)(sP,{disposition:g.disposition,onClose:()=>w(!1),onSaved:async()=>{await ai(),w(!1)}}),x&&g&&(0,C.jsx)(sQ,{mission:g.mission||"",onClose:()=>y(!1),onSaved:async()=>{await ai(),y(!1)}})]}):(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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 sP({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)(bj.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Edit Disposition Traits"}),(0,C.jsx)(bj.DialogDescription,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)("div",{className:"space-y-4 py-4",children:Object.keys(sN).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:sN[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sN[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:sN[a].lowLabel}),(0,C.jsx)("span",{children:sN[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)(bj.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 sQ({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)(bj.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Edit Mission"}),(0,C.jsx)(bj.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)(mZ.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)(bj.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 sR({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)(bj.Dialog,{open:a,onOpenChange:a=>!a&&n(),children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsxs)(bj.DialogTitle,{className:"flex items-center gap-2",children:[(0,C.jsx)(sK.default,{className:"w-5 h-5 text-rose-500"}),"create"===b?"Create":"Edit"," Directive"]}),(0,C.jsx)(bj.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)(mZ.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)(bj.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 sS({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)(sK.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)(sM,{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)(mK,{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)(q6,{remarkPlugins:[sB],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)(sR,{open:e,mode:"edit",directive:a,onClose:()=>f(!1),onSaved:d})]})}let sT=(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"}}),sU=D.forwardRef(({className:a,variant:b,...c},d)=>(0,C.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(sT({variant:b}),a),...c}));sU.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 sV=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));sV.displayName="AlertDescription";var bi=bi;let sW=(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"}]]),sX=[{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"}],sY=[{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"}],sZ=sX.map(a=>({category:a.value,threshold:"BLOCK_NONE"})),s$=[{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"]}],s_=s$.flatMap(a=>a.tools);function s0(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 s1(a){return{enable_observations:a.enable_observations??null,observations_mission:a.observations_mission??null}}function s2(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 s3(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function s4(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let s5={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function s6(){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)(s5),[j,k]=(0,D.useState)(s0({})),[l,n]=(0,D.useState)(s1({})),[o,p]=(0,D.useState)(s2({})),[q,r]=(0,D.useState)(s5),[s,t]=(0,D.useState)(s3({})),[u,v]=(0,D.useState)(s4({})),[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(s0(f)),[j,f]),_=(0,D.useMemo)(()=>JSON.stringify(l)!==JSON.stringify(s1(f)),[l,f]),aa=(0,D.useMemo)(()=>JSON.stringify(o)!==JSON.stringify(s2(f)),[o,f]),ab=(0,D.useMemo)(()=>JSON.stringify(q)!==JSON.stringify(h),[q,h]),ac=(0,D.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(s3(f)),[s,f]),ad=(0,D.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(s4(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(s0(d)),n(s1(d)),p(s2(d)),r(e),t(s3(d)),v(s4(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)(s8,{title:"Retain",description:"Control what gets extracted and stored from content",error:M,dirty:$,saving:w,onSave:af,children:[(0,C.jsx)(s9,{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)(ta,{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)(s9,{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)(mN.Select,{value:j.retain_extraction_mode??"",onValueChange:a=>k(b=>({...b,retain_extraction_mode:a})),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-full",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsx)(mN.SelectContent,{children:["concise","verbose","custom"].map(a=>(0,C.jsx)(mN.SelectItem,{value:a,children:a},a))})]})}),"custom"===j.retain_extraction_mode&&(0,C.jsx)(ta,{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)(s8,{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)(s9,{label:"Free Form Entities",description:"Extract regular named entities (people, places, concepts) alongside label groups. Disable to restrict extraction to label groups 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)(tc,{value:o.entity_labels??[],onChange:a=>p(b=>({...b,entity_labels:a.length>0?a:null}))})]}),(0,C.jsxs)(s8,{title:"Observations",description:"Control how facts are synthesized into durable observations",error:O,dirty:_,saving:y,onSave:ag,children:[(0,C.jsx)(s9,{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)(ta,{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.jsxs)(s8,{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)(ta,{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)(tb,{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)(tb,{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)(tb,{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)(s8,{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)(s9,{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?[...s_]: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)(s7,{selected:s.mcp_enabled_tools,onChange:a=>t({mcp_enabled_tools:a})})]}),(0,C.jsx)(s8,{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)(s9,{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?[...sZ]: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)(td,{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 s7({selected:a,onChange:b}){let c=new Set(a),d=s_.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 ",s_.length," tools enabled"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(d?[]:[...s_])},className:"text-xs text-primary hover:underline",children:d?"Deselect all":"Select all"})]}),(0,C.jsx)("div",{className:"space-y-4",children:s$.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(s_.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(s_.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 s8({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)(mP,{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)(sU,{variant:"destructive",children:[(0,C.jsx)(sW,{className:"h-4 w-4"}),(0,C.jsx)(sV,{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 s9({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 ta({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)(mZ.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function tb({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 tc({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:"Label Groups"}),(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 label groups 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)(sG.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)(mN.Select,{value:g.type,onValueChange:a=>e(h,{type:a,..."text"===a?{values:[]}:{}}),children:[(0,C.jsx)(mN.SelectTrigger,{className:"h-8 text-xs w-32 shrink-0",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"value",className:"text-xs",children:"Single value"}),(0,C.jsx)(mN.SelectItem,{value:"multi-values",className:"text-xs",children:"Multi-values"}),(0,C.jsx)(mN.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)(mO.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)(mK,{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)(mK,{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)(sL.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)(sL.Plus,{className:"h-3.5 w-3.5"}),"Add attribute"]})]})}function td({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:sX.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)(mN.Select,{value:c(a.value),onValueChange:d=>{var e;return e=a.value,void b(sX.map(a=>({category:a.value,threshold:a.value===e?d:c(a.value)})))},children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsx)(mN.SelectContent,{children:sY.map(a=>(0,C.jsx)(mN.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}let te=(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"}]]),tf=(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"}]]),tg=(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 th(){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)(mP,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,C.jsx)(mT,{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)(mP,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,C.jsx)(mT,{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)(te,{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)(mP,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,C.jsx)(mT,{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)(tf,{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)(mP,{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)(mT,{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)(tg,{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;function ti(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(0),[f,g]=(0,D.useState)(null),[h]=(0,D.useState)(10),[i,j]=(0,D.useState)(0),[k,l]=(0,D.useState)(null),[n,o]=(0,D.useState)(!1),[p,q]=(0,D.useState)(null),[r,s]=(0,D.useState)(!1),[t,u]=(0,D.useState)(!1),v=async(b=f,d=i)=>{if(a){o(!0);try{let f=await V.client.listOperations(a,{status:b||void 0,limit:h,offset:d});c(f.operations||[]),e(f.total||0)}catch(a){console.error("Error loading operations:",a)}finally{o(!1)}}},w=a=>{j(a),v(f,a)},x=async b=>{if(a){l(b);try{await V.client.cancelOperation(a,b),await v()}catch(a){}finally{l(null)}}},y=async b=>{if(a){u(!0),s(!0);try{let c=await V.client.getOperationStatus(a,b);q(c)}catch(a){console.error("Error loading operation details:",a),q({error:"Failed to load operation details"})}finally{u(!1)}}};return((0,D.useEffect)(()=>{if(a){v();let a=setInterval(()=>v(),5e3);return()=>clearInterval(a)}},[a]),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:()=>v(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",disabled:n,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${n?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d," operation",1!==d?"s":"",f?` (${f})`:""]})]}),(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),j(0),v(b,0)},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:()=>y(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)(sW,{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.jsx)(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(),x(a.id)},disabled:k===a.id,children:[k===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"}),k===a.id?"":"Cancel"]})})]},a.id))})]})}),d>h&&(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 ",i+1,"-",Math.min(i+h,d)," of"," ",d]}),(0,C.jsxs)("div",{className:"flex gap-2",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>w(Math.max(0,i-h)),disabled:0===i,children:"Previous"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>w(i+h),disabled:i+h>=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)(bj.Dialog,{open:r,onOpenChange:s,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Operation Details"}),(0,C.jsx)(bj.DialogDescription,{children:p?.operation_id&&(0,C.jsx)("span",{className:"font-mono text-xs",children:p.operation_id})})]}),t?(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"})}):p?(0,C.jsx)("div",{className:"space-y-4",children:p.error?(0,C.jsx)("div",{className:"text-red-600 dark:text-red-400",children:p.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"===p.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"===p.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)(sW,{className:"w-3 h-3"}),"failed"]}),"completed"===p.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:p.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:p.created_at?new Date(p.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:p.updated_at?new Date(p.updated_at).toLocaleString():"N/A"})]}),p.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(p.completed_at).toLocaleString()})]}),p.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:p.result_metadata.items_count})]})]}),p.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:p.error_message})]}),p.child_operations&&p.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 (",p.result_metadata?.num_sub_batches||p.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:p.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)(sW,{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 tj=(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"}]]);var bi=bi;function tk({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)(bj.Dialog,{open:k,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nG.VisuallyHidden,{children:(0,C.jsx)(bj.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)(q6,{remarkPlugins:[sB],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 tl(){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)(mP,{children:(0,C.jsx)(mT,{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)(sL.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)(tj,{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)(mP,{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)(mT,{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)(mK,{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)(q6,{remarkPlugins:[sB],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)(mK,{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)(tm,{open:l,onClose:()=>n(!1),onCreated:()=>{n(!1),z()}}),(0,C.jsx)(mm,{open:!!u,onOpenChange:a=>!a&&v(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Mental Model"}),(0,C.jsxs)(mH,{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)(mF,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mJ,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mI,{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)(to,{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)(tn,{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 tm({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)(bj.Dialog,{open:a,onOpenChange:a=>{a||(h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),b())},children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Create Mental Model"}),(0,C.jsx)(bj.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)(mO.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)(bj.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 tn({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)(bj.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Update Mental Model"}),(0,C.jsx)(bj.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)(mO.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)(bj.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 to({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=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)}},o=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})}`},p=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}))):[],q=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.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:d,className:"h-7 w-7 p-0",children:(0,C.jsx)(sM,{className:"h-3.5 w-3.5"})})]}),(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)(W.Button,{variant:"outline",size:"sm",onClick:n,disabled:g,className:"h-8",children:[g?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):(0,C.jsx)(ab,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(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:o(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:o(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)(q6,{remarkPlugins:[sB],children:a.content})})]}),p.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 (",p.length," ",1===p.length?"fact":"facts",")"]}),(0,C.jsx)("div",{className:"space-y-3",children:p.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)})})]}),q.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 (",q.length,")"]}),(0,C.jsx)("div",{className:"space-y-3",children:q.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.'})]}),(0,C.jsx)("div",{className:"pt-4 border-t border-border",children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:c,className:"text-muted-foreground hover:text-destructive hover:border-destructive",children:[(0,C.jsx)(mK,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]}),i&&f&&(0,C.jsx)(bn,{memoryId:i,onClose:()=>j(null)}),k&&f&&(0,C.jsx)(tk,{directiveId:k,onClose:()=>l(null)})]})}var tp=a.i(96743),tq=a.i(86228),tr=a.i(22297),ts=a.i(92843),tt=a.i(4691),tu=a.i(92616),tv=a.i(77192),tw=a.i(24050),tx=Symbol("radix.slottable");function ty(a){return D.isValidElement(a)&&"function"==typeof a.type&&"__radixId"in a.type&&a.type.__radixId===tx}var tz=a.i(46872),tA=a.i(41852),tB=a.i(52081),tC=["Enter"," "],tD=["ArrowUp","PageDown","End"],tE=["ArrowDown","PageUp","Home",...tD],tF={ltr:[...tC,"ArrowRight"],rtl:[...tC,"ArrowLeft"]},tG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tH="Menu",[tI,tJ,tK]=(0,aD.createCollection)(tH),[tL,tM]=(0,ax.createContextScope)(tH,[tK,tt.createPopperScope,tw.createRovingFocusGroupScope]),tN=(0,tt.createPopperScope)(),tO=(0,tw.createRovingFocusGroupScope)(),[tP,tQ]=tL(tH),[tR,tS]=tL(tH),tT=a=>{let{__scopeMenu:b,open:c=!1,children:d,dir:e,onOpenChange:f,modal:g=!0}=a,h=tN(b),[i,j]=D.useState(null),k=D.useRef(!1),l=(0,tz.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)(tt.Root,{...h,children:(0,C.jsx)(tP,{scope:b,open:c,onOpenChange:l,content:i,onContentChange:j,children:(0,C.jsx)(tR,{scope:b,onClose:D.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:k,dir:n,modal:g,children:d})})})};tT.displayName=tH;var tU=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tN(c);return(0,C.jsx)(tt.Anchor,{...e,...d,ref:b})});tU.displayName="MenuAnchor";var tV="MenuPortal",[tW,tX]=tL(tV,{forceMount:void 0}),tY=a=>{let{__scopeMenu:b,forceMount:c,children:d,container:e}=a,f=tQ(tV,b);return(0,C.jsx)(tW,{scope:b,forceMount:c,children:(0,C.jsx)(tv.Presence,{present:c||f.open,children:(0,C.jsx)(tu.Portal,{asChild:!0,container:e,children:d})})})};tY.displayName=tV;var tZ="MenuContent",[t$,t_]=tL(tZ),t0=D.forwardRef((a,b)=>{let c=tX(tZ,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tQ(tZ,a.__scopeMenu),g=tS(tZ,a.__scopeMenu);return(0,C.jsx)(tI.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tv.Presence,{present:d||f.open,children:(0,C.jsx)(tI.Slot,{scope:a.__scopeMenu,children:g.modal?(0,C.jsx)(t1,{...e,ref:b}):(0,C.jsx)(t2,{...e,ref:b})})})})}),t1=D.forwardRef((a,b)=>{let c=tQ(tZ,a.__scopeMenu),d=D.useRef(null),e=(0,aw.useComposedRefs)(b,d);return D.useEffect(()=>{let a=d.current;if(a)return(0,tA.hideOthers)(a)},[]),(0,C.jsx)(t4,{...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)})}),t2=D.forwardRef((a,b)=>{let c=tQ(tZ,a.__scopeMenu);return(0,C.jsx)(t4,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>c.onOpenChange(!1)})}),t3=((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(ty);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),t4=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=tQ(tZ,c),s=tS(tZ,c),t=tN(c),u=tO(c),v=tJ(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?tB.RemoveScroll:D.Fragment;D.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,tq.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)(t$,{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:t3,allowPinchZoom:!0}:void 0,children:(0,C.jsx)(tr.FocusScope,{asChild:!0,trapped:e,onMountAutoFocus:(0,av.composeEventHandlers)(f,a=>{a.preventDefault(),y.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:g,children:(0,C.jsx)(tp.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,children:(0,C.jsx)(tw.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)(tt.Content,{role:"menu","aria-orientation":"vertical","data-state":uu(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||!tE.includes(a.key))return;a.preventDefault();let g=v().filter(a=>!a.disabled).map(a=>a.ref.current);tD.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,ux(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)}))})})})})})})});t0.displayName=tZ;var t5=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"group",...d,ref:b})});t5.displayName="MenuGroup";var t6=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{...d,ref:b})});t6.displayName="MenuLabel";var t7="MenuItem",t8="menu.itemSelect",t9=D.forwardRef((a,b)=>{let{disabled:c=!1,onSelect:d,...e}=a,f=D.useRef(null),g=tS(t7,a.__scopeMenu),h=t_(t7,a.__scopeMenu),i=(0,aw.useComposedRefs)(b,f),j=D.useRef(!1);return(0,C.jsx)(ua,{...e,ref:i,disabled:c,onClick:(0,av.composeEventHandlers)(a.onClick,()=>{let a=f.current;if(!c&&a){let b=new CustomEvent(t8,{bubbles:!0,cancelable:!0});a.addEventListener(t8,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||tC.includes(a.key)&&(a.currentTarget.click(),a.preventDefault())})})});t9.displayName=t7;var ua=D.forwardRef((a,b)=>{let{__scopeMenu:c,disabled:d=!1,textValue:e,...f}=a,g=t_(t7,c),h=tO(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)(tI.ItemSlot,{scope:c,disabled:d,textValue:e??n,children:(0,C.jsx)(tw.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,ux(a=>{d?g.onItemLeave(a):(g.onItemEnter(a),a.defaultPrevented||a.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,ux(a=>g.onItemLeave(a))),onFocus:(0,av.composeEventHandlers)(a.onFocus,()=>l(!0)),onBlur:(0,av.composeEventHandlers)(a.onBlur,()=>l(!1))})})})}),ub=D.forwardRef((a,b)=>{let{checked:c=!1,onCheckedChange:d,...e}=a;return(0,C.jsx)(uj,{scope:a.__scopeMenu,checked:c,children:(0,C.jsx)(t9,{role:"menuitemcheckbox","aria-checked":uv(c)?"mixed":c,...e,ref:b,"data-state":uw(c),onSelect:(0,av.composeEventHandlers)(e.onSelect,()=>d?.(!!uv(c)||!c),{checkForDefaultPrevented:!1})})})});ub.displayName="MenuCheckboxItem";var uc="MenuRadioGroup",[ud,ue]=tL(uc,{value:void 0,onValueChange:()=>{}}),uf=D.forwardRef((a,b)=>{let{value:c,onValueChange:d,...e}=a,f=(0,tz.useCallbackRef)(d);return(0,C.jsx)(ud,{scope:a.__scopeMenu,value:c,onValueChange:f,children:(0,C.jsx)(t5,{...e,ref:b})})});uf.displayName=uc;var ug="MenuRadioItem",uh=D.forwardRef((a,b)=>{let{value:c,...d}=a,e=ue(ug,a.__scopeMenu),f=c===e.value;return(0,C.jsx)(uj,{scope:a.__scopeMenu,checked:f,children:(0,C.jsx)(t9,{role:"menuitemradio","aria-checked":f,...d,ref:b,"data-state":uw(f),onSelect:(0,av.composeEventHandlers)(d.onSelect,()=>e.onValueChange?.(c),{checkForDefaultPrevented:!1})})})});uh.displayName=ug;var ui="MenuItemIndicator",[uj,uk]=tL(ui,{checked:!1}),ul=D.forwardRef((a,b)=>{let{__scopeMenu:c,forceMount:d,...e}=a,f=uk(ui,c);return(0,C.jsx)(tv.Presence,{present:d||uv(f.checked)||!0===f.checked,children:(0,C.jsx)(aC.Primitive.span,{...e,ref:b,"data-state":uw(f.checked)})})});ul.displayName=ui;var um=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"separator","aria-orientation":"horizontal",...d,ref:b})});um.displayName="MenuSeparator";var un=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tN(c);return(0,C.jsx)(tt.Arrow,{...e,...d,ref:b})});un.displayName="MenuArrow";var[uo,up]=tL("MenuSub"),uq="MenuSubTrigger",ur=D.forwardRef((a,b)=>{let c=tQ(uq,a.__scopeMenu),d=tS(uq,a.__scopeMenu),e=up(uq,a.__scopeMenu),f=t_(uq,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)(tU,{asChild:!0,...j,children:(0,C.jsx)(ua,{id:e.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":e.contentId,"data-state":uu(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,ux(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,ux(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||tF[d.dir].includes(b.key)&&(c.onOpenChange(!0),c.content?.focus(),b.preventDefault())})})})});ur.displayName=uq;var us="MenuSubContent",ut=D.forwardRef((a,b)=>{let c=tX(tZ,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tQ(tZ,a.__scopeMenu),g=tS(tZ,a.__scopeMenu),h=up(us,a.__scopeMenu),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i);return(0,C.jsx)(tI.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tv.Presence,{present:d||f.open,children:(0,C.jsx)(tI.Slot,{scope:a.__scopeMenu,children:(0,C.jsx)(t4,{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=tG[g.dir].includes(a.key);b&&c&&(f.onOpenChange(!1),h.trigger?.focus(),a.preventDefault())})})})})})});function uu(a){return a?"open":"closed"}function uv(a){return"indeterminate"===a}function uw(a){return uv(a)?"indeterminate":a?"checked":"unchecked"}function ux(a){return b=>"mouse"===b.pointerType?a(b):void 0}ut.displayName=us;var uy="DropdownMenu",[uz,uA]=(0,ax.createContextScope)(uy,[tM]),uB=tM(),[uC,uD]=uz(uy),uE=a=>{let{__scopeDropdownMenu:b,children:c,dir:d,open:e,defaultOpen:f,onOpenChange:g,modal:h=!0}=a,i=uB(b),j=D.useRef(null),[k,l]=(0,ay.useControllableState)({prop:e,defaultProp:f??!1,onChange:g,caller:uy});return(0,C.jsx)(uC,{scope:b,triggerId:(0,ts.useId)(),triggerRef:j,contentId:(0,ts.useId)(),open:k,onOpenChange:l,onOpenToggle:D.useCallback(()=>l(a=>!a),[l]),modal:h,children:(0,C.jsx)(tT,{...i,open:k,onOpenChange:l,dir:d,modal:h,children:c})})};uE.displayName=uy;var uF="DropdownMenuTrigger",uG=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,disabled:d=!1,...e}=a,f=uD(uF,c),g=uB(c);return(0,C.jsx)(tU,{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())})})})});uG.displayName=uF;var uH=a=>{let{__scopeDropdownMenu:b,...c}=a,d=uB(b);return(0,C.jsx)(tY,{...d,...c})};uH.displayName="DropdownMenuPortal";var uI="DropdownMenuContent",uJ=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uD(uI,c),f=uB(c),g=D.useRef(!1);return(0,C.jsx)(t0,{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)"}})});uJ.displayName=uI,D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(t5,{...e,...d,ref:b})}).displayName="DropdownMenuGroup";var uK=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(t6,{...e,...d,ref:b})});uK.displayName="DropdownMenuLabel";var uL=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(t9,{...e,...d,ref:b})});uL.displayName="DropdownMenuItem";var uM=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(ub,{...e,...d,ref:b})});uM.displayName="DropdownMenuCheckboxItem",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(uf,{...e,...d,ref:b})}).displayName="DropdownMenuRadioGroup";var uN=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(uh,{...e,...d,ref:b})});uN.displayName="DropdownMenuRadioItem";var uO=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(ul,{...e,...d,ref:b})});uO.displayName="DropdownMenuItemIndicator";var uP=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(um,{...e,...d,ref:b})});uP.displayName="DropdownMenuSeparator",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(un,{...e,...d,ref:b})}).displayName="DropdownMenuArrow";var uQ=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(ur,{...e,...d,ref:b})});uQ.displayName="DropdownMenuSubTrigger";var uR=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uB(c);return(0,C.jsx)(ut,{...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)"}})});uR.displayName="DropdownMenuSubContent";let uS=(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)(uQ,{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=uQ.displayName,D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(uR,{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=uR.displayName;let uT=D.forwardRef(({className:a,sideOffset:b=4,...c},d)=>(0,C.jsx)(uH,{children:(0,C.jsx)(uJ,{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})}));uT.displayName=uJ.displayName;let uU=D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uL,{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}));uU.displayName=uL.displayName,D.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,C.jsxs)(uM,{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)(uO,{children:(0,C.jsx)(bh.Check,{className:"h-4 w-4"})})}),b]})).displayName=uM.displayName,D.forwardRef(({className:a,children:b,...c},d)=>(0,C.jsxs)(uN,{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)(uO,{children:(0,C.jsx)(uS,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=uN.displayName,D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uK,{ref:d,className:(0,S.cn)("px-2 py-1.5 text-sm font-semibold",b&&"pl-8",a),...c})).displayName=uK.displayName;let uV=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(uP,{ref:c,className:(0,S.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));uV.displayName=uP.displayName;var bi=bi;let uW=(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"}]]),uX=(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"}]]);function uY(){(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)(uE,{children:[(0,C.jsx)(uG,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",children:["Actions",(0,C.jsx)(uW,{className:"w-4 h-4 ml-2"})]})}),(0,C.jsxs)(uT,{align:"end",className:"w-48",children:[(0,C.jsxs)(uU,{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)(mV,{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)(uU,{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)(mK,{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)(uV,{}),(0,C.jsxs)(uU,{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)(uX,{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)(uV,{}),(0,C.jsxs)(uU,{onClick:()=>n(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,C.jsx)(mK,{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)("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)(th,{}),(0,C.jsx)(ti,{}),(0,C.jsx)(sO,{hideReflectFields:!0})]})]}),"configuration"===i&&k&&(0,C.jsx)("div",{className:"space-y-6",children:(0,C.jsx)(s6,{})})]})]}),"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)(sI,{})]}),"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)(sF,{})]}),"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)(me,{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)(me,{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)(me,{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)(tl,{},"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)(mL,{})]}),"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)(mM,{})]})]})})]}),(0,C.jsx)(mm,{open:l,onOpenChange:n,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Memory Bank"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:o,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(mm,{open:w,onOpenChange:x,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Reset Configuration"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:y,children:"Cancel"}),(0,C.jsx)(mI,{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)(uX,{className:"w-4 h-4 mr-2"}),"Reset Configuration"]})})]})]})}),(0,C.jsx)(mm,{open:q,onOpenChange:r,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Clear Observations"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:s,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})})]})}a.s(["default",()=>uY],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)(mP,{children:(0,C.jsxs)(mT,{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)(mN.Select,{value:p,onValueChange:a=>q(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mN.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mN.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)(mO.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)(mO.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)(mN.Select,{value:I,onValueChange:a=>J(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mN.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),B&&(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{children:"Answer"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,C.jsx)(q6,{remarkPlugins:[sB],children:z.text})})})]}),(0,C.jsxs)(mP,{className:"border-blue-200 dark:border-blue-800",children:[(0,C.jsxs)(mQ,{className:"py-4",children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(mW,{className:"w-4 h-4"}),"Add Directive"]}),(0,C.jsx)(mS,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,C.jsx)(mT,{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)(mZ.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)(mP,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,C.jsxs)(mQ,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-base",children:[(0,C.jsx)(mV,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",z.observations_created.length,")"]}),(0,C.jsx)(mS,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,C.jsx)(mT,{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)(mP,{className:"h-fit",children:[(0,C.jsxs)(mQ,{className:"pb-3",children:[(0,C.jsx)(mR,{className:"text-base",children:"Execution Trace"}),(0,C.jsxs)(mS,{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)(mT,{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)(mY,{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)(nF,{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)(nF,{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)(mU.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)(mU.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)(mP,{className:"h-fit",children:[(0,C.jsxs)(mQ,{className:"pb-3",children:[(0,C.jsx)(mR,{className:"text-base",children:"Based On"}),(0,C.jsxs)(mS,{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)(mT,{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)(mU.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)(mU.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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nF,{src:z,collapsed:2,theme:"default"})})})]})]}),!B&&!z&&(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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)(bn,{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)(mX,{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)(mV,{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)(q6,{remarkPlugins:[sB],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)(sE,{mentalModelId:ak,onClose:()=>al(null)})]}):(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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 sG=a.i(5784);let sH=(0,K.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function sI(){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)(mP,{children:(0,C.jsxs)(mT,{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)(mO.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)(mO.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)(nH,{className:"h-4 w-4 text-muted-foreground"}),(0,C.jsxs)(mN.Select,{value:u,onValueChange:a=>v(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-24 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"low",children:"Low"}),(0,C.jsx)(mN.SelectItem,{value:"mid",children:"Mid"}),(0,C.jsx)(mN.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)(mO.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)(mO.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)(mN.Select,{value:L,onValueChange:a=>P(a),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-40 h-8",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"any",children:"Any (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"all",children:"All (incl. untagged)"}),(0,C.jsx)(mN.SelectItem,{value:"any_strict",children:"Any (strict)"}),(0,C.jsx)(mN.SelectItem,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),ae&&(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,C.jsx)(mQ,{className:"py-3",children:(0,C.jsxs)(mR,{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)(mT,{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)(mP,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>ak(a),children:(0,C.jsx)(mT,{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)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{className:`transition-colors ${f?"border-primary":j.border}`,children:(0,C.jsxs)(mT,{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)(sG.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)(sG.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)(sH,{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)(mP,{className:`cursor-pointer transition-colors ${d?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(c),children:(0,C.jsx)(mT,{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)(sG.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)(sH,{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)(mP,{className:`cursor-pointer transition-colors ${j?"border-primary":"hover:border-primary/50"}`,onClick:()=>ap(i),children:(0,C.jsx)(mT,{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)(sG.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)(sH,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,C.jsx)(mP,{className:"border-primary bg-primary/5",children:(0,C.jsx)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{children:(0,C.jsx)(mR,{className:"text-lg",children:"Raw Response"})}),(0,C.jsx)(mT,{children:(0,C.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,C.jsx)(nF,{src:{results:R,...T&&{entities:T},...Z&&{chunks:Z},..._&&{observations:_},trace:ab},collapsed:2,theme:"default"})})})]})]}),!ae&&!R&&(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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)(bo,{memory:aj,onClose:()=>ak(null),inPanel:!0,bankId:p||void 0})})]}):(0,C.jsx)(mP,{className:"border-dashed",children:(0,C.jsxs)(mT,{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 sJ=(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 sK=a.i(83604),sK=sK,sL=a.i(15618),bi=bi;let sM=(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"}]]),sN={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 sO({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)(mP,{children:(0,C.jsxs)(mT,{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)(mP,{children:[(0,C.jsx)(mQ,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(mV,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,C.jsx)(mS,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)(W.Button,{onClick:()=>w(!0),variant:"ghost",size:"sm",children:(0,C.jsx)(sM,{className:"h-4 w-4"})})]})}),(0,C.jsx)(mT,{children:g&&(0,C.jsx)("div",{className:"space-y-4",children:Object.keys(sN).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:sN[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sN[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:sN[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:sN[a].highLabel})]})]},a))})})]}),(0,C.jsxs)(mP,{children:[(0,C.jsx)(mQ,{className:"pb-2",children:(0,C.jsxs)("div",{className:"flex items-start justify-between",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)(mR,{className:"flex items-center gap-2 text-lg",children:[(0,C.jsx)(sJ,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,C.jsx)(mS,{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)(sM,{className:"h-4 w-4"})})]})}),(0,C.jsx)(mT,{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)(sK.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)(sL.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)(mP,{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)(mT,{className:"p-3",children:(0,C.jsxs)("div",{className:"flex items-start gap-2",children:[(0,C.jsx)(sK.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)(sK.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)(mm,{open:N,onOpenChange:O,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Memory Bank"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:P,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(mm,{open:R,onOpenChange:S,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Clear Observations"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:T,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,C.jsx)(sR,{open:z,mode:"create",onClose:()=>A(!1),onCreated:a=>{q(b=>[a,...b]),A(!1)}}),(0,C.jsx)(mm,{open:!!J,onOpenChange:a=>!a&&K(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Directive"}),(0,C.jsxs)(mH,{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)(mF,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mJ,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mI,{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)(sS,{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)(sP,{disposition:g.disposition,onClose:()=>w(!1),onSaved:async()=>{await ai(),w(!1)}}),x&&g&&(0,C.jsx)(sQ,{mission:g.mission||"",onClose:()=>y(!1),onSaved:async()=>{await ai(),y(!1)}})]}):(0,C.jsx)(mP,{children:(0,C.jsxs)(mT,{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 sP({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)(bj.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Edit Disposition Traits"}),(0,C.jsx)(bj.DialogDescription,{children:"Traits that shape the reasoning and perspective"})]}),(0,C.jsx)("div",{className:"space-y-4 py-4",children:Object.keys(sN).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:sN[a].label}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground",children:sN[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:sN[a].lowLabel}),(0,C.jsx)("span",{children:sN[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)(bj.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 sQ({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)(bj.Dialog,{open:!0,onOpenChange:b,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-xl",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Edit Mission"}),(0,C.jsx)(bj.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)(mZ.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)(bj.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 sR({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)(bj.Dialog,{open:a,onOpenChange:a=>!a&&n(),children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsxs)(bj.DialogTitle,{className:"flex items-center gap-2",children:[(0,C.jsx)(sK.default,{className:"w-5 h-5 text-rose-500"}),"create"===b?"Create":"Edit"," Directive"]}),(0,C.jsx)(bj.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)(mZ.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)(bj.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 sS({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)(sK.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)(sM,{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)(mK,{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)(q6,{remarkPlugins:[sB],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)(sR,{open:e,mode:"edit",directive:a,onClose:()=>f(!1),onSaved:d})]})}let sT=(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"}}),sU=D.forwardRef(({className:a,variant:b,...c},d)=>(0,C.jsx)("div",{ref:d,role:"alert",className:(0,S.cn)(sT({variant:b}),a),...c}));sU.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 sV=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)("div",{ref:c,className:(0,S.cn)("text-sm [&_p]:leading-relaxed",a),...b}));sV.displayName="AlertDescription";var bi=bi;let sW=(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"}]]),sX=[{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"}],sY=[{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"}],sZ=sX.map(a=>({category:a.value,threshold:"BLOCK_NONE"})),s$=[{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"]}],s_=s$.flatMap(a=>a.tools);function s0(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 s1(a){return{enable_observations:a.enable_observations??null,observations_mission:a.observations_mission??null}}function s2(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 s3(a){return{mcp_enabled_tools:a.mcp_enabled_tools??null}}function s4(a){return{llm_gemini_safety_settings:a.llm_gemini_safety_settings??null}}let s5={reflect_mission:"",disposition_skepticism:3,disposition_literalism:3,disposition_empathy:3};function s6(){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)(s5),[j,k]=(0,D.useState)(s0({})),[l,n]=(0,D.useState)(s1({})),[o,p]=(0,D.useState)(s2({})),[q,r]=(0,D.useState)(s5),[s,t]=(0,D.useState)(s3({})),[u,v]=(0,D.useState)(s4({})),[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(s0(f)),[j,f]),_=(0,D.useMemo)(()=>JSON.stringify(l)!==JSON.stringify(s1(f)),[l,f]),aa=(0,D.useMemo)(()=>JSON.stringify(o)!==JSON.stringify(s2(f)),[o,f]),ab=(0,D.useMemo)(()=>JSON.stringify(q)!==JSON.stringify(h),[q,h]),ac=(0,D.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(s3(f)),[s,f]),ad=(0,D.useMemo)(()=>JSON.stringify(u)!==JSON.stringify(s4(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(s0(d)),n(s1(d)),p(s2(d)),r(e),t(s3(d)),v(s4(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)(s8,{title:"Retain",description:"Control what gets extracted and stored from content",error:M,dirty:$,saving:w,onSave:af,children:[(0,C.jsx)(s9,{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)(ta,{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)(s9,{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)(mN.Select,{value:j.retain_extraction_mode??"",onValueChange:a=>k(b=>({...b,retain_extraction_mode:a})),children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-full",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsx)(mN.SelectContent,{children:["concise","verbose","custom"].map(a=>(0,C.jsx)(mN.SelectItem,{value:a,children:a},a))})]})}),"custom"===j.retain_extraction_mode&&(0,C.jsx)(ta,{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)(s8,{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)(s9,{label:"Free Form Entities",description:"Extract regular named entities (people, places, concepts) alongside label groups. Disable to restrict extraction to label groups 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)(tc,{value:o.entity_labels??[],onChange:a=>p(b=>({...b,entity_labels:a.length>0?a:null}))})]}),(0,C.jsxs)(s8,{title:"Observations",description:"Control how facts are synthesized into durable observations",error:O,dirty:_,saving:y,onSave:ag,children:[(0,C.jsx)(s9,{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)(ta,{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.jsxs)(s8,{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)(ta,{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)(tb,{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)(tb,{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)(tb,{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)(s8,{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)(s9,{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?[...s_]: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)(s7,{selected:s.mcp_enabled_tools,onChange:a=>t({mcp_enabled_tools:a})})]}),(0,C.jsx)(s8,{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)(s9,{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?[...sZ]: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)(td,{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 s7({selected:a,onChange:b}){let c=new Set(a),d=s_.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 ",s_.length," tools enabled"]}),(0,C.jsx)("button",{type:"button",onClick:()=>{b(d?[]:[...s_])},className:"text-xs text-primary hover:underline",children:d?"Deselect all":"Select all"})]}),(0,C.jsx)("div",{className:"space-y-4",children:s$.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(s_.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(s_.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 s8({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)(mP,{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)(sU,{variant:"destructive",children:[(0,C.jsx)(sW,{className:"h-4 w-4"}),(0,C.jsx)(sV,{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 s9({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 ta({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)(mZ.Textarea,{value:c,onChange:a=>d(a.target.value),placeholder:e,rows:f??3,className:"font-mono text-sm"})]})})}function tb({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 tc({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:"Label Groups"}),(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 label groups 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)(sG.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)(mN.Select,{value:g.type,onValueChange:a=>e(h,{type:a,..."text"===a?{values:[]}:{}}),children:[(0,C.jsx)(mN.SelectTrigger,{className:"h-8 text-xs w-32 shrink-0",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"value",className:"text-xs",children:"Single value"}),(0,C.jsx)(mN.SelectItem,{value:"multi-values",className:"text-xs",children:"Multi-values"}),(0,C.jsx)(mN.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)(mO.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)(mK,{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)(mK,{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)(sL.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)(sL.Plus,{className:"h-3.5 w-3.5"}),"Add attribute"]})]})}function td({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:sX.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)(mN.Select,{value:c(a.value),onValueChange:d=>{var e;return e=a.value,void b(sX.map(a=>({category:a.value,threshold:a.value===e?d:c(a.value)})))},children:[(0,C.jsx)(mN.SelectTrigger,{className:"w-48 h-8 text-xs",children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsx)(mN.SelectContent,{children:sY.map(a=>(0,C.jsx)(mN.SelectItem,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]},a.value))})]})}let te=(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"}]]),tf=(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"}]]),tg=(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 th(){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)(mP,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,C.jsx)(mT,{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)(mP,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,C.jsx)(mT,{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)(te,{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)(mP,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,C.jsx)(mT,{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)(tf,{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)(mP,{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)(mT,{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)(tg,{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;function ti(){let{currentBank:a}=(0,H.useBank)(),[b,c]=(0,D.useState)([]),[d,e]=(0,D.useState)(0),[f,g]=(0,D.useState)(null),[h]=(0,D.useState)(10),[i,j]=(0,D.useState)(0),[k,l]=(0,D.useState)(null),[n,o]=(0,D.useState)(!1),[p,q]=(0,D.useState)(null),[r,s]=(0,D.useState)(!1),[t,u]=(0,D.useState)(!1),v=async(b=f,d=i)=>{if(a){o(!0);try{let f=await V.client.listOperations(a,{status:b||void 0,limit:h,offset:d});c(f.operations||[]),e(f.total||0)}catch(a){console.error("Error loading operations:",a)}finally{o(!1)}}},w=a=>{j(a),v(f,a)},x=async b=>{if(a){l(b);try{await V.client.cancelOperation(a,b),await v()}catch(a){}finally{l(null)}}},y=async b=>{if(a){u(!0),s(!0);try{let c=await V.client.getOperationStatus(a,b);q(c)}catch(a){console.error("Error loading operation details:",a),q({error:"Failed to load operation details"})}finally{u(!1)}}};return((0,D.useEffect)(()=>{if(a){v();let a=setInterval(()=>v(),5e3);return()=>clearInterval(a)}},[a]),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:()=>v(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",disabled:n,children:(0,C.jsx)(ab,{className:`w-4 h-4 text-muted-foreground hover:text-foreground ${n?"animate-spin":""}`})})]}),(0,C.jsxs)("p",{className:"text-sm text-muted-foreground",children:[d," operation",1!==d?"s":"",f?` (${f})`:""]})]}),(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),j(0),v(b,0)},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:()=>y(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)(sW,{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.jsx)(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(),x(a.id)},disabled:k===a.id,children:[k===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"}),k===a.id?"":"Cancel"]})})]},a.id))})]})}),d>h&&(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 ",i+1,"-",Math.min(i+h,d)," of"," ",d]}),(0,C.jsxs)("div",{className:"flex gap-2",children:[(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>w(Math.max(0,i-h)),disabled:0===i,children:"Previous"}),(0,C.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>w(i+h),disabled:i+h>=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)(bj.Dialog,{open:r,onOpenChange:s,children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Operation Details"}),(0,C.jsx)(bj.DialogDescription,{children:p?.operation_id&&(0,C.jsx)("span",{className:"font-mono text-xs",children:p.operation_id})})]}),t?(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"})}):p?(0,C.jsx)("div",{className:"space-y-4",children:p.error?(0,C.jsx)("div",{className:"text-red-600 dark:text-red-400",children:p.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"===p.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"===p.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)(sW,{className:"w-3 h-3"}),"failed"]}),"completed"===p.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:p.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:p.created_at?new Date(p.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:p.updated_at?new Date(p.updated_at).toLocaleString():"N/A"})]}),p.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(p.completed_at).toLocaleString()})]}),p.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:p.result_metadata.items_count})]})]}),p.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:p.error_message})]}),p.child_operations&&p.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 (",p.result_metadata?.num_sub_batches||p.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:p.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)(sW,{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 tj=(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"}]]);var bi=bi;function tk({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)(bj.Dialog,{open:k,onOpenChange:a=>!a&&b(),children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,C.jsx)(nG.VisuallyHidden,{children:(0,C.jsx)(bj.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)(q6,{remarkPlugins:[sB],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 tl(){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)(mP,{children:(0,C.jsx)(mT,{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)(sL.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)(tj,{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)(mP,{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)(mT,{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)(mK,{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)(q6,{remarkPlugins:[sB],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)(mK,{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)(tm,{open:l,onClose:()=>n(!1),onCreated:()=>{n(!1),z()}}),(0,C.jsx)(mm,{open:!!u,onOpenChange:a=>!a&&v(null),children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Mental Model"}),(0,C.jsxs)(mH,{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)(mF,{className:"flex-row justify-end space-x-2",children:[(0,C.jsx)(mJ,{className:"mt-0",children:"Cancel"}),(0,C.jsxs)(mI,{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)(to,{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)(tn,{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 tm({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)(bj.Dialog,{open:a,onOpenChange:a=>{a||(h({id:"",name:"",sourceQuery:"",maxTokens:"2048",tags:"",autoRefresh:!1}),b())},children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Create Mental Model"}),(0,C.jsx)(bj.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)(mO.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)(bj.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 tn({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)(bj.Dialog,{open:a,onOpenChange:a=>!a&&c(),children:(0,C.jsxs)(bj.DialogContent,{className:"sm:max-w-lg",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Update Mental Model"}),(0,C.jsx)(bj.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)(mO.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)(bj.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 to({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=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)}},o=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})}`},p=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}))):[],q=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.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:d,className:"h-7 w-7 p-0",children:(0,C.jsx)(sM,{className:"h-3.5 w-3.5"})})]}),(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)(W.Button,{variant:"outline",size:"sm",onClick:n,disabled:g,className:"h-8",children:[g?(0,C.jsx)(bi.default,{className:"w-4 h-4 animate-spin mr-1"}):(0,C.jsx)(ab,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(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:o(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:o(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)(q6,{remarkPlugins:[sB],children:a.content})})]}),p.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 (",p.length," ",1===p.length?"fact":"facts",")"]}),(0,C.jsx)("div",{className:"space-y-3",children:p.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)})})]}),q.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 (",q.length,")"]}),(0,C.jsx)("div",{className:"space-y-3",children:q.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.'})]}),(0,C.jsx)("div",{className:"pt-4 border-t border-border",children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:c,className:"text-muted-foreground hover:text-destructive hover:border-destructive",children:[(0,C.jsx)(mK,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]}),i&&f&&(0,C.jsx)(bn,{memoryId:i,onClose:()=>j(null)}),k&&f&&(0,C.jsx)(tk,{directiveId:k,onClose:()=>l(null)})]})}let tp=(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"}]]),tq=(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 tr=["consolidation.completed","retain.completed"],ts={url:"",secret:"",event_types:["consolidation.completed"],enabled:!0,http_config:{method:"POST",timeout_seconds:30,headers:[],params:[]}};function tt(a){return Object.fromEntries(a.filter(a=>a.key.trim()).map(a=>[a.key,a.value]))}function tu(a){return{method:a.method,timeout_seconds:a.timeout_seconds,headers:tt(a.headers),params:tt(a.params)}}function tv({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)(sL.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 tw({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)(sG.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)(sW,{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 tx(){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)(ts),[s,t]=(0,D.useState)(!1),[u,v]=(0,D.useState)(null),[w,x]=(0,D.useState)(ts),[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:tu(q.http_config)}),g(!1),r(ts),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:tu(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)(sL.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)(tp,{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)(sM,{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)(mK,{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)(bj.Dialog,{open:f,onOpenChange:a=>{a||(r(ts),p(!1)),g(a)},children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Add Webhook"}),(0,C.jsx)(bj.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)(mN.Select,{value:q.http_config.method,onValueChange:a=>r(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mN.SelectTrigger,{children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mN.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)(tq,{className:"w-4 h-4"}):(0,C.jsx)(tp,{className:"w-4 h-4"})})]})]}),(0,C.jsx)(tv,{label:"Custom Headers",pairs:q.http_config.headers,onChange:a=>r(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(tv,{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:tr.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mO.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)(bj.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)(bj.Dialog,{open:s,onOpenChange:a=>{a||(v(null),x(ts),z(!1),B(!1)),t(a)},children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Edit Webhook"}),(0,C.jsx)(bj.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)(mN.Select,{value:w.http_config.method,onValueChange:a=>x(b=>({...b,http_config:{...b.http_config,method:a}})),children:[(0,C.jsx)(mN.SelectTrigger,{children:(0,C.jsx)(mN.SelectValue,{})}),(0,C.jsxs)(mN.SelectContent,{children:[(0,C.jsx)(mN.SelectItem,{value:"POST",children:"POST"}),(0,C.jsx)(mN.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)(tq,{className:"w-4 h-4"}):(0,C.jsx)(tp,{className:"w-4 h-4"})})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,C.jsx)(mO.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)(tv,{label:"Custom Headers",pairs:w.http_config.headers,onChange:a=>x(b=>({...b,http_config:{...b.http_config,headers:a}}))}),(0,C.jsx)(tv,{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:tr.map(a=>(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(mO.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)(bj.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)(bj.Dialog,{open:!!l,onOpenChange:a=>{a||n(null)},children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-md",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Delete Webhook"}),(0,C.jsx)(bj.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)(bj.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)(bj.Dialog,{open:G,onOpenChange:a=>{a||(M([]),Q(null)),I(a)},children:(0,C.jsxs)(bj.DialogContent,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[(0,C.jsxs)(bj.DialogHeader,{children:[(0,C.jsx)(bj.DialogTitle,{children:"Webhook Deliveries"}),J&&(0,C.jsx)(bj.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)(tw,{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 ty=a.i(96743),tz=a.i(86228),tA=a.i(22297),tB=a.i(92843),tC=a.i(4691),tD=a.i(92616),tE=a.i(77192),tF=a.i(24050),tG=Symbol("radix.slottable");function tH(a){return D.isValidElement(a)&&"function"==typeof a.type&&"__radixId"in a.type&&a.type.__radixId===tG}var tI=a.i(46872),tJ=a.i(41852),tK=a.i(52081),tL=["Enter"," "],tM=["ArrowUp","PageDown","End"],tN=["ArrowDown","PageUp","Home",...tM],tO={ltr:[...tL,"ArrowRight"],rtl:[...tL,"ArrowLeft"]},tP={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tQ="Menu",[tR,tS,tT]=(0,aD.createCollection)(tQ),[tU,tV]=(0,ax.createContextScope)(tQ,[tT,tC.createPopperScope,tF.createRovingFocusGroupScope]),tW=(0,tC.createPopperScope)(),tX=(0,tF.createRovingFocusGroupScope)(),[tY,tZ]=tU(tQ),[t$,t_]=tU(tQ),t0=a=>{let{__scopeMenu:b,open:c=!1,children:d,dir:e,onOpenChange:f,modal:g=!0}=a,h=tW(b),[i,j]=D.useState(null),k=D.useRef(!1),l=(0,tI.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)(tC.Root,{...h,children:(0,C.jsx)(tY,{scope:b,open:c,onOpenChange:l,content:i,onContentChange:j,children:(0,C.jsx)(t$,{scope:b,onClose:D.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:k,dir:n,modal:g,children:d})})})};t0.displayName=tQ;var t1=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tW(c);return(0,C.jsx)(tC.Anchor,{...e,...d,ref:b})});t1.displayName="MenuAnchor";var t2="MenuPortal",[t3,t4]=tU(t2,{forceMount:void 0}),t5=a=>{let{__scopeMenu:b,forceMount:c,children:d,container:e}=a,f=tZ(t2,b);return(0,C.jsx)(t3,{scope:b,forceMount:c,children:(0,C.jsx)(tE.Presence,{present:c||f.open,children:(0,C.jsx)(tD.Portal,{asChild:!0,container:e,children:d})})})};t5.displayName=t2;var t6="MenuContent",[t7,t8]=tU(t6),t9=D.forwardRef((a,b)=>{let c=t4(t6,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tZ(t6,a.__scopeMenu),g=t_(t6,a.__scopeMenu);return(0,C.jsx)(tR.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tE.Presence,{present:d||f.open,children:(0,C.jsx)(tR.Slot,{scope:a.__scopeMenu,children:g.modal?(0,C.jsx)(ua,{...e,ref:b}):(0,C.jsx)(ub,{...e,ref:b})})})})}),ua=D.forwardRef((a,b)=>{let c=tZ(t6,a.__scopeMenu),d=D.useRef(null),e=(0,aw.useComposedRefs)(b,d);return D.useEffect(()=>{let a=d.current;if(a)return(0,tJ.hideOthers)(a)},[]),(0,C.jsx)(ud,{...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)})}),ub=D.forwardRef((a,b)=>{let c=tZ(t6,a.__scopeMenu);return(0,C.jsx)(ud,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>c.onOpenChange(!1)})}),uc=((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(tH);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),ud=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=tZ(t6,c),s=t_(t6,c),t=tW(c),u=tX(c),v=tS(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?tK.RemoveScroll:D.Fragment;D.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,tz.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)(t7,{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:uc,allowPinchZoom:!0}:void 0,children:(0,C.jsx)(tA.FocusScope,{asChild:!0,trapped:e,onMountAutoFocus:(0,av.composeEventHandlers)(f,a=>{a.preventDefault(),y.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:g,children:(0,C.jsx)(ty.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:j,onPointerDownOutside:k,onFocusOutside:l,onInteractOutside:n,onDismiss:o,children:(0,C.jsx)(tF.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)(tC.Content,{role:"menu","aria-orientation":"vertical","data-state":uD(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||!tN.includes(a.key))return;a.preventDefault();let g=v().filter(a=>!a.disabled).map(a=>a.ref.current);tM.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,uG(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)}))})})})})})})});t9.displayName=t6;var ue=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"group",...d,ref:b})});ue.displayName="MenuGroup";var uf=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{...d,ref:b})});uf.displayName="MenuLabel";var ug="MenuItem",uh="menu.itemSelect",ui=D.forwardRef((a,b)=>{let{disabled:c=!1,onSelect:d,...e}=a,f=D.useRef(null),g=t_(ug,a.__scopeMenu),h=t8(ug,a.__scopeMenu),i=(0,aw.useComposedRefs)(b,f),j=D.useRef(!1);return(0,C.jsx)(uj,{...e,ref:i,disabled:c,onClick:(0,av.composeEventHandlers)(a.onClick,()=>{let a=f.current;if(!c&&a){let b=new CustomEvent(uh,{bubbles:!0,cancelable:!0});a.addEventListener(uh,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||tL.includes(a.key)&&(a.currentTarget.click(),a.preventDefault())})})});ui.displayName=ug;var uj=D.forwardRef((a,b)=>{let{__scopeMenu:c,disabled:d=!1,textValue:e,...f}=a,g=t8(ug,c),h=tX(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)(tR.ItemSlot,{scope:c,disabled:d,textValue:e??n,children:(0,C.jsx)(tF.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,uG(a=>{d?g.onItemLeave(a):(g.onItemEnter(a),a.defaultPrevented||a.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,av.composeEventHandlers)(a.onPointerLeave,uG(a=>g.onItemLeave(a))),onFocus:(0,av.composeEventHandlers)(a.onFocus,()=>l(!0)),onBlur:(0,av.composeEventHandlers)(a.onBlur,()=>l(!1))})})})}),uk=D.forwardRef((a,b)=>{let{checked:c=!1,onCheckedChange:d,...e}=a;return(0,C.jsx)(us,{scope:a.__scopeMenu,checked:c,children:(0,C.jsx)(ui,{role:"menuitemcheckbox","aria-checked":uE(c)?"mixed":c,...e,ref:b,"data-state":uF(c),onSelect:(0,av.composeEventHandlers)(e.onSelect,()=>d?.(!!uE(c)||!c),{checkForDefaultPrevented:!1})})})});uk.displayName="MenuCheckboxItem";var ul="MenuRadioGroup",[um,un]=tU(ul,{value:void 0,onValueChange:()=>{}}),uo=D.forwardRef((a,b)=>{let{value:c,onValueChange:d,...e}=a,f=(0,tI.useCallbackRef)(d);return(0,C.jsx)(um,{scope:a.__scopeMenu,value:c,onValueChange:f,children:(0,C.jsx)(ue,{...e,ref:b})})});uo.displayName=ul;var up="MenuRadioItem",uq=D.forwardRef((a,b)=>{let{value:c,...d}=a,e=un(up,a.__scopeMenu),f=c===e.value;return(0,C.jsx)(us,{scope:a.__scopeMenu,checked:f,children:(0,C.jsx)(ui,{role:"menuitemradio","aria-checked":f,...d,ref:b,"data-state":uF(f),onSelect:(0,av.composeEventHandlers)(d.onSelect,()=>e.onValueChange?.(c),{checkForDefaultPrevented:!1})})})});uq.displayName=up;var ur="MenuItemIndicator",[us,ut]=tU(ur,{checked:!1}),uu=D.forwardRef((a,b)=>{let{__scopeMenu:c,forceMount:d,...e}=a,f=ut(ur,c);return(0,C.jsx)(tE.Presence,{present:d||uE(f.checked)||!0===f.checked,children:(0,C.jsx)(aC.Primitive.span,{...e,ref:b,"data-state":uF(f.checked)})})});uu.displayName=ur;var uv=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a;return(0,C.jsx)(aC.Primitive.div,{role:"separator","aria-orientation":"horizontal",...d,ref:b})});uv.displayName="MenuSeparator";var uw=D.forwardRef((a,b)=>{let{__scopeMenu:c,...d}=a,e=tW(c);return(0,C.jsx)(tC.Arrow,{...e,...d,ref:b})});uw.displayName="MenuArrow";var[ux,uy]=tU("MenuSub"),uz="MenuSubTrigger",uA=D.forwardRef((a,b)=>{let c=tZ(uz,a.__scopeMenu),d=t_(uz,a.__scopeMenu),e=uy(uz,a.__scopeMenu),f=t8(uz,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)(t1,{asChild:!0,...j,children:(0,C.jsx)(uj,{id:e.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":e.contentId,"data-state":uD(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,uG(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,uG(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||tO[d.dir].includes(b.key)&&(c.onOpenChange(!0),c.content?.focus(),b.preventDefault())})})})});uA.displayName=uz;var uB="MenuSubContent",uC=D.forwardRef((a,b)=>{let c=t4(t6,a.__scopeMenu),{forceMount:d=c.forceMount,...e}=a,f=tZ(t6,a.__scopeMenu),g=t_(t6,a.__scopeMenu),h=uy(uB,a.__scopeMenu),i=D.useRef(null),j=(0,aw.useComposedRefs)(b,i);return(0,C.jsx)(tR.Provider,{scope:a.__scopeMenu,children:(0,C.jsx)(tE.Presence,{present:d||f.open,children:(0,C.jsx)(tR.Slot,{scope:a.__scopeMenu,children:(0,C.jsx)(ud,{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=tP[g.dir].includes(a.key);b&&c&&(f.onOpenChange(!1),h.trigger?.focus(),a.preventDefault())})})})})})});function uD(a){return a?"open":"closed"}function uE(a){return"indeterminate"===a}function uF(a){return uE(a)?"indeterminate":a?"checked":"unchecked"}function uG(a){return b=>"mouse"===b.pointerType?a(b):void 0}uC.displayName=uB;var uH="DropdownMenu",[uI,uJ]=(0,ax.createContextScope)(uH,[tV]),uK=tV(),[uL,uM]=uI(uH),uN=a=>{let{__scopeDropdownMenu:b,children:c,dir:d,open:e,defaultOpen:f,onOpenChange:g,modal:h=!0}=a,i=uK(b),j=D.useRef(null),[k,l]=(0,ay.useControllableState)({prop:e,defaultProp:f??!1,onChange:g,caller:uH});return(0,C.jsx)(uL,{scope:b,triggerId:(0,tB.useId)(),triggerRef:j,contentId:(0,tB.useId)(),open:k,onOpenChange:l,onOpenToggle:D.useCallback(()=>l(a=>!a),[l]),modal:h,children:(0,C.jsx)(t0,{...i,open:k,onOpenChange:l,dir:d,modal:h,children:c})})};uN.displayName=uH;var uO="DropdownMenuTrigger",uP=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,disabled:d=!1,...e}=a,f=uM(uO,c),g=uK(c);return(0,C.jsx)(t1,{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())})})})});uP.displayName=uO;var uQ=a=>{let{__scopeDropdownMenu:b,...c}=a,d=uK(b);return(0,C.jsx)(t5,{...d,...c})};uQ.displayName="DropdownMenuPortal";var uR="DropdownMenuContent",uS=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uM(uR,c),f=uK(c),g=D.useRef(!1);return(0,C.jsx)(t9,{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)"}})});uS.displayName=uR,D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(ue,{...e,...d,ref:b})}).displayName="DropdownMenuGroup";var uT=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uf,{...e,...d,ref:b})});uT.displayName="DropdownMenuLabel";var uU=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(ui,{...e,...d,ref:b})});uU.displayName="DropdownMenuItem";var uV=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uk,{...e,...d,ref:b})});uV.displayName="DropdownMenuCheckboxItem",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uo,{...e,...d,ref:b})}).displayName="DropdownMenuRadioGroup";var uW=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uq,{...e,...d,ref:b})});uW.displayName="DropdownMenuRadioItem";var uX=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uu,{...e,...d,ref:b})});uX.displayName="DropdownMenuItemIndicator";var uY=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uv,{...e,...d,ref:b})});uY.displayName="DropdownMenuSeparator",D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uw,{...e,...d,ref:b})}).displayName="DropdownMenuArrow";var uZ=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uA,{...e,...d,ref:b})});uZ.displayName="DropdownMenuSubTrigger";var u$=D.forwardRef((a,b)=>{let{__scopeDropdownMenu:c,...d}=a,e=uK(c);return(0,C.jsx)(uC,{...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)"}})});u$.displayName="DropdownMenuSubContent";let u_=(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)(uZ,{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=uZ.displayName,D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(u$,{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=u$.displayName;let u0=D.forwardRef(({className:a,sideOffset:b=4,...c},d)=>(0,C.jsx)(uQ,{children:(0,C.jsx)(uS,{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})}));u0.displayName=uS.displayName;let u1=D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uU,{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}));u1.displayName=uU.displayName,D.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,C.jsxs)(uV,{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)(uX,{children:(0,C.jsx)(bh.Check,{className:"h-4 w-4"})})}),b]})).displayName=uV.displayName,D.forwardRef(({className:a,children:b,...c},d)=>(0,C.jsxs)(uW,{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)(uX,{children:(0,C.jsx)(u_,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=uW.displayName,D.forwardRef(({className:a,inset:b,...c},d)=>(0,C.jsx)(uT,{ref:d,className:(0,S.cn)("px-2 py-1.5 text-sm font-semibold",b&&"pl-8",a),...c})).displayName=uT.displayName;let u2=D.forwardRef(({className:a,...b},c)=>(0,C.jsx)(uY,{ref:c,className:(0,S.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));u2.displayName=uY.displayName;var bi=bi;let u3=(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"}]]),u4=(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"}]]);function u5(){(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)(uN,{children:[(0,C.jsx)(uP,{asChild:!0,children:(0,C.jsxs)(W.Button,{variant:"outline",size:"sm",children:["Actions",(0,C.jsx)(u3,{className:"w-4 h-4 ml-2"})]})}),(0,C.jsxs)(u0,{align:"end",className:"w-48",children:[(0,C.jsxs)(u1,{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)(mV,{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)(u1,{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)(mK,{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)(u2,{}),(0,C.jsxs)(u1,{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)(u4,{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)(u2,{}),(0,C.jsxs)(u1,{onClick:()=>n(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,C.jsx)(mK,{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)(th,{}),(0,C.jsx)(ti,{}),(0,C.jsx)(sO,{hideReflectFields:!0})]})]}),"configuration"===i&&k&&(0,C.jsx)("div",{className:"space-y-6",children:(0,C.jsx)(s6,{})}),"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)(tx,{})]})]})]}),"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)(sI,{})]}),"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)(sF,{})]}),"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)(me,{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)(me,{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)(me,{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)(tl,{},"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)(mL,{})]}),"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)(mM,{})]})]})})]}),(0,C.jsx)(mm,{open:l,onOpenChange:n,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Delete Memory Bank"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:o,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,C.jsx)(mm,{open:w,onOpenChange:x,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Reset Configuration"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:y,children:"Cancel"}),(0,C.jsx)(mI,{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)(u4,{className:"w-4 h-4 mr-2"}),"Reset Configuration"]})})]})]})}),(0,C.jsx)(mm,{open:q,onOpenChange:r,children:(0,C.jsxs)(mD,{children:[(0,C.jsxs)(mE,{children:[(0,C.jsx)(mG,{children:"Clear Observations"}),(0,C.jsx)(mH,{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)(mF,{children:[(0,C.jsx)(mJ,{disabled:s,children:"Cancel"}),(0,C.jsx)(mI,{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)(mK,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})})]})}a.s(["default",()=>u5],73101)}];
9
9
 
10
10
  //# sourceMappingURL=%5Broot-of-the-server%5D__d9fd2a9b._.js.map