@vectorize-io/hindsight-control-plane 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/package.json +1 -1
  2. package/standalone/.next/BUILD_ID +1 -1
  3. package/standalone/.next/build-manifest.json +2 -2
  4. package/standalone/.next/prerender-manifest.json +3 -3
  5. package/standalone/.next/server/app/_global-error.html +2 -2
  6. package/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/standalone/.next/server/app/_not-found.html +1 -1
  14. package/standalone/.next/server/app/_not-found.rsc +2 -2
  15. package/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  16. package/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  18. package/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/standalone/.next/server/app/api/banks/[bankId]/consolidate/route.js +2 -3
  22. package/standalone/.next/server/app/api/banks/[bankId]/consolidate/route.js.nft.json +1 -1
  23. package/standalone/.next/server/app/api/banks/[bankId]/directives/[directiveId]/route.js +1 -1
  24. package/standalone/.next/server/app/api/banks/[bankId]/directives/[directiveId]/route.js.nft.json +1 -1
  25. package/standalone/.next/server/app/api/banks/[bankId]/directives/route.js +1 -1
  26. package/standalone/.next/server/app/api/banks/[bankId]/directives/route.js.nft.json +1 -1
  27. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/refresh/route.js +1 -1
  28. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/refresh/route.js.nft.json +1 -1
  29. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/route.js +1 -1
  30. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/[mentalModelId]/route.js.nft.json +1 -1
  31. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/route.js +1 -1
  32. package/standalone/.next/server/app/api/banks/[bankId]/mental-models/route.js.nft.json +1 -1
  33. package/standalone/.next/server/app/api/banks/[bankId]/observations/[modelId]/route.js +1 -1
  34. package/standalone/.next/server/app/api/banks/[bankId]/observations/[modelId]/route.js.nft.json +1 -1
  35. package/standalone/.next/server/app/api/banks/[bankId]/observations/route.js +2 -3
  36. package/standalone/.next/server/app/api/banks/[bankId]/observations/route.js.nft.json +1 -1
  37. package/standalone/.next/server/app/api/banks/[bankId]/operations/[operationId]/route.js +2 -3
  38. package/standalone/.next/server/app/api/banks/[bankId]/operations/[operationId]/route.js.nft.json +1 -1
  39. package/standalone/.next/server/app/api/banks/[bankId]/route.js +2 -3
  40. package/standalone/.next/server/app/api/banks/[bankId]/route.js.nft.json +1 -1
  41. package/standalone/.next/server/app/api/banks/route.js +2 -3
  42. package/standalone/.next/server/app/api/banks/route.js.nft.json +1 -1
  43. package/standalone/.next/server/app/api/chunks/[chunkId]/route.js +2 -3
  44. package/standalone/.next/server/app/api/chunks/[chunkId]/route.js.nft.json +1 -1
  45. package/standalone/.next/server/app/api/documents/[documentId]/route.js +2 -3
  46. package/standalone/.next/server/app/api/documents/[documentId]/route.js.nft.json +1 -1
  47. package/standalone/.next/server/app/api/documents/route.js +2 -3
  48. package/standalone/.next/server/app/api/documents/route.js.nft.json +1 -1
  49. package/standalone/.next/server/app/api/entities/[entityId]/regenerate/route.js +2 -3
  50. package/standalone/.next/server/app/api/entities/[entityId]/regenerate/route.js.nft.json +1 -1
  51. package/standalone/.next/server/app/api/entities/[entityId]/route.js +2 -3
  52. package/standalone/.next/server/app/api/entities/[entityId]/route.js.nft.json +1 -1
  53. package/standalone/.next/server/app/api/entities/route.js +2 -3
  54. package/standalone/.next/server/app/api/entities/route.js.nft.json +1 -1
  55. package/standalone/.next/server/app/api/graph/route.js +2 -3
  56. package/standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
  57. package/standalone/.next/server/app/api/health/route.js +1 -2
  58. package/standalone/.next/server/app/api/health/route.js.nft.json +1 -1
  59. package/standalone/.next/server/app/api/list/route.js +2 -3
  60. package/standalone/.next/server/app/api/list/route.js.nft.json +1 -1
  61. package/standalone/.next/server/app/api/memories/[memoryId]/route.js +1 -1
  62. package/standalone/.next/server/app/api/memories/[memoryId]/route.js.nft.json +1 -1
  63. package/standalone/.next/server/app/api/memories/retain/route.js +2 -3
  64. package/standalone/.next/server/app/api/memories/retain/route.js.nft.json +1 -1
  65. package/standalone/.next/server/app/api/memories/retain_async/route.js +2 -3
  66. package/standalone/.next/server/app/api/memories/retain_async/route.js.nft.json +1 -1
  67. package/standalone/.next/server/app/api/operations/[agentId]/route.js +2 -3
  68. package/standalone/.next/server/app/api/operations/[agentId]/route.js.nft.json +1 -1
  69. package/standalone/.next/server/app/api/profile/[bankId]/route.js +2 -3
  70. package/standalone/.next/server/app/api/profile/[bankId]/route.js.nft.json +1 -1
  71. package/standalone/.next/server/app/api/recall/route.js +2 -3
  72. package/standalone/.next/server/app/api/recall/route.js.nft.json +1 -1
  73. package/standalone/.next/server/app/api/reflect/route.js +2 -3
  74. package/standalone/.next/server/app/api/reflect/route.js.nft.json +1 -1
  75. package/standalone/.next/server/app/api/stats/[agentId]/route.js +2 -3
  76. package/standalone/.next/server/app/api/stats/[agentId]/route.js.nft.json +1 -1
  77. package/standalone/.next/server/app/api/version/route.js +2 -3
  78. package/standalone/.next/server/app/api/version/route.js.nft.json +1 -1
  79. package/standalone/.next/server/app/banks/[bankId]/page_client-reference-manifest.js +1 -1
  80. package/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  81. package/standalone/.next/server/app/dashboard.html +1 -1
  82. package/standalone/.next/server/app/dashboard.rsc +2 -2
  83. package/standalone/.next/server/app/dashboard.segments/_full.segment.rsc +2 -2
  84. package/standalone/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  85. package/standalone/.next/server/app/dashboard.segments/_index.segment.rsc +2 -2
  86. package/standalone/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  87. package/standalone/.next/server/app/dashboard.segments/dashboard/__PAGE__.segment.rsc +1 -1
  88. package/standalone/.next/server/app/dashboard.segments/dashboard.segment.rsc +1 -1
  89. package/standalone/.next/server/app/index.html +1 -1
  90. package/standalone/.next/server/app/index.rsc +2 -2
  91. package/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  92. package/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  93. package/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  94. package/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  95. package/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  96. package/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  97. package/standalone/.next/server/chunks/[root-of-the-server]__02a1e7f7._.js +3 -0
  98. package/standalone/.next/server/chunks/{[root-of-the-server]__85fada80._.js → [root-of-the-server]__0f1b189c._.js} +2 -2
  99. package/standalone/.next/server/chunks/{[root-of-the-server]__9e91e653._.js → [root-of-the-server]__18142a79._.js} +2 -2
  100. package/standalone/.next/server/chunks/{[root-of-the-server]__fd2d4ac3._.js → [root-of-the-server]__228c769f._.js} +2 -2
  101. package/standalone/.next/server/chunks/[root-of-the-server]__2df99810._.js +21 -0
  102. package/standalone/.next/server/chunks/[root-of-the-server]__32db962b._.js +3 -0
  103. package/standalone/.next/server/chunks/{[root-of-the-server]__296b95db._.js → [root-of-the-server]__464d3847._.js} +2 -2
  104. package/standalone/.next/server/chunks/[root-of-the-server]__4f034a9d._.js +1 -1
  105. package/standalone/.next/server/chunks/[root-of-the-server]__4f8cb4ae._.js +1 -1
  106. package/standalone/.next/server/chunks/[root-of-the-server]__5e1d146d._.js +3 -0
  107. package/standalone/.next/server/chunks/[root-of-the-server]__6296f8c7._.js +1 -1
  108. package/standalone/.next/server/chunks/[root-of-the-server]__6872cebd._.js +1 -1
  109. package/standalone/.next/server/chunks/{[root-of-the-server]__ef34dcbb._.js → [root-of-the-server]__6ee44ea3._.js} +2 -2
  110. package/standalone/.next/server/chunks/{[root-of-the-server]__57dac9c2._.js → [root-of-the-server]__73093267._.js} +2 -2
  111. package/standalone/.next/server/chunks/{[root-of-the-server]__37560d9a._.js → [root-of-the-server]__81c0d784._.js} +2 -2
  112. package/standalone/.next/server/chunks/{[root-of-the-server]__a2b6ce38._.js → [root-of-the-server]__905dfb67._.js} +2 -2
  113. package/standalone/.next/server/chunks/[root-of-the-server]__9a7529ab._.js +1 -1
  114. package/standalone/.next/server/chunks/[root-of-the-server]__9ab5fe6b._.js +1 -1
  115. package/standalone/.next/server/chunks/[root-of-the-server]__9c3dd746._.js +3 -0
  116. package/standalone/.next/server/chunks/{[root-of-the-server]__116b0d31._.js → [root-of-the-server]__a044118e._.js} +2 -2
  117. package/standalone/.next/server/chunks/[root-of-the-server]__bae0f53c._.js +3 -0
  118. package/standalone/.next/server/chunks/[root-of-the-server]__be9afc00._.js +3 -0
  119. package/standalone/.next/server/chunks/{[root-of-the-server]__8578ca3f._.js → [root-of-the-server]__bfef8f90._.js} +2 -2
  120. package/standalone/.next/server/chunks/{[root-of-the-server]__687469c1._.js → [root-of-the-server]__d2485edb._.js} +2 -2
  121. package/standalone/.next/server/chunks/[root-of-the-server]__d4a965d7._.js +1 -1
  122. package/standalone/.next/server/chunks/[root-of-the-server]__d4b39930._.js +3 -0
  123. package/standalone/.next/server/chunks/{[root-of-the-server]__ab5df0f3._.js → [root-of-the-server]__d4f9d631._.js} +2 -2
  124. package/standalone/.next/server/chunks/{[root-of-the-server]__9af3dcb2._.js → [root-of-the-server]__e5a6b81d._.js} +2 -2
  125. package/standalone/.next/server/chunks/{[root-of-the-server]__356491b1._.js → [root-of-the-server]__f318615b._.js} +2 -2
  126. package/standalone/.next/server/chunks/[root-of-the-server]__faf484e1._.js +1 -1
  127. package/standalone/.next/server/chunks/ssr/[root-of-the-server]__3ff65f6b._.js +1 -1
  128. package/standalone/.next/server/pages/404.html +1 -1
  129. package/standalone/.next/server/pages/500.html +2 -2
  130. package/standalone/.next/server/server-reference-manifest.js +1 -1
  131. package/standalone/.next/server/server-reference-manifest.json +1 -1
  132. package/standalone/.next/static/chunks/{e574a89d58c6e4fc.js → 23a0ba0741952676.js} +1 -1
  133. package/standalone/.next/static/chunks/9a7e51393bf24b62.css +2 -0
  134. package/standalone/package.json +1 -1
  135. package/standalone/.next/server/chunks/[root-of-the-server]__478d7304._.js +0 -3
  136. package/standalone/.next/server/chunks/[root-of-the-server]__51072426._.js +0 -3
  137. package/standalone/.next/server/chunks/[root-of-the-server]__517fcb62._.js +0 -3
  138. package/standalone/.next/server/chunks/[root-of-the-server]__71e0e3b9._.js +0 -21
  139. package/standalone/.next/server/chunks/[root-of-the-server]__8241ce67._.js +0 -3
  140. package/standalone/.next/server/chunks/[root-of-the-server]__b9387f6f._.js +0 -3
  141. package/standalone/.next/server/chunks/[root-of-the-server]__e1881f02._.js +0 -3
  142. package/standalone/.next/server/chunks/[root-of-the-server]__e4e9fd7e._.js +0 -3
  143. package/standalone/.next/server/chunks/hindsight-clients_typescript_dist_79330c4c._.js +0 -3
  144. package/standalone/.next/static/chunks/29c428a7aa2236cf.css +0 -2
  145. /package/standalone/.next/static/{tqSnESoxV_HpcddrkuYV- → zGNfMglnlHqrqWAqOLkLX}/_buildManifest.js +0 -0
  146. /package/standalone/.next/static/{tqSnESoxV_HpcddrkuYV- → zGNfMglnlHqrqWAqOLkLX}/_clientMiddlewareManifest.json +0 -0
  147. /package/standalone/.next/static/{tqSnESoxV_HpcddrkuYV- → zGNfMglnlHqrqWAqOLkLX}/_ssgManifest.js +0 -0
