@flowfuse/flowfuse 2.29.2-7fc8fdf-202604160909.0 → 2.29.2-7fc8fdf-202604161027.0

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.
@@ -1 +1 @@
1
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="89cb4cac-2396-4c69-ae6f-64e109ea92a2",e._sentryDebugIdIdentifier="sentry-dbid-89cb4cac-2396-4c69-ae6f-64e109ea92a2")}catch(e){}}();var _global="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};_global.SENTRY_RELEASE={id:"7fc8fdf62301f4175cef239e2e2f57a2d9e36ea9"},(self.webpackChunk_flowfuse_flowfuse=self.webpackChunk_flowfuse_flowfuse||[]).push([[298],{99298:function(e,t,s){s.r(t),s.d(t,{default:function(){return Ds}});var a=s(41425);const o={class:"ff-expert"},n={ref:"scrollAnchor",class:"scroll-anchor"};var r=s(10810);const l={class:"action-buttons"},i=["disabled"],c={class:"right-buttons"},d=["placeholder","disabled"],m={class:"actions"},u={class:"left"},p={class:"right"},h=["disabled"];var g=s(5322),f=s(4048);const k={class:"capabilities-selector"},S={style:{"min-width":"300px"}},v={class:"flex flex-col gap-1 flex-1 min-w-0"},C={class:"truncate",style:{"line-height":"16px"}},b={key:0,class:"text-gray-400 text-sm truncate leading-4"},y={class:"tool-count-badge self-start",title:"Tools"};var w=s(20487),x=s(46437),V=s(97782),B=s(63391),N={name:"CapabilitiesSelector",components:{FfCheckbox:x.A,ListboxOption:w.h7,FfListbox:V.A},computed:{...(0,r.aH)(B.W,["selectedCapabilities","capabilities"]),hasCapabilities(){return this.capabilities&&this.capabilities.length>0},capabilitiesHandler:{get(){return this.selectedCapabilities},set(e){this.setSelectedCapabilities(e)}}},methods:{...(0,r.i0)(B.W,["setSelectedCapabilities"]),onCheckboxClick(e){const t=e=>`${e.instance}::${e.mcpServerUrl}`,s=this.selectedCapabilities||[],a=s.some(s=>t(s)===t(e));this.capabilitiesHandler=a?s.filter(s=>t(s)!==t(e)):[...s,e]},getResourceTooltip(e){return[["MCP Server:",e.mcpServerName],["Instance:",e.instanceName],e.title?["Title:",e.title]:[],e.description?["Description:",e.description]:[],e.tools?.length?["Tools:",...e.tools.map(e=>e.name)]:null,e.resources?.length?["Resources:",...e.resources.map(e=>e.name)]:null,e.resourceTemplates?.length?["Resource Templates:",...e.resourceTemplates.map(e=>e.name)]:null].filter(Boolean).map(e=>e.join("\n")).join("\n\n")}}},E=s(66262),I=(0,E.A)(N,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ff-checkbox"),i=(0,a.resolveComponent)("ListboxOption"),c=(0,a.resolveComponent)("ff-listbox");return(0,a.openBlock)(),(0,a.createElementBlock)("div",k,[(0,a.createVNode)(c,{modelValue:r.capabilitiesHandler,"onUpdate:modelValue":t[0]||(t[0]=e=>r.capabilitiesHandler=e),options:e.capabilities,disabled:!r.hasCapabilities,"return-model":"",multiple:"","label-key":"name","value-key":["instance","mcpServerUrl"],placeholder:"Resources","open-above":"","options-min-width":280,"align-right":""},{options:(0,a.withCtx)(({options:e})=>[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e,e=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:e.mcpServerName,as:"template",value:e,class:"ff-option ff-team-selection-option","data-option":e.mcpServerName,title:r.getResourceTooltip(e)},{default:(0,a.withCtx)(({active:t,selected:s})=>[(0,a.createElementVNode)("li",S,[(0,a.createElementVNode)("div",{class:(0,a.normalizeClass)(["ff-option-content flex truncate justify-start !items-start !gap-2 !p-2",{active:t}]),"data-click-exclude":"right-drawer"},[(0,a.createElementVNode)("div",null,[(0,a.createVNode)(l,{modelValue:s,onClick:(0,a.withModifiers)(t=>r.onCheckboxClick(e),["stop","prevent"])},null,8,["modelValue","onClick"])]),(0,a.createElementVNode)("div",v,[(0,a.createElementVNode)("span",C,(0,a.toDisplayString)(e.title),1),e.title?((0,a.openBlock)(),(0,a.createElementBlock)("p",b,(0,a.toDisplayString)(e.mcpServerName),1)):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("span",y,(0,a.toDisplayString)(e.toolCount),1)],2)])]),_:2},1032,["value","data-option","title"]))),128))]),_:1},8,["modelValue","options","disabled"])])}]]);const A={class:"context-selector-container"};var T=s(22511);const _=["title"],M={class:"text"},P={class:"icon-wrapper"};var O=s(88353),L=s(24487),R={name:"DefaultChip",components:{XIcon:O.default,PlusIcon:L.default},props:{modelValue:{type:Boolean,required:!1,default:!0},text:{type:String,required:!1,default:""},title:{type:String,required:!1,default:""}},emits:["toggle"],methods:{pluralize:T.td}},U=(0,E.A)(R,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("XIcon"),i=(0,a.resolveComponent)("PlusIcon");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)(["chip",{active:s.modelValue}]),title:s.title,onClick:t[0]||(t[0]=t=>e.$emit("toggle"))},[(0,a.createElementVNode)("div",M,[(0,a.renderSlot)(e.$slots,"text",{},()=>[(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(s.text),1)],!0)]),t[1]||(t[1]=(0,a.createElementVNode)("span",{class:"separator"},null,-1)),(0,a.createElementVNode)("div",P,[s.modelValue?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,class:"ff-icon ff-icon-sm"})):((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,class:"ff-icon ff-icon-sm"}))])],10,_)}],["__scopeId","data-v-bb1b17f2"]]),F=s(78721),D={name:"ContextChip",components:{DefaultChip:U},props:{contextItem:{type:Object,required:!1,default:()=>({})}},computed:{...(0,r.aH)(F.u,["getSelectedContext"]),selectedContext(){return this.getSelectedContext},text(){return this.contextItem.name||"Unnamed Context"},title(){return this.contextItem.title||`Include ${this.contextItem.name} in context`}},methods:{...(0,r.i0)(F.u,["setSelectedContext"]),pluralize:T.td,toggleSelection(){const e=this.selectedContext.filter(e=>e.name!==this.contextItem.name);this.setSelectedContext(e)}}},$=(0,E.A)(D,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{modelValue:!!s.contextItem,text:r.text,title:r.title,onToggle:r.toggleSelection},null,8,["modelValue","text","title","onToggle"])}]]);const z=["title"];var H={name:"DebugChip",components:{DefaultChip:U},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,r.aH)(F.u,["debugLog"]),selectedCounter(){return this.debugLog.length},selectionTitle(){const e={};return this.debugLog.forEach(t=>{e[t.type]=(e[t.type]??0)+1}),`Selected Logs: \n${this.debugLog.map((e,t)=>{const s=(e=e||{}).level||"",a="debug"!==s?s:"",o=e.metadata?.topic||"",n=e.source?.name||e.source?.id||e.metadata?.path||"",r=e.metadata?.format||"",l=e.source?.type||"",i=e.metadata?.property||"",c=[];return n&&c.push(`node: ${n}`),o&&c.push(`topic: ${o}`),a&&l&&c.push(`${l} : (${a})`),i&&(r?c.push(`property: ${i} ${r}`):c.push(`property: ${i}`)),`${t+1}: ${c.join(", ")}`}).join("\n")}`}},methods:{...(0,r.i0)(F.u,["resetDebugLogContext"]),pluralize:T.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.resetDebugLogContext()}}},q=(0,E.A)(H,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:r.toggleSelection},{text:(0,a.withCtx)(()=>[t[0]||(t[0]=(0,a.createElementVNode)("span",null,"Debug",-1)),(0,a.createElementVNode)("span",{class:"counter italic",title:r.selectionTitle},"( "+(0,a.toDisplayString)(r.selectedCounter)+" "+(0,a.toDisplayString)(r.pluralize("log",r.selectedCounter))+" )",9,z)]),_:1},8,["modelValue","onToggle"])}]]);const j=["title"];var W={name:"SelectionChip",components:{DefaultChip:U},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,r.aH)(F.u,["selectedNodes"]),filteredSelectedNodes(){return this.selectedNodes.filter(e=>!["global-config"].includes(e.type))},selectedCounter(){return this.filteredSelectedNodes.length},selectionTitle(){const e={};return this.filteredSelectedNodes.forEach(t=>{e[t.type]=(e[t.type]??0)+1}),`Selected nodes: \n${Object.keys(e).map(t=>`${e[t]} x ${t}`).join("\n")}`}},methods:{...(0,r.i0)(F.u,["setSelectedNodes"]),pluralize:T.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.setSelectedNodes([])}}},G=(0,E.A)(W,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:r.toggleSelection},{text:(0,a.withCtx)(()=>[t[0]||(t[0]=(0,a.createElementVNode)("span",null,"Selection",-1)),(0,a.createElementVNode)("span",{class:"counter italic",title:r.selectionTitle},"( "+(0,a.toDisplayString)(r.selectedCounter)+" "+(0,a.toDisplayString)(r.pluralize("node",r.selectedCounter))+" )",9,j)]),_:1},8,["modelValue","onToggle"])}]]);const J={class:"context-selector mr-2"};var K=s(52769),Z=s(59270),Y=s(34242),Q=s(28810),X={name:"ContextSelectorButton",components:{PaperClipIcon:K.default},data(){return{selectedContextItems:[]}},computed:{...(0,r.aH)(F.u,["availableContextOptions","getSelectedContext"]),hasContextOptions(){return this.contextOptions?.length>0},hasSelection(){return this.selectedContext?.length>0},selectedContext(){return this.getSelectedContext},contextOptions:{get(){return this.availableContextOptions.map(e=>{let t=Z.default;return"CubeIcon"===e.menuIcon?t=Y.default:"ViewListIcon"===e.menuIcon&&(t=Q.default),{...e,icon:t}})}}},methods:{pluralize:T.td,...(0,r.i0)(F.u,["setSelectedContext"]),selectItem(e){if(e.onSelectAction)(0,F.u)()[e.onSelectAction]();else{const t=e=>({value:e.value,name:e.name,label:e.label,icon:e.icon}),s=t(e),a=this.selectedContext||[];if(a.some(e=>e.value===s.value))return;this.setSelectedContext([...a,s].filter(Boolean))}}}},ee=(0,E.A)(X,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("PaperClipIcon"),i=(0,a.resolveComponent)("ff-listbox");return(0,a.openBlock)(),(0,a.createElementBlock)("div",J,[(0,a.createVNode)(i,{modelValue:n.selectedContextItems,"onUpdate:modelValue":t[0]||(t[0]=e=>n.selectedContextItems=e),class:(0,a.normalizeClass)(["context-selector",r.hasSelection?"active":""]),options:r.contextOptions,disabled:!r.hasContextOptions,"hide-chevron":!0,"icon-only":!0,"return-model":"","label-key":"label",placeholder:"Context","open-above":"","options-min-width":250,"align-right":"",onOptionSelected:r.selectItem},{icon:(0,a.withCtx)(()=>[(0,a.createVNode)(l,{class:"icon ff-icon ff-icon-sm"})]),_:1},8,["modelValue","class","options","disabled","onOptionSelected"])])}]]),te=s(26081),se={name:"ContextSelector",components:{ContextChip:$,DebugChip:q,SelectionChip:G,ContextSelectorButton:ee},computed:{...(0,r.aH)(F.u,["getSelectedContext","hasDebugLogsSelected","hasUserSelection"]),...(0,r.aH)(te.i,["isInsightsAgent"]),selectedContext(){return this.isInsightsAgent?[]:this.getSelectedContext},selectedContextFiltered(){return this.selectedContext.filter(e=>!1!==e.showAsChip)}},methods:{horizontalScrolling(e){const t=e.currentTarget;0!==e.deltaY&&(e.preventDefault(),t.scrollLeft+=e.deltaY/2)}}},ae=(0,E.A)(se,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("context-selector-button"),i=(0,a.resolveComponent)("context-chip"),c=(0,a.resolveComponent)("debug-chip"),d=(0,a.resolveComponent)("selection-chip");return(0,a.openBlock)(),(0,a.createElementBlock)("div",A,[e.isInsightsAgent?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(l,{key:0})),(0,a.createElementVNode)("div",{class:"chips-container",onWheel:t[0]||(t[0]=(...e)=>r.horizontalScrolling&&r.horizontalScrolling(...e))},[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.selectedContextFiltered,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,contextItem:e},null,8,["contextItem"]))),128)),e.hasDebugLogsSelected&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(c,{key:0})):(0,a.createCommentVNode)("v-if",!0),e.hasUserSelection&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(d,{key:1})):(0,a.createCommentVNode)("v-if",!0)],32)])}],["__scopeId","data-v-104983ce"]]),oe=s(28409),ne={name:"ExpertChatInput",components:{CapabilitiesSelector:I,ContextSelector:ae,ResizeBar:f.A},inject:{togglePinWithWidth:{from:"togglePinWithWidth",default:()=>()=>{}}},emits:["send","stop"],setup(){const{startResize:e,heightStyle:t,bindResizer:s,isResizing:a}=(0,g.n)();return{startResize:e,bindResizer:s,heightStyle:t,isInputResizing:a}},data(){return{inputText:"",includeSelection:!0,isTextareaFocused:!1}},computed:{...(0,r.aH)(F.u,["immersiveInstance","immersiveDevice"]),...(0,r.aH)(oe.W,["rightDrawer"]),...(0,r.aH)(te.i,["messages","isSessionExpired","isInsightsAgent","hasSelectedCapabilities","hasMessages","isWaitingForResponse"]),isInputDisabled(){return!!this.isSessionExpired||!!this.isWaitingForResponse||this.isInsightsAgent&&!this.hasSelectedCapabilities},isDrawerPinned(){return this.rightDrawer.fixed},canSend(){return this.inputText.trim().length>0&&!this.isInputDisabled},placeholderText(){return this.isInsightsAgent&&!this.hasSelectedCapabilities?"Select a resource to get started":this.isInsightsAgent?"Tell us what you want to know about":"Tell us what you need help with"},isImmersive(){return this.immersiveDevice||this.immersiveInstance}},mounted(){this.bindResizer({component:this.$refs.resizeTarget,maxHeightRatio:.9,minHeight:120,maxViewportMarginY:80})},methods:{...(0,r.i0)(F.u,["resetContextSelection"]),...(0,r.i0)(te.i,["startOver","handleQuery","handleMessageResponse"]),async handleSend(){if(!this.canSend)return;const e=this.inputText.trim();this.isDrawerPinned||0!==this.messages.length||this.togglePinWithWidth(),this.handleQuery({query:e}).then(e=>this.handleMessageResponse(e)).then(()=>{this.$nextTick(()=>{this.$refs.textarea.focus()})}).catch(e=>e),this.inputText=""},handleStop(){this.$emit("stop")},handleStartOver(){this.hasMessages&&(this.inputText="",this.isInsightsAgent||this.resetContextSelection(),this.startOver())},handleKeydown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSend())}}},re=(0,E.A)(ne,[["render",function(e,t,s,o,n,r){const g=(0,a.resolveComponent)("resize-bar"),f=(0,a.resolveComponent)("capabilities-selector"),k=(0,a.resolveComponent)("context-selector");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{ref:"resizeTarget",class:"ff-expert-input",style:(0,a.normalizeStyle)({height:o.heightStyle})},[(0,a.createVNode)(g,{"is-resizing":o.isInputResizing,direction:"horizontal",onMousedown:o.startResize},null,8,["is-resizing","onMousedown"]),(0,a.createCommentVNode)(" Action buttons row "),(0,a.createElementVNode)("div",l,[(0,a.createElementVNode)("button",{type:"button",class:"btn-start-over",disabled:e.isWaitingForResponse&&!e.isSessionExpired,onClick:t[0]||(t[0]=(...e)=>r.handleStartOver&&r.handleStartOver(...e))}," Start over ",8,i),(0,a.createElementVNode)("div",c,[e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(f,{key:0})):(0,a.createCommentVNode)("v-if",!0)])]),(0,a.createElementVNode)("div",{class:(0,a.normalizeClass)(["input-wrapper",{focused:n.isTextareaFocused}])},[(0,a.createCommentVNode)(" Textarea "),(0,a.withDirectives)((0,a.createElementVNode)("textarea",{ref:"textarea","onUpdate:modelValue":t[1]||(t[1]=e=>n.inputText=e),class:"chat-input",placeholder:r.placeholderText,disabled:r.isInputDisabled,onKeydown:t[2]||(t[2]=(...e)=>r.handleKeydown&&r.handleKeydown(...e)),onFocus:t[3]||(t[3]=e=>n.isTextareaFocused=!0),onBlur:t[4]||(t[4]=e=>n.isTextareaFocused=!1)},null,40,d),[[a.vModelText,n.inputText]]),(0,a.createElementVNode)("div",m,[(0,a.createElementVNode)("div",u,[r.isImmersive&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(k,{key:0})):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("div",p,[e.isWaitingForResponse&&!e.isSessionExpired?((0,a.openBlock)(),(0,a.createElementBlock)("button",{key:0,type:"button",class:"btn-stop",onClick:t[5]||(t[5]=(...e)=>r.handleStop&&r.handleStop(...e))}," Stop ")):e.isSessionExpired?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createElementBlock)("button",{key:1,type:"button",class:"btn-send",disabled:!r.canSend,onClick:t[6]||(t[6]=(...e)=>r.handleSend&&r.handleSend(...e))}," Send ",8,h))])])],2)],4)}],["__scopeId","data-v-f0a93ed0"]]);const le={ref:"messagesWrapper",class:"messages-wrapper"},ie={class:"flex flex-col gap-3"},ce={key:0},de={class:"ff-expert-loading"},me={key:0,class:"loading-message"};var ue=s(2e3),pe={name:"ExpertLoadingIndicator",data(){return{showMessage:!1,currentMessageIndex:0,messageVariants:{[ue.C]:["Ingesting the docs...","Reading the blog...","Searching through FlowFuse knowledge base","Analyzing your question...","Finding the best answer..."],[ue.q]:["Connecting to MCP resources...","Querying your Node-RED instances...","Instructing MCP tooling...","Ingesting responses...","Gathering insights...","Considering instructions...","Processing user response..."],transfer:["Catching up with new context...","Syncing your conversation...","Loading existing history...","Preparing your chat..."]},messageTimer:null,rotationTimer:null}},computed:{...(0,r.aH)(te.i,["loadingVariant"]),messages(){return this.messageVariants[this.loadingVariant]},currentMessage(){return this.messages[this.currentMessageIndex]}},mounted(){this.messageTimer=setTimeout(()=>{this.showMessage=!0,this.rotationTimer=setInterval(()=>{this.currentMessageIndex=(this.currentMessageIndex+1)%this.messages.length},3e3)},5e3)},beforeUnmount(){this.messageTimer&&clearTimeout(this.messageTimer),this.rotationTimer&&clearInterval(this.rotationTimer)}},he=(0,E.A)(pe,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",de,[t[0]||(t[0]=(0,a.createElementVNode)("div",{class:"loading-dots"},[(0,a.createElementVNode)("div",{class:"loading-dot"}),(0,a.createElementVNode)("div",{class:"loading-dot"}),(0,a.createElementVNode)("div",{class:"loading-dot"})],-1)),n.showMessage?((0,a.openBlock)(),(0,a.createElementBlock)("div",me,(0,a.toDisplayString)(r.currentMessage),1)):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-efa2c00e"]]);const ge={class:"flex flex-col gap-3"};var fe=s(99900);function ke({intervalMs:e=350,shallow:t=!1}={}){const s=(0,a.ref)([]),o=(0,a.ref)([]),{doWhile:n}=(0,fe.A)(),r=(0,a.ref)(!1);async function l(a=[]){s.value=t?a.map(m):a,await n(()=>s.value.length!==o.value.length,async()=>{if(!Array.isArray(s.value)||0===s.value.length)return;const e=m(s.value[o.value.length]),a=c(),n=t?!!a?.streamed:Object.values(a??{}).every(e=>e.streamed);a?n&&o.value.push(e):o.value.push(e),o.value.length===s.value.length&&(r.value=!0)},{intervalMs:e})}function i(e){e.value=e,o.value=e.map(m),r.value=!1}function c(){return o.value[o.value.length-1]}function d(e,s){t?o.value[e].streamed=!0:o.value[e][s].streamed=!0}function m(e={}){return t?{...e,streamed:!1}:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{streamable:t,streamed:!1}]))}return{addItemsSequentially:l,addItems:i,initStreamer:async function(e,{shouldStream:t=!1}={}){if(!t)return i(e),Promise.resolve();await l(e)},hasFinishedStreaming:r,items:s,getLastVisibleItem:c,setSubItemStreamedState:d,updateCardStreamingState:function(e,t){Object.keys(e).forEach(e=>{d(t,e)})},visibleItems:o}}const Se={class:"guide-badge"};var ve={name:"AnswerBadge",props:{kind:{required:!0,type:String}},computed:{title(){return"resources"===this.kind?"Resources":"Setup Guide"}}},Ce=(0,E.A)(ve,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",Se,[(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(r.title),1)])}],["__scopeId","data-v-0d393a03"]]);const be={key:0,class:"guide-header"},ye={class:"guide-title"},we={key:0,class:"guide-summary"},xe=["innerHTML"];var Ve=s(50011),Be=s(69510),Ne=s(92753),Ee=s(27402),Ie=s(85262),Ae=s(95387),Te=s(69359),_e=s(60023);Ve.A.registerLanguage("bash",Be.A),Ve.A.registerLanguage("shell",Be.A),Ve.A.registerLanguage("css",Ne.A),Ve.A.registerLanguage("javascript",Ae.A),Ve.A.registerLanguage("js",Ae.A),Ve.A.registerLanguage("json",Ee.A),Ve.A.registerLanguage("python",Ie.A),Ve.A.registerLanguage("py",Ie.A),Ve.A.registerLanguage("typescript",Ae.A),Ve.A.registerLanguage("ts",Ae.A),Ve.A.registerLanguage("xml",Te.A),Ve.A.registerLanguage("html",Te.A);const Me='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/></svg>',Pe=Me;function Oe({delayMs:e=30,splitRegex:t=/\s+/,joinWith:s=" "}={}){const o=(0,a.ref)(""),n=(0,a.ref)(!1);let r=null,l=[],i=0;const c=()=>{r&&clearTimeout(r),r=null,n.value=!1,l=[],i=0};return(0,a.onBeforeUnmount)(c),{text:o,isStreaming:n,stream:(d="")=>(c(),o.value="",l=String(d).trim().split(t).filter(Boolean),i=0,n.value=!0,new Promise(t=>{const c=async()=>n.value?i>=l.length?(await(0,a.nextTick)(),n.value=!1,t()):(o.value+=(o.value?s:"")+l[i],i+=1,void(r=setTimeout(c,e))):t();c()})),stop:c}}var Le={name:"StreamableContent",props:{modelValue:{type:Object,required:!1,default:null,validate(e,t){return t.string||e?!(!e||"object"!=typeof e)&&"string"==typeof e.streamable&&"boolean"==typeof e.streamed:(console.warn("StreamableContent: string prop is required when modelValue is null"),!1)}},string:{required:!1,type:String,default:null,validator(e,t){return!(!t.modelValue&&!e&&(console.warn("StreamableContent: string prop is required when modelValue is null"),1))}},shouldStream:{required:!1,type:Boolean,default:!0},richContent:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete","update:modelValue"],setup(){const{stream:e,text:t,isStreaming:s}=Oe({delayMs:30}),{markedInstance:a}=function(){const e=new _e.Dz({breaks:!0,gfm:!0});return e.use({renderer:{code({text:e,lang:t}){const s=t?t.split(/\s/)[0].toLowerCase():"";let a;return a=s&&Ve.A.getLanguage(s)?Ve.A.highlight(e,{language:s}).value:Ve.A.highlightAuto(e).value,`<div class="ff-code-block"><div class="ff-code-block--header">${s?`<span class="ff-code-block--lang">${s}</span>`:""}<button class="ff-code-block--copy">${Me}</button></div><pre><code class="hljs">${a.replace(/\n/g,"&#10;")}</code></pre></div>`}}}),{markedInstance:e}}();return{stream:e,streamedText:t,isStreaming:s,sanitize:T.aj,markedInstance:a}},computed:{...(0,r.aH)(F.u,["supportedActions"]),rawText(){const e=this.modelValue?this.modelValue.streamable:this.string;return this.richContent?this.markedInstance.parse(e||""):e},text(){const e=this.shouldStream?this.streamedText:this.rawText;return this.sanitize(e,{supportedActions:this.supportedActions,targetBlank:!0,appendQueryParameters:{utm_source:"flowfuse-expert",utm_medium:"assistant",utm_campaign:"expert-chat"}})}},watch:{isStreaming(e){e||(this.$emit("streaming-complete"),this.modelValue&&this.$emit("update:modelValue",{...this.modelValue,streamed:!0}))}},mounted(){this.shouldStream&&this.stream(this.rawText)},methods:{handleClick(e){const t=e.target.closest(".ff-code-block--copy");if(!t)return;const s=t.closest(".ff-code-block")?.querySelector("pre code");s&&navigator.clipboard.writeText(s.textContent||"").then(()=>{t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg>',setTimeout(()=>{t.innerHTML=Pe},2e3)}).catch(()=>{const e=document.createElement("textarea");e.value=s.textContent||"",e.style.position="fixed",e.style.left="-999999px",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)})}}},Re=(0,E.A)(Le,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",(0,a.mergeProps)({class:"streamable-content"},(0,a.toHandlers)(s.richContent?{click:r.handleClick}:{},!0)),[s.richContent?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:1},[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:r.text,innerHTML:r.text},null,8,xe))],64)):((0,a.openBlock)(),(0,a.createElementBlock)("span",{key:r.text},(0,a.toDisplayString)(r.text),1))],16)}],["__scopeId","data-v-7e74785e"]]),Ue={name:"GuideHeader",components:{StreamableContent:Re},props:{title:{type:String,required:!0},summary:{type:[String,null],required:!1,default:null},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],data(){return{streamableSummary:{streamable:this.summary,streamed:!1},streamableTitle:{streamable:this.title,streamed:!1}}},watch:{streamableSummary(e){e.streamed&&this.$emit("streaming-complete")},streamableTitle(e){!this.summary&&e.streamed&&this.$emit("streaming-complete")}}},Fe=(0,E.A)(Ue,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Title and Summary "),s.title?((0,a.openBlock)(),(0,a.createElementBlock)("div",be,[(0,a.createElementVNode)("h3",ye,[(0,a.createVNode)(l,{modelValue:n.streamableTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamableTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),s.summary?((0,a.openBlock)(),(0,a.createElementBlock)("p",we,[!s.shouldStream||n.streamableTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.streamableSummary,"onUpdate:modelValue":t[1]||(t[1]=e=>n.streamableSummary=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)],2112)}],["__scopeId","data-v-7abfce85"]]),De={name:"MessageBubble",props:{type:{required:!0,type:String},variant:{required:!1,type:String,default:null}},computed:{isAiMessage(){return"ai"===this.type},isHumanMessage(){return"human"===this.type},isSystemMessage(){return"system"===this.type}}},$e=(0,E.A)(De,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)(["message-bubble flex flex-col gap-1",{"ai-message":r.isAiMessage,"human-message":r.isHumanMessage,"system-message":r.isSystemMessage,[`system-${s.variant}`]:s.variant}])},[(0,a.renderSlot)(e.$slots,"default",{},void 0,!0)],2)}],["__scopeId","data-v-7581575e"]]);const ze={class:"guide-flows"},He={class:"section-title"},qe={key:0,class:"resources-grid"},je={class:"flex flex-col gap-3 p-3 bg-white border border-gray-200 rounded-lg"},We={class:"flex items-start gap-2"},Ge={class:"flex-1 flex flex-col gap-1 min-w-0"},Je={class:"flex items-start justify-between gap-2"},Ke={class:"text-sm font-medium text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0"},Ze={class:"flex items-start gap-2 flex-shrink-0 -mt-1"},Ye={key:0,class:"text-xs text-gray-500 overflow-hidden text-ellipsis whitespace-nowrap"};var Qe=s(50602),Xe=s(40839),et=s(37262),tt=s(46097),st={name:"StandardResourceCard",components:{StreamableContent:Re,TextCopier:et.A,FlowViewer:tt.A,ChevronUpIcon:Qe.A,ChevronDownIcon:Xe.A},props:{flow:{type:Object,required:!0},shouldStream:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete"],data(){return{flowsExpanded:!0,flowTitle:this.flow.title,flowUrl:this.flow.url,flowMetadata:this.flow.metadata}},computed:{...(0,r.aH)(te.i,["canImportFlows"]),flowsJson(){return this.flowMetadata?JSON.stringify(this.flowMetadata.streamable.flows,null,2):""}},watch:{flowMetadata(e){e.streamed&&this.$emit("streaming-complete")}},methods:{...(0,r.i0)(F.u,["sendFlowsToImport"]),importFlows(){this.sendFlowsToImport(this.flowsJson)},completeStreaming(){this.flowMetadata&&(this.flowMetadata.streamed=!0),this.$emit("streaming-complete")}}},at={name:"ListFlows",components:{StreamableContent:Re,FlowResourceCard:(0,E.A)(st,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("chevron-down-icon"),c=(0,a.resolveComponent)("chevron-up-icon"),d=(0,a.resolveComponent)("text-copier"),m=(0,a.resolveComponent)("ff-button"),u=(0,a.resolveComponent)("flow-viewer");return(0,a.openBlock)(),(0,a.createElementBlock)("div",je,[(0,a.createElementVNode)("div",We,[t[4]||(t[4]=(0,a.createStaticVNode)('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" class="flex-shrink-0 w-4 h-4 mt-0.5" data-v-494f7aa0><rect width="24" height="24" fill="gray" rx="4" data-v-494f7aa0></rect><g clip-path="url(#a)" data-v-494f7aa0><path fill="#fff" d="M0 12v-1.647c5.09 0 5.81-.9 6.44-1.695.72-.9 1.46-1.6 3.88-1.6v1.648c-1.76 0-2.04.354-2.51.948C6.79 10.937 5.5 12 0 12Z" data-v-494f7aa0></path><path fill="#fff" d="M8.6 16.941c-2.9 0-3.47-1.513-3.88-2.614C4.25 13.072 3.85 12 0 12v-1.647c4.67 0 5.67 1.618 6.34 3.419.38 1.015.57 1.522 2.26 1.522v1.647Z" data-v-494f7aa0></path><path fill="#fff" d="M16.78 19H9.9c-.95 0-1.72-.737-1.72-1.647v-2.47c0-.91.77-1.648 1.72-1.648h6.88c.95 0 1.72.738 1.72 1.647v2.47c0 .91-.77 1.648-1.72 1.648Zm0-4.118H9.9v2.47h6.88v-2.47Zm1.5-4.117H11.4c-.95 0-1.72-.738-1.72-1.647v-2.47c0-.91.77-1.648 1.72-1.648h6.88c.95 0 1.72.737 1.72 1.647v2.47c0 .91-.77 1.648-1.72 1.648Zm0-4.118H11.4v2.47h6.88v-2.47Z" data-v-494f7aa0></path></g><defs data-v-494f7aa0><clipPath id="a" data-v-494f7aa0><path fill="#fff" d="M0 5h20v14H0z" data-v-494f7aa0></path></clipPath></defs></svg>',1)),(0,a.createElementVNode)("div",Ge,[(0,a.createElementVNode)("div",Je,[(0,a.createElementVNode)("div",Ke,[(0,a.createVNode)(l,{modelValue:n.flowTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.flowTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("div",Ze,[(0,a.createElementVNode)("button",{class:"text-gray-600 hover:text-indigo-600 hover:bg-indigo-50 flex items-center transition-colors duration-200 rounded px-2 py-1",onClick:t[1]||(t[1]=e=>n.flowsExpanded=!n.flowsExpanded)},[t[2]||(t[2]=(0,a.createElementVNode)("span",null,"Preview",-1)),n.flowsExpanded?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,class:"h-4 w-4"})):(0,a.createCommentVNode)("v-if",!0),n.flowsExpanded?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(c,{key:1,class:"h-4 w-4"}))]),e.canImportFlows?((0,a.openBlock)(),(0,a.createBlock)(m,{key:1,size:"small",kind:"secondary",onClick:r.importFlows},{default:(0,a.withCtx)(()=>[...t[3]||(t[3]=[(0,a.createTextVNode)("Import",-1)])]),_:1},8,["onClick"])):((0,a.openBlock)(),(0,a.createBlock)(d,{key:0,text:r.flowsJson,showText:!1},null,8,["text"]))])]),n.flowMetadata?((0,a.openBlock)(),(0,a.createElementBlock)("div",Ye,[!s.shouldStream||n.flowTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,string:n.flowMetadata.streamable.category,"should-stream":s.shouldStream,onStreamingComplete:r.completeStreaming},null,8,["string","should-stream","onStreamingComplete"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])]),n.flowMetadata?((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:0,class:(0,a.normalizeClass)(["flex overflow-auto ml-8 max-h-[500px] flex-col relative",{hidden:n.flowsExpanded}])},[n.flowsExpanded?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(u,{key:0,flow:s.flow.metadata.streamable.flows},null,8,["flow"]))],2)):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-494f7aa0"]])},props:{flows:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{streamingTitle:{streamable:"Related Flows",streamed:!1}}},async mounted(){const e=this.flows.map(e=>({title:e.title,url:e.url,metadata:e.metadata}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},ot=(0,E.A)(at,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("FlowResourceCard");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Resources Section "),(0,a.createElementVNode)("div",ze,[(0,a.createElementVNode)("h4",He,[(0,a.createVNode)(l,{modelValue:n.streamingTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamingTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),n.streamingTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",qe,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,flow:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["flow","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])],2112)}],["__scopeId","data-v-61196fe4"]]);const nt={class:"guide-steps"},rt={class:"section-title"},lt={class:"steps-list"},it={class:"step-number"},ct={class:"step-content"},dt={class:"step-title"},mt={key:0,class:"step-detail"};var ut={name:"GuideStepsList",components:{StreamableContent:Re},props:{steps:{required:!0,type:Array},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,visibleItems:t}=ke();return{initStreamer:e,visibleItems:t}},async mounted(){await this.initStreamer(this.steps,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},pt=(0,E.A)(ut,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",nt,[(0,a.createElementVNode)("h4",rt,[(0,a.createVNode)(l,{string:"Steps:","should-stream":s.shouldStream},null,8,["should-stream"])]),(0,a.createElementVNode)("ol",lt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t,class:"step-item"},[(0,a.createElementVNode)("div",it,(0,a.toDisplayString)(t+1),1),(0,a.createElementVNode)("div",ct,[(0,a.createElementVNode)("h5",dt,[(0,a.createVNode)(l,{modelValue:e.title,"onUpdate:modelValue":t=>e.title=t,"should-stream":s.shouldStream},null,8,["modelValue","onUpdate:modelValue","should-stream"])]),!s.shouldStream||e.title.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("p",mt,[(0,a.createVNode)(l,{modelValue:e.detail,"onUpdate:modelValue":t=>e.detail=t,"should-stream":s.shouldStream},null,8,["modelValue","onUpdate:modelValue","should-stream"])])):(0,a.createCommentVNode)("v-if",!0)])]))),128))])])}],["__scopeId","data-v-2c3d62df"]]);const ht={class:"issues"};var gt={name:"IssuesList",components:{StreamableContent:Re,ExclamationIcon:s(7437).A},props:{issues:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a,sanitize:T.aj}},data(){return{streamedTitle:{streamable:"Issues",streamed:!1}}},async mounted(){const e=this.issues.map(e=>({content:e}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},ft=(0,E.A)(gt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("exclamation-icon"),i=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",ht,[(0,a.createElementVNode)("h4",null,[(0,a.createVNode)(l,{class:"ff-icon"}),(0,a.createVNode)(i,{modelValue:n.streamedTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamedTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("ul",null,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t},[(0,a.createVNode)(i,{"rich-content":!0,string:e.content.streamable,"should-stream":s.shouldStream,onStreamingComplete:e=>o.setSubItemStreamedState(t,"content")},null,8,["string","should-stream","onStreamingComplete"])]))),128))])])}],["__scopeId","data-v-0f1ffd8a"]]);const kt={class:"guide-packages"},St={class:"section-title"},vt={key:0,class:"packages-grid"},Ct=["href"],bt=["src"],yt={class:"package-info"},wt={class:"package-name"},xt={class:"package-url"},Vt={class:"package-actions"};var Bt={name:"PackageResourceCard",components:{StreamableContent:Re},props:{nodePackage:{type:Object,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(e){const t=(0,a.computed)(()=>{const t=e.nodePackage;return"object"==typeof t?t.id.streamable||t.name.streamable:t}),s=(0,a.computed)(()=>{const s=e.nodePackage;return s?s.url.streamable||s.metadata?.streamable?.source||s.metadata?.streamable?.url||`https://flows.nodered.org/node/${t.value}`:"https://flows.nodered.org/"});return{packageName:t,packageUrl:s}},data(){return{streamablePackageName:{streamable:this.packageName,streamed:!1},streamablePackageUrl:{streamable:this.packageUrl,streamed:!1}}},computed:{...(0,r.aH)(te.i,["canManagePalette"]),...(0,r.aH)(F.u,["palette"]),packageFaviconUrl(){const e=this.nodePackage.metadata?.streamable?.source||this.nodePackage.url.streamable;try{return`https://www.google.com/s2/favicons?domain=${new URL(e).hostname}`}catch(e){return"flows.nodered.org"}},isCorePackage(){return"core-node"===this.nodePackage.type.streamable||this.packageName.startsWith("node-red:")},isPackageInstalled(){const e=this.nodePackage;return!!this.palette?.[e.id.streamable]},urlWithUTMTracking(){const e=this.packageUrl;try{const t=new URL(e);return t.searchParams.set("utm_source","flowfuse-expert"),t.searchParams.set("utm_medium","assistant"),t.searchParams.set("utm_campaign","expert-chat"),t.toString()}catch(t){return e}}},watch:{streamablePackageUrl(e){e.streamed&&this.$emit("streaming-complete")}},methods:{...(0,r.i0)(F.u,["installNodePackage","manageNodePackage"]),handleImageError(e){e.target.style.display="none"},installPackage(){this.installNodePackage(this.packageName)},managePackage(){this.manageNodePackage(this.packageName)}}},Nt={name:"ListPackages",components:{StreamableContent:Re,PackageResourceCard:(0,E.A)(Bt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("ff-button");return(0,a.openBlock)(),(0,a.createElementBlock)("a",{href:r.urlWithUTMTracking,target:"_blank",rel:"noopener noreferrer",class:"package-card"},[(0,a.createElementVNode)("img",{src:r.packageFaviconUrl,alt:"Node-RED",class:"package-favicon",onError:t[0]||(t[0]=(...e)=>r.handleImageError&&r.handleImageError(...e))},null,40,bt),(0,a.createElementVNode)("div",yt,[(0,a.createElementVNode)("div",wt,[(0,a.createVNode)(l,{modelValue:n.streamablePackageName,"onUpdate:modelValue":t[1]||(t[1]=e=>n.streamablePackageName=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("div",xt,[!s.shouldStream||n.streamablePackageName.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.streamablePackageUrl,"onUpdate:modelValue":t[2]||(t[2]=e=>n.streamablePackageUrl=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("div",Vt,[e.canManagePalette&&!r.isCorePackage?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[r.isPackageInstalled?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,class:"w-20",size:"small",kind:"secondary",onClick:t[3]||(t[3]=(0,a.withModifiers)(e=>r.managePackage(s.nodePackage),["stop","prevent"]))},{default:(0,a.withCtx)(()=>[...t[5]||(t[5]=[(0,a.createTextVNode)("Manage ",-1)])]),_:1})):((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,class:"w-20",size:"small",kind:"secondary",onClick:t[4]||(t[4]=(0,a.withModifiers)(e=>r.installPackage(s.nodePackage),["stop","prevent"]))},{default:(0,a.withCtx)(()=>[...t[6]||(t[6]=[(0,a.createTextVNode)("Install ",-1)])]),_:1}))],64)):(0,a.createCommentVNode)("v-if",!0)])])],8,Ct)}],["__scopeId","data-v-505e915a"]])},props:{packages:{required:!0,type:Array},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{packagesTitle:{streamable:"Required Node Packages",streamed:!1}}},async mounted(){const e=this.packages.map(e=>({id:e.id,name:e.name,title:e.title,url:e.url,type:e.type,metadata:e.metadata,hostname:e.hostname}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},Et=(0,E.A)(Nt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("PackageResourceCard");return(0,a.openBlock)(),(0,a.createElementBlock)("div",kt,[(0,a.createElementVNode)("h4",St,[(0,a.createVNode)(l,{modelValue:n.packagesTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.packagesTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.packagesTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",vt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,nodePackage:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["nodePackage","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-02e3a116"]]);const It={key:0,class:"guide-resources"},At={class:"section-title"},Tt={key:0,class:"resources-grid"},_t=["href"],Mt=["src","alt"],Pt={class:"resource-info"},Ot={class:"resource-title"},Lt={key:0,class:"resource-url"};var Rt={name:"StandardResourceCard",components:{StreamableContent:Re},props:{resource:{type:Object,required:!0},shouldStream:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete"],data(){return{resourceUrl:this.resource.metadata?.streamable.source||this.resource.streamable.url,resourceTitle:{...this.resource.title},resourceMetadataSource:this.resource.metadata?.source}},computed:{favIconUrl(){const e=this.resourceUrl;try{return`https://www.google.com/s2/favicons?domain=${new URL(e).hostname}`}catch(e){return""}},urlWithUtmTracking(){const e=this.resourceUrl;try{const t=new URL(e);return t.searchParams.set("utm_source","flowfuse-expert"),t.searchParams.set("utm_medium","assistant"),t.searchParams.set("utm_campaign","expert-chat"),t.toString()}catch(t){return e}}},watch:{resourceTitle(e){e.streamed&&this.$emit("streaming-complete")}},methods:{handleImageError(e){e.target.style.display="none"}}},Ut={name:"ListResources",components:{StreamableContent:Re,StandardResourceCard:(0,E.A)(Rt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" todo clean resource.url references after transitioning to v4 api "),(0,a.createElementVNode)("a",{href:r.urlWithUtmTracking,target:"_blank",rel:"noopener noreferrer",class:"resource-card"},[(0,a.createElementVNode)("img",{src:r.favIconUrl,alt:s.resource.type,class:"resource-icon",onError:t[0]||(t[0]=(...e)=>r.handleImageError&&r.handleImageError(...e))},null,40,Mt),(0,a.createElementVNode)("div",Pt,[(0,a.createElementVNode)("div",Ot,[(0,a.createVNode)(l,{modelValue:n.resourceTitle,"onUpdate:modelValue":t[1]||(t[1]=e=>n.resourceTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.resourceTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",Lt,[n.resourceMetadataSource?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.resourceMetadataSource,"onUpdate:modelValue":t[2]||(t[2]=e=>n.resourceMetadataSource=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):s.resource.url?((0,a.openBlock)(),(0,a.createBlock)(l,{key:1,string:n.resourceUrl,"should-stream":s.shouldStream},null,8,["string","should-stream"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])],8,_t)],2112)}],["__scopeId","data-v-9429e64c"]])},props:{resources:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{resourceTitle:{streamable:"Related Resources",streamed:!1}}},async mounted(){const e=this.resources.map(e=>({title:e.title,url:e.url,metadata:e.metadata}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},Ft=(0,E.A)(Ut,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("StandardResourceCard");return s.resources&&s.resources.length>0?((0,a.openBlock)(),(0,a.createElementBlock)("div",It,[(0,a.createElementVNode)("h4",At,[(0,a.createVNode)(l,{modelValue:n.resourceTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.resourceTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.resourceTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",Tt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,resource:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["resource","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)}],["__scopeId","data-v-3c3ee9c0"]]),Dt={name:"RichContent",components:{StreamableContent:Re},props:{content:{required:!0,type:String},messageUuid:{required:!0,type:String},answerUuid:{required:!0,type:String},shouldStream:{required:!0,type:Boolean}},emits:["streaming-complete"],setup(){const{text:e,isStreaming:t,stream:s,stop:a}=Oe({delayMs:30});return{sanitize:T.aj,text:e,isStreaming:t,stream:s,stop:a}},async mounted(){this.shouldStream||await this.onStreamComplete()},methods:{...(0,r.i0)(te.i,["updateAnswerStreamedState"]),async onStreamComplete(){await this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answerUuid}),this.$emit("streaming-complete")}}},$t=(0,E.A)(Dt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createBlock)(l,{string:s.content,"should-stream":s.shouldStream,"rich-content":!0,onStreamingComplete:r.onStreamComplete},null,8,["string","should-stream","onStreamingComplete"])}]]);const zt={class:"suggestions"},Ht={key:0};var qt={name:"SuggestionsList",components:{StreamableContent:Re,InformationCircleIcon:s(82218).A},props:{suggestions:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}},data(){return{streamingTitle:{streamable:"Suggestions",streamed:!1}}},async mounted(){const e=this.suggestions.map(e=>({content:e}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},jt={name:"AnswerWrapper",components:{SuggestionsList:(0,E.A)(qt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("information-circle-icon"),i=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",zt,[(0,a.createElementVNode)("h4",null,[(0,a.createVNode)(l,{class:"ff-icon"}),(0,a.createVNode)(i,{modelValue:n.streamingTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamingTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.streamingTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("ul",Ht,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t},[(0,a.createVNode)(i,{"rich-content":!0,string:e.content.streamable,"should-stream":s.shouldStream,onStreamingComplete:e=>o.setSubItemStreamedState(t,"content")},null,8,["string","should-stream","onStreamingComplete"])]))),128))])):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-472ccb19"]]),RichContent:$t,PackagesList:Et,FlowsList:ot,AnswerBadge:Ce,ResourcesList:Ft,GuideStepsList:pt,MessageBubble:$e,GuideHeader:Fe,IssuesList:ft},props:{answer:{type:Object,required:!0},messageUuid:{type:String,required:!0}},emits:["streaming-complete"],setup(){const{waitFor:e}=(0,fe.A)();return{waitFor:e}},data(){return{componentStreamingOrder:[],streamedComponents:[]}},computed:{...(0,r.aH)(F.u,["supportedActions"]),...(0,r.aH)(te.i,["agentMode"]),hasGuideHeader(){return!(!this.answer.title||this.isChatAnswer)},hasGuideSteps(){return Object.hasOwnProperty.call(this.answer,"steps")&&this.answer.steps.length>0},hasResources(){return Object.hasOwnProperty.call(this.answer,"resources")&&this.answer.resources.length>0},hasNodePackages(){return this.answer.nodePackages&&this.answer.nodePackages.length>0},hasFlows(){return this.answer.flows&&this.answer.flows.length>0},hasSuggestions(){return this.answer.suggestions&&this.answer.suggestions.length>0},hasIssues(){return this.answer.issues&&this.answer.issues.length>0},hasPlainContent(){return this.answer.content&&this.answer.content.length>0},isChatAnswer(){return!Object.hasOwnProperty.call(this.answer,"kind")||"chat"===this.answer.kind},isEditorContext(){return this.$route?.name?.includes("editor")||!1},shouldShowRichContent(){const e="rich-content";return!!this.componentStreamingOrder.includes(e)&&!!this.hasPlainContent&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowGuideHeader(){const e="guide-header";return!!this.componentStreamingOrder.includes(e)&&!!this.hasGuideHeader&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowGuideStepList(){const e="guide-steps-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasGuideSteps&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowResourcesList(){const e="resources-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasResources&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowFlowsList(){const e="flows-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasFlows&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowPackagesList(){const e="packages-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasNodePackages&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowSuggestionsList(){const e="suggestions-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasSuggestions&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowIssuesList(){const e="issues-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasIssues&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldStream(){return!this.answer._streamed}},watch:{streamedComponents(){this.componentStreamingOrder.length===this.streamedComponents.length&&(this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answer._uuid}),this.$emit("streaming-complete"))}},beforeUnmount(){this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answer._uuid,agent:this.agentMode}),this.isEditorContext&&this.$refs.messageBubble.$el.removeEventListener("click",this.handleClick)},mounted(){this.buildStreamingOrder(),this.isEditorContext&&this.$refs.messageBubble.$el.addEventListener("click",this.handleClick)},methods:{...(0,r.i0)(te.i,["updateAnswerStreamedState"]),buildStreamingOrder(){this.hasPlainContent&&this.componentStreamingOrder.push("rich-content"),this.hasGuideHeader&&this.componentStreamingOrder.push("guide-header"),this.hasGuideSteps&&this.componentStreamingOrder.push("guide-steps-list"),this.hasResources&&this.componentStreamingOrder.push("resources-list"),this.hasFlows&&this.componentStreamingOrder.push("flows-list"),this.hasNodePackages&&this.componentStreamingOrder.push("packages-list"),this.hasIssues&&this.componentStreamingOrder.push("issues-list"),this.hasSuggestions&&this.componentStreamingOrder.push("suggestions-list")},async onComponentComplete(e){this.shouldStream||await this.waitFor(200),this.streamedComponents.push(e)},handleClick(e){const t=e.target;if(!this.isEditorContext)return;if(!t)return;if("A"!==t.nodeName)return;if(!t.classList.contains("assistant-action-link"))return;if(!t.getAttribute("data-assistant-action-href"))return;if(!t.getAttribute("data-action"))return;const s=t.getAttribute("data-action"),a=this.supportedActions?.[s];if(!a)return;e.preventDefault(),e.stopPropagation();const o={};for(const e of t.attributes)if(e.name.startsWith("data-param-")){const t=e.name.replace("data-param-",""),s=a.params?.properties?.[t];if(!s)continue;const n=s.type;let r=e.value;"boolean"===n?r="true"===r:"number"===n&&(r=+r),o[t]=r}(0,F.u)().invokeAction({action:s,params:o})}}},Wt=(0,E.A)(jt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("answer-badge"),i=(0,a.resolveComponent)("rich-content"),c=(0,a.resolveComponent)("guide-header"),d=(0,a.resolveComponent)("guide-steps-list"),m=(0,a.resolveComponent)("resources-list"),u=(0,a.resolveComponent)("flows-list"),p=(0,a.resolveComponent)("packages-list"),h=(0,a.resolveComponent)("issues-list"),g=(0,a.resolveComponent)("suggestions-list"),f=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(f,{ref:"messageBubble",type:"ai"},{default:(0,a.withCtx)(()=>[r.isChatAnswer?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,kind:s.answer.kind},null,8,["kind"])),r.shouldShowRichContent?((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,content:s.answer.content,"message-uuid":s.messageUuid,"answer-uuid":s.answer._uuid,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[0]||(t[0]=e=>r.onComponentComplete("rich-content"))},null,8,["content","message-uuid","answer-uuid","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowGuideHeader?((0,a.openBlock)(),(0,a.createBlock)(c,{key:2,title:s.answer.title,summary:s.answer.summary,"should-stream":r.shouldStream,class:"mt-3",onStreamingComplete:t[1]||(t[1]=e=>r.onComponentComplete("guide-header"))},null,8,["title","summary","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowGuideStepList?((0,a.openBlock)(),(0,a.createBlock)(d,{key:3,steps:s.answer.steps,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[2]||(t[2]=e=>r.onComponentComplete("guide-steps-list"))},null,8,["steps","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowResourcesList?((0,a.openBlock)(),(0,a.createBlock)(m,{key:4,resources:s.answer.resources,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[3]||(t[3]=e=>r.onComponentComplete("resources-list"))},null,8,["resources","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowFlowsList?((0,a.openBlock)(),(0,a.createBlock)(u,{key:5,flows:s.answer.flows,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[4]||(t[4]=e=>r.onComponentComplete("flows-list"))},null,8,["flows","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowPackagesList?((0,a.openBlock)(),(0,a.createBlock)(p,{key:6,packages:s.answer.nodePackages,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[5]||(t[5]=e=>r.onComponentComplete("packages-list"))},null,8,["packages","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowIssuesList?((0,a.openBlock)(),(0,a.createBlock)(h,{key:7,issues:s.answer.issues,"should-stream":r.shouldStream,onStreamingComplete:t[6]||(t[6]=e=>r.onComponentComplete("issues-list"))},null,8,["issues","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowSuggestionsList?((0,a.openBlock)(),(0,a.createBlock)(g,{key:8,suggestions:s.answer.suggestions,"should-stream":r.shouldStream,onStreamingComplete:t[7]||(t[7]=e=>r.onComponentComplete("suggestions-list"))},null,8,["suggestions","should-stream"])):(0,a.createCommentVNode)("v-if",!0)]),_:1},512)}]]);const Gt={class:"ff-expert-tool-call"},Jt={class:"ff-expert-tool-call--count"},Kt={class:"ff-expert-tool-call--duration"},Zt={class:"ff-expert-tool-call--body"},Yt={class:"ff-expert-tool-call--title"},Qt={class:"ff-expert-tool-call--name"},Xt=["title"],es={key:0,class:"ff-expert-tool-call--details"},ts={key:0,class:"ff-expert-tool-call--section"},ss=["onClick"],as={key:0,class:"ff-expert-tool-call--code"},os=["innerHTML"],ns={key:1,class:"ff-expert-tool-call--section"},rs=["onClick"],ls={class:"ff-expert-tool-call--section-duration"},is={key:0,class:"ff-expert-tool-call--code"},cs=["innerHTML"];var ds=s(80207);Ve.A.registerLanguage("json",Ee.A);var ms={name:"ToolCalls",components:{ChevronRightIcon:ds.A},props:{message:{type:Object,required:!0,validator:e=>Array.isArray(e.toolCalls)}},data(){return{expanded:!1,expandedSections:{}}},computed:{toolCalls(){return this.message.toolCalls||[]},toolCallCount(){return this.toolCalls.length},formattedDuration(){const e=this.message.duration;if(null==e)return 0;const t="string"==typeof e?parseFloat(e):e;return Math.round(1e3*t)}},methods:{toggleExpanded(){this.expanded=!this.expanded},toggleSection(e,t){const s=`${e}-${t}`,a=this.isSectionExpanded(e,t);this.expandedSections[s]=!a},isSectionExpanded(e,t){const s=`${e}-${t}`;return s in this.expandedSections?this.expandedSections[s]:"input"===t},formatKindBadge(e){return{mcp_tool:"T",mcp_resource:"R",mcp_resource_template:"RT",mcp_prompt:"P"}[e]||"?"},formatKindFull(e){return{mcp_tool:"MCP Tool",mcp_resource:"MCP Resource",mcp_resource_template:"MCP Resource Template",mcp_prompt:"MCP Prompt"}[e]||e||"Unknown"},hasContent(e){return null!=e&&(Array.isArray(e)?e.length>0:"object"==typeof e?Object.keys(e).length>0:"string"!=typeof e||""!==e.trim())},highlightJson(e){let t;if("string"==typeof e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e}else t=JSON.stringify(e,null,2);return Ve.A.highlight(t,{language:"json"}).value}}},us={name:"AiMessage",components:{ToolCalls:(0,E.A)(ms,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ChevronRightIcon");return(0,a.openBlock)(),(0,a.createElementBlock)("div",Gt,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--header",onClick:t[0]||(t[0]=(...e)=>r.toggleExpanded&&r.toggleExpanded(...e))},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon",{rotated:n.expanded}])},null,8,["class"]),(0,a.createElementVNode)("span",Jt,(0,a.toDisplayString)(r.toolCallCount)+" tool call"+(0,a.toDisplayString)(r.toolCallCount>1?"s":""),1),(0,a.createElementVNode)("span",Kt,(0,a.toDisplayString)(r.formattedDuration)+" ms ",1)]),(0,a.createElementVNode)("div",Zt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.toolCalls,e=>((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:e.id,class:"ff-expert-tool-call--item"},[(0,a.createElementVNode)("div",Yt,(0,a.toDisplayString)(e.title||e.name),1),(0,a.createElementVNode)("div",Qt,[(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--badge",title:r.formatKindFull(e.kind)},(0,a.toDisplayString)(r.formatKindBadge(e.kind)),9,Xt),(0,a.createTextVNode)(" "+(0,a.toDisplayString)(e.name),1)]),n.expanded?((0,a.openBlock)(),(0,a.createElementBlock)("div",es,[(0,a.createCommentVNode)(" Input section (collapsible, expanded by default) "),r.hasContent(e.args)?((0,a.openBlock)(),(0,a.createElementBlock)("div",ts,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--section-header",onClick:(0,a.withModifiers)(t=>r.toggleSection(e.id,"input"),["stop"])},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon-small",{rotated:r.isSectionExpanded(e.id,"input")}])},null,8,["class"]),t[1]||(t[1]=(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--section-label"},"Input",-1))],8,ss),r.isSectionExpanded(e.id,"input")?((0,a.openBlock)(),(0,a.createElementBlock)("div",as,[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),(0,a.createElementVNode)("pre",null,[(0,a.createElementVNode)("code",{innerHTML:r.highlightJson(e.args)},null,8,os)])])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0),(0,a.createCommentVNode)(" Output section (collapsible, collapsed by default) "),r.hasContent(e.output)?((0,a.openBlock)(),(0,a.createElementBlock)("div",ns,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--section-header",onClick:(0,a.withModifiers)(t=>r.toggleSection(e.id,"output"),["stop"])},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon-small",{rotated:r.isSectionExpanded(e.id,"output")}])},null,8,["class"]),t[2]||(t[2]=(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--section-label"},"Output",-1)),(0,a.createElementVNode)("span",ls,(0,a.toDisplayString)(e.durationMs||0)+" ms",1)],8,rs),r.isSectionExpanded(e.id,"output")?((0,a.openBlock)(),(0,a.createElementBlock)("div",is,[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),(0,a.createElementVNode)("pre",null,[(0,a.createElementVNode)("code",{innerHTML:r.highlightJson(e.output)},null,8,cs)])])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)]))),128))])])}],["__scopeId","data-v-3f750f09"]]),AnswerWrapper:Wt},props:{query:{type:String,required:!1,default:null},answer:{type:Object,required:!0},timings:{required:!1,default:null,type:Object},_type:{type:String,required:!0},_timestamp:{required:!0,type:Number},_uuid:{required:!0,type:String},_streamed:{required:!0,type:Boolean}},setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke({shallow:!0});return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}},computed:{toolCalls(){const e=this.answer.filter(e=>["mcp_tool","mcp_resource","mcp_resource_template","mcp_prompt"].includes(e.kind));if(e.length>0){const t=e.map(e=>({id:e.toolId,name:e.toolName,title:e.toolTitle||e.toolName,kind:e.kind,args:e.input,output:e.output,durationMs:e.durationMs}));return{type:"ai",kind:"tool_calls",toolCalls:t,duration:(e.reduce((e,t)=>e+(t.durationMs||0),0)/1e3).toFixed(2),content:`${t.length} tool call(s)`,timestamp:Date.now()}}return null},filteredAnswers(){return this.answer.filter(e=>!["mcp_tool","mcp_resource","mcp_resource_template","mcp_prompt"].includes(e.kind))}},async mounted(){await this.initStreamer(this.filteredAnswers,{shouldStream:!this._streamed})},methods:{slugify:T.Yv}},ps=(0,E.A)(us,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("tool-calls"),i=(0,a.resolveComponent)("answer-wrapper");return(0,a.openBlock)(),(0,a.createElementBlock)("div",ge,[r.toolCalls?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,message:r.toolCalls},null,8,["message"])):(0,a.createCommentVNode)("v-if",!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:r.slugify(`${e.kind}-${e.title}-${e.summary}-${e._uuid}`),"message-uuid":s._uuid,answer:e,onStreamingComplete:e=>o.setSubItemStreamedState(t)},null,8,["message-uuid","answer","onStreamingComplete"]))),128))])}]]),hs={name:"HumanMessage",components:{MessageBubble:$e},props:{content:{required:!0,type:String},_timestamp:{required:!0,type:Number},_type:{required:!0,type:String}}},gs=(0,E.A)(hs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(l,{type:"human"},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(s.content),1)]),_:1})}]]),fs={name:"SystemMessage",components:{MessageBubble:$e},props:{_type:{type:String,required:!0},_variant:{type:String,required:!0},message:{type:String,required:!0},_timestamp:{type:Number,required:!0}}},ks=(0,E.A)(fs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(l,{type:"system",variant:s._variant},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(s.message),1)]),_:1},8,["variant"])}]]),Ss={name:"ExpertMessages",components:{ExpertLoadingIndicator:he},emits:["resizing"],data(){return{resizeObserver:null,lastHeight:null}},computed:{...(0,r.aH)(te.i,["messages","isWaitingForResponse"]),messageTypes(){return{ai:(0,a.markRaw)(ps),human:(0,a.markRaw)(gs),system:(0,a.markRaw)(ks)}}},mounted(){this.mountResizeObserver()},beforeUnmount(){this.unmountResizeObserver()},methods:{mountResizeObserver(){const e=this.$refs.messagesWrapper;e&&(this.lastHeight=e.offsetHeight,this.resizeObserver=new ResizeObserver(([e])=>{const t=e.contentRect.height;t!==this.lastHeight&&(this.lastHeight=t,this.$emit("resizing"))}),this.resizeObserver.observe(e))},unmountResizeObserver(){this.resizeObserver?.disconnect()}}},vs=(0,E.A)(Ss,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("expert-loading-indicator");return(0,a.openBlock)(),(0,a.createElementBlock)("div",le,[(0,a.createElementVNode)("ul",ie,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e.messages,e=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:e._uuid,class:"flex flex-col gap-3"},[r.messageTypes[e._type]?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(r.messageTypes[e._type]),(0,a.mergeProps)({key:0,ref_for:!0},{...e}),null,16)):(0,a.createCommentVNode)("v-if",!0)]))),128)),e.isWaitingForResponse?((0,a.openBlock)(),(0,a.createElementBlock)("li",ce,[(0,a.createVNode)(l)])):(0,a.createCommentVNode)("v-if",!0)])],512)}],["__scopeId","data-v-46bc14ac"]]),Cs={name:"ExpertModeSwitcher",components:{ToggleButtonGroup:s(18779).A},props:{isFloating:{required:!1,type:Boolean,default:!1}},computed:{...(0,r.aH)(te.i,["agentMode"]),agentModeButtons(){return[{title:"Support",value:"support-agent"},{title:"Insights",value:"insights-agent"}]},agentModeWrapper:{get(){return this.agentMode},set(e){this.setAgentMode(e)}}},methods:{...(0,r.i0)(te.i,["setAgentMode"])}},bs=(0,E.A)(Cs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("toggle-button-group");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)({"mode-switcher-floating":s.isFloating})},[(0,a.createVNode)(l,{modelValue:r.agentModeWrapper,"onUpdate:modelValue":t[0]||(t[0]=e=>r.agentModeWrapper=e),buttons:r.agentModeButtons,"uses-links":!1,"visually-hide-title":!0},null,8,["modelValue","buttons"])],2)}],["__scopeId","data-v-e2cddf22"]]);const ys={class:"info-banner"},ws={key:0,class:"info-text"},xs={key:1,class:"info-text"};var Vs={name:"InfoBanner",computed:{...(0,r.aH)(te.i,["isSupportAgent","isInsightsAgent"])}},Bs=(0,E.A)(Vs,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Info Banner "),(0,a.createElementVNode)("div",ys,[e.isSupportAgent?((0,a.openBlock)(),(0,a.createElementBlock)("p",ws,[...t[0]||(t[0]=[(0,a.createTextVNode)(" AI agent has access to all of FlowFuse's ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/docs",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"documentation and knowledge",-1),(0,a.createTextVNode)(", ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/blog",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"blogposts",-1),(0,a.createTextVNode)(", and more. ",-1)])])):(0,a.createCommentVNode)("v-if",!0),e.isInsightsAgent?((0,a.openBlock)(),(0,a.createElementBlock)("p",xs,[...t[1]||(t[1]=[(0,a.createElementVNode)("span",{title:"This feature is still under development",class:"beta-badge"},"BETA",-1),(0,a.createTextVNode)(" AI agent can access ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/node-red/flowfuse/mcp/",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"MCP server tools",-1),(0,a.createTextVNode)(" configured in your hosted Node-RED instances. ",-1)])])):(0,a.createCommentVNode)("v-if",!0)])],2112)}],["__scopeId","data-v-73a526c1"]]);const Ns={class:"update-banner-text update-banner-header flex items-center justify-between"},Es=["title"],Is={class:"update-banner-badge ml-4 flex-shrink-0"},As={class:"update-banner-text update-banner-body",tabindex:"0"},Ts={class:"mb-2"},_s={class:"flex justify-end"};var Ms=s(99589),Ps=s.n(Ms);const Os="0.11.0";var Ls={name:"UpdateBanner",computed:{...(0,r.aH)(F.u,["palette","editorState","version","nodeRedVersion","supportedActions","isEditorRunning"]),assistantLoaded(){return!!(this.version||this.nodeRedVersion||this.palette)},assistantPackage(){return this.palette&&0!==Object.keys(this.palette).length?this.palette?.["@flowfuse/nr-assistant"]?{installed:!0,...this.palette["@flowfuse/nr-assistant"]}:{installed:!1}:null},availableUpdate(){return Array.isArray(this.editorState?.updatesAvailable?.palette)?this.editorState?.updatesAvailable?.palette?.find(e=>"@flowfuse/nr-assistant"===e.package):null},assistantState(){if(!this.version||Ps().lt(this.version,"0.10.1"));else if(!this.isEditorRunning)return{show:!1};const e=!1!==this.assistantPackage?.enabled,t=this.assistantPackage?.installed??this.assistantLoaded,s=(t?this.assistantPackage?.version:"")||this.version||"0.0.0",a=Ps().gte(this.nodeRedVersion||"0.0.0","4.1.6")&&!!this.availableUpdate;let o=!!this.availableUpdate?.latest;this.assistantLoaded&&!a&&(o=Ps().lt(s,Os));const n={show:!t||!e||o,statusClass:"",expectedVersion:this.availableUpdate?.latest||Os,installedVersion:s,installed:t,enabled:e,chip:"",title:"",body:"",buttonText:"",buttonAction:null};return t?e?o?(n.statusClass="",n.chip=this.availableUpdate?.latest?`V${this.availableUpdate.latest} available`:"Update available",n.title="New FlowFuse Expert Version Available",n.body="There is an update available for FlowFuse Expert in the Node-RED palette. Please update to the latest version to enjoy new features and improvements.",n.buttonText="Update...",n.buttonAction=this.manageAssistantPackage):n.show=!1:(n.statusClass="warning",n.chip="Not enabled",n.title="FlowFuse Expert Not Enabled",n.body="FlowFuse Expert is installed but not enabled in the Node-RED palette. Please enable it to access its features.",n.buttonText="Enable...",n.buttonAction=this.manageAssistantPackage):(n.statusClass="warning",n.chip="Not installed",n.title="FlowFuse Expert Not Installed",n.body="FlowFuse Expert is not installed in the Node-RED palette. Please install it to access its features.",n.buttonText="Install...",n.buttonAction=this.installAssistantPackage),n}},methods:{...(0,r.i0)(F.u,["manageNodePackage","installNodePackage"]),onButtonClick(){"function"==typeof this.assistantState?.buttonAction&&this.assistantState.buttonAction()},manageAssistantPackage(){this.manageNodePackage("@flowfuse/nr-assistant")},installAssistantPackage(){this.installNodePackage("@flowfuse/nr-assistant")}}},Rs=(0,E.A)(Ls,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ff-button");return r.assistantState.show?((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:0,class:(0,a.normalizeClass)(["info-banner update-banner",r.assistantState.statusClass])},[(0,a.createElementVNode)("div",Ns,[(0,a.createElementVNode)("span",{class:"truncate flex-1 pr-4",title:r.assistantState.title},(0,a.toDisplayString)(r.assistantState.title),9,Es),(0,a.createElementVNode)("span",Is,(0,a.toDisplayString)(r.assistantState.chip),1)]),(0,a.createElementVNode)("div",As,[(0,a.createElementVNode)("p",Ts,(0,a.toDisplayString)(r.assistantState.body),1),(0,a.createElementVNode)("div",_s,[(0,a.createVNode)(l,{kind:"secondary",size:"small",onClick:r.onButtonClick},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(r.assistantState.buttonText),1)]),_:1},8,["onClick"])])])],2)):(0,a.createCommentVNode)("v-if",!0)}],["__scopeId","data-v-5cb9ca11"]]),Us=s(96836),Fs={name:"ExpertPanel",components:{ExpertModeSwitcher:bs,InfoBanner:Bs,ExpertMessages:vs,ExpertChatInput:re,UpdateBanner:Rs},inject:{togglePinWithWidth:{from:"togglePinWithWidth",default:()=>()=>{}}},props:{instance:{type:Object,required:!1,default:null},device:{type:Object,required:!1,default:null}},data(){return{scrollCheckDebounce:null,autoScroll:!0}},computed:{...(0,r.aH)(te.i,["abortController","agentMode","messages","isInsightsAgent"]),...(0,r.aH)(oe.W,{isPinned:e=>e.rightDrawer.fixed}),...(0,r.aH)(Us.n,["features"]),isEditorContext(){return this.$route?.name?.includes("editor")||!1},isInsightsModeEnabled(){return!!this.features.expertInsights},agentModeWrapper:{get(){return this.agentMode},set(e){this.setAgentMode(e)}},isInstanceRunning(){const e="running"===this.instance?.meta?.state,t="running"===this.device?.status;return e||t}},watch:{agentMode:{immediate:!0,async handler(){this.isInsightsAgent&&await this.getCapabilities(),this.addWelcomeMessageIfNeeded()}},"instance.meta.state":{handler(e){this.isEditorContext&&"running"!==e&&this.reset()}},"device.status":{handler(e){this.isEditorContext&&"running"!==e&&this.reset()}}},mounted(){this.isEditorContext&&setTimeout(()=>{this.addWelcomeMessageIfNeeded()},1e3)},beforeUnmount(){this.scrollCheckDebounce&&clearTimeout(this.scrollCheckDebounce),this.resetSessionTimer()},methods:{...(0,r.i0)(te.i,["setAgentMode","setAbortController","resetSessionTimer","addWelcomeMessageIfNeeded"]),...(0,r.i0)(B.W,["getCapabilities"]),...(0,r.i0)(F.u,["reset"]),handleStopGeneration(){this.abortController&&(this.abortController.abort(),this.setAbortController(null))},handleScroll(){this.scrollCheckDebounce&&clearTimeout(this.scrollCheckDebounce),this.scrollCheckDebounce=setTimeout(()=>{const e=this.$refs.messagesContainer;if(!e)return;const t=e.scrollHeight-e.scrollTop-e.clientHeight<100;t&&!this.autoScroll?this.autoScroll=!0:!t&&this.autoScroll&&(this.autoScroll=!1)},100)},scrollToBottom(){this.autoScroll&&this.$nextTick(()=>{if(this.$refs.scrollAnchor){const e=this.$refs.messagesContainer;if(!e)return;e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}})}}},Ds=(0,E.A)(Fs,[["render",function(e,t,s,r,l,i){const c=(0,a.resolveComponent)("expert-mode-switcher"),d=(0,a.resolveComponent)("info-banner"),m=(0,a.resolveComponent)("expert-messages"),u=(0,a.resolveComponent)("update-banner"),p=(0,a.resolveComponent)("expert-chat-input");return(0,a.openBlock)(),(0,a.createElementBlock)("div",o,[i.isInsightsModeEnabled&&i.isEditorContext?((0,a.openBlock)(),(0,a.createBlock)(c,{key:0,isFloating:!0})):(0,a.createCommentVNode)("v-if",!0),(0,a.createElementVNode)("div",{ref:"messagesContainer",class:(0,a.normalizeClass)(["messages-container",{"has-mode-switcher":i.isInsightsModeEnabled&&i.isEditorContext}]),onScroll:t[0]||(t[0]=(...e)=>i.handleScroll&&i.handleScroll(...e))},[(0,a.createVNode)(d),(0,a.createVNode)(m,{onResizing:i.scrollToBottom},null,8,["onResizing"]),(0,a.createElementVNode)("div",n,null,512)],34),(0,a.createCommentVNode)(" Updates Available Banner "),i.isEditorContext&&i.isInstanceRunning?((0,a.openBlock)(),(0,a.createBlock)(u,{key:1})):(0,a.createCommentVNode)("v-if",!0),(0,a.createVNode)(p,{onStop:i.handleStopGeneration},null,8,["onStop"])])}],["__scopeId","data-v-d99b62d4"]])}}]);
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ce643797-d788-4649-ab37-0df2bc9d7fcd",e._sentryDebugIdIdentifier="sentry-dbid-ce643797-d788-4649-ab37-0df2bc9d7fcd")}catch(e){}}();var _global="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};_global.SENTRY_RELEASE={id:"7fc8fdf62301f4175cef239e2e2f57a2d9e36ea9"},(self.webpackChunk_flowfuse_flowfuse=self.webpackChunk_flowfuse_flowfuse||[]).push([[298],{99298:function(e,t,s){s.r(t),s.d(t,{default:function(){return Ds}});var a=s(41425);const o={class:"ff-expert"},n={ref:"scrollAnchor",class:"scroll-anchor"};var r=s(10810);const l={class:"action-buttons"},i=["disabled"],c={class:"right-buttons"},d=["placeholder","disabled"],m={class:"actions"},u={class:"left"},p={class:"right"},h=["disabled"];var g=s(5322),f=s(4048);const k={class:"capabilities-selector"},S={style:{"min-width":"300px"}},v={class:"flex flex-col gap-1 flex-1 min-w-0"},C={class:"truncate",style:{"line-height":"16px"}},b={key:0,class:"text-gray-400 text-sm truncate leading-4"},y={class:"tool-count-badge self-start",title:"Tools"};var w=s(20487),x=s(46437),V=s(97782),B=s(63391),N={name:"CapabilitiesSelector",components:{FfCheckbox:x.A,ListboxOption:w.h7,FfListbox:V.A},computed:{...(0,r.aH)(B.W,["selectedCapabilities","capabilities"]),hasCapabilities(){return this.capabilities&&this.capabilities.length>0},capabilitiesHandler:{get(){return this.selectedCapabilities},set(e){this.setSelectedCapabilities(e)}}},methods:{...(0,r.i0)(B.W,["setSelectedCapabilities"]),onCheckboxClick(e){const t=e=>`${e.instance}::${e.mcpServerUrl}`,s=this.selectedCapabilities||[],a=s.some(s=>t(s)===t(e));this.capabilitiesHandler=a?s.filter(s=>t(s)!==t(e)):[...s,e]},getResourceTooltip(e){return[["MCP Server:",e.mcpServerName],["Instance:",e.instanceName],e.title?["Title:",e.title]:[],e.description?["Description:",e.description]:[],e.tools?.length?["Tools:",...e.tools.map(e=>e.name)]:null,e.resources?.length?["Resources:",...e.resources.map(e=>e.name)]:null,e.resourceTemplates?.length?["Resource Templates:",...e.resourceTemplates.map(e=>e.name)]:null].filter(Boolean).map(e=>e.join("\n")).join("\n\n")}}},E=s(66262),I=(0,E.A)(N,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ff-checkbox"),i=(0,a.resolveComponent)("ListboxOption"),c=(0,a.resolveComponent)("ff-listbox");return(0,a.openBlock)(),(0,a.createElementBlock)("div",k,[(0,a.createVNode)(c,{modelValue:r.capabilitiesHandler,"onUpdate:modelValue":t[0]||(t[0]=e=>r.capabilitiesHandler=e),options:e.capabilities,disabled:!r.hasCapabilities,"return-model":"",multiple:"","label-key":"name","value-key":["instance","mcpServerUrl"],placeholder:"Resources","open-above":"","options-min-width":280,"align-right":""},{options:(0,a.withCtx)(({options:e})=>[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e,e=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:e.mcpServerName,as:"template",value:e,class:"ff-option ff-team-selection-option","data-option":e.mcpServerName,title:r.getResourceTooltip(e)},{default:(0,a.withCtx)(({active:t,selected:s})=>[(0,a.createElementVNode)("li",S,[(0,a.createElementVNode)("div",{class:(0,a.normalizeClass)(["ff-option-content flex truncate justify-start !items-start !gap-2 !p-2",{active:t}]),"data-click-exclude":"right-drawer"},[(0,a.createElementVNode)("div",null,[(0,a.createVNode)(l,{modelValue:s,onClick:(0,a.withModifiers)(t=>r.onCheckboxClick(e),["stop","prevent"])},null,8,["modelValue","onClick"])]),(0,a.createElementVNode)("div",v,[(0,a.createElementVNode)("span",C,(0,a.toDisplayString)(e.title),1),e.title?((0,a.openBlock)(),(0,a.createElementBlock)("p",b,(0,a.toDisplayString)(e.mcpServerName),1)):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("span",y,(0,a.toDisplayString)(e.toolCount),1)],2)])]),_:2},1032,["value","data-option","title"]))),128))]),_:1},8,["modelValue","options","disabled"])])}]]);const A={class:"context-selector-container"};var T=s(22511);const _=["title"],M={class:"text"},P={class:"icon-wrapper"};var O=s(88353),L=s(24487),R={name:"DefaultChip",components:{XIcon:O.default,PlusIcon:L.default},props:{modelValue:{type:Boolean,required:!1,default:!0},text:{type:String,required:!1,default:""},title:{type:String,required:!1,default:""}},emits:["toggle"],methods:{pluralize:T.td}},U=(0,E.A)(R,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("XIcon"),i=(0,a.resolveComponent)("PlusIcon");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)(["chip",{active:s.modelValue}]),title:s.title,onClick:t[0]||(t[0]=t=>e.$emit("toggle"))},[(0,a.createElementVNode)("div",M,[(0,a.renderSlot)(e.$slots,"text",{},()=>[(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(s.text),1)],!0)]),t[1]||(t[1]=(0,a.createElementVNode)("span",{class:"separator"},null,-1)),(0,a.createElementVNode)("div",P,[s.modelValue?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,class:"ff-icon ff-icon-sm"})):((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,class:"ff-icon ff-icon-sm"}))])],10,_)}],["__scopeId","data-v-bb1b17f2"]]),F=s(78721),D={name:"ContextChip",components:{DefaultChip:U},props:{contextItem:{type:Object,required:!1,default:()=>({})}},computed:{...(0,r.aH)(F.u,["getSelectedContext"]),selectedContext(){return this.getSelectedContext},text(){return this.contextItem.name||"Unnamed Context"},title(){return this.contextItem.title||`Include ${this.contextItem.name} in context`}},methods:{...(0,r.i0)(F.u,["setSelectedContext"]),pluralize:T.td,toggleSelection(){const e=this.selectedContext.filter(e=>e.name!==this.contextItem.name);this.setSelectedContext(e)}}},$=(0,E.A)(D,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{modelValue:!!s.contextItem,text:r.text,title:r.title,onToggle:r.toggleSelection},null,8,["modelValue","text","title","onToggle"])}]]);const z=["title"];var H={name:"DebugChip",components:{DefaultChip:U},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,r.aH)(F.u,["debugLog"]),selectedCounter(){return this.debugLog.length},selectionTitle(){const e={};return this.debugLog.forEach(t=>{e[t.type]=(e[t.type]??0)+1}),`Selected Logs: \n${this.debugLog.map((e,t)=>{const s=(e=e||{}).level||"",a="debug"!==s?s:"",o=e.metadata?.topic||"",n=e.source?.name||e.source?.id||e.metadata?.path||"",r=e.metadata?.format||"",l=e.source?.type||"",i=e.metadata?.property||"",c=[];return n&&c.push(`node: ${n}`),o&&c.push(`topic: ${o}`),a&&l&&c.push(`${l} : (${a})`),i&&(r?c.push(`property: ${i} ${r}`):c.push(`property: ${i}`)),`${t+1}: ${c.join(", ")}`}).join("\n")}`}},methods:{...(0,r.i0)(F.u,["resetDebugLogContext"]),pluralize:T.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.resetDebugLogContext()}}},q=(0,E.A)(H,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:r.toggleSelection},{text:(0,a.withCtx)(()=>[t[0]||(t[0]=(0,a.createElementVNode)("span",null,"Debug",-1)),(0,a.createElementVNode)("span",{class:"counter italic",title:r.selectionTitle},"( "+(0,a.toDisplayString)(r.selectedCounter)+" "+(0,a.toDisplayString)(r.pluralize("log",r.selectedCounter))+" )",9,z)]),_:1},8,["modelValue","onToggle"])}]]);const j=["title"];var W={name:"SelectionChip",components:{DefaultChip:U},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,r.aH)(F.u,["selectedNodes"]),filteredSelectedNodes(){return this.selectedNodes.filter(e=>!["global-config"].includes(e.type))},selectedCounter(){return this.filteredSelectedNodes.length},selectionTitle(){const e={};return this.filteredSelectedNodes.forEach(t=>{e[t.type]=(e[t.type]??0)+1}),`Selected nodes: \n${Object.keys(e).map(t=>`${e[t]} x ${t}`).join("\n")}`}},methods:{...(0,r.i0)(F.u,["setSelectedNodes"]),pluralize:T.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.setSelectedNodes([])}}},G=(0,E.A)(W,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(l,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:r.toggleSelection},{text:(0,a.withCtx)(()=>[t[0]||(t[0]=(0,a.createElementVNode)("span",null,"Selection",-1)),(0,a.createElementVNode)("span",{class:"counter italic",title:r.selectionTitle},"( "+(0,a.toDisplayString)(r.selectedCounter)+" "+(0,a.toDisplayString)(r.pluralize("node",r.selectedCounter))+" )",9,j)]),_:1},8,["modelValue","onToggle"])}]]);const J={class:"context-selector mr-2"};var K=s(52769),Z=s(59270),Y=s(34242),Q=s(28810),X={name:"ContextSelectorButton",components:{PaperClipIcon:K.default},data(){return{selectedContextItems:[]}},computed:{...(0,r.aH)(F.u,["availableContextOptions","getSelectedContext"]),hasContextOptions(){return this.contextOptions?.length>0},hasSelection(){return this.selectedContext?.length>0},selectedContext(){return this.getSelectedContext},contextOptions:{get(){return this.availableContextOptions.map(e=>{let t=Z.default;return"CubeIcon"===e.menuIcon?t=Y.default:"ViewListIcon"===e.menuIcon&&(t=Q.default),{...e,icon:t}})}}},methods:{pluralize:T.td,...(0,r.i0)(F.u,["setSelectedContext"]),selectItem(e){if(e.onSelectAction)(0,F.u)()[e.onSelectAction]();else{const t=e=>({value:e.value,name:e.name,label:e.label,icon:e.icon}),s=t(e),a=this.selectedContext||[];if(a.some(e=>e.value===s.value))return;this.setSelectedContext([...a,s].filter(Boolean))}}}},ee=(0,E.A)(X,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("PaperClipIcon"),i=(0,a.resolveComponent)("ff-listbox");return(0,a.openBlock)(),(0,a.createElementBlock)("div",J,[(0,a.createVNode)(i,{modelValue:n.selectedContextItems,"onUpdate:modelValue":t[0]||(t[0]=e=>n.selectedContextItems=e),class:(0,a.normalizeClass)(["context-selector",r.hasSelection?"active":""]),options:r.contextOptions,disabled:!r.hasContextOptions,"hide-chevron":!0,"icon-only":!0,"return-model":"","label-key":"label",placeholder:"Context","open-above":"","options-min-width":250,"align-right":"",onOptionSelected:r.selectItem},{icon:(0,a.withCtx)(()=>[(0,a.createVNode)(l,{class:"icon ff-icon ff-icon-sm"})]),_:1},8,["modelValue","class","options","disabled","onOptionSelected"])])}]]),te=s(26081),se={name:"ContextSelector",components:{ContextChip:$,DebugChip:q,SelectionChip:G,ContextSelectorButton:ee},computed:{...(0,r.aH)(F.u,["getSelectedContext","hasDebugLogsSelected","hasUserSelection"]),...(0,r.aH)(te.i,["isInsightsAgent"]),selectedContext(){return this.isInsightsAgent?[]:this.getSelectedContext},selectedContextFiltered(){return this.selectedContext.filter(e=>!1!==e.showAsChip)}},methods:{horizontalScrolling(e){const t=e.currentTarget;0!==e.deltaY&&(e.preventDefault(),t.scrollLeft+=e.deltaY/2)}}},ae=(0,E.A)(se,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("context-selector-button"),i=(0,a.resolveComponent)("context-chip"),c=(0,a.resolveComponent)("debug-chip"),d=(0,a.resolveComponent)("selection-chip");return(0,a.openBlock)(),(0,a.createElementBlock)("div",A,[e.isInsightsAgent?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(l,{key:0})),(0,a.createElementVNode)("div",{class:"chips-container",onWheel:t[0]||(t[0]=(...e)=>r.horizontalScrolling&&r.horizontalScrolling(...e))},[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.selectedContextFiltered,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,contextItem:e},null,8,["contextItem"]))),128)),e.hasDebugLogsSelected&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(c,{key:0})):(0,a.createCommentVNode)("v-if",!0),e.hasUserSelection&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(d,{key:1})):(0,a.createCommentVNode)("v-if",!0)],32)])}],["__scopeId","data-v-104983ce"]]),oe=s(28409),ne={name:"ExpertChatInput",components:{CapabilitiesSelector:I,ContextSelector:ae,ResizeBar:f.A},inject:{togglePinWithWidth:{from:"togglePinWithWidth",default:()=>()=>{}}},emits:["send","stop"],setup(){const{startResize:e,heightStyle:t,bindResizer:s,isResizing:a}=(0,g.n)();return{startResize:e,bindResizer:s,heightStyle:t,isInputResizing:a}},data(){return{inputText:"",includeSelection:!0,isTextareaFocused:!1}},computed:{...(0,r.aH)(F.u,["immersiveInstance","immersiveDevice"]),...(0,r.aH)(oe.W,["rightDrawer"]),...(0,r.aH)(te.i,["messages","isSessionExpired","isInsightsAgent","hasSelectedCapabilities","hasMessages","isWaitingForResponse"]),isInputDisabled(){return!!this.isSessionExpired||!!this.isWaitingForResponse||this.isInsightsAgent&&!this.hasSelectedCapabilities},isDrawerPinned(){return this.rightDrawer.fixed},canSend(){return this.inputText.trim().length>0&&!this.isInputDisabled},placeholderText(){return this.isInsightsAgent&&!this.hasSelectedCapabilities?"Select a resource to get started":this.isInsightsAgent?"Tell us what you want to know about":"Tell us what you need help with"},isImmersive(){return this.immersiveDevice||this.immersiveInstance}},mounted(){this.bindResizer({component:this.$refs.resizeTarget,maxHeightRatio:.9,minHeight:120,maxViewportMarginY:80})},methods:{...(0,r.i0)(F.u,["resetContextSelection"]),...(0,r.i0)(te.i,["startOver","handleQuery","handleMessageResponse"]),async handleSend(){if(!this.canSend)return;const e=this.inputText.trim();this.isDrawerPinned||0!==this.messages.length||this.togglePinWithWidth(),this.handleQuery({query:e}).then(e=>this.handleMessageResponse(e)).then(()=>{this.$nextTick(()=>{this.$refs.textarea.focus()})}).catch(e=>e),this.inputText=""},handleStop(){this.$emit("stop")},handleStartOver(){this.hasMessages&&(this.inputText="",this.isInsightsAgent||this.resetContextSelection(),this.startOver())},handleKeydown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSend())}}},re=(0,E.A)(ne,[["render",function(e,t,s,o,n,r){const g=(0,a.resolveComponent)("resize-bar"),f=(0,a.resolveComponent)("capabilities-selector"),k=(0,a.resolveComponent)("context-selector");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{ref:"resizeTarget",class:"ff-expert-input",style:(0,a.normalizeStyle)({height:o.heightStyle})},[(0,a.createVNode)(g,{"is-resizing":o.isInputResizing,direction:"horizontal",onMousedown:o.startResize},null,8,["is-resizing","onMousedown"]),(0,a.createCommentVNode)(" Action buttons row "),(0,a.createElementVNode)("div",l,[(0,a.createElementVNode)("button",{type:"button",class:"btn-start-over",disabled:e.isWaitingForResponse&&!e.isSessionExpired,onClick:t[0]||(t[0]=(...e)=>r.handleStartOver&&r.handleStartOver(...e))}," Start over ",8,i),(0,a.createElementVNode)("div",c,[e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(f,{key:0})):(0,a.createCommentVNode)("v-if",!0)])]),(0,a.createElementVNode)("div",{class:(0,a.normalizeClass)(["input-wrapper",{focused:n.isTextareaFocused}])},[(0,a.createCommentVNode)(" Textarea "),(0,a.withDirectives)((0,a.createElementVNode)("textarea",{ref:"textarea","onUpdate:modelValue":t[1]||(t[1]=e=>n.inputText=e),class:"chat-input",placeholder:r.placeholderText,disabled:r.isInputDisabled,onKeydown:t[2]||(t[2]=(...e)=>r.handleKeydown&&r.handleKeydown(...e)),onFocus:t[3]||(t[3]=e=>n.isTextareaFocused=!0),onBlur:t[4]||(t[4]=e=>n.isTextareaFocused=!1)},null,40,d),[[a.vModelText,n.inputText]]),(0,a.createElementVNode)("div",m,[(0,a.createElementVNode)("div",u,[r.isImmersive&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(k,{key:0})):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("div",p,[e.isWaitingForResponse&&!e.isSessionExpired?((0,a.openBlock)(),(0,a.createElementBlock)("button",{key:0,type:"button",class:"btn-stop",onClick:t[5]||(t[5]=(...e)=>r.handleStop&&r.handleStop(...e))}," Stop ")):e.isSessionExpired?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createElementBlock)("button",{key:1,type:"button",class:"btn-send",disabled:!r.canSend,onClick:t[6]||(t[6]=(...e)=>r.handleSend&&r.handleSend(...e))}," Send ",8,h))])])],2)],4)}],["__scopeId","data-v-f0a93ed0"]]);const le={ref:"messagesWrapper",class:"messages-wrapper"},ie={class:"flex flex-col gap-3"},ce={key:0},de={class:"ff-expert-loading"},me={key:0,class:"loading-message"};var ue=s(2e3),pe={name:"ExpertLoadingIndicator",data(){return{showMessage:!1,currentMessageIndex:0,messageVariants:{[ue.C]:["Ingesting the docs...","Reading the blog...","Searching through FlowFuse knowledge base","Analyzing your question...","Finding the best answer..."],[ue.q]:["Connecting to MCP resources...","Querying your Node-RED instances...","Instructing MCP tooling...","Ingesting responses...","Gathering insights...","Considering instructions...","Processing user response..."],transfer:["Catching up with new context...","Syncing your conversation...","Loading existing history...","Preparing your chat..."]},messageTimer:null,rotationTimer:null}},computed:{...(0,r.aH)(te.i,["loadingVariant"]),messages(){return this.messageVariants[this.loadingVariant]},currentMessage(){return this.messages[this.currentMessageIndex]}},mounted(){this.messageTimer=setTimeout(()=>{this.showMessage=!0,this.rotationTimer=setInterval(()=>{this.currentMessageIndex=(this.currentMessageIndex+1)%this.messages.length},3e3)},5e3)},beforeUnmount(){this.messageTimer&&clearTimeout(this.messageTimer),this.rotationTimer&&clearInterval(this.rotationTimer)}},he=(0,E.A)(pe,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",de,[t[0]||(t[0]=(0,a.createElementVNode)("div",{class:"loading-dots"},[(0,a.createElementVNode)("div",{class:"loading-dot"}),(0,a.createElementVNode)("div",{class:"loading-dot"}),(0,a.createElementVNode)("div",{class:"loading-dot"})],-1)),n.showMessage?((0,a.openBlock)(),(0,a.createElementBlock)("div",me,(0,a.toDisplayString)(r.currentMessage),1)):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-efa2c00e"]]);const ge={class:"flex flex-col gap-3"};var fe=s(99900);function ke({intervalMs:e=350,shallow:t=!1}={}){const s=(0,a.ref)([]),o=(0,a.ref)([]),{doWhile:n}=(0,fe.A)(),r=(0,a.ref)(!1);async function l(a=[]){s.value=t?a.map(m):a,await n(()=>s.value.length!==o.value.length,async()=>{if(!Array.isArray(s.value)||0===s.value.length)return;const e=m(s.value[o.value.length]),a=c(),n=t?!!a?.streamed:Object.values(a??{}).every(e=>e.streamed);a?n&&o.value.push(e):o.value.push(e),o.value.length===s.value.length&&(r.value=!0)},{intervalMs:e})}function i(e){e.value=e,o.value=e.map(m),r.value=!1}function c(){return o.value[o.value.length-1]}function d(e,s){t?o.value[e].streamed=!0:o.value[e][s].streamed=!0}function m(e={}){return t?{...e,streamed:!1}:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{streamable:t,streamed:!1}]))}return{addItemsSequentially:l,addItems:i,initStreamer:async function(e,{shouldStream:t=!1}={}){if(!t)return i(e),Promise.resolve();await l(e)},hasFinishedStreaming:r,items:s,getLastVisibleItem:c,setSubItemStreamedState:d,updateCardStreamingState:function(e,t){Object.keys(e).forEach(e=>{d(t,e)})},visibleItems:o}}const Se={class:"guide-badge"};var ve={name:"AnswerBadge",props:{kind:{required:!0,type:String}},computed:{title(){return"resources"===this.kind?"Resources":"Setup Guide"}}},Ce=(0,E.A)(ve,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",Se,[(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(r.title),1)])}],["__scopeId","data-v-0d393a03"]]);const be={key:0,class:"guide-header"},ye={class:"guide-title"},we={key:0,class:"guide-summary"},xe=["innerHTML"];var Ve=s(50011),Be=s(69510),Ne=s(92753),Ee=s(27402),Ie=s(85262),Ae=s(95387),Te=s(69359),_e=s(60023);Ve.A.registerLanguage("bash",Be.A),Ve.A.registerLanguage("shell",Be.A),Ve.A.registerLanguage("css",Ne.A),Ve.A.registerLanguage("javascript",Ae.A),Ve.A.registerLanguage("js",Ae.A),Ve.A.registerLanguage("json",Ee.A),Ve.A.registerLanguage("python",Ie.A),Ve.A.registerLanguage("py",Ie.A),Ve.A.registerLanguage("typescript",Ae.A),Ve.A.registerLanguage("ts",Ae.A),Ve.A.registerLanguage("xml",Te.A),Ve.A.registerLanguage("html",Te.A);const Me='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/></svg>',Pe=Me;function Oe({delayMs:e=30,splitRegex:t=/\s+/,joinWith:s=" "}={}){const o=(0,a.ref)(""),n=(0,a.ref)(!1);let r=null,l=[],i=0;const c=()=>{r&&clearTimeout(r),r=null,n.value=!1,l=[],i=0};return(0,a.onBeforeUnmount)(c),{text:o,isStreaming:n,stream:(d="")=>(c(),o.value="",l=String(d).trim().split(t).filter(Boolean),i=0,n.value=!0,new Promise(t=>{const c=async()=>n.value?i>=l.length?(await(0,a.nextTick)(),n.value=!1,t()):(o.value+=(o.value?s:"")+l[i],i+=1,void(r=setTimeout(c,e))):t();c()})),stop:c}}var Le={name:"StreamableContent",props:{modelValue:{type:Object,required:!1,default:null,validate(e,t){return t.string||e?!(!e||"object"!=typeof e)&&"string"==typeof e.streamable&&"boolean"==typeof e.streamed:(console.warn("StreamableContent: string prop is required when modelValue is null"),!1)}},string:{required:!1,type:String,default:null,validator(e,t){return!(!t.modelValue&&!e&&(console.warn("StreamableContent: string prop is required when modelValue is null"),1))}},shouldStream:{required:!1,type:Boolean,default:!0},richContent:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete","update:modelValue"],setup(){const{stream:e,text:t,isStreaming:s}=Oe({delayMs:30}),{markedInstance:a}=function(){const e=new _e.Dz({breaks:!0,gfm:!0});return e.use({renderer:{code({text:e,lang:t}){const s=t?t.split(/\s/)[0].toLowerCase():"";let a;return a=s&&Ve.A.getLanguage(s)?Ve.A.highlight(e,{language:s}).value:Ve.A.highlightAuto(e).value,`<div class="ff-code-block"><div class="ff-code-block--header">${s?`<span class="ff-code-block--lang">${s}</span>`:""}<button class="ff-code-block--copy">${Me}</button></div><pre><code class="hljs">${a.replace(/\n/g,"&#10;")}</code></pre></div>`}}}),{markedInstance:e}}();return{stream:e,streamedText:t,isStreaming:s,sanitize:T.aj,markedInstance:a}},computed:{...(0,r.aH)(F.u,["supportedActions"]),rawText(){const e=this.modelValue?this.modelValue.streamable:this.string;return this.richContent?this.markedInstance.parse(e||""):e},text(){const e=this.shouldStream?this.streamedText:this.rawText;return this.sanitize(e,{supportedActions:this.supportedActions,targetBlank:!0,appendQueryParameters:{utm_source:"flowfuse-expert",utm_medium:"assistant",utm_campaign:"expert-chat"}})}},watch:{isStreaming(e){e||(this.$emit("streaming-complete"),this.modelValue&&this.$emit("update:modelValue",{...this.modelValue,streamed:!0}))}},mounted(){this.shouldStream&&this.stream(this.rawText)},methods:{handleClick(e){const t=e.target.closest(".ff-code-block--copy");if(!t)return;const s=t.closest(".ff-code-block")?.querySelector("pre code");s&&navigator.clipboard.writeText(s.textContent||"").then(()=>{t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg>',setTimeout(()=>{t.innerHTML=Pe},2e3)}).catch(()=>{const e=document.createElement("textarea");e.value=s.textContent||"",e.style.position="fixed",e.style.left="-999999px",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)})}}},Re=(0,E.A)(Le,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",(0,a.mergeProps)({class:"streamable-content"},(0,a.toHandlers)(s.richContent?{click:r.handleClick}:{},!0)),[s.richContent?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:1},[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:r.text,innerHTML:r.text},null,8,xe))],64)):((0,a.openBlock)(),(0,a.createElementBlock)("span",{key:r.text},(0,a.toDisplayString)(r.text),1))],16)}],["__scopeId","data-v-7e74785e"]]),Ue={name:"GuideHeader",components:{StreamableContent:Re},props:{title:{type:String,required:!0},summary:{type:[String,null],required:!1,default:null},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],data(){return{streamableSummary:{streamable:this.summary,streamed:!1},streamableTitle:{streamable:this.title,streamed:!1}}},watch:{streamableSummary(e){e.streamed&&this.$emit("streaming-complete")},streamableTitle(e){!this.summary&&e.streamed&&this.$emit("streaming-complete")}}},Fe=(0,E.A)(Ue,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Title and Summary "),s.title?((0,a.openBlock)(),(0,a.createElementBlock)("div",be,[(0,a.createElementVNode)("h3",ye,[(0,a.createVNode)(l,{modelValue:n.streamableTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamableTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),s.summary?((0,a.openBlock)(),(0,a.createElementBlock)("p",we,[!s.shouldStream||n.streamableTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.streamableSummary,"onUpdate:modelValue":t[1]||(t[1]=e=>n.streamableSummary=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)],2112)}],["__scopeId","data-v-7abfce85"]]),De={name:"MessageBubble",props:{type:{required:!0,type:String},variant:{required:!1,type:String,default:null}},computed:{isAiMessage(){return"ai"===this.type},isHumanMessage(){return"human"===this.type},isSystemMessage(){return"system"===this.type}}},$e=(0,E.A)(De,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)(["message-bubble flex flex-col gap-1",{"ai-message":r.isAiMessage,"human-message":r.isHumanMessage,"system-message":r.isSystemMessage,[`system-${s.variant}`]:s.variant}])},[(0,a.renderSlot)(e.$slots,"default",{},void 0,!0)],2)}],["__scopeId","data-v-7581575e"]]);const ze={class:"guide-flows"},He={class:"section-title"},qe={key:0,class:"resources-grid"},je={class:"flex flex-col gap-3 p-3 bg-white border border-gray-200 rounded-lg"},We={class:"flex items-start gap-2"},Ge={class:"flex-1 flex flex-col gap-1 min-w-0"},Je={class:"flex items-start justify-between gap-2"},Ke={class:"text-sm font-medium text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0"},Ze={class:"flex items-start gap-2 flex-shrink-0 -mt-1"},Ye={key:0,class:"text-xs text-gray-500 overflow-hidden text-ellipsis whitespace-nowrap"};var Qe=s(50602),Xe=s(40839),et=s(37262),tt=s(46097),st={name:"StandardResourceCard",components:{StreamableContent:Re,TextCopier:et.A,FlowViewer:tt.A,ChevronUpIcon:Qe.A,ChevronDownIcon:Xe.A},props:{flow:{type:Object,required:!0},shouldStream:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete"],data(){return{flowsExpanded:!0,flowTitle:this.flow.title,flowUrl:this.flow.url,flowMetadata:this.flow.metadata}},computed:{...(0,r.aH)(te.i,["canImportFlows"]),flowsJson(){return this.flowMetadata?JSON.stringify(this.flowMetadata.streamable.flows,null,2):""}},watch:{flowMetadata(e){e.streamed&&this.$emit("streaming-complete")}},methods:{...(0,r.i0)(F.u,["sendFlowsToImport"]),importFlows(){this.sendFlowsToImport(this.flowsJson)},completeStreaming(){this.flowMetadata&&(this.flowMetadata.streamed=!0),this.$emit("streaming-complete")}}},at={name:"ListFlows",components:{StreamableContent:Re,FlowResourceCard:(0,E.A)(st,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("chevron-down-icon"),c=(0,a.resolveComponent)("chevron-up-icon"),d=(0,a.resolveComponent)("text-copier"),m=(0,a.resolveComponent)("ff-button"),u=(0,a.resolveComponent)("flow-viewer");return(0,a.openBlock)(),(0,a.createElementBlock)("div",je,[(0,a.createElementVNode)("div",We,[t[4]||(t[4]=(0,a.createStaticVNode)('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" class="flex-shrink-0 w-4 h-4 mt-0.5" data-v-494f7aa0><rect width="24" height="24" fill="gray" rx="4" data-v-494f7aa0></rect><g clip-path="url(#a)" data-v-494f7aa0><path fill="#fff" d="M0 12v-1.647c5.09 0 5.81-.9 6.44-1.695.72-.9 1.46-1.6 3.88-1.6v1.648c-1.76 0-2.04.354-2.51.948C6.79 10.937 5.5 12 0 12Z" data-v-494f7aa0></path><path fill="#fff" d="M8.6 16.941c-2.9 0-3.47-1.513-3.88-2.614C4.25 13.072 3.85 12 0 12v-1.647c4.67 0 5.67 1.618 6.34 3.419.38 1.015.57 1.522 2.26 1.522v1.647Z" data-v-494f7aa0></path><path fill="#fff" d="M16.78 19H9.9c-.95 0-1.72-.737-1.72-1.647v-2.47c0-.91.77-1.648 1.72-1.648h6.88c.95 0 1.72.738 1.72 1.647v2.47c0 .91-.77 1.648-1.72 1.648Zm0-4.118H9.9v2.47h6.88v-2.47Zm1.5-4.117H11.4c-.95 0-1.72-.738-1.72-1.647v-2.47c0-.91.77-1.648 1.72-1.648h6.88c.95 0 1.72.737 1.72 1.647v2.47c0 .91-.77 1.648-1.72 1.648Zm0-4.118H11.4v2.47h6.88v-2.47Z" data-v-494f7aa0></path></g><defs data-v-494f7aa0><clipPath id="a" data-v-494f7aa0><path fill="#fff" d="M0 5h20v14H0z" data-v-494f7aa0></path></clipPath></defs></svg>',1)),(0,a.createElementVNode)("div",Ge,[(0,a.createElementVNode)("div",Je,[(0,a.createElementVNode)("div",Ke,[(0,a.createVNode)(l,{modelValue:n.flowTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.flowTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("div",Ze,[(0,a.createElementVNode)("button",{class:"text-gray-600 hover:text-indigo-600 hover:bg-indigo-50 flex items-center transition-colors duration-200 rounded px-2 py-1",onClick:t[1]||(t[1]=e=>n.flowsExpanded=!n.flowsExpanded)},[t[2]||(t[2]=(0,a.createElementVNode)("span",null,"Preview",-1)),n.flowsExpanded?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,class:"h-4 w-4"})):(0,a.createCommentVNode)("v-if",!0),n.flowsExpanded?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(c,{key:1,class:"h-4 w-4"}))]),e.canImportFlows?((0,a.openBlock)(),(0,a.createBlock)(m,{key:1,size:"small",kind:"secondary",onClick:r.importFlows},{default:(0,a.withCtx)(()=>[...t[3]||(t[3]=[(0,a.createTextVNode)("Import",-1)])]),_:1},8,["onClick"])):((0,a.openBlock)(),(0,a.createBlock)(d,{key:0,text:r.flowsJson,showText:!1},null,8,["text"]))])]),n.flowMetadata?((0,a.openBlock)(),(0,a.createElementBlock)("div",Ye,[!s.shouldStream||n.flowTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,string:n.flowMetadata.streamable.category,"should-stream":s.shouldStream,onStreamingComplete:r.completeStreaming},null,8,["string","should-stream","onStreamingComplete"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])]),n.flowMetadata?((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:0,class:(0,a.normalizeClass)(["flex overflow-auto ml-8 max-h-[500px] flex-col relative",{hidden:n.flowsExpanded}])},[n.flowsExpanded?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(u,{key:0,flow:s.flow.metadata.streamable.flows},null,8,["flow"]))],2)):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-494f7aa0"]])},props:{flows:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{streamingTitle:{streamable:"Related Flows",streamed:!1}}},async mounted(){const e=this.flows.map(e=>({title:e.title,url:e.url,metadata:e.metadata}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},ot=(0,E.A)(at,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("FlowResourceCard");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Resources Section "),(0,a.createElementVNode)("div",ze,[(0,a.createElementVNode)("h4",He,[(0,a.createVNode)(l,{modelValue:n.streamingTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamingTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),n.streamingTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",qe,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,flow:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["flow","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])],2112)}],["__scopeId","data-v-61196fe4"]]);const nt={class:"guide-steps"},rt={class:"section-title"},lt={class:"steps-list"},it={class:"step-number"},ct={class:"step-content"},dt={class:"step-title"},mt={key:0,class:"step-detail"};var ut={name:"GuideStepsList",components:{StreamableContent:Re},props:{steps:{required:!0,type:Array},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,visibleItems:t}=ke();return{initStreamer:e,visibleItems:t}},async mounted(){await this.initStreamer(this.steps,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},pt=(0,E.A)(ut,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",nt,[(0,a.createElementVNode)("h4",rt,[(0,a.createVNode)(l,{string:"Steps:","should-stream":s.shouldStream},null,8,["should-stream"])]),(0,a.createElementVNode)("ol",lt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t,class:"step-item"},[(0,a.createElementVNode)("div",it,(0,a.toDisplayString)(t+1),1),(0,a.createElementVNode)("div",ct,[(0,a.createElementVNode)("h5",dt,[(0,a.createVNode)(l,{modelValue:e.title,"onUpdate:modelValue":t=>e.title=t,"should-stream":s.shouldStream},null,8,["modelValue","onUpdate:modelValue","should-stream"])]),!s.shouldStream||e.title.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("p",mt,[(0,a.createVNode)(l,{modelValue:e.detail,"onUpdate:modelValue":t=>e.detail=t,"should-stream":s.shouldStream},null,8,["modelValue","onUpdate:modelValue","should-stream"])])):(0,a.createCommentVNode)("v-if",!0)])]))),128))])])}],["__scopeId","data-v-2c3d62df"]]);const ht={class:"issues"};var gt={name:"IssuesList",components:{StreamableContent:Re,ExclamationIcon:s(7437).A},props:{issues:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a,sanitize:T.aj}},data(){return{streamedTitle:{streamable:"Issues",streamed:!1}}},async mounted(){const e=this.issues.map(e=>({content:e}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},ft=(0,E.A)(gt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("exclamation-icon"),i=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",ht,[(0,a.createElementVNode)("h4",null,[(0,a.createVNode)(l,{class:"ff-icon"}),(0,a.createVNode)(i,{modelValue:n.streamedTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamedTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("ul",null,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t},[(0,a.createVNode)(i,{"rich-content":!0,string:e.content.streamable,"should-stream":s.shouldStream,onStreamingComplete:e=>o.setSubItemStreamedState(t,"content")},null,8,["string","should-stream","onStreamingComplete"])]))),128))])])}],["__scopeId","data-v-0f1ffd8a"]]);const kt={class:"guide-packages"},St={class:"section-title"},vt={key:0,class:"packages-grid"},Ct=["href"],bt=["src"],yt={class:"package-info"},wt={class:"package-name"},xt={class:"package-url"},Vt={class:"package-actions"};var Bt={name:"PackageResourceCard",components:{StreamableContent:Re},props:{nodePackage:{type:Object,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(e){const t=(0,a.computed)(()=>{const t=e.nodePackage;return"object"==typeof t?t.id.streamable||t.name.streamable:t}),s=(0,a.computed)(()=>{const s=e.nodePackage;return s?s.url.streamable||s.metadata?.streamable?.source||s.metadata?.streamable?.url||`https://flows.nodered.org/node/${t.value}`:"https://flows.nodered.org/"});return{packageName:t,packageUrl:s}},data(){return{streamablePackageName:{streamable:this.packageName,streamed:!1},streamablePackageUrl:{streamable:this.packageUrl,streamed:!1}}},computed:{...(0,r.aH)(te.i,["canManagePalette"]),...(0,r.aH)(F.u,["palette"]),packageFaviconUrl(){const e=this.nodePackage.metadata?.streamable?.source||this.nodePackage.url.streamable;try{return`https://www.google.com/s2/favicons?domain=${new URL(e).hostname}`}catch(e){return"flows.nodered.org"}},isCorePackage(){return"core-node"===this.nodePackage.type.streamable||this.packageName.startsWith("node-red:")},isPackageInstalled(){const e=this.nodePackage;return!!this.palette?.[e.id.streamable]},urlWithUTMTracking(){const e=this.packageUrl;try{const t=new URL(e);return t.searchParams.set("utm_source","flowfuse-expert"),t.searchParams.set("utm_medium","assistant"),t.searchParams.set("utm_campaign","expert-chat"),t.toString()}catch(t){return e}}},watch:{streamablePackageUrl(e){e.streamed&&this.$emit("streaming-complete")}},methods:{...(0,r.i0)(F.u,["installNodePackage","manageNodePackage"]),handleImageError(e){e.target.style.display="none"},installPackage(){this.installNodePackage(this.packageName)},managePackage(){this.manageNodePackage(this.packageName)}}},Nt={name:"ListPackages",components:{StreamableContent:Re,PackageResourceCard:(0,E.A)(Bt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("ff-button");return(0,a.openBlock)(),(0,a.createElementBlock)("a",{href:r.urlWithUTMTracking,target:"_blank",rel:"noopener noreferrer",class:"package-card"},[(0,a.createElementVNode)("img",{src:r.packageFaviconUrl,alt:"Node-RED",class:"package-favicon",onError:t[0]||(t[0]=(...e)=>r.handleImageError&&r.handleImageError(...e))},null,40,bt),(0,a.createElementVNode)("div",yt,[(0,a.createElementVNode)("div",wt,[(0,a.createVNode)(l,{modelValue:n.streamablePackageName,"onUpdate:modelValue":t[1]||(t[1]=e=>n.streamablePackageName=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.createElementVNode)("div",xt,[!s.shouldStream||n.streamablePackageName.streamed?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.streamablePackageUrl,"onUpdate:modelValue":t[2]||(t[2]=e=>n.streamablePackageUrl=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):(0,a.createCommentVNode)("v-if",!0)]),(0,a.createElementVNode)("div",Vt,[e.canManagePalette&&!r.isCorePackage?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[r.isPackageInstalled?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,class:"w-20",size:"small",kind:"secondary",onClick:t[3]||(t[3]=(0,a.withModifiers)(e=>r.managePackage(s.nodePackage),["stop","prevent"]))},{default:(0,a.withCtx)(()=>[...t[5]||(t[5]=[(0,a.createTextVNode)("Manage ",-1)])]),_:1})):((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,class:"w-20",size:"small",kind:"secondary",onClick:t[4]||(t[4]=(0,a.withModifiers)(e=>r.installPackage(s.nodePackage),["stop","prevent"]))},{default:(0,a.withCtx)(()=>[...t[6]||(t[6]=[(0,a.createTextVNode)("Install ",-1)])]),_:1}))],64)):(0,a.createCommentVNode)("v-if",!0)])])],8,Ct)}],["__scopeId","data-v-505e915a"]])},props:{packages:{required:!0,type:Array},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{packagesTitle:{streamable:"Required Node Packages",streamed:!1}}},async mounted(){const e=this.packages.map(e=>({id:e.id,name:e.name,title:e.title,url:e.url,type:e.type,metadata:e.metadata,hostname:e.hostname}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},Et=(0,E.A)(Nt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("PackageResourceCard");return(0,a.openBlock)(),(0,a.createElementBlock)("div",kt,[(0,a.createElementVNode)("h4",St,[(0,a.createVNode)(l,{modelValue:n.packagesTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.packagesTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.packagesTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",vt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,nodePackage:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["nodePackage","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-02e3a116"]]);const It={key:0,class:"guide-resources"},At={class:"section-title"},Tt={key:0,class:"resources-grid"},_t=["href"],Mt=["src","alt"],Pt={class:"resource-info"},Ot={class:"resource-title"},Lt={key:0,class:"resource-url"};var Rt={name:"StandardResourceCard",components:{StreamableContent:Re},props:{resource:{type:Object,required:!0},shouldStream:{type:Boolean,required:!1,default:!1}},emits:["streaming-complete"],data(){return{resourceUrl:this.resource.metadata?.streamable.source||this.resource.streamable.url,resourceTitle:{...this.resource.title},resourceMetadataSource:this.resource.metadata?.source}},computed:{favIconUrl(){const e=this.resourceUrl;try{return`https://www.google.com/s2/favicons?domain=${new URL(e).hostname}`}catch(e){return""}},urlWithUtmTracking(){const e=this.resourceUrl;try{const t=new URL(e);return t.searchParams.set("utm_source","flowfuse-expert"),t.searchParams.set("utm_medium","assistant"),t.searchParams.set("utm_campaign","expert-chat"),t.toString()}catch(t){return e}}},watch:{resourceTitle(e){e.streamed&&this.$emit("streaming-complete")}},methods:{handleImageError(e){e.target.style.display="none"}}},Ut={name:"ListResources",components:{StreamableContent:Re,StandardResourceCard:(0,E.A)(Rt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" todo clean resource.url references after transitioning to v4 api "),(0,a.createElementVNode)("a",{href:r.urlWithUtmTracking,target:"_blank",rel:"noopener noreferrer",class:"resource-card"},[(0,a.createElementVNode)("img",{src:r.favIconUrl,alt:s.resource.type,class:"resource-icon",onError:t[0]||(t[0]=(...e)=>r.handleImageError&&r.handleImageError(...e))},null,40,Mt),(0,a.createElementVNode)("div",Pt,[(0,a.createElementVNode)("div",Ot,[(0,a.createVNode)(l,{modelValue:n.resourceTitle,"onUpdate:modelValue":t[1]||(t[1]=e=>n.resourceTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.resourceTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",Lt,[n.resourceMetadataSource?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,modelValue:n.resourceMetadataSource,"onUpdate:modelValue":t[2]||(t[2]=e=>n.resourceMetadataSource=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])):s.resource.url?((0,a.openBlock)(),(0,a.createBlock)(l,{key:1,string:n.resourceUrl,"should-stream":s.shouldStream},null,8,["string","should-stream"])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])],8,_t)],2112)}],["__scopeId","data-v-9429e64c"]])},props:{resources:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}},data(){return{resourceTitle:{streamable:"Related Resources",streamed:!1}}},async mounted(){const e=this.resources.map(e=>({title:e.title,url:e.url,metadata:e.metadata}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},Ft=(0,E.A)(Ut,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content"),i=(0,a.resolveComponent)("StandardResourceCard");return s.resources&&s.resources.length>0?((0,a.openBlock)(),(0,a.createElementBlock)("div",It,[(0,a.createElementVNode)("h4",At,[(0,a.createVNode)(l,{modelValue:n.resourceTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.resourceTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.resourceTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("div",Tt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:t,resource:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["resource","should-stream","onStreamingComplete"]))),128))])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)}],["__scopeId","data-v-3c3ee9c0"]]),Dt={name:"RichContent",components:{StreamableContent:Re},props:{content:{required:!0,type:String},messageUuid:{required:!0,type:String},answerUuid:{required:!0,type:String},shouldStream:{required:!0,type:Boolean}},emits:["streaming-complete"],setup(){const{text:e,isStreaming:t,stream:s,stop:a}=Oe({delayMs:30});return{sanitize:T.aj,text:e,isStreaming:t,stream:s,stop:a}},async mounted(){this.shouldStream||await this.onStreamComplete()},methods:{...(0,r.i0)(te.i,["updateAnswerStreamedState"]),async onStreamComplete(){await this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answerUuid}),this.$emit("streaming-complete")}}},$t=(0,E.A)(Dt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createBlock)(l,{string:s.content,"should-stream":s.shouldStream,"rich-content":!0,onStreamingComplete:r.onStreamComplete},null,8,["string","should-stream","onStreamingComplete"])}]]);const zt={class:"suggestions"},Ht={key:0};var qt={name:"SuggestionsList",components:{StreamableContent:Re,InformationCircleIcon:s(82218).A},props:{suggestions:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke();return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}},data(){return{streamingTitle:{streamable:"Suggestions",streamed:!1}}},async mounted(){const e=this.suggestions.map(e=>({content:e}));await this.initStreamer(e,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},jt={name:"AnswerWrapper",components:{SuggestionsList:(0,E.A)(qt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("information-circle-icon"),i=(0,a.resolveComponent)("streamable-content");return(0,a.openBlock)(),(0,a.createElementBlock)("div",zt,[(0,a.createElementVNode)("h4",null,[(0,a.createVNode)(l,{class:"ff-icon"}),(0,a.createVNode)(i,{modelValue:n.streamingTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.streamingTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),!s.shouldStream||n.streamingTitle.streamed?((0,a.openBlock)(),(0,a.createElementBlock)("ul",Ht,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:t},[(0,a.createVNode)(i,{"rich-content":!0,string:e.content.streamable,"should-stream":s.shouldStream,onStreamingComplete:e=>o.setSubItemStreamedState(t,"content")},null,8,["string","should-stream","onStreamingComplete"])]))),128))])):(0,a.createCommentVNode)("v-if",!0)])}],["__scopeId","data-v-472ccb19"]]),RichContent:$t,PackagesList:Et,FlowsList:ot,AnswerBadge:Ce,ResourcesList:Ft,GuideStepsList:pt,MessageBubble:$e,GuideHeader:Fe,IssuesList:ft},props:{answer:{type:Object,required:!0},messageUuid:{type:String,required:!0}},emits:["streaming-complete"],setup(){const{waitFor:e}=(0,fe.A)();return{waitFor:e}},data(){return{componentStreamingOrder:[],streamedComponents:[]}},computed:{...(0,r.aH)(F.u,["supportedActions"]),...(0,r.aH)(te.i,["agentMode"]),hasGuideHeader(){return!(!this.answer.title||this.isChatAnswer)},hasGuideSteps(){return Object.hasOwnProperty.call(this.answer,"steps")&&this.answer.steps.length>0},hasResources(){return Object.hasOwnProperty.call(this.answer,"resources")&&this.answer.resources.length>0},hasNodePackages(){return this.answer.nodePackages&&this.answer.nodePackages.length>0},hasFlows(){return this.answer.flows&&this.answer.flows.length>0},hasSuggestions(){return this.answer.suggestions&&this.answer.suggestions.length>0},hasIssues(){return this.answer.issues&&this.answer.issues.length>0},hasPlainContent(){return this.answer.content&&this.answer.content.length>0},isChatAnswer(){return!Object.hasOwnProperty.call(this.answer,"kind")||"chat"===this.answer.kind},isEditorContext(){return this.$route?.name?.includes("editor")||!1},shouldShowRichContent(){const e="rich-content";return!!this.componentStreamingOrder.includes(e)&&!!this.hasPlainContent&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowGuideHeader(){const e="guide-header";return!!this.componentStreamingOrder.includes(e)&&!!this.hasGuideHeader&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowGuideStepList(){const e="guide-steps-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasGuideSteps&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowResourcesList(){const e="resources-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasResources&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowFlowsList(){const e="flows-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasFlows&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowPackagesList(){const e="packages-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasNodePackages&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowSuggestionsList(){const e="suggestions-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasSuggestions&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldShowIssuesList(){const e="issues-list";return!!this.componentStreamingOrder.includes(e)&&!!this.hasIssues&&(0===this.componentStreamingOrder.indexOf(e)||this.streamedComponents.length>=this.componentStreamingOrder.indexOf(e))},shouldStream(){return!this.answer._streamed}},watch:{streamedComponents(){this.componentStreamingOrder.length===this.streamedComponents.length&&(this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answer._uuid}),this.$emit("streaming-complete"))}},beforeUnmount(){this.updateAnswerStreamedState({messageUuid:this.messageUuid,answerUuid:this.answer._uuid,agent:this.agentMode}),this.isEditorContext&&this.$refs.messageBubble.$el.removeEventListener("click",this.handleClick)},mounted(){this.buildStreamingOrder(),this.isEditorContext&&this.$refs.messageBubble.$el.addEventListener("click",this.handleClick)},methods:{...(0,r.i0)(te.i,["updateAnswerStreamedState"]),buildStreamingOrder(){this.hasPlainContent&&this.componentStreamingOrder.push("rich-content"),this.hasGuideHeader&&this.componentStreamingOrder.push("guide-header"),this.hasGuideSteps&&this.componentStreamingOrder.push("guide-steps-list"),this.hasResources&&this.componentStreamingOrder.push("resources-list"),this.hasFlows&&this.componentStreamingOrder.push("flows-list"),this.hasNodePackages&&this.componentStreamingOrder.push("packages-list"),this.hasIssues&&this.componentStreamingOrder.push("issues-list"),this.hasSuggestions&&this.componentStreamingOrder.push("suggestions-list")},async onComponentComplete(e){this.shouldStream||await this.waitFor(200),this.streamedComponents.push(e)},handleClick(e){const t=e.target;if(!this.isEditorContext)return;if(!t)return;if("A"!==t.nodeName)return;if(!t.classList.contains("assistant-action-link"))return;if(!t.getAttribute("data-assistant-action-href"))return;if(!t.getAttribute("data-action"))return;const s=t.getAttribute("data-action"),a=this.supportedActions?.[s];if(!a)return;e.preventDefault(),e.stopPropagation();const o={};for(const e of t.attributes)if(e.name.startsWith("data-param-")){const t=e.name.replace("data-param-",""),s=a.params?.properties?.[t];if(!s)continue;const n=s.type;let r=e.value;"boolean"===n?r="true"===r:"number"===n&&(r=+r),o[t]=r}(0,F.u)().invokeAction({action:s,params:o})}}},Wt=(0,E.A)(jt,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("answer-badge"),i=(0,a.resolveComponent)("rich-content"),c=(0,a.resolveComponent)("guide-header"),d=(0,a.resolveComponent)("guide-steps-list"),m=(0,a.resolveComponent)("resources-list"),u=(0,a.resolveComponent)("flows-list"),p=(0,a.resolveComponent)("packages-list"),h=(0,a.resolveComponent)("issues-list"),g=(0,a.resolveComponent)("suggestions-list"),f=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(f,{ref:"messageBubble",type:"ai"},{default:(0,a.withCtx)(()=>[r.isChatAnswer?(0,a.createCommentVNode)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,kind:s.answer.kind},null,8,["kind"])),r.shouldShowRichContent?((0,a.openBlock)(),(0,a.createBlock)(i,{key:1,content:s.answer.content,"message-uuid":s.messageUuid,"answer-uuid":s.answer._uuid,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[0]||(t[0]=e=>r.onComponentComplete("rich-content"))},null,8,["content","message-uuid","answer-uuid","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowGuideHeader?((0,a.openBlock)(),(0,a.createBlock)(c,{key:2,title:s.answer.title,summary:s.answer.summary,"should-stream":r.shouldStream,class:"mt-3",onStreamingComplete:t[1]||(t[1]=e=>r.onComponentComplete("guide-header"))},null,8,["title","summary","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowGuideStepList?((0,a.openBlock)(),(0,a.createBlock)(d,{key:3,steps:s.answer.steps,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[2]||(t[2]=e=>r.onComponentComplete("guide-steps-list"))},null,8,["steps","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowResourcesList?((0,a.openBlock)(),(0,a.createBlock)(m,{key:4,resources:s.answer.resources,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[3]||(t[3]=e=>r.onComponentComplete("resources-list"))},null,8,["resources","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowFlowsList?((0,a.openBlock)(),(0,a.createBlock)(u,{key:5,flows:s.answer.flows,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[4]||(t[4]=e=>r.onComponentComplete("flows-list"))},null,8,["flows","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowPackagesList?((0,a.openBlock)(),(0,a.createBlock)(p,{key:6,packages:s.answer.nodePackages,"should-stream":r.shouldStream,class:"mb-3",onStreamingComplete:t[5]||(t[5]=e=>r.onComponentComplete("packages-list"))},null,8,["packages","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowIssuesList?((0,a.openBlock)(),(0,a.createBlock)(h,{key:7,issues:s.answer.issues,"should-stream":r.shouldStream,onStreamingComplete:t[6]||(t[6]=e=>r.onComponentComplete("issues-list"))},null,8,["issues","should-stream"])):(0,a.createCommentVNode)("v-if",!0),r.shouldShowSuggestionsList?((0,a.openBlock)(),(0,a.createBlock)(g,{key:8,suggestions:s.answer.suggestions,"should-stream":r.shouldStream,onStreamingComplete:t[7]||(t[7]=e=>r.onComponentComplete("suggestions-list"))},null,8,["suggestions","should-stream"])):(0,a.createCommentVNode)("v-if",!0)]),_:1},512)}]]);const Gt={class:"ff-expert-tool-call"},Jt={class:"ff-expert-tool-call--count"},Kt={class:"ff-expert-tool-call--duration"},Zt={class:"ff-expert-tool-call--body"},Yt={class:"ff-expert-tool-call--title"},Qt={class:"ff-expert-tool-call--name"},Xt=["title"],es={key:0,class:"ff-expert-tool-call--details"},ts={key:0,class:"ff-expert-tool-call--section"},ss=["onClick"],as={key:0,class:"ff-expert-tool-call--code"},os=["innerHTML"],ns={key:1,class:"ff-expert-tool-call--section"},rs=["onClick"],ls={class:"ff-expert-tool-call--section-duration"},is={key:0,class:"ff-expert-tool-call--code"},cs=["innerHTML"];var ds=s(80207);Ve.A.registerLanguage("json",Ee.A);var ms={name:"ToolCalls",components:{ChevronRightIcon:ds.A},props:{message:{type:Object,required:!0,validator:e=>Array.isArray(e.toolCalls)}},data(){return{expanded:!1,expandedSections:{}}},computed:{toolCalls(){return this.message.toolCalls||[]},toolCallCount(){return this.toolCalls.length},formattedDuration(){const e=this.message.duration;if(null==e)return 0;const t="string"==typeof e?parseFloat(e):e;return Math.round(1e3*t)}},methods:{toggleExpanded(){this.expanded=!this.expanded},toggleSection(e,t){const s=`${e}-${t}`,a=this.isSectionExpanded(e,t);this.expandedSections[s]=!a},isSectionExpanded(e,t){const s=`${e}-${t}`;return s in this.expandedSections?this.expandedSections[s]:"input"===t},formatKindBadge(e){return{mcp_tool:"T",mcp_resource:"R",mcp_resource_template:"RT",mcp_prompt:"P"}[e]||"?"},formatKindFull(e){return{mcp_tool:"MCP Tool",mcp_resource:"MCP Resource",mcp_resource_template:"MCP Resource Template",mcp_prompt:"MCP Prompt"}[e]||e||"Unknown"},hasContent(e){return null!=e&&(Array.isArray(e)?e.length>0:"object"==typeof e?Object.keys(e).length>0:"string"!=typeof e||""!==e.trim())},highlightJson(e){let t;if("string"==typeof e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e}else t=JSON.stringify(e,null,2);return Ve.A.highlight(t,{language:"json"}).value}}},us={name:"AiMessage",components:{ToolCalls:(0,E.A)(ms,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ChevronRightIcon");return(0,a.openBlock)(),(0,a.createElementBlock)("div",Gt,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--header",onClick:t[0]||(t[0]=(...e)=>r.toggleExpanded&&r.toggleExpanded(...e))},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon",{rotated:n.expanded}])},null,8,["class"]),(0,a.createElementVNode)("span",Jt,(0,a.toDisplayString)(r.toolCallCount)+" tool call"+(0,a.toDisplayString)(r.toolCallCount>1?"s":""),1),(0,a.createElementVNode)("span",Kt,(0,a.toDisplayString)(r.formattedDuration)+" ms ",1)]),(0,a.createElementVNode)("div",Zt,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.toolCalls,e=>((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:e.id,class:"ff-expert-tool-call--item"},[(0,a.createElementVNode)("div",Yt,(0,a.toDisplayString)(e.title||e.name),1),(0,a.createElementVNode)("div",Qt,[(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--badge",title:r.formatKindFull(e.kind)},(0,a.toDisplayString)(r.formatKindBadge(e.kind)),9,Xt),(0,a.createTextVNode)(" "+(0,a.toDisplayString)(e.name),1)]),n.expanded?((0,a.openBlock)(),(0,a.createElementBlock)("div",es,[(0,a.createCommentVNode)(" Input section (collapsible, expanded by default) "),r.hasContent(e.args)?((0,a.openBlock)(),(0,a.createElementBlock)("div",ts,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--section-header",onClick:(0,a.withModifiers)(t=>r.toggleSection(e.id,"input"),["stop"])},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon-small",{rotated:r.isSectionExpanded(e.id,"input")}])},null,8,["class"]),t[1]||(t[1]=(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--section-label"},"Input",-1))],8,ss),r.isSectionExpanded(e.id,"input")?((0,a.openBlock)(),(0,a.createElementBlock)("div",as,[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),(0,a.createElementVNode)("pre",null,[(0,a.createElementVNode)("code",{innerHTML:r.highlightJson(e.args)},null,8,os)])])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0),(0,a.createCommentVNode)(" Output section (collapsible, collapsed by default) "),r.hasContent(e.output)?((0,a.openBlock)(),(0,a.createElementBlock)("div",ns,[(0,a.createElementVNode)("div",{class:"ff-expert-tool-call--section-header",onClick:(0,a.withModifiers)(t=>r.toggleSection(e.id,"output"),["stop"])},[(0,a.createVNode)(l,{class:(0,a.normalizeClass)(["ff-icon-small",{rotated:r.isSectionExpanded(e.id,"output")}])},null,8,["class"]),t[2]||(t[2]=(0,a.createElementVNode)("span",{class:"ff-expert-tool-call--section-label"},"Output",-1)),(0,a.createElementVNode)("span",ls,(0,a.toDisplayString)(e.durationMs||0)+" ms",1)],8,rs),r.isSectionExpanded(e.id,"output")?((0,a.openBlock)(),(0,a.createElementBlock)("div",is,[(0,a.createCommentVNode)(" eslint-disable-next-line vue/no-v-html "),(0,a.createElementVNode)("pre",null,[(0,a.createElementVNode)("code",{innerHTML:r.highlightJson(e.output)},null,8,cs)])])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)])):(0,a.createCommentVNode)("v-if",!0)]))),128))])])}],["__scopeId","data-v-3f750f09"]]),AnswerWrapper:Wt},props:{query:{type:String,required:!1,default:null},answer:{type:Object,required:!0},timings:{required:!1,default:null,type:Object},_type:{type:String,required:!0},_timestamp:{required:!0,type:Number},_uuid:{required:!0,type:String},_streamed:{required:!0,type:Boolean}},setup(){const{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}=ke({shallow:!0});return{initStreamer:e,setSubItemStreamedState:t,visibleItems:s,items:a}},computed:{toolCalls(){const e=this.answer.filter(e=>["mcp_tool","mcp_resource","mcp_resource_template","mcp_prompt"].includes(e.kind));if(e.length>0){const t=e.map(e=>({id:e.toolId,name:e.toolName,title:e.toolTitle||e.toolName,kind:e.kind,args:e.input,output:e.output,durationMs:e.durationMs}));return{type:"ai",kind:"tool_calls",toolCalls:t,duration:(e.reduce((e,t)=>e+(t.durationMs||0),0)/1e3).toFixed(2),content:`${t.length} tool call(s)`,timestamp:Date.now()}}return null},filteredAnswers(){return this.answer.filter(e=>!["mcp_tool","mcp_resource","mcp_resource_template","mcp_prompt"].includes(e.kind))}},async mounted(){await this.initStreamer(this.filteredAnswers,{shouldStream:!this._streamed})},methods:{slugify:T.Yv}},ps=(0,E.A)(us,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("tool-calls"),i=(0,a.resolveComponent)("answer-wrapper");return(0,a.openBlock)(),(0,a.createElementBlock)("div",ge,[r.toolCalls?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,message:r.toolCalls},null,8,["message"])):(0,a.createCommentVNode)("v-if",!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(i,{key:r.slugify(`${e.kind}-${e.title}-${e.summary}-${e._uuid}`),"message-uuid":s._uuid,answer:e,onStreamingComplete:e=>o.setSubItemStreamedState(t)},null,8,["message-uuid","answer","onStreamingComplete"]))),128))])}]]),hs={name:"HumanMessage",components:{MessageBubble:$e},props:{content:{required:!0,type:String},_timestamp:{required:!0,type:Number},_type:{required:!0,type:String}}},gs=(0,E.A)(hs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(l,{type:"human"},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(s.content),1)]),_:1})}]]),fs={name:"SystemMessage",components:{MessageBubble:$e},props:{_type:{type:String,required:!0},_variant:{type:String,required:!0},message:{type:String,required:!0},_timestamp:{type:Number,required:!0}}},ks=(0,E.A)(fs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("message-bubble");return(0,a.openBlock)(),(0,a.createBlock)(l,{type:"system",variant:s._variant},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(s.message),1)]),_:1},8,["variant"])}]]),Ss={name:"ExpertMessages",components:{ExpertLoadingIndicator:he},emits:["resizing"],data(){return{resizeObserver:null,lastHeight:null}},computed:{...(0,r.aH)(te.i,["messages","isWaitingForResponse"]),messageTypes(){return{ai:(0,a.markRaw)(ps),human:(0,a.markRaw)(gs),system:(0,a.markRaw)(ks)}}},mounted(){this.mountResizeObserver()},beforeUnmount(){this.unmountResizeObserver()},methods:{mountResizeObserver(){const e=this.$refs.messagesWrapper;e&&(this.lastHeight=e.offsetHeight,this.resizeObserver=new ResizeObserver(([e])=>{const t=e.contentRect.height;t!==this.lastHeight&&(this.lastHeight=t,this.$emit("resizing"))}),this.resizeObserver.observe(e))},unmountResizeObserver(){this.resizeObserver?.disconnect()}}},vs=(0,E.A)(Ss,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("expert-loading-indicator");return(0,a.openBlock)(),(0,a.createElementBlock)("div",le,[(0,a.createElementVNode)("ul",ie,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(e.messages,e=>((0,a.openBlock)(),(0,a.createElementBlock)("li",{key:e._uuid,class:"flex flex-col gap-3"},[r.messageTypes[e._type]?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(r.messageTypes[e._type]),(0,a.mergeProps)({key:0,ref_for:!0},{...e}),null,16)):(0,a.createCommentVNode)("v-if",!0)]))),128)),e.isWaitingForResponse?((0,a.openBlock)(),(0,a.createElementBlock)("li",ce,[(0,a.createVNode)(l)])):(0,a.createCommentVNode)("v-if",!0)])],512)}],["__scopeId","data-v-46bc14ac"]]),Cs={name:"ExpertModeSwitcher",components:{ToggleButtonGroup:s(18779).A},props:{isFloating:{required:!1,type:Boolean,default:!1}},computed:{...(0,r.aH)(te.i,["agentMode"]),agentModeButtons(){return[{title:"Support",value:"support-agent"},{title:"Insights",value:"insights-agent"}]},agentModeWrapper:{get(){return this.agentMode},set(e){this.setAgentMode(e)}}},methods:{...(0,r.i0)(te.i,["setAgentMode"])}},bs=(0,E.A)(Cs,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("toggle-button-group");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)({"mode-switcher-floating":s.isFloating})},[(0,a.createVNode)(l,{modelValue:r.agentModeWrapper,"onUpdate:modelValue":t[0]||(t[0]=e=>r.agentModeWrapper=e),buttons:r.agentModeButtons,"uses-links":!1,"visually-hide-title":!0},null,8,["modelValue","buttons"])],2)}],["__scopeId","data-v-e2cddf22"]]);const ys={class:"info-banner"},ws={key:0,class:"info-text"},xs={key:1,class:"info-text"};var Vs={name:"InfoBanner",computed:{...(0,r.aH)(te.i,["isSupportAgent","isInsightsAgent"])}},Bs=(0,E.A)(Vs,[["render",function(e,t,s,o,n,r){return(0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createCommentVNode)(" Info Banner "),(0,a.createElementVNode)("div",ys,[e.isSupportAgent?((0,a.openBlock)(),(0,a.createElementBlock)("p",ws,[...t[0]||(t[0]=[(0,a.createTextVNode)(" AI agent has access to all of FlowFuse's ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/docs",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"documentation and knowledge",-1),(0,a.createTextVNode)(", ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/blog",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"blogposts",-1),(0,a.createTextVNode)(", and more. ",-1)])])):(0,a.createCommentVNode)("v-if",!0),e.isInsightsAgent?((0,a.openBlock)(),(0,a.createElementBlock)("p",xs,[...t[1]||(t[1]=[(0,a.createElementVNode)("span",{title:"This feature is still under development",class:"beta-badge"},"BETA",-1),(0,a.createTextVNode)(" AI agent can access ",-1),(0,a.createElementVNode)("a",{href:"https://flowfuse.com/node-red/flowfuse/mcp/",target:"_blank",rel:"noopener noreferrer",class:"info-link"},"MCP server tools",-1),(0,a.createTextVNode)(" configured in your hosted Node-RED instances. ",-1)])])):(0,a.createCommentVNode)("v-if",!0)])],2112)}],["__scopeId","data-v-73a526c1"]]);const Ns={class:"update-banner-text update-banner-header flex items-center justify-between"},Es=["title"],Is={class:"update-banner-badge ml-4 flex-shrink-0"},As={class:"update-banner-text update-banner-body",tabindex:"0"},Ts={class:"mb-2"},_s={class:"flex justify-end"};var Ms=s(99589),Ps=s.n(Ms);const Os="0.11.0";var Ls={name:"UpdateBanner",computed:{...(0,r.aH)(F.u,["palette","editorState","version","nodeRedVersion","supportedActions","isEditorRunning"]),assistantLoaded(){return!!(this.version||this.nodeRedVersion||this.palette)},assistantPackage(){return this.palette&&0!==Object.keys(this.palette).length?this.palette?.["@flowfuse/nr-assistant"]?{installed:!0,...this.palette["@flowfuse/nr-assistant"]}:{installed:!1}:null},availableUpdate(){return Array.isArray(this.editorState?.updatesAvailable?.palette)?this.editorState?.updatesAvailable?.palette?.find(e=>"@flowfuse/nr-assistant"===e.package):null},assistantState(){if(!this.version||Ps().lt(this.version,"0.10.1"));else if(!this.isEditorRunning)return{show:!1};const e=!1!==this.assistantPackage?.enabled,t=this.assistantPackage?.installed??this.assistantLoaded,s=(t?this.assistantPackage?.version:"")||this.version||"0.0.0",a=Ps().gte(this.nodeRedVersion||"0.0.0","4.1.6")&&!!this.availableUpdate;let o=!!this.availableUpdate?.latest;this.assistantLoaded&&!a&&(o=Ps().lt(s,Os));const n={show:!t||!e||o,statusClass:"",expectedVersion:this.availableUpdate?.latest||Os,installedVersion:s,installed:t,enabled:e,chip:"",title:"",body:"",buttonText:"",buttonAction:null};return t?e?o?(n.statusClass="",n.chip=this.availableUpdate?.latest?`V${this.availableUpdate.latest} available`:"Update available",n.title="New FlowFuse Expert Version Available",n.body="There is an update available for FlowFuse Expert in the Node-RED palette. Please update to the latest version to enjoy new features and improvements.",n.buttonText="Update...",n.buttonAction=this.manageAssistantPackage):n.show=!1:(n.statusClass="warning",n.chip="Not enabled",n.title="FlowFuse Expert Not Enabled",n.body="FlowFuse Expert is installed but not enabled in the Node-RED palette. Please enable it to access its features.",n.buttonText="Enable...",n.buttonAction=this.manageAssistantPackage):(n.statusClass="warning",n.chip="Not installed",n.title="FlowFuse Expert Not Installed",n.body="FlowFuse Expert is not installed in the Node-RED palette. Please install it to access its features.",n.buttonText="Install...",n.buttonAction=this.installAssistantPackage),n}},methods:{...(0,r.i0)(F.u,["manageNodePackage","installNodePackage"]),onButtonClick(){"function"==typeof this.assistantState?.buttonAction&&this.assistantState.buttonAction()},manageAssistantPackage(){this.manageNodePackage("@flowfuse/nr-assistant")},installAssistantPackage(){this.installNodePackage("@flowfuse/nr-assistant")}}},Rs=(0,E.A)(Ls,[["render",function(e,t,s,o,n,r){const l=(0,a.resolveComponent)("ff-button");return r.assistantState.show?((0,a.openBlock)(),(0,a.createElementBlock)("div",{key:0,class:(0,a.normalizeClass)(["info-banner update-banner",r.assistantState.statusClass])},[(0,a.createElementVNode)("div",Ns,[(0,a.createElementVNode)("span",{class:"truncate flex-1 pr-4",title:r.assistantState.title},(0,a.toDisplayString)(r.assistantState.title),9,Es),(0,a.createElementVNode)("span",Is,(0,a.toDisplayString)(r.assistantState.chip),1)]),(0,a.createElementVNode)("div",As,[(0,a.createElementVNode)("p",Ts,(0,a.toDisplayString)(r.assistantState.body),1),(0,a.createElementVNode)("div",_s,[(0,a.createVNode)(l,{kind:"secondary",size:"small",onClick:r.onButtonClick},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(r.assistantState.buttonText),1)]),_:1},8,["onClick"])])])],2)):(0,a.createCommentVNode)("v-if",!0)}],["__scopeId","data-v-5cb9ca11"]]),Us=s(96836),Fs={name:"ExpertPanel",components:{ExpertModeSwitcher:bs,InfoBanner:Bs,ExpertMessages:vs,ExpertChatInput:re,UpdateBanner:Rs},inject:{togglePinWithWidth:{from:"togglePinWithWidth",default:()=>()=>{}}},props:{instance:{type:Object,required:!1,default:null},device:{type:Object,required:!1,default:null}},data(){return{scrollCheckDebounce:null,autoScroll:!0}},computed:{...(0,r.aH)(te.i,["abortController","agentMode","messages","isInsightsAgent"]),...(0,r.aH)(oe.W,{isPinned:e=>e.rightDrawer.fixed}),...(0,r.aH)(Us.n,["features"]),isEditorContext(){return this.$route?.name?.includes("editor")||!1},isInsightsModeEnabled(){return!!this.features.expertInsights},agentModeWrapper:{get(){return this.agentMode},set(e){this.setAgentMode(e)}},isInstanceRunning(){const e="running"===this.instance?.meta?.state,t="running"===this.device?.status;return e||t}},watch:{agentMode:{immediate:!0,async handler(){this.isInsightsAgent&&await this.getCapabilities(),this.addWelcomeMessageIfNeeded()}},"instance.meta.state":{handler(e){this.isEditorContext&&"running"!==e&&this.reset()}},"device.status":{handler(e){this.isEditorContext&&"running"!==e&&this.reset()}}},mounted(){this.isEditorContext&&setTimeout(()=>{this.addWelcomeMessageIfNeeded()},1e3)},beforeUnmount(){this.scrollCheckDebounce&&clearTimeout(this.scrollCheckDebounce),this.resetSessionTimer()},methods:{...(0,r.i0)(te.i,["setAgentMode","setAbortController","resetSessionTimer","addWelcomeMessageIfNeeded"]),...(0,r.i0)(B.W,["getCapabilities"]),...(0,r.i0)(F.u,["reset"]),handleStopGeneration(){this.abortController&&(this.abortController.abort(),this.setAbortController(null))},handleScroll(){this.scrollCheckDebounce&&clearTimeout(this.scrollCheckDebounce),this.scrollCheckDebounce=setTimeout(()=>{const e=this.$refs.messagesContainer;if(!e)return;const t=e.scrollHeight-e.scrollTop-e.clientHeight<100;t&&!this.autoScroll?this.autoScroll=!0:!t&&this.autoScroll&&(this.autoScroll=!1)},100)},scrollToBottom(){this.autoScroll&&this.$nextTick(()=>{if(this.$refs.scrollAnchor){const e=this.$refs.messagesContainer;if(!e)return;e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}})}}},Ds=(0,E.A)(Fs,[["render",function(e,t,s,r,l,i){const c=(0,a.resolveComponent)("expert-mode-switcher"),d=(0,a.resolveComponent)("info-banner"),m=(0,a.resolveComponent)("expert-messages"),u=(0,a.resolveComponent)("update-banner"),p=(0,a.resolveComponent)("expert-chat-input");return(0,a.openBlock)(),(0,a.createElementBlock)("div",o,[i.isInsightsModeEnabled&&i.isEditorContext?((0,a.openBlock)(),(0,a.createBlock)(c,{key:0,isFloating:!0})):(0,a.createCommentVNode)("v-if",!0),(0,a.createElementVNode)("div",{ref:"messagesContainer",class:(0,a.normalizeClass)(["messages-container",{"has-mode-switcher":i.isInsightsModeEnabled&&i.isEditorContext}]),onScroll:t[0]||(t[0]=(...e)=>i.handleScroll&&i.handleScroll(...e))},[(0,a.createVNode)(d),(0,a.createVNode)(m,{onResizing:i.scrollToBottom},null,8,["onResizing"]),(0,a.createElementVNode)("div",n,null,512)],34),(0,a.createCommentVNode)(" Updates Available Banner "),i.isEditorContext&&i.isInstanceRunning?((0,a.openBlock)(),(0,a.createBlock)(u,{key:1})):(0,a.createCommentVNode)("v-if",!0),(0,a.createVNode)(p,{onStop:i.handleStopGeneration},null,8,["onStop"])])}],["__scopeId","data-v-d99b62d4"]])}}]);