import{d as P,i as l,s as $,e as h,o as z,m as y,v as w,n as m,M as D,A as d,q as S,u as a,z as g,l as A,x as M,y as q}from"../../../../../common/index.CPcBO1Os.js";import{a as E}from"../../../../../common/vue-router.jJOaD9p9.js";import{a as k}from"../../../../../common/index.BA7kDUNA.js";import{u as R}from"../../../../../common/index.B24w2ZeB.js";import{u as F,s as U}from"../../index.CjI1uML7.js";import j from"../AIAgentIcon.BOnBhzPT.js";import{B as G}from"../../../../../common/index.B1jVoQr7.js";import{a as p}from"../../../../../common/index.B0UuxB9L.js";import{S as O}from"../../../../../common/index.CXHDE9hf.js";import{A as H}from"../../../../../common/index.BtaMLWKH.js";import{_ as J}from"../../../../../common/_plugin-vue_export-helper.DlAUqK2U.js";import"../../../../../common/index.TkDYtvUB.js";import"../../../../../common/index.B91jMiUk.js";import"../../../../../common/_getTag.5j88QV3u.js";import"../../../../../common/useState.DXwtWea_.js";import"../../../../../common/devWarning.DpJYEIzv.js";import"../../../../../common/compact-item.BK6dH04p.js";import"../../../../../common/Compact.B3btkLRg.js";import"../../../../../common/Portal.B2TrUL41.js";import"../../../../../common/InfoCircleFilled.DFXLEYKe.js";import"../../../../../common/CloseOutlined.gy8y5blQ.js";import"../../../../../common/ExclamationCircleFilled.CnnwVzET.js";import"../../../../../common/CloseCircleFilled.DsHyRhur.js";import"../../../../../common/KeyCode.D63Tfrq7.js";import"../../../../../common/FormItemContext.Bd2ze9Fn.js";import"../../../../../common/omit.ddwJ_9WE.js";const K=["id"],L={class:"ai-agent-box-header"},Q={class:"ai-agent-title-status"},X={class:"ai-agent-title"},Y={class:"ai-agent-status"},Z={key:1,class:"ai-agent-description"},ee={class:"ai-agent-footer"},r="wc-vendors-product-moderator-ai",te=P({__name:"WcVendorsProductModerator",setup(ae){const{__:o,sprintf:b}=window.wp.i18n,{emit:V}=R("saaiSettingsSaved"),C=E(),x=F(),{aiAgents:B}=U(x),u=l(()=>B.value.find(e=>e.id===r)||null),v=l(()=>{var e;return((e=u.value)==null?void 0:e.title)||""}),I=l(()=>{var e;return((e=u.value)==null?void 0:e.description)||""}),f=l(()=>{var e;return((e=u.value)==null?void 0:e.icon)||""}),_=l(()=>{var e;return((e=$())==null?void 0:e.isWcVendorsActive)||!1}),t=h(!1),c=h(!1),T=async()=>{var e,s,i;try{c.value=!0;const n=await k().get("storeagent-ai/v1/".concat(r,"/settings"));(((e=n.data)==null?void 0:e.data)||n.data||{}).enabled==="yes"?t.value=!0:t.value=!1}catch(n){((s=n==null?void 0:n.response)==null?void 0:s.status)===404||((i=n==null?void 0:n.error)==null?void 0:i.code)==="rest_no_route"||p.error(o("Failed to load settings. Using default values.","storeagent-ai-for-woocommerce")),t.value=!1}finally{c.value=!1}},W=async e=>{const s=t.value;try{c.value=!0,t.value=e,await k().post("storeagent-ai/v1/".concat(r,"/settings/save"),{enabled:e?"yes":"no"}),V(r),p.success(o("Settings saved successfully.","storeagent-ai-for-woocommerce"))}catch(i){p.error(o("Failed to save settings. Please try again.","storeagent-ai-for-woocommerce")),t.value=s}finally{c.value=!1}},N=()=>{C.replace({name:"IndexPage",query:{page:"storeagent-settings",subpage:"ai-agents",agent:r}})};return z(()=>{T()}),(e,s)=>u.value?(m(),y("div",{key:0,id:"agent-".concat(r),class:"saai-agent-box",style:D({transitionDelay:"".concat(r.charCodeAt(0)%5*.005,"s")})},[d("div",L,[f.value?(m(),S(j,{key:0,icon:f.value,alt:a(b)(a(o)("%s logo","storeagent-ai-for-woocommerce"),v.value)},null,8,["icon","alt"])):w("",!0),d("div",Q,[d("h3",X,g(v.value),1),d("p",Y,[A(a(O),{title:t.value?a(o)("Deactivate this agent","storeagent-ai-for-woocommerce"):a(o)("Activate this agent","storeagent-ai-for-woocommerce"),checked:t.value,"onUpdate:checked":s[0]||(s[0]=i=>t.value=i),disabled:!_.value||c.value,size:"default",onChange:s[1]||(s[1]=i=>W(!!i))},null,8,["title","checked","disabled"])])])]),_.value?(m(),y("p",Z,g(I.value),1)):(m(),S(a(H),{key:0,message:a(o)("WC Vendors Plugin Required","storeagent-ai-for-woocommerce"),description:a(o)("The WC Vendors plugin must be installed and activated to use this integration.","storeagent-ai-for-woocommerce"),type:"warning","show-icon":"",class:"integration-alert"},null,8,["message","description"])),d("div",ee,[A(a(G),{size:"small",onClick:N},{default:M(()=>[q(g(a(o)("SETTINGS","storeagent-ai-for-woocommerce")),1)]),_:1})])],12,K)):w("",!0)}}),Te=J(te,[["__scopeId","data-v-b7d56017"]]);export{Te as default};
