import{r as c,I as ue,_ as fe,bb as S,ba as e,B as w}from"./createLucideIcon-BcINIXoS.js";import{M as Te,m as _e}from"./Lightbox-0egOu1U6.js";import{T,M as ge,b as L,C as be,S as Ie,s as b,e as z,c as oe,a as Pe,B as Le,R as ze,h as Ae,m as Me}from"../assets/admin-D0g83suT.js";import{I as O}from"./index-ChG3lseq.js";import{F as le,S as de}from"./file-text-Ciw6jjPW.js";import{S as ne}from"./sparkles-Cs-ol-GM.js";import{C as Ee,S as ye}from"./Pagination-CT65wBFk.js";import{c as ce,a as je,g as we,o as ve}from"./openrouter-Df8bB4Fu.js";import{R as $,F as Re,D as Ne}from"./Table-Zgkg3btb.js";import{A as ke}from"./index-BeAu3ZUr.js";import{T as me}from"./index-BuM9R26h.js";import{R as Oe}from"./FormOutlined-BkGRjBue.js";import{S as Fe}from"./index-Djba9N7u.js";import"./EyeOutlined-B40DaD3_.js";import"./addEventListener-DSPI5EF0.js";import"./LeftOutlined-Ci58k6gc.js";import"./SearchOutlined-B5_bI2oW.js";import"./Input-gYODSeX_.js";import"./index-DoQOayR8.js";var Ue={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-32 736H663.9V602.2h104l15.6-120.7H663.9v-77.1c0-35 9.7-58.8 59.8-58.8h63.9v-108c-11.1-1.5-49-4.8-93.2-4.8-92.2 0-155.3 56.3-155.3 159.6v89H434.9v120.7h104.3V848H176V176h672v672z"}}]},name:"facebook",theme:"outlined"},Be=function(t,d){return c.createElement(ue,fe({},t,{ref:d,icon:Ue}))},De=c.forwardRef(Be),$e={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 306.9c-113.5 0-205.1 91.6-205.1 205.1S398.5 717.1 512 717.1 717.1 625.5 717.1 512 625.5 306.9 512 306.9zm0 338.4c-73.4 0-133.3-59.9-133.3-133.3S438.6 378.7 512 378.7 645.3 438.6 645.3 512 585.4 645.3 512 645.3zm213.5-394.6c-26.5 0-47.9 21.4-47.9 47.9s21.4 47.9 47.9 47.9 47.9-21.3 47.9-47.9a47.84 47.84 0 00-47.9-47.9zM911.8 512c0-55.2.5-109.9-2.6-165-3.1-64-17.7-120.8-64.5-167.6-46.9-46.9-103.6-61.4-167.6-64.5-55.2-3.1-109.9-2.6-165-2.6-55.2 0-109.9-.5-165 2.6-64 3.1-120.8 17.7-167.6 64.5C132.6 226.3 118.1 283 115 347c-3.1 55.2-2.6 109.9-2.6 165s-.5 109.9 2.6 165c3.1 64 17.7 120.8 64.5 167.6 46.9 46.9 103.6 61.4 167.6 64.5 55.2 3.1 109.9 2.6 165 2.6 55.2 0 109.9.5 165-2.6 64-3.1 120.8-17.7 167.6-64.5 46.9-46.9 61.4-103.6 64.5-167.6 3.2-55.1 2.6-109.8 2.6-165zm-88 235.8c-7.3 18.2-16.1 31.8-30.2 45.8-14.1 14.1-27.6 22.9-45.8 30.2C695.2 844.7 570.3 840 512 840c-58.3 0-183.3 4.7-235.9-16.1-18.2-7.3-31.8-16.1-45.8-30.2-14.1-14.1-22.9-27.6-30.2-45.8C179.3 695.2 184 570.3 184 512c0-58.3-4.7-183.3 16.1-235.9 7.3-18.2 16.1-31.8 30.2-45.8s27.6-22.9 45.8-30.2C328.7 179.3 453.7 184 512 184s183.3-4.7 235.9 16.1c18.2 7.3 31.8 16.1 45.8 30.2 14.1 14.1 22.9 27.6 30.2 45.8C844.7 328.7 840 453.7 840 512c0 58.3 4.7 183.2-16.2 235.8z"}}]},name:"instagram",theme:"outlined"},We=function(t,d){return c.createElement(ue,fe({},t,{ref:d,icon:$e}))},He=c.forwardRef(We);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Ge=S("code",qe);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ve=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],re=S("copy",Ve);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ye=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Je=S("eye",Ye);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ke=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Qe=S("lightbulb",Ke);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xe=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Ze=S("message-circle",Xe);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ea=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],aa=S("rotate-cw",ea);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ia=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ta=S("send",ia);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sa=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Ce=S("share-2",sa);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ca=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],na=S("terminal",ca);/**
 * @license lucide-react v1.24.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ra=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],oa=S("wand-sparkles",ra),{Title:la,Text:da}=T;function ma({testMessages:a,setTestMessages:t,hasTested:d,setHasTested:h,isTesting:x,testInput:l,setTestInput:p,handleTestMessage:o}){return e.jsx("div",{className:"cai-basis-[400px] cai-shrink-0 cai-flex cai-flex-col",children:e.jsxs("div",{className:"cai-border cai-border-solid cai-border-slate-200 cai-rounded-xl cai-bg-white cai-overflow-hidden cai-flex-1 cai-min-h-[600px] cai-flex cai-flex-col cai-shadow-sm",children:[e.jsxs("div",{className:"cai-p-4 cai-flex cai-justify-between cai-items-center cai-border-b cai-border-gray-200",children:[e.jsx(da,{className:"cai-font-semibold cai-text-base cai-text-slate-900",children:"Preview"}),e.jsx(w,{type:"text",icon:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.92-10.24l5.58 3.67"})}),onClick:()=>{t([]),h(!1)},size:"small"})]}),e.jsx("div",{className:"cai-flex-1 cai-p-6 cai-flex cai-flex-col cai-bg-slate-50 cai-overflow-y-auto",children:d?e.jsxs("div",{className:"cai-flex cai-flex-col cai-gap-4",children:[a.map((i,n)=>e.jsx("div",{className:i.role==="user"?"cai-self-end cai-max-w-[85%]":"cai-self-start cai-max-w-[85%]",children:e.jsx("div",{className:`cai-px-4 cai-py-3 cai-text-sm cai-leading-relaxed ${i.role==="user"?"cai-bg-slate-900 cai-text-white cai-rounded-2xl cai-rounded-br-sm":i.role==="error"?"cai-bg-red-50 cai-text-red-700 cai-rounded-2xl cai-rounded-bl-sm cai-shadow-sm cai-border cai-border-solid cai-border-red-200":"cai-bg-white cai-text-slate-900 cai-rounded-2xl cai-rounded-bl-sm cai-shadow-sm cai-border cai-border-solid cai-border-slate-200"}`,children:i.role==="user"||i.role==="error"?i.content:e.jsx("div",{className:"replyan-markdown-preview",children:e.jsx(Te,{components:_e,children:i.content})})})},n)),x&&e.jsx("div",{className:"cai-self-start cai-px-4 cai-py-3 cai-bg-white cai-border cai-border-solid cai-border-slate-200 cai-rounded-2xl cai-rounded-bl-sm",children:e.jsx("span",{className:"cai-text-slate-400 cai-text-sm",children:"Typing..."})})]}):e.jsxs("div",{className:"cai-flex-1 cai-flex cai-flex-col cai-items-center cai-justify-center",children:[e.jsx("div",{className:"cai-bg-gradient-to-br cai-from-[#a78bfa] cai-to-[#f472b6] cai-rounded-xl cai-p-3 cai-text-white cai-mb-4",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"})})}),e.jsx(la,{level:4,className:"!cai-text-slate-700 !cai-mb-4 !cai-mt-0",children:"Test your AI Agent"})]})}),e.jsx("div",{className:"cai-p-4 cai-bg-white",children:e.jsxs("div",{className:"cai-border cai-border-solid cai-border-slate-200 cai-rounded-xl cai-p-3 cai-bg-white cai-flex cai-flex-col",children:[e.jsx(O.TextArea,{id:"preview-input",value:l,onChange:i=>p(i.target.value),onPressEnter:i=>{i.shiftKey||(i.preventDefault(),o())},placeholder:"Enter your message...",bordered:!1,autoSize:{minRows:2,maxRows:4},className:"!cai-p-0 !cai-resize-none !cai-mb-2 !cai-shadow-none"}),e.jsx("div",{className:"cai-flex cai-justify-end cai-items-center",children:e.jsx(w,{type:"primary",shape:"circle",onClick:o,loading:x,icon:!x&&e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),e.jsx("polyline",{points:"5 12 12 5 19 12"})]}),className:"!cai-bg-slate-900 !cai-border-slate-900"})})]})})]})})}const xe=window.replyan_ai_admin||{},xa=({open:a,onClose:t,currentInstruction:d="",agentId:h=0,model:x="",onApply:l})=>{const[p,o]=c.useState(""),[i,n]=c.useState(!1),[r,m]=c.useState(!1),u=async()=>{var g,j;if(!d.trim()){b.warning("No instruction text to optimize");return}n(!0),o(""),m(!1);try{const k=await(await fetch(`${xe.restUrl}optimize-instruction`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":xe.restNonce},body:JSON.stringify({instruction:d,agent_id:h,model:x||void 0})})).json();if(k.success&&((g=k.data)!=null&&g.optimized))o(k.data.optimized);else{const A=k.message||((j=k.data)==null?void 0:j.message)||"Optimization failed. Please try again.";b.error(A)}}catch(v){console.error("Optimization error:",v),b.error("Failed to connect to the optimization service.")}finally{n(!1)}};c.useEffect(()=>{a&&d.trim()&&u(),a&&m(!1)},[a]);const f=()=>{if(!p){b.info("No optimized instruction to copy yet");return}navigator.clipboard.writeText(p),m(!0),b.success("Copied to clipboard"),setTimeout(()=>m(!1),2e3)},s=()=>{l&&p&&l(p),t()};return e.jsxs(ge,{open:a,onCancel:t,footer:null,width:940,zIndex:1e5,centered:!0,destroyOnClose:!0,closable:!1,className:"cai-optimize-instruction-modal",styles:{content:{padding:0,overflow:"hidden",borderRadius:20,boxShadow:"0 25px 60px -12px rgba(0, 0, 0, 0.25)"},body:{padding:0,overflow:"hidden"}},children:[e.jsx("div",{style:{background:"linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #3b82f6 100%)"},className:"cai-px-7 cai-py-5 cai-flex-shrink-0",children:e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-3",children:[e.jsx("div",{className:"cai-w-10 cai-h-10 cai-rounded-xl cai-bg-white/20 cai-backdrop-blur-sm cai-flex cai-items-center cai-justify-center",children:e.jsx(oa,{size:20,className:"cai-text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"cai-text-lg cai-font-bold cai-text-white cai-m-0 cai-leading-tight",children:"Optimize Instructions"}),e.jsx("p",{className:"cai-text-sm cai-text-white/70 cai-mt-0.5 cai-mb-0",children:"AI-powered structure optimization for your agent prompts"})]})]}),e.jsx("button",{type:"button",onClick:t,className:"cai-w-8 cai-h-8 cai-rounded-lg cai-bg-white/15 hover:cai-bg-white/25 cai-border-none cai-cursor-pointer cai-flex cai-items-center cai-justify-center cai-transition-colors cai-text-white/80 hover:cai-text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}),e.jsxs("div",{className:"cai-flex cai-flex-col md:cai-flex-row cai-overflow-hidden",style:{height:"460px",maxHeight:"460px"},children:[e.jsxs("div",{className:"cai-flex cai-flex-col cai-w-full md:cai-w-1/2 cai-h-full cai-border-r cai-border-slate-100 cai-overflow-hidden",style:{background:"#fafbfc"},children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2.5 cai-px-6 cai-py-3.5 cai-border-b cai-border-slate-100 cai-flex-shrink-0",style:{height:"52px"},children:[e.jsx("div",{className:"cai-w-7 cai-h-7 cai-rounded-lg cai-flex cai-items-center cai-justify-center",style:{background:"#f1f5f9"},children:e.jsx(le,{size:14,className:"cai-text-slate-500"})}),e.jsx("span",{className:"cai-font-semibold cai-text-[13px] cai-text-slate-700 cai-tracking-wide cai-uppercase",children:"Your Instructions"})]}),e.jsx("div",{className:"cai-flex-1 cai-overflow-y-auto cai-px-6 cai-py-5 cai-text-sm cai-text-slate-600 cai-whitespace-pre-wrap cai-leading-relaxed",style:{height:"calc(460px - 52px)",maxHeight:"calc(460px - 52px)"},children:d||e.jsxs("div",{className:"cai-flex cai-flex-col cai-items-center cai-justify-center cai-h-full cai-text-center cai-py-12",children:[e.jsx(le,{size:36,className:"cai-text-slate-200 cai-mb-3"}),e.jsx("span",{className:"cai-text-slate-400 cai-text-sm",children:"No instructions provided yet."}),e.jsx("span",{className:"cai-text-slate-300 cai-text-xs cai-mt-1",children:"Write your agent instructions first, then optimize."})]})})]}),e.jsxs("div",{className:"cai-flex cai-flex-col cai-w-full md:cai-w-1/2 cai-h-full cai-bg-white cai-overflow-hidden",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between cai-px-6 cai-py-3.5 cai-border-b cai-border-slate-100 cai-flex-shrink-0",style:{height:"52px"},children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2.5",children:[e.jsx("div",{className:"cai-w-7 cai-h-7 cai-rounded-lg cai-flex cai-items-center cai-justify-center",style:{background:"linear-gradient(135deg, #eff6ff, #dbeafe)"},children:e.jsx(ne,{size:14,className:"cai-text-blue-600"})}),e.jsx("span",{className:"cai-font-semibold cai-text-[13px] cai-text-slate-700 cai-tracking-wide cai-uppercase",children:"Optimized Output"})]}),e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-1",children:[e.jsx(L,{title:"Regenerate",children:e.jsx("button",{type:"button",onClick:u,disabled:i,className:"cai-w-8 cai-h-8 cai-flex cai-items-center cai-justify-center cai-text-slate-400 hover:cai-text-blue-600 hover:cai-bg-blue-50 cai-rounded-lg cai-transition-all cai-border-none cai-bg-transparent cai-cursor-pointer disabled:cai-opacity-50 disabled:cai-cursor-not-allowed",children:e.jsx(aa,{size:15,className:i?"cai-animate-spin":""})})}),e.jsx(L,{title:r?"Copied!":"Copy to clipboard",children:e.jsx("button",{type:"button",onClick:f,className:"cai-w-8 cai-h-8 cai-flex cai-items-center cai-justify-center cai-text-slate-400 hover:cai-text-blue-600 hover:cai-bg-blue-50 cai-rounded-lg cai-transition-all cai-border-none cai-bg-transparent cai-cursor-pointer",children:r?e.jsx(be,{size:15,className:"cai-text-green-500"}):e.jsx(re,{size:15})})})]})]}),e.jsx("div",{className:"cai-flex-1 cai-flex cai-flex-col cai-px-6 cai-py-5 cai-overflow-hidden",style:{height:"calc(460px - 52px)",maxHeight:"calc(460px - 52px)"},children:i?e.jsxs("div",{className:"cai-flex-1 cai-flex cai-flex-col cai-items-center cai-justify-center cai-text-center cai-w-full cai-h-full",children:[e.jsx("div",{className:"cai-mb-3",children:e.jsx(Ie,{size:"large"})}),e.jsx("span",{className:"cai-text-slate-700 cai-text-sm cai-font-semibold",children:"Optimizing your instructions..."}),e.jsx("span",{className:"cai-text-slate-400 cai-text-xs cai-mt-1 cai-max-w-[260px]",children:"Fixing redundancies, inconsistent fallbacks, and cleaning format"})]}):e.jsx("textarea",{value:p,onChange:g=>o(g.target.value),placeholder:"Optimized instructions will appear here...",className:"cai-w-full cai-h-full cai-flex-1 cai-border-none cai-outline-none !cai-p-0 cai-text-sm cai-leading-relaxed cai-text-slate-800 cai-bg-transparent cai-resize-none cai-overflow-y-auto",style:{border:"none",outline:"none",resize:"none",height:"100%",maxHeight:"100%",width:"100%",boxShadow:"none"}})})]})]}),e.jsxs("div",{className:"cai-flex cai-justify-end cai-items-center cai-gap-3 cai-px-7 cai-py-4 cai-border-t cai-border-slate-100 cai-bg-slate-50/50 cai-flex-shrink-0",children:[e.jsx(w,{onClick:t,size:"large",className:"!cai-rounded-xl !cai-px-7 !cai-h-10 !cai-border-slate-200 !cai-text-slate-600 hover:!cai-border-slate-300 hover:!cai-text-slate-800 !cai-font-medium !cai-text-sm",children:"Cancel"}),e.jsx(w,{type:"primary",onClick:s,size:"large",disabled:!p||i,className:"!cai-rounded-xl !cai-px-7 !cai-h-10 !cai-border-none !cai-font-medium !cai-text-sm !cai-shadow-md",style:{background:p?"linear-gradient(135deg, #1d4ed8, #2563eb)":void 0},children:"Apply Changes"})]})]})},se=[{id:"1",title:"Templates #1",category:"Real Estate & Properties",description:"Property inquiries, buyer qualification, and viewing booking.",content:`Persona Name: HomeFinder Assistant

Role: You are HomeFinder Assistant, a helpful AI assistant for HomeFinder Realty. Your goal is to answer customer questions accurately, politely, and help them inquire about, schedule property viewings, or connect with a property agent.

Primary Language: English, Taglish

Style: Professional, friendly, knowledgeable, and helpful.

# PROPERTY VIEWING RULES:
1. When a client inquires about a property viewing, gather the following details:
   - Client full name
   - Contact phone number / email
   - Property name or location of interest
   - Preferred date and time for the viewing
2. Always clarify whether they prefer an in-person site tour or a virtual walkthrough.
3. Inform the client that our licensed property specialist will confirm the schedule within 24 hours.

# GENERAL GUIDELINES:
- Answer questions regarding property pricing, unit types, down payment schemes, and amenities based on available listings.
- Never guarantee reservations or discounts without agent confirmation.
- If a property is sold out, suggest similar nearby projects.`},{id:"2",title:"Templates #2",category:"E-Commerce & Online Shop",description:"Product recommendation, order taking, and shipping assistance.",content:`Persona Name: ShopMate Assistant

Role: You are ShopMate Assistant, the official virtual shopping assistant for our online store. Your mission is to help shoppers find products, answer questions about orders and shipping, and guide them through completing purchases.

Primary Language: English, Taglish

Style: Warm, cheerful, energetic, and proactive.

# ORDER & CHECKOUT RULES:
1. When a customer wants to place an order, assist them by collecting:
   - Full Name
   - Mobile Phone Number
   - Complete Shipping Address (Street, Barangay/City, Postal Code)
   - Item Name, Color/Size Variant, and Quantity
2. Clarify available payment options (Cash on Delivery, Credit Card, GCash, Bank Transfer).
3. Always provide an order recap and ask for confirmation before directing them to checkout.

# STORE & SHIPPING GUIDELINES:
- Standard delivery takes 2-3 business days for Metro areas and 5-7 business days for provincial areas.
- For size inquiries, reference the size chart and recommend sizing up when between sizes.
- If an item is out of stock, offer to notify them upon restock or suggest top alternatives.`},{id:"3",title:"Templates #3",category:"Lead Generation & Sales",description:"Consultative qualification and discovery call booking.",content:`Persona Name: GrowthConnect Assistant

Role: You are GrowthConnect Assistant, the AI consultative representative for our business services. Your goal is to understand visitor requirements, qualify potential leads, and schedule discovery consultations.

Primary Language: English, Taglish

Style: Consultative, professional, persuasive, and efficient.

# LEAD QUALIFICATION & BOOKING RULES:
1. Greet visitors warmly and ask what specific challenge or service they need help with.
2. Briefly explain how our solutions deliver measurable results for their use case.
3. Collect the following information to book a free discovery call:
   - Full Name & Job Title
   - Business / Company Name
   - Work Email & Contact Number
   - Estimated monthly budget or project timeline
4. Confirm their preferred calendar slot for a 15-minute introductory call with our strategy consultant.

# CONSTRAINTS:
- Do not quote custom pricing commitments before discovery.
- Keep responses focused on benefits and value rather than lengthy technical jargon.`},{id:"4",title:"Templates #4",category:"Technical Support",description:"Structured troubleshooting and support escalation.",content:`Persona Name: TechSolve Assistant

Role: You are TechSolve Assistant, a Tier-1 technical support engineer for our software platform. Your responsibility is to diagnose user issues, provide clear step-by-step troubleshooting, and escalate complex bugs to engineering.

Primary Language: English

Style: Patient, methodical, analytical, and reassuring.

# TROUBLESHOOTING RULES:
1. Empathize with the user's issue and acknowledge the inconvenience.
2. Ask targeted diagnostic questions one at a time:
   - Error code or screenshot description
   - Operating system and browser version
   - Exact steps taken before the issue occurred
3. Provide step-by-step resolution steps using numbered lists.
4. Verify whether each step worked before moving to the next.

# ESCALATION RULES:
- If the issue requires database modification, account credentials, or bug patching:
  + Collect the user's registered account email.
  + Summarize the issue and advise them that ticket #T-Support has been created for Tier-2 engineering.
- Never request passwords, tokens, or payment card security codes.`},{id:"5",title:"Templates #5",category:"Healthcare & Clinic Concierge",description:"Patient inquiries, doctor schedules, and appointment booking.",content:`Persona Name: CarePoint Assistant

Role: You are CarePoint Assistant, the virtual patient coordinator for CarePoint Medical Clinic. You assist patients with doctor specialties, clinic hours, service information, and appointment booking.

Primary Language: English, Taglish

Style: Compassionate, respectful, reassuring, and attentive.

# APPOINTMENT BOOKING RULES:
1. For patient appointment inquiries, collect:
   - Patient Full Name & Age
   - Contact Phone Number & Email
   - Reason for Consultation / Department (e.g., Pediatrics, Dental, General Medicine, Cardiology)
   - Preferred Doctor (if any) and desired appointment date/time
2. Remind patients to arrive 15 minutes prior to their scheduled consultation with valid ID.

# MEDICAL DISCLAIMER RULES:
- Never provide medical diagnosis, prescribe medications, or replace emergency care.
- For emergency medical symptoms (chest pain, severe breathing difficulty, acute injury), immediately instruct the user to call local emergency services (911) or visit the nearest hospital emergency room.`},{id:"6",title:"Templates #6",category:"Restaurant & Hospitality",description:"Menu recommendations, dietary info, and table reservations.",content:`Persona Name: Bistro Luxe Assistant

Role: You are Bistro Luxe Assistant, the virtual host and concierge for Bistro Luxe. Your goal is to showcase our menu offerings, answer dietary questions, and assist guests with table reservations.

Primary Language: English, Taglish

Style: Welcoming, vibrant, elegant, and hospitable.

# TABLE RESERVATION RULES:
1. When a guest inquires about dining or booking a table, collect:
   - Guest Full Name
   - Mobile Contact Number
   - Party Size (Number of adults and children)
   - Date and Preferred Time Slot
   - Special Occasions (Birthday, Anniversary, Business Dinner)
   - Dietary Restrictions (Vegan, Halal, Nut Allergy, Gluten-Free)
2. For parties larger than 8 guests, inform them that our reservation manager will reach out for group menu confirmation.

# MENU & VENUE GUIDELINES:
- Highlight our signature dishes and current chef's seasonal specials.
- Provide operating hours, parking options, corkage fees, and dress code upon request.`}],pa=({open:a,onClose:t,onApply:d})=>{const[h,x]=c.useState("1"),[l,p]=c.useState(!1),o=se.find(r=>r.id===h)||se[0],i=()=>{o!=null&&o.content&&(navigator.clipboard.writeText(o.content),p(!0),b.success("Template copied to clipboard"),setTimeout(()=>p(!1),2e3))},n=()=>{d&&(o!=null&&o.content)&&(d(o.content),b.success("Template applied to instructions")),t()};return e.jsxs(ge,{open:a,onCancel:t,footer:null,width:900,zIndex:1e5,centered:!0,destroyOnClose:!0,closable:!1,className:"cai-template-instruction-modal",styles:{content:{padding:0,overflow:"hidden",borderRadius:16,boxShadow:"0 20px 50px -12px rgba(0, 0, 0, 0.2)"},body:{padding:0,overflow:"hidden"}},children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between cai-px-6 cai-py-4 cai-border-b cai-border-slate-100 cai-bg-white",children:[e.jsx("div",{className:"cai-flex cai-items-center cai-gap-2.5",children:e.jsx("h3",{className:"cai-text-base cai-font-semibold cai-text-slate-800 cai-m-0",children:"Reference template"})}),e.jsx("button",{type:"button",onClick:t,className:"cai-w-8 cai-h-8 cai-rounded-lg cai-bg-transparent hover:cai-bg-slate-100 cai-border-none cai-cursor-pointer cai-flex cai-items-center cai-justify-center cai-transition-colors cai-text-slate-400 hover:cai-text-slate-600",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"cai-flex cai-flex-col md:cai-flex-row cai-overflow-hidden",style:{height:"480px",maxHeight:"480px"},children:[e.jsxs("div",{className:"cai-flex cai-flex-col cai-w-full md:cai-w-[280px] cai-flex-shrink-0 cai-border-r cai-border-slate-100 cai-bg-slate-50/50 cai-overflow-hidden",children:[e.jsx("div",{className:"cai-px-5 cai-py-3.5 cai-border-b cai-border-slate-100 cai-flex-shrink-0",children:e.jsx("span",{className:"cai-font-semibold cai-text-sm cai-text-slate-700",children:"Templates"})}),e.jsx("div",{className:"cai-flex-1 cai-overflow-y-auto cai-p-4 cai-flex cai-flex-col cai-gap-2.5",children:se.map(r=>{const m=r.id===h;return e.jsxs("div",{onClick:()=>x(r.id),className:`cai-group cai-flex cai-items-center cai-justify-between cai-px-4 cai-py-3.5 cai-rounded-xl cai-cursor-pointer cai-transition-all ${m?"cai-bg-white cai-border cai-border-blue-500 cai-shadow-sm":"cai-bg-white cai-border cai-border-slate-200/80 hover:cai-border-slate-300 hover:cai-bg-slate-50/80"}`,children:[e.jsx("div",{className:"cai-flex cai-flex-col",children:e.jsx("span",{className:`cai-text-sm cai-font-medium ${m?"cai-text-blue-600":"cai-text-slate-700 group-hover:cai-text-slate-900"}`,children:r.title})}),e.jsx("div",{className:`cai-transition-colors ${m?"cai-text-blue-500":"cai-text-slate-400 group-hover:cai-text-slate-600"}`,children:e.jsx(Je,{size:18})})]},r.id)})})]}),e.jsxs("div",{className:"cai-flex cai-flex-col cai-flex-1 cai-bg-white cai-overflow-hidden",style:{background:"#efefef",borderRadius:"14px 0px 0px 0px"},children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between cai-px-6 cai-py-3.5 cai-border-b cai-border-slate-100 cai-flex-shrink-0",children:[e.jsx("span",{className:"cai-font-semibold cai-text-sm cai-text-slate-700",children:"Instruction"}),e.jsx("div",{className:"cai-flex cai-items-center cai-gap-2",children:e.jsx(L,{title:l?"Copied!":"Copy instruction",children:e.jsx("button",{type:"button",onClick:i,className:"cai-w-8 cai-h-8 cai-flex cai-items-center cai-justify-center cai-text-slate-400 hover:cai-text-blue-600 hover:cai-bg-blue-50 cai-rounded-lg cai-transition-all cai-border-none cai-bg-transparent cai-cursor-pointer",children:l?e.jsx(be,{size:16,className:"cai-text-green-500"}):e.jsx(re,{size:16})})})})]}),e.jsx("div",{className:"cai-flex-1 cai-overflow-y-auto cai-px-6 cai-py-5 cai-text-[13px] cai-text-slate-700 cai-whitespace-pre-wrap cai-leading-relaxed",style:{height:"calc(480px - 52px)",maxHeight:"calc(480px - 52px)"},children:o==null?void 0:o.content}),e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between cai-px-6 cai-py-3 cai-border-t cai-border-slate-100 cai-bg-slate-50/50 cai-flex-shrink-0",children:[e.jsx("span",{className:"cai-text-xs cai-text-slate-400",children:o.category}),e.jsx(w,{type:"primary",onClick:n,className:"!cai-rounded-lg !cai-px-5 !cai-h-8 !cai-text-xs !cai-font-medium !cai-bg-blue-600 hover:!cai-bg-blue-700 !cai-border-none !cai-shadow-none",children:"Use this template"})]})]})]})]})},{Title:ha,Text:X}=T,{TextArea:ua}=O;function fa({agentName:a,setAgentName:t,agentDescription:d,setAgentDescription:h,instructionText:x,setInstructionText:l,includeWoocommerce:p,setIncludeWoocommerce:o,agentId:i=0,model:n=""}){const[r,m]=c.useState(!1),[u,f]=c.useState(!1);return e.jsxs("div",{className:"cai-pt-6",children:[e.jsxs("div",{className:"cai-mb-6",children:[e.jsx(X,{className:"cai-block cai-mb-2 cai-font-medium cai-text-slate-900",children:"Agent Name"}),e.jsx(O,{value:a,onChange:s=>t(s.target.value),placeholder:"e.g. John Doe Agent",size:"large",className:"!cai-rounded-lg"})]}),e.jsxs("div",{className:"cai-mb-8",children:[e.jsx(X,{className:"cai-block cai-mb-2 cai-font-medium cai-text-slate-900",children:"Description"}),e.jsx(O,{value:d,onChange:s=>h(s.target.value),placeholder:"Short description of the agent",size:"large",className:"!cai-rounded-lg"})]}),e.jsx("div",{className:"cai-flex cai-justify-between cai-items-start cai-mb-6",children:e.jsxs("div",{children:[e.jsx(ha,{level:4,className:"!cai-mt-0 !cai-mb-1 !cai-text-slate-900",children:"Create your instruction"}),e.jsx(X,{type:"secondary",className:"cai-text-slate-500",children:"Control your Agent by adding custom instruction"})]})}),e.jsx("div",{className:"cai-mb-4",children:e.jsx(Ee,{checked:p,onChange:s=>o(s.target.checked),className:"cai-text-sm cai-text-slate-700 cai-font-medium",children:"Include WooCommerce Products in retrieval (the product will be available for retrieval)"})}),e.jsxs("div",{style:{backgroundColor:"#f3f3f3"},className:"cai-instruction-editor cai-border cai-border-slate-200 cai-rounded-xl cai-p-6 cai-shadow-sm",children:[e.jsx(ua,{value:x,onChange:s=>l(s.target.value),autoSize:{minRows:15,maxRows:25},bordered:!1,maxLength:15e3,className:"!cai-p-0 !cai-text-sm !cai-leading-relaxed !cai-text-slate-900 !cai-resize-none"}),e.jsxs("div",{className:"cai-flex cai-justify-between cai-items-center cai-mt-6 cai-pt-4 cai-border-t cai-border-slate-100",children:[e.jsx("div",{className:"cai-flex cai-items-center cai-gap-4",children:e.jsx(L,{title:"AI Optimization",children:e.jsxs("span",{onClick:()=>m(!0),className:"cai-flex cai-items-center cai-gap-1.5 cai-cursor-pointer cai-text-slate-500 hover:cai-text-indigo-600 cai-transition-colors cai-text-xs cai-font-medium cai-editor-icon",children:[e.jsx(ne,{size:16,className:"cai-text-indigo-500"}),e.jsx("span",{children:"AI Optimization"})]})})}),e.jsxs(X,{type:"secondary",className:"cai-text-xs cai-text-slate-400",children:[x.length.toLocaleString(),"/15,000"]})]})]}),e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2.5 cai-mt-4 cai-px-1",children:[e.jsx(Qe,{size:18,className:"cai-text-slate-400"}),e.jsxs("span",{className:"cai-text-sm cai-text-slate-600",children:["Need help writing instructions?"," ",e.jsx("button",{type:"button",onClick:()=>f(!0),className:"cai-text-blue-600 hover:cai-text-blue-700 hover:cai-underline cai-cursor-pointer cai-font-medium cai-bg-transparent cai-border-none cai-p-0 cai-inline",children:"View reference templates"})]})]}),e.jsx(xa,{open:r,onClose:()=>m(!1),currentInstruction:x,agentId:i,model:n,onApply:s=>l(s)}),e.jsx(pa,{open:u,onClose:()=>f(!1),onApply:s=>l(s)})]})}const{Text:W}=T;function ga({model:a,setModel:t,temperature:d,setTemperature:h,maxTokens:x,setMaxTokens:l,isStrictModel:p}){var f;const o=((f=window.replyan_ai_admin)==null?void 0:f.models)||{},[i,n]=c.useState("openai");c.useEffect(()=>{a.includes("openrouter/")?n("openrouter"):a.includes("claude")?n("anthropic"):a.includes("gemini")?n("gemini"):n("openai")},[a]);const r=s=>{const g=s.target.value;n(g),g==="openrouter"?t("openrouter/meta-llama/llama-3-8b-instruct"):g==="openai"?t("gpt-4.1-mini"):g==="anthropic"?t("claude-3-5-sonnet-20240620"):g==="gemini"&&t("gemini-2.5-flash")},m=Object.entries(o).filter(([s])=>i==="anthropic"?s.includes("claude"):i==="gemini"?s.includes("gemini"):!s.includes("claude")&&!s.includes("gemini")&&!s.includes("openrouter/")).map(([s,g])=>({value:s,label:g})),u=i==="openrouter"?a.replace("openrouter/",""):"";return e.jsxs("div",{className:"cai-pt-6",children:[e.jsxs("div",{className:"cai-mb-8",children:[e.jsx(W,{className:"cai-block cai-mb-2 cai-font-medium cai-text-slate-900",children:"AI Provider"}),e.jsx($.Group,{value:i,onChange:r,className:"cai-w-full",children:e.jsxs("div",{className:"cai-grid cai-grid-cols-2 sm:cai-grid-cols-4 cai-gap-4",children:[e.jsxs($.Button,{value:"openai",className:"!cai-h-auto !cai-p-4 !cai-text-center !cai-rounded-xl cai-flex cai-flex-col cai-items-center cai-justify-center",children:[e.jsx("img",{src:ce,alt:"ChatGPT",className:"cai-w-8 cai-h-8 cai-object-contain cai-mb-1"}),e.jsx("div",{className:"cai-mt-2 cai-font-medium",children:"ChatGPT"})]}),e.jsxs($.Button,{value:"anthropic",className:"!cai-h-auto !cai-p-4 !cai-text-center !cai-rounded-xl cai-flex cai-flex-col cai-items-center cai-justify-center",children:[e.jsx("img",{src:je,alt:"Claude",className:"cai-w-8 cai-h-8 cai-object-contain cai-mb-1"}),e.jsx("div",{className:"cai-mt-2 cai-font-medium",children:"Claude"})]}),e.jsxs($.Button,{value:"gemini",className:"!cai-h-auto !cai-p-4 !cai-text-center !cai-rounded-xl cai-flex cai-flex-col cai-items-center cai-justify-center",children:[e.jsx("img",{src:we,alt:"Gemini",className:"cai-w-8 cai-h-8 cai-object-contain cai-mb-1"}),e.jsx("div",{className:"cai-mt-2 cai-font-medium",children:"Gemini"})]}),e.jsxs($.Button,{value:"openrouter",className:"!cai-h-auto !cai-p-4 !cai-text-center !cai-rounded-xl cai-flex cai-flex-col cai-items-center cai-justify-center",children:[e.jsx("img",{src:ve,alt:"OpenRouter",className:"cai-w-8 cai-h-8 cai-object-contain cai-mb-1 cai-text-indigo-500"}),e.jsx("div",{className:"cai-mt-2 cai-font-medium",children:"OpenRouter"})]})]})})]}),e.jsx(ke,{message:"Tip: Choose the Right AI Model",description:"More advanced AI models generally provide better reasoning, accuracy, and more natural conversations. However, they may also consume more tokens, respond more slowly, and increase API costs. For most chatbots, a balanced model such as GPT-4.1 Mini provides an excellent combination of quality, speed, and cost.",type:"info",showIcon:!0,className:"cai-mb-6 cai-rounded-xl"}),e.jsxs("div",{className:"cai-p-6 cai-bg-white cai-border cai-border-slate-200 cai-rounded-xl cai-shadow-sm",children:[e.jsxs("div",{className:"cai-flex cai-justify-between cai-items-center cai-mb-6 cai-pb-4 cai-border-b cai-border-slate-100",children:[e.jsxs("div",{children:[e.jsx(W,{className:"cai-text-sm cai-font-medium cai-block",children:"Select model"}),i==="openrouter"&&e.jsxs(W,{className:"cai-text-xs cai-text-slate-500 cai-block cai-mt-1",children:["Not sure which model to choose? Browse available models ",e.jsx("a",{href:"https://openrouter.ai/models",target:"_blank",rel:"noopener noreferrer",className:"cai-text-indigo-600 hover:cai-text-indigo-700",children:"here"}),"."]})]}),i==="openrouter"?e.jsx(O,{value:u,onChange:s=>t(`openrouter/${s.target.value}`),placeholder:"e.g. mistralai/mixtral-8x7b-instruct",className:"cai-w-[250px]"}):e.jsx(ye,{value:a,onChange:t,className:"cai-w-[200px]",options:m})]}),!p&&e.jsxs("div",{className:"cai-mb-8",children:[e.jsxs("div",{className:"cai-flex cai-justify-between cai-mb-2",children:[e.jsxs(W,{className:"cai-text-sm cai-font-medium cai-text-slate-700",children:["Temperature",e.jsx(L,{title:"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.",children:e.jsx("span",{className:"cai-text-slate-400 cai-text-xs cai-ml-1 cai-cursor-help",children:"?"})})]}),e.jsx(me,{value:d,onChange:s=>h(s!==null?s:.2),min:0,max:2,step:.1,className:"cai-w-[60px] !cai-rounded-md",controls:!1})]}),e.jsx(de,{value:d,onChange:h,min:0,max:2,step:.1,trackStyle:{background:"#6366f1"},handleStyle:{borderColor:"#6366f1",background:"#6366f1"}})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"cai-flex cai-justify-between cai-mb-2",children:[e.jsxs(W,{className:"cai-text-sm cai-font-medium cai-text-slate-700",children:[p?"Max Completion Tokens":"Max Tokens",e.jsx(L,{title:"The maximum number of tokens to generate in the completion. The total tokens of your prompt plus max tokens cannot exceed the model's context length.",children:e.jsx("span",{className:"cai-text-slate-400 cai-text-xs cai-ml-1 cai-cursor-help",children:"?"})})]}),e.jsx(me,{value:x,onChange:s=>l(s!==null?s:1e3),min:50,max:4e3,step:50,className:"cai-w-[60px] !cai-rounded-md",controls:!1})]}),e.jsx(de,{value:x,onChange:l,min:50,max:4e3,step:50,trackStyle:{background:"#6366f1"},handleStyle:{borderColor:"#6366f1",background:"#6366f1"}})]})]})]})}const{Text:ba,Paragraph:si}=T;function ya({activeAgent:a}){const t=a?`[replyan_ai agent="${a.id}"]`:"[replyan_ai]",d=()=>{navigator.clipboard.writeText(t),b.success("Shortcode copied to clipboard!")};return e.jsxs("div",{className:"cai-flex cai-flex-col cai-gap-6 cai-p-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"cai-text-lg cai-font-semibold cai-text-slate-800 cai-mb-2",children:"Agent Shortcode"}),e.jsx("p",{className:"cai-text-sm cai-text-slate-500 cai-mb-0",children:"Use this shortcode to embed this specific agent anywhere on your site. You can embed multiple different agents on the same page."})]}),e.jsx(z,{className:"cai-border-slate-200 cai-shadow-sm cai-bg-slate-50/50",children:e.jsxs("div",{className:"cai-flex cai-flex-col cai-gap-4",children:[e.jsx(ke,{message:"How it works",description:"By defining the agent parameter, the chatbot widget will automatically inherit this agent's model, temperature, and custom instructions.",type:"info",showIcon:!0,className:"cai-border-blue-200 cai-bg-blue-50"}),e.jsxs("div",{className:"cai-flex cai-flex-col cai-gap-2",children:[e.jsx(ba,{strong:!0,className:"cai-text-slate-700",children:"Shortcode snippet:"}),e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-3 cai-bg-slate-900 cai-p-4 cai-rounded-lg cai-shadow-inner",children:[e.jsx(na,{size:18,className:"cai-text-slate-400"}),e.jsx("code",{className:"cai-flex-1 cai-text-green-400 cai-font-mono cai-text-base",children:t}),e.jsx(L,{title:"Copy to clipboard",children:e.jsx(w,{type:"text",icon:e.jsx(re,{size:16,className:"cai-text-slate-300 hover:cai-text-white"}),onClick:d,className:"cai-flex cai-items-center cai-justify-center"})})]})]})]})})]})}const{Title:ja,Text:wa}=T,pe=window.replyan_ai_admin||{};function va({assignedForms:a,setAssignedForms:t}){const[d,h]=c.useState([]),[x,l]=c.useState(!1);c.useEffect(()=>{(async()=>{l(!0);try{const n=new URLSearchParams;n.append("action","replyan_ai_get_forms"),n.append("nonce",pe.nonce),n.append("per_page","100");const m=await(await fetch(pe.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},credentials:"same-origin",body:n})).json();m.success&&h(m.data.forms||[])}catch(n){console.error("Failed to fetch forms for mapping",n)}finally{l(!1)}})()},[]);const p=(i,n)=>{t(n?[...a,{form_id:i,is_default:0}]:a.filter(r=>parseInt(r.form_id,10)!==parseInt(i,10)))},o=[{title:"Enable for this Agent",dataIndex:"id",key:"enable",width:180,render:i=>{const n=a.some(r=>parseInt(r.form_id,10)===parseInt(i,10));return e.jsx(Fe,{checked:n,onChange:r=>p(i,r)})}},{title:"Form Name",dataIndex:"name",key:"name",render:i=>e.jsx("strong",{children:i})},{title:"AI Instructions",dataIndex:"ai_instruction",key:"ai_instruction",render:i=>i}];return e.jsxs(z,{className:"cai-shadow-sm cai-mt-4",children:[e.jsxs("div",{className:"cai-mb-4",children:[e.jsxs(ja,{level:5,className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx(Oe,{})," Assigned Dynamic Forms"]}),e.jsx(wa,{type:"secondary",children:"Select which forms this AI agent is allowed to trigger and use during a conversation."})]}),e.jsx(Re,{columns:o,dataSource:d,rowKey:"id",loading:x,pagination:!1,size:"small"})]})}const{Title:Na,Text:Z,Paragraph:ka}=T,{Option:ci}=ye;function Ca({facebookPageId:a,setFacebookPageId:t,facebookPageName:d,setFacebookPageName:h,facebookPageToken:x,setFacebookPageToken:l}){const[p,o]=c.useState(""),[i,n]=c.useState(!0),[r,m]=c.useState(!1),[u,f]=c.useState(""),[s,g]=c.useState([]),[j,v]=c.useState(!1),[k,A]=c.useState(!1);c.useEffect(()=>{{n(!1);return}},[]),c.useEffect(()=>{},[p]);{const P=[{name:"Facebook Messenger",icon:e.jsx(De,{className:"cai-text-xl cai-text-blue-600"}),bgColor:"cai-bg-blue-50",borderColor:"cai-border-blue-100",description:"Connect to your Facebook Pages and auto-reply to incoming customer messages 24/7.",status:"In Development",statusColor:"processing"},{name:"WhatsApp Business",icon:e.jsx(Ze,{size:20,className:"cai-text-emerald-600"}),bgColor:"cai-bg-emerald-50",borderColor:"cai-border-emerald-100",description:"Engage leads and provide instant support to customers directly through WhatsApp.",status:"Planned",statusColor:"default"},{name:"Instagram Direct",icon:e.jsx(He,{className:"cai-text-xl cai-text-pink-600"}),bgColor:"cai-bg-pink-50",borderColor:"cai-border-pink-100",description:"Automatically answer direct messages, product inquiries, and story mentions.",status:"Planned",statusColor:"default"},{name:"Telegram Bot",icon:e.jsx(ta,{size:20,className:"cai-text-sky-600"}),bgColor:"cai-bg-sky-50",borderColor:"cai-border-sky-100",description:"Deploy this agent into Telegram chats, channels, and customer support groups.",status:"Planned",statusColor:"default"}];return e.jsxs(z,{className:"!cai-rounded-xl cai-shadow-sm cai-mt-4",children:[e.jsx("div",{className:"cai-flex cai-flex-col sm:cai-flex-row sm:cai-items-center cai-justify-between cai-gap-4 cai-pb-6 cai-border-b cai-border-slate-100",children:e.jsxs("div",{className:"cai-flex cai-items-start cai-gap-3.5",children:[e.jsx("div",{className:"cai-p-3 cai-bg-indigo-50 cai-text-indigo-600 cai-rounded-xl cai-flex cai-items-center cai-justify-center",children:e.jsx(Ce,{size:22})}),e.jsxs("div",{children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2.5",children:[e.jsx(Na,{level:5,className:"!cai-m-0 !cai-text-base !cai-font-semibold",children:"Social & Omnichannel Integrations"}),e.jsx(oe,{color:"blue",className:"!cai-rounded-full cai-px-2.5 cai-py-0.5 !cai-text-xs !cai-font-medium !cai-m-0",children:"Coming Soon"})]}),e.jsx(ka,{className:"cai-text-slate-500 cai-mt-1 !cai-mb-0 cai-text-sm",children:"Connect your AI agent to external messaging channels to automate customer conversations everywhere."})]})]})}),e.jsxs("div",{className:"cai-pt-6",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2 cai-mb-4",children:[e.jsx(ne,{size:16,className:"cai-text-indigo-500"}),e.jsx(Z,{strong:!0,className:"cai-text-xs cai-uppercase cai-tracking-wider cai-text-slate-400",children:"Upcoming Channels"})]}),e.jsx("div",{className:"cai-grid cai-grid-cols-1 md:cai-grid-cols-2 cai-gap-4",children:P.map(y=>e.jsxs("div",{className:`cai-p-4 cai-rounded-xl cai-border cai-border-solid ${y.borderColor} cai-bg-white hover:cai-shadow-sm cai-transition-all cai-duration-200`,children:[e.jsxs("div",{className:"cai-flex cai-items-start cai-justify-between cai-gap-3 cai-mb-2",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-3",children:[e.jsx("div",{className:`cai-w-9 cai-h-9 ${y.bgColor} cai-rounded-lg cai-flex cai-items-center cai-justify-center`,children:y.icon}),e.jsx(Z,{strong:!0,className:"cai-text-sm cai-text-slate-800",children:y.name})]}),e.jsx(oe,{color:y.statusColor,className:"!cai-rounded-full !cai-m-0 !cai-text-[11px]",children:y.status})]}),e.jsx(Z,{className:"cai-text-xs cai-text-slate-500 cai-leading-relaxed cai-block cai-pl-12",children:y.description})]},y.name))})]}),e.jsx("div",{className:"cai-mt-6 cai-p-4 cai-bg-slate-50 cai-rounded-xl cai-border cai-border-dashed cai-border-slate-200 cai-text-center",children:e.jsx(Z,{className:"cai-text-xs cai-text-slate-500",children:"🚀 Omnichannel capabilities are actively being developed for upcoming releases. Webhook synchronization and multi-page routing will be configurable here."})})]})}}const Sa=`Persona Name: John Doe
Role: You are John Doe, a helpful AI assistant for our website. Your goal is to answer customer questions accurately and politely.
Primary Language: English
Style: Professional and friendly.

# RULES:
1. Keep your answers short and concise.
2. Always greet the user on the first interaction.
3. If you don't know the answer, politely let the user know and offer to connect them with a human agent.`,Ta=(a,t)=>{const[d,h]=c.useState(a?a.agent_name:""),[x,l]=c.useState(a?a.description:""),[p,o]=c.useState(!1),[i,n]=c.useState(a?a.model:"gpt-4.1-mini"),[r,m]=c.useState(a?Number(a.temperature):.2),[u,f]=c.useState(a?Number(a.max_tokens):1e3),[s,g]=c.useState(a?a.facebook_page_id:""),[j,v]=c.useState(a?a.facebook_page_name:""),[k,A]=c.useState(a?a.facebook_page_token:""),[P,y]=c.useState([]),[F,H]=c.useState(""),[q,G]=c.useState(!1),[ee,V]=c.useState(!1),[U,ae]=c.useState(a?a.instruction:Sa),[Y,ie]=c.useState(a?!!Number(a.include_woocommerce):!1),[J,K]=c.useState([]);c.useEffect(()=>{a&&te()},[a]);const te=async()=>{var _,C;try{const N=new URLSearchParams;N.append("action","replyan_ai_get_agent_forms"),N.append("nonce",((_=window.replyan_ai_admin)==null?void 0:_.nonce)||""),N.append("agent_id",a.id);const I=await(await fetch((C=window.replyan_ai_admin)==null?void 0:C.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:N})).json();I.success&&K(I.data.forms||[])}catch(N){console.error("Failed to fetch assigned forms",N)}};return{agentName:d,setAgentName:h,agentDescription:x,setAgentDescription:l,isSaving:p,model:i,setModel:n,temperature:r,setTemperature:m,maxTokens:u,setMaxTokens:f,testMessages:P,setTestMessages:y,testInput:F,setTestInput:H,isTesting:q,hasTested:ee,setHasTested:V,instructionText:U,setInstructionText:ae,includeWoocommerce:Y,setIncludeWoocommerce:ie,assignedForms:J,setAssignedForms:K,facebookPageId:s,setFacebookPageId:g,facebookPageName:j,setFacebookPageName:v,facebookPageToken:k,setFacebookPageToken:A,handleTestMessage:async()=>{var N,M,I;if(!F.trim()||q)return;V(!0);const _={role:"user",content:F},C=[...P,_];y(C),H(""),G(!0);try{const E={action:"replyan_ai_test_agent",nonce:((N=window.replyan_ai_admin)==null?void 0:N.nonce)||"",message:_.content,model:i,instruction:U,temperature:r,max_tokens:u,history:JSON.stringify(P)},Q=await(await fetch(((M=window.replyan_ai_admin)==null?void 0:M.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(E)})).json();if(Q.success)y([...C,{role:"assistant",content:Q.data.reply}]);else{const R=((I=Q.data)==null?void 0:I.message)||"Test failed.";y([...C,{role:"error",content:R}]),b.error(R)}}catch{const B="An error occurred during test.";y([...C,{role:"error",content:B}]),b.error(B)}finally{G(!1)}},handleSave:async()=>{var _,C,N,M,I;if(!d.trim()){b.error("Please enter an Agent Name.");return}o(!0);try{const E=i.includes("claude")?"anthropic":i.includes("gemini")?"gemini":"openai",B={id:a?a.id:void 0,agent_name:d,description:x,instruction:U,provider:E,model:i,temperature:r,max_tokens:u,include_woocommerce:Y?1:0,facebook_page_id:s,facebook_page_name:j,facebook_page_token:k},R=await(await fetch(((_=window.replyan_ai_admin)==null?void 0:_.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"replyan_ai_save_agent",nonce:((C=window.replyan_ai_admin)==null?void 0:C.nonce)||"",agent_data:JSON.stringify(B)})})).json();if(R.success){const Se=R.data.id,D=new URLSearchParams;D.append("action","replyan_ai_save_agent_forms"),D.append("nonce",((N=window.replyan_ai_admin)==null?void 0:N.nonce)||""),D.append("agent_id",Se),D.append("forms",JSON.stringify(J)),await fetch(((M=window.replyan_ai_admin)==null?void 0:M.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:D}),b.success("Agent saved successfully!"),t()}else b.error(((I=R.data)==null?void 0:I.message)||"Failed to save agent.")}catch(E){console.error("Error saving agent:",E),b.error("An error occurred while saving.")}finally{o(!1)}}}},{Title:_a}=T;function Ia({onBack:a,editingAgent:t}){const{agentName:d,setAgentName:h,agentDescription:x,setAgentDescription:l,isSaving:p,model:o,setModel:i,temperature:n,setTemperature:r,maxTokens:m,setMaxTokens:u,testMessages:f,setTestMessages:s,testInput:g,setTestInput:j,isTesting:v,hasTested:k,setHasTested:A,instructionText:P,setInstructionText:y,includeWoocommerce:F,setIncludeWoocommerce:H,assignedForms:q,setAssignedForms:G,facebookPageId:ee,setFacebookPageId:V,facebookPageName:U,setFacebookPageName:ae,facebookPageToken:Y,setFacebookPageToken:ie,handleTestMessage:J,handleSave:K}=Ta(t,a),te=o.startsWith("o1")||o.startsWith("o3")||o.startsWith("gpt-5")||o.startsWith("chatgpt-5");return e.jsxs("div",{className:"cai-flex cai-gap-6 cai-items-stretch",children:[e.jsxs("div",{className:"cai-flex-1 cai-basis-[60%] cai-min-w-0",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-justify-between cai-mb-6",children:[e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-3",children:[e.jsx(w,{type:"text",icon:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]}),onClick:a}),e.jsx(_a,{level:4,className:"!cai-m-0 !cai-text-lg !cai-font-semibold",children:t?"Edit Agent":"Create Agent"})]}),e.jsx("div",{className:"cai-flex cai-items-center cai-gap-3",children:e.jsx(w,{type:"primary",onClick:K,loading:p,className:"!cai-bg-indigo-500 !cai-rounded-full cai-px-6 !cai-h-auto cai-py-2 !cai-font-medium",children:"Save Agent"})})]}),e.jsx("div",{className:"cai-agent-tabs-wrapper",children:e.jsx(Pe,{defaultActiveKey:"1",items:[{key:"1",label:e.jsxs("span",{className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx("span",{className:"cai-text-base",children:"✨"})," Instruction"]}),children:e.jsx(fa,{agentName:d,setAgentName:h,agentDescription:x,setAgentDescription:l,instructionText:P,setInstructionText:y,includeWoocommerce:F,setIncludeWoocommerce:H,agentId:(t==null?void 0:t.id)||0,model:o})},{key:"2",label:e.jsxs("span",{className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx("span",{className:"cai-text-base cai-flex cai-items-center",children:e.jsx(Le,{size:18})})," AI Model"]}),children:e.jsx(ga,{model:o,setModel:i,temperature:n,setTemperature:r,maxTokens:m,setMaxTokens:u,isStrictModel:te})},{key:"3",label:e.jsxs("span",{className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx("span",{className:"cai-text-base cai-flex cai-items-center",children:e.jsx(Ge,{size:18})})," Shortcode"]}),children:e.jsx(ya,{activeAgent:t})},{key:"4",label:e.jsxs("span",{className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx("span",{className:"cai-text-base cai-flex cai-items-center",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]})})," Forms"]}),children:e.jsx(va,{assignedForms:q,setAssignedForms:G})},{key:"5",label:e.jsxs("span",{className:"cai-flex cai-items-center cai-gap-2",children:[e.jsx("span",{className:"cai-text-base cai-flex cai-items-center",children:e.jsx(Ce,{size:18})})," Social"]}),children:e.jsx(Ca,{facebookPageId:ee,setFacebookPageId:V,facebookPageName:U,setFacebookPageName:ae,facebookPageToken:Y,setFacebookPageToken:ie})}]})})]}),e.jsx(ma,{testMessages:f,setTestMessages:s,hasTested:k,setHasTested:A,isTesting:v,testInput:g,setTestInput:j,handleTestMessage:J})]})}const Pa=a=>{const[t,d]=c.useState([]),[h,x]=c.useState(!0),l=async()=>{var n,r;x(!0);try{const u=await(await fetch(((n=window.replyan_ai_admin)==null?void 0:n.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"replyan_ai_get_agents",nonce:((r=window.replyan_ai_admin)==null?void 0:r.nonce)||""})})).json();if(u.success){const f=u.data.agents||[],s=u.data.default_agent_id,g=[...f].sort((j,v)=>j.id==s?-1:v.id==s?1:0);d(g)}}catch(m){console.error("Failed to fetch agents:",m)}finally{x(!1)}},p=async n=>{var r,m,u;try{const s=await(await fetch(((r=window.replyan_ai_admin)==null?void 0:r.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"replyan_ai_delete_agent",nonce:((m=window.replyan_ai_admin)==null?void 0:m.nonce)||"",agent_id:n})})).json();s.success?(b.success("Agent removed"),l()):b.error(((u=s.data)==null?void 0:u.message)||"Failed to remove")}catch{b.error("An error occurred")}},o=async n=>{var r,m,u;try{const s=await(await fetch(((r=window.replyan_ai_admin)==null?void 0:r.ajaxUrl)||"/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"replyan_ai_make_default",nonce:((m=window.replyan_ai_admin)==null?void 0:m.nonce)||"",agent_id:n})})).json();s.success?(b.success("Agent set as default"),l()):b.error(((u=s.data)==null?void 0:u.message)||"Failed to set default")}catch{b.error("An error occurred")}};return c.useEffect(()=>{a==="list"&&l()},[a]),{agents:t,loading:h,fetchAgents:l,getDropdownItems:(n,r)=>{const m=[];return r||(m.push({key:"default",label:e.jsx("span",{children:"Make Default"}),onClick:()=>o(n.id)}),m.push({type:"divider"})),m.push({key:"remove",label:e.jsx("span",{className:"cai-text-red-500",children:"Remove agent"}),onClick:()=>p(n.id),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#ef4444",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),m}}},{Text:La}=T;function za({loading:a,agents:t,setEditingAgent:d,setView:h,getDropdownItems:x,getProviderIcon:l}){return e.jsxs("div",{className:"cai-mb-8",children:[e.jsx(La,{type:"secondary",strong:!0,className:"cai-text-xs cai-uppercase cai-tracking-wide cai-text-slate-500",children:"DEFAULT AGENT"}),a?e.jsx("div",{className:"cai-p-5 cai-text-slate-400",children:"Loading agents..."}):t.length>0?e.jsxs(z,{className:"cai-agent-card cai-mt-3 !cai-rounded-xl !cai-border-slate-200 cai-shadow-sm",styles:{body:{padding:"20px"}},children:[e.jsxs("div",{className:"cai-agent-actions cai-absolute cai-top-4 cai-right-4 cai-flex cai-gap-2",children:[e.jsx(w,{type:"text",size:"small",icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]}),className:"!cai-text-slate-900",onClick:()=>{d(t[0]),h("create")}}),e.jsx(Ne,{menu:{items:x(t[0],!0)},trigger:["click"],placement:"bottomRight",children:e.jsx(w,{type:"text",size:"small",className:"!cai-bg-slate-200 !cai-rounded-full !cai-w-7 !cai-h-7 !cai-p-0 cai-flex cai-items-center cai-justify-center !cai-text-slate-900",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1"}),e.jsx("circle",{cx:"12",cy:"5",r:"1"}),e.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})})]}),e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-4",children:[e.jsx("div",{className:"cai-w-14 cai-h-14 cai-rounded-2xl cai-border cai-border-slate-100 cai-bg-white cai-flex cai-items-center cai-justify-center cai-shadow-sm cai-shrink-0",children:e.jsx("img",{src:l(t[0].model),alt:"Provider",className:"cai-w-8 cai-h-8 cai-object-contain"})}),e.jsxs("div",{className:"cai-min-w-0 cai-flex-1",children:[e.jsx("div",{className:"cai-text-base cai-font-semibold cai-text-slate-900 cai-whitespace-nowrap cai-overflow-hidden cai-text-ellipsis",children:t[0].agent_name}),e.jsx("div",{className:"cai-text-sm cai-text-slate-500 cai-mt-1 cai-whitespace-nowrap cai-overflow-hidden cai-text-ellipsis",children:t[0].description||"No description provided."})]})]})]}):e.jsx("div",{className:"cai-p-5 cai-text-slate-400",children:"No agents created yet."})]})}const{Text:Aa}=T;function Ma({agents:a,setEditingAgent:t,setView:d,getDropdownItems:h,getProviderIcon:x}){return e.jsxs("div",{children:[e.jsx(Aa,{type:"secondary",strong:!0,className:"cai-text-xs cai-uppercase cai-tracking-wide cai-text-slate-500",children:"ALL AGENTS"}),e.jsx(ze,{gutter:[16,16],className:"!cai-mt-3",children:a.slice(1).map(l=>e.jsx(Ae,{xs:24,md:12,lg:8,children:e.jsxs(z,{className:"cai-agent-card !cai-rounded-xl !cai-border-slate-200 cai-h-full cai-shadow-sm",styles:{body:{padding:"20px",display:"flex",flexDirection:"column",height:"100%",position:"relative"}},children:[e.jsxs("div",{className:"cai-agent-actions cai-absolute cai-top-4 cai-right-4 cai-flex cai-gap-2",children:[e.jsx(w,{type:"text",size:"small",icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]}),className:"!cai-text-slate-900",onClick:()=>{t(l),d("create")}}),e.jsx(Ne,{menu:{items:h(l,!1)},trigger:["click"],placement:"bottomRight",children:e.jsx(w,{type:"text",size:"small",className:"!cai-bg-slate-200 !cai-rounded-full !cai-w-7 !cai-h-7 !cai-p-0 cai-flex cai-items-center cai-justify-center !cai-text-slate-900",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1"}),e.jsx("circle",{cx:"12",cy:"5",r:"1"}),e.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})})]}),e.jsxs("div",{className:"cai-flex cai-items-start cai-gap-4 cai-flex-1",children:[e.jsx("div",{className:"cai-w-12 cai-h-12 cai-rounded-2xl cai-border cai-border-slate-100 cai-bg-white cai-flex cai-items-center cai-justify-center cai-shadow-sm cai-shrink-0",children:e.jsx("img",{src:x(l.model),alt:"Provider",className:"cai-w-7 cai-h-7 cai-object-contain"})}),e.jsxs("div",{className:"cai-min-w-0 cai-flex-1",children:[e.jsx("div",{className:"cai-text-base cai-font-semibold cai-text-slate-900 cai-pr-12 cai-whitespace-nowrap cai-overflow-hidden cai-text-ellipsis",children:l.agent_name}),e.jsx("div",{className:"cai-text-sm cai-text-slate-500 cai-mt-1 cai-whitespace-nowrap cai-overflow-hidden cai-text-ellipsis",children:l.description||"No description provided."})]})]}),e.jsxs("div",{className:"cai-flex cai-items-center cai-gap-2 cai-mt-6 cai-text-slate-500 cai-text-sm",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),"Ready to use"]})]})},l.id))})]})}const he=a=>a?a.includes("openrouter/")?ve:a.includes("claude")?je:a.includes("gemini")?we:ce:ce,{Title:Ea,Text:Ra}=T;function ni(){const[a,t]=c.useState("list"),[d,h]=c.useState(null),[x,l]=c.useState(!0),[p,o]=c.useState(""),{agents:i,loading:n,getDropdownItems:r}=Pa(a),m=(i==null?void 0:i.filter(f=>{var j,v;const s=(j=f.agent_name)==null?void 0:j.toLowerCase().includes(p.toLowerCase()),g=(v=f.description)==null?void 0:v.toLowerCase().includes(p.toLowerCase());return s||g}))||[],u=Me;return c.useEffect(()=>{var s;if((s=window.replyan_ai_admin)!=null&&s.is_pro){l(!1);return}const f=(i==null?void 0:i.length)>=u;l(f)},[i]),a==="create"?e.jsx("div",{className:"cai-px-8 cai-pb-8",children:e.jsx(z,{className:"replyan-ai-settings-card !cai-rounded-xl",children:e.jsx(Ia,{onBack:()=>{t("list"),h(null)},editingAgent:d})})}):e.jsx("div",{className:"cai-px-8 cai-pb-8",children:e.jsx(z,{className:"replyan-ai-settings-card !cai-rounded-xl",children:e.jsxs("div",{className:"cai-pb-6",children:[e.jsx(Ea,{level:2,className:"!cai-mt-0 !cai-mb-2 !cai-text-[24px] !cai-text-slate-900",children:"My Agents"}),e.jsx(Ra,{type:"secondary",className:"cai-text-sm cai-block cai-mb-6 cai-text-slate-500",children:"Manage and set up your Agents. Each Agent can be used in multiple features"}),e.jsxs("div",{className:"cai-flex cai-justify-between cai-mb-8",children:[e.jsx(O.Search,{placeholder:"Search...",className:"cai-max-w-[300px]",size:"large",value:p,onChange:f=>o(f.target.value)}),!x&&e.jsx(w,{type:"primary",size:"large",onClick:()=>t("create"),className:"!cai-bg-indigo-500 !cai-rounded-full cai-px-6 cai-flex cai-items-center cai-justify-center",children:"+ Create new agent"})]}),e.jsx(za,{loading:n,agents:m,setEditingAgent:h,setView:t,getDropdownItems:r,getProviderIcon:he}),e.jsx(Ma,{agents:m,setEditingAgent:h,setView:t,getDropdownItems:r,getProviderIcon:he})]})})})}export{ni as default};
