Changeset 3421612
- Timestamp:
- 12/17/2025 08:04:24 AM (6 weeks ago)
- Location:
- ai-engine/trunk
- Files:
-
- 8 edited
-
ai-engine.php (modified) (3 diffs)
-
app/index.js (modified) (3 diffs)
-
classes/engines/chatml.php (modified) (17 diffs)
-
classes/engines/mistral.php (modified) (13 diffs)
-
classes/engines/openai.php (modified) (2 diffs)
-
classes/query/image.php (modified) (3 diffs)
-
constants/models.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ai-engine/trunk/ai-engine.php
r3417844 r3421612 5 5 Plugin URI: https://wordpress.org/plugins/ai-engine/ 6 6 Description: AI meets WordPress. Your site can now chat, write poetry, solve problems, and maybe make you coffee. 7 Version: 3.2. 87 Version: 3.2.9 8 8 Author: Jordy Meow 9 9 Author URI: https://jordymeow.com … … 13 13 */ 14 14 15 define( 'MWAI_VERSION', '3.2. 8' );15 define( 'MWAI_VERSION', '3.2.9' ); 16 16 define( 'MWAI_PREFIX', 'mwai' ); 17 17 define( 'MWAI_DOMAIN', 'ai-engine' ); … … 30 30 define( 'MWAI_FALLBACK_MODEL_VISION', 'gpt-5-chat-latest' ); 31 31 define( 'MWAI_FALLBACK_MODEL_JSON', 'gpt-5-mini' ); 32 define( 'MWAI_FALLBACK_MODEL_IMAGES', 'gpt-image-1 ' );32 define( 'MWAI_FALLBACK_MODEL_IMAGES', 'gpt-image-1.5' ); 33 33 define( 'MWAI_FALLBACK_MODEL_AUDIO', 'whisper-1' ); 34 34 define( 'MWAI_FALLBACK_MODEL_EMBEDDINGS', 'text-embedding-3-small' ); -
ai-engine/trunk/app/index.js
r3417844 r3421612 549 549 grid-template-columns: 1fr 1fr 1fr; 550 550 grid-gap: 20px; 551 `,si=({addons:e})=>{const t=e.some((e=>e.enabled))?"enabled":"all",[a,n]=ri(t),l=oi((()=>"enabled"===a?e.filter((e=>e.enabled)):"disabled"===a?e.filter((e=>!e.enabled)):e),[e,a]);return React.createElement(React.Fragment,null,React.createElement(Ge.V,null,React.createElement(Q.o,{name:"filter",value:a,onChange:e=>n(e)},React.createElement(Q.K,{title:"All",value:"all"}),React.createElement(Q.K,{title:"Enabled",value:"enabled"}),React.createElement(Q.K,{title:"Disabled",value:"disabled"}))),React.createElement(Y.g,null),React.createElement(ii,null,l.map((e=>React.createElement(X.L,{key:e.id,style:{marginBottom:0,borderRadius:8,overflow:"auto"},footer:React.createElement("div",{style:{display:"flex",width:"100%",alignItems:"center",marginLeft:10,minHeight:30}},React.createElement("span",{style:{fontSize:"12px",marginRight:15,color:e.enabled?"#4CAF50":"#666",textTransform:"uppercase",fontWeight:"bold"}},e.enabled?React.createElement("label",null,"Enabled"):React.createElement("label",null,"Disabled")),React.createElement("div",{style:{flex:"auto"}}),e.enabled&&e.settings_url&&React.createElement(h.M,{className:"primary",onClick:()=>window.open(e.settings_url,"_self")},"Settings"),!e.enabled&&React.createElement(h.M,{className:"primary",onClick:()=>window.open(e.install_url,"_blank")},"Install"))},React.createElement("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",marginBottom:10}},React.createElement("div",{style:{width:32,marginTop:-5}},React.createElement(li.r,null)),React.createElement(s.s,{h3:!0,style:{margin:0,marginLeft:8,fontWeight:"bold"}},e.name),React.createElement("div",{style:{marginLeft:5,marginTop:2,fontSize:15,color:"#fec74c"}},Array.from({length:e.stars},((e,t)=>React.createElement("span",{key:t},"★"))))),React.createElement("div",{className:"addon-description"},e.description))))))},{useMemo:ci,useState:di,useEffect:mi,useCallback:ui,useRef:pi}=wp.element,gi=[{envKey:"ai_default_env",modelKey:"ai_default_model",fallbackKey:"default"},{envKey:"ai_fast_default_env",modelKey:"ai_fast_default_model",fallbackKey:"fast"},{envKey:"ai_embeddings_default_env",modelKey:"ai_embeddings_default_model",fallbackKey:"embeddings"},{envKey:"ai_vision_default_env",modelKey:"ai_vision_default_model",fallbackKey:"vision"},{envKey:"ai_images_default_env",modelKey:"ai_images_default_model",fallbackKey:"images"},{envKey:"ai_audio_default_env",modelKey:"ai_audio_default_model",fallbackKey:"audio"},{envKey:"ai_json_default_env",modelKey:"ai_json_default_model",fallbackKey:"json"}],Ei=["module_forms","module_statistics","module_embeddings","module_assistants","module_orchestration","module_cross_site"],hi=()=>{var e,t,a,n,l,r,o,i,p;const[v,b]=di(y.fF),w=y.gh.replace("/wp-json",""),[_,T]=di((()=>{const e=localStorage.getItem("mwai_settings_section");return e||"ai"})),[C,A]=di(null),[I,N]=di(!1),[O,S]=di(!1),[M,x]=di({isOpen:!1,command:"",title:""}),[k,P]=di(!1),[L,D]=di("default"),F=null==v?void 0:v.module_suggestions,U=null==v?void 0:v.module_advisor,B=null==v?void 0:v.module_forms,H=null==v?void 0:v.module_finetunes,ae=null==v?void 0:v.module_statistics,ne=null==v?void 0:v.module_playground,le=null==v?void 0:v.module_generator_content,ie=null==v?void 0:v.module_generator_images,se=null==v?void 0:v.module_generator_videos,ce=null==v?void 0:v.module_moderation,de=null==v?void 0:v.module_embeddings,me=null==v?void 0:v.module_assistants,ue=null==v?void 0:v.module_transcription,ge=null==v?void 0:v.module_devtools,Re=null==v?void 0:v.module_chatbots,fe=null==v?void 0:v.module_search,ye=null==v?void 0:v.module_orchestration,ve=null==v?void 0:v.module_cross_site,be=null==v?void 0:v.forms_editor,we=ci((()=>null!=v&&v.ai_envs?null==v?void 0:v.ai_envs:[]),[v]),Te=ci((()=>null!=v&&v.mcp_envs?null==v?void 0:v.mcp_envs:[]),[v]),Ce=null==v?void 0:v.ai_fast_default_env,Ae=null==v?void 0:v.ai_fast_default_model,Ie=null==v?void 0:v.ai_default_env,Ne=null==v?void 0:v.ai_default_model,Me=null==v?void 0:v.ai_vision_default_env,xe=null==v?void 0:v.ai_vision_default_model,ke=null==v?void 0:v.ai_embeddings_default_env,Pe=null==v?void 0:v.ai_embeddings_default_model,Le=null==v?void 0:v.ai_images_default_env,De=null==v?void 0:v.ai_images_default_model,Ue=null==v?void 0:v.ai_audio_default_env,Be=null==v?void 0:v.ai_audio_default_model,He=null==v?void 0:v.ai_json_default_env,je=null==v?void 0:v.ai_json_default_model,$e=null==v?void 0:v.ai_streaming,ze=null==v?void 0:v.ai_responses_api,Ge=null==v?void 0:v.privacy_first,We=null!=v&&v.embeddings_envs?null==v?void 0:v.embeddings_envs:[],qe=null==v?void 0:v.embeddings_default_env,Ke=null==v?void 0:v.syntax_highlight,Ve=null==v?void 0:v.event_logs,Ye=null==v?void 0:v.chatbot_discussions,Xe=null==v?void 0:v.chatbot_gdpr_consent,Qe=null==v?void 0:v.chatbot_gdpr_text,Je=null==v?void 0:v.chatbot_gdpr_button,Ze=null==v?void 0:v.speech_recognition,et=null==v?void 0:v.speech_synthesis,tt=null==v?void 0:v.public_api,it=null==v?void 0:v.statistics_data,st=null==v?void 0:v.statistics_forms_data,ct=null==v?void 0:v.intro_message,dt=null==v?void 0:v.context_max_length,mt=null==v?void 0:v.banned_ips,ut=null==v?void 0:v.banned_words,pt=null==v?void 0:v.ignore_word_boundaries,gt=(null==v?void 0:v.custom_languages)||[],Et=(null==v?void 0:v.admin_bar)??["settings"],ht=null==v?void 0:v.resolve_shortcodes,Rt=null==v?void 0:v.clean_uninstall,{completionModels:ft}=he(v),{completionModels:yt}=he(v,null==v?void 0:v.ai_default_env),{completionModels:vt}=he(v,null==v?void 0:v.ai_fast_default_env),{visionModels:bt}=he(v,null==v?void 0:v.ai_vision_default_env),{audioModels:wt}=he(v,null==v?void 0:v.ai_audio_default_env),{jsonModels:_t}=he(v,null==v?void 0:v.ai_json_default_env),{imageModels:Tt}=he(v,null==v?void 0:v.ai_images_default_env),{embeddingsModels:Ct}=he(v,null==v?void 0:v.ai_embeddings_default_env),At=ci((()=>we&&null!=v&&v.ai_engines?we.filter((e=>{if("azure"===e.type){var t;return null===(t=e.deployments)||void 0===t?void 0:t.some((e=>{var t,a;return(null===(t=e.model)||void 0===t?void 0:t.includes("embedding"))||(null===(a=e.model)||void 0===a?void 0:a.includes("ada"))}))}const a=v.ai_engines.find((t=>t.type===e.type));if(!a||!a.models)return!1;return a.models.some((e=>pe(e,"embedding")))})):[]),[we,v]),It=ci((()=>Ct.find((e=>e.model===Pe))),[Ct,Pe]),Nt=ci((()=>{var e;if(!It)return[];if(pe(It,"matryoshka")&&(null==It||null===(e=It.dimensions)||void 0===e?void 0:e.length)>0){const e=It.dimensions[0];return[3072,2048,1536,1024,768,512].filter((t=>t<=e))} return(null==It?void 0:It.dimensions)||[]}),[It]),Ot=(e,t,a)=>!(!e||!t)&&(!(!a||0===a.length)&&a.some((e=>e.model===t))),Mt=I,kt=ui((async e=>{try{if((0,f.F1)(e)===(0,f.F1)(v))return;N(!0);const t=await(0,f.IU)(`${y.y0}/settings/update`,{method:"POST",nonce:y.ok,json:{options:e}});b(t.options)}catch(t){console.error(oe.A.ERROR.UPDATING_OPTIONS,null!=t&&t.message?{message:t.message,options:v,newOptions:e}:{err:t,options:v,newOptions:e}),t.message&&A(React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.ERROR.UPDATING_OPTIONS),React.createElement("small",null,(0,f.FE)(oe.A.ERROR.CHECK_YOUR_CONSOLE))))}finally{N(!1)}}),[v]),Pt=(ui(((e,t)=>{var a;if(!e)return[];const n=we.find((t=>t.id===e));if(!n)return[];let l=[];const r=(null==v||null===(a=v.ai_models)||void 0===a?void 0:a.filter((e=>e.type===n.type&&(!e.envId||e.envId===n.id))))??[];if(r.length>0)l=r;else{var o;const e=null==v||null===(o=v.ai_engines)||void 0===o?void 0:o.find((e=>e.type===n.type));l=(null==e?void 0:e.models)??[]}if(!l.length)return[];switch(t){case"embeddings":return l.filter((e=>pe(e,"embedding")));case"vision":return l.filter((e=>pe(e,"vision")));case"images":return l.filter((e=>pe(e,"image")));case"audio":return l.filter((e=>pe(e,"audio")));case"json":return l.filter((e=>pe(e,"json")));default:return l.filter((e=>pe(e,"chat")||pe(e,"completion")))}}),[we,null==v?void 0:v.ai_engines,null==v?void 0:v.ai_models]),pi(!1));mi((()=>{if(Pt.current)return;(async()=>{let e=!1;const t={...v};gi.forEach((({envKey:a,modelKey:n,fallbackKey:l})=>{const r=y.hI[l],o="embeddings"===l?At:we;let i=!1;if(v[a]&&(i=!!o.find((e=>e.id===v[a]))),!i){const l=o.find((e=>"openai"===(null==e?void 0:e.type)));if(l)t[a]===l.id&&t[n]===r||(console.warn(`Updating ${a} and ${n} to ${l.id} and ${r}`),e=!0,t[a]=l.id,t[n]=r);else{const l=null!==v[a]&&""!==v[a],r=null!==v[n]&&""!==v[n],o="ai_embeddings_default_model"===n&&null!==v.ai_embeddings_default_dimensions&&""!==v.ai_embeddings_default_dimensions;(l||r||o)&&(console.warn(`No valid environment for ${a}, resetting to null`),e=!0,t[a]=null,t[n]=null,"ai_embeddings_default_model"===n&&(t.ai_embeddings_default_dimensions=null))}}if("ai_embeddings_default_model"===n&&t[n]){const a=(null==t?void 0:t.ai_embeddings_default_dimensions)||null;if(null!==a){const l=Ct.find((e=>e.model===t[n]));if(l){var s;const n=pe(l,"matryoshka");let r=(null==l?void 0:l.dimensions)||[];if(n&&(null==l||null===(s=l.dimensions)||void 0===s?void 0:s.length)>0){const e=l.dimensions[0];r=[3072,2048,1536,1024,768,512].filter((t=>t<=e))}if(!r.includes(parseInt(a))){const a=r[0]||null;null!==a&&(t.ai_embeddings_default_dimensions=a,console.warn(`Updating embeddings default dimensions to ${a}`),e=!0)}}}}})),e&&(Pt.current=!0,await kt(t))})()}),[we,At,v,kt,Ct,y.hI]);const Lt=async()=>{N(!0);try{const e=await ot();b(e)}catch(e){console.error(oe.A.ERROR.GETTING_OPTIONS,null!=e&&e.message?{message:e.message}:{err:e}),e.message&&A(React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.ERROR.GETTING_OPTIONS),React.createElement("small",null,(0,f.FE)(oe.A.ERROR.CHECK_YOUR_CONSOLE))))}finally{N(!1)}},Dt=async(e,t)=>{const a={...v,[t]:e};await kt(a)},Ft=async e=>{S(!0);try{await Dt(e,"embeddings_settings")}finally{S(!1)}},Ut=async(e,t)=>{const a=We.map((a=>a.id===e?{...a,...t}:a));Dt(a,"embeddings_envs")};mi((()=>{if(!y.zN){const e={...v};let t=!1;Ei.forEach((a=>{e[a]&&(e[a]=!1,console.warn(`Resetting ${a}`),t=!0)})),t&&(0,f.F1)(e)!==(0,f.F1)(v)&&kt(e)}}),[]),mi((()=>{localStorage.setItem("mwai_settings_section",_)}),[_]),mi((()=>{!$e&&Ve&&Dt(!1,"event_logs")}),[$e,Ve,Dt]),mi((()=>{"ai"===_||"files"===_||"php_api"===_||"rest_api"===_||"mcp"===_||"others"===_||"addons"===_||"chatbot"===_&&Re||"knowledge"===_&&de||"orchestration"===_&&ye||"assistants"===_&&me||T("ai")}),[_,Re,de,ye,me]),mi((()=>{if(!y.am)return;(0,te._)()||P(!0)}),[y.am]);const Bt=React.createElement(c.d,{title:oe.A.COMMON.UTILITIES},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_suggestions",label:oe.A.COMMON.POSTS_SUGGESTIONS,value:"1",checked:F,description:oe.A.COMMON.POSTS_SUGGESTIONS_HELP,onChange:Dt}))),Ht=React.createElement(c.d,{title:oe.A.COMMON.ADVISOR},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_advisor",label:oe.A.COMMON.ENABLE,value:"1",checked:U,description:oe.A.HELP.ADVISOR,onChange:Dt}))),jt=React.createElement(c.d,{title:oe.A.COMMON.GENERATORS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_generator_content",label:oe.A.COMMON.CONTENT_GENERATOR,value:"1",checked:le,description:oe.A.COMMON.CONTENT_GENERATOR_HELP,onChange:Dt}),React.createElement(m.R,{name:"module_generator_images",label:oe.A.COMMON.IMAGES_GENERATOR,value:"1",checked:ie,description:oe.A.COMMON.IMAGES_GENERATOR_HELP,onChange:Dt}),React.createElement(m.R,{name:"module_generator_videos",label:"Videos Generator",value:"1",checked:se,description:"Generate videos using AI models like Sora. Create videos from text prompts with control over duration and resolution.",onChange:Dt}))),$t=React.createElement(c.d,{title:oe.A.COMMON.PLAYGROUND},React.createElement(m.R,{name:"module_playground",label:oe.A.COMMON.ENABLE,value:"1",checked:ne,description:oe.A.COMMON.PLAYGROUND_HELP,onChange:Dt})),zt=React.createElement(c.d,{title:oe.A.COMMON.FORMS},React.createElement(m.R,{name:"module_forms",label:oe.A.COMMON.ENABLE,value:"1",checked:B,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.FORMS_HELP,onChange:Dt})),Gt=React.createElement(c.d,{title:oe.A.COMMON.SEARCH},React.createElement(m.R,{name:"module_search",label:oe.A.COMMON.ENABLE,value:"1",checked:fe,description:oe.A.COMMON.SEARCH_HELP,onChange:Dt})),Wt=React.createElement(c.d,{title:oe.A.COMMON.FINETUNES},React.createElement(m.R,{name:"module_finetunes",label:oe.A.COMMON.ENABLE,value:"1",checked:H,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!H,style:{marginRight:3}}),oe.A.HELP.FINETUNES),onChange:Dt})),qt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.INSIGHTS)},React.createElement(m.R,{name:"module_statistics",label:oe.A.COMMON.ENABLE,value:"1",checked:ae,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.INSIGHTS_HELP,onChange:Dt})),Kt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.MODERATION)},React.createElement(m.R,{name:"module_moderation",label:oe.A.COMMON.ENABLE,value:"1",checked:ce,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!ce,style:{marginRight:3}}),oe.A.COMMON.MODERATION_HELP),onChange:Dt})),Vt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.TRANSCRIPTION)},React.createElement(m.R,{name:"module_transcription",label:oe.A.COMMON.ENABLE,value:"1",checked:ue,description:oe.A.COMMON.TRANSCRIPTION_HELP,onChange:Dt})),Yt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.KNOWLEDGE)},React.createElement(m.R,{name:"module_embeddings",label:oe.A.COMMON.ENABLE,value:"1",checked:de,requirePro:!0,isPro:y.zN,description:(0,f.FE)(oe.A.COMMON.KNOWLEDGE_HELP),onChange:Dt})),Xt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.ASSISTANTS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(m.R,{name:"module_assistants",label:oe.A.COMMON.ENABLE,value:"1",checked:me,requirePro:!0,isPro:y.zN,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!me,style:{marginRight:3}}),oe.A.HELP.ASSISTANTS),onChange:Dt})),Qt=React.createElement(c.d,{title:oe.A.COMMON.ORCHESTRATION},React.createElement(m.R,{name:"module_orchestration",label:oe.A.COMMON.ENABLE,value:"1",checked:ye,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.ORCHESTRATION_HELP,onChange:Dt})),Jt=React.createElement(c.d,{title:oe.A.COMMON.CHATBOT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_chatbots",label:oe.A.COMMON.ENABLE,value:"1",checked:Re,description:oe.A.COMMON.CHATBOT_HELP,onChange:Dt}))),Zt=React.createElement(c.d,{title:"Cross-Site"},React.createElement(m.R,{name:"module_cross_site",label:oe.A.COMMON.ENABLE,value:"1",checked:ve,requirePro:!0,isPro:y.zN,description:"Enable chatbots to be embedded on external websites with domain-based access control.",onChange:Dt})),ea=React.createElement(c.d,{title:oe.A.COMMON.QUERIES_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"statistics_data",label:oe.A.COMMON.ENABLE,value:"1",checked:it,description:oe.A.HELP.QUERIES_DATA,onChange:Dt}))),ta=React.createElement(c.d,{title:oe.A.COMMON.QUERIES_FORMS_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"statistics_forms_data",label:oe.A.COMMON.ENABLE,value:"1",checked:st,description:oe.A.HELP.QUERIES_FORMS_DATA,onChange:Dt}))),na=React.createElement(c.d,{title:oe.A.COMMON.INTRO_MESSAGE},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"intro_message",label:oe.A.COMMON.ENABLE,value:"1",checked:ct,description:oe.A.HELP.INTRO_MESSAGE,onChange:Dt}))),la=React.createElement(c.d,{title:"Forms Editor"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"forms_editor",label:oe.A.COMMON.ENABLE,value:"1",checked:!!B&&!!be,disabled:!B,description:B?"Enable the Forms Editor (adds a new tab). Build forms with blocks and shortcodes.":"Enable the Forms module to use the Forms Editor.",onChange:Dt}))),ra=React.createElement(c.d,{title:oe.A.COMMON.CHATBOT_SELECT},React.createElement(K.u,{scrolldown:!0,name:"chatbot_select",value:null==v?void 0:v.chatbot_select,onChange:Dt,description:oe.A.HELP.CHATBOT_SELECT},React.createElement(K.j,{key:"tabs",value:"tabs",label:oe.A.COMMON.TABS}),React.createElement(K.j,{key:"dropdown",value:"dropdown",label:oe.A.COMMON.DROPDOWN}))),oa=React.createElement(c.d,{title:oe.A.COMMON.WEBSPEECH_API},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"speech_recognition",label:oe.A.COMMON.SPEECH_RECOGNITION,value:"1",checked:Ze,description:oe.A.HELP.SPEECH_RECOGNITION,onChange:Dt})),React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"speech_synthesis",label:oe.A.COMMON.SPEECH_SYNTHESIS+" (SOON)",value:"1",disabled:!0,checked:et,description:oe.A.HELP.SPEECH_SYNTHESIS,onChange:Dt}))),ia=React.createElement(c.d,{title:oe.A.COMMON.GDPR_CONSENT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_gdpr_consent",label:oe.A.COMMON.ENABLE,value:"1",checked:Xe,description:oe.A.HELP.GDPR_CONSENT,onChange:Dt}))),sa=React.createElement(c.d,{title:oe.A.COMMON.GDPR_TEXT},React.createElement(V.A,{name:"chatbot_gdpr_text",value:Qe,onBlur:Dt})),da=React.createElement(c.d,{title:oe.A.COMMON.GDPR_BUTTON},React.createElement(V.A,{name:"chatbot_gdpr_button",value:Je,onBlur:Dt})),ma=React.createElement(c.d,{title:oe.A.COMMON.STREAMING},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ai_streaming",label:oe.A.COMMON.ENABLE,value:"1",checked:$e,description:oe.A.HELP.STREAMING,onChange:Dt}))),ua=React.createElement(c.d,{title:"Responses API"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ai_responses_api",label:oe.A.COMMON.ENABLE,value:"1",checked:ze,description:"Use OpenAI's new Responses API for improved performance and features. This is recommended, but can be disabled if you experience issues.",onChange:Dt}))),pa=React.createElement(c.d,{title:oe.A.COMMON.PRIVACY_FIRST},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"privacy_first",label:oe.A.COMMON.ENABLE,value:"1",checked:Ge,description:oe.A.HELP.PRIVACY_FIRST,onChange:Dt}))),ga=React.createElement(c.d,{title:oe.A.COMMON.DISCUSSIONS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions",label:oe.A.COMMON.ENABLE,value:"1",checked:Ye,description:oe.A.HELP.DISCUSSIONS,onChange:Dt}))),Ea=React.createElement(c.d,{title:oe.A.COMMON.SUMMARIZE},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions_titling",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.chatbot_discussions_titling,description:oe.A.HELP.DISCUSSION_SUMMARY,onChange:Dt}))),ha=React.createElement(c.d,{title:oe.A.COMMON.PAGING||"Paging"},React.createElement(K.u,{scrolldown:!0,name:"chatbot_discussions_paging",value:(null==v?void 0:v.chatbot_discussions_paging)||10,onChange:Dt,description:oe.A.HELP.DISCUSSIONS_PAGING||"Number of discussions to display per page"},React.createElement(K.j,{value:"None",label:"None"}),React.createElement(K.j,{value:5,label:"5 per Page"}),React.createElement(K.j,{value:10,label:"10 per Page"}),React.createElement(K.j,{value:15,label:"15 per Page"}),React.createElement(K.j,{value:20,label:"20 per Page"}),React.createElement(K.j,{value:30,label:"30 per Page"}),React.createElement(K.j,{value:50,label:"50 per Page"}))),Ra=React.createElement(c.d,{title:oe.A.COMMON.REFRESH_INTERVAL||"Refresh Interval"},React.createElement(K.u,{scrolldown:!0,name:"chatbot_discussions_refresh_interval",value:(null==v?void 0:v.chatbot_discussions_refresh_interval)||5,onChange:Dt,description:oe.A.HELP.DISCUSSIONS_REFRESH_INTERVAL||"How often to refresh the discussions list (in seconds)"},React.createElement(K.j,{value:1,label:"1 second"}),React.createElement(K.j,{value:2,label:"2 seconds"}),React.createElement(K.j,{value:5,label:"5 seconds"}),React.createElement(K.j,{value:10,label:"10 seconds"}),React.createElement(K.j,{value:30,label:"30 seconds"}),React.createElement(K.j,{value:60,label:"60 seconds"}),React.createElement(K.j,{value:120,label:"120 seconds"}),React.createElement(K.j,{value:"Manual",label:"Manually"}),React.createElement(K.j,{value:"Never",label:"Never"}))),fa=React.createElement(c.d,{title:"Metadata Bar"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions_metadata_enabled",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_enabled,description:"Display a metadata bar under discussion titles.",onChange:Dt}))),ya=null!=v&&v.chatbot_discussions_metadata_enabled?React.createElement(c.d,{title:"Metadata Display"},React.createElement(d.E,{max:"3"},React.createElement(m.R,{name:"chatbot_discussions_metadata_start_date",label:"Start Date",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_start_date,description:"Show when the discussion was created.",onChange:Dt}),React.createElement(m.R,{name:"chatbot_discussions_metadata_last_update",label:"Last Update",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_last_update,description:"Show when the discussion was last modified.",onChange:Dt}),React.createElement(m.R,{name:"chatbot_discussions_metadata_message_count",label:"Message Count",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_message_count,description:"Show the number of messages in the discussion.",onChange:Dt}))):null,va=React.createElement(c.d,{title:oe.A.COMMON.SYNTAX_HIGHLIGHT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"syntax_highlight",label:oe.A.COMMON.ENABLE,value:"1",checked:Ke,description:oe.A.HELP.SYNTAX_HIGHLIGHT,onChange:Dt}))),ba=React.createElement(c.d,{title:oe.A.COMMON.EVENT_LOGS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"event_logs",label:oe.A.COMMON.ENABLE,value:"1",checked:Ve,disabled:!$e,description:oe.A.HELP.EVENT_LOGS,onChange:Dt}))),wa=React.createElement(c.d,{title:oe.A.COMMON.PUBLIC_API},React.createElement(m.R,{name:"public_api",label:oe.A.COMMON.ENABLE,value:"1",checked:tt,description:oe.A.HELP.PUBLIC_API,onChange:Dt}),tt&&React.createElement(_o,{value:`${y.gh}/mwai/v1/`},React.createElement("span",null,w,React.createElement("span",{className:"highlight"},"/wp-json/mwai/v1/")))),_a=React.createElement(c.d,{title:oe.A.COMMON.BEARER_TOKEN},React.createElement(V.A,{name:"public_api_bearer_token",value:null==v?void 0:v.public_api_bearer_token,description:Oe(oe.A.HELP.BEARER_TOKEN,oe.A.HELP.BEARER_TOKEN_URL,oe.A.HELP.BEARER_TOKEN_LINK_TEXT),onBlur:Dt})),Ta=React.createElement(c.d,{title:"SSE Endpoint"},React.createElement(m.R,{name:"module_mcp",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.module_mcp,description:"Enable MCP server endpoint for AI assistants like ChatGPT and Claude to manage your WordPress site.",onChange:Dt}),(null==v?void 0:v.module_mcp)&&React.createElement(React.Fragment,null,React.createElement(_o,{value:`${y.gh}/mcp/v1/sse`},React.createElement("span",null,w,React.createElement("span",{className:"highlight"},"/wp-json/mcp/v1/sse"))))),Ca=React.createElement(c.d,{title:oe.A.COMMON.BEARER_TOKEN},React.createElement(V.A,{name:"mcp_bearer_token",value:null==v?void 0:v.mcp_bearer_token,description:(0,f.FE)(oe.A.HELP.MCP_BEARER_TOKEN),onBlur:Dt})),Aa=React.createElement(c.d,{title:"No-Auth URL"},React.createElement(m.R,{name:"mcp_noauth_url",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_noauth_url,disabled:!(null!=v&&v.module_mcp&&null!=v&&v.mcp_bearer_token),description:"For clients that don't support bearer token headers (like ChatGPT). The token is embedded directly in the URL for convenience.",onChange:Dt}),(null==v?void 0:v.mcp_noauth_url)&&(null==v?void 0:v.module_mcp)&&(null==v?void 0:v.mcp_bearer_token)&&React.createElement(React.Fragment,null,React.createElement(_o,{value:`${y.gh}/mcp/v1/${v.mcp_bearer_token}/sse`},React.createElement("span",null,w,"/wp-json/mcp/v1/",React.createElement("span",{className:"highlight"},v.mcp_bearer_token),"/sse")),React.createElement("p",{style:{margin:"12px 0 0 0",padding:"10px",backgroundColor:"#fff3cd",border:"1px solid #ffc107",borderRadius:"4px",fontSize:"13px",color:"#856404"}},React.createElement("strong",null,"⚠️")," Keep this token absolutely secret. Use a long, random value. Anyone with this token has full admin access to your site."))),Na=React.createElement(c.d,{title:"WordPress"},React.createElement(m.R,{name:"mcp_core",label:"Enable (Recommended)",value:"1",checked:null==v?void 0:v.mcp_core,description:"Manage posts, pages, comments, users, media, taxonomies, and WordPress settings.",onChange:Dt})),Oa=React.createElement(c.d,{title:"Plugins"},React.createElement(m.R,{name:"mcp_plugins",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_plugins,requirePro:!0,isPro:y.zN,description:"Install, activate, update, and modify plugins.",onChange:Dt})),Sa=React.createElement(c.d,{title:"Themes"},React.createElement(m.R,{name:"mcp_themes",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_themes,requirePro:!0,isPro:y.zN,description:"Install, activate, switch, and customize themes.",onChange:Dt})),Ma=React.createElement(c.d,{title:"Dynamic REST"},React.createElement(m.R,{name:"mcp_dynamic_rest",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_dynamic_rest,description:"Raw access to WordPress's native REST API. More technical and limited compared to the optimized tools above. Only enable if you need direct REST API access.",onChange:Dt})),xa=React.createElement(c.d,{title:"Local Upload"},React.createElement(K.u,{scrolldown:!0,name:"image_local_upload",value:null==v?void 0:v.image_local_upload,onChange:Dt,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(K.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(K.j,{key:"library",value:"library",label:"Media Library"}))),ka=React.createElement(c.d,{title:"Remote Upload"},React.createElement(K.u,{scrolldown:!0,name:"image_remote_upload",value:null==v?void 0:v.image_remote_upload,onChange:Dt,description:"Select Upload Data for private sites; Share URLs requires your WordPress to be online and reachable."},React.createElement(K.j,{key:"data",value:"data",label:"Upload Data"}),React.createElement(K.j,{key:"url",value:"url",label:"Share URLs"}))),Pa=React.createElement(c.d,{title:"Expiration"},React.createElement(K.u,{scrolldown:!0,name:"image_expires",value:(null==v?void 0:v.image_expires)??"never",onChange:Dt,description:"Uploaded files will be deleted after a certain amount of time. This also affects files uploaded to OpenAI via the Assistants."},React.createElement(K.j,{key:300,value:300,label:"5 minutes"}),React.createElement(K.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(K.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(K.j,{key:86400,value:86400,label:"1 day"}),React.createElement(K.j,{key:604800,value:604800,label:"1 week"}),React.createElement(K.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(K.j,{key:"Never",value:"never",label:"Never"}))),La=React.createElement(c.d,{title:"Local Download"},React.createElement(K.u,{scrolldown:!0,name:"image_local_download",value:(null==v?void 0:v.image_local_download)??null,onChange:Dt,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(K.j,{key:null,value:null,label:"None"}),React.createElement(K.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(K.j,{key:"library",value:"library",label:"Media Library"}))),Da=React.createElement(c.d,{title:"Expiration"},React.createElement(K.u,{scrolldown:!0,name:"image_expires_download",value:(null==v?void 0:v.image_expires_download)??"never",onChange:Dt,description:"Downloaded files will be deleted after a certain amount of time."},React.createElement(K.j,{key:300,value:300,label:"5 minutes"}),React.createElement(K.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(K.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(K.j,{key:86400,value:86400,label:"1 day"}),React.createElement(K.j,{key:604800,value:604800,label:"1 week"}),React.createElement(K.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(K.j,{key:"Never",value:"never",label:"Never"}))),Fa=React.createElement(c.d,{title:oe.A.COMMON.DEV_TOOLS},React.createElement(m.R,{name:"module_devtools",label:oe.A.COMMON.ENABLE,value:"1",checked:ge,description:oe.A.HELP.DEV_TOOLS,onChange:Dt})),Ua=React.createElement(c.d,{title:oe.A.COMMON.SHORTCODES},React.createElement(m.R,{name:"resolve_shortcodes",label:oe.A.COMMON.RESOLVE,value:"1",checked:ht,description:oe.A.HELP.RESOLVE_SHORTCODE,onChange:Dt})),Ba=React.createElement(c.d,{title:oe.A.COMMON.CONTEXT_MAX_LENGTH},React.createElement(V.A,{name:"context_max_length",value:dt,type:"number",step:"1",description:oe.A.HELP.CONTEXT_MAX_LENGTH,onBlur:Dt})),Ha=React.createElement(c.d,{title:oe.A.COMMON.BANNED_WORDS},React.createElement(V.A,{id:"banned_words",name:"banned_words",value:ut,isCommaSeparatedArray:!0,description:oe.A.HELP.BANNED_WORDS,onBlur:Dt})),ja=React.createElement(c.d,{title:oe.A.COMMON.WORD_BOUNDARIES},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ignore_word_boundaries",label:oe.A.COMMON.IGNORE,value:"1",checked:pt,description:oe.A.HELP.WORD_BOUNDARIES,onChange:Dt}))),$a=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_default_model",value:yt.some((e=>e.model===Ne))?Ne:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),yt.map((e=>React.createElement(K.j,{value:e.model,label:e.name}))))),za=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_fast_default_model",value:vt.some((e=>e.model===Ae))?Ae:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),vt.map((e=>React.createElement(K.j,{value:e.model,label:e.name}))))),Ga=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_model",value:Ct.some((e=>e.model===Pe))?Pe:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),Ct.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Wa=React.createElement(c.d,{title:oe.A.COMMON.DIMENSIONS},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_dimensions",value:(null==v?void 0:v.ai_embeddings_default_dimensions)||"",onChange:Dt},React.createElement(K.j,{value:"",label:"Not Set"}),Nt.map(((e,t)=>React.createElement(K.j,{value:e,label:0===t?`${e} (Native)`:e}))))),qa=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_vision_default_model",value:bt.some((e=>e.model===xe))?xe:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),bt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Ka=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_audio_default_model",value:wt.some((e=>e.model===Be))?Be:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),wt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Va=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_json_default_model",value:_t.some((e=>e.model===je))?je:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),_t.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Ya=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_images_default_model",value:Tt.some((e=>e.model===De))?De:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),Tt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Xa=React.createElement(c.d,{title:oe.A.COMMON.BANNED_IPS},React.createElement(V.A,{id:"banned_ips",name:"banned_ips",value:mt,isCommaSeparatedArray:!0,description:oe.A.HELP.BANNED_IPS,onBlur:Dt})),Qa=React.createElement(c.d,{title:"Available Languages"},React.createElement(V.A,{id:"custom_languages",name:"custom_languages",value:gt,isCommaSeparatedArray:!0,description:"The complete list of languages available in AI Engine. You can add, remove, or modify languages. Use format: 'Language Name (code)' or just 'Language Name'. The language code (e.g., 'en', 'fr') helps with internationalization but is optional.",placeholder:"English (en), French (fr), Spanish (es), German (de)",onBlur:Dt})),Ja=React.createElement(c.d,{title:oe.A.COMMON.PLAYGROUND},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.playground,onChange:e=>{const t={...Et,playground:e};Dt(t,"admin_bar")}})),Za=React.createElement(c.d,{title:oe.A.COMMON.GENERATE_CONTENT},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.content_generator,onChange:e=>{const t={...Et,content_generator:e};Dt(t,"admin_bar")}})),en=React.createElement(c.d,{title:oe.A.COMMON.GENERATE_IMAGES},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.images_generator,onChange:e=>{const t={...Et,images_generator:e};Dt(t,"admin_bar")}})),tn=React.createElement(c.d,{title:"AI Engine"},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.settings,onChange:e=>{const t={...Et,settings:e};Dt(t,"admin_bar")}})),an=React.createElement("div",null,React.createElement(ca,{options:v})),nn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_default_env",value:Ie||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),ln=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_fast_default_env",value:Ce||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),rn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_env",value:ke||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),At.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),on=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_vision_default_env",value:Me||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),sn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_audio_default_env",value:Ue||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),cn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_json_default_env",value:He||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),dn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_images_default_env",value:Le||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),mn=React.createElement(K.u,{scrolldown:!0,name:"embeddings_default_env",value:qe,onChange:Dt},We.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),un=React.createElement(c.d,{title:oe.A.COMMON.PLUGIN_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"clean_uninstall",label:oe.A.COMMON.DELETE_ALL,description:oe.A.COMMON.PLUGIN_DATA_DESCRIPTION,value:"1",checked:Rt,onChange:Dt})));return React.createElement(u.z,null,React.createElement(Fe,{options:v}),React.createElement(g.N,null,React.createElement(g.Y,{fullWidth:!0},React.createElement(Ee,{options:v}),ct&&React.createElement(X.L,null,Se(oe.A.SETTINGS.INTRO,[{url:oe.A.SETTINGS.INTRO_TUTORIAL_URL,text:oe.A.SETTINGS.INTRO_TUTORIAL_TEXT},{url:oe.A.SETTINGS.INTRO_DOCS_URL,text:oe.A.SETTINGS.INTRO_DOCS_TEXT},{url:oe.A.SETTINGS.INTRO_ADDONS_URL,text:oe.A.SETTINGS.INTRO_ADDONS_TEXT},{url:oe.A.SETTINGS.INTRO_DISCLAIMER_URL,text:oe.A.SETTINGS.INTRO_DISCLAIMER_TEXT}])),React.createElement(E._,{keepTabOnReload:!0},React.createElement(E.V,{key:"dashboard",title:oe.A.COMMON.DASHBOARD},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0},React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.CLIENT_MODULES,className:"primary"},Jt,zt,Gt),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.SERVER_MODULES,className:"primary"},qt,Yt,Qt,Wt,Kt,Xt),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.BACKEND_MODULES,className:"primary"},Ht,jt,$t,Bt,Vt)),React.createElement(g.Y,{minimal:!0},React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USAGE,className:"primary"},an)))),Re&&React.createElement(E.V,{key:"chatbots",title:oe.A.COMMON.CHATBOTS},React.createElement(zr,{options:v,updateOption:Dt,busy:Mt})),fe&&React.createElement(E.V,{key:"search",title:oe.A.COMMON.SEARCH},React.createElement(So,{options:v,updateOption:Dt,busy:Mt})),Re&&Ye&&React.createElement(E.V,{key:"discussions",title:oe.A.COMMON.DISCUSSIONS},React.createElement(Ia,null)),B&&be&&React.createElement(E.V,{key:"forms",title:oe.A.COMMON.FORMS},React.createElement(ni,null)),ae&&React.createElement(E.V,{key:"insights",title:oe.A.COMMON.INSIGHTS},React.createElement(to,{options:v,updateOption:Dt,busy:Mt})),de&&React.createElement(E.V,{key:"knowledge",title:oe.A.COMMON.KNOWLEDGE},React.createElement(aa,{options:v,updateEnvironment:Ut,updateOption:Dt})),H&&React.createElement(E.V,{key:"finetunes",title:oe.A.COMMON.FINETUNES},React.createElement(St,{options:v,updateOption:Dt,refreshOptions:Lt})),ce&&React.createElement(E.V,{key:"moderation",title:oe.A.COMMON.MODERATION},React.createElement(xt,{options:v,updateOption:Dt,busy:Mt})),ue&&React.createElement(E.V,{key:"transcription",title:oe.A.COMMON.TRANSCRIPTION},React.createElement(Ao,{options:v,updateOption:Dt})),React.createElement(E.V,{key:"settings",title:oe.A.COMMON.SETTINGS},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingTop:10,marginBottom:10}},React.createElement(Q.o,{inversed:!0,name:"quicklinks",value:_,onChange:T},React.createElement(Q.K,{title:"AI",value:"ai"}),de&&React.createElement(Q.K,{title:"Knowledge",value:"knowledge"}),Re&&React.createElement(Q.K,{title:"Chatbot",value:"chatbot"}),ye&&React.createElement(Q.K,{title:"Orchestration",value:"orchestration"}),me&&React.createElement(Q.K,{title:oe.A.COMMON.ASSISTANTS,value:"assistants"}),React.createElement(Q.K,{title:"Files & Media",value:"files"}),React.createElement(Q.K,{title:"PHP API",value:"php_api"}),React.createElement(Q.K,{title:"REST API",value:"rest_api"}),React.createElement(Q.K,{title:"MCP",value:"mcp"}),React.createElement(Q.K,{title:"Add-ons",value:"addons"}),React.createElement(Q.K,{title:oe.A.COMMON.OTHERS,value:"others"}))),React.createElement(g.Y,{minimal:!0,fullWidth:!0},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0,fullWidth:"assistants"===_},"ai"===_&&React.createElement(React.Fragment,null,React.createElement(Eo,{busy:Mt,options:v,environments:we,updateEnvironment:async(e,t)=>{const a=we.map((a=>a.id===e?{...a,...t}:a));Dt(a,"ai_envs")},updateOption:Dt}),React.createElement(Y.g,null),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.AI_ENVIRONMENT_DEFAULTS,subtitle:"Select the default environment and model for each type of AI query",className:"primary"},React.createElement(Q.o,{name:"envSection",value:L,onChange:e=>D(e)},React.createElement(Q.K,{title:Ot(Ie,Ne,yt)?oe.A.COMMON.DEFAULT:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.DEFAULT),value:"default"}),React.createElement(Q.K,{title:Ot(Ce,Ae,vt)?oe.A.COMMON.DEFAULT_FAST:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.DEFAULT_FAST),value:"fast"}),React.createElement(Q.K,{title:Ot(Me,xe,bt)?oe.A.COMMON.VISION:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.VISION),value:"vision"}),React.createElement(Q.K,{title:Ot(Le,De,Tt)?oe.A.COMMON.IMAGES:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.IMAGES),value:"images"}),React.createElement(Q.K,{title:Ot(ke,Pe,Ct)?oe.A.COMMON.EMBEDDINGS:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.EMBEDDINGS),value:"embeddings"}),React.createElement(Q.K,{title:Ot(Ue,Be,wt)?oe.A.COMMON.AUDIO:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.AUDIO),value:"audio"}),React.createElement(Q.K,{title:Ot(He,je,_t)?oe.A.COMMON.JSON:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.JSON),value:"json"})),React.createElement(Y.g,null),"default"===L&&React.createElement(React.Fragment,null,nn,$a,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"The default environment for general AI queries and content generation.")),"fast"===L&&React.createElement(React.Fragment,null,ln,za,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"Used for quick tasks like generating discussion titles and optimizing search queries.")),"vision"===L&&React.createElement(React.Fragment,null,on,qa,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For analyzing and understanding images, including image-to-text capabilities.")),"images"===L&&React.createElement(React.Fragment,null,dn,Ya,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For generating images using AI models like DALL-E.")),"embeddings"===L&&React.createElement(React.Fragment,null,rn,Ga,Wa,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For creating text embeddings used in semantic search and similarity matching.")),"audio"===L&&React.createElement(React.Fragment,null,sn,Ka,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For audio transcription and speech-to-text processing.")),"json"===L&&React.createElement(React.Fragment,null,cn,Va,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For structured data generation and JSON output formatting.")))),"knowledge"===_&&de&&React.createElement(React.Fragment,null,React.createElement(co,{busy:Mt,options:v,environments:We,updateEnvironment:Ut,updateOption:Dt}),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.EMBEDDINGS_ENVIRONMENT_DEFAULT,className:"primary"},mn)),"chatbot"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.CHATBOT,className:"primary"},ga,Zt,va,oa,ia,Xe&&React.createElement(React.Fragment,null,sa,da))),"assistants"===_&&me&&React.createElement(React.Fragment,null),"orchestration"===_&&React.createElement(React.Fragment,null,React.createElement(fo,{busy:Mt,options:v,mcpServers:Te,updateMCPServer:async(e,t)=>{const a=Te.map((a=>a.id===e?{...a,...t}:a));Dt(a,"mcp_envs")},updateOption:Dt})),"files"===_&&React.createElement(R.z,{busy:Mt,title:"Uploaded by Users",subtitle:"Manage how user-uploaded files are stored and handled",className:"primary"},xa,ka,Pa),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USER_INTERFACE,className:"primary"},na,la),"others"===_&&ae&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.INSIGHTS,className:"primary"},React.createElement("p",null,oe.A.HELP.STATISTICS),ea,ta),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.ADMIN_BAR,className:"primary"},tn,Ja,Za,en),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.MAINTENANCE,className:"primary"},React.createElement("p",{style:{marginBottom:"15px"}},"It is important to keep regular backups of your settings. Use Export Settings to save your configuration. Import Settings allows you to restore a previous configuration. Reset Settings will restore all settings to their defaults. Reset Usage will clear all usage statistics and start fresh."),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",marginBottom:"10px"}},React.createElement(h.M,{className:"blue",onClick:async()=>{N("exportSettings");try{const e=await lt(),t=await at(),a={chatbots:e,themes:t,options:await ot()},n=new Blob([(0,f.F1)(a)],{type:"application/json"}),l=URL.createObjectURL(n),r=document.createElement("a");r.href=l;const o=new Date,i=`ai-engine-${o.getFullYear()}-${o.getMonth()+1}-${o.getDate()}.json`;r.setAttribute("download",i),r.click()}catch(e){alert("Error while exporting settings. Please check your console."),console.log(e)}finally{N(!1)}},style:{flex:2}},"Export Settings"),React.createElement(h.M,{className:"danger",onClick:async()=>{N("importSettings");try{const e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=async e=>{const t=e.target.files[0];if(!t)return;const a=new FileReader;a.onload=async e=>{const t=JSON.parse(e.target.result),{chatbots:a,themes:n,options:l}=t;await rt(a),await nt(n),await kt(l),alert("Settings imported. The page will now reload to reflect the changes."),window.location.reload()},a.readAsText(t)},e.click()}catch(e){alert("Error while importing settings. Please check your console."),console.log(e)}finally{N(!1)}},style:{flex:1}},"Import Settings"),React.createElement(h.M,{className:"danger",onClick:async()=>{if(window.confirm(oe.A.ALERTS.ARE_YOU_SURE)){N(!0);try{await(0,f.IU)(`${y.y0}/settings/reset`,{method:"POST",nonce:y.ok}),alert("Settings reset. The page will now reload to reflect the changes."),window.location.reload()}catch(e){alert("Error while resetting settings. Please check your console."),console.log(e)}finally{N(!1)}}},style:{flex:1}},"Reset Settings")),React.createElement(h.M,{className:"danger",onClick:async()=>{if(window.confirm(oe.A.COMMON.RESET_USAGE_SURE)){N(!0);try{await Dt([],"ai_usage"),await Dt([],"ai_usage_daily");const e=await(0,f.IU)(`${y.y0}/settings/options`,{method:"GET",headers:{"X-WP-Nonce":y.ok}});e.success&&e.options&&(kt(e.options),showSnackbar("Usage data has been reset successfully.","success"))}catch(e){console.error("Error resetting usage:",e),showSnackbar("Failed to reset usage data. Please try again.","error")}finally{N(!1)}}},disabled:Mt,fullWidth:!0},oe.A.COMMON.RESET," ",oe.A.COMMON.USAGE)),"mcp"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"MCP Access",className:"primary"},React.createElement("p",null,Se(oe.A.HELP.MCP_INTRO,[{url:oe.A.HELP.MCP_TUTORIAL_URL,text:oe.A.HELP.MCP_TUTORIAL_TEXT},{url:oe.A.HELP.MCP_CLAUDE_TUTORIAL_URL,text:oe.A.HELP.MCP_CLAUDE_TUTORIAL_TEXT}])),React.createElement(Y.g,null),Ta,Ca,Aa),(null==v?void 0:v.module_mcp)&&React.createElement(R.z,{busy:Mt,title:"MCP Features",className:"primary"},React.createElement("p",null,"AI Engine provides optimized, AI-friendly tools specifically designed for seamless WordPress management. These tools are intelligently structured for clarity and ease-of-use by AI assistants. Dynamic REST provides raw access to WordPress's native REST API (the Automattic way) which is more technical and limited in scope."),Na,Oa,Sa,Ma,React.createElement("p",{style:{marginTop:15}},"If you are a developer, you might be interested in hooking your own tools. They will appear automatically in the MCP Functions section on the right. Learn more in the ",React.createElement("a",{href:"https://ai.thehiddendocs.com/mcp/",target:"_blank",rel:"noreferrer"},"documentation ↗"),"."))),"php_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"PHP API",className:"primary"},React.createElement("p",{style:{marginBottom:12,fontSize:13}},"This internal API is why AI Engine was created originally. AI Engine is designed to be the ",React.createElement("strong",null,"AI Engine for WordPress"),", providing a unified interface for integrating AI capabilities into your site through simple PHP code."),React.createElement("p",{style:{marginBottom:12,fontSize:13}},"Access AI Engine through the global ",React.createElement("code",null,"$mwai")," object. Each query type automatically uses its corresponding default environment and model from ",React.createElement("strong",null,"AI > Default Environments"),". Override these by passing custom options (see Advanced Examples)."),React.createElement("p",{style:{marginBottom:12,fontSize:13}},"For easy code integration, use ",React.createElement("a",{href:"https://wordpress.org/plugins/code-engine/",target:"_blank",rel:"noreferrer"},"Code Engine ↗")," to create and manage your PHP snippets."),React.createElement("p",{style:{marginBottom:0,fontSize:13}},"To go deeper: ",React.createElement("a",{href:oe.A.HELP.PHP_API_FUNCTIONS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_FUNCTIONS_TEXT),", ",React.createElement("a",{href:oe.A.HELP.PHP_API_CLASSES_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_CLASSES_TEXT),", ",React.createElement("a",{href:oe.A.HELP.PHP_API_FILTERS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_FILTERS_TEXT),".")),React.createElement(R.z,{busy:Mt,title:"Basic Examples",className:"primary"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Text Query")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$result = $mwai->simpleTextQuery( "Write a haiku about AI" );\necho $result;'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Get AI-generated text responses for any prompt.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Image Generation")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n$url = $mwai->simpleImageQuery( \"A serene mountain landscape\" );\necho '<img src=\"' . esc_url( $url ) . '\" />';"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Generate images from text descriptions.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Vision Query")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$result = $mwai->simpleVisionQuery(\n "What\'s in this image?",\n "https://example.com/photo.jpg"\n);\necho $result;'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Analyze images with AI vision capabilities.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Structured JSON Response")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$data = $mwai->simpleJsonQuery( "Generate a product review" );\n// Returns structured JSON data\nprint_r( $data );'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Get structured data responses for easy parsing."))))),"rest_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"REST API",className:"primary"},React.createElement("p",null,Oe(oe.A.HELP.REST_API_INTRO,oe.A.HELP.REST_API_MAKE_URL,oe.A.HELP.REST_API_MAKE_TEXT)),React.createElement("p",{style:{marginTop:10,fontSize:13}},"The REST API uses the environments and models configured in ",React.createElement("strong",null,"AI > Default Environments"),", except if ",React.createElement("code",null,"envId")," or ",React.createElement("code",null,"model")," are specified in the ",React.createElement("code",null,"options")," parameter."),React.createElement("p",{style:{marginTop:10,fontSize:13}},"For complete API reference and advanced usage, see the ",React.createElement("a",{href:oe.A.HELP.REST_API_DOCS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.REST_API_DOCS_TEXT),"."),React.createElement(Y.g,null),wa,_a),tt&&React.createElement(R.z,{busy:Mt,title:"Authentication",className:"primary"},React.createElement("p",{style:{marginBottom:10,fontSize:13}},"All endpoints require Bearer Token authentication. Include this header in all requests:"),React.createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:4,fontSize:12,marginBottom:15}},"Authorization: Bearer ",(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#4CAF50",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"GET"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleAuthCheck")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleAuthCheck",command:`curl -X GET "${y.gh}/mwai/v1/simpleAuthCheck" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}"`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:0,color:"#666",fontSize:13}},"Test authentication and get current user email"))),tt&&React.createElement(R.z,{busy:Mt,title:"Options",className:"primary"},React.createElement("p",{style:{marginBottom:15,fontSize:13}},"Most endpoints accept an ",React.createElement("code",null,"options")," parameter (JSON object) to customize AI behavior. Common options include:"),React.createElement("div",{style:{marginBottom:15}},React.createElement("strong",{style:{fontSize:13}},"Core Options:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13,lineHeight:1.6}},React.createElement("li",null,React.createElement("code",null,"envId")," (string): AI Environment ID to use (find IDs in AI → Environments)"),React.createElement("li",null,React.createElement("code",null,"scope")," (string): Request scope (default: 'public-api')"),React.createElement("li",null,React.createElement("code",null,"model")," (string): Specific AI model to use (e.g., 'gpt-4', 'claude-3-5-sonnet-20241022')"),React.createElement("li",null,React.createElement("code",null,"temperature")," (number): Creativity level, 0-1 (default varies by model)"),React.createElement("li",null,React.createElement("code",null,"maxTokens")," (number): Maximum response length in tokens"))),React.createElement("div",{style:{marginBottom:15}},React.createElement("strong",{style:{fontSize:13}},"Image Options:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13,lineHeight:1.6}},React.createElement("li",null,React.createElement("code",null,"resolution")," (string): Image size (e.g., '1024x1024', '1792x1024')"))),React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Example:")),React.createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:4,fontSize:12,overflow:"auto"}},'{\n "message": "Write a haiku about AI",\n "options": {\n "envId": "your-env-id",\n "model": "gpt-4",\n "temperature": 0.7,\n "maxTokens": 150\n }\n}')))),React.createElement(g.Y,{minimal:!0},"php_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"Advanced Examples",className:"primary"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Chatbot with Memory")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n// First message\n$reply = $mwai->simpleChatbotQuery( \"default\", \"Hello!\" );\n$chatId = $reply['chatId'];\necho $reply['reply'];\n\n// Follow-up with memory\n$reply = $mwai->simpleChatbotQuery(\n \"default\",\n \"What did I just say?\",\n [ 'chatId' => $chatId ]\n);\necho $reply['reply'];"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Maintain conversation context by reusing the chatId for follow-up questions.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Using Custom Options")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n$options = [\n 'envId' => 'your-env-id',\n 'model' => 'gpt-4',\n 'temperature' => 0.7,\n 'maxTokens' => 500\n];\n$result = $mwai->simpleTextQuery( \"Your prompt\", $options );\necho $result;"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Override defaults with custom environment, model, and parameters."))))),"mcp"===_&&(null==v?void 0:v.module_mcp)&&React.createElement(vo,{options:v}),"ai"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.GENERAL,className:"primary"},ma,ba,ua)),"knowledge"===_&&de&&React.createElement(React.Fragment,null,React.createElement(R.z,{className:"primary",title:"Information"},React.createElement("div",{style:{marginBottom:10}},React.createElement("p",null,"For ",React.createElement("a",{href:"https://en.wikipedia.org/wiki/Retrieval-augmented_generation",target:"_blank",rel:"noreferrer"},"RAG ↗"),", or simply to give your chatbots a knowledge base, vector stores are used. AI Engine supports various vector stores. You'll need to create embeddings to feed your vector store, then your chatbots can search it."),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:0,margin:"20px 0",padding:"20px 15px",background:"linear-gradient(135deg, rgba(99,102,241,0.05) 0%, rgba(168,85,247,0.05) 100%)",borderRadius:12,flexWrap:"wrap"}},[{icon:j.A,label:"User Query",color:"#3b82f6",tooltip:"The user asks a question to the chatbot."},{icon:$.A,label:"Embedding",color:"#f59e0b",tooltip:"The query is converted into a vector (array of numbers) using an embedding model."},{icon:z.A,label:"Vector Match",color:"#10b981",tooltip:"The vector is compared against your knowledge base to find similar content."},{icon:G.A,label:"Context",color:"#8b5cf6",tooltip:"Relevant content is retrieved and added to the conversation context."},{icon:W.A,label:"AI Response",color:"#06b6d4",tooltip:"The AI generates a response enriched with the retrieved knowledge."}].map(((e,t,a)=>React.createElement("div",{key:t,style:{display:"flex",alignItems:"center"}},React.createElement(J.f,{text:e.tooltip},React.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:"8px 16px",cursor:"help"}},React.createElement("div",{style:{width:40,height:40,borderRadius:10,background:`${e.color}15`,display:"flex",alignItems:"center",justifyContent:"center"}},React.createElement(e.icon,{size:20,color:e.color})),React.createElement("span",{style:{fontSize:"0.75em",color:"#64748b",fontWeight:500}},e.label))),t<a.length-1&&React.createElement(q.A,{size:16,color:"#cbd5e1",style:{margin:"0 -4px",marginBottom:20}}))))),React.createElement("p",null,React.createElement("b",null,"Create an Environment for Embeddings")," (try Chroma), add content in the ",React.createElement("b",null,"Knowledge")," tab, and use ",React.createElement("b",null,"Query Mode")," to test before enabling in your chatbots. Learn more in the ",React.createElement("a",{href:"https://ai.thehiddendocs.com/knowledge/",target:"_blank",rel:"noreferrer"},"documentation ↗"),"."),React.createElement("p",{style:{marginTop:15}},React.createElement("strong",null,"Default AI Environment")),(e=>{const t=null==v?void 0:v.ai_embeddings_default_env,a=null==v?void 0:v.ai_embeddings_default_model,n=null==v||null===(e=v.ai_envs)||void 0===e?void 0:e.find((e=>e.id===t)),l=t&&a&&Ct.some((e=>e.model===a));return t&&n?a&&l?React.createElement(React.Fragment,null,React.createElement("p",{style:{marginTop:10}},React.createElement("strong",null,oe.A.COMMON.AI_ENVIRONMENT,":")," ",n.name,React.createElement("br",null),React.createElement("strong",null,oe.A.COMMON.EMBEDDINGS_MODEL,":")," ",a,React.createElement("br",null),React.createElement("strong",null,oe.A.COMMON.DIMENSIONS,":")," ",(null==v?void 0:v.ai_embeddings_default_dimensions)||"Auto"),React.createElement("p",{style:{marginTop:8,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px"}},"This is currently the default AI environment to create embeddings. You can change it in the ",React.createElement("b",null,"AI")," tab, or override it per environment for embeddings. For Chroma, it uses its internal embedding by default (check the Advanced section).")):React.createElement(Z.X,{variant:"danger",style:{marginTop:10}},React.createElement("strong",null,"Model not configured.")," Environment ",React.createElement("b",null,n.name)," is selected but no valid embeddings model is set. Please go to ",React.createElement("b",null,"AI")," tab → ",React.createElement("b",null,"Default Environments for AI")," → ",React.createElement("b",null,"Embeddings")," and select a model."):React.createElement(Z.X,{variant:"danger",style:{marginTop:10}},React.createElement("strong",null,"Not configured.")," Please go to ",React.createElement("b",null,"AI")," tab → ",React.createElement("b",null,"Default Environments for AI")," → ",React.createElement("b",null,"Embeddings")," and select an environment.")})())),React.createElement(R.z,{className:"primary",title:"Embeddings Search",busy:O},React.createElement(c.d,{title:"Method"},React.createElement(K.u,{scrolldown:!0,value:(null==v||null===(e=v.embeddings_settings)||void 0===e?void 0:e.search_method)||"simple",onChange:e=>Ft({...v.embeddings_settings,search_method:e}),description:(0,f.FE)("<b>Simple:</b> Uses only the last message (default, fastest).<br/><b>Context-Aware:</b> Includes more conversation history for better context.<br/><b>Smart Search:</b> Uses AI to create smarter searches based on full context (uses Default Fast model).")},React.createElement(K.j,{value:"simple",label:"Simple"}),React.createElement(K.j,{value:"context_aware",label:"Context-Aware"}),React.createElement(K.j,{value:"smart_search",label:"Smart Search"}))),("context_aware"===(null==v||null===(t=v.embeddings_settings)||void 0===t?void 0:t.search_method)||"smart_search"===(null==v||null===(a=v.embeddings_settings)||void 0===a?void 0:a.search_method)||"user_messages"===(null==v||null===(n=v.embeddings_settings)||void 0===n?void 0:n.search_method)||"ai_optimized"===(null==v||null===(l=v.embeddings_settings)||void 0===l?void 0:l.search_method))&&React.createElement(c.d,{title:"Messages"},React.createElement(V.A,{type:"number",value:(null==v||null===(r=v.embeddings_settings)||void 0===r?void 0:r.context_messages)||10,min:1,max:20,onFinalChange:e=>Ft({...v.embeddings_settings,context_messages:parseInt(e)||10}),description:"Number of recent messages to consider for context."})),("smart_search"===(null==v||null===(o=v.embeddings_settings)||void 0===o?void 0:o.search_method)||"ai_optimized"===(null==v||null===(i=v.embeddings_settings)||void 0===i?void 0:i.search_method))&&React.createElement(c.d,{title:"Instructions"},React.createElement(m.R,{name:"include_instructions",label:"Enable",value:"1",checked:(null==v||null===(p=v.embeddings_settings)||void 0===p?void 0:p.include_instructions)||!1,onChange:()=>{var e;return Ft({...v.embeddings_settings,include_instructions:!(null!=v&&null!==(e=v.embeddings_settings)&&void 0!==e&&e.include_instructions)})},description:"Include chatbot instructions in the search query to help the AI find more relevant context."})))),"chatbot"===_&&React.createElement(React.Fragment,null,Ye&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.DISCUSSIONS,className:"primary"},Ea,ha,Ra,fa,ya),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USER_INTERFACE,className:"primary"},ra)),"orchestration"===_&&React.createElement(R.z,{className:"primary",title:"Information"},React.createElement("p",null,(0,f.FE)(oe.A.SETTINGS.ORCHESTRATION_INFO))),"rest_api"===_&&tt&&React.createElement(R.z,{className:"primary",title:"Available Endpoints"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleTextQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleTextQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleTextQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "Write a haiku about AI",\n "options": {\n "scope": "workflow",\n "temperature": 0.7,\n "maxTokens": 150\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Send a text query to AI (with streaming support)"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," or ",React.createElement("code",null,"prompt")," (required): Text input"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleImageQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleImageQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleImageQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "prompt": "A futuristic city at sunset",\n "resolution": "1024x1024",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Generate an image from text prompt"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"prompt")," (required): Image description"),React.createElement("li",null,React.createElement("code",null,"resolution"),' (optional): Image size, e.g., "1024x1024"'),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleChatbotQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleChatbotQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleChatbotQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "botId": "default",\n "message": "Hello, how can you help me?"\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Send a message to a chatbot"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"botId")," (required): Chatbot ID"),React.createElement("li",null,React.createElement("code",null,"message")," (required): User message"),React.createElement("li",null,React.createElement("code",null,"chatId")," (optional): For continuing conversations"),React.createElement("li",null,React.createElement("code",null,"fileIds")," (optional): Array of file IDs for context")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleVisionQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleVisionQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleVisionQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "What is in this image?",\n "url": "https://example.com/image.jpg",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Analyze an image with AI"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," (required): Question about the image"),React.createElement("li",null,React.createElement("code",null,"url")," (required): Image URL to analyze"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleJsonQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleJsonQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleJsonQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "Generate a user profile",\n "schema": {"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "number"}}},\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Get structured JSON response from AI"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," (required): Your prompt"),React.createElement("li",null,React.createElement("code",null,"schema")," (optional): JSON schema for response structure"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleTranscribeAudio")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleTranscribeAudio",command:`curl -X POST "${y.gh}/mwai/v1/simpleTranscribeAudio" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "url": "https://example.com/audio.mp3",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Transcribe audio to text"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"url")," or ",React.createElement("code",null,"mediaId")," (required): Audio file URL or WordPress media ID"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/moderationCheck")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"moderationCheck",command:`curl -X POST "${y.gh}/mwai/v1/moderationCheck" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "text": "Your text to moderate"\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Check content for policy violations"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"text")," (required): Text to moderate")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#4CAF50",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"GET"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/listChatbots")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"listChatbots",command:`curl -X GET "${y.gh}/mwai/v1/listChatbots" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}"`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Get list of all available chatbots")))),"files"===_&&React.createElement(R.z,{busy:Mt,title:"Generated by AI",subtitle:"Manage how AI-generated files are stored and handled",className:"primary"},La,null!==(null==v?void 0:v.image_local_download)&&Da),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.ADVANCED,className:"primary"},Ua,Ba,Fa,un),"others"===_&&React.createElement(R.z,{busy:Mt,title:"Languages",className:"primary"},Qa),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.SECURITY,className:"primary"},pa,Ha,(null==ut?void 0:ut.length)>0&&ja,Xa)))),"addons"===_&&React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingRight:10,marginTop:-20}},React.createElement(si,{addons:null==v?void 0:v.addons,updateOption:Dt})),"assistants"===_&&me&&React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingRight:10,marginTop:-20}},React.createElement(s.s,{h2:!0,style:{color:"white"}},oe.A.COMMON.ASSISTANTS),React.createElement(Do,{options:v,refreshOptions:Lt})))),ge&&React.createElement(E.V,{key:"devtools",title:oe.A.COMMON.DEV_TOOLS},React.createElement(ro,{options:v,setOptions:b,updateOption:Dt,busy:Mt})),React.createElement(E.V,{key:"license",title:k?`⚠️ ${oe.A.COMMON.LICENSE_TAB}`:oe.A.COMMON.LICENSE_TAB},React.createElement(re,{domain:y.bl,prefix:y.Pl,isPro:y.am,isRegistered:y.zN}))))),React.createElement(ee.n,{isOpen:C,title:oe.A.COMMON.ERROR,content:C,onRequestClose:()=>A(!1),okButton:{label:"Close",onClick:()=>A(!1)}}),React.createElement(ee.n,{isOpen:M.isOpen,title:`cURL: ${M.title}`,onRequestClose:()=>x({isOpen:!1,command:"",title:""}),cancelButton:{label:"Close",onClick:()=>x({isOpen:!1,command:"",title:""})}},React.createElement("div",null,React.createElement("pre",{style:{background:"#f5f5f5",padding:15,borderRadius:4,overflow:"auto",fontSize:12,margin:0,border:"1px solid #ddd",whiteSpace:"pre-wrap",wordBreak:"break-all",marginBottom:15}},M.command),React.createElement(h.M,{fullWidth:!0,className:"primary",icon:"duplicate",onClick:()=>{navigator.clipboard.writeText(M.command),x({isOpen:!1,command:"",title:""})}},"Copy to Clipboard"))))};var Ri=a(6087);const fi=[{value:"informative",label:oe.A.WRITING_STYLES.INFORMATIVE},{value:"descriptive",label:oe.A.WRITING_STYLES.DESCRIPTIVE},{value:"creative",label:oe.A.WRITING_STYLES.CREATIVE},{value:"narrative",label:oe.A.WRITING_STYLES.NARRATIVE},{value:"persuasive",label:oe.A.WRITING_STYLES.PERSUASIVE},{value:"reflective",label:oe.A.WRITING_STYLES.REFLECTIVE},{value:"argumentative",label:oe.A.WRITING_STYLES.ARGUMENTATIVE},{value:"analytical",label:oe.A.WRITING_STYLES.ANALYTICAL},{value:"evaluative",label:oe.A.WRITING_STYLES.EVALUATIVE},{value:"journalistic",label:oe.A.WRITING_STYLES.JOURNALISTIC},{value:"technical",label:oe.A.WRITING_STYLES.TECHNICAL}],yi=[{value:"neutral",label:oe.A.WRITING_TONES.NEUTRAL},{value:"formal",label:oe.A.WRITING_TONES.FORMAL},{value:"assertive",label:oe.A.WRITING_TONES.ASSERTIVE},{value:"cheerful",label:oe.A.WRITING_TONES.CHEERFUL},{value:"humorous",label:oe.A.WRITING_TONES.HUMOROUS},{value:"informal",label:oe.A.WRITING_TONES.INFORMAL},{value:"inspirational",label:oe.A.WRITING_TONES.INSPIRATIONAL},{value:"professional",label:oe.A.WRITING_TONES.PROFESSIONAL},{value:"confluent",label:oe.A.WRITING_TONES.CONFLUENT},{value:"emotional",label:oe.A.WRITING_TONES.EMOTIONAL},{value:"persuasive",label:oe.A.WRITING_TONES.PERSUASIVE},{value:"supportive",label:oe.A.WRITING_TONES.SUPPORTIVE},{value:"sarcastic",label:oe.A.WRITING_TONES.SARCASTIC},{value:"condescending",label:oe.A.WRITING_TONES.CONDESCENDING},{value:"skeptical",label:oe.A.WRITING_TONES.SKEPTICAL},{value:"narrative",label:oe.A.WRITING_TONES.NARRATIVE},{value:"journalistic",label:oe.A.WRITING_TONES.JOURNALISTIC}],vi="",bi="Write a title for an article in {LANGUAGE}. Must be between 40 and 60 characters. Write naturally as a human would. Output only the title, no formatting, no Markdown, no special characters.\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nGenerate a title based on the topic above, taking into account the provided context.",wi='Write {SECTIONS_COUNT} consecutive headings for an article about "{TITLE}", in {LANGUAGE}. Each heading is between 40 and 60 characters. Format each heading with Markdown (## ). Write naturally as a human would. Output only the headings, nothing else.\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nCreate headings that align with both the topic and context provided above.',_i='Write an article about "{TITLE}" in {LANGUAGE}. Write {PARAGRAPHS_PER_SECTION} paragraphs per heading. Use Markdown for formatting. Add an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ". Write naturally as a human would.\n\n### ARTICLE STRUCTURE:\n{SECTIONS}\n\n### TOPIC DETAILS:\n{TOPIC}\n\n### WRITING CONTEXT:\n{CONTEXT}\n\nWrite the article following the structure above, incorporating the topic details while adhering to the context guidelines.',Ti='Write an excerpt for an article in {LANGUAGE}. Must be between 40 and 60 characters. Write naturally as a human would. Output only the excerpt, no formatting.\n\n### ARTICLE TITLE:\n"{TITLE}"\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nCreate a compelling excerpt that captures the essence of the article while considering the context.',Ci=[{id:"default",name:"Default Template",mode:"query",model:vi,envId:"",temperature:.8,stopSequence:"",maxTokens:2048,prompt:""},{id:"article_translator",name:"Text Translator",mode:"query",model:vi,envId:"",temperature:.3,stopSequence:"",maxTokens:2048,prompt:"Translate this article into French:\n\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n"},{id:"restaurant_review",name:"Restaurant Review Writer",mode:"query",model:vi,envId:"",temperature:.8,stopSequence:"",maxTokens:2048,prompt:"Write a review for a French restaurant located in Kagurazaka, Tokyo. Looks like an old restaurant, food is traditional, chef is talkative, it is always full. Not expensive, but not fancy.\n"},{id:"article_corrector",name:"Text Corrector",mode:"query",model:vi,envId:"",temperature:.2,stopSequence:"",maxTokens:2048,prompt:"Fix the grammar and spelling mistakes in this text:\n\nI wake up at eleben yesderday, I will go bed eary tonigt.\n"},{id:"seo_assistant",name:"SEO Optimizer",mode:"query",model:vi,envId:"",temperature:.6,stopSequence:"",maxTokens:1024,prompt:"For the following article, write a SEO-friendly and short title, keywords for Google, and a short excerpt to introduce it. Use this format:\n\nTitle: \nKeywords: \nExcerpt:\n\nArticle:\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town."}],Ai=[{id:"default",name:"Default Template",model:"",envId:"",resolution:"",maxResults:1,prompt:""},{id:"cyberpunk_shibuya",name:"Cyberpunk Shibuya, 2099",model:"",envId:"",resolution:"",maxResults:1,prompt:"A rainy night in Shibuya Crossing in the year 2099, filled with glowing holographic kanji, umbrellas reflecting neon lights, and humanoid robots blending in with humans under the city glow. (Style: cinematic realism, rain-soaked atmosphere, high contrast)"},{id:"tranquil_koi",name:"Tranquil Koi Dream",model:"",envId:"",resolution:"",maxResults:1,prompt:"A surreal composition of a floating temple garden above a pond of flying koi fish, each one carrying tiny lanterns illuminating soft fog. (Style: ethereal watercolor painting, soft color palette, dreamlike)"},{id:"tokyo_apartment",name:"Old Tokyo Apartment Spirit",model:"",envId:"",resolution:"",maxResults:1,prompt:"A nostalgic 1960s Tokyo apartment room filled with plants, tatami mats, and warm afternoon light — but with subtle ghostly figures appearing through the shoji doors. (Style: realistic photo with supernatural touch, muted colors, film grain)"}],Ii=[{id:"default",name:"Default Template",mode:"single",topic:"",topics:"",context:"",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.8,maxTokens:2048,sectionsCount:2,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"creative",writingTone:"cheerful",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti},{id:"explore_tokyo_offbeat",name:"Explore Tokyo Offbeat",mode:"single",topic:"5 hidden Tokyo neighborhoods only locals know: retro Showa-era streets, authentic Edo atmosphere, family-run restaurant alleys, old shopping arcades, quiet residential gems. Write in first person as a Tokyo local sharing secret spots.",topics:"",context:"",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.8,maxTokens:2048,sectionsCount:5,paragraphsCount:2,language:"en",customLanguage:"",writingStyle:"informative",writingTone:"informal",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti},{id:"cat_blog_bulk",name:"Cat Blog Bulk Generator",mode:"bulk",topic:"",topics:"Why Cats Make Perfect Companions\nUnderstanding Cat Body Language\nThe Science Behind Purring\nIndoor vs Outdoor Cats Debate\nBest Cat Breeds for Families\nCat Nutrition Guide\nTraining Your Cat: Tips and Tricks\nCommon Cat Health Issues",context:"Context: This is for a cat enthusiast blog targeting pet owners and cat lovers. The tone should be friendly, informative, and occasionally playful. Include practical tips, scientific facts, and real-world advice. Each article should be engaging and helpful for cat parents at all experience levels.",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.7,maxTokens:2048,sectionsCount:4,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"informative",writingTone:"cheerful",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti}],Ni=[{id:"default",name:"Default Template",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:""},{id:"last_train",name:"The Last Train to Kyoto",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:"A 30-second cinematic sequence following the final train leaving Tokyo Station at night — empty city, soft piano music, lights flickering through the window, and a mysterious letter left on the seat. (Mood: melancholic, poetic, cinematic lighting)"},{id:"festival_foxes",name:"Festival of Foxes",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:"A short looping video of a nighttime matsuri in the mountains, where everyone wears fox masks. The camera glides through paper lanterns, taiko drums, and dancers, as the masks begin to subtly move on their own. (Mood: magical realism, glowing reds and golds, hypnotic rhythm)"},{id:"rising_tokyo",name:"Rising Tokyo",model:"sora-2",envId:"",resolution:"1280x720",duration:8,prompt:"A timelapse of Tokyo transforming from the Edo period to the futuristic skyline — wooden houses morphing into skyscrapers, rickshaws turning into maglev trains, Mt. Fuji remaining constant in the distance. (Mood: epic evolution, orchestral build-up, history blending with sci-fi)"}],{useState:Oi,useEffect:Si,useMemo:Mi}=wp.element;function xi(){return(new Date).getTime().toString(36)+Math.random().toString(36).substr(2,9)}const ki="mwai_last_template_",Pi=e=>{const t=[...e];return t.sort(((e,t)=>{if("default"===e.id)return-1;if("default"===t.id)return 1;const a=e.name||"",n=t.name||"";return a.localeCompare(n)})),t},Li=(e="playground")=>{const[t,a]=Oi(),[n,l]=Oi(!1),[r,i]=Oi([]),{isLoading:s,data:c}=(0,o.I)({queryKey:[`templates-${e}`],queryFn:()=>(async e=>{try{const t=await(0,f.IU)(`${y.y0}/system/templates?category=${e}`,{nonce:y.ok});let a=[];"imagesGenerator"===e?a=Ai:"videosGenerator"===e?a=Ni:"playground"===e?a=Ci:"contentGenerator"===e&&(a=Ii);const n=a.find((e=>"default"===e.id));return null!=t&&t.templates&&t.templates.length>0&&(a=Pi(t.templates)),n?a.forEach((e=>{Object.keys(n).forEach((t=>{void 0===e[t]&&(e[t]=n[t])}))})):console.warn("Default template not found for category: "+e),a}catch(e){console.error(e),alert(e.message)}})(e)});Si((()=>{for(let t=0;t<r.length;t++){const a=r[t];let n=!1;if(a&&(null===a.envId||void 0===a.envId||null===a.model||void 0===a.model)){const t=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_env)||null;let l=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_model)||null;"imagesGenerator"===e&&(l="dall-e-3-hd"),"videosGenerator"===e&&(l="sora-2"),t&&l&&(a.envId=t,a.model=l,n=!0)}n&&i([...r])}}),[r]),Si((()=>{if(c){i(c);const t=(e=>{try{const t=`${ki}${e}`,a=localStorage.getItem(t);if(!a)return null;const n=JSON.parse(a);return Date.now()-n.timestamp>2592e6?(localStorage.removeItem(t),null):n.templateId}catch(e){return console.warn("Failed to load template preference:",e),null}})(e);let n=null;if(t&&(n=c.find((e=>e.id===t))),!n){n=c.find((e=>"default"===e.id))||c[0]}a(n)}}),[c,e]);const d=async t=>{t=Pi(t),i(t);try{return await(0,f.IU)(`${y.y0}/system/templates`,{method:"POST",nonce:y.ok,json:{category:e,templates:t}})}catch(e){console.error(e),alert(e.message)}},m=Mi((()=>{if(!t||0===r.length)return!1;const e=r.find((e=>e.id===t.id));return!!e&&(Object.keys(t).length!==Object.keys(e).length||Object.keys(e).some((a=>e[a]!==t[a])))}),[t,r]),u=t=>{a(t),t&&t.id&&((e,t)=>{try{const a=`${ki}${e}`,n={templateId:t,timestamp:Date.now()};localStorage.setItem(a,JSON.stringify(n))}catch(e){console.warn("Failed to save template preference:",e)}})(e,t.id)},p=()=>{const e=r.find((e=>e.id===t.id));e&&u({...e})},g=()=>{const e=prompt(oe.A.COMMON.NAME,t.name||oe.A.TEMPLATES.NEW_TEMPLATE_NAME);if(!e)return!1;const a={...t,id:xi(),name:e};d([...r,a]),u({...a})},E=()=>{const e=r.map((e=>e.id===t.id?t:e));d(e),u({...t})},R=()=>{const e=prompt("Template Name",t.name);if(!e)return;const a={...r[0],id:xi(),name:e};d([...r,a]),u({...a})},v=()=>{const e=prompt("Template Name",t.name);if(!e)return;const a=r.map((a=>a.id===t.id?{...a,name:e}:a));d([...a]),u({...a.find((e=>e.id===t.id))})},b=()=>{if(!confirm(oe.A.TEMPLATES.DELETE_ALL_CONFIRM))return;let t=[];"imagesGenerator"===e?t=[...Ai]:"videosGenerator"===e?t=[...Ni]:"playground"===e?t=[...Ci]:"contentGenerator"===e&&(t=[...Ii]),d(t),u({...t[0]})},w=Mi((()=>m&&!!t),[m,t]),_=Mi((()=>t&&"default"!==t.id),[t]),T=Mi((()=>t&&"default"!==t.id),[t]),C=Mi((()=>React.createElement("div",{style:{margin:"0"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"}},React.createElement("h3",{style:{margin:0,fontSize:"14px",fontWeight:600}},oe.A.TEMPLATES.TEMPLATE),React.createElement(We.S,{small:!0,onLabel:oe.A.TEMPLATES.EDIT,offLabel:oe.A.TEMPLATES.EDIT,width:60,onChange:l,checked:n})),s&&React.createElement("div",{style:{display:"flex",marginTop:30,justifyContent:"center"}},React.createElement(Ri.X,{type:"icon",size:"24px",color:"#2271b1"})),!s&&React.createElement(React.Fragment,null,React.createElement(K.u,{scrolldown:!0,name:"template",value:null==t?void 0:t.id,onChange:e=>{const t=r.find((t=>t.id===e));u({...t})}},r.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),m&&React.createElement("div",{style:{display:"flex",gap:"4px",marginTop:"8px"}},React.createElement(h.M,{className:"secondary",style:{flex:1},icon:"undo",disabled:!w,onClick:p},"Undo"),React.createElement(h.M,{className:"primary",style:{flex:1},icon:"save",disabled:!w,onClick:E},"Save")),n&&React.createElement("div",{style:{marginTop:"8px"}},React.createElement("div",{style:{display:"flex",gap:"4px",justifyContent:"center"}},React.createElement(h.M,{className:"primary",rounded:!0,icon:"plus",onClick:R}),React.createElement(h.M,{className:"primary",rounded:!0,icon:"duplicate",onClick:g}),React.createElement("div",{style:{width:"12px"}}),React.createElement(h.M,{className:"secondary",rounded:!0,icon:"rename",disabled:!_,onClick:v}),React.createElement(h.M,{className:"danger",rounded:!0,icon:"delete",disabled:!T,onClick:()=>(e=>{if(!confirm(oe.A.TEMPLATES.DELETE_CONFIRM))return;const t=r.filter((t=>t.id!==e.id));d([...t]),u({...t[0]})})(t)})))),n&&React.createElement("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid #e0e0e0"}},React.createElement(h.M,{className:"danger",small:!0,style:{width:"100%"},onClick:b},"Reset All Templates")))),[r,t,n,m,w,s]);return{template:t,templates:r,clearTemplate:p,setTemplate:u,jsxTemplates:C,isEdit:n}},{useState:Di,useMemo:Fi}=wp.element,Ui=e=>{const[t,a]=Di(0),[n,l]=Di(0),r=()=>{a(0),l(0)};return{addUsage:(n,r,o)=>{const i=e(n,r,o);l(i),a(t+i)},jsxUsageCosts:Fi((()=>{let e=(0,f.FE)(oe.A.COMMON.USAGE_HELP);if(!y.zN){const t=Oe(oe.A.COMMON.USAGE_PRO_HELP,oe.A.COMMON.USAGE_PRO_HELP_URL,oe.A.COMMON.USAGE_PRO_HELP_LINK_TEXT);e=React.createElement(React.Fragment,null,e," ",t)}return React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.COMMON.SESSION,": ",React.createElement("span",{style:{float:"right"}},"$",t.toFixed(4))),React.createElement("div",null,oe.A.COMMON.LAST_REQUEST,": ",React.createElement("span",{style:{float:"right"}},"$",n.toFixed(4))),React.createElement(Y.g,{height:15}),React.createElement("p",{style:{fontSize:11,lineHeight:1.4,opacity:.6,margin:0}},e),React.createElement(Y.g,{height:15}),React.createElement(h.M,{fullWidth:!0,onClick:r},oe.A.COMMON.RESET_USAGE))}),[t,n])}},{useState:Bi,useEffect:Hi,useRef:ji}=wp.element,$i=(0,b.Ay)($e.m)`551 `,si=({addons:e})=>{const t=e.some((e=>e.enabled))?"enabled":"all",[a,n]=ri(t),l=oi((()=>"enabled"===a?e.filter((e=>e.enabled)):"disabled"===a?e.filter((e=>!e.enabled)):e),[e,a]);return React.createElement(React.Fragment,null,React.createElement(Ge.V,null,React.createElement(Q.o,{name:"filter",value:a,onChange:e=>n(e)},React.createElement(Q.K,{title:"All",value:"all"}),React.createElement(Q.K,{title:"Enabled",value:"enabled"}),React.createElement(Q.K,{title:"Disabled",value:"disabled"}))),React.createElement(Y.g,null),React.createElement(ii,null,l.map((e=>React.createElement(X.L,{key:e.id,style:{marginBottom:0,borderRadius:8,overflow:"auto"},footer:React.createElement("div",{style:{display:"flex",width:"100%",alignItems:"center",marginLeft:10,minHeight:30}},React.createElement("span",{style:{fontSize:"12px",marginRight:15,color:e.enabled?"#4CAF50":"#666",textTransform:"uppercase",fontWeight:"bold"}},e.enabled?React.createElement("label",null,"Enabled"):React.createElement("label",null,"Disabled")),React.createElement("div",{style:{flex:"auto"}}),e.enabled&&e.settings_url&&React.createElement(h.M,{className:"primary",onClick:()=>window.open(e.settings_url,"_self")},"Settings"),!e.enabled&&React.createElement(h.M,{className:"primary",onClick:()=>window.open(e.install_url,"_blank")},"Install"))},React.createElement("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",marginBottom:10}},React.createElement("div",{style:{width:32,marginTop:-5}},React.createElement(li.r,null)),React.createElement(s.s,{h3:!0,style:{margin:0,marginLeft:8,fontWeight:"bold"}},e.name),React.createElement("div",{style:{marginLeft:5,marginTop:2,fontSize:15,color:"#fec74c"}},Array.from({length:e.stars},((e,t)=>React.createElement("span",{key:t},"★"))))),React.createElement("div",{className:"addon-description"},e.description))))))},{useMemo:ci,useState:di,useEffect:mi,useCallback:ui,useRef:pi}=wp.element,gi=[{envKey:"ai_default_env",modelKey:"ai_default_model",fallbackKey:"default"},{envKey:"ai_fast_default_env",modelKey:"ai_fast_default_model",fallbackKey:"fast"},{envKey:"ai_embeddings_default_env",modelKey:"ai_embeddings_default_model",fallbackKey:"embeddings"},{envKey:"ai_vision_default_env",modelKey:"ai_vision_default_model",fallbackKey:"vision"},{envKey:"ai_images_default_env",modelKey:"ai_images_default_model",fallbackKey:"images"},{envKey:"ai_audio_default_env",modelKey:"ai_audio_default_model",fallbackKey:"audio"},{envKey:"ai_json_default_env",modelKey:"ai_json_default_model",fallbackKey:"json"}],Ei=["module_forms","module_statistics","module_embeddings","module_assistants","module_orchestration","module_cross_site"],hi=()=>{var e,t,a,n,l,r,o,i,p;const[v,b]=di(y.fF),w=y.gh.replace("/wp-json",""),[_,T]=di((()=>{const e=localStorage.getItem("mwai_settings_section");return e||"ai"})),[C,A]=di(null),[I,N]=di(!1),[O,S]=di(!1),[M,x]=di({isOpen:!1,command:"",title:""}),[k,P]=di(!1),[L,D]=di("default"),F=null==v?void 0:v.module_suggestions,U=null==v?void 0:v.module_advisor,B=null==v?void 0:v.module_forms,H=null==v?void 0:v.module_finetunes,ae=null==v?void 0:v.module_statistics,ne=null==v?void 0:v.module_playground,le=null==v?void 0:v.module_generator_content,ie=null==v?void 0:v.module_generator_images,se=null==v?void 0:v.module_generator_videos,ce=null==v?void 0:v.module_moderation,de=null==v?void 0:v.module_embeddings,me=null==v?void 0:v.module_assistants,ue=null==v?void 0:v.module_transcription,ge=null==v?void 0:v.module_devtools,Re=null==v?void 0:v.module_chatbots,fe=null==v?void 0:v.module_search,ye=null==v?void 0:v.module_orchestration,ve=null==v?void 0:v.module_cross_site,be=null==v?void 0:v.forms_editor,we=ci((()=>null!=v&&v.ai_envs?null==v?void 0:v.ai_envs:[]),[v]),Te=ci((()=>null!=v&&v.mcp_envs?null==v?void 0:v.mcp_envs:[]),[v]),Ce=null==v?void 0:v.ai_fast_default_env,Ae=null==v?void 0:v.ai_fast_default_model,Ie=null==v?void 0:v.ai_default_env,Ne=null==v?void 0:v.ai_default_model,Me=null==v?void 0:v.ai_vision_default_env,xe=null==v?void 0:v.ai_vision_default_model,ke=null==v?void 0:v.ai_embeddings_default_env,Pe=null==v?void 0:v.ai_embeddings_default_model,Le=null==v?void 0:v.ai_images_default_env,De=null==v?void 0:v.ai_images_default_model,Ue=null==v?void 0:v.ai_audio_default_env,Be=null==v?void 0:v.ai_audio_default_model,He=null==v?void 0:v.ai_json_default_env,je=null==v?void 0:v.ai_json_default_model,$e=null==v?void 0:v.ai_streaming,ze=null==v?void 0:v.ai_responses_api,Ge=null==v?void 0:v.privacy_first,We=null!=v&&v.embeddings_envs?null==v?void 0:v.embeddings_envs:[],qe=null==v?void 0:v.embeddings_default_env,Ke=null==v?void 0:v.syntax_highlight,Ve=null==v?void 0:v.event_logs,Ye=null==v?void 0:v.chatbot_discussions,Xe=null==v?void 0:v.chatbot_gdpr_consent,Qe=null==v?void 0:v.chatbot_gdpr_text,Je=null==v?void 0:v.chatbot_gdpr_button,Ze=null==v?void 0:v.speech_recognition,et=null==v?void 0:v.speech_synthesis,tt=null==v?void 0:v.public_api,it=null==v?void 0:v.statistics_data,st=null==v?void 0:v.statistics_forms_data,ct=null==v?void 0:v.intro_message,dt=null==v?void 0:v.context_max_length,mt=null==v?void 0:v.banned_ips,ut=null==v?void 0:v.banned_words,pt=null==v?void 0:v.ignore_word_boundaries,gt=(null==v?void 0:v.custom_languages)||[],Et=(null==v?void 0:v.admin_bar)??["settings"],ht=null==v?void 0:v.resolve_shortcodes,Rt=null==v?void 0:v.clean_uninstall,{completionModels:ft}=he(v),{completionModels:yt}=he(v,null==v?void 0:v.ai_default_env),{completionModels:vt}=he(v,null==v?void 0:v.ai_fast_default_env),{visionModels:bt}=he(v,null==v?void 0:v.ai_vision_default_env),{audioModels:wt}=he(v,null==v?void 0:v.ai_audio_default_env),{jsonModels:_t}=he(v,null==v?void 0:v.ai_json_default_env),{imageModels:Tt}=he(v,null==v?void 0:v.ai_images_default_env),{embeddingsModels:Ct}=he(v,null==v?void 0:v.ai_embeddings_default_env),At=ci((()=>we&&null!=v&&v.ai_engines?we.filter((e=>{if("azure"===e.type){var t;return null===(t=e.deployments)||void 0===t?void 0:t.some((e=>{var t,a;return(null===(t=e.model)||void 0===t?void 0:t.includes("embedding"))||(null===(a=e.model)||void 0===a?void 0:a.includes("ada"))}))}const a=v.ai_engines.find((t=>t.type===e.type));if(!a||!a.models)return!1;return a.models.some((e=>pe(e,"embedding")))})):[]),[we,v]),It=ci((()=>Ct.find((e=>e.model===Pe))),[Ct,Pe]),Nt=ci((()=>{var e;if(!It)return[];if(pe(It,"matryoshka")&&(null==It||null===(e=It.dimensions)||void 0===e?void 0:e.length)>0){const e=It.dimensions[0];return[3072,2048,1536,1024,768,512].filter((t=>t<=e))}const t=null==It?void 0:It.dimensions;return t?Array.isArray(t)?t:[t]:[]}),[It]),Ot=(e,t,a)=>!(!e||!t)&&(!(!a||0===a.length)&&a.some((e=>e.model===t))),Mt=I,kt=ui((async e=>{try{if((0,f.F1)(e)===(0,f.F1)(v))return;N(!0);const t=await(0,f.IU)(`${y.y0}/settings/update`,{method:"POST",nonce:y.ok,json:{options:e}});b(t.options)}catch(t){console.error(oe.A.ERROR.UPDATING_OPTIONS,null!=t&&t.message?{message:t.message,options:v,newOptions:e}:{err:t,options:v,newOptions:e}),t.message&&A(React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.ERROR.UPDATING_OPTIONS),React.createElement("small",null,(0,f.FE)(oe.A.ERROR.CHECK_YOUR_CONSOLE))))}finally{N(!1)}}),[v]),Pt=(ui(((e,t)=>{var a;if(!e)return[];const n=we.find((t=>t.id===e));if(!n)return[];let l=[];const r=(null==v||null===(a=v.ai_models)||void 0===a?void 0:a.filter((e=>e.type===n.type&&(!e.envId||e.envId===n.id))))??[];if(r.length>0)l=r;else{var o;const e=null==v||null===(o=v.ai_engines)||void 0===o?void 0:o.find((e=>e.type===n.type));l=(null==e?void 0:e.models)??[]}if(!l.length)return[];switch(t){case"embeddings":return l.filter((e=>pe(e,"embedding")));case"vision":return l.filter((e=>pe(e,"vision")));case"images":return l.filter((e=>pe(e,"image")));case"audio":return l.filter((e=>pe(e,"audio")));case"json":return l.filter((e=>pe(e,"json")));default:return l.filter((e=>pe(e,"chat")||pe(e,"completion")))}}),[we,null==v?void 0:v.ai_engines,null==v?void 0:v.ai_models]),pi(!1));mi((()=>{if(Pt.current)return;(async()=>{let e=!1;const t={...v};gi.forEach((({envKey:a,modelKey:n,fallbackKey:l})=>{const r=y.hI[l],o="embeddings"===l?At:we;let i=!1;if(v[a]&&(i=!!o.find((e=>e.id===v[a]))),!i){const l=o.find((e=>"openai"===(null==e?void 0:e.type)));if(l)t[a]===l.id&&t[n]===r||(console.warn(`Updating ${a} and ${n} to ${l.id} and ${r}`),e=!0,t[a]=l.id,t[n]=r);else{const l=null!==v[a]&&""!==v[a],r=null!==v[n]&&""!==v[n],o="ai_embeddings_default_model"===n&&null!==v.ai_embeddings_default_dimensions&&""!==v.ai_embeddings_default_dimensions;(l||r||o)&&(console.warn(`No valid environment for ${a}, resetting to null`),e=!0,t[a]=null,t[n]=null,"ai_embeddings_default_model"===n&&(t.ai_embeddings_default_dimensions=null))}}if("ai_embeddings_default_model"===n&&t[n]){const a=(null==t?void 0:t.ai_embeddings_default_dimensions)||null;if(null!==a){const l=Ct.find((e=>e.model===t[n]));if(l){var s;const n=pe(l,"matryoshka"),r=null==l?void 0:l.dimensions;let o=r?Array.isArray(r)?r:[r]:[];if(n&&(null==l||null===(s=l.dimensions)||void 0===s?void 0:s.length)>0){const e=l.dimensions[0];o=[3072,2048,1536,1024,768,512].filter((t=>t<=e))}if(!o.includes(parseInt(a))){const a=o[0]||null;null!==a&&(t.ai_embeddings_default_dimensions=a,console.warn(`Updating embeddings default dimensions to ${a}`),e=!0)}}}}})),e&&(Pt.current=!0,await kt(t))})()}),[we,At,v,kt,Ct,y.hI]);const Lt=async()=>{N(!0);try{const e=await ot();b(e)}catch(e){console.error(oe.A.ERROR.GETTING_OPTIONS,null!=e&&e.message?{message:e.message}:{err:e}),e.message&&A(React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.ERROR.GETTING_OPTIONS),React.createElement("small",null,(0,f.FE)(oe.A.ERROR.CHECK_YOUR_CONSOLE))))}finally{N(!1)}},Dt=async(e,t)=>{const a={...v,[t]:e};await kt(a)},Ft=async e=>{S(!0);try{await Dt(e,"embeddings_settings")}finally{S(!1)}},Ut=async(e,t)=>{const a=We.map((a=>a.id===e?{...a,...t}:a));Dt(a,"embeddings_envs")};mi((()=>{if(!y.zN){const e={...v};let t=!1;Ei.forEach((a=>{e[a]&&(e[a]=!1,console.warn(`Resetting ${a}`),t=!0)})),t&&(0,f.F1)(e)!==(0,f.F1)(v)&&kt(e)}}),[]),mi((()=>{localStorage.setItem("mwai_settings_section",_)}),[_]),mi((()=>{!$e&&Ve&&Dt(!1,"event_logs")}),[$e,Ve,Dt]),mi((()=>{"ai"===_||"files"===_||"php_api"===_||"rest_api"===_||"mcp"===_||"others"===_||"addons"===_||"chatbot"===_&&Re||"knowledge"===_&&de||"orchestration"===_&&ye||"assistants"===_&&me||T("ai")}),[_,Re,de,ye,me]),mi((()=>{if(!y.am)return;(0,te._)()||P(!0)}),[y.am]);const Bt=React.createElement(c.d,{title:oe.A.COMMON.UTILITIES},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_suggestions",label:oe.A.COMMON.POSTS_SUGGESTIONS,value:"1",checked:F,description:oe.A.COMMON.POSTS_SUGGESTIONS_HELP,onChange:Dt}))),Ht=React.createElement(c.d,{title:oe.A.COMMON.ADVISOR},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_advisor",label:oe.A.COMMON.ENABLE,value:"1",checked:U,description:oe.A.HELP.ADVISOR,onChange:Dt}))),jt=React.createElement(c.d,{title:oe.A.COMMON.GENERATORS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_generator_content",label:oe.A.COMMON.CONTENT_GENERATOR,value:"1",checked:le,description:oe.A.COMMON.CONTENT_GENERATOR_HELP,onChange:Dt}),React.createElement(m.R,{name:"module_generator_images",label:oe.A.COMMON.IMAGES_GENERATOR,value:"1",checked:ie,description:oe.A.COMMON.IMAGES_GENERATOR_HELP,onChange:Dt}),React.createElement(m.R,{name:"module_generator_videos",label:"Videos Generator",value:"1",checked:se,description:"Generate videos using AI models like Sora. Create videos from text prompts with control over duration and resolution.",onChange:Dt}))),$t=React.createElement(c.d,{title:oe.A.COMMON.PLAYGROUND},React.createElement(m.R,{name:"module_playground",label:oe.A.COMMON.ENABLE,value:"1",checked:ne,description:oe.A.COMMON.PLAYGROUND_HELP,onChange:Dt})),zt=React.createElement(c.d,{title:oe.A.COMMON.FORMS},React.createElement(m.R,{name:"module_forms",label:oe.A.COMMON.ENABLE,value:"1",checked:B,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.FORMS_HELP,onChange:Dt})),Gt=React.createElement(c.d,{title:oe.A.COMMON.SEARCH},React.createElement(m.R,{name:"module_search",label:oe.A.COMMON.ENABLE,value:"1",checked:fe,description:oe.A.COMMON.SEARCH_HELP,onChange:Dt})),Wt=React.createElement(c.d,{title:oe.A.COMMON.FINETUNES},React.createElement(m.R,{name:"module_finetunes",label:oe.A.COMMON.ENABLE,value:"1",checked:H,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!H,style:{marginRight:3}}),oe.A.HELP.FINETUNES),onChange:Dt})),qt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.INSIGHTS)},React.createElement(m.R,{name:"module_statistics",label:oe.A.COMMON.ENABLE,value:"1",checked:ae,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.INSIGHTS_HELP,onChange:Dt})),Kt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.MODERATION)},React.createElement(m.R,{name:"module_moderation",label:oe.A.COMMON.ENABLE,value:"1",checked:ce,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!ce,style:{marginRight:3}}),oe.A.COMMON.MODERATION_HELP),onChange:Dt})),Vt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.TRANSCRIPTION)},React.createElement(m.R,{name:"module_transcription",label:oe.A.COMMON.ENABLE,value:"1",checked:ue,description:oe.A.COMMON.TRANSCRIPTION_HELP,onChange:Dt})),Yt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.KNOWLEDGE)},React.createElement(m.R,{name:"module_embeddings",label:oe.A.COMMON.ENABLE,value:"1",checked:de,requirePro:!0,isPro:y.zN,description:(0,f.FE)(oe.A.COMMON.KNOWLEDGE_HELP),onChange:Dt})),Xt=React.createElement(c.d,{title:React.createElement(React.Fragment,null,oe.A.COMMON.ASSISTANTS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(m.R,{name:"module_assistants",label:oe.A.COMMON.ENABLE,value:"1",checked:me,requirePro:!0,isPro:y.zN,description:React.createElement(React.Fragment,null,React.createElement(_e,{disabled:!me,style:{marginRight:3}}),oe.A.HELP.ASSISTANTS),onChange:Dt})),Qt=React.createElement(c.d,{title:oe.A.COMMON.ORCHESTRATION},React.createElement(m.R,{name:"module_orchestration",label:oe.A.COMMON.ENABLE,value:"1",checked:ye,requirePro:!0,isPro:y.zN,description:oe.A.COMMON.ORCHESTRATION_HELP,onChange:Dt})),Jt=React.createElement(c.d,{title:oe.A.COMMON.CHATBOT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"module_chatbots",label:oe.A.COMMON.ENABLE,value:"1",checked:Re,description:oe.A.COMMON.CHATBOT_HELP,onChange:Dt}))),Zt=React.createElement(c.d,{title:"Cross-Site"},React.createElement(m.R,{name:"module_cross_site",label:oe.A.COMMON.ENABLE,value:"1",checked:ve,requirePro:!0,isPro:y.zN,description:"Enable chatbots to be embedded on external websites with domain-based access control.",onChange:Dt})),ea=React.createElement(c.d,{title:oe.A.COMMON.QUERIES_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"statistics_data",label:oe.A.COMMON.ENABLE,value:"1",checked:it,description:oe.A.HELP.QUERIES_DATA,onChange:Dt}))),ta=React.createElement(c.d,{title:oe.A.COMMON.QUERIES_FORMS_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"statistics_forms_data",label:oe.A.COMMON.ENABLE,value:"1",checked:st,description:oe.A.HELP.QUERIES_FORMS_DATA,onChange:Dt}))),na=React.createElement(c.d,{title:oe.A.COMMON.INTRO_MESSAGE},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"intro_message",label:oe.A.COMMON.ENABLE,value:"1",checked:ct,description:oe.A.HELP.INTRO_MESSAGE,onChange:Dt}))),la=React.createElement(c.d,{title:"Forms Editor"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"forms_editor",label:oe.A.COMMON.ENABLE,value:"1",checked:!!B&&!!be,disabled:!B,description:B?"Enable the Forms Editor (adds a new tab). Build forms with blocks and shortcodes.":"Enable the Forms module to use the Forms Editor.",onChange:Dt}))),ra=React.createElement(c.d,{title:oe.A.COMMON.CHATBOT_SELECT},React.createElement(K.u,{scrolldown:!0,name:"chatbot_select",value:null==v?void 0:v.chatbot_select,onChange:Dt,description:oe.A.HELP.CHATBOT_SELECT},React.createElement(K.j,{key:"tabs",value:"tabs",label:oe.A.COMMON.TABS}),React.createElement(K.j,{key:"dropdown",value:"dropdown",label:oe.A.COMMON.DROPDOWN}))),oa=React.createElement(c.d,{title:oe.A.COMMON.WEBSPEECH_API},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"speech_recognition",label:oe.A.COMMON.SPEECH_RECOGNITION,value:"1",checked:Ze,description:oe.A.HELP.SPEECH_RECOGNITION,onChange:Dt})),React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"speech_synthesis",label:oe.A.COMMON.SPEECH_SYNTHESIS+" (SOON)",value:"1",disabled:!0,checked:et,description:oe.A.HELP.SPEECH_SYNTHESIS,onChange:Dt}))),ia=React.createElement(c.d,{title:oe.A.COMMON.GDPR_CONSENT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_gdpr_consent",label:oe.A.COMMON.ENABLE,value:"1",checked:Xe,description:oe.A.HELP.GDPR_CONSENT,onChange:Dt}))),sa=React.createElement(c.d,{title:oe.A.COMMON.GDPR_TEXT},React.createElement(V.A,{name:"chatbot_gdpr_text",value:Qe,onBlur:Dt})),da=React.createElement(c.d,{title:oe.A.COMMON.GDPR_BUTTON},React.createElement(V.A,{name:"chatbot_gdpr_button",value:Je,onBlur:Dt})),ma=React.createElement(c.d,{title:oe.A.COMMON.STREAMING},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ai_streaming",label:oe.A.COMMON.ENABLE,value:"1",checked:$e,description:oe.A.HELP.STREAMING,onChange:Dt}))),ua=React.createElement(c.d,{title:"Responses API"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ai_responses_api",label:oe.A.COMMON.ENABLE,value:"1",checked:ze,description:"Use OpenAI's new Responses API for improved performance and features. This is recommended, but can be disabled if you experience issues.",onChange:Dt}))),pa=React.createElement(c.d,{title:oe.A.COMMON.PRIVACY_FIRST},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"privacy_first",label:oe.A.COMMON.ENABLE,value:"1",checked:Ge,description:oe.A.HELP.PRIVACY_FIRST,onChange:Dt}))),ga=React.createElement(c.d,{title:oe.A.COMMON.DISCUSSIONS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions",label:oe.A.COMMON.ENABLE,value:"1",checked:Ye,description:oe.A.HELP.DISCUSSIONS,onChange:Dt}))),Ea=React.createElement(c.d,{title:oe.A.COMMON.SUMMARIZE},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions_titling",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.chatbot_discussions_titling,description:oe.A.HELP.DISCUSSION_SUMMARY,onChange:Dt}))),ha=React.createElement(c.d,{title:oe.A.COMMON.PAGING||"Paging"},React.createElement(K.u,{scrolldown:!0,name:"chatbot_discussions_paging",value:(null==v?void 0:v.chatbot_discussions_paging)||10,onChange:Dt,description:oe.A.HELP.DISCUSSIONS_PAGING||"Number of discussions to display per page"},React.createElement(K.j,{value:"None",label:"None"}),React.createElement(K.j,{value:5,label:"5 per Page"}),React.createElement(K.j,{value:10,label:"10 per Page"}),React.createElement(K.j,{value:15,label:"15 per Page"}),React.createElement(K.j,{value:20,label:"20 per Page"}),React.createElement(K.j,{value:30,label:"30 per Page"}),React.createElement(K.j,{value:50,label:"50 per Page"}))),Ra=React.createElement(c.d,{title:oe.A.COMMON.REFRESH_INTERVAL||"Refresh Interval"},React.createElement(K.u,{scrolldown:!0,name:"chatbot_discussions_refresh_interval",value:(null==v?void 0:v.chatbot_discussions_refresh_interval)||5,onChange:Dt,description:oe.A.HELP.DISCUSSIONS_REFRESH_INTERVAL||"How often to refresh the discussions list (in seconds)"},React.createElement(K.j,{value:1,label:"1 second"}),React.createElement(K.j,{value:2,label:"2 seconds"}),React.createElement(K.j,{value:5,label:"5 seconds"}),React.createElement(K.j,{value:10,label:"10 seconds"}),React.createElement(K.j,{value:30,label:"30 seconds"}),React.createElement(K.j,{value:60,label:"60 seconds"}),React.createElement(K.j,{value:120,label:"120 seconds"}),React.createElement(K.j,{value:"Manual",label:"Manually"}),React.createElement(K.j,{value:"Never",label:"Never"}))),fa=React.createElement(c.d,{title:"Metadata Bar"},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"chatbot_discussions_metadata_enabled",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_enabled,description:"Display a metadata bar under discussion titles.",onChange:Dt}))),ya=null!=v&&v.chatbot_discussions_metadata_enabled?React.createElement(c.d,{title:"Metadata Display"},React.createElement(d.E,{max:"3"},React.createElement(m.R,{name:"chatbot_discussions_metadata_start_date",label:"Start Date",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_start_date,description:"Show when the discussion was created.",onChange:Dt}),React.createElement(m.R,{name:"chatbot_discussions_metadata_last_update",label:"Last Update",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_last_update,description:"Show when the discussion was last modified.",onChange:Dt}),React.createElement(m.R,{name:"chatbot_discussions_metadata_message_count",label:"Message Count",value:"1",checked:null==v?void 0:v.chatbot_discussions_metadata_message_count,description:"Show the number of messages in the discussion.",onChange:Dt}))):null,va=React.createElement(c.d,{title:oe.A.COMMON.SYNTAX_HIGHLIGHT},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"syntax_highlight",label:oe.A.COMMON.ENABLE,value:"1",checked:Ke,description:oe.A.HELP.SYNTAX_HIGHLIGHT,onChange:Dt}))),ba=React.createElement(c.d,{title:oe.A.COMMON.EVENT_LOGS},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"event_logs",label:oe.A.COMMON.ENABLE,value:"1",checked:Ve,disabled:!$e,description:oe.A.HELP.EVENT_LOGS,onChange:Dt}))),wa=React.createElement(c.d,{title:oe.A.COMMON.PUBLIC_API},React.createElement(m.R,{name:"public_api",label:oe.A.COMMON.ENABLE,value:"1",checked:tt,description:oe.A.HELP.PUBLIC_API,onChange:Dt}),tt&&React.createElement(_o,{value:`${y.gh}/mwai/v1/`},React.createElement("span",null,w,React.createElement("span",{className:"highlight"},"/wp-json/mwai/v1/")))),_a=React.createElement(c.d,{title:oe.A.COMMON.BEARER_TOKEN},React.createElement(V.A,{name:"public_api_bearer_token",value:null==v?void 0:v.public_api_bearer_token,description:Oe(oe.A.HELP.BEARER_TOKEN,oe.A.HELP.BEARER_TOKEN_URL,oe.A.HELP.BEARER_TOKEN_LINK_TEXT),onBlur:Dt})),Ta=React.createElement(c.d,{title:"SSE Endpoint"},React.createElement(m.R,{name:"module_mcp",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.module_mcp,description:"Enable MCP server endpoint for AI assistants like ChatGPT and Claude to manage your WordPress site.",onChange:Dt}),(null==v?void 0:v.module_mcp)&&React.createElement(React.Fragment,null,React.createElement(_o,{value:`${y.gh}/mcp/v1/sse`},React.createElement("span",null,w,React.createElement("span",{className:"highlight"},"/wp-json/mcp/v1/sse"))))),Ca=React.createElement(c.d,{title:oe.A.COMMON.BEARER_TOKEN},React.createElement(V.A,{name:"mcp_bearer_token",value:null==v?void 0:v.mcp_bearer_token,description:(0,f.FE)(oe.A.HELP.MCP_BEARER_TOKEN),onBlur:Dt})),Aa=React.createElement(c.d,{title:"No-Auth URL"},React.createElement(m.R,{name:"mcp_noauth_url",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_noauth_url,disabled:!(null!=v&&v.module_mcp&&null!=v&&v.mcp_bearer_token),description:"For clients that don't support bearer token headers (like ChatGPT). The token is embedded directly in the URL for convenience.",onChange:Dt}),(null==v?void 0:v.mcp_noauth_url)&&(null==v?void 0:v.module_mcp)&&(null==v?void 0:v.mcp_bearer_token)&&React.createElement(React.Fragment,null,React.createElement(_o,{value:`${y.gh}/mcp/v1/${v.mcp_bearer_token}/sse`},React.createElement("span",null,w,"/wp-json/mcp/v1/",React.createElement("span",{className:"highlight"},v.mcp_bearer_token),"/sse")),React.createElement("p",{style:{margin:"12px 0 0 0",padding:"10px",backgroundColor:"#fff3cd",border:"1px solid #ffc107",borderRadius:"4px",fontSize:"13px",color:"#856404"}},React.createElement("strong",null,"⚠️")," Keep this token absolutely secret. Use a long, random value. Anyone with this token has full admin access to your site."))),Na=React.createElement(c.d,{title:"WordPress"},React.createElement(m.R,{name:"mcp_core",label:"Enable (Recommended)",value:"1",checked:null==v?void 0:v.mcp_core,description:"Manage posts, pages, comments, users, media, taxonomies, and WordPress settings.",onChange:Dt})),Oa=React.createElement(c.d,{title:"Plugins"},React.createElement(m.R,{name:"mcp_plugins",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_plugins,requirePro:!0,isPro:y.zN,description:"Install, activate, update, and modify plugins.",onChange:Dt})),Sa=React.createElement(c.d,{title:"Themes"},React.createElement(m.R,{name:"mcp_themes",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_themes,requirePro:!0,isPro:y.zN,description:"Install, activate, switch, and customize themes.",onChange:Dt})),Ma=React.createElement(c.d,{title:"Dynamic REST"},React.createElement(m.R,{name:"mcp_dynamic_rest",label:oe.A.COMMON.ENABLE,value:"1",checked:null==v?void 0:v.mcp_dynamic_rest,description:"Raw access to WordPress's native REST API. More technical and limited compared to the optimized tools above. Only enable if you need direct REST API access.",onChange:Dt})),xa=React.createElement(c.d,{title:"Local Upload"},React.createElement(K.u,{scrolldown:!0,name:"image_local_upload",value:null==v?void 0:v.image_local_upload,onChange:Dt,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(K.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(K.j,{key:"library",value:"library",label:"Media Library"}))),ka=React.createElement(c.d,{title:"Remote Upload"},React.createElement(K.u,{scrolldown:!0,name:"image_remote_upload",value:null==v?void 0:v.image_remote_upload,onChange:Dt,description:"Select Upload Data for private sites; Share URLs requires your WordPress to be online and reachable."},React.createElement(K.j,{key:"data",value:"data",label:"Upload Data"}),React.createElement(K.j,{key:"url",value:"url",label:"Share URLs"}))),Pa=React.createElement(c.d,{title:"Expiration"},React.createElement(K.u,{scrolldown:!0,name:"image_expires",value:(null==v?void 0:v.image_expires)??"never",onChange:Dt,description:"Uploaded files will be deleted after a certain amount of time. This also affects files uploaded to OpenAI via the Assistants."},React.createElement(K.j,{key:300,value:300,label:"5 minutes"}),React.createElement(K.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(K.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(K.j,{key:86400,value:86400,label:"1 day"}),React.createElement(K.j,{key:604800,value:604800,label:"1 week"}),React.createElement(K.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(K.j,{key:"Never",value:"never",label:"Never"}))),La=React.createElement(c.d,{title:"Local Download"},React.createElement(K.u,{scrolldown:!0,name:"image_local_download",value:(null==v?void 0:v.image_local_download)??null,onChange:Dt,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(K.j,{key:null,value:null,label:"None"}),React.createElement(K.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(K.j,{key:"library",value:"library",label:"Media Library"}))),Da=React.createElement(c.d,{title:"Expiration"},React.createElement(K.u,{scrolldown:!0,name:"image_expires_download",value:(null==v?void 0:v.image_expires_download)??"never",onChange:Dt,description:"Downloaded files will be deleted after a certain amount of time."},React.createElement(K.j,{key:300,value:300,label:"5 minutes"}),React.createElement(K.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(K.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(K.j,{key:86400,value:86400,label:"1 day"}),React.createElement(K.j,{key:604800,value:604800,label:"1 week"}),React.createElement(K.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(K.j,{key:"Never",value:"never",label:"Never"}))),Fa=React.createElement(c.d,{title:oe.A.COMMON.DEV_TOOLS},React.createElement(m.R,{name:"module_devtools",label:oe.A.COMMON.ENABLE,value:"1",checked:ge,description:oe.A.HELP.DEV_TOOLS,onChange:Dt})),Ua=React.createElement(c.d,{title:oe.A.COMMON.SHORTCODES},React.createElement(m.R,{name:"resolve_shortcodes",label:oe.A.COMMON.RESOLVE,value:"1",checked:ht,description:oe.A.HELP.RESOLVE_SHORTCODE,onChange:Dt})),Ba=React.createElement(c.d,{title:oe.A.COMMON.CONTEXT_MAX_LENGTH},React.createElement(V.A,{name:"context_max_length",value:dt,type:"number",step:"1",description:oe.A.HELP.CONTEXT_MAX_LENGTH,onBlur:Dt})),Ha=React.createElement(c.d,{title:oe.A.COMMON.BANNED_WORDS},React.createElement(V.A,{id:"banned_words",name:"banned_words",value:ut,isCommaSeparatedArray:!0,description:oe.A.HELP.BANNED_WORDS,onBlur:Dt})),ja=React.createElement(c.d,{title:oe.A.COMMON.WORD_BOUNDARIES},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"ignore_word_boundaries",label:oe.A.COMMON.IGNORE,value:"1",checked:pt,description:oe.A.HELP.WORD_BOUNDARIES,onChange:Dt}))),$a=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_default_model",value:yt.some((e=>e.model===Ne))?Ne:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),yt.map((e=>React.createElement(K.j,{value:e.model,label:e.name}))))),za=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_fast_default_model",value:vt.some((e=>e.model===Ae))?Ae:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),vt.map((e=>React.createElement(K.j,{value:e.model,label:e.name}))))),Ga=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_model",value:Ct.some((e=>e.model===Pe))?Pe:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),Ct.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Wa=React.createElement(c.d,{title:oe.A.COMMON.DIMENSIONS},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_dimensions",value:(null==v?void 0:v.ai_embeddings_default_dimensions)||"",onChange:Dt},React.createElement(K.j,{value:"",label:"Not Set"}),Nt.map(((e,t)=>React.createElement(K.j,{value:e,label:0===t?`${e} (Native)`:e}))))),qa=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_vision_default_model",value:bt.some((e=>e.model===xe))?xe:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),bt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Ka=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_audio_default_model",value:wt.some((e=>e.model===Be))?Be:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),wt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Va=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_json_default_model",value:_t.some((e=>e.model===je))?je:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),_t.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Ya=React.createElement(c.d,{title:oe.A.COMMON.MODEL},React.createElement(K.u,{scrolldown:!0,name:"ai_images_default_model",value:Tt.some((e=>e.model===De))?De:"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),Tt.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name}))))),Xa=React.createElement(c.d,{title:oe.A.COMMON.BANNED_IPS},React.createElement(V.A,{id:"banned_ips",name:"banned_ips",value:mt,isCommaSeparatedArray:!0,description:oe.A.HELP.BANNED_IPS,onBlur:Dt})),Qa=React.createElement(c.d,{title:"Available Languages"},React.createElement(V.A,{id:"custom_languages",name:"custom_languages",value:gt,isCommaSeparatedArray:!0,description:"The complete list of languages available in AI Engine. You can add, remove, or modify languages. Use format: 'Language Name (code)' or just 'Language Name'. The language code (e.g., 'en', 'fr') helps with internationalization but is optional.",placeholder:"English (en), French (fr), Spanish (es), German (de)",onBlur:Dt})),Ja=React.createElement(c.d,{title:oe.A.COMMON.PLAYGROUND},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.playground,onChange:e=>{const t={...Et,playground:e};Dt(t,"admin_bar")}})),Za=React.createElement(c.d,{title:oe.A.COMMON.GENERATE_CONTENT},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.content_generator,onChange:e=>{const t={...Et,content_generator:e};Dt(t,"admin_bar")}})),en=React.createElement(c.d,{title:oe.A.COMMON.GENERATE_IMAGES},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.images_generator,onChange:e=>{const t={...Et,images_generator:e};Dt(t,"admin_bar")}})),tn=React.createElement(c.d,{title:"AI Engine"},React.createElement(m.R,{label:oe.A.COMMON.ENABLE,value:"1",checked:null==Et?void 0:Et.settings,onChange:e=>{const t={...Et,settings:e};Dt(t,"admin_bar")}})),an=React.createElement("div",null,React.createElement(ca,{options:v})),nn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_default_env",value:Ie||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),ln=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_fast_default_env",value:Ce||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),rn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_embeddings_default_env",value:ke||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),At.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),on=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_vision_default_env",value:Me||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),sn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_audio_default_env",value:Ue||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),cn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_json_default_env",value:He||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),dn=React.createElement(React.Fragment,null,React.createElement(Y.g,{height:5}),React.createElement(c.d,{title:oe.A.COMMON.ENVIRONMENT},React.createElement(K.u,{scrolldown:!0,name:"ai_images_default_env",value:Le||"",onChange:Dt},React.createElement(K.j,{value:"",label:"None"}),we.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))))),mn=React.createElement(K.u,{scrolldown:!0,name:"embeddings_default_env",value:qe,onChange:Dt},We.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),un=React.createElement(c.d,{title:oe.A.COMMON.PLUGIN_DATA},React.createElement(d.E,{max:"1"},React.createElement(m.R,{name:"clean_uninstall",label:oe.A.COMMON.DELETE_ALL,description:oe.A.COMMON.PLUGIN_DATA_DESCRIPTION,value:"1",checked:Rt,onChange:Dt})));return React.createElement(u.z,null,React.createElement(Fe,{options:v}),React.createElement(g.N,null,React.createElement(g.Y,{fullWidth:!0},React.createElement(Ee,{options:v}),ct&&React.createElement(X.L,null,Se(oe.A.SETTINGS.INTRO,[{url:oe.A.SETTINGS.INTRO_TUTORIAL_URL,text:oe.A.SETTINGS.INTRO_TUTORIAL_TEXT},{url:oe.A.SETTINGS.INTRO_DOCS_URL,text:oe.A.SETTINGS.INTRO_DOCS_TEXT},{url:oe.A.SETTINGS.INTRO_ADDONS_URL,text:oe.A.SETTINGS.INTRO_ADDONS_TEXT},{url:oe.A.SETTINGS.INTRO_DISCLAIMER_URL,text:oe.A.SETTINGS.INTRO_DISCLAIMER_TEXT}])),React.createElement(E._,{keepTabOnReload:!0},React.createElement(E.V,{key:"dashboard",title:oe.A.COMMON.DASHBOARD},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0},React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.CLIENT_MODULES,className:"primary"},Jt,zt,Gt),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.SERVER_MODULES,className:"primary"},qt,Yt,Qt,Wt,Kt,Xt),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.BACKEND_MODULES,className:"primary"},Ht,jt,$t,Bt,Vt)),React.createElement(g.Y,{minimal:!0},React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USAGE,className:"primary"},an)))),Re&&React.createElement(E.V,{key:"chatbots",title:oe.A.COMMON.CHATBOTS},React.createElement(zr,{options:v,updateOption:Dt,busy:Mt})),fe&&React.createElement(E.V,{key:"search",title:oe.A.COMMON.SEARCH},React.createElement(So,{options:v,updateOption:Dt,busy:Mt})),Re&&Ye&&React.createElement(E.V,{key:"discussions",title:oe.A.COMMON.DISCUSSIONS},React.createElement(Ia,null)),B&&be&&React.createElement(E.V,{key:"forms",title:oe.A.COMMON.FORMS},React.createElement(ni,null)),ae&&React.createElement(E.V,{key:"insights",title:oe.A.COMMON.INSIGHTS},React.createElement(to,{options:v,updateOption:Dt,busy:Mt})),de&&React.createElement(E.V,{key:"knowledge",title:oe.A.COMMON.KNOWLEDGE},React.createElement(aa,{options:v,updateEnvironment:Ut,updateOption:Dt})),H&&React.createElement(E.V,{key:"finetunes",title:oe.A.COMMON.FINETUNES},React.createElement(St,{options:v,updateOption:Dt,refreshOptions:Lt})),ce&&React.createElement(E.V,{key:"moderation",title:oe.A.COMMON.MODERATION},React.createElement(xt,{options:v,updateOption:Dt,busy:Mt})),ue&&React.createElement(E.V,{key:"transcription",title:oe.A.COMMON.TRANSCRIPTION},React.createElement(Ao,{options:v,updateOption:Dt})),React.createElement(E.V,{key:"settings",title:oe.A.COMMON.SETTINGS},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingTop:10,marginBottom:10}},React.createElement(Q.o,{inversed:!0,name:"quicklinks",value:_,onChange:T},React.createElement(Q.K,{title:"AI",value:"ai"}),de&&React.createElement(Q.K,{title:"Knowledge",value:"knowledge"}),Re&&React.createElement(Q.K,{title:"Chatbot",value:"chatbot"}),ye&&React.createElement(Q.K,{title:"Orchestration",value:"orchestration"}),me&&React.createElement(Q.K,{title:oe.A.COMMON.ASSISTANTS,value:"assistants"}),React.createElement(Q.K,{title:"Files & Media",value:"files"}),React.createElement(Q.K,{title:"PHP API",value:"php_api"}),React.createElement(Q.K,{title:"REST API",value:"rest_api"}),React.createElement(Q.K,{title:"MCP",value:"mcp"}),React.createElement(Q.K,{title:"Add-ons",value:"addons"}),React.createElement(Q.K,{title:oe.A.COMMON.OTHERS,value:"others"}))),React.createElement(g.Y,{minimal:!0,fullWidth:!0},React.createElement(g.N,null,React.createElement(g.Y,{minimal:!0,fullWidth:"assistants"===_},"ai"===_&&React.createElement(React.Fragment,null,React.createElement(Eo,{busy:Mt,options:v,environments:we,updateEnvironment:async(e,t)=>{const a=we.map((a=>a.id===e?{...a,...t}:a));Dt(a,"ai_envs")},updateOption:Dt}),React.createElement(Y.g,null),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.AI_ENVIRONMENT_DEFAULTS,subtitle:"Select the default environment and model for each type of AI query",className:"primary"},React.createElement(Q.o,{name:"envSection",value:L,onChange:e=>D(e)},React.createElement(Q.K,{title:Ot(Ie,Ne,yt)?oe.A.COMMON.DEFAULT:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.DEFAULT),value:"default"}),React.createElement(Q.K,{title:Ot(Ce,Ae,vt)?oe.A.COMMON.DEFAULT_FAST:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.DEFAULT_FAST),value:"fast"}),React.createElement(Q.K,{title:Ot(Me,xe,bt)?oe.A.COMMON.VISION:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.VISION),value:"vision"}),React.createElement(Q.K,{title:Ot(Le,De,Tt)?oe.A.COMMON.IMAGES:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.IMAGES),value:"images"}),React.createElement(Q.K,{title:Ot(ke,Pe,Ct)?oe.A.COMMON.EMBEDDINGS:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.EMBEDDINGS),value:"embeddings"}),React.createElement(Q.K,{title:Ot(Ue,Be,wt)?oe.A.COMMON.AUDIO:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.AUDIO),value:"audio"}),React.createElement(Q.K,{title:Ot(He,je,_t)?oe.A.COMMON.JSON:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:"var(--neko-red)",marginLeft:0,marginRight:4}},"⚠"),oe.A.COMMON.JSON),value:"json"})),React.createElement(Y.g,null),"default"===L&&React.createElement(React.Fragment,null,nn,$a,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"The default environment for general AI queries and content generation.")),"fast"===L&&React.createElement(React.Fragment,null,ln,za,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"Used for quick tasks like generating discussion titles and optimizing search queries.")),"vision"===L&&React.createElement(React.Fragment,null,on,qa,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For analyzing and understanding images, including image-to-text capabilities.")),"images"===L&&React.createElement(React.Fragment,null,dn,Ya,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For generating images using AI models like DALL-E.")),"embeddings"===L&&React.createElement(React.Fragment,null,rn,Ga,Wa,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For creating text embeddings used in semantic search and similarity matching.")),"audio"===L&&React.createElement(React.Fragment,null,sn,Ka,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For audio transcription and speech-to-text processing.")),"json"===L&&React.createElement(React.Fragment,null,cn,Va,React.createElement(Y.g,{height:15}),React.createElement(s.s,{p:!0,style:{margin:0}},"For structured data generation and JSON output formatting.")))),"knowledge"===_&&de&&React.createElement(React.Fragment,null,React.createElement(co,{busy:Mt,options:v,environments:We,updateEnvironment:Ut,updateOption:Dt}),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.EMBEDDINGS_ENVIRONMENT_DEFAULT,className:"primary"},mn)),"chatbot"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.CHATBOT,className:"primary"},ga,Zt,va,oa,ia,Xe&&React.createElement(React.Fragment,null,sa,da))),"assistants"===_&&me&&React.createElement(React.Fragment,null),"orchestration"===_&&React.createElement(React.Fragment,null,React.createElement(fo,{busy:Mt,options:v,mcpServers:Te,updateMCPServer:async(e,t)=>{const a=Te.map((a=>a.id===e?{...a,...t}:a));Dt(a,"mcp_envs")},updateOption:Dt})),"files"===_&&React.createElement(R.z,{busy:Mt,title:"Uploaded by Users",subtitle:"Manage how user-uploaded files are stored and handled",className:"primary"},xa,ka,Pa),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USER_INTERFACE,className:"primary"},na,la),"others"===_&&ae&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.INSIGHTS,className:"primary"},React.createElement("p",null,oe.A.HELP.STATISTICS),ea,ta),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.ADMIN_BAR,className:"primary"},tn,Ja,Za,en),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.MAINTENANCE,className:"primary"},React.createElement("p",{style:{marginBottom:"15px"}},"It is important to keep regular backups of your settings. Use Export Settings to save your configuration. Import Settings allows you to restore a previous configuration. Reset Settings will restore all settings to their defaults. Reset Usage will clear all usage statistics and start fresh."),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px",marginBottom:"10px"}},React.createElement(h.M,{className:"blue",onClick:async()=>{N("exportSettings");try{const e=await lt(),t=await at(),a={chatbots:e,themes:t,options:await ot()},n=new Blob([(0,f.F1)(a)],{type:"application/json"}),l=URL.createObjectURL(n),r=document.createElement("a");r.href=l;const o=new Date,i=`ai-engine-${o.getFullYear()}-${o.getMonth()+1}-${o.getDate()}.json`;r.setAttribute("download",i),r.click()}catch(e){alert("Error while exporting settings. Please check your console."),console.log(e)}finally{N(!1)}},style:{flex:2}},"Export Settings"),React.createElement(h.M,{className:"danger",onClick:async()=>{N("importSettings");try{const e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=async e=>{const t=e.target.files[0];if(!t)return;const a=new FileReader;a.onload=async e=>{const t=JSON.parse(e.target.result),{chatbots:a,themes:n,options:l}=t;await rt(a),await nt(n),await kt(l),alert("Settings imported. The page will now reload to reflect the changes."),window.location.reload()},a.readAsText(t)},e.click()}catch(e){alert("Error while importing settings. Please check your console."),console.log(e)}finally{N(!1)}},style:{flex:1}},"Import Settings"),React.createElement(h.M,{className:"danger",onClick:async()=>{if(window.confirm(oe.A.ALERTS.ARE_YOU_SURE)){N(!0);try{await(0,f.IU)(`${y.y0}/settings/reset`,{method:"POST",nonce:y.ok}),alert("Settings reset. The page will now reload to reflect the changes."),window.location.reload()}catch(e){alert("Error while resetting settings. Please check your console."),console.log(e)}finally{N(!1)}}},style:{flex:1}},"Reset Settings")),React.createElement(h.M,{className:"danger",onClick:async()=>{if(window.confirm(oe.A.COMMON.RESET_USAGE_SURE)){N(!0);try{await Dt([],"ai_usage"),await Dt([],"ai_usage_daily");const e=await(0,f.IU)(`${y.y0}/settings/options`,{method:"GET",headers:{"X-WP-Nonce":y.ok}});e.success&&e.options&&(kt(e.options),showSnackbar("Usage data has been reset successfully.","success"))}catch(e){console.error("Error resetting usage:",e),showSnackbar("Failed to reset usage data. Please try again.","error")}finally{N(!1)}}},disabled:Mt,fullWidth:!0},oe.A.COMMON.RESET," ",oe.A.COMMON.USAGE)),"mcp"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"MCP Access",className:"primary"},React.createElement("p",null,Se(oe.A.HELP.MCP_INTRO,[{url:oe.A.HELP.MCP_TUTORIAL_URL,text:oe.A.HELP.MCP_TUTORIAL_TEXT},{url:oe.A.HELP.MCP_CLAUDE_TUTORIAL_URL,text:oe.A.HELP.MCP_CLAUDE_TUTORIAL_TEXT}])),React.createElement(Y.g,null),Ta,Ca,Aa),(null==v?void 0:v.module_mcp)&&React.createElement(R.z,{busy:Mt,title:"MCP Features",className:"primary"},React.createElement("p",null,"AI Engine provides optimized, AI-friendly tools specifically designed for seamless WordPress management. These tools are intelligently structured for clarity and ease-of-use by AI assistants. Dynamic REST provides raw access to WordPress's native REST API (the Automattic way) which is more technical and limited in scope."),Na,Oa,Sa,Ma,React.createElement("p",{style:{marginTop:15}},"If you are a developer, you might be interested in hooking your own tools. They will appear automatically in the MCP Functions section on the right. Learn more in the ",React.createElement("a",{href:"https://ai.thehiddendocs.com/mcp/",target:"_blank",rel:"noreferrer"},"documentation ↗"),"."))),"php_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"PHP API",className:"primary"},React.createElement("p",{style:{marginBottom:12,fontSize:13}},"This internal API is why AI Engine was created originally. AI Engine is designed to be the ",React.createElement("strong",null,"AI Engine for WordPress"),", providing a unified interface for integrating AI capabilities into your site through simple PHP code."),React.createElement("p",{style:{marginBottom:12,fontSize:13}},"Access AI Engine through the global ",React.createElement("code",null,"$mwai")," object. Each query type automatically uses its corresponding default environment and model from ",React.createElement("strong",null,"AI > Default Environments"),". Override these by passing custom options (see Advanced Examples)."),React.createElement("p",{style:{marginBottom:12,fontSize:13}},"For easy code integration, use ",React.createElement("a",{href:"https://wordpress.org/plugins/code-engine/",target:"_blank",rel:"noreferrer"},"Code Engine ↗")," to create and manage your PHP snippets."),React.createElement("p",{style:{marginBottom:0,fontSize:13}},"To go deeper: ",React.createElement("a",{href:oe.A.HELP.PHP_API_FUNCTIONS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_FUNCTIONS_TEXT),", ",React.createElement("a",{href:oe.A.HELP.PHP_API_CLASSES_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_CLASSES_TEXT),", ",React.createElement("a",{href:oe.A.HELP.PHP_API_FILTERS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.PHP_API_FILTERS_TEXT),".")),React.createElement(R.z,{busy:Mt,title:"Basic Examples",className:"primary"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Text Query")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$result = $mwai->simpleTextQuery( "Write a haiku about AI" );\necho $result;'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Get AI-generated text responses for any prompt.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Image Generation")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n$url = $mwai->simpleImageQuery( \"A serene mountain landscape\" );\necho '<img src=\"' . esc_url( $url ) . '\" />';"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Generate images from text descriptions.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Vision Query")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$result = $mwai->simpleVisionQuery(\n "What\'s in this image?",\n "https://example.com/photo.jpg"\n);\necho $result;'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Analyze images with AI vision capabilities.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Structured JSON Response")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},'global $mwai;\n$data = $mwai->simpleJsonQuery( "Generate a product review" );\n// Returns structured JSON data\nprint_r( $data );'),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Get structured data responses for easy parsing."))))),"rest_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"REST API",className:"primary"},React.createElement("p",null,Oe(oe.A.HELP.REST_API_INTRO,oe.A.HELP.REST_API_MAKE_URL,oe.A.HELP.REST_API_MAKE_TEXT)),React.createElement("p",{style:{marginTop:10,fontSize:13}},"The REST API uses the environments and models configured in ",React.createElement("strong",null,"AI > Default Environments"),", except if ",React.createElement("code",null,"envId")," or ",React.createElement("code",null,"model")," are specified in the ",React.createElement("code",null,"options")," parameter."),React.createElement("p",{style:{marginTop:10,fontSize:13}},"For complete API reference and advanced usage, see the ",React.createElement("a",{href:oe.A.HELP.REST_API_DOCS_URL,target:"_blank",rel:"noreferrer"},oe.A.HELP.REST_API_DOCS_TEXT),"."),React.createElement(Y.g,null),wa,_a),tt&&React.createElement(R.z,{busy:Mt,title:"Authentication",className:"primary"},React.createElement("p",{style:{marginBottom:10,fontSize:13}},"All endpoints require Bearer Token authentication. Include this header in all requests:"),React.createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:4,fontSize:12,marginBottom:15}},"Authorization: Bearer ",(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#4CAF50",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"GET"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleAuthCheck")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleAuthCheck",command:`curl -X GET "${y.gh}/mwai/v1/simpleAuthCheck" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}"`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:0,color:"#666",fontSize:13}},"Test authentication and get current user email"))),tt&&React.createElement(R.z,{busy:Mt,title:"Options",className:"primary"},React.createElement("p",{style:{marginBottom:15,fontSize:13}},"Most endpoints accept an ",React.createElement("code",null,"options")," parameter (JSON object) to customize AI behavior. Common options include:"),React.createElement("div",{style:{marginBottom:15}},React.createElement("strong",{style:{fontSize:13}},"Core Options:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13,lineHeight:1.6}},React.createElement("li",null,React.createElement("code",null,"envId")," (string): AI Environment ID to use (find IDs in AI → Environments)"),React.createElement("li",null,React.createElement("code",null,"scope")," (string): Request scope (default: 'public-api')"),React.createElement("li",null,React.createElement("code",null,"model")," (string): Specific AI model to use (e.g., 'gpt-4', 'claude-3-5-sonnet-20241022')"),React.createElement("li",null,React.createElement("code",null,"temperature")," (number): Creativity level, 0-1 (default varies by model)"),React.createElement("li",null,React.createElement("code",null,"maxTokens")," (number): Maximum response length in tokens"))),React.createElement("div",{style:{marginBottom:15}},React.createElement("strong",{style:{fontSize:13}},"Image Options:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13,lineHeight:1.6}},React.createElement("li",null,React.createElement("code",null,"resolution")," (string): Image size (e.g., '1024x1024', '1792x1024')"))),React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Example:")),React.createElement("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:4,fontSize:12,overflow:"auto"}},'{\n "message": "Write a haiku about AI",\n "options": {\n "envId": "your-env-id",\n "model": "gpt-4",\n "temperature": 0.7,\n "maxTokens": 150\n }\n}')))),React.createElement(g.Y,{minimal:!0},"php_api"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:"Advanced Examples",className:"primary"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Chatbot with Memory")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n// First message\n$reply = $mwai->simpleChatbotQuery( \"default\", \"Hello!\" );\n$chatId = $reply['chatId'];\necho $reply['reply'];\n\n// Follow-up with memory\n$reply = $mwai->simpleChatbotQuery(\n \"default\",\n \"What did I just say?\",\n [ 'chatId' => $chatId ]\n);\necho $reply['reply'];"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Maintain conversation context by reusing the chatId for follow-up questions.")),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{marginBottom:10}},React.createElement("strong",{style:{fontSize:13}},"Using Custom Options")),React.createElement("pre",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"#fff",padding:12,borderRadius:4,fontSize:11,overflow:"auto",margin:0,boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},"global $mwai;\n$options = [\n 'envId' => 'your-env-id',\n 'model' => 'gpt-4',\n 'temperature' => 0.7,\n 'maxTokens' => 500\n];\n$result = $mwai->simpleTextQuery( \"Your prompt\", $options );\necho $result;"),React.createElement("p",{style:{marginTop:10,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px",margin:"10px 0 0 0"}},"Override defaults with custom environment, model, and parameters."))))),"mcp"===_&&(null==v?void 0:v.module_mcp)&&React.createElement(vo,{options:v}),"ai"===_&&React.createElement(React.Fragment,null,React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.GENERAL,className:"primary"},ma,ba,ua)),"knowledge"===_&&de&&React.createElement(React.Fragment,null,React.createElement(R.z,{className:"primary",title:"Information"},React.createElement("div",{style:{marginBottom:10}},React.createElement("p",null,"For ",React.createElement("a",{href:"https://en.wikipedia.org/wiki/Retrieval-augmented_generation",target:"_blank",rel:"noreferrer"},"RAG ↗"),", or simply to give your chatbots a knowledge base, vector stores are used. AI Engine supports various vector stores. You'll need to create embeddings to feed your vector store, then your chatbots can search it."),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:0,margin:"20px 0",padding:"20px 15px",background:"linear-gradient(135deg, rgba(99,102,241,0.05) 0%, rgba(168,85,247,0.05) 100%)",borderRadius:12,flexWrap:"wrap"}},[{icon:j.A,label:"User Query",color:"#3b82f6",tooltip:"The user asks a question to the chatbot."},{icon:$.A,label:"Embedding",color:"#f59e0b",tooltip:"The query is converted into a vector (array of numbers) using an embedding model."},{icon:z.A,label:"Vector Match",color:"#10b981",tooltip:"The vector is compared against your knowledge base to find similar content."},{icon:G.A,label:"Context",color:"#8b5cf6",tooltip:"Relevant content is retrieved and added to the conversation context."},{icon:W.A,label:"AI Response",color:"#06b6d4",tooltip:"The AI generates a response enriched with the retrieved knowledge."}].map(((e,t,a)=>React.createElement("div",{key:t,style:{display:"flex",alignItems:"center"}},React.createElement(J.f,{text:e.tooltip},React.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:"8px 16px",cursor:"help"}},React.createElement("div",{style:{width:40,height:40,borderRadius:10,background:`${e.color}15`,display:"flex",alignItems:"center",justifyContent:"center"}},React.createElement(e.icon,{size:20,color:e.color})),React.createElement("span",{style:{fontSize:"0.75em",color:"#64748b",fontWeight:500}},e.label))),t<a.length-1&&React.createElement(q.A,{size:16,color:"#cbd5e1",style:{margin:"0 -4px",marginBottom:20}}))))),React.createElement("p",null,React.createElement("b",null,"Create an Environment for Embeddings")," (try Chroma), add content in the ",React.createElement("b",null,"Knowledge")," tab, and use ",React.createElement("b",null,"Query Mode")," to test before enabling in your chatbots. Learn more in the ",React.createElement("a",{href:"https://ai.thehiddendocs.com/knowledge/",target:"_blank",rel:"noreferrer"},"documentation ↗"),"."),React.createElement("p",{style:{marginTop:15}},React.createElement("strong",null,"Default AI Environment")),(e=>{const t=null==v?void 0:v.ai_embeddings_default_env,a=null==v?void 0:v.ai_embeddings_default_model,n=null==v||null===(e=v.ai_envs)||void 0===e?void 0:e.find((e=>e.id===t)),l=t&&a&&Ct.some((e=>e.model===a));return t&&n?a&&l?React.createElement(React.Fragment,null,React.createElement("p",{style:{marginTop:10}},React.createElement("strong",null,oe.A.COMMON.AI_ENVIRONMENT,":")," ",n.name,React.createElement("br",null),React.createElement("strong",null,oe.A.COMMON.EMBEDDINGS_MODEL,":")," ",a,React.createElement("br",null),React.createElement("strong",null,oe.A.COMMON.DIMENSIONS,":")," ",(null==v?void 0:v.ai_embeddings_default_dimensions)||"Auto"),React.createElement("p",{style:{marginTop:8,fontSize:"var(--neko-small-font-size)",color:"var(--neko-gray-60)",lineHeight:"14px"}},"This is currently the default AI environment to create embeddings. You can change it in the ",React.createElement("b",null,"AI")," tab, or override it per environment for embeddings. For Chroma, it uses its internal embedding by default (check the Advanced section).")):React.createElement(Z.X,{variant:"danger",style:{marginTop:10}},React.createElement("strong",null,"Model not configured.")," Environment ",React.createElement("b",null,n.name)," is selected but no valid embeddings model is set. Please go to ",React.createElement("b",null,"AI")," tab → ",React.createElement("b",null,"Default Environments for AI")," → ",React.createElement("b",null,"Embeddings")," and select a model."):React.createElement(Z.X,{variant:"danger",style:{marginTop:10}},React.createElement("strong",null,"Not configured.")," Please go to ",React.createElement("b",null,"AI")," tab → ",React.createElement("b",null,"Default Environments for AI")," → ",React.createElement("b",null,"Embeddings")," and select an environment.")})())),React.createElement(R.z,{className:"primary",title:"Embeddings Search",busy:O},React.createElement(c.d,{title:"Method"},React.createElement(K.u,{scrolldown:!0,value:(null==v||null===(e=v.embeddings_settings)||void 0===e?void 0:e.search_method)||"simple",onChange:e=>Ft({...v.embeddings_settings,search_method:e}),description:(0,f.FE)("<b>Simple:</b> Uses only the last message (default, fastest).<br/><b>Context-Aware:</b> Includes more conversation history for better context.<br/><b>Smart Search:</b> Uses AI to create smarter searches based on full context (uses Default Fast model).")},React.createElement(K.j,{value:"simple",label:"Simple"}),React.createElement(K.j,{value:"context_aware",label:"Context-Aware"}),React.createElement(K.j,{value:"smart_search",label:"Smart Search"}))),("context_aware"===(null==v||null===(t=v.embeddings_settings)||void 0===t?void 0:t.search_method)||"smart_search"===(null==v||null===(a=v.embeddings_settings)||void 0===a?void 0:a.search_method)||"user_messages"===(null==v||null===(n=v.embeddings_settings)||void 0===n?void 0:n.search_method)||"ai_optimized"===(null==v||null===(l=v.embeddings_settings)||void 0===l?void 0:l.search_method))&&React.createElement(c.d,{title:"Messages"},React.createElement(V.A,{type:"number",value:(null==v||null===(r=v.embeddings_settings)||void 0===r?void 0:r.context_messages)||10,min:1,max:20,onFinalChange:e=>Ft({...v.embeddings_settings,context_messages:parseInt(e)||10}),description:"Number of recent messages to consider for context."})),("smart_search"===(null==v||null===(o=v.embeddings_settings)||void 0===o?void 0:o.search_method)||"ai_optimized"===(null==v||null===(i=v.embeddings_settings)||void 0===i?void 0:i.search_method))&&React.createElement(c.d,{title:"Instructions"},React.createElement(m.R,{name:"include_instructions",label:"Enable",value:"1",checked:(null==v||null===(p=v.embeddings_settings)||void 0===p?void 0:p.include_instructions)||!1,onChange:()=>{var e;return Ft({...v.embeddings_settings,include_instructions:!(null!=v&&null!==(e=v.embeddings_settings)&&void 0!==e&&e.include_instructions)})},description:"Include chatbot instructions in the search query to help the AI find more relevant context."})))),"chatbot"===_&&React.createElement(React.Fragment,null,Ye&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.DISCUSSIONS,className:"primary"},Ea,ha,Ra,fa,ya),React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.USER_INTERFACE,className:"primary"},ra)),"orchestration"===_&&React.createElement(R.z,{className:"primary",title:"Information"},React.createElement("p",null,(0,f.FE)(oe.A.SETTINGS.ORCHESTRATION_INFO))),"rest_api"===_&&tt&&React.createElement(R.z,{className:"primary",title:"Available Endpoints"},React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:20}},React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleTextQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleTextQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleTextQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "Write a haiku about AI",\n "options": {\n "scope": "workflow",\n "temperature": 0.7,\n "maxTokens": 150\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Send a text query to AI (with streaming support)"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," or ",React.createElement("code",null,"prompt")," (required): Text input"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleImageQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleImageQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleImageQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "prompt": "A futuristic city at sunset",\n "resolution": "1024x1024",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Generate an image from text prompt"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"prompt")," (required): Image description"),React.createElement("li",null,React.createElement("code",null,"resolution"),' (optional): Image size, e.g., "1024x1024"'),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleChatbotQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleChatbotQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleChatbotQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "botId": "default",\n "message": "Hello, how can you help me?"\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Send a message to a chatbot"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"botId")," (required): Chatbot ID"),React.createElement("li",null,React.createElement("code",null,"message")," (required): User message"),React.createElement("li",null,React.createElement("code",null,"chatId")," (optional): For continuing conversations"),React.createElement("li",null,React.createElement("code",null,"fileIds")," (optional): Array of file IDs for context")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleVisionQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleVisionQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleVisionQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "What is in this image?",\n "url": "https://example.com/image.jpg",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Analyze an image with AI"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," (required): Question about the image"),React.createElement("li",null,React.createElement("code",null,"url")," (required): Image URL to analyze"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleJsonQuery")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleJsonQuery",command:`curl -X POST "${y.gh}/mwai/v1/simpleJsonQuery" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "message": "Generate a user profile",\n "schema": {"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "number"}}},\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Get structured JSON response from AI"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"message")," (required): Your prompt"),React.createElement("li",null,React.createElement("code",null,"schema")," (optional): JSON schema for response structure"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/simpleTranscribeAudio")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"simpleTranscribeAudio",command:`curl -X POST "${y.gh}/mwai/v1/simpleTranscribeAudio" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "url": "https://example.com/audio.mp3",\n "options": {\n "scope": "workflow"\n }\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Transcribe audio to text"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"url")," or ",React.createElement("code",null,"mediaId")," (required): Audio file URL or WordPress media ID"),React.createElement("li",null,React.createElement("code",null,"options")," (optional): JSON object with settings (see Options section above)")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#2196F3",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"POST"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/moderationCheck")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"moderationCheck",command:`curl -X POST "${y.gh}/mwai/v1/moderationCheck" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}" \\\n -H "Content-Type: application/json" \\\n -d '{\n "text": "Your text to moderate"\n }'`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Check content for policy violations"),React.createElement("div",{style:{marginTop:10}},React.createElement("strong",{style:{fontSize:13}},"Parameters:"),React.createElement("ul",{style:{marginLeft:20,marginTop:5,fontSize:13}},React.createElement("li",null,React.createElement("code",null,"text")," (required): Text to moderate")))),React.createElement("div",{style:{padding:15,border:"1px solid #ddd",borderRadius:8,background:"#f8f8f8"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},React.createElement("span",{style:{padding:"2px 8px",backgroundColor:"#4CAF50",color:"white",borderRadius:4,fontSize:12,fontWeight:600}},"GET"),React.createElement("code",{style:{fontSize:14}},"/mwai/v1/listChatbots")),React.createElement(h.M,{size:"small",className:"secondary",icon:"zap",onClick:()=>x({isOpen:!0,title:"listChatbots",command:`curl -X GET "${y.gh}/mwai/v1/listChatbots" \\\n -H "Authorization: Bearer ${(null==v?void 0:v.public_api_bearer_token)||"YOUR_TOKEN"}"`}),title:"Show cURL command"},"cURL")),React.createElement("p",{style:{margin:"8px 0",color:"#666",fontSize:13}},"Get list of all available chatbots")))),"files"===_&&React.createElement(R.z,{busy:Mt,title:"Generated by AI",subtitle:"Manage how AI-generated files are stored and handled",className:"primary"},La,null!==(null==v?void 0:v.image_local_download)&&Da),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.ADVANCED,className:"primary"},Ua,Ba,Fa,un),"others"===_&&React.createElement(R.z,{busy:Mt,title:"Languages",className:"primary"},Qa),"others"===_&&React.createElement(R.z,{busy:Mt,title:oe.A.COMMON.SECURITY,className:"primary"},pa,Ha,(null==ut?void 0:ut.length)>0&&ja,Xa)))),"addons"===_&&React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingRight:10,marginTop:-20}},React.createElement(si,{addons:null==v?void 0:v.addons,updateOption:Dt})),"assistants"===_&&me&&React.createElement(g.Y,{minimal:!0,fullWidth:!0,style:{paddingLeft:10,paddingRight:10,marginTop:-20}},React.createElement(s.s,{h2:!0,style:{color:"white"}},oe.A.COMMON.ASSISTANTS),React.createElement(Do,{options:v,refreshOptions:Lt})))),ge&&React.createElement(E.V,{key:"devtools",title:oe.A.COMMON.DEV_TOOLS},React.createElement(ro,{options:v,setOptions:b,updateOption:Dt,busy:Mt})),React.createElement(E.V,{key:"license",title:k?`⚠️ ${oe.A.COMMON.LICENSE_TAB}`:oe.A.COMMON.LICENSE_TAB},React.createElement(re,{domain:y.bl,prefix:y.Pl,isPro:y.am,isRegistered:y.zN}))))),React.createElement(ee.n,{isOpen:C,title:oe.A.COMMON.ERROR,content:C,onRequestClose:()=>A(!1),okButton:{label:"Close",onClick:()=>A(!1)}}),React.createElement(ee.n,{isOpen:M.isOpen,title:`cURL: ${M.title}`,onRequestClose:()=>x({isOpen:!1,command:"",title:""}),cancelButton:{label:"Close",onClick:()=>x({isOpen:!1,command:"",title:""})}},React.createElement("div",null,React.createElement("pre",{style:{background:"#f5f5f5",padding:15,borderRadius:4,overflow:"auto",fontSize:12,margin:0,border:"1px solid #ddd",whiteSpace:"pre-wrap",wordBreak:"break-all",marginBottom:15}},M.command),React.createElement(h.M,{fullWidth:!0,className:"primary",icon:"duplicate",onClick:()=>{navigator.clipboard.writeText(M.command),x({isOpen:!1,command:"",title:""})}},"Copy to Clipboard"))))};var Ri=a(6087);const fi=[{value:"informative",label:oe.A.WRITING_STYLES.INFORMATIVE},{value:"descriptive",label:oe.A.WRITING_STYLES.DESCRIPTIVE},{value:"creative",label:oe.A.WRITING_STYLES.CREATIVE},{value:"narrative",label:oe.A.WRITING_STYLES.NARRATIVE},{value:"persuasive",label:oe.A.WRITING_STYLES.PERSUASIVE},{value:"reflective",label:oe.A.WRITING_STYLES.REFLECTIVE},{value:"argumentative",label:oe.A.WRITING_STYLES.ARGUMENTATIVE},{value:"analytical",label:oe.A.WRITING_STYLES.ANALYTICAL},{value:"evaluative",label:oe.A.WRITING_STYLES.EVALUATIVE},{value:"journalistic",label:oe.A.WRITING_STYLES.JOURNALISTIC},{value:"technical",label:oe.A.WRITING_STYLES.TECHNICAL}],yi=[{value:"neutral",label:oe.A.WRITING_TONES.NEUTRAL},{value:"formal",label:oe.A.WRITING_TONES.FORMAL},{value:"assertive",label:oe.A.WRITING_TONES.ASSERTIVE},{value:"cheerful",label:oe.A.WRITING_TONES.CHEERFUL},{value:"humorous",label:oe.A.WRITING_TONES.HUMOROUS},{value:"informal",label:oe.A.WRITING_TONES.INFORMAL},{value:"inspirational",label:oe.A.WRITING_TONES.INSPIRATIONAL},{value:"professional",label:oe.A.WRITING_TONES.PROFESSIONAL},{value:"confluent",label:oe.A.WRITING_TONES.CONFLUENT},{value:"emotional",label:oe.A.WRITING_TONES.EMOTIONAL},{value:"persuasive",label:oe.A.WRITING_TONES.PERSUASIVE},{value:"supportive",label:oe.A.WRITING_TONES.SUPPORTIVE},{value:"sarcastic",label:oe.A.WRITING_TONES.SARCASTIC},{value:"condescending",label:oe.A.WRITING_TONES.CONDESCENDING},{value:"skeptical",label:oe.A.WRITING_TONES.SKEPTICAL},{value:"narrative",label:oe.A.WRITING_TONES.NARRATIVE},{value:"journalistic",label:oe.A.WRITING_TONES.JOURNALISTIC}],vi="",bi="Write a title for an article in {LANGUAGE}. Must be between 40 and 60 characters. Write naturally as a human would. Output only the title, no formatting, no Markdown, no special characters.\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nGenerate a title based on the topic above, taking into account the provided context.",wi='Write {SECTIONS_COUNT} consecutive headings for an article about "{TITLE}", in {LANGUAGE}. Each heading is between 40 and 60 characters. Format each heading with Markdown (## ). Write naturally as a human would. Output only the headings, nothing else.\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nCreate headings that align with both the topic and context provided above.',_i='Write an article about "{TITLE}" in {LANGUAGE}. Write {PARAGRAPHS_PER_SECTION} paragraphs per heading. Use Markdown for formatting. Add an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ". Write naturally as a human would.\n\n### ARTICLE STRUCTURE:\n{SECTIONS}\n\n### TOPIC DETAILS:\n{TOPIC}\n\n### WRITING CONTEXT:\n{CONTEXT}\n\nWrite the article following the structure above, incorporating the topic details while adhering to the context guidelines.',Ti='Write an excerpt for an article in {LANGUAGE}. Must be between 40 and 60 characters. Write naturally as a human would. Output only the excerpt, no formatting.\n\n### ARTICLE TITLE:\n"{TITLE}"\n\n### TOPIC:\n{TOPIC}\n\n### CONTEXT:\n{CONTEXT}\n\nCreate a compelling excerpt that captures the essence of the article while considering the context.',Ci=[{id:"default",name:"Default Template",mode:"query",model:vi,envId:"",temperature:.8,stopSequence:"",maxTokens:2048,prompt:""},{id:"article_translator",name:"Text Translator",mode:"query",model:vi,envId:"",temperature:.3,stopSequence:"",maxTokens:2048,prompt:"Translate this article into French:\n\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n"},{id:"restaurant_review",name:"Restaurant Review Writer",mode:"query",model:vi,envId:"",temperature:.8,stopSequence:"",maxTokens:2048,prompt:"Write a review for a French restaurant located in Kagurazaka, Tokyo. Looks like an old restaurant, food is traditional, chef is talkative, it is always full. Not expensive, but not fancy.\n"},{id:"article_corrector",name:"Text Corrector",mode:"query",model:vi,envId:"",temperature:.2,stopSequence:"",maxTokens:2048,prompt:"Fix the grammar and spelling mistakes in this text:\n\nI wake up at eleben yesderday, I will go bed eary tonigt.\n"},{id:"seo_assistant",name:"SEO Optimizer",mode:"query",model:vi,envId:"",temperature:.6,stopSequence:"",maxTokens:1024,prompt:"For the following article, write a SEO-friendly and short title, keywords for Google, and a short excerpt to introduce it. Use this format:\n\nTitle: \nKeywords: \nExcerpt:\n\nArticle:\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town."}],Ai=[{id:"default",name:"Default Template",model:"",envId:"",resolution:"",maxResults:1,prompt:""},{id:"cyberpunk_shibuya",name:"Cyberpunk Shibuya, 2099",model:"",envId:"",resolution:"",maxResults:1,prompt:"A rainy night in Shibuya Crossing in the year 2099, filled with glowing holographic kanji, umbrellas reflecting neon lights, and humanoid robots blending in with humans under the city glow. (Style: cinematic realism, rain-soaked atmosphere, high contrast)"},{id:"tranquil_koi",name:"Tranquil Koi Dream",model:"",envId:"",resolution:"",maxResults:1,prompt:"A surreal composition of a floating temple garden above a pond of flying koi fish, each one carrying tiny lanterns illuminating soft fog. (Style: ethereal watercolor painting, soft color palette, dreamlike)"},{id:"tokyo_apartment",name:"Old Tokyo Apartment Spirit",model:"",envId:"",resolution:"",maxResults:1,prompt:"A nostalgic 1960s Tokyo apartment room filled with plants, tatami mats, and warm afternoon light — but with subtle ghostly figures appearing through the shoji doors. (Style: realistic photo with supernatural touch, muted colors, film grain)"}],Ii=[{id:"default",name:"Default Template",mode:"single",topic:"",topics:"",context:"",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.8,maxTokens:2048,sectionsCount:2,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"creative",writingTone:"cheerful",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti},{id:"explore_tokyo_offbeat",name:"Explore Tokyo Offbeat",mode:"single",topic:"5 hidden Tokyo neighborhoods only locals know: retro Showa-era streets, authentic Edo atmosphere, family-run restaurant alleys, old shopping arcades, quiet residential gems. Write in first person as a Tokyo local sharing secret spots.",topics:"",context:"",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.8,maxTokens:2048,sectionsCount:5,paragraphsCount:2,language:"en",customLanguage:"",writingStyle:"informative",writingTone:"informal",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti},{id:"cat_blog_bulk",name:"Cat Blog Bulk Generator",mode:"bulk",topic:"",topics:"Why Cats Make Perfect Companions\nUnderstanding Cat Body Language\nThe Science Behind Purring\nIndoor vs Outdoor Cats Debate\nBest Cat Breeds for Families\nCat Nutrition Guide\nTraining Your Cat: Tips and Tricks\nCommon Cat Health Issues",context:"Context: This is for a cat enthusiast blog targeting pet owners and cat lovers. The tone should be friendly, informative, and occasionally playful. Include practical tips, scientific facts, and real-world advice. Each article should be engaging and helpful for cat parents at all experience levels.",topicsAreTitles:!1,title:"",sections:"",model:vi,envId:"",temperature:.7,maxTokens:2048,sectionsCount:4,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"informative",writingTone:"cheerful",titlePromptFormat:bi,sectionsPromptFormat:wi,contentPromptFormat:_i,excerptPromptFormat:Ti}],Ni=[{id:"default",name:"Default Template",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:""},{id:"last_train",name:"The Last Train to Kyoto",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:"A 30-second cinematic sequence following the final train leaving Tokyo Station at night — empty city, soft piano music, lights flickering through the window, and a mysterious letter left on the seat. (Mood: melancholic, poetic, cinematic lighting)"},{id:"festival_foxes",name:"Festival of Foxes",model:"sora-2",envId:"",resolution:"1280x720",duration:4,prompt:"A short looping video of a nighttime matsuri in the mountains, where everyone wears fox masks. The camera glides through paper lanterns, taiko drums, and dancers, as the masks begin to subtly move on their own. (Mood: magical realism, glowing reds and golds, hypnotic rhythm)"},{id:"rising_tokyo",name:"Rising Tokyo",model:"sora-2",envId:"",resolution:"1280x720",duration:8,prompt:"A timelapse of Tokyo transforming from the Edo period to the futuristic skyline — wooden houses morphing into skyscrapers, rickshaws turning into maglev trains, Mt. Fuji remaining constant in the distance. (Mood: epic evolution, orchestral build-up, history blending with sci-fi)"}],{useState:Oi,useEffect:Si,useMemo:Mi}=wp.element;function xi(){return(new Date).getTime().toString(36)+Math.random().toString(36).substr(2,9)}const ki="mwai_last_template_",Pi=e=>{const t=[...e];return t.sort(((e,t)=>{if("default"===e.id)return-1;if("default"===t.id)return 1;const a=e.name||"",n=t.name||"";return a.localeCompare(n)})),t},Li=(e="playground")=>{const[t,a]=Oi(),[n,l]=Oi(!1),[r,i]=Oi([]),{isLoading:s,data:c}=(0,o.I)({queryKey:[`templates-${e}`],queryFn:()=>(async e=>{try{const t=await(0,f.IU)(`${y.y0}/system/templates?category=${e}`,{nonce:y.ok});let a=[];"imagesGenerator"===e?a=Ai:"videosGenerator"===e?a=Ni:"playground"===e?a=Ci:"contentGenerator"===e&&(a=Ii);const n=a.find((e=>"default"===e.id));return null!=t&&t.templates&&t.templates.length>0&&(a=Pi(t.templates)),n?a.forEach((e=>{Object.keys(n).forEach((t=>{void 0===e[t]&&(e[t]=n[t])}))})):console.warn("Default template not found for category: "+e),a}catch(e){console.error(e),alert(e.message)}})(e)});Si((()=>{for(let t=0;t<r.length;t++){const a=r[t];let n=!1;if(a&&(null===a.envId||void 0===a.envId||null===a.model||void 0===a.model)){const t=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_env)||null;let l=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_model)||null;"imagesGenerator"===e&&(l="dall-e-3-hd"),"videosGenerator"===e&&(l="sora-2"),t&&l&&(a.envId=t,a.model=l,n=!0)}n&&i([...r])}}),[r]),Si((()=>{if(c){i(c);const t=(e=>{try{const t=`${ki}${e}`,a=localStorage.getItem(t);if(!a)return null;const n=JSON.parse(a);return Date.now()-n.timestamp>2592e6?(localStorage.removeItem(t),null):n.templateId}catch(e){return console.warn("Failed to load template preference:",e),null}})(e);let n=null;if(t&&(n=c.find((e=>e.id===t))),!n){n=c.find((e=>"default"===e.id))||c[0]}a(n)}}),[c,e]);const d=async t=>{t=Pi(t),i(t);try{return await(0,f.IU)(`${y.y0}/system/templates`,{method:"POST",nonce:y.ok,json:{category:e,templates:t}})}catch(e){console.error(e),alert(e.message)}},m=Mi((()=>{if(!t||0===r.length)return!1;const e=r.find((e=>e.id===t.id));return!!e&&(Object.keys(t).length!==Object.keys(e).length||Object.keys(e).some((a=>e[a]!==t[a])))}),[t,r]),u=t=>{a(t),t&&t.id&&((e,t)=>{try{const a=`${ki}${e}`,n={templateId:t,timestamp:Date.now()};localStorage.setItem(a,JSON.stringify(n))}catch(e){console.warn("Failed to save template preference:",e)}})(e,t.id)},p=()=>{const e=r.find((e=>e.id===t.id));e&&u({...e})},g=()=>{const e=prompt(oe.A.COMMON.NAME,t.name||oe.A.TEMPLATES.NEW_TEMPLATE_NAME);if(!e)return!1;const a={...t,id:xi(),name:e};d([...r,a]),u({...a})},E=()=>{const e=r.map((e=>e.id===t.id?t:e));d(e),u({...t})},R=()=>{const e=prompt("Template Name",t.name);if(!e)return;const a={...r[0],id:xi(),name:e};d([...r,a]),u({...a})},v=()=>{const e=prompt("Template Name",t.name);if(!e)return;const a=r.map((a=>a.id===t.id?{...a,name:e}:a));d([...a]),u({...a.find((e=>e.id===t.id))})},b=()=>{if(!confirm(oe.A.TEMPLATES.DELETE_ALL_CONFIRM))return;let t=[];"imagesGenerator"===e?t=[...Ai]:"videosGenerator"===e?t=[...Ni]:"playground"===e?t=[...Ci]:"contentGenerator"===e&&(t=[...Ii]),d(t),u({...t[0]})},w=Mi((()=>m&&!!t),[m,t]),_=Mi((()=>t&&"default"!==t.id),[t]),T=Mi((()=>t&&"default"!==t.id),[t]),C=Mi((()=>React.createElement("div",{style:{margin:"0"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"}},React.createElement("h3",{style:{margin:0,fontSize:"14px",fontWeight:600}},oe.A.TEMPLATES.TEMPLATE),React.createElement(We.S,{small:!0,onLabel:oe.A.TEMPLATES.EDIT,offLabel:oe.A.TEMPLATES.EDIT,width:60,onChange:l,checked:n})),s&&React.createElement("div",{style:{display:"flex",marginTop:30,justifyContent:"center"}},React.createElement(Ri.X,{type:"icon",size:"24px",color:"#2271b1"})),!s&&React.createElement(React.Fragment,null,React.createElement(K.u,{scrolldown:!0,name:"template",value:null==t?void 0:t.id,onChange:e=>{const t=r.find((t=>t.id===e));u({...t})}},r.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),m&&React.createElement("div",{style:{display:"flex",gap:"4px",marginTop:"8px"}},React.createElement(h.M,{className:"secondary",style:{flex:1},icon:"undo",disabled:!w,onClick:p},"Undo"),React.createElement(h.M,{className:"primary",style:{flex:1},icon:"save",disabled:!w,onClick:E},"Save")),n&&React.createElement("div",{style:{marginTop:"8px"}},React.createElement("div",{style:{display:"flex",gap:"4px",justifyContent:"center"}},React.createElement(h.M,{className:"primary",rounded:!0,icon:"plus",onClick:R}),React.createElement(h.M,{className:"primary",rounded:!0,icon:"duplicate",onClick:g}),React.createElement("div",{style:{width:"12px"}}),React.createElement(h.M,{className:"secondary",rounded:!0,icon:"rename",disabled:!_,onClick:v}),React.createElement(h.M,{className:"danger",rounded:!0,icon:"delete",disabled:!T,onClick:()=>(e=>{if(!confirm(oe.A.TEMPLATES.DELETE_CONFIRM))return;const t=r.filter((t=>t.id!==e.id));d([...t]),u({...t[0]})})(t)})))),n&&React.createElement("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid #e0e0e0"}},React.createElement(h.M,{className:"danger",small:!0,style:{width:"100%"},onClick:b},"Reset All Templates")))),[r,t,n,m,w,s]);return{template:t,templates:r,clearTemplate:p,setTemplate:u,jsxTemplates:C,isEdit:n}},{useState:Di,useMemo:Fi}=wp.element,Ui=e=>{const[t,a]=Di(0),[n,l]=Di(0),r=()=>{a(0),l(0)};return{addUsage:(n,r,o)=>{const i=e(n,r,o);l(i),a(t+i)},jsxUsageCosts:Fi((()=>{let e=(0,f.FE)(oe.A.COMMON.USAGE_HELP);if(!y.zN){const t=Oe(oe.A.COMMON.USAGE_PRO_HELP,oe.A.COMMON.USAGE_PRO_HELP_URL,oe.A.COMMON.USAGE_PRO_HELP_LINK_TEXT);e=React.createElement(React.Fragment,null,e," ",t)}return React.createElement(React.Fragment,null,React.createElement("div",null,oe.A.COMMON.SESSION,": ",React.createElement("span",{style:{float:"right"}},"$",t.toFixed(4))),React.createElement("div",null,oe.A.COMMON.LAST_REQUEST,": ",React.createElement("span",{style:{float:"right"}},"$",n.toFixed(4))),React.createElement(Y.g,{height:15}),React.createElement("p",{style:{fontSize:11,lineHeight:1.4,opacity:.6,margin:0}},e),React.createElement(Y.g,{height:15}),React.createElement(h.M,{fullWidth:!0,onClick:r},oe.A.COMMON.RESET_USAGE))}),[t,n])}},{useState:Bi,useEffect:Hi,useRef:ji}=wp.element,$i=(0,b.Ay)($e.m)` 552 552 .neko-textarea-container { 553 553 … … 578 578 color: white; 579 579 } 580 `,{useState:qi,useEffect:Ki,useMemo:Vi}=wp.element,Yi=e=>{const{post:t,onTitleClick:a={},onClose:n={}}=e,[l,r]=qi([]),[o,i]=qi(!1),[s,c]=qi(!1);Ki((()=>{t&&d(t)}),[t]);const d=async({postId:e,postTitle:t})=>{i(!0);try{var a;const t=await(0,f.IU)(`${y.y0}/ai/magic_wand`,{method:"POST",nonce:y.ok,json:{action:"suggestTitles",data:{postId:e}}});r(null===(a=t.data)||void 0===a?void 0:a.results)}catch(e){console.error(e),c(e.message)}i(!1)},m=async()=>{n(),r([]),c(),i(!1)},u=Vi((()=>o?React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px"}},React.createElement(Ri.X,{type:"icon",size:"32px",color:"#2271b1"})):s?React.createElement(React.Fragment,null,"Error: ",s):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(Gi,null,l.map((e=>React.createElement(Wi,{key:e,onClick:()=>{(async e=>{i(!0);try{await a(e),m()}catch(e){c(e.message)}i(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,s]),p=Vi((()=>{const e=[];return e.push({label:"Close",onClick:m}),!o&&(null==l?void 0:l.length)>0&&e.push({label:"Try Again",onClick:()=>d(t),variant:"primary"}),e}),[o,l,t]);return React.createElement(g.N,null,React.createElement(ee.n,{isOpen:t,onRequestClose:m,title:`New title for "${null==t?void 0:t.postTitle}"`,content:u,okButton:p[0],cancelButton:p[1]}))},{useState:Xi,useEffect:Qi,useMemo:Ji}=wp.element,Zi=e=>{const{post:t,onExcerptClick:a={},onClose:n={}}=e,[l,r]=Xi([]),[o,i]=Xi(!1),[s,c]=Xi(!1);Qi((()=>{t&&d(t)}),[t]);const d=async({postId:e})=>{i(!0);try{var t;const a=await(0,f.IU)(`${y.y0}/ai/magic_wand`,{method:"POST",nonce:y.ok,json:{action:"suggestExcerpts",data:{postId:e}}});r(null===(t=a.data)||void 0===t?void 0:t.results)}catch(e){console.error(e),c(e.message)}i(!1)},m=async()=>{n(),r([]),c(),i(!1)},u=Ji((()=>o?React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px"}},React.createElement(Ri.X,{type:"icon",size:"32px",color:"#2271b1"})):s?React.createElement(React.Fragment,null,"Error: ",s):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(Gi,null,l.map((e=>React.createElement(Wi,{key:e,onClick:()=>{(async e=>{i(!0);try{await a(e),m()}catch(e){c(e.message)}i(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,s]),p=Ji((()=>{const e=[];return e.push({label:"Close",onClick:m}),!o&&(null==l?void 0:l.length)>0&&e.push({label:"Try Again",onClick:()=>d(t),variant:"primary"}),e}),[o,l,t]);return React.createElement(g.N,null,React.createElement(ee.n,{isOpen:t,onRequestClose:m,title:`New excerpt for "${null==t?void 0:t.postTitle}"`,content:u,okButton:p[0],cancelButton:p[1]}))},{useState:es,useEffect:ts}=wp.element,as=()=>{const[e,t]=es();ts((()=>{setTimeout((()=>{document.querySelectorAll(".mwai-magic-wand-action").forEach((e=>{const t=e.querySelector(".mwai-magic-wand-trigger"),a=e.querySelector(".mwai-magic-wand-dropdown");let n;e.addEventListener("mouseenter",(()=>{clearTimeout(n),a.style.display="block"})),e.addEventListener("mouseleave",(()=>{n=setTimeout((()=>{a.style.display="none"}),200)})),t.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation()}))})),document.addEventListener("click",(e=>{if(e.target.closest(".mwai-link-title")){e.preventDefault(),e.stopPropagation();const a=e.target.closest(".mwai-link-title"),n=a.getAttribute("data-id"),l=a.getAttribute("data-title");console.log("Title click:",n,l),t({postId:n,postTitle:l,mode:"title"})}if(e.target.closest(".mwai-link-excerpt")){e.preventDefault(),e.stopPropagation();const a=e.target.closest(".mwai-link-excerpt"),n=a.getAttribute("data-id"),l=a.getAttribute("data-title");console.log("Excerpt click:",n,l),t({postId:n,postTitle:l,mode:"excerpt"})}}))}),100)}),[]);return React.createElement(r.A,null,React.createElement(g.N,null,React.createElement(Yi,{post:"title"===(null==e?void 0:e.mode)?e:null,onTitleClick:async a=>{const n=await(0,f.IU)(`${y.y0}/helpers/update_post_title`,{method:"POST",nonce:y.ok,json:{postId:e.postId,title:a}});if(!n.success)throw new Error(n.message);{t();const n=document.querySelector(`tr[id="post-${e.postId}"]`);if(n){const e=n.querySelector(".row-title");e&&(e.innerHTML=a)}const l=n.querySelector(".hidden .post_title");l&&(l.innerHTML=a)}},onClose:()=>{t()}}),React.createElement(Zi,{post:"excerpt"===(null==e?void 0:e.mode)?e:null,onExcerptClick:async a=>{const n=await(0,f.IU)(`${y.y0}/helpers/update_post_excerpt`,{method:"POST",nonce:y.ok,json:{postId:e.postId,excerpt:a}});if(!n.success)throw new Error(n.message);t()},onClose:()=>{t()}})))},{useState:ns,useEffect:ls,useMemo:rs,useRef:os}=wp.element,is=()=>{const[e,t]=ns(""),[a,n]=ns(""),{template:l,setTemplate:r,clearTemplate:i,jsxTemplates:c}=Li("contentGenerator"),d=(0,Xe.XS)(),[p,E]=ns(!1),[R,v]=ns(),[b,w]=ns(!1),[_,T]=ns(!1),[C,A]=ns(!1),[I,N]=ns(!1),[O,S]=ns(),[M,x]=ns("post"),[k,P]=ns([]),[L,D]=ns([]),[F,U]=ns({}),B=os(),{isLoading:H,data:j}=(0,o.I)({queryKey:["postTypes"],queryFn:Je}),$=d.busy||p,z=(null==l?void 0:l.title)??"",G=(null==l?void 0:l.sections)??"",W=(null==l?void 0:l.mode)??"single",q=(null==l?void 0:l.topic)??"",J=(null==l?void 0:l.topics)??"",Z=(null==l?void 0:l.context)??"",te=(null==l?void 0:l.model)??(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_model)??null,ae=(null==l?void 0:l.sectionsCount)??2,ne=(null==l?void 0:l.paragraphsCount)??3,le=(null==l?void 0:l.writingStyle)??"creative",re=(null==l?void 0:l.writingTone)??"cheerful",ie=(null==l?void 0:l.titlePromptFormat)??"",me=(null==l?void 0:l.sectionsPromptFormat)??"",ue=(null==l?void 0:l.contentPromptFormat)??"",pe=(null==l?void 0:l.excerptPromptFormat)??"",ge=(null==l?void 0:l.envId)??"",Re=(null==l?void 0:l.temperature)??.6,fe=(null==l||l.maxTokens,(null==l?void 0:l.topicsAreTitles)??!1),ye=!me||!ae,{completionModels:ve,calculatePrice:be}=(null==l||l.useMaxTokens,he(y.fF,ge||null)),{addUsage:we,jsxUsageCosts:_e}=Ui(be),Te=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_envs)||[],{jsxLanguageSelector:Ce,currentLanguage:Ae,isCustom:Ie,currentHumanLanguage:Ne}=(({disabled:e,options:t,language:a})=>{const[n,l]=ce(a??"en"),r=(null==t?void 0:t.languages)||[],o=se((()=>Object.keys(r).map((e=>({value:e,label:r[e]})))),[r]);de((()=>{l(a)}),[a]),de((()=>{const e=localStorage.getItem("mwai_preferred_language");if(e&&o.find((t=>t.value===e)))return void l(e);const t=(document.querySelector("html").lang||navigator.language||navigator.userLanguage).substr(0,2);o.find((e=>e.value===t))&&l(t)}),[]);const i=se((()=>{const e=o.find((e=>e.value===n));return e?e.label:(console.warn("A system language should be set."),"English")}),[n,o]),s=(e,t)=>{l(e,t),localStorage.setItem("mwai_preferred_language",e)};return{jsxLanguageSelector:se((()=>React.createElement(K.u,{scrolldown:!0,name:"language",disabled:e,description:(0,f.FE)(oe.A.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:n,onChange:s},o.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),[n,i,o]),currentLanguage:n,currentHumanLanguage:i}})({options:y.fF,language:null==l?void 0:l.language,customLanguage:null==l?void 0:l.customLanguage}),Oe=rs((()=>(e=>{if(!e)return null;const t=e.split(" ").length,a=e.length,n=[];return a?(t<3?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_SHORT):t>8?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_LONG):a<40?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_SHORT):a>70&&n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_LONG_2),n.join(" ")):void 0})(z)),[z]),Se=(e,t)=>{r((a=>{const n={...a,[t]:e};return"envId"===t&&""===e&&(n.model=""),n}))};ls((()=>{const e=J.split("\n").map((e=>e.trim())).filter((e=>!!e));P(e)}),[J]),ls((()=>{l&&Se("","sections")}),[z,ae]),ls((()=>{t(""),n(""),S()}),[G,ne]),ls((()=>{l&&(!Ie&&l.customLanguage&&Se(null,"customLanguage"),Ie&&l.customLanguage!==Ne&&Se(Ne,"customLanguage"),l.language!==Ae&&Se(Ae,"language"))}),[Ie,Ae,Ne]);const Me=(e,t=Z)=>{let a="";return t&&t.trim()?a=t:e=(e=e.replace(/### CONTEXT:[\s\S]*?(?=(###|Write|Create|Generate)|$)/g,"").trim()).replace(/### WRITING CONTEXT:[\s\S]*?(?=(###|Write|Create|Generate)|$)/g,"").trim(),e.replace("{LANGUAGE}",Ne).replace("{WRITING_STYLE}",le).replace("{WRITING_TONE}",re).replace("{PARAGRAPHS_PER_SECTION}",ne).replace("{SECTIONS_COUNT}",ae).replace("{CONTEXT}",a)},xe=rs((()=>{const e=(e,t)=>!!t.find((t=>t.includes(e))),t=[ie,me,ue,pe];return{language:e("{LANGUAGE}",t),writingStyle:e("{WRITING_STYLE}",t),writingTone:e("{WRITING_TONE}",t),sectionsCount:e("{SECTIONS_COUNT}",t),paragraphsCount:e("{PARAGRAPHS_PER_SECTION}",t),context:e("{CONTEXT}",t)}}),[ie,me,ue,pe,ae,ne]),ke=async(e,t=!1)=>{B.current||(B.current=new AbortController);try{var a,n;const t={scope:"admin-tools",envId:ge||null,model:te||null,session:y.dZ,message:e,temperature:Re},l=await(0,f.IU)(`${y.y0}/ai/completions`,{method:"POST",nonce:y.ok,signal:B.current.signal,json:t});we(te,(null==l||null===(a=l.usage)||void 0===a?void 0:a.prompt_tokens)||0,(null==l||null===(n=l.usage)||void 0===n?void 0:n.completion_tokens)||0);let r=l.data.trim();return r.startsWith('"')&&r.endsWith('"')&&(r=r.substring(1,r.length-1)),r}catch(e){if(t)throw new Error(e.message);return"AbortError"!==e.name&&(console.error(e),v(e.message)),null}},Pe=async(e=q,t=z,a=!1)=>{if(!t)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);E(!0),U({...F,sections:new Date}),Se("","sections");let n=me.replace("{TITLE}",t).replace("{TOPIC}",e);n=Me(n);let l=await ke(n,a);var r;return l=(r=l)?r.split("\n").map((e=>((e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e))).filter((e=>e)).join("\n"):r,l&&Se(l,"sections"),E(!1),U({...F,sections:null}),l},Le=async(e=q,a=z,n=G,l=!1)=>{if(!a)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);if(!ye&&!n)return void alert(oe.A.CONTENT_GENERATOR.SECTIONS_MISSING);E(!0),U({...F,content:new Date}),t((()=>""));let r=ue.replace("{TITLE}",a).replace("{SECTIONS}",n).replace("{TOPIC}",e);r=Me(r);let o=await ke(r,l);return o&&(o=o.replace(/^===INTRO:\n/,"").replace(/^===INTRO: \n/,"").replace(/===INTRO: /,"").replace(/===OUTRO:\n/,"").replace(/===OUTRO: \n/,"").replace(/===OUTRO: /,""),t((()=>o))),E(!1),U({...F,content:null}),o},De=async(e=q,t=z,a=!1)=>{if(!t)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);E(!0),U({...F,excerpt:new Date}),n((()=>""));let l=pe.replace("{TITLE}",t).replace("{TOPIC}",e);l=Me(l);const r=await ke(l,a);return r&&n((()=>r)),E(!1),U({...F,excerpt:null}),r},Be=async(e=q,t=!1)=>{E(!0),B.current=new AbortController,U({...F,all:new Date});try{let a=e;if(!fe||!t){const n=Me(ie.replace("{TOPIC}",e));a=await ke(n,t)}let n=null,l=null,r=null;return E(!1),a&&(Se(a,"title"),ye||(U((e=>({...e,sections:new Date}))),n=await Pe(e,a,t),U((e=>({...e,sections:null})))),(n||ye)&&(U((e=>({...e,content:new Date}))),l=await Le(e,a,n,t),U((e=>({...e,content:null}))),l&&(U((e=>({...e,excerpt:new Date}))),r=await De(e,a,t),U((e=>({...e,excerpt:null})))))),{title:a,heads:n,content:l,excerpt:r}}catch(e){throw console.error(e),E(!1),U({}),e}},He=async(t=z,n=e,l=a,r=!1)=>{E(!0),B.current=new AbortController;try{const e=await(0,f.IU)(`${y.y0}/helpers/create_post`,{method:"POST",nonce:y.ok,signal:B.current.signal,json:{title:t,content:n,excerpt:l,postType:M}});return r||S(e.postId),e.postId}catch(e){return"AbortError"!==e.name&&(console.error(e),v(e.message)),null}finally{E(!1)}};return React.createElement(u.z,{nekoErrors:[]},React.createElement(Fe,{title:oe.A.COMMON.CONTENT_GENERATOR}),React.createElement(g.N,null,React.createElement(Ee,{options:y.fF}),(null===y.fF||void 0===y.fF?void 0:y.fF.intro_message)&&React.createElement(g.Y,{fullWidth:!0},React.createElement(X.L,{style:{marginBottom:0}},React.createElement(s.s,{p:!0},(0,f.FE)(oe.A.CONTENT_GENERATOR.INTRO)))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,c),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},"bulk"===W?oe.A.COMMON.CONTEXT||"Context":oe.A.COMMON.TOPIC),"bulk"===W?React.createElement(React.Fragment,null,React.createElement("p",{style:{marginTop:0,marginBottom:10,fontSize:12,opacity:.6}},"Provide context that will be used for all generated posts to make them more accurate and relevant."),React.createElement($e.m,{name:"context",disabled:$||H,rows:14,value:Z,onChange:Se,placeholder:"Example: This is for a cat enthusiast blog targeting pet owners and cat lovers. The tone should be friendly, informative, and occasionally playful. Include practical tips and scientific facts when relevant."})):React.createElement($e.m,{name:"topic",disabled:$||H,rows:16,value:q,onChange:Se,placeholder:"Example: Write a comprehensive guide about adopting a rescue cat, covering the adoption process, preparing your home, first days together, and tips for helping the cat adjust to their new environment. Include advice for families with children or other pets."}),React.createElement(Y.g,null),React.createElement(h.M,{fullWidth:!0,ai:!0,disabled:!q||"bulk"===W||H,busy:$,onClick:()=>Be(),onStopClick:()=>{var e;null===(e=B.current)||void 0===e||e.abort(),E(!1),U({})},startTime:null==F?void 0:F.all,style:{height:50,fontSize:16,flex:4}},oe.A.COMMON.GENERATE))),React.createElement(g.Y,{style:{flex:2}},React.createElement(Q.o,{name:"mode",value:W,disabled:$,onChange:Se},React.createElement(Q.K,{title:oe.A.CONTENT_GENERATOR.SINGLE_GENERATE,value:"single"}),React.createElement(Q.K,{title:oe.A.CONTENT_GENERATOR.BULK_GENERATE,value:"bulk",count:k.length})),React.createElement(Y.g,null),"bulk"===W&&React.createElement(Na,null,React.createElement("p",{style:{marginTop:0,marginBottom:20}},(0,f.FE)(oe.A.CONTENT_GENERATOR.TOPICS_HELP)),React.createElement("div",{style:{display:"flex"}},React.createElement(h.M,{ai:!0,disabled:$||!k.length,onClick:async()=>{D([]);const e=k.map(((e,t)=>async()=>{console.log("Topic "+t);try{const{title:t,content:a,excerpt:n}=await Be(e,!0);if(t&&a&&n){const l=await He(t,a,n,!0);D((r=>[...r,{postId:l,topic:e,title:t,content:a,excerpt:n}]))}else console.warn("Could not generate the post for: "+e)}catch(e){confirm(oe.A.CONTENT_GENERATOR.BULK_ERROR_CONFIRM.replace("{MESSAGE}",e.message))||(d.stop(),d.reset(),E(!1))}return{success:!0}}));await d.start(e),d.reset()}},oe.A.COMMON.GENERATE),React.createElement(Ye.j,{busy:d.busy,style:{marginLeft:10,flex:"auto"},value:d.value,max:d.max,onStopClick:d.stop})),React.createElement(Y.g,null),React.createElement("h3",null,oe.A.COMMON.TOPICS),React.createElement($e.m,{name:"topics",rows:10,value:J,onChange:Se,placeholder:"Example:\nWhy Cats Make Perfect Companions\nUnderstanding Cat Body Language\nThe Science Behind Purring\nIndoor vs Outdoor Cats Debate\nBest Cat Breeds for Families"}),React.createElement(m.R,{name:"topicsAreTitles",label:oe.A.CONTENT_GENERATOR.USE_TOPICS_AS_TITLES,value:"1",checked:fe,onChange:Se}),React.createElement("h3",null,oe.A.CONTENT_GENERATOR.GENERATED_POSTS),!L.length&&React.createElement("i",null,oe.A.CONTENT_GENERATOR.NOTHING_YET),L.length>0&&React.createElement("ul",null,L.map((e=>React.createElement("li",{key:e.postId},e.title," ",React.createElement("a",{target:"_blank",href:`/?p=${e.postId}`,rel:"noreferrer"},oe.A.COMMON.VIEW)," ","or"," ",React.createElement("a",{target:"_blank",href:`/wp-admin/post.php?post=${e.postId}&action=edit`,rel:"noreferrer"},oe.A.COMMON.EDIT)))))),"single"===W&&React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},oe.A.COMMON.TITLE),React.createElement(V.A,{name:"title",disabled:$,value:z,onChange:Se,placeholder:"The title will appear here after clicking 'Generate'"}),Oe&&React.createElement("div",{className:"information"},oe.A.CONTENT_GENERATOR.ADVICE,": ",Oe),me&&React.createElement(React.Fragment,null,React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.CONTENT_GENERATOR.SECTIONS),React.createElement("div",{style:{display:"flex",alignItems:"center"}},xe.sectionsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},oe.A.CONTENT_GENERATOR.NUMBER_OF_SECTIONS,":"," "),React.createElement(K.u,{scrolldown:!0,name:"sectionsCount",disabled:$,style:{marginRight:10},value:ae,description:"",onChange:Se},[2,3,4,5,6,8,10,12].map((e=>React.createElement(K.j,{key:e,value:e,label:e}))))),ae>0&&React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.sections,onClick:()=>Pe()},oe.A.CONTENT_GENERATOR.GENERATE_SECTIONS))),ae>0&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{name:"sections",disabled:$,rows:4,value:G,description:oe.A.CONTENT_GENERATOR.SECTIONS_HELP,onChange:Se,placeholder:"Sections will appear here after clicking 'Generate'"}))),React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.CONTENT),React.createElement("div",{style:{display:"flex",alignItems:"center"}},xe.paragraphsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},oe.A.CONTENT_GENERATOR.PARAGRAPHS_PER_SECTION,": "),React.createElement(K.u,{scrolldown:!0,name:"paragraphsCount",disabled:$,style:{marginRight:10},value:ne,description:"",onChange:Se},[1,2,3,4,6,8,10].map((e=>React.createElement(K.j,{key:e,value:e,label:e}))))),React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.content,onClick:()=>Le()},oe.A.CONTENT_GENERATOR.GENERATE_CONTENT))),React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{countable:"words",disabled:$,rows:12,value:e,description:oe.A.CONTENT_GENERATOR.CONTENT_HELP,onChange:t,placeholder:"Your article content will appear here after clicking 'Generate'"}),React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.EXCERPT),React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.excerpt,onClick:()=>De()},oe.A.CONTENT_GENERATOR.GENERATE_EXCERPT)),React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{disabled:$,value:a,onBlur:n,rows:3,placeholder:"The excerpt will appear here after clicking 'Generate'"}),React.createElement(Y.g,null),React.createElement(h.M,{fullWidth:!0,style:{height:60,fontSize:16},onClick:()=>He(),busy:$,disabled:!z||!e},oe.A.CONTENT_GENERATOR.CREATE_POST))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},oe.A.COMMON.CONTENT),!xe.language&&!xe.writingStyle&&!xe.writingTone&&!M&&React.createElement("div",{style:{fontSize:11,lineHeight:"14px"}},oe.A.CONTENT_GENERATOR.CONTENT_PARAMS_INTRO),xe.language&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.LANGUAGE,":"),Ce),xe.writingStyle&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.CONTENT_GENERATOR.WRITING_STYLE,":"),React.createElement(K.u,{scrolldown:!0,name:"writingStyle",disabled:$,value:le,description:"",onChange:Se},fi.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),xe.writingTone&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.CONTENT_GENERATOR.WRITING_TONE,":"),React.createElement(K.u,{scrolldown:!0,name:"writingTone",disabled:$,value:re,description:"",onChange:Se},yi.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.POST_TYPE,":"),React.createElement(K.u,{scrolldown:!0,disabled:$,name:"postType",onChange:x,value:M},null==j?void 0:j.map((e=>React.createElement(K.j,{key:e.type,value:e.type,label:e.name})))))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>w(!b),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.MODEL),React.createElement(je.z,{icon:b?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),b&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.ENVIRONMENT,":"),React.createElement(K.u,{scrolldown:!0,name:"envId",value:ge??"",onChange:Se},Te.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(K.j,{value:"",label:"Default"})),React.createElement("label",null,oe.A.COMMON.MODEL,":"),React.createElement(K.u,{name:"model",value:te||"",scrolldown:!0,disabled:!ge,onChange:Se},React.createElement(K.j,{value:"",label:ge?"None":"Default"}),ve.map((e=>React.createElement(K.j,{key:e,value:e.model,label:e.name})))),React.createElement("label",null,oe.A.COMMON.TEMPERATURE,":"),React.createElement(V.A,{name:"temperature",value:Re,type:"number",onChange:Se,onBlur:Se,description:oe.A.HELP.TEMPERATURE}))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>A(!C),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},(0,f.FE)(oe.A.COMMON.PROMPTS)),React.createElement(je.z,{icon:C?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),C&&React.createElement(React.Fragment,null,React.createElement("p",{style:{fontSize:11,lineHeight:"14px",opacity:.6}},oe.A.CONTENT_GENERATOR.PROMPTS_INTRO),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_TITLE)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"titlePromptFormat",value:ie,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_SECTIONS)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"sectionsPromptFormat",value:me,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_CONTENT)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"contentPromptFormat",value:ue,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_EXCERPT)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"excerptPromptFormat",value:pe,onChange:Se}))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>N(!I),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.USAGE),React.createElement(je.z,{icon:I?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),I&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),_e)))),React.createElement(ee.n,{isOpen:O,onRequestClose:()=>S(),okButton:{label:oe.A.CONTENT_GENERATOR.EDIT_POST,onClick:()=>{window.open(`/wp-admin/post.php?post=${O}&action=edit`,"_blank"),i(),S()}},cancelButton:{label:oe.A.COMMON.CLOSE,onClick:()=>{S()}},title:oe.A.CONTENT_GENERATOR.POST_CREATED,content:React.createElement("p",null,oe.A.CONTENT_GENERATOR.POST_CREATED_AS_DRAFT)}),React.createElement(ee.n,{isOpen:R,onRequestClose:()=>{v()},okButton:{onClick:()=>{v()}},title:oe.A.COMMON.ERROR,content:React.createElement("p",null,R)}))},{useState:ss,useEffect:cs,useMemo:ds,useRef:ms}=wp.element;function us(e,t=42){let a=e.replace(/[\s|,]+/g,"-");a=a.replace(/--+/g,"-");const n=a.split("-");let l=n[0],r=1;for(;r<n.length&&n[r]&&l.length+n[r].length<t;)l+="-"+n[r],r++;return l.length>t+1&&(l=l.slice(0,t+2)),l }b.Ay.div`580 `,{useState:qi,useEffect:Ki,useMemo:Vi}=wp.element,Yi=e=>{const{post:t,onTitleClick:a={},onClose:n={}}=e,[l,r]=qi([]),[o,i]=qi(!1),[s,c]=qi(!1);Ki((()=>{t&&d(t)}),[t]);const d=async({postId:e,postTitle:t})=>{i(!0);try{var a;const t=await(0,f.IU)(`${y.y0}/ai/magic_wand`,{method:"POST",nonce:y.ok,json:{action:"suggestTitles",data:{postId:e}}});r(null===(a=t.data)||void 0===a?void 0:a.results)}catch(e){console.error(e),c(e.message)}i(!1)},m=async()=>{n(),r([]),c(),i(!1)},u=Vi((()=>o?React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px"}},React.createElement(Ri.X,{type:"icon",size:"32px",color:"#2271b1"})):s?React.createElement(React.Fragment,null,"Error: ",s):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(Gi,null,l.map((e=>React.createElement(Wi,{key:e,onClick:()=>{(async e=>{i(!0);try{await a(e),m()}catch(e){c(e.message)}i(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,s]),p=Vi((()=>{const e=[];return e.push({label:"Close",onClick:m}),!o&&(null==l?void 0:l.length)>0&&e.push({label:"Try Again",onClick:()=>d(t),variant:"primary"}),e}),[o,l,t]);return React.createElement(g.N,null,React.createElement(ee.n,{isOpen:t,onRequestClose:m,title:`New title for "${null==t?void 0:t.postTitle}"`,content:u,okButton:p[0],cancelButton:p[1]}))},{useState:Xi,useEffect:Qi,useMemo:Ji}=wp.element,Zi=e=>{const{post:t,onExcerptClick:a={},onClose:n={}}=e,[l,r]=Xi([]),[o,i]=Xi(!1),[s,c]=Xi(!1);Qi((()=>{t&&d(t)}),[t]);const d=async({postId:e})=>{i(!0);try{var t;const a=await(0,f.IU)(`${y.y0}/ai/magic_wand`,{method:"POST",nonce:y.ok,json:{action:"suggestExcerpts",data:{postId:e}}});r(null===(t=a.data)||void 0===t?void 0:t.results)}catch(e){console.error(e),c(e.message)}i(!1)},m=async()=>{n(),r([]),c(),i(!1)},u=Ji((()=>o?React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px"}},React.createElement(Ri.X,{type:"icon",size:"32px",color:"#2271b1"})):s?React.createElement(React.Fragment,null,"Error: ",s):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(Gi,null,l.map((e=>React.createElement(Wi,{key:e,onClick:()=>{(async e=>{i(!0);try{await a(e),m()}catch(e){c(e.message)}i(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,s]),p=Ji((()=>{const e=[];return e.push({label:"Close",onClick:m}),!o&&(null==l?void 0:l.length)>0&&e.push({label:"Try Again",onClick:()=>d(t),variant:"primary"}),e}),[o,l,t]);return React.createElement(g.N,null,React.createElement(ee.n,{isOpen:t,onRequestClose:m,title:`New excerpt for "${null==t?void 0:t.postTitle}"`,content:u,okButton:p[0],cancelButton:p[1]}))},{useState:es,useEffect:ts}=wp.element,as=()=>{const[e,t]=es();ts((()=>{setTimeout((()=>{document.querySelectorAll(".mwai-magic-wand-action").forEach((e=>{const t=e.querySelector(".mwai-magic-wand-trigger"),a=e.querySelector(".mwai-magic-wand-dropdown");let n;e.addEventListener("mouseenter",(()=>{clearTimeout(n),a.style.display="block"})),e.addEventListener("mouseleave",(()=>{n=setTimeout((()=>{a.style.display="none"}),200)})),t.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation()}))})),document.addEventListener("click",(e=>{if(e.target.closest(".mwai-link-title")){e.preventDefault(),e.stopPropagation();const a=e.target.closest(".mwai-link-title"),n=a.getAttribute("data-id"),l=a.getAttribute("data-title");console.log("Title click:",n,l),t({postId:n,postTitle:l,mode:"title"})}if(e.target.closest(".mwai-link-excerpt")){e.preventDefault(),e.stopPropagation();const a=e.target.closest(".mwai-link-excerpt"),n=a.getAttribute("data-id"),l=a.getAttribute("data-title");console.log("Excerpt click:",n,l),t({postId:n,postTitle:l,mode:"excerpt"})}}))}),100)}),[]);return React.createElement(r.A,null,React.createElement(g.N,null,React.createElement(Yi,{post:"title"===(null==e?void 0:e.mode)?e:null,onTitleClick:async a=>{const n=await(0,f.IU)(`${y.y0}/helpers/update_post_title`,{method:"POST",nonce:y.ok,json:{postId:e.postId,title:a}});if(!n.success)throw new Error(n.message);{t();const n=document.querySelector(`tr[id="post-${e.postId}"]`);if(n){const e=n.querySelector(".row-title");e&&(e.innerHTML=a)}const l=n.querySelector(".hidden .post_title");l&&(l.innerHTML=a)}},onClose:()=>{t()}}),React.createElement(Zi,{post:"excerpt"===(null==e?void 0:e.mode)?e:null,onExcerptClick:async a=>{const n=await(0,f.IU)(`${y.y0}/helpers/update_post_excerpt`,{method:"POST",nonce:y.ok,json:{postId:e.postId,excerpt:a}});if(!n.success)throw new Error(n.message);t()},onClose:()=>{t()}})))},{useState:ns,useEffect:ls,useMemo:rs,useRef:os}=wp.element,is=()=>{const[e,t]=ns(""),[a,n]=ns(""),{template:l,setTemplate:r,clearTemplate:i,jsxTemplates:c}=Li("contentGenerator"),d=(0,Xe.XS)(),[p,E]=ns(!1),[R,v]=ns(),[b,w]=ns(!1),[_,T]=ns(!1),[C,A]=ns(!1),[I,N]=ns(!1),[O,S]=ns(),[M,x]=ns("post"),[k,P]=ns([]),[L,D]=ns([]),[F,U]=ns({}),B=os(),{isLoading:H,data:j}=(0,o.I)({queryKey:["postTypes"],queryFn:Je}),$=d.busy||p,z=(null==l?void 0:l.title)??"",G=(null==l?void 0:l.sections)??"",W=(null==l?void 0:l.mode)??"single",q=(null==l?void 0:l.topic)??"",J=(null==l?void 0:l.topics)??"",Z=(null==l?void 0:l.context)??"",te=(null==l?void 0:l.model)??(null===y.fF||void 0===y.fF?void 0:y.fF.ai_default_model)??null,ae=(null==l?void 0:l.sectionsCount)??2,ne=(null==l?void 0:l.paragraphsCount)??3,le=(null==l?void 0:l.writingStyle)??"creative",re=(null==l?void 0:l.writingTone)??"cheerful",ie=(null==l?void 0:l.titlePromptFormat)??"",me=(null==l?void 0:l.sectionsPromptFormat)??"",ue=(null==l?void 0:l.contentPromptFormat)??"",pe=(null==l?void 0:l.excerptPromptFormat)??"",ge=(null==l?void 0:l.envId)??"",Re=(null==l?void 0:l.temperature)??.6,fe=(null==l||l.maxTokens,(null==l?void 0:l.topicsAreTitles)??!1),ye=!me||!ae,{completionModels:ve,calculatePrice:be}=(null==l||l.useMaxTokens,he(y.fF,ge||null)),{addUsage:we,jsxUsageCosts:_e}=Ui(be),Te=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_envs)||[],{jsxLanguageSelector:Ce,currentLanguage:Ae,isCustom:Ie,currentHumanLanguage:Ne}=(({disabled:e,options:t,language:a})=>{const[n,l]=ce(a??"en"),r=(null==t?void 0:t.languages)||[],o=se((()=>Object.keys(r).map((e=>({value:e,label:r[e]})))),[r]);de((()=>{l(a)}),[a]),de((()=>{const e=localStorage.getItem("mwai_preferred_language");if(e&&o.find((t=>t.value===e)))return void l(e);const t=(document.querySelector("html").lang||navigator.language||navigator.userLanguage).substr(0,2);o.find((e=>e.value===t))&&l(t)}),[]);const i=se((()=>{const e=o.find((e=>e.value===n));return e?e.label:(console.warn("A system language should be set."),"English")}),[n,o]),s=(e,t)=>{l(e,t),localStorage.setItem("mwai_preferred_language",e)};return{jsxLanguageSelector:se((()=>React.createElement(K.u,{scrolldown:!0,name:"language",disabled:e,description:(0,f.FE)(oe.A.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:n,onChange:s},o.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),[n,i,o]),currentLanguage:n,currentHumanLanguage:i}})({options:y.fF,language:null==l?void 0:l.language,customLanguage:null==l?void 0:l.customLanguage}),Oe=rs((()=>(e=>{if(!e)return null;const t=e.split(" ").length,a=e.length,n=[];return a?(t<3?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_SHORT):t>8?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_LONG):a<40?n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_SHORT):a>70&&n.push(oe.A.CONTENT_GENERATOR.TITLE_TOO_LONG_2),n.join(" ")):void 0})(z)),[z]),Se=(e,t)=>{r((a=>{const n={...a,[t]:e};return"envId"===t&&""===e&&(n.model=""),n}))};ls((()=>{const e=J.split("\n").map((e=>e.trim())).filter((e=>!!e));P(e)}),[J]),ls((()=>{l&&Se("","sections")}),[z,ae]),ls((()=>{t(""),n(""),S()}),[G,ne]),ls((()=>{l&&(!Ie&&l.customLanguage&&Se(null,"customLanguage"),Ie&&l.customLanguage!==Ne&&Se(Ne,"customLanguage"),l.language!==Ae&&Se(Ae,"language"))}),[Ie,Ae,Ne]);const Me=(e,t=Z)=>{let a="";return t&&t.trim()?a=t:e=(e=e.replace(/### CONTEXT:[\s\S]*?(?=(###|Write|Create|Generate)|$)/g,"").trim()).replace(/### WRITING CONTEXT:[\s\S]*?(?=(###|Write|Create|Generate)|$)/g,"").trim(),e.replace("{LANGUAGE}",Ne).replace("{WRITING_STYLE}",le).replace("{WRITING_TONE}",re).replace("{PARAGRAPHS_PER_SECTION}",ne).replace("{SECTIONS_COUNT}",ae).replace("{CONTEXT}",a)},xe=rs((()=>{const e=(e,t)=>!!t.find((t=>t.includes(e))),t=[ie,me,ue,pe];return{language:e("{LANGUAGE}",t),writingStyle:e("{WRITING_STYLE}",t),writingTone:e("{WRITING_TONE}",t),sectionsCount:e("{SECTIONS_COUNT}",t),paragraphsCount:e("{PARAGRAPHS_PER_SECTION}",t),context:e("{CONTEXT}",t)}}),[ie,me,ue,pe,ae,ne]),ke=async(e,t=!1)=>{B.current||(B.current=new AbortController);try{var a,n;const t={scope:"admin-tools",envId:ge||null,model:te||null,session:y.dZ,message:e,temperature:Re},l=await(0,f.IU)(`${y.y0}/ai/completions`,{method:"POST",nonce:y.ok,signal:B.current.signal,json:t});we(te,(null==l||null===(a=l.usage)||void 0===a?void 0:a.prompt_tokens)||0,(null==l||null===(n=l.usage)||void 0===n?void 0:n.completion_tokens)||0);let r=l.data.trim();return r.startsWith('"')&&r.endsWith('"')&&(r=r.substring(1,r.length-1)),r}catch(e){if(t)throw new Error(e.message);return"AbortError"!==e.name&&(console.error(e),v(e.message)),null}},Pe=async(e=q,t=z,a=!1)=>{if(!t)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);E(!0),U({...F,sections:new Date}),Se("","sections");let n=me.replace("{TITLE}",t).replace("{TOPIC}",e);n=Me(n);let l=await ke(n,a);var r;return l=(r=l)?r.split("\n").map((e=>((e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e))).filter((e=>e)).join("\n"):r,l&&Se(l,"sections"),E(!1),U({...F,sections:null}),l},Le=async(e=q,a=z,n=G,l=!1)=>{if(!a)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);if(!ye&&!n)return void alert(oe.A.CONTENT_GENERATOR.SECTIONS_MISSING);E(!0),U({...F,content:new Date}),t((()=>""));let r=ue.replace("{TITLE}",a).replace("{SECTIONS}",n).replace("{TOPIC}",e);r=Me(r);let o=await ke(r,l);return o&&(o=o.replace(/^===INTRO:\n/,"").replace(/^===INTRO: \n/,"").replace(/===INTRO: /,"").replace(/===OUTRO:\n/,"").replace(/===OUTRO: \n/,"").replace(/===OUTRO: /,""),t((()=>o))),E(!1),U({...F,content:null}),o},De=async(e=q,t=z,a=!1)=>{if(!t)return void alert(oe.A.CONTENT_GENERATOR.TITLE_MISSING);E(!0),U({...F,excerpt:new Date}),n((()=>""));let l=pe.replace("{TITLE}",t).replace("{TOPIC}",e);l=Me(l);const r=await ke(l,a);return r&&n((()=>r)),E(!1),U({...F,excerpt:null}),r},Be=async(e=q,t=!1)=>{E(!0),B.current=new AbortController,U({...F,all:new Date});try{let a=e;if(!fe||!t){const n=Me(ie.replace("{TOPIC}",e));a=await ke(n,t)}let n=null,l=null,r=null;return E(!1),a&&(Se(a,"title"),ye||(U((e=>({...e,sections:new Date}))),n=await Pe(e,a,t),U((e=>({...e,sections:null})))),(n||ye)&&(U((e=>({...e,content:new Date}))),l=await Le(e,a,n,t),U((e=>({...e,content:null}))),l&&(U((e=>({...e,excerpt:new Date}))),r=await De(e,a,t),U((e=>({...e,excerpt:null})))))),{title:a,heads:n,content:l,excerpt:r}}catch(e){throw console.error(e),E(!1),U({}),e}},He=async(t=z,n=e,l=a,r=!1)=>{E(!0),B.current=new AbortController;try{const e=await(0,f.IU)(`${y.y0}/helpers/create_post`,{method:"POST",nonce:y.ok,signal:B.current.signal,json:{title:t,content:n,excerpt:l,postType:M}});return r||S(e.postId),e.postId}catch(e){return"AbortError"!==e.name&&(console.error(e),v(e.message)),null}finally{E(!1)}};return React.createElement(u.z,{nekoErrors:[]},React.createElement(Fe,{title:oe.A.COMMON.CONTENT_GENERATOR}),React.createElement(g.N,null,React.createElement(Ee,{options:y.fF}),(null===y.fF||void 0===y.fF?void 0:y.fF.intro_message)&&React.createElement(g.Y,{fullWidth:!0},React.createElement(X.L,{style:{marginBottom:0}},React.createElement(s.s,{p:!0},(0,f.FE)(oe.A.CONTENT_GENERATOR.INTRO)))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,c),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},"bulk"===W?oe.A.COMMON.CONTEXT||"Context":oe.A.COMMON.TOPIC),"bulk"===W?React.createElement(React.Fragment,null,React.createElement("p",{style:{marginTop:0,marginBottom:10,fontSize:12,opacity:.6}},"Provide context that will be used for all generated posts to make them more accurate and relevant."),React.createElement($e.m,{name:"context",disabled:$||H,rows:14,value:Z,onChange:Se,placeholder:"Example: This is for a cat enthusiast blog targeting pet owners and cat lovers. The tone should be friendly, informative, and occasionally playful. Include practical tips and scientific facts when relevant."})):React.createElement($e.m,{name:"topic",disabled:$||H,rows:16,value:q,onChange:Se,placeholder:"Example: Write a comprehensive guide about adopting a rescue cat, covering the adoption process, preparing your home, first days together, and tips for helping the cat adjust to their new environment. Include advice for families with children or other pets."}),React.createElement(Y.g,null),React.createElement(h.M,{fullWidth:!0,ai:!0,disabled:!q||"bulk"===W||H,busy:$,onClick:()=>Be(),onStopClick:()=>{var e;null===(e=B.current)||void 0===e||e.abort(),E(!1),U({})},startTime:null==F?void 0:F.all,style:{height:50,fontSize:16,flex:4}},oe.A.COMMON.GENERATE))),React.createElement(g.Y,{style:{flex:2}},React.createElement(Q.o,{name:"mode",value:W,disabled:$,onChange:Se},React.createElement(Q.K,{title:oe.A.CONTENT_GENERATOR.SINGLE_GENERATE,value:"single"}),React.createElement(Q.K,{title:oe.A.CONTENT_GENERATOR.BULK_GENERATE,value:"bulk",count:k.length})),React.createElement(Y.g,null),"bulk"===W&&React.createElement(Na,null,React.createElement("p",{style:{marginTop:0,marginBottom:20}},(0,f.FE)(oe.A.CONTENT_GENERATOR.TOPICS_HELP)),React.createElement("div",{style:{display:"flex"}},React.createElement(h.M,{ai:!0,disabled:$||!k.length,onClick:async()=>{D([]);const e=k.map(((e,t)=>async()=>{console.log("Topic "+t);try{const{title:t,content:a,excerpt:n}=await Be(e,!0);if(t&&a&&n){const l=await He(t,a,n,!0);D((r=>[...r,{postId:l,topic:e,title:t,content:a,excerpt:n}]))}else console.warn("Could not generate the post for: "+e)}catch(e){confirm(oe.A.CONTENT_GENERATOR.BULK_ERROR_CONFIRM.replace("{MESSAGE}",e.message))||(d.stop(),d.reset(),E(!1))}return{success:!0}}));await d.start(e),d.reset()}},oe.A.COMMON.GENERATE),React.createElement(Ye.j,{busy:d.busy,style:{marginLeft:10,flex:"auto"},value:d.value,max:d.max,onStopClick:d.stop})),React.createElement(Y.g,null),React.createElement("h3",null,oe.A.COMMON.TOPICS),React.createElement($e.m,{name:"topics",rows:10,value:J,onChange:Se,placeholder:"Example:\nWhy Cats Make Perfect Companions\nUnderstanding Cat Body Language\nThe Science Behind Purring\nIndoor vs Outdoor Cats Debate\nBest Cat Breeds for Families"}),React.createElement(m.R,{name:"topicsAreTitles",label:oe.A.CONTENT_GENERATOR.USE_TOPICS_AS_TITLES,value:"1",checked:fe,onChange:Se}),React.createElement("h3",null,oe.A.CONTENT_GENERATOR.GENERATED_POSTS),!L.length&&React.createElement("i",null,oe.A.CONTENT_GENERATOR.NOTHING_YET),L.length>0&&React.createElement("ul",null,L.map((e=>React.createElement("li",{key:e.postId},e.title," ",React.createElement("a",{target:"_blank",href:`/?p=${e.postId}`,rel:"noreferrer"},oe.A.COMMON.VIEW)," ","or"," ",React.createElement("a",{target:"_blank",href:`/wp-admin/post.php?post=${e.postId}&action=edit`,rel:"noreferrer"},oe.A.COMMON.EDIT)))))),"single"===W&&React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},oe.A.COMMON.TITLE),React.createElement(V.A,{name:"title",disabled:$,value:z,onChange:Se,placeholder:"The title will appear here after clicking 'Generate'"}),Oe&&React.createElement("div",{className:"information"},oe.A.CONTENT_GENERATOR.ADVICE,": ",Oe),me&&React.createElement(React.Fragment,null,React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.CONTENT_GENERATOR.SECTIONS),React.createElement("div",{style:{display:"flex",alignItems:"center"}},xe.sectionsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},oe.A.CONTENT_GENERATOR.NUMBER_OF_SECTIONS,":"," "),React.createElement(K.u,{scrolldown:!0,name:"sectionsCount",disabled:$,style:{marginRight:10},value:ae,description:"",onChange:Se},[2,3,4,5,6,8,10,12].map((e=>React.createElement(K.j,{key:e,value:e,label:e}))))),ae>0&&React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.sections,onClick:()=>Pe()},oe.A.CONTENT_GENERATOR.GENERATE_SECTIONS))),ae>0&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{name:"sections",disabled:$,rows:4,value:G,description:oe.A.CONTENT_GENERATOR.SECTIONS_HELP,onChange:Se,placeholder:"Sections will appear here after clicking 'Generate'"}))),React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.CONTENT),React.createElement("div",{style:{display:"flex",alignItems:"center"}},xe.paragraphsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},oe.A.CONTENT_GENERATOR.PARAGRAPHS_PER_SECTION,": "),React.createElement(K.u,{scrolldown:!0,name:"paragraphsCount",disabled:$,style:{marginRight:10},value:ne,description:"",onChange:Se},[1,2,3,4,6,8,10].map((e=>React.createElement(K.j,{key:e,value:e,label:e}))))),React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.content,onClick:()=>Le()},oe.A.CONTENT_GENERATOR.GENERATE_CONTENT))),React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{countable:"words",disabled:$,rows:12,value:e,description:oe.A.CONTENT_GENERATOR.CONTENT_HELP,onChange:t,placeholder:"Your article content will appear here after clicking 'Generate'"}),React.createElement(Y.g,null),React.createElement(Ue,null,React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.EXCERPT),React.createElement(h.M,{ai:!0,disabled:!z,busy:$,startTime:null==F?void 0:F.excerpt,onClick:()=>De()},oe.A.CONTENT_GENERATOR.GENERATE_EXCERPT)),React.createElement(Y.g,{tiny:!0}),React.createElement($e.m,{disabled:$,value:a,onBlur:n,rows:3,placeholder:"The excerpt will appear here after clicking 'Generate'"}),React.createElement(Y.g,null),React.createElement(h.M,{fullWidth:!0,style:{height:60,fontSize:16},onClick:()=>He(),busy:$,disabled:!z||!e},oe.A.CONTENT_GENERATOR.CREATE_POST))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},oe.A.COMMON.CONTENT),!xe.language&&!xe.writingStyle&&!xe.writingTone&&!M&&React.createElement("div",{style:{fontSize:11,lineHeight:"14px"}},oe.A.CONTENT_GENERATOR.CONTENT_PARAMS_INTRO),xe.language&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.LANGUAGE,":"),Ce),xe.writingStyle&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.CONTENT_GENERATOR.WRITING_STYLE,":"),React.createElement(K.u,{scrolldown:!0,name:"writingStyle",disabled:$,value:le,description:"",onChange:Se},fi.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),xe.writingTone&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.CONTENT_GENERATOR.WRITING_TONE,":"),React.createElement(K.u,{scrolldown:!0,name:"writingTone",disabled:$,value:re,description:"",onChange:Se},yi.map((e=>React.createElement(K.j,{key:e.value,value:e.value,label:e.label}))))),React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.POST_TYPE,":"),React.createElement(K.u,{scrolldown:!0,disabled:$,name:"postType",onChange:x,value:M},null==j?void 0:j.map((e=>React.createElement(K.j,{key:e.type,value:e.type,label:e.name})))))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>w(!b),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.MODEL),React.createElement(je.z,{icon:b?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),b&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.ENVIRONMENT,":"),React.createElement(K.u,{scrolldown:!0,name:"envId",value:ge??"",onChange:Se},Te.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(K.j,{value:"",label:"Default"})),React.createElement("label",null,oe.A.COMMON.MODEL,":"),React.createElement(K.u,{name:"model",value:te||"",scrolldown:!0,disabled:!ge,onChange:Se},React.createElement(K.j,{value:"",label:ge?"None":"Default"}),ve.map((e=>React.createElement(K.j,{key:e,value:e.model,label:e.name})))),React.createElement("label",null,oe.A.COMMON.TEMPERATURE,":"),React.createElement(V.A,{name:"temperature",value:Re,type:"number",onChange:Se,onBlur:Se,description:oe.A.HELP.TEMPERATURE}))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>A(!C),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},(0,f.FE)(oe.A.COMMON.PROMPTS)),React.createElement(je.z,{icon:C?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),C&&React.createElement(React.Fragment,null,React.createElement("p",{style:{fontSize:11,lineHeight:"14px",opacity:.6}},oe.A.CONTENT_GENERATOR.PROMPTS_INTRO),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_TITLE)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"titlePromptFormat",value:ie,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_SECTIONS)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"sectionsPromptFormat",value:me,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_CONTENT)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"contentPromptFormat",value:ue,onChange:Se}),React.createElement("label",null,(0,f.FE)(oe.A.CONTENT_GENERATOR.PROMPT_EXCERPT)),React.createElement($e.m,{disabled:$||"default"===(null==l?void 0:l.id),name:"excerptPromptFormat",value:pe,onChange:Se}))),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(Ue,{onClick:()=>N(!I),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginBottom:0}},oe.A.COMMON.USAGE),React.createElement(je.z,{icon:I?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),I&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),_e)))),React.createElement(ee.n,{isOpen:O,onRequestClose:()=>S(),okButton:{label:oe.A.CONTENT_GENERATOR.EDIT_POST,onClick:()=>{window.open(`/wp-admin/post.php?post=${O}&action=edit`,"_blank"),i(),S()}},cancelButton:{label:oe.A.COMMON.CLOSE,onClick:()=>{S()}},title:oe.A.CONTENT_GENERATOR.POST_CREATED,content:React.createElement("p",null,oe.A.CONTENT_GENERATOR.POST_CREATED_AS_DRAFT)}),React.createElement(ee.n,{isOpen:R,onRequestClose:()=>{v()},okButton:{onClick:()=>{v()}},title:oe.A.COMMON.ERROR,content:React.createElement("p",null,R)}))},{useState:ss,useEffect:cs,useMemo:ds,useRef:ms}=wp.element;function us(e,t=42){let a=e.replace(/[\s|,]+/g,"-");a=a.replace(/--+/g,"-");const n=a.split("-");let l=n[0],r=1;for(;r<n.length&&n[r]&&l.length+n[r].length<t;)l+="-"+n[r],r++;return l.length>t+1&&(l=l.slice(0,t+2)),l=l.replace(/\.+$/,""),l}b.Ay.div` 581 581 margin-bottom: 5px; 582 582 label { … … 752 752 margin: 0 auto; 753 753 } 754 `,ys=()=>{var e,t,a;const{template:n,setTemplate:l,jsxTemplates:r}=Li("imagesGenerator"),[o,i]=ss(),c=new URLSearchParams(window.location.search).get("editId"),[d,m]=ss(c?"edit":"generate"),[p,E]=ss(!1),[R,v]=ss(),[b,w]=ss( !1),[_,T]=ss(!1),[C,A]=ss(!1),[I,N]=ss(!1),O=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_envs)||[],{imageModels:S,getModel:M}=he(y.fF,(null==n?void 0:n.envId)||null),x=M(null==n?void 0:n.model),k=ds((()=>{if(null===y.fF||void 0===y.fF||!y.fF.ai_engines||!O)return[];const e=(e,t)=>!(!e||!e.tags)&&(!!Array.isArray(e.tags)&&e.tags.includes(t));return O.filter((t=>{for(const a of y.fF.ai_engines){if(!a.models)continue;if(a.type!==t.type)continue;if(a.models.some((t=>e(t,"image")||e(t,"image-generation"))))return!0}return!1}))}),[O,y.fF]),[P,L]=ss([]),[D,F]=ss([]),[U,B]=ss(),[H,j]=ss(""),[$,z]=ss(""),[G,W]=ss(""),[q,J]=ss(""),[Z,te]=ss(""),[ae,ne]=ss([]),[le,re]=ss(!1),[ie,se]=ss(null),[ce,de]=ss(30),[me,ue]=ss(!0),[ge,Re]=ss({x:0,y:0,visible:!1}),fe=ms(),ye=ms(),ve=ms(),be=(ms([]),null==n?void 0:n.prompt),[we,_e]=ss(1),[Te,Ce]=ss(0),[Ae,Ie]=ss(0),[Ne,Oe]=ss([]),[Se,Me]=ss(!0),[xe,ke]=ss([]),Pe=ms(),Le=(null==n?void 0:n.style)??null,De=e=>{l({...n,prompt:e})},Be=(e,t)=>{l((a=>{const n={...a,[t]:e};return"envId"===t&&""===e&&(n.model="",n.resolution=""),"model"===t&&(n.resolution=""),n}))},[He,ze]=ss({title:"",filename:"",description:""});cs((()=>{if(U){const e=qe(U);let t,a,n;if(e&&e.attachment_id)t=e.filename||"",a=e.title||"",n=e.description||"";else{const e=D.indexOf(U)+1;t=(us(be).toLowerCase()||"image")+".png",a=`Untitled Image #${e||1}`,n=be||""}te(t),j(a),z(n),W(n),J(a),ze({title:a,filename:t,description:n})}}),[U]);cs((()=>{c&&fetch(`${y.gh}/wp/v2/media/${c}`).then((e=>e.json())).then((e=>v(e.source_url)))}),[c]),cs((()=>{(async()=>{try{const e=await(0,f.IU)(y.y0+"/helpers/list_draft_media?type=image",{method:"GET",nonce:y.ok});if(e.success&&e.media){const t=[...e.media].sort(((e,t)=>(t.created_at||0)-(e.created_at||0)));Oe(t);const a=t.map((e=>e.url));F(a)}}catch(e){console.error("Error loading draft images:",e)}finally{Me(!1)}})()}),[]),cs((()=>{if(R&&ye.current&&fe.current){const e=ye.current,t=fe.current;e.onload=()=>{t.width=e.naturalWidth,t.height=e.naturalHeight;t.getContext("2d").clearRect(0,0,t.width,t.height),ve.current||(ve.current=document.createElement("canvas")),ve.current.width=t.width,ve.current.height=t.height}}}),[R]),cs((()=>{if(!le)return;const e=e=>{"["===e.key?(e.preventDefault(),de((e=>Math.max(5,e-5)))):"]"===e.key&&(e.preventDefault(),de((e=>Math.min(200,e+5))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[le]);const Ge=ms();cs((()=>{if(R&&ye.current&&Ge.current){const e=ye.current,t=Ge.current;e.onload=()=>{t.width=e.naturalWidth,t.height=e.naturalHeight}}}),[R]);const We=(e,t,a,n,l)=>{const r=e.createRadialGradient(t,a,0,t,a,n/2);if(l>=1)r.addColorStop(0,"rgba(255, 0, 0, 1)"),r.addColorStop(1,"rgba(255, 0, 0, 1)");else{const e=.5*l;r.addColorStop(0,"rgba(255, 0, 0, 1)"),r.addColorStop(e,"rgba(255, 0, 0, 1)"),r.addColorStop(1,"rgba(255, 0, 0, 0)")}e.fillStyle=r,e.beginPath(),e.arc(t,a,n/2,0,2*Math.PI),e.fill()};cs((()=>{P.length>0&&!b&&(async()=>{if(0===P.length||b)return;w(!0),Pe.current=new AbortController;const e=P[0],t=Date.now();try{const a="edit"===d?"image_edit":"images",n={env:"admin-tools",envId:e.envId||void 0,model:e.model||void 0,resolution:e.resolution,style:e.style,scope:"admin-tools",session:y.dZ,message:e.prompt,maxResults:1,mediaId:c,local_download:null};let l;if(console.log("Image Edit Request:",{mode:d,endpoint:a,hasMask:!!ie,editId:c,requestData:n}),"edit"===d&&ie){const e=new FormData;Object.keys(n).forEach((t=>{null!==n[t]&&void 0!==n[t]&&e.append(t,String(n[t]))})),e.append("mask",ie,"mask.png"),console.log("FormData contents:");for(let[t,a]of e.entries())console.log(t,a);if(l=await fetch(`${y.y0}/ai/${a}`,{method:"POST",headers:{"X-WP-Nonce":y.ok},signal:Pe.current.signal,body:e}),!l.ok){const e=await l.json();throw new Error(e.message||"Request failed")}l=await l.json()}else l=await(0,f.IU)(`${y.y0}/ai/${a}`,{method:"POST",nonce:y.ok,signal:Pe.current.signal,json:n});if(l.data&&l.data.length>0){const a=l.data[0];e.id&&ke((t=>t.filter((t=>t.id!==e.id)))),F((e=>[a,...e]));try{const n=D.length+1,l=(us(e.prompt).toLowerCase()||"image")+".png",r=`Untitled Image #${n}`,o=((Date.now()-t)/1e3).toFixed(1),i=await(0,f.IU)(`${y.y0}/helpers/create_image`,{method:"POST",nonce:y.ok,json:{url:a,title:r,description:e.prompt||"",caption:"",alt:"",filename:l,model:e.model,latency:o,env_id:e.envId}});i.success&&i.attachmentId&&Oe((t=>[{url:a,attachment_id:i.attachmentId,title:r,description:e.prompt||"",filename:l,model:e.model,generation_time:o,env_id:e.envId,created_at:Date.now()/1e3},...t]))}catch(e){console.error("Error auto-saving image to draft media:",e)}}L((e=>e.slice(1))),Ie((e=>e+1)),1===P.length&&(Ce(0),Ie(0))}catch(t){"AbortError"===t.name||/aborted/i.test(t.message)||(console.error(t),i(t.message+(P.length>1?" The other tasks will continue.":"")),e.id&&ke((t=>t.filter((t=>t.id!==e.id)))),L((e=>e.slice(1))),Ce((e=>e-1)))}finally{w(!1)}})()}),[P,b]);const qe=e=>Ne.find((t=>t.url===e));return React.createElement(u.z,{nekoErrors:[]},React.createElement(Fe,{title:oe.A.COMMON.IMAGES_GENERATOR}),React.createElement(g.N,null,React.createElement(Ee,{options:y.fF}),(null===y.fF||void 0===y.fF?void 0:y.fF.intro_message)&&React.createElement(g.Y,{fullWidth:!0},React.createElement(X.L,{style:{marginBottom:0}},React.createElement(s.s,{p:!0},(0,f.FE)(oe.A.COMMON.IMAGES_GENERATOR_INTRO)))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,"edit"===d&&R&&React.createElement(React.Fragment,null,React.createElement(ps,{maskMode:le,onMouseMove:e=>{if(le){const t=e.currentTarget.getBoundingClientRect();Re({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})}},onMouseLeave:()=>Re((e=>({...e,visible:!1})))},React.createElement("img",{ref:ye,src:R}),React.createElement("canvas",{ref:fe,onMouseDown:e=>{if(!le)return;const t=fe.current,a=t.getBoundingClientRect(),n=t.getContext("2d"),l=t.width/a.width,r=t.height/a.height,o=ce*l;let i=!0,s=(e.clientX-a.left)*l,c=(e.clientY-a.top)*r;const d=.5;let m=null;const u=e=>{n.save(),n.globalAlpha=e,We(n,s,c,o,.5),n.restore()};let p=d,g=!0;const E=()=>{i&&(g?(u(d),g=!1):(p=Math.min(p+.05,1),u(.05)),m=requestAnimationFrame(E))};E();const h=e=>{if(!i)return;const t=(e.clientX-a.left)*l,m=(e.clientY-a.top)*r,u=t-s,E=m-c,h=Math.sqrt(u*u+E*E);if(h>1){const e=Math.ceil(h/2);for(let t=1;t<=e;t++){const a=t/e,l=s+u*a,r=c+E*a;n.save(),n.globalAlpha=.15,We(n,l,r,o,.5),n.restore()}s=t,c=m,p=d,g=!0}},R=()=>{i=!1,m&&cancelAnimationFrame(m),(e=>{const t=fe.current,a=document.createElement("canvas");a.width=t.width,a.height=t.height;const n=a.getContext("2d");n.fillStyle="black",n.fillRect(0,0,a.width,a.height);const l=t.getContext("2d").getImageData(0,0,t.width,t.height),r=n.getImageData(0,0,a.width,a.height);for(let e=0;e<l.data.length;e+=4){const t=l.data[e],a=l.data[e+3];t>200&&a>100&&(r.data[e]=0,r.data[e+1]=0,r.data[e+2]=0,r.data[e+3]=0)}n.putImageData(r,0,0),a.toBlob(e,"image/png")})((e=>{se(e)})),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",R)}}),React.createElement(gs,{visible:ge.visible&&le,style:{left:ge.x,top:ge.y,width:ce,height:ce}})),React.createElement("div",{style:{display:"flex",gap:5,marginBottom:5}},React.createElement(h.M,{onClick:()=>{if(le){const e=fe.current;e.getContext("2d").clearRect(0,0,e.width,e.height),se(null),re(!1)}else re(!0)},style:{flex:2}},le?"Remove Mask":"Create Mask"),le&&React.createElement(React.Fragment,null,React.createElement(h.M,{onClick:()=>de((e=>Math.max(5,e-5))),style:{flex:1},title:"Decrease brush size"},"−"),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0 10px",border:"1px solid #ddd",borderRadius:4,background:"#f5f5f5",minWidth:40}},ce),React.createElement(h.M,{onClick:()=>de((e=>Math.min(200,e+5))),style:{flex:1},title:"Increase brush size"},"+"))),le&&React.createElement("div",{style:{fontSize:11,opacity:.6,marginBottom:10,textAlign:"center"}},"Use [ and ] keys to adjust brush size")),"edit"!==d&&r),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},(0,f.FE)(oe.A.COMMON.PROMPT)),React.createElement($e.m,{value:be,onChange:De,rows:10,placeholder:"Describe the image you want to generate..."})),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(h.M,{fullWidth:!0,disabled:!be,ai:!0,onClick:()=>{if(!be)return void console.error("Prompt is empty, cannot add to queue.");if("edit"===d&&!pe(x,"image-edit"))return void i("This model does not support image editing.");const e=Date.now()+Math.random(),t={id:e,prompt:be,envId:n.envId,model:n.model,resolution:n.resolution,style:n.style};ke((t=>[...t,{id:e,status:"queuing"}])),L((e=>[...e,t]))},style:{height:50,fontSize:16,flex:4}},oe.A.COMMON.GENERATE))),React.createElement(g.Y,{style:{flex:2}},React.createElement(Q.o,{value:d,onChange:e=>{"generate"===e?location.href="edit.php?page=mwai_images_generator":"edit"===e&&(c?m("edit"):E(!0))}},React.createElement(Q.K,{title:"Create",value:"generate"}),React.createElement(Q.K,{title:"Editor",value:"edit"})),React.createElement(Y.g,null),React.createElement("div",null,React.createElement(ee.n,{isOpen:!!U,title:"Image Details",size:"larger",onRequestClose:()=>B(),okButton:{label:"Save Meta",disabled:!(H!==He.title||Z!==He.filename||$!==He.description),onClick:async()=>{const e=qe(U);if(e&&e.attachment_id)try{const t=function(e){const t=e.split("."),a=t.length>1?"."+t.pop():"";let n=t.join(".");return n=n.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-+|-+$/g,""),n||(n="file"),n+a.toLowerCase()}(Z),a=await(0,f.IU)(y.y0+"/helpers/update_media_metadata",{method:"POST",nonce:y.ok,json:{attachmentId:e.attachment_id,title:H,description:$,caption:$,alt:H,filename:t}});Oe(Ne.map((n=>n.attachment_id===e.attachment_id?{...n,title:H,filename:t,description:$,caption:$,alt:H,url:a.url||n.url}:n))),a.url&&a.url!==U&&F(D.map((e=>e===U?a.url:e))),ze({title:H,filename:t,description:$}),te(t),B()}catch(e){i(e.message||"Failed to update metadata")}},busy:I},cancelButton:{label:"Close",onClick:()=>B()},customButtons:React.createElement(h.M,{ai:!0,onClick:async()=>{N(!0);try{const e=qe(U);if(null==e||!e.attachment_id)throw new Error("No attachment ID found for this image");const t=await(0,f.IU)(`${y.y0}/helpers/generate_image_meta`,{method:"POST",nonce:y.ok,json:{attachmentId:e.attachment_id}});if(null!=t&&t.data){const e=t.data.title||"",a=t.data.description||"";j(e),z(a),W(a),J(e),t.data.filename&&te(t.data.filename)}}catch(e){"AbortError"===e.name||/aborted/i.test(e.message)||(console.error(e),i(e.message))}finally{N(!1)}},busy:I},"Generate Meta"),content:U&&React.createElement(Rs,null,React.createElement("a",{href:U,target:"_blank",rel:"noreferrer"},React.createElement("img",{src:U})),React.createElement("div",{className:"fields-container"},React.createElement("div",{className:"column"},React.createElement("div",{className:"field"},React.createElement("label",null,"Title"),React.createElement(V.A,{value:H,onChange:j})),React.createElement("div",{className:"field"},React.createElement("label",null,"Filename"),React.createElement(V.A,{value:Z,onChange:te}))),React.createElement("div",{className:"column"},React.createElement("div",{className:"field"},React.createElement("label",null,"Description"),React.createElement($e.m,{value:$,onChange:z,rows:5})))))}),!U&&React.createElement(React.Fragment,null,Se||0!==D.length||0!==xe.length?React.createElement(hs,null,xe.map((e=>React.createElement(Es,{key:e.id},React.createElement("div",{className:"thumbnail"},React.createElement("div",{className:"placeholder"},"Queuing...")),React.createElement("div",{className:"metadata"},React.createElement("div",{className:"title"},"Generating..."),React.createElement("div",{className:"filename"},"—")),React.createElement("div",{className:"actions"})))),D.map(((e,t)=>{ae.find((t=>t.url===e));const a=qe(e);return React.createElement(Es,{key:e,onClick:()=>B(e)},React.createElement("div",{className:"thumbnail"},React.createElement("img",{src:e})),React.createElement("div",{className:"metadata"},React.createElement("div",{className:"title"},(null==a?void 0:a.title)||`Untitled Image #${t+1}`),React.createElement("div",{className:"filename"},(null==a?void 0:a.filename)||"image.png"),(null==a?void 0:a.description)&&React.createElement("div",{className:"description"},a.description),(null==a?void 0:a.created_at)&&React.createElement("div",{className:"timestamp"},(e=>{if(!e)return"";const t=Date.now()/1e3-e;return t<60?"Just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})(a.created_at),a.model&&` • ${a.model}`,a.generation_time&&` • ${a.generation_time}s`)),React.createElement("div",{className:"actions"},a&&a.attachment_id&&React.createElement(React.Fragment,null,React.createElement(h.M,{rounded:!0,icon:"check",onClick:t=>(async(e,t)=>{e&&e.stopPropagation();const a=qe(t);if(a&&a.attachment_id)try{await(0,f.IU)(y.y0+"/helpers/approve_media",{method:"POST",nonce:y.ok,json:{attachmentId:a.attachment_id}}),F(D.filter((e=>e!==t))),Oe(Ne.filter((e=>e.url!==t)))}catch(e){i(e.message||"Failed to approve image")}})(t,e)}),React.createElement(h.M,{rounded:!0,className:"danger",icon:"close",onClick:t=>(async(e,t)=>{e&&e.stopPropagation();const a=qe(t);if(a&&a.attachment_id&&confirm("Are you sure you want to reject and delete this image?"))try{await(0,f.IU)(y.y0+"/helpers/reject_media",{method:"POST",nonce:y.ok,json:{attachmentId:a.attachment_id}}),F(D.filter((e=>e!==t))),Oe(Ne.filter((e=>e.url!==t)))}catch(e){i(e.message||"Failed to reject image")}})(t,e)}))))}))):React.createElement(fs,null,React.createElement(je.z,null,"image"),React.createElement(s.s,{h3:!0},"No images yet"),React.createElement(s.s,{p:!0},"Images will appear here as drafts after generation. You can edit their metadata before approving. Approve adds them to the Media Library, Reject removes them permanently."))))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,{style:{marginBottom:25}},React.createElement(Ue,{onClick:()=>ue(!me),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginTop:0,marginBottom:0}},oe.A.COMMON.MODEL),React.createElement(je.z,{icon:me?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),me&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),React.createElement("label",null,oe.A.COMMON.ENVIRONMENT,":"),React.createElement(K.u,{scrolldown:!0,name:"envId",value:(null==n?void 0:n.envId)??"",onChange:Be},React.createElement(K.j,{value:"",label:"Default"}),k.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),React.createElement("label",null,oe.A.COMMON.MODEL,":"),React.createElement(K.u,{scrolldown:!0,name:"model",value:(null==n?void 0:n.model)||"",disabled:!(null!=n&&n.envId),onChange:Be},React.createElement(K.j,{value:"",label:null!=n&&n.envId?"None":"Default"}),S.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name})))),(null==x||null===(e=x.resolutions)||void 0===e?void 0:e.length)>0&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.RESOLUTION,":"),React.createElement(K.u,{scrolldown:!0,name:"resolution",value:(null==n?void 0:n.resolution)||"",onChange:Be},React.createElement(K.j,{value:"",label:"Default"}),null==x||null===(t=x.resolutions)||void 0===t?void 0:t.map((e=>React.createElement(K.j,{key:e.name,value:e.name,label:e.label}))))),"custom"===(null==n?void 0:n.resolution)&&React.createElement(React.Fragment,null,React.createElement("label",null,"Custom Resolution:"),React.createElement(V.A,{name:"customResolution",value:null==n?void 0:n.customResolution,onChange:e=>Be(e,"customResolution")})),(null==x||null===(a=x.model)||void 0===a?void 0:a.startsWith("dall-e-3"))&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.STYLE,":"),React.createElement(K.u,{scrolldown:!0,name:"style",value:Le,onChange:Be},React.createElement(K.j,{key:"none",value:null,label:"None"}),React.createElement(K.j,{key:"natural",value:"natural",label:"Natural"}),React.createElement(K.j,{key:"vivid",value:"vivid",label:"Vivid"}))))))),React.createElement(ee.n,{isOpen:o,onRequestClose:()=>{i()},okButton:{onClick:()=>{i()}},title:"Error",content:React.createElement("p",null,o)}),React.createElement(ee.n,{isOpen:p,onRequestClose:()=>E(!1),okButton:{onClick:()=>E(!1)},title:"Image Edit",content:React.createElement("p",null,"Editing images is only available via the Edit action in the Media Library and is still in active development.")}))},{useState:vs,useEffect:bs,useRef:ws,useCallback:_s,useMemo:Ts}=wp.element,Cs=b.Ay.div`754 `,ys=()=>{var e,t,a;const{template:n,setTemplate:l,jsxTemplates:r}=Li("imagesGenerator"),[o,i]=ss(),c=new URLSearchParams(window.location.search).get("editId"),[d,m]=ss(c?"edit":"generate"),[p,E]=ss(!1),[R,v]=ss(),[b,w]=ss(""),[_,T]=ss(!1),[C,A]=ss(!1),[I,N]=ss(!1),[O,S]=ss(!1),M=(null===y.fF||void 0===y.fF?void 0:y.fF.ai_envs)||[],{imageModels:x,getModel:k}=he(y.fF,(null==n?void 0:n.envId)||null),P=k(null==n?void 0:n.model),L=ds((()=>{if(null===y.fF||void 0===y.fF||!y.fF.ai_engines||!M)return[];const e=(e,t)=>!(!e||!e.tags)&&(!!Array.isArray(e.tags)&&e.tags.includes(t));return M.filter((t=>{for(const a of y.fF.ai_engines){if(!a.models)continue;if(a.type!==t.type)continue;if(a.models.some((t=>e(t,"image")||e(t,"image-generation"))))return!0}return!1}))}),[M,y.fF]),[D,F]=ss([]),[U,B]=ss([]),[H,j]=ss(),[$,z]=ss(""),[G,W]=ss(""),[q,J]=ss(""),[Z,te]=ss(""),[ae,ne]=ss(""),[le,re]=ss([]),[ie,se]=ss(!1),[ce,de]=ss(null),[me,ue]=ss(30),[ge,Re]=ss(!0),[fe,ye]=ss({x:0,y:0,visible:!1}),ve=ms(),be=ms(),we=ms(),_e=(ms([]),"edit"===d?b:null==n?void 0:n.prompt),[Te,Ce]=ss(1),[Ae,Ie]=ss(0),[Ne,Oe]=ss(0),[Se,Me]=ss([]),[xe,ke]=ss(!0),[Pe,Le]=ss([]),De=ms(),Be=(null==n?void 0:n.style)??null,He=e=>{"edit"===d?w(e):l({...n,prompt:e})},ze=(e,t)=>{l((a=>{const n={...a,[t]:e};return"envId"===t&&""===e&&(n.model="",n.resolution=""),"model"===t&&(n.resolution=""),n}))},[Ge,We]=ss({title:"",filename:"",description:""});cs((()=>{if(H){const e=Ve(H);let t,a,n;if(e&&e.attachment_id)t=e.filename||"",a=e.title||"",n=e.description||"";else{const e=U.indexOf(H)+1;t=(us(_e).toLowerCase()||"image")+".png",a=`Untitled Image #${e||1}`,n=_e||""}ne(t),z(a),W(n),J(n),te(a),We({title:a,filename:t,description:n})}}),[H]);cs((()=>{c&&fetch(`${y.gh}/wp/v2/media/${c}`).then((e=>e.json())).then((e=>v(e.source_url)))}),[c]),cs((()=>{(async()=>{try{const e=await(0,f.IU)(y.y0+"/helpers/list_draft_media?type=image",{method:"GET",nonce:y.ok});if(e.success&&e.media){const t=[...e.media].sort(((e,t)=>(t.created_at||0)-(e.created_at||0)));Me(t);const a=t.map((e=>e.url));B(a)}}catch(e){console.error("Error loading draft images:",e)}finally{ke(!1)}})()}),[]),cs((()=>{if(R&&be.current&&ve.current){const e=be.current,t=ve.current;e.onload=()=>{t.width=e.naturalWidth,t.height=e.naturalHeight;t.getContext("2d").clearRect(0,0,t.width,t.height),we.current||(we.current=document.createElement("canvas")),we.current.width=t.width,we.current.height=t.height}}}),[R]),cs((()=>{if(!ie)return;const e=e=>{"["===e.key?(e.preventDefault(),ue((e=>Math.max(5,e-5)))):"]"===e.key&&(e.preventDefault(),ue((e=>Math.min(200,e+5))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[ie]);const qe=ms();cs((()=>{if(R&&be.current&&qe.current){const e=be.current,t=qe.current;e.onload=()=>{t.width=e.naturalWidth,t.height=e.naturalHeight}}}),[R]);const Ke=(e,t,a,n,l)=>{const r=e.createRadialGradient(t,a,0,t,a,n/2);if(l>=1)r.addColorStop(0,"rgba(255, 0, 0, 1)"),r.addColorStop(1,"rgba(255, 0, 0, 1)");else{const e=.5*l;r.addColorStop(0,"rgba(255, 0, 0, 1)"),r.addColorStop(e,"rgba(255, 0, 0, 1)"),r.addColorStop(1,"rgba(255, 0, 0, 0)")}e.fillStyle=r,e.beginPath(),e.arc(t,a,n/2,0,2*Math.PI),e.fill()};cs((()=>{D.length>0&&!_&&(async()=>{if(0===D.length||_)return;T(!0),De.current=new AbortController;const e=D[0],t=Date.now();try{const a="edit"===d?"image_edit":"images",n={env:"admin-tools",envId:e.envId||void 0,model:e.model||void 0,resolution:e.resolution,style:e.style,scope:"admin-tools",session:y.dZ,message:e.prompt,maxResults:1,mediaId:c,local_download:null};let l;if(console.log("Image Edit Request:",{mode:d,endpoint:a,hasMask:!!ce,editId:c,requestData:n}),"edit"===d&&ce){const e=new FormData;Object.keys(n).forEach((t=>{null!==n[t]&&void 0!==n[t]&&e.append(t,String(n[t]))})),e.append("mask",ce,"mask.png"),console.log("FormData contents:");for(let[t,a]of e.entries())console.log(t,a);if(l=await fetch(`${y.y0}/ai/${a}`,{method:"POST",headers:{"X-WP-Nonce":y.ok},signal:De.current.signal,body:e}),!l.ok){const e=await l.json();throw new Error(e.message||"Request failed")}l=await l.json()}else l=await(0,f.IU)(`${y.y0}/ai/${a}`,{method:"POST",nonce:y.ok,signal:De.current.signal,json:n});if(l.data&&l.data.length>0){const a=l.data[0];e.id&&Le((t=>t.filter((t=>t.id!==e.id)))),B((e=>[a,...e]));try{const n=U.length+1,l=(us(e.prompt).toLowerCase()||"image")+".png",r=`Untitled Image #${n}`,o=((Date.now()-t)/1e3).toFixed(1),i=await(0,f.IU)(`${y.y0}/helpers/create_image`,{method:"POST",nonce:y.ok,json:{url:a,title:r,description:e.prompt||"",caption:"",alt:"",filename:l,model:e.model,latency:o,env_id:e.envId}});i.success&&i.attachmentId&&Me((t=>[{url:a,attachment_id:i.attachmentId,title:r,description:e.prompt||"",filename:l,model:e.model,generation_time:o,env_id:e.envId,created_at:Date.now()/1e3},...t]))}catch(e){console.error("Error auto-saving image to draft media:",e)}}F((e=>e.slice(1))),Oe((e=>e+1)),1===D.length&&(Ie(0),Oe(0))}catch(t){"AbortError"===t.name||/aborted/i.test(t.message)||(console.error(t),i(t.message+(D.length>1?" The other tasks will continue.":"")),e.id&&Le((t=>t.filter((t=>t.id!==e.id)))),F((e=>e.slice(1))),Ie((e=>e-1)))}finally{T(!1)}})()}),[D,_]);const Ve=e=>Se.find((t=>t.url===e));return React.createElement(u.z,{nekoErrors:[]},React.createElement(Fe,{title:oe.A.COMMON.IMAGES_GENERATOR}),React.createElement(g.N,null,React.createElement(Ee,{options:y.fF}),(null===y.fF||void 0===y.fF?void 0:y.fF.intro_message)&&React.createElement(g.Y,{fullWidth:!0},React.createElement(X.L,{style:{marginBottom:0}},React.createElement(s.s,{p:!0},(0,f.FE)(oe.A.COMMON.IMAGES_GENERATOR_INTRO)))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,null,"edit"===d&&R&&React.createElement(React.Fragment,null,React.createElement(ps,{maskMode:ie,onMouseMove:e=>{if(ie){const t=e.currentTarget.getBoundingClientRect();ye({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})}},onMouseLeave:()=>ye((e=>({...e,visible:!1})))},React.createElement("img",{ref:be,src:R}),React.createElement("canvas",{ref:ve,onMouseDown:e=>{if(!ie)return;const t=ve.current,a=t.getBoundingClientRect(),n=t.getContext("2d"),l=t.width/a.width,r=t.height/a.height,o=me*l;let i=!0,s=(e.clientX-a.left)*l,c=(e.clientY-a.top)*r;const d=.5;let m=null;const u=e=>{n.save(),n.globalAlpha=e,Ke(n,s,c,o,.5),n.restore()};let p=d,g=!0;const E=()=>{i&&(g?(u(d),g=!1):(p=Math.min(p+.05,1),u(.05)),m=requestAnimationFrame(E))};E();const h=e=>{if(!i)return;const t=(e.clientX-a.left)*l,m=(e.clientY-a.top)*r,u=t-s,E=m-c,h=Math.sqrt(u*u+E*E);if(h>1){const e=Math.ceil(h/2);for(let t=1;t<=e;t++){const a=t/e,l=s+u*a,r=c+E*a;n.save(),n.globalAlpha=.15,Ke(n,l,r,o,.5),n.restore()}s=t,c=m,p=d,g=!0}},R=()=>{i=!1,m&&cancelAnimationFrame(m),(e=>{const t=ve.current,a=document.createElement("canvas");a.width=t.width,a.height=t.height;const n=a.getContext("2d");n.fillStyle="black",n.fillRect(0,0,a.width,a.height);const l=t.getContext("2d").getImageData(0,0,t.width,t.height),r=n.getImageData(0,0,a.width,a.height);for(let e=0;e<l.data.length;e+=4){const t=l.data[e],a=l.data[e+3];t>200&&a>100&&(r.data[e]=0,r.data[e+1]=0,r.data[e+2]=0,r.data[e+3]=0)}n.putImageData(r,0,0),a.toBlob(e,"image/png")})((e=>{de(e)})),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",R)}}),React.createElement(gs,{visible:fe.visible&&ie,style:{left:fe.x,top:fe.y,width:me,height:me}})),React.createElement("div",{style:{display:"flex",gap:5,marginBottom:5}},React.createElement(h.M,{onClick:()=>{if(ie){const e=ve.current;e.getContext("2d").clearRect(0,0,e.width,e.height),de(null),se(!1)}else se(!0)},style:{flex:2}},ie?"Remove Mask":"Create Mask"),ie&&React.createElement(React.Fragment,null,React.createElement(h.M,{onClick:()=>ue((e=>Math.max(5,e-5))),style:{flex:1},title:"Decrease brush size"},"−"),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0 10px",border:"1px solid #ddd",borderRadius:4,background:"#f5f5f5",minWidth:40}},me),React.createElement(h.M,{onClick:()=>ue((e=>Math.min(200,e+5))),style:{flex:1},title:"Increase brush size"},"+"))),ie&&React.createElement("div",{style:{fontSize:11,opacity:.6,marginBottom:10,textAlign:"center"}},"Use [ and ] keys to adjust brush size")),"edit"!==d&&r),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement("h2",{style:{marginTop:0}},(0,f.FE)(oe.A.COMMON.PROMPT)),React.createElement($e.m,{value:_e,onChange:He,rows:10,placeholder:"Describe the image you want to generate..."})),React.createElement(Y.g,null),React.createElement(Na,null,React.createElement(h.M,{fullWidth:!0,disabled:!_e,ai:!0,onClick:()=>{if(!_e)return void console.error("Prompt is empty, cannot add to queue.");if("edit"===d&&!pe(P,"image-edit"))return void i("This model does not support image editing.");const e=Date.now()+Math.random(),t={id:e,prompt:_e,envId:n.envId,model:n.model,resolution:n.resolution,style:n.style};Le((t=>[...t,{id:e,status:"queuing"}])),F((e=>[...e,t]))},style:{height:50,fontSize:16,flex:4}},oe.A.COMMON.GENERATE))),React.createElement(g.Y,{style:{flex:2}},React.createElement(Q.o,{value:d,onChange:e=>{"generate"===e?location.href="edit.php?page=mwai_images_generator":"edit"===e&&(c?m("edit"):E(!0))}},React.createElement(Q.K,{title:"Create",value:"generate"}),React.createElement(Q.K,{title:"Editor",value:"edit"})),React.createElement(Y.g,null),React.createElement("div",null,React.createElement(ee.n,{isOpen:!!H,title:"Image Details",size:"larger",onRequestClose:()=>j(),okButton:{label:"Save Meta",disabled:!($!==Ge.title||ae!==Ge.filename||G!==Ge.description),onClick:async()=>{const e=Ve(H);if(e&&e.attachment_id)try{const t=function(e){const t=e.split("."),a=t.length>1?"."+t.pop():"";let n=t.join(".");return n=n.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-+|-+$/g,""),n||(n="file"),n+a.toLowerCase()}(ae),a=await(0,f.IU)(y.y0+"/helpers/update_media_metadata",{method:"POST",nonce:y.ok,json:{attachmentId:e.attachment_id,title:$,description:G,caption:G,alt:$,filename:t}});Me(Se.map((n=>n.attachment_id===e.attachment_id?{...n,title:$,filename:t,description:G,caption:G,alt:$,url:a.url||n.url}:n))),a.url&&a.url!==H&&B(U.map((e=>e===H?a.url:e))),We({title:$,filename:t,description:G}),ne(t),j()}catch(e){i(e.message||"Failed to update metadata")}},busy:O},cancelButton:{label:"Close",onClick:()=>j()},customButtons:React.createElement(h.M,{ai:!0,onClick:async()=>{S(!0);try{const e=Ve(H);if(null==e||!e.attachment_id)throw new Error("No attachment ID found for this image");const t=await(0,f.IU)(`${y.y0}/helpers/generate_image_meta`,{method:"POST",nonce:y.ok,json:{attachmentId:e.attachment_id}});if(null!=t&&t.data){const e=t.data.title||"",a=t.data.description||"";z(e),W(a),J(a),te(e),t.data.filename&&ne(t.data.filename)}}catch(e){"AbortError"===e.name||/aborted/i.test(e.message)||(console.error(e),i(e.message))}finally{S(!1)}},busy:O},"Generate Meta"),content:H&&React.createElement(Rs,null,React.createElement("a",{href:H,target:"_blank",rel:"noreferrer"},React.createElement("img",{src:H})),React.createElement("div",{className:"fields-container"},React.createElement("div",{className:"column"},React.createElement("div",{className:"field"},React.createElement("label",null,"Title"),React.createElement(V.A,{value:$,onChange:z})),React.createElement("div",{className:"field"},React.createElement("label",null,"Filename"),React.createElement(V.A,{value:ae,onChange:ne}))),React.createElement("div",{className:"column"},React.createElement("div",{className:"field"},React.createElement("label",null,"Description"),React.createElement($e.m,{value:G,onChange:W,rows:5})))))}),!H&&React.createElement(React.Fragment,null,xe||0!==U.length||0!==Pe.length?React.createElement(hs,null,Pe.map((e=>React.createElement(Es,{key:e.id},React.createElement("div",{className:"thumbnail"},React.createElement("div",{className:"placeholder"},"Queuing...")),React.createElement("div",{className:"metadata"},React.createElement("div",{className:"title"},"Generating..."),React.createElement("div",{className:"filename"},"—")),React.createElement("div",{className:"actions"})))),U.map(((e,t)=>{le.find((t=>t.url===e));const a=Ve(e);return React.createElement(Es,{key:e,onClick:()=>j(e)},React.createElement("div",{className:"thumbnail"},React.createElement("img",{src:e})),React.createElement("div",{className:"metadata"},React.createElement("div",{className:"title"},(null==a?void 0:a.title)||`Untitled Image #${t+1}`),React.createElement("div",{className:"filename"},(null==a?void 0:a.filename)||"image.png"),(null==a?void 0:a.description)&&React.createElement("div",{className:"description"},a.description),(null==a?void 0:a.created_at)&&React.createElement("div",{className:"timestamp"},(e=>{if(!e)return"";const t=Date.now()/1e3-e;return t<60?"Just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})(a.created_at),a.model&&` • ${a.model}`,a.generation_time&&` • ${a.generation_time}s`)),React.createElement("div",{className:"actions"},a&&a.attachment_id&&React.createElement(React.Fragment,null,React.createElement(h.M,{rounded:!0,icon:"check",onClick:t=>(async(e,t)=>{e&&e.stopPropagation();const a=Ve(t);if(a&&a.attachment_id)try{await(0,f.IU)(y.y0+"/helpers/approve_media",{method:"POST",nonce:y.ok,json:{attachmentId:a.attachment_id}}),B(U.filter((e=>e!==t))),Me(Se.filter((e=>e.url!==t)))}catch(e){i(e.message||"Failed to approve image")}})(t,e)}),React.createElement(h.M,{rounded:!0,className:"danger",icon:"close",onClick:t=>(async(e,t)=>{e&&e.stopPropagation();const a=Ve(t);if(a&&a.attachment_id&&confirm("Are you sure you want to reject and delete this image?"))try{await(0,f.IU)(y.y0+"/helpers/reject_media",{method:"POST",nonce:y.ok,json:{attachmentId:a.attachment_id}}),B(U.filter((e=>e!==t))),Me(Se.filter((e=>e.url!==t)))}catch(e){i(e.message||"Failed to reject image")}})(t,e)}))))}))):React.createElement(fs,null,React.createElement(je.z,null,"image"),React.createElement(s.s,{h3:!0},"No images yet"),React.createElement(s.s,{p:!0},"Images will appear here as drafts after generation. You can edit their metadata before approving. Approve adds them to the Media Library, Reject removes them permanently."))))),React.createElement(g.Y,{style:{flex:1}},React.createElement(Na,{style:{marginBottom:25}},React.createElement(Ue,{onClick:()=>Re(!ge),style:{cursor:"pointer"}},React.createElement("h2",{style:{marginTop:0,marginBottom:0}},oe.A.COMMON.MODEL),React.createElement(je.z,{icon:ge?"chevron-up":"chevron-down",height:"20",style:{opacity:.7}})),ge&&React.createElement(React.Fragment,null,React.createElement(Y.g,{tiny:!0}),React.createElement("label",null,oe.A.COMMON.ENVIRONMENT,":"),React.createElement(K.u,{scrolldown:!0,name:"envId",value:(null==n?void 0:n.envId)??"",onChange:ze},React.createElement(K.j,{value:"",label:"Default"}),L.map((e=>React.createElement(K.j,{key:e.id,value:e.id,label:e.name})))),React.createElement("label",null,oe.A.COMMON.MODEL,":"),React.createElement(K.u,{scrolldown:!0,name:"model",value:(null==n?void 0:n.model)||"",disabled:!(null!=n&&n.envId),onChange:ze},React.createElement(K.j,{value:"",label:null!=n&&n.envId?"None":"Default"}),x.map((e=>React.createElement(K.j,{key:e.model,value:e.model,label:e.name})))),(null==P||null===(e=P.resolutions)||void 0===e?void 0:e.length)>0&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.RESOLUTION,":"),React.createElement(K.u,{scrolldown:!0,name:"resolution",value:(null==n?void 0:n.resolution)||"",onChange:ze},React.createElement(K.j,{value:"",label:"Default"}),null==P||null===(t=P.resolutions)||void 0===t?void 0:t.map((e=>React.createElement(K.j,{key:e.name,value:e.name,label:e.label}))))),"custom"===(null==n?void 0:n.resolution)&&React.createElement(React.Fragment,null,React.createElement("label",null,"Custom Resolution:"),React.createElement(V.A,{name:"customResolution",value:null==n?void 0:n.customResolution,onChange:e=>ze(e,"customResolution")})),(null==P||null===(a=P.model)||void 0===a?void 0:a.startsWith("dall-e-3"))&&React.createElement(React.Fragment,null,React.createElement("label",null,oe.A.COMMON.STYLE,":"),React.createElement(K.u,{scrolldown:!0,name:"style",value:Be,onChange:ze},React.createElement(K.j,{key:"none",value:null,label:"None"}),React.createElement(K.j,{key:"natural",value:"natural",label:"Natural"}),React.createElement(K.j,{key:"vivid",value:"vivid",label:"Vivid"}))))))),React.createElement(ee.n,{isOpen:o,onRequestClose:()=>{i()},okButton:{onClick:()=>{i()}},title:"Error",content:React.createElement("p",null,o)}),React.createElement(ee.n,{isOpen:p,onRequestClose:()=>E(!1),okButton:{onClick:()=>E(!1)},title:"Image Edit",content:React.createElement("p",null,"Editing images is only available via the Edit action in the Media Library and is still in active development.")}))},{useState:vs,useEffect:bs,useRef:ws,useCallback:_s,useMemo:Ts}=wp.element,Cs=b.Ay.div` 755 755 display: flex; 756 756 align-items: center; -
ai-engine/trunk/classes/engines/chatml.php
r3417844 r3421612 391 391 // https://platform.openai.com/docs/api-reference/images/create#images-create-quality 392 392 393 if ( $model === 'gpt-image-1' || $model === 'gpt-image-1-mini') {393 if ( strpos( $model, 'gpt-image' ) === 0 ) { 394 394 // GPT Image models (token-based pricing) 395 395 $body['model'] = $model; // Use the actual model name … … 743 743 ]; 744 744 } 745 745 746 746 // Handle thinking/reasoning content (from Ollama and potentially other models) 747 747 // This can appear alongside or instead of regular content … … 800 800 // Check if this is a realtime model being used with chat completions 801 801 if ( $this->is_realtime_model( $query->model ) ) { 802 throw new Exception( 802 throw new Exception( 803 803 'Realtime models (like ' . $query->model . ') are designed for voice/audio interactions and cannot be used with this API.' 804 804 ); 805 805 } 806 806 807 807 if ( $streamCallback ) { 808 808 // Disable streaming only for "o1" (as December 2024, it works for preview and mini) … … 946 946 private function get_audio( $url ) { 947 947 require_once( ABSPATH . 'wp-admin/includes/media.php' ); 948 948 949 949 // Validate URL scheme to prevent SSRF attacks 950 950 $parts = wp_parse_url( $url ); 951 if ( ! isset( $parts['scheme'] ) || !in_array( $parts['scheme'], [ 'http', 'https' ], true ) ) {951 if ( !isset( $parts['scheme'] ) || !in_array( $parts['scheme'], [ 'http', 'https' ], true ) ) { 952 952 throw new Exception( 'Invalid URL scheme; only HTTP/HTTPS allowed.' ); 953 953 } 954 954 955 955 $tmpFile = tempnam( sys_get_temp_dir(), 'audio_' ); 956 956 file_put_contents( $tmpFile, file_get_contents( $url ) ); … … 967 967 public function run_transcribe_query( $query ) { 968 968 $audioData = null; 969 969 970 970 // Priority 1: Direct audio data 971 971 if ( !empty( $query->audioData ) ) { … … 1093 1093 throw new Exception( 'GPT-5 models only support the Responses API. Please enable "Use Responses API" in AI Engine settings to use ' . $query->model . '.' ); 1094 1094 } 1095 1095 1096 1096 $isStreaming = !is_null( $streamCallback ); 1097 1097 … … 1144 1144 $returned_id = $this->inId; 1145 1145 $returned_model = $this->inModel ? $this->inModel : $query->model; 1146 1146 1147 1147 // Use regular content if available, otherwise fall back to thinking/reasoning 1148 1148 $finalContent = $this->streamContent; … … 1152 1152 // Wrap in asterisks to show as italics in markdown 1153 1153 $finalContent = '*' . $this->streamThinking . '*'; 1154 1154 1155 1155 // Log this for debugging 1156 1156 if ( $this->core->get_option( 'queries_debug_mode' ) ) { … … 1158 1158 } 1159 1159 } 1160 1160 1161 1161 $message = [ 'role' => 'assistant', 'content' => $finalContent ]; 1162 1162 // Prefer tool_calls; fall back to legacy only if necessary … … 1167 1167 $message['function_call'] = $this->streamFunctionCall; 1168 1168 } 1169 1169 1170 1170 // Optionally include thinking as metadata if both content and thinking exist 1171 1171 if ( !empty( $this->streamContent ) && !empty( $this->streamThinking ) ) { … … 1231 1231 throw new Exception( 'No content received (res is null).' ); 1232 1232 } 1233 1233 1234 1234 // Comprehensive logging for non-streaming mode - capture FULL response 1235 1235 $queries_debug = $this->core->get_option( 'queries_debug_mode' ); … … 1239 1239 error_log( json_encode( $data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ); 1240 1240 error_log( '[AI Engine Queries] ========================================' ); 1241 1241 1242 1242 // Look specifically for container_id 1243 1243 $this->search_for_container_id_recursive( $data, '' ); 1244 1244 } 1245 1245 1246 1246 if ( !$data['model'] ) { 1247 1247 $service = $this->get_service_name(); … … 1902 1902 } 1903 1903 1904 1905 1904 // If it's a GET, body should be null, and we should append the query to the URL. 1906 1905 if ( $method === 'GET' ) { … … 1954 1953 $res = wp_remote_retrieve_body( $res ); 1955 1954 1956 1957 1955 // Handle empty responses for container LIST API only (not for file content downloads) 1958 if ( strpos( $url, '/containers/' ) !== false && 1959 strpos( $url, '/files' ) !== false && 1956 if ( strpos( $url, '/containers/' ) !== false && 1957 strpos( $url, '/files' ) !== false && 1960 1958 strpos( $url, '/content' ) === false && // Don't apply this to content downloads 1961 1959 empty( $res ) ) { … … 1963 1961 $data = $json ? [] : ''; 1964 1962 error_log( '[AI Engine] Container LIST API returned empty response, treating as empty array' ); 1965 } else { 1963 } 1964 else { 1966 1965 $data = $json ? json_decode( $res, true ) : $res; 1967 1966 } 1968 1967 1969 1968 // Debug logging for decoded data (skip for content downloads) 1970 1969 if ( strpos( $url, '/containers/' ) !== false && strpos( $url, '/files' ) !== false && strpos( $url, '/content' ) === false ) { … … 1980 1979 } 1981 1980 } 1982 1981 1983 1982 $this->handle_response_errors( $data ); 1984 1983 … … 2045 2044 foreach ( $data as $key => $value ) { 2046 2045 $currentPath = $path ? $path . '.' . $key : $key; 2047 2046 2048 2047 // Check if this key is container_id 2049 2048 if ( $key === 'container_id' ) { 2050 2049 error_log( '[AI Engine Queries] *** FOUND container_id at path: ' . $currentPath . ' = ' . $value . ' ***' ); 2051 2050 } 2052 2051 2053 2052 // Recursively search in nested structures 2054 2053 if ( is_array( $value ) || is_object( $value ) ) { -
ai-engine/trunk/classes/engines/mistral.php
r3417844 r3421612 2 2 3 3 class Meow_MWAI_Engines_Mistral extends Meow_MWAI_Engines_ChatML { 4 5 4 public function __construct( $core, $env ) { 6 5 parent::__construct( $core, $env ); … … 122 121 if ( strpos( $modelId, 'medium' ) !== false ) { 123 122 $name = 'Magistral Medium'; 124 } else if ( strpos( $modelId, 'small' ) !== false ) { 123 } 124 else if ( strpos( $modelId, 'small' ) !== false ) { 125 125 $name = 'Magistral Small'; 126 126 } … … 132 132 if ( strpos( $modelId, 'large' ) !== false ) { 133 133 $name = 'Mistral Large'; 134 } else if ( strpos( $modelId, 'medium' ) !== false ) { 134 } 135 else if ( strpos( $modelId, 'medium' ) !== false ) { 135 136 $name = 'Mistral Medium'; 136 } else if ( strpos( $modelId, 'small' ) !== false ) { 137 } 138 else if ( strpos( $modelId, 'small' ) !== false ) { 137 139 $name = 'Mistral Small'; 138 } else if ( strpos( $modelId, 'saba' ) !== false ) { 140 } 141 else if ( strpos( $modelId, 'saba' ) !== false ) { 139 142 $name = 'Mistral Saba'; 140 } else if ( strpos( $modelId, 'tiny' ) !== false || strpos( $modelId, 'nemo' ) !== false ) { 143 } 144 else if ( strpos( $modelId, 'tiny' ) !== false || strpos( $modelId, 'nemo' ) !== false ) { 141 145 $name = 'Mistral Nemo'; 142 } else if ( strpos( $modelId, 'embed' ) !== false ) { 146 } 147 else if ( strpos( $modelId, 'embed' ) !== false ) { 143 148 $name = 'Mistral Embed'; 144 149 } … … 148 153 if ( strpos( $modelId, 'large' ) !== false ) { 149 154 $name = 'Pixtral Large'; 150 } else if ( strpos( $modelId, '12b' ) !== false ) { 155 } 156 else if ( strpos( $modelId, '12b' ) !== false ) { 151 157 $name = 'Pixtral 12B'; 152 158 } … … 157 163 if ( strpos( $modelId, 'embed' ) !== false ) { 158 164 $name = 'Codestral Embed'; 159 } else { 165 } 166 else { 160 167 $name = 'Codestral'; 161 168 // No version suffix for Codestral … … 166 173 if ( strpos( $modelId, 'medium' ) !== false ) { 167 174 $name = 'Devstral Medium'; 168 } else if ( strpos( $modelId, 'small' ) !== false ) { 175 } 176 else if ( strpos( $modelId, 'small' ) !== false ) { 169 177 $name = 'Devstral Small'; 170 178 // No version suffix for Devstral … … 176 184 if ( strpos( $modelId, '8b' ) !== false ) { 177 185 $name = 'Ministral 8B'; 178 } else if ( strpos( $modelId, '3b' ) !== false ) { 186 } 187 else if ( strpos( $modelId, '3b' ) !== false ) { 179 188 $name = 'Ministral 3B'; 180 189 } … … 185 194 if ( strpos( $modelId, 'small' ) !== false ) { 186 195 $name = 'Voxtral Small'; 187 } else if ( strpos( $modelId, 'mini' ) !== false ) { 196 } 197 else if ( strpos( $modelId, 'mini' ) !== false ) { 188 198 $name = 'Voxtral Mini'; 189 199 } … … 196 206 if ( strpos( $modelId, 'mistral-7b' ) !== false ) { 197 207 $name = 'Mistral 7B (Open)'; 198 } else if ( strpos( $modelId, 'mistral-nemo' ) !== false ) { 208 } 209 else if ( strpos( $modelId, 'mistral-nemo' ) !== false ) { 199 210 $name = 'Mistral Nemo (Open)'; 200 } else if ( strpos( $modelId, 'mixtral-8x7b' ) !== false ) { 211 } 212 else if ( strpos( $modelId, 'mixtral-8x7b' ) !== false ) { 201 213 $name = 'Mixtral 8x7B (Open)'; 202 } else if ( strpos( $modelId, 'mixtral-8x22b' ) !== false ) { 214 } 215 else if ( strpos( $modelId, 'mixtral-8x22b' ) !== false ) { 203 216 $name = 'Mixtral 8x22B (Open)'; 204 217 } … … 349 362 if ( isset( $model['max_context_length'] ) ) { 350 363 $maxContextualTokens = (int) $model['max_context_length']; 351 } else if ( isset( $model['context_window'] ) ) { 364 } 365 else if ( isset( $model['context_window'] ) ) { 352 366 $maxContextualTokens = (int) $model['context_window']; 353 367 } … … 363 377 $priceIn = 4.00; 364 378 $priceOut = 12.00; 365 } else { 379 } 380 else { 366 381 $priceIn = 2.00; 367 382 $priceOut = 6.00; 368 383 } 369 } else if ( strpos( $modelId, 'mistral-large' ) !== false || strpos( $modelId, 'pixtral-large' ) !== false ) { 384 } 385 else if ( strpos( $modelId, 'mistral-large' ) !== false || strpos( $modelId, 'pixtral-large' ) !== false ) { 370 386 $priceIn = 3.00; 371 387 $priceOut = 9.00; 372 } else if ( strpos( $modelId, 'mistral-medium' ) !== false ) { 388 } 389 else if ( strpos( $modelId, 'mistral-medium' ) !== false ) { 373 390 $priceIn = 2.70; 374 391 $priceOut = 8.10; 375 } else if ( strpos( $modelId, 'mistral-small' ) !== false ) { 392 } 393 else if ( strpos( $modelId, 'mistral-small' ) !== false ) { 376 394 $priceIn = 1.00; 377 395 $priceOut = 3.00; 378 } else if ( strpos( $modelId, 'codestral' ) !== false ) { 396 } 397 else if ( strpos( $modelId, 'codestral' ) !== false ) { 379 398 if ( strpos( $modelId, '2501' ) !== false || strpos( $modelId, '2508' ) !== false ) { 380 399 $priceIn = 0.30; 381 400 $priceOut = 0.90; 382 } else { 401 } 402 else { 383 403 $priceIn = 1.00; 384 404 $priceOut = 3.00; 385 405 } 386 } else if ( strpos( $modelId, 'devstral' ) !== false ) { 406 } 407 else if ( strpos( $modelId, 'devstral' ) !== false ) { 387 408 $priceIn = 0.50; 388 409 $priceOut = 1.50; 389 } else if ( strpos( $modelId, 'ministral' ) !== false ) { 410 } 411 else if ( strpos( $modelId, 'ministral' ) !== false ) { 390 412 $priceIn = 0.10; 391 413 $priceOut = 0.10; 392 } else if ( strpos( $modelId, 'pixtral-12b' ) !== false ) { 414 } 415 else if ( strpos( $modelId, 'pixtral-12b' ) !== false ) { 393 416 $priceIn = 0.15; 394 417 $priceOut = 0.15; 395 } else if ( strpos( $modelId, 'voxtral' ) !== false ) { 418 } 419 else if ( strpos( $modelId, 'voxtral' ) !== false ) { 396 420 $priceIn = 0.50; 397 421 $priceOut = 1.50; 398 } else if ( strpos( $modelId, 'mistral-saba' ) !== false ) { 422 } 423 else if ( strpos( $modelId, 'mistral-saba' ) !== false ) { 399 424 $priceIn = 0.20; 400 425 $priceOut = 0.60; 401 } else if ( strpos( $modelId, 'open-mistral' ) !== false || strpos( $modelId, 'mistral-tiny' ) !== false ) { 426 } 427 else if ( strpos( $modelId, 'open-mistral' ) !== false || strpos( $modelId, 'mistral-tiny' ) !== false ) { 402 428 $priceIn = 0.15; 403 429 $priceOut = 0.15; 404 } else if ( strpos( $modelId, 'open-mixtral-8x7b' ) !== false ) { 430 } 431 else if ( strpos( $modelId, 'open-mixtral-8x7b' ) !== false ) { 405 432 $priceIn = 0.50; 406 433 $priceOut = 0.50; 407 } else if ( strpos( $modelId, 'open-mixtral-8x22b' ) !== false ) { 434 } 435 else if ( strpos( $modelId, 'open-mixtral-8x22b' ) !== false ) { 408 436 $priceIn = 0.90; 409 437 $priceOut = 0.90; 410 } else if ( strpos( $modelId, 'embed' ) !== false ) { 438 } 439 else if ( strpos( $modelId, 'embed' ) !== false ) { 411 440 $priceIn = 0.10; 412 441 $priceOut = 0.00; 413 } else { 442 } 443 else { 414 444 // Default pricing for unknown models 415 445 $priceIn = 1.00; 416 446 $priceOut = 3.00; 417 447 } 418 419 // Mark this model as seen420 $seenModels[$modelName] = true;421 448 422 449 // Only include latest models and key open-source versions … … 459 486 } 460 487 488 // Mark this model as seen (after confirming it will be included) 489 $seenModels[$modelName] = true; 490 461 491 $models[] = [ 462 492 'model' => $modelId, … … 485 515 } 486 516 487 488 517 /** 489 518 * Connection check for Mistral API -
ai-engine/trunk/classes/engines/openai.php
r3417844 r3421612 533 533 else if ( $query instanceof Meow_MWAI_Query_Image ) { 534 534 // For image generation, we can use the integrated approach 535 if ( $query->model === 'gpt-image-1') {535 if ( strpos( $query->model, 'gpt-image' ) === 0 ) { 536 536 $body['tools'] = [[ 537 537 'type' => 'image_generation' … … 960 960 if ( isset( $this->env['deployments'] ) && is_array( $this->env['deployments'] ) ) { 961 961 foreach ( $this->env['deployments'] as $deployment ) { 962 // Check if this is a n image model deployment (gpt-image-1)963 if ( isset( $deployment['model'] ) && $deployment['model'] === 'gpt-image-1'&& isset( $deployment['name'] ) ) {962 // Check if this is a gpt-image model deployment 963 if ( isset( $deployment['model'] ) && strpos( $deployment['model'], 'gpt-image' ) === 0 && isset( $deployment['name'] ) ) { 964 964 $headers['x-ms-oai-image-generation-deployment'] = $deployment['name']; 965 965 Meow_MWAI_Logging::log( 'Responses API: Added Azure image generation deployment header: ' . $deployment['name'] ); -
ai-engine/trunk/classes/query/image.php
r3376814 r3421612 6 6 public ?string $localDownload = 'uploads'; 7 7 public ?string $localDownloadExpiry = 'uploads'; 8 public ?array $attachedFiles = null; 8 9 9 10 #region Constructors, Serialization … … 65 66 } 66 67 68 public function add_file( Meow_MWAI_Query_DroppedFile $file ): void { 69 if ( $this->attachedFiles === null ) { 70 $this->attachedFiles = []; 71 } 72 $this->attachedFiles[] = $file; 73 } 74 75 public function set_files( array $files ): void { 76 $this->attachedFiles = $files; 77 } 78 79 public function get_files(): ?array { 80 return $this->attachedFiles; 81 } 82 83 public function getAttachments(): array { 84 return $this->attachedFiles ?? []; 85 } 86 67 87 // Based on the params of the query, update the attributes 68 88 public function inject_params( array $params ): void { … … 79 99 if ( array_key_exists( 'localDownload', $params ) ) { 80 100 $this->set_local_download( $params['localDownload'] ); 81 } elseif ( array_key_exists( 'local_download', $params ) ) { 101 } 102 elseif ( array_key_exists( 'local_download', $params ) ) { 82 103 $this->set_local_download( $params['local_download'] ); 83 104 } -
ai-engine/trunk/constants/models.php
r3417844 r3421612 616 616 https://platform.openai.com/docs/models/dall-e-3 617 617 */ 618 [ 619 'model' => 'gpt-image-1.5', 620 'name' => 'GPT Image 1.5', 621 'family' => 'gpt-image', 622 'features' => ['text-to-image'], 623 'resolutions' => [ 624 [ 625 'name' => '1024x1024', 626 'label' => '1024x1024' 627 ], 628 [ 629 'name' => '1024x1536', 630 'label' => '1024x1536' 631 ], 632 [ 633 'name' => '1536x1024', 634 'label' => '1536x1024' 635 ] 636 ], 637 'type' => 'token', 638 'mode' => 'image', 639 'price' => [ 640 'in' => 8.00, 641 'out' => 32.00, 642 'cached' => 2.00 643 ], 644 'unit' => 1 / 1000000, 645 'finetune' => false, 646 'tags' => ['core', 'image', 'image-edit', 'responses'] 647 ], 618 648 [ 619 649 'model' => 'gpt-image-1', -
ai-engine/trunk/readme.txt
r3417844 r3421612 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 3.2. 88 Stable tag: 3.2.9 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 243 243 244 244 == Changelog == 245 246 = 3.2.9 (2025/12/17) = 247 * Add: Added support for the new gpt-image-1.5 model, works quite well! 😊 248 * Fix: Restored reliable image editing (added missing file attachment handling, separating the edit mode prompt from templates, and preventing double dots in generated filenames). 249 * Fix: Corrected Mistral model filtering so available models now appear and work as expected. 250 * Fix: Resolved a UI crash when selecting OpenRouter providers that use non-standard model data. 245 251 246 252 = 3.2.8 (2025/12/12) =
Note: See TracChangeset
for help on using the changeset viewer.