@@ -5,4 +5,4 @@ You can add a description to the \`${hx}\` by passing a \`${hk}\` 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 \`${hx}\`. 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 R.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null};let hD=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hv,{className:(0,Y.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));hD.displayName=hv.displayName;let hM=R.forwardRef(({className:e,...t},n)=>(0,D.jsxs)(hm,{children:[(0,D.jsx)(hD,{}),(0,D.jsx)(hN,{ref:n,className:(0,Y.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));hM.displayName=hN.displayName;let hP=({className:e,...t})=>(0,D.jsx)("div",{className:(0,Y.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});hP.displayName="AlertDialogHeader";let hR=({className:e,...t})=>(0,D.jsx)("div",{className:(0,Y.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});hR.displayName="AlertDialogFooter";let hL=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hE,{ref:n,className:(0,Y.cn)("text-lg font-semibold",e),...t}));hL.displayName=hE.displayName;let hI=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hC,{ref:n,className:(0,Y.cn)("text-sm text-muted-foreground",e),...t}));hI.displayName=hC.displayName;let hO=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(hT,{ref:n,className:(0,Y.cn)((0,$.buttonVariants)(),e),...t}));hO.displayName=hT.displayName;let hB=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(h_,{ref:n,className:(0,Y.cn)((0,$.buttonVariants)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));hB.displayName=h_.displayName;let hF=(0,O.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 hz(){let{currentBank:e}=(0,L.useBank)(),[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(""),[s,l]=(0,R.useState)(0),[c,u]=(0,R.useState)(null),[d,h]=(0,R.useState)(!1),[p,f]=(0,R.useState)(null),[g,v]=(0,R.useState)(null),[x,y]=(0,R.useState)(null),b=async()=>{if(e){i(!0);try{let t=await q.client.listDocuments({bank_id:e,q:a,limit:100});n(t.items||[]),l(t.total||0)}catch(e){console.error("Error loading documents:",e),alert("Error loading documents: "+e.message)}finally{i(!1)}}},w=async t=>{if(e){h(!0),u({id:t});try{let n=await q.client.getDocument(t,e);u(n)}catch(e){console.error("Error loading document:",e),alert("Error loading document: "+e.message),u(null)}finally{h(!1)}}},N=async()=>{if(!e||!g)return;let t=g.id;f(t),v(null);try{let n=await q.client.deleteDocument(t,e);y({success:!0,message:`Deleted document and ${n.memory_units_deleted} memory units.`}),c?.id===t&&u(null),b()}catch(e){console.error("Error deleting document:",e),y({success:!1,message:"Error deleting document: "+e.message})}finally{f(null)}};return(0,R.useEffect)(()=>{e&&b()},[e]),(0,D.jsxs)("div",{children:[r?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading documents..."})]})}):t.length>0?(0,D.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[s," total documents"]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"📄"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"No documents found"})]})}),t.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"w-full",children:[(0,D.jsx)("div",{className:"px-5 mb-4",children:(0,D.jsx)(K.Input,{type:"text",value:a,onChange:e=>o(e.target.value),placeholder:"Search documents (ID)...",className:"max-w-2xl"})}),(0,D.jsx)("div",{className:"overflow-x-auto px-5 pb-5",children:(0,D.jsxs)(es,{children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{children:[(0,D.jsx)(ed,{children:"Document ID"}),(0,D.jsx)(ed,{children:"Created"}),(0,D.jsx)(ed,{children:"Context"}),(0,D.jsx)(ed,{children:"Text Length"}),(0,D.jsx)(ed,{children:"Memory Units"})]})}),(0,D.jsx)(ec,{children:t.length>0?t.map(e=>(0,D.jsxs)(eu,{className:`cursor-pointer hover:bg-muted/50 ${c?.id===e.id?"bg-primary/10":""}`,onClick:()=>w(e.id),children:[(0,D.jsx)(eh,{title:e.id,className:"text-card-foreground",children:e.id.length>30?e.id.substring(0,30)+"...":e.id}),(0,D.jsx)(eh,{className:"text-card-foreground",children:e.created_at?new Date(e.created_at).toLocaleString():"N/A"}),(0,D.jsx)(eh,{className:"text-card-foreground",children:e.retain_params?.context||"-"}),(0,D.jsxs)(eh,{className:"text-card-foreground",children:[e.text_length?.toLocaleString()," chars"]}),(0,D.jsx)(eh,{className:"text-card-foreground",children:e.memory_unit_count})]},e.id)):(0,D.jsx)(eu,{children:(0,D.jsx)(eh,{colSpan:5,className:"text-center",children:'Click "Load Documents" to view data'})})})]})})]}),c&&(0,D.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,D.jsxs)("div",{className:"p-5",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:"Document Details"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Original document text and metadata"})]}),(0,D.jsxs)($.Button,{variant:"secondary",size:"sm",onClick:()=>u(null),className:"h-9 px-3 gap-2",children:[(0,D.jsx)(to.X,{className:"h-4 w-4"}),"Close"]})]}),d?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"⏳"}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading document..."})]})}):(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Document ID"}),(0,D.jsx)("div",{className:"text-sm font-mono break-all text-card-foreground",children:c.id})]}),c.created_at&&(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Created"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:new Date(c.created_at).toLocaleString()})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Memory Units"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:c.memory_unit_count})]})]}),c.original_text&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Text Length"}),(0,D.jsxs)("div",{className:"text-sm font-medium text-card-foreground",children:[c.original_text.length.toLocaleString()," characters"]})]}),c.retain_params&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Retain Parameters"}),(0,D.jsxs)("div",{className:"text-sm space-y-2 text-card-foreground",children:[c.retain_params.context&&(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"font-semibold",children:"Context:"})," ",c.retain_params.context]}),c.retain_params.event_date&&(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"font-semibold",children:"Event Date:"})," ",new Date(c.retain_params.event_date).toLocaleString()]}),c.retain_params.metadata&&(0,D.jsxs)("div",{className:"mt-2",children:[(0,D.jsx)("span",{className:"font-semibold",children:"Metadata:"}),(0,D.jsx)("pre",{className:"mt-1 text-xs bg-background p-2 rounded text-card-foreground",children:JSON.stringify(c.retain_params.metadata,null,2)})]})]})]}),c.tags&&c.tags.length>0&&(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:c.tags.map((e,t)=>(0,D.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:e},t))})]}),(0,D.jsx)("div",{className:"pt-2 border-t border-border",children:(0,D.jsxs)($.Button,{variant:"destructive",size:"sm",onClick:()=>{v({id:c.id,memoryCount:c.memory_unit_count})},className:"w-full gap-2",disabled:p===c.id,children:[p===c.id?(0,D.jsx)("span",{className:"animate-spin",children:"⏳"}):(0,D.jsx)(hF,{className:"h-4 w-4"}),"Delete Document"]})}),c.original_text&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Original Text"}),(0,D.jsx)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border max-h-[400px] overflow-y-auto",children:(0,D.jsx)("pre",{className:"text-sm whitespace-pre-wrap font-mono leading-relaxed text-card-foreground",children:c.original_text})})]})]})]})})]}),(0,D.jsx)(hg,{open:!!g,onOpenChange:e=>!e&&v(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Document"}),(0,D.jsxs)(hI,{children:["Are you sure you want to delete document"," ",(0,D.jsxs)("span",{className:"font-mono font-semibold",children:['"',g?.id,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),"This will also delete"," ",g?.memoryCount!==void 0?(0,D.jsxs)("span",{className:"font-semibold",children:[g.memoryCount," memory units"]}):"all memory units"," ","extracted from this document.",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hR,{children:[(0,D.jsx)(hB,{children:"Cancel"}),(0,D.jsx)(hO,{onClick:N,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),(0,D.jsx)(hg,{open:!!x,onOpenChange:e=>!e&&y(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:x?.success?"Document Deleted":"Error"}),(0,D.jsx)(hI,{children:x?.message})]}),(0,D.jsx)(hR,{children:(0,D.jsx)(hO,{onClick:()=>y(null),children:"OK"})})]})})]})}function hV(){let{currentBank:e}=(0,L.useBank)(),[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,l]=(0,R.useState)(!1),[c,u]=(0,R.useState)(1),[d,h]=(0,R.useState)(0),p=Math.ceil(d/50),f=(c-1)*50,g=async(t=1)=>{if(e){i(!0);try{let r=await q.client.listEntities({bank_id:e,limit:50,offset:(t-1)*50});n(r.items||[]),h(r.total||0)}catch(e){console.error("Error loading entities:",e),alert("Error loading entities: "+e.message)}finally{i(!1)}}},v=async t=>{if(e){l(!0);try{let n=await q.client.getEntity(t,e);o(n)}catch(e){console.error("Error loading entity detail:",e),alert("Error loading entity detail: "+e.message)}finally{l(!1)}}},x=e=>{u(e),g(e)};(0,R.useEffect)(()=>{e&&(u(1),g(1),o(null))},[e]);let y=e=>e?new Date(e).toLocaleDateString():"N/A";return(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{children:r?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading entities..."})]})}):t.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"mb-4 text-sm text-muted-foreground",children:[d," ",1===d?"entity":"entities"]}),(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)(es,{children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{children:[(0,D.jsx)(ed,{children:"Name"}),(0,D.jsx)(ed,{children:"Mentions"}),(0,D.jsx)(ed,{children:"First Seen"}),(0,D.jsx)(ed,{children:"Last Seen"})]})}),(0,D.jsx)(ec,{children:t.map(e=>(0,D.jsxs)(eu,{onClick:()=>v(e.id),className:`cursor-pointer hover:bg-muted/50 ${a?.id===e.id?"bg-primary/10":""}`,children:[(0,D.jsx)(eh,{className:"font-medium text-card-foreground",children:e.canonical_name}),(0,D.jsx)(eh,{className:"text-card-foreground",children:e.mention_count}),(0,D.jsx)(eh,{className:"text-card-foreground",children:y(e.first_seen)}),(0,D.jsx)(eh,{className:"text-card-foreground",children:y(e.last_seen)})]},e.id))})]})}),p>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[f+1,"-",Math.min(f+50,d)," of ",d]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>x(1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(ee,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>x(c-1),disabled:1===c||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(H,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[c," / ",p]}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>x(c+1),disabled:c===p||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(U,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>x(p),disabled:c===p||r,className:"h-7 w-7 p-0",children:(0,D.jsx)(et,{className:"h-3 w-3"})})]})]})]}):(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("div",{className:"text-4xl mb-2",children:"..."}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:"No entities found"}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Entities are extracted from facts when memories are added."})]})})}),a&&(0,D.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,D.jsxs)("div",{className:"p-5",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center mb-6 pb-4 border-b border-border",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-card-foreground",children:a.canonical_name}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Entity details"})]}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"h-8 w-8 p-0",children:(0,D.jsx)("span",{className:"text-lg",children:"x"})})]}),(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Mentions"}),(0,D.jsx)("div",{className:"text-lg font-semibold text-card-foreground",children:a.mention_count})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"First Seen"}),(0,D.jsx)("div",{className:"text-sm font-medium text-card-foreground",children:y(a.first_seen)})]})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-2",children:"Entity ID"}),(0,D.jsx)("code",{className:"text-xs font-mono break-all text-muted-foreground",children:a.id})]})]})]})})]})}var hH=e.i(26330),hU=e.i(3536),hG=e.i(65491),hY=e.i(10772),hX=e.i(53660),hW=e.i(74606),hq=Symbol("radix.slottable");function h$(e){return R.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===hq}var hK=e.i(30207),hZ=e.i(34620),hQ=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hJ=R.forwardRef((e,t)=>(0,D.jsx)(eT.Primitive.span,{...e,ref:t,style:{...hQ,...e.style}}));hJ.displayName="VisuallyHidden";var h0=e.i(86312),h1=e.i(85369),h2=[" ","Enter","ArrowUp","ArrowDown"],h5=[" ","Enter"],h3="Select",[h4,h6,h7]=(0,eS.createCollection)(h3),[h9,h8]=(0,eN.createContextScope)(h3,[h7,hX.createPopperScope]),pe=(0,hX.createPopperScope)(),[pt,pn]=h9(h3),[pr,pi]=h9(h3),pa=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:p,form:f}=e,g=pe(t),[v,x]=R.useState(null),[y,b]=R.useState(null),[w,N]=R.useState(!1),j=(0,eE.useDirection)(c),[E,k]=(0,ej.useControllableState)({prop:r,defaultProp:i??!1,onChange:a,caller:h3}),[C,T]=(0,ej.useControllableState)({prop:o,defaultProp:s,onChange:l,caller:h3}),S=R.useRef(null),_=!v||f||!!v.closest("form"),[A,M]=R.useState(new Set),P=Array.from(A).map(e=>e.props.value).join(";");return(0,D.jsx)(hX.Root,{...g,children:(0,D.jsxs)(pt,{required:p,scope:t,trigger:v,onTriggerChange:x,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:N,contentId:(0,hY.useId)(),value:C,onValueChange:T,open:E,onOpenChange:k,dir:j,triggerPointerDownPosRef:S,disabled:h,children:[(0,D.jsx)(h4.Provider,{scope:t,children:(0,D.jsx)(pr,{scope:e.__scopeSelect,onNativeOptionAdd:R.useCallback(e=>{M(t=>new Set(t).add(e))},[]),onNativeOptionRemove:R.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),_?(0,D.jsxs)(pG,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:C,onChange:e=>T(e.target.value),disabled:h,form:f,children:[void 0===C?(0,D.jsx)("option",{value:""}):null,Array.from(A)]},P):null]})})};pa.displayName=h3;var po="SelectTrigger",ps=R.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=pe(n),o=pn(po,n),s=o.disabled||r,l=(0,ew.useComposedRefs)(t,o.onTriggerChange),c=h6(n),u=R.useRef("touch"),[d,h,p]=pX(e=>{let t=c().filter(e=>!e.disabled),n=t.find(e=>e.value===o.value),r=pW(t,e,n);void 0!==r&&o.onValueChange(r.value)}),f=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,D.jsx)(hX.Anchor,{asChild:!0,...a,children:(0,D.jsx)(eT.Primitive.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:s,"data-disabled":s?"":void 0,"data-placeholder":pY(o.value)?"":void 0,...i,ref:l,onClick:(0,eb.composeEventHandlers)(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&f(e)}),onPointerDown:(0,eb.composeEventHandlers)(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())}),onKeyDown:(0,eb.composeEventHandlers)(i.onKeyDown,e=>{let t=""!==d.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||h(e.key),(!t||" "!==e.key)&&h2.includes(e.key)&&(f(),e.preventDefault())})})})});ps.displayName=po;var pl="SelectValue",pc=R.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o="",...s}=e,l=pn(pl,n),{onValueNodeHasChildrenChange:c}=l,u=void 0!==a,d=(0,ew.useComposedRefs)(t,l.onValueNodeChange);return(0,hZ.useLayoutEffect)(()=>{c(u)},[c,u]),(0,D.jsx)(eT.Primitive.span,{...s,ref:d,style:{pointerEvents:"none"},children:pY(l.value)?(0,D.jsx)(D.Fragment,{children:o}):a})});pc.displayName=pl;var pu=R.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,D.jsx)(eT.Primitive.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});pu.displayName="SelectIcon";var pd=e=>(0,D.jsx)(hW.Portal,{asChild:!0,...e});pd.displayName="SelectPortal";var ph="SelectContent",pp=R.forwardRef((e,t)=>{let n=pn(ph,e.__scopeSelect),[r,i]=R.useState();return((0,hZ.useLayoutEffect)(()=>{i(new DocumentFragment)},[]),n.open)?(0,D.jsx)(pv,{...e,ref:t}):r?ep.createPortal((0,D.jsx)(pf,{scope:e.__scopeSelect,children:(0,D.jsx)(h4.Slot,{scope:e.__scopeSelect,children:(0,D.jsx)("div",{children:e.children})})}),r):null});pp.displayName=ph;var[pf,pg]=h9(ph),pm=((o=R.forwardRef((e,t)=>{let{children:n,...r}=e;if(R.isValidElement(n)){var i;let e,a,o=(i=n,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...a}:"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==R.Fragment&&(s.ref=t?(0,ew.composeRefs)(t,o):o),R.cloneElement(n,s)}return R.Children.count(n)>1?R.Children.only(null):null})).displayName="SelectContent.RemoveScroll.SlotClone",n=o,(r=R.forwardRef((e,t)=>{let{children:r,...i}=e,a=R.Children.toArray(r),o=a.find(h$);if(o){let e=o.props.children,r=a.map(t=>t!==o?t:R.Children.count(e)>1?R.Children.only(null):R.isValidElement(e)?e.props.children:null);return(0,D.jsx)(n,{...i,ref:t,children:R.isValidElement(e)?R.cloneElement(e,void 0,r):null})}return(0,D.jsx)(n,{...i,ref:t,children:r})})).displayName="SelectContent.RemoveScroll.Slot",r),pv=R.forwardRef((e,t)=>{let{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:f,hideWhenDetached:g,avoidCollisions:v,...x}=e,y=pn(ph,n),[b,w]=R.useState(null),[N,j]=R.useState(null),E=(0,ew.useComposedRefs)(t,e=>w(e)),[k,C]=R.useState(null),[T,S]=R.useState(null),_=h6(n),[A,M]=R.useState(!1),P=R.useRef(!1);R.useEffect(()=>{if(b)return(0,h0.hideOthers)(b)},[b]),(0,hU.useFocusGuards)();let L=R.useCallback(e=>{let[t,...n]=_().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:"nearest"}),n===t&&N&&(N.scrollTop=0),n===r&&N&&(N.scrollTop=N.scrollHeight),n?.focus(),document.activeElement!==i))return},[_,N]),I=R.useCallback(()=>L([k,b]),[L,k,b]);R.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:O,triggerPointerDownPosRef:B}=y;R.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(B.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():b.contains(n.target)||O(!1),document.removeEventListener("pointermove",t),B.current=null};return null!==B.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[b,O,B]),R.useEffect(()=>{let e=()=>O(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[O]);let[F,z]=pX(e=>{let t=_().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=pW(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),V=R.useCallback((e,t,n)=>{let r=!P.current&&!n;(void 0!==y.value&&y.value===t||r)&&(C(e),r&&(P.current=!0))},[y.value]),H=R.useCallback(()=>b?.focus(),[b]),U=R.useCallback((e,t,n)=>{let r=!P.current&&!n;(void 0!==y.value&&y.value===t||r)&&S(e)},[y.value]),G="popper"===r?py:px,Y=G===py?{side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:f,hideWhenDetached:g,avoidCollisions:v}:{};return(0,D.jsx)(pf,{scope:n,content:b,viewport:N,onViewportChange:j,itemRefCallback:V,selectedItem:k,onItemLeave:H,itemTextRefCallback:U,focusSelectedItem:I,selectedItemText:T,position:r,isPositioned:A,searchRef:F,children:(0,D.jsx)(h1.RemoveScroll,{as:pm,allowPinchZoom:!0,children:(0,D.jsx)(hG.FocusScope,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:(0,eb.composeEventHandlers)(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,D.jsx)(hH.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,D.jsx)(G,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:e=>e.preventDefault(),...x,...Y,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:(0,eb.composeEventHandlers)(x.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=_().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});pv.displayName="SelectContentImpl";var px=R.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=pn(ph,n),o=pg(ph,n),[s,l]=R.useState(null),[c,u]=R.useState(null),d=(0,ew.useComposedRefs)(t,e=>u(e)),h=h6(n),p=R.useRef(!1),f=R.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:x,focusSelectedItem:y}=o,b=R.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&c&&g&&v&&x){let e=a.trigger.getBoundingClientRect(),t=c.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=x.getBoundingClientRect();if("rtl"!==a.dir){let r=i.left-t.left,a=n.left-r,o=e.left-a,l=e.width+o,c=Math.max(l,t.width),u=ey(a,[10,Math.max(10,window.innerWidth-10-c)]);s.style.minWidth=l+"px",s.style.left=u+"px"}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,l=e.width+o,c=Math.max(l,t.width),u=ey(a,[10,Math.max(10,window.innerWidth-10-c)]);s.style.minWidth=l+"px",s.style.right=u+"px"}let o=h(),l=window.innerHeight-20,u=g.scrollHeight,d=window.getComputedStyle(c),f=parseInt(d.borderTopWidth,10),y=parseInt(d.paddingTop,10),b=parseInt(d.borderBottomWidth,10),w=f+y+u+parseInt(d.paddingBottom,10)+b,N=Math.min(5*v.offsetHeight,w),j=window.getComputedStyle(g),E=parseInt(j.paddingTop,10),k=parseInt(j.paddingBottom,10),C=e.top+e.height/2-10,T=v.offsetHeight/2,S=f+y+(v.offsetTop+T);if(S<=C){let e=o.length>0&&v===o[o.length-1].ref.current;s.style.bottom="0px";let t=Math.max(l-C,T+(e?k:0)+(c.clientHeight-g.offsetTop-g.offsetHeight)+b);s.style.height=S+t+"px"}else{let e=o.length>0&&v===o[0].ref.current;s.style.top="0px";let t=Math.max(C,f+g.offsetTop+(e?E:0)+T);s.style.height=t+(w-S)+"px",g.scrollTop=S-C+g.offsetTop}s.style.margin="10px 0",s.style.minHeight=N+"px",s.style.maxHeight=l+"px",r?.(),requestAnimationFrame(()=>p.current=!0)}},[h,a.trigger,a.valueNode,s,c,g,v,x,a.dir,r]);(0,hZ.useLayoutEffect)(()=>b(),[b]);let[w,N]=R.useState();(0,hZ.useLayoutEffect)(()=>{c&&N(window.getComputedStyle(c).zIndex)},[c]);let j=R.useCallback(e=>{e&&!0===f.current&&(b(),y?.(),f.current=!1)},[b,y]);return(0,D.jsx)(pb,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:j,children:(0,D.jsx)("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:(0,D.jsx)(eT.Primitive.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});px.displayName="SelectItemAlignedPosition";var py=R.forwardRef((e,t)=>{let{__scopeSelect:n,align:r="start",collisionPadding:i=10,...a}=e,o=pe(n);return(0,D.jsx)(hX.Content,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});py.displayName="SelectPopperPosition";var[pb,pw]=h9(ph,{}),pN="SelectViewport",pj=R.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=pg(pN,n),o=pw(pN,n),s=(0,ew.useComposedRefs)(t,a.onViewportChange),l=R.useRef(0);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,D.jsx)(h4.Slot,{scope:n,children:(0,D.jsx)(eT.Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:s,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:(0,eb.composeEventHandlers)(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-20,i=Math.max(parseFloat(n.style.minHeight),parseFloat(n.style.height));if(i<r){let a=i+e,o=Math.min(r,a),s=a-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}l.current=t.scrollTop})})})]})});pj.displayName=pN;var pE="SelectGroup",[pk,pC]=h9(pE);R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=(0,hY.useId)();return(0,D.jsx)(pk,{scope:n,id:i,children:(0,D.jsx)(eT.Primitive.div,{role:"group","aria-labelledby":i,...r,ref:t})})}).displayName=pE;var pT="SelectLabel",pS=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=pC(pT,n);return(0,D.jsx)(eT.Primitive.div,{id:i.id,...r,ref:t})});pS.displayName=pT;var p_="SelectItem",[pA,pD]=h9(p_),pM=R.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=pn(p_,n),l=pg(p_,n),c=s.value===r,[u,d]=R.useState(a??""),[h,p]=R.useState(!1),f=(0,ew.useComposedRefs)(t,e=>l.itemRefCallback?.(e,r,i)),g=(0,hY.useId)(),v=R.useRef("touch"),x=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(""===r)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,D.jsx)(pA,{scope:n,value:r,disabled:i,textId:g,isSelected:c,onItemTextChange:R.useCallback(e=>{d(t=>t||(e?.textContent??"").trim())},[]),children:(0,D.jsx)(h4.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,D.jsx)(eT.Primitive.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:f,onFocus:(0,eb.composeEventHandlers)(o.onFocus,()=>p(!0)),onBlur:(0,eb.composeEventHandlers)(o.onBlur,()=>p(!1)),onClick:(0,eb.composeEventHandlers)(o.onClick,()=>{"mouse"!==v.current&&x()}),onPointerUp:(0,eb.composeEventHandlers)(o.onPointerUp,()=>{"mouse"===v.current&&x()}),onPointerDown:(0,eb.composeEventHandlers)(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:(0,eb.composeEventHandlers)(o.onPointerMove,e=>{v.current=e.pointerType,i?l.onItemLeave?.():"mouse"===v.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:(0,eb.composeEventHandlers)(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:(0,eb.composeEventHandlers)(o.onKeyDown,e=>{(l.searchRef?.current===""||" "!==e.key)&&(h5.includes(e.key)&&x()," "===e.key&&e.preventDefault())})})})})});pM.displayName=p_;var pP="SelectItemText",pR=R.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=pn(pP,n),s=pg(pP,n),l=pD(pP,n),c=pi(pP,n),[u,d]=R.useState(null),h=(0,ew.useComposedRefs)(t,e=>d(e),l.onItemTextChange,e=>s.itemTextRefCallback?.(e,l.value,l.disabled)),p=u?.textContent,f=R.useMemo(()=>(0,D.jsx)("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=c;return(0,hZ.useLayoutEffect)(()=>(g(f),()=>v(f)),[g,v,f]),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(eT.Primitive.span,{id:l.textId,...a,ref:h}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren?ep.createPortal(a.children,o.valueNode):null]})});pR.displayName=pP;var pL="SelectItemIndicator",pI=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return pD(pL,n).isSelected?(0,D.jsx)(eT.Primitive.span,{"aria-hidden":!0,...r,ref:t}):null});pI.displayName=pL;var pO="SelectScrollUpButton",pB=R.forwardRef((e,t)=>{let n=pg(pO,e.__scopeSelect),r=pw(pO,e.__scopeSelect),[i,a]=R.useState(!1),o=(0,ew.useComposedRefs)(t,r.onScrollButtonChange);return(0,hZ.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),i?(0,D.jsx)(pV,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});pB.displayName=pO;var pF="SelectScrollDownButton",pz=R.forwardRef((e,t)=>{let n=pg(pF,e.__scopeSelect),r=pw(pF,e.__scopeSelect),[i,a]=R.useState(!1),o=(0,ew.useComposedRefs)(t,r.onScrollButtonChange);return(0,hZ.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),i?(0,D.jsx)(pV,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});pz.displayName=pF;var pV=R.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=pg("SelectScrollButton",n),o=R.useRef(null),s=h6(n),l=R.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return R.useEffect(()=>()=>l(),[l]),(0,hZ.useLayoutEffect)(()=>{let e=s().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[s]),(0,D.jsx)(eT.Primitive.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:(0,eb.composeEventHandlers)(i.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(r,50))}),onPointerMove:(0,eb.composeEventHandlers)(i.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(r,50))}),onPointerLeave:(0,eb.composeEventHandlers)(i.onPointerLeave,()=>{l()})})}),pH=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{"aria-hidden":!0,...r,ref:t})});pH.displayName="SelectSeparator";var pU="SelectArrow";R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=pe(n),a=pn(pU,n),o=pg(pU,n);return a.open&&"popper"===o.position?(0,D.jsx)(hX.Arrow,{...i,...r,ref:t}):null}).displayName=pU;var pG=R.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=R.useRef(null),a=(0,ew.useComposedRefs)(r,i),o=(0,ek.usePrevious)(t);return R.useEffect(()=>{let e=i.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==t&&n){let r=new Event("change",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,D.jsx)(eT.Primitive.select,{...n,style:{...hQ,...n.style},ref:a,defaultValue:t})});function pY(e){return""===e||void 0===e}function pX(e){let t=(0,hK.useCallbackRef)(e),n=R.useRef(""),r=R.useRef(0),i=R.useCallback(e=>{let i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),a=R.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return R.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function pW(e,t,n){var r,i;let a=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=(r=e,i=Math.max(o,0),r.map((e,t)=>r[(i+t)%r.length]));1===a.length&&(s=s.filter(e=>e!==n));let l=s.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return l!==n?l:void 0}pG.displayName="SelectBubbleInput";let pq=(0,O.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),p$=(0,O.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),pK=R.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(ps,{ref:r,className:(0,Y.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,(0,D.jsx)(pu,{asChild:!0,children:(0,D.jsx)(pq,{className:"h-4 w-4 opacity-50"})})]}));pK.displayName=ps.displayName;let pZ=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(pB,{ref:n,className:(0,Y.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,D.jsx)(p$,{className:"h-4 w-4"})}));pZ.displayName=pB.displayName;let pQ=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(pz,{ref:n,className:(0,Y.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,D.jsx)(pq,{className:"h-4 w-4"})}));pQ.displayName=pz.displayName;let pJ=R.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>(0,D.jsx)(pd,{children:(0,D.jsxs)(pp,{ref:i,className:(0,Y.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover 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-select-content-transform-origin]","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[(0,D.jsx)(pZ,{}),(0,D.jsx)(pj,{className:(0,Y.cn)("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),(0,D.jsx)(pQ,{})]})}));pJ.displayName=pp.displayName,R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(pS,{ref:n,className:(0,Y.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=pS.displayName;let p0=R.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(pM,{ref:r,className:(0,Y.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(pI,{children:(0,D.jsx)(ta.Check,{className:"h-4 w-4"})})}),(0,D.jsx)(pR,{children:t})]}));p0.displayName=pM.displayName,R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(pH,{ref:n,className:(0,Y.cn)("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=pH.displayName;var p1=e.i(32089);let p2=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));p2.displayName="Card";let p5=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("flex flex-col space-y-1.5 p-6",e),...t}));p5.displayName="CardHeader";let p3=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("text-2xl font-semibold leading-none tracking-tight",e),...t}));p3.displayName="CardTitle";let p4=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("text-sm text-muted-foreground",e),...t}));p4.displayName="CardDescription";let p6=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("p-6 pt-0",e),...t}));p6.displayName="CardContent",R.forwardRef(({className:e,...t},n)=>(0,D.jsx)("div",{ref:n,className:(0,Y.cn)("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter";let p7=(0,O.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),p9=(0,O.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"}]]),p8=(0,O.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"}]]),fe=(0,O.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"}]]),ft=(0,O.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 fn=e.i(1864);"function"==typeof SuppressedError&&SuppressedError;var fr=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach(function(t){e.addRange(t)}),t&&t.focus()}},fi={"text/plain":"Text","text/html":"Url",default:"Text"},fa=function(e,t){var n,r,i,a,o,s,l,c,u=!1;t||(t={}),i=t.debug||!1;try{if(o=fr(),s=document.createRange(),l=document.getSelection(),(c=document.createElement("span")).textContent=e,c.ariaHidden="true",c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),void 0===n.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var r=fi[t.format]||fi.default;window.clipboardData.setData(r,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(c),s.selectNodeContents(c),l.addRange(s),!document.execCommand("copy"))throw Error("copy command was unsuccessful");u=!0}catch(o){i&&console.error("unable to copy using execCommand: ",o),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),u=!0}catch(o){i&&console.error("unable to copy using clipboardData: ",o),i&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",r=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",a=n.replace(/#{\s*key\s*}/g,r),window.prompt(a,e)}}finally{l&&("function"==typeof l.removeRange?l.removeRange(s):l.removeAllRanges()),c&&document.body.removeChild(c),o()}return u};function fo(e){return"[object Object]"===Object.prototype.toString.call(e)}function fs(e){return Array.isArray(e)?e.length:fo(e)?Object.keys(e).length:0}function fl(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=fs(e);if("function"==typeof r){let i=fd(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||fo(e)&&o>i)}function fc(e,t,n,r,i,a){if(a&&void 0!==a.collapsed)return!!a.collapsed;if("boolean"==typeof r)return r;if("number"==typeof r&&t>r)return!0;let o=Math.ceil(e.length/100);if("function"==typeof r){let i=fd(r,[{node:e,depth:t,indexOrName:n,size:o}]);if("boolean"==typeof i)return i}return!!(Array.isArray(e)&&o>i||fo(e)&&o>i)}function fu(e,t,n){return"boolean"==typeof e?e:"number"==typeof e&&!!(t>e)||"collapsed"===e&&!!n||"expanded"===e&&!n}function fd(e,t){try{return e(...t)}catch(e){reportError(e)}}function fh(e){if(!0===e||fo(e)&&!0===e.add)return!0}function fp(e){if(!0===e||fo(e)&&!0===e.edit)return!0}function ff(e){if(!0===e||fo(e)&&!0===e.delete)return!0}function fg(e){return!e||void 0===e.add||!!e.add}function fm(e){return!e||void 0===e.edit||!!e.edit}function fv(e){return!e||void 0===e.delete||!!e.delete}function fx(e){return!e||void 0===e.enableClipboard||!!e.enableClipboard}function fy(){return(fy=Object.assign.bind()).apply(this,arguments)}var fb=function(e){return R.createElement("svg",fy({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),g||(g=R.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 fw(){return(fw=Object.assign.bind()).apply(this,arguments)}var fN=function(e){return R.createElement("svg",fw({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),v||(v=R.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 fj(){return(fj=Object.assign.bind()).apply(this,arguments)}var fE=function(e){return R.createElement("svg",fj({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),x||(x=R.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"})),y||(y=R.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 fk({node:e,nodeMeta:t}){let{customizeCopy:n,CopyComponent:r,CopiedComponent:i}=(0,R.useContext)(fY),[a,o]=(0,R.useState)(!1),s=r=>{r.stopPropagation();let i=n(e,t);"string"==typeof i&&i&&function(e){var t,n,r,i;t=this,n=void 0,r=void 0,i=function*(){try{yield navigator.clipboard.writeText(e)}catch(t){fa(e)}},new(r||(r=Promise))(function(e,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(t){var n;t.done?e(t.value):((n=t.value)instanceof r?n:new r(function(e){e(n)})).then(o,s)}l((i=i.apply(t,n||[])).next())})}(i),o(!0),setTimeout(()=>o(!1),3e3)};return a?"function"==typeof i?(0,D.jsx)(i,{className:"json-view--copy",style:{display:"inline-block"}}):(0,D.jsx)(fE,{className:"json-view--copy",style:{display:"inline-block"}}):"function"==typeof r?(0,D.jsx)(r,{onClick:s,className:"json-view--copy"}):(0,D.jsx)(fN,{onClick:s,className:"json-view--copy"})}function fC({indexOrName:e,value:t,depth:n,deleteHandle:r,editHandle:i,parent:a,parentPath:o}){let{displayArrayIndex:s}=(0,R.useContext)(fY),l=Array.isArray(a);return(0,D.jsxs)("div",Object.assign({className:"json-view--pair"},{children:[!l||l&&s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",Object.assign({className:"number"==typeof e?"json-view--index":"json-view--property"},{children:e})),":"," "]}):(0,D.jsx)(D.Fragment,{}),(0,D.jsx)(fU,{node:t,depth:n+1,deleteHandle:(e,t)=>r(e,t),editHandle:(e,t,n,r)=>i(e,t,n,r),parent:a,indexOrName:e,parentPath:o})]}))}function fT(){return(fT=Object.assign.bind()).apply(this,arguments)}var fS=function(e){return R.createElement("svg",fT({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),b||(b=R.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"})),w||(w=R.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 f_(){return(f_=Object.assign.bind()).apply(this,arguments)}var fA=function(e){return R.createElement("svg",f_({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),N||(N=R.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"})),j||(j=R.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 fD(){return(fD=Object.assign.bind()).apply(this,arguments)}var fM=function(e){return R.createElement("svg",fD({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),E||(E=R.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"})),k||(k=R.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 fP(){return(fP=Object.assign.bind()).apply(this,arguments)}var fR=function(e){return R.createElement("svg",fP({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),C||(C=R.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"})),T||(T=R.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 fL({originNode:e,node:t,depth:n,index:r,deleteHandle:i,customOptions:a,startIndex:o,parent:s,parentPath:l}){let{enableClipboard:c,src:u,onEdit:d,onChange:h,forceUpdate:p,displaySize:f,CustomOperation:g}=(0,R.useContext)(fY),v=[...l,String(r)],[x,y]=(0,R.useState)(!0),b=(0,R.useCallback)((t,r,i)=>{e[t]=r,d&&d({newValue:r,oldValue:i,depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),h&&h({type:"edit",depth:n,src:u,indexOrName:t,parentType:"array",parentPath:l}),p()},[t,d,h,p]),w=t=>{e.splice(t,1),i&&i(t,l),p()},N=(0,D.jsxs)(D.Fragment,{children:[!x&&(0,D.jsxs)("span",Object.assign({onClick:()=>y(!0),className:"jv-size-chevron"},{children:[fu(f,n,x)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[fs(t)," Items"]})),(0,D.jsx)(fb,{className:"jv-chevron"})]})),!x&&c&&fx(a)&&(0,D.jsx)(fk,{node:t,nodeMeta:{depth:n,indexOrName:r,parent:s,parentPath:l,currentPath:v}}),"function"==typeof g?(0,D.jsx)(g,{node:t}):null]});return(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{children:"["}),N,x?(0,D.jsxs)("button",Object.assign({onClick:()=>y(!1),className:"jv-button"},{children:[o," ... ",o+t.length-1]})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:t.map((e,i)=>(0,D.jsx)(fC,{indexOrName:i+o,value:e,depth:n,parent:t,deleteHandle:w,editHandle:b,parentPath:l},String(r)+String(i)))})),(0,D.jsx)("span",{children:"]"})]})}function fI({node:e,depth:t,deleteHandle:n,indexOrName:r,customOptions:i,parent:a,parentPath:o}){let s=void 0!==r?[...o,String(r)]:o,l=[];for(let t=0;t<e.length;t+=100)l.push(e.slice(t,t+100));let{collapsed:c,enableClipboard:u,collapseObjectsAfterLength:d,editable:h,onDelete:p,src:f,onAdd:g,CustomOperation:v,onChange:x,forceUpdate:y,displaySize:b}=(0,R.useContext)(fY),[w,N]=(0,R.useState)(fc(e,t,r,c,d,i));(0,R.useEffect)(()=>{N(fc(e,t,r,c,d,i))},[c,d]);let[j,E]=(0,R.useState)(!1),[k,C]=(0,R.useState)(!1),T=()=>{e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:f,parentType:"array",parentPath:o}),x&&x({type:"add",indexOrName:e.length-1,depth:t,src:f,parentType:"array",parentPath:o}),y()},S=j||k,_=(0,D.jsxs)(D.Fragment,{children:[!w&&!S&&(0,D.jsxs)("span",Object.assign({onClick:()=>N(!0),className:"jv-size-chevron"},{children:[fu(b,t,w)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[e.length," Items"]})),(0,D.jsx)(fb,{className:"jv-chevron"})]})),S&&(0,D.jsx)(fM,{className:"json-view--edit",style:{display:"inline-block"},onClick:k?T:()=>{E(!1),n&&n(r,o),p&&p({value:e,depth:t,src:f,indexOrName:r,parentType:"array",parentPath:o}),x&&x({type:"delete",depth:t,src:f,indexOrName:r,parentType:"array",parentPath:o})}}),S&&(0,D.jsx)(fR,{className:"json-view--edit",style:{display:"inline-block"},onClick:()=>{E(!1),C(!1)}}),!w&&!S&&u&&fx(i)&&(0,D.jsx)(fk,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:a,parentPath:o,currentPath:s}}),!w&&!S&&fh(h)&&fg(i)&&(0,D.jsx)(fA,{className:"json-view--edit",onClick:()=>{T()}}),!w&&!S&&ff(h)&&fv(i)&&n&&(0,D.jsx)(fS,{className:"json-view--edit",onClick:()=>E(!0)}),"function"==typeof v?(0,D.jsx)(v,{node:e}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"["}),_,w?(0,D.jsx)("button",Object.assign({onClick:()=>N(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:l.map((a,s)=>(0,D.jsx)(fL,{originNode:e,node:a,depth:t,index:s,startIndex:100*s,deleteHandle:n,customOptions:i,parentPath:o},String(r)+String(s)))})),(0,D.jsx)("span",{children:"]"}),w&&fu(b,t,w)&&(0,D.jsxs)("span",Object.assign({onClick:()=>N(!1),className:"jv-size"},{children:[e.length," Items"]}))]})}function fO({node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parent:a,parentPath:o}){let{collapsed:s,onCollapse:l,enableClipboard:c,ignoreLargeArray:u,collapseObjectsAfterLength:d,editable:h,onDelete:p,src:f,onAdd:g,onEdit:v,onChange:x,forceUpdate:y,displaySize:b,CustomOperation:w}=(0,R.useContext)(fY),N=void 0!==n?[...o,String(n)]:o;if(!u&&Array.isArray(e)&&e.length>100)return(0,D.jsx)(fI,{node:e,depth:t,indexOrName:n,deleteHandle:r,customOptions:i,parentPath:N});let j=fo(e),[E,k]=(0,R.useState)(fl(e,t,n,s,d,i)),C=r=>{null==l||l({isCollapsing:!r,node:e,depth:t,indexOrName:n}),k(r)};(0,R.useEffect)(()=>{C(fl(e,t,n,s,d,i))},[s,d]);let T=(0,R.useCallback)((n,r,i)=>{Array.isArray(e)?e[+n]=r:e&&(e[n]=r),v&&v({newValue:r,oldValue:i,depth:t,src:f,indexOrName:n,parentType:j?"object":"array",parentPath:N}),x&&x({type:"edit",depth:t,src:f,indexOrName:n,parentType:j?"object":"array",parentPath:N}),y()},[e,v,x,y]),S=t=>{Array.isArray(e)?e.splice(+t,1):e&&delete e[t],y()},[_,A]=(0,R.useState)(!1),[M,P]=(0,R.useState)(!1),L=(0,R.useRef)(null),I=()=>{var n;if(j){let r=null==(n=L.current)?void 0:n.value;r&&(e[r]=null,L.current&&(L.current.value=""),P(!1),g&&g({indexOrName:r,depth:t,src:f,parentType:"object",parentPath:N}),x&&x({type:"add",indexOrName:r,depth:t,src:f,parentType:"object",parentPath:N}))}else Array.isArray(e)&&(e.push(null),g&&g({indexOrName:e.length-1,depth:t,src:f,parentType:"array",parentPath:N}),x&&x({type:"add",indexOrName:e.length-1,depth:t,src:f,parentType:"array",parentPath:N}));y()},O=_||M,B=()=>{A(!1),P(!1)},F=(0,D.jsxs)(D.Fragment,{children:[!E&&!O&&(0,D.jsxs)("span",Object.assign({onClick:()=>C(!0),className:"jv-size-chevron"},{children:[fu(b,t,E)&&(0,D.jsxs)("span",Object.assign({className:"jv-size"},{children:[fs(e)," Items"]})),(0,D.jsx)(fb,{className:"jv-chevron"})]})),M&&j&&(0,D.jsx)("input",{className:"json-view--input",placeholder:"property",ref:L,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),I()):"Escape"===e.key&&B()}}),O&&(0,D.jsx)(fM,{className:"json-view--edit",style:{display:"inline-block"},onClick:M?I:()=>{A(!1),r&&r(n,N),p&&p({value:e,depth:t,src:f,indexOrName:n,parentType:j?"object":"array",parentPath:N}),x&&x({type:"delete",depth:t,src:f,indexOrName:n,parentType:j?"object":"array",parentPath:N})}}),O&&(0,D.jsx)(fR,{className:"json-view--edit",style:{display:"inline-block"},onClick:B}),!E&&!O&&c&&fx(i)&&(0,D.jsx)(fk,{node:e,nodeMeta:{depth:t,indexOrName:n,parent:a,parentPath:o,currentPath:N}}),!E&&!O&&fh(h)&&fg(i)&&(0,D.jsx)(fA,{className:"json-view--edit",onClick:()=>{j?(P(!0),setTimeout(()=>{var e;return null==(e=L.current)?void 0:e.focus()})):I()}}),!E&&!O&&ff(h)&&fv(i)&&r&&(0,D.jsx)(fS,{className:"json-view--edit",onClick:()=>A(!0)}),"function"==typeof w?(0,D.jsx)(w,{node:e}):null]});return Array.isArray(e)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"["}),F,E?(0,D.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:e.map((r,i)=>(0,D.jsx)(fC,{indexOrName:i,value:r,depth:t,parent:e,deleteHandle:S,editHandle:T,parentPath:N},String(n)+String(i)))})),(0,D.jsx)("span",{children:"]"}),E&&fu(b,t,E)&&(0,D.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[fs(e)," Items"]}))]}):j?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{children:"{"}),F,E?(0,D.jsx)("button",Object.assign({onClick:()=>C(!1),className:"jv-button"},{children:"..."})):(0,D.jsx)("div",Object.assign({className:"jv-indent"},{children:Object.entries(e).map(([r,i])=>(0,D.jsx)(fC,{indexOrName:r,value:i,depth:t,parent:e,deleteHandle:S,editHandle:T,parentPath:N},String(n)+String(r)))})),(0,D.jsx)("span",{children:"}"}),E&&fu(b,t,E)&&(0,D.jsxs)("span",Object.assign({onClick:()=>C(!1),className:"jv-size"},{children:[fs(e)," Items"]}))]}):(0,D.jsx)("span",{children:String(e)})}let fB=R.default.forwardRef(({str:e,className:t,ctrlClick:n},r)=>{let{collapseStringMode:i,collapseStringsAfterLength:a,customizeCollapseStringUI:o}=(0,R.useContext)(fY),[s,l]=(0,R.useState)(!0),c=(0,R.useRef)(null);a=a>0?a:0;let u=e.replace(/\s+/g," "),d="function"==typeof o?o(u,s):"string"==typeof o?o:"...",h=e=>{var t;if((e.ctrlKey||e.metaKey)&&n)n(e);else{let e=window.getSelection();if(e&&e.anchorOffset!==e.focusOffset&&(null==(t=e.anchorNode)?void 0:t.parentElement)===c.current)return;l(!s)}};if(e.length<=a)return(0,D.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']}));if("address"===i)return e.length<=10?(0,D.jsxs)("span",Object.assign({ref:c,className:t,onClick:n},{children:['"',e,'"']})):(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,6),d,u.slice(-4)]:e,'"']}));if("directly"===i)return(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[u.slice(0,a),d]:e,'"']}));if("word"===i){let n=a,r=a+1,i=u,o=1;for(;;){if(/\W/.test(e[n])){i=e.slice(0,n);break}if(/\W/.test(e[r])){i=e.slice(0,r);break}if(6===o){i=e.slice(0,a);break}o++,n--,r++}return(0,D.jsxs)("span",Object.assign({ref:c,onClick:h,className:t+" cursor-pointer"},{children:['"',s?[i,d]:e,'"']}))}return(0,D.jsxs)("span",Object.assign({ref:c,className:t},{children:['"',e,'"']}))});function fF(){return(fF=Object.assign.bind()).apply(this,arguments)}var fz=function(e){return R.createElement("svg",fF({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),S||(S=R.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 fV(){return(fV=Object.assign.bind()).apply(this,arguments)}var fH=function(e){return R.createElement("svg",fV({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none",viewBox:"0 0 24 24"},e),_||(_=R.createElement("path",{fill:"currentColor",d:"M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"})),A||(A=R.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 fU({node:e,depth:t,deleteHandle:n,indexOrName:r,parent:i,editHandle:a,parentPath:o}){let s,{collapseStringsAfterLength:l,enableClipboard:c,editable:u,src:d,onDelete:h,onChange:p,customizeNode:f,matchesURL:g,urlRegExp:v,EditComponent:x,DoneComponent:y,CancelComponent:b,CustomOperation:w}=(0,R.useContext)(fY);if("function"==typeof f&&(s=fd(f,[{node:e,depth:t,indexOrName:r}])),s){if((0,R.isValidElement)(s))return s;else if("function"==typeof s){let n=s;return(0,D.jsx)(n,{node:e,depth:t,indexOrName:r})}}if(Array.isArray(e)||fo(e))return(0,D.jsx)(fO,{parent:i,node:e,depth:t,indexOrName:r,deleteHandle:n,parentPath:o,customOptions:"object"==typeof s?s:void 0});{var N;let f=typeof e,j=void 0!==r?[...o,String(r)]:o,[E,k]=(0,R.useState)(!1),[C,T]=(0,R.useState)(!1),S=(0,R.useRef)(null),_=()=>{k(!0),setTimeout(()=>{var e,t;null==(e=window.getSelection())||e.selectAllChildren(S.current),null==(t=S.current)||t.focus()})},A=(0,R.useCallback)(()=>{let t=S.current.innerText;try{let n=JSON.parse(t);a&&a(r,n,e,o)}catch(i){let n="string"===f?t.trim().replace(/^\"([\s\S]+?)\"$/,"$1"):t;a&&a(r,n,e,o)}k(!1)},[a,r,e,o,f]),M=()=>{k(!1),T(!1)},P=()=>{T(!1),n&&n(r,o),h&&h({value:e,depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",parentPath:o}),p&&p({depth:t,src:d,indexOrName:r,parentType:Array.isArray(i)?"array":"object",type:"delete",parentPath:o})},L=(0,R.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),A()):"Escape"===e.key&&M()},[A]),I=E||C,O=!I&&fp(u)&&fm(s)&&a?e=>{(e.ctrlKey||e.metaKey)&&_()}:void 0,B=(0,D.jsxs)(D.Fragment,{children:[I&&("function"==typeof y?(0,D.jsx)(y,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A}):(0,D.jsx)(fM,{className:"json-view--edit",style:{display:"inline-block"},onClick:C?P:A})),I&&("function"==typeof b?(0,D.jsx)(b,{className:"json-view--edit",style:{display:"inline-block"},onClick:M}):(0,D.jsx)(fR,{className:"json-view--edit",style:{display:"inline-block"},onClick:M})),!I&&c&&fx(s)&&(0,D.jsx)(fk,{node:e,nodeMeta:{depth:t,indexOrName:r,parent:i,parentPath:o,currentPath:j}}),!I&&g&&"string"===f&&v.test(e)&&(!(N=s)||void 0===N.matchesURL||!!N.matchesURL)&&(0,D.jsx)("a",Object.assign({href:e,target:"_blank",className:"json-view--link"},{children:(0,D.jsx)(fH,{})})),!I&&fp(u)&&fm(s)&&a&&("function"==typeof x?(0,D.jsx)(x,{className:"json-view--edit",onClick:_}):(0,D.jsx)(fz,{className:"json-view--edit",onClick:_})),!I&&ff(u)&&fv(s)&&n&&(0,D.jsx)(fS,{className:"json-view--edit",onClick:()=>T(!0)}),"function"==typeof w?(0,D.jsx)(w,{node:e}):null]}),F="json-view--string";switch(f){case"number":case"bigint":F="json-view--number";break;case"boolean":F="json-view--boolean";break;case"object":F="json-view--null"}"string"==typeof(null==s?void 0:s.className)&&(F+=" "+s.className),C&&(F+=" json-view--deleting");let z=String(e);"bigint"===f&&(z+="n");let V=(0,R.useMemo)(()=>(0,D.jsx)("span",{contentEditable:!0,className:F,dangerouslySetInnerHTML:{__html:"string"===f?`"${z}"`:z},ref:S,onKeyDown:L}),[z,f,L]);return"string"===f?(0,D.jsxs)(D.Fragment,{children:[E?V:e.length>l?(0,D.jsx)(fB,{str:e,ref:S,className:F,ctrlClick:O}):(0,D.jsxs)("span",Object.assign({className:F,onClick:O},{children:['"',z,'"']})),B]}):(0,D.jsxs)(D.Fragment,{children:[E?V:(0,D.jsx)("span",Object.assign({className:F,onClick:O},{children:z})),B]})}}let fG=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,fY=(0,R.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:fG,ignoreLargeArray:!1,CopyComponent:void 0,CopiedComponent:void 0,EditComponent:void 0,CancelComponent:void 0,DoneComponent:void 0,CustomOperation:void 0});function fX({src:e,collapseStringsAfterLength:t=99,collapseStringMode:n="directly",customizeCollapseStringUI:r,collapseObjectsAfterLength:i=99,collapsed:a,onCollapse:o,enableClipboard:s=!0,editable:l=!1,onEdit:c,onDelete:u,onAdd:d,onChange:h,dark:p=!1,theme:f="default",customizeNode:g,customizeCopy:v=e=>(function(e,t){if("string"==typeof e)return e;try{return JSON.stringify(e,(e,t)=>{switch(typeof t){case"bigint":return String(t)+"n";case"number":case"boolean":case"object":case"string":return t;default:return String(t)}},void 0)}catch(e){return`${e.name}: ${e.message}`||"JSON.stringify failed"}})(e),displaySize:x,displayArrayIndex:y=!0,style:b,className:w,matchesURL:N=!1,urlRegExp:j=fG,ignoreLargeArray:E=!1,CopyComponent:k,CopiedComponent:C,EditComponent:T,CancelComponent:S,DoneComponent:_,CustomOperation:A}){let[M,P]=(0,R.useState)(0),L=(0,R.useCallback)(()=>P(e=>++e),[]),[I,O]=(0,R.useState)(e);return(0,R.useEffect)(()=>O(e),[e]),(0,D.jsx)(fY.Provider,Object.assign({value:{src:I,collapseStringsAfterLength:t,collapseStringMode:n,customizeCollapseStringUI:r,collapseObjectsAfterLength:i,collapsed:a,onCollapse:o,enableClipboard:s,editable:l,onEdit:c,onDelete:u,onAdd:d,onChange:h,forceUpdate:L,customizeNode:g,customizeCopy:v,displaySize:x,displayArrayIndex:y,matchesURL:N,urlRegExp:j,ignoreLargeArray:E,CopyComponent:k,CopiedComponent:C,EditComponent:T,CancelComponent:S,DoneComponent:_,CustomOperation:A}},{children:(0,D.jsx)("code",Object.assign({className:"json-view"+(p?" dark":"")+(f&&"default"!==f?" json-view_"+f:"")+(w?" "+w:""),style:b},{children:(0,D.jsx)(fU,{node:I,depth:1,editHandle:(e,t,n,r)=>{O(t),c&&c({newValue:t,oldValue:n,depth:1,src:I,indexOrName:e,parentType:null,parentPath:r}),h&&h({type:"edit",depth:1,src:I,indexOrName:e,parentType:null,parentPath:r})},deleteHandle:(e,t)=>{O(void 0),u&&u({value:I,depth:1,src:I,indexOrName:e,parentType:null,parentPath:t}),h&&h({depth:1,src:I,indexOrName:e,parentType:null,type:"delete",parentPath:t})},parentPath:[]})}))}))}let fW=(0,O.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 fq(){}function f$(){}let fK=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fZ=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fQ={};function fJ(e,t){return((t||fQ).jsx?fZ:fK).test(e)}let f0=/[ \t\n\f\r]/g;function f1(e){return""===e.replace(f0,"")}class f2{constructor(e,t){this.attribute=t,this.property=e}}f2.prototype.attribute="",f2.prototype.booleanish=!1,f2.prototype.boolean=!1,f2.prototype.commaOrSpaceSeparated=!1,f2.prototype.commaSeparated=!1,f2.prototype.defined=!1,f2.prototype.mustUseProperty=!1,f2.prototype.number=!1,f2.prototype.overloadedBoolean=!1,f2.prototype.property="",f2.prototype.spaceSeparated=!1,f2.prototype.space=void 0;let f5=0,f3=gt(),f4=gt(),f6=gt(),f7=gt(),f9=gt(),f8=gt(),ge=gt();function gt(){return 2**++f5}e.s(["boolean",0,f3,"booleanish",0,f4,"commaOrSpaceSeparated",0,ge,"commaSeparated",0,f8,"number",0,f7,"overloadedBoolean",0,f6,"spaceSeparated",0,f9],744);var gn=e.i(744);let gr=Object.keys(gn);class gi extends f2{constructor(e,t,n,r){let i=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++i<gr.length;){const e=gr[i];!function(e,t,n){n&&(e[t]=n)}(this,gr[i],(n&gn[e])===gn[e])}}}function ga(e){return e.toLowerCase()}gi.prototype.defined=!0;let go=/[A-Z]/g,gs=/-[a-z]/g,gl=/^data[-\w.:]+$/i;function gc(e){return"-"+e.toLowerCase()}function gu(e){return e.charAt(1).toUpperCase()}let gd={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 gh{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function gp(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new gh(n,r,t)}function gf(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new gi(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ga(r)]=r,n[ga(a.attribute)]=r}return new gh(t,n,e.space)}gh.prototype.normal={},gh.prototype.property={},gh.prototype.space=void 0;let gg=gf({properties:{ariaActiveDescendant:null,ariaAtomic:f4,ariaAutoComplete:null,ariaBusy:f4,ariaChecked:f4,ariaColCount:f7,ariaColIndex:f7,ariaColSpan:f7,ariaControls:f9,ariaCurrent:null,ariaDescribedBy:f9,ariaDetails:null,ariaDisabled:f4,ariaDropEffect:f9,ariaErrorMessage:null,ariaExpanded:f4,ariaFlowTo:f9,ariaGrabbed:f4,ariaHasPopup:null,ariaHidden:f4,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:f9,ariaLevel:f7,ariaLive:null,ariaModal:f4,ariaMultiLine:f4,ariaMultiSelectable:f4,ariaOrientation:null,ariaOwns:f9,ariaPlaceholder:null,ariaPosInSet:f7,ariaPressed:f4,ariaReadOnly:f4,ariaRelevant:null,ariaRequired:f4,ariaRoleDescription:f9,ariaRowCount:f7,ariaRowIndex:f7,ariaRowSpan:f7,ariaSelected:f4,ariaSetSize:f7,ariaSort:null,ariaValueMax:f7,ariaValueMin:f7,ariaValueNow:f7,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function gm(e,t){return t in e?e[t]:t}function gv(e,t){return gm(e,t.toLowerCase())}let gx=gf({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:f8,acceptCharset:f9,accessKey:f9,action:null,allow:null,allowFullScreen:f3,allowPaymentRequest:f3,allowUserMedia:f3,alt:null,as:null,async:f3,autoCapitalize:null,autoComplete:f9,autoFocus:f3,autoPlay:f3,blocking:f9,capture:null,charSet:null,checked:f3,cite:null,className:f9,cols:f7,colSpan:null,content:null,contentEditable:f4,controls:f3,controlsList:f9,coords:f7|f8,crossOrigin:null,data:null,dateTime:null,decoding:null,default:f3,defer:f3,dir:null,dirName:null,disabled:f3,download:f6,draggable:f4,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:f3,formTarget:null,headers:f9,height:f7,hidden:f6,high:f7,href:null,hrefLang:null,htmlFor:f9,httpEquiv:f9,id:null,imageSizes:null,imageSrcSet:null,inert:f3,inputMode:null,integrity:null,is:null,isMap:f3,itemId:null,itemProp:f9,itemRef:f9,itemScope:f3,itemType:f9,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:f3,low:f7,manifest:null,max:null,maxLength:f7,media:null,method:null,min:null,minLength:f7,multiple:f3,muted:f3,name:null,nonce:null,noModule:f3,noValidate:f3,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:f3,optimum:f7,pattern:null,ping:f9,placeholder:null,playsInline:f3,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:f3,referrerPolicy:null,rel:f9,required:f3,reversed:f3,rows:f7,rowSpan:f7,sandbox:f9,scope:null,scoped:f3,seamless:f3,selected:f3,shadowRootClonable:f3,shadowRootDelegatesFocus:f3,shadowRootMode:null,shape:null,size:f7,sizes:null,slot:null,span:f7,spellCheck:f4,src:null,srcDoc:null,srcLang:null,srcSet:null,start:f7,step:null,style:null,tabIndex:f7,target:null,title:null,translate:null,type:null,typeMustMatch:f3,useMap:null,value:f4,width:f7,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:f9,axis:null,background:null,bgColor:null,border:f7,borderColor:null,bottomMargin:f7,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:f3,declare:f3,event:null,face:null,frame:null,frameBorder:null,hSpace:f7,leftMargin:f7,link:null,longDesc:null,lowSrc:null,marginHeight:f7,marginWidth:f7,noResize:f3,noHref:f3,noShade:f3,noWrap:f3,object:null,profile:null,prompt:null,rev:null,rightMargin:f7,rules:null,scheme:null,scrolling:f4,standby:null,summary:null,text:null,topMargin:f7,valueType:null,version:null,vAlign:null,vLink:null,vSpace:f7,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:f3,disableRemotePlayback:f3,prefix:null,property:null,results:f7,security:null,unselectable:null},space:"html",transform:gv}),gy=gf({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:ge,accentHeight:f7,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:f7,amplitude:f7,arabicForm:null,ascent:f7,attributeName:null,attributeType:null,azimuth:f7,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:f7,by:null,calcMode:null,capHeight:f7,className:f9,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:f7,diffuseConstant:f7,direction:null,display:null,dur:null,divisor:f7,dominantBaseline:null,download:f3,dx:null,dy:null,edgeMode:null,editable:null,elevation:f7,enableBackground:null,end:null,event:null,exponent:f7,externalResourcesRequired:null,fill:null,fillOpacity:f7,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:f8,g2:f8,glyphName:f8,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:f7,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:f7,horizOriginX:f7,horizOriginY:f7,id:null,ideographic:f7,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:f7,k:f7,k1:f7,k2:f7,k3:f7,k4:f7,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:f7,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:f7,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:f7,overlineThickness:f7,paintOrder:null,panose1:null,path:null,pathLength:f7,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:f9,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:f7,pointsAtY:f7,pointsAtZ:f7,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,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:f7,specularExponent:f7,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:f7,strikethroughThickness:f7,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:f7,strokeOpacity:f7,strokeWidth:null,style:null,surfaceScale:f7,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:f7,tableValues:null,target:null,targetX:f7,targetY:f7,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:f7,underlineThickness:f7,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:f7,values:null,vAlphabetic:f7,vMathematical:f7,vectorEffect:null,vHanging:f7,vIdeographic:f7,version:null,vertAdvY:f7,vertOriginX:f7,vertOriginY:f7,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:f7,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gm}),gb=gf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),gw=gf({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:gv}),gN=gf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),gj=gp([gg,gx,gb,gw,gN],"html"),gE=gp([gg,gy,gb,gw,gN],"svg");var gk=e.i(15511);let gC=gS("end"),gT=gS("start");function gS(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function g_(e){return e&&"object"==typeof e?"position"in e||"type"in e?gD(e.position):"start"in e||"end"in e?gD(e):"line"in e||"column"in e?gA(e):"":""}function gA(e){return gM(e&&e.line)+":"+gM(e&&e.column)}function gD(e){return gA(e&&e.start)+"-"+gA(e&&e.end)}function gM(e){return e&&"number"==typeof e?e:1}class gP extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},a=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=g_(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}gP.prototype.file="",gP.prototype.name="",gP.prototype.reason="",gP.prototype.message="",gP.prototype.stack="",gP.prototype.column=void 0,gP.prototype.line=void 0,gP.prototype.ancestors=void 0,gP.prototype.cause=void 0,gP.prototype.fatal=void 0,gP.prototype.place=void 0,gP.prototype.ruleId=void 0,gP.prototype.source=void 0;let gR={}.hasOwnProperty,gL=new Map,gI=/[A-Z]/g,gO=new Set(["table","tbody","thead","tfoot","tr"]),gB=new Set(["td","th"]),gF="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gz(e,t,n){var r,i,a,o,s,l,c,u,d;let h,p,f,g,v,x,y,b,w,N,j;return"element"===t.type?(r=e,i=t,a=n,p=h=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===h.space&&(r.schema=gE),r.ancestors.push(i),f=gG(r,i.tagName,!1),g=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&gR.call(t.properties,r)){let a=function(e,t,n){let r=function(e,t){let n=ga(t),r=t,i=f2;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&gl.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(gs,gu);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!gs.test(e)){let n=e.replace(go,gc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=gi}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,gk.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new gP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=gF+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)gR.call(e,t)&&(n[function(e){let t=e.replace(gI,gX);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?gd[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(a){let[r,o]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof o&&gB.has(t.tagName)?n=o:i[r]=o}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),v=gU(r,i),gO.has(i.tagName)&&(v=v.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&f1(e.value):f1(e))})),gV(r,g,f,i),gH(g,v),r.ancestors.pop(),r.schema=h,r.create(i,f,g,a)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return fq("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}gY(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(o=e,s=t,l=n,y=x=o.schema,"svg"===s.name&&"html"===x.space&&(o.schema=gE),o.ancestors.push(s),b=null===s.name?o.Fragment:gG(o,s.name,!0),w=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];fq("ExpressionStatement"===t.type);let i=t.expression;fq("ObjectExpression"===i.type);let a=i.properties[0];fq("SpreadElement"===a.type),Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else gY(e,t.position);else{let i,a=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];fq("ExpressionStatement"===t.type),i=e.evaluater.evaluateExpression(t.expression)}else gY(e,t.position);else i=null===r.value||r.value;n[a]=i}return n}(o,s),N=gU(o,s),gV(o,w,b,s),gH(w,N),o.ancestors.pop(),o.schema=x,o.create(s,b,w,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gY(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=n,gH(j={},gU(c,u)),c.create(u,c.Fragment,j,d)):"text"===t.type?t.value:void 0}function gV(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function gH(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function gU(e,t){let n=[],r=-1,i=e.passKeys?new Map:gL;for(;++r<t.children.length;){let a,o=t.children[r];if(e.passKeys){let e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){let t=i.get(e)||0;a=e+"-"+t,i.set(e,t+1)}}let s=gz(e,o,a);void 0!==s&&n.push(s)}return n}function gG(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=fJ(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}fq(e,"always a result"),r=e}else r=fJ(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return gR.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);gY(e)}function gY(e,t){let n=new gP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=gF+"#cannot-handle-mdx-estrees-without-createevaluater",n}function gX(e){return"-"+e.toLowerCase()}let gW={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"]},gq={};function g$(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return gK(e.children,t,n)}return Array.isArray(e)?gK(e,t,n):""}function gK(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=g$(e[i],t,n);return r.join("")}function gZ(e,t,n,r){let i,a=e.length,o=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)(i=r.slice(o,o+1e4)).unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function gQ(e,t){return e.length>0?(gZ(e,e.length,0,t),e):t}let gJ={}.hasOwnProperty;function g0(e){return null!==e&&e<-2}function g1(e){return -2===e||-1===e||32===e}function g2(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function g5(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return g1(r)?(e.enter(n),function r(o){return g1(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}g2(/[A-Za-z]/),g2(/[\dA-Za-z]/),g2(/[#-'*+\--9=?A-Z^-~]/),g2(/\d/),g2(/[\dA-Fa-f]/),g2(/[!-/:-@[-`{-~]/),g2(/\p{P}|\p{S}/u),g2(/\s/);let g3={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),g5(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return g0(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},g4={tokenize:function(e){let t,n,r,i=this,a=[],o=0;return s;function s(t){if(o<a.length){let n=a[o];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(o++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&x();let r=i.events.length,a=r;for(;a--;)if("exit"===i.events[a][0]&&"chunkFlow"===i.events[a][1].type){n=i.events[a][1].end;break}v(o);let s=r;for(;s<i.events.length;)i.events[s][1].end={...n},s++;return gZ(i.events,a+1,0,i.events.slice(r)),i.events.length=s,c(e)}return s(e)}function c(n){if(o===a.length){if(!t)return h(n);if(t.currentConstruct&&t.currentConstruct.concrete)return f(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(g6,u,d)(n)}function u(e){return t&&x(),v(o),h(e)}function d(e){return i.parser.lazy[i.now().line]=o!==a.length,r=i.now().offset,f(e)}function h(t){return i.containerState={},e.attempt(g6,p,f)(t)}function p(e){return o++,a.push([i.currentConstruct,i.containerState]),h(e)}function f(r){if(null===r){t&&x(),v(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){g(e.exit("chunkFlow"),!0),v(0),e.consume(n);return}return g0(n)?(e.consume(n),g(e.exit("chunkFlow")),o=0,i.interrupt=void 0,s):(e.consume(n),t)}(r)}function g(e,a){let s=i.sliceStream(e);if(a&&s.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(s),i.parser.lazy[e.start.line]){let e,n,a=t.events.length;for(;a--;)if(t.events[a][1].start.offset<r&&(!t.events[a][1].end||t.events[a][1].end.offset>r))return;let s=i.events.length,l=s;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(v(o),a=s;a<i.events.length;)i.events[a][1].end={...n},a++;gZ(i.events,l+1,0,i.events.slice(s)),i.events.length=a}}function v(t){let n=a.length;for(;n-- >t;){let t=a[n];i.containerState=t[1],t[0].exit.call(i,e)}a.length=t}function x(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},g6={tokenize:function(e,t,n){return g5(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},g7=mo(/[A-Za-z]/),g9=mo(/[\dA-Za-z]/),g8=mo(/[#-'*+\--9=?A-Z^-~]/),me=mo(/\d/),mt=mo(/[\dA-Fa-f]/),mn=mo(/[!-/:-@[-`{-~]/);function mr(e){return null!==e&&e<-2}function mi(e){return null!==e&&(e<0||32===e)}function ma(e){return -2===e||-1===e||32===e}function mo(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function ms(e,t,n,r){let i=r?r-1:1/0,a=0;return function(r){return ma(r)?(e.enter(n),function r(o){return ma(o)&&a++<i?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}mo(/\p{P}|\p{S}/u),mo(/\s/);let ml={partial:!0,tokenize:function(e,t,n){return function(t){return ma(t)?ms(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||mr(e)?t(e):n(e)}}};class mc{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&mu(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),mu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),mu(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);mu(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);mu(this.left,t.reverse())}}}function mu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function md(e){let t,n,r,i,a,o,s,l={},c=-1,u=new mc(e);for(;++c<u.length;){for(;c in l;)c=l[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((r=0)<(o=t[1]._tokenizer.events).length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e.get(t)[1],a=e.get(t)[2],o=t-1,s=[],l=i._tokenizer;!l&&(l=a.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,u=[],d={},h=-1,p=i,f=0,g=0,v=[0];for(;p;){for(;e.get(++o)[1]!==p;);s.push(o),!p._tokenizer&&(n=a.sliceStream(p),p.next||n.push(null),r&&l.defineSkip(p.start),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),p._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++h<c.length;)"exit"===c[h][0]&&"enter"===c[h-1][0]&&c[h][1].type===c[h-1][1].type&&c[h][1].start.line!==c[h][1].end.line&&(g=h+1,v.push(g),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(l.events=[],p?(p._tokenizer=void 0,p.previous=void 0):v.pop(),h=v.length;h--;){let t=c.slice(v[h],v[h+1]),n=s.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),h=-1;++h<u.length;)d[f+u[h][0]]=f+u[h][1],f+=u[h][1]-u[h][0]-1;return d}(u,c)),c=l[c],s=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=u.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(u.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else if("linePrefix"===i[1].type||"listItemIndent"===i[1].type);else break;n&&(t[1].end={...u.get(n)[1].start},(a=u.slice(n,c)).unshift(t),u.splice(n,c-n+1,a))}}return gZ(e,0,1/0,u.slice(0)),!s}let mh={resolve:function(e){return md(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):mr(t)?e.check(mp,a,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},mp={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ms(e,i,"linePrefix")};function i(i){if(null===i||mr(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},mf={tokenize:function(e){let t=this,n=e.attempt(ml,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,g5(e,e.attempt(this.parser.constructs.flow,r,e.attempt(mh,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},mg={resolveAll:my()},mm=mx("string"),mv=mx("text");function mx(e){return{resolveAll:my("text"===e?mb:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return l(e)?i(e):o(e)}function o(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),s)}function s(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function my(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function mb(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],a=t.sliceStream(i),o=a.length,s=-1,l=0;for(;o--;){let e=a[o];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let a={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}mj(/[A-Za-z]/),mj(/[\dA-Za-z]/),mj(/[#-'*+\--9=?A-Z^-~]/),mj(/\d/),mj(/[\dA-Fa-f]/),mj(/[!-/:-@[-`{-~]/);let mw=mj(/\p{P}|\p{S}/u),mN=mj(/\s/);function mj(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mE(e){return null===e||null!==e&&(e<0||32===e)||mN(e)?1:mw(e)?2:void 0}function mk(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}let mC={name:"attention",resolveAll:function(e,t){let n,r,i,a,o,s,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[n][1].end},h={...e[u][1].start};mT(d,-s),mT(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},o={type:s>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},i={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:s>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[n][1].end={...a.start},e[u][1].start={...o.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=gQ(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=gQ(l,[["enter",r,t],["enter",a,t],["exit",a,t],["enter",i,t]]),l=gQ(l,mk(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=gQ(l,[["exit",i,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=gQ(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,gZ(e,n-1,u-n+3,l),u=n+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,a=mE(i);return function(o){return n=o,e.enter("attentionSequence"),function o(s){if(s===n)return e.consume(s),o;let l=e.exit("attentionSequence"),c=mE(s),u=!c||2===c&&a||r.includes(s),d=!a||2===a&&c||r.includes(i);return l._open=!!(42===n?u:u&&(a||!d)),l._close=!!(42===n?d:d&&(c||!u)),t(s)}(o)}}};function mT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let mS={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return ma(t)?ms(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(mS,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return ma(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},m_={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return mn(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},mA=document.createElement("i");function mD(e){let t="&"+e+";";mA.innerHTML=t;let n=mA.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let mM={name:"characterReference",tokenize:function(e,t,n){let r,i,a=this,o=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=g9,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=mt,c):(e.enter("characterReferenceValue"),r=7,i=me,c(t))}function c(s){if(59===s&&o){let r=e.exit("characterReferenceValue");return i!==g9||mD(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return i(s)&&o++<r?(e.consume(s),c):n(s)}}},mP={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},mR={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(t){return e.enter("codeFencedFence"),ma(t)?ms(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(a++,e.consume(i),t):a>=s?(e.exit("codeFencedFenceSequence"),ma(i)?ms(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||mr(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},o=0,s=0;return function(t){var a;let c;return a=t,o=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=a,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s<3?n(i):(e.exit("codeFencedFenceSequence"),ma(i)?ms(e,l,"whitespace")(i):l(i))}(a)};function l(a){return null===a||mr(a)?(e.exit("codeFencedFence"),i.interrupt?t(a):e.check(mP,u,f)(a)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||mr(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):ma(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ms(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(a))}function c(t){return null===t||mr(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||mr(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function u(t){return e.attempt(a,f,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return o>0&&ma(t)?ms(e,p,"linePrefix",o+1)(t):p(t)}function p(t){return null===t||mr(t)?e.check(mP,u,f)(t):(e.enter("codeFlowValue"),function t(n){return null===n||mr(n)?(e.exit("codeFlowValue"),p(n)):(e.consume(n),t)}(t))}function f(n){return e.exit("codeFenced"),t(n)}}},mL={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),ms(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?a(n):mr(n)?e.attempt(mI,t,a)(n):(e.enter("codeFlowValue"),function n(r){return null===r||mr(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function a(n){return e.exit("codeIndented"),t(n)}}},mI={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):mr(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):ms(e,a,"linePrefix",5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):mr(e)?i(e):n(e)}}};function mO(e){return null!==e&&(e<32||127===e)}function mB(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mF(e,t,n,r,i,a,o,s,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),d):null===t||32===t||41===t||mO(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),f(t))};function d(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||null!==t&&t<-2?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(i){return!u&&(null===i||41===i||null!==i&&(i<0||32===i))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(i)):u<c&&40===i?(e.consume(i),u++,f):41===i?(e.consume(i),u--,f):null===i||32===i||40===i||mO(i)?n(i):(e.consume(i),92===i?g:f)}function g(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function mz(e){return null!==e&&e<-2}function mV(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mH(e,t,n,r,i,a){let o,s=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),c};function c(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):mz(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||mz(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=-2!==t&&-1!==t&&32!==t),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function mU(e){return null!==e&&e<-2}function mG(e){return -2===e||-1===e||32===e}function mY(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function mX(e,t,n,r,i,a){let o;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=40===t?41:t,s):n(t)};function s(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){if(t===o)return e.exit(a),s(o);if(null===t)return n(t);if(mU(t)){var r,i;let n,a;return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r=l,i="linePrefix",n=1/0,a=0,function(t){return mG(t)?(e.enter(i),function t(o){return mG(o)&&a++<n?(e.consume(o),t):(e.exit(i),r(o))}(t)):r(t)}}return e.enter("chunkString",{contentType:"string"}),c(t)}function c(t){return t===o||null===t||mU(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===o||92===t?(e.consume(t),c):c(t)}}function mW(e){return -2===e||-1===e||32===e}function mq(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function m$(e,t){let n;return function r(i){var a,o;if(null!==i&&i<-2)return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r;if(mW(i)){let t,s;return(a=r,o=n?"linePrefix":"lineSuffix",t=1/0,s=0,function(n){return mW(n)?(e.enter(o),function n(r){return mW(r)&&s++<t?(e.consume(r),n):(e.exit(o),a(r))}(n)):a(n)})(i)}return t(i)}}function mK(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}mB(/[A-Za-z]/),mB(/[\dA-Za-z]/),mB(/[#-'*+\--9=?A-Z^-~]/),mB(/\d/),mB(/[\dA-Fa-f]/),mB(/[!-/:-@[-`{-~]/),mB(/\p{P}|\p{S}/u),mB(/\s/),mV(/[A-Za-z]/),mV(/[\dA-Za-z]/),mV(/[#-'*+\--9=?A-Z^-~]/),mV(/\d/),mV(/[\dA-Fa-f]/),mV(/[!-/:-@[-`{-~]/),mV(/\p{P}|\p{S}/u),mV(/\s/),mY(/[A-Za-z]/),mY(/[\dA-Za-z]/),mY(/[#-'*+\--9=?A-Z^-~]/),mY(/\d/),mY(/[\dA-Fa-f]/),mY(/[!-/:-@[-`{-~]/),mY(/\p{P}|\p{S}/u),mY(/\s/),mq(/[A-Za-z]/),mq(/[\dA-Za-z]/),mq(/[#-'*+\--9=?A-Z^-~]/),mq(/\d/),mq(/[\dA-Fa-f]/),mq(/[!-/:-@[-`{-~]/),mq(/\p{P}|\p{S}/u),mq(/\s/);let mZ={partial:!0,tokenize:function(e,t,n){return function(t){return mi(t)?m$(e,r)(t):n(t)};function r(t){return mX(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return ma(t)?ms(e,a,"whitespace")(t):a(t)}function a(e){return null===e||mr(e)?t(e):n(e)}}},mQ=["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"],mJ=["pre","script","style","textarea"],m0={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(ml,t,n)}}},m1={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return mr(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},m2={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&gZ(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,a,o=e.length,s=0;for(;o--;)if(n=e[o][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[o][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[o][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=o,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(i=o);let l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},u={type:"labelText",start:{...e[r+s+2][1].end},end:{...e[i-2][1].start}};return a=gQ(a=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+s+3)),a=gQ(a,[["enter",u,t]]),a=gQ(a,mk(t.parser.constructs.insideSpan.null,e.slice(r+s+4,i-3),t)),a=gQ(a,[["exit",u,t],e[i-2],e[i-1],["exit",c,t]]),a=gQ(a,e.slice(i+1)),a=gQ(a,[["exit",l,t]]),gZ(e,r,e.length,a),e},tokenize:function(e,t,n){let r,i,a=this,o=a.events.length;for(;o--;)if(("labelImage"===a.events[o][1].type||"labelLink"===a.events[o][1].type)&&!a.events[o][1]._balanced){r=a.events[o][1];break}return function(t){return r?r._inactive?u(t):(i=a.parser.defined.includes(mK(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)};function s(t){return 40===t?e.attempt(m5,c,i?c:u)(t):91===t?e.attempt(m3,c,i?l:u)(t):i?c(t):u(t)}function l(t){return e.attempt(m4,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},m5={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return mi(t)?m$(e,i)(t):i(t)}function i(t){return 41===t?c(t):mF(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return mi(t)?m$(e,s)(t):c(t)}function o(e){return n(e)}function s(t){return 34===t||39===t||40===t?mX(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return mi(t)?m$(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},m3={tokenize:function(e,t,n){let r=this;return function(t){return mH.call(r,e,i,a,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(mK(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},m4={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},m6={name:"labelStartImage",resolveAll:m2.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},m7={name:"labelStartLink",resolveAll:m2.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},m9={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ms(e,t,"linePrefix")}}},m8={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(a){var o;return e.enter("thematicBreak"),r=o=a,function a(o){return o===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),ma(n)?ms(e,a,"whitespace")(n):a(n))}(o)):i>=3&&(null===o||mr(o))?(e.exit("thematicBreak"),t(o)):n(o)}(o)}}},ve={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(ml,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ms(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!ma(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(vn,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,ms(e,e.attempt(ve,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,o=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:me(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(m8,n,s)(t):s(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return me(i)&&++o<10?(e.consume(i),t):(!r.interrupt||o<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),s(i)):n(i)}(t)}return n(t)};function s(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(ml,r.interrupt?n:l,e.attempt(vt,u,c))}function l(e){return r.containerState.initialBlankLine=!0,a++,u(e)}function c(t){return ma(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},vt={partial:!0,tokenize:function(e,t,n){let r=this;return ms(e,function(e){let i=r.events[r.events.length-1];return!ma(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},vn={partial:!0,tokenize:function(e,t,n){let r=this;return ms(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},vr={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(r=a)}else"content"===e[a][1].type&&e.splice(a,1),i||"definition"!==e[a][1].type||(i=a);let o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",o,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=o,e.push(["exit",o,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var o;let s,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){s="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||s)?(e.enter("setextHeadingLine"),r=t,o=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),ma(n)?ms(e,a,"lineSuffix")(n):a(n))}(o)):n(t)};function a(r){return null===r||mr(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,mH.call(i,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function a(t){return(r=mK(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o):n(t)}function o(t){return mi(t)?m$(e,s)(t):s(t)}function s(t){return mF(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(mZ,c,c)(t)}function c(t){return ma(t)?ms(e,u,"whitespace")(t):u(t)}function u(a){return null===a||mr(a)?(e.exit("definition"),i.parser.defined.push(r),t(a)):n(a)}}}},"disable",0,{null:[]},"document",0,{42:ve,43:ve,45:ve,48:ve,49:ve,50:ve,51:ve,52:ve,53:ve,54:ve,55:ve,56:ve,57:ve,62:mS},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,a=3;return"whitespace"===e[3][1].type&&(a+=2),i-2>a&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(a===i-1||i-4>a&&"whitespace"===e[i-2][1].type)&&(i-=a+1===i?2:4),i>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[i][1].end},r={type:"chunkText",start:e[a][1].start,end:e[i][1].end,contentType:"text"},gZ(e,a,i-a+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var a;return e.enter("atxHeading"),a=i,e.enter("atxHeadingSequence"),function i(a){return 35===a&&r++<6?(e.consume(a),i):null===a||mi(a)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||mr(r)?(e.exit("atxHeading"),t(r)):ma(r)?ms(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||mi(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(a)):n(a)}(a)}}},42:m8,45:[vr,m8],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,a,o,s,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),i=!0,p):63===o?(e.consume(o),r=3,l.interrupt?t:P):g7(o)?(e.consume(o),a=String.fromCharCode(o),f):n(o)}function u(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,o=0,h):g7(i)?(e.consume(i),r=4,l.interrupt?t:P):n(i)}function d(r){return 45===r?(e.consume(r),l.interrupt?t:P):n(r)}function h(r){let i="CDATA[";return r===i.charCodeAt(o++)?(e.consume(r),o===i.length)?l.interrupt?t:k:h:n(r)}function p(t){return g7(t)?(e.consume(t),a=String.fromCharCode(t),f):n(t)}function f(o){if(null===o||47===o||62===o||mi(o)){let s=47===o,c=a.toLowerCase();return!s&&!i&&mJ.includes(c)?(r=1,l.interrupt?t(o):k(o)):mQ.includes(a.toLowerCase())?(r=6,s)?(e.consume(o),g):l.interrupt?t(o):k(o):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(o):i?function t(n){return ma(n)?(e.consume(n),t):j(n)}(o):v(o))}return 45===o||g9(o)?(e.consume(o),a+=String.fromCharCode(o),f):n(o)}function g(r){return 62===r?(e.consume(r),l.interrupt?t:k):n(r)}function v(t){return 47===t?(e.consume(t),j):58===t||95===t||g7(t)?(e.consume(t),x):ma(t)?(e.consume(t),v):j(t)}function x(t){return 45===t||46===t||58===t||95===t||g9(t)?(e.consume(t),x):y(t)}function y(t){return 61===t?(e.consume(t),b):ma(t)?(e.consume(t),y):v(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),s=t,w):ma(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||mi(n)?y(n):(e.consume(n),t)}(t)}function w(t){return t===s?(e.consume(t),s=null,N):null===t||mr(t)?n(t):(e.consume(t),w)}function N(e){return 47===e||62===e||ma(e)?v(e):n(e)}function j(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||mr(t)?k(t):ma(t)?(e.consume(t),E):n(t)}function k(t){return 45===t&&2===r?(e.consume(t),_):60===t&&1===r?(e.consume(t),A):62===t&&4===r?(e.consume(t),R):63===t&&3===r?(e.consume(t),P):93===t&&5===r?(e.consume(t),M):mr(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(m0,L,C)(t)):null===t||mr(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),k)}function C(t){return e.check(m1,T,L)(t)}function T(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),S}function S(t){return null===t||mr(t)?C(t):(e.enter("htmlFlowData"),k(t))}function _(t){return 45===t?(e.consume(t),P):k(t)}function A(t){return 47===t?(e.consume(t),a="",D):k(t)}function D(t){if(62===t){let n=a.toLowerCase();return mJ.includes(n)?(e.consume(t),R):k(t)}return g7(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),D):k(t)}function M(t){return 93===t?(e.consume(t),P):k(t)}function P(t){return 62===t?(e.consume(t),R):45===t&&2===r?(e.consume(t),P):k(t)}function R(t){return null===t||mr(t)?(e.exit("htmlFlowData"),L(t)):(e.consume(t),R)}function L(n){return e.exit("htmlFlow"),t(n)}}},61:vr,95:m8,96:mR,126:mR},"flowInitial",0,{[-2]:mL,[-1]:mL,32:mL},"insideSpan",0,{null:[mC,mg]},"string",0,{38:mM,92:m_},"text",0,{[-5]:m9,[-4]:m9,[-3]:m9,33:m6,38:mM,42:mC,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return g7(t)?(e.consume(t),a):64===t?n(t):s(t)}function a(t){return 43===t||45===t||46===t||g9(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,o):(43===n||45===n||46===n||g9(n))&&r++<32?(e.consume(n),t):(r=0,s(n))}(t)):s(t)}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||null!==r&&(r<32||127===r)?n(r):(e.consume(r),o)}function s(t){return 64===t?(e.consume(t),l):g8(t)?(e.consume(t),s):n(t)}function l(i){return g9(i)?function i(a){return 46===a?(e.consume(a),r=0,l):62===a?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(a){if((45===a||g9(a))&&r++<63){let n=45===a?t:i;return e.consume(a),n}return n(a)}(a)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,a,o=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),w):63===t?(e.consume(t),y):g7(t)?(e.consume(t),j):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,p):g7(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):mr(t)?(a=u,D(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?A(e):45===e?d(e):u(e)}function p(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),g):mr(t)?(a=f,D(t)):(e.consume(t),f)}function g(t){return 93===t?(e.consume(t),v):f(t)}function v(t){return 62===t?A(t):93===t?(e.consume(t),v):f(t)}function x(t){return null===t||62===t?A(t):mr(t)?(a=x,D(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):mr(t)?(a=y,D(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function w(t){return g7(t)?(e.consume(t),N):n(t)}function N(t){return 45===t||g9(t)?(e.consume(t),N):function t(n){return mr(n)?(a=t,D(n)):ma(n)?(e.consume(n),t):A(n)}(t)}function j(t){return 45===t||g9(t)?(e.consume(t),j):47===t||62===t||mi(t)?E(t):n(t)}function E(t){return 47===t?(e.consume(t),A):58===t||95===t||g7(t)?(e.consume(t),k):mr(t)?(a=E,D(t)):ma(t)?(e.consume(t),E):A(t)}function k(t){return 45===t||46===t||58===t||95===t||g9(t)?(e.consume(t),k):function t(n){return 61===n?(e.consume(n),C):mr(n)?(a=t,D(n)):ma(n)?(e.consume(n),t):E(n)}(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,T):mr(t)?(a=C,D(t)):ma(t)?(e.consume(t),C):(e.consume(t),S)}function T(t){return t===r?(e.consume(t),r=void 0,_):null===t?n(t):mr(t)?(a=T,D(t)):(e.consume(t),T)}function S(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||mi(t)?E(t):(e.consume(t),S)}function _(e){return 47===e||62===e||mi(e)?E(e):n(e)}function A(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function D(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return ma(t)?ms(e,P,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):P(t)}function P(t){return e.enter("htmlTextData"),a(t)}}}],91:m7,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return mr(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},m_],93:m2,95:mC,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),a++,t):(e.exit("codeTextSequence"),o(n))}(t)};function o(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),o):96===l?(i=e.enter("codeTextSequence"),r=0,function n(o){return 96===o?(e.consume(o),r++,n):r===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(o)):(i.type="codeTextData",s(o))}(l)):mr(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):(e.enter("codeTextData"),s(l))}function s(t){return null===t||32===t||96===t||mr(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),s)}}}}],4127);var vi=e.i(4127);let va=/[\0\t\n\r]/g;function vo(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let vs=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vl(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return vo(n.slice(t?2:1),t?16:10)}return mD(n)||e}let vc={}.hasOwnProperty;function vu(e){return{line:e.line,column:e.column,offset:e.offset}}function vd(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+g_({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+g_({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+g_({start:t.start,end:t.end})+") is still open")}function vh(e){let t=this;t.parser=function(n){var r,i;let a,o,s,l;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(x),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(f),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(p),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(p,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(g),hardBreakTrailing:r(g),htmlFlow:r(v,i),htmlFlowData:c,htmlText:r(v,i),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(x),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(y),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(f),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:o(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:o(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:o(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=vo(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=mD(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=vu(e.end)},codeFenced:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:o(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=mK(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:o(),hardBreakEscape:o(d),hardBreakTrailing:o(d),htmlFlow:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(vs,vl),n.identifier=mK(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=vu(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),u.call(this,e))},link:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=mK(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:o(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:o(),thematicBreak:o()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(vc.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:a,exit:s,buffer:i,resume:l,data:n},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,n){let r,i,a,o,s=t-1,l=-1,c=!1;for(;++s<=n;){let t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,o=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||o||l||a||(a=s),o=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:o=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let o=s;for(i=void 0;o--;){let t=e[o];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=o}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}a&&(!i||a<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||s,0,["exit",r,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(s,0,["enter",i,t[2]]),s++,n++,a=void 0,o=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),u));for(u=-1;++u<e.length;){let n=t[e[u][0]];vc.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},o),e[u][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||vd).call(o,void 0,e[0])}for(r.position={start:vu(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:vu(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r};function r(e,t){return function(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:vu(t.start),end:void 0}}function o(e){return function(t){e&&e.call(this,t),s.call(this,t)}}function s(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||vd).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+g_({start:e.start,end:e.end})+"): it’s not open");n.position.end=vu(e.end)}function l(){var e;return e=this.stack.pop(),g$(e,"boolean"!=typeof gq.includeImageAlt||gq.includeImageAlt,"boolean"!=typeof gq.includeHtml||gq.includeHtml)}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:vu(e.start),end:void 0},t.push(n)),this.stack.push(n)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=vu(e.end)}function d(){this.data.atHardBreak=!0}function h(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function f(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function v(){return{type:"html",value:""}}function x(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!md(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(gJ.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];if(a)for(r in a){gJ.call(i,r)||(i[r]=[]);let e=a[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);gZ(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([vi,...(e||{}).extensions||[]]),content:n(g3),defined:[],document:n(g4),flow:n(mf),lazy:{},string:n(mm),text:n(mv)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],l={attempt:f(function(e,t){g(e,t.from)}),check:f(p),consume:function(e){g0(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,v()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){let t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:f(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,v()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let a,o=e[r];if("string"==typeof o)a=o;else switch(o){case -5:a="\r";break;case -4:a="\n";break;case -3:a="\r\n";break;case -2:a=t?" ":" ";break;case -1:if(!t&&n)continue;a=" ";break;default:a=String.fromCharCode(o)}n=-2===o,i.push(a)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(o=gQ(o,e),function(){let e;for(;r._index<o.length;){let n=o[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==o[o.length-1])?[]:(g(t,0),c.events=mk(a,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;if(r===a)n=[e[r].slice(i,o)];else{if(n=e.slice(r,a),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}o>0&&n.push(e[a].slice(0,o))}return n}(o,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function p(e,t){t.restore()}function f(e,t){return function(n,i,a){var o;let u,d,p,f;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(o=n,function(e){let t=null!==e&&o[e],n=null!==e&&o.null;return g([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(u=e,d=0,0===e.length)?a:x(e[d])}function x(e){return function(n){let i,a,o,u,d;return(i=h(),a=c.previous,o=c.currentConstruct,u=c.events.length,d=Array.from(s),f={from:u,restore:function(){r=i,c.previous=a,c.currentConstruct=o,c.events.length=u,s=d,v()}},p=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,y,b)(n)}}function y(t){return e(p,f),i}function b(e){return(f.restore(),++d<u.length)?x(u[d]):a}}}function g(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&gZ(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((o=1,s="",l=!0,function(e,t,n){let r,i,c,u,d,h=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,s="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(va.lastIndex=c,u=(r=va.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(u),!r){s=e.slice(c);break}if(10===d&&c===u&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),c<u&&(h.push(e.slice(c,u)),o+=u-c),d){case 0:h.push(65533),o++;break;case 9:for(i=4*Math.ceil(o/4),h.push(-2);o++<i;)h.push(-1);break;case 10:h.push(-4),o=1;break;default:a=!0,o=1}c=u+1}return n&&(a&&h.push(-5),s&&h.push(s),h.push(null)),h})(n,r,!0))))}}let vp="object"==typeof self?self:globalThis,vf=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[a,o]=e[i];switch(a){case 0:case -1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new vp[e](t),i)}case 8:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new vp[a](o),i)})(0)},{toString:vg}={},{keys:vm}=Object,vv=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=vg.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},vx=([e,t])=>0===e&&("function"===t||"symbol"===t),vy=(e,{json:t,lossy:n}={})=>{var r,i,a;let o,s,l=[];return(r=!(t||n),i=!!t,a=new Map,o=(e,t)=>{let n=l.push(e)-1;return a.set(t,n),n},s=e=>{if(a.has(e))return a.get(e);let[t,n]=vv(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return o([-1],e)}return o([t,i],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),o([n,[...t]],e)}let r=[],i=o([t,r],e);for(let t of e)r.push(s(t));return i}case 2:{if(n)switch(n){case"BigInt":return o([n,e.toString()],e);case"Boolean":case"Number":case"String":return o([n,e.valueOf()],e)}if(i&&"toJSON"in e)return s(e.toJSON());let a=[],l=o([t,a],e);for(let t of vm(e))(r||!vx(vv(e[t])))&&a.push([s(t),s(e[t])]);return l}case 3:return o([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return o([t,{source:n,flags:r}],e)}case 5:{let n=[],i=o([t,n],e);for(let[t,i]of e)(r||!(vx(vv(t))||vx(vv(i))))&&n.push([s(t),s(i)]);return i}case 6:{let n=[],i=o([t,n],e);for(let t of e)(r||!vx(vv(t)))&&n.push(s(t));return i}}let{message:l}=e;return o([t,{name:n,message:l}],e)})(e),l},vb="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?vf(vy(e,t)):structuredClone(e):(e,t)=>vf(vy(e,t));vN(/[A-Za-z]/);let vw=vN(/[\dA-Za-z]/);function vN(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function vj(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o="";if(37===a&&vw(e.charCodeAt(n+1))&&vw(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function vE(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function vk(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}vN(/[#-'*+\--9=?A-Z^-~]/),vN(/\d/),vN(/[\dA-Fa-f]/),vN(/[!-/:-@[-`{-~]/),vN(/\p{P}|\p{S}/u),vN(/\s/);let vC=function(e){var t,n;if(null==e)return vS;if("function"==typeof e)return vT(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=vC(e[n]);return vT(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,vT(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,vT(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function vT(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function vS(){return!0}let v_=[];function vA(e,t,n,r){var i,a,o;let s,l,c,u,d,h;"function"==typeof t&&"function"!=typeof n?(l=void 0,c=t,s=n):(l=t,c=n,s=r),i=l,a=function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return c(e,r,n)},o=s,"function"==typeof i&&"function"!=typeof a?(o=a,a=i):u=i,d=vC(u),h=o?-1:1,(function e(t,n,r){let s=t&&"object"==typeof t?t:{};if("string"==typeof s.type){let e="string"==typeof s.tagName?s.tagName:"string"==typeof s.name?s.name:void 0;Object.defineProperty(l,"name",{value:"node ("+t.type+(e?"<"+e+">":"")+")"})}return l;function l(){var s;let l,c,u,p=v_;if((!i||d(t,n,r[r.length-1]||void 0))&&!1===(p=Array.isArray(s=a(t,r))?s:"number"==typeof s?[!0,s]:null==s?v_:[s])[0])return p;if("children"in t&&t.children&&t.children&&"skip"!==p[0])for(c=(o?t.children.length:-1)+h,u=r.concat(t);c>-1&&c<t.children.length;){if(!1===(l=e(t.children[c],c,u)())[0])return l;c="number"==typeof l[1]?l[1]:c+h}return p}})(e,void 0,[])()}function vD(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),a=i[0];a&&"text"===a.type?a.value="["+a.value:i.unshift({type:"text",value:"["});let o=i[i.length-1];return o&&"text"===o.type?o.value+=r:i.push({type:"text",value:r}),i}function vM(e){let t=e.spread;return null==t?e.children.length>1:t}function vP(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let vR={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a={type:"element",tagName:"pre",properties:{},children:[a=e.applyData(t,a)]},e.patch(t,a),a},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),a=vj(i.toLowerCase()),o=e.footnoteOrder.indexOf(i),s=e.footnoteCounts.get(i);void 0===s?(s=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=o+1,s+=1,e.footnoteCounts.set(i,s);let l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vD(e,t);let i={src:vj(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){let n={src:vj(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vD(e,t);let i={href:vj(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){let n={href:vj(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=vM(n[r])}return t}(n):vM(t),a={},o=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let e=r[s];(i||0!==s||"element"!==e.type||"p"!==e.tagName)&&o.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?o.push(e):o.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&o.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=gT(t.children[1]),o=gC(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,o=a?a.length:t.children.length,s=-1,l=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(vP(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(vP(t.slice(i),i>0,!1)),a.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:vL,yaml:vL,definition:vL,footnoteDefinition:vL};function vL(){}let vI={}.hasOwnProperty,vO={};function vB(e,t){e.position&&(t.position=function(e){let t=gT(e),n=gC(e);if(t&&n)return{start:t,end:n}}(e))}function vF(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,vb(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function vz(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function vV(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function vH(e,t){let n,r,i,a,o=(n=t||vO,r=new Map,i=new Map,a={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=vV(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=vV(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:vF,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...vR,...n.handlers},one:function(e,t){let n=e.type,r=a.handlers[n];if(vI.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=vb(n);return r.children=a.all(e),r}return vb(e)}return(a.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(vI.call(n,"hProperties")||vI.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(a,e,t)},options:n,patch:vB,wrap:vz},vA(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a),s=o.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||vE,r=e.options.footnoteBackLabel||vk,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[],l=-1;for(;++l<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[l]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),c=vj(o.toLowerCase()),u=0,d=[],h=e.footnoteCounts.get(o);for(;void 0!==h&&++u<=h;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else a.push(...d);let f={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(i,f),s.push(f)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...vb(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(o),c=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return l&&(fq("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function vU(e,t){return e&&"run"in e?async function(n,r){let i=vH(n,{file:r,...t});await e.run(i,r)}:function(n,r){return vH(n,{file:r,...e||t})}}function vG(e){if(e)throw e}var vY=e.i(4100);function vX(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let vW=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');vZ(e);let r=0,i=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else i<0&&(n=!0,i=a+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let o=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){r=a+1;break}}else o<0&&(n=!0,o=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(i=a):(s=-1,i=o));return r===i?i=o:i<0&&(i=e.length),e.slice(r,i)},vq=function(e){let t;if(vZ(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},v$=function(e){let t;vZ(e);let n=e.length,r=-1,i=0,a=-1,o=0;for(;n--;){let s=e.codePointAt(n);if(47===s){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===s?a<0?a=n:1!==o&&(o=1):a>-1&&(o=-1)}return a<0||r<0||0===o||1===o&&a===r-1&&a===i+1?"":e.slice(a,r)},vK=function(...e){var t;let n,r,i,a=-1;for(;++a<e.length;)vZ(e[a]),e[a]&&(i=void 0===i?e[a]:i+"/"+e[a]);return void 0===i?".":(vZ(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",a=0,o=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else if(47===n)break;else n=47;if(47===n){if(o===l-1||1===s);else if(o!==l-1&&2===s){if(i.length<2||2!==a||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",a=0):a=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),o=l,s=0;continue}}else if(i.length>0){i="",a=0,o=l,s=0;continue}}t&&(i=i.length>0?i+"/..":"..",a=2)}else i.length>0?i+="/"+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else 46===n&&s>-1?s++:s=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function vZ(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function vQ(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let vJ=["history","path","basename","stem","extname","dirname"];class v0{constructor(e){let t,n;t=e?vQ(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<vJ.length;){const e=vJ[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)vJ.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?vW(this.path):void 0}set basename(e){v2(e,"basename"),v1(e,"basename"),this.path=vK(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?vq(this.path):void 0}set dirname(e){v5(this.basename,"dirname"),this.path=vK(e||"",this.basename)}get extname(){return"string"==typeof this.path?v$(this.path):void 0}set extname(e){if(v1(e,"extname"),v5(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=vK(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){vQ(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!vQ(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),v2(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?vW(this.path,this.extname):void 0}set stem(e){v2(e,"stem"),v1(e,"stem"),this.path=vK(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new gP(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function v1(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function v2(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function v5(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let v3=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},v4={}.hasOwnProperty;class v6 extends v3{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(a,...o){let s=e[++n],l=-1;if(a)return void r(a);for(;++l<t.length;)(null===o[l]||void 0===o[l])&&(o[l]=t[l]);t=o,s?(function(e,t){let n;return function(...t){let a,o=e.length>t.length;o&&t.push(r);try{a=e.apply(this,t)}catch(e){if(o&&n)throw e;return r(e)}o||(a&&a.then&&"function"==typeof a.then?a.then(i,r):a instanceof Error?r(a):i(a))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(s,i)(...o):r(null,...o)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new v6,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,vY.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(xe("data",this.frozen),this.namespace[e]=t,this):v4.call(this.namespace,e)&&this.namespace[e]||void 0:e?(xe("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=xr(e),n=this.parser||this.Parser;return v9("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),v9("process",this.parser||this.Parser),v8("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=xr(e),o=n.parse(a);function s(e,n){e||!n?i(e):r?r(n):(fq(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(o,a,function(e,t,r){var i,a;if(e||!t||!r)return s(e);let o=n.stringify(t,r);"string"==typeof(i=o)||(a=i)&&"object"==typeof a&&"byteLength"in a&&"byteOffset"in a?r.value=o:r.result=o,s(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),v9("processSync",this.parser||this.Parser),v8("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,vG(e),t=r}),xn("processSync","process",n),fq(t,"we either bailed on an error or have a tree"),t}run(e,t,n){xt(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){fq("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let o=xr(t);r.run(e,o,function(t,r,o){let s=r||e;t?a(t):i?i(s):(fq(n,"`done` is defined if `resolve` is not"),n(void 0,s,o))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){vG(e),n=t,r=!0}),xn("runSync","run",r),fq(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=xr(t),r=this.compiler||this.Compiler;return v8("stringify",r),xt(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(xe("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else if("object"==typeof e)Array.isArray(e)?a(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(r.settings=(0,vY.default)(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)o(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;o(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function o(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];vX(o)&&vX(r)&&(r=(0,vY.default)(!0,o,r)),n[i]=[e,r,...a]}}}}let v7=new v6().freeze();function v9(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function v8(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function xe(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xt(e){if(!vX(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function xn(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function xr(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new v0(e)}let xi=[],xa={allowDangerousHtml:!0},xo=/^(https?|ircs?|mailto|xmpp)$/i,xs=[{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 xl(e){var t;let n,r,i,a,o,s=(n=(t=e).rehypePlugins||xi,r=t.remarkPlugins||xi,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...xa}:xa,v7().use(vh).use(r).use(vU,i).use(n)),l=(a=e.children||"",o=new v0,"string"==typeof a?o.value=a:f$("Unexpected value `"+a+"` for `children` prop, expected `string`"),o);return function(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,l=t.urlTransform||xc;for(let e of xs)Object.hasOwn(t,e.from)&&f$("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&a&&f$("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),vA(e,function(e,t,i){if("raw"===e.type&&i&&"number"==typeof t)return o?i.children.splice(t,1):i.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in gW)if(Object.hasOwn(gW,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=gW[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let o=n?!n.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&r&&"number"==typeof t&&(o=!r(e,t,i)),o&&i&&"number"==typeof t)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}),function(e,t){var n,r,i,a;let o;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let s=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=s,r=t.jsxDEV,o=function(e,t,i,a){let o=Array.isArray(i.children),s=gT(e);return r(t,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:n,lineNumber:s?s.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,a=t.jsxs,o=function(e,t,n,r){let o=Array.isArray(n.children)?a:i;return r?o(t,n,r):o(t,n)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?gE:gj,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=gz(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:D.Fragment,components:i,ignoreInvalidStyle:!0,jsx:D.jsx,jsxs:D.jsxs,passKeys:!0,passNode:!0})}(s.runSync(s.parse(l),l),e)}function xc(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return -1===t||-1!==i&&t>i||-1!==n&&t>n||-1!==r&&t>r||xo.test(e.slice(0,t))?e:""}let xu=e=>{let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`};function xd({mentalModel:e}){return(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),e.trigger?.refresh_after_consolidation&&(0,D.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,D.jsx)(fW,{className:"w-3 h-3"}),"Auto refresh"]})]}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground/70",children:e.id}),e.source_query&&(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e.source_query})]}),(0,D.jsxs)("div",{className:"flex gap-8",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Created"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:xu(e.created_at)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Last Refreshed"}),(0,D.jsx)("div",{className:"text-sm text-foreground",children:xu(e.last_refreshed_at)})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xl,{children:e.content})})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map((e,t)=>(0,D.jsx)("span",{className:"px-2 py-0.5 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded text-xs",children:e},t))})]})]})}function xh({mentalModelId:e,onClose:t}){let{currentBank:n}=(0,L.useBank)(),[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(!1),[s,l]=(0,R.useState)(null);(0,R.useEffect)(()=>{e&&n&&(async()=>{o(!0),l(null),i(null);try{let t=await q.client.getMentalModel(n,e);i(t)}catch(e){console.error("Error loading mental model:",e),l(e.message)}finally{o(!1)}})()},[e,n]);let c=null!==e;return(0,D.jsx)(tl.Dialog,{open:c,onOpenChange:e=>!e&&t(),children:(0,D.jsxs)(tl.DialogContent,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col p-6",children:[(0,D.jsx)(hJ,{children:(0,D.jsx)(tl.DialogTitle,{children:"Mental Model Details"})}),a?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)(ts,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):s?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)("div",{className:"text-center text-destructive",children:(0,D.jsxs)("div",{className:"text-sm",children:["Error: ",s]})})}):r?(0,D.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,D.jsx)(xd,{mentalModel:r})}):null]})})}function xp(){let e,t,n,r,i,a,o,s,l,c,u,{currentBank:d}=(0,L.useBank)(),[h,p]=(0,R.useState)(""),[f,g]=(0,R.useState)("mid"),[v,x]=(0,R.useState)(4096),[y,b]=(0,R.useState)(!0),[w,N]=(0,R.useState)(!0),[j,E]=(0,R.useState)("answer"),[k,C]=(0,R.useState)(null),[T,S]=(0,R.useState)(!1),[_,A]=(0,R.useState)(""),[M,P]=(0,R.useState)("any"),[I,O]=(0,R.useState)(""),[z,V]=(0,R.useState)(!1),[H,U]=(0,R.useState)(!1),[G,Y]=(0,R.useState)(null),[X,W]=(0,R.useState)(null),[Z,Q]=(0,R.useState)(null),[J,ee]=(0,R.useState)(!1),[et,en]=(0,R.useState)(null),[er,ea]=(0,R.useState)(null),[eo,es]=(0,R.useState)(!1),[el,ec]=(0,R.useState)(null),[eu,ed]=(0,R.useState)("world"),eh="General Feedback",ep=async e=>{if(en(e),ea(null),d&&e?.id){es(!0);try{let t=await q.client.listObservations(d),n=t.items?.find(t=>t.id===e.id);ea(n||e)}catch(t){console.error("Failed to load observation:",t),ea(e)}finally{es(!1)}}},ef=async()=>{if(d&&I.trim()){V(!0);try{let e=await q.client.listDirectives(d),t=e.items?.find(e=>e.name===eh);if(t){let e=t.content?`${t.content}
8
- ${I.trim()}`:I.trim();await q.client.updateDirective(d,t.id,{content:e})}else await q.client.createDirective(d,{name:eh,content:I.trim()});O(""),U(!0),setTimeout(()=>U(!1),3e3)}catch(e){console.error("Error submitting feedback:",e),alert("Error submitting feedback: "+e.message)}finally{V(!1)}}},eg=async()=>{if(d&&h){S(!0),E("answer");try{let e=_.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=await q.client.reflect({bank_id:d,query:h,budget:f,max_tokens:v,include_facts:y,include_tool_calls:w,...e.length>0&&{tags:e,tags_match:M}});C(t)}catch(e){console.error("Error running reflect:",e),alert("Error running reflect: "+e.message)}finally{S(!1)}}};return d?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(B,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"text",value:h,onChange:e=>p(e.target.value),placeholder:"What would you like to reflect on?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&eg()})]}),(0,D.jsx)($.Button,{onClick:eg,disabled:T||!h,className:"h-12 px-8",children:T?"Reflecting...":"Reflect"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Budget:"}),(0,D.jsxs)(pa,{value:f,onValueChange:e=>g(e),children:[(0,D.jsx)(pK,{className:"w-24 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"low",children:"Low"}),(0,D.jsx)(p0,{value:"mid",children:"Mid"}),(0,D.jsx)(p0,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(K.Input,{type:"number",value:v,onChange:e=>x(parseInt(e.target.value)||4096),className:"w-24 h-8"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:y,onCheckedChange:e=>b(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Source"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:w,onCheckedChange:e=>N(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Tools"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(td.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(K.Input,{type:"text",value:_,onChange:e=>A(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(pa,{value:M,onValueChange:e=>P(e),children:[(0,D.jsx)(pK,{className:"w-40 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(p0,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(p0,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(p0,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),T&&(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Reflecting on memories..."})]})}),!T&&k&&(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[k.usage&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Input tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.usage.input_tokens?.toLocaleString()})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Output tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.usage.output_tokens?.toLocaleString()})]})]}),k.trace?.tool_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Tool calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.trace.tool_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",k.trace.tool_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),k.trace?.llm_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"LLM calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.trace.llm_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",k.trace.llm_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>E(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${j===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===e?"Answer":"trace"===e?"Trace":"JSON"},e))})]}),"answer"===j&&(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{children:"Answer"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"text-base leading-relaxed whitespace-pre-wrap",children:k.text})})]}),k.new_opinions&&k.new_opinions.length>0&&(0,D.jsxs)(p2,{className:"border-green-200 dark:border-green-800",children:[(0,D.jsxs)(p5,{className:"bg-green-50 dark:bg-green-950",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2",children:[(0,D.jsx)(B,{className:"w-5 h-5"}),"New Opinions Formed"]}),(0,D.jsx)(p4,{children:"New beliefs generated from this interaction"})]}),(0,D.jsx)(p6,{className:"pt-6",children:(0,D.jsx)("div",{className:"space-y-3",children:k.new_opinions.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-muted rounded-lg border border-border",children:[(0,D.jsx)("div",{className:"font-semibold text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"text-sm text-muted-foreground mt-1",children:["Confidence: ",e.confidence?.toFixed(2)]})]},t))})})]}),(0,D.jsxs)(p2,{className:"border-blue-200 dark:border-blue-800",children:[(0,D.jsxs)(p5,{className:"py-4",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(p8,{className:"w-4 h-4"}),"Add Directive"]}),(0,D.jsx)(p4,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,D.jsx)(p6,{className:"pt-0",children:H?(0,D.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,D.jsx)("span",{className:"text-lg",children:"✓"}),(0,D.jsxs)("span",{className:"text-sm font-medium",children:["Directive saved to ",eh]})]}):(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsx)(fn.Textarea,{value:I,onChange:e=>O(e.target.value),placeholder:"e.g., Always respond in formal English...",className:"flex-1 min-h-[60px] resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ef()}}),(0,D.jsx)($.Button,{onClick:ef,disabled:z||!I.trim(),className:"self-end",children:z?"Saving...":"Save"})]})})]})]}),"trace"===j&&(0,D.jsxs)("div",{className:"space-y-4",children:[k.observations_created&&k.observations_created.length>0&&(0,D.jsxs)(p2,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,D.jsxs)(p5,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(p9,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",k.observations_created.length,")"]}),(0,D.jsx)(p4,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,D.jsx)(p6,{className:"pt-4",children:(0,D.jsx)("div",{className:"space-y-2",children:k.observations_created.map((e,t)=>(0,D.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,D.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:e.name}),(0,D.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:e.description}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",e.id]})]},t))})})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,D.jsxs)(p2,{className:"h-fit",children:[(0,D.jsxs)(p5,{className:"pb-3",children:[(0,D.jsx)(p3,{className:"text-base",children:"Execution Trace"}),(0,D.jsxs)(p4,{className:"text-xs",children:[k.iterations||0," iteration",1!==(k.iterations||0)?"s":""," •"," ",(k.trace?.llm_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)+(k.trace?.tool_calls?.reduce((e,t)=>e+t.duration_ms,0)||0),"ms total"]})]}),(0,D.jsx)(p6,{children:w?k.trace?.llm_calls&&k.trace.llm_calls.length>0||k.trace?.tool_calls&&k.trace.tool_calls.length>0?(0,D.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(e=k.trace?.llm_calls||[],t=k.trace?.tool_calls||[],n=[],e.forEach((r,i)=>{let a=t.filter(e=>e.iteration===i+1),o=i===e.length-1,s=r.scope.includes("final")||o&&0===a.length,l=s?e.length:i+1;n.push({type:"llm",llm:r,iteration:l,isFinal:s}),a.length>0&&n.push({type:"tools",tools:a,iteration:i+1})}),n.map((e,t)=>(0,D.jsxs)("div",{className:"relative",children:[t<n.length-1&&(0,D.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===e.type?(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${e.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:e.isFinal?(0,D.jsx)(ta.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,D.jsx)("span",{className:"text-[10px] font-semibold",children:e.iteration})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsx)("span",{className:"font-medium text-sm",children:e.isFinal?"Response generated":"Agent decided"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(ei,{className:"w-3 h-3"}),e.llm.duration_ms,"ms"]})]}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:e.isFinal?"Final answer":"Called tools below"})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.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,D.jsx)(ft,{className:"w-3 h-3",fill:"currentColor"})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Executing ",e.tools?.length," tool",e.tools?.length!==1?"s":""]}),e.tools?.map((e,t)=>(0,D.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.tool}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(ei,{className:"w-3 h-3"}),e.duration_ms,"ms"]})]}),(0,D.jsxs)("div",{className:"p-2 space-y-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Input:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(fX,{src:e.input,collapsed:1,theme:"default"})})]}),e.output&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Output:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(fX,{src:e.output,collapsed:1,theme:"default"})})]})]})]},t))]})]})]},t)))}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"No operations"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No LLM or tool calls were made during this reflection."})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Tool Calls" to see trace.'})]})]})})]}),(0,D.jsxs)(p2,{className:"h-fit",children:[(0,D.jsxs)(p5,{className:"pb-3",children:[(0,D.jsx)(p3,{className:"text-base",children:"Based On"}),(0,D.jsxs)(p4,{className:"text-xs",children:[(k.based_on?.memories?.length||0)+(k.based_on?.observations?.filter(e=>"directive"!==e.subtype)?.length||0)+(k.based_on?.directives?.length||0)," ","items used"]})]}),(0,D.jsx)(p6,{children:y?k.based_on?.memories&&k.based_on.memories.length>0||k.based_on?.mental_models&&k.based_on.mental_models.length>0||k.based_on?.directives&&k.based_on.directives.length>0||k.based_on?.observations&&k.based_on.observations.length>0?(i=(r=k.based_on?.memories||[]).filter(e=>"world"===e.type),a=r.filter(e=>"experience"===e.type),o=k.based_on?.mental_models||[],s=(k.based_on?.observations||[]).filter(e=>"directive"!==e.subtype),c=[{id:"directives",label:"Directives",count:(l=k.based_on?.directives||[]).length},{id:"mental_models",label:"Mental Models",count:o.length},{id:"observations",label:"Observations",count:s.length},{id:"world",label:"World",count:i.length},{id:"experience",label:"Experience",count:a.length}],u=(()=>{switch(eu){case"directives":return l;case"mental_models":return o;case"observations":return s;case"world":return i;case"experience":return a;default:return[]}})(),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:c.map(e=>(0,D.jsxs)("button",{onClick:()=>ed(e.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${eu===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.label," (",e.count,")"]},e.id))}),u.length>0?(0,D.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:u.map((e,t)=>{let n,r;return(0,D.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==eu?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==eu&&("observations"===eu?ep(e):"mental_models"===eu?ec(e.id):Y(e.id))},children:"directives"===eu?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.content&&(0,D.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.content})]}):"observations"===eu?(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}):"mental_models"===eu?(r=(n=e.text?.indexOf(": ")??-1)>0?e.text.slice(0,n):e.id,(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:r}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.id})]})):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text}),e.context&&(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:e.context})]})},e.id||t)})}):(0,D.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:["No ",eu," items"]})]})):(0,D.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,D.jsx)(p7,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:"No facts found"}),(0,D.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,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Source" to see memories.'})]})]})})]})]})]}),"json"===j&&(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(fX,{src:k,collapsed:2,theme:"default"})})})]})]}),!T&&!k&&(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Reflect"}),(0,D.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,D.jsx)(tp,{memoryId:G,onClose:()=>Y(null)}),X&&(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(fe,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,D.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{W(null),Q(null)},children:(0,D.jsx)(to.X,{className:"w-4 h-4"})})]}),J?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,D.jsx)("p",{className:"mt-1 font-medium",children:Z?.name||X.name})]}),Z?.description&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,D.jsx)("p",{className:"mt-1 text-sm",children:Z.description})]}),Z?.tags&&Z.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(td.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),(Z?.content||X.content)&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:Z?.content||X.content})})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:X.id})]})]})]})}),et&&(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(p9,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Observation"})]}),(0,D.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{en(null),ea(null)},children:(0,D.jsx)(to.X,{className:"w-4 h-4"})})]}),eo?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Text"}),(0,D.jsx)("p",{className:"mt-1 font-medium",children:er?.text||et.text})]}),er?.tags&&er.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:er.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(td.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),er?.source_memories&&er.source_memories.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Source Memories (",er.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-2",children:er.source_memories.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.text||("string"==typeof e?e:"")})},t))})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:et.id})]})]})]})}),(0,D.jsx)(xh,{mentalModelId:el,onClose:()=>ec(null)})]}):(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(F,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start reflecting."})]})})}let xf=(0,O.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function xg(){let e,t,n,r,i,a,o,s,l,c,u,d,h,p,{currentBank:f}=(0,L.useBank)(),[g,v]=(0,R.useState)(""),[x,y]=(0,R.useState)(["world"]),[b,w]=(0,R.useState)("mid"),[N,j]=(0,R.useState)(4096),[E,k]=(0,R.useState)(""),[C,T]=(0,R.useState)(!1),[S,_]=(0,R.useState)(!1),[A,M]=(0,R.useState)(""),[P,O]=(0,R.useState)("any"),[B,H]=(0,R.useState)(null),[G,Y]=(0,R.useState)(null),[X,W]=(0,R.useState)(null),[Q,J]=(0,R.useState)(null),[ee,et]=(0,R.useState)(null),[en,er]=(0,R.useState)(!1),[ea,eo]=(0,R.useState)("results"),[es,el]=(0,R.useState)(null),[ec,eu]=(0,R.useState)(new Set),[ed,eh]=(0,R.useState)(new Set),ep=e=>{eu(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ef=e=>{eh(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},eg=e=>{let t=e.id||e.node_id;el(B?.find(e=>e.id===t||e.node_id===t)||e)},em=async()=>{if(!f)return void alert("Please select a memory bank first");if(g){if(0===x.length)return void alert("Please select at least one type (World, Experience, or Observations)");er(!0);try{let e=A.split(",").map(e=>e.trim()).filter(e=>e.length>0),t={bank_id:f,query:g,types:x,budget:b,max_tokens:N,trace:!0,include:{entities:S?{max_tokens:500}:null,chunks:C?{max_tokens:8192}:null},...E&&{query_timestamp:E},...e.length>0&&{tags:e,tags_match:P}},n=await q.client.recall(t);H(n.results||[]),Y(n.entities||null),W(n.chunks||null),J(n.observations||null),et(n.trace||null),eo("results")}catch(e){console.error("Error running search:",e),alert("Error running search: "+e.message)}finally{er(!1)}}},ev=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return f?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(I.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"What would you like to recall?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&em()})]}),(0,D.jsx)($.Button,{onClick:em,disabled:en||!g,className:"h-12 px-8",children:en?"Searching...":"Recall"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Types:"}),(0,D.jsxs)("div",{className:"flex gap-3",children:[["world","experience"].map(e=>(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:x.includes(e),onCheckedChange:()=>ev(e)}),(0,D.jsx)("span",{className:"text-sm capitalize",children:e})]},e)),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:x.includes("observation"),onCheckedChange:()=>ev("observation")}),(0,D.jsx)("span",{className:"text-sm",children:"Observations"})]})]})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(fW,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsxs)(pa,{value:b,onValueChange:e=>w(e),children:[(0,D.jsx)(pK,{className:"w-24 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"low",children:"Low"}),(0,D.jsx)(p0,{value:"mid",children:"Mid"}),(0,D.jsx)(p0,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(K.Input,{type:"number",value:N,onChange:e=>j(parseInt(e.target.value)),className:"w-24 h-8"})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(ei,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"datetime-local",value:E,onChange:e=>k(e.target.value),className:"h-8",placeholder:"Query date"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:C,onCheckedChange:e=>T(e)}),(0,D.jsx)(z.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Chunks"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:S,onCheckedChange:e=>_(e)}),(0,D.jsx)(V,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Entities"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(td.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(K.Input,{type:"text",value:A,onChange:e=>M(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(pa,{value:P,onValueChange:e=>O(e),children:[(0,D.jsx)(pK,{className:"w-40 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(p0,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(p0,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(p0,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),en&&(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Searching memories..."})]})}),!en&&B&&(0,D.jsxs)("div",{className:"space-y-4",children:[ee?.summary&&(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Results:"}),(0,D.jsx)("span",{className:"font-semibold",children:B.length})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Duration:"}),(0,D.jsxs)("span",{className:"font-semibold",children:[ee.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Nodes visited:"}),(0,D.jsx)("span",{className:"font-semibold",children:ee.summary.total_nodes_visited})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>eo(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ea===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===e?"Results":"trace"===e?"Trace":"JSON"},e))})]}),"results"===ea&&(0,D.jsxs)("div",{className:"space-y-4",children:[Q&&Q.length>0&&(0,D.jsxs)(p2,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,D.jsx)(p5,{className:"py-3",children:(0,D.jsxs)(p3,{className:"text-base flex items-center gap-2",children:[(0,D.jsx)(F,{className:"h-4 w-4 text-orange-500"}),(0,D.jsx)("span",{children:"Observations"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",Q.length,")"]})]})}),(0,D.jsx)(p6,{className:"pt-0 space-y-2",children:Q.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,D.jsx)("p",{className:"text-sm text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,D.jsxs)("span",{children:["Proof count: ",e.proof_count||1]}),(0,D.jsxs)("span",{children:["Relevance: ",(e.relevance||0).toFixed(3)]})]})]},e.id||t))})]}),(0,D.jsx)("div",{className:"space-y-3",children:0!==B.length||Q&&0!==Q.length?B.map((e,t)=>{let n=ee?.visits?.find(t=>t.node_id===e.id),r=n?n.weights.final_weight:e.score||0;return(0,D.jsx)(p2,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>el(e),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-start gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-semibold text-primary",children:t+1})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:e.type||"world"}),e.context&&(0,D.jsx)("span",{className:"truncate max-w-xs",children:e.context}),e.occurred_start&&(0,D.jsx)("span",{children:new Date(e.occurred_start).toLocaleDateString()})]})]}),(0,D.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,D.jsx)("div",{className:"text-sm font-semibold",children:r.toFixed(3)}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:"score"})]}),(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},t)}):(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-12",children:[(0,D.jsx)(I.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"No memories found for this query."})]})})})]}),"trace"===ea&&ee&&(0,D.jsxs)("div",{className:"space-y-4",children:[ee.retrieval_results&&ee.retrieval_results.length>0&&(e={},ee.retrieval_results.forEach(t=>{let n=t.fact_type||"all";e[n]||(e[n]=[]),e[n].push(t)}),t=Object.keys(e),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,D.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,D.jsx)("span",{children:"PARALLEL RETRIEVAL"}),(0,D.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,D.jsx)("div",{className:"space-y-2",children:t.map((t,n)=>{let r=e[t],i=`lane-${t}`,a=ec.has(i),o=r.reduce((e,t)=>e+(t.results?.length||0),0),s=Math.max(...r.map(e=>e.duration_seconds||0)),l={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},c=l[t]||l.all;return(0,D.jsx)(p2,{className:`transition-colors ${a?"border-primary":c.border}`,children:(0,D.jsxs)(p6,{className:"py-3 px-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>ep(i),children:[(0,D.jsx)("div",{className:`w-8 h-8 rounded-lg ${c.bg} flex items-center justify-center`,children:(0,D.jsx)("span",{className:`text-sm font-bold ${c.text} capitalize`,children:t.charAt(0).toUpperCase()})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground capitalize",children:t}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r.length," methods"]})]}),(0,D.jsx)("div",{className:"flex gap-1.5 mt-1",children:r.map((e,t)=>(0,D.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[e.method_name,": ",e.results?.length||0]},t))})]}),(0,D.jsxs)("div",{className:"text-right",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:o}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[s.toFixed(2),"s"]})]}),a?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]}),a&&(0,D.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,D.jsx)("div",{className:`grid gap-3 ${1===r.length?"grid-cols-1":2===r.length?"grid-cols-2":3===r.length?"grid-cols-3":"grid-cols-4"}`,children:r.map((e,t)=>{let n,r,a,o,s=`${i}-method-${t}`,l=ec.has(s),c=e.results||[];return(0,D.jsxs)("div",{className:"flex flex-col",children:[(0,D.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${l?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:e=>{e.stopPropagation(),ep(s)},children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:e.method_name}),"temporal"===e.method_name&&e.metadata?.constraint&&(0,D.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,D.jsx)(Z,{className:"h-3 w-3"}),e.metadata.constraint.start?new Date(e.metadata.constraint.start).toLocaleDateString():"any"," → ",e.metadata.constraint.end?new Date(e.metadata.constraint.end).toLocaleDateString():"any"]})]}),l?(0,D.jsx)(pq,{className:"h-3 w-3 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-3 w-3 text-muted-foreground"})]}),(0,D.jsxs)("div",{className:"flex items-end justify-between",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:c.length}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[e.duration_seconds?.toFixed(2),"s"]})]})]}),l&&c.length>0&&(n=`results-${s}`,a=(r=ed.has(n))?c:c.slice(0,5),o=c.length>5,(0,D.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[a.map((e,t)=>(0,D.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:e.text}),(0,D.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,D.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(e.score||e.similarity||0).toFixed(4)})})]})]})},t)),o&&(0,D.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(n)},children:r?"Show less":`View all ${c.length} results`})]}))]},s)})})})]})},i)})}),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)("div",{className:"flex items-center gap-2",children:t.map((e,t)=>{let n={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,D.jsx)("div",{className:"flex flex-col items-center",children:(0,D.jsx)("div",{className:`w-1 h-4 ${n[e]||n.all} rounded-full opacity-50`})},t)})})}),(0,D.jsx)("div",{className:"flex justify-center",children:(0,D.jsx)(xf,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ee.rrf_merged&&(n="rrf-merge",r=ec.has(n),(0,D.jsxs)("div",{children:[(0,D.jsx)(p2,{className:`cursor-pointer transition-colors ${r?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(n),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"RRF Fusion"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"merge"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Reciprocal Rank Fusion of all retrieval results"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ee.rrf_merged.length}),r?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]})})}),r&&ee.rrf_merged.length>0&&(i="results-rrf",o=(a=ed.has(i))?ee.rrf_merged:ee.rrf_merged.slice(0,5),s=ee.rrf_merged.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[o.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["RRF Score: ",(e.rrf_score||e.score||0).toFixed(4)]})]})]})},t)),s&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(i)},children:a?"Show less":`View all ${ee.rrf_merged.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(xf,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ee.reranked&&(l="reranking",c=ec.has(l),(0,D.jsxs)("div",{children:[(0,D.jsx)(p2,{className:`cursor-pointer transition-colors ${c?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(l),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Combined Scoring"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"rerank"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,D.jsx)("span",{className:"font-mono text-xs",children:"0.6×cross_encoder + 0.2×rrf + 0.1×temporal + 0.1×recency"})})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ee.reranked.length}),c?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]})})}),c&&ee.reranked.length>0&&(u="results-rerank",h=(d=ed.has(u))?ee.reranked:ee.reranked.slice(0,5),p=ee.reranked.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[h.map((e,t)=>{let n=e.score_components||{};return(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,D.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(e.rerank_score||e.score||0).toFixed(4)]}),void 0!==n.cross_encoder_score_normalized&&(0,D.jsxs)("span",{title:"Cross-encoder (60%)",children:["CE: ",n.cross_encoder_score_normalized.toFixed(3)]}),void 0!==n.rrf_normalized&&(0,D.jsxs)("span",{title:`RRF normalized (20%) - raw: ${n.rrf_score?.toFixed(4)||"N/A"}`,children:["RRF: ",n.rrf_normalized.toFixed(3)]}),void 0!==n.temporal&&(0,D.jsxs)("span",{title:"Temporal proximity (10%)",children:["Tmp: ",n.temporal.toFixed(3)]}),void 0!==n.recency&&(0,D.jsxs)("span",{title:"Recency (10%)",children:["Rec: ",n.recency.toFixed(3)]})]})]})]})},t)}),p&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(u)},children:d?"Show less":`View all ${ee.reranked.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(xf,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,D.jsx)(p2,{className:"border-primary bg-primary/5",children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Final Results"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:"output"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Top results after all processing steps"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-primary",children:B?.length||0})]})})})]}),"json"===ea&&(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(fX,{src:{results:B,...G&&{entities:G},...X&&{chunks:X},...Q&&{observations:Q},trace:ee},collapsed:2,theme:"default"})})})]})]}),!en&&!B&&(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(I.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Recall"}),(0,D.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."})]})}),es&&(0,D.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,D.jsx)(tf,{memory:es,onClose:()=>el(null),inPanel:!0,bankId:f||void 0})})]}):(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(F,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start recalling."})]})})}var xm=e.i(78152),xv=e.i(96626),xx=e.i(42727),xy=Symbol("radix.slottable");function xb(e){return R.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===xy}var xw=["Enter"," "],xN=["ArrowUp","PageDown","End"],xj=["ArrowDown","PageUp","Home",...xN],xE={ltr:[...xw,"ArrowRight"],rtl:[...xw,"ArrowLeft"]},xk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},xC="Menu",[xT,xS,x_]=(0,eS.createCollection)(xC),[xA,xD]=(0,eN.createContextScope)(xC,[x_,hX.createPopperScope,xx.createRovingFocusGroupScope]),xM=(0,hX.createPopperScope)(),xP=(0,xx.createRovingFocusGroupScope)(),[xR,xL]=xA(xC),[xI,xO]=xA(xC),xB=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=xM(t),[l,c]=R.useState(null),u=R.useRef(!1),d=(0,hK.useCallbackRef)(a),h=(0,eE.useDirection)(i);return R.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,D.jsx)(hX.Root,{...s,children:(0,D.jsx)(xR,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,D.jsx)(xI,{scope:t,onClose:R.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:o,children:r})})})};xB.displayName=xC;var xF=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=xM(n);return(0,D.jsx)(hX.Anchor,{...i,...r,ref:t})});xF.displayName="MenuAnchor";var xz="MenuPortal",[xV,xH]=xA(xz,{forceMount:void 0}),xU=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=xL(xz,t);return(0,D.jsx)(xV,{scope:t,forceMount:n,children:(0,D.jsx)(xv.Presence,{present:n||a.open,children:(0,D.jsx)(hW.Portal,{asChild:!0,container:i,children:r})})})};xU.displayName=xz;var xG="MenuContent",[xY,xX]=xA(xG),xW=R.forwardRef((e,t)=>{let n=xH(xG,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xL(xG,e.__scopeMenu),o=xO(xG,e.__scopeMenu);return(0,D.jsx)(xT.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(xv.Presence,{present:r||a.open,children:(0,D.jsx)(xT.Slot,{scope:e.__scopeMenu,children:o.modal?(0,D.jsx)(xq,{...i,ref:t}):(0,D.jsx)(x$,{...i,ref:t})})})})}),xq=R.forwardRef((e,t)=>{let n=xL(xG,e.__scopeMenu),r=R.useRef(null),i=(0,ew.useComposedRefs)(t,r);return R.useEffect(()=>{let e=r.current;if(e)return(0,h0.hideOthers)(e)},[]),(0,D.jsx)(xZ,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:(0,eb.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),x$=R.forwardRef((e,t)=>{let n=xL(xG,e.__scopeMenu);return(0,D.jsx)(xZ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),xK=((s=R.forwardRef((e,t)=>{let{children:n,...r}=e;if(R.isValidElement(n)){var i;let e,a,o=(i=n,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...a}:"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==R.Fragment&&(s.ref=t?(0,ew.composeRefs)(t,o):o),R.cloneElement(n,s)}return R.Children.count(n)>1?R.Children.only(null):null})).displayName="MenuContent.ScrollLock.SlotClone",i=s,(a=R.forwardRef((e,t)=>{let{children:n,...r}=e,a=R.Children.toArray(n),o=a.find(xb);if(o){let e=o.props.children,n=a.map(t=>t!==o?t:R.Children.count(e)>1?R.Children.only(null):R.isValidElement(e)?e.props.children:null);return(0,D.jsx)(i,{...r,ref:t,children:R.isValidElement(e)?R.cloneElement(e,void 0,n):null})}return(0,D.jsx)(i,{...r,ref:t,children:n})})).displayName="MenuContent.ScrollLock.Slot",a),xZ=R.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:f,...g}=e,v=xL(xG,n),x=xO(xG,n),y=xM(n),b=xP(n),w=xS(n),[N,j]=R.useState(null),E=R.useRef(null),k=(0,ew.useComposedRefs)(t,E,v.onContentChange),C=R.useRef(0),T=R.useRef(""),S=R.useRef(0),_=R.useRef(null),A=R.useRef("right"),M=R.useRef(0),P=f?h1.RemoveScroll:R.Fragment;R.useEffect(()=>()=>window.clearTimeout(C.current),[]),(0,hU.useFocusGuards)();let L=R.useCallback(e=>{var t,n;return A.current===_.current?.side&&(t=e,!!(n=_.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],l=o.x,c=o.y,u=s.x,d=s.y;c>r!=d>r&&n<(u-l)*(r-c)/(d-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,D.jsx)(xY,{scope:n,searchRef:T,onItemEnter:R.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:R.useCallback(e=>{L(e)||(E.current?.focus(),j(null))},[L]),onTriggerLeave:R.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:S,onPointerGraceIntentChange:R.useCallback(e=>{_.current=e},[]),children:(0,D.jsx)(P,{...f?{as:xK,allowPinchZoom:!0}:void 0,children:(0,D.jsx)(hG.FocusScope,{asChild:!0,trapped:i,onMountAutoFocus:(0,eb.composeEventHandlers)(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,D.jsx)(hH.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,children:(0,D.jsx)(xx.Root,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:j,onEntryFocus:(0,eb.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,D.jsx)(hX.Content,{role:"menu","aria-orientation":"vertical","data-state":yp(v.open),"data-radix-menu-content":"",dir:x.dir,...y,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:(0,eb.composeEventHandlers)(g.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,a,o,s,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=T.current+i,a=w().filter(e=>!e.disabled),o=document.activeElement,s=a.find(e=>e.ref.current===o)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,a=n?e.indexOf(n):-1,o=(r=Math.max(a,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(o=o.filter(e=>e!==n));let s=o.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return s!==n?s:void 0}(a.map(e=>e.textValue),t,s),c=a.find(e=>e.textValue===l)?.ref.current,function e(t){T.current=t,window.clearTimeout(C.current),""!==t&&(C.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let a=E.current;if(e.target!==a||!xj.includes(e.key))return;e.preventDefault();let o=w().filter(e=>!e.disabled).map(e=>e.ref.current);xN.includes(e.key)&&o.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(o)}),onBlur:(0,eb.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(C.current),T.current="")}),onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(A.current=e.clientX>M.current?"right":"left",M.current=e.clientX)}))})})})})})})});xW.displayName=xG;var xQ=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{role:"group",...r,ref:t})});xQ.displayName="MenuGroup";var xJ=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{...r,ref:t})});xJ.displayName="MenuLabel";var x0="MenuItem",x1="menu.itemSelect",x2=R.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=R.useRef(null),o=xO(x0,e.__scopeMenu),s=xX(x0,e.__scopeMenu),l=(0,ew.useComposedRefs)(t,a),c=R.useRef(!1);return(0,D.jsx)(x5,{...i,ref:l,disabled:n,onClick:(0,eb.composeEventHandlers)(e.onClick,()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(x1,{bubbles:!0,cancelable:!0});e.addEventListener(x1,e=>r?.(e),{once:!0}),(0,eT.dispatchDiscreteCustomEvent)(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,eb.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==s.searchRef.current;n||t&&" "===e.key||xw.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});x2.displayName=x0;var x5=R.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=xX(x0,n),s=xP(n),l=R.useRef(null),c=(0,ew.useComposedRefs)(t,l),[u,d]=R.useState(!1),[h,p]=R.useState("");return R.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[a.children]),(0,D.jsx)(xT.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,D.jsx)(xx.Item,{asChild:!0,...s,focusable:!r,children:(0,D.jsx)(eT.Primitive.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:c,onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,eb.composeEventHandlers)(e.onPointerLeave,ym(e=>o.onItemLeave(e))),onFocus:(0,eb.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,eb.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),x3=R.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,D.jsx)(yn,{scope:e.__scopeMenu,checked:n,children:(0,D.jsx)(x2,{role:"menuitemcheckbox","aria-checked":yf(n)?"mixed":n,...i,ref:t,"data-state":yg(n),onSelect:(0,eb.composeEventHandlers)(i.onSelect,()=>r?.(!!yf(n)||!n),{checkForDefaultPrevented:!1})})})});x3.displayName="MenuCheckboxItem";var x4="MenuRadioGroup",[x6,x7]=xA(x4,{value:void 0,onValueChange:()=>{}}),x9=R.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=(0,hK.useCallbackRef)(r);return(0,D.jsx)(x6,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,D.jsx)(xQ,{...i,ref:t})})});x9.displayName=x4;var x8="MenuRadioItem",ye=R.forwardRef((e,t)=>{let{value:n,...r}=e,i=x7(x8,e.__scopeMenu),a=n===i.value;return(0,D.jsx)(yn,{scope:e.__scopeMenu,checked:a,children:(0,D.jsx)(x2,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":yg(a),onSelect:(0,eb.composeEventHandlers)(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});ye.displayName=x8;var yt="MenuItemIndicator",[yn,yr]=xA(yt,{checked:!1}),yi=R.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=yr(yt,n);return(0,D.jsx)(xv.Presence,{present:r||yf(a.checked)||!0===a.checked,children:(0,D.jsx)(eT.Primitive.span,{...i,ref:t,"data-state":yg(a.checked)})})});yi.displayName=yt;var ya=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ya.displayName="MenuSeparator";var yo=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=xM(n);return(0,D.jsx)(hX.Arrow,{...i,...r,ref:t})});yo.displayName="MenuArrow";var[ys,yl]=xA("MenuSub"),yc="MenuSubTrigger",yu=R.forwardRef((e,t)=>{let n=xL(yc,e.__scopeMenu),r=xO(yc,e.__scopeMenu),i=yl(yc,e.__scopeMenu),a=xX(yc,e.__scopeMenu),o=R.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,c={__scopeMenu:e.__scopeMenu},u=R.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return R.useEffect(()=>u,[u]),R.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]),(0,D.jsx)(xF,{asChild:!0,...c,children:(0,D.jsx)(x5,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":yp(n.open),...e,ref:(0,ew.composeRefs)(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(t=>{a.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||o.current||(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,eb.composeEventHandlers)(e.onPointerLeave,ym(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,o=t[i?"left":"right"],l=t[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:o,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:o,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,t=>{let i=""!==a.searchRef.current;e.disabled||i&&" "===t.key||xE[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});yu.displayName=yc;var yd="MenuSubContent",yh=R.forwardRef((e,t)=>{let n=xH(xG,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xL(xG,e.__scopeMenu),o=xO(xG,e.__scopeMenu),s=yl(yd,e.__scopeMenu),l=R.useRef(null),c=(0,ew.useComposedRefs)(t,l);return(0,D.jsx)(xT.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(xv.Presence,{present:r||a.open,children:(0,D.jsx)(xT.Slot,{scope:e.__scopeMenu,children:(0,D.jsx)(xZ,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,eb.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:(0,eb.composeEventHandlers)(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=xk[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});function yp(e){return e?"open":"closed"}function yf(e){return"indeterminate"===e}function yg(e){return yf(e)?"indeterminate":e?"checked":"unchecked"}function ym(e){return t=>"mouse"===t.pointerType?e(t):void 0}yh.displayName=yd;var yv="DropdownMenu",[yx,yy]=(0,eN.createContextScope)(yv,[xD]),yb=xD(),[yw,yN]=yx(yv),yj=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,l=yb(t),c=R.useRef(null),[u,d]=(0,ej.useControllableState)({prop:i,defaultProp:a??!1,onChange:o,caller:yv});return(0,D.jsx)(yw,{scope:t,triggerId:(0,hY.useId)(),triggerRef:c,contentId:(0,hY.useId)(),open:u,onOpenChange:d,onOpenToggle:R.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,D.jsx)(xB,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};yj.displayName=yv;var yE="DropdownMenuTrigger",yk=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=yN(yE,n),o=yb(n);return(0,D.jsx)(xF,{asChild:!0,...o,children:(0,D.jsx)(eT.Primitive.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:(0,ew.composeRefs)(t,a.triggerRef),onPointerDown:(0,eb.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});yk.displayName=yE;var yC=e=>{let{__scopeDropdownMenu:t,...n}=e,r=yb(t);return(0,D.jsx)(xU,{...r,...n})};yC.displayName="DropdownMenuPortal";var yT="DropdownMenuContent",yS=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yN(yT,n),a=yb(n),o=R.useRef(!1);return(0,D.jsx)(xW,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:(0,eb.composeEventHandlers)(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:(0,eb.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.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)"}})});yS.displayName=yT,R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(xQ,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var y_=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(xJ,{...i,...r,ref:t})});y_.displayName="DropdownMenuLabel";var yA=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x2,{...i,...r,ref:t})});yA.displayName="DropdownMenuItem";var yD=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x3,{...i,...r,ref:t})});yD.displayName="DropdownMenuCheckboxItem",R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x9,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var yM=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(ye,{...i,...r,ref:t})});yM.displayName="DropdownMenuRadioItem";var yP=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yi,{...i,...r,ref:t})});yP.displayName="DropdownMenuItemIndicator";var yR=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(ya,{...i,...r,ref:t})});yR.displayName="DropdownMenuSeparator",R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yo,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var yL=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yu,{...i,...r,ref:t})});yL.displayName="DropdownMenuSubTrigger";var yI=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yh,{...i,...r,ref:t,style:{...e.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)"}})});yI.displayName="DropdownMenuSubContent";let yO=(0,O.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);R.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,D.jsxs)(yL,{ref:i,className:(0,Y.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",t&&"pl-8",e),...r,children:[n,(0,D.jsx)(U,{className:"ml-auto"})]})).displayName=yL.displayName,R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(yI,{ref:n,className:(0,Y.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]",e),...t})).displayName=yI.displayName;let yB=R.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,D.jsx)(yC,{children:(0,D.jsx)(yS,{ref:r,sideOffset:t,className:(0,Y.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]",e),...n})}));yB.displayName=yS.displayName;let yF=R.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(yA,{ref:r,className:(0,Y.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",t&&"pl-8",e),...n}));yF.displayName=yA.displayName,R.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,D.jsxs)(yD,{ref:i,className:(0,Y.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",e),checked:n,...r,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(yP,{children:(0,D.jsx)(ta.Check,{className:"h-4 w-4"})})}),t]})).displayName=yD.displayName,R.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(yM,{ref:r,className:(0,Y.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",e),...n,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(yP,{children:(0,D.jsx)(yO,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=yM.displayName,R.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(y_,{ref:r,className:(0,Y.cn)("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n})).displayName=y_.displayName;let yz=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(yR,{ref:n,className:(0,Y.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));yz.displayName=yR.displayName;let yV=(0,O.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),yH=(0,O.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"}]]),yU=(0,O.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"}]]),yG=(0,O.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"}]]),yY=(0,O.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"}]]),yX=(0,O.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"}]]),yW=(0,O.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var yq=e.i(7233);let y$=(0,O.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"}]]),yK=(0,O.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"}]]),yZ={skepticism:{label:"Skepticism",shortLabel:"S",description:"How skeptical vs trusting when forming opinions",lowLabel:"Trusting",highLabel:"Skeptical"},literalism:{label:"Literalism",shortLabel:"L",description:"How literally to interpret information when forming opinions",lowLabel:"Flexible",highLabel:"Literal"},empathy:{label:"Empathy",shortLabel:"E",description:"How much to consider emotional context when forming opinions",lowLabel:"Detached",highLabel:"Empathetic"}};function yQ({disposition:e,editMode:t,editDisposition:n,onEditChange:r}){let i=t?n:e;return(0,D.jsx)("div",{className:"space-y-4",children:Object.keys(yZ).map(e=>(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:yZ[e].label}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:yZ[e].description})]}),(0,D.jsxs)("span",{className:"text-sm font-bold text-primary",children:[i[e],"/5"]})]}),t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,D.jsx)("span",{children:yZ[e].lowLabel}),(0,D.jsx)("span",{children:yZ[e].highLabel})]}),(0,D.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:n[e],onChange:t=>r(e,parseInt(t.target.value)),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]}):(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:yZ[e].lowLabel}),(0,D.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,D.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(i[e]-1)/4*100}%`}})}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:yZ[e].highLabel})]})]},e))})}function yJ(){let e=(0,M.useRouter)(),{currentBank:t,setCurrentBank:n,loadBanks:r}=(0,L.useBank)(),{features:i}=(0,xm.useFeatures)(),a=i?.observations??!1,[o,s]=(0,R.useState)(null),[l,c]=(0,R.useState)(null),[u,d]=(0,R.useState)([]),[h,p]=(0,R.useState)(0),[f,g]=(0,R.useState)([]),[v,x]=(0,R.useState)(0),[y,b]=(0,R.useState)(!1),[w,N]=(0,R.useState)(!1),[j,E]=(0,R.useState)(!1),[k,C]=(0,R.useState)(!1),[T,S]=(0,R.useState)(null),[_,A]=(0,R.useState)(null),[P,I]=(0,R.useState)(!1),O=(0,R.useRef)(j);(0,R.useEffect)(()=>{O.current=j},[j]);let[B,z]=(0,R.useState)(!1),[V,H]=(0,R.useState)(!1),[U,G]=(0,R.useState)(!1),[Y,X]=(0,R.useState)(!1),[W,K]=(0,R.useState)(!1),[Z,Q]=(0,R.useState)(null),[J]=(0,R.useState)(10),[ee,et]=(0,R.useState)(0),[ea,eo]=(0,R.useState)(null),[ep,ef]=(0,R.useState)(""),[eg,em]=(0,R.useState)({skepticism:3,literalism:3,empathy:3}),ev=async(e=Z,n=ee)=>{if(t)try{let r=await q.client.listOperations(t,{status:e||void 0,limit:J,offset:n});d(r.operations||[]),p(r.total||0)}catch(e){console.error("Error loading operations:",e)}},ex=async(e=!1)=>{if(t){if(e){try{let[e,n,r]=await Promise.all([q.client.getBankStats(t),q.client.listDirectives(t),q.client.listMentalModels(t)]);c(e),g(n.items||[]),x(r.items?.length||0)}catch(e){console.error("Error refreshing stats:",e)}return}b(!0);try{let[e,n,r,i]=await Promise.all([q.client.getBankProfile(t),q.client.getBankStats(t),q.client.listDirectives(t),q.client.listMentalModels(t)]);s(e),c(n),g(r.items||[]),x(i.items?.length||0),await ev(),O.current||(ef(e.mission||""),em(e.disposition))}catch(e){console.error("Error loading bank profile:",e),alert("Error loading bank profile: "+e.message)}finally{b(!1)}}},ey=async()=>{if(t){N(!0);try{await q.client.updateBankProfile(t,{mission:ep,disposition:eg}),await ex(),E(!1)}catch(e){console.error("Error saving bank profile:",e),alert("Error saving bank profile: "+e.message)}finally{N(!1)}}},eb=async()=>{if(t){H(!0);try{await q.client.deleteBank(t),z(!1),n(null),await r(),e.push("/")}catch(e){console.error("Error deleting bank:",e),alert("Error deleting bank: "+e.message)}finally{H(!1)}}},ew=async()=>{if(t){X(!0);try{let e=await q.client.clearObservations(t);G(!1),await ex(),alert(e.message||"Observations cleared successfully")}catch(e){console.error("Error clearing observations:",e),alert("Error clearing observations: "+e.message)}finally{X(!1)}}},eN=async()=>{if(t){K(!0);try{await q.client.triggerConsolidation(t),await ex(),await ev()}catch(e){console.error("Error triggering consolidation:",e),alert("Error triggering consolidation: "+e.message)}finally{K(!1)}}},ej=e=>{et(e),ev(Z,e)},eE=async e=>{if(t){eo(e);try{await q.client.cancelOperation(t,e),await ev()}catch(e){console.error("Error cancelling operation:",e),alert("Error cancelling operation: "+e.message)}finally{eo(null)}}},ek=async()=>{if(t&&_){I(!0);try{await q.client.deleteDirective(t,_.id),g(e=>e.filter(e=>e.id!==_.id)),T?.id===_.id&&S(null),A(null)}catch(e){console.error("Error deleting directive:",e),alert("Error deleting: "+e.message)}finally{I(!1)}}};return((0,R.useEffect)(()=>{if(t){ex();let e=setInterval(()=>ex(!0),5e3);return()=>clearInterval(e)}},[t]),(0,R.useEffect)(()=>{let e=e=>{"Escape"===e.key&&S(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),t)?y&&!o?(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"text-center py-10",children:[(0,D.jsx)(ei,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,D.jsx)("div",{className:"text-lg text-muted-foreground",children:"Loading profile..."})]})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{className:"text-2xl font-bold text-foreground",children:o?.name||t}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground font-mono",children:t})]}),(0,D.jsx)("div",{className:"flex gap-2",children:j?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)($.Button,{onClick:()=>{o&&(ef(o.mission||""),em(o.disposition)),E(!1)},variant:"secondary",disabled:w,children:"Cancel"}),(0,D.jsx)($.Button,{onClick:ey,disabled:w,children:w?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(yV,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]}):(0,D.jsxs)(yj,{children:[(0,D.jsx)(yk,{asChild:!0,children:(0,D.jsxs)($.Button,{variant:"outline",size:"sm",children:["Actions",(0,D.jsx)(y$,{className:"w-4 h-4 ml-2"})]})}),(0,D.jsxs)(yB,{align:"end",className:"w-48",children:[(0,D.jsxs)(yF,{onClick:()=>E(!0),children:[(0,D.jsx)(yK,{className:"w-4 h-4 mr-2"}),"Edit Profile"]}),(0,D.jsx)(yz,{}),(0,D.jsxs)(yF,{onClick:eN,disabled:W||!a,title:a?void 0:"Observations feature is not enabled",children:[W?(0,D.jsx)(ts,{className:"w-4 h-4 mr-2 animate-spin"}):(0,D.jsx)(p9,{className:"w-4 h-4 mr-2"}),W?"Consolidating...":"Run Consolidation",!a&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsxs)(yF,{onClick:()=>G(!0),disabled:!a,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:a?void 0:"Observations feature is not enabled",children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Clear Observations",!a&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsx)(yz,{}),(0,D.jsxs)(yF,{onClick:()=>z(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})]})]})})]}),l&&(0,D.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,D.jsx)(p2,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/20",children:(0,D.jsx)(F,{className:"w-5 h-5 text-blue-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Memories"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_nodes})]})]})})}),(0,D.jsx)(p2,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/20",children:(0,D.jsx)(yU,{className:"w-5 h-5 text-purple-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Links"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_links})]})]})})}),(0,D.jsx)(p2,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/20",children:(0,D.jsx)(yG,{className:"w-5 h-5 text-emerald-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Documents"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_documents})]})]})})}),(0,D.jsx)(p2,{className:`bg-gradient-to-br ${l.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,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:`p-2 rounded-lg ${l.pending_operations>0?"bg-amber-500/20":"bg-slate-500/20"}`,children:(0,D.jsx)(yY,{className:`w-5 h-5 ${l.pending_operations>0?"text-amber-500 animate-pulse":"text-slate-500"}`})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Pending"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.pending_operations})]})]})})})]}),l&&(0,D.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,D.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-semibold uppercase tracking-wide",children:"World Facts"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:l.nodes_by_fact_type?.world||0})]}),(0,D.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-semibold uppercase tracking-wide",children:"Experience"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-purple-600 dark:text-purple-400 mt-1",children:l.nodes_by_fact_type?.experience||0})]}),(0,D.jsxs)("div",{className:`rounded-xl p-4 text-center ${a?"bg-amber-500/10 border border-amber-500/20":"bg-muted/50 border border-muted"}`,title:a?void 0:"Observations feature is not enabled",children:[(0,D.jsxs)("p",{className:`text-xs font-semibold uppercase tracking-wide ${a?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:["Observations",!a&&(0,D.jsx)("span",{className:"ml-1 normal-case",children:"(Off)"})]}),(0,D.jsx)("p",{className:`text-2xl font-bold mt-1 ${a?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:a?l.total_mental_models||0:"—"})]}),(0,D.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-semibold uppercase tracking-wide",children:"Mental Models"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-cyan-600 dark:text-cyan-400 mt-1",children:v})]}),(0,D.jsxs)("div",{className:"bg-rose-500/10 border border-rose-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-semibold uppercase tracking-wide",children:"Directives"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-rose-600 dark:text-rose-400 mt-1",children:f.length})]})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,D.jsxs)(p2,{children:[(0,D.jsxs)(p5,{className:"pb-2",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(p9,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,D.jsx)(p4,{children:"Traits that shape how opinions are formed via Reflect"})]}),(0,D.jsx)(p6,{children:o&&(0,D.jsx)(yQ,{disposition:o.disposition,editMode:j,editDisposition:eg,onEditChange:(e,t)=>em(n=>({...n,[e]:t}))})})]}),(0,D.jsxs)(p2,{children:[(0,D.jsxs)(p5,{className:"pb-2",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yX,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,D.jsx)(p4,{children:"Who the agent is and what they're trying to accomplish. Used for mental models and reflect."})]}),(0,D.jsx)(p6,{children:j?(0,D.jsx)(fn.Textarea,{value:ep,onChange:e=>ef(e.target.value),placeholder:"e.g., I am a PM for the engineering team. I help coordinate sprints and track project progress...",rows:6,className:"resize-none"}):(0,D.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:o?.mission||"No mission set. Set a mission to derive structural mental models and personalize reflect responses."})})]})]}),(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),"Directives"]}),(0,D.jsx)(p4,{children:"Hard rules that must be followed during reflect"})]}),(0,D.jsxs)($.Button,{onClick:()=>C(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,D.jsx)(yq.Plus,{className:"w-4 h-4 mr-1"}),"Add"]})]})}),(0,D.jsx)(p6,{children:f.length>0?(0,D.jsx)("div",{className:"grid grid-cols-2 gap-3",children:f.map(e=>(0,D.jsx)(p2,{className:`cursor-pointer transition-colors border-rose-500/30 ${T?.id===e.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>S(e),children:(0,D.jsx)(p6,{className:"p-3",children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)(yW,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:e.content}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,D.jsx)(td.Tag,{className:"w-3 h-3 text-muted-foreground"}),e.tags.map(e=>(0,D.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e},e))]})]})]})})},e.id))}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,D.jsx)(yW,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:"No directives yet. Directives are hard rules that must be followed during reflect."})]})})]}),(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yY,{className:"w-5 h-5 text-primary"}),"Background Operations",(0,D.jsx)("button",{onClick:()=>ev(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",children:(0,D.jsx)(en,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})]}),(0,D.jsxs)(p4,{children:[h," operation",1!==h?"s":"",Z?` (${Z})`:""]})]}),(0,D.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(e=>(0,D.jsx)("button",{onClick:()=>{var t;Q(t=e.value),et(0),ev(t,0)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${Z===e.value?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e.label},e.value??"all"))})]})}),(0,D.jsx)(p6,{children:u.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)(es,{children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{children:[(0,D.jsx)(ed,{className:"w-[100px]",children:"ID"}),(0,D.jsx)(ed,{children:"Type"}),(0,D.jsx)(ed,{children:"Created"}),(0,D.jsx)(ed,{children:"Status"}),(0,D.jsx)(ed,{className:"w-[80px]"})]})}),(0,D.jsx)(ec,{children:u.map(e=>(0,D.jsxs)(eu,{className:"failed"===e.status?"bg-red-500/5":"",children:[(0,D.jsx)(eh,{className:"font-mono text-xs text-muted-foreground",children:e.id.substring(0,8)}),(0,D.jsx)(eh,{className:"font-medium",children:e.task_type}),(0,D.jsx)(eh,{className:"text-sm text-muted-foreground",children:new Date(e.created_at).toLocaleString()}),(0,D.jsxs)(eh,{children:["pending"===e.status&&(0,D.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,D.jsx)(ei,{className:"w-3 h-3"}),"pending"]}),"failed"===e.status&&(0,D.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:e.error_message??void 0,children:[(0,D.jsx)(yH,{className:"w-3 h-3"}),"failed"]}),"completed"===e.status&&(0,D.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,D.jsx)(er,{className:"w-3 h-3"}),"completed"]})]}),(0,D.jsx)(eh,{children:"pending"===e.status&&(0,D.jsxs)($.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>eE(e.id),disabled:ea===e.id,children:[ea===e.id?(0,D.jsx)(ts,{className:"w-3 h-3 animate-spin"}):(0,D.jsx)(to.X,{className:"w-3 h-3 mr-1"}),ea===e.id?"":"Cancel"]})})]},e.id))})]})}),h>J&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,D.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",ee+1,"-",Math.min(ee+J,h)," of"," ",h]}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>ej(Math.max(0,ee-J)),disabled:0===ee,children:"Previous"}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>ej(ee+J),disabled:ee+J>=h,children:"Next"})]})]})]}):(0,D.jsxs)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:["No ",Z?`${Z} `:"","operations"]})})]}),(0,D.jsx)(hg,{open:B,onOpenChange:z,children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Memory Bank"}),(0,D.jsx)(hI,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.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."}),l&&(0,D.jsxs)("p",{children:["This will delete ",l.total_nodes," memories, ",l.total_documents," ","documents, and ",l.total_links," links."]})]})})]}),(0,D.jsxs)(hR,{children:[(0,D.jsx)(hB,{disabled:V,children:"Cancel"}),(0,D.jsx)(hO,{onClick:eb,disabled:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:V?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,D.jsx)(hg,{open:U,onOpenChange:G,children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Clear Observations"}),(0,D.jsx)(hI,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.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."}),l&&l.total_mental_models>0&&(0,D.jsxs)("p",{children:["This will delete ",l.total_mental_models," observations."]})]})})]}),(0,D.jsxs)(hR,{children:[(0,D.jsx)(hB,{disabled:Y,children:"Cancel"}),(0,D.jsx)(hO,{onClick:ew,disabled:Y,className:"bg-amber-500 text-white hover:bg-amber-600",children:Y?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ts,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,D.jsx)(y0,{open:k,mode:"create",onClose:()=>C(!1),onCreated:e=>{g(t=>[e,...t]),C(!1)}}),(0,D.jsx)(hg,{open:!!_,onOpenChange:e=>!e&&A(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Directive"}),(0,D.jsxs)(hI,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',_?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hR,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hB,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hO,{onClick:ek,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[P?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),T&&(0,D.jsx)(y1,{directive:T,onClose:()=>S(null),onDelete:()=>A({id:T.id,name:T.name}),onUpdated:e=>{g(t=>t.map(t=>t.id===e.id?e:t)),S(e)}})]}):(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"p-10 text-center",children:[(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Please select a memory bank from the dropdown above to view its profile."})]})})}function y0({open:e,mode:t,directive:n,onClose:r,onCreated:i,onSaved:a}){let{currentBank:o}=(0,L.useBank)(),[s,l]=(0,R.useState)(!1),[c,u]=(0,R.useState)({name:"",content:"",tags:""});(0,R.useEffect)(()=>{"edit"===t&&n?u({name:n.name,content:n.content,tags:(n.tags||[]).join(", ")}):"create"===t&&u({name:"",content:"",tags:""})},[e,t,n]);let d=async()=>{if(o&&c.name.trim()&&c.content.trim()){l(!0);try{let e=c.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0);if("create"===t){let t=await q.client.createDirective(o,{name:c.name.trim(),content:c.content.trim(),tags:e.length>0?e:void 0});u({name:"",content:"",tags:""}),i?.(t)}else if(n){let t=await q.client.updateDirective(o,n.id,{name:c.name.trim(),content:c.content.trim(),tags:e});a?.(t),r()}}catch(e){console.error(`Error ${"create"===t?"creating":"updating"} directive:`,e),alert(`Error ${"create"===t?"creating":"updating"}: `+e.message)}finally{l(!1)}}},h=()=>{"create"===t&&u({name:"",content:"",tags:""}),r()};return(0,D.jsx)(tl.Dialog,{open:e,onOpenChange:e=>!e&&h(),children:(0,D.jsxs)(tl.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(tl.DialogHeader,{children:[(0,D.jsxs)(tl.DialogTitle,{className:"flex items-center gap-2",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),"create"===t?"Create":"Edit"," Directive"]}),(0,D.jsx)(tl.DialogDescription,{children:"Directives are hard rules that must be followed during reflect."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(K.Input,{value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:"e.g., Competitor Policy"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Rule *"}),(0,D.jsx)(fn.Textarea,{value:c.content,onChange:e=>u({...c,content:e.target.value}),placeholder:"e.g., Never mention competitor products directly.",className:"min-h-[120px]"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(K.Input,{value:c.tags,onChange:e=>u({...c,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,D.jsxs)(tl.DialogFooter,{children:[(0,D.jsx)($.Button,{variant:"outline",onClick:h,disabled:s,children:"Cancel"}),(0,D.jsxs)($.Button,{onClick:d,disabled:s||!c.name.trim()||!c.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[s?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"create"===t?"Create":"Save"]})]})]})})}function y1({directive:e,onClose:t,onDelete:n,onUpdated:r}){let[i,a]=(0,R.useState)(!1);return(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-7 w-7 p-0",children:(0,D.jsx)(yK,{className:"h-3.5 w-3.5"})})]}),(0,D.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,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,D.jsx)(hF,{className:"h-4 w-4"})}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(to.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Rule"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xl,{children:e.content})})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,D.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]})]})]}),(0,D.jsx)(y0,{open:i,mode:"edit",directive:e,onClose:()=>a(!1),onSaved:r})]})}function y2(){let{currentBank:e}=(0,L.useBank)(),[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(""),[s,l]=(0,R.useState)(1),[c,u]=(0,R.useState)(!1),[d,h]=(0,R.useState)(null),[p,f]=(0,R.useState)(null),[g,v]=(0,R.useState)(!1),x=t.filter(e=>{if(!a)return!0;let t=a.toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.source_query.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),y=async()=>{if(e){i(!0);try{let t=await q.client.listMentalModels(e);n(t.items||[])}catch(e){console.error("Error loading mental models:",e)}finally{i(!1)}}},b=async()=>{if(e&&p){v(!0);try{await q.client.deleteMentalModel(e,p.id),n(e=>e.filter(e=>e.id!==p.id)),d?.id===p.id&&h(null),f(null)}catch(e){console.error("Error deleting mental model:",e),alert("Error deleting: "+e.message)}finally{v(!1)}}};if((0,R.useEffect)(()=>{e&&y()},[e]),(0,R.useEffect)(()=>{let e=e=>{"Escape"===e.key&&h(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,R.useEffect)(()=>{l(1)},[a]),!e)return(0,D.jsx)(p2,{children:(0,D.jsx)(p6,{className:"p-10 text-center",children:(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to view mental models."})})});let w=Math.ceil(x.length/100),N=(s-1)*100,j=N+100,E=x.slice(N,j);return(0,D.jsxs)("div",{children:[r?(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(en,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"mb-4",children:(0,D.jsx)(K.Input,{type:"text",value:a,onChange:e=>o(e.target.value),placeholder:"Filter mental models by name, query, or content...",className:"max-w-md"})}),(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:a?`${x.length} of ${t.length} mental models`:`${t.length} mental model${1!==t.length?"s":""}`}),(0,D.jsxs)($.Button,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[(0,D.jsx)(yq.Plus,{className:"w-4 h-4 mr-2"}),"Add Mental Model"]})]}),x.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,D.jsxs)(es,{className:"table-fixed",children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{className:"bg-muted/50",children:[(0,D.jsx)(ed,{className:"w-[20%]",children:"ID"}),(0,D.jsx)(ed,{className:"w-[20%]",children:"Name"}),(0,D.jsx)(ed,{className:"w-[35%]",children:"Source Query"}),(0,D.jsx)(ed,{className:"w-[15%]",children:"Last Refreshed"}),(0,D.jsx)(ed,{className:"w-[10%]"})]})}),(0,D.jsx)(ec,{children:E.map(e=>{let t=new Date(e.last_refreshed_at),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,D.jsxs)(eu,{className:`cursor-pointer hover:bg-muted/50 ${d?.id===e.id?"bg-primary/10":""}`,onClick:()=>h(e),children:[(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate block",children:e.id})}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("div",{className:"font-medium text-foreground",children:e.name})}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground truncate",children:e.source_query})}),(0,D.jsxs)(eh,{className:"py-2 text-sm text-foreground",children:[(0,D.jsx)("div",{children:n}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:r})]}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)($.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:t=>{t.stopPropagation(),f({id:e.id,name:e.name})},children:(0,D.jsx)(hF,{className:"h-4 w-4"})})})]},e.id)})})]})}),w>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[N+1,"-",Math.min(j,x.length)," of"," ",x.length]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(1),disabled:1===s,className:"h-7 w-7 p-0",children:(0,D.jsx)(ee,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(e=>Math.max(1,e-1)),disabled:1===s,className:"h-7 w-7 p-0",children:(0,D.jsx)(H,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[s," / ",w]}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(e=>Math.min(w,e+1)),disabled:s===w,className:"h-7 w-7 p-0",children:(0,D.jsx)(U,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(w),disabled:s===w,className:"h-7 w-7 p-0",children:(0,D.jsx)(et,{className:"h-3 w-3"})})]})]})]}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,D.jsx)(B,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:a?"No mental models match your filter":"No mental models yet. Create a mental model to generate and save a summary from your memories."})]})]}),(0,D.jsx)(y5,{open:c,onClose:()=>u(!1),onCreated:()=>{u(!1),y()}}),(0,D.jsx)(hg,{open:!!p,onOpenChange:e=>!e&&f(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Mental Model"}),(0,D.jsxs)(hI,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',p?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hR,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hB,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hO,{onClick:b,disabled:g,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[g?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),d&&(0,D.jsx)(y3,{mentalModel:d,onClose:()=>h(null),onDelete:()=>f({id:d.id,name:d.name}),onRefreshed:e=>{n(t=>t.map(t=>t.id===e.id?e:t)),h(e)}})]})}function y5({open:e,onClose:t,onCreated:n}){let{currentBank:r}=(0,L.useBank)(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),l=async()=>{if(r&&o.name.trim()&&o.sourceQuery.trim()){a(!0);try{let e=o.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=parseInt(o.maxTokens)||2048;await q.client.createMentalModel(r,{name:o.name.trim(),source_query:o.sourceQuery.trim(),tags:e.length>0?e:void 0,max_tokens:t}),s({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),n()}catch(e){console.error("Error creating mental model:",e),alert("Error creating mental model: "+e.message)}finally{a(!1)}}};return(0,D.jsx)(tl.Dialog,{open:e,onOpenChange:e=>{e||(s({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),t())},children:(0,D.jsxs)(tl.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(tl.DialogHeader,{children:[(0,D.jsx)(tl.DialogTitle,{children:"Create Mental Model"}),(0,D.jsx)(tl.DialogDescription,{children:"Create a mental model by running a query. The content will be auto-generated and can be refreshed later."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(K.Input,{value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,D.jsx)(K.Input,{value:o.sourceQuery,onChange:e=>s({...o,sourceQuery:e.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,D.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,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,D.jsx)(K.Input,{type:"number",value:o.maxTokens,onChange:e=>s({...o,maxTokens:e.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(K.Input,{value:o.tags,onChange:e=>s({...o,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,D.jsxs)(tl.DialogFooter,{children:[(0,D.jsx)($.Button,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),(0,D.jsx)($.Button,{onClick:l,disabled:i||!o.name.trim()||!o.sourceQuery.trim(),children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}),"Generating..."]}):"Create"})]})]})})}function y3({mentalModel:e,onClose:t,onDelete:n,onRefreshed:r}){let{currentBank:i}=(0,L.useBank)(),[a,o]=(0,R.useState)(!1),[s,l]=(0,R.useState)(null),[c,u]=(0,R.useState)(!1),[d,h]=(0,R.useState)(e.name),[p,f]=(0,R.useState)(!1);(0,R.useEffect)(()=>{h(e.name),u(!1)},[e.id,e.name]);let g=async()=>{if(!i)return;o(!0);let t=e.last_refreshed_at;try{await q.client.refreshMentalModel(i,e.id);let n=0,a=async()=>{n++;try{let s=await q.client.getMentalModel(i,e.id);if(s.last_refreshed_at!==t){r(s),o(!1);return}if(n>=120){o(!1),alert("Refresh is taking longer than expected. Check the operations list for status.");return}setTimeout(a,1e3)}catch(e){console.error("Error polling mental model:",e),o(!1)}};setTimeout(a,1e3)}catch(e){console.error("Error refreshing mental model:",e),alert("Error refreshing: "+e.message),o(!1)}},v=async()=>{if(i&&d.trim()){f(!0);try{let t=await q.client.updateMentalModel(i,e.id,{name:d.trim()});r(t),u(!1)}catch(e){console.error("Error updating mental model:",e),alert("Error updating: "+e.message)}finally{f(!1)}}},x=e=>{let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`},y=e.reflect_response?.based_on?Object.entries(e.reflect_response.based_on).filter(([e])=>"observation"!==e).flatMap(([e,t])=>t.map(t=>({...t,factType:e}))):[],b=e.reflect_response?.based_on?.observation||[];return(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsx)("div",{className:"flex-1 mr-4",children:c?(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(K.Input,{value:d,onChange:e=>h(e.target.value),className:"text-lg font-bold",autoFocus:!0}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsxs)($.Button,{size:"sm",onClick:v,disabled:p||!d.trim(),children:[p?(0,D.jsx)(ts,{className:"w-3 h-3 animate-spin mr-1"}):null,"Save"]}),(0,D.jsx)($.Button,{size:"sm",variant:"outline",onClick:()=>{h(e.name),u(!1)},children:"Cancel"})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"h-7 w-7 p-0",children:(0,D.jsx)(yK,{className:"h-3.5 w-3.5"})})]}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e.source_query})]})}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsxs)($.Button,{variant:"outline",size:"sm",onClick:g,disabled:a,className:"h-8",children:[a?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):(0,D.jsx)(en,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(to.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xl,{children:e.content})})]}),y.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Based On (",y.length," ",1===y.length?"fact":"facts",")"]}),(0,D.jsx)("div",{className:"space-y-3",children:y.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${"world"===e.factType?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"experience"===e.factType?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-purple-500/10 text-purple-600 dark:text-purple-400"}`,children:e.factType}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>l(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t))})]}),b.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Observations Used (",b.length,")"]}),(0,D.jsx)("div",{className:"space-y-3",children:b.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.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,D.jsx)($.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>l(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t))})]}),!e.reflect_response&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Based On"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:'No source data available. Click "Refresh" to regenerate with source tracking.'})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,D.jsxs)("div",{className:"flex gap-6 text-sm text-muted-foreground",children:[(0,D.jsxs)("span",{children:["Created: ",x(e.created_at)]}),(0,D.jsxs)("span",{children:["Refreshed: ",x(e.last_refreshed_at)]})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,D.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]}),(0,D.jsx)("div",{className:"pt-4 border-t border-border",children:(0,D.jsxs)($.Button,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive hover:border-destructive",children:[(0,D.jsx)(hF,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]}),s&&i&&(0,D.jsx)(tp,{memoryId:s,onClose:()=>l(null)})]})}function y4(){let e=(0,M.useParams)(),t=(0,M.useRouter)(),n=(0,M.useSearchParams)(),{features:r}=(0,xm.useFeatures)(),i=e.bankId,a=n.get("view")||"profile",o=n.get("subTab")||"world",s=r?.observations??!1,l=e=>{t.push(`/banks/${i}?view=data&subTab=${e}`)};return(0,D.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,D.jsx)(P.BankSelector,{}),(0,D.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,D.jsx)(W,{currentTab:a,onTabChange:e=>{t.push(`/banks/${i}?view=${e}`)}}),(0,D.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,D.jsxs)("div",{className:"p-6",children:["profile"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Bank Profile"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and edit the memory bank profile, disposition traits, and background information."}),(0,D.jsx)(yJ,{})]}),"recall"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Recall"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Analyze memory recall with detailed trace information and retrieval methods."}),(0,D.jsx)(xg,{})]}),"reflect"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Reflect"}),(0,D.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,D.jsx)(xp,{})]}),"data"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Memories"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and explore different types of memories stored in this memory bank."}),(0,D.jsx)("div",{className:"mb-6 border-b border-border",children:(0,D.jsxs)("div",{className:"flex gap-1",children:[(0,D.jsxs)("button",{onClick:()=>l("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["World Facts","world"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Experience","experience"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Observations",!s&&(0,D.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Mental Models","mental-models"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,D.jsxs)("div",{children:["world"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Objective facts about the world received from external sources."}),(0,D.jsx)(hs,{factType:"world"},"world")]}),"experience"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"The bank's own actions, interactions, and first-person experiences."}),(0,D.jsx)(hs,{factType:"experience"},"experience")]}),"observations"===o&&(s?(0,D.jsxs)("div",{children:[(0,D.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,D.jsx)(hs,{factType:"observation"},"observations")]}):(0,D.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,D.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,D.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Z"}),(0,D.jsx)("path",{d:"M12 8v4"}),(0,D.jsx)("path",{d:"M12 16h.01"})]})}),(0,D.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"Observations Not Enabled"}),(0,D.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md",children:["Observations consolidation is disabled on this server. Set"," ",(0,D.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})," ","to enable."]})]})),"mental-models"===o&&(0,D.jsxs)("div",{children:[(0,D.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,D.jsx)(y2,{},"mental-models")]})]})]}),"documents"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Documents"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Manage documents and retain new memories."}),(0,D.jsx)(hz,{})]}),"entities"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Entities"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Explore entities (people, organizations, places) mentioned in memories."}),(0,D.jsx)(hV,{})]})]})})]})]})}e.s(["default",()=>y4],37578)}]);
8
+ ${I.trim()}`:I.trim();await q.client.updateDirective(d,t.id,{content:e})}else await q.client.createDirective(d,{name:eh,content:I.trim()});O(""),U(!0),setTimeout(()=>U(!1),3e3)}catch(e){console.error("Error submitting feedback:",e),alert("Error submitting feedback: "+e.message)}finally{V(!1)}}},eg=async()=>{if(d&&h){S(!0),E("answer");try{let e=_.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=await q.client.reflect({bank_id:d,query:h,budget:f,max_tokens:v,include_facts:y,include_tool_calls:w,...e.length>0&&{tags:e,tags_match:M}});C(t)}catch(e){console.error("Error running reflect:",e),alert("Error running reflect: "+e.message)}finally{S(!1)}}};return d?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(B,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"text",value:h,onChange:e=>p(e.target.value),placeholder:"What would you like to reflect on?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&eg()})]}),(0,D.jsx)($.Button,{onClick:eg,disabled:T||!h,className:"h-12 px-8",children:T?"Reflecting...":"Reflect"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Budget:"}),(0,D.jsxs)(pa,{value:f,onValueChange:e=>g(e),children:[(0,D.jsx)(pK,{className:"w-24 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"low",children:"Low"}),(0,D.jsx)(p0,{value:"mid",children:"Mid"}),(0,D.jsx)(p0,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(K.Input,{type:"number",value:v,onChange:e=>x(parseInt(e.target.value)||4096),className:"w-24 h-8"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:y,onCheckedChange:e=>b(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Source"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:w,onCheckedChange:e=>N(e)}),(0,D.jsx)("span",{className:"text-sm",children:"Include Tools"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(td.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(K.Input,{type:"text",value:_,onChange:e=>A(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(pa,{value:M,onValueChange:e=>P(e),children:[(0,D.jsx)(pK,{className:"w-40 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(p0,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(p0,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(p0,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),T&&(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Reflecting on memories..."})]})}),!T&&k&&(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[k.usage&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Input tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.usage.input_tokens?.toLocaleString()})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Output tokens:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.usage.output_tokens?.toLocaleString()})]})]}),k.trace?.tool_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Tool calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.trace.tool_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",k.trace.tool_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),k.trace?.llm_calls&&(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"LLM calls:"}),(0,D.jsx)("span",{className:"font-semibold",children:k.trace.llm_calls.length}),(0,D.jsxs)("span",{className:"text-muted-foreground",children:["(",k.trace.llm_calls.reduce((e,t)=>e+t.duration_ms,0),"ms)"]})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["answer","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>E(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${j===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"answer"===e?"Answer":"trace"===e?"Trace":"JSON"},e))})]}),"answer"===j&&(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{children:"Answer"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"text-base leading-relaxed whitespace-pre-wrap",children:k.text})})]}),(0,D.jsxs)(p2,{className:"border-blue-200 dark:border-blue-800",children:[(0,D.jsxs)(p5,{className:"py-4",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(p8,{className:"w-4 h-4"}),"Add Directive"]}),(0,D.jsx)(p4,{className:"text-xs",children:"Hard rules injected into prompts that the agent must follow"})]}),(0,D.jsx)(p6,{className:"pt-0",children:H?(0,D.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,D.jsx)("span",{className:"text-lg",children:"✓"}),(0,D.jsxs)("span",{className:"text-sm font-medium",children:["Directive saved to ",eh]})]}):(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsx)(fn.Textarea,{value:I,onChange:e=>O(e.target.value),placeholder:"e.g., Always respond in formal English...",className:"flex-1 min-h-[60px] resize-none",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ef()}}),(0,D.jsx)($.Button,{onClick:ef,disabled:z||!I.trim(),className:"self-end",children:z?"Saving...":"Save"})]})})]})]}),"trace"===j&&(0,D.jsxs)("div",{className:"space-y-4",children:[k.observations_created&&k.observations_created.length>0&&(0,D.jsxs)(p2,{className:"border-emerald-200 dark:border-emerald-800",children:[(0,D.jsxs)(p5,{className:"bg-emerald-50 dark:bg-emerald-950 py-3",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-base",children:[(0,D.jsx)(p9,{className:"w-4 h-4 text-emerald-600"}),"Observations Created (",k.observations_created.length,")"]}),(0,D.jsx)(p4,{className:"text-xs",children:"New observations learned during this reflection"})]}),(0,D.jsx)(p6,{className:"pt-4",children:(0,D.jsx)("div",{className:"space-y-2",children:k.observations_created.map((e,t)=>(0,D.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,D.jsx)("div",{className:"font-medium text-sm text-emerald-900 dark:text-emerald-100",children:e.name}),(0,D.jsx)("div",{className:"text-xs text-emerald-700 dark:text-emerald-300 mt-1",children:e.description}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-2 font-mono",children:["ID: ",e.id]})]},t))})})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,D.jsxs)(p2,{className:"h-fit",children:[(0,D.jsxs)(p5,{className:"pb-3",children:[(0,D.jsx)(p3,{className:"text-base",children:"Execution Trace"}),(0,D.jsxs)(p4,{className:"text-xs",children:[k.iterations||0," iteration",1!==(k.iterations||0)?"s":""," •"," ",(k.trace?.llm_calls?.reduce((e,t)=>e+t.duration_ms,0)||0)+(k.trace?.tool_calls?.reduce((e,t)=>e+t.duration_ms,0)||0),"ms total"]})]}),(0,D.jsx)(p6,{children:w?k.trace?.llm_calls&&k.trace.llm_calls.length>0||k.trace?.tool_calls&&k.trace.tool_calls.length>0?(0,D.jsx)("div",{className:"max-h-[500px] overflow-y-auto pr-2",children:(e=k.trace?.llm_calls||[],t=k.trace?.tool_calls||[],n=[],e.forEach((r,i)=>{let a=t.filter(e=>e.iteration===i+1),o=i===e.length-1,s=r.scope.includes("final")||o&&0===a.length,l=s?e.length:i+1;n.push({type:"llm",llm:r,iteration:l,isFinal:s}),a.length>0&&n.push({type:"tools",tools:a,iteration:i+1})}),n.map((e,t)=>(0,D.jsxs)("div",{className:"relative",children:[t<n.length-1&&(0,D.jsx)("div",{className:"absolute left-3 top-6 bottom-0 w-0.5 bg-border"}),"llm"===e.type?(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.jsx)("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${e.isFinal?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-primary/10 text-primary"}`,children:e.isFinal?(0,D.jsx)(ta.Check,{className:"w-3.5 h-3.5",strokeWidth:2.5}):(0,D.jsx)("span",{className:"text-[10px] font-semibold",children:e.iteration})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsx)("span",{className:"font-medium text-sm",children:e.isFinal?"Response generated":"Agent decided"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(ei,{className:"w-3 h-3"}),e.llm.duration_ms,"ms"]})]}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:e.isFinal?"Final answer":"Called tools below"})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 pb-3",children:[(0,D.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,D.jsx)(ft,{className:"w-3 h-3",fill:"currentColor"})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Executing ",e.tools?.length," tool",e.tools?.length!==1?"s":""]}),e.tools?.map((e,t)=>(0,D.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/50",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.tool}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(ei,{className:"w-3 h-3"}),e.duration_ms,"ms"]})]}),(0,D.jsxs)("div",{className:"p-2 space-y-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Input:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(fX,{src:e.input,collapsed:1,theme:"default"})})]}),e.output&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Output:"}),(0,D.jsx)("div",{className:"bg-muted p-1.5 rounded text-xs overflow-auto max-h-32",children:(0,D.jsx)(fX,{src:e.output,collapsed:1,theme:"default"})})]})]})]},t))]})]})]},t)))}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"No operations"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No LLM or tool calls were made during this reflection."})]})]}):(0,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Tool Calls" to see trace.'})]})]})})]}),(0,D.jsxs)(p2,{className:"h-fit",children:[(0,D.jsxs)(p5,{className:"pb-3",children:[(0,D.jsx)(p3,{className:"text-base",children:"Based On"}),(0,D.jsxs)(p4,{className:"text-xs",children:[(k.based_on?.memories?.length||0)+(k.based_on?.observations?.filter(e=>"directive"!==e.subtype)?.length||0)+(k.based_on?.directives?.length||0)," ","items used"]})]}),(0,D.jsx)(p6,{children:y?k.based_on?.memories&&k.based_on.memories.length>0||k.based_on?.mental_models&&k.based_on.mental_models.length>0||k.based_on?.directives&&k.based_on.directives.length>0||k.based_on?.observations&&k.based_on.observations.length>0?(i=(r=k.based_on?.memories||[]).filter(e=>"world"===e.type),a=r.filter(e=>"experience"===e.type),o=k.based_on?.mental_models||[],s=(k.based_on?.observations||[]).filter(e=>"directive"!==e.subtype),c=[{id:"directives",label:"Directives",count:(l=k.based_on?.directives||[]).length},{id:"mental_models",label:"Mental Models",count:o.length},{id:"observations",label:"Observations",count:s.length},{id:"world",label:"World",count:i.length},{id:"experience",label:"Experience",count:a.length}],u=(()=>{switch(eu){case"directives":return l;case"mental_models":return o;case"observations":return s;case"world":return i;case"experience":return a;default:return[]}})(),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 mb-4",children:c.map(e=>(0,D.jsxs)("button",{onClick:()=>ed(e.id),className:`flex-1 px-3 py-1.5 rounded-md text-sm font-medium transition-all ${eu===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.label," (",e.count,")"]},e.id))}),u.length>0?(0,D.jsx)("div",{className:"max-h-[400px] overflow-y-auto pr-2 space-y-3",children:u.map((e,t)=>{let n,r;return(0,D.jsx)("div",{className:`p-4 bg-muted/50 rounded-lg border border-border/50 ${"directives"!==eu?"cursor-pointer hover:bg-muted/80 transition-colors":""}`,onClick:()=>{"directives"!==eu&&("observations"===eu?ep(e):"mental_models"===eu?ec(e.id):Y(e.id))},children:"directives"===eu?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.content&&(0,D.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.content})]}):"observations"===eu?(0,D.jsx)("div",{className:"font-medium text-sm",children:e.name}):"mental_models"===eu?(r=(n=e.text?.indexOf(": ")??-1)>0?e.text.slice(0,n):e.id,(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"font-medium text-sm",children:r}),(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.id})]})):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text}),e.context&&(0,D.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:e.context})]})},e.id||t)})}):(0,D.jsxs)("p",{className:"text-sm text-muted-foreground text-center py-4",children:["No ",eu," items"]})]})):(0,D.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,D.jsx)(p7,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-amber-900 dark:text-amber-100",children:"No facts found"}),(0,D.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,D.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted border border-border rounded-lg",children:[(0,D.jsx)(p7,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"font-medium text-sm text-foreground",children:"Not included"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Enable "Include Source" to see memories.'})]})]})})]})]})]}),"json"===j&&(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(fX,{src:k,collapsed:2,theme:"default"})})})]})]}),!T&&!k&&(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(B,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Reflect"}),(0,D.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,D.jsx)(tp,{memoryId:G,onClose:()=>Y(null)}),X&&(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(fe,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Directive"})]}),(0,D.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{W(null),Q(null)},children:(0,D.jsx)(to.X,{className:"w-4 h-4"})})]}),J?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),(0,D.jsx)("p",{className:"mt-1 font-medium",children:Z?.name||X.name})]}),Z?.description&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,D.jsx)("p",{className:"mt-1 text-sm",children:Z.description})]}),Z?.tags&&Z.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(td.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),(Z?.content||X.content)&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Content"}),(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:Z?.content||X.content})})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:X.id})]})]})]})}),et&&(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(p9,{className:"w-5 h-5"}),(0,D.jsx)("h2",{className:"text-lg font-semibold",children:"Observation"})]}),(0,D.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{en(null),ea(null)},children:(0,D.jsx)(to.X,{className:"w-4 h-4"})})]}),eo?(0,D.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Text"}),(0,D.jsx)("p",{className:"mt-1 font-medium",children:er?.text||et.text})]}),er?.tags&&er.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-1",children:er.tags.map(e=>(0,D.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1",children:[(0,D.jsx)(td.Tag,{className:"w-2.5 h-2.5"}),e]},e))})]}),er?.source_memories&&er.source_memories.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:["Source Memories (",er.source_memories.length,")"]}),(0,D.jsx)("div",{className:"space-y-2",children:er.source_memories.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.text||("string"==typeof e?e:"")})},t))})]}),(0,D.jsxs)("div",{className:"pt-2 border-t",children:[(0,D.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),(0,D.jsx)("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:et.id})]})]})]})}),(0,D.jsx)(xh,{mentalModelId:el,onClose:()=>ec(null)})]}):(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(F,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start reflecting."})]})})}let xf=(0,O.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);function xg(){let e,t,n,r,i,a,o,s,l,c,u,d,h,p,{currentBank:f}=(0,L.useBank)(),[g,v]=(0,R.useState)(""),[x,y]=(0,R.useState)(["world"]),[b,w]=(0,R.useState)("mid"),[N,j]=(0,R.useState)(4096),[E,k]=(0,R.useState)(""),[C,T]=(0,R.useState)(!1),[S,_]=(0,R.useState)(!1),[A,M]=(0,R.useState)(""),[P,O]=(0,R.useState)("any"),[B,H]=(0,R.useState)(null),[G,Y]=(0,R.useState)(null),[X,W]=(0,R.useState)(null),[Q,J]=(0,R.useState)(null),[ee,et]=(0,R.useState)(null),[en,er]=(0,R.useState)(!1),[ea,eo]=(0,R.useState)("results"),[es,el]=(0,R.useState)(null),[ec,eu]=(0,R.useState)(new Set),[ed,eh]=(0,R.useState)(new Set),ep=e=>{eu(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ef=e=>{eh(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},eg=e=>{let t=e.id||e.node_id;el(B?.find(e=>e.id===t||e.node_id===t)||e)},em=async()=>{if(!f)return void alert("Please select a memory bank first");if(g){if(0===x.length)return void alert("Please select at least one type (World, Experience, or Observations)");er(!0);try{let e=A.split(",").map(e=>e.trim()).filter(e=>e.length>0),t={bank_id:f,query:g,types:x,budget:b,max_tokens:N,trace:!0,include:{entities:S?{max_tokens:500}:null,chunks:C?{max_tokens:8192}:null},...E&&{query_timestamp:E},...e.length>0&&{tags:e,tags_match:P}},n=await q.client.recall(t);H(n.results||[]),Y(n.entities||null),W(n.chunks||null),J(n.observations||null),et(n.trace||null),eo("results")}catch(e){console.error("Error running search:",e),alert("Error running search: "+e.message)}finally{er(!1)}}},ev=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return f?(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"pt-6",children:[(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)("div",{className:"flex-1 relative",children:[(0,D.jsx)(I.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"What would you like to recall?",className:"pl-10 h-12 text-lg",onKeyDown:e=>"Enter"===e.key&&em()})]}),(0,D.jsx)($.Button,{onClick:em,disabled:en||!g,className:"h-12 px-8",children:en?"Searching...":"Recall"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-6 mt-4 pt-4 border-t",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:"Types:"}),(0,D.jsxs)("div",{className:"flex gap-3",children:[["world","experience"].map(e=>(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:x.includes(e),onCheckedChange:()=>ev(e)}),(0,D.jsx)("span",{className:"text-sm capitalize",children:e})]},e)),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:x.includes("observation"),onCheckedChange:()=>ev("observation")}),(0,D.jsx)("span",{className:"text-sm",children:"Observations"})]})]})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(fW,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsxs)(pa,{value:b,onValueChange:e=>w(e),children:[(0,D.jsx)(pK,{className:"w-24 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"low",children:"Low"}),(0,D.jsx)(p0,{value:"mid",children:"Mid"}),(0,D.jsx)(p0,{value:"high",children:"High"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-sm text-muted-foreground",children:"Tokens:"}),(0,D.jsx)(K.Input,{type:"number",value:N,onChange:e=>j(parseInt(e.target.value)),className:"w-24 h-8"})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(ei,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)(K.Input,{type:"datetime-local",value:E,onChange:e=>k(e.target.value),className:"h-8",placeholder:"Query date"})]}),(0,D.jsx)("div",{className:"h-6 w-px bg-border"}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:C,onCheckedChange:e=>T(e)}),(0,D.jsx)(z.FileText,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Chunks"})]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)(p1.Checkbox,{checked:S,onCheckedChange:e=>_(e)}),(0,D.jsx)(V,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("span",{className:"text-sm",children:"Entities"})]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-4 pt-4 border-t",children:[(0,D.jsx)(td.Tag,{className:"h-4 w-4 text-muted-foreground"}),(0,D.jsx)("div",{className:"flex-1 max-w-md",children:(0,D.jsx)(K.Input,{type:"text",value:A,onChange:e=>M(e.target.value),placeholder:"Filter by tags (comma-separated)",className:"h-8"})}),(0,D.jsxs)(pa,{value:P,onValueChange:e=>O(e),children:[(0,D.jsx)(pK,{className:"w-40 h-8",children:(0,D.jsx)(pc,{})}),(0,D.jsxs)(pJ,{children:[(0,D.jsx)(p0,{value:"any",children:"Any (incl. untagged)"}),(0,D.jsx)(p0,{value:"all",children:"All (incl. untagged)"}),(0,D.jsx)(p0,{value:"any_strict",children:"Any (strict)"}),(0,D.jsx)(p0,{value:"all_strict",children:"All (strict)"})]})]})]})]})}),en&&(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Searching memories..."})]})}),!en&&B&&(0,D.jsxs)("div",{className:"space-y-4",children:[ee?.summary&&(0,D.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Results:"}),(0,D.jsx)("span",{className:"font-semibold",children:B.length})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Duration:"}),(0,D.jsxs)("span",{className:"font-semibold",children:[ee.summary.total_duration_seconds?.toFixed(2),"s"]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-muted-foreground",children:"Nodes visited:"}),(0,D.jsx)("span",{className:"font-semibold",children:ee.summary.total_nodes_visited})]}),(0,D.jsx)("div",{className:"flex-1"}),(0,D.jsx)("div",{className:"flex gap-1 bg-muted p-1 rounded-lg",children:["results","trace","json"].map(e=>(0,D.jsx)("button",{onClick:()=>eo(e),className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${ea===e?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"results"===e?"Results":"trace"===e?"Trace":"JSON"},e))})]}),"results"===ea&&(0,D.jsxs)("div",{className:"space-y-4",children:[Q&&Q.length>0&&(0,D.jsxs)(p2,{className:"border-orange-500/30 bg-orange-500/5",children:[(0,D.jsx)(p5,{className:"py-3",children:(0,D.jsxs)(p3,{className:"text-base flex items-center gap-2",children:[(0,D.jsx)(F,{className:"h-4 w-4 text-orange-500"}),(0,D.jsx)("span",{children:"Observations"}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",Q.length,")"]})]})}),(0,D.jsx)(p6,{className:"pt-0 space-y-2",children:Q.map((e,t)=>(0,D.jsxs)("div",{className:"p-3 bg-background rounded-lg border border-orange-500/20",children:[(0,D.jsx)("p",{className:"text-sm text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-orange-500/10 text-orange-600",children:"Observation"}),(0,D.jsxs)("span",{children:["Proof count: ",e.proof_count||1]}),(0,D.jsxs)("span",{children:["Relevance: ",(e.relevance||0).toFixed(3)]})]})]},e.id||t))})]}),(0,D.jsx)("div",{className:"space-y-3",children:0!==B.length||Q&&0!==Q.length?B.map((e,t)=>{let n=ee?.visits?.find(t=>t.node_id===e.id),r=n?n.weights.final_weight:e.score||0;return(0,D.jsx)(p2,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>el(e),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-start gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-semibold text-primary",children:t+1})}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-foreground",children:e.text}),(0,D.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[(0,D.jsx)("span",{className:"px-2 py-0.5 rounded bg-muted capitalize",children:e.type||"world"}),e.context&&(0,D.jsx)("span",{className:"truncate max-w-xs",children:e.context}),e.occurred_start&&(0,D.jsx)("span",{children:new Date(e.occurred_start).toLocaleDateString()})]})]}),(0,D.jsxs)("div",{className:"flex-shrink-0 text-right",children:[(0,D.jsx)("div",{className:"text-sm font-semibold",children:r.toFixed(3)}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:"score"})]}),(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"})]})})},t)}):(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-12",children:[(0,D.jsx)(I.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"No memories found for this query."})]})})})]}),"trace"===ea&&ee&&(0,D.jsxs)("div",{className:"space-y-4",children:[ee.retrieval_results&&ee.retrieval_results.length>0&&(e={},ee.retrieval_results.forEach(t=>{let n=t.fact_type||"all";e[n]||(e[n]=[]),e[n].push(t)}),t=Object.keys(e),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[(0,D.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,D.jsx)("span",{children:"PARALLEL RETRIEVAL"}),(0,D.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,D.jsx)("div",{className:"space-y-2",children:t.map((t,n)=>{let r=e[t],i=`lane-${t}`,a=ec.has(i),o=r.reduce((e,t)=>e+(t.results?.length||0),0),s=Math.max(...r.map(e=>e.duration_seconds||0)),l={world:{bg:"bg-blue-500/10",text:"text-blue-500",border:"border-blue-500/30"},experience:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},opinion:{bg:"bg-purple-500/10",text:"text-purple-500",border:"border-purple-500/30"},all:{bg:"bg-gray-500/10",text:"text-gray-500",border:"border-gray-500/30"}},c=l[t]||l.all;return(0,D.jsx)(p2,{className:`transition-colors ${a?"border-primary":c.border}`,children:(0,D.jsxs)(p6,{className:"py-3 px-4",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>ep(i),children:[(0,D.jsx)("div",{className:`w-8 h-8 rounded-lg ${c.bg} flex items-center justify-center`,children:(0,D.jsx)("span",{className:`text-sm font-bold ${c.text} capitalize`,children:t.charAt(0).toUpperCase()})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground capitalize",children:t}),(0,D.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r.length," methods"]})]}),(0,D.jsx)("div",{className:"flex gap-1.5 mt-1",children:r.map((e,t)=>(0,D.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground capitalize",children:[e.method_name,": ",e.results?.length||0]},t))})]}),(0,D.jsxs)("div",{className:"text-right",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:o}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[s.toFixed(2),"s"]})]}),a?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]}),a&&(0,D.jsx)("div",{className:"mt-4 pt-4 border-t border-border",children:(0,D.jsx)("div",{className:`grid gap-3 ${1===r.length?"grid-cols-1":2===r.length?"grid-cols-2":3===r.length?"grid-cols-3":"grid-cols-4"}`,children:r.map((e,t)=>{let n,r,a,o,s=`${i}-method-${t}`,l=ec.has(s),c=e.results||[];return(0,D.jsxs)("div",{className:"flex flex-col",children:[(0,D.jsxs)("div",{className:`p-3 rounded-lg cursor-pointer transition-colors ${l?"bg-primary/10 border border-primary":"bg-muted/50 hover:bg-muted"}`,onClick:e=>{e.stopPropagation(),ep(s)},children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground capitalize",children:e.method_name}),"temporal"===e.method_name&&e.metadata?.constraint&&(0,D.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,D.jsx)(Z,{className:"h-3 w-3"}),e.metadata.constraint.start?new Date(e.metadata.constraint.start).toLocaleDateString():"any"," → ",e.metadata.constraint.end?new Date(e.metadata.constraint.end).toLocaleDateString():"any"]})]}),l?(0,D.jsx)(pq,{className:"h-3 w-3 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-3 w-3 text-muted-foreground"})]}),(0,D.jsxs)("div",{className:"flex items-end justify-between",children:[(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:c.length}),(0,D.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[e.duration_seconds?.toFixed(2),"s"]})]})]}),l&&c.length>0&&(n=`results-${s}`,a=(r=ed.has(n))?c:c.slice(0,5),o=c.length>5,(0,D.jsxs)("div",{className:"mt-2 space-y-1.5 max-h-[300px] overflow-y-auto",children:[a.map((e,t)=>(0,D.jsx)("div",{className:"p-2 bg-background rounded cursor-pointer hover:bg-muted/50 transition-colors border border-border",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-xs text-foreground line-clamp-2",children:e.text}),(0,D.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,D.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(e.score||e.similarity||0).toFixed(4)})})]})]})},t)),o&&(0,D.jsx)("button",{className:"w-full text-[10px] text-primary hover:text-primary/80 py-1.5 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(n)},children:r?"Show less":`View all ${c.length} results`})]}))]},s)})})})]})},i)})}),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)("div",{className:"flex items-center gap-2",children:t.map((e,t)=>{let n={world:"bg-blue-500",experience:"bg-green-500",opinion:"bg-purple-500",all:"bg-gray-500"};return(0,D.jsx)("div",{className:"flex flex-col items-center",children:(0,D.jsx)("div",{className:`w-1 h-4 ${n[e]||n.all} rounded-full opacity-50`})},t)})})}),(0,D.jsx)("div",{className:"flex justify-center",children:(0,D.jsx)(xf,{className:"h-5 w-5 text-muted-foreground/50"})})]})),ee.rrf_merged&&(n="rrf-merge",r=ec.has(n),(0,D.jsxs)("div",{children:[(0,D.jsx)(p2,{className:`cursor-pointer transition-colors ${r?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(n),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-purple-500",children:"∪"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"RRF Fusion"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"merge"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Reciprocal Rank Fusion of all retrieval results"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ee.rrf_merged.length}),r?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]})})}),r&&ee.rrf_merged.length>0&&(i="results-rrf",o=(a=ed.has(i))?ee.rrf_merged:ee.rrf_merged.slice(0,5),s=ee.rrf_merged.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[o.map((e,t)=>(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:["RRF Score: ",(e.rrf_score||e.score||0).toFixed(4)]})]})]})},t)),s&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(i)},children:a?"Show less":`View all ${ee.rrf_merged.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(xf,{className:"h-4 w-4 text-muted-foreground/50"})})]})),ee.reranked&&(l="reranking",c=ec.has(l),(0,D.jsxs)("div",{children:[(0,D.jsx)(p2,{className:`cursor-pointer transition-colors ${c?"border-primary":"hover:border-primary/50"}`,onClick:()=>ep(l),children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-amber-500",children:"⚡"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Combined Scoring"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:"rerank"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:(0,D.jsx)("span",{className:"font-mono text-xs",children:"0.6×cross_encoder + 0.2×rrf + 0.1×temporal + 0.1×recency"})})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-foreground",children:ee.reranked.length}),c?(0,D.jsx)(pq,{className:"h-5 w-5 text-muted-foreground"}):(0,D.jsx)(U,{className:"h-5 w-5 text-muted-foreground"})]})})}),c&&ee.reranked.length>0&&(u="results-rerank",h=(d=ed.has(u))?ee.reranked:ee.reranked.slice(0,5),p=ee.reranked.length>5,(0,D.jsxs)("div",{className:"ml-6 mt-2 space-y-2 border-l-2 border-muted pl-4 max-h-[400px] overflow-y-auto",children:[h.map((e,t)=>{let n=e.score_components||{};return(0,D.jsx)("div",{className:"p-3 bg-muted/30 rounded-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:t=>{t.stopPropagation(),eg(e)},children:(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:t+1}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:e.text}),(0,D.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2 text-[10px] text-muted-foreground font-mono",children:[(0,D.jsxs)("span",{className:"font-semibold text-foreground",children:["= ",(e.rerank_score||e.score||0).toFixed(4)]}),void 0!==n.cross_encoder_score_normalized&&(0,D.jsxs)("span",{title:"Cross-encoder (60%)",children:["CE: ",n.cross_encoder_score_normalized.toFixed(3)]}),void 0!==n.rrf_normalized&&(0,D.jsxs)("span",{title:`RRF normalized (20%) - raw: ${n.rrf_score?.toFixed(4)||"N/A"}`,children:["RRF: ",n.rrf_normalized.toFixed(3)]}),void 0!==n.temporal&&(0,D.jsxs)("span",{title:"Temporal proximity (10%)",children:["Tmp: ",n.temporal.toFixed(3)]}),void 0!==n.recency&&(0,D.jsxs)("span",{title:"Recency (10%)",children:["Rec: ",n.recency.toFixed(3)]})]})]})]})},t)}),p&&(0,D.jsx)("button",{className:"w-full text-xs text-primary hover:text-primary/80 py-2 hover:bg-muted/50 rounded transition-colors",onClick:e=>{e.stopPropagation(),ef(u)},children:d?"Show less":`View all ${ee.reranked.length} results`})]})),(0,D.jsx)("div",{className:"flex justify-center py-2",children:(0,D.jsx)(xf,{className:"h-4 w-4 text-muted-foreground/50"})})]})),(0,D.jsx)(p2,{className:"border-primary bg-primary/5",children:(0,D.jsx)(p6,{className:"py-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:(0,D.jsx)("span",{className:"text-sm font-bold text-primary",children:"✓"})}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"font-semibold text-foreground",children:"Final Results"}),(0,D.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/20 text-primary",children:"output"})]}),(0,D.jsx)("div",{className:"text-sm text-muted-foreground mt-0.5",children:"Top results after all processing steps"})]}),(0,D.jsx)("div",{className:"text-2xl font-bold text-primary",children:B?.length||0})]})})})]}),"json"===ea&&(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{children:(0,D.jsx)(p3,{className:"text-lg",children:"Raw Response"})}),(0,D.jsx)(p6,{children:(0,D.jsx)("div",{className:"bg-muted p-4 rounded-lg overflow-auto max-h-[600px]",children:(0,D.jsx)(fX,{src:{results:B,...G&&{entities:G},...X&&{chunks:X},...Q&&{observations:Q},trace:ee},collapsed:2,theme:"default"})})})]})]}),!en&&!B&&(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(I.Search,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Ready to Recall"}),(0,D.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."})]})}),es&&(0,D.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,D.jsx)(tf,{memory:es,onClose:()=>el(null),inPanel:!0,bankId:f||void 0})})]}):(0,D.jsx)(p2,{className:"border-dashed",children:(0,D.jsxs)(p6,{className:"flex flex-col items-center justify-center py-16",children:[(0,D.jsx)(F,{className:"h-12 w-12 text-muted-foreground mb-4"}),(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to start recalling."})]})})}var xm=e.i(78152),xv=e.i(96626),xx=e.i(42727),xy=Symbol("radix.slottable");function xb(e){return R.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===xy}var xw=["Enter"," "],xN=["ArrowUp","PageDown","End"],xj=["ArrowDown","PageUp","Home",...xN],xE={ltr:[...xw,"ArrowRight"],rtl:[...xw,"ArrowLeft"]},xk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},xC="Menu",[xT,xS,x_]=(0,eS.createCollection)(xC),[xA,xD]=(0,eN.createContextScope)(xC,[x_,hX.createPopperScope,xx.createRovingFocusGroupScope]),xM=(0,hX.createPopperScope)(),xP=(0,xx.createRovingFocusGroupScope)(),[xR,xL]=xA(xC),[xI,xO]=xA(xC),xB=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=xM(t),[l,c]=R.useState(null),u=R.useRef(!1),d=(0,hK.useCallbackRef)(a),h=(0,eE.useDirection)(i);return R.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,D.jsx)(hX.Root,{...s,children:(0,D.jsx)(xR,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,D.jsx)(xI,{scope:t,onClose:R.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:o,children:r})})})};xB.displayName=xC;var xF=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=xM(n);return(0,D.jsx)(hX.Anchor,{...i,...r,ref:t})});xF.displayName="MenuAnchor";var xz="MenuPortal",[xV,xH]=xA(xz,{forceMount:void 0}),xU=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=xL(xz,t);return(0,D.jsx)(xV,{scope:t,forceMount:n,children:(0,D.jsx)(xv.Presence,{present:n||a.open,children:(0,D.jsx)(hW.Portal,{asChild:!0,container:i,children:r})})})};xU.displayName=xz;var xG="MenuContent",[xY,xX]=xA(xG),xW=R.forwardRef((e,t)=>{let n=xH(xG,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xL(xG,e.__scopeMenu),o=xO(xG,e.__scopeMenu);return(0,D.jsx)(xT.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(xv.Presence,{present:r||a.open,children:(0,D.jsx)(xT.Slot,{scope:e.__scopeMenu,children:o.modal?(0,D.jsx)(xq,{...i,ref:t}):(0,D.jsx)(x$,{...i,ref:t})})})})}),xq=R.forwardRef((e,t)=>{let n=xL(xG,e.__scopeMenu),r=R.useRef(null),i=(0,ew.useComposedRefs)(t,r);return R.useEffect(()=>{let e=r.current;if(e)return(0,h0.hideOthers)(e)},[]),(0,D.jsx)(xZ,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:(0,eb.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),x$=R.forwardRef((e,t)=>{let n=xL(xG,e.__scopeMenu);return(0,D.jsx)(xZ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),xK=((s=R.forwardRef((e,t)=>{let{children:n,...r}=e;if(R.isValidElement(n)){var i;let e,a,o=(i=n,(a=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(a=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...a}:"className"===r&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==R.Fragment&&(s.ref=t?(0,ew.composeRefs)(t,o):o),R.cloneElement(n,s)}return R.Children.count(n)>1?R.Children.only(null):null})).displayName="MenuContent.ScrollLock.SlotClone",i=s,(a=R.forwardRef((e,t)=>{let{children:n,...r}=e,a=R.Children.toArray(n),o=a.find(xb);if(o){let e=o.props.children,n=a.map(t=>t!==o?t:R.Children.count(e)>1?R.Children.only(null):R.isValidElement(e)?e.props.children:null);return(0,D.jsx)(i,{...r,ref:t,children:R.isValidElement(e)?R.cloneElement(e,void 0,n):null})}return(0,D.jsx)(i,{...r,ref:t,children:n})})).displayName="MenuContent.ScrollLock.Slot",a),xZ=R.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:f,...g}=e,v=xL(xG,n),x=xO(xG,n),y=xM(n),b=xP(n),w=xS(n),[N,j]=R.useState(null),E=R.useRef(null),k=(0,ew.useComposedRefs)(t,E,v.onContentChange),C=R.useRef(0),T=R.useRef(""),S=R.useRef(0),_=R.useRef(null),A=R.useRef("right"),M=R.useRef(0),P=f?h1.RemoveScroll:R.Fragment;R.useEffect(()=>()=>window.clearTimeout(C.current),[]),(0,hU.useFocusGuards)();let L=R.useCallback(e=>{var t,n;return A.current===_.current?.side&&(t=e,!!(n=_.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],l=o.x,c=o.y,u=s.x,d=s.y;c>r!=d>r&&n<(u-l)*(r-c)/(d-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,D.jsx)(xY,{scope:n,searchRef:T,onItemEnter:R.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:R.useCallback(e=>{L(e)||(E.current?.focus(),j(null))},[L]),onTriggerLeave:R.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:S,onPointerGraceIntentChange:R.useCallback(e=>{_.current=e},[]),children:(0,D.jsx)(P,{...f?{as:xK,allowPinchZoom:!0}:void 0,children:(0,D.jsx)(hG.FocusScope,{asChild:!0,trapped:i,onMountAutoFocus:(0,eb.composeEventHandlers)(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,D.jsx)(hH.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,children:(0,D.jsx)(xx.Root,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:j,onEntryFocus:(0,eb.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,D.jsx)(hX.Content,{role:"menu","aria-orientation":"vertical","data-state":yp(v.open),"data-radix-menu-content":"",dir:x.dir,...y,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:(0,eb.composeEventHandlers)(g.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,a,o,s,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=T.current+i,a=w().filter(e=>!e.disabled),o=document.activeElement,s=a.find(e=>e.ref.current===o)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,a=n?e.indexOf(n):-1,o=(r=Math.max(a,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(o=o.filter(e=>e!==n));let s=o.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return s!==n?s:void 0}(a.map(e=>e.textValue),t,s),c=a.find(e=>e.textValue===l)?.ref.current,function e(t){T.current=t,window.clearTimeout(C.current),""!==t&&(C.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let a=E.current;if(e.target!==a||!xj.includes(e.key))return;e.preventDefault();let o=w().filter(e=>!e.disabled).map(e=>e.ref.current);xN.includes(e.key)&&o.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(o)}),onBlur:(0,eb.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(C.current),T.current="")}),onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(A.current=e.clientX>M.current?"right":"left",M.current=e.clientX)}))})})})})})})});xW.displayName=xG;var xQ=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{role:"group",...r,ref:t})});xQ.displayName="MenuGroup";var xJ=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{...r,ref:t})});xJ.displayName="MenuLabel";var x0="MenuItem",x1="menu.itemSelect",x2=R.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=R.useRef(null),o=xO(x0,e.__scopeMenu),s=xX(x0,e.__scopeMenu),l=(0,ew.useComposedRefs)(t,a),c=R.useRef(!1);return(0,D.jsx)(x5,{...i,ref:l,disabled:n,onClick:(0,eb.composeEventHandlers)(e.onClick,()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(x1,{bubbles:!0,cancelable:!0});e.addEventListener(x1,e=>r?.(e),{once:!0}),(0,eT.dispatchDiscreteCustomEvent)(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,eb.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==s.searchRef.current;n||t&&" "===e.key||xw.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});x2.displayName=x0;var x5=R.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=xX(x0,n),s=xP(n),l=R.useRef(null),c=(0,ew.useComposedRefs)(t,l),[u,d]=R.useState(!1),[h,p]=R.useState("");return R.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[a.children]),(0,D.jsx)(xT.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,D.jsx)(xx.Item,{asChild:!0,...s,focusable:!r,children:(0,D.jsx)(eT.Primitive.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:c,onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,eb.composeEventHandlers)(e.onPointerLeave,ym(e=>o.onItemLeave(e))),onFocus:(0,eb.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,eb.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),x3=R.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,D.jsx)(yn,{scope:e.__scopeMenu,checked:n,children:(0,D.jsx)(x2,{role:"menuitemcheckbox","aria-checked":yf(n)?"mixed":n,...i,ref:t,"data-state":yg(n),onSelect:(0,eb.composeEventHandlers)(i.onSelect,()=>r?.(!!yf(n)||!n),{checkForDefaultPrevented:!1})})})});x3.displayName="MenuCheckboxItem";var x4="MenuRadioGroup",[x6,x7]=xA(x4,{value:void 0,onValueChange:()=>{}}),x9=R.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=(0,hK.useCallbackRef)(r);return(0,D.jsx)(x6,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,D.jsx)(xQ,{...i,ref:t})})});x9.displayName=x4;var x8="MenuRadioItem",ye=R.forwardRef((e,t)=>{let{value:n,...r}=e,i=x7(x8,e.__scopeMenu),a=n===i.value;return(0,D.jsx)(yn,{scope:e.__scopeMenu,checked:a,children:(0,D.jsx)(x2,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":yg(a),onSelect:(0,eb.composeEventHandlers)(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});ye.displayName=x8;var yt="MenuItemIndicator",[yn,yr]=xA(yt,{checked:!1}),yi=R.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=yr(yt,n);return(0,D.jsx)(xv.Presence,{present:r||yf(a.checked)||!0===a.checked,children:(0,D.jsx)(eT.Primitive.span,{...i,ref:t,"data-state":yg(a.checked)})})});yi.displayName=yt;var ya=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,D.jsx)(eT.Primitive.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ya.displayName="MenuSeparator";var yo=R.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=xM(n);return(0,D.jsx)(hX.Arrow,{...i,...r,ref:t})});yo.displayName="MenuArrow";var[ys,yl]=xA("MenuSub"),yc="MenuSubTrigger",yu=R.forwardRef((e,t)=>{let n=xL(yc,e.__scopeMenu),r=xO(yc,e.__scopeMenu),i=yl(yc,e.__scopeMenu),a=xX(yc,e.__scopeMenu),o=R.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,c={__scopeMenu:e.__scopeMenu},u=R.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return R.useEffect(()=>u,[u]),R.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]),(0,D.jsx)(xF,{asChild:!0,...c,children:(0,D.jsx)(x5,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":yp(n.open),...e,ref:(0,ew.composeRefs)(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:(0,eb.composeEventHandlers)(e.onPointerMove,ym(t=>{a.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||o.current||(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,eb.composeEventHandlers)(e.onPointerLeave,ym(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,o=t[i?"left":"right"],l=t[i?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:o,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:o,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,t=>{let i=""!==a.searchRef.current;e.disabled||i&&" "===t.key||xE[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});yu.displayName=yc;var yd="MenuSubContent",yh=R.forwardRef((e,t)=>{let n=xH(xG,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=xL(xG,e.__scopeMenu),o=xO(xG,e.__scopeMenu),s=yl(yd,e.__scopeMenu),l=R.useRef(null),c=(0,ew.useComposedRefs)(t,l);return(0,D.jsx)(xT.Provider,{scope:e.__scopeMenu,children:(0,D.jsx)(xv.Presence,{present:r||a.open,children:(0,D.jsx)(xT.Slot,{scope:e.__scopeMenu,children:(0,D.jsx)(xZ,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,eb.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:(0,eb.composeEventHandlers)(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=xk[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});function yp(e){return e?"open":"closed"}function yf(e){return"indeterminate"===e}function yg(e){return yf(e)?"indeterminate":e?"checked":"unchecked"}function ym(e){return t=>"mouse"===t.pointerType?e(t):void 0}yh.displayName=yd;var yv="DropdownMenu",[yx,yy]=(0,eN.createContextScope)(yv,[xD]),yb=xD(),[yw,yN]=yx(yv),yj=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,l=yb(t),c=R.useRef(null),[u,d]=(0,ej.useControllableState)({prop:i,defaultProp:a??!1,onChange:o,caller:yv});return(0,D.jsx)(yw,{scope:t,triggerId:(0,hY.useId)(),triggerRef:c,contentId:(0,hY.useId)(),open:u,onOpenChange:d,onOpenToggle:R.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,D.jsx)(xB,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};yj.displayName=yv;var yE="DropdownMenuTrigger",yk=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=yN(yE,n),o=yb(n);return(0,D.jsx)(xF,{asChild:!0,...o,children:(0,D.jsx)(eT.Primitive.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:(0,ew.composeRefs)(t,a.triggerRef),onPointerDown:(0,eb.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:(0,eb.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});yk.displayName=yE;var yC=e=>{let{__scopeDropdownMenu:t,...n}=e,r=yb(t);return(0,D.jsx)(xU,{...r,...n})};yC.displayName="DropdownMenuPortal";var yT="DropdownMenuContent",yS=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yN(yT,n),a=yb(n),o=R.useRef(!1);return(0,D.jsx)(xW,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:(0,eb.composeEventHandlers)(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:(0,eb.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.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)"}})});yS.displayName=yT,R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(xQ,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var y_=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(xJ,{...i,...r,ref:t})});y_.displayName="DropdownMenuLabel";var yA=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x2,{...i,...r,ref:t})});yA.displayName="DropdownMenuItem";var yD=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x3,{...i,...r,ref:t})});yD.displayName="DropdownMenuCheckboxItem",R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(x9,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var yM=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(ye,{...i,...r,ref:t})});yM.displayName="DropdownMenuRadioItem";var yP=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yi,{...i,...r,ref:t})});yP.displayName="DropdownMenuItemIndicator";var yR=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(ya,{...i,...r,ref:t})});yR.displayName="DropdownMenuSeparator",R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yo,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var yL=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yu,{...i,...r,ref:t})});yL.displayName="DropdownMenuSubTrigger";var yI=R.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yb(n);return(0,D.jsx)(yh,{...i,...r,ref:t,style:{...e.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)"}})});yI.displayName="DropdownMenuSubContent";let yO=(0,O.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);R.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,D.jsxs)(yL,{ref:i,className:(0,Y.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",t&&"pl-8",e),...r,children:[n,(0,D.jsx)(U,{className:"ml-auto"})]})).displayName=yL.displayName,R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(yI,{ref:n,className:(0,Y.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]",e),...t})).displayName=yI.displayName;let yB=R.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,D.jsx)(yC,{children:(0,D.jsx)(yS,{ref:r,sideOffset:t,className:(0,Y.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]",e),...n})}));yB.displayName=yS.displayName;let yF=R.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(yA,{ref:r,className:(0,Y.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",t&&"pl-8",e),...n}));yF.displayName=yA.displayName,R.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,D.jsxs)(yD,{ref:i,className:(0,Y.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",e),checked:n,...r,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(yP,{children:(0,D.jsx)(ta.Check,{className:"h-4 w-4"})})}),t]})).displayName=yD.displayName,R.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(yM,{ref:r,className:(0,Y.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",e),...n,children:[(0,D.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,D.jsx)(yP,{children:(0,D.jsx)(yO,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=yM.displayName,R.forwardRef(({className:e,inset:t,...n},r)=>(0,D.jsx)(y_,{ref:r,className:(0,Y.cn)("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n})).displayName=y_.displayName;let yz=R.forwardRef(({className:e,...t},n)=>(0,D.jsx)(yR,{ref:n,className:(0,Y.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));yz.displayName=yR.displayName;let yV=(0,O.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),yH=(0,O.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"}]]),yU=(0,O.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"}]]),yG=(0,O.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"}]]),yY=(0,O.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"}]]),yX=(0,O.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"}]]),yW=(0,O.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var yq=e.i(7233);let y$=(0,O.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"}]]),yK=(0,O.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"}]]),yZ={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 yQ({disposition:e,editMode:t,editDisposition:n,onEditChange:r}){let i=t?n:e;return(0,D.jsx)("div",{className:"space-y-4",children:Object.keys(yZ).map(e=>(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:yZ[e].label}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:yZ[e].description})]}),(0,D.jsxs)("span",{className:"text-sm font-bold text-primary",children:[i[e],"/5"]})]}),t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[(0,D.jsx)("span",{children:yZ[e].lowLabel}),(0,D.jsx)("span",{children:yZ[e].highLabel})]}),(0,D.jsx)("input",{type:"range",min:"1",max:"5",step:"1",value:n[e],onChange:t=>r(e,parseInt(t.target.value)),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"})]}):(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:yZ[e].lowLabel}),(0,D.jsx)("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:(0,D.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${(i[e]-1)/4*100}%`}})}),(0,D.jsx)("span",{className:"text-xs text-muted-foreground",children:yZ[e].highLabel})]})]},e))})}function yJ(){let e=(0,M.useRouter)(),{currentBank:t,setCurrentBank:n,loadBanks:r}=(0,L.useBank)(),{features:i}=(0,xm.useFeatures)(),a=i?.observations??!1,[o,s]=(0,R.useState)(null),[l,c]=(0,R.useState)(null),[u,d]=(0,R.useState)([]),[h,p]=(0,R.useState)(0),[f,g]=(0,R.useState)([]),[v,x]=(0,R.useState)(0),[y,b]=(0,R.useState)(!1),[w,N]=(0,R.useState)(!1),[j,E]=(0,R.useState)(!1),[k,C]=(0,R.useState)(!1),[T,S]=(0,R.useState)(null),[_,A]=(0,R.useState)(null),[P,I]=(0,R.useState)(!1),O=(0,R.useRef)(j);(0,R.useEffect)(()=>{O.current=j},[j]);let[B,z]=(0,R.useState)(!1),[V,H]=(0,R.useState)(!1),[U,G]=(0,R.useState)(!1),[Y,X]=(0,R.useState)(!1),[W,K]=(0,R.useState)(!1),[Z,Q]=(0,R.useState)(null),[J]=(0,R.useState)(10),[ee,et]=(0,R.useState)(0),[ea,eo]=(0,R.useState)(null),[ep,ef]=(0,R.useState)(""),[eg,em]=(0,R.useState)({skepticism:3,literalism:3,empathy:3}),ev=async(e=Z,n=ee)=>{if(t)try{let r=await q.client.listOperations(t,{status:e||void 0,limit:J,offset:n});d(r.operations||[]),p(r.total||0)}catch(e){console.error("Error loading operations:",e)}},ex=async(e=!1)=>{if(t){if(e){try{let[e,n,r]=await Promise.all([q.client.getBankStats(t),q.client.listDirectives(t),q.client.listMentalModels(t)]);c(e),g(n.items||[]),x(r.items?.length||0)}catch(e){console.error("Error refreshing stats:",e)}return}b(!0);try{let[e,n,r,i]=await Promise.all([q.client.getBankProfile(t),q.client.getBankStats(t),q.client.listDirectives(t),q.client.listMentalModels(t)]);s(e),c(n),g(r.items||[]),x(i.items?.length||0),await ev(),O.current||(ef(e.mission||""),em(e.disposition))}catch(e){console.error("Error loading bank profile:",e),alert("Error loading bank profile: "+e.message)}finally{b(!1)}}},ey=async()=>{if(t){N(!0);try{await q.client.updateBankProfile(t,{mission:ep,disposition:eg}),await ex(),E(!1)}catch(e){console.error("Error saving bank profile:",e),alert("Error saving bank profile: "+e.message)}finally{N(!1)}}},eb=async()=>{if(t){H(!0);try{await q.client.deleteBank(t),z(!1),n(null),await r(),e.push("/")}catch(e){console.error("Error deleting bank:",e),alert("Error deleting bank: "+e.message)}finally{H(!1)}}},ew=async()=>{if(t){X(!0);try{let e=await q.client.clearObservations(t);G(!1),await ex(),alert(e.message||"Observations cleared successfully")}catch(e){console.error("Error clearing observations:",e),alert("Error clearing observations: "+e.message)}finally{X(!1)}}},eN=async()=>{if(t){K(!0);try{await q.client.triggerConsolidation(t),await ex(),await ev()}catch(e){console.error("Error triggering consolidation:",e),alert("Error triggering consolidation: "+e.message)}finally{K(!1)}}},ej=e=>{et(e),ev(Z,e)},eE=async e=>{if(t){eo(e);try{await q.client.cancelOperation(t,e),await ev()}catch(e){console.error("Error cancelling operation:",e),alert("Error cancelling operation: "+e.message)}finally{eo(null)}}},ek=async()=>{if(t&&_){I(!0);try{await q.client.deleteDirective(t,_.id),g(e=>e.filter(e=>e.id!==_.id)),T?.id===_.id&&S(null),A(null)}catch(e){console.error("Error deleting directive:",e),alert("Error deleting: "+e.message)}finally{I(!1)}}};return((0,R.useEffect)(()=>{if(t){ex();let e=setInterval(()=>ex(!0),5e3);return()=>clearInterval(e)}},[t]),(0,R.useEffect)(()=>{let e=e=>{"Escape"===e.key&&S(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),t)?y&&!o?(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"text-center py-10",children:[(0,D.jsx)(ei,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground animate-pulse"}),(0,D.jsx)("div",{className:"text-lg text-muted-foreground",children:"Loading profile..."})]})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-center",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{className:"text-2xl font-bold text-foreground",children:o?.name||t}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground font-mono",children:t})]}),(0,D.jsx)("div",{className:"flex gap-2",children:j?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)($.Button,{onClick:()=>{o&&(ef(o.mission||""),em(o.disposition)),E(!1)},variant:"secondary",disabled:w,children:"Cancel"}),(0,D.jsx)($.Button,{onClick:ey,disabled:w,children:w?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(yV,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]}):(0,D.jsxs)(yj,{children:[(0,D.jsx)(yk,{asChild:!0,children:(0,D.jsxs)($.Button,{variant:"outline",size:"sm",children:["Actions",(0,D.jsx)(y$,{className:"w-4 h-4 ml-2"})]})}),(0,D.jsxs)(yB,{align:"end",className:"w-48",children:[(0,D.jsxs)(yF,{onClick:()=>E(!0),children:[(0,D.jsx)(yK,{className:"w-4 h-4 mr-2"}),"Edit Profile"]}),(0,D.jsx)(yz,{}),(0,D.jsxs)(yF,{onClick:eN,disabled:W||!a,title:a?void 0:"Observations feature is not enabled",children:[W?(0,D.jsx)(ts,{className:"w-4 h-4 mr-2 animate-spin"}):(0,D.jsx)(p9,{className:"w-4 h-4 mr-2"}),W?"Consolidating...":"Run Consolidation",!a&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsxs)(yF,{onClick:()=>G(!0),disabled:!a,className:"text-amber-600 dark:text-amber-400 focus:text-amber-700 dark:focus:text-amber-300",title:a?void 0:"Observations feature is not enabled",children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Clear Observations",!a&&(0,D.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Off"})]}),(0,D.jsx)(yz,{}),(0,D.jsxs)(yF,{onClick:()=>z(!0),className:"text-red-600 dark:text-red-400 focus:text-red-700 dark:focus:text-red-300",children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})]})]})})]}),l&&(0,D.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,D.jsx)(p2,{className:"bg-gradient-to-br from-blue-500/10 to-blue-600/5 border-blue-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/20",children:(0,D.jsx)(F,{className:"w-5 h-5 text-blue-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Memories"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_nodes})]})]})})}),(0,D.jsx)(p2,{className:"bg-gradient-to-br from-purple-500/10 to-purple-600/5 border-purple-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/20",children:(0,D.jsx)(yU,{className:"w-5 h-5 text-purple-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Links"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_links})]})]})})}),(0,D.jsx)(p2,{className:"bg-gradient-to-br from-emerald-500/10 to-emerald-600/5 border-emerald-500/20",children:(0,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/20",children:(0,D.jsx)(yG,{className:"w-5 h-5 text-emerald-500"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Documents"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.total_documents})]})]})})}),(0,D.jsx)(p2,{className:`bg-gradient-to-br ${l.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,D.jsx)(p6,{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:`p-2 rounded-lg ${l.pending_operations>0?"bg-amber-500/20":"bg-slate-500/20"}`,children:(0,D.jsx)(yY,{className:`w-5 h-5 ${l.pending_operations>0?"text-amber-500 animate-pulse":"text-slate-500"}`})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Pending"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-foreground",children:l.pending_operations})]})]})})})]}),l&&(0,D.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,D.jsxs)("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-semibold uppercase tracking-wide",children:"World Facts"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400 mt-1",children:l.nodes_by_fact_type?.world||0})]}),(0,D.jsxs)("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-semibold uppercase tracking-wide",children:"Experience"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-purple-600 dark:text-purple-400 mt-1",children:l.nodes_by_fact_type?.experience||0})]}),(0,D.jsxs)("div",{className:`rounded-xl p-4 text-center ${a?"bg-amber-500/10 border border-amber-500/20":"bg-muted/50 border border-muted"}`,title:a?void 0:"Observations feature is not enabled",children:[(0,D.jsxs)("p",{className:`text-xs font-semibold uppercase tracking-wide ${a?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:["Observations",!a&&(0,D.jsx)("span",{className:"ml-1 normal-case",children:"(Off)"})]}),(0,D.jsx)("p",{className:`text-2xl font-bold mt-1 ${a?"text-amber-600 dark:text-amber-400":"text-muted-foreground"}`,children:a?l.total_mental_models||0:"—"})]}),(0,D.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-semibold uppercase tracking-wide",children:"Mental Models"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-cyan-600 dark:text-cyan-400 mt-1",children:v})]}),(0,D.jsxs)("div",{className:"bg-rose-500/10 border border-rose-500/20 rounded-xl p-4 text-center",children:[(0,D.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-semibold uppercase tracking-wide",children:"Directives"}),(0,D.jsx)("p",{className:"text-2xl font-bold text-rose-600 dark:text-rose-400 mt-1",children:f.length})]})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,D.jsxs)(p2,{children:[(0,D.jsxs)(p5,{className:"pb-2",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(p9,{className:"w-5 h-5 text-primary"}),"Disposition Profile"]}),(0,D.jsx)(p4,{children:"Traits that shape how observations are formed via Reflect"})]}),(0,D.jsx)(p6,{children:o&&(0,D.jsx)(yQ,{disposition:o.disposition,editMode:j,editDisposition:eg,onEditChange:(e,t)=>em(n=>({...n,[e]:t}))})})]}),(0,D.jsxs)(p2,{children:[(0,D.jsxs)(p5,{className:"pb-2",children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yX,{className:"w-5 h-5 text-primary"}),"Mission"]}),(0,D.jsx)(p4,{children:"Who the agent is and what they're trying to accomplish. Used for mental models and reflect."})]}),(0,D.jsx)(p6,{children:j?(0,D.jsx)(fn.Textarea,{value:ep,onChange:e=>ef(e.target.value),placeholder:"e.g., I am a PM for the engineering team. I help coordinate sprints and track project progress...",rows:6,className:"resize-none"}):(0,D.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:o?.mission||"No mission set. Set a mission to derive structural mental models and personalize reflect responses."})})]})]}),(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),"Directives"]}),(0,D.jsx)(p4,{children:"Hard rules that must be followed during reflect"})]}),(0,D.jsxs)($.Button,{onClick:()=>C(!0),variant:"outline",size:"sm",className:"h-8",children:[(0,D.jsx)(yq.Plus,{className:"w-4 h-4 mr-1"}),"Add"]})]})}),(0,D.jsx)(p6,{children:f.length>0?(0,D.jsx)("div",{className:"grid grid-cols-2 gap-3",children:f.map(e=>(0,D.jsx)(p2,{className:`cursor-pointer transition-colors border-rose-500/30 ${T?.id===e.id?"bg-rose-500/10 border-rose-500":"hover:bg-rose-500/5"}`,onClick:()=>S(e),children:(0,D.jsx)(p6,{className:"p-3",children:(0,D.jsxs)("div",{className:"flex items-start gap-2",children:[(0,D.jsx)(yW,{className:"w-4 h-4 text-rose-500 shrink-0 mt-0.5"}),(0,D.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,D.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:e.content}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[(0,D.jsx)(td.Tag,{className:"w-3 h-3 text-muted-foreground"}),e.tags.map(e=>(0,D.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e},e))]})]})]})})},e.id))}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-rose-500/30 rounded-lg text-center",children:[(0,D.jsx)(yW,{className:"w-6 h-6 mx-auto mb-2 text-rose-500/50"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:"No directives yet. Directives are hard rules that must be followed during reflect."})]})})]}),(0,D.jsxs)(p2,{children:[(0,D.jsx)(p5,{className:"pb-2",children:(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)(p3,{className:"flex items-center gap-2 text-lg",children:[(0,D.jsx)(yY,{className:"w-5 h-5 text-primary"}),"Background Operations",(0,D.jsx)("button",{onClick:()=>ev(),className:"p-1 rounded hover:bg-muted transition-colors",title:"Refresh operations",children:(0,D.jsx)(en,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})]}),(0,D.jsxs)(p4,{children:[h," operation",1!==h?"s":"",Z?` (${Z})`:""]})]}),(0,D.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(e=>(0,D.jsx)("button",{onClick:()=>{var t;Q(t=e.value),et(0),ev(t,0)},className:`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${Z===e.value?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:e.label},e.value??"all"))})]})}),(0,D.jsx)(p6,{children:u.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)(es,{children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{children:[(0,D.jsx)(ed,{className:"w-[100px]",children:"ID"}),(0,D.jsx)(ed,{children:"Type"}),(0,D.jsx)(ed,{children:"Created"}),(0,D.jsx)(ed,{children:"Status"}),(0,D.jsx)(ed,{className:"w-[80px]"})]})}),(0,D.jsx)(ec,{children:u.map(e=>(0,D.jsxs)(eu,{className:"failed"===e.status?"bg-red-500/5":"",children:[(0,D.jsx)(eh,{className:"font-mono text-xs text-muted-foreground",children:e.id.substring(0,8)}),(0,D.jsx)(eh,{className:"font-medium",children:e.task_type}),(0,D.jsx)(eh,{className:"text-sm text-muted-foreground",children:new Date(e.created_at).toLocaleString()}),(0,D.jsxs)(eh,{children:["pending"===e.status&&(0,D.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,D.jsx)(ei,{className:"w-3 h-3"}),"pending"]}),"failed"===e.status&&(0,D.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:e.error_message??void 0,children:[(0,D.jsx)(yH,{className:"w-3 h-3"}),"failed"]}),"completed"===e.status&&(0,D.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,D.jsx)(er,{className:"w-3 h-3"}),"completed"]})]}),(0,D.jsx)(eh,{children:"pending"===e.status&&(0,D.jsxs)($.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400",onClick:()=>eE(e.id),disabled:ea===e.id,children:[ea===e.id?(0,D.jsx)(ts,{className:"w-3 h-3 animate-spin"}):(0,D.jsx)(to.X,{className:"w-3 h-3 mr-1"}),ea===e.id?"":"Cancel"]})})]},e.id))})]})}),h>J&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[(0,D.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Showing ",ee+1,"-",Math.min(ee+J,h)," of"," ",h]}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>ej(Math.max(0,ee-J)),disabled:0===ee,children:"Previous"}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>ej(ee+J),disabled:ee+J>=h,children:"Next"})]})]})]}):(0,D.jsxs)("p",{className:"text-muted-foreground text-center py-8 text-sm",children:["No ",Z?`${Z} `:"","operations"]})})]}),(0,D.jsx)(hg,{open:B,onOpenChange:z,children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Memory Bank"}),(0,D.jsx)(hI,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to delete the memory bank"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.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."}),l&&(0,D.jsxs)("p",{children:["This will delete ",l.total_nodes," memories, ",l.total_documents," ","documents, and ",l.total_links," links."]})]})})]}),(0,D.jsxs)(hR,{children:[(0,D.jsx)(hB,{disabled:V,children:"Cancel"}),(0,D.jsx)(hO,{onClick:eb,disabled:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:V?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Delete Bank"]})})]})]})}),(0,D.jsx)(hg,{open:U,onOpenChange:G,children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Clear Observations"}),(0,D.jsx)(hI,{asChild:!0,children:(0,D.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,D.jsxs)("p",{children:["Are you sure you want to clear all observations for"," ",(0,D.jsx)("span",{className:"font-semibold text-foreground",children:t}),"?"]}),(0,D.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."}),l&&l.total_mental_models>0&&(0,D.jsxs)("p",{children:["This will delete ",l.total_mental_models," observations."]})]})})]}),(0,D.jsxs)(hR,{children:[(0,D.jsx)(hB,{disabled:Y,children:"Cancel"}),(0,D.jsx)(hO,{onClick:ew,disabled:Y,className:"bg-amber-500 text-white hover:bg-amber-600",children:Y?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ts,{className:"w-4 h-4 mr-2 animate-spin"}),"Clearing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(hF,{className:"w-4 h-4 mr-2"}),"Clear Observations"]})})]})]})}),(0,D.jsx)(y0,{open:k,mode:"create",onClose:()=>C(!1),onCreated:e=>{g(t=>[e,...t]),C(!1)}}),(0,D.jsx)(hg,{open:!!_,onOpenChange:e=>!e&&A(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Directive"}),(0,D.jsxs)(hI,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',_?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hR,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hB,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hO,{onClick:ek,disabled:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[P?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),T&&(0,D.jsx)(y1,{directive:T,onClose:()=>S(null),onDelete:()=>A({id:T.id,name:T.name}),onUpdated:e=>{g(t=>t.map(t=>t.id===e.id?e:t)),S(e)}})]}):(0,D.jsx)(p2,{children:(0,D.jsxs)(p6,{className:"p-10 text-center",children:[(0,D.jsx)("h3",{className:"text-xl font-semibold mb-2 text-card-foreground",children:"No Bank Selected"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Please select a memory bank from the dropdown above to view its profile."})]})})}function y0({open:e,mode:t,directive:n,onClose:r,onCreated:i,onSaved:a}){let{currentBank:o}=(0,L.useBank)(),[s,l]=(0,R.useState)(!1),[c,u]=(0,R.useState)({name:"",content:"",tags:""});(0,R.useEffect)(()=>{"edit"===t&&n?u({name:n.name,content:n.content,tags:(n.tags||[]).join(", ")}):"create"===t&&u({name:"",content:"",tags:""})},[e,t,n]);let d=async()=>{if(o&&c.name.trim()&&c.content.trim()){l(!0);try{let e=c.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0);if("create"===t){let t=await q.client.createDirective(o,{name:c.name.trim(),content:c.content.trim(),tags:e.length>0?e:void 0});u({name:"",content:"",tags:""}),i?.(t)}else if(n){let t=await q.client.updateDirective(o,n.id,{name:c.name.trim(),content:c.content.trim(),tags:e});a?.(t),r()}}catch(e){console.error(`Error ${"create"===t?"creating":"updating"} directive:`,e),alert(`Error ${"create"===t?"creating":"updating"}: `+e.message)}finally{l(!1)}}},h=()=>{"create"===t&&u({name:"",content:"",tags:""}),r()};return(0,D.jsx)(tl.Dialog,{open:e,onOpenChange:e=>!e&&h(),children:(0,D.jsxs)(tl.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(tl.DialogHeader,{children:[(0,D.jsxs)(tl.DialogTitle,{className:"flex items-center gap-2",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),"create"===t?"Create":"Edit"," Directive"]}),(0,D.jsx)(tl.DialogDescription,{children:"Directives are hard rules that must be followed during reflect."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(K.Input,{value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:"e.g., Competitor Policy"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Rule *"}),(0,D.jsx)(fn.Textarea,{value:c.content,onChange:e=>u({...c,content:e.target.value}),placeholder:"e.g., Never mention competitor products directly.",className:"min-h-[120px]"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(K.Input,{value:c.tags,onChange:e=>u({...c,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,D.jsxs)(tl.DialogFooter,{children:[(0,D.jsx)($.Button,{variant:"outline",onClick:h,disabled:s,children:"Cancel"}),(0,D.jsxs)($.Button,{onClick:d,disabled:s||!c.name.trim()||!c.content.trim(),className:"bg-rose-500 hover:bg-rose-600",children:[s?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"create"===t?"Create":"Save"]})]})]})})}function y1({directive:e,onClose:t,onDelete:n,onUpdated:r}){let[i,a]=(0,R.useState)(!1);return(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsxs)("div",{className:"flex items-start gap-3",children:[(0,D.jsx)(yW,{className:"w-5 h-5 text-rose-500"}),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>a(!0),className:"h-7 w-7 p-0",children:(0,D.jsx)(yK,{className:"h-3.5 w-3.5"})})]}),(0,D.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,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0 text-muted-foreground hover:text-rose-500",children:(0,D.jsx)(hF,{className:"h-4 w-4"})}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(to.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Rule"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xl,{children:e.content})})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,D.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]})]})]}),(0,D.jsx)(y0,{open:i,mode:"edit",directive:e,onClose:()=>a(!1),onSaved:r})]})}function y2(){let{currentBank:e}=(0,L.useBank)(),[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(""),[s,l]=(0,R.useState)(1),[c,u]=(0,R.useState)(!1),[d,h]=(0,R.useState)(null),[p,f]=(0,R.useState)(null),[g,v]=(0,R.useState)(!1),x=t.filter(e=>{if(!a)return!0;let t=a.toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.source_query.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),y=async()=>{if(e){i(!0);try{let t=await q.client.listMentalModels(e);n(t.items||[])}catch(e){console.error("Error loading mental models:",e)}finally{i(!1)}}},b=async()=>{if(e&&p){v(!0);try{await q.client.deleteMentalModel(e,p.id),n(e=>e.filter(e=>e.id!==p.id)),d?.id===p.id&&h(null),f(null)}catch(e){console.error("Error deleting mental model:",e),alert("Error deleting: "+e.message)}finally{v(!1)}}};if((0,R.useEffect)(()=>{e&&y()},[e]),(0,R.useEffect)(()=>{let e=e=>{"Escape"===e.key&&h(null)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,R.useEffect)(()=>{l(1)},[a]),!e)return(0,D.jsx)(p2,{children:(0,D.jsx)(p6,{className:"p-10 text-center",children:(0,D.jsx)("p",{className:"text-muted-foreground",children:"Select a memory bank to view mental models."})})});let w=Math.ceil(x.length/100),N=(s-1)*100,j=N+100,E=x.slice(N,j);return(0,D.jsxs)("div",{children:[r?(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(en,{className:"w-8 h-8 mx-auto mb-3 text-muted-foreground animate-spin"}),(0,D.jsx)("p",{className:"text-muted-foreground",children:"Loading..."})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"mb-4",children:(0,D.jsx)(K.Input,{type:"text",value:a,onChange:e=>o(e.target.value),placeholder:"Filter mental models by name, query, or content...",className:"max-w-md"})}),(0,D.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,D.jsx)("div",{className:"text-sm text-muted-foreground",children:a?`${x.length} of ${t.length} mental models`:`${t.length} mental model${1!==t.length?"s":""}`}),(0,D.jsxs)($.Button,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[(0,D.jsx)(yq.Plus,{className:"w-4 h-4 mr-2"}),"Add Mental Model"]})]}),x.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"border rounded-lg overflow-hidden",children:(0,D.jsxs)(es,{className:"table-fixed",children:[(0,D.jsx)(el,{children:(0,D.jsxs)(eu,{className:"bg-muted/50",children:[(0,D.jsx)(ed,{className:"w-[20%]",children:"ID"}),(0,D.jsx)(ed,{className:"w-[20%]",children:"Name"}),(0,D.jsx)(ed,{className:"w-[35%]",children:"Source Query"}),(0,D.jsx)(ed,{className:"w-[15%]",children:"Last Refreshed"}),(0,D.jsx)(ed,{className:"w-[10%]"})]})}),(0,D.jsx)(ec,{children:E.map(e=>{let t=new Date(e.last_refreshed_at),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return(0,D.jsxs)(eu,{className:`cursor-pointer hover:bg-muted/50 ${d?.id===e.id?"bg-primary/10":""}`,onClick:()=>h(e),children:[(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("code",{className:"text-xs font-mono text-muted-foreground truncate block",children:e.id})}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("div",{className:"font-medium text-foreground",children:e.name})}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)("div",{className:"text-sm text-muted-foreground truncate",children:e.source_query})}),(0,D.jsxs)(eh,{className:"py-2 text-sm text-foreground",children:[(0,D.jsx)("div",{children:n}),(0,D.jsx)("div",{className:"text-xs text-muted-foreground",children:r})]}),(0,D.jsx)(eh,{className:"py-2",children:(0,D.jsx)($.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:t=>{t.stopPropagation(),f({id:e.id,name:e.name})},children:(0,D.jsx)(hF,{className:"h-4 w-4"})})})]},e.id)})})]})}),w>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t",children:[(0,D.jsxs)("div",{className:"text-xs text-muted-foreground",children:[N+1,"-",Math.min(j,x.length)," of"," ",x.length]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(1),disabled:1===s,className:"h-7 w-7 p-0",children:(0,D.jsx)(ee,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(e=>Math.max(1,e-1)),disabled:1===s,className:"h-7 w-7 p-0",children:(0,D.jsx)(H,{className:"h-3 w-3"})}),(0,D.jsxs)("span",{className:"text-xs px-2",children:[s," / ",w]}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(e=>Math.min(w,e+1)),disabled:s===w,className:"h-7 w-7 p-0",children:(0,D.jsx)(U,{className:"h-3 w-3"})}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",onClick:()=>l(w),disabled:s===w,className:"h-7 w-7 p-0",children:(0,D.jsx)(et,{className:"h-3 w-3"})})]})]})]}):(0,D.jsxs)("div",{className:"p-6 border border-dashed border-border rounded-lg text-center",children:[(0,D.jsx)(B,{className:"w-6 h-6 mx-auto mb-2 text-muted-foreground"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:a?"No mental models match your filter":"No mental models yet. Create a mental model to generate and save a summary from your memories."})]})]}),(0,D.jsx)(y5,{open:c,onClose:()=>u(!1),onCreated:()=>{u(!1),y()}}),(0,D.jsx)(hg,{open:!!p,onOpenChange:e=>!e&&f(null),children:(0,D.jsxs)(hM,{children:[(0,D.jsxs)(hP,{children:[(0,D.jsx)(hL,{children:"Delete Mental Model"}),(0,D.jsxs)(hI,{children:["Are you sure you want to delete"," ",(0,D.jsxs)("span",{className:"font-semibold",children:['"',p?.name,'"']}),"?",(0,D.jsx)("br",{}),(0,D.jsx)("br",{}),(0,D.jsx)("span",{className:"text-destructive font-semibold",children:"This action cannot be undone."})]})]}),(0,D.jsxs)(hR,{className:"flex-row justify-end space-x-2",children:[(0,D.jsx)(hB,{className:"mt-0",children:"Cancel"}),(0,D.jsxs)(hO,{onClick:b,disabled:g,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[g?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):null,"Delete"]})]})]})}),d&&(0,D.jsx)(y3,{mentalModel:d,onClose:()=>h(null),onDelete:()=>f({id:d.id,name:d.name}),onRefreshed:e=>{n(t=>t.map(t=>t.id===e.id?e:t)),h(e)}})]})}function y5({open:e,onClose:t,onCreated:n}){let{currentBank:r}=(0,L.useBank)(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),l=async()=>{if(r&&o.name.trim()&&o.sourceQuery.trim()){a(!0);try{let e=o.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0),t=parseInt(o.maxTokens)||2048;await q.client.createMentalModel(r,{name:o.name.trim(),source_query:o.sourceQuery.trim(),tags:e.length>0?e:void 0,max_tokens:t}),s({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),n()}catch(e){console.error("Error creating mental model:",e),alert("Error creating mental model: "+e.message)}finally{a(!1)}}};return(0,D.jsx)(tl.Dialog,{open:e,onOpenChange:e=>{e||(s({name:"",sourceQuery:"",maxTokens:"2048",tags:""}),t())},children:(0,D.jsxs)(tl.DialogContent,{className:"sm:max-w-lg",children:[(0,D.jsxs)(tl.DialogHeader,{children:[(0,D.jsx)(tl.DialogTitle,{children:"Create Mental Model"}),(0,D.jsx)(tl.DialogDescription,{children:"Create a mental model by running a query. The content will be auto-generated and can be refreshed later."})]}),(0,D.jsxs)("div",{className:"space-y-4 py-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Name *"}),(0,D.jsx)(K.Input,{value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:"e.g., Team Communication Preferences"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Source Query *"}),(0,D.jsx)(K.Input,{value:o.sourceQuery,onChange:e=>s({...o,sourceQuery:e.target.value}),placeholder:"e.g., How does the team prefer to communicate?"}),(0,D.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,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Max Tokens"}),(0,D.jsx)(K.Input,{type:"number",value:o.maxTokens,onChange:e=>s({...o,maxTokens:e.target.value}),placeholder:"2048",min:"256",max:"8192"}),(0,D.jsx)("p",{className:"text-xs text-muted-foreground",children:"Maximum tokens for the generated response (256-8192)."})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsxs)("label",{className:"text-sm font-medium text-foreground",children:["Tags ",(0,D.jsx)("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),(0,D.jsx)(K.Input,{value:o.tags,onChange:e=>s({...o,tags:e.target.value}),placeholder:"e.g., project-x, team-alpha (comma-separated)"})]})]}),(0,D.jsxs)(tl.DialogFooter,{children:[(0,D.jsx)($.Button,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),(0,D.jsx)($.Button,{onClick:l,disabled:i||!o.name.trim()||!o.sourceQuery.trim(),children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}),"Generating..."]}):"Create"})]})]})})}function y3({mentalModel:e,onClose:t,onDelete:n,onRefreshed:r}){let{currentBank:i}=(0,L.useBank)(),[a,o]=(0,R.useState)(!1),[s,l]=(0,R.useState)(null),[c,u]=(0,R.useState)(!1),[d,h]=(0,R.useState)(e.name),[p,f]=(0,R.useState)(!1);(0,R.useEffect)(()=>{h(e.name),u(!1)},[e.id,e.name]);let g=async()=>{if(!i)return;o(!0);let t=e.last_refreshed_at;try{await q.client.refreshMentalModel(i,e.id);let n=0,a=async()=>{n++;try{let s=await q.client.getMentalModel(i,e.id);if(s.last_refreshed_at!==t){r(s),o(!1);return}if(n>=120){o(!1),alert("Refresh is taking longer than expected. Check the operations list for status.");return}setTimeout(a,1e3)}catch(e){console.error("Error polling mental model:",e),o(!1)}};setTimeout(a,1e3)}catch(e){console.error("Error refreshing mental model:",e),alert("Error refreshing: "+e.message),o(!1)}},v=async()=>{if(i&&d.trim()){f(!0);try{let t=await q.client.updateMentalModel(i,e.id,{name:d.trim()});r(t),u(!1)}catch(e){console.error("Error updating mental model:",e),alert("Error updating: "+e.message)}finally{f(!1)}}},x=e=>{let t=new Date(e);return`${t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} at ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}`},y=e.reflect_response?.based_on?Object.entries(e.reflect_response.based_on).filter(([e])=>"observation"!==e).flatMap(([e,t])=>t.map(t=>({...t,factType:e}))):[],b=e.reflect_response?.based_on?.observation||[];return(0,D.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,D.jsxs)("div",{className:"p-6",children:[(0,D.jsxs)("div",{className:"flex justify-between items-start mb-8 pb-5 border-b border-border",children:[(0,D.jsx)("div",{className:"flex-1 mr-4",children:c?(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(K.Input,{value:d,onChange:e=>h(e.target.value),className:"text-lg font-bold",autoFocus:!0}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsxs)($.Button,{size:"sm",onClick:v,disabled:p||!d.trim(),children:[p?(0,D.jsx)(ts,{className:"w-3 h-3 animate-spin mr-1"}):null,"Save"]}),(0,D.jsx)($.Button,{size:"sm",variant:"outline",onClick:()=>{h(e.name),u(!1)},children:"Cancel"})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("h3",{className:"text-xl font-bold text-foreground",children:e.name}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"h-7 w-7 p-0",children:(0,D.jsx)(yK,{className:"h-3.5 w-3.5"})})]}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e.source_query})]})}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsxs)($.Button,{variant:"outline",size:"sm",onClick:g,disabled:a,className:"h-8",children:[a?(0,D.jsx)(ts,{className:"w-4 h-4 animate-spin mr-1"}):(0,D.jsx)(en,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(0,D.jsx)($.Button,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,D.jsx)(to.X,{className:"h-4 w-4"})})]})]}),(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Content"}),(0,D.jsx)("div",{className:"prose prose-base dark:prose-invert max-w-none",children:(0,D.jsx)(xl,{children:e.content})})]}),y.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Based On (",y.length," ",1===y.length?"fact":"facts",")"]}),(0,D.jsx)("div",{className:"space-y-3",children:y.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${"world"===e.factType?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"experience"===e.factType?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-purple-500/10 text-purple-600 dark:text-purple-400"}`,children:e.factType}),(0,D.jsx)($.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>l(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t))})]}),b.length>0&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsxs)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:["Observations Used (",b.length,")"]}),(0,D.jsx)("div",{className:"space-y-3",children:b.map((e,t)=>(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,D.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,D.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,D.jsx)($.Button,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>l(e.id),children:"View"})]}),(0,D.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.text})]},e.id||t))})]}),!e.reflect_response&&(0,D.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,D.jsx)("div",{className:"text-xs font-bold text-muted-foreground uppercase mb-3",children:"Based On"}),(0,D.jsx)("p",{className:"text-sm text-muted-foreground",children:'No source data available. Click "Refresh" to regenerate with source tracking.'})]}),e.tags&&e.tags.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Tags"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-2",children:e.tags.map(e=>(0,D.jsx)("span",{className:"px-2 py-1 rounded bg-muted text-muted-foreground text-sm",children:e},e))})]}),(0,D.jsxs)("div",{className:"flex gap-6 text-sm text-muted-foreground",children:[(0,D.jsxs)("span",{children:["Created: ",x(e.created_at)]}),(0,D.jsxs)("span",{children:["Refreshed: ",x(e.last_refreshed_at)]})]}),(0,D.jsxs)("div",{className:"p-4 bg-muted/50 rounded-lg",children:[(0,D.jsx)("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"ID"}),(0,D.jsx)("code",{className:"text-sm font-mono break-all text-muted-foreground",children:e.id})]}),(0,D.jsx)("div",{className:"pt-4 border-t border-border",children:(0,D.jsxs)($.Button,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive hover:border-destructive",children:[(0,D.jsx)(hF,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]}),s&&i&&(0,D.jsx)(tp,{memoryId:s,onClose:()=>l(null)})]})}function y4(){let e=(0,M.useParams)(),t=(0,M.useRouter)(),n=(0,M.useSearchParams)(),{features:r}=(0,xm.useFeatures)(),i=e.bankId,a=n.get("view")||"profile",o=n.get("subTab")||"world",s=r?.observations??!1,l=e=>{t.push(`/banks/${i}?view=data&subTab=${e}`)};return(0,D.jsxs)("div",{className:"min-h-screen bg-background flex flex-col",children:[(0,D.jsx)(P.BankSelector,{}),(0,D.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,D.jsx)(W,{currentTab:a,onTabChange:e=>{t.push(`/banks/${i}?view=${e}`)}}),(0,D.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,D.jsxs)("div",{className:"p-6",children:["profile"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Bank Profile"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and edit the memory bank profile, disposition traits, and background information."}),(0,D.jsx)(yJ,{})]}),"recall"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Recall"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Analyze memory recall with detailed trace information and retrieval methods."}),(0,D.jsx)(xg,{})]}),"reflect"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Reflect"}),(0,D.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,D.jsx)(xp,{})]}),"data"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Memories"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"View and explore different types of memories stored in this memory bank."}),(0,D.jsx)("div",{className:"mb-6 border-b border-border",children:(0,D.jsxs)("div",{className:"flex gap-1",children:[(0,D.jsxs)("button",{onClick:()=>l("world"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"world"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["World Facts","world"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("experience"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"experience"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Experience","experience"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("observations"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"observations"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Observations",!s&&(0,D.jsx)("span",{className:"ml-2 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Off"}),"observations"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]}),(0,D.jsxs)("button",{onClick:()=>l("mental-models"),className:`px-6 py-3 font-semibold text-sm transition-all relative ${"mental-models"===o?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:["Mental Models","mental-models"===o&&(0,D.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]})]})}),(0,D.jsxs)("div",{children:["world"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Objective facts about the world received from external sources."}),(0,D.jsx)(hs,{factType:"world"},"world")]}),"experience"===o&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"The bank's own actions, interactions, and first-person experiences."}),(0,D.jsx)(hs,{factType:"experience"},"experience")]}),"observations"===o&&(s?(0,D.jsxs)("div",{children:[(0,D.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,D.jsx)(hs,{factType:"observation"},"observations")]}):(0,D.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,D.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,D.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,D.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Z"}),(0,D.jsx)("path",{d:"M12 8v4"}),(0,D.jsx)("path",{d:"M12 16h.01"})]})}),(0,D.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"Observations Not Enabled"}),(0,D.jsxs)("p",{className:"text-sm text-muted-foreground max-w-md",children:["Observations consolidation is disabled on this server. Set"," ",(0,D.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"HINDSIGHT_API_ENABLE_OBSERVATIONS=true"})," ","to enable."]})]})),"mental-models"===o&&(0,D.jsxs)("div",{children:[(0,D.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,D.jsx)(y2,{},"mental-models")]})]})]}),"documents"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Documents"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Manage documents and retain new memories."}),(0,D.jsx)(hz,{})]}),"entities"===a&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Entities"}),(0,D.jsx)("p",{className:"text-muted-foreground mb-6",children:"Explore entities (people, organizations, places) mentioned in memories."}),(0,D.jsx)(hV,{})]})]})})]})]})}e.s(["default",()=>y4],37578)}]);