@blueking/ai-blueking 2.1.4-beta.12 → 2.1.4-beta.13
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/README.md +11 -1
- package/dist/components/chat-bot.vue.d.ts.map +1 -1
- package/dist/components/composables/use-chatbot-init.d.ts +7 -1
- package/dist/components/composables/use-chatbot-init.d.ts.map +1 -1
- package/dist/components/types.d.ts +4 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/composables/use-ai-blueking-init.d.ts +4 -0
- package/dist/composables/use-ai-blueking-init.d.ts.map +1 -1
- package/dist/standalone/index.es.min.js +224 -198
- package/dist/standalone/index.iife.min.js +2 -2
- package/dist/standalone/index.umd.min.js +2 -2
- package/dist/vue2/index.es.min.js +230 -199
- package/dist/vue2/index.iife.min.js +2 -2
- package/dist/vue2/index.umd.min.js +184 -184
- package/dist/vue2.d.ts.map +1 -1
- package/dist/vue3/index.es.min.js +264 -238
- package/dist/vue3/index.iife.min.js +2 -2
- package/dist/vue3/index.umd.min.js +3 -3
- package/package.json +1 -1
|
@@ -3498,5 +3498,5 @@ Use Shift + Enter to enter a new line`:`输入 “/”唤出 Prompt
|
|
|
3498
3498
|
`)),t.onAgentAction?.(e,n)),m=async(e,n)=>{t.onUserAction?.(e,n)},h=async(e,n,r)=>{t.onUserInputConfirm?.(e,n,r)},g=async(e,n)=>{t.onUserShortcutConfirm?.(e,n)};return(n,s)=>(H(),Gr(`div`,{ref_key:`messageContainerRef`,ref:r,class:`ai-message-container`},[(H(!0),Gr(Lr,null,dr(e.messageGroups,(r,i)=>(H(),Gr(`div`,{id:r.uid,key:i,class:`message-group`,style:he({backgroundColor:r.checked?`#f5f7fa`:`transparent`}),onMouseenter:e=>u(r),onMouseleave:e=>d(r,e)},[e.enableSelection&&r.type!==V(Ri).Loading?(H(),Kr(V(Vd),{key:0,class:`message-group-checkbox`,"model-value":r.checked,"onUpdate:modelValue":e=>f(r,e)},null,8,[`model-value`,`onUpdate:modelValue`])):ti(`v-if`,!0),Xr(`div`,{class:be([`message-group-messages`,{"message-group-enabled-selection":e.renderMode===V(Wi).Share||e.enableSelection&&r.type!==V(Ri).Loading}]),style:he({width:e.enableSelection&&r.type!==V(Ri).Loading?`calc(100% - 16px)`:`100%`})},[(H(!0),Gr(Lr,null,dr(r.messages,(t,r)=>pr(n.$slots,`default`,ai({key:r,ref_for:!0},{message:t,messageToolsStatus:e.messageToolsStatus}),()=>[(H(),Kr(jGt,{key:r,message:t,"message-tools-status":e.messageToolsStatus,"on-action":e=>m(e,t),"on-input-confirm":(e,n)=>h(t,e,n),"on-shortcut-confirm":e=>g(t,e),"tippy-options":e.messageToolsTippyOptions},null,8,[`message`,`message-tools-status`,`on-action`,`on-input-confirm`,`on-shortcut-confirm`,`tippy-options`]))])),128)),e.renderMode!==V(Wi).Share&&!(e.enableSelection&&r.type!==V(Ri).Loading)&&!r.pause&&r.type===V(Ri).Assistant&&e.messageToolsStatus!==V(Cp).Hidden?(H(),Kr(HUt,{key:0,"message-tools":l.value,"message-tools-status":e.messageToolsStatus,"on-action":e=>p(e,r.messages),style:he({visibility:r.isHover?`visible`:`hidden`}),"tippy-options":t.messageToolsTippyOptions,onFeedback:(e,n,i)=>t.onAgentFeedback?.(e,r.messages,n,i)},null,8,[`message-tools`,`message-tools-status`,`on-action`,`style`,`tippy-options`,`onFeedback`])):ti(`v-if`,!0)],6)],44,MGt))),128)),Xr(`div`,{ref_key:`messageContainerBottomRef`,ref:i,class:`message-container-bottom`,tabindex:`0`},null,512),Xr(`div`,NGt,[Mn(Zr(EUt,{loading:e.messageStatus===V(zi).StopLoading,title:e.messageStatus===V(zi).StopLoading?V(Ui)(`正在停止`):V(Ui)(`停止生成`),onClick:s[0]||=e=>n.$emit(`stopStreaming`)},{icon:jn(()=>[Zr(V(gie))]),_:1},8,[`loading`,`title`]),[[Ei,e.messageStatus===V(zi).Streaming||e.messageStatus===V(zi).StopLoading||e.messageStatus===V(zi).Fetching||e.messageStatus===V(zi).Pending]]),Mn(Zr(EUt,{title:V(Ui)(`返回底部`),onClick:V(a)},{icon:jn(()=>[Zr(V(wie))]),_:1},8,[`title`,`onClick`]),[[Ei,V(o)]])])],512))}}),FGt={class:`execution-summary`},IGt={class:`execution-summary-header`},LGt={class:`execution-summary-content`},RGt=[`onMouseenter`],zGt={class:`content-item-header`},BGt={class:`content-item-title`},VGt={class:`content-item-messages`},HGt={key:0,class:`timeline-line`},UGt={key:1,class:`execution-summary-content-empty`},WGt={class:`execution-summary-content-empty-text`},GGt=Qn({__name:`execution-summary`,props:{messageGroups:{}},emits:[`locateMessageGroup`,`updateKeyword`],setup(e,{emit:t}){let n=t,r=ap(),{keyword:i}=lTe(),a=cn(void 0),o=e=>{if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`},s=e=>{n(`locateMessageGroup`,e.uid,e)},l=()=>{i.value=``,n(`updateKeyword`,``)};return(t,u)=>(H(),Gr(`div`,FGt,[Xr(`div`,IGt,[Zr(V(Pd),{modelValue:V(i),"onUpdate:modelValue":[u[0]||=e=>on(i)?i.value=e:null,u[1]||=e=>n(`updateKeyword`,e)],class:`execution-summary-header-input`,clearable:``,placeholder:V(Ui)(`搜索 关键字`)},null,8,[`modelValue`,`placeholder`])]),Xr(`div`,LGt,[e.messageGroups.length?(H(!0),Gr(Lr,{key:0},dr(e.messageGroups,(t,n)=>(H(),Gr(`div`,{key:t.uid,class:`execution-summary-content-item`,onMouseenter:e=>a.value=t.uid,onMouseleave:u[2]||=e=>a.value=void 0},[Xr(`div`,zGt,[u[3]||=Xr(`span`,{class:`timeline-dot`},null,-1),Mn((H(),Gr(`span`,BGt,[ei(Oe(typeof t.userMessageTitle==`number`?o(t.userMessageTitle):t.userMessageTitle),1)])),[[V(wp),{...V(r)}]]),Mn(Zr(V(Cd),{class:`content-item-locate`,text:``,theme:`primary`,onClick:e=>s(t)},{default:jn(()=>[ei(Oe(V(Ui)(`在对话中定位`)),1)]),_:1},8,[`onClick`]),[[Ei,a.value===t.uid]])]),Xr(`div`,VGt,[(H(!0),Gr(Lr,null,dr(t.messages,(e,t)=>(H(),Kr(jGt,{key:t,message:e},null,8,[`message`]))),128))]),n<e.messageGroups.length-1?(H(),Gr(`div`,HGt)):ti(`v-if`,!0)],40,RGt))),128)):(H(),Gr(`div`,UGt,[Zr(V(mCe),{class:`empty-exception`,type:`empty`}),Xr(`div`,WGt,[ei(Oe(V(i)?V(Ui)(`搜索结果为空`):V(Ui)(`暂无数据`))+` `,1),V(i)?(H(),Kr(V(Cd),{key:0,text:``,theme:`primary`,onClick:l},{default:jn(()=>[ei(Oe(V(Ui)(`清空搜索`)),1)]),_:1})):ti(`v-if`,!0)])]))])]))}}),KGt={class:`ai-message-loading-row`},qGt={class:`ai-message-loading-icon-wrap`},JGt={key:0,class:`ai-message-loading-text ai-message-loading-text-custom`},YGt={key:1,"aria-live":`polite`,class:`ai-message-loading-text`},XGt=Qn({name:`MessageLoading`,inheritAttrs:!1,__name:`message-loading`,props:{duration:{default:1.8},gap:{default:8},iconSize:{default:32},stagger:{default:.135},text:{default:`加载中...`}},setup(e){let t=e,n=ute(),r=mi(()=>{let{class:e,style:t,...r}=n;return r}),i=mi(()=>({display:`block`,width:`${t.iconSize}px`,height:`${t.iconSize}px`})),a=mi(()=>[...t.text]),o=mi(()=>{let e=n.style,r={"--ai-message-loading-duration":`${t.duration}s`,"--ai-message-loading-stagger":`${t.stagger}s`,"--ai-message-loading-gap":`${t.gap}px`};return e&&typeof e==`object`&&!Array.isArray(e)?{...r,...e}:r});return(e,t)=>(H(),Gr(`div`,ai({class:[`ai-message-loading`,V(n).class],style:o.value},r.value),[Xr(`div`,KGt,[Xr(`span`,qGt,[pr(e.$slots,`icon`,{},()=>[Zr(V(Jre),{class:`ai-message-loading-icon-svg`,style:he(i.value)},null,8,[`style`])])]),e.$slots.text?(H(),Gr(`span`,JGt,[pr(e.$slots,`text`)])):(H(),Gr(`span`,YGt,[(H(!0),Gr(Lr,null,dr(a.value,(e,t)=>(H(),Gr(`span`,{key:`${t}-${e}`,class:`ai-message-loading-char`,style:he({"--char-index":t})},Oe(e),5))),128))]))])],16))}}),ZGt={class:`ai-selection-footer`},QGt={class:`ai-selection-footer-left`},$Gt={class:`select-all-text`},eKt={class:`ai-selection-footer-right`},tKt=Qn({__name:`selection-footer`,props:{isAllSelected:{type:Boolean},loading:{type:Boolean},selectedCount:{}},emits:[`cancel`,`confirm`,`toggle-all`],setup(e,{emit:t}){let n=t;return(t,r)=>(H(),Gr(`div`,ZGt,[Xr(`div`,QGt,[Zr(V(Vd),{"model-value":e.isAllSelected,"onUpdate:modelValue":r[0]||=e=>n(`toggle-all`,e)},null,8,[`model-value`]),Xr(`span`,$Gt,Oe(V(Ui)(`全选`)),1)]),Xr(`div`,eKt,[Zr(V(Cd),{disabled:e.loading,onClick:r[1]||=e=>n(`cancel`)},{default:jn(()=>[ei(Oe(V(Ui)(`取消`)),1)]),_:1},8,[`disabled`]),Zr(V(Cd),{disabled:e.selectedCount===0,loading:e.loading,theme:`primary`,onClick:r[2]||=e=>n(`confirm`)},{default:jn(()=>[ei(Oe(V(Ui)(`确定`)),1)]),_:1},8,[`disabled`,`loading`])])]))}}),nKt={key:0,class:`ai-chat-container-loading`},rKt={key:1,class:`ai-welcome-content`},iKt={class:`ai-welcome-title`},aKt={key:0,class:`ai-welcome-remark`},oKt=Qn({__name:`chat-container`,props:yr({chatLoading:{type:Boolean},commonTippyOptions:{},getSideRenderComponent:{},getSideTabRenderComponent:{},onCustomTabChange:{},openingRemark:{},placement:{default:`left`},resizeProps:{},defaultUploadFiles:{},inputMaxHeight:{},messageStatus:{},modelValue:{},onSendMessage:{},onStopSending:{},onUpload:{},placeholder:{},prompts:{},resources:{},shortcutId:{},shortcuts:{},supportUpload:{type:Boolean},tippyOptions:{},messages:{},messageToolsStatus:{},onAgentAction:{},onAgentFeedback:{},onUserAction:{},renderMode:{},onUserInputConfirm:{},onUserShortcutConfirm:{}},{renderMode:{required:!1,default:Wi.Chat},renderModeModifiers:{},selectedShortcut:{required:!1},selectedShortcutModifiers:{},cite:{required:!1,default:``},citeModifiers:{}}),emits:yr([`selectShortcut`,`deleteShortcut`,`update:modelValue`,`stopStreaming`,`shortcutClose`,`shortcutSubmit`,`confirmShare`,`collapseChange`],[`update:renderMode`,`update:selectedShortcut`,`update:cite`]),setup(e,{expose:t,emit:n}){let r=Awe.TabPanel,i=e,a=Dr(e,`renderMode`);uTe({renderMode:a});let o=mi(()=>({collapsible:!1,immediate:!0,min:400,...i.resizeProps,placement:i.placement})),s=mi(()=>i.getSideRenderComponent?.(U,p.value.data?.props??{})??p.value.data?.component);Qwe({supportUpload:mi(()=>i.supportUpload??!1)});let l=Dr(e,`selectedShortcut`),u=Dr(e,`cite`),d=n;fTe({tippyOptions:mi(()=>i.commonTippyOptions??{})});let{tabs:f,selectedTab:p,isCollapse:m,addCustomTab:h,removeCustomTab:g,selectCustomTab:_,resetCustomTab:v}=Ywe({onTabChange:async e=>{let t=p.value.data?.props||{loading:!0,data:{}};p.value.data={...p.value.data,props:t};let n=await i.onCustomTabChange?.(e);p.value.data={...p.value.data,props:{...t,loading:!1,data:n}}}}),y=cn(``),b=sn([]),x=cn(400),S=mi(()=>`calc(100% - ${x.value}px)`),{messageGroups:C,executionGroups:w,isShareMode:T,isAllSelected:E,onToggleShareAll:D,onCancelShare:O,onConfirmShare:k}=aTe({keyword:y,messages:mi(()=>i.messages),selectedUserMessages:b});Ln(m,e=>{e&&(y.value=``,x.value=0),d(`collapseChange`,e,x.value)}),Ln(()=>w.value,e=>{!e.length&&!y.value&&v()},{immediate:!0,deep:!1});let A=mi(()=>i.messageStatus===zi.StopLoading?zi.StopLoading:C.value?.some(e=>e.messages.some(e=>e.id===`__loading__`))?zi.Fetching:i.messageStatus),j=()=>{l.value=null,d(`shortcutClose`)},M=e=>{d(`shortcutSubmit`,e)},N=()=>{d(`deleteShortcut`)},P=e=>{d(`selectShortcut`,e)},F=(e,t)=>{d(`update:modelValue`,e,t)},I=()=>{m.value=!m.value},L=e=>{if(!e)return;let t=document.getElementById(e);if(!t){let t=C.value.find(t=>t.messages.some(t=>t.uid===e));t&&document.getElementById(t.uid)?.scrollIntoView({behavior:`smooth`});return}t.scrollIntoView({behavior:`smooth`})},R=e=>{_(f.value.find(t=>t.name===e))},ee=e=>{y.value=e},te=async(e,t)=>{if(e.id===`share`){T.value=!0;return}return i.onAgentAction?.(e,t)},z=()=>{d(`confirmShare`,k()),En(()=>{T.value=!1,b.value=[]})},B=e=>{x.value=e};return cr(()=>{v()}),t({selectedTab:p,addCustomTab:h,removeCustomTab:g,selectCustomTab:_,enterShareMode:()=>{T.value=!0},exitShareMode:()=>{O()}}),(t,n)=>(H(),Gr(`div`,{class:`ai-chat-container`,style:he({"--resize-main-width":S.value})},[e.chatLoading?(H(),Gr(`div`,nKt,[Zr(XGt)])):(H(),Kr(V(hwe),ai({key:1,class:[`ai-chat-container-resize-layout`,{"ai-is-collapse":V(m)||!y.value?.length&&V(w)?.length<1||a.value===V(Wi).Share}]},o.value,{onResizing:B}),{aside:jn(()=>[!V(m)&&(V(w)?.length||y.value?.length)&&a.value!==V(Wi).Share?(H(),Gr(Lr,{key:0},[Zr(V(Awe),{active:V(p).name,class:`ai-chat-container-tab`,"label-height":40,type:`unborder-card`,onChange:R},{default:jn(()=>[(H(!0),Gr(Lr,null,dr(V(f),t=>(H(),Kr(V(r),{key:t.name,class:`ai-chat-container-tab-panel`,label:()=>U(`div`,{class:`ai-execution-summary-label`,onVnodeMounted:e=>{V(p).name===t.name&&e.el?.scrollIntoView({behavior:`smooth`})}},e.getSideTabRenderComponent?.(U,t,{removeCustomTab:V(g)})??[U(t.name===V(`execution`)?V(iie):V(aie),{class:`ai-execution-summary-icon`}),Mn(U(`span`,{class:`ai-execution-summary-label-text`},t.label??``),[[V(wp),{...e.commonTippyOptions,text:t.label??``}]]),t.name===V(`execution`)?null:U(V(Xi),{class:`ai-execution-close-icon`,onClick:()=>{V(g)(t.name)}})]),name:t.name},null,8,[`label`,`name`]))),128))]),_:1},8,[`active`]),V(p)?.name===V(`execution`)?(H(),Gr(Lr,{key:0},[V(m)?ti(`v-if`,!0):(H(),Kr(GGt,{key:0,"message-groups":V(w),style:{height:`calc(100% - 40px)`},onLocateMessageGroup:L,onUpdateKeyword:ee},null,8,[`message-groups`]))],64)):ti(`v-if`,!0),V(p)?(H(),Gr(`div`,{key:V(p).name,class:`ai-chat-container-message-slot`},[(H(),Kr(lr(s.value),ai({key:V(p).name},V(p)?.data?.props),{locateButton:jn(()=>[Zr(V(Cd),{class:`ai-locate-button`,size:`small`,text:``,theme:`primary`,onClick:n[0]||=e=>L(V(p)?.data?.messageUid)},{default:jn(()=>[ei(Oe(V(Ui)(`在对话中定位`)),1)]),_:1})]),_:1},16))])):ti(`v-if`,!0)],64)):ti(`v-if`,!0),V(w)?.length&&a.value!==V(Wi).Share?(H(),Gr(`div`,{key:1,class:be([`collapse-button`,{"is-right":e.placement===`right`}]),onClick:I},[Zr(V(iie)),ei(` `+Oe(V(Ui)(`执行情况`)),1)],2)):ti(`v-if`,!0)]),main:jn(()=>[e.messages?.length?pr(t.$slots,`default`,xe(ai({key:0},{messages:e.messages,messageStatus:e.messageStatus,messageGroups:V(C),selectedUserMessages:b.value,messageToolsStatus:e.messageToolsStatus,isShareMode:V(T),commonTippyOptions:e.commonTippyOptions,handleAgentAction:te,onAgentFeedback:e.onAgentFeedback,onUserAction:e.onUserAction,onUserInputConfirm:e.onUserInputConfirm,onUserShortcutConfirm:e.onUserShortcutConfirm})),()=>[e.messages?.length?(H(),Kr(PGt,{key:0,"selected-user-messages":b.value,"onUpdate:selectedUserMessages":n[1]||=e=>b.value=e,"enable-selection":V(T),"message-groups":V(C),"message-status":A.value,"message-tools-status":e.messageToolsStatus,"message-tools-tippy-options":e.commonTippyOptions,messages:e.messages,"on-agent-action":te,"on-agent-feedback":e.onAgentFeedback,"on-user-action":e.onUserAction,"on-user-input-confirm":e.onUserInputConfirm,"on-user-shortcut-confirm":e.onUserShortcutConfirm,"render-mode":a.value,onStopStreaming:n[2]||=e=>d(`stopStreaming`)},{default:jn(({message:e,messageToolsStatus:n})=>[pr(t.$slots,`message`,xe(Qr({message:e,messageToolsStatus:n})))]),_:3},8,[`selected-user-messages`,`enable-selection`,`message-groups`,`message-status`,`message-tools-status`,`message-tools-tippy-options`,`messages`,`on-agent-feedback`,`on-user-action`,`on-user-input-confirm`,`on-user-shortcut-confirm`,`render-mode`])):ti(`v-if`,!0)]):(H(),Gr(`div`,rKt,[pr(t.$slots,`welcome`,xe(Qr({openingRemark:e.openingRemark})),()=>[Zr(V(Yre)),Xr(`h2`,iKt,Oe(V(Ui)(`你好,我是小鲸`)),1),e.openingRemark?(H(),Gr(`div`,aKt,[Zr(l9,{content:e.openingRemark},null,8,[`content`])])):ti(`v-if`,!0)])])),a.value===V(Wi).Share?ti(`v-if`,!0):(H(),Gr(Lr,{key:2},[V(T)?(H(),Kr(tKt,{key:0,"is-all-selected":V(E),loading:!1,"selected-count":b.value.length,onCancel:V(O),onConfirm:z,onToggleAll:V(D)},null,8,[`is-all-selected`,`selected-count`,`onCancel`,`onToggleAll`])):l.value?.components?.length?(H(),Kr(Bwe,ai({key:1},l.value,{onClose:j,onSubmit:M}),null,16)):(H(),Kr(TUt,{key:2,cite:u.value,"onUpdate:cite":n[3]||=e=>u.value=e,"message-status":A.value,"model-value":e.modelValue,"on-send-message":e.onSendMessage,"on-stop-sending":e.onStopSending,"on-upload":e.onUpload,placeholder:e.placeholder,prompts:e.prompts,resources:e.resources,"shortcut-id":l.value?.id,shortcuts:e.shortcuts,"support-upload":e.supportUpload,"tippy-options":e.commonTippyOptions,onDeleteShortcut:N,onSelectShortcut:P,"onUpdate:modelValue":F},null,8,[`cite`,`message-status`,`model-value`,`on-send-message`,`on-stop-sending`,`on-upload`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`,`support-upload`,`tippy-options`]))],64))]),_:3},16,[`class`]))],4))}}),sKt=`data:image/png;base64,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`,cKt=e=>({conversationSettings:{openingRemark:e?.conversation_settings?.opening_remark,predefinedQuestions:e?.conversation_settings?.predefined_questions,commands:e?.conversation_settings?.commands?.map(e=>({id:e.id,name:e.name,alias:e.alias,icon:e.icon,components:e.components.map(e=>({type:e.type,name:e.name,key:e.key,placeholder:e.placeholder,default:e.default,required:e.required,fillBack:e.fill_back,fillRegx:e.fill_regx,rows:e.rows,min:e.min,max:e.max,options:e.options})),content:e.content,agentId:e.agent_id,status:e.status,supportUpload:e.support_upload})),enableChatSession:e?.conversation_settings?.enable_chat_session},promptSetting:e?.prompt_setting?{content:e.prompt_setting.content,supportUpload:e.prompt_setting.support_upload}:void 0,agentName:e?.agent_name,chatGroup:e?.chat_group?{enabled:e.chat_group.enabled,staff:e.chat_group.staff,username:e.chat_group.username}:void 0,saasUrl:e?.saas_url,resources:e?.resources}),N9=function(e){return e.FlowAgent=`flow_agent`,e.KnowledgeRag=`knowledge_rag`,e.ReferenceDocument=`reference_document`,e}({}),P9=function(e){return e.Activity=`activity`,e.Assistant=`assistant`,e.Developer=`developer`,e.Guide=`guide`,e.Hidden=`hidden`,e.HiddenAssistant=`hidden-assistant`,e.HiddenGuide=`hidden-guide`,e.HiddenSystem=`hidden-system`,e.HiddenUser=`hidden-user`,e.Info=`info`,e.Pause=`pause`,e.Placeholder=`placeholder`,e.Reasoning=`reasoning`,e.System=`system`,e.TemplateAssistant=`template-assistant`,e.TemplateGuide=`template-guide`,e.TemplateHidden=`template-hidden`,e.TemplateSystem=`template-system`,e.TemplateUser=`template-user`,e.Tool=`tool`,e.User=`user`,e}({}),F9=function(e){return e.Complete=`complete`,e.Error=`error`,e.Pending=`pending`,e.Stop=`stop`,e.Streaming=`streaming`,e}({}),lKt=function(e){return e.Binary=`binary`,e.Function=`function`,e.Text=`text`,e}({}),I9=e=>{let t={id:e.id,messageId:e.message_id,name:e.name,role:e.role,sessionCode:e.session_code,status:e.status};switch(e.role){case P9.Activity:{let n=e,r=e=>e.map(e=>({name:e.name,originFileUrl:e.origin_file_url,url:e.url})),i;switch(n.activity_type){case N9.ReferenceDocument:i=r(n.content);break;case N9.KnowledgeRag:{let e=n.content;i={content:e.content,referenceDocument:r(e.reference_document)};break}case N9.FlowAgent:default:i=n.content;break}return{...t,activityType:n.activity_type,content:i,role:n.role}}case P9.Assistant:{let n=e;return{...t,content:n.content,property:n.property,role:n.role,toolCalls:n.tool_calls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcpName:e.function.mcp_name},id:e.id,type:e.type}))}}case P9.Developer:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Guide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Hidden:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenAssistant:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenGuide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenSystem:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenUser:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Info:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Pause:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Placeholder:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Reasoning:{let n=e;return{...t,content:n.content,duration:n.duration,role:n.role}}case P9.System:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateAssistant:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateGuide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateHidden:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateSystem:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateUser:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Tool:{let n=e;return{...t,content:n.content,duration:n.duration,error:n.error,role:n.role,toolCallId:n.tool_call_id}}case P9.User:{let n=e,r=n.content;return{...t,content:Array.isArray(r)?r.map(e=>{if(e.type===lKt.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mimeType:t.mime_type,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role}}}},uKt=e=>{let t={id:e.id,message_id:e.messageId,name:e.name,role:e.role,session_code:e.sessionCode,status:e.status};switch(e.role){case P9.Activity:{let n=e,r=e=>e.map(e=>({name:e.name,origin_file_url:e.originFileUrl,url:e.url})),i;switch(n.activityType){case N9.ReferenceDocument:i=r(n.content);break;case N9.KnowledgeRag:{let e=n.content;i={content:e.content,reference_document:r(e.referenceDocument)};break}case N9.FlowAgent:default:i=n.content;break}return{...t,activity_type:n.activityType,content:i,role:n.role}}case P9.Assistant:{let n=e;return{...t,property:n.property,content:n.content,role:n.role,tool_calls:n.toolCalls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcp_name:e.function.mcpName},id:e.id,type:e.type}))}}case P9.Developer:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Guide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Hidden:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenAssistant:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenGuide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenSystem:{let n=e;return{...t,content:n.content,role:n.role}}case P9.HiddenUser:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Info:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Pause:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Placeholder:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Reasoning:{let n=e;return{...t,content:n.content,duration:n.duration,role:n.role}}case P9.System:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateAssistant:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateGuide:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateHidden:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateSystem:{let n=e;return{...t,content:n.content,role:n.role}}case P9.TemplateUser:{let n=e;return{...t,content:n.content,role:n.role}}case P9.Tool:{let n=e;return{...t,content:n.content,duration:n.duration,error:n.error,role:n.role,tool_call_id:n.toolCallId}}case P9.User:{let n=e,r=n.content;return{...t,content:Array.isArray(r)?r.map(e=>{if(e.type===lKt.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mime_type:t.mimeType,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role}}}},L9=e=>({sessionCode:e.session_code,sessionContentCount:e.session_content_count,sessionName:e.session_name,isTemporary:e.is_temporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updatedAt:e.updated_at,createdAt:e.created_at,roleInfo:e.role_info?{collectionId:e.role_info.collection_id,collectionName:e.role_info.collection_name,content:e.role_info.content,variables:e.role_info.variables}:void 0,sessionProperty:{isAutoClear:e.session_property?.is_auto_clear,isAutoCalcPrompt:e.session_property?.is_auto_clac_prompt}}),dKt=e=>({session_code:e.sessionCode,session_content_count:e.sessionContentCount,session_name:e.sessionName,is_temporary:e.isTemporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updated_at:e.updatedAt,created_at:e.createdAt,role_info:e.roleInfo?{collection_id:e.roleInfo.collectionId,collection_name:e.roleInfo.collectionName,content:e.roleInfo.content,variables:e.roleInfo.variables}:void 0,session_property:{is_auto_clear:e.sessionProperty?.isAutoClear,is_auto_clac_prompt:e.sessionProperty?.isAutoCalcPrompt}}),fKt=e=>({session_code:e.sessionCode,session_content_ids:e.sessionContentIds,rate:e.rate,comment:e.comment,labels:e.labels}),pKt=e=>({sessionCode:e.session_code,sessionContentIds:e.session_content_ids,rate:e.rate,comment:e.comment,labels:e.lables}),mKt=()=>`temp_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,hKt=e=>{let t=sn([]),n=sn(!1),r=sn(!1),i=r=>(n.value=!0,e.http?.message.getMessages(r).then(e=>{t.value=e}).finally(()=>{n.value=!1})),a=()=>f(t.value),o=e=>{t.value=t.value.map(t=>t.messageId===e.messageId?e:t)},s=e=>{t.value.push(e)},l=()=>t.value.findLast(e=>[F9.Pending,F9.Streaming].includes(e.status)),u=e=>t.value.find(t=>t.messageId===e),d=async n=>{let r=mKt(),i={...n,id:r,messageId:r};t.value.push(i);try{let i=await e.http?.message.plusMessage(n);if(i){let e=t.value.findIndex(e=>e.messageId===r);if(e!==-1){let r={...i,...`property`in n&&n.property?{property:n.property}:{}};t.value[e]=r}}}catch(e){let n=t.value.findIndex(e=>e.messageId===r);throw n!==-1&&(t.value[n]={...t.value[n],status:F9.Error}),e}},f=async n=>{let i=n.reduce((e,t)=>(t.role===P9.User&&e.push(t.id),e),[]);if(i.length<=0)return;let a=[...t.value];t.value=t.value.filter(e=>!n.includes(e)),r.value=!0;try{await e.http?.message.batchDeleteMessages(i)}catch(e){throw t.value=a,e}finally{r.value=!1}};return{list:t,isListLoading:n,isDeleteLoading:r,getMessages:i,clearMessages:a,getCurrentLoadingMessage:l,getMessageByMessageId:u,modifyMessage:o,plusMessage:s,createAndPlusMessage:d,deleteMessages:f,shareMessages:async(t,n,r)=>{let i=n.reduce((e,t)=>(t.role===P9.User&&e.push(t.id),e),[]);if(!(i.length<=0))return e.http?.message.shareMessages(t,i,r)},getFlowAgentTaskInfo:t=>e.http?.message.getFlowAgentTaskInfo(t),getFlowAgentTaskNodeInfo:(t,n)=>e.http?.message.getFlowAgentTaskNodeInfo(t,n),reset:()=>{t.value=[],n.value=!1,r.value=!1}}},R9=function(e){return e.FlowAgentEnd=`flow_agent_end`,e.FlowAgentResult=`flow_agent_result`,e.FlowAgentStart=`flow_agent_start`,e.KnowledgeRagEnd=`knowledge_rag_end`,e.KnowledgeRagResult=`knowledge_rag_result`,e.KnowledgeRagStart=`knowledge_rag_start`,e.KnowledgeRagTextContent=`knowledge_rag_text_content`,e.ReferenceDocument=`reference_document`,e.TempMessage=`temp_message`,e}({}),z9=function(e){return e.ActivityDelta=`ACTIVITY_DELTA`,e.ActivitySnapshot=`ACTIVITY_SNAPSHOT`,e.Custom=`CUSTOM`,e.MessagesSnapshot=`MESSAGES_SNAPSHOT`,e.Raw=`RAW`,e.RunError=`RUN_ERROR`,e.RunFinished=`RUN_FINISHED`,e.RunStarted=`RUN_STARTED`,e.StateDelta=`STATE_DELTA`,e.StateSnapshot=`STATE_SNAPSHOT`,e.StepFinished=`STEP_FINISHED`,e.StepStarted=`STEP_STARTED`,e.TextMessageChunk=`TEXT_MESSAGE_CHUNK`,e.TextMessageContent=`TEXT_MESSAGE_CONTENT`,e.TextMessageEnd=`TEXT_MESSAGE_END`,e.TextMessageStart=`TEXT_MESSAGE_START`,e.ThinkingEnd=`THINKING_END`,e.ThinkingStart=`THINKING_START`,e.ThinkingTextMessageContent=`THINKING_TEXT_MESSAGE_CONTENT`,e.ThinkingTextMessageEnd=`THINKING_TEXT_MESSAGE_END`,e.ThinkingTextMessageStart=`THINKING_TEXT_MESSAGE_START`,e.ToolCallArgs=`TOOL_CALL_ARGS`,e.ToolCallChunk=`TOOL_CALL_CHUNK`,e.ToolCallEnd=`TOOL_CALL_END`,e.ToolCallResult=`TOOL_CALL_RESULT`,e.ToolCallStart=`TOOL_CALL_START`,e}({}),gKt=function(e){return e.Blocked=`BLOCKED`,e.Created=`CREATED`,e.Failed=`FAILED`,e.Finished=`FINISHED`,e.LoopReady=`LOOP_READY`,e.Ready=`READY`,e.Revoked=`REVOKED`,e.RollBackFailed=`ROLL_BACK_FAILED`,e.RollBackSuccess=`ROLL_BACK_SUCCESS`,e.RollingBack=`ROLLING_BACK`,e.Running=`RUNNING`,e.Suspended=`SUSPENDED`,e}({}),B9=class{messageModule;onDoneCallback;onErrorCallback;onMessageCallback;onStartCallback;constructor(e){this.onDoneCallback=e?.onDone,this.onErrorCallback=e?.onError,this.onMessageCallback=e?.onMessage,this.onStartCallback=e?.onStart}handleActivityDeltaEvent(e){}handleActivitySnapshotEvent(e){}handleCustomEvent(e){switch(e.name){case R9.FlowAgentStart:this.handleFlowAgentStartCustomEvent(e);break;case R9.FlowAgentResult:this.handleFlowAgentResultCustomEvent(e);break;case R9.FlowAgentEnd:this.handleFlowAgentEndCustomEvent(e);break;case R9.ReferenceDocument:this.handleReferenceDocumentCustomEvent(e);break;case R9.KnowledgeRagStart:this.handleKnowledgeRagStartCustomEvent(e);break;case R9.KnowledgeRagTextContent:this.handleKnowledgeRagTextContentCustomEvent(e);break;case R9.KnowledgeRagResult:this.handleKnowledgeRagResultCustomEvent(e);break;case R9.KnowledgeRagEnd:this.handleKnowledgeRagEndCustomEvent(e);break;case R9.TempMessage:this.handleTempMessageCustomEvent(e);break;default:break}}handleFlowAgentEndCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();if(t&&t.role===P9.Activity&&t.activityType===N9.FlowAgent){t.status=F9.Complete;let n=e.value;this.messageModule.plusMessage({role:P9.Assistant,content:n.map(e=>e.task_outputs.join(`
|
|
3499
3499
|
`)).join(`
|
|
3500
3500
|
`),status:F9.Complete})}}handleFlowAgentResultCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Activity&&t.activityType===N9.FlowAgent&&(t.content=e.value)}handleFlowAgentStartCustomEvent(e){let t=e.value;this.messageModule.plusMessage({role:P9.Activity,activityType:N9.FlowAgent,content:t.map(e=>({nodes:{},task_id:Number(e.task_id),task_name:``,task_outputs:[],task_state:gKt.Created})),status:F9.Streaming})}handleKnowledgeRagEndCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Activity&&t.activityType===N9.KnowledgeRag&&(t.status=F9.Complete)}handleKnowledgeRagResultCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Activity&&t.activityType===N9.KnowledgeRag&&(t.content.referenceDocument=e.value)}handleKnowledgeRagStartCustomEvent(e){this.messageModule.plusMessage({role:P9.Activity,activityType:N9.KnowledgeRag,content:{content:``,referenceDocument:[]},status:F9.Streaming})}handleKnowledgeRagTextContentCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();if(t&&t.role===P9.Activity&&t.activityType===N9.KnowledgeRag){let n=e.value;t.content.content=n.cover?n.chunk.content:t.content.content+n.chunk.content}}handleMessagesSnapshotEvent(e){e.messages&&e.messages.length>0&&(this.messageModule.list.value=e.messages.map(I9))}handleRawEvent(e){}handleReferenceDocumentCustomEvent(e){this.messageModule.plusMessage({role:P9.Activity,activityType:N9.ReferenceDocument,content:e.value,status:F9.Complete})}handleRunErrorEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=F9.Complete),this.messageModule.plusMessage({role:P9.Assistant,content:e.message,status:F9.Error})}handleRunFinishedEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=F9.Complete)}handleRunStartedEvent(e){}handleStateDeltaEvent(e){}handleStateSnapshotEvent(e){}handleStepFinishedEvent(e){}handleStepStartedEvent(e){}handleTempMessageCustomEvent(e){let t=e.value;this.messageModule.plusMessage({role:P9.Assistant,content:t.message,status:t.status})}handleTextMessageChunkEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t?t.content+=e.delta||``:this.messageModule.plusMessage({role:e.role,content:e.delta||``,status:F9.Complete,messageId:e.messageId})}handleTextMessageContentEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.content+=e.delta)}handleTextMessageEndEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.status=F9.Complete)}handleTextMessageStartEvent(e){this.messageModule.plusMessage({role:e.role,content:``,status:F9.Streaming,messageId:e.messageId})}handleThinkingEndEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Reasoning&&(t.duration=e.duration,t.status=F9.Complete)}handleThinkingStartEvent(e){this.messageModule.plusMessage({role:P9.Reasoning,content:[],status:F9.Streaming})}handleThinkingTextMessageContentEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Reasoning&&(t.content[t.content.length-1]+=e.delta)}handleThinkingTextMessageEndEvent(e){}handleThinkingTextMessageStartEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===P9.Reasoning&&t.content.push(``)}handleToolCallArgsEvent(e){this.messageModule.list.value.forEach(t=>{t.role===P9.Assistant&&t.toolCalls&&t.toolCalls.forEach(t=>{t.id===e.toolCallId&&(t.function.arguments+=e.delta)})})}handleToolCallChunkEvent(e){}handleToolCallEndEvent(e){this.messageModule.list.value.forEach(t=>{t.role===P9.Assistant&&t.toolCalls&&t.toolCalls.some(t=>t.id===e.toolCallId)&&(t.status=F9.Complete)})}handleToolCallResultEvent(e){this.messageModule.plusMessage({role:P9.Tool,content:e.content,duration:e.duration,status:F9.Complete,toolCallId:e.toolCallId,messageId:e.messageId})}handleToolCallStartEvent(e){this.messageModule.plusMessage({role:P9.Assistant,content:``,status:F9.Streaming,toolCalls:[{id:e.toolCallId,type:lKt.Function,function:{mcpName:e.mcpName,name:e.toolCallName,arguments:``,description:e.description}}]})}injectMessageModule(e){this.messageModule=e}onDone(){this.onDoneCallback?.()}onError(e){this.messageModule.plusMessage({role:P9.Assistant,content:e.message,status:F9.Error}),this.onErrorCallback?.(e)}onMessage(e){let t=e;switch(this.onMessageCallback?.(t),t.type){case z9.ActivityDelta:this.handleActivityDeltaEvent(t);break;case z9.ActivitySnapshot:this.handleActivitySnapshotEvent(t);break;case z9.Custom:this.handleCustomEvent(t);break;case z9.MessagesSnapshot:this.handleMessagesSnapshotEvent(t);break;case z9.Raw:this.handleRawEvent(t);break;case z9.RunError:this.handleRunErrorEvent(t);break;case z9.RunFinished:this.handleRunFinishedEvent(t);break;case z9.RunStarted:this.handleRunStartedEvent(t);break;case z9.StateDelta:this.handleStateDeltaEvent(t);break;case z9.StateSnapshot:this.handleStateSnapshotEvent(t);break;case z9.StepFinished:this.handleStepFinishedEvent(t);break;case z9.StepStarted:this.handleStepStartedEvent(t);break;case z9.TextMessageChunk:this.handleTextMessageChunkEvent(t);break;case z9.TextMessageContent:this.handleTextMessageContentEvent(t);break;case z9.TextMessageEnd:this.handleTextMessageEndEvent(t);break;case z9.TextMessageStart:this.handleTextMessageStartEvent(t);break;case z9.ThinkingEnd:this.handleThinkingEndEvent(t);break;case z9.ThinkingStart:this.handleThinkingStartEvent(t);break;case z9.ThinkingTextMessageContent:this.handleThinkingTextMessageContentEvent(t);break;case z9.ThinkingTextMessageEnd:this.handleThinkingTextMessageEndEvent(t);break;case z9.ThinkingTextMessageStart:this.handleThinkingTextMessageStartEvent(t);break;case z9.ToolCallArgs:this.handleToolCallArgsEvent(t);break;case z9.ToolCallChunk:this.handleToolCallChunkEvent(t);break;case z9.ToolCallEnd:this.handleToolCallEndEvent(t);break;case z9.ToolCallResult:this.handleToolCallResultEvent(t);break;case z9.ToolCallStart:this.handleToolCallStartEvent(t);break;default:break}}onStart(){this.onStartCallback?.()}},_Kt=(e,t)=>{let n=sn(null),r=sn(!1),i=sn(!1),a=t||new B9,o=null,s=()=>(r.value=!0,e.http?.agent.getAgentInfo().then(e=>{n.value=e}).finally(()=>{r.value=!1})),l=(t,n)=>{let r=t.promptSetting?.content?.at(-1);r?.role===P9.Pause&&e.message?.createAndPlusMessage({role:P9.Assistant,content:r.content,status:F9.Complete,sessionCode:n,property:{extra:{pause:!0}}})},u=async(t,n,r)=>{a instanceof B9&&a.injectMessageModule(e.message),o=new AbortController,e.http?.fetchClient.streamRequest({url:n||`chat_completion/`,method:`POST`,data:{session_code:t,execute_kwargs:{stream:!0}},controller:o,onDone:()=>{i.value=!1,a.onDone?.call(a)},onError:e=>{i.value=!1,a.onError?.call(a,e)},onMessage:e=>{a.onMessage?.call(a,e)},onStart:()=>{i.value=!0,a.onStart?.call(a)},...r})};return{info:n,isInfoLoading:r,isChatting:i,chat:async(t,n,r,i,a)=>{await e.message?.createAndPlusMessage({role:P9.User,content:t,status:F9.Complete,sessionCode:n,...a&&{property:a}}),u(n,r,i)},handleRole:l,resendMessage:async(t,n,r,i,a)=>{let o=e.message?.list.value||[],s=o.findIndex(e=>String(e.id)===t);if(s===-1)throw Error(`Message not found: ${t}`);let l=o[s];if(l.role!==P9.User)throw Error(`Can only resend user messages`);let d=l.content,f=l.property,p=r??d,m=o.slice(s),h=e.message?.deleteMessages(m),g=e.message?.createAndPlusMessage({role:P9.User,content:p,status:F9.Complete,sessionCode:n,...f&&{property:f}});u(n,i,a),Promise.all([h,g]).catch(e=>{console.error(`[resendMessage] API error:`,e)})},resumeStreamingChat:(t,n,r)=>{let i=e.message?.list.value.at(-1);(i?.status===F9.Streaming||i?.role===P9.User)&&u(t,n,r)},abortChat:()=>{o?.abort?.(),o=null},stopChat:async t=>e.http.message?.stopChat(t),getAgentInfo:s,reset:e=>{a=e||new B9,n.value=null,r.value=!1}}};function vKt(e){return on(e)}function V9(e){if(e==null)return;let t=e,n=0;for(;n<32;){if(n+=1,typeof t==`function`){t=t();continue}if(vKt(t)){t=V(t);continue}break}return n>=32&&console.warn(`[chat-helper] resolveRequestValue: exceeded max unwrap depth`),t}var yKt=class{handlers=[];clear(){this.handlers=[]}eject(e){this.handlers[e]&&(this.handlers[e]=null)}forEach(e){this.handlers.forEach(t=>{t!==null&&e(t)})}use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1}},bKt=class e{defaults;interceptors;constructor(e={}){this.defaults=U9({method:`GET`,headers:{"Content-Type":`application/json`},timeout:3e4,responseType:`json`,credentials:`include`,mode:`cors`,validateStatus:e=>e>=200&&e<300},e),this.interceptors={request:new yKt,response:new yKt}}applyResponseErrorInterceptors(e){let t=e;return this.interceptors.response.forEach(e=>{e.rejected&&(t=e.rejected(t))}),t}create(t){return new e(U9(this.defaults,t||{}))}delete(e,t,n){return this.request({...n,url:e,method:`DELETE`,params:t})}get(e,t,n){return this.request({...n,url:e,method:`GET`,params:t})}head(e,t,n){return this.request({...n,url:e,method:`HEAD`,params:t})}options(e,t,n){return this.request({...n,url:e,method:`OPTIONS`,params:t})}patch(e,t,n){return this.request({...n,url:e,method:`PATCH`,data:t})}post(e,t,n){return this.request({...n,url:e,method:`POST`,data:t})}prepareRequest(e,t=!1){let n=U9(this.defaults,e);this.interceptors.request.forEach(e=>{if(e.fulfilled)try{n=e.fulfilled(n)}catch(t){throw e.rejected?e.rejected(t):t}});let r=n.url||``;n.baseURL&&!r.startsWith(`http`)&&(r=n.baseURL+r),r=xKt(r,n.params);let i=SKt(n.data),a=new Headers(SKt(n.headers));t&&!a.has(`Accept`)&&a.set(`Accept`,`text/event-stream`),i!=null&&(n.transformRequest?i=n.transformRequest(i,SKt(n.headers)):a.get(`Content-Type`)?.includes(`application/json`)&&typeof i==`object`&&!(i instanceof FormData)&&!(i instanceof Blob)&&!(i instanceof ArrayBuffer)&&(i=JSON.stringify(i)));let o=n.controller??new AbortController,s={method:n.method,credentials:n.credentials,mode:n.mode,headers:a,body:i,signal:o.signal};return{url:r,requestConfig:n,fetchConfig:s,controller:o}}put(e,t,n){return this.request({...n,url:e,method:`PUT`,data:t})}async request(e){let{url:t,fetchConfig:n,requestConfig:r,controller:i}=this.prepareRequest(e),a=r.timeout&&r.timeout>0?setTimeout(()=>i.abort(),r.timeout):void 0;try{let e=await fetch(t,n);a&&clearTimeout(a);let i,o=r.responseType||`json`;try{switch(o){case`json`:i=await e.json();break;case`text`:i=await e.text();break;case`blob`:i=await e.blob();break;case`arrayBuffer`:i=await e.arrayBuffer();break;case`formData`:i=await e.formData();break;default:i=await e.json()}}catch{i=null}r.transformResponse&&(i=r.transformResponse(i));let s={data:i,status:e.status,statusText:e.statusText,headers:e.headers,config:r};if(!(r.validateStatus||this.defaults.validateStatus)(e.status))throw H9(s.data?.error?.message||`Request failed with status code ${e.status}`,r,`ERR_BAD_RESPONSE`,s);let l=s;this.interceptors.response.forEach(e=>{if(e.fulfilled)try{l=e.fulfilled(l)}catch(t){throw e.rejected?e.rejected(t):t}}),l instanceof Promise&&(l=await l);let u=l.data;if(![0,`success`].includes(u.code))throw H9(u.message,r,u.code,l);return u.data}catch(e){if(a&&clearTimeout(a),e instanceof Error&&e.name===`AbortError`){let e=H9(`Request timeout`,r,`ECONNABORTED`,void 0);throw this.applyResponseErrorInterceptors(e)}let t=e.isAxiosError===!0?e:H9(e.message,r,e.code,void 0);throw this.applyResponseErrorInterceptors(t)}}stream(e,t){return this.streamRequest({...t,url:e})}async streamRequest(e){let{url:t,fetchConfig:n,requestConfig:r}=this.prepareRequest(e,!0);try{let i=await fetch(t,n);if(!(r.validateStatus||this.defaults.validateStatus)(i.status)){let t=`Request failed with status code ${i.status}`;try{let e=await i.json();e?.error?.message&&(t=e.error.message)}catch{t=`Request failed with status code ${i.status}`}let n=H9(t,r,`ERR_BAD_RESPONSE`,void 0);e.onError?.(n);return}e.onStart?.();let a=i.body?.pipeThrough(new window.TextDecoderStream).getReader();if(!a){let t=Error(`IResponse body is not readable`);e.onError?.(t);return}let o=``,s=e=>{try{return JSON.parse(e),!0}catch{return!1}};for(;;){let{value:t,done:n}=await a.read();if(n){e.onDone?.();break}(o+t.toString()).split(`
|
|
3501
|
-
`).forEach(t=>{let n=t.replace(`data:`,``).trim();if(s(n)){let t=JSON.parse(n);e.onMessage?.(t),o=``}else n&&(o=n)})}}catch(t){throw t instanceof Error&&(t.name===`AbortError`?e.onDone?.():e.onError?.(t)),t}}};function xKt(e,t){if(!t)return e;let n=new URLSearchParams;Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(Array.isArray(r)?r.forEach(t=>n.append(e,String(t))):n.append(e,String(r)))});let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e}function H9(e,t,n,r){let i=Error(e);return i.config=t,i.code=String(n),i.response=r,i.isAxiosError=!0,i}function SKt(e){return V9(e)}function CKt(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function U9(e,t){let n={...e};for(let r in t){let i=t[r];if(CKt(i)){let t=e[r];n[r]=U9(t||{},i)}else n[r]=i}return n}new bKt;var wKt=new Set([`POST`,`PUT`,`PATCH`,`DELETE`]),TKt=new Set([`GET`,`HEAD`,`OPTIONS`]);function EKt(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function DKt(e,t){let{headers:n,data:r}=t.requestData;!n&&!r||e.interceptors.request.use(e=>{let t=e,i=(e.method??`GET`).toUpperCase();if(n){let r=V9(n);if(r&&Object.keys(r).length>0){let n=V9(e.headers)??{};t={...t,headers:{...n,...r}}}}if(r){let n=V9(r);if(n&&Object.keys(n).length>0){if(wKt.has(i)){let r=V9(e.data);r==null?t={...t,data:n}:EKt(r)?t={...t,data:{...n,...r}}:console.warn(`[chat-helper] requestData.data 无法注入:当前请求体不是普通对象(FormData/Blob/string 等),已跳过合并。`,{method:i,existingType:typeof r})}else if(TKt.has(i)){let r=e.params??{};t={...t,params:{...n,...r}}}}}return t})}var OKt=e=>{let t=new bKt({baseURL:e.requestData.urlPrefix});return DKt(t,e),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response),{fetchClient:t,reset:e=>{t.defaults.baseURL=e.requestData.urlPrefix,t.interceptors.request.clear(),t.interceptors.response.clear(),DKt(t,e),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response)}}},kKt=e=>({getAgentInfo:t=>e.get(`agent/info/`,void 0,t).then(cKt)}),AKt=e=>({getMessages:(t,n,r)=>e.get(`session_content/content/`,{session_code:t,limit:n},r).then(e=>e.map(I9)),plusMessage:(t,n)=>e.post(`session_content/`,uKt(t),n).then(I9),modifyMessage:(t,n)=>e.put(`session_content/${t.id}/`,uKt(t),n).then(I9),deleteMessage:(t,n)=>e.delete(`session_content/${t}/`,void 0,n),batchDeleteMessages:(t,n)=>e.post(`session_content/batch_delete/`,{ids:t},n),shareMessages:(t,n,r,i)=>e.post(`share/`,{session_code:t,content_ids:n,...r?{expired_at:r}:{}},i),stopChat:(t,n)=>e.post(`session_content/stop/`,{session_code:t},n),getFlowAgentTaskInfo:(t,n)=>e.get(`flow_agent/${t}/task_info/`,void 0,n),getFlowAgentTaskNodeInfo:(t,n,r)=>e.get(`flow_agent/${t}/task_node_info/${n}/`,void 0,r)}),jKt=e=>({clearSession:(t,n)=>e.post(`chat_completion/${t}/clear/`,void 0,n),getSessions:t=>e.get(`session/`,void 0,t).then(e=>e.map(L9)),plusSession:(t,n)=>e.post(`session/`,dKt(t),n).then(e=>L9(e)),modifySession:(t,n)=>e.put(`session/${t.sessionCode}/`,dKt(t),n).then(e=>L9(e)),deleteSession:(t,n)=>e.delete(`session/${t}/`,void 0,n),batchDeleteSessions:(t,n)=>e.post(`session/batch_delete/`,{session_codes:t},n),getSession:(t,n)=>e.get(`session/${t}/`,void 0,n).then(e=>L9(e)),postSessionFeedback:(t,n)=>e.post(`session_feedback/`,fKt(t),n).then(e=>pKt(e)),getSessionFeedbackReasons:(t,n)=>e.get(`session_feedback/reasons/`,{rate:t},n),renameSession:(t,n)=>e.post(`session/${t}/ai_rename/`,void 0,n).then(e=>L9(e)),uploadFile:(t,n,r)=>{let i=encodeURIComponent(n.name);return n.arrayBuffer().then(a=>e.post(`session/${t}/upload/${i}/`,a,{...r,headers:{"Content-Disposition":`attachment; filename="${n.name}"`}}))}}),MKt=e=>({agent:kKt(e),session:jKt(e),message:AKt(e),fetchClient:e}),NKt=e=>{let{fetchClient:t,reset:n}=OKt(e);return{...MKt(t),reset:n}},PKt=()=>({agent:null,http:null,message:null,session:null,registerAgent(e){this.agent=e},registerHttp(e){this.http=e},registerMessage(e){this.message=e},registerSession(e){this.session=e}}),FKt=e=>{let t=sn([]),n=sn(null),r=sn(!1),i=sn(!1),a=sn(!1),o=sn(!1),s=sn(!1),l=sn(!1),u=sn(!1),d=e=>{t.value=t.value.map(t=>t.sessionCode===e.sessionCode?{...t,...e}:t),n.value?.sessionCode===e.sessionCode&&(n.value=t.value.find(t=>t.sessionCode===e.sessionCode)??n.value)},f=()=>(i.value=!0,e.http?.session.getSessions().then(e=>{t.value=e}).finally(()=>{i.value=!1})),p=async(r,i)=>{e.agent?.abortChat(),n.value=t.value.find(e=>e.sessionCode===r)??null,i?.loadMessages===!1?e.message&&(e.message.list.value=[]):(await e.message?.getMessages(r),e.agent?.resumeStreamingChat(r))};return{list:t,current:n,isCurrentLoading:r,isListLoading:i,isCreateLoading:a,isUpdateLoading:o,isDeleteLoading:s,isBatchDeleteLoading:l,getSessions:f,chooseSession:p,getSession:t=>(r.value=!0,e.http?.session.getSession(t).then(e=>{n.value=e}).finally(()=>{r.value=!1})),createSession:async(n,r)=>{a.value=!0;try{let i=await e.http?.session.plusSession(n);i&&(t.value.unshift(i),await p(i.sessionCode,{loadMessages:r?.loadMessages??!1}))}finally{a.value=!1}},updateSession:t=>(o.value=!0,e.http?.session.modifySession(t).then(e=>{d(e)}).finally(()=>{o.value=!1})),deleteSession:async r=>{s.value=!0;try{await e.http?.session.deleteSession(r),t.value=t.value.filter(e=>e.sessionCode!==r),n.value?.sessionCode===r&&t.value[0]?.sessionCode&&await p(t.value[0].sessionCode)}finally{s.value=!1}},batchDeleteSessions:async r=>{if(r.length!==0){l.value=!0;try{await e.http?.session.batchDeleteSessions(r);let i=new Set(r);t.value=t.value.filter(e=>!i.has(e.sessionCode)),n.value&&i.has(n.value.sessionCode)&&(t.value.length>0?await p(t.value[0].sessionCode):(n.value=null,e.message&&(e.message.list.value=[])))}finally{l.value=!1}}},postSessionFeedback:t=>e.http?.session.postSessionFeedback(t),getSessionFeedbackReasons:t=>e.http?.session.getSessionFeedbackReasons(t),renameSession:t=>(u.value=!0,e.http?.session.renameSession(t).then(e=>{d({sessionCode:e.sessionCode,sessionName:e.sessionName})}).finally(()=>{u.value=!1})),uploadFile:(t,n)=>e.http?.session.uploadFile(t,n),reset:()=>{t.value=[],n.value=null,r.value=!1,i.value=!1,a.value=!1,o.value=!1,s.value=!1,l.value=!1,u.value=!1}}},IKt=e=>{let t=PKt(),n=NKt(e),r=_Kt(t,e.protocol),i=hKt(t),a=FKt(t);return t.registerHttp(n),t.registerMessage(i),t.registerAgent(r),t.registerSession(a),{agent:r,session:a,message:i,http:n,reset:e=>{n.reset(e),r.reset(e.protocol),i.reset(),a.reset()}}};function LKt(e,t){return{urlPrefix:e,headers:()=>V9(un(t)?.headers),data:()=>V9(un(t)?.data)}}function RKt(e,t){let n=null;for(let r of e)if(r.role===`user`&&r.id!==void 0&&(n=r),r===t)break;return n}function zKt(e,t){let n=RKt(e,t);if(n?.id!==void 0)return typeof n.id==`number`?n.id:Number(n.id)}function BKt(e){if(!e)return[];if(typeof e!=`string`)return[{type:`text`,content:e}];let t=[],n=/```custom-component\s*\n([\s\S]*?)\n```/g,r=0,i;for(;(i=n.exec(e))!==null;){if(i.index>r){let n=e.slice(r,i.index).trim();n&&t.push({type:`text`,content:n})}try{let e=JSON.parse(i[1]);t.push({type:`custom`,data:e,raw:i[1]})}catch{t.push({type:`text`,content:i[0]})}r=i.index+i[0].length}if(r<e.length){let n=e.slice(r).trim();n&&t.push({type:`text`,content:n})}return t}var VKt=e=>{let t=document.cookie.match(RegExp(`(^| )${e}=([^;]*)(;|$)`));return t?t[2]:``},HKt=e=>e.endsWith(`/`)?e:`${e}/`,UKt=e=>{if(!e)return e;try{let t=new URL(e,window.location.origin);return t.protocol=window.location.protocol,HKt(t.toString())}catch(t){return console.warn(`Failed to normalize URL:`,t),HKt(e)}};async function WKt(e){if(typeof navigator<`u`&&`clipboard`in navigator)try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{document.body.removeChild(t)}}function GKt(){let e=window.navigator.userAgent.toLowerCase(),t=window.navigator.platform.toLowerCase();return t.includes(`mac`)||e.includes(`mac`)?`mac`:t.includes(`win`)||e.includes(`win`)?`windows`:t.includes(`linux`)||e.includes(`linux`)?`linux`:`unknown`}function KKt(){return qKt()?`Cmd + I`:`Ctrl + I`}function qKt(){return GKt()===`mac`}function JKt(e){let t=qKt()?e.metaKey:e.ctrlKey,n=e.key.toLowerCase()===`i`;return t&&n&&!e.shiftKey&&!e.altKey}var YKt=VKt(`blueking_language`)||`zh-cn`,XKt={小鲸:`BK GPT`,关闭:`close`,发送:`Send`,请输入:`Please input`,昨天:`yesterday`,"3天前":`3 days ago`,"5天前":`5 days ago`,"1周前":`1 week ago`,更早:`Older`,删除:`Delete`,恢复默认大小:`Restore default size`,"AI 小鲸":`AI BK GPT`,新增会话:`New chat`,历史会话:`History session`,停止生成:`Stop generating`,复制:`Copy`,编辑:`Edit`,今天:`Today`,搜索会话名称:`Search session name`,重命名:`Rename`,自动生成命名:`Auto generate name`,分享会话:`Share session`,无智能体使用权限:`No permission to use this agent`,暂无使用权限:`No permission`,请输入新的会话名称:`Please enter new session name`,"确认删除会话 ?":`Confirm delete session?`,搜索为空:`No search results`,暂无对话:`No conversations`,转人工:`Transfer to human`,缩小高度:`Shrink height`,全选:`Select all`,取消:`Cancel`,确定:`Confirm`,分享链接已复制到剪贴板:`Share link copied to clipboard`},ZKt={重命名:`重命名`,自动生成命名:`自动生成命名`,分享会话:`分享会话`,全选:`全选`,取消:`取消`,确定:`确定`,分享链接已复制到剪贴板:`分享链接已复制到剪贴板`},W9=e=>YKt===`en`?XKt[e]||e:ZKt[e]||e;function QKt(e){let{triggerRef:t,panelComponent:n,panelProps:r={},tippyOptions:i={}}=e,a=sn(null),o=null,s=()=>(o||=document.createElement(`div`),Fi(U(n,{...r,onClose:f}),o),o),l=e=>{let n=e.target,r=t.value;if(r&&r.contains(n))return;let i=document.querySelector(`.tippy-box[data-theme~="history-panel"]`);if(i&&i.contains(n))return;let o=document.querySelector(`.tippy-box[data-theme~="more-menu-light"]`);o&&o.contains(n)||a.value?.state.isVisible&&a.value.hide()},u=()=>{if(!t.value||a.value)return;let e={placement:`bottom-end`,offset:[0,8],appendTo:document.querySelector(`.ai-blueking-container-wrapper`)||document.body};a.value=xp(t.value,{content:s(),interactive:!0,trigger:`manual`,theme:`light history-panel`,arrow:!1,hideOnClick:!1,animation:`scale`,duration:200,delay:[0,0],...e,...i,onShow:()=>{a.value&&o&&a.value.setContent(s()),setTimeout(()=>{document.addEventListener(`click`,l,!1)},0)},onHidden:()=>{document.removeEventListener(`click`,l,!1)}})},d=()=>{a.value||u(),a.value?.show()},f=()=>{a.value?.hide()},p=()=>{a.value||u(),a.value?.state.isVisible?f():d()},m=e=>{e.stopPropagation(),p()},h=()=>{a.value&&=(a.value.destroy(),null),o&&=(Fi(null,o),null),document.removeEventListener(`click`,l,!1)};return sr(()=>{h()}),{show:d,hide:f,toggle:p,handleTriggerClick:m,destroy:h,isVisible:()=>a.value?.state.isVisible??!1}}var $Kt={class:`history-group`},eqt={class:`history-group-title`},tqt={class:`history-group-list`},nqt=Qn({__name:`history-group`,props:{currentSessionCode:{},sessions:{},title:{}},setup(e){let t=e;return(e,n)=>(H(),Gr(`div`,$Kt,[Xr(`div`,eqt,[Xr(`span`,null,Oe(t.title),1)]),Xr(`div`,tqt,[pr(e.$slots,`default`,{},void 0,!0)])]))}}),G9=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},rqt=G9(nqt,[[`__scopeId`,`data-v-3b603cb6`]]),iqt={class:`history-item-actions`},aqt=G9(Qn({__name:`history-item`,props:{isActive:{type:Boolean},isEditing:{type:Boolean},session:{}},emits:[`click`,`delete`,`edit`,`rename-cancel`,`rename-confirm`],setup(e,{emit:t}){let n=e,r=t,i=Nwe,a=sn(null),o=sn(``);Ln(()=>n.isEditing,e=>{e&&(o.value=n.session.sessionName,En(()=>{if(a.value)try{let e=a.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus edit input:`,e)}}))});let s=()=>{n.isEditing||r(`click`,n.session)},l=()=>{r(`edit`,n.session)},u=()=>{r(`delete`,n.session.sessionCode)},d=()=>{let e=o.value.trim();e&&e!==n.session.sessionName?r(`rename-confirm`,n.session.sessionCode,e):r(`rename-cancel`)},f=()=>{r(`rename-cancel`)},p=(e,t)=>{t.key===`Enter`?d():t.key===`Escape`&&f()};return(e,t)=>(H(),Gr(`div`,{class:be([`history-item`,{active:n.isActive}]),onClick:s},[n.isEditing?(H(),Kr(V(Pd),{key:1,ref_key:`editInputRef`,ref:a,modelValue:o.value,"onUpdate:modelValue":t[1]||=e=>o.value=e,style:{width:`100%`,height:`28px`},onBlur:d,onKeyup:p,onClick:t[2]||=Pi(()=>{},[`stop`])},null,8,[`modelValue`])):(H(),Gr(Lr,{key:0},[Zr(V(xbe),{style:{width:`calc(100% - 42px)`}},{default:jn(()=>[ei(Oe(n.session.sessionName),1)]),_:1}),Xr(`span`,iqt,[Mn(Xr(`i`,{class:`bkai-icon bkai-bianji`,onClick:Pi(l,[`stop`])},null,512),[[V(i),{content:V(W9)(`编辑`),boundary:`parent`}]]),Zr(V(VCe),{title:V(W9)(`确认删除会话 ?`),content:`删除操作无法撤回,请谨慎操作!`,"confirm-config":{theme:`danger`},trigger:`click`,boundary:`parent`,onConfirm:u},{default:jn(()=>[Mn(Xr(`i`,{class:`bkai-icon bkai-shanchu`,onClick:t[0]||=Pi(()=>{},[`stop`])},null,512),[[V(i),{content:V(W9)(`删除`),boundary:`parent`}]])]),_:1},8,[`title`])])],64))],2))}}),[[`__scopeId`,`data-v-fea14d3a`]]),oqt={class:`history-search`},sqt={class:`input-icon`},cqt=G9(Qn({__name:`history-search`,props:{modelValue:{default:``},placeholder:{default:``}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=e=>{r(`update:modelValue`,e)};return(e,t)=>(H(),Gr(`div`,oqt,[Zr(V(Pd),{"model-value":n.modelValue,behavior:`simplicity`,placeholder:n.placeholder||V(W9)(`搜索会话名称`),style:{height:`22px`},"onUpdate:modelValue":i},{suffix:jn(()=>[Xr(`span`,sqt,[Zr(V(Ou))])]),_:1},8,[`model-value`,`placeholder`])]))}}),[[`__scopeId`,`data-v-e7ff40b2`]]),lqt={class:`bkai-history-dropdown`},uqt={class:`history-dropdown-header`},dqt={class:`history-dropdown-header-title`},fqt={class:`history-dropdown-content`},pqt=G9(Qn({__name:`index`,props:{sessionBusinessManager:{}},emits:[`close`,`session-delete`,`session-rename`,`session-switch`],setup(e,{emit:t}){let n=e,r=t,i=sn(``),a=sn(null),o=mi(()=>n.sessionBusinessManager.currentSession.value?.sessionCode),s=mi(()=>{let e={today:{key:`today`,alias:W9(`今天`),sessionList:[]},yesterday:{key:`yesterday`,alias:W9(`昨天`),sessionList:[]},"3days":{key:`3days`,alias:W9(`3天前`),sessionList:[]},"5days":{key:`5days`,alias:W9(`5天前`),sessionList:[]},"1week":{key:`1week`,alias:W9(`1周前`),sessionList:[]},before:{key:`before`,alias:W9(`更早`),sessionList:[]}},t=n.sessionBusinessManager.sessionList.value.filter(e=>e.sessionName.toLowerCase().includes(i.value.toLowerCase())),r=new Date,a=new Date(r);a.setDate(a.getDate()-1);let o=new Date(r);o.setDate(r.getDate()-3);let s=new Date(r);s.setDate(r.getDate()-5);let l=new Date(r);l.setDate(r.getDate()-7);for(let n of t){let t=new Date(n.createdAt||``),i=t.toDateString();i===r.toDateString()?e.today.sessionList.push(n):i===a.toDateString()?e.yesterday.sessionList.push(n):t>=o&&t>s?e[`3days`].sessionList.push(n):t>=s&&t>l?e[`5days`].sessionList.push(n):t>=l?e[`1week`].sessionList.push(n):e.before.sessionList.push(n)}for(let t of Object.values(e))t.sessionList.sort((e,t)=>{let n=new Date(e.createdAt||0).getTime();return new Date(t.createdAt||0).getTime()-n});return Object.values(e).filter(e=>e.sessionList.length>0)}),l=e=>o.value===e,u=e=>{l(e.sessionCode)||(r(`session-switch`,e.sessionCode),r(`close`))},d=e=>{a.value=e.sessionCode},f=e=>{r(`session-delete`,e)},p=(e,t)=>{let i=n.sessionBusinessManager.sessionList.value.find(t=>t.sessionCode===e);i&&(i.sessionName=t),a.value=null,r(`session-rename`,e,t)},m=()=>{a.value=null};return(e,t)=>(H(),Gr(`div`,lqt,[Xr(`div`,uqt,[Xr(`h1`,dqt,Oe(V(W9)(`历史会话`)),1),Zr(cqt,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e,placeholder:V(W9)(`搜索会话名称`)},null,8,[`modelValue`,`placeholder`])]),Xr(`div`,fqt,[s.value.length>0?(H(!0),Gr(Lr,{key:0},dr(s.value,e=>(H(),Kr(rqt,{key:e.key,"current-session-code":o.value,sessions:e.sessionList,title:e.alias},{default:jn(()=>[(H(!0),Gr(Lr,null,dr(e.sessionList,e=>(H(),Kr(aqt,{key:e.sessionCode,"is-active":l(e.sessionCode),"is-editing":a.value===e.sessionCode,session:e,onClick:u,onDelete:f,onEdit:d,onRenameCancel:m,onRenameConfirm:p},null,8,[`is-active`,`is-editing`,`session`]))),128))]),_:2},1032,[`current-session-code`,`sessions`,`title`]))),128)):(H(),Kr(V(mCe),{key:1,description:i.value?V(W9)(`搜索为空`):V(W9)(`暂无对话`),scene:`part`,style:{"margin-top":`100px`},type:i.value?`search-empty`:`empty`},null,8,[`description`,`type`]))])]))}}),[[`__scopeId`,`data-v-143fb0ef`]]);function mqt(e){return e.sessionBusinessManager?QKt({triggerRef:e.triggerRef,panelComponent:pqt,panelProps:{sessionBusinessManager:e.sessionBusinessManager,onSessionSwitch:e.onSessionSwitch,onSessionDelete:e.onSessionDelete,onSessionRename:e.onSessionRename},tippyOptions:{placement:`bottom-end`,offset:[0,8],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body}}):{handleTriggerClick:()=>{},show:()=>{},hide:()=>{},toggle:()=>{},destroy:()=>{},isVisible:()=>!1}}var hqt={class:`left-section`},gqt={class:`logo`},_qt=[`src`],vqt={key:0,class:`rename-tooltip`},yqt={class:`rename-content`},bqt={key:0,class:`tippy-dropdown-menu`},xqt={key:1,class:`bkai-icon bkai-auto-refresh-line`},Sqt={class:`right-section`},Cqt=G9(Qn({__name:`index`,props:{title:{default:``},agentName:{default:``},sessionName:{default:``},isCompressionHeight:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},showHistoryIcon:{type:Boolean,default:!0},showNewChatIcon:{type:Boolean,default:!0},showCompressionIcon:{type:Boolean,default:!0},showMoreIcon:{type:Boolean,default:!0},enableChatSession:{type:Boolean,default:!0},hasPermission:{type:Boolean,default:!0},chatGroup:{default:()=>({enabled:!1,staff:[],username:``})},hasSessionContents:{type:Boolean},autoGenerateLoading:{type:Boolean},dropdownMenuConfig:{default:()=>({showRename:!0,showAutoGenerate:!0,showShare:!1})},sessionBusinessManager:{default:void 0},renderMode:{default:Wi.Chat}},emits:[`close`,`toggle-compression`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`,`history-session-switch`,`history-session-delete`,`history-session-rename`,`new-chat-created`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=Nwe,o=sn(null),s=sn(null),l=$n(`moreMenuTippyRef`),u=sn(!1),d=sn(``),f=sn(null),p=sn(!1),m=()=>document.querySelector(`.ai-blueking-panel`)||document.body,h=null,g=()=>{!s.value||!r.sessionBusinessManager||(h=mqt({triggerRef:s,sessionBusinessManager:r.sessionBusinessManager,onSessionSwitch:e=>i(`history-session-switch`,e),onSessionDelete:e=>i(`history-session-delete`,e),onSessionRename:(e,t)=>i(`history-session-rename`,e,t)}))},_=mi(()=>r.hasPermission?r.enableChatSession?r.title||`${r.agentName||``}-${r.sessionName||``}`:r.agentName:W9(`无智能体使用权限`)),v=mi(()=>r.isCompressionHeight?`bkai-morenchicun`:`bkai-yasuo`),y=mi(()=>r.isCompressionHeight?W9(`恢复默认尺寸`):W9(`缩小高度`)),b=mi(()=>r.hasPermission),x=e=>b.value?e:W9(`暂无使用权限`),S=()=>({cursor:b.value?`pointer`:`not-allowed`}),C=sn(!1),w=async()=>{if(!C.value){C.value=!0;try{if(r.sessionBusinessManager)try{let e=await r.sessionBusinessManager.createNewSession();e&&i(`new-chat-created`,{sessionCode:e.sessionCode,sessionName:e.sessionName,createdAt:e.createdAt})}catch(e){console.error(`Failed to create new session:`,e),Af({theme:`error`,message:W9(`创建会话失败`)})}i(`new-chat`)}finally{C.value=!1}}},T=e=>{e.stopPropagation(),r.sessionBusinessManager?(h||g(),h&&h.handleTriggerClick(e)):i(`history-click`,e)},E=()=>{i(`help-click`)},D=e=>{e.stopPropagation(),h&&h.isVisible()&&h.hide(),l.value&&(p.value?l.value.hide():l.value.show())},O=()=>{l.value?.hide(),j()},k=()=>{!r.hasSessionContents||r.autoGenerateLoading||i(`auto-generate-name`)},A=()=>{r.hasSessionContents&&(l.value?.hide(),i(`share`))},j=()=>{document.removeEventListener(`click`,F),d.value=r.sessionName||``,u.value=!0,setTimeout(()=>{document.addEventListener(`click`,F)},100),setTimeout(()=>{if(f.value)try{let e=f.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},M=()=>{let e=d.value.trim();if(!e){N();return}i(`rename`,e),u.value=!1,d.value=``},N=()=>{u.value=!1,d.value=``},P=(e,t)=>{d.value=e,t.key===`Enter`?M():t.key===`Escape`&&N()},F=e=>{if(!u.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&N()};return Ln(()=>r.autoGenerateLoading,(e,t)=>{t&&!e&&p.value&&l.value?.hide()}),or(()=>{r.sessionBusinessManager&&g(),document.addEventListener(`click`,F)}),sr(()=>{h&&=(h.destroy(),null),document.removeEventListener(`click`,F)}),t({headerRef:o,historyIconRef:s}),(t,n)=>(H(),Gr(`div`,{ref_key:`headerRef`,ref:o,class:be([`ai-header drag-handle`,{draggable:r.draggable}])},[Xr(`div`,hqt,[Xr(`div`,gqt,[Xr(`img`,{alt:`logo`,src:V(sKt)},null,8,_qt)]),Xr(`div`,{class:be([`title`,{"title-with-tooltip":u.value}])},[ei(Oe(_.value)+` `,1),ti(` 重命名 tooltip 直接绑定在 title 上 `),u.value?(H(),Gr(`div`,vqt,[Xr(`div`,yqt,[Zr(V(Pd),{ref_key:`renameInputRef`,ref:f,modelValue:d.value,"onUpdate:modelValue":n[0]||=e=>d.value=e,class:`rename-input`,placeholder:V(W9)(`请输入新的会话名称`),onKeyup:P},null,8,[`modelValue`,`placeholder`]),Xr(`div`,{class:`rename-buttons`},[Xr(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:M}),Xr(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:N})])])])):ti(`v-if`,!0)],2),ti(` 更多图标下拉菜单 - 使用 vue-tippy `),r.showMoreIcon&&b.value?(H(),Kr(V(Xa),{key:0,ref_key:`moreMenuTippyRef`,ref:l,arrow:!1,"append-to":m,offset:[0,4],interactive:``,placement:`bottom-start`,theme:`ai-blueking-light more-menu-light light`,trigger:`manual`,onHidden:n[1]||=e=>p.value=!1,onShown:n[2]||=e=>p.value=!0},{content:jn(()=>[p.value?(H(),Gr(`div`,bqt,[r.dropdownMenuConfig?.showRename?(H(),Gr(`div`,{key:0,class:`tippy-menu-item`,onClick:O},[n[7]||=Xr(`i`,{class:`bkai-icon bkai-bianji`},null,-1),Xr(`span`,null,Oe(V(W9)(`重命名`)),1)])):ti(`v-if`,!0),r.dropdownMenuConfig?.showAutoGenerate?Mn((H(),Gr(`div`,{key:1,class:be([`tippy-menu-item`,{disabled:!r.hasSessionContents||r.autoGenerateLoading}]),onClick:k},[r.autoGenerateLoading?(H(),Kr(V(hd),{key:0,mode:`spin`,size:`mini`,theme:`primary`})):(H(),Gr(`i`,xqt)),Xr(`span`,null,Oe(V(W9)(`自动生成命名`)),1)],2)),[[V(Za),{content:r.hasSessionContents?``:V(W9)(`请先发起会话`),theme:`ai-blueking-tooltip`,arrow:!0,delay:[300,0],appendTo:m}]]):ti(`v-if`,!0),r.dropdownMenuConfig?.showShare&&r.renderMode!==V(Wi).Test?Mn((H(),Gr(`div`,{key:2,class:be([`tippy-menu-item`,{disabled:!r.hasSessionContents}]),onClick:A},[n[8]||=Xr(`i`,{class:`bkai-icon bkai-fenxiang`},null,-1),Xr(`span`,null,Oe(V(W9)(`分享会话`)),1)],2)),[[V(Za),{content:r.hasSessionContents?``:V(W9)(`请先发起会话`),theme:`ai-blueking-tooltip`,arrow:!0,delay:[300,0],appendTo:m}]]):ti(`v-if`,!0)])):ti(`v-if`,!0)]),default:jn(()=>[Xr(`span`,{class:`bkai-icon bkai-more`,onClick:D})]),_:1},512)):ti(`v-if`,!0)]),pr(t.$slots,`headerLeft`,{},void 0,!0),Xr(`div`,Sqt,[ti(` 新增会话按钮 `),r.showNewChatIcon&&e.enableChatSession!==!1?Mn((H(),Gr(`i`,{key:0,class:be([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!b.value||C.value}]),style:he(S()),onClick:n[3]||=e=>b.value&&!C.value?w():void 0},null,6)),[[V(a),{content:C.value?V(W9)(`正在创建会话...`):x(V(W9)(`新增会话`)),boundary:`parent`}]]):ti(`v-if`,!0),ti(` 历史会话按钮 `),r.showHistoryIcon&&e.enableChatSession!==!1?Mn((H(),Gr(`i`,{key:1,ref_key:`historyIconRef`,ref:s,class:be([`bkai-icon`,`bkai-history`,{disabled:!b.value}]),style:he(S()),onClick:n[4]||=e=>b.value?T(e):void 0},null,6)),[[V(a),{content:x(V(W9)(`历史会话`)),boundary:`parent`}]]):ti(`v-if`,!0),e.chatGroup?.enabled?Mn((H(),Gr(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:E},null,512)),[[V(a),{content:V(W9)(`转人工`),boundary:`parent`}]]):ti(`v-if`,!0),r.showCompressionIcon?Mn((H(),Gr(`i`,{key:3,class:be([`bkai-icon`,v.value]),onClick:n[5]||=e=>i(`toggle-compression`)},null,2)),[[V(a),{content:y.value,boundary:`parent`}]]):ti(`v-if`,!0),Mn(Xr(`i`,{class:`bkai-icon bkai-close-line-2`,onClick:n[6]||=e=>i(`close`)},null,512),[[V(a),{content:V(W9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-de3b1a3b`]]),wqt=class{_isGenerating;_isStopLoading;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r=null,i={}){this.agentModule=e,this.messageModule=t,this.sessionModule=n,this.eventEmitter=r,this.config=i,this._isGenerating=sn(!1),this._isStopLoading=sn(!1)}get isGenerating(){return this._isGenerating}get isStopLoading(){return this._isStopLoading}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=RKt(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==P9.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),s=i.property;this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,s),this.emit(`chat-regenerate`,{messageId:e}),l.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==P9.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let s=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),s.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}async stopGeneration(){let e=this.sessionModule?.current?.value?.sessionCode??``;this._isStopLoading.value=!0;try{await this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}finally{this._isStopLoading.value=!1}}},Tqt=class{agentModule;config;eventEmitter;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t=null,n=null,r={}){this.sessionModule=e,this.agentModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return await this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`}),this.sessionModule.current.value}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t);let n=this.agentModule?.info.value;n&&this.agentModule?.handleRole(n,t.sessionCode),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let n=t[0],r=(n.sessionContentCount??0)>0,i=e?.alwaysCreateNewSession??this.config.alwaysCreateNewSession??!1;r||i?await this.createNewSession():await this.switchSession(n.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},Eqt=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.map(e=>String(e.id))}}},Dqt=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,t=[]){this._propsShortcuts=sn(t),this._agentShortcuts=sn([]),this.eventEmitter=e,this._effectiveShortcuts=mi(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},Oqt=class{_isCompressed;_isDraggingOrResizing;_nimbusMinimized;_panelVisible;_positionAndSize;cleanupFunctions;config;containerRef=null;debugMode;listeners;onceListeners;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=sn(e.initialPanelVisible??!1),this._nimbusMinimized=sn(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=sn(!1),this._isCompressed=sn(!1),this._positionAndSize=sn({x:0,y:0,width:400,height:window.innerHeight})}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),expandForSidePanel:this.expandForSidePanel.bind(this),collapseSidePanel:this.collapseSidePanel.bind(this),positionAndSize:mi(()=>this.containerRef?.positionAndSize?.value??this._positionAndSize.value),isCompressed:mi(()=>this._isCompressed.value),isSidePanelExpanded:mi(()=>this.containerRef?.isSidePanelExpanded?.value??!1)}}get isCompressed(){return this._isCompressed}get isDraggingOrResizing(){return this._isDraggingOrResizing}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:mi(()=>this._nimbusMinimized.value)}}get nimbusMinimized(){return this._nimbusMinimized}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:mi(()=>this._panelVisible.value)}}get panelVisible(){return this._panelVisible}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}collapseSidePanel(){this.containerRef?.collapseSidePanel&&this.containerRef.collapseSidePanel()}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}expandForSidePanel(e){this.containerRef?.expandForSidePanel&&this.containerRef.expandForSidePanel(e)}getConfig(){return this.config}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}hasListeners(e){return this.listenerCount(e)>0}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}setCompressed(e){this._isCompressed.value=e}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setDebugMode(e){this.debugMode=e}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}};function kqt(e){return new Oqt(e)}var Aqt={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"side-panel-expand":null,"side-panel-collapse":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"new-chat-created":`new-chat-created`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function jqt(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:case`new-chat-created`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var Mqt=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=sn(new Set),this._isSelectionMode=sn(!1),this._editingSessionCode=sn(null),this._loadingStates=qt({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}};function Nqt(e){let{props:t,emit:n,scrollToBottom:r}=e,i=cn(null),a=cn(null),o=cn(null),s=cn(null),l=sn(!1),u=sn(!t.chatHelper),d=sn(null),f=()=>t.chatHelper?!t.chatHelper.agent||!t.chatHelper.session||!t.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:t.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},p=()=>{let e=f();if(!e.valid)return console.error(e.error),d.value=Error(e.error),null;if(t.chatHelper)return t.chatHelper;let i=new B9({onStart:()=>{n(`receive-start`)},onMessage:e=>{n(`receive-text`)},onDone:()=>{n(`receive-end`),r()},onError:e=>{n(`error`,e)}}),a=IKt({requestData:LKt(UKt(t.url),()=>un(t.requestOptions)),protocol:i});return i.injectMessageModule(a.message),a},m=async(e,t)=>{if(e)try{let n=e.session.current?.value?.sessionCode??``;await e.agent.stopChat(n),t&&e.agent.abortChat()}catch{}},h=0,g=async()=>{let e=++h,r=i.value,f=u.value;l.value=!1,d.value=null,u.value=!t.chatHelper,await m(r,f),i.value=null,a.value=null,o.value=null,s.value=null;let g=p();if(!g)return;let _=new Tqt(g.session,g.agent,null,{enableChatSession:!0,autoSwitchToInitialSession:!!t.sessionCode,loadRecentSessionOnMount:t.autoLoad,initialSessionCode:t.sessionCode,alwaysCreateNewSession:t.alwaysCreateNewSession}),v=new wqt(g.agent,g.message,g.session,null,{openingRemark:t.helloText,predefinedQuestions:t.prompts,placeholder:t.placeholder}),y=new Dqt(null,t.shortcuts||[]);i.value=g,a.value=_,o.value=v,s.value=y;try{if(u.value&&(await Promise.all([g.agent.getAgentInfo(),g.session.getSessions()]),e!==h||(await _.loadRecentSession({skipLoadSessions:!0}),e!==h)))return;l.value=!0,n(`agent-info-loaded`,g)}catch(t){if(e!==h)return;console.error(`Failed to initialize ChatBot:`,t),d.value=t,n(`error`,t)}};return Ln([()=>t.url,()=>t.chatHelper],()=>g(),{immediate:!0}),sr(()=>{m(i.value,u.value)}),{chatHelper:i,isStandaloneMode:u,isInitialized:l,initError:d,chatBusinessManager:o,sessionBusinessManager:a,shortcutManager:s}}function Pqt(e){let{props:t,chatHelper:n,chatBusinessManager:r,sessionBusinessManager:i,shortcutManager:a,isStandaloneMode:o,isInitialized:s,selectedShortcut:l}=e,u=mi(()=>r.value?.isStopLoading.value?zi.StopLoading:((t.chatHelper||n.value)?.agent)?.isChatting?.value?zi.Streaming:zi.Complete),d=mi(()=>u.value===zi.Streaming?Cp.Disabled:void 0),f=mi(()=>r.value?.messages.value??[]),p=mi(()=>r.value?.isMessagesLoading.value??!1);return{messageStatus:u,messageToolsStatus:d,messages:f,isMessagesLoading:p,isGenerating:mi(()=>r.value?.isGenerating.value??!1),currentSession:mi(()=>i.value?.currentSession.value??null),isWelcomeState:mi(()=>o.value&&!s.value?!1:!p.value&&f.value.length===0),openingRemark:mi(()=>n.value?.agent.info.value?.conversationSettings?.openingRemark||``),effectiveResources:mi(()=>t.resources?.length?t.resources:n.value?.agent.info.value?.resources??[]),effectivePrompts:mi(()=>t.prompts?.length?t.prompts:n.value?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),effectiveSupportUpload:mi(()=>l.value?.supportUpload?l.value.supportUpload.vision===!0:n.value?.agent.info.value?.promptSetting?.supportUpload?.vision===!0),chatbotStyle:mi(()=>({height:typeof t.height==`number`?`${t.height}px`:t.height,maxWidth:typeof t.maxWidth==`number`?`${t.maxWidth}px`:t.maxWidth})),filteredShortcuts:mi(()=>a.value?.shortcuts.value??[])}}function Fqt(e){let{emit:t,chatHelper:n,chatBusinessManager:r,selectedShortcut:i,selectedResources:a}=e,o=cn([[]]),s=cn(``),l=(e,t)=>{o.value=e,a.value=t},u=async(e,i={})=>{if(!r.value||!n.value)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let l=n.value.session.current?.value?.sessionCode;if(!l)throw Error(`[ChatBot] Cannot send message: no active session`);o.value=[[]],s.value=``,a.value=[],t(`send-message`,typeof e==`string`?e:``),await r.value.sendMessage(e,l,i)},d=async e=>{let t=n.value?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let r=await n.value.session.uploadFile(t,e);if(!r?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return r},f=async(e,n)=>{try{let t={};s.value&&(t.cite=s.value),i.value&&(t.command=i.value.id),a.value.length&&(t.resources=a.value),await u(e,Object.keys(t).length?{property:{extra:t}}:{})}catch(e){console.error(`Failed to send message:`,e),t(`error`,e)}},p=async()=>{await m()},m=async()=>{if(!r.value){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}await r.value.stopGeneration(),t(`stop`)};return{userInput:o,cite:s,handleUpdateModelValue:l,doSendMessage:u,handleSendMessage:f,handleUpload:d,handleStopSending:p,stopGeneration:m}}function Iqt(e){let{emit:t,chatHelper:n,isStandaloneMode:r}=e,i=async e=>{if(!(!n.value||e.length===0))try{await WKt((await new Eqt(n.value.message,n.value.session).shareMessages(e)).shareUrl),Af({message:`分享链接已复制到剪贴板`,theme:`success`})}catch(e){console.error(`[ChatBot] Failed to share messages:`,e),Af({message:`分享失败,请重试`,theme:`error`})}};return{handleConfirmShare:async e=>{r.value&&await i(e),t(`confirm-share`,e)}}}function Lqt(e){let{props:t,emit:n,shortcutManager:r,doSendMessage:i,selectedShortcut:a}=e,o=mi(()=>r.value?.effectiveShortcuts.value??[]),s=(e,t)=>{let n=e,r;if(r=n.enable_fill_back&&n.fill_back_component_key?n.fill_back_component_key:n.components?.find(e=>e.fillBack)?.key,r&&t){let e=n.components?.map(e=>e.key===r?{...e,default:t}:{...e,default:e.default??void 0});a.value={...n,components:e,formModel:{...n.formModel,[r]:t}}}else a.value={...n,formModel:{...n.formModel}}},l=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.alias||e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},u=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?o.value.find(e=>e.id===t.command)??null:null},d=(e,t)=>{s(e,t),n(`shortcut-click`,{shortcut:e,source:`main`})},f=()=>{a.value=null};return Ln(()=>t.shortcuts,e=>{r.value?.setShortcuts(e||[])},{immediate:!0}),Ln(()=>e.chatHelper.value?.agent.info.value?.conversationSettings?.commands,e=>{e&&r.value?.setAgentShortcuts(e)},{immediate:!0}),{effectiveShortcuts:o,selectShortcutWithText:s,buildShortcutProperty:l,getShortcutFromMessage:u,handleSelectShortcut:d,handleCloseShortcut:f,handleShortcutSubmit:async e=>{if(!a.value){console.error(`[ChatBot] No selected shortcut`);return}let t=l(a.value,e),r=a.value.name,o=a.value;f();try{await i(r,{property:t})}catch(e){a.value=o,console.error(`[ChatBot] Failed to submit shortcut:`,e),n(`error`,e)}},sendShortcutDirectly:async(e,t)=>{let r=e,a={...r.formModel},o=r.components||[];for(let e of o)e.key in a||(a[e.key]=e.default??``);let s;s=r.enable_fill_back&&r.fill_back_component_key?r.fill_back_component_key:o.find(e=>e.fillBack)?.key,s&&t&&(a[s]=t);let u=l(r,a),d=r.name;try{await i(d,{property:u})}catch(e){console.error(`[ChatBot] Failed to send shortcut directly:`,e),n(`error`,e)}}}}function Rqt(e){let{emit:t,chatHelper:n,chatBusinessManager:r,cite:i,focusInput:a,scrollToBottom:o,getShortcutFromMessage:s,buildShortcutProperty:l}=e,u=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=r.value.messages.value,i=RKt(t,e[0]);if(!i){console.error(`[ChatBot] No user message found before AI messages`);return}let a=[i,...e];await n.value.message.deleteMessages(a)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),t(`error`,e)}},d=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let i=n.value.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await r.value.regenerateFromAIMessages(e,i),o()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),t(`error`,e)}},f=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=r.value.messages.value,i=t.findIndex(t=>t===e);if(i===-1){console.error(`[ChatBot] User message not found in messages list`);return}let a=[];for(let e=i+1;e<t.length;e++){let n=t[e];if(n.role===Ri.User)break;a.push(n)}let o=[e,...a];await n.value.message.deleteMessages(o)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),t(`error`,e)}};return{handleAgentAction:async(e,t)=>{if(e.id===`cite`){i.value=t.filter(e=>e.role!==Ri.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
|
|
3502
|
-
`),a();return}if(e.id===`rebuild`){await d(t);return}if(e.id===`delete`){await u(t);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await n.value?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},handleAgentFeedback:async(e,i,a,o)=>{if(!n.value){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let s=n.value.session.current?.value?.sessionCode;if(!s){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let l=zKt(r.value?.messages.value||[],i[0]);if(l===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let u=e.id===`like`?5:0;try{await n.value.session.postSessionFeedback({sessionCode:s,sessionContentIds:[l],rate:u,labels:a,comment:o}),t(`feedback`,e,i[0],a,o)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),t(`error`,e)}},handleUserAction:async(e,t)=>{if(e.id===`delete`){await f(t);return}if(e.id===`cite`){i.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),a();return}console.log(`handleUserAction`,e,t)},handleUserInputConfirm:async(e,r,i)=>{if(!n.value){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let a=n.value.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot edit message: no active session`);return}let s=e.id;if(s===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,s,a,r),await n.value.agent.resendMessage(String(s),a,r),o()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),t(`error`,e)}},handleUserShortcutConfirm:async(e,i)=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let a=n.value.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let u=e.id;if(u===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let t=s(e);if(!t){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let n=l(t,i),d=String(i.input??``);await r.value.resendMessageWithProperty(String(u),a,d,n),o()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),t(`error`,e)}},handleStopStreaming:async()=>{if(!r.value){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}await r.value.stopGeneration(),t(`stop`)}}}var zqt=Qn({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},alwaysCreateNewSession:{type:Boolean},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},renderMode:{default:Wi.Chat},extCls:{},height:{},helloText:{},maxWidth:{},messageToolsTippyOptions:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcuts:{default:()=>[]},url:{default:``},placement:{default:`left`},resizeProps:{},getSideRenderComponent:{},getSideTabRenderComponent:{},onCustomTabChange:{}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`execution-panel-change`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=_r(),o=sn(),s=sn(),l=sn(),u=cn([]),d=sn(null),f=mi({get:()=>r.renderMode??Wi.Chat,set:()=>{}}),p=async()=>{await En(),o.value&&(o.value.scrollTop=o.value.scrollHeight)},m=()=>{l.value?.focus?.()},{chatHelper:h,isStandaloneMode:g,isInitialized:_,initError:v,chatBusinessManager:y,sessionBusinessManager:b,shortcutManager:x}=Nqt({props:r,emit:i,scrollToBottom:p}),{userInput:S,cite:C,handleUpdateModelValue:w,doSendMessage:T,handleSendMessage:E,handleUpload:D,handleStopSending:O,stopGeneration:k}=Fqt({emit:i,chatHelper:h,chatBusinessManager:y,selectedShortcut:d,selectedResources:u}),{handleSelectShortcut:A,handleCloseShortcut:j,handleShortcutSubmit:M,selectShortcutWithText:N,getShortcutFromMessage:P,buildShortcutProperty:F,sendShortcutDirectly:I}=Lqt({props:r,emit:i,chatHelper:h,shortcutManager:x,doSendMessage:T,selectedShortcut:d}),{messageStatus:L,messageToolsStatus:R,messages:ee,isMessagesLoading:te,isGenerating:z,currentSession:B,isWelcomeState:ne,openingRemark:re,effectiveResources:ie,effectivePrompts:ae,effectiveSupportUpload:oe,chatbotStyle:se,filteredShortcuts:ce}=Pqt({props:r,chatHelper:h,chatBusinessManager:y,sessionBusinessManager:b,shortcutManager:x,isStandaloneMode:g,isInitialized:_,selectedShortcut:d}),{handleAgentAction:le,handleAgentFeedback:ue,handleUserAction:de,handleUserInputConfirm:fe,handleUserShortcutConfirm:pe,handleStopStreaming:me}=Rqt({emit:i,chatHelper:h,chatBusinessManager:y,cite:C,focusInput:m,scrollToBottom:p,getShortcutFromMessage:P,buildShortcutProperty:F}),ge=mi(()=>!_.value||te.value),{handleConfirmShare:_e}=Iqt({emit:i,chatHelper:h,isStandaloneMode:g}),ve=e=>{i(`execution-panel-change`,e)},ye=async e=>{if(r.onCustomTabChange)return r.onCustomTabChange(e);let t=e.data?.props;if(t?.task_id!=null&&t?.node_id)return h.value?.message.getFlowAgentTaskNodeInfo(t.task_id,t.node_id)};return t({sendMessage:e=>E(e,[[]]),stopGeneration:k,switchSession:async e=>{if(!b.value){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await b.value.switchSession(e),i(`session-switched`,b.value.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),i(`error`,e)}},messages:ee,currentSession:B,isGenerating:z,getChatHelper:()=>h.value,setCiteText:e=>{C.value=e},focusInput:m,enterShareMode:()=>s.value?.enterShareMode(),exitShareMode:()=>s.value?.exitShareMode(),selectShortcut:(e,t)=>{N(e,t)},sendShortcut:(e,t)=>I(e,t)}),(t,n)=>(H(),Gr(`div`,{class:be([`ai-chatbot`,r.extCls,{"welcome-state":V(ne)}]),style:he(V(se))},[Zr(V(oKt),{ref_key:`chatContainerRef`,ref:s,cite:V(C),"onUpdate:cite":n[0]||=e=>on(C)?C.value=e:null,"selected-shortcut":d.value,"onUpdate:selectedShortcut":n[1]||=e=>d.value=e,"render-mode":f.value,"onUpdate:renderMode":n[2]||=e=>f.value=e,"chat-loading":ge.value,"common-tippy-options":e.messageToolsTippyOptions,"message-status":V(L),"message-tools-status":V(R),messages:V(ee),"model-value":V(S),"on-agent-action":V(le),"on-agent-feedback":V(ue),"get-side-render-component":r.getSideRenderComponent,"get-side-tab-render-component":r.getSideTabRenderComponent,"on-custom-tab-change":ye,"on-send-message":V(E),"on-stop-sending":V(O),"on-upload":V(D),"on-user-action":V(de),"on-user-input-confirm":V(fe),"on-user-shortcut-confirm":V(pe),"opening-remark":V(re),placeholder:r.placeholder,placement:r.placement,prompts:V(ae),"resize-props":r.resizeProps,resources:V(ie),"shortcut-id":d.value?.id,shortcuts:V(ce),"support-upload":V(oe),onCollapseChange:ve,onConfirmShare:V(_e),onDeleteShortcut:V(j),onSelectShortcut:V(A),onShortcutClose:V(j),onShortcutSubmit:V(M),onStopStreaming:V(me),"onUpdate:modelValue":V(w)},{message:jn(({message:n,messageToolsStatus:r})=>[ti(` 消费方提供了 #message slot 时,优先使用消费方的渲染 `),V(a).message?pr(t.$slots,`message`,{key:0,message:n,messageToolsStatus:r}):(H(),Gr(Lr,{key:1},[ti(` 否则使用默认的 MessageRender `),Zr(V(jGt),{message:n,"message-tools-status":r,"on-action":e=>V(de)(e,n),"on-input-confirm":(e,t)=>V(fe)(n,e,t),"on-shortcut-confirm":e=>V(pe)(n,e),"tippy-options":e.messageToolsTippyOptions},fr({_:2},[t.$slots.codeHeader?{name:`codeHeader`,fn:jn(e=>[pr(t.$slots,`codeHeader`,xe(Qr(e)))]),key:`0`}:void 0]),1032,[`message`,`message-tools-status`,`on-action`,`on-input-confirm`,`on-shortcut-confirm`,`tippy-options`])],2112))]),_:3},8,`cite.selected-shortcut.render-mode.chat-loading.common-tippy-options.message-status.message-tools-status.messages.model-value.on-agent-action.on-agent-feedback.get-side-render-component.get-side-tab-render-component.on-send-message.on-stop-sending.on-upload.on-user-action.on-user-input-confirm.on-user-shortcut-confirm.opening-remark.placeholder.placement.prompts.resize-props.resources.shortcut-id.shortcuts.support-upload.onConfirmShare.onDeleteShortcut.onSelectShortcut.onShortcutClose.onShortcutSubmit.onStopStreaming.onUpdate:modelValue`.split(`.`))],6))}}),K9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Bqt(e){let{url:t,requestOptions:n,autoInit:r=!0,protocolCallbacks:i}=e,a=un(t);if(!a)throw Error(`[useChatBootstrap] url is required`);let o=sn(K9.IDLE),s=sn(null),l=sn(!1),u=new Map,d=new B9({onStart:()=>{i?.onStart?.()},onMessage:e=>{i?.onMessage?.(e)},onDone:()=>{i?.onDone?.()},onError:e=>{i?.onError?.(e)}}),f=IKt({requestData:LKt(a,n),protocol:d});d.injectMessageModule(f.message);let p=mi(()=>o.value===K9.LOADING_AGENT),m=mi(()=>o.value===K9.READY),h=mi(()=>f.agent.info.value??null),g=mi(()=>h.value?.agentName??``),_=mi(()=>f.session.current.value??null),v=mi(()=>f.session.list.value??[]),y=null,b=0,x=async e=>{s.value=null;try{if(o.value=K9.LOADING_AGENT,await Promise.all([f.agent.getAgentInfo(),f.session.getSessions()]),e!==b)return;o.value=K9.READY,l.value=!0}catch(t){if(e!==b)return;throw console.error(`[useChatBootstrap] Initialization failed:`,t),s.value=t,o.value=K9.ERROR,t}},S=async()=>{if(l.value)return;if(y)return y;let e=b;return y=x(e).finally(()=>{e===b&&(y=null)}),y},C=()=>{b+=1,o.value=K9.IDLE,s.value=null,l.value=!1,y=null},w=async()=>{C(),await S()},T=async e=>{C();let t=f.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await S()};return Ln(()=>un(t),(e,t)=>{e&&e!==t&&t&&T(e).catch(()=>{})}),r&&Promise.resolve().then(()=>{S().catch(()=>{})}),{chatHelper:f,protocol:d,phase:o,isInitializing:p,isReady:m,error:s,agentInfo:h,agentName:g,currentSession:_,sessionList:v,initialize:S,retry:w,updateConfig:T,registerExtension:(e,t)=>{u.set(e,t)},getExtension:e=>u.get(e)}}function Vqt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),newChatCreated:t=>e(`new-chat-created`,{session:t}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Hqt(e){let{componentManager:t,emit:n,debug:r=!1}=e,i=[],a=()=>{for(let[e,a]of Object.entries(Aqt)){if(a===null)continue;let o=t.on(e,t=>{let i=jqt(e,t);r&&console.debug(`[useEventBridge] ${e} -> ${a}`,i),n(a,...i)});i.push(o)}},o=(e,n)=>{r&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,n),t.emit(e,n)},s=(e,...t)=>{r&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),n(e,...t)},l=()=>{i.forEach(e=>e()),i.length=0};return a(),cr(()=>{l()}),{forwardToManager:o,emitDirect:s,cleanup:l}}function Uqt(e){let{props:t,emit:n}=e,r=sn(),i=sn(),a=mi(()=>UKt(t.url??``)),o=kqt({initialPanelVisible:!1,initialNimbusMinimized:t.defaultMinimize,enablePopup:t.enablePopup,enableNimbus:!t.hideNimbus,enableDraggable:t.draggable}),s=o.panelVisible,l=o.nimbusMinimized,{forwardToManager:u}=Hqt({componentManager:o,emit:n}),d=Vqt(u),f=(e,t)=>{let n=t instanceof Error?t.message:String(t);console.error(`[AIBlueking] ${e} error:`,t),o.emitInternal(`sdk-error`,{apiName:e,code:-1,message:n,data:t})},p=e=>{f(`chat`,e)},{chatHelper:m,isReady:h,error:g,agentInfo:_,agentName:v,currentSession:y,initialize:b}=Bqt({url:a,requestOptions:()=>un(t.requestOptions),autoInit:!0,protocolCallbacks:{onStart:()=>{d.receiveStart()},onMessage:()=>{d.receiveText()},onDone:()=>{d.receiveEnd()},onError:e=>{f(`chat`,e)}}}),x=m,S=new Tqt(x.session,x.agent,null,{enableChatSession:t.enableChatSession,initialSessionCode:t.initialSessionCode,alwaysCreateNewSession:t.alwaysCreateNewSession}),C=new Eqt(x.message,x.session),w=new Dqt(null,t.shortcuts||[]),T=null,E=()=>t.loadRecentSessionOnMount?(T||=S.loadRecentSession({skipLoadSessions:!0}).finally(()=>{T=null}),T):Promise.resolve(),D=async()=>{await b(),await E()},O={appendTo:e=>{let t=e.closest(`.draggable-container-content`);return console.log(`[ai-blueking] appendTo called, ref:`,e),console.log(`[ai-blueking] appendTo closest result:`,t),t??document.body}},k=mi(()=>o.isCompressed.value),A=mi(()=>v.value),j=mi(()=>x.message.list.value.length===0),M=mi(()=>t.resources?.length?t.resources:_.value?.resources??[]),N=mi(()=>t.prompts?.length?t.prompts:_.value?.conversationSettings?.predefinedQuestions??[]);Ln(()=>g.value,e=>{e&&f(`init`,e)}),Ln(()=>h.value,async e=>{if(e&&_.value){let e=_.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(u(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&w.setAgentShortcuts(e.conversationSettings.commands)),t.loadRecentSessionOnMount)try{await E()}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),Ln(()=>t.shortcuts,e=>{w.setShortcuts(e||[])},{immediate:!0});let P=e=>{JKt(e)&&(e.preventDefault(),s.value?o.hidePanel():o.showPanel())};return or(async()=>{r.value&&o.setContainerRef(r.value),window.addEventListener(`keydown`,P)}),sr(()=>{window.removeEventListener(`keydown`,P),o.destroy()}),{chatHelper:x,componentManager:o,sessionBusinessManager:S,shareBusinessManager:C,shortcutManager:w,forwarders:d,forwardToManager:u,chatBotRef:i,draggableContainerRef:r,panelVisible:s,nimbusMinimized:l,normalizedUrl:a,agentInfo:_,agentName:A,currentSession:y,isCompressed:k,isWelcomeState:j,messageToolsTippyOptions:O,agentResources:M,agentPrompts:N,handleError:p,ensureSessionReady:D}}function Wqt(e){let{shortcutManager:t,chatBotRef:n,forwardToManager:r,show:i,props:a}=e,o=sn(!1),s=sn(``);return{aiSelectionVisible:o,selectedText:s,filteredPopupShortcuts:mi(()=>{let e=t.effectiveShortcuts.value;return typeof a.shortcutFilter==`function`&&s.value?e.filter(e=>a.shortcutFilter?.(e,s.value)):e}),handleSelectionChange:e=>{s.value=e},handleAiSelectionShortcut:async(e,t)=>{o.value=!1,await i(),n.value&&(e.components?.length?n.value.selectShortcut(e,t):(n.value.selectShortcut(e),n.value.setCiteText(t),n.value.focusInput())),r(`shortcut-click`,{shortcut:e,source:`popup`})}}}function Gqt(e,t=!1){let n=window.innerHeight-48-40,r=window.innerWidth-48-16,i=sn(r),a=sn(n),o=sn(0),s=sn(t),l=sn(!1),u=sn(!1),d=0,f=e=>{e?i.value=window.innerWidth-12:i.value=r},p=(e,t)=>{a.value=t,o.value=t-n},m=()=>{En(()=>{a.value=window.innerHeight-48-40+o.value,s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-48-16})};return or(()=>{window.addEventListener(`resize`,m),m()}),cr(()=>{window.removeEventListener(`resize`,m)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:i,nimbusTop:a,isMinimize:s,isHovering:l,isDragging:u,handleNimbusDragging:p,handleNimbusMinimize:f,handleClick:()=>{if(u.value){u.value=!1;return}e(`click`)},handleMinimize:()=>{s.value=!s.value,e(`minimize`,s.value),s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-60},handleDragging:(e,t)=>{i.value=e,a.value=t},handleMouseEnter:()=>{l.value=!0},handleMouseLeave:()=>{l.value=!1},handleMouseDown:()=>{d=Date.now(),u.value=!1},handleMouseUp:()=>{Date.now()-d>200&&(u.value=!0)}}}var Kqt=420;function qqt(e){let{componentManager:t,chatBotRef:n,forwarders:r,forwardToManager:i,beforeNimbusClick:a,ensureSessionReady:o}=e,s=async e=>{t.showPanel(e),o&&await o(),e&&n.value&&await n.value.switchSession(e)},l=async e=>{await s(e)},u=()=>{t.hidePanel()};return{show:s,handleShow:l,hide:u,handleClose:()=>{u()},handleNimbusClick:async()=>{if(a&&await a()===!1){t.emit(`nimbus-click`,{});return}t.handleNimbusClick()},handleDragging:e=>{t.handleDragging(e)},handleResizing:e=>{t.handleResizing(e)},handleDragStop:e=>{t.handleDragStop(e)},handleResizeStop:e=>{t.handleResizeStop(e)},handleToggleCompression:()=>{t.container.toggleCompression()},handleCompressionChange:e=>{t.setCompressed(e)},handleExecutionPanelChange:e=>{e?t.collapseSidePanel():t.expandForSidePanel(Kqt)},sendMessage:async e=>{n.value&&await n.value.sendMessage(e)},handleReceiveStart:()=>{r.receiveStart()},handleReceiveText:()=>{r.receiveText()},handleReceiveEnd:()=>{r.receiveEnd()},handleStop:()=>{r.stop()},stopGeneration:()=>{n.value&&n.value.stopGeneration()},updatePosition:(e,n)=>{t.container.updatePosition(e,n)},updateSize:(e,n)=>{t.container.updateSize(e,n)},updatePositionAndSize:(e,n,r,i)=>{t.container.updatePositionAndSize(e,n,r,i)},setCiteText:e=>{n.value&&n.value.setCiteText(e)},focusInput:()=>{n.value&&n.value.focusInput()},selectShortcut:(e,t)=>{n.value&&n.value.selectShortcut(e,t)},sendShortcut:(e,t)=>n.value?n.value.sendShortcut(e,t):Promise.resolve(),getChatHelper:()=>n.value?n.value.getChatHelper():null,handleShortcutClick:e=>{i(`shortcut-click`,e)}}}function Jqt(e){let{chatHelper:t,sessionBusinessManager:n,chatBotRef:r,forwarders:i,handleError:a,currentSession:o}=e,s=sn(``),l=sn(!0),u=sn(!1),d=sn(!1),f=()=>t.message.list.value.some(e=>{if(!(`property`in e))return!0;let{property:t}=e;return!t?.extra?.pause});return Ln(()=>o.value,e=>{e&&(s.value=e.sessionName||``,u.value=(e.sessionContentCount??0)>0||f())},{immediate:!0}),Ln(()=>t.message.list.value.length,()=>{u.value=f()}),{sessionName:s,hasPermission:l,hasSessionContents:u,autoGenerateLoading:d,handleNewChat:async()=>{r.value?.exitShareMode(),i.newChat()},handleNewChatCreated:e=>{i.newChatCreated(e)},handleHistoryClick:e=>{i.historyClick(e)},handleHistorySessionSwitch:async e=>{r.value?.exitShareMode(),await n.switchSession(e)},handleHistorySessionDelete:async e=>{await n.deleteSession(e)},handleHistorySessionRename:async(e,t)=>{await n.updateSessionName(e,t)},handleAutoGenerateName:async()=>{let e=t.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}d.value=!0;try{await t.session.renameSession(e);let n=t.session.list.value.find(t=>t.sessionCode===e);n&&(s.value=n.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),a(e)}finally{d.value=!1}i.autoGenerateName()},handleHelpClick:()=>{i.helpClick()},handleRename:async e=>{let n=t.session.current?.value;if(!n){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await t.session.updateSession({...n,sessionName:e}),s.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),a(e)}i.rename(e)},handleSessionSwitched:e=>{e&&(s.value=e.sessionName||``,u.value=(e.sessionContentCount??0)>0||f())},addNewSession:async e=>{e?await n.createSession(e):await n.createNewSession()},switchToSession:async e=>{r.value&&await r.value.switchSession(e)},updateSessionName:async(e,t)=>{try{await n.updateSessionName(e,t),s.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),a(e)}}}}function Yqt(e){let{shareBusinessManager:t,chatBotRef:n,forwarders:r,handleError:i}=e,a=sn(!1);return{isShareLoading:a,handleShare:()=>{n.value?.enterShareMode(),r.share()},handleCancelShare:()=>{n.value?.exitShareMode()},handleConfirmShare:async e=>{a.value=!0;try{let{shareUrl:i,userMessageIds:a}=await t.shareMessages(e);await WKt(i),Af({message:W9(`分享链接已复制到剪贴板`),theme:`success`}),n.value?.exitShareMode(),r.shareMessages(a)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),i(e)}finally{a.value=!1}}}}function Xqt(e={}){let t=sn([]),n=(n,r,i={})=>{try{let a=typeof n==`string`?document.querySelector(n):n;if(!a)return console.warn(`Tooltip target not found: ${n}`),null;let o=xp(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return t.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},r=(e,t,r={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=n(e,t,r);i&&a.push(i)}),a},i=e=>{let t=[];return e.forEach(({element:e,content:r,options:i})=>{let a=n(e,r,i);a&&t.push(a)}),t},a=()=>{t.value.forEach(e=>{e.destroy()}),t.value=[]};return sr(()=>{a()}),{instances:t,createTooltip:n,createTooltipsForSelector:r,createMultipleTooltips:i,destroyAll:a,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}var Zqt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,renderMode:Wi.Chat,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:void 0,helloText:W9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,alwaysCreateNewSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0},Qqt=class extends B9{eventEmitter;constructor(e={}){super({onStart:e.onStart,onMessage:e.onMessage,onDone:e.onDone,onError:e.onError}),this.eventEmitter=e.eventEmitter}handleRunErrorEvent(e){super.handleRunErrorEvent(e),this.eventEmitter?.emit(`run-error`,{event:e})}handleTextMessageChunkEvent(e){super.handleTextMessageChunkEvent(e),this.eventEmitter?.emit(`text-chunk`,{event:e})}handleThinkingEndEvent(e){super.handleThinkingEndEvent(e),this.eventEmitter?.emit(`thinking-end`,{event:e})}handleThinkingStartEvent(e){super.handleThinkingStartEvent(e),this.eventEmitter?.emit(`thinking-start`,{event:e})}handleToolCallEndEvent(e){super.handleToolCallEndEvent(e),this.eventEmitter?.emit(`tool-call-end`,{event:e})}handleToolCallStartEvent(e){super.handleToolCallStartEvent(e),this.eventEmitter?.emit(`tool-call-start`,{event:e})}};function $qt(e={}){let{eventEmitter:t,onStart:n,onMessage:r,onDone:i,onError:a,onTextChunk:o}=e;return new B9({onStart:()=>{t?.emit(`receive-start`,{}),n?.()},onMessage:e=>{t?.emit(`receive-message`,{event:e}),e.type===`TextMessageChunk`&&o&&o(e),r?.(e)},onDone:()=>{t?.emit(`receive-end`,{}),i?.()},onError:e=>{t?.emit(`receive-error`,{error:e}),a?.(e)}})}function eJt(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function q9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function tJt(e,t,n){return e-t-n}function nJt(e,t,n){return e-t-n}function J9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function rJt(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>eJt(r[e]));if(!eJt(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function iJt(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function Y9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function X9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var aJt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Z9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},oJt={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},sJt={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},Q9=Z9.mouse,cJt={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=iJt(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),Y9(document.documentElement,`mousedown`,this.deselect),Y9(document.documentElement,`touchend touchcancel`,this.deselect),Y9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){X9(document.documentElement,`mousedown`,this.deselect),X9(document.documentElement,`touchstart`,this.handleUp),X9(document.documentElement,`mousemove`,this.move),X9(document.documentElement,`touchmove`,this.move),X9(document.documentElement,`mouseup`,this.handleUp),X9(document.documentElement,`touchend touchcancel`,this.deselect),X9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){Q9=Z9.touch,this.elementDown(e)},elementMouseDown(e){Q9=Z9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!rJt(t,this.dragHandle,this.$el)||this.dragCancel&&rJt(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),Y9(document.documentElement,Q9.move,this.move),Y9(document.documentElement,Q9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),X9(document.documentElement,Q9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){Q9=Z9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),Y9(document.documentElement,Q9.move,this.handleResize),Y9(document.documentElement,Q9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=q9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=J9(i.left-a,r.minLeft,r.maxLeft),l=J9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=J9(i.right+a,r.minRight,r.maxRight),d=J9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=q9(this.grid,e,this.top,1),r=J9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=q9(this.grid,this.left,e,1),r=J9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=q9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=J9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=J9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=J9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=J9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=tJt(this.parentWidth,t,r),p=nJt(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=q9(this.grid,e,0,1),r=J9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=tJt(this.parentWidth,this.left,r),o=nJt(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=q9(this.grid,0,e,1),r=J9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=tJt(this.parentWidth,this.left,i),o=nJt(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),X9(document.documentElement,Q9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?oJt:sJt}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},lJt=[`onMousedown`,`onTouchstart`];function uJt(e,t,n,r,i,a){return H(),Gr(`div`,{style:he(a.style),class:be([{[n.classNameActive]:e.enabled,[n.classNameDragging]:e.dragging,[n.classNameResizing]:e.resizing,[n.classNameDraggable]:n.draggable,[n.classNameResizable]:n.resizable},n.className]),onMousedown:t[0]||=(...e)=>a.elementMouseDown&&a.elementMouseDown(...e),onTouchstart:t[1]||=(...e)=>a.elementTouchDown&&a.elementTouchDown(...e)},[(H(!0),Gr(Lr,null,dr(a.actualHandles,t=>(H(),Gr(`div`,{key:t,class:be([n.classNameHandle,n.classNameHandle+`-`+t]),style:he({display:e.enabled?`block`:`none`}),onMousedown:Pi(e=>a.handleDown(t,e),[`stop`,`prevent`]),onTouchstart:Pi(e=>a.handleTouchDown(t,e),[`stop`,`prevent`])},[pr(e.$slots,t)],46,lJt))),128)),pr(e.$slots,`default`)],38)}var dJt=aJt(cJt,[[`render`,uJt]]);function fJt(e){fJt.installed||(fJt.installed=!0,e.component(`VueDraggableResizable`,dJt))}var pJt={install:fJt},$9=null;typeof window<`u`?$9=window.Vue:typeof global<`u`&&($9=global.Vue),$9&&$9.use(pJt);function mJt(e={},t){let n=e.initWidth||400,r=e.minWidth||400,i=e.minHeight||400,a=e.maxWidthPercent||40,o=e.compressedHeight||800,s=e.compressedPadding===void 0?0:e.compressedPadding,l=sn(e.defaultLeft===void 0?window.innerWidth-n:e.defaultLeft),u=sn(e.defaultTop===void 0?0:e.defaultTop),d=sn(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),f=sn(n),p=sn(u.value),m=sn(l.value),h=sn(f.value),g=sn(d.value),_=sn(Math.max(window.innerWidth*(a/100),h.value)),v=sn(!1),y=sn(0),b=null,x=null,S=sn(!1),C=e=>{let t=window.innerWidth,n={...e};return n.width>t&&(n.width=t),n.x+n.width>t&&(n.x=t-n.width),n.x<0&&(n.x=0),n},w=()=>({x:m.value,y:p.value,width:h.value,height:g.value}),T=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),t?.onDragging?.(w())},E=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,t?.onResizing?.(w())},D=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),S.value&&(x=w()),t?.onDragStop?.(w())},O=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,S.value&&(x=w()),t?.onResizeStop?.(w())},k=()=>{_.value=Math.max(window.innerWidth*(a/100),h.value),En(()=>{if(v.value)m.value=window.innerWidth-h.value-s,p.value=window.innerHeight-o-s;else{let e=window.innerWidth-h.value-y.value;m.value=Math.max(0,e),setTimeout(()=>{g.value=window.innerHeight-p.value},0)}h.value>_.value&&(h.value=_.value)})},A=()=>{v.value?(p.value=u.value,En(()=>{g.value=d.value,m.value=l.value,h.value=f.value})):(p.value=window.innerHeight-o-s,m.value=l.value-s,h.value=n,g.value=o),v.value=!v.value},j=(e,t)=>{m.value=e,p.value=t,y.value=e-(window.innerWidth-h.value)},M=(e,t)=>{h.value=Math.max(r,Math.min(e,_.value)),g.value=Math.max(i,t)};return or(()=>{window.addEventListener(`resize`,k)}),sr(()=>{window.removeEventListener(`resize`,k)}),{minWidth:r,minHeight:i,maxWidth:_,top:p,left:m,width:h,height:g,isCompressed:v,isSidePanelExpanded:S,handleDragging:T,handleResizing:E,handleDragStop:D,handleResizeStop:O,toggleCompression:A,updatePosition:j,updateSize:M,updatePositionAndSize:(e,t,n,r)=>{j(e,t),M(n,r)},expandForSidePanel:e=>{if(S.value)return;let t=w();b={...t},S.value=!0;let n=t.x+t.width,r=x?.width??t.width+e,i=C({x:n-r,y:t.y,width:r,height:t.height});j(i.x,i.y),En(()=>{M(i.width,i.height)})},collapseSidePanel:()=>{if(!S.value)return;let e=w();x={...e},S.value=!1;let t=e.x+e.width,n=b?.width??e.width,r=C({x:t-n,y:e.y,width:n,height:e.height});M(r.width,r.height),En(()=>{j(r.x,r.y)})}}}var hJt={class:`draggable-container-content`},gJt=G9(Qn({__name:`draggable-container`,props:{className:{default:``},compressedHeight:{default:800},compressedPadding:{default:0},defaultHeight:{default:void 0},defaultWidth:{default:400},defaultX:{default:void 0},defaultY:{default:0},draggable:{type:Boolean,default:!0},dragHandle:{default:`.drag-handle`},maxWidth:{default:void 0},maxWidthPercent:{default:80},minHeight:{default:400},minWidth:{default:400},resizable:{type:Boolean,default:!0},teleportTo:{default:`body`},visible:{type:Boolean,default:!1}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=sn(!1),{minWidth:o,minHeight:s,maxWidth:l,top:u,left:d,width:f,height:p,isCompressed:m,isSidePanelExpanded:h,handleDragging:g,handleResizing:_,handleDragStop:v,handleResizeStop:y,toggleCompression:b,updatePosition:x,updateSize:S,updatePositionAndSize:C,expandForSidePanel:w,collapseSidePanel:T}=mJt({initWidth:r.defaultWidth,minWidth:r.minWidth,minHeight:r.minHeight,maxWidthPercent:r.maxWidthPercent,compressedHeight:r.compressedHeight,defaultHeight:r.defaultHeight,defaultTop:r.defaultY,defaultLeft:r.defaultX,compressedPadding:r.compressedPadding},{onDragStop:e=>i(`drag-stop`,e),onResizeStop:e=>i(`resize-stop`,e),onDragging:e=>i(`dragging`,e),onResizing:e=>i(`resizing`,e)}),E=mi(()=>({"--draggable-max-width":typeof r.maxWidth==`number`?`${r.maxWidth}px`:r.maxWidth??`${l.value}px`})),D=mi(()=>({x:d.value,y:u.value,width:f.value,height:p.value})),O=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},k=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},A=(e,t)=>{a.value||(a.value=!0,O()),g(e,t)},j=(e,t,n,r)=>{a.value||(a.value=!0,O()),_(e,t,n,r)},M=(e,t)=>{v(e,t),a.value=!1,k()},N=(e,t,n,r)=>{y(e,t,n,r),a.value=!1,k()};return Ln(m,e=>{i(`compression-change`,e)}),t({updatePosition:x,updateSize:S,updatePositionAndSize:C,toggleCompression:b,expandForSidePanel:w,collapseSidePanel:T,positionAndSize:D,isCompressed:m,isSidePanelExpanded:h}),(e,t)=>Mn((H(),Kr(V(dJt),{ref:`draggableRef`,active:r.visible,class:be([`draggable-container-wrapper`,r.className]),"class-name":`draggable-container-inner`,"drag-handle":r.dragHandle,draggable:r.draggable,h:V(p),"max-width":V(l),"min-height":V(s),"min-width":V(o),parent:!0,"prevent-deactivation":!0,resizable:r.resizable,style:he(E.value),w:V(f),x:V(d),y:V(u),onDragStop:M,onDragging:A,onResizeStop:N,onResizing:j},{default:jn(()=>[Xr(`div`,hJt,[pr(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`active`,`class`,`drag-handle`,`draggable`,`h`,`max-width`,`min-height`,`min-width`,`resizable`,`style`,`w`,`x`,`y`])),[[Ei,r.visible]])}}),[[`__scopeId`,`data-v-1118456b`]]),_Jt={class:`nimbus-bkai-wrapper`},vJt=[`width`,`height`,`src`],yJt=G9(Qn({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:t}){Kne(e=>({v05a8b16e:`${a.value.container}px`,v4e1cf4ca:`${a.value.wrapper}px`,v5ab0c513:`${a.value.mini.right}px`,v40c13a80:`${a.value.mini.size}px`,v0d35a9ef:`${a.value.mini.fontSize}px`}));let n=e,r=t,i={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},a=mi(()=>i[n.size]),o=sn(null),s=sn(null),{nimbusLeft:l,nimbusTop:u,isMinimize:d,handleClick:f,handleMinimize:p,handleDragging:m,handleMouseEnter:h,handleMouseLeave:g,handleMouseDown:_,handleMouseUp:v}=Gqt(r,n.isMinimize);Ln(d,e=>{r(`update:isMinimize`,e)});let y=mi(()=>d.value?W9(`恢复默认大小`):W9(`最小化,将缩成锚点`)),{createTooltip:b,destroyAll:x}=Xqt({theme:`ai-blueking`,delay:[0,0]}),S=()=>{En(()=>{C()})},C=()=>{x(),o.value&&!d.value&&b(o.value,KKt(),{placement:`left`}),s.value&&b(s.value,y.value,{placement:`top`})};return Ln(()=>d.value,()=>{En(()=>{C()})}),or(()=>{En(()=>{C()}),window.addEventListener(`resize`,S)}),sr(()=>{window.removeEventListener(`resize`,S)}),(t,n)=>(H(),Kr(V(dJt),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:a.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:a.value.container,x:V(l),y:V(u),onDragging:V(m)},{default:jn(()=>[Xr(`div`,{ref_key:`nimbusContainerRef`,ref:o,class:be([`nimbus-container`,{"is-minimize":V(d)}]),onClick:n[1]||=(...e)=>V(f)&&V(f)(...e),onMousedown:n[2]||=(...e)=>V(_)&&V(_)(...e),onMouseenter:n[3]||=(...e)=>V(h)&&V(h)(...e),onMouseleave:n[4]||=(...e)=>V(g)&&V(g)(...e),onMouseup:n[5]||=(...e)=>V(v)&&V(v)(...e)},[Xr(`div`,_Jt,[Xr(`img`,{width:a.value.img,height:a.value.img,src:V(sKt),alt:`nimbus`},null,8,vJt)]),Xr(`i`,{ref_key:`minimizeButtonRef`,ref:s,class:be([`nimbus-mini bkai-icon`,V(d)?`bkai-yinyong`:`bkai-minus-line`]),onClick:n[0]||=Pi((...e)=>V(p)&&V(p)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),bJt=G9(Qn({__name:`ai-blueking`,props:fte({autoSwitchToInitialSession:{type:Boolean},alwaysCreateNewSession:{type:Boolean},beforeNimbusClick:{type:Function},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},renderMode:{},shortcutFilter:{type:Function},resizeProps:{},getSideRenderComponent:{type:Function},getSideTabRenderComponent:{type:Function},onCustomTabChange:{type:Function}},Zqt),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`new-chat-created`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:t,emit:n}){let r=e,{chatHelper:i,componentManager:a,sessionBusinessManager:o,shareBusinessManager:s,shortcutManager:l,forwarders:u,forwardToManager:d,chatBotRef:f,draggableContainerRef:p,panelVisible:m,nimbusMinimized:h,normalizedUrl:g,agentName:_,currentSession:v,isCompressed:y,isWelcomeState:b,messageToolsTippyOptions:x,agentResources:S,agentPrompts:C,handleError:w,ensureSessionReady:T}=Uqt({props:r,emit:n}),{show:E,hide:D,handleShow:O,handleClose:k,handleNimbusClick:A,handleDragging:j,handleResizing:M,handleDragStop:N,handleResizeStop:P,handleToggleCompression:F,handleCompressionChange:I,handleExecutionPanelChange:L,sendMessage:R,handleReceiveStart:ee,handleReceiveText:te,handleReceiveEnd:z,handleStop:B,stopGeneration:ne,setCiteText:re,focusInput:ie,selectShortcut:ae,sendShortcut:oe,getChatHelper:se,updatePosition:ce,updateSize:le,updatePositionAndSize:ue,handleShortcutClick:de}=qqt({componentManager:a,chatBotRef:f,forwarders:u,forwardToManager:d,beforeNimbusClick:r.beforeNimbusClick,ensureSessionReady:T}),{sessionName:fe,hasPermission:pe,hasSessionContents:me,autoGenerateLoading:ge,handleNewChat:_e,handleNewChatCreated:ve,handleHistoryClick:ye,handleHistorySessionSwitch:Se,handleHistorySessionDelete:Ce,handleHistorySessionRename:we,handleAutoGenerateName:Te,handleHelpClick:Ee,handleRename:De,handleSessionSwitched:Oe,addNewSession:ke,switchToSession:Ae,updateSessionName:je}=Jqt({chatHelper:i,sessionBusinessManager:o,chatBotRef:f,forwarders:u,handleError:w,currentSession:v}),{isShareLoading:Me,handleShare:Ne,handleCancelShare:Pe,handleConfirmShare:Fe}=Yqt({shareBusinessManager:s,chatBotRef:f,forwarders:u,handleError:w}),{aiSelectionVisible:Ie,filteredPopupShortcuts:Le,handleSelectionChange:Re,handleAiSelectionShortcut:ze}=Wqt({shortcutManager:l,chatBotRef:f,forwardToManager:d,show:E,props:r}),Be=e=>{me.value=!0,u.sendMessage(e)};return t({show:E,handleShow:O,handleClose:k,hide:D,sendMessage:R,selectShortcut:ae,sendShortcut:oe,getChatHelper:se,stopGeneration:ne,addNewSession:ke,switchToSession:Ae,updateSessionName:je,updatePosition:ce,updateSize:le,updatePositionAndSize:ue,setCiteText:re,focusInput:ie}),(e,t)=>(H(),Kr(Un,{to:r.teleportTo},[Xr(`div`,{class:be([`ai-blueking-v2`,r.extCls])},[ti(` 可拖拽容器 `),Zr(V(gJt),{ref_key:`draggableContainerRef`,ref:p,"compressed-padding":r.miniPadding,"default-height":r.defaultHeight,"default-width":r.defaultWidth,"default-x":r.defaultLeft,"default-y":r.defaultTop,"drag-handle":`.drag-handle`,draggable:r.draggable,"max-width":r.maxWidth,"max-width-percent":80,visible:V(m),onCompressionChange:V(I),onDragStop:V(N),onDragging:V(j),onResizeStop:V(P),onResizing:V(M)},{default:jn(()=>[Xr(`div`,{class:be([`ai-blueking-panel`,{"has-messages":!V(b)}])},[ti(` 独立的 Header 组件 `),r.hideHeader?ti(`v-if`,!0):(H(),Kr(Cqt,{key:0,"agent-name":V(_),"chat-helper":V(i),draggable:r.draggable,"dropdown-menu-config":r.dropdownMenuConfig,"enable-chat-session":r.enableChatSession,"has-permission":V(pe),"has-session-contents":V(me),"auto-generate-loading":V(ge),"is-compression-height":V(y),"render-mode":r.renderMode,"session-business-manager":V(o),"session-name":V(fe),"show-compression-icon":r.showCompressionIcon,"show-history-icon":r.showHistoryIcon,"show-more-icon":r.showMoreIcon,"show-new-chat-icon":r.showNewChatIcon,title:r.title,onAutoGenerateName:V(Te),onClose:V(k),onHelpClick:V(Ee),onHistoryClick:V(ye),onHistorySessionDelete:V(Ce),onHistorySessionRename:V(we),onHistorySessionSwitch:V(Se),onNewChat:V(_e),onNewChatCreated:V(ve),onRename:V(De),onShare:V(Ne),onToggleCompression:V(F)},fr({_:2},[e.$slots.headerLeft?{name:`headerLeft`,fn:jn(()=>[pr(e.$slots,`headerLeft`,{},void 0,!0)]),key:`0`}:void 0]),1032,`agent-name.chat-helper.draggable.dropdown-menu-config.enable-chat-session.has-permission.has-session-contents.auto-generate-loading.is-compression-height.render-mode.session-business-manager.session-name.show-compression-icon.show-history-icon.show-more-icon.show-new-chat-icon.title.onAutoGenerateName.onClose.onHelpClick.onHistoryClick.onHistorySessionDelete.onHistorySessionRename.onHistorySessionSwitch.onNewChat.onNewChatCreated.onRename.onShare.onToggleCompression`.split(`.`))),ti(` ChatBot 核心组件(仅聊天区域) `),Zr(zqt,{ref_key:`chatBotRef`,ref:f,"always-create-new-session":r.alwaysCreateNewSession,"auto-load":r.loadRecentSessionOnMount,"chat-helper":V(i),"hello-text":r.helloText,"message-tools-tippy-options":V(x),placeholder:r.placeholder,prompts:V(C),"render-mode":r.renderMode,"request-options":r.requestOptions,"get-side-render-component":r.getSideRenderComponent,"get-side-tab-render-component":r.getSideTabRenderComponent,"on-custom-tab-change":r.onCustomTabChange,"resize-props":r.resizeProps,resources:V(S),"session-code":r.initialSessionCode,"share-loading":V(Me),shortcuts:r.shortcuts,style:he({height:r.hideHeader?`100%`:`calc(100% - 48px)`}),url:V(g),onCancelShare:V(Pe),onConfirmShare:t[0]||=e=>V(Fe)(e),onError:t[1]||=e=>V(w)(e),onExecutionPanelChange:V(L),onReceiveEnd:V(z),onReceiveStart:V(ee),onReceiveText:V(te),onRequestShare:V(Ne),onSendMessage:t[2]||=e=>Be(e),onSessionSwitched:t[3]||=e=>V(Oe)(e),onShortcutClick:V(de),onStop:V(B)},fr({_:2},[e.$slots.codeHeader?{name:`codeHeader`,fn:jn(t=>[pr(e.$slots,`codeHeader`,xe(Qr(t)),void 0,!0)]),key:`0`}:void 0,e.$slots.message?{name:`message`,fn:jn(t=>[pr(e.$slots,`message`,xe(Qr(t)),void 0,!0)]),key:`1`}:void 0]),1032,`always-create-new-session.auto-load.chat-helper.hello-text.message-tools-tippy-options.placeholder.prompts.render-mode.request-options.get-side-render-component.get-side-tab-render-component.on-custom-tab-change.resize-props.resources.session-code.share-loading.shortcuts.style.url.onCancelShare.onExecutionPanelChange.onReceiveEnd.onReceiveStart.onReceiveText.onRequestShare.onShortcutClick.onStop`.split(`.`))],2)]),_:3},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`,`onCompressionChange`,`onDragStop`,`onDragging`,`onResizeStop`,`onResizing`]),ti(` Nimbus 悬浮球 `),r.hideNimbus?ti(`v-if`,!0):(H(),Kr(yJt,{key:0,"is-minimize":V(h),"onUpdate:isMinimize":t[4]||=e=>on(h)?h.value=e:null,"is-panel-show":V(m),"onUpdate:isPanelShow":t[5]||=e=>on(m)?m.value=e:null,"default-minimize":r.defaultMinimize,size:r.nimbusSize,onClick:V(A)},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`,`onClick`])),ti(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),r.enablePopup?(H(),Kr(V(Yoe),{key:1,visible:V(Ie),"onUpdate:visible":t[6]||=e=>on(Ie)?Ie.value=e:null,"exclude-selectors":[`.draggable-container-wrapper`],"max-shortcut-count":r.shortcutLimit,shortcuts:V(Le),onSelectShortcut:V(ze),onSelectionChange:V(Re)},null,8,[`visible`,`max-shortcut-count`,`shortcuts`,`onSelectShortcut`,`onSelectionChange`])):ti(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-f367dd3f`]]);function xJt(e){return`on`+e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function SJt(){return`bk`}function CJt(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`[ai-blueking] mount container not found: ${e}`);return t}function wJt(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){if(!r)continue;let e=n.startsWith(`on`)&&n.length>2?n:xJt(n);t[e]=r}return t}function TJt(e,t,n){let r=CJt(e),i=Jt({...n?.props??{}}),a=null,o=Ii({setup(){return()=>U(Hfe,{prefix:SJt()},{default:()=>U(t,{...i,...wJt(n?.on),ref:e=>{a=e}})})}});return o.mount(r),{app:o,getExpose:()=>a,get expose(){return a},updateProps(e){Object.assign(i,e)},unmount(){o.unmount(),a=null}}}function EJt(e,t){return TJt(e,bJt,t)}function DJt(e,t){return TJt(e,zqt,t)}e.AGUIProtocol=B9,e.AIBlueking=bJt,e.BluekingProtocol=Qqt,e.BootstrapPhase=K9,e.ChatBot=zqt,e.ChatBusinessManager=wqt,e.ComponentManager=Oqt,e.DraggableContainer=gJt,e.MessageContentType=Li,e.RenderMode=Wi,e.SessionBusinessManager=Tqt,e.ShortcutManager=Dqt,e.UIStateManager=Mqt,e.buildStandaloneListeners=wJt,e.createApp=Ii,e.createBluekingProtocol=$qt,e.createComponentManager=kqt,e.defaultProps=Zqt,e.h=U,e.mountAIBlueking=EJt,e.mountChatBot=DJt,e.mountStandaloneComponent=TJt,e.parseCustomBlocks=BKt,e.render=Fi,e.resolveMountContainer=CJt,e.useChatBootstrap=Bqt,e.useChatHelper=IKt,e.useDraggable=mJt});
|
|
3501
|
+
`).forEach(t=>{let n=t.replace(`data:`,``).trim();if(s(n)){let t=JSON.parse(n);e.onMessage?.(t),o=``}else n&&(o=n)})}}catch(t){throw t instanceof Error&&(t.name===`AbortError`?e.onDone?.():e.onError?.(t)),t}}};function xKt(e,t){if(!t)return e;let n=new URLSearchParams;Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(Array.isArray(r)?r.forEach(t=>n.append(e,String(t))):n.append(e,String(r)))});let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e}function H9(e,t,n,r){let i=Error(e);return i.config=t,i.code=String(n),i.response=r,i.isAxiosError=!0,i}function SKt(e){return V9(e)}function CKt(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function U9(e,t){let n={...e};for(let r in t){let i=t[r];if(CKt(i)){let t=e[r];n[r]=U9(t||{},i)}else n[r]=i}return n}new bKt;var wKt=new Set([`POST`,`PUT`,`PATCH`,`DELETE`]),TKt=new Set([`GET`,`HEAD`,`OPTIONS`]);function EKt(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function DKt(e,t){let{headers:n,data:r}=t.requestData;!n&&!r||e.interceptors.request.use(e=>{let t=e,i=(e.method??`GET`).toUpperCase();if(n){let r=V9(n);if(r&&Object.keys(r).length>0){let n=V9(e.headers)??{};t={...t,headers:{...n,...r}}}}if(r){let n=V9(r);if(n&&Object.keys(n).length>0){if(wKt.has(i)){let r=V9(e.data);r==null?t={...t,data:n}:EKt(r)?t={...t,data:{...n,...r}}:console.warn(`[chat-helper] requestData.data 无法注入:当前请求体不是普通对象(FormData/Blob/string 等),已跳过合并。`,{method:i,existingType:typeof r})}else if(TKt.has(i)){let r=e.params??{};t={...t,params:{...n,...r}}}}}return t})}var OKt=e=>{let t=new bKt({baseURL:e.requestData.urlPrefix});return DKt(t,e),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response),{fetchClient:t,reset:e=>{t.defaults.baseURL=e.requestData.urlPrefix,t.interceptors.request.clear(),t.interceptors.response.clear(),DKt(t,e),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response)}}},kKt=e=>({getAgentInfo:t=>e.get(`agent/info/`,void 0,t).then(cKt)}),AKt=e=>({getMessages:(t,n,r)=>e.get(`session_content/content/`,{session_code:t,limit:n},r).then(e=>e.map(I9)),plusMessage:(t,n)=>e.post(`session_content/`,uKt(t),n).then(I9),modifyMessage:(t,n)=>e.put(`session_content/${t.id}/`,uKt(t),n).then(I9),deleteMessage:(t,n)=>e.delete(`session_content/${t}/`,void 0,n),batchDeleteMessages:(t,n)=>e.post(`session_content/batch_delete/`,{ids:t},n),shareMessages:(t,n,r,i)=>e.post(`share/`,{session_code:t,content_ids:n,...r?{expired_at:r}:{}},i),stopChat:(t,n)=>e.post(`session_content/stop/`,{session_code:t},n),getFlowAgentTaskInfo:(t,n)=>e.get(`flow_agent/${t}/task_info/`,void 0,n),getFlowAgentTaskNodeInfo:(t,n,r)=>e.get(`flow_agent/${t}/task_node_info/${n}/`,void 0,r)}),jKt=e=>({clearSession:(t,n)=>e.post(`chat_completion/${t}/clear/`,void 0,n),getSessions:t=>e.get(`session/`,void 0,t).then(e=>e.map(L9)),plusSession:(t,n)=>e.post(`session/`,dKt(t),n).then(e=>L9(e)),modifySession:(t,n)=>e.put(`session/${t.sessionCode}/`,dKt(t),n).then(e=>L9(e)),deleteSession:(t,n)=>e.delete(`session/${t}/`,void 0,n),batchDeleteSessions:(t,n)=>e.post(`session/batch_delete/`,{session_codes:t},n),getSession:(t,n)=>e.get(`session/${t}/`,void 0,n).then(e=>L9(e)),postSessionFeedback:(t,n)=>e.post(`session_feedback/`,fKt(t),n).then(e=>pKt(e)),getSessionFeedbackReasons:(t,n)=>e.get(`session_feedback/reasons/`,{rate:t},n),renameSession:(t,n)=>e.post(`session/${t}/ai_rename/`,void 0,n).then(e=>L9(e)),uploadFile:(t,n,r)=>{let i=encodeURIComponent(n.name);return n.arrayBuffer().then(a=>e.post(`session/${t}/upload/${i}/`,a,{...r,headers:{"Content-Disposition":`attachment; filename="${n.name}"`}}))}}),MKt=e=>({agent:kKt(e),session:jKt(e),message:AKt(e),fetchClient:e}),NKt=e=>{let{fetchClient:t,reset:n}=OKt(e);return{...MKt(t),reset:n}},PKt=()=>({agent:null,http:null,message:null,session:null,registerAgent(e){this.agent=e},registerHttp(e){this.http=e},registerMessage(e){this.message=e},registerSession(e){this.session=e}}),FKt=e=>{let t=sn([]),n=sn(null),r=sn(!1),i=sn(!1),a=sn(!1),o=sn(!1),s=sn(!1),l=sn(!1),u=sn(!1),d=e=>{t.value=t.value.map(t=>t.sessionCode===e.sessionCode?{...t,...e}:t),n.value?.sessionCode===e.sessionCode&&(n.value=t.value.find(t=>t.sessionCode===e.sessionCode)??n.value)},f=()=>(i.value=!0,e.http?.session.getSessions().then(e=>{t.value=e}).finally(()=>{i.value=!1})),p=async(r,i)=>{e.agent?.abortChat(),n.value=t.value.find(e=>e.sessionCode===r)??null,i?.loadMessages===!1?e.message&&(e.message.list.value=[]):(await e.message?.getMessages(r),e.agent?.resumeStreamingChat(r))};return{list:t,current:n,isCurrentLoading:r,isListLoading:i,isCreateLoading:a,isUpdateLoading:o,isDeleteLoading:s,isBatchDeleteLoading:l,getSessions:f,chooseSession:p,getSession:t=>(r.value=!0,e.http?.session.getSession(t).then(e=>{n.value=e}).finally(()=>{r.value=!1})),createSession:async(n,r)=>{a.value=!0;try{let i=await e.http?.session.plusSession(n);i&&(t.value.unshift(i),await p(i.sessionCode,{loadMessages:r?.loadMessages??!1}))}finally{a.value=!1}},updateSession:t=>(o.value=!0,e.http?.session.modifySession(t).then(e=>{d(e)}).finally(()=>{o.value=!1})),deleteSession:async r=>{s.value=!0;try{await e.http?.session.deleteSession(r),t.value=t.value.filter(e=>e.sessionCode!==r),n.value?.sessionCode===r&&t.value[0]?.sessionCode&&await p(t.value[0].sessionCode)}finally{s.value=!1}},batchDeleteSessions:async r=>{if(r.length!==0){l.value=!0;try{await e.http?.session.batchDeleteSessions(r);let i=new Set(r);t.value=t.value.filter(e=>!i.has(e.sessionCode)),n.value&&i.has(n.value.sessionCode)&&(t.value.length>0?await p(t.value[0].sessionCode):(n.value=null,e.message&&(e.message.list.value=[])))}finally{l.value=!1}}},postSessionFeedback:t=>e.http?.session.postSessionFeedback(t),getSessionFeedbackReasons:t=>e.http?.session.getSessionFeedbackReasons(t),renameSession:t=>(u.value=!0,e.http?.session.renameSession(t).then(e=>{d({sessionCode:e.sessionCode,sessionName:e.sessionName})}).finally(()=>{u.value=!1})),uploadFile:(t,n)=>e.http?.session.uploadFile(t,n),reset:()=>{t.value=[],n.value=null,r.value=!1,i.value=!1,a.value=!1,o.value=!1,s.value=!1,l.value=!1,u.value=!1}}},IKt=e=>{let t=PKt(),n=NKt(e),r=_Kt(t,e.protocol),i=hKt(t),a=FKt(t);return t.registerHttp(n),t.registerMessage(i),t.registerAgent(r),t.registerSession(a),{agent:r,session:a,message:i,http:n,reset:e=>{n.reset(e),r.reset(e.protocol),i.reset(),a.reset()}}};function LKt(e,t){return{urlPrefix:e,headers:()=>V9(un(t)?.headers),data:()=>V9(un(t)?.data)}}function RKt(e,t){let n=null;for(let r of e)if(r.role===`user`&&r.id!==void 0&&(n=r),r===t)break;return n}function zKt(e,t){let n=RKt(e,t);if(n?.id!==void 0)return typeof n.id==`number`?n.id:Number(n.id)}function BKt(e){if(!e)return[];if(typeof e!=`string`)return[{type:`text`,content:e}];let t=[],n=/```custom-component\s*\n([\s\S]*?)\n```/g,r=0,i;for(;(i=n.exec(e))!==null;){if(i.index>r){let n=e.slice(r,i.index).trim();n&&t.push({type:`text`,content:n})}try{let e=JSON.parse(i[1]);t.push({type:`custom`,data:e,raw:i[1]})}catch{t.push({type:`text`,content:i[0]})}r=i.index+i[0].length}if(r<e.length){let n=e.slice(r).trim();n&&t.push({type:`text`,content:n})}return t}var VKt=e=>{let t=document.cookie.match(RegExp(`(^| )${e}=([^;]*)(;|$)`));return t?t[2]:``},HKt=e=>e.endsWith(`/`)?e:`${e}/`,UKt=e=>{if(!e)return e;try{let t=new URL(e,window.location.origin);return t.protocol=window.location.protocol,HKt(t.toString())}catch(t){return console.warn(`Failed to normalize URL:`,t),HKt(e)}};async function WKt(e){if(typeof navigator<`u`&&`clipboard`in navigator)try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{document.body.removeChild(t)}}function GKt(){let e=window.navigator.userAgent.toLowerCase(),t=window.navigator.platform.toLowerCase();return t.includes(`mac`)||e.includes(`mac`)?`mac`:t.includes(`win`)||e.includes(`win`)?`windows`:t.includes(`linux`)||e.includes(`linux`)?`linux`:`unknown`}function KKt(){return qKt()?`Cmd + I`:`Ctrl + I`}function qKt(){return GKt()===`mac`}function JKt(e){let t=qKt()?e.metaKey:e.ctrlKey,n=e.key.toLowerCase()===`i`;return t&&n&&!e.shiftKey&&!e.altKey}var YKt=VKt(`blueking_language`)||`zh-cn`,XKt={小鲸:`BK GPT`,关闭:`close`,发送:`Send`,请输入:`Please input`,昨天:`yesterday`,"3天前":`3 days ago`,"5天前":`5 days ago`,"1周前":`1 week ago`,更早:`Older`,删除:`Delete`,恢复默认大小:`Restore default size`,"AI 小鲸":`AI BK GPT`,新增会话:`New chat`,历史会话:`History session`,停止生成:`Stop generating`,复制:`Copy`,编辑:`Edit`,今天:`Today`,搜索会话名称:`Search session name`,重命名:`Rename`,自动生成命名:`Auto generate name`,分享会话:`Share session`,无智能体使用权限:`No permission to use this agent`,暂无使用权限:`No permission`,请输入新的会话名称:`Please enter new session name`,"确认删除会话 ?":`Confirm delete session?`,搜索为空:`No search results`,暂无对话:`No conversations`,转人工:`Transfer to human`,缩小高度:`Shrink height`,全选:`Select all`,取消:`Cancel`,确定:`Confirm`,分享链接已复制到剪贴板:`Share link copied to clipboard`},ZKt={重命名:`重命名`,自动生成命名:`自动生成命名`,分享会话:`分享会话`,全选:`全选`,取消:`取消`,确定:`确定`,分享链接已复制到剪贴板:`分享链接已复制到剪贴板`},W9=e=>YKt===`en`?XKt[e]||e:ZKt[e]||e;function QKt(e){let{triggerRef:t,panelComponent:n,panelProps:r={},tippyOptions:i={}}=e,a=sn(null),o=null,s=()=>(o||=document.createElement(`div`),Fi(U(n,{...r,onClose:f}),o),o),l=e=>{let n=e.target,r=t.value;if(r&&r.contains(n))return;let i=document.querySelector(`.tippy-box[data-theme~="history-panel"]`);if(i&&i.contains(n))return;let o=document.querySelector(`.tippy-box[data-theme~="more-menu-light"]`);o&&o.contains(n)||a.value?.state.isVisible&&a.value.hide()},u=()=>{if(!t.value||a.value)return;let e={placement:`bottom-end`,offset:[0,8],appendTo:document.querySelector(`.ai-blueking-container-wrapper`)||document.body};a.value=xp(t.value,{content:s(),interactive:!0,trigger:`manual`,theme:`light history-panel`,arrow:!1,hideOnClick:!1,animation:`scale`,duration:200,delay:[0,0],...e,...i,onShow:()=>{a.value&&o&&a.value.setContent(s()),setTimeout(()=>{document.addEventListener(`click`,l,!1)},0)},onHidden:()=>{document.removeEventListener(`click`,l,!1)}})},d=()=>{a.value||u(),a.value?.show()},f=()=>{a.value?.hide()},p=()=>{a.value||u(),a.value?.state.isVisible?f():d()},m=e=>{e.stopPropagation(),p()},h=()=>{a.value&&=(a.value.destroy(),null),o&&=(Fi(null,o),null),document.removeEventListener(`click`,l,!1)};return sr(()=>{h()}),{show:d,hide:f,toggle:p,handleTriggerClick:m,destroy:h,isVisible:()=>a.value?.state.isVisible??!1}}var $Kt={class:`history-group`},eqt={class:`history-group-title`},tqt={class:`history-group-list`},nqt=Qn({__name:`history-group`,props:{currentSessionCode:{},sessions:{},title:{}},setup(e){let t=e;return(e,n)=>(H(),Gr(`div`,$Kt,[Xr(`div`,eqt,[Xr(`span`,null,Oe(t.title),1)]),Xr(`div`,tqt,[pr(e.$slots,`default`,{},void 0,!0)])]))}}),G9=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},rqt=G9(nqt,[[`__scopeId`,`data-v-3b603cb6`]]),iqt={class:`history-item-actions`},aqt=G9(Qn({__name:`history-item`,props:{isActive:{type:Boolean},isEditing:{type:Boolean},session:{}},emits:[`click`,`delete`,`edit`,`rename-cancel`,`rename-confirm`],setup(e,{emit:t}){let n=e,r=t,i=Nwe,a=sn(null),o=sn(``);Ln(()=>n.isEditing,e=>{e&&(o.value=n.session.sessionName,En(()=>{if(a.value)try{let e=a.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus edit input:`,e)}}))});let s=()=>{n.isEditing||r(`click`,n.session)},l=()=>{r(`edit`,n.session)},u=()=>{r(`delete`,n.session.sessionCode)},d=()=>{let e=o.value.trim();e&&e!==n.session.sessionName?r(`rename-confirm`,n.session.sessionCode,e):r(`rename-cancel`)},f=()=>{r(`rename-cancel`)},p=(e,t)=>{t.key===`Enter`?d():t.key===`Escape`&&f()};return(e,t)=>(H(),Gr(`div`,{class:be([`history-item`,{active:n.isActive}]),onClick:s},[n.isEditing?(H(),Kr(V(Pd),{key:1,ref_key:`editInputRef`,ref:a,modelValue:o.value,"onUpdate:modelValue":t[1]||=e=>o.value=e,style:{width:`100%`,height:`28px`},onBlur:d,onKeyup:p,onClick:t[2]||=Pi(()=>{},[`stop`])},null,8,[`modelValue`])):(H(),Gr(Lr,{key:0},[Zr(V(xbe),{style:{width:`calc(100% - 42px)`}},{default:jn(()=>[ei(Oe(n.session.sessionName),1)]),_:1}),Xr(`span`,iqt,[Mn(Xr(`i`,{class:`bkai-icon bkai-bianji`,onClick:Pi(l,[`stop`])},null,512),[[V(i),{content:V(W9)(`编辑`),boundary:`parent`}]]),Zr(V(VCe),{title:V(W9)(`确认删除会话 ?`),content:`删除操作无法撤回,请谨慎操作!`,"confirm-config":{theme:`danger`},trigger:`click`,boundary:`parent`,onConfirm:u},{default:jn(()=>[Mn(Xr(`i`,{class:`bkai-icon bkai-shanchu`,onClick:t[0]||=Pi(()=>{},[`stop`])},null,512),[[V(i),{content:V(W9)(`删除`),boundary:`parent`}]])]),_:1},8,[`title`])])],64))],2))}}),[[`__scopeId`,`data-v-fea14d3a`]]),oqt={class:`history-search`},sqt={class:`input-icon`},cqt=G9(Qn({__name:`history-search`,props:{modelValue:{default:``},placeholder:{default:``}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=e=>{r(`update:modelValue`,e)};return(e,t)=>(H(),Gr(`div`,oqt,[Zr(V(Pd),{"model-value":n.modelValue,behavior:`simplicity`,placeholder:n.placeholder||V(W9)(`搜索会话名称`),style:{height:`22px`},"onUpdate:modelValue":i},{suffix:jn(()=>[Xr(`span`,sqt,[Zr(V(Ou))])]),_:1},8,[`model-value`,`placeholder`])]))}}),[[`__scopeId`,`data-v-e7ff40b2`]]),lqt={class:`bkai-history-dropdown`},uqt={class:`history-dropdown-header`},dqt={class:`history-dropdown-header-title`},fqt={class:`history-dropdown-content`},pqt=G9(Qn({__name:`index`,props:{sessionBusinessManager:{}},emits:[`close`,`session-delete`,`session-rename`,`session-switch`],setup(e,{emit:t}){let n=e,r=t,i=sn(``),a=sn(null),o=mi(()=>n.sessionBusinessManager.currentSession.value?.sessionCode),s=mi(()=>{let e={today:{key:`today`,alias:W9(`今天`),sessionList:[]},yesterday:{key:`yesterday`,alias:W9(`昨天`),sessionList:[]},"3days":{key:`3days`,alias:W9(`3天前`),sessionList:[]},"5days":{key:`5days`,alias:W9(`5天前`),sessionList:[]},"1week":{key:`1week`,alias:W9(`1周前`),sessionList:[]},before:{key:`before`,alias:W9(`更早`),sessionList:[]}},t=n.sessionBusinessManager.sessionList.value.filter(e=>e.sessionName.toLowerCase().includes(i.value.toLowerCase())),r=new Date,a=new Date(r);a.setDate(a.getDate()-1);let o=new Date(r);o.setDate(r.getDate()-3);let s=new Date(r);s.setDate(r.getDate()-5);let l=new Date(r);l.setDate(r.getDate()-7);for(let n of t){let t=new Date(n.createdAt||``),i=t.toDateString();i===r.toDateString()?e.today.sessionList.push(n):i===a.toDateString()?e.yesterday.sessionList.push(n):t>=o&&t>s?e[`3days`].sessionList.push(n):t>=s&&t>l?e[`5days`].sessionList.push(n):t>=l?e[`1week`].sessionList.push(n):e.before.sessionList.push(n)}for(let t of Object.values(e))t.sessionList.sort((e,t)=>{let n=new Date(e.createdAt||0).getTime();return new Date(t.createdAt||0).getTime()-n});return Object.values(e).filter(e=>e.sessionList.length>0)}),l=e=>o.value===e,u=e=>{l(e.sessionCode)||(r(`session-switch`,e.sessionCode),r(`close`))},d=e=>{a.value=e.sessionCode},f=e=>{r(`session-delete`,e)},p=(e,t)=>{let i=n.sessionBusinessManager.sessionList.value.find(t=>t.sessionCode===e);i&&(i.sessionName=t),a.value=null,r(`session-rename`,e,t)},m=()=>{a.value=null};return(e,t)=>(H(),Gr(`div`,lqt,[Xr(`div`,uqt,[Xr(`h1`,dqt,Oe(V(W9)(`历史会话`)),1),Zr(cqt,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e,placeholder:V(W9)(`搜索会话名称`)},null,8,[`modelValue`,`placeholder`])]),Xr(`div`,fqt,[s.value.length>0?(H(!0),Gr(Lr,{key:0},dr(s.value,e=>(H(),Kr(rqt,{key:e.key,"current-session-code":o.value,sessions:e.sessionList,title:e.alias},{default:jn(()=>[(H(!0),Gr(Lr,null,dr(e.sessionList,e=>(H(),Kr(aqt,{key:e.sessionCode,"is-active":l(e.sessionCode),"is-editing":a.value===e.sessionCode,session:e,onClick:u,onDelete:f,onEdit:d,onRenameCancel:m,onRenameConfirm:p},null,8,[`is-active`,`is-editing`,`session`]))),128))]),_:2},1032,[`current-session-code`,`sessions`,`title`]))),128)):(H(),Kr(V(mCe),{key:1,description:i.value?V(W9)(`搜索为空`):V(W9)(`暂无对话`),scene:`part`,style:{"margin-top":`100px`},type:i.value?`search-empty`:`empty`},null,8,[`description`,`type`]))])]))}}),[[`__scopeId`,`data-v-143fb0ef`]]);function mqt(e){return e.sessionBusinessManager?QKt({triggerRef:e.triggerRef,panelComponent:pqt,panelProps:{sessionBusinessManager:e.sessionBusinessManager,onSessionSwitch:e.onSessionSwitch,onSessionDelete:e.onSessionDelete,onSessionRename:e.onSessionRename},tippyOptions:{placement:`bottom-end`,offset:[0,8],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body}}):{handleTriggerClick:()=>{},show:()=>{},hide:()=>{},toggle:()=>{},destroy:()=>{},isVisible:()=>!1}}var hqt={class:`left-section`},gqt={class:`logo`},_qt=[`src`],vqt={key:0,class:`rename-tooltip`},yqt={class:`rename-content`},bqt={key:0,class:`tippy-dropdown-menu`},xqt={key:1,class:`bkai-icon bkai-auto-refresh-line`},Sqt={class:`right-section`},Cqt=G9(Qn({__name:`index`,props:{title:{default:``},agentName:{default:``},sessionName:{default:``},isCompressionHeight:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},showHistoryIcon:{type:Boolean,default:!0},showNewChatIcon:{type:Boolean,default:!0},showCompressionIcon:{type:Boolean,default:!0},showMoreIcon:{type:Boolean,default:!0},enableChatSession:{type:Boolean,default:!0},hasPermission:{type:Boolean,default:!0},chatGroup:{default:()=>({enabled:!1,staff:[],username:``})},hasSessionContents:{type:Boolean},autoGenerateLoading:{type:Boolean},dropdownMenuConfig:{default:()=>({showRename:!0,showAutoGenerate:!0,showShare:!1})},sessionBusinessManager:{default:void 0},renderMode:{default:Wi.Chat}},emits:[`close`,`toggle-compression`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`,`history-session-switch`,`history-session-delete`,`history-session-rename`,`new-chat-created`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=Nwe,o=sn(null),s=sn(null),l=$n(`moreMenuTippyRef`),u=sn(!1),d=sn(``),f=sn(null),p=sn(!1),m=()=>document.querySelector(`.ai-blueking-panel`)||document.body,h=null,g=()=>{!s.value||!r.sessionBusinessManager||(h=mqt({triggerRef:s,sessionBusinessManager:r.sessionBusinessManager,onSessionSwitch:e=>i(`history-session-switch`,e),onSessionDelete:e=>i(`history-session-delete`,e),onSessionRename:(e,t)=>i(`history-session-rename`,e,t)}))},_=mi(()=>r.hasPermission?r.enableChatSession?r.title||`${r.agentName||``}-${r.sessionName||``}`:r.agentName:W9(`无智能体使用权限`)),v=mi(()=>r.isCompressionHeight?`bkai-morenchicun`:`bkai-yasuo`),y=mi(()=>r.isCompressionHeight?W9(`恢复默认尺寸`):W9(`缩小高度`)),b=mi(()=>r.hasPermission),x=e=>b.value?e:W9(`暂无使用权限`),S=()=>({cursor:b.value?`pointer`:`not-allowed`}),C=sn(!1),w=async()=>{if(!C.value){C.value=!0;try{if(r.sessionBusinessManager)try{let e=await r.sessionBusinessManager.createNewSession();e&&i(`new-chat-created`,{sessionCode:e.sessionCode,sessionName:e.sessionName,createdAt:e.createdAt})}catch(e){console.error(`Failed to create new session:`,e),Af({theme:`error`,message:W9(`创建会话失败`)})}i(`new-chat`)}finally{C.value=!1}}},T=e=>{e.stopPropagation(),r.sessionBusinessManager?(h||g(),h&&h.handleTriggerClick(e)):i(`history-click`,e)},E=()=>{i(`help-click`)},D=e=>{e.stopPropagation(),h&&h.isVisible()&&h.hide(),l.value&&(p.value?l.value.hide():l.value.show())},O=()=>{l.value?.hide(),j()},k=()=>{!r.hasSessionContents||r.autoGenerateLoading||i(`auto-generate-name`)},A=()=>{r.hasSessionContents&&(l.value?.hide(),i(`share`))},j=()=>{document.removeEventListener(`click`,F),d.value=r.sessionName||``,u.value=!0,setTimeout(()=>{document.addEventListener(`click`,F)},100),setTimeout(()=>{if(f.value)try{let e=f.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},M=()=>{let e=d.value.trim();if(!e){N();return}i(`rename`,e),u.value=!1,d.value=``},N=()=>{u.value=!1,d.value=``},P=(e,t)=>{d.value=e,t.key===`Enter`?M():t.key===`Escape`&&N()},F=e=>{if(!u.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&N()};return Ln(()=>r.autoGenerateLoading,(e,t)=>{t&&!e&&p.value&&l.value?.hide()}),or(()=>{r.sessionBusinessManager&&g(),document.addEventListener(`click`,F)}),sr(()=>{h&&=(h.destroy(),null),document.removeEventListener(`click`,F)}),t({headerRef:o,historyIconRef:s}),(t,n)=>(H(),Gr(`div`,{ref_key:`headerRef`,ref:o,class:be([`ai-header drag-handle`,{draggable:r.draggable}])},[Xr(`div`,hqt,[Xr(`div`,gqt,[Xr(`img`,{alt:`logo`,src:V(sKt)},null,8,_qt)]),Xr(`div`,{class:be([`title`,{"title-with-tooltip":u.value}])},[ei(Oe(_.value)+` `,1),ti(` 重命名 tooltip 直接绑定在 title 上 `),u.value?(H(),Gr(`div`,vqt,[Xr(`div`,yqt,[Zr(V(Pd),{ref_key:`renameInputRef`,ref:f,modelValue:d.value,"onUpdate:modelValue":n[0]||=e=>d.value=e,class:`rename-input`,placeholder:V(W9)(`请输入新的会话名称`),onKeyup:P},null,8,[`modelValue`,`placeholder`]),Xr(`div`,{class:`rename-buttons`},[Xr(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:M}),Xr(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:N})])])])):ti(`v-if`,!0)],2),ti(` 更多图标下拉菜单 - 使用 vue-tippy `),r.showMoreIcon&&b.value?(H(),Kr(V(Xa),{key:0,ref_key:`moreMenuTippyRef`,ref:l,arrow:!1,"append-to":m,offset:[0,4],interactive:``,placement:`bottom-start`,theme:`ai-blueking-light more-menu-light light`,trigger:`manual`,onHidden:n[1]||=e=>p.value=!1,onShown:n[2]||=e=>p.value=!0},{content:jn(()=>[p.value?(H(),Gr(`div`,bqt,[r.dropdownMenuConfig?.showRename?(H(),Gr(`div`,{key:0,class:`tippy-menu-item`,onClick:O},[n[7]||=Xr(`i`,{class:`bkai-icon bkai-bianji`},null,-1),Xr(`span`,null,Oe(V(W9)(`重命名`)),1)])):ti(`v-if`,!0),r.dropdownMenuConfig?.showAutoGenerate?Mn((H(),Gr(`div`,{key:1,class:be([`tippy-menu-item`,{disabled:!r.hasSessionContents||r.autoGenerateLoading}]),onClick:k},[r.autoGenerateLoading?(H(),Kr(V(hd),{key:0,mode:`spin`,size:`mini`,theme:`primary`})):(H(),Gr(`i`,xqt)),Xr(`span`,null,Oe(V(W9)(`自动生成命名`)),1)],2)),[[V(Za),{content:r.hasSessionContents?``:V(W9)(`请先发起会话`),theme:`ai-blueking-tooltip`,arrow:!0,delay:[300,0],appendTo:m}]]):ti(`v-if`,!0),r.dropdownMenuConfig?.showShare&&r.renderMode!==V(Wi).Test?Mn((H(),Gr(`div`,{key:2,class:be([`tippy-menu-item`,{disabled:!r.hasSessionContents}]),onClick:A},[n[8]||=Xr(`i`,{class:`bkai-icon bkai-fenxiang`},null,-1),Xr(`span`,null,Oe(V(W9)(`分享会话`)),1)],2)),[[V(Za),{content:r.hasSessionContents?``:V(W9)(`请先发起会话`),theme:`ai-blueking-tooltip`,arrow:!0,delay:[300,0],appendTo:m}]]):ti(`v-if`,!0)])):ti(`v-if`,!0)]),default:jn(()=>[Xr(`span`,{class:`bkai-icon bkai-more`,onClick:D})]),_:1},512)):ti(`v-if`,!0)]),pr(t.$slots,`headerLeft`,{},void 0,!0),Xr(`div`,Sqt,[ti(` 新增会话按钮 `),r.showNewChatIcon&&e.enableChatSession!==!1?Mn((H(),Gr(`i`,{key:0,class:be([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!b.value||C.value}]),style:he(S()),onClick:n[3]||=e=>b.value&&!C.value?w():void 0},null,6)),[[V(a),{content:C.value?V(W9)(`正在创建会话...`):x(V(W9)(`新增会话`)),boundary:`parent`}]]):ti(`v-if`,!0),ti(` 历史会话按钮 `),r.showHistoryIcon&&e.enableChatSession!==!1?Mn((H(),Gr(`i`,{key:1,ref_key:`historyIconRef`,ref:s,class:be([`bkai-icon`,`bkai-history`,{disabled:!b.value}]),style:he(S()),onClick:n[4]||=e=>b.value?T(e):void 0},null,6)),[[V(a),{content:x(V(W9)(`历史会话`)),boundary:`parent`}]]):ti(`v-if`,!0),e.chatGroup?.enabled?Mn((H(),Gr(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:E},null,512)),[[V(a),{content:V(W9)(`转人工`),boundary:`parent`}]]):ti(`v-if`,!0),r.showCompressionIcon?Mn((H(),Gr(`i`,{key:3,class:be([`bkai-icon`,v.value]),onClick:n[5]||=e=>i(`toggle-compression`)},null,2)),[[V(a),{content:y.value,boundary:`parent`}]]):ti(`v-if`,!0),Mn(Xr(`i`,{class:`bkai-icon bkai-close-line-2`,onClick:n[6]||=e=>i(`close`)},null,512),[[V(a),{content:V(W9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-de3b1a3b`]]),wqt=class{_isGenerating;_isStopLoading;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r=null,i={}){this.agentModule=e,this.messageModule=t,this.sessionModule=n,this.eventEmitter=r,this.config=i,this._isGenerating=sn(!1),this._isStopLoading=sn(!1)}get isGenerating(){return this._isGenerating}get isStopLoading(){return this._isStopLoading}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=RKt(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==P9.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),s=i.property;this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,s),this.emit(`chat-regenerate`,{messageId:e}),l.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==P9.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let s=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),s.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}async stopGeneration(){let e=this.sessionModule?.current?.value?.sessionCode??``;this._isStopLoading.value=!0;try{await this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}finally{this._isStopLoading.value=!1}}},Tqt=class{agentModule;config;eventEmitter;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t=null,n=null,r={}){this.sessionModule=e,this.agentModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return await this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`}),this.sessionModule.current.value}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t);let n=this.agentModule?.info.value;n&&this.agentModule?.handleRole(n,t.sessionCode),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let n=t[0],r=(n.sessionContentCount??0)>0,i=e?.alwaysCreateNewSession??this.config.alwaysCreateNewSession??!1;r||i?await this.createNewSession():await this.switchSession(n.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},Eqt=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.map(e=>String(e.id))}}},Dqt=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,t=[]){this._propsShortcuts=sn(t),this._agentShortcuts=sn([]),this.eventEmitter=e,this._effectiveShortcuts=mi(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},Oqt=class{_isCompressed;_isDraggingOrResizing;_nimbusMinimized;_panelVisible;_positionAndSize;cleanupFunctions;config;containerRef=null;debugMode;listeners;onceListeners;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=sn(e.initialPanelVisible??!1),this._nimbusMinimized=sn(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=sn(!1),this._isCompressed=sn(!1),this._positionAndSize=sn({x:0,y:0,width:400,height:window.innerHeight})}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),expandForSidePanel:this.expandForSidePanel.bind(this),collapseSidePanel:this.collapseSidePanel.bind(this),positionAndSize:mi(()=>this.containerRef?.positionAndSize?.value??this._positionAndSize.value),isCompressed:mi(()=>this._isCompressed.value),isSidePanelExpanded:mi(()=>this.containerRef?.isSidePanelExpanded?.value??!1)}}get isCompressed(){return this._isCompressed}get isDraggingOrResizing(){return this._isDraggingOrResizing}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:mi(()=>this._nimbusMinimized.value)}}get nimbusMinimized(){return this._nimbusMinimized}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:mi(()=>this._panelVisible.value)}}get panelVisible(){return this._panelVisible}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}collapseSidePanel(){this.containerRef?.collapseSidePanel&&this.containerRef.collapseSidePanel()}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}expandForSidePanel(e){this.containerRef?.expandForSidePanel&&this.containerRef.expandForSidePanel(e)}getConfig(){return this.config}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}hasListeners(e){return this.listenerCount(e)>0}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}setCompressed(e){this._isCompressed.value=e}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setDebugMode(e){this.debugMode=e}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}};function kqt(e){return new Oqt(e)}var Aqt={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"side-panel-expand":null,"side-panel-collapse":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"new-chat-created":`new-chat-created`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function jqt(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:case`new-chat-created`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var Mqt=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=sn(new Set),this._isSelectionMode=sn(!1),this._editingSessionCode=sn(null),this._loadingStates=qt({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}},Nqt=class extends Error{constructor(){super(`[ChatBot] Initialization was superseded by a newer init`),this.name=`ChatBotInitStaleError`}};function Pqt(e){let{props:t,emit:n,scrollToBottom:r}=e,i=cn(null),a=cn(null),o=cn(null),s=cn(null),l=sn(!1),u=sn(!t.chatHelper),d=sn(null),f=mi(()=>l.value),p=()=>t.chatHelper?!t.chatHelper.agent||!t.chatHelper.session||!t.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:t.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},m=()=>{let e=p();if(!e.valid)return console.error(e.error),d.value=Error(e.error),null;if(t.chatHelper)return t.chatHelper;let i=new B9({onStart:()=>{n(`receive-start`)},onMessage:e=>{n(`receive-text`)},onDone:()=>{n(`receive-end`),r()},onError:e=>{n(`error`,e)}}),a=IKt({requestData:LKt(UKt(t.url),()=>un(t.requestOptions)),protocol:i});return i.injectMessageModule(a.message),a},h=async(e,t)=>{if(e)try{let n=e.session.current?.value?.sessionCode??``;await e.agent.stopChat(n),t&&e.agent.abortChat()}catch{}},g=0,_=null,v=null,y=null,b=e=>{y&&=(e?y.reject(e):y.resolve(),null),_=null},x=e=>{if(e!==g)throw new Nqt},S=async e=>{let r=i.value,f=u.value;l.value=!1,d.value=null,u.value=!t.chatHelper,await h(r,f),x(e),i.value=null,a.value=null,o.value=null,s.value=null;let p=m();if(!p)throw d.value??Error(`[ChatBot] Failed to create chatHelper`);let g=new Tqt(p.session,p.agent,null,{enableChatSession:!0,autoSwitchToInitialSession:!!t.sessionCode,loadRecentSessionOnMount:t.autoLoad,initialSessionCode:t.sessionCode,alwaysCreateNewSession:t.alwaysCreateNewSession}),_=new wqt(p.agent,p.message,p.session,null,{openingRemark:t.helloText,predefinedQuestions:t.prompts,placeholder:t.placeholder}),v=new Dqt(null,t.shortcuts||[]);i.value=p,a.value=g,o.value=_,s.value=v;try{u.value&&(await Promise.all([p.agent.getAgentInfo(),p.session.getSessions()]),x(e),await g.loadRecentSession({skipLoadSessions:!0}),x(e)),x(e),l.value=!0,n(`agent-info-loaded`,p)}catch(t){throw x(e),console.error(`Failed to initialize ChatBot:`,t),d.value=t,n(`error`,t),t}},C=()=>{b(new Nqt),v=null;let e=++g;_=new Promise((t,n)=>{y={resolve:t,reject:n},S(e).then(()=>{y&&=(v=Promise.resolve(),y.resolve(),null)}).catch(e=>{if(y){let t=e instanceof Error?e:Error(String(e));y.reject(t),y=null}}).finally(()=>{e===g&&(_=null)})}),_.catch(()=>{})};return Ln([()=>t.url,()=>t.chatHelper],()=>C(),{immediate:!0}),sr(()=>{b(),h(i.value,u.value)}),{chatHelper:i,isStandaloneMode:u,isInitialized:l,isReady:f,initError:d,whenReady:()=>l.value?(v||=Promise.resolve(),v):d.value?Promise.reject(d.value):_||Promise.resolve(),chatBusinessManager:o,sessionBusinessManager:a,shortcutManager:s}}function Fqt(e){let{props:t,chatHelper:n,chatBusinessManager:r,sessionBusinessManager:i,shortcutManager:a,isStandaloneMode:o,isInitialized:s,selectedShortcut:l}=e,u=mi(()=>r.value?.isStopLoading.value?zi.StopLoading:((t.chatHelper||n.value)?.agent)?.isChatting?.value?zi.Streaming:zi.Complete),d=mi(()=>u.value===zi.Streaming?Cp.Disabled:void 0),f=mi(()=>r.value?.messages.value??[]),p=mi(()=>r.value?.isMessagesLoading.value??!1);return{messageStatus:u,messageToolsStatus:d,messages:f,isMessagesLoading:p,isGenerating:mi(()=>r.value?.isGenerating.value??!1),currentSession:mi(()=>i.value?.currentSession.value??null),isWelcomeState:mi(()=>o.value&&!s.value?!1:!p.value&&f.value.length===0),openingRemark:mi(()=>n.value?.agent.info.value?.conversationSettings?.openingRemark||``),effectiveResources:mi(()=>t.resources?.length?t.resources:n.value?.agent.info.value?.resources??[]),effectivePrompts:mi(()=>t.prompts?.length?t.prompts:n.value?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),effectiveSupportUpload:mi(()=>l.value?.supportUpload?l.value.supportUpload.vision===!0:n.value?.agent.info.value?.promptSetting?.supportUpload?.vision===!0),chatbotStyle:mi(()=>({height:typeof t.height==`number`?`${t.height}px`:t.height,maxWidth:typeof t.maxWidth==`number`?`${t.maxWidth}px`:t.maxWidth})),filteredShortcuts:mi(()=>a.value?.shortcuts.value??[])}}function Iqt(e){let{emit:t,chatHelper:n,chatBusinessManager:r,selectedShortcut:i,selectedResources:a}=e,o=cn([[]]),s=cn(``),l=(e,t)=>{o.value=e,a.value=t},u=async(e,i={})=>{if(!r.value||!n.value)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let l=n.value.session.current?.value?.sessionCode;if(!l)throw Error(`[ChatBot] Cannot send message: no active session`);o.value=[[]],s.value=``,a.value=[],t(`send-message`,typeof e==`string`?e:``),await r.value.sendMessage(e,l,i)},d=async e=>{let t=n.value?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let r=await n.value.session.uploadFile(t,e);if(!r?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return r},f=async(e,n)=>{try{let t={};s.value&&(t.cite=s.value),i.value&&(t.command=i.value.id),a.value.length&&(t.resources=a.value),await u(e,Object.keys(t).length?{property:{extra:t}}:{})}catch(e){console.error(`Failed to send message:`,e),t(`error`,e)}},p=async()=>{await m()},m=async()=>{if(!r.value){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}await r.value.stopGeneration(),t(`stop`)};return{userInput:o,cite:s,handleUpdateModelValue:l,doSendMessage:u,handleSendMessage:f,handleUpload:d,handleStopSending:p,stopGeneration:m}}function Lqt(e){let{emit:t,chatHelper:n,isStandaloneMode:r}=e,i=async e=>{if(!(!n.value||e.length===0))try{await WKt((await new Eqt(n.value.message,n.value.session).shareMessages(e)).shareUrl),Af({message:`分享链接已复制到剪贴板`,theme:`success`})}catch(e){console.error(`[ChatBot] Failed to share messages:`,e),Af({message:`分享失败,请重试`,theme:`error`})}};return{handleConfirmShare:async e=>{r.value&&await i(e),t(`confirm-share`,e)}}}function Rqt(e){let{props:t,emit:n,shortcutManager:r,doSendMessage:i,selectedShortcut:a}=e,o=mi(()=>r.value?.effectiveShortcuts.value??[]),s=(e,t)=>{let n=e,r;if(r=n.enable_fill_back&&n.fill_back_component_key?n.fill_back_component_key:n.components?.find(e=>e.fillBack)?.key,r&&t){let e=n.components?.map(e=>e.key===r?{...e,default:t}:{...e,default:e.default??void 0});a.value={...n,components:e,formModel:{...n.formModel,[r]:t}}}else a.value={...n,formModel:{...n.formModel}}},l=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.alias||e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},u=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?o.value.find(e=>e.id===t.command)??null:null},d=(e,t)=>{s(e,t),n(`shortcut-click`,{shortcut:e,source:`main`})},f=()=>{a.value=null};return Ln(()=>t.shortcuts,e=>{r.value?.setShortcuts(e||[])},{immediate:!0}),Ln(()=>e.chatHelper.value?.agent.info.value?.conversationSettings?.commands,e=>{e&&r.value?.setAgentShortcuts(e)},{immediate:!0}),{effectiveShortcuts:o,selectShortcutWithText:s,buildShortcutProperty:l,getShortcutFromMessage:u,handleSelectShortcut:d,handleCloseShortcut:f,handleShortcutSubmit:async e=>{if(!a.value){console.error(`[ChatBot] No selected shortcut`);return}let t=l(a.value,e),r=a.value.name,o=a.value;f();try{await i(r,{property:t})}catch(e){a.value=o,console.error(`[ChatBot] Failed to submit shortcut:`,e),n(`error`,e)}},sendShortcutDirectly:async(e,t)=>{let r=e,a={...r.formModel},o=r.components||[];for(let e of o)e.key in a||(a[e.key]=e.default??``);let s;s=r.enable_fill_back&&r.fill_back_component_key?r.fill_back_component_key:o.find(e=>e.fillBack)?.key,s&&t&&(a[s]=t);let u=l(r,a),d=r.name;try{await i(d,{property:u})}catch(e){console.error(`[ChatBot] Failed to send shortcut directly:`,e),n(`error`,e)}}}}function zqt(e){let{emit:t,chatHelper:n,chatBusinessManager:r,cite:i,focusInput:a,scrollToBottom:o,getShortcutFromMessage:s,buildShortcutProperty:l}=e,u=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=r.value.messages.value,i=RKt(t,e[0]);if(!i){console.error(`[ChatBot] No user message found before AI messages`);return}let a=[i,...e];await n.value.message.deleteMessages(a)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),t(`error`,e)}},d=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let i=n.value.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await r.value.regenerateFromAIMessages(e,i),o()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),t(`error`,e)}},f=async e=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=r.value.messages.value,i=t.findIndex(t=>t===e);if(i===-1){console.error(`[ChatBot] User message not found in messages list`);return}let a=[];for(let e=i+1;e<t.length;e++){let n=t[e];if(n.role===Ri.User)break;a.push(n)}let o=[e,...a];await n.value.message.deleteMessages(o)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),t(`error`,e)}};return{handleAgentAction:async(e,t)=>{if(e.id===`cite`){i.value=t.filter(e=>e.role!==Ri.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
|
|
3502
|
+
`),a();return}if(e.id===`rebuild`){await d(t);return}if(e.id===`delete`){await u(t);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await n.value?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},handleAgentFeedback:async(e,i,a,o)=>{if(!n.value){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let s=n.value.session.current?.value?.sessionCode;if(!s){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let l=zKt(r.value?.messages.value||[],i[0]);if(l===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let u=e.id===`like`?5:0;try{await n.value.session.postSessionFeedback({sessionCode:s,sessionContentIds:[l],rate:u,labels:a,comment:o}),t(`feedback`,e,i[0],a,o)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),t(`error`,e)}},handleUserAction:async(e,t)=>{if(e.id===`delete`){await f(t);return}if(e.id===`cite`){i.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),a();return}console.log(`handleUserAction`,e,t)},handleUserInputConfirm:async(e,r,i)=>{if(!n.value){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let a=n.value.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot edit message: no active session`);return}let s=e.id;if(s===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,s,a,r),await n.value.agent.resendMessage(String(s),a,r),o()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),t(`error`,e)}},handleUserShortcutConfirm:async(e,i)=>{if(!r.value||!n.value){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let a=n.value.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let u=e.id;if(u===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let t=s(e);if(!t){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let n=l(t,i),d=String(i.input??``);await r.value.resendMessageWithProperty(String(u),a,d,n),o()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),t(`error`,e)}},handleStopStreaming:async()=>{if(!r.value){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}await r.value.stopGeneration(),t(`stop`)}}}var Bqt=Qn({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},alwaysCreateNewSession:{type:Boolean},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},renderMode:{default:Wi.Chat},extCls:{},height:{},helloText:{},maxWidth:{},messageToolsTippyOptions:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcuts:{default:()=>[]},url:{default:``},placement:{default:`left`},resizeProps:{},getSideRenderComponent:{},getSideTabRenderComponent:{},onCustomTabChange:{}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`execution-panel-change`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=_r(),o=sn(),s=sn(),l=sn(),u=cn([]),d=sn(null),f=mi({get:()=>r.renderMode??Wi.Chat,set:()=>{}}),p=async()=>{await En(),o.value&&(o.value.scrollTop=o.value.scrollHeight)},m=()=>{l.value?.focus?.()},{chatHelper:h,isStandaloneMode:g,isInitialized:_,isReady:v,initError:y,whenReady:b,chatBusinessManager:x,sessionBusinessManager:S,shortcutManager:C}=Pqt({props:r,emit:i,scrollToBottom:p}),{userInput:w,cite:T,handleUpdateModelValue:E,doSendMessage:D,handleSendMessage:O,handleUpload:k,handleStopSending:A,stopGeneration:j}=Iqt({emit:i,chatHelper:h,chatBusinessManager:x,selectedShortcut:d,selectedResources:u}),{handleSelectShortcut:M,handleCloseShortcut:N,handleShortcutSubmit:P,selectShortcutWithText:F,getShortcutFromMessage:I,buildShortcutProperty:L,sendShortcutDirectly:R}=Rqt({props:r,emit:i,chatHelper:h,shortcutManager:C,doSendMessage:D,selectedShortcut:d}),{messageStatus:ee,messageToolsStatus:te,messages:z,isMessagesLoading:B,isGenerating:ne,currentSession:re,isWelcomeState:ie,openingRemark:ae,effectiveResources:oe,effectivePrompts:se,effectiveSupportUpload:ce,chatbotStyle:le,filteredShortcuts:ue}=Fqt({props:r,chatHelper:h,chatBusinessManager:x,sessionBusinessManager:S,shortcutManager:C,isStandaloneMode:g,isInitialized:_,selectedShortcut:d}),{handleAgentAction:de,handleAgentFeedback:fe,handleUserAction:pe,handleUserInputConfirm:me,handleUserShortcutConfirm:ge,handleStopStreaming:_e}=zqt({emit:i,chatHelper:h,chatBusinessManager:x,cite:T,focusInput:m,scrollToBottom:p,getShortcutFromMessage:I,buildShortcutProperty:L}),ve=mi(()=>!_.value||B.value),{handleConfirmShare:ye}=Lqt({emit:i,chatHelper:h,isStandaloneMode:g}),Se=e=>{i(`execution-panel-change`,e)},Ce=async e=>{if(r.onCustomTabChange)return r.onCustomTabChange(e);let t=e.data?.props;if(t?.task_id!=null&&t?.node_id)return h.value?.message.getFlowAgentTaskNodeInfo(t.task_id,t.node_id)};return t({sendMessage:e=>O(e,[[]]),stopGeneration:j,switchSession:async e=>{if(!S.value){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await S.value.switchSession(e),i(`session-switched`,S.value.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),i(`error`,e)}},messages:z,currentSession:re,isGenerating:ne,isReady:v,whenReady:b,getChatHelper:()=>h.value,setCiteText:e=>{T.value=e},focusInput:m,enterShareMode:()=>s.value?.enterShareMode(),exitShareMode:()=>s.value?.exitShareMode(),selectShortcut:(e,t)=>{F(e,t)},sendShortcut:(e,t)=>R(e,t)}),(t,n)=>(H(),Gr(`div`,{class:be([`ai-chatbot`,r.extCls,{"welcome-state":V(ie)}]),style:he(V(le))},[Zr(V(oKt),{ref_key:`chatContainerRef`,ref:s,cite:V(T),"onUpdate:cite":n[0]||=e=>on(T)?T.value=e:null,"selected-shortcut":d.value,"onUpdate:selectedShortcut":n[1]||=e=>d.value=e,"render-mode":f.value,"onUpdate:renderMode":n[2]||=e=>f.value=e,"chat-loading":ve.value,"common-tippy-options":e.messageToolsTippyOptions,"message-status":V(ee),"message-tools-status":V(te),messages:V(z),"model-value":V(w),"on-agent-action":V(de),"on-agent-feedback":V(fe),"get-side-render-component":r.getSideRenderComponent,"get-side-tab-render-component":r.getSideTabRenderComponent,"on-custom-tab-change":Ce,"on-send-message":V(O),"on-stop-sending":V(A),"on-upload":V(k),"on-user-action":V(pe),"on-user-input-confirm":V(me),"on-user-shortcut-confirm":V(ge),"opening-remark":V(ae),placeholder:r.placeholder,placement:r.placement,prompts:V(se),"resize-props":r.resizeProps,resources:V(oe),"shortcut-id":d.value?.id,shortcuts:V(ue),"support-upload":V(ce),onCollapseChange:Se,onConfirmShare:V(ye),onDeleteShortcut:V(N),onSelectShortcut:V(M),onShortcutClose:V(N),onShortcutSubmit:V(P),onStopStreaming:V(_e),"onUpdate:modelValue":V(E)},{message:jn(({message:n,messageToolsStatus:r})=>[ti(` 消费方提供了 #message slot 时,优先使用消费方的渲染 `),V(a).message?pr(t.$slots,`message`,{key:0,message:n,messageToolsStatus:r}):(H(),Gr(Lr,{key:1},[ti(` 否则使用默认的 MessageRender `),Zr(V(jGt),{message:n,"message-tools-status":r,"on-action":e=>V(pe)(e,n),"on-input-confirm":(e,t)=>V(me)(n,e,t),"on-shortcut-confirm":e=>V(ge)(n,e),"tippy-options":e.messageToolsTippyOptions},fr({_:2},[t.$slots.codeHeader?{name:`codeHeader`,fn:jn(e=>[pr(t.$slots,`codeHeader`,xe(Qr(e)))]),key:`0`}:void 0]),1032,[`message`,`message-tools-status`,`on-action`,`on-input-confirm`,`on-shortcut-confirm`,`tippy-options`])],2112))]),_:3},8,`cite.selected-shortcut.render-mode.chat-loading.common-tippy-options.message-status.message-tools-status.messages.model-value.on-agent-action.on-agent-feedback.get-side-render-component.get-side-tab-render-component.on-send-message.on-stop-sending.on-upload.on-user-action.on-user-input-confirm.on-user-shortcut-confirm.opening-remark.placeholder.placement.prompts.resize-props.resources.shortcut-id.shortcuts.support-upload.onConfirmShare.onDeleteShortcut.onSelectShortcut.onShortcutClose.onShortcutSubmit.onStopStreaming.onUpdate:modelValue`.split(`.`))],6))}}),K9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Vqt(e){let{url:t,requestOptions:n,autoInit:r=!0,protocolCallbacks:i}=e,a=un(t);if(!a)throw Error(`[useChatBootstrap] url is required`);let o=sn(K9.IDLE),s=sn(null),l=sn(!1),u=new Map,d=new B9({onStart:()=>{i?.onStart?.()},onMessage:e=>{i?.onMessage?.(e)},onDone:()=>{i?.onDone?.()},onError:e=>{i?.onError?.(e)}}),f=IKt({requestData:LKt(a,n),protocol:d});d.injectMessageModule(f.message);let p=mi(()=>o.value===K9.LOADING_AGENT),m=mi(()=>o.value===K9.READY),h=mi(()=>f.agent.info.value??null),g=mi(()=>h.value?.agentName??``),_=mi(()=>f.session.current.value??null),v=mi(()=>f.session.list.value??[]),y=null,b=0,x=async e=>{s.value=null;try{if(o.value=K9.LOADING_AGENT,await Promise.all([f.agent.getAgentInfo(),f.session.getSessions()]),e!==b)return;o.value=K9.READY,l.value=!0}catch(t){if(e!==b)return;throw console.error(`[useChatBootstrap] Initialization failed:`,t),s.value=t,o.value=K9.ERROR,t}},S=async()=>{if(l.value)return;if(y)return y;let e=b;return y=x(e).finally(()=>{e===b&&(y=null)}),y},C=()=>{b+=1,o.value=K9.IDLE,s.value=null,l.value=!1,y=null},w=async()=>{C(),await S()},T=async e=>{C();let t=f.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await S()};return Ln(()=>un(t),(e,t)=>{e&&e!==t&&t&&T(e).catch(()=>{})}),r&&Promise.resolve().then(()=>{S().catch(()=>{})}),{chatHelper:f,protocol:d,phase:o,isInitializing:p,isReady:m,error:s,agentInfo:h,agentName:g,currentSession:_,sessionList:v,initialize:S,retry:w,updateConfig:T,registerExtension:(e,t)=>{u.set(e,t)},getExtension:e=>u.get(e)}}function Hqt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),newChatCreated:t=>e(`new-chat-created`,{session:t}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Uqt(e){let{componentManager:t,emit:n,debug:r=!1}=e,i=[],a=()=>{for(let[e,a]of Object.entries(Aqt)){if(a===null)continue;let o=t.on(e,t=>{let i=jqt(e,t);r&&console.debug(`[useEventBridge] ${e} -> ${a}`,i),n(a,...i)});i.push(o)}},o=(e,n)=>{r&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,n),t.emit(e,n)},s=(e,...t)=>{r&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),n(e,...t)},l=()=>{i.forEach(e=>e()),i.length=0};return a(),cr(()=>{l()}),{forwardToManager:o,emitDirect:s,cleanup:l}}function Wqt(e){let{props:t,emit:n}=e,r=sn(),i=sn(),a=mi(()=>UKt(t.url??``)),o=kqt({initialPanelVisible:!1,initialNimbusMinimized:t.defaultMinimize,enablePopup:t.enablePopup,enableNimbus:!t.hideNimbus,enableDraggable:t.draggable}),s=o.panelVisible,l=o.nimbusMinimized,{forwardToManager:u}=Uqt({componentManager:o,emit:n}),d=Hqt(u),f=(e,t)=>{let n=t instanceof Error?t.message:String(t);console.error(`[AIBlueking] ${e} error:`,t),o.emitInternal(`sdk-error`,{apiName:e,code:-1,message:n,data:t})},p=e=>{f(`chat`,e)},{chatHelper:m,isReady:h,error:g,agentInfo:_,agentName:v,currentSession:y,initialize:b}=Vqt({url:a,requestOptions:()=>un(t.requestOptions),autoInit:!0,protocolCallbacks:{onStart:()=>{d.receiveStart()},onMessage:()=>{d.receiveText()},onDone:()=>{d.receiveEnd()},onError:e=>{f(`chat`,e)}}}),x=m,S=new Tqt(x.session,x.agent,null,{enableChatSession:t.enableChatSession,initialSessionCode:t.initialSessionCode,alwaysCreateNewSession:t.alwaysCreateNewSession}),C=new Eqt(x.message,x.session),w=new Dqt(null,t.shortcuts||[]),T=null,E=()=>t.loadRecentSessionOnMount?(T||=S.loadRecentSession({skipLoadSessions:!0}).finally(()=>{T=null}),T):Promise.resolve(),D=async()=>{await b(),await E()},O={appendTo:e=>{let t=e.closest(`.draggable-container-content`);return console.log(`[ai-blueking] appendTo called, ref:`,e),console.log(`[ai-blueking] appendTo closest result:`,t),t??document.body}},k=mi(()=>o.isCompressed.value),A=mi(()=>v.value),j=mi(()=>x.message.list.value.length===0),M=mi(()=>t.resources?.length?t.resources:_.value?.resources??[]),N=mi(()=>t.prompts?.length?t.prompts:_.value?.conversationSettings?.predefinedQuestions??[]);Ln(()=>g.value,e=>{e&&f(`init`,e)}),Ln(()=>h.value,async e=>{if(e&&_.value){let e=_.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(u(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&w.setAgentShortcuts(e.conversationSettings.commands)),t.loadRecentSessionOnMount)try{await E()}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),Ln(()=>t.shortcuts,e=>{w.setShortcuts(e||[])},{immediate:!0});let P=e=>{JKt(e)&&(e.preventDefault(),s.value?o.hidePanel():o.showPanel())};return or(async()=>{r.value&&o.setContainerRef(r.value),window.addEventListener(`keydown`,P)}),sr(()=>{window.removeEventListener(`keydown`,P),o.destroy()}),{chatHelper:x,componentManager:o,sessionBusinessManager:S,shareBusinessManager:C,shortcutManager:w,forwarders:d,forwardToManager:u,chatBotRef:i,draggableContainerRef:r,panelVisible:s,nimbusMinimized:l,normalizedUrl:a,agentInfo:_,agentName:A,currentSession:y,isCompressed:k,isWelcomeState:j,messageToolsTippyOptions:O,agentResources:M,agentPrompts:N,handleError:p,ensureSessionReady:D}}function Gqt(e){let{shortcutManager:t,chatBotRef:n,forwardToManager:r,show:i,props:a}=e,o=sn(!1),s=sn(``);return{aiSelectionVisible:o,selectedText:s,filteredPopupShortcuts:mi(()=>{let e=t.effectiveShortcuts.value;return typeof a.shortcutFilter==`function`&&s.value?e.filter(e=>a.shortcutFilter?.(e,s.value)):e}),handleSelectionChange:e=>{s.value=e},handleAiSelectionShortcut:async(e,t)=>{o.value=!1,await i(),n.value&&(e.components?.length?n.value.selectShortcut(e,t):(n.value.selectShortcut(e),n.value.setCiteText(t),n.value.focusInput())),r(`shortcut-click`,{shortcut:e,source:`popup`})}}}function Kqt(e,t=!1){let n=window.innerHeight-48-40,r=window.innerWidth-48-16,i=sn(r),a=sn(n),o=sn(0),s=sn(t),l=sn(!1),u=sn(!1),d=0,f=e=>{e?i.value=window.innerWidth-12:i.value=r},p=(e,t)=>{a.value=t,o.value=t-n},m=()=>{En(()=>{a.value=window.innerHeight-48-40+o.value,s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-48-16})};return or(()=>{window.addEventListener(`resize`,m),m()}),cr(()=>{window.removeEventListener(`resize`,m)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:i,nimbusTop:a,isMinimize:s,isHovering:l,isDragging:u,handleNimbusDragging:p,handleNimbusMinimize:f,handleClick:()=>{if(u.value){u.value=!1;return}e(`click`)},handleMinimize:()=>{s.value=!s.value,e(`minimize`,s.value),s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-60},handleDragging:(e,t)=>{i.value=e,a.value=t},handleMouseEnter:()=>{l.value=!0},handleMouseLeave:()=>{l.value=!1},handleMouseDown:()=>{d=Date.now(),u.value=!1},handleMouseUp:()=>{Date.now()-d>200&&(u.value=!0)}}}var qqt=420;function Jqt(e){let{componentManager:t,chatBotRef:n,forwarders:r,forwardToManager:i,beforeNimbusClick:a,ensureSessionReady:o}=e,s=async e=>{t.showPanel(e),o&&await o(),e&&n.value&&await n.value.switchSession(e)},l=async e=>{await s(e)},u=()=>{t.hidePanel()};return{show:s,handleShow:l,hide:u,handleClose:()=>{u()},handleNimbusClick:async()=>{if(a&&await a()===!1){t.emit(`nimbus-click`,{});return}t.handleNimbusClick()},handleDragging:e=>{t.handleDragging(e)},handleResizing:e=>{t.handleResizing(e)},handleDragStop:e=>{t.handleDragStop(e)},handleResizeStop:e=>{t.handleResizeStop(e)},handleToggleCompression:()=>{t.container.toggleCompression()},handleCompressionChange:e=>{t.setCompressed(e)},handleExecutionPanelChange:e=>{e?t.collapseSidePanel():t.expandForSidePanel(qqt)},sendMessage:async e=>{n.value&&await n.value.sendMessage(e)},handleReceiveStart:()=>{r.receiveStart()},handleReceiveText:()=>{r.receiveText()},handleReceiveEnd:()=>{r.receiveEnd()},handleStop:()=>{r.stop()},stopGeneration:()=>{n.value&&n.value.stopGeneration()},updatePosition:(e,n)=>{t.container.updatePosition(e,n)},updateSize:(e,n)=>{t.container.updateSize(e,n)},updatePositionAndSize:(e,n,r,i)=>{t.container.updatePositionAndSize(e,n,r,i)},setCiteText:e=>{n.value&&n.value.setCiteText(e)},focusInput:()=>{n.value&&n.value.focusInput()},selectShortcut:(e,t)=>{n.value&&n.value.selectShortcut(e,t)},sendShortcut:(e,t)=>n.value?n.value.sendShortcut(e,t):Promise.resolve(),getChatHelper:()=>n.value?n.value.getChatHelper():null,handleShortcutClick:e=>{i(`shortcut-click`,e)}}}function Yqt(e){let{chatHelper:t,sessionBusinessManager:n,chatBotRef:r,forwarders:i,handleError:a,currentSession:o}=e,s=sn(``),l=sn(!0),u=sn(!1),d=sn(!1),f=()=>t.message.list.value.some(e=>{if(!(`property`in e))return!0;let{property:t}=e;return!t?.extra?.pause});return Ln(()=>o.value,e=>{e&&(s.value=e.sessionName||``,u.value=(e.sessionContentCount??0)>0||f())},{immediate:!0}),Ln(()=>t.message.list.value.length,()=>{u.value=f()}),{sessionName:s,hasPermission:l,hasSessionContents:u,autoGenerateLoading:d,handleNewChat:async()=>{r.value?.exitShareMode(),i.newChat()},handleNewChatCreated:e=>{i.newChatCreated(e)},handleHistoryClick:e=>{i.historyClick(e)},handleHistorySessionSwitch:async e=>{r.value?.exitShareMode(),await n.switchSession(e)},handleHistorySessionDelete:async e=>{await n.deleteSession(e)},handleHistorySessionRename:async(e,t)=>{await n.updateSessionName(e,t)},handleAutoGenerateName:async()=>{let e=t.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}d.value=!0;try{await t.session.renameSession(e);let n=t.session.list.value.find(t=>t.sessionCode===e);n&&(s.value=n.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),a(e)}finally{d.value=!1}i.autoGenerateName()},handleHelpClick:()=>{i.helpClick()},handleRename:async e=>{let n=t.session.current?.value;if(!n){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await t.session.updateSession({...n,sessionName:e}),s.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),a(e)}i.rename(e)},handleSessionSwitched:e=>{e&&(s.value=e.sessionName||``,u.value=(e.sessionContentCount??0)>0||f())},addNewSession:async e=>{e?await n.createSession(e):await n.createNewSession()},switchToSession:async e=>{r.value&&await r.value.switchSession(e)},updateSessionName:async(e,t)=>{try{await n.updateSessionName(e,t),s.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),a(e)}}}}function Xqt(e){let{shareBusinessManager:t,chatBotRef:n,forwarders:r,handleError:i}=e,a=sn(!1);return{isShareLoading:a,handleShare:()=>{n.value?.enterShareMode(),r.share()},handleCancelShare:()=>{n.value?.exitShareMode()},handleConfirmShare:async e=>{a.value=!0;try{let{shareUrl:i,userMessageIds:a}=await t.shareMessages(e);await WKt(i),Af({message:W9(`分享链接已复制到剪贴板`),theme:`success`}),n.value?.exitShareMode(),r.shareMessages(a)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),i(e)}finally{a.value=!1}}}}function Zqt(e={}){let t=sn([]),n=(n,r,i={})=>{try{let a=typeof n==`string`?document.querySelector(n):n;if(!a)return console.warn(`Tooltip target not found: ${n}`),null;let o=xp(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return t.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},r=(e,t,r={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=n(e,t,r);i&&a.push(i)}),a},i=e=>{let t=[];return e.forEach(({element:e,content:r,options:i})=>{let a=n(e,r,i);a&&t.push(a)}),t},a=()=>{t.value.forEach(e=>{e.destroy()}),t.value=[]};return sr(()=>{a()}),{instances:t,createTooltip:n,createTooltipsForSelector:r,createMultipleTooltips:i,destroyAll:a,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}var Qqt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,renderMode:Wi.Chat,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:void 0,helloText:W9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,alwaysCreateNewSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0},$qt=class extends B9{eventEmitter;constructor(e={}){super({onStart:e.onStart,onMessage:e.onMessage,onDone:e.onDone,onError:e.onError}),this.eventEmitter=e.eventEmitter}handleRunErrorEvent(e){super.handleRunErrorEvent(e),this.eventEmitter?.emit(`run-error`,{event:e})}handleTextMessageChunkEvent(e){super.handleTextMessageChunkEvent(e),this.eventEmitter?.emit(`text-chunk`,{event:e})}handleThinkingEndEvent(e){super.handleThinkingEndEvent(e),this.eventEmitter?.emit(`thinking-end`,{event:e})}handleThinkingStartEvent(e){super.handleThinkingStartEvent(e),this.eventEmitter?.emit(`thinking-start`,{event:e})}handleToolCallEndEvent(e){super.handleToolCallEndEvent(e),this.eventEmitter?.emit(`tool-call-end`,{event:e})}handleToolCallStartEvent(e){super.handleToolCallStartEvent(e),this.eventEmitter?.emit(`tool-call-start`,{event:e})}};function eJt(e={}){let{eventEmitter:t,onStart:n,onMessage:r,onDone:i,onError:a,onTextChunk:o}=e;return new B9({onStart:()=>{t?.emit(`receive-start`,{}),n?.()},onMessage:e=>{t?.emit(`receive-message`,{event:e}),e.type===`TextMessageChunk`&&o&&o(e),r?.(e)},onDone:()=>{t?.emit(`receive-end`,{}),i?.()},onError:e=>{t?.emit(`receive-error`,{error:e}),a?.(e)}})}function tJt(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function q9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function nJt(e,t,n){return e-t-n}function rJt(e,t,n){return e-t-n}function J9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function iJt(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>tJt(r[e]));if(!tJt(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function aJt(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function Y9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function X9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var oJt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Z9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},sJt={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},cJt={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},Q9=Z9.mouse,lJt={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=aJt(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),Y9(document.documentElement,`mousedown`,this.deselect),Y9(document.documentElement,`touchend touchcancel`,this.deselect),Y9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){X9(document.documentElement,`mousedown`,this.deselect),X9(document.documentElement,`touchstart`,this.handleUp),X9(document.documentElement,`mousemove`,this.move),X9(document.documentElement,`touchmove`,this.move),X9(document.documentElement,`mouseup`,this.handleUp),X9(document.documentElement,`touchend touchcancel`,this.deselect),X9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){Q9=Z9.touch,this.elementDown(e)},elementMouseDown(e){Q9=Z9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!iJt(t,this.dragHandle,this.$el)||this.dragCancel&&iJt(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),Y9(document.documentElement,Q9.move,this.move),Y9(document.documentElement,Q9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),X9(document.documentElement,Q9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){Q9=Z9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),Y9(document.documentElement,Q9.move,this.handleResize),Y9(document.documentElement,Q9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=q9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=J9(i.left-a,r.minLeft,r.maxLeft),l=J9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=J9(i.right+a,r.minRight,r.maxRight),d=J9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=q9(this.grid,e,this.top,1),r=J9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=q9(this.grid,this.left,e,1),r=J9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=q9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=J9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=J9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=J9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=J9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=nJt(this.parentWidth,t,r),p=rJt(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=q9(this.grid,e,0,1),r=J9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=nJt(this.parentWidth,this.left,r),o=rJt(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=q9(this.grid,0,e,1),r=J9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=nJt(this.parentWidth,this.left,i),o=rJt(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),X9(document.documentElement,Q9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?sJt:cJt}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},uJt=[`onMousedown`,`onTouchstart`];function dJt(e,t,n,r,i,a){return H(),Gr(`div`,{style:he(a.style),class:be([{[n.classNameActive]:e.enabled,[n.classNameDragging]:e.dragging,[n.classNameResizing]:e.resizing,[n.classNameDraggable]:n.draggable,[n.classNameResizable]:n.resizable},n.className]),onMousedown:t[0]||=(...e)=>a.elementMouseDown&&a.elementMouseDown(...e),onTouchstart:t[1]||=(...e)=>a.elementTouchDown&&a.elementTouchDown(...e)},[(H(!0),Gr(Lr,null,dr(a.actualHandles,t=>(H(),Gr(`div`,{key:t,class:be([n.classNameHandle,n.classNameHandle+`-`+t]),style:he({display:e.enabled?`block`:`none`}),onMousedown:Pi(e=>a.handleDown(t,e),[`stop`,`prevent`]),onTouchstart:Pi(e=>a.handleTouchDown(t,e),[`stop`,`prevent`])},[pr(e.$slots,t)],46,uJt))),128)),pr(e.$slots,`default`)],38)}var fJt=oJt(lJt,[[`render`,dJt]]);function pJt(e){pJt.installed||(pJt.installed=!0,e.component(`VueDraggableResizable`,fJt))}var mJt={install:pJt},$9=null;typeof window<`u`?$9=window.Vue:typeof global<`u`&&($9=global.Vue),$9&&$9.use(mJt);function hJt(e={},t){let n=e.initWidth||400,r=e.minWidth||400,i=e.minHeight||400,a=e.maxWidthPercent||40,o=e.compressedHeight||800,s=e.compressedPadding===void 0?0:e.compressedPadding,l=sn(e.defaultLeft===void 0?window.innerWidth-n:e.defaultLeft),u=sn(e.defaultTop===void 0?0:e.defaultTop),d=sn(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),f=sn(n),p=sn(u.value),m=sn(l.value),h=sn(f.value),g=sn(d.value),_=sn(Math.max(window.innerWidth*(a/100),h.value)),v=sn(!1),y=sn(0),b=null,x=null,S=sn(!1),C=e=>{let t=window.innerWidth,n={...e};return n.width>t&&(n.width=t),n.x+n.width>t&&(n.x=t-n.width),n.x<0&&(n.x=0),n},w=()=>({x:m.value,y:p.value,width:h.value,height:g.value}),T=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),t?.onDragging?.(w())},E=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,t?.onResizing?.(w())},D=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),S.value&&(x=w()),t?.onDragStop?.(w())},O=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,S.value&&(x=w()),t?.onResizeStop?.(w())},k=()=>{_.value=Math.max(window.innerWidth*(a/100),h.value),En(()=>{if(v.value)m.value=window.innerWidth-h.value-s,p.value=window.innerHeight-o-s;else{let e=window.innerWidth-h.value-y.value;m.value=Math.max(0,e),setTimeout(()=>{g.value=window.innerHeight-p.value},0)}h.value>_.value&&(h.value=_.value)})},A=()=>{v.value?(p.value=u.value,En(()=>{g.value=d.value,m.value=l.value,h.value=f.value})):(p.value=window.innerHeight-o-s,m.value=l.value-s,h.value=n,g.value=o),v.value=!v.value},j=(e,t)=>{m.value=e,p.value=t,y.value=e-(window.innerWidth-h.value)},M=(e,t)=>{h.value=Math.max(r,Math.min(e,_.value)),g.value=Math.max(i,t)};return or(()=>{window.addEventListener(`resize`,k)}),sr(()=>{window.removeEventListener(`resize`,k)}),{minWidth:r,minHeight:i,maxWidth:_,top:p,left:m,width:h,height:g,isCompressed:v,isSidePanelExpanded:S,handleDragging:T,handleResizing:E,handleDragStop:D,handleResizeStop:O,toggleCompression:A,updatePosition:j,updateSize:M,updatePositionAndSize:(e,t,n,r)=>{j(e,t),M(n,r)},expandForSidePanel:e=>{if(S.value)return;let t=w();b={...t},S.value=!0;let n=t.x+t.width,r=x?.width??t.width+e,i=C({x:n-r,y:t.y,width:r,height:t.height});j(i.x,i.y),En(()=>{M(i.width,i.height)})},collapseSidePanel:()=>{if(!S.value)return;let e=w();x={...e},S.value=!1;let t=e.x+e.width,n=b?.width??e.width,r=C({x:t-n,y:e.y,width:n,height:e.height});M(r.width,r.height),En(()=>{j(r.x,r.y)})}}}var gJt={class:`draggable-container-content`},_Jt=G9(Qn({__name:`draggable-container`,props:{className:{default:``},compressedHeight:{default:800},compressedPadding:{default:0},defaultHeight:{default:void 0},defaultWidth:{default:400},defaultX:{default:void 0},defaultY:{default:0},draggable:{type:Boolean,default:!0},dragHandle:{default:`.drag-handle`},maxWidth:{default:void 0},maxWidthPercent:{default:80},minHeight:{default:400},minWidth:{default:400},resizable:{type:Boolean,default:!0},teleportTo:{default:`body`},visible:{type:Boolean,default:!1}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=sn(!1),{minWidth:o,minHeight:s,maxWidth:l,top:u,left:d,width:f,height:p,isCompressed:m,isSidePanelExpanded:h,handleDragging:g,handleResizing:_,handleDragStop:v,handleResizeStop:y,toggleCompression:b,updatePosition:x,updateSize:S,updatePositionAndSize:C,expandForSidePanel:w,collapseSidePanel:T}=hJt({initWidth:r.defaultWidth,minWidth:r.minWidth,minHeight:r.minHeight,maxWidthPercent:r.maxWidthPercent,compressedHeight:r.compressedHeight,defaultHeight:r.defaultHeight,defaultTop:r.defaultY,defaultLeft:r.defaultX,compressedPadding:r.compressedPadding},{onDragStop:e=>i(`drag-stop`,e),onResizeStop:e=>i(`resize-stop`,e),onDragging:e=>i(`dragging`,e),onResizing:e=>i(`resizing`,e)}),E=mi(()=>({"--draggable-max-width":typeof r.maxWidth==`number`?`${r.maxWidth}px`:r.maxWidth??`${l.value}px`})),D=mi(()=>({x:d.value,y:u.value,width:f.value,height:p.value})),O=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},k=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},A=(e,t)=>{a.value||(a.value=!0,O()),g(e,t)},j=(e,t,n,r)=>{a.value||(a.value=!0,O()),_(e,t,n,r)},M=(e,t)=>{v(e,t),a.value=!1,k()},N=(e,t,n,r)=>{y(e,t,n,r),a.value=!1,k()};return Ln(m,e=>{i(`compression-change`,e)}),t({updatePosition:x,updateSize:S,updatePositionAndSize:C,toggleCompression:b,expandForSidePanel:w,collapseSidePanel:T,positionAndSize:D,isCompressed:m,isSidePanelExpanded:h}),(e,t)=>Mn((H(),Kr(V(fJt),{ref:`draggableRef`,active:r.visible,class:be([`draggable-container-wrapper`,r.className]),"class-name":`draggable-container-inner`,"drag-handle":r.dragHandle,draggable:r.draggable,h:V(p),"max-width":V(l),"min-height":V(s),"min-width":V(o),parent:!0,"prevent-deactivation":!0,resizable:r.resizable,style:he(E.value),w:V(f),x:V(d),y:V(u),onDragStop:M,onDragging:A,onResizeStop:N,onResizing:j},{default:jn(()=>[Xr(`div`,gJt,[pr(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`active`,`class`,`drag-handle`,`draggable`,`h`,`max-width`,`min-height`,`min-width`,`resizable`,`style`,`w`,`x`,`y`])),[[Ei,r.visible]])}}),[[`__scopeId`,`data-v-1118456b`]]),vJt={class:`nimbus-bkai-wrapper`},yJt=[`width`,`height`,`src`],bJt=G9(Qn({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:t}){Kne(e=>({v05a8b16e:`${a.value.container}px`,v4e1cf4ca:`${a.value.wrapper}px`,v5ab0c513:`${a.value.mini.right}px`,v40c13a80:`${a.value.mini.size}px`,v0d35a9ef:`${a.value.mini.fontSize}px`}));let n=e,r=t,i={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},a=mi(()=>i[n.size]),o=sn(null),s=sn(null),{nimbusLeft:l,nimbusTop:u,isMinimize:d,handleClick:f,handleMinimize:p,handleDragging:m,handleMouseEnter:h,handleMouseLeave:g,handleMouseDown:_,handleMouseUp:v}=Kqt(r,n.isMinimize);Ln(d,e=>{r(`update:isMinimize`,e)});let y=mi(()=>d.value?W9(`恢复默认大小`):W9(`最小化,将缩成锚点`)),{createTooltip:b,destroyAll:x}=Zqt({theme:`ai-blueking`,delay:[0,0]}),S=()=>{En(()=>{C()})},C=()=>{x(),o.value&&!d.value&&b(o.value,KKt(),{placement:`left`}),s.value&&b(s.value,y.value,{placement:`top`})};return Ln(()=>d.value,()=>{En(()=>{C()})}),or(()=>{En(()=>{C()}),window.addEventListener(`resize`,S)}),sr(()=>{window.removeEventListener(`resize`,S)}),(t,n)=>(H(),Kr(V(fJt),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:a.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:a.value.container,x:V(l),y:V(u),onDragging:V(m)},{default:jn(()=>[Xr(`div`,{ref_key:`nimbusContainerRef`,ref:o,class:be([`nimbus-container`,{"is-minimize":V(d)}]),onClick:n[1]||=(...e)=>V(f)&&V(f)(...e),onMousedown:n[2]||=(...e)=>V(_)&&V(_)(...e),onMouseenter:n[3]||=(...e)=>V(h)&&V(h)(...e),onMouseleave:n[4]||=(...e)=>V(g)&&V(g)(...e),onMouseup:n[5]||=(...e)=>V(v)&&V(v)(...e)},[Xr(`div`,vJt,[Xr(`img`,{width:a.value.img,height:a.value.img,src:V(sKt),alt:`nimbus`},null,8,yJt)]),Xr(`i`,{ref_key:`minimizeButtonRef`,ref:s,class:be([`nimbus-mini bkai-icon`,V(d)?`bkai-yinyong`:`bkai-minus-line`]),onClick:n[0]||=Pi((...e)=>V(p)&&V(p)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),xJt=G9(Qn({__name:`ai-blueking`,props:fte({autoSwitchToInitialSession:{type:Boolean},alwaysCreateNewSession:{type:Boolean},beforeNimbusClick:{type:Function},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},renderMode:{},shortcutFilter:{type:Function},resizeProps:{},getSideRenderComponent:{type:Function},getSideTabRenderComponent:{type:Function},onCustomTabChange:{type:Function}},Qqt),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`new-chat-created`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:t,emit:n}){let r=e,{chatHelper:i,componentManager:a,sessionBusinessManager:o,shareBusinessManager:s,shortcutManager:l,forwarders:u,forwardToManager:d,chatBotRef:f,draggableContainerRef:p,panelVisible:m,nimbusMinimized:h,normalizedUrl:g,agentName:_,currentSession:v,isCompressed:y,isWelcomeState:b,messageToolsTippyOptions:x,agentResources:S,agentPrompts:C,handleError:w,ensureSessionReady:T}=Wqt({props:r,emit:n}),{show:E,hide:D,handleShow:O,handleClose:k,handleNimbusClick:A,handleDragging:j,handleResizing:M,handleDragStop:N,handleResizeStop:P,handleToggleCompression:F,handleCompressionChange:I,handleExecutionPanelChange:L,sendMessage:R,handleReceiveStart:ee,handleReceiveText:te,handleReceiveEnd:z,handleStop:B,stopGeneration:ne,setCiteText:re,focusInput:ie,selectShortcut:ae,sendShortcut:oe,getChatHelper:se,updatePosition:ce,updateSize:le,updatePositionAndSize:ue,handleShortcutClick:de}=Jqt({componentManager:a,chatBotRef:f,forwarders:u,forwardToManager:d,beforeNimbusClick:r.beforeNimbusClick,ensureSessionReady:T}),{sessionName:fe,hasPermission:pe,hasSessionContents:me,autoGenerateLoading:ge,handleNewChat:_e,handleNewChatCreated:ve,handleHistoryClick:ye,handleHistorySessionSwitch:Se,handleHistorySessionDelete:Ce,handleHistorySessionRename:we,handleAutoGenerateName:Te,handleHelpClick:Ee,handleRename:De,handleSessionSwitched:Oe,addNewSession:ke,switchToSession:Ae,updateSessionName:je}=Yqt({chatHelper:i,sessionBusinessManager:o,chatBotRef:f,forwarders:u,handleError:w,currentSession:v}),{isShareLoading:Me,handleShare:Ne,handleCancelShare:Pe,handleConfirmShare:Fe}=Xqt({shareBusinessManager:s,chatBotRef:f,forwarders:u,handleError:w}),{aiSelectionVisible:Ie,filteredPopupShortcuts:Le,handleSelectionChange:Re,handleAiSelectionShortcut:ze}=Gqt({shortcutManager:l,chatBotRef:f,forwardToManager:d,show:E,props:r}),Be=e=>{me.value=!0,u.sendMessage(e)};return t({show:E,handleShow:O,handleClose:k,hide:D,sendMessage:R,selectShortcut:ae,sendShortcut:oe,getChatHelper:se,stopGeneration:ne,addNewSession:ke,switchToSession:Ae,updateSessionName:je,updatePosition:ce,updateSize:le,updatePositionAndSize:ue,setCiteText:re,focusInput:ie}),(e,t)=>(H(),Kr(Un,{to:r.teleportTo},[Xr(`div`,{class:be([`ai-blueking-v2`,r.extCls])},[ti(` 可拖拽容器 `),Zr(V(_Jt),{ref_key:`draggableContainerRef`,ref:p,"compressed-padding":r.miniPadding,"default-height":r.defaultHeight,"default-width":r.defaultWidth,"default-x":r.defaultLeft,"default-y":r.defaultTop,"drag-handle":`.drag-handle`,draggable:r.draggable,"max-width":r.maxWidth,"max-width-percent":80,visible:V(m),onCompressionChange:V(I),onDragStop:V(N),onDragging:V(j),onResizeStop:V(P),onResizing:V(M)},{default:jn(()=>[Xr(`div`,{class:be([`ai-blueking-panel`,{"has-messages":!V(b)}])},[ti(` 独立的 Header 组件 `),r.hideHeader?ti(`v-if`,!0):(H(),Kr(Cqt,{key:0,"agent-name":V(_),"chat-helper":V(i),draggable:r.draggable,"dropdown-menu-config":r.dropdownMenuConfig,"enable-chat-session":r.enableChatSession,"has-permission":V(pe),"has-session-contents":V(me),"auto-generate-loading":V(ge),"is-compression-height":V(y),"render-mode":r.renderMode,"session-business-manager":V(o),"session-name":V(fe),"show-compression-icon":r.showCompressionIcon,"show-history-icon":r.showHistoryIcon,"show-more-icon":r.showMoreIcon,"show-new-chat-icon":r.showNewChatIcon,title:r.title,onAutoGenerateName:V(Te),onClose:V(k),onHelpClick:V(Ee),onHistoryClick:V(ye),onHistorySessionDelete:V(Ce),onHistorySessionRename:V(we),onHistorySessionSwitch:V(Se),onNewChat:V(_e),onNewChatCreated:V(ve),onRename:V(De),onShare:V(Ne),onToggleCompression:V(F)},fr({_:2},[e.$slots.headerLeft?{name:`headerLeft`,fn:jn(()=>[pr(e.$slots,`headerLeft`,{},void 0,!0)]),key:`0`}:void 0]),1032,`agent-name.chat-helper.draggable.dropdown-menu-config.enable-chat-session.has-permission.has-session-contents.auto-generate-loading.is-compression-height.render-mode.session-business-manager.session-name.show-compression-icon.show-history-icon.show-more-icon.show-new-chat-icon.title.onAutoGenerateName.onClose.onHelpClick.onHistoryClick.onHistorySessionDelete.onHistorySessionRename.onHistorySessionSwitch.onNewChat.onNewChatCreated.onRename.onShare.onToggleCompression`.split(`.`))),ti(` ChatBot 核心组件(仅聊天区域) `),Zr(Bqt,{ref_key:`chatBotRef`,ref:f,"always-create-new-session":r.alwaysCreateNewSession,"auto-load":r.loadRecentSessionOnMount,"chat-helper":V(i),"hello-text":r.helloText,"message-tools-tippy-options":V(x),placeholder:r.placeholder,prompts:V(C),"render-mode":r.renderMode,"request-options":r.requestOptions,"get-side-render-component":r.getSideRenderComponent,"get-side-tab-render-component":r.getSideTabRenderComponent,"on-custom-tab-change":r.onCustomTabChange,"resize-props":r.resizeProps,resources:V(S),"session-code":r.initialSessionCode,"share-loading":V(Me),shortcuts:r.shortcuts,style:he({height:r.hideHeader?`100%`:`calc(100% - 48px)`}),url:V(g),onCancelShare:V(Pe),onConfirmShare:t[0]||=e=>V(Fe)(e),onError:t[1]||=e=>V(w)(e),onExecutionPanelChange:V(L),onReceiveEnd:V(z),onReceiveStart:V(ee),onReceiveText:V(te),onRequestShare:V(Ne),onSendMessage:t[2]||=e=>Be(e),onSessionSwitched:t[3]||=e=>V(Oe)(e),onShortcutClick:V(de),onStop:V(B)},fr({_:2},[e.$slots.codeHeader?{name:`codeHeader`,fn:jn(t=>[pr(e.$slots,`codeHeader`,xe(Qr(t)),void 0,!0)]),key:`0`}:void 0,e.$slots.message?{name:`message`,fn:jn(t=>[pr(e.$slots,`message`,xe(Qr(t)),void 0,!0)]),key:`1`}:void 0]),1032,`always-create-new-session.auto-load.chat-helper.hello-text.message-tools-tippy-options.placeholder.prompts.render-mode.request-options.get-side-render-component.get-side-tab-render-component.on-custom-tab-change.resize-props.resources.session-code.share-loading.shortcuts.style.url.onCancelShare.onExecutionPanelChange.onReceiveEnd.onReceiveStart.onReceiveText.onRequestShare.onShortcutClick.onStop`.split(`.`))],2)]),_:3},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`,`onCompressionChange`,`onDragStop`,`onDragging`,`onResizeStop`,`onResizing`]),ti(` Nimbus 悬浮球 `),r.hideNimbus?ti(`v-if`,!0):(H(),Kr(bJt,{key:0,"is-minimize":V(h),"onUpdate:isMinimize":t[4]||=e=>on(h)?h.value=e:null,"is-panel-show":V(m),"onUpdate:isPanelShow":t[5]||=e=>on(m)?m.value=e:null,"default-minimize":r.defaultMinimize,size:r.nimbusSize,onClick:V(A)},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`,`onClick`])),ti(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),r.enablePopup?(H(),Kr(V(Yoe),{key:1,visible:V(Ie),"onUpdate:visible":t[6]||=e=>on(Ie)?Ie.value=e:null,"exclude-selectors":[`.draggable-container-wrapper`],"max-shortcut-count":r.shortcutLimit,shortcuts:V(Le),onSelectShortcut:V(ze),onSelectionChange:V(Re)},null,8,[`visible`,`max-shortcut-count`,`shortcuts`,`onSelectShortcut`,`onSelectionChange`])):ti(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-f367dd3f`]]);function SJt(e){return`on`+e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function CJt(){return`bk`}function wJt(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`[ai-blueking] mount container not found: ${e}`);return t}function TJt(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){if(!r)continue;let e=n.startsWith(`on`)&&n.length>2?n:SJt(n);t[e]=r}return t}function EJt(e,t,n){let r=wJt(e),i=Jt({...n?.props??{}}),a=null,o=Ii({setup(){return()=>U(Hfe,{prefix:CJt()},{default:()=>U(t,{...i,...TJt(n?.on),ref:e=>{a=e}})})}});return o.mount(r),{app:o,getExpose:()=>a,get expose(){return a},updateProps(e){Object.assign(i,e)},unmount(){o.unmount(),a=null}}}function DJt(e,t){return EJt(e,xJt,t)}function OJt(e,t){return EJt(e,Bqt,t)}e.AGUIProtocol=B9,e.AIBlueking=xJt,e.BluekingProtocol=$qt,e.BootstrapPhase=K9,e.ChatBot=Bqt,e.ChatBusinessManager=wqt,e.ComponentManager=Oqt,e.DraggableContainer=_Jt,e.MessageContentType=Li,e.RenderMode=Wi,e.SessionBusinessManager=Tqt,e.ShortcutManager=Dqt,e.UIStateManager=Mqt,e.buildStandaloneListeners=TJt,e.createApp=Ii,e.createBluekingProtocol=eJt,e.createComponentManager=kqt,e.defaultProps=Qqt,e.h=U,e.mountAIBlueking=DJt,e.mountChatBot=OJt,e.mountStandaloneComponent=EJt,e.parseCustomBlocks=BKt,e.render=Fi,e.resolveMountContainer=wJt,e.useChatBootstrap=Vqt,e.useChatHelper=IKt,e.useDraggable=hJt});
|