| 1 |
import{L as ce,M as ue,f as r,e as g,y as de,v as b,N as pe,g as v,l as m,j as c,C as e,G as u,x as o,t as d,q as _,m as L,u as n,F as W,D as ve,O as me}from"./vue.esm-bundler.js?ver=1.7.1";import{t as a}from"./Translator.js?ver=1.7.1";import{B as _e,_ as fe}from"./Badge.js?ver=1.7.1";import{R as D}from"./Rest.js?ver=1.7.1";import{n as y}from"./Notify.js?ver=1.7.1";import{C as $}from"./OrderCustomerInformation.js?ver=1.7.1";import"./Arr.js?ver=1.7.1";import"./Model.js?ver=1.7.1";import"./common.js?ver=1.7.1";import"./dayjs.min.js?ver=1.7.1";import"./Str.js?ver=1.7.1";import"./timezone.js?ver=1.7.1";import"./weekOfYear.js?ver=1.7.1";import"./Utils.js?ver=1.7.1";import"./CurrencyFormatter.js?ver=1.7.1";import"./index.js?ver=1.7.1";import"./vue-router.js?ver=1.7.1";import"./Url.js?ver=1.7.1";import"./DynamicIcon.js?ver=1.7.1";import"./preload-helper.js?ver=1.7.1";import"./_plugin-vue_export-helper.js?ver=1.7.1";import"./index3.js?ver=1.7.1";import"./IconButton.js?ver=1.7.1";import"./TransitionAccordion.js?ver=1.7.1";import"./Animation.js?ver=1.7.1";import"./Empty.js?ver=1.7.1";import"./CardBody.js?ver=1.7.1";import"./UserCan.js?ver=1.7.1";import"./Asset.js?ver=1.7.1";import"./AddressComponent.js?ver=1.7.1";import"./NotFound.js?ver=1.7.1";import"./productService.js?ver=1.7.1";const he={key:0,class:"fct-content-card-list-item py-4 px-6 !flex !pr-6 items-start justify-between !gap-4"},be={class:"min-w-0"},ge={class:"fct-content-card-list-head"},ye={class:"flex items-start gap-2 flex-row"},Ce={class:"mb-0"},we={key:0,class:"fct-content-card-list-content mt-1"},ke={class:"flex items-center gap-3 shrink-0"},Ve={class:"space-y-4"},xe={key:0,class:"fct-mcp-content-box"},Me={class:"fct-mcp-content-box-title"},He={class:"fct-mcp-content-box-text"},Fe={class:"fct-mcp-content-box-action"},Se={key:2,class:"fct-mcp-content-box is-active"},Pe={class:"fct-mcp-content-box-title"},Le={class:"fct-mcp-content-box-text"},De={class:"fct-mcp-agents-text"},je={class:"tools-count"},Be={class:"tools-label"},Te={class:"fct-form-group"},Ue={class:"fct-form-group"},qe={class:"form-note mb-3"},Ie=["href"],Ae={class:"grid gap-3 md:grid-cols-2 mb-3"},Ee={key:0,class:"mb-3"},Ne={key:1,class:"form-note mb-2"},Re={class:"relative fct-mcp-snippet"},Ze={class:"fct-mcp-snippet-code"},Oe={class:"mt-2 flex justify-end"},kt={__name:"McpSettings",props:ce({name:{type:String,required:!0},field:{type:Object},fieldKey:{type:String},value:{required:!0},variant:{type:String},nesting:{type:Boolean,default:!1},statePath:{type:String},form:{type:Object,required:!0},callback:{type:Function,required:!0},label:{type:String},attribute:{required:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(x){const M=ue(x,"modelValue"),A=l=>{const t=M.value&&typeof M.value=="object"?M.value:{};M.value={...t,active:l?"yes":"no"}},G=[{key:"claude-code",label:"Claude Code"},{key:"claude-desktop",label:"Claude Desktop"},{key:"cursor",label:"Cursor"},{key:"codex",label:"Codex"},{key:"generic",label:a("Other")}],E=r(!1),N=r(!1),j=r(!1),H=r(!1),s=r({mcp_enabled:!1,adapter_available:!1,toolkit_installed:!1,can_auto_install:!1,toolkit_download_url:"",endpoint_url:"",tools_count:0,app_passwords_url:"",current_user_login:"",is_local_dev:!1}),C=r("no"),B=r(!1),w=r("claude-code"),R=r({}),Z=r(!1),T=r(!1),k=r(""),U=r(""),F=r(!1),O=r(!1),h=g(()=>C.value==="yes"),q=g(()=>!!s.value.adapter_available),K=g(()=>q.value?h.value?a("Active"):a("Inactive"):a("Setup required")),Y=g(()=>q.value&&h.value?"active":"inactive"),S=g(()=>R.value[w.value]||null),P=g(()=>{const l=S.value;if(!l||!l.snippet)return"";let t=l.snippet;const p=k.value.trim(),V=U.value.trim();if(p&&V){let f="";try{f=btoa(`${p}:${V}`)}catch{f=""}f&&(t=t.split("<base64(your-username:application-password)>").join(f)),t=t.split("<your-username>").join(p),t=t.split("<your-application-password>").join(V)}return t}),J=()=>(N.value=!0,D.get("settings/mcp").then(l=>{s.value={...s.value,...l},C.value=l.mcp_enabled?"yes":"no",A(!!l.mcp_enabled),l.current_user_login&&!k.value&&(k.value=l.current_user_login),O.value||(F.value=!!l.is_local_dev,O.value=!0)}).catch(l=>y.error(l)).finally(()=>{N.value=!1})),Q=l=>{j.value=!0,D.post("settings/mcp/toggle",{mcp_enabled:l}).then(t=>{y.success(t.message),s.value.mcp_enabled=!!t.mcp_enabled,A(!!t.mcp_enabled),h.value&&H.value&&I()}).catch(t=>{C.value=l==="yes"?"no":"yes",y.error(t)}).finally(()=>{j.value=!1})},I=()=>(T.value=!0,D.get("settings/mcp/config-snippets",{local_dev:F.value?"yes":"no"}).then(l=>(R.value=l.snippets||{},Z.value=!0,l)).catch(l=>y.error(l)).finally(()=>{T.value=!1})),X=l=>{w.value=l},ee=()=>{I()},te=()=>{P.value&&$.copy(P.value,{successMessage:a("Connection snippet copied to your clipboard")})},le=()=>{H.value=!0,h.value&&!Z.value&&I()},ae=()=>{B.value=!0,D.post("settings/mcp/install-adapter",{}).then(l=>{y.success(l.message),setTimeout(()=>{window.location.reload()},800)}).catch(l=>{y.error(l),B.value=!1})},oe=()=>{s.value.endpoint_url&&$.copy(s.value.endpoint_url,{successMessage:a("Endpoint URL copied to your clipboard")})};return de(()=>{J().then(()=>{E.value=!0})}),(l,t)=>{const p=b("el-button"),V=b("el-switch"),f=b("el-input"),z=b("el-tab-pane"),ne=b("el-tabs"),se=b("el-checkbox"),ie=b("el-drawer"),re=pe("loading");return E.value?(c(),v("div",he,[e("div",be,[e("div",ge,[e("div",ye,[e("h4",Ce,o(x.field.title),1),u(_e,{size:"small",type:Y.value,"hide-icon":!0},{default:d(()=>[_(o(K.value),1)]),_:1},8,["type"])])]),x.field.description?(c(),v("div",we,[e("p",null,o(x.field.description),1)])):m("",!0)]),e("div",ke,[!q.value||h.value?(c(),L(p,{key:0,size:"small",onClick:le},{default:d(()=>[_(o(n(a)("Configure")),1)]),_:1})):m("",!0),u(V,{"active-value":"yes","inactive-value":"no",modelValue:C.value,"onUpdate:modelValue":t[0]||(t[0]=i=>C.value=i),loading:j.value,onChange:Q},null,8,["modelValue","loading"])]),u(ie,{modelValue:H.value,"onUpdate:modelValue":t[6]||(t[6]=i=>H.value=i),title:n(a)("MCP Connection"),"aria-label":n(a)("MCP Connection"),size:"640px","append-to":"#fct_admin_app_wrapper","close-on-click-modal":!0,class:"fct-mcp-settings-drawer"},{default:d(()=>[e("div",Ve,[s.value.adapter_available?m("",!0):(c(),v("div",xe,[t[7]||(t[7]=e("div",{class:"fct-mcp-content-box-logo"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},[e("g",{"clip-path":"url(#clip0_23040_79251)"},[e("path",{d:"M28.8 0H3.2C1.43269 0 0 1.43269 0 3.2V28.8C0 30.5673 1.43269 32 3.2 32H28.8C30.5673 32 32 30.5673 32 28.8V3.2C32 1.43269 30.5673 0 28.8 0Z",fill:"#008CFF"}),e("path",{d:"M7.5 12.8637C7.5 9.3491 10.3491 6.5 13.8637 6.5H15.4545V19.2272C15.4545 22.7418 12.6055 25.5909 9.0909 25.5909H7.5V12.8637Z",fill:"white"}),e("path",{d:"M17.0454 17.6371C17.0454 14.1225 19.8945 11.2734 23.4091 11.2734H25V19.228C25 22.7425 22.1509 25.5916 18.6363 25.5916H17.0454V17.6371Z",fill:"white"})]),e("defs",null,[e("clipPath",{id:"clip0_23040_79251"},[e("rect",{width:"32",height:"32",fill:"white"})])])])],-1)),e("h4",Me,o(n(a)("FluentHub is required")),1),e("p",He,o(n(a)("FluentCart speaks to AI agents through the MCP adapter bundled with FluentHub (WordPress 6.9+). The endpoint will not respond until it is installed and active.")),1),e("div",Fe,[s.value.can_auto_install?(c(),L(p,{key:0,loading:B.value,onClick:ae},{default:d(()=>[_(o(s.value.toolkit_installed?n(a)("Activate FluentHub"):n(a)("Install FluentHub")),1)]),_:1},8,["loading"])):(c(),L(p,{key:1,tag:"a",href:s.value.toolkit_download_url,target:"_blank",rel:"noopener noreferrer"},{default:d(()=>[_(o(n(a)("Download FluentHub")),1)]),_:1},8,["href"]))])])),s.value.can_auto_install?m("",!0):(c(),L(fe,{key:1,type:"info",icon:"InformationFill",content:n(a)("Tip: FluentCart Pro can install it for you in one click.")},null,8,["content"])),s.value.adapter_available&&!h.value?(c(),v("div",Se,[t[8]||(t[8]=e("div",{class:"fct-mcp-content-box-logo"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},[e("g",{"clip-path":"url(#clip0_23040_79251)"},[e("path",{d:"M28.8 0H3.2C1.43269 0 0 1.43269 0 3.2V28.8C0 30.5673 1.43269 32 3.2 32H28.8C30.5673 32 32 30.5673 32 28.8V3.2C32 1.43269 30.5673 0 28.8 0Z",fill:"#008CFF"}),e("path",{d:"M7.5 12.8637C7.5 9.3491 10.3491 6.5 13.8637 6.5H15.4545V19.2272C15.4545 22.7418 12.6055 25.5909 9.0909 25.5909H7.5V12.8637Z",fill:"white"}),e("path",{d:"M17.0454 17.6371C17.0454 14.1225 19.8945 11.2734 23.4091 11.2734H25V19.228C25 22.7425 22.1509 25.5916 18.6363 25.5916H17.0454V17.6371Z",fill:"white"})]),e("defs",null,[e("clipPath",{id:"clip0_23040_79251"},[e("rect",{width:"32",height:"32",fill:"white"})])])])],-1)),e("h4",Pe,o(n(a)("FluentHub is active")),1),e("p",Le,o(n(a)("Turn MCP on from the card to generate connection snippets for your AI clients.")),1)])):m("",!0),s.value.adapter_available&&h.value?(c(),v(W,{key:3},[e("div",De,[e("span",je,o(s.value.tools_count),1),e("span",Be,o(n(a)("AI tools available to connected agents")),1)]),e("div",Te,[e("label",null,o(n(a)("Endpoint URL")),1),u(f,{modelValue:s.value.endpoint_url,"onUpdate:modelValue":t[1]||(t[1]=i=>s.value.endpoint_url=i),readonly:""},{append:d(()=>[u(p,{onClick:oe},{default:d(()=>[_(o(n(a)("Copy")),1)]),_:1})]),_:1},8,["modelValue"])]),e("div",Ue,[e("label",null,o(n(a)("Connect a client")),1),e("p",qe,[_(o(n(a)("Create an application password for your WordPress user, then fill it in below. Your password stays in the browser — it is only written into the snippet you copy."))+" ",1),e("a",{href:s.value.app_passwords_url,target:"_blank",rel:"noopener noreferrer"},o(n(a)("Create an application password")),9,Ie)]),e("div",Ae,[u(f,{modelValue:k.value,"onUpdate:modelValue":t[2]||(t[2]=i=>k.value=i),placeholder:n(a)("WordPress username")},null,8,["modelValue","placeholder"]),u(f,{modelValue:U.value,"onUpdate:modelValue":t[3]||(t[3]=i=>U.value=i),type:"password","show-password":"",placeholder:n(a)("Application password")},null,8,["modelValue","placeholder"])]),u(ne,{modelValue:w.value,"onUpdate:modelValue":t[4]||(t[4]=i=>w.value=i),onTabChange:X},{default:d(()=>[(c(),v(W,null,ve(G,i=>u(z,{key:i.key,label:i.label,name:i.key},null,8,["label","name"])),64))]),_:1},8,["modelValue"]),w.value==="claude-desktop"?(c(),v("div",Ee,[u(se,{modelValue:F.value,"onUpdate:modelValue":t[5]||(t[5]=i=>F.value=i),onChange:ee},{default:d(()=>[_(o(n(a)("Local/self-signed site (disable TLS verification)")),1)]),_:1},8,["modelValue"])])):m("",!0),S.value&&S.value.instructions?(c(),v("p",Ne,o(S.value.instructions),1)):m("",!0),e("div",Re,[me((c(),v("pre",Ze,[_(o(P.value),1)])),[[re,T.value]]),e("div",Oe,[u(p,{type:"primary",disabled:!P.value,onClick:te},{default:d(()=>[_(o(n(a)("Copy snippet")),1)]),_:1},8,["disabled"])])])])],64)):m("",!0)])]),_:1},8,["modelValue","title","aria-label"])])):m("",!0)}}};export{kt as default}; |