@gientech/modual 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/chat.js CHANGED
@@ -592,7 +592,7 @@ html body {
592
592
  }
593
593
  `};function Mle({config:e,styles:t}){if(!e)return null;const n=JSON.parse(e.configJson),r=Ht(()=>{var o;return{...F8.colors,...(o=t==null?void 0:t.theme)==null?void 0:o.colors}},[t]);return Je("div",{className:"w-[340px] rounded-xl p-4 animate-fade-in bg-white",children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-md font-bold truncate mr-2",style:{color:r.primary},children:n.config_name||"\u52A9\u624B\u914D\u7F6E"}),K("span",{className:"text-xs truncate rounded px-2 py-0.5",style:{backgroundColor:`${r.primary}1A`,color:r.disabled},children:n.model_name})]}),K("div",{className:"border-b my-2",style:{borderColor:r.border}}),Je("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-700 mb-2",style:{color:r.text},children:[Je("div",{children:["\u4E0A\u4E0B\u6587\u6700\u5927\u8F6E\u6570\uFF1A",K("span",{className:"font-semibold",children:n.max_round})]}),Je("div",{children:["\u6700\u5927\u4EE4\u724C\u6570\uFF1A",K("span",{className:"font-semibold",children:n.max_tokens})]}),Je("div",{children:["\u6E29\u5EA6\uFF1A",K("span",{className:"font-semibold",children:n.temperature})]}),Je("div",{children:["\u53EC\u56DE\u6570\uFF1A",K("span",{className:"font-semibold",children:n.top_k})]}),Je("div",{children:["\u591A\u6837\u6027\uFF1A",K("span",{className:"font-semibold",children:n.top_p})]}),Je("div",{children:["\u76F8\u4F3C\u5EA6\u9608\u503C\uFF1A",K("span",{className:"font-semibold",children:n.score_threshold})]})]}),Je("div",{className:"mb-2",children:[K("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5173\u8054\u77E5\u8BC6\u5E93\uFF1A"}),K("div",{className:"flex flex-wrap gap-1",children:n.knowledge_base_name?n.knowledge_base_name.split(";").map((o,i)=>K("span",{className:"px-2 py-0.5 rounded-full text-xs",style:{backgroundColor:`${r.primary}1A`,color:r.primary},children:o},i)):K("span",{className:"text-gray-300",style:{color:r.disabled},children:"\u65E0"})})]}),Je("div",{className:"mb-2",children:[K("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5F00\u542F\u529F\u80FD:"}),Je("div",{className:"flex flex-wrap gap-2 text-xs mt-2",children:[!!n.enabled_faq&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"FAQ"}),!!n.enabled_graph&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u56FE\u8C31"}),!!n.dependOnKb&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u5F3A\u77E5\u8BC6\u4F9D\u8D56"}),!!n.enabled_table_select&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u8868\u683C\u7B5B\u9009"}),!!n.enabled_rerank&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u7CBE\u6392\u6A21\u5F0F"}),!!n.need_trace_source&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u6EAF\u6E90"}),!!n.is_download&&K("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u4E0B\u8F7D\u6EAF\u6E90"})]})]})]})}function Nle(e,t=[],n=60){const[r,o]=ut("");return At(()=>{o("");let i=0;const a=setInterval(()=>{o(s=>i>=e.length?(clearInterval(a),s):(i++,e.slice(0,i)))},n);return()=>clearInterval(a)},[e,...t]),r}function Dle(e){const{assistantList:t,eventsEmit:n,styles:r,selectedId:o,onSelectAssistant:i,productLogo:a}=e,[s,l]=ut(1),[c,u]=ut(!1),[d,f]=ut(""),h=c||d.trim()?6:12,m=et(),g=et(!1),p=et(null),v=et(null),y=et("");At(()=>{o&&m.current!==o&&(n==null||n("conversation:new_assistant_change",{assistantId:o}),m.current=o)},[o,n]);const b=Ht(()=>ga(),[]);At(()=>{var $;if(($=r==null?void 0:r.theme)!=null&&$.colors){const M=document.createElement("style");return M.innerHTML=Ole(r.theme.colors,b),M.id=`g-welcome-styles-${b}`,document.head.appendChild(M),()=>{const N=document.getElementById(M.id);N&&N.remove()}}},[r,b]);const E=Ht(()=>t.find($=>$.id===o),[t,o]),x=Ht(()=>JSON.parse((E==null?void 0:E.configJson)||"{}"),[E]),C=Ht(()=>{if(!d.trim())return t||[];const $=d.toLowerCase().trim();return(t||[]).filter(M=>{var D,T;const N=((D=M.name)==null?void 0:D.toLowerCase())||"";try{const j=((T=JSON.parse(M.configJson||"{}").config_name)==null?void 0:T.toLowerCase())||"";return N.includes($)||j.includes($)}catch{return N.includes($)}})},[t,d]),k=Math.ceil(((C==null?void 0:C.length)||0)/h),S=(C==null?void 0:C.slice((s-1)*h,s*h))||[];At(()=>{if(o&&o!==v.current){if(g.current&&p.current!==null){v.current=o;return}const $=d.trim()?C:t;if($&&$.length>0){const M=$.findIndex(N=>N.id===o);if(M!==-1){const N=Math.floor(M/h)+1;l(N),v.current=o}}}},[o,t,C,h,d]),At(()=>{if(d!==y.current){if(g.current&&p.current!==null){l(p.current),g.current=!1,p.current=null,y.current=d;return}if(v.current===o){y.current=d;return}g.current||(d.trim()&&(v.current=null),l(1)),y.current=d}},[d,o]),At(()=>{k>0&&s>k&&l(k)},[k,s]);const O=x.prologue||"\u60A8\u597D\uFF0C\u6B22\u8FCE\u4F7F\u7528\u5C0F\u9CB8\u667A\u80FD\u95EE\u7B54",A=Nle(O,[o],30);return Je("div",{className:`flex flex-col relative items-center justify-center h-full w-full g-welcome-${b}`,children:[K("img",{src:a||Ale,alt:"logo",className:"mb-4",style:{width:68,height:68}}),K("div",{className:"text-3xl font-bold mb-2 g-welcome-title",children:A}),!o&&K("div",{className:"flex mb-2 g-welcome-subtitle",children:"\u8BF7\u9009\u62E9\u4E00\u4E2A\u667A\u80FD\u52A9\u624B"}),Je("div",{style:{maxWidth:"1200px"},className:`flex mt-8 flex-wrap gap-3
594
594
  max-w-[1200px] px-8 w-full mx-auto justify-center mb-4`,children:[c?K("div",{className:"flex items-center gap-2 px-5 w-full",style:{flexBasis:"100%"},children:K(Wu,{className:"g-welcome-search-input w-full",placeholder:"\u641C\u7D22\u52A9\u624B\u540D\u79F0",prefix:K(c3,{size:16}),suffix:K("button",{type:"button",onClick:()=>{u(!1),f("")},style:{background:"transparent",border:"none",cursor:"pointer"},children:K(vp,{size:14})}),value:d,onChange:$=>f($.target.value),autoFocus:!0})}):K("button",{type:"button",className:"g-welcome-search-btn",onClick:()=>u(!0),children:K(c3,{size:16})}),S&&S.length>0?K(E0,{children:S.map($=>{const M=o===$.id;let N=$.icon;try{const D=JSON.parse($.configJson||"{}");N=N||D.icon||D.avatar||D.logo}catch{}return N=N||$le,K(IT,{content:()=>K(Mle,{config:t.find(D=>D.id===$.id),styles:r}),trigger:"hover",placement:"bottom",children:Je("button",{type:"button",className:`g-welcome-btn px-3 cursor-pointer rounded-full border font-medium min-w-[160px] text-sm transition-all flex items-center gap-2 ${M?"active":""}`,onClick:()=>{i==null||i($.id);const D=c||d.trim(),I=(D?t:d.trim()?C:t).findIndex(j=>j.id===$.id);if(I!==-1){const R=Math.floor(I/(D?12:h))+1;l(R),v.current=$.id,D&&(p.current=R,g.current=!0,setTimeout(()=>{f(""),u(!1)},100))}},title:$.name,children:[K("span",{className:"icon-badge",children:K("img",{src:N,alt:"icon",style:{width:16,height:16,borderRadius:4}})}),K("span",{className:"truncate max-w-[180px]",children:$.name})]})},$.id)})}):K("div",{className:"g-welcome-subtitle",children:"\u6682\u65E0\u53EF\u7528\u52A9\u624B"})]}),k>1&&Je("div",{className:"flex items-center gap-2",children:[K("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l($=>Math.max(1,$-1)),disabled:s===1,children:K(Dz,{size:16})}),K("div",{className:"flex items-center gap-1",children:(()=>{const $=[];if(k<=7)for(let N=1;N<=k;N++)$.push(N);else if($.push(1),s<=4){for(let N=2;N<=5;N++)$.push(N);$.push("..."),$.push(k)}else if(s>=k-3){$.push("...");for(let N=k-4;N<=k;N++)$.push(N)}else{$.push("...");for(let N=s-1;N<=s+1;N++)$.push(N);$.push("..."),$.push(k)}return $.map((N,D)=>{if(N==="...")return K("span",{className:"g-welcome-pagination-text px-1",children:"..."},`ellipsis-${D}`);const T=N;return K("button",{type:"button",className:`g-welcome-pagination-btn ${s===T?"active":""}`,onClick:()=>l(T),children:T},T)})})()}),K("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l($=>Math.min(k,$+1)),disabled:s===k,children:K(TT,{size:16})})]})]})}async function Tle(e,t){const n=e.getReader();let r;for(;!(r=await n.read()).done;)t(r.value)}function Ple(e){let t,n,r,o=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=Fle(t,a);const s=t.length;let l=0;for(;n<s;){o&&(t[n]===10&&(l=++n),o=!1);let c=-1;for(;n<s&&c===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-l);break;case 13:o=!0;case 10:c=n;break}if(c===-1)break;e(t.subarray(l,c),r),l=n,r=-1}l===s?t=void 0:l!==0&&(t=t.subarray(l),n-=l)}}function Ile(e,t,n){let r=Mk();const o=new TextDecoder;return function(a,s){if(a.length===0)n==null||n(r),r=Mk();else if(s>0){const l=o.decode(a.subarray(0,s)),c=s+(a[s+1]===32?2:1),u=o.decode(a.subarray(c));switch(l){case"data":r.data=r.data?r.data+`
