1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6686],{738:(e,t,a)=>{a.d(t,{w:()=>i});var s=a(95155),n=a(12115),l=a(57268),r=a(49498);let i=n.forwardRef(({className:e,orientation:t="horizontal",decorative:a=!0,...n},i)=>(0,s.jsx)(l.b,{ref:i,decorative:a,orientation:t,className:(0,r.cn)("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...n}));i.displayName=l.b.displayName},4186:(e,t,a)=>{a.d(t,{CZ:()=>u,KY:()=>o,LX:()=>d,UE:()=>c,cc:()=>i,gw:()=>h,vC:()=>m});var s=a(95155),n=a(12115),l=a(49498),r=a(52201);let i=(0,n.forwardRef)(({variant:e="primary",size:t="md",children:a,className:n="",leftIcon:l,rightIcon:i,...d},c)=>(0,s.jsx)(r.l_y,{ref:c,variant:{primary:"primary",secondary:"secondary",ghost:"ghost",danger:"danger",outline:"outline"}[e]||e,size:{sm:"sm",md:"default",lg:"lg"}[t]||t,leftIcon:l,rightIcon:i,className:n,...d,children:a}));function d({variant:e="default",children:t,className:a="",icon:n}){return(0,s.jsxs)(r.ARm,{variant:e,className:a,children:[n&&(0,s.jsx)("span",{className:"mr-1",children:n}),t]})}i.displayName="ThemedButton";let c=(0,n.forwardRef)(({readOnly:e=!1,className:t="",...a},n)=>(0,s.jsx)(r.P6t,{ref:n,readOnly:e,disabled:e,className:t,...a}));c.displayName="ThemedInput";let o=(0,n.forwardRef)(({readOnly:e=!1,className:t="",...a},n)=>(0,s.jsx)(r.rUX,{ref:n,readOnly:e,disabled:e,className:(0,l.cn)("min-h-[80px]",t),...a}));o.displayName="ThemedTextarea";let u=(0,n.forwardRef)(({className:e="",children:t,...a},n)=>(0,s.jsx)(r.hMb,{ref:n,className:e,...a,children:t}));u.displayName="ThemedSelect";let m=(0,n.forwardRef)(({label:e,className:t="",onCheckedChange:a,checked:n,defaultChecked:l,disabled:i,onClick:d,onChange:c,...o},u)=>(0,s.jsx)(r.EDT,{ref:u,checked:n,onChange:e=>{a&&a(e),c&&c({target:{checked:e}})},disabled:i,label:e,className:t,...o}));m.displayName="ThemedCheckbox";let h=(0,n.forwardRef)(({className:e="",...t},a)=>(0,s.jsx)(r.hdZ,{ref:a,className:e,...t}));h.displayName="ThemedSearchInput"},15392:(e,t,a)=>{a.d(t,{k:()=>i});var s=a(95155),n=a(12115),l=a(98215),r=a(49498);let i=n.forwardRef(({className:e,value:t,indicatorClassName:a,...n},i)=>(0,s.jsx)(l.bL,{ref:i,className:(0,r.cn)("relative h-4 w-full overflow-hidden rounded-full bg-gray-800",e),...n,children:(0,s.jsx)(l.C1,{className:(0,r.cn)("h-full w-full flex-1 bg-primary transition-all",a),style:{transform:`translateX(-${100-(t||0)}%)`}})}));i.displayName=l.bL.displayName},17174:(e,t,a)=>{a.d(t,{H:()=>m,u:()=>h});var s=a(95155),n=a(12115),l=a(20421),r=a(88793),i=a(20523),d=a(52056),c=a(61362),o=a(36624),u=a(90843);
1function m(){let[e,t]=(0,n.useState)(null),[a,m]=(0,n.useState)(!0),[h,p]=(0,n.useState)(null),g=(0,o.useAuthenticatedApi)(),{isLoading:x,startupId:f}=(0,u.Z2)();(0,n.useEffect)(()=>{!x&&f&&w()},[x,f]);let w=async()=>{try{let e=await g.get("/api/knowledge/storage/usage"),a=e.data||e;if(a&&a.detail)throw Error(a.detail);if(!a||!a.usage||!a.limit||"number"!=typeof a.percentage_used)throw Error("Invalid storage data format");a.ui||(a.ui={message:`${a.usage.formatted} / ${a.limit.formatted}`,status:a.percentage_used>=95?"error":a.percentage_used>=80?"warning":"success",show_upgrade_prompt:!1}),t(a),p(null)}catch(e){p(e instanceof Error?e.message:"Failed to load storage info")}finally{m(!1)}};return a?(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-4 w-4 animate-pulse"}),(0,s.jsx)("span",{children:"Loading storage info..."})]}):h?(0,s.jsxs)("div",{className:"text-sm text-red-500",children:["Error loading storage info: ",h]}):e?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(i.A,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs sm:text-sm font-medium",children:"Knowledge Storage"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(()=>{switch(e.ui.status){case"error":return(0,s.jsx)(d.A,{className:"h-4 w-4 text-destructive"});case"warning":return(0,s.jsx)(d.A,{className:"h-4 w-4 text-yellow-500"});default:return(0,s.jsx)(c.A,{className:"h-4 w-4 text-green-500"})}})(),(0,s.jsxs)("span",{className:"text-xs sm:text-sm text-muted-foreground",children:[e.usage.formatted," / ",e.limit.formatted]})]})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700",children:(0,s.jsx)("div",{className:`h-2 rounded-full transition-all ${e.percentage_used>=95?"bg-red-600":e.percentage_used>=80?"bg-yellow-500":"bg-green-600"}`,style:{width:`${Math.min(e.percentage_used,100)}%`}})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.ui.message})]}),e.ui.show_upgrade_prompt&&(0,s.jsxs)(l.Fc,{className:"error"===e.ui.status?"border-destructive":"border-yellow-500",children:[(0,s.jsx)(d.A,{className:"h-4 w-4"}),(0,s.jsxs)(l.TN,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[(0,s.jsx)("span",{className:"text-xs sm:text-sm",children:e.ui.upgrade_message||"Upgrade for more storage"}),(0,s.jsx)(r.Button,{size:"sm",variant:"outline",onClick:()=>window.location.href="/settings/billing",className:"w-full sm:w-auto",children:"Upgrade"})]})]}),!e.can_upload&&(0,s.jsxs)(l.Fc,{className:"border-destructive",children:[(0,s.jsx)(d.A,{className:"h-4 w-4"}),(0,s.jsx)(l.TN,{className:"text-xs sm:text-sm",children:"Storage limit reached. Please delete some documents or upgrade your plan to continue uploading."})]})]}):(0,s.jsx)("div",{className:"text-sm text-gray-500",children:"No storage data available"})}function h(){let[e,t]=(0,n.useState)(null),a=(0,o.useAuthenticatedApi)(),{isLoading:l,startupId:r}=(0,u.Z2)();if((0,n.useEffect)(()=>{let e=async()=>{try{let e=await a.get("/api/knowledge/storage/usage"),s=e.data||e;t(s)}catch(e){}};!l&&r&&e()},[l,r]),!e)return null;let d=()=>e.percentage_used>=95?"text-destructive":e.percentage_used>=80?"text-yellow-500":"text-muted-foreground";return(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-xs",children:[(0,s.jsx)(i.A,{className:`h-3 w-3 ${d()}`}),(0,s.jsxs)("span",{className:d(),children:[e.percentage_used.toFixed(0),"% used"]})]})}},43781:(e,t,a)=>{a.d(t,{M:()=>n});var s=a(60867);let n={async listKnowledgeChunks(e={}){let t=new URLSearchParams;Object.entries(e).forEach(([e,a])=>{null!=a&&""!==a&&t.append(e,a)});let a=`/api/knowledgechunk/${t.toString()?`?${t.toString()}`:""}`;return s.api.get(a)},getKnowledgeChunk:async e=>s.api.get(`/api/knowledgechunk/${e}`),createKnowledgeChunk:async e=>s.api.post("/api/knowledgechunk/",e),updateKnowledgeChunk:async(e,t)=>s.api.put(`/api/knowledgechunk/${e}`,t),deleteKnowledgeChunk:async e=>s.api.delete(`/api/knowledgechunk/${e}`),async getAgentEffectiveKnowledge(e,t=null){let a=new URLSearchParams;t&&a.append("limit",t);let n=`/api/knowledge/agent/${e}/effective${a.toString()?`?${a.toString()}`:""}`;return s.api.get(n)},async getTeamEffectiveKnowledge(e,t=null){let a=new URLSearchParams;t&&a.append("limit",t);let n=`/api/knowledge/team/${e}/effective${a.toString()?`?${a.toString()}`:""}`;return s.api.get(n)},async getGlobalKnowledge(){let e=await this.listKnowledgeChunks();return(Array.isArray(e)?e:e.data||[]).filter(e=>!e.agent_id&&!e.team_id)},async getTeamKnowledge(e){return this.listKnowledgeChunks({team_id:e,agent_id:"null"})},async getAgentKnowledge(e){return this.listKnowledgeChunks({agent_id:e})},async searchKnowledge(e,t={}){let a=new URLSearchParams;return a.append("q",e),t.agent_id&&a.append("agent_id",t.agent_id),t.team_id&&a.append("team_id",t.team_id),t.source_type&&a.append("source_type",t.source_type),t.limit&&a.append("limit",t.limit),s.api.get(`/api/knowledge/search?${a.toString()}`)},getKnowledgeStats:async()=>s.api.get("/api/knowledge/stats"),async bulkDeleteKnowledgeChunks(e){let t=new URLSearchParams;
1return t.append("operation","delete_chunks"),e.forEach(e=>t.append("ids",e)),s.api.post(`/api/knowledge/bulk?${t.toString()}`,{})},async bulkUpdateScope(e,t){let a=new URLSearchParams;return a.append("operation","update_scope"),e.forEach(e=>a.append("ids",e)),s.api.post(`/api/knowledge/bulk?${a.toString()}`,{scope:t})},createChunkedKnowledge:async e=>s.api.post("/api/knowledge/chunk-text",e),async previewChunks(e,t={}){let a=new URLSearchParams;return a.append("content",e),t.chunk_size&&a.append("chunk_size",t.chunk_size),t.chunk_overlap&&a.append("chunk_overlap",t.chunk_overlap),t.chunking_method&&a.append("chunking_method",t.chunking_method),s.api.get(`/api/knowledge/preview-chunks?${a.toString()}`)},rechunkKnowledge:async(e,t)=>s.api.post(`/api/knowledge/rechunk/${e}`,t)}},58055:(e,t,a)=>{a.d(t,{ST:()=>r,nr:()=>i,oh:()=>d});var s=a(95155);a(12115);var n=a(49498),l=a(52201);function r({open:e,onClose:t,title:a,description:r,icon:i,actions:d,children:c,className:o="",footer:u=null,maxWidth:m="max-w-2xl"}){return(0,s.jsxs)(l.MXq,{isOpen:e,onClose:t,side:"right",size:m?.includes("full")?"full":m?.includes("4xl")?"4xl":m?.includes("3xl")?"3xl":m?.includes("2xl")?"2xl":m?.includes("xl")?"xl":m?.includes("lg")?"lg":m?.includes("md")?"default":m?.includes("sm")?"sm":"2xl",showCloseButton:!1,className:(0,n.cn)("flex flex-col overflow-hidden",o),children:[(0,s.jsx)(l.MXq.Header,{children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,s.jsx)("span",{className:"text-primary",children:i}),(0,s.jsxs)("div",{children:[(0,s.jsx)(l.MXq.Title,{children:a}),r&&(0,s.jsx)(l.MXq.Description,{children:r})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[d,(0,s.jsx)("button",{onClick:t,className:"p-2 rounded-lg transition-colors text-muted-foreground hover:bg-primary/10 hover:text-foreground",children:(0,s.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M18 6 6 18"}),(0,s.jsx)("path",{d:"m6 6 12 12"})]})})]})]})}),(0,s.jsx)(l.MXq.Content,{children:c}),u&&(0,s.jsx)(l.MXq.Footer,{children:u})]})}function i({title:e,icon:t,children:a,className:l=""}){return(0,s.jsxs)("div",{className:(0,n.cn)("space-y-4",l),children:[e&&(0,s.jsxs)("h3",{className:"text-lg font-medium flex items-center text-foreground",children:[t&&(0,s.jsx)("span",{className:"mr-2 text-primary",children:t}),e]}),a]})}function d({label:e,sublabel:t,required:a=!1,children:l,className:r=""}){return(0,s.jsxs)("div",{className:(0,n.cn)("space-y-2",r),children:[e&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm font-medium text-muted-foreground",children:[e," ",a&&(0,s.jsx)("span",{className:"text-primary",children:"*"})]}),t&&(0,s.jsx)("p",{className:"text-xs mt-1 text-muted-foreground",children:t})]}),l]})}},76686:(e,t,a)=>{a.d(t,{A:()=>w});var s=a(95155),n=a(12115),l=a(15392);a(738);var r=a(58055),i=a(4186),d=a(59133),c=a(83622);a(43781);var o=a(36624);a(20508),a(91169),a(39068);var u=a(21786),m=a(50859),h=a(89715),p=a(35299),g=a(42529),x=a(6132),f=a(17174);function w({open:e,onClose:t,onSuccess:a,mode:w="file",editingDocument:y=null,agents:_=[],teams:k=[],defaultScope:j="global"}){let N=(0,o.useAuthenticatedApi)(),v=(0,c.v)(N),[b,C]=(0,n.useState)(!1),[S,D]=(0,n.useState)({title:"",content:"",description:"",source_type:"edit"===w?"text":w,scope:j,agent_id:null,team_id:null,url:"",file:null,file_data:null,metadata:{},enable_chunking:!0,chunk_size:1e3,chunk_overlap:200,chunking_method:"recursive"}),[A,$]=(0,n.useState)(!1),[L,K]=(0,n.useState)(!1),[E,z]=(0,n.useState)(0),[U,R]=(0,n.useState)(""),[T,q]=(0,n.use
1State)(""),[M,P]=(0,n.useState)(null),[F,X]=(0,n.useState)(!1),B=async e=>{try{return K(!0),((await v.getDocumentChunks(e.id)).chunks||[]).sort((e,t)=>(e.chunk_index||0)-(t.chunk_index||0)).map(e=>e.content).join("\n\n")}catch(e){return console.error("Failed to load document content:",e),""}finally{K(!1)}};(0,n.useEffect)(()=>{let t=async()=>{if(y){let e=await B(y);D({title:y.title||"",content:e,description:y.description||"",source_type:y.source_type||"text",scope:y.agent_id?"agent":y.team_id?"team":"global",agent_id:y.agent_id||null,team_id:y.team_id||null,url:y.source_url||y.meta?.url||"",file:null,file_data:null,metadata:y.meta||{},enable_chunking:(y.chunk_count||1)>1,chunk_size:y.chunk_size||1e3,chunk_overlap:y.chunk_overlap||200,chunking_method:y.chunk_method||"recursive"}),setTimeout(()=>{let e=document.querySelector("[data-sidebar-content]");e&&(e.scrollTop=0)},100)}else D({title:"",content:"",description:"",source_type:w,scope:j,agent_id:null,team_id:null,url:"",file:null,file_data:null,metadata:{},enable_chunking:!0,chunk_size:1e3,chunk_overlap:200,chunking_method:"recursive"});R(""),q(""),z(0)};e&&t()},[y,w,j,e]);let I=(e,t)=>{D(a=>({...a,[e]:t})),R("")},O=async e=>{let t=e.target.files[0];if(t){let a=[".mp3",".m4a",".wav",".ogg",".webm"].some(e=>t.name.toLowerCase().endsWith(e));if(t.size>(a?0x3200000:0xa00000)){let s=(t.size/1048576).toFixed(2);R(`File size (${s} MB) exceeds the maximum allowed size of ${a?50:10} MB. Please upload a smaller file.`),e.target.value="",D(e=>({...e,file:null,file_data:null}));return}X(!0),R("");let s=new FileReader;s.onload=()=>{let e=s.result.split(",")[1];D(a=>({...a,file:t,file_data:e,title:a.title||t.name,metadata:{...a.metadata,filename:t.name,filesize:t.size}})),X(!1)},s.onerror=e=>{console.error("Error reading file:",e),R("Failed to read file content"),X(!1)},s.readAsDataURL(t)}},G=async e=>{if(e&&e.preventDefault&&e.preventDefault(),S.title.trim()?"file"!==S.source_type||S.file_data||"edit"===w?"url"!==S.source_type||S.url.trim()?"text"!==S.source_type||S.content.trim()?"agent"!==S.scope||S.agent_id?"team"!==S.scope||!!S.team_id||(R("Please select a team"),!1):(R("Please select an agent"),!1):(R("Content is required"),!1):(R("URL is required"),!1):(R("Please select a file to upload"),!1):(R("Title is required"),!1)){$(!0),R(""),z(0);try{let e,s={title:S.title.trim(),content:S.content.trim(),description:S.description.trim()||null,source_type:S.source_type,source_url:"url"===S.source_type?S.url.trim():null,file_data:"file"===S.source_type?S.file_data:null,file_name:"file"===S.source_type&&S.file?S.file.name:null,agent_id:"agent"===S.scope?S.agent_id:null,team_id:"team"===S.scope?S.team_id:null,metadata:{...S.metadata,..."url"===S.source_type&&{url:S.url.trim()},...b&&{absorb_behavior:!0}},chunk_size:S.chunk_size,chunk_overlap:S.chunk_overlap,chunking_method:S.chunking_method};if("file"===S.source_type&&S.file){let e=setInterval(()=>{z(t=>t>=90?(clearInterval(e),90):t+10)},200)}if(y)try{await v.deleteDocument(y.id),e=await v.createDocument(s)}catch(t){console.warn("Failed to delete old document, creating new one:",t),e=await v.createDocument(s)}else e=await v.createDocument(s);z(100),e.chunks_created?q(`Document created successfully! Generated ${e.chunks_created} chunks.`):e.document?q("Document created successfully!"):q("edit"===w?"Knowledge updated successfully!":"Knowledge uploaded successfully!"),setTimeout(()=>{a?.(),t?.()},900)}catch(e){console.error("Failed to save knowledge:",e),R(e.response?.data?.detail||"Failed to save knowledge. Please try again."),z(0)}finally{$(!1)}}},W=(0,s.jsx)("div",{className:"p-6 border-t border-theme-light bg-white/50 dark:bg-gray-800/50",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(i.cc,{variant:"ghost",onClick:t,children:"Cancel"}),(0,s.jsxs)(i.cc,{variant:"primary",onClick:G,disabled:A,children:[A&&(0,s.jsx)(p.A,{className:"w-4 h-4 mr-2 animate-spin"}),"edit"===w?"Update Knowledge":"Upload Knowledge"]})]})});return(0,s.jsx)(d.lG,{open:e,onOpenChange:e=>{e||t()},children:(0,s.jsxs)(d.Cf,{className:"flex max-h-[85vh] max-w-2xl flex-col gap-0 overflow-hidden p-0",children:[(0,s.jsx)(d.c7,{className:"space-y-0 border-b border-border px-6 py-5 text-left",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(u.A,{className:"mt-0.5 h-5 w-5 shrink-0 text-primary",strokeWidth:1.5}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(d.L3,{className:"text-[18px] font-semibold leading-tight",style:{fontFamily:"var(--font-display)"},children:"edit"===w?"Edit Knowledge":"Add Knowledge"}),(0,s.jsx)(d.rr,{className:"mt-0.5 text-[13px] text-muted-foreground",children:"edit"===w?"Update
1knowledge information":"Upload content your Chief can learn from or reference"})]})]}),(0,s.jsx)("div",{className:"shrink-0",children:(0,s.jsx)(f.u,{})})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:(0,s.jsxs)("div",{className:"space-y-6",children:["edit"!==w&&(0,s.jsx)(r.nr,{title:"Source Type",children:(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:["file","text","url"].map(e=>(0,s.jsxs)(i.cc,{type:"button",variant:S.source_type===e?"primary":"secondary",size:"md",onClick:()=>I("source_type",e),className:"flex items-center justify-center gap-2 w-full",children:[(e=>{switch(e){case"file":return(0,s.jsx)(u.A,{className:"w-4 h-4"});case"url":return(0,s.jsx)(m.A,{className:"w-4 h-4"});default:return(0,s.jsx)(h.A,{className:"w-4 h-4"})}})(e),e.charAt(0).toUpperCase()+e.slice(1)]},e))})}),"edit"!==w&&(0,s.jsxs)("label",{className:"flex cursor-pointer select-none items-start gap-2.5",children:[(0,s.jsx)("input",{type:"checkbox",checked:b,onChange:e=>C(e.target.checked),className:"mt-0.5 h-4 w-4 shrink-0 cursor-pointer accent-[var(--primary)]"}),(0,s.jsxs)("span",{className:"text-[13px] leading-snug text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Learn how to work from this"})," â distill its principles into how I operate (you approve what I pick up), not just store it for reference."]})]}),(0,s.jsx)(r.oh,{label:"Title",required:!0,children:(0,s.jsx)(i.UE,{value:S.title,onChange:e=>I("title",e.target.value),placeholder:"Enter a descriptive title",className:"w-full",required:!0})}),(0,s.jsx)(r.oh,{label:"Description",children:(0,s.jsx)(i.KY,{value:S.description,onChange:e=>I("description",e.target.value),placeholder:"Optional description of the document content",className:"w-full",rows:2})}),"file"===S.source_type&&"edit"!==w&&(0,s.jsxs)(r.oh,{label:"File",required:!0,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i.cc,{type:"button",variant:"secondary",size:"md",onClick:()=>document.getElementById("file-input").click(),disabled:F,className:"min-w-[140px]",children:"Choose File"}),(0,s.jsx)("span",{className:"text-sm text-theme-muted",children:S.file?S.file.name:"No file chosen"})]}),(0,s.jsx)("input",{id:"file-input",type:"file",onChange:O,accept:".pdf,.txt,.md,.csv,.xlsx,.xls,.mp3,.m4a,.wav,.ogg,.webm",required:!0,disabled:F,className:"hidden"}),F&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-md",children:[(0,s.jsx)(p.A,{className:"w-4 h-4 animate-spin text-blue-600 dark:text-blue-400"}),(0,s.jsx)("span",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Reading file content..."})]}),S.file&&S.file_data&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md",children:[(0,s.jsx)(g.A,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),(0,s.jsxs)("span",{className:"text-sm text-green-700 dark:text-green-300",children:["File ready: ",S.file.name," (",Math.round(S.file.size/1024)," KB)"]})]}),(0,s.jsx)("p",{className:"text-xs text-theme-muted mt-1",children:"Supported formats: PDF, TXT, MD, CSV, XLSX, XLS, MP3, M4A, WAV, OGG, WEBM (max 10 MB, 50 MB for audio)"})]}),"url"===S.source_type&&(0,s.jsx)(r.oh,{label:"URL",required:!0,children:(0,s.jsx)(i.UE,{type:"url",value:S.url,onChange:e=>I("url",e.target.value),placeholder:"https://example.com/article",className:"w-full",required:!0})}),"text"===S.source_type&&(0,s.jsx)(r.oh,{label:"Content",required:!0,children:L?(0,s.jsxs)("div",{className:"flex items-center justify-center p-8 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg",children:[(0,s.jsx)(p.A,{className:"w-6 h-6 animate-spin mr-2"}),(0,s.jsx)("span",{className:"text-sm text-theme-muted",children:"Loading document content..."})]}):(0,s.jsx)(i.KY,{value:S.content,onChange:e=>I("content",e.target.value),placeholder:"Enter your knowledge content here...",className:"w-full",rows:8,required:!0})}),!1,!1,E>0&&E<100&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-theme-heading",children:"Upload Progress"}),(0,s.jsxs)("span",{className:"text-sm text-theme-muted",children:[E,"%"]})]}),(0,s.jsx)(l.k,{value:E,className:"h-2"})]}),U&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md",children:[(0,s.jsx)(x.A,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),(0,s.jsx)("span",{className:"text-sm text-red-700 dark:text-red-300",children:U})]}),T&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md",children:[(0,s.jsx)(g.A,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),(0,s.jsx)("span",{className:"text-sm text-green-700 dark:text-green-300",children:T})]})]})}),W]})})}},83622:(e,t,a)=>{a.d(t,{D:()=>l,v:()=>n});var s=a(60867);let n=e=>({async listDocuments(t={}){let a=new URLSearchParams;Object.entries(t).forEach(([e,t])=>{null!=t&&""!==t&&a.append(e,t)});let s=`/api/knowledge/documents${a.toString()?`?${a.toString()}`:""}`;return e.get(s)},getDocument:async t=>e.get(`/api/knowledge/documents/${t}`),getDocumentChunks:async t=>e.get(`/api/knowledge/documents/${t}/chunks`),createDocument:async t=>e.post("/api/knowledge/documents",t),deleteDocument:async t=>e.delete(`/api/knowledge/documents/${t}`),async bulkDeleteDocuments(t){let a=new URLSearchParams;
1return a.append("operation","delete_documents"),t.forEach(e=>a.append("ids",e)),e.post(`/api/knowledge/bulk?${a.toString()}`,{})},async getGlobalDocuments(){let e=await this.listDocuments();return(e.data||e.documents||[]).filter(e=>!e.agent_id&&!e.team_id)},async getTeamDocuments(e){let t=await this.listDocuments({team_id:e});return t.data||t.documents||[]},async getAgentDocuments(e){let t=await this.listDocuments({agent_id:e});return t.data||t.documents||[]},async searchDocuments(e,t={}){let a=await this.listDocuments(t),s=a.data||a.documents||[];if(!e)return s;let n=e.toLowerCase();return s.filter(e=>e.title.toLowerCase().includes(n)||e.description&&e.description.toLowerCase().includes(n)||e.source_type.toLowerCase().includes(n))},async getDocumentStats(){let e=await this.listDocuments(),t=e.data||e.documents||[],a={total_documents:t.length,total_chunks:t.reduce((e,t)=>e+(t.chunk_count||0),0),by_scope:{global:t.filter(e=>!e.agent_id&&!e.team_id).length,team:t.filter(e=>e.team_id&&!e.agent_id).length,agent:t.filter(e=>e.agent_id).length},by_source_type:{}};return t.forEach(e=>{a.by_source_type[e.source_type]=(a.by_source_type[e.source_type]||0)+1}),a},async rechunkDocument(e,t){let a=await this.getDocument(e),s=((await this.getDocumentChunks(e)).chunks||[]).sort((e,t)=>(e.chunk_index||0)-(t.chunk_index||0)).map(e=>e.content).join("\n\n");await this.deleteDocument(e);let n={title:a.title,content:s,description:a.description,source_type:a.source_type,source_url:a.source_url,agent_id:a.agent_id,team_id:a.team_id,chunk_size:t.chunk_size,chunk_overlap:t.chunk_overlap,chunking_method:t.chunking_method,metadata:a.meta||{}};return this.createDocument(n)}}),l=n(s.api)}}]);
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.