1import{j as e}from"./vendor-query-DCEy32gT.js";import{a as r}from"./vendor-react-DQQd_tv7.js";import{c as B,bi as P,bA as U,aY as A,a2 as z,Z as C,aE as i,aF as m,aP as y,aG as u,aH as g,aK as E,aL as D,aM as M,aN as k,aI as H,T as O,aJ as V,h as R,aj as T,ak as W,ad as F,aO as _}from"./index-BLMWtrsz.js";import{L as K}from"./lightbulb-CO-aOQSB.js";import"./vendor-pdf-Bs2G1MsY.js";import"./vendor-charts-DQlLoY8T.js";import"./vendor-dnd-CEOzIhnA.js";import"./vendor-cmdk-DZOUNnSX.js";import"./vendor-date-DvNbr4u3.js";import"./vendor-canvas-BALaVOQn.js";import"./vendor-panels-BoPcG2Ma.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const q=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Z=B("Building",q);function G({organizationId:c}){const[h,o]=r.useState({}),[N,p]=r.useState(!0),[l,b]=r.useState({});r.useEffect(()=>{(async()=>{try{const s=["ai","organization","project","estimator","subcontractor","procurement","workflow"],a={};let d=0;for(const j of s)a[j]=[];o(a),b({total:d})}catch(s){console.error("Failed to load memories:",s)}finally{p(!1)}})()},[c]);const f=[{id:"ai",label:"AI Memory",icon:P,description:"AI execution patterns & decisions"},{id:"organization",label:"Organization",icon:Z,description:"Company-wide knowledge"},{id:"project",label:"Projects",icon:U,description:"Project outcomes & lessons"},{id:"estimator",label:"Estimators",icon:A,description:"Estimation patterns & insights"},{id:"subcontractor",label:"Subcontractors",icon:A,description:"Vendor performance"},{id:"procurement",label:"Procurement",icon:z,description:"Supply chain intelligence"},{id:"workflow",label:"Workflows",icon:C,description:"Process optimizations"}];return N?e.jsx("div",{className:"animate-pulse h-96 bg-slate-200 rounded"}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Construction Operating Memory"}),e.jsx("p",{className:"text-slate-600",children:"Persistent organizational intelligence that compounds over time"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:f.map(t=>{var d;const s=t.icon,a=((d=h[t.id])==null?void 0:d.length)||0;return e.jsxs(i,{className:"cursor-pointer hover:border-primary transition-colors",children:[e.jsxs(m,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(s,{className:"w-5 h-5 text-primary"}),e.jsx(y,{variant:"secondary",children:a})]}),e.jsx(u,{className:"text-sm",children:t.label})]}),e.jsx(g,{children:e.jsx("p",{className:"text-xs text-slate-600",children:t.description})})]},t.id)})}),e.jsxs(E,{defaultValue:"ai",className:"w-full",children:[e.jsx(D,{className:"grid w-full grid-cols-7",children:f.map(t=>e.jsx(M,{value:t.id,className:"text-xs",children:t.label},t.id))}),f.map(t=>{var s;return e.jsx(k,{value:t.id,className:"space-y-4 mt-6",children:((s=h[t.id])==null?void 0:s.length)>0?e.jsx("div",{className:"space-y-3",children:h[t.id].slice(0,10).map((a,d)=>{var j;return e.jsx(i,{className:"border-l-4 border-l-blue-500",children:e.jsx(m,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:a.title}),e.jsxs("p",{className:"text-xs text-slate-600 mt-1",children:[(j=a.description)==null?void 0:j.substring(0,100),"..."]})]}),a.confidence_score&&e.jsxs(y,{variant:"outline",children:[(a.confidence_score*100).toFixed(0),"%"]})]})})},d)})}):e.jsx(i,{className:"border-dashed text-center py-8",children:e.jsxs("p",{className:"text-slate-600",children:["No ",t.label.toLowerCase()," memories yet"]})})},t.id)})]})]})}function J({task:c,projectId:h,estimatorEmail:o,subcontractorId:N,tradeModules:p=[]}){var s,a,d,j,v,w,I;const[l,b]=r.useState(null),[f,t]=r.useState(!1);return r.useEffect(()=>{(async()=>
6{if(c){t(!0);try{const x=await R.functions.invoke("contextualMemoryLookup",{currentTask:c,projectId:h,estimatorEmail:o,subcontractorId:N,tradeModules:p});b(x.data.contextualMemories)}catch(x){console.error("Failed to load contextual memory:",x)}finally{t(!1)}}})()},[c,h,o,N,p]),l?e.jsxs("div",{className:"space-y-4",children:[((s=l.warnings)==null?void 0:s.length)>0&&e.jsxs(H,{className:"border-red-200 bg-red-50",children:[e.jsx(O,{className:"w-4 h-4 text-red-600"}),e.jsxs(V,{className:"text-red-800",children:[e.jsxs("p",{className:"font-semibold mb-2",children:["Historical Warnings (",l.warnings.length,")"]}),e.jsx("ul",{className:"space-y-1 text-sm",children:l.warnings.slice(0,3).map((n,x)=>{var S,L;return e.jsxs("li",{className:"text-red-700",children:["⢠",((S=n.cautions)==null?void 0:S[0])||n.bottleneck||((L=n.risks)==null?void 0:L[0])]},x)})})]})]}),((a=l.patterns)==null?void 0:a.length)>0&&e.jsxs(i,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"})," Historical Patterns"]})}),e.jsx(g,{className:"space-y-2",children:l.patterns.slice(0,3).map((n,x)=>{var S;return e.jsxs("div",{className:"p-2 bg-slate-50 rounded text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-700",children:n.type}),e.jsxs("p",{className:"text-xs text-slate-600 mt-1",children:[(S=n.description)==null?void 0:S.substring(0,80),"..."]})]},x)})})]}),((d=l.relevant)==null?void 0:d.length)>0&&e.jsxs(i,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm flex items-center gap-2",children:[e.jsx(K,{className:"w-4 h-4"})," Relevant Knowledge"]})}),e.jsx(g,{className:"space-y-2 max-h-64 overflow-y-auto",children:l.relevant.slice(0,5).map((n,x)=>e.jsxs("div",{className:"p-2 border border-slate-200 rounded text-xs",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx(y,{variant:"secondary",children:n.type}),n.confidence&&e.jsxs("span",{className:"text-slate-500",children:[(n.confidence*100).toFixed(0),"%"]})]}),e.jsx("p",{className:"text-slate-700",children:n.content||n.description||n.title})]},x))})]}),((j=l.recommendations)==null?void 0:j.length)>0&&e.jsxs(i,{className:"border-blue-200 bg-blue-50",children:[e.jsx(m,{className:"pb-2",children:e.jsx(u,{className:"text-sm text-blue-900",children:"Based on History"})}),e.jsx(g,{children:e.jsx("ul",{className:"space-y-1 text-sm text-blue-900",children:l.recommendations.map((n,x)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-600 font-semibold mt-0.5",children:"â"}),e.jsx("span",{children:n})]},x))})})]}),!((v=l.relevant)!=null&&v.length)&&!((w=l.warnings)!=null&&w.length)&&!((I=l.patterns)!=null&&I.length)&&e.jsx(i,{className:"border-dashed text-center py-4",children:e.jsx("p",{className:"text-sm text-slate-600",children:"No historical context available for this task"})})]}):null}function Q(){const[c,h]=r.useState(""),[o,N]=r.useState([]),[p,l]=r.useState(!1),[b,f]=r.useState(!1),t=async s=>{if(s.preventDefault(),!!c.trim()){l(!0);try{const a=await R.functions.invoke("semanticMemorySearch",{query:c});N(a.data.results||[]),f(!0)}catch(a){console.error("Search failed:",a),N([])}finally{l(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:t,className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(T,{className:"absolute left-3 top-3 w-4 h-4 text-slate-400"}),e.jsx(W,{placeholder:"Search organizational memory (patterns, vendor insights, lessons learned...)",value:c,onChange:s=>h(s.target.value),className:"pl-10"})]}),e.jsx(F,{type:"submit",className:"w-full",disabled:p||!c.trim(),children:p?"Searching...":"Search Memory"})]}),b&&o.length===0&&!p&&e.jsx(i,{className:"border-dashed text-center py-8",children:e.jsxs("p",{className:"text-slate-600",children:['No memories found for "',c,'"']})}),e.jsx("div",{className:"space-y-3",children:o.slice(0,10).map((s,a)=>{var d,j,v,w;return e.jsxs(i,{className:"border-l-4 border-l-blue-500 hover:shadow-md transition-shadow",children:[e.jsx(m,{className:"pb-2",children:e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(y,{variant:"secondary",className:"text-xs",children:s.entityType.replace("Memory","")}),e.jsx(y,{variant:"outline",className:"text-xs text-blue-600",children:s.matchScore})]}),((d=s.memory)==null?void 0:d.title)&&e.jsx("p",{className:"font-semibold text-sm",children:s.memory.title})]})})}),e.jsxs(g,{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm text-slate-700",children:[(v=(j=s.memory)==null?void 0:j.description)==null?void 0:v.substring(0,150),"..."]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-600",children:[e.jsx("span",{children:s.relevanceReason}),((w=s.memory)==null?void 0:w.created_date)&&e.jsxs("span",{children:["Updated ",new Date(s.memory.created_date).toLocaleDateString()]})]})]})]},a)})}),b&&o.length>0&&e.jsxs(i,{className:"bg-slate-50",children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm flex items-center gap-2",children:[e.jsx(C,{className:"w-4 h-4"})," Search Insights"]})}),e.jsx(g,{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-600 mb-2",children:"Related Categories"}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:o.slice(0,5).map((s,a)=>e.jsx(y,{variant:"outline",className:"text-xs",children:s.entityType.replace("Memory","")},a))})]})})]})]})}function ie(){const[c,h]=r.useState(null),[o,N]=r.useState("estimate_creation"),[p,l]=r.useState(null),[b,f]=r.useState(!0);r.useEffect(()=>{(async()=>{try{const a=await R.auth.me();h(a)}catch(a){console.error("Failed to load user:",a)}finally{f(!1)}})()},[]);const t=[{id:"estimate_creation",label:"Estimate Creation",icon:"ð"},{id:"subcontractor_selection",label:"Subcontractor Selection",icon:"ð¥"},{id:"procurement",label:"Procurement",icon:"ð¦"},{id:"workflow_execution",label:"Workflow Execution",icon:"âï¸"},{id:"schedule_planning",label:"Schedule Planning",icon:"ð
"}];return b?e.jsx("div",{className:"animate-pulse h-96 bg-slate-200 rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-4xl font-bold flex items-center gap-3",children:[e.jsx(P,{className:"w-8 h-8 text-blue-600"}),"Construction Operating Memory System"]}),e.jsx("p",{className:"text-slate-600 mt-2",children:"Persistent organizational intelligence that c
6ompounds over time, eliminating repetitive work and maintaining historical context"})]}),e.jsxs(E,{defaultValue:"dashboard",className:"w-full",children:[e.jsxs(D,{className:"grid w-full grid-cols-4",children:[e.jsxs(M,{value:"dashboard",className:"flex items-center gap-2",children:[e.jsx(P,{className:"w-4 h-4"})," Dashboard"]}),e.jsxs(M,{value:"contextual",className:"flex items-center gap-2",children:[e.jsx(C,{className:"w-4 h-4"})," Contextual Memory"]}),e.jsxs(M,{value:"search",className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-4 h-4"})," Semantic Search"]}),e.jsxs(M,{value:"architecture",className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"})," Architecture"]})]}),e.jsx(k,{value:"dashboard",className:"mt-6",children:e.jsx(G,{organizationId:c==null?void 0:c.organization_id})}),e.jsxs(k,{value:"contextual",className:"mt-6 space-y-4",children:[e.jsx(i,{children:e.jsxs(m,{children:[e.jsxs(u,{className:"text-base flex items-center gap-2",children:[e.jsx(C,{className:"w-4 h-4"})," Context-Aware Memory Retrieval"]}),e.jsx(_,{children:"Automatically surface relevant memories based on your current task"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:"Select Current Task"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:t.map(s=>e.jsxs(F,{variant:o===s.id?"default":"outline",onClick:()=>N(s.id),className:"text-xs h-auto py-2",children:[e.jsx("span",{className:"mr-1",children:s.icon}),s.label]},s.id))})]}),e.jsx(J,{task:o,projectId:p})]}),e.jsx(k,{value:"search",className:"mt-6",children:e.jsxs(i,{children:[e.jsxs(m,{children:[e.jsxs(u,{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-4 h-4"})," Semantic Memory Search"]}),e.jsx(_,{children:"Search across all organizational memories using natural language"})]}),e.jsx(g,{children:e.jsx(Q,{})})]})}),e.jsxs(k,{value:"architecture",className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(i,{children:[e.jsx(m,{children:e.jsx(u,{className:"text-base",children:"Memory Layers"})}),e.jsx(g,{className:"space-y-3",children:[{name:"AI Memory",desc:"System execution patterns"},{name:"Organization Memory",desc:"Company-wide knowledge"},{name:"Project Memory",desc:"Project outcomes and lessons"},{name:"Estimator Memory",desc:"Bias correction and insights"},{name:"Subcontractor Memory",desc:"Vendor performance"},{name:"Procurement Memory",desc:"Supply chain intelligence"},{name:"Workflow Memory",desc:"Process optimizations"}].map((s,a)=>e.jsxs("div",{className:"p-2 border border-slate-200 rounded",children:[e.jsx("p",{className:"font-semibold text-sm",children:s.name}),e.jsx("p",{className:"text-xs text-slate-600",children:s.desc})]},a))})]}),e.jsxs(i,{children:[e.jsx(m,{children:e.jsx(u,{className:"text-base",children:"Retrieval Systems"})}),e.jsx(g,{className:"space-y-3",children:[{name:"Contextual Retrieval",desc:"Task-aware memory lookup"},{name:"Semantic Search",desc:"Vector-based similarity search"},{name:"Historical Reference",desc:"Time-bound lookups"},{name:"Project Intelligence",desc:"Project-scoped memories"},{name:"Pattern Matching",desc:"Similarity-based discovery"},{name:"Relevance Ranking",desc:"Importance-based sorting"},{name:"Usage Tracking",desc:"Frequency-weighted results"}].map((s,a)=>e.jsxs("div",{className:"p-2 border border-slate-200 rounded",children:[e.jsx("p",{className:"font-semibold text-sm",children:s.name}),e.jsx("p",{className:"text-xs text-slate-600",children:s.desc})]},a))})]})]}),e.jsxs(i,{children:[e.jsx(m,{children:e.jsx(u,{className:"text-base",children:"System Capabilities"})}),e.jsx(g,{children:e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Persistent Context:"})," All memories stored and retrievable"]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Knowledge Compounding:"})," Memories build on each other over time"]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Reduced Repetition:"})," AI avoids recalculating known patterns"]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Historical Continuity:"})," Full project and org context"]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Contextual Intelligence:"})," Right memory at the right time"]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-600 font-bold",children:"â"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Semantic Discovery:"})," Find related knowledge across boundaries"]})]})]})})]})]})]})]})}export{ie as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.