595
- `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":const d=parseInt(u,10);isNaN(d)||t(r.retry=d);break}}}}function Fle(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Mk(){return{data:"",event:"",id:"",retry:void 0}}var Ble=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n};const I6="text/event-stream",Rle=1e3,Nk="last-event-id";function Lle(e,t){var{signal:n,headers:r,onopen:o,onmessage:i,onclose:a,onerror:s,openWhenHidden:l,fetch:c}=t,u=Ble(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,f)=>{const h=Object.assign({},r);h.accept||(h.accept=I6);let m;function g(){m.abort(),document.hidden||x()}l||document.addEventListener("visibilitychange",g);let p=Rle,v=0;function y(){document.removeEventListener("visibilitychange",g),window.clearTimeout(v),m.abort()}n==null||n.addEventListener("abort",()=>{y(),d()});const b=c??window.fetch,E=o??jle;async function x(){var C;m=new AbortController;try{const k=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:m.signal}));await E(k),await Tle(k.body,Ple(Ile(S=>{S?h[Nk]=S:delete h[Nk]},S=>{p=S},i))),a==null||a(),y(),d()}catch(k){if(!m.signal.aborted)try{const S=(C=s==null?void 0:s(k))!==null&&C!==void 0?C:p;window.clearTimeout(v),v=window.setTimeout(x,S)}catch(S){y(),f(S)}}}x()})}function jle(e){const t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(I6)))throw new Error(`Expected content-type to be ${I6}, Actual: ${t}`)}class am extends Error{}let To=null,aa=null;const _le=({baseUrl:e,token:t,CSRFToken:n,setChatData:r,activeSessionId:o,setAppStatus:i,setConversationList:a})=>{const s=p=>{if(!p)return!1;if(typeof p=="string"){const v=p.trim();return v!==""&&v!=="[]"&&v!=="null"}return!0},l=({content:p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:C,databaseReference:k,llmType:S,resultType:O,queryId:A,tokens:$})=>{r(M=>{var z;if(!M[0])return M;const N=M[0],D=N.messages||[],T=D.length-1;if(T<0)return M;const I=D[T];if(I.istype!=="ai")return M;let j=D.slice();if(b!=null&&b.length){const B=D.length-2;if(B>=0&&((z=D[B])==null?void 0:z.istype)==="user"){const F={...D[B],filePaths:b};j[B]=F}}const R=C!==void 0&&s(C)?C:I.graphReference;v===2&&C!==void 0&&console.log("[AichatUseController] reset_chat status=2 \u65F6\u7684 graphReference:",{graphReference:C,isValid:s(C),lastMessageGraphReference:I.graphReference,finalGraphReference:R});const H={...I,content:(I.content||"")+p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:R,databaseReference:k??I.databaseReference,resultType:O,llmType:S,tokens:$,queryId:A||I.queryId||ga(32)};return H.clientSideId=H.clientSideId||H.queryId+"-ai",j[T]=H,[{...N,isNew:!1,messages:j},...M.slice(1)]})},c=p=>{if(p instanceof am)throw i(v=>({...v,display:"error",sender:"ready"})),To&&(To.abort(),To=null),aa=null,p};return{updateUserFilesMessage:({currentFiles:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-2;if(E<0||b[E].istype!=="user")return v;const C=b.slice();return C[E]={...b[E],currentFiles:p},[{...y,messages:C},...v.slice(1)]})},api_startChat_re:(p,v)=>{To&&To.abort(),To=new AbortController,aa=p.sessionId;const y=`${e}/qa/ai/question_re`;console.log("data",p);const b={...p};Lle(y,{method:"post",signal:To.signal,headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:t||"","X-CSRF-TOKEN-IN":n||""},openWhenHidden:!0,body:JSON.stringify(b),onopen:async E=>{if(E.status===500)throw new am("Internal Server Error");if(!E.ok)throw new am(`HTTP error: ${E.status}`)},onmessage:E=>{const x=JSON.parse(E.data);if(aa!==x.sessionId){console.log("[AichatUseController] \u6D41\u5F0F\u8BF7\u6C42\u7684 sessionId \u5DF2\u4E0D\u5339\u914D\uFF0C\u5FFD\u7565\u6570\u636E",{currentStreamSessionId:aa,receivedSessionId:x.sessionId,activeSessionId:o});return}if(o!==x.sessionId)return;const{reply:C,resultType:k,respTime:S,reference:O,webReference:A,graphReference:$,filePaths:M,status:N,docs:D,llmType:T,databaseReference:I}=x,j=M?JSON.parse(M):[];N===2&&C&&C.content&&(C.content.includes("\u6A21\u578B\u6682\u65E0\u6CD5\u8FD4\u56DE")||C.content.includes("\u5931\u8D25")||C.content.includes("\u9519\u8BEF")||C.content.includes("\u8BF7\u7A0D\u540E\u518D\u8BD5"))&&i(H=>({...H,display:"ready",sender:"ready"}));const R=s($)?$:void 0;if(N===2&&console.log("[AichatUseController] status=2 \u65F6\u7684 graphReference:",{graphReference:$,type:typeof $,isValid:s($),finalGraphReference:R}),N===2){if(l({content:C.content||"",status:2,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens}),i(H=>({...H,display:"ready",sender:"ready"})),v){const H=S||Date.now();console.log("[AichatUseController] \u6D88\u606F\u53D1\u9001\u6210\u529F\uFF0CgmtModified:",H),v(H)}}else l({content:C.content||"",status:N,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens})},onerror:c,onclose:()=>{aa===p.sessionId&&(aa=null)}})},addEmptyMessage:({queryId:p,content:v,filePaths:y,currentFiles:b})=>{r(E=>{const x=new Date().toISOString(),C=p||ga(32),k={istype:"user",content:v,time:x,queryId:C,clientSideId:C+"-user",filePaths:y||"",currentFiles:b||[]},S={istype:"ai",content:"",time:new Date(Date.now()+1).toISOString(),streaming:!0,status:0,queryId:C,clientSideId:C+"-ai"},O=E.find(A=>A.id===o);return O?O.messages.push(k,S):console.warn("addEmptyMessage called without an active session."),[...E]})},setLastEmptyMessage:({now:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-1;if(E<0)return v;const x=b[E];if(x.istype!=="ai")return v;const C=b.slice();return C[E]={...x,istype:"ai",content:"",time:p,streaming:!0,status:0},[{...y,messages:C},...v.slice(1)]})},stopStream:()=>{To&&(To.abort(),To=null),aa=null,i(p=>({...p,display:"ready",sender:"ready"}))},cancelStreamBySessionId:p=>To&&aa===p?(console.log("[AichatUseController] \u5207\u6362\u4F1A\u8BDD\uFF0C\u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u5F0F\u8BF7\u6C42",p),To.abort(),To=null,aa=null,i(v=>({...v,display:"ready",sender:"ready"})),!0):!1}},zle="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACRSURBVHgB7ZJBCsQgDEWTmQvMncT7dOuqmY3iai6kMN31UmIjdNFFKuk+DwKahP9ABDAMQyTnvHCtT/ZjjIs0e0nN1hr03kkjGTu8+0PEjzR/S81a6+6cQz6S9x5KKdsknLi+IQRSC07JfybRhE8FM4k2fICgIKVE/MYrF427NlwtuEpOgSr8MUNy9x0Nw7jnAFsnZ7Uu5CkqAAAAAElFTkSuQmCC",{TextArea:Dk}=Wu,{useForm:Hle}=La,LR={\u56DE\u7B54\u4E0D\u4F73:"ansPoor",\u683C\u5F0F\u95EE\u9898:"formatError",\u7406\u89E3\u95EE\u9898\u6709\u8BEF:"harmfulInfo",\u5176\u4ED6:"othres"},Vle=({open:e,setOpen:t,feedBackList:n,handleConfirm:r})=>{const o={header:{padding:"20px 24px",borderBottom:"1px solid #F0F0F0",margin:0},body:{padding:"16px 24px 20px 24px",borderBottom:"1px solid #F0F0F0"},mask:{},footer:{padding:"16px 24px",margin:0},content:{padding:0,borderRadius:"4px",width:"563px"}},[i]=Hle(),[a,s]=ut({}),l=async()=>{try{const u=await i.validateFields();t(!1);const d={...u};Object.entries(a||{}).forEach(f=>{const[h,m]=f;m&&(d[LR[h]]=m)}),r(d)}catch(u){console.log(u);return}};At(()=>{e||(i.resetFields(),s(null))},[e]);const c=Ht(()=>{var u;return(u=JSON.parse(localStorage.getItem("gitech_ril:rag_ai")||"{}"))==null?void 0:u.userInfo},[]);return K(mp,{modal:{styles:o},children:Je(yp,{open:e,onCancel:()=>t(!1),title:K("div",{className:"text-[16px] text-[#2A2A2A] font-bold leading-[1]",children:"\u611F\u8C22\u60A8\u7684\u53CD\u9988\uFF01\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u4E0D\u65AD\u4F18\u5316\u4E0E\u63D0\u5347\u3002"}),footer:Je("div",{children:[K(ko,{className:"mr-[16px] w-[76px]",onClick:()=>{t(!1)},children:"\u53D6\u6D88"}),K(ko,{type:"primary",className:"w-[76px] border-none",onClick:l,children:"\u786E\u8BA4"})]}),children:[K(Wle,{feedBackList:n,treeSelectResult:a,setTreeSelectResult:s}),Je(La,{form:i,layout:"vertical",children:[K(La.Item,{name:"supplementExplain",label:"\u8865\u5145\u63CF\u8FF0",children:K(Dk,{})})," ",K(La.Item,{name:"idealAnswer",label:"\u60A8\u89C9\u5F97\u66F4\u597D\u7684\u56DE\u7B54\u662F\u4EC0\u4E48\uFF1F",children:K(Dk,{})}),c&&Je(E0,{children:[K(La.Item,{name:"userPhone",label:"\u8054\u7CFB\u7535\u8BDD",initialValue:c==null?void 0:c.phone,children:K(Wu,{disabled:!0})}),K(La.Item,{name:"deptName",label:"\u90E8\u95E8",initialValue:c==null?void 0:c.deptName,children:K(Wu,{disabled:!0})})]})]})]})})},Wle=({feedBackList:e,treeSelectResult:t,setTreeSelectResult:n})=>{const[r,o]=ut(!1),[i,a]=ut([]),[s,l]=ut([]),[c,u]=ut([]),[d,f]=ut(null),h=Ht(()=>(l([]),d!=null&&d.items?[{title:"\u5168\u9009",key:"\u5168\u9009",children:d.items.map(g=>({title:g,key:g}))}]:[]),[d]),m=g=>{u(p=>Array.isArray(p)&&Array.isArray(s)?Object.entries(t).reduce((y,b)=>{const[E,x]=b,k=(x?x.split(";"):[]).filter(S=>S!==g);return n(S=>({...S||{},[E]:k.join(";")})),[...y,...k]},[]):p)};return At(()=>{if(a(["\u5168\u9009"]),!t||!(d!=null&&d.que_name))return;const g=t[d.que_name]||"",p=g?g.split(";"):[];l(p)},[h,r]),At(()=>{t===null&&(u([]),f(null),l([]))},[t]),At(()=>{console.log("treeSelectResult",t),console.log("selectedValue",c),console.log("feedBackList",e),console.log("pKey",LR),console.log("selectedParent",d)},[t,c]),Je("div",{className:"relative mb-[24px] z-20",children:[Je("div",{className:"absolute w-full z-10",children:[Je("div",{className:"h-[32px] box-border flex items-center justify-between border-[1px] border-solid border-[#D9D9D9] rounded-[4px] cursor-pointer",onClick:()=>o(!r),children:[K("div",{className:"ml-[16px]",children:"\u95EE\u9898\u7C7B\u578B"}),K("img",{src:zle,width:24,height:24,className:"mr-[16px]"})]}),Je("div",{style:{display:r?"":"none"},className:"h-[288px] rounded-[4px] shadow-md mt-[4px] bg-white",children:[Je("div",{className:"h-[248px] flex",style:{borderBottom:"1px solid #F0F0F0"},children:[K("div",{className:"w-[203px] px-[8px] py-[8px]",style:{borderRight:"1px solid #F0F0F0"},children:e.map((g,p)=>{var v;return Je("div",{className:"rounded-[4px] h-[32px] cursor-pointer flex items-center",style:{backgroundColor:(d==null?void 0:d.que_name)===g.que_name?"#E6F4FF":""},children:[K("div",{className:"h-full w-full leading-[32px]",onClick:()=>{f(g)},children:Je("div",{className:"ml-[8px] text-[14px] text-[#2A2A2A]",children:[g.que_name,"(",t&&t[g.que_name]?t[g.que_name].split(";").length:0,"/",(v=g==null?void 0:g.items)==null?void 0:v.length,")"]})}),K(TT,{className:"mr-[8px] w-3 h-3 text-[rgba(0,0,0,0.45)]"})]},p)})}),K("div",{className:"selfTree h-full flex-1 mt-[8px] ml-[16px]",children:K(kz,{checkable:!0,defaultSelectedKeys:["0-1"],treeData:h,blockNode:!0,checkedKeys:s,expandedKeys:i,onCheck:g=>{Array.isArray(g)&&n(p=>({...p||{},[(d==null?void 0:d.que_name)||""]:(g||[]).filter(v=>v!=="\u5168\u9009").join(";")})),l(g)}})})]}),Je("div",{className:"flex justify-end h-[40px] items-center",children:[K(ko,{size:"small",className:"mr-[8px]",onClick:()=>o(!1),children:"\u53D6\u6D88"}),K(ko,{size:"small",type:"primary",className:"border-none mr-[16px]",onClick:()=>{u(g=>Array.isArray(g)&&Array.isArray(s)?Object.values(t).reduce((v,y)=>[...v,...y?y.split(";"):[]],[]):g),o(!1)},children:"\u786E\u8BA4"})]})]})]}),K("div",{className:"h-[32px]"}),!!(c!=null&&c.length)&&Je("div",{children:[Je("div",{className:"mt-[5px] text-[12px] text-[#555555]",children:["\u5DF2\u9009\u62E9 ",c.length," \u4E2A"]}),(c||[]).map(g=>{let p="";return Object.entries(t||{}).forEach(v=>{const[y,b]=v;b.indexOf(g)>-1&&(p=y)}),Je(Az,{closable:!0,className:"mt-[5px]",onClose:()=>m(g),children:[p,"\uFF08",g,"\uFF09"]},g)})]})]})},Tk=e=>e?Array.isArray(e)?e.map(r=>"/minio/"+r.split("/").slice(3).join("/")):"/minio/"+e.split("/").slice(3).join("/"):"",Pk="http://10.15.12.13:9000/",Ule=e=>{if(typeof e=="string"){const t=e.split(".");return t.length?t[t.length-1]:""}else return""},Gle=e=>{var x,C,k,S,O,A,$,M;const{file_type:t,file_name:n,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,onlyDownloadTypes:l,references:c,eventsEmit:u,styles:d,isUploadFile:f,type:h,collectionItems:m,pdfPages:g=0,fileManagerData:p}=e;if(h==="collection"&&Array.isArray(m)){const T=`calc(90% - ${.5}px)`,I=m.slice(0,4),j=m.length>4,R="\u6253\u5F00\u5408\u96C6",H=()=>{if(p&&t==="pdf"&&!e.pdfPages){const V=((p==null?void 0:p.uploadedFiles)||[]).find(z=>{var B;return((z==null?void 0:z.name)||((B=z==null?void 0:z.file)==null?void 0:B.name))===n});if(!(V!=null&&V.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{...e,pdfPages:(V==null?void 0:V.pdfPages)||0})}else u==null||u("reference_file:click",e)};return Je("div",{className:"user-file relative group flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all bg-white shadow",style:{width:94,height:94,minWidth:94,minHeight:94,borderColor:(C=(x=d==null?void 0:d.theme)==null?void 0:x.colors)==null?void 0:C.border},onClick:H,children:[K("div",{className:"grid grid-cols-2 items-center justify-center grid-rows-2 gap-1 w-full h-full",style:{width:"100%",height:"100%",gap:1},children:I.map((V,z)=>{var P,L,_,W;if(j&&z===3)return K("div",{className:"flex items-center justify-center bg-gray-100 rounded",style:{width:T,height:T},children:K("span",{className:"text-xl text-gray-300 font-bold scale-75",children:"..."})},"ellipsis");if(V.file_type==="image"||V.file_type==="jpg"||V.file_type==="jpeg"||V.file_type==="png"||V.file_type==="gif"||V.file_type==="bmp"||V.file_type==="webp")return K("div",{className:"relative flex items-center justify-center bg-white rounded-lg border overflow-hidden",style:{width:T,height:T,borderColor:(L=(P=d==null?void 0:d.theme)==null?void 0:P.colors)==null?void 0:L.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:K("img",{src:String(V.url||V.file_path||""),alt:V.file_name||"",className:"object-contain max-w-full max-h-full"})})},V.file_name||z);const F=F6(String(V.file_type||""),d);return K("div",{className:"user-file flex flex-col items-center justify-center rounded-lg border bg-gray-50 p-1 text-sm",title:V.file_name,style:{width:T,height:T,borderColor:(W=(_=d==null?void 0:d.theme)==null?void 0:_.colors)==null?void 0:W.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:F})},V.file_name||z)})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg pointer-events-none",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{size:20,className:"mb-1 text-white"}),K("span",{className:"text-white text-center",style:{fontSize:12},children:R})]})})]})}const v=()=>{if(console.log(o,"parse_url",r,"url"),p&&t==="pdf"&&!g){const N=((p==null?void 0:p.uploadedFiles)||[]).find(D=>{var T;return((D==null?void 0:D.name)||((T=D==null?void 0:D.file)==null?void 0:T.name))===(n||"").replace(/\s+/g,"")});if(!(N!=null&&N.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:N.pdfPages||0})}else u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:g})},y=Ht(()=>(n||"").split(".").pop()||"",[n]),b=F6(y,d),E=async()=>{if(r){const N=Tk(r.indexOf("http")>-1?r:`${Pk}/${r}`);if(y.toLowerCase()==="json"){try{const I=await fetch(N);if(!I.ok)throw new Error("\u4E0B\u8F7D\u5931\u8D25");const j=await I.blob(),R=document.createElement("a");R.href=URL.createObjectURL(j),R.download=n||"",document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(R.href),1e3)}catch{alert("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}return}const T=document.createElement("a");T.href=N,T.download=n||"",document.body.appendChild(T),T.click(),document.body.removeChild(T)}};return l&&l.includes(y.toLowerCase())?Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:E,style:{borderColor:(S=(k=d==null?void 0:d.theme)==null?void 0:k.colors)==null?void 0:S.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u4E0B\u8F7D\u6587\u4EF6"})]})})]},n):y==="image"||y==="jpg"||y==="jpeg"||y==="png"||y==="gif"||y==="bmp"||y==="webp"?Je("div",{className:"relative group w-24 h-24 cursor-pointer flex items-center justify-center",onClick:()=>v(),children:[r?K("img",{src:String(Tk(r&&r.indexOf("http")>-1?r:`${Pk}/${r}`)||""),alt:n||"",className:"w-full h-full object-cover rounded-md border",style:{borderColor:(A=(O=d==null?void 0:d.theme)==null?void 0:O.colors)==null?void 0:A.border}}):K("div",{className:"w-full h-full flex items-center justify-center",children:K("span",{className:"animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 w-8 h-8 inline-block"})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-md",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(Lz,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",children:"\u67E5\u770B\u56FE\u7247"})]})})]},n):Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:v,style:{borderColor:(M=($=d==null?void 0:d.theme)==null?void 0:$.colors)==null?void 0:M.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u6253\u5F00\u6587\u4EF6"})]})})]},n)},qle=e=>e?e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`:"",Yle=({fileName:e,fileSize:t,icon:n,statusText:r,statusColor:o="text-gray-400",statusIcon:i,onRemove:a,themeColors:s={},cardId:l,showRemove:c=!0,disabledRemove:u=!1,onRemoveWithAnim:d,extra:f,style:h})=>Je("div",{id:l,className:"group gap-x-2.5 items-center file-display-card relative flex w-[210px] bg-white border border-gray-200 rounded-md shadow-sm px-2 py-1 transition-all hover:shadow-md hover:border-blue-300",style:h,children:[K("div",{className:"pt-1",children:n}),Je("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[Je("div",{className:"flex items-center justify-between gap-1",children:[K("span",{className:"text-[12px] font-medium truncate max-w-[120px]",title:e,children:e}),K("span",{className:"ml-1 text-[11px] text-gray-400",children:qle(t)})]}),Je("div",{className:`text-[10px] mt-0.5 flex items-center gap-3 ${o}`,children:[i,K("span",{children:r})]})]}),f,c&&!u&&K("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 text-xs p-0.5 rounded-full bg-white shadow-sm z-10",onClick:()=>{d&&l?d(l):a&&a()},title:"\u79FB\u9664",style:{lineHeight:0,color:s.error||"#FF0000"},children:K(vp,{className:"w-3.5 h-3.5"})})]});function F6(e,t){var r;const n=((r=t==null?void 0:t.theme)==null?void 0:r.icons)||{};switch(e.toLowerCase()){case"docx":case"doc":return n.docx?K("img",{src:n.docx,alt:"docx",style:{width:20,height:20}}):K(Ko,{type:"rag/word",size:18});case"image":case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return n.image?K("img",{src:n.image,alt:"image",style:{width:20,height:20}}):K(Ko,{type:"rag/pic",size:18});case"pptx":case"ppt":return n.pptx?K("img",{src:n.pptx,alt:"pptx",style:{width:20,height:20}}):K(Ko,{type:"rag/ppt",size:18});case"sheets":case"excel":case"xls":case"csv":case"xlsx":case"xlsm":case"xlsb":case"xltx":case"xltm":case"xlt":case"xlam":return n.sheets?K("img",{src:n.sheets,alt:"sheets",style:{width:20,height:20}}):K(Ko,{type:"rag/excel",size:18});case"pdf":return n.pdf?K("img",{src:n.pdf,alt:"pdf",style:{width:20,height:20}}):K(Ko,{type:"rag/pdf",size:18});case"txt":return n.txt?K("img",{src:n.txt,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/txt",size:18});case"md":return n.md?K("img",{src:n.md,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/document",size:18});case"json":return n.json?K("img",{src:n.json,alt:"json",style:{width:20,height:20}}):K(Ko,{type:"rag/json",size:18});case"html":case"htm":return n.html?K("img",{src:n.html,alt:"html",style:{width:20,height:20}}):K(Ko,{type:"rag/url",size:18});case"xml":default:return K(Ko,{type:"rag/file",size:18})}}const Xle=[{file:{name:"\u4EA7\u54C1\u9700\u6C42\u6587\u6863.pdf",size:1024*1024*2.5,type:"application/pdf"},type:"pdf",status:"uploaded",url:"https://example.com/file1.pdf"},{file:{name:"\u6570\u636E\u5206\u6790\u62A5\u544A.xlsx",size:1024*1024*1.2,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},type:"excel",status:"uploaded",url:"https://example.com/file3.xlsx"},{file:{name:"\u7CFB\u7EDF\u67B6\u6784\u56FE.png",size:1024*512,type:"image/png"},type:"image",status:"uploaded",url:"https://example.com/file2.png"}];function Kle({open:e,onCancel:t,files:n=Xle,currentFiles:r=[],onUpload:o,onRemoveFile:i,styles:a,eventsEmit:s}){const l={pending:"\u5F85\u4E0A\u4F20",uploading:"\u4E0A\u4F20\u4E2D",uploaded:"\u5DF2\u4E0A\u4F20",analyzing:"\u89E3\u6790\u4E2D",analyze_failed:"\u89E3\u6790\u5931\u8D25",error:"\u5931\u8D25"},[c,u]=ut([]),d=(g,p)=>{s&&s("uploaded_file:removeFromTemp",{file:g,idx:p})},f=a&&a.theme&&a.theme.colors?a.theme.colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080",shadow:"#000000",appBackground:"#fff"},h=n.map((g,p)=>Je("div",{className:"relative flex flex-col gap-2.5 items-center justify-center",children:[K("div",{className:"absolute right-1 top-1 z-10",children:K(jT,{title:"\u786E\u8BA4\u4ECE\u4E34\u65F6\u5BF9\u8BDD\u77E5\u8BC6\u5E93\u79FB\u9664\u8BE5\u6587\u4EF6\uFF1F",onConfirm:()=>d(g,p),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",children:K("button",{className:"bg-white cursor-pointer rounded-full p-0.5",style:{lineHeight:0,color:f&&f.text?f.text:"#FF0000",transition:"background 0.2s, color 0.2s"},onMouseOver:v=>{v.currentTarget.style.color=f&&f.error?f.error:"#FF0000"},onMouseOut:v=>{v.currentTarget.style.color=f.text},title:"\u79FB\u9664",children:K(vp,{className:"w-3 h-3"})})})}),K(Gle,{file_type:Ule(g.file.name||g.name),file_name:g.name||g.file.name,url:g.url,retrieve_tags:[],styles:a,isUploadFile:!0,eventsEmit:s,parse_url:g.convertedFilePath,pdfPages:g.pdfPages||0})]},g.file.name+p)),m=r.map((g,p)=>{const v=g.file.name.split(".").pop()||"",y=F6(v,a);return K(Yle,{cardId:`pending-file-card-${p}`,fileName:g.file.name,fileSize:g.file.size,icon:y,statusText:l[g.status||"pending"],statusColor:"text-gray-400",showRemove:!0,onRemove:()=>i&&i(g,p,"pending"),themeColors:f,style:{boxShadow:"none",height:55,background:"#f8fafc"}},g.file.name+p)});return c.length>0?(f&&f.error&&f.error,f&&f.error&&f.error+"",f&&f.error&&f.error):(f&&f.disabledText&&f.disabledText,f&&f.disabledBackground&&f.disabledBackground,f&&f.disabledText&&f.disabledText),Je(yp,{open:e,onCancel:t,footer:null,title:"\u5BF9\u8BDD\u4E34\u65F6\u6587\u4EF6\u77E5\u8BC6\u5E93",closable:!1,width:800,styles:{body:{padding:"0",maxHeight:"70vh",overflow:"auto"}},children:[Je("div",{className:"file-manager-modal space-y-6 px-4 py-4",children:[Je("div",{className:"",children:[K("div",{className:"flex items-center mb-2 justify-between",children:Je("div",{className:"flex items-center",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5DF2\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[n.length," \u4E2A"]})]})}),K("div",{className:"w-full relative min-h-[200px] max-h-[260px] p-2 overflow-y-auto",style:{overflowX:"hidden"},children:K("div",{className:"flex flex-wrap gap-1",children:h.length>0?h:K("div",{className:"flex items-center w-full h-full py-10 justify-center text-gray-400 text-sm",children:"\u6682\u65E0\u5DF2\u4E0A\u4F20\u6587\u4EF6"})})})]}),Je("div",{children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5F85\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[r.length," \u4E2A"]})]}),Je("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[m,K(B8.Dragger,{multiple:!0,showUploadList:!1,beforeUpload:(g,p)=>(g===p[0]&&(o==null||o(p)),!1),className:"!bg-gray-50 !border-dashed !border-gray-300 hover:!border-blue-400 cursor-pointer min-w-[160px] max-w-[220px] flex flex-row items-center justify-center border-2 rounded-lg transition-all",style:{height:45,boxShadow:"none",padding:0},children:Je("div",{className:"flex flex-row items-center pb-8 justify-center",children:[K(PT,{size:20,className:"text-blue-400 mr-2"}),K("div",{className:"text-xs text-gray-500",children:"\u4E0A\u4F20\u6587\u4EF6"})]})})]})]}),K("div",{className:"flex justify-end gap-2",children:K(ko,{type:"primary",onClick:t,children:"\u786E\u8BA4"})})]}),K("style",{children:`
595
+ `+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":const d=parseInt(u,10);isNaN(d)||t(r.retry=d);break}}}}function Fle(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Mk(){return{data:"",event:"",id:"",retry:void 0}}var Ble=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n};const I6="text/event-stream",Rle=1e3,Nk="last-event-id";function Lle(e,t){var{signal:n,headers:r,onopen:o,onmessage:i,onclose:a,onerror:s,openWhenHidden:l,fetch:c}=t,u=Ble(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,f)=>{const h=Object.assign({},r);h.accept||(h.accept=I6);let m;function g(){m.abort(),document.hidden||x()}l||document.addEventListener("visibilitychange",g);let p=Rle,v=0;function y(){document.removeEventListener("visibilitychange",g),window.clearTimeout(v),m.abort()}n==null||n.addEventListener("abort",()=>{y(),d()});const b=c??window.fetch,E=o??jle;async function x(){var C;m=new AbortController;try{const k=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:m.signal}));await E(k),await Tle(k.body,Ple(Ile(S=>{S?h[Nk]=S:delete h[Nk]},S=>{p=S},i))),a==null||a(),y(),d()}catch(k){if(!m.signal.aborted)try{const S=(C=s==null?void 0:s(k))!==null&&C!==void 0?C:p;window.clearTimeout(v),v=window.setTimeout(x,S)}catch(S){y(),f(S)}}}x()})}function jle(e){const t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(I6)))throw new Error(`Expected content-type to be ${I6}, Actual: ${t}`)}class am extends Error{}let To=null,aa=null;const _le=({baseUrl:e,token:t,CSRFToken:n,setChatData:r,activeSessionId:o,setAppStatus:i,setConversationList:a})=>{const s=p=>{if(!p)return!1;if(typeof p=="string"){const v=p.trim();return v!==""&&v!=="[]"&&v!=="null"}return!0},l=({content:p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:C,databaseReference:k,llmType:S,resultType:O,queryId:A,tokens:$})=>{r(M=>{var z;if(!M[0])return M;const N=M[0],D=N.messages||[],T=D.length-1;if(T<0)return M;const I=D[T];if(I.istype!=="ai")return M;let j=D.slice();if(b!=null&&b.length){const B=D.length-2;if(B>=0&&((z=D[B])==null?void 0:z.istype)==="user"){const F={...D[B],filePaths:b};j[B]=F}}const R=C!==void 0&&s(C)?C:I.graphReference;v===2&&C!==void 0&&console.log("[AichatUseController] reset_chat status=2 \u65F6\u7684 graphReference:",{graphReference:C,isValid:s(C),lastMessageGraphReference:I.graphReference,finalGraphReference:R});const H={...I,content:(I.content||"")+p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:R,databaseReference:k??I.databaseReference,resultType:O,llmType:S,tokens:$,queryId:A||I.queryId||ga(32)};return H.clientSideId=H.clientSideId||H.queryId+"-ai",j[T]=H,[{...N,isNew:!1,messages:j},...M.slice(1)]})},c=p=>{if(p instanceof am)throw i(v=>({...v,display:"error",sender:"ready"})),To&&(To.abort(),To=null),aa=null,p};return{updateUserFilesMessage:({currentFiles:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-2;if(E<0||b[E].istype!=="user")return v;const C=b.slice();return C[E]={...b[E],currentFiles:p},[{...y,messages:C},...v.slice(1)]})},api_startChat_re:(p,v)=>{To&&To.abort(),To=new AbortController,aa=p.sessionId;const y=`${e}/qa/ai/question_re`;console.log("data",p);const b={...p};Lle(y,{method:"post",signal:To.signal,headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:t||"","X-CSRF-TOKEN-IN":n||""},openWhenHidden:!0,body:JSON.stringify(b),onopen:async E=>{if(E.status===500)throw new am("Internal Server Error");if(!E.ok)throw new am(`HTTP error: ${E.status}`)},onmessage:E=>{const x=JSON.parse(E.data);if(aa!==x.sessionId){console.log("[AichatUseController] \u6D41\u5F0F\u8BF7\u6C42\u7684 sessionId \u5DF2\u4E0D\u5339\u914D\uFF0C\u5FFD\u7565\u6570\u636E",{currentStreamSessionId:aa,receivedSessionId:x.sessionId,activeSessionId:o});return}if(o!==x.sessionId)return;const{reply:C,resultType:k,respTime:S,reference:O,webReference:A,graphReference:$,filePaths:M,status:N,docs:D,llmType:T,databaseReference:I}=x,j=M?JSON.parse(M):[];N===2&&C&&C.content&&(C.content.includes("\u6A21\u578B\u6682\u65E0\u6CD5\u8FD4\u56DE")||C.content.includes("\u5931\u8D25")||C.content.includes("\u9519\u8BEF")||C.content.includes("\u8BF7\u7A0D\u540E\u518D\u8BD5"))&&i(H=>({...H,display:"ready",sender:"ready"}));const R=s($)?$:void 0;if(N===2&&console.log("[AichatUseController] status=2 \u65F6\u7684 graphReference:",{graphReference:$,type:typeof $,isValid:s($),finalGraphReference:R}),N===2){if(l({content:C.content||"",status:2,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens}),i(H=>({...H,display:"ready",sender:"ready"})),v){const H=S||Date.now();console.log("[AichatUseController] \u6D88\u606F\u53D1\u9001\u6210\u529F\uFF0CgmtModified:",H),v(H)}}else l({content:C.content||"",status:N,respTime:S,filePaths:j,reference:O||D||"",webReference:A||"",graphReference:R,databaseReference:I,llmType:T,resultType:k,queryId:x.queryId,tokens:x.tokens})},onerror:c,onclose:()=>{aa===p.sessionId&&(aa=null)}})},addEmptyMessage:({queryId:p,content:v,filePaths:y,currentFiles:b})=>{r(E=>{const x=new Date().toISOString(),C=p||ga(32),k={istype:"user",content:v,time:x,queryId:C,clientSideId:C+"-user",filePaths:y||"",currentFiles:b||[]},S={istype:"ai",content:"",time:new Date(Date.now()+1).toISOString(),streaming:!0,status:0,queryId:C,clientSideId:C+"-ai"},O=E.find(A=>A.id===o);return O?O.messages.push(k,S):console.warn("addEmptyMessage called without an active session."),[...E]})},setLastEmptyMessage:({now:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-1;if(E<0)return v;const x=b[E];if(x.istype!=="ai")return v;const C=b.slice();return C[E]={...x,istype:"ai",content:"",time:p,streaming:!0,status:0},[{...y,messages:C},...v.slice(1)]})},stopStream:()=>{To&&(To.abort(),To=null),aa=null,i(p=>({...p,display:"ready",sender:"ready"}))},cancelStreamBySessionId:p=>To&&aa===p?(console.log("[AichatUseController] \u5207\u6362\u4F1A\u8BDD\uFF0C\u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u5F0F\u8BF7\u6C42",p),To.abort(),To=null,aa=null,i(v=>({...v,display:"ready",sender:"ready"})),!0):!1}},zle="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACRSURBVHgB7ZJBCsQgDEWTmQvMncT7dOuqmY3iai6kMN31UmIjdNFFKuk+DwKahP9ABDAMQyTnvHCtT/ZjjIs0e0nN1hr03kkjGTu8+0PEjzR/S81a6+6cQz6S9x5KKdsknLi+IQRSC07JfybRhE8FM4k2fICgIKVE/MYrF427NlwtuEpOgSr8MUNy9x0Nw7jnAFsnZ7Uu5CkqAAAAAElFTkSuQmCC",{TextArea:Dk}=Wu,{useForm:Hle}=La,LR={\u56DE\u7B54\u4E0D\u4F73:"ansPoor",\u683C\u5F0F\u95EE\u9898:"formatError",\u7406\u89E3\u95EE\u9898\u6709\u8BEF:"harmfulInfo",\u5176\u4ED6:"othres"},Vle=({open:e,setOpen:t,feedBackList:n,handleConfirm:r})=>{const o={header:{padding:"20px 24px",borderBottom:"1px solid #F0F0F0",margin:0},body:{padding:"16px 24px 20px 24px",borderBottom:"1px solid #F0F0F0"},mask:{},footer:{padding:"16px 24px",margin:0},content:{padding:0,borderRadius:"4px",width:"563px"}},[i]=Hle(),[a,s]=ut({}),l=async()=>{try{const u=await i.validateFields();t(!1);const d={...u};Object.entries(a||{}).forEach(f=>{const[h,m]=f;m&&(d[LR[h]]=m)}),r(d)}catch(u){console.log(u);return}};At(()=>{e||(i.resetFields(),s(null))},[e]);const c=Ht(()=>{var u;return(u=JSON.parse(localStorage.getItem("gitech_ril:rag_ai")||"{}"))==null?void 0:u.userInfo},[e]);return K(mp,{modal:{styles:o},children:Je(yp,{open:e,onCancel:()=>t(!1),title:K("div",{className:"text-[16px] text-[#2A2A2A] font-bold leading-[1]",children:"\u611F\u8C22\u60A8\u7684\u53CD\u9988\uFF01\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u4E0D\u65AD\u4F18\u5316\u4E0E\u63D0\u5347\u3002"}),destroyOnHidden:!0,footer:Je("div",{children:[K(ko,{className:"mr-[16px] w-[76px]",onClick:()=>{t(!1)},children:"\u53D6\u6D88"}),K(ko,{type:"primary",className:"w-[76px] border-none",onClick:l,children:"\u786E\u8BA4"})]}),children:[K(Wle,{feedBackList:n,treeSelectResult:a,setTreeSelectResult:s}),Je(La,{form:i,layout:"vertical",children:[K(La.Item,{name:"supplementExplain",label:"\u8865\u5145\u63CF\u8FF0",children:K(Dk,{})})," ",K(La.Item,{name:"idealAnswer",label:"\u60A8\u89C9\u5F97\u66F4\u597D\u7684\u56DE\u7B54\u662F\u4EC0\u4E48\uFF1F",children:K(Dk,{})}),c&&Je(E0,{children:[K(La.Item,{name:"userPhone",label:"\u8054\u7CFB\u7535\u8BDD",initialValue:c==null?void 0:c.phone,children:K(Wu,{disabled:!0})}),K(La.Item,{name:"deptName",label:"\u90E8\u95E8",initialValue:c==null?void 0:c.deptName,children:K(Wu,{disabled:!0})})]})]})]})})},Wle=({feedBackList:e,treeSelectResult:t,setTreeSelectResult:n})=>{const[r,o]=ut(!1),[i,a]=ut([]),[s,l]=ut([]),[c,u]=ut([]),[d,f]=ut(null),h=Ht(()=>(l([]),d!=null&&d.items?[{title:"\u5168\u9009",key:"\u5168\u9009",children:d.items.map(g=>({title:g,key:g}))}]:[]),[d]),m=g=>{u(p=>Array.isArray(p)&&Array.isArray(s)?Object.entries(t).reduce((y,b)=>{const[E,x]=b,k=(x?x.split(";"):[]).filter(S=>S!==g);return n(S=>({...S||{},[E]:k.join(";")})),[...y,...k]},[]):p)};return At(()=>{if(a(["\u5168\u9009"]),!t||!(d!=null&&d.que_name))return;const g=t[d.que_name]||"",p=g?g.split(";"):[];l(p)},[h,r]),At(()=>{t===null&&(u([]),f(null),l([]))},[t]),At(()=>{console.log("treeSelectResult",t),console.log("selectedValue",c),console.log("feedBackList",e),console.log("pKey",LR),console.log("selectedParent",d)},[t,c]),Je("div",{className:"relative mb-[24px] z-20",children:[Je("div",{className:"absolute w-full z-10",children:[Je("div",{className:"h-[32px] box-border flex items-center justify-between border-[1px] border-solid border-[#D9D9D9] rounded-[4px] cursor-pointer",onClick:()=>o(!r),children:[K("div",{className:"ml-[16px]",children:"\u95EE\u9898\u7C7B\u578B"}),K("img",{src:zle,width:24,height:24,className:"mr-[16px]"})]}),Je("div",{style:{display:r?"":"none"},className:"h-[288px] rounded-[4px] shadow-md mt-[4px] bg-white",children:[Je("div",{className:"h-[248px] flex",style:{borderBottom:"1px solid #F0F0F0"},children:[K("div",{className:"w-[203px] px-[8px] py-[8px]",style:{borderRight:"1px solid #F0F0F0"},children:e.map((g,p)=>{var v;return Je("div",{className:"rounded-[4px] h-[32px] cursor-pointer flex items-center",style:{backgroundColor:(d==null?void 0:d.que_name)===g.que_name?"#E6F4FF":""},children:[K("div",{className:"h-full w-full leading-[32px]",onClick:()=>{f(g)},children:Je("div",{className:"ml-[8px] text-[14px] text-[#2A2A2A]",children:[g.que_name,"(",t&&t[g.que_name]?t[g.que_name].split(";").length:0,"/",(v=g==null?void 0:g.items)==null?void 0:v.length,")"]})}),K(TT,{className:"mr-[8px] w-3 h-3 text-[rgba(0,0,0,0.45)]"})]},p)})}),K("div",{className:"selfTree h-full flex-1 mt-[8px] ml-[16px]",children:K(kz,{checkable:!0,defaultSelectedKeys:["0-1"],treeData:h,blockNode:!0,checkedKeys:s,expandedKeys:i,onCheck:g=>{Array.isArray(g)&&n(p=>({...p||{},[(d==null?void 0:d.que_name)||""]:(g||[]).filter(v=>v!=="\u5168\u9009").join(";")})),l(g)}})})]}),Je("div",{className:"flex justify-end h-[40px] items-center",children:[K(ko,{size:"small",className:"mr-[8px]",onClick:()=>o(!1),children:"\u53D6\u6D88"}),K(ko,{size:"small",type:"primary",className:"border-none mr-[16px]",onClick:()=>{u(g=>Array.isArray(g)&&Array.isArray(s)?Object.values(t).reduce((v,y)=>[...v,...y?y.split(";"):[]],[]):g),o(!1)},children:"\u786E\u8BA4"})]})]})]}),K("div",{className:"h-[32px]"}),!!(c!=null&&c.length)&&Je("div",{children:[Je("div",{className:"mt-[5px] text-[12px] text-[#555555]",children:["\u5DF2\u9009\u62E9 ",c.length," \u4E2A"]}),(c||[]).map(g=>{let p="";return Object.entries(t||{}).forEach(v=>{const[y,b]=v;b.indexOf(g)>-1&&(p=y)}),Je(Az,{closable:!0,className:"mt-[5px]",onClose:()=>m(g),children:[p,"\uFF08",g,"\uFF09"]},g)})]})]})},Tk=e=>e?Array.isArray(e)?e.map(r=>"/minio/"+r.split("/").slice(3).join("/")):"/minio/"+e.split("/").slice(3).join("/"):"",Pk="http://10.15.12.13:9000/",Ule=e=>{if(typeof e=="string"){const t=e.split(".");return t.length?t[t.length-1]:""}else return""},Gle=e=>{var x,C,k,S,O,A,$,M;const{file_type:t,file_name:n,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,onlyDownloadTypes:l,references:c,eventsEmit:u,styles:d,isUploadFile:f,type:h,collectionItems:m,pdfPages:g=0,fileManagerData:p}=e;if(h==="collection"&&Array.isArray(m)){const T=`calc(90% - ${.5}px)`,I=m.slice(0,4),j=m.length>4,R="\u6253\u5F00\u5408\u96C6",H=()=>{if(p&&t==="pdf"&&!e.pdfPages){const V=((p==null?void 0:p.uploadedFiles)||[]).find(z=>{var B;return((z==null?void 0:z.name)||((B=z==null?void 0:z.file)==null?void 0:B.name))===n});if(!(V!=null&&V.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{...e,pdfPages:(V==null?void 0:V.pdfPages)||0})}else u==null||u("reference_file:click",e)};return Je("div",{className:"user-file relative group flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all bg-white shadow",style:{width:94,height:94,minWidth:94,minHeight:94,borderColor:(C=(x=d==null?void 0:d.theme)==null?void 0:x.colors)==null?void 0:C.border},onClick:H,children:[K("div",{className:"grid grid-cols-2 items-center justify-center grid-rows-2 gap-1 w-full h-full",style:{width:"100%",height:"100%",gap:1},children:I.map((V,z)=>{var P,L,_,W;if(j&&z===3)return K("div",{className:"flex items-center justify-center bg-gray-100 rounded",style:{width:T,height:T},children:K("span",{className:"text-xl text-gray-300 font-bold scale-75",children:"..."})},"ellipsis");if(V.file_type==="image"||V.file_type==="jpg"||V.file_type==="jpeg"||V.file_type==="png"||V.file_type==="gif"||V.file_type==="bmp"||V.file_type==="webp")return K("div",{className:"relative flex items-center justify-center bg-white rounded-lg border overflow-hidden",style:{width:T,height:T,borderColor:(L=(P=d==null?void 0:d.theme)==null?void 0:P.colors)==null?void 0:L.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:K("img",{src:String(V.url||V.file_path||""),alt:V.file_name||"",className:"object-contain max-w-full max-h-full"})})},V.file_name||z);const F=F6(String(V.file_type||""),d);return K("div",{className:"user-file flex flex-col items-center justify-center rounded-lg border bg-gray-50 p-1 text-sm",title:V.file_name,style:{width:T,height:T,borderColor:(W=(_=d==null?void 0:d.theme)==null?void 0:_.colors)==null?void 0:W.border},children:K("div",{className:"flex items-center justify-center w-full h-full scale-75",children:F})},V.file_name||z)})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg pointer-events-none",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{size:20,className:"mb-1 text-white"}),K("span",{className:"text-white text-center",style:{fontSize:12},children:R})]})})]})}const v=()=>{if(console.log(o,"parse_url",r,"url"),p&&t==="pdf"&&!g){const N=((p==null?void 0:p.uploadedFiles)||[]).find(D=>{var T;return((D==null?void 0:D.name)||((T=D==null?void 0:D.file)==null?void 0:T.name))===(n||"").replace(/\s+/g,"")});if(!(N!=null&&N.pdfPages)){ir.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:N.pdfPages||0})}else u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:g})},y=Ht(()=>(n||"").split(".").pop()||"",[n]),b=F6(y,d),E=async()=>{if(r){const N=Tk(r.indexOf("http")>-1?r:`${Pk}/${r}`);if(y.toLowerCase()==="json"){try{const I=await fetch(N);if(!I.ok)throw new Error("\u4E0B\u8F7D\u5931\u8D25");const j=await I.blob(),R=document.createElement("a");R.href=URL.createObjectURL(j),R.download=n||"",document.body.appendChild(R),R.click(),document.body.removeChild(R),setTimeout(()=>URL.revokeObjectURL(R.href),1e3)}catch{alert("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}return}const T=document.createElement("a");T.href=N,T.download=n||"",document.body.appendChild(T),T.click(),document.body.removeChild(T)}};return l&&l.includes(y.toLowerCase())?Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:E,style:{borderColor:(S=(k=d==null?void 0:d.theme)==null?void 0:k.colors)==null?void 0:S.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u4E0B\u8F7D\u6587\u4EF6"})]})})]},n):y==="image"||y==="jpg"||y==="jpeg"||y==="png"||y==="gif"||y==="bmp"||y==="webp"?Je("div",{className:"relative group w-24 h-24 cursor-pointer flex items-center justify-center",onClick:()=>v(),children:[r?K("img",{src:String(Tk(r&&r.indexOf("http")>-1?r:`${Pk}/${r}`)||""),alt:n||"",className:"w-full h-full object-cover rounded-md border",style:{borderColor:(A=(O=d==null?void 0:d.theme)==null?void 0:O.colors)==null?void 0:A.border}}):K("div",{className:"w-full h-full flex items-center justify-center",children:K("span",{className:"animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 w-8 h-8 inline-block"})}),K("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-md",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(Lz,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",children:"\u67E5\u770B\u56FE\u7247"})]})})]},n):Je("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:v,style:{borderColor:(M=($=d==null?void 0:d.theme)==null?void 0:$.colors)==null?void 0:M.border},children:[b,K("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),K("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:Je("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[K(d1,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),K("div",{className:"text-white text-center",style:{fontSize:10},children:"\u6253\u5F00\u6587\u4EF6"})]})})]},n)},qle=e=>e?e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`:"",Yle=({fileName:e,fileSize:t,icon:n,statusText:r,statusColor:o="text-gray-400",statusIcon:i,onRemove:a,themeColors:s={},cardId:l,showRemove:c=!0,disabledRemove:u=!1,onRemoveWithAnim:d,extra:f,style:h})=>Je("div",{id:l,className:"group gap-x-2.5 items-center file-display-card relative flex w-[210px] bg-white border border-gray-200 rounded-md shadow-sm px-2 py-1 transition-all hover:shadow-md hover:border-blue-300",style:h,children:[K("div",{className:"pt-1",children:n}),Je("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[Je("div",{className:"flex items-center justify-between gap-1",children:[K("span",{className:"text-[12px] font-medium truncate max-w-[120px]",title:e,children:e}),K("span",{className:"ml-1 text-[11px] text-gray-400",children:qle(t)})]}),Je("div",{className:`text-[10px] mt-0.5 flex items-center gap-3 ${o}`,children:[i,K("span",{children:r})]})]}),f,c&&!u&&K("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 text-xs p-0.5 rounded-full bg-white shadow-sm z-10",onClick:()=>{d&&l?d(l):a&&a()},title:"\u79FB\u9664",style:{lineHeight:0,color:s.error||"#FF0000"},children:K(vp,{className:"w-3.5 h-3.5"})})]});function F6(e,t){var r;const n=((r=t==null?void 0:t.theme)==null?void 0:r.icons)||{};switch(e.toLowerCase()){case"docx":case"doc":return n.docx?K("img",{src:n.docx,alt:"docx",style:{width:20,height:20}}):K(Ko,{type:"rag/word",size:18});case"image":case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return n.image?K("img",{src:n.image,alt:"image",style:{width:20,height:20}}):K(Ko,{type:"rag/pic",size:18});case"pptx":case"ppt":return n.pptx?K("img",{src:n.pptx,alt:"pptx",style:{width:20,height:20}}):K(Ko,{type:"rag/ppt",size:18});case"sheets":case"excel":case"xls":case"csv":case"xlsx":case"xlsm":case"xlsb":case"xltx":case"xltm":case"xlt":case"xlam":return n.sheets?K("img",{src:n.sheets,alt:"sheets",style:{width:20,height:20}}):K(Ko,{type:"rag/excel",size:18});case"pdf":return n.pdf?K("img",{src:n.pdf,alt:"pdf",style:{width:20,height:20}}):K(Ko,{type:"rag/pdf",size:18});case"txt":return n.txt?K("img",{src:n.txt,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/txt",size:18});case"md":return n.md?K("img",{src:n.md,alt:"txt",style:{width:20,height:20}}):K(Ko,{type:"rag/document",size:18});case"json":return n.json?K("img",{src:n.json,alt:"json",style:{width:20,height:20}}):K(Ko,{type:"rag/json",size:18});case"html":case"htm":return n.html?K("img",{src:n.html,alt:"html",style:{width:20,height:20}}):K(Ko,{type:"rag/url",size:18});case"xml":default:return K(Ko,{type:"rag/file",size:18})}}const Xle=[{file:{name:"\u4EA7\u54C1\u9700\u6C42\u6587\u6863.pdf",size:1024*1024*2.5,type:"application/pdf"},type:"pdf",status:"uploaded",url:"https://example.com/file1.pdf"},{file:{name:"\u6570\u636E\u5206\u6790\u62A5\u544A.xlsx",size:1024*1024*1.2,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},type:"excel",status:"uploaded",url:"https://example.com/file3.xlsx"},{file:{name:"\u7CFB\u7EDF\u67B6\u6784\u56FE.png",size:1024*512,type:"image/png"},type:"image",status:"uploaded",url:"https://example.com/file2.png"}];function Kle({open:e,onCancel:t,files:n=Xle,currentFiles:r=[],onUpload:o,onRemoveFile:i,styles:a,eventsEmit:s}){const l={pending:"\u5F85\u4E0A\u4F20",uploading:"\u4E0A\u4F20\u4E2D",uploaded:"\u5DF2\u4E0A\u4F20",analyzing:"\u89E3\u6790\u4E2D",analyze_failed:"\u89E3\u6790\u5931\u8D25",error:"\u5931\u8D25"},[c,u]=ut([]),d=(g,p)=>{s&&s("uploaded_file:removeFromTemp",{file:g,idx:p})},f=a&&a.theme&&a.theme.colors?a.theme.colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080",shadow:"#000000",appBackground:"#fff"},h=n.map((g,p)=>Je("div",{className:"relative flex flex-col gap-2.5 items-center justify-center",children:[K("div",{className:"absolute right-1 top-1 z-10",children:K(jT,{title:"\u786E\u8BA4\u4ECE\u4E34\u65F6\u5BF9\u8BDD\u77E5\u8BC6\u5E93\u79FB\u9664\u8BE5\u6587\u4EF6\uFF1F",onConfirm:()=>d(g,p),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",children:K("button",{className:"bg-white cursor-pointer rounded-full p-0.5",style:{lineHeight:0,color:f&&f.text?f.text:"#FF0000",transition:"background 0.2s, color 0.2s"},onMouseOver:v=>{v.currentTarget.style.color=f&&f.error?f.error:"#FF0000"},onMouseOut:v=>{v.currentTarget.style.color=f.text},title:"\u79FB\u9664",children:K(vp,{className:"w-3 h-3"})})})}),K(Gle,{file_type:Ule(g.file.name||g.name),file_name:g.name||g.file.name,url:g.url,retrieve_tags:[],styles:a,isUploadFile:!0,eventsEmit:s,parse_url:g.convertedFilePath,pdfPages:g.pdfPages||0})]},g.file.name+p)),m=r.map((g,p)=>{const v=g.file.name.split(".").pop()||"",y=F6(v,a);return K(Yle,{cardId:`pending-file-card-${p}`,fileName:g.file.name,fileSize:g.file.size,icon:y,statusText:l[g.status||"pending"],statusColor:"text-gray-400",showRemove:!0,onRemove:()=>i&&i(g,p,"pending"),themeColors:f,style:{boxShadow:"none",height:55,background:"#f8fafc"}},g.file.name+p)});return c.length>0?(f&&f.error&&f.error,f&&f.error&&f.error+"",f&&f.error&&f.error):(f&&f.disabledText&&f.disabledText,f&&f.disabledBackground&&f.disabledBackground,f&&f.disabledText&&f.disabledText),Je(yp,{open:e,onCancel:t,footer:null,title:"\u5BF9\u8BDD\u4E34\u65F6\u6587\u4EF6\u77E5\u8BC6\u5E93",closable:!1,width:800,styles:{body:{padding:"0",maxHeight:"70vh",overflow:"auto"}},children:[Je("div",{className:"file-manager-modal space-y-6 px-4 py-4",children:[Je("div",{className:"",children:[K("div",{className:"flex items-center mb-2 justify-between",children:Je("div",{className:"flex items-center",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5DF2\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[n.length," \u4E2A"]})]})}),K("div",{className:"w-full relative min-h-[200px] max-h-[260px] p-2 overflow-y-auto",style:{overflowX:"hidden"},children:K("div",{className:"flex flex-wrap gap-1",children:h.length>0?h:K("div",{className:"flex items-center w-full h-full py-10 justify-center text-gray-400 text-sm",children:"\u6682\u65E0\u5DF2\u4E0A\u4F20\u6587\u4EF6"})})})]}),Je("div",{children:[Je("div",{className:"flex items-center mb-2",children:[K("span",{className:"text-xs font-semibold text-gray-700",children:"\u5F85\u4E0A\u4F20\u6587\u4EF6"}),Je("span",{className:"ml-2 text-xs text-gray-400",children:[r.length," \u4E2A"]})]}),Je("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[m,K(B8.Dragger,{multiple:!0,showUploadList:!1,beforeUpload:(g,p)=>(g===p[0]&&(o==null||o(p)),!1),className:"!bg-gray-50 !border-dashed !border-gray-300 hover:!border-blue-400 cursor-pointer min-w-[160px] max-w-[220px] flex flex-row items-center justify-center border-2 rounded-lg transition-all",style:{height:45,boxShadow:"none",padding:0},children:Je("div",{className:"flex flex-row items-center pb-8 justify-center",children:[K(PT,{size:20,className:"text-blue-400 mr-2"}),K("div",{className:"text-xs text-gray-500",children:"\u4E0A\u4F20\u6587\u4EF6"})]})})]})]}),K("div",{className:"flex justify-end gap-2",children:K(ko,{type:"primary",onClick:t,children:"\u786E\u8BA4"})})]}),K("style",{children:`
596
596
  .file-manager-modal .ant-upload-wrapper,
597
597
  .file-manager-modal .ant-upload-drag,
598
598
  .file-manager-modal .ant-upload-drag-container {
package/modelManage.d.ts CHANGED
@@ -12,7 +12,7 @@ declare interface ModelManageViewProps {
12
12
  styles?: Styles;
13
13
  CustomComponents?: CustomComponents;
14
14
  eventsEmit?: (name: string, data: any) => void;
15
- hideModelReplace?: boolean;
15
+ showModelReplace?: boolean;
16
16
  getBtnDisabled?: (type: OPT_BTN, permission: number) => boolean;
17
17
  }
18
18
 
package/modelManage.js CHANGED
@@ -1 +1 @@
1
- import{jsx as o,jsxs as V}from"react/jsx-runtime";import{useState as h,useMemo as O,useRef as Q,useEffect as ee}from"react";import{J as L,m as Ie}from"./assets/index-DJPAws60.js";import{b as ve,F as $,S as se,T as ue,i as ae}from"./assets/index-antI2hFx.js";import{O as ne}from"./assets/index-DBPtDW8Y.js";import{D as we}from"./assets/index-4Ac00q5P.js";import{X as ke}from"./assets/x-DxuhxSb6.js";import{M as ce,s as j}from"./assets/style-BeYL_E4J.js";import{T as xe,B as oe}from"./assets/index-q0nZjKAG.js";/* empty css */import{P as Le}from"./assets/plus-qlmqrjBc.js";import"react-dom";const Se=""+new URL("assets/empty.png",import.meta.url).href,Re=({url:s,token:A,role:c,eventsEmit:p})=>{const m=ve.create({baseURL:s,timeout:1e6});return m.interceptors.request.use(e=>{let a=A;return!a&&!["user/login","user/kaptcha","user/regist"].some(l=>e.url.includes(l))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=a||"",e.headers.userName=c==="\u672A\u767B\u5F55\u7528\u6237"?"":c,e)}),m.interceptors.response.use(e=>{const a=["user/kaptcha"],u=e.data;if(a.some(k=>e.config.url&&e.config.url.includes(k))||u.size&&u.type)return u;const{success:l,errorMsg:g,errorCode:x}=u;return l?u:(p&&p("request:error_business",{errorCode:x,errorMsg:g||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:u}),!1)},e=>{var a,u,l,g,x,k,z,W,U;if(e.message==="canceled")return Promise.reject(e);if(p){let v="request:error_network",N={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((a=e==null?void 0:e.response)==null?void 0:a.status)===401?(v="request:error_auth",N={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((l=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:l.errorCode)==="30013"||((x=(g=e==null?void 0:e.response)==null?void 0:g.data)==null?void 0:x.errorCode)==="30023")&&(v="request:error_business",N={errorCode:(z=(k=e==null?void 0:e.response)==null?void 0:k.data)==null?void 0:z.errorCode,errorMsg:((U=(W=e==null?void 0:e.response)==null?void 0:W.data)==null?void 0:U.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(v,N)}return Promise.reject(e)}),{getModelList:async e=>{try{const a=await m.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:u,data:l}=a;if(u)return l}catch(a){return console.log("getModelList error:",a),!1}},delModelById:async e=>{try{const a=await m.delete(`/delete?id=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("delModelById error:",a)}},createModel:async e=>{try{const a=await m.post("/create",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("createModel error:",a)}},updateModelById:async e=>{try{const a=await m.put("/update",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("updateModelById error:",a)}},getUseTypeList:async()=>{try{const e=await m.get("/getModelTypes"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getUseTypeList error:",e),!1}},getModelProtocolsList:async()=>{try{const e=await m.get("/getModelProtocols"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getModelProtocolsList error:",e),!1}},testStatus:async()=>{try{const e=await m.post("/check"),{success:a,data:u}=e;if(a)return u}catch(e){console.log("testStatus error:",e)}},replaceModel:async(e,a)=>{try{const u=await m.get(`/replaceModel?sourceModelId=${e}&targetModelId=${a}`),{success:l,data:g}=u;if(l)return g}catch(u){console.log("replaceModel error:",u)}},checkModel:async e=>{try{const a=await m.get(`/checkModelReference?modelName=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("checkModelReference error:",a)}}}},ze=({drawerTitle:s,drawerVisible:A,modelInfo:c,handleDrawerClose:p,modelUseTypeOpt:m,modelProtocolsOpt:S,eventsEmit:i})=>{const[M,R]=h(!1),[q,n]=h(!1),f=O(()=>({id:"config-model",layout:"vertical",formWidth:"550px",fields:[{id:"modelName",name:"modelName",label:"\u6A21\u578B\u540D\u79F0",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578B\u540D\u79F0",counter:30},{id:"modelIde",name:"modelIde",label:"\u6A21\u578BID",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578BID",defaultValue:""},{id:"apiKey",name:"apiKey",label:"APIKey",type:"input",required:!1,placeholder:"\u8BF7\u8F93\u5165APIKey",defaultValue:""},{id:"url",name:"url",label:"\u8BF7\u6C42URL",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u8BF7\u6C42URL",defaultValue:""},{id:"modelProtocol",name:"modelProtocol",label:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"select",required:!0,options:S},{id:"type",name:"type",label:"\u4F7F\u7528\u7C7B\u578B",type:"select",required:!0,options:m,defaultValue:1,controlledItems:{1:["thinking"]}},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1},{id:"thinking",name:"thinking",label:"\u63A8\u7406\u601D\u8003\u5F00\u5173",type:"switch",required:!1,helpText:"\u5982\u679C\u60A8\u90E8\u7F72\u7684\u6A21\u578B\u672C\u8EAB\u5177\u6709\u63A8\u7406\u601D\u8003\u7684\u5F00\u5173\uFF0C\u60A8\u53EF\u4EE5\u6253\u5F00\u5F53\u524D\u5F00\u5173\u652F\u6301\u63A8\u7406\u601D\u8003\u80FD\u529B\uFF0C\u5982Qwen3"}]}),[c,m,S]),B=Q(null),I=async(u,l,g)=>{var x;switch(console.log("[Form] eventsEmit:",u,l,g),u){case"form:ready":l.formRef&&(B.current=l.formRef);break;case"form:change":if(!((x=B.current)!=null&&x.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const k=await B.current.getValue("type");k==2||k==3?n(!0):n(!1);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,l)}i==null||i(u,l,g)},e=async()=>{try{R(!0);const u=await B.current.getAllData();u.isValid&&(c!=null&&c.id?await i("form_submitted_edit",u,void 0):await i("form_submitted_add",u,void 0))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},a=O(()=>{const u=c==null?void 0:c.data.reduce((l,g)=>(l[g.columnId]=g.value,l),{});return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:f.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:f.id,type:"form",size:"md",formWidth:f.formWidth,formConfig:{layout:f.layout,showReset:!1,showSubmit:!1,formWidth:f.formWidth}}],dataSource:[{id:f.id,fields:f.fields,defaultValues:u||{}}],eventsEmit:I}},[c,q,f]);return o(we,{title:s,placement:"right",width:560,onClose:p,closeIcon:!1,extra:o(ke,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:V("div",{className:"flex justify-end items-center gap-3",children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:p}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:M,onClick:e})]}),children:o(ne,{...a},"example-form")})},{Item:le}=$,Ve=({modelVisible:s,options:A,eventsEmit:c,replaceModel:p})=>{const[m,S]=h(!1),[i]=$.useForm(),M=$.useWatch("sourceModelId",i),R=O(()=>{const n=A.find(f=>f.value==M);return n?A.filter(B=>B.useType==n.useType&&B.value!==M&&B.status==1):[]},[M]);return ee(()=>{M&&i.setFieldValue("targetModelId",void 0)},[M]),V(ce,{open:s,title:"\u6A21\u578B\u66FF\u6362",width:620,destroyOnHidden:!0,onCancel:()=>{i.resetFields(),c&&c("close_model")},footer:V("div",{className:"flex justify-end gap-3",style:{justifyContent:"end",margin:"20px 4px"},children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{i.resetFields(),c&&c("close_model")}}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:m,onClick:async()=>{try{S(!0);const n=await i.validateFields(),{sourceModelId:f,targetModelId:B}=n;await p(f,B)&&(j.success("\u6A21\u578B\u66FF\u6362\u6210\u529F"),i.resetFields(),c&&c("replace_model"))}catch(n){console.log("e---->",n)}finally{S(!1)}}})]}),children:[V("div",{className:"flex gap-3",style:{margin:"20px 4px"},children:[o("div",{children:o(xe,{size:22,color:"#f4a02a"})}),o("span",{className:"text-[14px]",children:"\u5982\u9700\u66F4\u6362\u6A21\u578B\uFF0C\u5728\u4E00\u952E\u66FF\u6362\u65F6\uFF0C\u7CFB\u7EDF\u5C06\u81EA\u52A8\u66F4\u65B0\u77E5\u8BC6\u89E3\u6790\u914D\u7F6E\u3001\u68C0\u7D22\u6D4B\u8BD5\u548C\u52A9\u624B\u914D\u7F6E\u4E2D\u7684\u6A21\u578B\u3002\u82E5\u66FF\u6362\u7684\u662F\u6587\u6863\u89E3\u6790\u7528\u7684Embedding\u6A21\u578B\uFF0C\u5219\u4F7F\u7528\u8BE5\u6A21\u578B\u7684\u6587\u6863\u5C06\u5168\u90E8\u91CD\u65B0\u6392\u961F\u89E3\u6790\uFF0C\u72B6\u6001\u53D8\u4E3A\u201C\u89E3\u6790\u4E2D\u201D\uFF0C\u4E14\u672A\u89E3\u6790\u5B8C\u6210\u7684\u6587\u6863\u6682\u4E0D\u53EF\u68C0\u7D22\uFF01"})]}),V($,{form:i,colon:!1,labelCol:{span:5},wrapperCol:{span:18},style:{margin:"40px 60px"},children:[o(le,{label:"\u6A21\u578B\u540D\u79F0",name:"sourceModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:A})}),o(le,{label:"\u66FF\u6362\u4E3A",name:"targetModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:R})})]})]})},X={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},J=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0},{statusType:"warning",value:"\u68C0\u6D4B\u4E2D",status:2}],qe=s=>typeof s=="string"&&s in X?X[s]:X.default;var K=(s=>(s[s.DATE=0]="DATE",s[s.VIEW=1]="VIEW",s[s.ERROR=2]="ERROR",s[s.AUTHORIZE=3]="AUTHORIZE",s[s.DELETE=4]="DELETE",s[s.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",s[s.DOWNLOAD=6]="DOWNLOAD",s[s.EDIT=7]="EDIT",s[s.ADD=8]="ADD",s[s.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",s[s.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",s))(K||{});const{confirm:re}=ce,Ue={pageNum:1,pageSize:1e3},Ne=s=>{const{value:A,cell:c}=s,p=qe(s.cell.statusType);return A=="\u4E0D\u53EF\u7528"?o(ue,{title:c.errorMsg,children:o("div",{className:"flex items-center gap-2",children:o(oe,{color:p,text:A})})}):o(oe,{color:p,text:A})};function Xe(s){const{url:A,token:c,role:p,CustomComponents:m,eventsEmit:S,getBtnDisabled:i,hideModelReplace:M}=s,[R,q]=h({container:"ready",content:"ready"}),n=Q(null),[f,B]=h(),I=Q(null),[e,a]=h(!1),[u,l]=h(!1),[g,x]=h([]),[k,z]=h(!1),[W,U]=h(""),[v,N]=h(),[Z,ie]=h([]),[P,de]=h([]),{getModelList:Fe,delModelById:me,createModel:pe,updateModelById:fe,getUseTypeList:ye,getModelProtocolsList:ge,testStatus:Ae,replaceModel:Be,checkModel:Ee}=Re({url:A,token:c,role:p,eventsEmit:S});ee(()=>{q(r=>({...r,content:"loading"})),G(),he()},[]),ee(()=>{},[k]);const De=r=>(r||[]).map((t,F)=>{let d=J.find(w=>w.status==t.status);return{id:t.id,data:[{columnId:"modelName",value:t.modelName},{columnId:"modelProtocol",value:t.modelProtocol,type:"customized"},{columnId:"type",value:t.type,type:"customized"},{columnId:"dec",value:t.dec},{columnId:"status",...d,type:"customized",errorMsg:t.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",status:t.status,type:"action",disabled:i&&i(K.EDIT,t.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"url",value:t.url},{columnId:"apiKey",value:t.apiKey},{columnId:"modelIde",value:t.modelIde},{columnId:"thinking",value:t.thinking}]}}),he=async()=>{try{const[r,t]=await Promise.allSettled([ye(),ge()]);r.status==="fulfilled"&&r.value&&ie((r.value||[]).map(F=>({...F,value:Number(F.value)}))),t.status==="fulfilled"&&t.value&&de((t.value||[]).map(F=>({...F,value:Number(F.value)})))}catch(r){console.error("[TableApiError] getTableList:",r)}},te=async()=>{try{const r=await Fe(Ue);if(r.records){const t=De(r.records),F=(r.records||[]).map(d=>({value:d.id,label:d.modelName,useType:d.type,status:d.status}));return x(F),B(t||[]),q(d=>({...d,content:"ready"})),t||[]}}catch(r){console.error("[TableApiError] getTableList:",r)}},G=async()=>{const r=await te();be(r||[])?I.current&&(clearTimeout(I.current),I.current=null):(I.current&&(clearTimeout(I.current),I.current=null),I.current=setTimeout(()=>{G()},5e3))};function be(r){if(!Array.isArray(r))return!0;for(const t of r)if(t.data){const F=t.data.find(d=>d.columnId==="status");if(F&&F.status===2)return!1}return!0}const Ce=O(()=>({label:"\u6570\u636E\u5E93\u8868\u683C",defaultActiveId:"model-table",model:null,views:[{label:"\u6A21\u578B",id:"model-table",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"modelName",title:"\u6A21\u578B\u540D\u79F0",type:"label"},{id:"modelProtocol",title:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=P.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=Z.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"dec",title:"\u8BF4\u660E",type:"paragraph"},{id:"status",title:"\u72B6\u6001",type:"customized",component:o(Ne,{}),helpText:"\u5F53\u524D\u6A21\u578B\u72B6\u6001\u4E3A\u521D\u6B21\u65B0\u589E\u6821\u9A8C\u72B6\u6001\uFF0C\u82E5\u6A21\u578B\u4E0B\u7EBF\uFF0C\u6B64\u72B6\u6001\u4E0D\u4F1A\u4E3B\u52A8\u66F4\u65B0\uFF0C\u9700\u624B\u52A8\u6267\u884C\u6A21\u578B\u5220\u9664"},{id:"actions",title:"\u64CD\u4F5C",type:"customized",component:r=>{const{value:t,cell:F,row:d}=r,{disabled:w,label:T,status:_}=F;return _==2?o(ue,{title:"\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u7A0D\u540E",children:o(L,{mode:"text",label:T,disabled:!0})}):w?o(ue,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:o(L,{mode:"text",label:T,disabled:w})}):o(L,{mode:"text",label:T,onClick:()=>H(`table_action_${t}`,d,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:o(Le,{})},...M?[]:[{type:"customized",key:"test",render:()=>o(L,{loading:e,mode:"primary",label:"\u6A21\u578B\u72B6\u6001\u68C0\u6D4B",onClick:()=>{H("toolbar_test")}})},{type:"button",btnType:"primary",key:"replace",label:"\u6A21\u578B\u66FF\u6362"}]]}]}),[f,Z,P,e,M]),Me=()=>V("div",{className:"flex flex-col items-center justify-center h-full",children:[o("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:o("img",{src:Se,width:120})}),o("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u65B0\u5EFA\u6A21\u578B"}),o("div",{className:"flex gap-3",children:o(L,{mode:"primary",label:"\u65B0\u5EFA\u6A21\u578B",onClick:()=>{U("\u65B0\u5EFA"),z(!0)}})})]});async function H(r,t,F){var d,w,T,_;switch(console.log("[adopter] mergedEventsEmit",r,t,F),r){case"toolbar_add":{U("\u65B0\u5EFA"),z(!0);break}case"toolbar_test":{a(!0),await Ae()&&(a(!1),await G(),j.success("\u6A21\u578B\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u72B6\u6001\u66F4\u65B0\uFF01"));break}case"toolbar_replace":{l(!0);break}case"table_action_delete":{try{const b=t.data.find(D=>D.columnId=="modelName").value;if(await Ee(b)>0)re({title:"\u5220\u9664\u6A21\u578B",content:o("div",{style:{marginRight:"20px"},children:"\u5F53\u524D\u6A21\u578B\u5728\u7CFB\u7EDF\u5185\u5DF2\u88AB\u914D\u7F6E\u4F7F\u7528\uFF0C\u5220\u9664\u53EF\u80FD\u5F71\u54CD\u6587\u6863\u89E3\u6790\u3001\u95EE\u7B54\u3001\u591A\u6A21\u6001\u80FD\u529B\u4F7F\u7528\u7B49\uFF0C\u8BF7\u60A8\u5148\u4F7F\u7528\u201C\u6A21\u578B\u4E00\u952E\u66FF\u6362\u201D\u80FD\u529B\u5C06\u8BE5\u6A21\u578B\u66FF\u6362\u4E3A\u540C\u7C7B\u578B\u6A21\u578B\uFF0C\u518D\u5220\u9664\u6A21\u578B"}),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88"});else{const D=t.data.find(C=>C.columnId=="modelName").value;re({title:"\u786E\u8BA4\u5220\u9664\uFF1F",content:`\u786E\u5B9A\u8981\u5220\u9664\u6A21\u578B \u201C${D}\u201D \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`,okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await me(t.id)&&(n!=null&&n.current)&&(n==null||n.current.appFn.removeItem(t.id),j.success("\u5220\u9664\u6210\u529F"))}})}}catch(b){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",b)}break}case"table_action_edit":{U("\u7F16\u8F91"),z(!0),N(t);break}case"form_submitted_add":{try{const b=t.fields.reduce((D,C)=>(D[C.name]=C.value,D),{}),E=await pe({...b});if(E){let D=J.find(y=>y.status==E.status);const C={id:E.id,data:[...(Object.keys(E)||[]).map(y=>({columnId:y,value:E[y],...(y=="modelProtocol"||y=="type")&&{type:"customized"},...y=="status"&&{...D,type:"customized",errorMsg:E.errorMsg}})),{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(w=(d=n==null?void 0:n.current)==null?void 0:d.appFn)==null||w.addItem(C,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(b){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",b)}finally{Y()}break}case"form_submitted_edit":{try{const b=t.fields.reduce((D,C)=>(D[C.name]=C.value,D),{}),E=await fe({...b,id:v.id});if(E){let D=J.find(y=>y.status==E.status);const C={...v,data:v.data.map(y=>{if(E[y.columnId]!==null&&E[y.columnId]!==void 0){if(y.columnId=="status")return{...y,...D};y.value=E[y.columnId]}return y})};(_=(T=n==null?void 0:n.current)==null?void 0:T.appFn)==null||_.updateItem(C,v==null?void 0:v.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(b){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",b)}finally{Y()}break}case"replace_model":{await te(),l(!1);break}case"close_model":{l(!1);break}default:typeof s.eventsEmit=="function"&&s.eventsEmit(r,t);break}}const Y=()=>{z(!1),N(void 0)};return V(Ie,{title:"\u6A21\u578B\u7BA1\u7406",children:[o(ne,{dataSource:f,ref:n,eventsEmit:H,status:R,CustomComponents:{EmptyData:Me,...m},styles:{theme:{...ae,colors:{...ae.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},...Ce}),o(ze,{drawerTitle:W,drawerVisible:k,handleDrawerClose:Y,modelInfo:v,modelUseTypeOpt:Z,modelProtocolsOpt:P,eventsEmit:H}),o(Ve,{modelVisible:u,options:g,eventsEmit:H,replaceModel:Be})]})}export{Xe as default};
1
+ import{jsx as o,jsxs as V}from"react/jsx-runtime";import{useState as h,useMemo as O,useRef as Q,useEffect as ee}from"react";import{J as L,m as Ie}from"./assets/index-DJPAws60.js";import{b as ve,F as $,S as se,T as ue,i as ae}from"./assets/index-antI2hFx.js";import{O as ne}from"./assets/index-DBPtDW8Y.js";import{D as we}from"./assets/index-4Ac00q5P.js";import{X as ke}from"./assets/x-DxuhxSb6.js";import{M as ce,s as j}from"./assets/style-BeYL_E4J.js";import{T as xe,B as oe}from"./assets/index-q0nZjKAG.js";/* empty css */import{P as Le}from"./assets/plus-qlmqrjBc.js";import"react-dom";const Se=""+new URL("assets/empty.png",import.meta.url).href,Re=({url:s,token:A,role:c,eventsEmit:p})=>{const m=ve.create({baseURL:s,timeout:1e6});return m.interceptors.request.use(e=>{let a=A;return!a&&!["user/login","user/kaptcha","user/regist"].some(l=>e.url.includes(l))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=a||"",e.headers.userName=c==="\u672A\u767B\u5F55\u7528\u6237"?"":c,e)}),m.interceptors.response.use(e=>{const a=["user/kaptcha"],u=e.data;if(a.some(k=>e.config.url&&e.config.url.includes(k))||u.size&&u.type)return u;const{success:l,errorMsg:g,errorCode:x}=u;return l?u:(p&&p("request:error_business",{errorCode:x,errorMsg:g||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:u}),!1)},e=>{var a,u,l,g,x,k,z,W,U;if(e.message==="canceled")return Promise.reject(e);if(p){let v="request:error_network",N={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((a=e==null?void 0:e.response)==null?void 0:a.status)===401?(v="request:error_auth",N={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((l=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:l.errorCode)==="30013"||((x=(g=e==null?void 0:e.response)==null?void 0:g.data)==null?void 0:x.errorCode)==="30023")&&(v="request:error_business",N={errorCode:(z=(k=e==null?void 0:e.response)==null?void 0:k.data)==null?void 0:z.errorCode,errorMsg:((U=(W=e==null?void 0:e.response)==null?void 0:W.data)==null?void 0:U.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(v,N)}return Promise.reject(e)}),{getModelList:async e=>{try{const a=await m.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:u,data:l}=a;if(u)return l}catch(a){return console.log("getModelList error:",a),!1}},delModelById:async e=>{try{const a=await m.delete(`/delete?id=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("delModelById error:",a)}},createModel:async e=>{try{const a=await m.post("/create",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("createModel error:",a)}},updateModelById:async e=>{try{const a=await m.put("/update",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("updateModelById error:",a)}},getUseTypeList:async()=>{try{const e=await m.get("/getModelTypes"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getUseTypeList error:",e),!1}},getModelProtocolsList:async()=>{try{const e=await m.get("/getModelProtocols"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getModelProtocolsList error:",e),!1}},testStatus:async()=>{try{const e=await m.post("/check"),{success:a,data:u}=e;if(a)return u}catch(e){console.log("testStatus error:",e)}},replaceModel:async(e,a)=>{try{const u=await m.get(`/replaceModel?sourceModelId=${e}&targetModelId=${a}`),{success:l,data:g}=u;if(l)return g}catch(u){console.log("replaceModel error:",u)}},checkModel:async e=>{try{const a=await m.get(`/checkModelReference?modelName=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("checkModelReference error:",a)}}}},ze=({drawerTitle:s,drawerVisible:A,modelInfo:c,handleDrawerClose:p,modelUseTypeOpt:m,modelProtocolsOpt:S,eventsEmit:i})=>{const[M,R]=h(!1),[q,n]=h(!1),f=O(()=>({id:"config-model",layout:"vertical",formWidth:"550px",fields:[{id:"modelName",name:"modelName",label:"\u6A21\u578B\u540D\u79F0",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578B\u540D\u79F0",counter:30},{id:"modelIde",name:"modelIde",label:"\u6A21\u578BID",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578BID",defaultValue:""},{id:"apiKey",name:"apiKey",label:"APIKey",type:"input",required:!1,placeholder:"\u8BF7\u8F93\u5165APIKey",defaultValue:""},{id:"url",name:"url",label:"\u8BF7\u6C42URL",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u8BF7\u6C42URL",defaultValue:""},{id:"modelProtocol",name:"modelProtocol",label:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"select",required:!0,options:S},{id:"type",name:"type",label:"\u4F7F\u7528\u7C7B\u578B",type:"select",required:!0,options:m,defaultValue:1,controlledItems:{1:["thinking"]}},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1},{id:"thinking",name:"thinking",label:"\u63A8\u7406\u601D\u8003\u5F00\u5173",type:"switch",required:!1,helpText:"\u5982\u679C\u60A8\u90E8\u7F72\u7684\u6A21\u578B\u672C\u8EAB\u5177\u6709\u63A8\u7406\u601D\u8003\u7684\u5F00\u5173\uFF0C\u60A8\u53EF\u4EE5\u6253\u5F00\u5F53\u524D\u5F00\u5173\u652F\u6301\u63A8\u7406\u601D\u8003\u80FD\u529B\uFF0C\u5982Qwen3"}]}),[c,m,S]),B=Q(null),I=async(u,l,g)=>{var x;switch(console.log("[Form] eventsEmit:",u,l,g),u){case"form:ready":l.formRef&&(B.current=l.formRef);break;case"form:change":if(!((x=B.current)!=null&&x.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const k=await B.current.getValue("type");k==2||k==3?n(!0):n(!1);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,l)}i==null||i(u,l,g)},e=async()=>{try{R(!0);const u=await B.current.getAllData();u.isValid&&(c!=null&&c.id?await i("form_submitted_edit",u,void 0):await i("form_submitted_add",u,void 0))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},a=O(()=>{const u=c==null?void 0:c.data.reduce((l,g)=>(l[g.columnId]=g.value,l),{});return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:f.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:f.id,type:"form",size:"md",formWidth:f.formWidth,formConfig:{layout:f.layout,showReset:!1,showSubmit:!1,formWidth:f.formWidth}}],dataSource:[{id:f.id,fields:f.fields,defaultValues:u||{}}],eventsEmit:I}},[c,q,f]);return o(we,{title:s,placement:"right",width:560,onClose:p,closeIcon:!1,extra:o(ke,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:V("div",{className:"flex justify-end items-center gap-3",children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:p}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:M,onClick:e})]}),children:o(ne,{...a},"example-form")})},{Item:le}=$,Ve=({modelVisible:s,options:A,eventsEmit:c,replaceModel:p})=>{const[m,S]=h(!1),[i]=$.useForm(),M=$.useWatch("sourceModelId",i),R=O(()=>{const n=A.find(f=>f.value==M);return n?A.filter(B=>B.useType==n.useType&&B.value!==M&&B.status==1):[]},[M]);return ee(()=>{M&&i.setFieldValue("targetModelId",void 0)},[M]),V(ce,{open:s,title:"\u6A21\u578B\u66FF\u6362",width:620,destroyOnHidden:!0,onCancel:()=>{i.resetFields(),c&&c("close_model")},footer:V("div",{className:"flex justify-end gap-3",style:{justifyContent:"end",margin:"20px 4px"},children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{i.resetFields(),c&&c("close_model")}}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:m,onClick:async()=>{try{S(!0);const n=await i.validateFields(),{sourceModelId:f,targetModelId:B}=n;await p(f,B)&&(j.success("\u6A21\u578B\u66FF\u6362\u6210\u529F"),i.resetFields(),c&&c("replace_model"))}catch(n){console.log("e---->",n)}finally{S(!1)}}})]}),children:[V("div",{className:"flex gap-3",style:{margin:"20px 4px"},children:[o("div",{children:o(xe,{size:22,color:"#f4a02a"})}),o("span",{className:"text-[14px]",children:"\u5982\u9700\u66F4\u6362\u6A21\u578B\uFF0C\u5728\u4E00\u952E\u66FF\u6362\u65F6\uFF0C\u7CFB\u7EDF\u5C06\u81EA\u52A8\u66F4\u65B0\u77E5\u8BC6\u89E3\u6790\u914D\u7F6E\u3001\u68C0\u7D22\u6D4B\u8BD5\u548C\u52A9\u624B\u914D\u7F6E\u4E2D\u7684\u6A21\u578B\u3002\u82E5\u66FF\u6362\u7684\u662F\u6587\u6863\u89E3\u6790\u7528\u7684Embedding\u6A21\u578B\uFF0C\u5219\u4F7F\u7528\u8BE5\u6A21\u578B\u7684\u6587\u6863\u5C06\u5168\u90E8\u91CD\u65B0\u6392\u961F\u89E3\u6790\uFF0C\u72B6\u6001\u53D8\u4E3A\u201C\u89E3\u6790\u4E2D\u201D\uFF0C\u4E14\u672A\u89E3\u6790\u5B8C\u6210\u7684\u6587\u6863\u6682\u4E0D\u53EF\u68C0\u7D22\uFF01"})]}),V($,{form:i,colon:!1,labelCol:{span:5},wrapperCol:{span:18},style:{margin:"40px 60px"},children:[o(le,{label:"\u6A21\u578B\u540D\u79F0",name:"sourceModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:A})}),o(le,{label:"\u66FF\u6362\u4E3A",name:"targetModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:R})})]})]})},X={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},J=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0},{statusType:"warning",value:"\u68C0\u6D4B\u4E2D",status:2}],qe=s=>typeof s=="string"&&s in X?X[s]:X.default;var K=(s=>(s[s.DATE=0]="DATE",s[s.VIEW=1]="VIEW",s[s.ERROR=2]="ERROR",s[s.AUTHORIZE=3]="AUTHORIZE",s[s.DELETE=4]="DELETE",s[s.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",s[s.DOWNLOAD=6]="DOWNLOAD",s[s.EDIT=7]="EDIT",s[s.ADD=8]="ADD",s[s.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",s[s.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",s))(K||{});const{confirm:re}=ce,Ue={pageNum:1,pageSize:1e3},Ne=s=>{const{value:A,cell:c}=s,p=qe(s.cell.statusType);return A=="\u4E0D\u53EF\u7528"?o(ue,{title:c.errorMsg,children:o("div",{className:"flex items-center gap-2",children:o(oe,{color:p,text:A})})}):o(oe,{color:p,text:A})};function Xe(s){const{url:A,token:c,role:p,CustomComponents:m,eventsEmit:S,getBtnDisabled:i,showModelReplace:M}=s,[R,q]=h({container:"ready",content:"ready"}),n=Q(null),[f,B]=h(),I=Q(null),[e,a]=h(!1),[u,l]=h(!1),[g,x]=h([]),[k,z]=h(!1),[W,U]=h(""),[v,N]=h(),[Z,ie]=h([]),[P,de]=h([]),{getModelList:Fe,delModelById:me,createModel:pe,updateModelById:fe,getUseTypeList:ye,getModelProtocolsList:ge,testStatus:Ae,replaceModel:Be,checkModel:Ee}=Re({url:A,token:c,role:p,eventsEmit:S});ee(()=>{q(r=>({...r,content:"loading"})),G(),he()},[]),ee(()=>{},[k]);const De=r=>(r||[]).map((t,F)=>{let d=J.find(w=>w.status==t.status);return{id:t.id,data:[{columnId:"modelName",value:t.modelName},{columnId:"modelProtocol",value:t.modelProtocol,type:"customized"},{columnId:"type",value:t.type,type:"customized"},{columnId:"dec",value:t.dec},{columnId:"status",...d,type:"customized",errorMsg:t.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",status:t.status,type:"action",disabled:i&&i(K.EDIT,t.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"url",value:t.url},{columnId:"apiKey",value:t.apiKey},{columnId:"modelIde",value:t.modelIde},{columnId:"thinking",value:t.thinking}]}}),he=async()=>{try{const[r,t]=await Promise.allSettled([ye(),ge()]);r.status==="fulfilled"&&r.value&&ie((r.value||[]).map(F=>({...F,value:Number(F.value)}))),t.status==="fulfilled"&&t.value&&de((t.value||[]).map(F=>({...F,value:Number(F.value)})))}catch(r){console.error("[TableApiError] getTableList:",r)}},te=async()=>{try{const r=await Fe(Ue);if(r.records){const t=De(r.records),F=(r.records||[]).map(d=>({value:d.id,label:d.modelName,useType:d.type,status:d.status}));return x(F),B(t||[]),q(d=>({...d,content:"ready"})),t||[]}}catch(r){console.error("[TableApiError] getTableList:",r)}},G=async()=>{const r=await te();be(r||[])?I.current&&(clearTimeout(I.current),I.current=null):(I.current&&(clearTimeout(I.current),I.current=null),I.current=setTimeout(()=>{G()},5e3))};function be(r){if(!Array.isArray(r))return!0;for(const t of r)if(t.data){const F=t.data.find(d=>d.columnId==="status");if(F&&F.status===2)return!1}return!0}const Ce=O(()=>({label:"\u6570\u636E\u5E93\u8868\u683C",defaultActiveId:"model-table",model:null,views:[{label:"\u6A21\u578B",id:"model-table",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"modelName",title:"\u6A21\u578B\u540D\u79F0",type:"label"},{id:"modelProtocol",title:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=P.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=Z.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"dec",title:"\u8BF4\u660E",type:"paragraph"},{id:"status",title:"\u72B6\u6001",type:"customized",component:o(Ne,{}),helpText:"\u5F53\u524D\u6A21\u578B\u72B6\u6001\u4E3A\u521D\u6B21\u65B0\u589E\u6821\u9A8C\u72B6\u6001\uFF0C\u82E5\u6A21\u578B\u4E0B\u7EBF\uFF0C\u6B64\u72B6\u6001\u4E0D\u4F1A\u4E3B\u52A8\u66F4\u65B0\uFF0C\u9700\u624B\u52A8\u6267\u884C\u6A21\u578B\u5220\u9664"},{id:"actions",title:"\u64CD\u4F5C",type:"customized",component:r=>{const{value:t,cell:F,row:d}=r,{disabled:w,label:T,status:_}=F;return _==2?o(ue,{title:"\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u7A0D\u540E",children:o(L,{mode:"text",label:T,disabled:!0})}):w?o(ue,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:o(L,{mode:"text",label:T,disabled:w})}):o(L,{mode:"text",label:T,onClick:()=>H(`table_action_${t}`,d,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:o(Le,{})},...M?[{type:"customized",key:"test",render:()=>o(L,{loading:e,mode:"primary",label:"\u6A21\u578B\u72B6\u6001\u68C0\u6D4B",onClick:()=>{H("toolbar_test")}})},{type:"button",btnType:"primary",key:"replace",label:"\u6A21\u578B\u66FF\u6362"}]:[]]}]}),[f,Z,P,e,M]),Me=()=>V("div",{className:"flex flex-col items-center justify-center h-full",children:[o("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:o("img",{src:Se,width:120})}),o("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u65B0\u5EFA\u6A21\u578B"}),o("div",{className:"flex gap-3",children:o(L,{mode:"primary",label:"\u65B0\u5EFA\u6A21\u578B",onClick:()=>{U("\u65B0\u5EFA"),z(!0)}})})]});async function H(r,t,F){var d,w,T,_;switch(console.log("[adopter] mergedEventsEmit",r,t,F),r){case"toolbar_add":{U("\u65B0\u5EFA"),z(!0);break}case"toolbar_test":{a(!0),await Ae()&&(a(!1),await G(),j.success("\u6A21\u578B\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u72B6\u6001\u66F4\u65B0\uFF01"));break}case"toolbar_replace":{l(!0);break}case"table_action_delete":{try{const b=t.data.find(D=>D.columnId=="modelName").value;if(await Ee(b)>0)re({title:"\u5220\u9664\u6A21\u578B",content:o("div",{style:{marginRight:"20px"},children:"\u5F53\u524D\u6A21\u578B\u5728\u7CFB\u7EDF\u5185\u5DF2\u88AB\u914D\u7F6E\u4F7F\u7528\uFF0C\u5220\u9664\u53EF\u80FD\u5F71\u54CD\u6587\u6863\u89E3\u6790\u3001\u95EE\u7B54\u3001\u591A\u6A21\u6001\u80FD\u529B\u4F7F\u7528\u7B49\uFF0C\u8BF7\u60A8\u5148\u4F7F\u7528\u201C\u6A21\u578B\u4E00\u952E\u66FF\u6362\u201D\u80FD\u529B\u5C06\u8BE5\u6A21\u578B\u66FF\u6362\u4E3A\u540C\u7C7B\u578B\u6A21\u578B\uFF0C\u518D\u5220\u9664\u6A21\u578B"}),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88"});else{const D=t.data.find(C=>C.columnId=="modelName").value;re({title:"\u786E\u8BA4\u5220\u9664\uFF1F",content:`\u786E\u5B9A\u8981\u5220\u9664\u6A21\u578B \u201C${D}\u201D \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`,okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await me(t.id)&&(n!=null&&n.current)&&(n==null||n.current.appFn.removeItem(t.id),j.success("\u5220\u9664\u6210\u529F"))}})}}catch(b){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",b)}break}case"table_action_edit":{U("\u7F16\u8F91"),z(!0),N(t);break}case"form_submitted_add":{try{const b=t.fields.reduce((D,C)=>(D[C.name]=C.value,D),{}),E=await pe({...b});if(E){let D=J.find(y=>y.status==E.status);const C={id:E.id,data:[...(Object.keys(E)||[]).map(y=>({columnId:y,value:E[y],...(y=="modelProtocol"||y=="type")&&{type:"customized"},...y=="status"&&{...D,type:"customized",errorMsg:E.errorMsg}})),{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(w=(d=n==null?void 0:n.current)==null?void 0:d.appFn)==null||w.addItem(C,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(b){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",b)}finally{Y()}break}case"form_submitted_edit":{try{const b=t.fields.reduce((D,C)=>(D[C.name]=C.value,D),{}),E=await fe({...b,id:v.id});if(E){let D=J.find(y=>y.status==E.status);const C={...v,data:v.data.map(y=>{if(E[y.columnId]!==null&&E[y.columnId]!==void 0){if(y.columnId=="status")return{...y,...D};y.value=E[y.columnId]}return y})};(_=(T=n==null?void 0:n.current)==null?void 0:T.appFn)==null||_.updateItem(C,v==null?void 0:v.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(b){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",b)}finally{Y()}break}case"replace_model":{await te(),l(!1);break}case"close_model":{l(!1);break}default:typeof s.eventsEmit=="function"&&s.eventsEmit(r,t);break}}const Y=()=>{z(!1),N(void 0)};return V(Ie,{title:"\u6A21\u578B\u7BA1\u7406",children:[o(ne,{dataSource:f,ref:n,eventsEmit:H,status:R,CustomComponents:{EmptyData:Me,...m},styles:{theme:{...ae,colors:{...ae.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},...Ce}),o(ze,{drawerTitle:W,drawerVisible:k,handleDrawerClose:Y,modelInfo:v,modelUseTypeOpt:Z,modelProtocolsOpt:P,eventsEmit:H}),o(Ve,{modelVisible:u,options:g,eventsEmit:H,replaceModel:Be})]})}export{Xe as default};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "style": "assets/style.css",
5
5
  "private": false,
6
- "version": "1.9.7",
6
+ "version": "1.9.9",
7
7
  "author": "hanfeng_Zhang",
8
8
  "type": "module",
9
9
  "main": "index.js",