@flowfuse/flowfuse
Version:
An open source low-code development platform
1 lines • 103 kB
JavaScript
"use strict";(self.webpackChunk_flowfuse_flowfuse=self.webpackChunk_flowfuse_flowfuse||[]).push([[98,259],{6259:function(e,t,s){s.d(t,{default:function(){return b}});var a=s(41425);const o={ref:"drawer",class:"ff-expert-drawer","data-el":"expert-drawer",tabindex:"-1"},n={class:"header"},l={key:0,class:"agent-mode"},i={class:"header-actions"},r=["title"];var d=s(13020),c=s(39312),u=s(51580),p=s(10810),m=s(26195),h=s(48098),g=s(26460),f=s(96825),k=s(28409),v={name:"ExpertDrawer",components:{ToggleButtonGroup:m.A,ExpertPanel:h.default,XMarkIcon:d.A,LockClosedIcon:c.A,LockOpenIcon:u.A},inject:["togglePinWithWidth","shouldAllowPinning"],computed:{...(0,p.aH)(k.W,["rightDrawer"]),...(0,p.aH)(f.i,["agentMode"]),...(0,p.aH)(g.n,["featuresCheck"]),agentModeButtons(){return[{title:"Support",value:"support-agent"},{title:"Insights",value:"insights-agent"}]},isAssistantModeEnabled(){return!!this.featuresCheck?.isExpertAssistantFeatureEnabled},isInsightsModeEnabled(){return!!this.featuresCheck?.isExpertInsightsFeatureEnabled},isPinned(){return this.rightDrawer.fixed},agentModeWrapper:{get(){return this.agentMode},set(e){this.setAgentMode(e)}}},mounted(){setTimeout(()=>{this.$refs.drawer?.focus()},350)},methods:{...(0,p.i0)(k.W,["closeRightDrawer"]),...(0,p.i0)(f.i,["setAgentMode"]),closeDrawer(){this.closeRightDrawer()},togglePin(){this.togglePinWithWidth()}}},b=(0,s(66262).A)(v,[["render",function(e,t,s,d,c,u){const p=(0,a.g2)("toggle-button-group"),m=(0,a.g2)("LockClosedIcon"),h=(0,a.g2)("LockOpenIcon"),g=(0,a.g2)("XMarkIcon"),f=(0,a.g2)("ExpertPanel");return(0,a.openBlock)(),(0,a.CE)("div",o,[(0,a.Lk)("div",n,[t[3]||(t[3]=(0,a.Lk)("div",{class:"flex items-center gap-1.5"},[(0,a.Lk)("img",{src:"/ff-minimal-red.svg",alt:"FlowFuse",class:"w-5 h-5 shrink-0"}),(0,a.Lk)("h2",{class:"title"},"Expert")],-1)),u.isInsightsModeEnabled&&u.isAssistantModeEnabled?((0,a.openBlock)(),(0,a.CE)("div",l,[(0,a.createVNode)(p,{modelValue:u.agentModeWrapper,"onUpdate:modelValue":t[0]||(t[0]=e=>u.agentModeWrapper=e),buttons:u.agentModeButtons,usesLinks:!1,"visually-hide-title":!0},null,8,["modelValue","buttons"])])):(0,a.Q3)("v-if",!0),(0,a.Lk)("div",i,[u.shouldAllowPinning()?((0,a.openBlock)(),(0,a.CE)("button",{key:0,class:(0,a.C4)(["header-button pin-button",{"is-pinned":u.isPinned}]),title:u.isPinned?"Unpin drawer":"Pin drawer open","data-el":"expert-drawer-pin-button",onClick:t[1]||(t[1]=(...e)=>u.togglePin&&u.togglePin(...e))},[u.isPinned?((0,a.openBlock)(),(0,a.createBlock)(m,{key:0,class:"ff-icon"})):((0,a.openBlock)(),(0,a.createBlock)(h,{key:1,class:"ff-icon"}))],10,r)):(0,a.Q3)("v-if",!0),(0,a.Lk)("button",{class:"header-button",title:"Close Expert","data-el":"expert-drawer-close-button",onClick:t[2]||(t[2]=(...e)=>u.closeDrawer&&u.closeDrawer(...e))},[(0,a.createVNode)(g,{class:"ff-icon"})])])]),(0,a.createVNode)(f)],512)}],["__scopeId","data-v-83bf8a2c"]])},48098:function(e,t,s){s.r(t),s.d(t,{default:function(){return Da}});var a=s(41425);const o={class:"ff-expert"},n={ref:"scrollAnchor",class:"scroll-anchor"};var l=s(10810);const i={class:"action-buttons"},r=["disabled"],d={class:"right-buttons"},c=["placeholder","disabled"],u={class:"actions"},p={class:"left overflow-hidden"},m={class:"right"},h=["disabled"],g={class:"expert-settings"},f={class:"expert-settings__group"},k={class:"expert-settings__group"};var v=s(51040),b=s(64725),y=s(82287);const C={class:"capabilities-selector"},S={style:{"min-width":"300px"}},w={class:"flex flex-col gap-1 flex-1 min-w-0"},x={class:"truncate",style:{"line-height":"16px"}},B={key:0,class:"text-gray-400 text-sm truncate leading-4"},_={class:"tool-count-badge self-start",title:"Tools"};var A=s(20487),I=s(34904),L=s(31911),E=s(63391),T={name:"CapabilitiesSelector",components:{FfCheckbox:I.A,ListboxOption:A.h7,FfListbox:L.A},computed:{...(0,l.aH)(E.W,["selectedCapabilities","capabilities"]),hasCapabilities(){return this.capabilities&&this.capabilities.length>0},capabilitiesHandler:{get(){return this.selectedCapabilities},set(e){this.setSelectedCapabilities(e)}}},methods:{...(0,l.i0)(E.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")}}},V=s(66262),P=(0,V.A)(T,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("ff-checkbox"),r=(0,a.g2)("ListboxOption"),d=(0,a.g2)("ff-listbox");return(0,a.openBlock)(),(0,a.CE)("div",C,[(0,a.createVNode)(d,{modelValue:l.capabilitiesHandler,"onUpdate:modelValue":t[0]||(t[0]=e=>l.capabilitiesHandler=e),options:e.capabilities,disabled:!l.hasCapabilities,"return-model":"",multiple:"","label-key":"name","value-key":["mcpServer"],placeholder:"Resources","open-above":"","options-min-width":280,"align-right":""},{options:(0,a.k6)(({options:e})=>[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(e,e=>((0,a.openBlock)(),(0,a.createBlock)(r,{key:e.mcpServer,as:"template",value:e,class:"ff-option ff-team-selection-option","data-option":e.mcpServer,title:l.getResourceTooltip(e)},{default:(0,a.k6)(({active:t,selected:s})=>[(0,a.Lk)("li",S,[(0,a.Lk)("div",{class:(0,a.C4)(["ff-option-content flex truncate justify-start items-start! gap-2! p-2!",{active:t}]),"data-click-exclude":"right-drawer"},[(0,a.Lk)("div",null,[(0,a.createVNode)(i,{modelValue:s,onClick:(0,a.D$)(t=>l.onCheckboxClick(e),["stop","prevent"])},null,8,["modelValue","onClick"])]),(0,a.Lk)("div",w,[(0,a.Lk)("span",x,(0,a.v_)(e.title),1),e.title?((0,a.openBlock)(),(0,a.CE)("p",B,(0,a.v_)(e.mcpServerName),1)):(0,a.Q3)("v-if",!0)]),(0,a.Lk)("span",_,(0,a.v_)(e.toolCount),1)],2)])]),_:2},1032,["value","data-option","title"]))),128))]),_:1},8,["modelValue","options","disabled"])])}]]);const M={class:"tool-permissions","data-el":"expert-tool-permissions"},O={key:0,class:"tool-permissions__notice"},R={key:1,class:"tool-permissions__notice"},q={class:"tool-permissions__group-title"},N={class:"tool-permissions__block"},$={class:"tool-permissions__cell"},F={class:"tool-permissions__title"},U={class:"tool-permissions__hint"},W={class:"tool-permissions__default-control"},Q={key:0,class:"tool-permissions__count"},D={class:"tool-permissions__cell"},H={class:"tool-permissions__title"},z={key:1,class:"tool-permissions__session"},j={class:"tool-permissions__type"},K={key:0,class:"tool-permissions__static"},G={key:1,class:"tool-permissions__empty"};var J=s(99589),Y=s.n(J),X=s(81021),Z=s(1153),ee=s(78128),te=s(26195),se=s(10964),ae=s(78721);const oe=["read","write","delete"],ne={read:"Read",write:"Write",delete:"Delete"},le="nr‑assistant";var ie={name:"ToolPermissionsSettings",components:{ToggleButtonGroup:te.A,"ff-accordion":ee.A},props:{inEditor:{type:Boolean,default:!1}},computed:{...(0,l.aH)(ae.u7,["toolCatalog","teamGroupDefaults","teamToolPreferences","savedToolPolicyFor","sessionOverrideFor","toolAvailabilityFor"]),...(0,l.aH)(se.A,["teamMembership"]),canUseWriteTools(){return(0,X.C$)(Z.YK.Member,this.teamMembership)},isImmersive(){return"immersive"===(0,se.A)().expert?.scope},policyButtons(){return[{title:"Always allow",value:"allow"},{title:"Ask",value:"ask"},{title:"Always deny",value:"deny"}]},defaultColumns(){return[{label:"Action",key:"action"},{label:"Permission",key:"permission",class:"permission-col"}]},toolColumns(){return[{label:"Tool",key:"tool",class:"tool-col"},{label:"Type",key:"type"},{label:"Permission",key:"permission",class:"permission-col"}]},classDefaults(){return[{key:"read",label:"Read",hint:"View only, no changes"},{key:"write",label:"Write",hint:"Create or change resources"},{key:"delete",label:"Delete",hint:"Remove resources"}]},orderedGroups(){const e={key:ae.Kg.FLOW_BUILDING,title:"Flow Building Tools",tools:this.groupTools(ae.Kg.FLOW_BUILDING),empty:"No flow-building tools available yet."},t={key:ae.Kg.PLATFORM,title:"FlowFuse Platform Tools",tools:this.groupTools(ae.Kg.PLATFORM),empty:"Individual platform tools appear here once they ship."};return this.isImmersive?[e,t]:[t,e]}},methods:{...(0,l.i0)(ae.u7,["setToolPreference","setToolClassDefault","promoteSessionOverride","resetGroupClassPreferences"]),scopeLabel(e){return ne[e]||ne.write},familyHasCustom(e){return e.variantKeys.some(e=>!!this.teamToolPreferences[e])},customCount(e,t){return e.tools.filter(e=>e.toolClass===t&&this.familyHasCustom(e)).length},sessionNoteFor(e){const t=this.sessionOverrideFor(e);return"allow"===t?"Allowed for this chat":"deny"===t?"Denied for this chat":null},groupTools(e){const t=new Map;for(const s of this.toolCatalog){if((0,ae.F8)(s)!==e)continue;const a=this.displayName(s),o=(0,ae.Kl)(s),n=`${o}::${a}`;t.has(n)||t.set(n,{familyKey:n,displayName:a,toolClass:o,variants:[]}),t.get(n).variants.push(s)}const s=[];for(const e of t.values()){const t=this.resolveFamily(e.variants);s.push({familyKey:e.familyKey,displayName:e.displayName,toolClass:e.toolClass,status:t.status,activeKey:t.activeKey,variantKeys:e.variants.map(e=>e.key),...this.describeControl(e.toolClass,t)})}return s.sort((e,t)=>oe.indexOf(e.toolClass)-oe.indexOf(t.toolClass)||e.displayName.localeCompare(t.displayName))},displayName(e){const t=e.name||e.key||"";return t.replace(/[ _-]?[vV]\d+$/,"").trim()||t},setFamilyPreference(e,t){for(const s of e)this.setToolPreference(s,t)},resolveFamily(e){const t=e.map(e=>({v:e,a:this.toolAvailabilityFor(e)})),s=t.filter(e=>"available"===e.a.status),a=t.some(e=>"requires-update"===e.a.status);if(s.length){const e=s.sort((e,t)=>this.compareMin(e.v,t.v)).pop();return{status:"available",activeKey:e.v.key,deprecated:e.a.deprecated||a,requiredVersion:a?this.latestRequiredVersion(t):null}}const o=t.filter(e=>"requires-update"===e.a.status);return o.length?{status:"requires-update",activeKey:o[0].v.key,deprecated:!1,requiredVersion:this.latestRequiredVersion(t)}:{status:"deprecated",activeKey:e[0].key,deprecated:!0,requiredVersion:null}},describeControl(e,t){return"requires-update"===t.status?{control:"status",statusLabel:"Update required",statusHint:t.requiredVersion?`Needs ${le} ${t.requiredVersion}`:`Update ${le} to enable`}:"deprecated"===t.status?{control:"status",statusLabel:"Deprecated",statusHint:`No longer available — update ${le}`}:"read"===e||this.canUseWriteTools?{control:"toggle",statusLabel:"",statusHint:t.deprecated?`Newer version available — update ${le}`:""}:{control:"role",statusLabel:"Unavailable",statusHint:""}},compareMin(e,t){const s=e.minVersion,a=t.minVersion;return s&&a&&Y().valid(s)&&Y().valid(a)?Y().compare(s,a):s&&!a?1:!s&&a?-1:0},latestRequiredVersion(e){const t=e.map(e=>e.a.requiredVersion).filter(e=>e&&Y().valid(e));return t.length?t.sort(Y().compare).pop():null}}},re=(0,V.A)(ie,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("ff-data-table-cell"),r=(0,a.g2)("ff-button"),d=(0,a.g2)("ToggleButtonGroup"),c=(0,a.g2)("ff-data-table-row"),u=(0,a.g2)("ff-data-table"),p=(0,a.g2)("ff-accordion"),m=(0,a.gN)("ff-tooltip");return(0,a.openBlock)(),(0,a.CE)("div",M,[s.inEditor?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.CE)("p",O," Flow-building tools run in an instance editor. Open one to let the Expert use them; you can still set their permissions here. ")),l.canUseWriteTools?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.CE)("p",R," Your role is read-only, so the Expert can use read-only tools but cannot run actions that change flows. ")),((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(l.orderedGroups,s=>((0,a.openBlock)(),(0,a.CE)("section",{key:s.key,class:"tool-permissions__section"},[(0,a.Lk)("h4",q,(0,a.v_)(s.title),1),(0,a.Lk)("div",N,[t[1]||(t[1]=(0,a.Lk)("p",{class:"tool-permissions__subtitle"},"Default permissions",-1)),t[2]||(t[2]=(0,a.Lk)("p",{class:"tool-permissions__intro"}," Choose what the Expert may do by default for each action type. A permission set on an individual tool below overrides its type default, and keeps that setting until you reset it. ",-1)),(0,a.createVNode)(u,{columns:l.defaultColumns,"show-search":!1},{rows:(0,a.k6)(()=>[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(l.classDefaults,o=>((0,a.openBlock)(),(0,a.createBlock)(c,{key:o.key},{default:(0,a.k6)(()=>[(0,a.createVNode)(i,null,{default:(0,a.k6)(()=>[(0,a.Lk)("div",$,[(0,a.Lk)("span",F,(0,a.v_)(o.label),1),(0,a.Lk)("span",U,(0,a.v_)(o.hint),1)])]),_:2},1024),(0,a.createVNode)(i,{class:"permission-col"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",W,[l.customCount(s,o.key)?((0,a.openBlock)(),(0,a.CE)("span",Q,(0,a.v_)(l.customCount(s,o.key))+" set individually",1)):(0,a.Q3)("v-if",!0),l.customCount(s,o.key)?(0,a.bo)(((0,a.openBlock)(),(0,a.createBlock)(r,{key:1,kind:"tertiary",size:"small",class:"tool-permissions__reset",onClick:t=>e.resetGroupClassPreferences(s.key,o.key)},{default:(0,a.k6)(()=>[...t[0]||(t[0]=[(0,a.eW)(" Reset ",-1)])]),_:1},8,["onClick"])),[[m,`Reset ${o.label} tools in ${s.title} to this default`,"left"]]):(0,a.Q3)("v-if",!0),(0,a.createVNode)(d,{class:"tool-permissions__toggle",size:"small","uses-links":!1,buttons:l.policyButtons,"model-value":e.teamGroupDefaults(s.key)[o.key],"onUpdate:modelValue":t=>e.setToolClassDefault(s.key,o.key,t)},null,8,["buttons","model-value","onUpdate:modelValue"])])]),_:2},1024)]),_:2},1024))),128))]),_:2},1032,["columns"])]),s.tools.length?((0,a.openBlock)(),(0,a.createBlock)(p,{key:0,label:"Individual tools","set-open":!1},{content:(0,a.k6)(()=>[(0,a.createVNode)(u,{columns:l.toolColumns,"show-search":!1},{rows:(0,a.k6)(()=>[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(s.tools,s=>((0,a.openBlock)(),(0,a.createBlock)(c,{key:s.familyKey},{default:(0,a.k6)(()=>[(0,a.createVNode)(i,{class:"tool-col"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",D,[(0,a.Lk)("span",H,(0,a.v_)(s.displayName),1),s.statusHint?((0,a.openBlock)(),(0,a.CE)("span",{key:0,class:(0,a.C4)(["tool-permissions__hint",`is-${s.status}`])},(0,a.v_)(s.statusHint),3)):(0,a.Q3)("v-if",!0),l.sessionNoteFor(s.activeKey)?((0,a.openBlock)(),(0,a.CE)("span",z,[(0,a.eW)((0,a.v_)(l.sessionNoteFor(s.activeKey))+" ",1),(0,a.createVNode)(r,{kind:"tertiary",size:"small",onClick:t=>e.promoteSessionOverride(s.activeKey)},{default:(0,a.k6)(()=>[...t[3]||(t[3]=[(0,a.eW)(" Make permanent ",-1)])]),_:1},8,["onClick"])])):(0,a.Q3)("v-if",!0)])]),_:2},1024),(0,a.createVNode)(i,null,{default:(0,a.k6)(()=>[(0,a.Lk)("span",j,(0,a.v_)(l.scopeLabel(s.toolClass)),1)]),_:2},1024),(0,a.createVNode)(i,{class:"permission-col"},{default:(0,a.k6)(()=>["toggle"!==s.control?((0,a.openBlock)(),(0,a.CE)("span",K,(0,a.v_)(s.statusLabel),1)):((0,a.openBlock)(),(0,a.createBlock)(d,{key:1,class:"tool-permissions__toggle",size:"small","uses-links":!1,buttons:l.policyButtons,"model-value":e.savedToolPolicyFor(s.activeKey),"onUpdate:modelValue":e=>l.setFamilyPreference(s.variantKeys,e)},null,8,["buttons","model-value","onUpdate:modelValue"]))]),_:2},1024)]),_:2},1024))),128))]),_:2},1032,["columns"])]),_:2},1024)):((0,a.openBlock)(),(0,a.CE)("p",G,(0,a.v_)(s.empty),1))]))),128))])}],["__scopeId","data-v-28f8ca3c"]]);const de=["title"],ce={class:"text"},ue={class:"icon-wrapper"};var pe=s(52725),me=s(65428),he=s(22511),ge={name:"DefaultChip",components:{XMarkIcon:pe.A,PlusIcon:me.A},props:{modelValue:{type:Boolean,required:!1,default:!0},text:{type:String,required:!1,default:""},title:{type:String,required:!1,default:""},disabled:{type:Boolean,required:!1,default:!1}},emits:["toggle"],methods:{pluralize:he.td,onClick(){this.disabled||this.$emit("toggle")}}},fe=(0,V.A)(ge,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("XMarkIcon"),r=(0,a.g2)("PlusIcon");return(0,a.openBlock)(),(0,a.CE)("div",{class:(0,a.C4)(["chip",{active:s.modelValue,disabled:s.disabled}]),title:s.title,onClick:t[0]||(t[0]=(...e)=>l.onClick&&l.onClick(...e))},[(0,a.Lk)("div",ce,[(0,a.RG)(e.$slots,"text",{},()=>[(0,a.Lk)("span",null,(0,a.v_)(s.text),1)],!0)]),t[1]||(t[1]=(0,a.Lk)("span",{class:"separator"},null,-1)),(0,a.Lk)("div",ue,[(0,a.RG)(e.$slots,"icon",{active:s.modelValue},()=>[s.modelValue?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,class:"ff-icon ff-icon-sm"})):((0,a.openBlock)(),(0,a.createBlock)(r,{key:1,class:"ff-icon ff-icon-sm"}))],!0)])],10,de)}],["__scopeId","data-v-acc71ca6"]]);const ke={class:"context-selector-container"};var ve={name:"ContextChip",components:{DefaultChip:fe},props:{contextItem:{type:Object,required:!1,default:()=>({})}},computed:{...(0,l.aH)(ae.u7,["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,l.i0)(ae.u7,["setSelectedContext"]),pluralize:he.td,toggleSelection(){const e=this.selectedContext.filter(e=>e.name!==this.contextItem.name);this.setSelectedContext(e)}}},be=(0,V.A)(ve,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(i,{modelValue:!!s.contextItem,text:l.text,title:l.title,onToggle:l.toggleSelection},null,8,["modelValue","text","title","onToggle"])}]]);const ye=["title"];var Ce={name:"DebugChip",components:{DefaultChip:fe},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,l.aH)(ae.u7,["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||"",l=e.metadata?.format||"",i=e.source?.type||"",r=e.metadata?.property||"",d=[];return n&&d.push(`node: ${n}`),o&&d.push(`topic: ${o}`),a&&i&&d.push(`${i} : (${a})`),r&&(l?d.push(`property: ${r} ${l}`):d.push(`property: ${r}`)),`${t+1}: ${d.join(", ")}`}).join("\n")}`}},methods:{...(0,l.i0)(ae.u7,["resetDebugLogContext"]),pluralize:he.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.resetDebugLogContext()}}},Se=(0,V.A)(Ce,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(i,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:l.toggleSelection},{text:(0,a.k6)(()=>[t[0]||(t[0]=(0,a.Lk)("span",null,"Debug",-1)),(0,a.Lk)("span",{class:"counter italic",title:l.selectionTitle},"( "+(0,a.v_)(l.selectedCounter)+" "+(0,a.v_)(l.pluralize("log",l.selectedCounter))+" )",9,ye)]),_:1},8,["modelValue","onToggle"])}]]);const we=["title"];var xe={name:"SelectionChip",components:{DefaultChip:fe},props:{modelValue:{type:Boolean,required:!1,default:!0}},emits:["update:modelValue"],computed:{...(0,l.aH)(ae.u7,["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,l.i0)(ae.u7,["setSelectedNodes"]),pluralize:he.td,toggleSelection(){this.$emit("update:modelValue",!this.modelValue),this.setSelectedNodes([])}}},Be=(0,V.A)(xe,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("default-chip");return(0,a.openBlock)(),(0,a.createBlock)(i,{class:"flow-selection-button",modelValue:s.modelValue,onToggle:l.toggleSelection},{text:(0,a.k6)(()=>[t[0]||(t[0]=(0,a.Lk)("span",null,"Selection",-1)),(0,a.Lk)("span",{class:"counter italic",title:l.selectionTitle},"( "+(0,a.v_)(l.selectedCounter)+" "+(0,a.v_)(l.pluralize("node",l.selectedCounter))+" )",9,we)]),_:1},8,["modelValue","onToggle"])}]]);const _e={class:"context-selector mr-2"};var Ae=s(9080),Ie=s(81429),Le=s(41541),Ee=s(26218),Te={name:"ContextSelectorButton",components:{PaperClipIcon:Ae.A},data(){return{selectedContextItems:[]}},computed:{...(0,l.aH)(ae.u7,["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=Ie.A;return"CubeIcon"===e.menuIcon?t=Le.A:"Bars4Icon"===e.menuIcon&&(t=Ee.A),{...e,icon:t}})}}},methods:{pluralize:he.td,...(0,l.i0)(ae.u7,["setSelectedContext"]),selectItem(e){if(e.onSelectAction)(0,ae.u7)()[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))}}}},Ve=(0,V.A)(Te,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("PaperClipIcon"),r=(0,a.g2)("ff-listbox");return(0,a.openBlock)(),(0,a.CE)("div",_e,[(0,a.createVNode)(r,{modelValue:n.selectedContextItems,"onUpdate:modelValue":t[0]||(t[0]=e=>n.selectedContextItems=e),class:(0,a.C4)(["context-selector",l.hasSelection?"active":""]),options:l.contextOptions,disabled:!l.hasContextOptions,"hide-chevron":!0,"icon-only":!0,"return-model":"","label-key":"label",placeholder:"Context","open-above":"","options-min-width":250,"align-right":"",onOptionSelected:l.selectItem},{icon:(0,a.k6)(()=>[(0,a.createVNode)(i,{class:"icon ff-icon ff-icon-sm"})]),_:1},8,["modelValue","class","options","disabled","onOptionSelected"])])}]]),Pe=s(96825),Me={name:"ContextSelector",components:{ContextChip:be,DebugChip:Se,SelectionChip:Be,ContextSelectorButton:Ve},computed:{...(0,l.aH)(ae.u7,["getSelectedContext","hasDebugLogsSelected","hasUserSelection"]),...(0,l.aH)(Pe.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)}}};const Oe=(0,V.A)(Me,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("context-selector-button"),r=(0,a.g2)("context-chip"),d=(0,a.g2)("debug-chip"),c=(0,a.g2)("selection-chip");return(0,a.openBlock)(),(0,a.CE)("div",ke,[e.isInsightsAgent?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(i,{key:0})),(0,a.Lk)("div",{class:"chips-container",onWheel:t[0]||(t[0]=(...e)=>l.horizontalScrolling&&l.horizontalScrolling(...e))},[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(l.selectedContextFiltered,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(r,{key:t,contextItem:e},null,8,["contextItem"]))),128)),e.hasDebugLogsSelected&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(d,{key:0})):(0,a.Q3)("v-if",!0),e.hasUserSelection&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(c,{key:1})):(0,a.Q3)("v-if",!0)],32)])}],["__scopeId","data-v-104983ce"]]);var Re=Oe,qe=s(28409),Ne={name:"ExpertChatInput",components:{CapabilitiesSelector:P,Cog8ToothIcon:v.A,ContextSelector:Re,DefaultChip:fe,FormHeading:b.A,ResizeBar:y.A,ToolPermissionsSettings:re},inject:{togglePinWithWidth:{from:"togglePinWithWidth",default:()=>()=>{}}},emits:["send","stop"],setup(){const{startResize:e,heightStyle:t,bindResizer:s,setHeight:o,isResizing:n}=function(){const e=(0,a.KR)(window.innerWidth),t=(0,a.KR)(window.innerHeight),s=(0,a.KR)(0),o=(0,a.KR)(0),n=(0,a.KR)(0),l=(0,a.KR)(0),i=(0,a.KR)(0),r=(0,a.KR)(1),d=(0,a.KR)(1),c=(0,a.KR)(!1);let u=0,p=0,m=0,h=0;const g=(0,a.KR)(0),f=(0,a.KR)(0);function k(){c.value=!1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",k)}function v(a){if(c.value){const i=a.clientX-u,r=a.clientY-p,d=m+i,c=h-r;g.value=Math.min(Math.max(s.value,d),e.value-n.value),f.value=Math.min(Math.max(o.value,c),t.value-l.value)}}return{heightStyle:(0,a.EW)(()=>t.value<i.value?`${Math.min(f.value,t.value)}px`:`${Math.min(f.value,t.value*d.value)}px`),widthStyle:(0,a.EW)(()=>e.value<i.value?`${Math.min(g.value,e.value)}px`:`${Math.min(g.value,e.value*r.value)}px`),isResizing:(0,a.EW)(()=>c.value),startResize:function(e){c.value=!0,u=e.clientX,p=e.clientY,m=g.value,h=f.value,document.addEventListener("mousemove",v),document.addEventListener("mouseup",k)},stopResize:k,bindResizer:function({component:e=null,initialWidth:t=0,initialHeight:a=0,minWidth:c,minHeight:u,maxViewportMarginX:p,maxViewportMarginY:m,mobileBreakpoint:h=640,maxWidthRatio:k,maxHeightRatio:v}={}){let b=t,y=a;if(e){const s=e.$el||e;if(s&&s.getBoundingClientRect){const e=s.getBoundingClientRect();b=t||e.width,y=a||e.height}}f.value=y,g.value=b,s.value=c,o.value=u,n.value=p,l.value=m,i.value=h??0,r.value=k??1,d.value=v??1},setWidth:function(e){g.value=e},setHeight:function(e){f.value=e}}}();return{startResize:e,bindResizer:s,heightStyle:t,setHeight:o,isInputResizing:n}},data(){return{inputText:"",includeSelection:!0,isTextareaFocused:!1,requestingPlanChange:!1,userResized:!1}},computed:{...(0,l.aH)(ae.u7,["isImmersiveInstance","isImmersiveDevice"]),...(0,l.aH)(qe.W,["rightDrawer"]),...(0,l.aH)(Pe.i,["messages","isSessionExpired","isInsightsAgent","hasSelectedCapabilities","hasMessages","isWaitingForResponse","pendingInput","composerCommand","questionCadence","planMode"]),questionCadenceOptions(){return[{label:"All at once",value:"all",description:"Asks every open question together in a single turn."},{label:"One at a time",value:"one",description:"Asks one question, then follows up based on your answer."}]},questionCadenceWrapper:{get(){return this.questionCadence},set(e){this.setQuestionCadence(e)}},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.requestingPlanChange?"Describe a change to the plan, or paste an edited version":this.isInsightsAgent?"Tell us what you want to know about":"Tell us what you need help with"},isImmersive(){return this.isImmersiveDevice||this.isImmersiveInstance},containerStyle(){return this.userResized?{height:this.heightStyle}:{}}},watch:{pendingInput(e){e&&(this.inputText=e,this.requestingPlanChange=!1,this.setPendingInput(""),this.$nextTick(()=>this.$refs.textarea.focus()))},composerCommand(e){e&&(this.inputText="",this.requestingPlanChange="request-plan-change"===e,this.requestingPlanChange&&this.$nextTick(()=>this.$refs.textarea.focus()),this.setComposerCommand(null))},inputText(e){e&&this.requestingPlanChange&&(this.requestingPlanChange=!1)}},mounted(){this.bindResizer({component:this.$refs.resizeTarget,maxHeightRatio:.9,minHeight:120,maxViewportMarginY:80}),this.fetchToolCatalog()},methods:{...(0,l.i0)(ae.u7,["resetContextSelection"]),...(0,l.i0)(Pe.i,["startOver","handleQuery","setPendingInput","setComposerCommand","setQuestionCadence","setPlanMode","fetchToolCatalog"]),openSettings(){this.$refs.settingsDialog.show()},async handleSend(){if(!this.canSend)return;const e=this.inputText.trim();this.isDrawerPinned||0!==this.messages.length||this.togglePinWithWidth(),this.handleQuery({query:e}).then(()=>{this.$nextTick(()=>{this.$refs.textarea.focus()})}).catch(e=>e),this.inputText="",this.requestingPlanChange=!1},onStartResize(e){const t=this.$refs.resizeTarget;t&&this.setHeight(t.offsetHeight),this.userResized=!0,this.startResize(e)},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())}}},$e=(0,V.A)(Ne,[["render",function(e,t,s,o,n,l){const v=(0,a.g2)("resize-bar"),b=(0,a.g2)("ff-toggle-switch"),y=(0,a.g2)("default-chip"),C=(0,a.g2)("capabilities-selector"),S=(0,a.g2)("Cog8ToothIcon"),w=(0,a.g2)("context-selector"),x=(0,a.g2)("FormHeading"),B=(0,a.g2)("ff-radio-group"),_=(0,a.g2)("tool-permissions-settings"),A=(0,a.g2)("ff-dialog");return(0,a.openBlock)(),(0,a.CE)("div",{ref:"resizeTarget",class:"ff-expert-input",style:(0,a.Tr)(l.containerStyle)},[(0,a.createVNode)(v,{"is-resizing":o.isInputResizing,direction:"horizontal",onMousedown:l.onStartResize},null,8,["is-resizing","onMousedown"]),(0,a.Q3)(" Action buttons row "),(0,a.Lk)("div",i,[(0,a.Lk)("button",{type:"button",class:"btn-start-over",disabled:e.isWaitingForResponse&&!e.isSessionExpired,onClick:t[0]||(t[0]=(...e)=>l.handleStartOver&&l.handleStartOver(...e))}," Start over ",8,r),(0,a.Lk)("div",d,[e.isInsightsAgent?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(y,{key:0,class:"plan-mode-chip",text:"Plan mode",modelValue:e.planMode,disabled:e.isWaitingForResponse,title:"Plan mode: the Expert proposes a plan before making any changes, and acts only once you approve it.","data-el":"expert-plan-mode-toggle",onToggle:t[1]||(t[1]=t=>e.setPlanMode(!e.planMode))},{icon:(0,a.k6)(()=>[(0,a.createVNode)(b,{modelValue:e.planMode,size:"small",tabindex:"-1"},null,8,["modelValue"])]),_:1},8,["modelValue","disabled"])),e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(C,{key:1})):((0,a.openBlock)(),(0,a.CE)("button",{key:2,type:"button",class:"btn-settings","data-el":"expert-settings-menu","aria-label":"Expert settings",title:"Expert settings",onClick:t[2]||(t[2]=(...e)=>l.openSettings&&l.openSettings(...e))},[(0,a.createVNode)(S,{class:"btn-settings__icon"})]))])]),(0,a.Lk)("div",{class:(0,a.C4)(["input-wrapper",{focused:n.isTextareaFocused}])},[(0,a.Q3)(" Textarea "),(0,a.bo)((0,a.Lk)("textarea",{ref:"textarea","onUpdate:modelValue":t[3]||(t[3]=e=>n.inputText=e),class:"chat-input",placeholder:l.placeholderText,disabled:l.isInputDisabled,onKeydown:t[4]||(t[4]=(...e)=>l.handleKeydown&&l.handleKeydown(...e)),onFocus:t[5]||(t[5]=e=>n.isTextareaFocused=!0),onBlur:t[6]||(t[6]=e=>n.isTextareaFocused=!1)},null,40,c),[[a.Jo,n.inputText]]),(0,a.Lk)("div",u,[(0,a.Lk)("div",p,[l.isImmersive&&!e.isInsightsAgent?((0,a.openBlock)(),(0,a.createBlock)(w,{key:0})):(0,a.Q3)("v-if",!0)]),(0,a.Lk)("div",m,[e.isWaitingForResponse&&!e.isSessionExpired?((0,a.openBlock)(),(0,a.CE)("button",{key:0,type:"button",class:"btn-stop",onClick:t[7]||(t[7]=(...e)=>l.handleStop&&l.handleStop(...e))}," Stop ")):e.isSessionExpired?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.CE)("button",{key:1,type:"button",class:"btn-send",disabled:!l.canSend,onClick:t[8]||(t[8]=(...e)=>l.handleSend&&l.handleSend(...e))}," Send ",8,h))])])],2),(0,a.createVNode)(A,{ref:"settingsDialog",header:"Expert settings","confirm-label":"Done","can-be-canceled":!1,"data-el":"expert-settings-dialog",boxClass:"max-w-[54rem]!"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",g,[(0,a.Lk)("div",f,[(0,a.createVNode)(x,null,{default:(0,a.k6)(()=>[...t[10]||(t[10]=[(0,a.eW)("Follow-up questions",-1)])]),_:1}),t[11]||(t[11]=(0,a.Lk)("p",null,"When a request needs more detail, choose how the Expert asks for it.",-1)),(0,a.createVNode)(B,{modelValue:l.questionCadenceWrapper,"onUpdate:modelValue":t[9]||(t[9]=e=>l.questionCadenceWrapper=e),orientation:"vertical",options:l.questionCadenceOptions,"data-el":"expert-question-cadence"},null,8,["modelValue","options"])]),(0,a.Lk)("div",k,[(0,a.createVNode)(x,null,{default:(0,a.k6)(()=>[...t[12]||(t[12]=[(0,a.eW)("Tool permissions",-1)])]),_:1}),t[13]||(t[13]=(0,a.Lk)("p",null,"Choose which actions the Expert can run, and which need your approval.",-1)),(0,a.createVNode)(_,{"in-editor":l.isImmersive},null,8,["in-editor"])])])]),_:1},512)],4)}],["__scopeId","data-v-454b0274"]]);const Fe={ref:"messagesWrapper",class:"messages-wrapper"},Ue={class:"flex flex-col gap-3"},We={key:0},Qe={class:"ff-expert-loading"},De={key:0,class:"loading-message"};var He=s(2e3),ze={name:"ExpertLoadingIndicator",data(){return{showMessage:!1,currentMessageIndex:0,messageVariants:{[He.C]:["Ingesting the docs...","Reading the blog...","Searching through FlowFuse knowledge base","Analyzing your question...","Finding the best answer..."],[He.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,l.aH)(Pe.i,["loadingVariant","inFlightUpdates"]),messages(){return this.inFlightUpdates.length>0?this.inFlightUpdates: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)}},je=(0,V.A)(ze,[["render",function(e,t,s,o,n,l){return(0,a.openBlock)(),(0,a.CE)("div",Qe,[t[0]||(t[0]=(0,a.Lk)("div",{class:"loading-dots"},[(0,a.Lk)("div",{class:"loading-dot"}),(0,a.Lk)("div",{class:"loading-dot"}),(0,a.Lk)("div",{class:"loading-dot"})],-1)),n.showMessage?((0,a.openBlock)(),(0,a.CE)("div",De,(0,a.v_)(l.currentMessage),1)):(0,a.Q3)("v-if",!0)])}],["__scopeId","data-v-987264e4"]]);const Ke={class:"flex flex-col gap-3"};var Ge=s(99900);const Je={class:"guide-badge"};var Ye={name:"AnswerBadge",props:{kind:{required:!0,type:String}},computed:{title(){return"resources"===this.kind?"Resources":"Setup Guide"}}},Xe=(0,V.A)(Ye,[["render",function(e,t,s,o,n,l){return(0,a.openBlock)(),(0,a.CE)("div",Je,[(0,a.Lk)("span",null,(0,a.v_)(l.title),1)])}],["__scopeId","data-v-7d8bb1a7"]]);const Ze={key:0,class:"guide-header"},et={class:"guide-title"},tt={key:0,class:"guide-summary"},st=["innerHTML"];var at=s(50011),ot=s(69510),nt=s(92753),lt=s(27402),it=s(85262),rt=s(95387),dt=s(69359),ct=s(60023);at.A.registerLanguage("bash",ot.A),at.A.registerLanguage("shell",ot.A),at.A.registerLanguage("css",nt.A),at.A.registerLanguage("javascript",rt.A),at.A.registerLanguage("js",rt.A),at.A.registerLanguage("json",lt.A),at.A.registerLanguage("python",it.A),at.A.registerLanguage("py",it.A),at.A.registerLanguage("typescript",rt.A),at.A.registerLanguage("ts",rt.A),at.A.registerLanguage("xml",dt.A),at.A.registerLanguage("html",dt.A);const ut='<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>',pt=ut;function mt({delayMs:e=30,splitRegex:t=/\s+/,joinWith:s=" "}={}){const o=(0,a.KR)(""),n=(0,a.KR)(!1);let l=null,i=[],r=0;const d=()=>{l&&clearTimeout(l),l=null,n.value=!1,i=[],r=0};return(0,a.xo)(d),{text:o,isStreaming:n,stream:(c="")=>(d(),o.value="",i=String(c).trim().split(t).filter(Boolean),r=0,n.value=!0,new Promise(t=>{const d=async()=>n.value?r>=i.length?(await(0,a.dY)(),n.value=!1,t()):(o.value+=(o.value?s:"")+i[r],r+=1,void(l=setTimeout(d,e))):t();d()})),stop:d}}var ht={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}=mt({delayMs:30}),{markedInstance:a}=function(){const e=new ct.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&&at.A.getLanguage(s)?at.A.highlight(e,{language:s}).value:at.A.highlightAuto(e).value,`<div class="ff-code-block"><div class="ff-code-block--header"><button class="ff-code-block--copy">${ut}</button>${s?`<span class="ff-code-block--lang">${s}</span>`:""}</div><pre><code class="hljs">${a.replace(/\n/g," ")}</code></pre></div>`},checkbox({checked:e}){return`<span class="ff-checkbox${e?" ff-checkbox--checked":""}">${e?"☑":"☐"}</span>`},list(e){const t=e.ordered?"ol":"ul",s=e.ordered&&1!==e.start?` start="${e.start}"`:"",a=e.items.some(e=>e.task)?' class="ff-task-list"':"";let o="";for(const t of e.items)o+=this.listitem(t);return`<${t}${s}${a}>\n${o}</${t}>\n`},table(e){let t="";for(const s of e.header)t+=this.tablecell(s);const s=this.tablerow({text:t});let a="";for(const t of e.rows){let e="";for(const s of t)e+=this.tablecell(s);a+=this.tablerow({text:e})}return a&&(a=`<tbody>${a}</tbody>`),`<div class="ff-table-block"><div class="ff-table-block--header"><button class="ff-table-block--copy">${ut}</button></div><table><thead>${s}</thead>${a}</table></div>`}}}),{markedInstance:e}}();return{stream:e,streamedText:t,isStreaming:s,sanitize:he.aj,markedInstance:a}},computed:{...(0,l.aH)(ae.u7,["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")||e.target.closest(".ff-table-block--copy");if(!t)return;let s="";const a=t.closest(".ff-code-block")?.querySelector("pre code"),o=t.closest(".ff-table-block")?.querySelector("table");if(a)s=a.textContent||"";else if(o){const e=[...o.querySelectorAll("tr")];s=e.map(e=>[...e.querySelectorAll("th, td")].map(e=>e.textContent.trim()).join("\t")).join("\n")}s&&navigator.clipboard.writeText(s).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=pt},2e3)}).catch(()=>{const e=document.createElement("textarea");e.value=s,e.style.position="fixed",e.style.left="-999999px",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)})}}},gt=(0,V.A)(ht,[["render",function(e,t,s,o,n,l){return(0,a.openBlock)(),(0,a.CE)("div",(0,a.v6)({class:"streamable-content"},(0,a.Tb)(s.richContent?{click:l.handleClick}:{},!0)),[s.richContent?((0,a.openBlock)(),(0,a.CE)(a.FK,{key:1},[(0,a.Q3)(" eslint-disable-next-line vue/no-v-html "),((0,a.openBlock)(),(0,a.CE)("div",{key:l.text,innerHTML:l.text},null,8,st))],64)):((0,a.openBlock)(),(0,a.CE)("span",{key:l.text},(0,a.v_)(l.text),1))],16)}],["__scopeId","data-v-23764d4f"]]),ft={name:"GuideHeader",components:{StreamableContent:gt},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")}}},kt=(0,V.A)(ft,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("streamable-content");return(0,a.openBlock)(),(0,a.CE)(a.FK,null,[(0,a.Q3)(" Title and Summary "),s.title?((0,a.openBlock)(),(0,a.CE)("div",Ze,[(0,a.Lk)("h3",et,[(0,a.createVNode)(i,{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.CE)("p",tt,[!s.shouldStream||n.streamableTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(i,{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.Q3)("v-if",!0)])):(0,a.Q3)("v-if",!0)])):(0,a.Q3)("v-if",!0)],2112)}],["__scopeId","data-v-7fe35b3c"]]),vt={name:"MessageBubble",props:{type:{required:!0,type:String},variant:{required:!1,type:String,default:null},bare:{required:!1,type:Boolean,default:!1}},computed:{isAiMessage(){return"ai"===this.type},isHumanMessage(){return"human"===this.type},isSystemMessage(){return"system"===this.type}}},bt=(0,V.A)(vt,[["render",function(e,t,s,o,n,l){return(0,a.openBlock)(),(0,a.CE)("div",{class:(0,a.C4)(["message-bubble flex flex-col gap-1",{"ai-message":l.isAiMessage,"human-message":l.isHumanMessage,"system-message":l.isSystemMessage,"message-bubble--bare":s.bare,[`system-${s.variant}`]:s.variant}])},[(0,a.RG)(e.$slots,"default",{},void 0,!0)],2)}],["__scopeId","data-v-7b24ae0c"]]);const yt={class:"guide-flows"},Ct={class:"section-title"},St={key:0,class:"resources-grid"};function wt({intervalMs:e=350,shallow:t=!1}={}){const s=(0,a.KR)([]),o=(0,a.KR)([]),{doWhile:n}=(0,Ge.A)(),l=(0,a.KR)(!1);async function i(a=[]){s.value=t?a.map(u):a,await n(()=>s.value.length!==o.value.length,async()=>{if(!Array.isArray(s.value)||0===s.value.length)return;const e=u(s.value[o.value.length]),a=d(),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&&(l.value=!0)},{intervalMs:e})}function r(e){e.value=e,o.value=e.map(u),l.value=!1}function d(){return o.value[o.value.length-1]}function c(e,s){t?o.value[e].streamed=!0:o.value[e][s].streamed=!0}function u(e={}){return t?{...e,streamed:!1}:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{streamable:t,streamed:!1}]))}return{addItemsSequentially:i,addItems:r,initStreamer:async function(e,{shouldStream:t=!1}={}){if(!t)return r(e),Promise.resolve();await i(e)},hasFinishedStreaming:l,items:s,getLastVisibleItem:d,setSubItemStreamedState:c,updateCardStreamingState:function(e,t){Object.keys(e).forEach(e=>{c(t,e)})},visibleItems:o}}const xt={class:"flex flex-col gap-3 p-3 bg-white border border-gray-200 rounded-lg"},Bt={class:"flex items-start gap-2"},_t={class:"flex-1 flex flex-col gap-1 min-w-0"},At={class:"flex items-start justify-between gap-2"},It={class:"text-sm font-medium text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0"},Lt={class:"flex items-start gap-2 shrink-0 -mt-1"},Et={key:0,class:"text-xs text-gray-500 overflow-hidden text-ellipsis whitespace-nowrap"};var Tt=s(72615),Vt=s(22118),Pt=s(45964),Mt=s(60926),Ot={name:"StandardResourceCard",components:{StreamableContent:gt,TextCopier:Pt.A,FlowViewer:Mt.A,ChevronUpIcon:Tt.A,ChevronDownIcon:Vt.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,l.aH)(Pe.i,["canImportFlows"]),flowData(){return this.flowMetadata?.streamable?.flows??null},flowCategory(){return this.flowMetadata?.streamable?.category??null},flowsJson(){return this.flowData?JSON.stringify(this.flowData,null,2):""}},watch:{flowMetadata(e){e.streamed&&this.$emit("streaming-complete")}},mounted(){this.flowCategory||this.$nextTick(()=>this.completeStreaming())},methods:{...(0,l.i0)(ae.u7,["sendFlowsToImport"]),importFlows(){this.sendFlowsToImport(this.flowsJson)},completeStreaming(){this.flowMetadata&&(this.flowMetadata.streamed=!0),this.$emit("streaming-complete")}}},Rt={name:"ListFlows",components:{StreamableContent:gt,FlowResourceCard:(0,V.A)(Ot,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("streamable-content"),r=(0,a.g2)("chevron-down-icon"),d=(0,a.g2)("chevron-up-icon"),c=(0,a.g2)("text-copier"),u=(0,a.g2)("ff-button"),p=(0,a.g2)("flow-viewer");return(0,a.openBlock)(),(0,a.CE)("div",xt,[(0,a.Lk)("div",Bt,[t[4]||(t[4]=(0,a.Fv)('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" class="shrink-0 w-4 h-4 mt-0.5" data-v-c0469a76><rect width="24" height="24" fill="var(--ff-color-icon-flow-bg)" rx="4" data-v-c0469a76></rect><g clip-path="url(#a)" data-v-c0469a76><path fill="var(--ff-color-icon-flow-fg)" 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-c0469a76></path><path fill="var(--ff-color-icon-flow-fg)" 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-c0469a76></path><path fill="var(--ff-color-icon-flow-fg)" 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-c0469a76></path></g><defs data-v-c0469a76><clipPath id="a" data-v-c0469a76><path fill="var(--ff-color-icon-flow-fg)" d="M0 5h20v14H0z" data-v-c0469a76></path></clipPath></defs></svg>',1)),(0,a.Lk)("div",_t,[(0,a.Lk)("div",At,[(0,a.Lk)("div",It,[(0,a.createVNode)(i,{modelValue:n.flowTitle,"onUpdate:modelValue":t[0]||(t[0]=e=>n.flowTitle=e),"should-stream":s.shouldStream},null,8,["modelValue","should-stream"])]),(0,a.Lk)("div",Lt,[(0,a.Lk)("button",{class:"text-gray-600 hover:text-indigo-600 hover:bg-indigo-50 flex items-center transition-colors duration-200 rounded-sm px-2 py-1",onClick:t[1]||(t[1]=e=>n.flowsExpanded=!n.flowsExpanded)},[t[2]||(t[2]=(0,a.Lk)("span",null,"Preview",-1)),n.flowsExpanded?((0,a.openBlock)(),(0,a.createBlock)(r,{key:0,class:"h-4 w-4"})):(0,a.Q3)("v-if",!0),n.flowsExpanded?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(d,{key:1,class:"h-4 w-4"}))]),e.canImportFlows?((0,a.openBlock)(),(0,a.createBlock)(u,{key:1,size:"small",kind:"secondary",onClick:l.importFlows},{default:(0,a.k6)(()=>[...t[3]||(t[3]=[(0,a.eW)("Import",-1)])]),_:1},8,["onClick"])):((0,a.openBlock)(),(0,a.createBlock)(c,{key:0,text:l.flowsJson,showText:!1},null,8,["text"]))])]),l.flowCategory?((0,a.openBlock)(),(0,a.CE)("div",Et,[!s.shouldStream||n.flowTitle.streamed?((0,a.openBlock)(),(0,a.createBlock)(i,{key:0,string:l.flowCategory,"should-stream":s.shouldStream,onStreamingComplete:l.completeStreaming},null,8,["string","should-stream","onStreamingComplete"])):(0,a.Q3)("v-if",!0)])):(0,a.Q3)("v-if",!0)])]),l.flowData?((0,a.openBlock)(),(0,a.CE)("div",{key:0,class:(0,a.C4)(["flex overflow-auto ml-8 max-h-[500px] flex-col relative",{hidden:n.flowsExpanded}])},[n.flowsExpanded?(0,a.Q3)("v-if",!0):((0,a.openBlock)(),(0,a.createBlock)(p,{key:0,flow:l.flowData},null,8,["flow"]))],2)):(0,a.Q3)("v-if",!0)])}],["__scopeId","data-v-c0469a76"]])},props:{flows:{type:Array,required:!0},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,updateCardStreamingState:t,visibleItems:s,items:a}=wt();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")}},qt=(0,V.A)(Rt,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("streamable-content"),r=(0,a.g2)("FlowResourceCard");return(0,a.openBlock)(),(0,a.CE)(a.FK,null,[(0,a.Q3)(" Resources Section "),(0,a.Lk)("div",yt,[(0,a.Lk)("h4",Ct,[(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"])]),n.streamingTitle.streamed?((0,a.openBlock)(),(0,a.CE)("div",St,[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.createBlock)(r,{key:t,flow:e,"should-stream":s.shouldStream,onStreamingComplete:s=>o.updateCardStreamingState(e,t)},null,8,["flow","should-stream","onStreamingComplete"]))),128))])):(0,a.Q3)("v-if",!0)])],2112)}],["__scopeId","data-v-67b38b2a"]]);const Nt={class:"guide-steps"},$t={class:"section-title"},Ft={class:"steps-list"},Ut={class:"step-number"},Wt={class:"step-content"},Qt={class:"step-title"},Dt={key:0,class:"step-detail"};var Ht={name:"GuideStepsList",components:{StreamableContent:gt},props:{steps:{required:!0,type:Array},shouldStream:{type:Boolean,default:!1}},emits:["streaming-complete"],setup(){const{initStreamer:e,visibleItems:t}=wt();return{initStreamer:e,visibleItems:t}},async mounted(){await this.initStreamer(this.steps,{shouldStream:this.shouldStream}),this.$emit("streaming-complete")}},zt=(0,V.A)(Ht,[["render",function(e,t,s,o,n,l){const i=(0,a.g2)("streamable-content");return(0,a.openBlock)(),(0,a.CE)("div",Nt,[(0,a.Lk)("h4",$t,[(0,a.createVNode)(i,{string:"Steps:","should-stream":s.shouldStream},null,8,["should-stream"])]),(0,a.Lk)("ol",Ft,[((0,a.openBlock)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(o.visibleItems,(e,t)=>((0,a.openBlock)(),(0,a.CE)("li",{key:t,class:"step-item"},[(0,a.Lk)("div",Ut,(0,a.v_)(t+1),1),(0,a.Lk)("div",Wt,[(0,a.Lk)("h5",Qt,[(0,a.createVNode)(i,{modelValue:e.title,"onUpdate:modelValue":t=>e.title=t,"should-stream":s.shouldStream},null,8,["modelValue","onUpdate:modelValue