@gientech/modual 2.2.3-fix.3 → 2.2.3-fix.4
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.
|
@@ -940,4 +940,4 @@ ${v.substring(ne)}`;y(me),requestAnimationFrame(()=>{ee.selectionStart=ee.select
|
|
|
940
940
|
relative w-[35px] h-8 flex items-center justify-center rounded-full group overflow-hidden shadow-sm
|
|
941
941
|
transition-all duration-200
|
|
942
942
|
${r==="processing"?"animate-pulse":""}
|
|
943
|
-
`,style:{cursor:r==="processing"||O?"pointer":"not-allowed",background:r==="processing"?"#222222":O?`linear-gradient(to bottom right, ${B}, ${(L==null?void 0:L.primary)||"#0275d8"})`:q},onClick:()=>{r==="processing"?e&&e("sender:stop",{}):O&&e&&e("sender:send")},title:r==="processing"?"\u505C\u6B62\u5F53\u524D\u5BF9\u8BDD":"\u53D1\u9001",children:_e("div",{className:"relative flex items-center gap-x-1 font-medium",style:{color:!O&&r!=="processing"?Y:"#ffffff"},children:r==="processing"?_e(aDe,{size:46,color:"#ffffff",circleColor:"#ffffff"}):_e(pQ,{size:20,className:O?"sender-icon-active":"",style:{color:O?"#ffffff":Y,strokeWidth:2.5}})})})]})]})]})}),_e("div",{className:"mt-2 pt-2 pb-3 px-1 flex items-center justify-between ",children:_e("span",{className:"text-[10px]",style:{color:X}})})]}),d&&_e("div",{className:" absolute bottom-3 left-0 right-0 w-full text-xs text-center",children:_e("div",{className:"text-xs text-center",style:{color:Y},children:d})})]})]})}const uDe={sm:"240px",md:"260px",lg:"280px"},cDe={sm:"12px",md:"16px",lg:"20px"},dDe={sm:"2px",md:"4px",lg:"8px"},hDe={sm:"4px",md:"8px",lg:"16px"},fDe={sm:"4px",md:"8px",lg:"16px"},pDe={sm:"0 1px 2px #eee",md:"0 2px 8px #ddd",lg:"0 4px 16px #ccc"},gDe={sm:"1.2",md:"1.5",lg:"2"};function mDe(t){return{...t,size:cDe[t.size]||t.size,radius:dDe[t.radius]||t.radius,padding:hDe[t.padding]||t.padding,margin:fDe[t.margin]||t.margin,shadow:pDe[t.shadow]||t.shadow,lineHeight:gDe[t.lineHeight]||t.lineHeight,sidebar:uDe[t.sidebar]||t.sidebar}}function Pk(t,e){if(!e)return t;const n=Array.isArray(t)?[...t]:{...t};for(const r in e)if(e[r]!==void 0&&e[r]!==null&&Object.prototype.hasOwnProperty.call(e,r))if(r==="actions"&&Array.isArray(t[r])&&Array.isArray(e[r])){const i=new Map;t[r].forEach(a=>{a.name&&i.set(a.name,a)}),e[r].forEach(a=>{a.name&&i.set(a.name,a)}),n[r]=Array.from(i.values())}else typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])&&typeof e[r]=="object"&&e[r]!==null&&!Array.isArray(e[r])?n[r]=Pk(t[r],e[r]):n[r]=e[r];return n}const vDe=t=>_.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},_.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 14.6666C11.6819 14.6666 14.6667 11.6819 14.6667 7.99998C14.6667 4.31808 11.6819 1.33331 8 1.33331C4.3181 1.33331 1.33334 4.31808 1.33334 7.99998C1.33334 11.6819 4.3181 14.6666 8 14.6666Z",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M1.33334 8H14.6667",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 14.6666C9.47277 14.6666 10.6667 11.6819 10.6667 7.99998C10.6667 4.31808 9.47277 1.33331 8 1.33331C6.52724 1.33331 5.33334 4.31808 5.33334 7.99998C5.33334 11.6819 6.52724 14.6666 8 14.6666Z",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M3.28597 3.38068C4.4924 4.58711 6.15907 5.33331 8 5.33331C9.84097 5.33331 11.5076 4.58711 12.7141 3.38068",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M12.7141 12.6193C11.5076 11.4129 9.84097 10.6667 8 10.6667C6.15907 10.6667 4.4924 11.4129 3.28597 12.6193",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"})),yDe=t=>_.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},_.createElement("path",{d:"M1.73633 1.57642C2.53848 0.774265 3.74473 0.714862 4.87207 1.03052C6.02182 1.35245 7.24885 2.09683 8.3125 3.1604C9.37624 4.22414 10.1204 5.45195 10.4424 6.60181C10.758 7.72909 10.6986 8.93446 9.89648 9.73657C9.09439 10.5387 7.88901 10.5981 6.76172 10.2825C5.61186 9.96051 4.38405 9.21632 3.32031 8.15259C2.25674 7.08894 1.51236 5.86191 1.19043 4.71216C0.874775 3.58481 0.934176 2.37857 1.73633 1.57642Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M6.76172 5.41479C7.88883 5.09929 9.09442 5.15888 9.89648 5.96069C10.6986 6.76284 10.758 7.96909 10.4424 9.09644C10.1204 10.2462 9.37617 11.4732 8.3125 12.5369C7.24882 13.6005 6.02187 14.3448 4.87207 14.6667C3.74472 14.9824 2.53848 14.923 1.73633 14.1208C0.934528 13.3188 0.874922 12.1132 1.19043 10.9861C1.51239 9.83623 2.25659 8.60841 3.32031 7.54468C4.38405 6.48096 5.61186 5.73675 6.76172 5.41479Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M11.1282 1.03052C12.2553 0.715012 13.4609 0.774612 14.263 1.57642C15.0651 2.37857 15.1246 3.58481 14.8089 4.71216C14.4869 5.86196 13.7427 7.08892 12.679 8.15259C11.6153 9.21627 10.3884 9.96048 9.23859 10.2825C8.11124 10.5981 6.90499 10.5387 6.10284 9.73657C5.30106 8.9345 5.24144 7.72892 5.55695 6.60181C5.8789 5.45195 6.62311 4.22414 7.68683 3.1604C8.75056 2.09668 9.97838 1.35248 11.1282 1.03052Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M6.10284 5.96069C6.90499 5.15855 8.11124 5.09914 9.23859 5.41479C10.3883 5.73673 11.6154 6.48111 12.679 7.54468C13.7427 8.60841 14.4869 9.83623 14.8089 10.9861C15.1245 12.1134 15.0651 13.3188 14.263 14.1208C13.4609 14.9229 12.2555 14.9823 11.1282 14.6667C9.97838 14.3448 8.75055 13.6006 7.68683 12.5369C6.62325 11.4732 5.87888 10.2462 5.55695 9.09644C5.24129 7.96909 5.3007 6.76284 6.10284 5.96069Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"})),QB={actions:[{name:"upload",icon:_e(di,{type:"wenda/shangchuanwenjian",color:"#000",size:20}),tip:"\u6587\u4EF6\u4E0A\u4F20"}],switchs:[{label:"\u8054\u7F51\u641C\u7D22",name:"netSearch",type:"switch",defaultValue:!1,enabled:!0,icon:_e(vDe,{width:16,height:16,className:"aichat-netsearch-icon",style:{color:"#4B8CF7"}})},{label:"\u6DF1\u5EA6\u601D\u8003",name:"reasoning",type:"switch",defaultValue:!0,enabled:!0,icon:_e(yDe,{width:16,height:16})}]};function bDe({senderConfig:t,handleEventsEmit:e}){const[n,r]=bt(""),[i,a]=bt([]);$t(()=>{console.log("uploadedFiles",i)},[i]);const o=()=>{r(""),i.forEach(f=>{f.preview&&f.type==="image"&&URL.revokeObjectURL(f.preview)}),console.log("=============1"),a([])},s=f=>{r(f)},l=f=>{console.log("Sending message:",f)},u=f=>f.type.startsWith("image")?"image":"document",c=f=>{const m=u(f),p={file:f,type:m};return m==="image"&&(p.preview=URL.createObjectURL(f)),p},d=f=>{if(f&&f.length>0){const m=Array.from(f),p=mv(m,i,t);if(p.valid)console.log("=============3"),a([...m.map(g=>c(g))]);else{vv(p);const g=m.filter(v=>!p.rejectedFiles.includes(v));g.length>0&&(console.log("=============2"),a([...g.map(v=>c(v))]))}}},h=f=>{console.log("=============4"),a(m=>m.filter((p,g)=>g!==f))};return $t(()=>{e==null||e("fileManager:change",{uploadedFiles:i,senderConfig:t,setUploadedFiles:f=>{a([...f])}})},[i,t]),{uploadedFiles:i,inputValue:n,handleSendMessage:l,handleMessageChange:s,clearInput:o,handleUploadFiles:d,handleRemoveFile:h,setUploadedFiles:a}}const ZB=[{id:ps(32)},{id:ps(32)}],iPe=({scrollOld:t=!1,token:e,styles:n={},senderConfig:r={},disclaimer:i="\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u4E0D\u4EE3\u8868\u672C\u516C\u53F8\u89C2\u70B9\u3002",viewLimit:a})=>{const o=lt(null),s=lt(void 0),l=lt([]),u=lt(void 0),c=lt(void 0),d=lt(null),h=lt(new Map),[f,m]=bt([]);ZB.forEach(ie=>{h.current.set(ie.id,{current:ie.id})});const p=(ie,le)=>{[...h.current.values()].forEach(ve=>{const Ee=ve==null?void 0:ve.current;Ee&&typeof Ee[ie]=="function"&&Ee[ie](J)})},[g,v]=bt(()=>({uploadedFiles:[]})),[y,b]=bt(ZB),[E,x]=bt([]),[w,C]=bt(!1),[k,S]=bt({}),[T,$]=bt({}),O=yO(bO,n==null?void 0:n.theme),N=mDe(O.space),D={...O,space:N,colors:{...O.colors,info:O.colors.info||"#0000FF",background:O.colors.background||"#ffffff",text:O.colors.text||"#343a40",border:O.colors.border||"#dee2e6",disabled:O.colors.disabled||"#808080",disabledBackground:O.colors.disabledBackground||"#F5F5F5",disabledText:O.colors.disabledText||"#808080"}},L=nn(()=>yO({theme:bO,mode:"light"},n),[n]),B={...n,theme:D},[I,F]=bt([]),[H,W]=bt(()=>Pk(QB,r));$t(()=>{if(r){const ie=Pk(QB,r);W(ie)}},[r]);const X=(ie,le)=>{switch(console.log("Event emitted:",ie,le),ie){case"sender:action_upload":d.current&&d.current.click();break;case"fileChanges":v(le);break;case"fileManager:change":{typeof(le==null?void 0:le.setUploadedFiles)=="function"&&(c.current=le.setUploadedFiles,s.current=le.removeFile,u.current=le==null?void 0:le.senderConfig,l.current=Array.isArray(le==null?void 0:le.uploadedFiles)?le.uploadedFiles:[],Array.isArray(le==null?void 0:le.uploadedFiles)&&m(le.uploadedFiles));break}case"sender:stop":p("handleStopMessage");break;case"assistant:change":b(pe=>pe.map(ve=>ve.id===le.id?{...ve,configId:le.configId}:ve));break;case"sender:configChange":le&&le.all&&S(le.all);break;case"sender:change":q(le);break;case"sender:send":{p("handleSendMessage");break}}},{handleMessageChange:q,clearInput:Y,inputValue:U,handleUploadFiles:z,uploadedFiles:J,handleRemoveFile:te}=bDe({senderConfig:r,handleEventsEmit:X}),Z=ie=>{$(ie.all)},ee=()=>{const ie=ps(32);h.current.set(ie,{current:ie});const le=new Set(y.map(Ee=>Ee.configId).filter(Boolean));let pe="";const ve=E.find(Ee=>!le.has(Ee.value));ve?pe=ve.value:E.length&&(pe=E[0].value),b(Ee=>[...Ee,{id:ie,configId:pe}])},K=ie=>{b(le=>{if(le.length<=2)return le;const pe=le.findIndex(Ae=>Ae.id===ie);if(pe===-1)return le;const ve=le[pe],Ee=h.current.get(ve.id),xe=Ee==null?void 0:Ee.current;if(xe&&typeof(xe==null?void 0:xe.unmount)=="function")try{xe.unmount()}catch{}return h.current.delete(ve.id),[...le.slice(0,pe),...le.slice(pe+1)]})},ne=ie=>ie.map(le=>{const pe=JSON.parse(le.configJson);return{details:{model_name:pe.model_name||"",temperature:pe.temperature||"",max_tokens:pe.max_tokens||""},label:le.name,value:le.id}}),me=async()=>{try{const ie=await HIe({token:e});if(ie.length){const le=ne(ie);x(le),b(pe=>pe.map((ve,Ee)=>{var xe;return{...ve,configId:((xe=le==null?void 0:le[Ee])==null?void 0:xe.value)||""}})),C(!1)}}catch(ie){console.log("error",ie)}},de=nn(()=>g.uploadedFiles||[],[g]);IU({fileManagerData:{uploadedFiles:de},styles:L,eventsEmit:X});const fe=ie=>{const le=ie.target.files;if(le&&le.length>0){console.log("[DEBUG] handleFileSelect \u89E6\u53D1",{filesCount:le.length,hasSetUploadedFilesRef:!!c.current,hasSenderConfig:!!u.current,dynamicSenderConfig:H,dynamicSenderConfigKeys:H?Object.keys(H):[],senderConfigRef:u.current,senderConfigRefKeys:u.current?Object.keys(u.current):[]});const pe=Array.from(le);let ve=u.current;(!ve||ve.upload_size_limit===void 0&&ve.upload_number_limit===void 0&&(!ve.upload_file_type_limit||ve.upload_file_type_limit.length===0))&&(ve=H);const Ee=l.current||[];console.log("[DEBUG] \u9A8C\u8BC1\u914D\u7F6E\u68C0\u67E5",{configSource:ve,upload_number_limit:ve==null?void 0:ve.upload_number_limit,upload_size_limit:ve==null?void 0:ve.upload_size_limit,existingFilesCount:Ee.length,newFilesCount:pe.length});const xe=ve&&(ve.upload_size_limit!==void 0||ve.upload_number_limit!==void 0&&ve.upload_number_limit>0||ve.upload_file_type_limit&&ve.upload_file_type_limit.length>0);if(console.log("[DEBUG] \u914D\u7F6E\u68C0\u67E5\u7ED3\u679C",{hasUploadLimitConfig:xe,upload_number_limit:ve==null?void 0:ve.upload_number_limit,upload_size_limit:ve==null?void 0:ve.upload_size_limit,upload_file_type_limit:ve==null?void 0:ve.upload_file_type_limit}),xe){const Ae={upload_size_limit:ve.upload_size_limit,upload_number_limit:ve.upload_number_limit,upload_file_type_limit:ve.upload_file_type_limit,upload_limit_message:ve.upload_limit_message};console.log("[DEBUG] \u6267\u884C\u6587\u4EF6\u9A8C\u8BC1",{uploadConfig:Ae,existingFilesCount:Ee.length,newFilesCount:pe.length,totalCount:Ee.length+pe.length});const we=mv(pe,Ee,Ae);if(console.log("[DEBUG] \u9A8C\u8BC1\u7ED3\u679C",{valid:we.valid,errors:we.errors,rejectedFilesCount:we.rejectedFiles.length}),!we.valid){vv(we);const Oe=pe.filter(qe=>!we.rejectedFiles.includes(qe));if(Oe.length===0){d.current&&(d.current.value="");return}pe.splice(0,pe.length,...Oe)}}if(c.current){const Ae=pe.map(we=>({file:we,type:we.type.startsWith("image/")?"image":"document",status:"pending",name:we.name}));console.log("[DEBUG] \u901A\u8FC7 setUploadedFilesRef \u8BBE\u7F6E\u6587\u4EF6",Ae),c.current(Ae)}else console.warn("[DEBUG] setUploadedFilesRef \u672A\u8BBE\u7F6E\uFF0C\u5EF6\u8FDF\u91CD\u8BD5"),setTimeout(()=>{if(c.current){const Ae=pe.map(we=>({file:we,type:we.type.startsWith("image/")?"image":"document",status:"pending",name:we.name}));console.log("[DEBUG] \u5EF6\u8FDF\u540E\u901A\u8FC7 setUploadedFilesRef \u8BBE\u7F6E\u6587\u4EF6",Ae),c.current(Ae)}else console.error("[DEBUG] \u5EF6\u8FDF\u540E setUploadedFilesRef \u4ECD\u672A\u8BBE\u7F6E")},100)}d.current&&(d.current.value="")},se=nn(()=>{const ie=y.map(le=>{var pe;return(pe=le==null?void 0:le.appStatus)==null?void 0:pe.sender}).filter(Boolean);return console.log("chatItems",y),ie.includes("error")?"error":ie.includes("uploading")?"uploading":ie.includes("processing")?"processing":"ready"},[y]);return $t(()=>{console.log("senderStatus",se)},[se]),$t(()=>{C(!0),me()},[]),Ot("div",{style:{display:"flex",gap:"20px",height:"100%",boxSizing:"border-box",flexDirection:"column",position:"relative"},className:"selfScrollBar",ref:o,children:[Ot("div",{style:{display:"flex",gap:"20px",height:"calc(100% - 195px)",overflowX:"auto"},children:[_e("input",{ref:d,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.txt,.md,.json,.csv,.zip,.rar,.7z",style:{display:"none"},onChange:fe}),y.map((ie,le)=>{const pe=h.current.get(ie.id);return _e(QIe,{index:le,ref:pe,item:ie,scrollOld:t,token:e,styles:n,status:se,inputValue:U,uploadedFiles:J,senderSwitchValues:k,clearInput:Y,configLoading:w,showRemoveIcon:(y==null?void 0:y.length)>2,assistantList:E.filter(ve=>ve.value===ie.configId||y.every(Ee=>Ee.configId!==ve.value)),emitEvent:X,onRemove:K,senderConfig:H,normalizedStyles:L,setChatItems:b},ie.id)})]}),Ot("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"end"},children:[_e(lDe,{value:U,status:se,styles:B,recommandQuestions:[],eventsEmit:(ie,le)=>{X(ie,le)},uploadedFiles:J,fileUploadStatus:I,onUpload:z,onRemoveFile:te,senderConfig:r,onSenderConfigChange:Z,disclaimer:i}),_e("div",{className:"flex absolute text-[12px] cursor-pointer z-20",style:{left:"24px",bottom:"150px"},children:_e(u9,{count:y.length,size:"small",color:"#1677ff",children:_e(Cd,{icon:_e(fQ,{className:"w-3"}),onClick:ee,type:"link",disabled:y.length>=(a||10),size:"small",children:"\u6DFB\u52A0\u52A9\u624B"})})})]})]})};export{BDe as A,GAe as B,iPe as C,_ge as D,FDe as E,wge as F,Tge as G,LDe as H,n3e as I,nPe as J,Sge as K,r3e as T,kge as W,JDe as a,o3e as b,Qy as c,t3e as d,QDe as e,yge as f,a3e as g,i3e as h,ZDe as i,cS as j,tPe as k,ePe as l,Age as m,KDe as n,XDe as o,rPe as p,Df as q,jDe as r,RDe as s,dge as t,IU as u,fM as v,pM as w,mv as x,vv as y,e3e as z};
|
|
943
|
+
`,style:{cursor:r==="processing"||O?"pointer":"not-allowed",background:r==="processing"?"#222222":O?`linear-gradient(to bottom right, ${B}, ${(L==null?void 0:L.primary)||"#0275d8"})`:q},onClick:()=>{r==="processing"?e&&e("sender:stop",{}):O&&e&&e("sender:send")},title:r==="processing"?"\u505C\u6B62\u5F53\u524D\u5BF9\u8BDD":"\u53D1\u9001",children:_e("div",{className:"relative flex items-center gap-x-1 font-medium",style:{color:!O&&r!=="processing"?Y:"#ffffff"},children:r==="processing"?_e(aDe,{size:46,color:"#ffffff",circleColor:"#ffffff"}):_e(pQ,{size:20,className:O?"sender-icon-active":"",style:{color:O?"#ffffff":Y,strokeWidth:2.5}})})})]})]})]})}),_e("div",{className:"mt-2 pt-2 pb-3 px-1 flex items-center justify-between ",children:_e("span",{className:"text-[10px]",style:{color:X}})})]}),d&&_e("div",{className:" absolute bottom-3 left-0 right-0 w-full text-xs text-center",children:_e("div",{className:"text-xs text-center",style:{color:Y},children:d})})]})]})}const uDe={sm:"240px",md:"260px",lg:"280px"},cDe={sm:"12px",md:"16px",lg:"20px"},dDe={sm:"2px",md:"4px",lg:"8px"},hDe={sm:"4px",md:"8px",lg:"16px"},fDe={sm:"4px",md:"8px",lg:"16px"},pDe={sm:"0 1px 2px #eee",md:"0 2px 8px #ddd",lg:"0 4px 16px #ccc"},gDe={sm:"1.2",md:"1.5",lg:"2"};function mDe(t){return{...t,size:cDe[t.size]||t.size,radius:dDe[t.radius]||t.radius,padding:hDe[t.padding]||t.padding,margin:fDe[t.margin]||t.margin,shadow:pDe[t.shadow]||t.shadow,lineHeight:gDe[t.lineHeight]||t.lineHeight,sidebar:uDe[t.sidebar]||t.sidebar}}function Pk(t,e){if(!e)return t;const n=Array.isArray(t)?[...t]:{...t};for(const r in e)if(e[r]!==void 0&&e[r]!==null&&Object.prototype.hasOwnProperty.call(e,r))if(r==="actions"&&Array.isArray(t[r])&&Array.isArray(e[r])){const i=new Map;t[r].forEach(a=>{a.name&&i.set(a.name,a)}),e[r].forEach(a=>{a.name&&i.set(a.name,a)}),n[r]=Array.from(i.values())}else typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])&&typeof e[r]=="object"&&e[r]!==null&&!Array.isArray(e[r])?n[r]=Pk(t[r],e[r]):n[r]=e[r];return n}const vDe=t=>_.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},_.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 14.6666C11.6819 14.6666 14.6667 11.6819 14.6667 7.99998C14.6667 4.31808 11.6819 1.33331 8 1.33331C4.3181 1.33331 1.33334 4.31808 1.33334 7.99998C1.33334 11.6819 4.3181 14.6666 8 14.6666Z",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M1.33334 8H14.6667",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 14.6666C9.47277 14.6666 10.6667 11.6819 10.6667 7.99998C10.6667 4.31808 9.47277 1.33331 8 1.33331C6.52724 1.33331 5.33334 4.31808 5.33334 7.99998C5.33334 11.6819 6.52724 14.6666 8 14.6666Z",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M3.28597 3.38068C4.4924 4.58711 6.15907 5.33331 8 5.33331C9.84097 5.33331 11.5076 4.58711 12.7141 3.38068",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M12.7141 12.6193C11.5076 11.4129 9.84097 10.6667 8 10.6667C6.15907 10.6667 4.4924 11.4129 3.28597 12.6193",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"})),yDe=t=>_.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},_.createElement("path",{d:"M1.73633 1.57642C2.53848 0.774265 3.74473 0.714862 4.87207 1.03052C6.02182 1.35245 7.24885 2.09683 8.3125 3.1604C9.37624 4.22414 10.1204 5.45195 10.4424 6.60181C10.758 7.72909 10.6986 8.93446 9.89648 9.73657C9.09439 10.5387 7.88901 10.5981 6.76172 10.2825C5.61186 9.96051 4.38405 9.21632 3.32031 8.15259C2.25674 7.08894 1.51236 5.86191 1.19043 4.71216C0.874775 3.58481 0.934176 2.37857 1.73633 1.57642Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M6.76172 5.41479C7.88883 5.09929 9.09442 5.15888 9.89648 5.96069C10.6986 6.76284 10.758 7.96909 10.4424 9.09644C10.1204 10.2462 9.37617 11.4732 8.3125 12.5369C7.24882 13.6005 6.02187 14.3448 4.87207 14.6667C3.74472 14.9824 2.53848 14.923 1.73633 14.1208C0.934528 13.3188 0.874922 12.1132 1.19043 10.9861C1.51239 9.83623 2.25659 8.60841 3.32031 7.54468C4.38405 6.48096 5.61186 5.73675 6.76172 5.41479Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M11.1282 1.03052C12.2553 0.715012 13.4609 0.774612 14.263 1.57642C15.0651 2.37857 15.1246 3.58481 14.8089 4.71216C14.4869 5.86196 13.7427 7.08892 12.679 8.15259C11.6153 9.21627 10.3884 9.96048 9.23859 10.2825C8.11124 10.5981 6.90499 10.5387 6.10284 9.73657C5.30106 8.9345 5.24144 7.72892 5.55695 6.60181C5.8789 5.45195 6.62311 4.22414 7.68683 3.1604C8.75056 2.09668 9.97838 1.35248 11.1282 1.03052Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{d:"M6.10284 5.96069C6.90499 5.15855 8.11124 5.09914 9.23859 5.41479C10.3883 5.73673 11.6154 6.48111 12.679 7.54468C13.7427 8.60841 14.4869 9.83623 14.8089 10.9861C15.1245 12.1134 15.0651 13.3188 14.263 14.1208C13.4609 14.9229 12.2555 14.9823 11.1282 14.6667C9.97838 14.3448 8.75055 13.6006 7.68683 12.5369C6.62325 11.4732 5.87888 10.2462 5.55695 9.09644C5.24129 7.96909 5.3007 6.76284 6.10284 5.96069Z",stroke:"#4E6EF2",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round"})),QB={actions:[{name:"upload",icon:_e(di,{type:"wenda/shangchuanwenjian",color:"#000",size:20}),tip:"\u6587\u4EF6\u4E0A\u4F20"}],switchs:[{label:"\u8054\u7F51\u641C\u7D22",name:"netSearch",type:"switch",defaultValue:!1,enabled:!0,icon:_e(vDe,{width:16,height:16,className:"aichat-netsearch-icon",style:{color:"#4B8CF7"}})},{label:"\u6DF1\u5EA6\u601D\u8003",name:"reasoning",type:"switch",defaultValue:!0,enabled:!0,icon:_e(yDe,{width:16,height:16})}]};function bDe({senderConfig:t,handleEventsEmit:e}){const[n,r]=bt(""),[i,a]=bt([]);$t(()=>{console.log("uploadedFiles",i)},[i]);const o=()=>{r(""),i.forEach(f=>{f.preview&&f.type==="image"&&URL.revokeObjectURL(f.preview)}),console.log("=============1"),a([])},s=f=>{r(f)},l=f=>{console.log("Sending message:",f)},u=f=>f.type.startsWith("image")?"image":"document",c=f=>{const m=u(f),p={file:f,type:m};return m==="image"&&(p.preview=URL.createObjectURL(f)),p},d=f=>{if(f&&f.length>0){const m=Array.from(f),p=mv(m,i,t);if(p.valid)console.log("=============3"),a([...m.map(g=>c(g))]);else{vv(p);const g=m.filter(v=>!p.rejectedFiles.includes(v));g.length>0&&(console.log("=============2"),a([...g.map(v=>c(v))]))}}},h=f=>{console.log("=============4"),a(m=>m.filter((p,g)=>g!==f))};return $t(()=>{e==null||e("fileManager:change",{uploadedFiles:i,senderConfig:t,setUploadedFiles:f=>{a([...f])}})},[i,t]),{uploadedFiles:i,inputValue:n,handleSendMessage:l,handleMessageChange:s,clearInput:o,handleUploadFiles:d,handleRemoveFile:h,setUploadedFiles:a}}const ZB=[{id:ps(32)},{id:ps(32)}],iPe=({scrollOld:t=!1,token:e,styles:n={},senderConfig:r={},disclaimer:i="\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u4E0D\u4EE3\u8868\u672C\u516C\u53F8\u89C2\u70B9\u3002",viewLimit:a})=>{const o=lt(null),s=lt(void 0),l=lt([]),u=lt(void 0),c=lt(void 0),d=lt(null),h=lt(new Map),[f,m]=bt([]);ZB.forEach(ie=>{h.current.set(ie.id,{current:ie.id})});const p=(ie,le)=>{[...h.current.values()].forEach(ve=>{const Ee=ve==null?void 0:ve.current;Ee&&typeof Ee[ie]=="function"&&Ee[ie](J)})},[g,v]=bt(()=>({uploadedFiles:[]})),[y,b]=bt(ZB),[E,x]=bt([]),[w,C]=bt(!1),[k,S]=bt({}),[T,$]=bt({}),O=yO(bO,n==null?void 0:n.theme),N=mDe(O.space),D={...O,space:N,colors:{...O.colors,info:O.colors.info||"#0000FF",background:O.colors.background||"#ffffff",text:O.colors.text||"#343a40",border:O.colors.border||"#dee2e6",disabled:O.colors.disabled||"#808080",disabledBackground:O.colors.disabledBackground||"#F5F5F5",disabledText:O.colors.disabledText||"#808080"}},L=nn(()=>yO({theme:bO,mode:"light"},n),[n]),B={...n,theme:D},[I,F]=bt([]),[H,W]=bt(()=>Pk(QB,r));$t(()=>{if(r){const ie=Pk(QB,r);W(ie)}},[r]);const X=(ie,le)=>{switch(console.log("Event emitted:",ie,le),ie){case"sender:action_upload":d.current&&d.current.click();break;case"fileChanges":v(le);break;case"fileManager:change":{typeof(le==null?void 0:le.setUploadedFiles)=="function"&&(c.current=le.setUploadedFiles,s.current=le.removeFile,u.current=le==null?void 0:le.senderConfig,l.current=Array.isArray(le==null?void 0:le.uploadedFiles)?le.uploadedFiles:[],Array.isArray(le==null?void 0:le.uploadedFiles)&&m(le.uploadedFiles));break}case"sender:stop":p("handleStopMessage");break;case"assistant:change":b(pe=>pe.map(ve=>ve.id===le.id?{...ve,configId:le.configId}:ve));break;case"sender:configChange":le&&le.all&&S(le.all);break;case"sender:change":q(le);break;case"sender:send":{p("handleSendMessage");break}}},{handleMessageChange:q,clearInput:Y,inputValue:U,handleUploadFiles:z,uploadedFiles:J,handleRemoveFile:te}=bDe({senderConfig:r,handleEventsEmit:X}),Z=ie=>{$(ie.all)},ee=()=>{const ie=ps(32);h.current.set(ie,{current:ie});const le=new Set(y.map(Ee=>Ee.configId).filter(Boolean));let pe="";const ve=E.find(Ee=>!le.has(Ee.value));ve?pe=ve.value:E.length&&(pe=E[0].value),b(Ee=>[...Ee,{id:ie,configId:pe}])},K=ie=>{b(le=>{if(le.length<=2)return le;const pe=le.findIndex(Ae=>Ae.id===ie);if(pe===-1)return le;const ve=le[pe],Ee=h.current.get(ve.id),xe=Ee==null?void 0:Ee.current;if(xe&&typeof(xe==null?void 0:xe.unmount)=="function")try{xe.unmount()}catch{}return h.current.delete(ve.id),[...le.slice(0,pe),...le.slice(pe+1)]})},ne=ie=>ie.map(le=>{const pe=JSON.parse(le.configJson);return{details:{model_name:pe.model_name||"",temperature:pe.temperature||"",max_tokens:pe.max_tokens||""},label:le.name,value:le.id}}),me=async()=>{try{const ie=await HIe({token:e});if(ie.length){const le=ne(ie);x(le),b(pe=>pe.map((ve,Ee)=>{var xe;return{...ve,configId:((xe=le==null?void 0:le[Ee])==null?void 0:xe.value)||""}})),C(!1)}}catch(ie){console.log("error",ie)}},de=nn(()=>g.uploadedFiles||[],[g]);IU({fileManagerData:{uploadedFiles:de},styles:L,eventsEmit:X});const fe=ie=>{const le=ie.target.files;if(le&&le.length>0){console.log("[DEBUG] handleFileSelect \u89E6\u53D1",{filesCount:le.length,hasSetUploadedFilesRef:!!c.current,hasSenderConfig:!!u.current,dynamicSenderConfig:H,dynamicSenderConfigKeys:H?Object.keys(H):[],senderConfigRef:u.current,senderConfigRefKeys:u.current?Object.keys(u.current):[]});const pe=Array.from(le);let ve=u.current;(!ve||ve.upload_size_limit===void 0&&ve.upload_number_limit===void 0&&(!ve.upload_file_type_limit||ve.upload_file_type_limit.length===0))&&(ve=H);const Ee=l.current||[];console.log("[DEBUG] \u9A8C\u8BC1\u914D\u7F6E\u68C0\u67E5",{configSource:ve,upload_number_limit:ve==null?void 0:ve.upload_number_limit,upload_size_limit:ve==null?void 0:ve.upload_size_limit,existingFilesCount:Ee.length,newFilesCount:pe.length});const xe=ve&&(ve.upload_size_limit!==void 0||ve.upload_number_limit!==void 0&&ve.upload_number_limit>0||ve.upload_file_type_limit&&ve.upload_file_type_limit.length>0);if(console.log("[DEBUG] \u914D\u7F6E\u68C0\u67E5\u7ED3\u679C",{hasUploadLimitConfig:xe,upload_number_limit:ve==null?void 0:ve.upload_number_limit,upload_size_limit:ve==null?void 0:ve.upload_size_limit,upload_file_type_limit:ve==null?void 0:ve.upload_file_type_limit}),xe){const Ae={upload_size_limit:ve.upload_size_limit,upload_number_limit:ve.upload_number_limit,upload_file_type_limit:ve.upload_file_type_limit,upload_limit_message:ve.upload_limit_message};console.log("[DEBUG] \u6267\u884C\u6587\u4EF6\u9A8C\u8BC1",{uploadConfig:Ae,existingFilesCount:Ee.length,newFilesCount:pe.length,totalCount:Ee.length+pe.length});const we=mv(pe,Ee,Ae);if(console.log("[DEBUG] \u9A8C\u8BC1\u7ED3\u679C",{valid:we.valid,errors:we.errors,rejectedFilesCount:we.rejectedFiles.length}),!we.valid){vv(we);const Oe=pe.filter(qe=>!we.rejectedFiles.includes(qe));if(Oe.length===0){d.current&&(d.current.value="");return}pe.splice(0,pe.length,...Oe)}}if(c.current){const Ae=pe.map(we=>({file:we,type:we.type.startsWith("image/")?"image":"document",status:"pending",name:we.name}));console.log("[DEBUG] \u901A\u8FC7 setUploadedFilesRef \u8BBE\u7F6E\u6587\u4EF6",Ae),c.current(Ae)}else console.warn("[DEBUG] setUploadedFilesRef \u672A\u8BBE\u7F6E\uFF0C\u5EF6\u8FDF\u91CD\u8BD5"),setTimeout(()=>{if(c.current){const Ae=pe.map(we=>({file:we,type:we.type.startsWith("image/")?"image":"document",status:"pending",name:we.name}));console.log("[DEBUG] \u5EF6\u8FDF\u540E\u901A\u8FC7 setUploadedFilesRef \u8BBE\u7F6E\u6587\u4EF6",Ae),c.current(Ae)}else console.error("[DEBUG] \u5EF6\u8FDF\u540E setUploadedFilesRef \u4ECD\u672A\u8BBE\u7F6E")},100)}d.current&&(d.current.value="")},se=nn(()=>{const ie=y.map(le=>{var pe;return(pe=le==null?void 0:le.appStatus)==null?void 0:pe.sender}).filter(Boolean);return console.log("chatItems",y),ie.includes("error")?"error":ie.includes("uploading")?"uploading":ie.includes("processing")?"processing":"ready"},[y]);return $t(()=>{console.log("senderStatus",se)},[se]),$t(()=>{C(!0),me()},[]),Ot("div",{style:{display:"flex",gap:"20px",height:"100%",boxSizing:"border-box",flexDirection:"column",position:"relative"},className:"selfScrollBar",ref:o,children:[Ot("div",{style:{display:"flex",gap:"20px",height:"calc(100% - 195px)",overflowX:"auto"},children:[_e("input",{ref:d,type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.txt,.md,.json,.csv,.zip,.rar,.7z",style:{display:"none"},onChange:fe}),y.map((ie,le)=>{const pe=h.current.get(ie.id);return _e(QIe,{index:le,ref:pe,item:ie,scrollOld:t,token:e,styles:n,status:se,inputValue:U,uploadedFiles:J,senderSwitchValues:k,clearInput:Y,configLoading:w,showRemoveIcon:(y==null?void 0:y.length)>2,assistantList:E.filter(ve=>ve.value===ie.configId||y.every(Ee=>Ee.configId!==ve.value)),emitEvent:X,onRemove:K,senderConfig:H,normalizedStyles:L,setChatItems:b},ie.id)})]}),Ot("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"end"},children:[_e(lDe,{value:U,status:se,styles:B,recommandQuestions:[],eventsEmit:(ie,le)=>{X(ie,le)},uploadedFiles:J,fileUploadStatus:I,onUpload:z,onRemoveFile:te,senderConfig:r,onSenderConfigChange:Z,disclaimer:i}),_e("div",{className:"flex absolute text-[12px] cursor-pointer z-20",style:{left:"24px",bottom:"150px"},children:_e(u9,{count:y.length,size:"small",color:"#1677ff",children:_e(Cd,{icon:_e(fQ,{className:"w-3"}),onClick:ee,type:"link",disabled:y.length>=(a||10),size:"small",children:"\u6DFB\u52A0\u52A9\u624B"})})})]})]})};export{mv as A,GAe as B,iPe as C,_ge as D,vv as E,wge as F,Tge as G,BDe as H,FDe as I,LDe as J,Sge as K,r3e as T,kge as W,JDe as a,o3e as b,Qy as c,t3e as d,QDe as e,yge as f,a3e as g,i3e as h,ZDe as i,cS as j,tPe as k,ePe as l,Age as m,KDe as n,XDe as o,rPe as p,Df as q,jDe as r,RDe as s,dge as t,IU as u,fM as v,pM as w,nPe as x,n3e as y,e3e as z};
|