Changeset 3496835
- Timestamp:
- 04/01/2026 04:49:20 PM (33 hours ago)
- Location:
- websamurai/trunk
- Files:
-
- 10 edited
-
build/admin.asset.php (modified) (1 diff)
-
build/admin.js (modified) (1 diff)
-
inc/class-websamurai-api-keys.php (modified) (1 diff)
-
inc/enqueue.php (modified) (1 diff)
-
inc/oauth-api.php (modified) (4 diffs)
-
inc/oauth-handler.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
src/admin/App.jsx (modified) (1 diff)
-
src/admin/components/OAuthConnect.jsx (modified) (1 diff)
-
websamurai.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
websamurai/trunk/build/admin.asset.php
r3448047 r3496835 1 <?php return array('dependencies' => array('jquery', 'react', 'react-dom'), 'version' => ' 3a362d81851ad0274853');1 <?php return array('dependencies' => array('jquery', 'react', 'react-dom'), 'version' => '4961a00047da778dee91'); -
websamurai/trunk/build/admin.js
r3448047 r3496835 1 1 /*! For license information please see admin.js.LICENSE.txt */ 2 (()=>{"use strict";var e={20:(e,t,n)=>{var r=n(609),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,a={},u=null,l=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)i.call(t,r)&&!s.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:o,type:e,key:u,ref:l,props:a,_owner:c.current}}t.Fragment=a,t.jsx=u,t.jsxs=u},338:(e,t,n)=>{var r=n(795);t.H=r.createRoot,r.hydrateRoot},609:e=>{e.exports=window.React},795:e=>{e.exports=window.ReactDOM},848:(e,t,n)=>{e.exports=n(20)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=n(338),o=n(609),a=n(848);function i(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var i=r&&r.prototype instanceof u?r:u,l=Object.create(i.prototype);return c(l,"_invoke",function(n,r,o){var a,i,c,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,i=0,c=e,f.n=n,s}};function p(n,r){for(i=n,c=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(c=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(i=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,i=0))}if(o||n>1)return s;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),i=l,c=m;(t=i<2?e:c)||!d;){a||(i?i<3?(i>1&&(f.n=-1),p(i,c)):f.n=c:f.v=c);try{if(u=2,a){if(i||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,i<2&&(i=0)}else 1===i&&(t=a.return)&&t.call(a),i<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==s)break}catch(t){a=e,i=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),l}var s={};function u(){}function l(){}function d(){}t=Object.getPrototypeOf;var f=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return l.prototype=d,c(p,"constructor",d),c(d,"constructor",l),l.displayName="GeneratorFunction",c(d,o,"GeneratorFunction"),c(p),c(p,o,"Generator"),c(p,r,function(){return this}),c(p,"toString",function(){return"[object Generator]"}),(i=function(){return{w:a,m}})()}function c(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,n,r){function a(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},c(e,t,n,r)}function s(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,c,"next",e)}function c(e){s(a,r,o,i,c,"throw",e)}i(void 0)})}}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const f=function(){var e=l((0,o.useState)([]),2),t=e[0],n=e[1],r=l((0,o.useState)(!0),2),c=r[0],s=r[1],d=l((0,o.useState)(null),2),f=d[0],p=d[1],m=l((0,o.useState)(""),2),h=m[0],v=m[1],y=l((0,o.useState)(null),2),b=y[0],j=y[1],g=l((0,o.useState)(!1),2),x=g[0],w=g[1],A=window.samurAiAdmin||{},N=(A.ajaxUrl,A.nonce),S=A.apiUrl;(0,o.useEffect)(function(){k()},[]);var k=function(){var e=u(i().m(function e(){var t,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,s(!0),e.n=1,fetch("".concat(S,"/api-keys"),{headers:{"X-WP-Nonce":N}});case 1:if((t=e.v).ok){e.n=2;break}throw new Error("Failed to fetch API keys");case 2:return e.n=3,t.json();case 3:r=e.v,n(r),p(null),e.n=5;break;case 4:e.p=4,o=e.v,p(o.message);case 5:return e.p=5,s(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),P=function(){var e=u(i().m(function e(t){var n,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),h.trim()){e.n=1;break}return p("Please enter a name for the API key"),e.a(2);case 1:return e.p=1,w(!0),p(null),e.n=2,fetch("".concat(S,"/api-keys"),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":N},body:JSON.stringify({name:h})});case 2:if((n=e.v).ok){e.n=3;break}throw new Error("Failed to generate API key");case 3:return e.n=4,n.json();case 4:return r=e.v,j(r),v(""),e.n=5,k();case 5:e.n=7;break;case 6:e.p=6,o=e.v,p(o.message);case 7:return e.p=7,w(!1),e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}));return function(t){return e.apply(this,arguments)}}(),I=function(){var e=u(i().m(function e(t){var n;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to delete this API key?")){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,fetch("".concat(S,"/api-keys/").concat(t),{method:"DELETE",headers:{"X-WP-Nonce":N}});case 2:if(e.v.ok){e.n=3;break}throw new Error("Failed to delete API key");case 3:return e.n=4,k();case 4:e.n=6;break;case 5:e.p=5,n=e.v,p(n.message);case 6:return e.a(2)}},e,null,[[1,5]])}));return function(t){return e.apply(this,arguments)}}();return c&&0===t.length?(0,a.jsx)("div",{className:"loading",children:"Loading API keys..."}):(0,a.jsxs)("div",{className:"api-key-manager",children:[f&&(0,a.jsx)("div",{className:"notice notice-error",children:(0,a.jsx)("p",{children:f})}),b&&(0,a.jsx)("div",{className:"generated-key-modal",children:(0,a.jsxs)("div",{className:"generated-key-content",children:[(0,a.jsx)("h3",{children:"API Key Generated Successfully!"}),(0,a.jsx)("p",{className:"warning-text",children:"Make sure to copy your API key now. You won't be able to see it again!"}),(0,a.jsxs)("div",{className:"key-display",children:[(0,a.jsx)("code",{children:b.key}),(0,a.jsx)("button",{className:"button button-primary",onClick:function(){return e=b.key,navigator.clipboard.writeText(e),void alert("API key copied to clipboard!");var e},children:"Copy Key"})]}),(0,a.jsxs)("div",{className:"key-info",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Name:"})," ",b.name]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Created:"})," ",b.created]})]}),(0,a.jsx)("button",{className:"button",onClick:function(){j(null)},children:"Close"})]})}),(0,a.jsxs)("div",{className:"generate-key-form",children:[(0,a.jsx)("h3",{children:"Generate New API Key"}),(0,a.jsxs)("form",{onSubmit:P,children:[(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"key-name",children:"Key Name"}),(0,a.jsx)("input",{type:"text",id:"key-name",className:"regular-text",value:h,onChange:function(e){return v(e.target.value)},placeholder:"e.g., Production Server, Development",disabled:x})]}),(0,a.jsx)("button",{type:"submit",className:"button button-primary",disabled:x,children:x?"Generating...":"Generate API Key"})]})]}),(0,a.jsxs)("div",{className:"api-keys-list",children:[(0,a.jsx)("h3",{children:"Existing API Keys"}),0===t.length?(0,a.jsx)("p",{children:"No API keys found. Generate one to get started."}):(0,a.jsxs)("table",{className:"wp-list-table widefat fixed striped",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Key"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Last Used"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:t.map(function(e){return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:e.name}),(0,a.jsx)("td",{children:(0,a.jsx)("code",{children:e.key_prefix})}),(0,a.jsx)("td",{children:e.created}),(0,a.jsx)("td",{children:e.last_used||"Never"}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"button button-small button-link-delete",onClick:function(){return I(e.id)},children:"Delete"})})]},e.id)})})]})]}),(0,a.jsxs)("div",{className:"mcp-server-info",children:[(0,a.jsx)("h3",{children:"MCP Server Information"}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Endpoint:"})," ",(0,a.jsxs)("code",{children:[S,"/mcp"]})]}),(0,a.jsx)("p",{children:"To use this MCP server, include your API key in requests using either:"}),(0,a.jsxs)("ul",{children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"X-API-Key"})," header"]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"Authorization: Bearer YOUR_KEY"})," header"]})]})]}),(0,a.jsxs)("div",{className:"mcp-setup-help",children:[(0,a.jsx)("h3",{children:"Help Setting Up"}),(0,a.jsxs)("p",{children:["To connect this MCP server to your AI chatbot (Claude Desktop, Cline, or other MCP-compatible clients), you'll need to configure the server endpoint and authentication. Generate an API key above, then follow the step-by-step instructions in our comprehensive setup guide."," ",(0,a.jsx)("a",{href:"https://websamurai.io/chatbot_setup/",target:"_blank",rel:"noopener noreferrer",className:"setup-guide-link",children:"View Complete Setup Guide →"})]})]})]})};function p(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return m(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(m(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,m(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,m(d,"constructor",u),m(u,"constructor",s),s.displayName="GeneratorFunction",m(u,o,"GeneratorFunction"),m(d),m(d,o,"Generator"),m(d,r,function(){return this}),m(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:a,m:f}})()}function m(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,n,r){function a(t,n){m(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},m(e,t,n,r)}function h(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){h(a,r,o,i,c,"next",e)}function c(e){h(a,r,o,i,c,"throw",e)}i(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const j=function(e){var t=e.onConnectionChange,n=y((0,o.useState)(!1),2),r=n[0],i=n[1],c=y((0,o.useState)(!0),2),s=c[0],u=c[1],l=y((0,o.useState)(null),2),d=l[0],f=l[1],m=y((0,o.useState)(null),2),h=m[0],b=m[1];(0,o.useEffect)(function(){j()},[]);var j=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return n=e.v,e.n=3,n.json();case 3:(r=e.v).connected&&(i(!0),f(r)),t&&t(),e.n=5;break;case 4:e.p=4,o=e.v,console.error("Error checking OAuth status:",o);case 5:return e.p=5,u(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),g=function(){var e=v(p().m(function e(){var t,n,r;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/refresh"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 2:return t=e.v,e.n=3,t.json();case 3:if(!(n=e.v).success){e.n=5;break}return e.n=4,j();case 4:e.n=6;break;case 5:b(n.message||"Failed to refresh user data");case 6:e.n=8;break;case 7:e.p=7,r=e.v,b("An error occurred while refreshing user data"),console.error("Error refreshing:",r);case 8:return e.p=8,u(!1),e.f(8);case 9:return e.a(2)}},e,null,[[1,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),x=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to disconnect from cp.websamurai.io?")){e.n=1;break}return e.a(2);case 1:return u(!0),b(null),e.p=2,e.n=3,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/disconnect"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 3:return n=e.v,e.n=4,n.json();case 4:(r=e.v).success?(i(!1),f(null),t&&t()):b(r.message||"Failed to disconnect"),e.n=6;break;case 5:e.p=5,o=e.v,b("An error occurred while disconnecting"),console.error("Error disconnecting:",o);case 6:return e.p=6,u(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}();return s?(0,a.jsx)("div",{className:"oauth-connect",children:(0,a.jsx)("div",{className:"loading",children:"Loading connection status..."})}):(0,a.jsxs)("div",{className:"oauth-connect",children:[(0,a.jsxs)("div",{className:"oauth-header",children:[(0,a.jsx)("h3",{children:"Connect to Service"}),(0,a.jsx)("p",{children:"Authenticate with your SamuraiWP Control Panel account to enable advanced AI features and synchronization."})]}),h&&(0,a.jsxs)("div",{className:"oauth-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",h]}),r?(0,a.jsxs)("div",{className:"oauth-connected",children:[(0,a.jsxs)("div",{className:"status-badge connected",children:[(0,a.jsx)("span",{className:"status-icon",children:"✓"}),"Connected"]}),(0,a.jsxs)("div",{className:"connection-info",children:[(0,a.jsxs)("div",{className:"connection-info-header",children:[(0,a.jsx)("h4",{children:"Connection Details"}),(0,a.jsx)("button",{className:"button button-small oauth-refresh",onClick:g,disabled:s,title:"Refresh user data from server",children:"↻ Refresh"})]}),d&&(0,a.jsxs)("dl",{children:[(0,a.jsx)("dt",{children:"Connected:"}),(0,a.jsx)("dd",{children:d.connected_at?new Date(d.connected_at).toLocaleString():"N/A"}),d.user_data&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:"User ID:"}),(0,a.jsx)("dd",{children:d.user_data.id||"N/A"}),(0,a.jsx)("dt",{children:"Name:"}),(0,a.jsxs)("dd",{children:[d.user_data.FirstName," ",d.user_data.LastName]}),(0,a.jsx)("dt",{children:"Login ID:"}),(0,a.jsx)("dd",{children:d.user_data.LoginID||"N/A"}),(0,a.jsx)("dt",{children:"User Email:"}),(0,a.jsx)("dd",{children:d.user_data.Email||"N/A"}),(0,a.jsx)("dt",{children:"Role:"}),(0,a.jsx)("dd",{children:d.user_data.RoleList||"N/A"}),(0,a.jsx)("dt",{children:"Last Refreshed:"}),(0,a.jsx)("dd",{children:d.refreshed_at?new Date(d.refreshed_at).toLocaleString():"Never"})]})]})]}),(0,a.jsx)("button",{className:"button button-secondary oauth-disconnect",onClick:x,disabled:s,children:"Disconnect"})]}):(0,a.jsxs)("div",{className:"oauth-disconnected",children:[(0,a.jsxs)("div",{className:"status-badge disconnected",children:[(0,a.jsx)("span",{className:"status-icon",children:"○"}),"Not Connected"]}),(0,a.jsxs)("div",{className:"oauth-benefits",children:[(0,a.jsx)("h4",{children:"Benefits of Connecting:"}),(0,a.jsxs)("ul",{children:[(0,a.jsx)("li",{children:"Access advanced AI models and features"}),(0,a.jsx)("li",{children:"Sync your settings across multiple sites"}),(0,a.jsx)("li",{children:"Automatic updates and improvements"}),(0,a.jsx)("li",{children:"Priority support and assistance"})]})]}),(0,a.jsx)("button",{className:"button button-primary oauth-connect-btn",onClick:function(){b(null);var e="".concat(window. location.origin,"/samuraiauth/?nonce=").concat(window.samurAiAdmin.nonce),t=window.samurAiAdmin.oauthBaseUrl||"https://cp.websamurai.io",n="".concat(t,"/oauth/auth/?callback=").concat(encodeURIComponent(e));window.location.href=n},disabled:s,children:"Connect to Service"}),(0,a.jsx)("p",{className:"oauth-privacy",children:"Your authentication is secure and encrypted. We only access the information necessary to provide our services."})]})]})};function g(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return x(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(x(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,x(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,x(d,"constructor",u),x(u,"constructor",s),s.displayName="GeneratorFunction",x(u,o,"GeneratorFunction"),x(d),x(d,o,"Generator"),x(d,r,function(){return this}),x(d,"toString",function(){return"[object Generator]"}),(g=function(){return{w:a,m:f}})()}function x(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}x=function(e,t,n,r){function a(t,n){x(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},x(e,t,n,r)}function w(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function A(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,c,"next",e)}function c(e){w(a,r,o,i,c,"throw",e)}i(void 0)})}}function N(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const k=function(){var e=N((0,o.useState)(!0),2),t=e[0],n=e[1],r=N((0,o.useState)(!1),2),i=r[0],c=r[1],s=N((0,o.useState)(null),2),u=s[0],l=s[1],d=N((0,o.useState)(null),2),f=d[0],p=d[1],m=N((0,o.useState)(""),2),h=m[0],v=m[1],y=N((0,o.useState)(""),2),b=y[0],j=y[1];(0,o.useEffect)(function(){x()},[]);var x=function(){var e=A(g().m(function e(){var t,r,o;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return n(!0),l(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return t=e.v,e.n=3,t.json();case 3:(r=e.v).success?(v(r.data.PromptInstructions||""),j(r.data.PromptInstructionsImage||"")):l(r.message||"Failed to load prompt instructions"),e.n=5;break;case 4:e.p=4,o=e.v,l("An error occurred while loading prompt instructions"),console.error("Error loading prompt instructions:",o);case 5:return e.p=5,n(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),w=function(){var e=A(g().m(function e(){var t,n,r;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return c(!0),l(null),p(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"},body:JSON.stringify({promptInstructions:h,promptInstructionsImage:b})});case 2:return t=e.v,e.n=3,t.json();case 3:(n=e.v).success?(p("Prompt instructions saved successfully!"),setTimeout(function(){return p(null)},3e3)):l(n.message||"Failed to save prompt instructions"),e.n=5;break;case 4:e.p=4,r=e.v,l("An error occurred while saving prompt instructions"),console.error("Error saving prompt instructions:",r);case 5:return e.p=5,c(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}();return t?(0,a.jsx)("div",{className:"prompt-instructions",children:(0,a.jsx)("div",{className:"loading",children:"Loading prompt instructions..."})}):u&&!f?(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),(0,a.jsxs)("div",{className:"prompt-instructions-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",u]})]}):(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),f&&(0,a.jsxs)("div",{className:"prompt-instructions-success",children:[(0,a.jsx)("strong",{children:"Success:"})," ",f]}),(0,a.jsxs)("div",{className:"prompt-instructions-fields",children:[(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions",children:(0,a.jsx)("strong",{children:"Prompt Instructions"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for general AI text generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions",className:"large-text",rows:"8",value:h,onChange:function(e){return v(e.target.value)},placeholder:"Enter additional prompt instructions for text generation..."})]}),(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions-image",children:(0,a.jsx)("strong",{children:"Prompt Instructions (Image)"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for AI image generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions-image",className:"large-text",rows:"8",value:b,onChange:function(e){return j(e.target.value)},placeholder:"Enter additional prompt instructions for image generation..."})]})]}),(0,a.jsx)("div",{className:"prompt-instructions-actions",children:(0,a.jsx)("button",{className:"button button-primary",onClick:w,disabled:i,children:i?"Saving...":"Save Prompt Instructions"})})]})},P=window.jQuery;function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=n.n(P)();const E=function(){var e=O((0,o.useState)(""),2),t=e[0],n=e[1],r=O((0,o.useState)(""),2),i=r[0],c=r[1],s=O((0,o.useState)(""),2),u=s[0],l=s[1],d=O((0,o.useState)(!1),2),f=d[0],p=d[1],m=O((0,o.useState)(!1),2),h=m[0],v=m[1],y=O((0,o.useState)(!1),2),b=y[0],j=y[1],g=(0,o.useRef)(null),x=(0,o.useRef)(null);(0,o.useEffect)(function(){return function(){g.current&&clearInterval(g.current)}},[]);var w=function(e){c(e)},A=function(){n(""),c(""),l(""),p(!1),v(!1),j(!1),g.current&&(clearInterval(g.current),g.current=null),x.current=null};return(0,a.jsxs)("div",{className:"websamurai-generate-container",children:[(0,a.jsxs)("div",{className:"websamurai-generate-header",children:[(0,a.jsx)("h2",{children:"Generate Image with AI"}),(0,a.jsx)("p",{children:"Describe the image you want to create and our AI will generate it for you."})]}),(0,a.jsxs)("div",{className:"websamurai-generate-body",children:[(0,a.jsxs)("div",{className:"websamurai-input-group",children:[(0,a.jsx)("label",{htmlFor:"websamurai-description",children:"Image Description:"}),(0,a.jsx)("textarea",{id:"websamurai-description",className:"websamurai-textarea",placeholder:"e.g., A serene landscape with mountains and a lake at sunset",rows:"4",value:t,onChange:function(e){return n(e.target.value)},disabled:f})]}),i&&(0,a.jsx)("div",{className:"websamurai-status",children:(0,a.jsx)("p",{children:i})}),u&&(0,a.jsx)("div",{className:"websamurai-preview",children:(0,a.jsx)("img",{src:u,alt:"Generated"})}),(0,a.jsxs)("div",{className:"websamurai-actions",children:[!f&&!h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",onClick:function(){""!==t.trim()?(p(!0),v(!1),j(!1),l(""),w("Starting image generation..."),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_generate_image",nonce:window.samurAiAdmin.nonce,description:t},success:function(e){var t,n;e.success&&e.data.conversation?(x.current=e.data.conversation.id,w("Image generation started. Please wait..."),t=e.data.conversation.id,n=0,g.current=setInterval(function(){if(++n>60)return clearInterval(g.current),g.current=null,w("Image generation timed out. Please try again."),p(!1),void j(!0);C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_poll_image",nonce:window.samurAiAdmin.nonce,conversation_id:t},success:function(e){if(e.success&&e.data.conversation){var t=e.data.conversation;if(!0===t.DoneResponse||"true"===t.DoneResponse){clearInterval(g.current),g.current=null;var r=null;if(t.Prompt&&t.Prompt.prompts&&Array.isArray(t.Prompt.prompts))for(var o=0;o<t.Prompt.prompts.length;o++){var a=t.Prompt.prompts[o];if("assistant"===a.role&&a.content&&"object"===I(a.content)&&a.content.url){var i=a.content.url;r=window.samurAiAdmin.oauthBaseUrl+i;break}}r?(w("Image generated successfully!"),l(r),p(!1),v(!0),j(!0)):(w("Image generation completed but no image URL was returned."),p(!1),j(!0))}else w("Generating image... ("+n+")")}},error:function(){}})},5e3)):(w(e.data.message||"Failed to start image generation."),p(!1),j(!0))},error:function(e,t,n){w("Error: "+n),p(!1),j(!0)}})):alert("Please enter a description for the image.")},children:"Generate Image"}),f&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",disabled:!0,children:"Generating..."}),h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-add-btn",onClick:function(){u?(w("Adding image to media library..."),v(!1),j(!1),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_add_image_to_media",nonce:window.samurAiAdmin.nonce,image_url:u,description:t},success:function(e){e.success?(w("Image added to media library successfully!"),setTimeout(function(){A()},2e3)):(w(e.data.message||"Failed to add image to library."),v(!0),j(!0))},error:function(e,t,n){w("Error: "+n),v(!0),j(!0)}})):alert("No image to add.")},children:"Add to Library"}),b&&(0,a.jsx)("button",{type:"button",className:"button button-large websamurai-retry-btn",onClick:A,children:"Try Again"})]})]})]})};function T(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return G(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(G(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,G(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,G(d,"constructor",u),G(u,"constructor",s),s.displayName="GeneratorFunction",G(u,o,"GeneratorFunction"),G(d),G(d,o,"Generator"),G(d,r,function(){return this}),G(d,"toString",function(){return"[object Generator]"}),(T=function(){return{w:a,m:f}})()}function G(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}G=function(e,t,n,r){function a(t,n){G(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},G(e,t,n,r)}function F(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function U(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const R=function(){var e=U((0,o.useState)("oauth"),2),t=e[0],n=e[1],r=U((0,o.useState)(!1),2),i=r[0],c=r[1];(0,o.useEffect)(function(){s()},[]);var s=function(){var e,t=(e=T().m(function e(){var t,n,r;return T().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 1:return t=e.v,e.n=2,t.json();case 2:n=e.v,c(n.connected||!1),e.n=4;break;case 3:e.p=3,r=e.v,console.error("Error checking OAuth status:",r);case 4:return e.a(2)}},e,null,[[0,3]])}),function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){F(a,r,o,i,c,"next",e)}function c(e){F(a,r,o,i,c,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}();return(0,a.jsxs)("div",{className:"websamurai-admin",children:[(0,a.jsxs)("div",{className:"websamurai-admin-header",children:[(0,a.jsx)("h2",{children:"Samur AI Settings"}),(0,a.jsx)("p",{children:"Configure authentication and manage API keys"})]}),(0,a.jsxs)("div",{className:"websamurai-tabs",children:[(0,a.jsxs)("div",{className:"tab-navigation",children:[(0,a.jsx)("button",{className:"tab-button ".concat("oauth"===t?"active":""),onClick:function(){return n("oauth")},children:"OAuth Connection"}),(0,a.jsx)("button",{className:"tab-button ".concat("api-keys"===t?"active":""),onClick:function(){return n("api-keys")},children:"API Keys"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("prompt-instructions"===t?"active":""),onClick:function(){return n("prompt-instructions")},children:"Extra Prompt Instructions"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("media-generate"===t?"active":""),onClick:function(){return n("media-generate")},children:"Generate AI Image"})]}),(0,a.jsxs)("div",{className:"tab-content",children:["oauth"===t&&(0,a.jsx)(j,{onConnectionChange:s}),"api-keys"===t&&(0,a.jsx)(f,{}),"prompt-instructions"===t&&i&&(0,a.jsx)(k,{}),"media-generate"===t&&i&&(0,a.jsx)(E,{})]})]})]})};document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("websamurai-admin-root");e&&(0,r.H)(e).render((0,a.jsx)(R,{}));var t=document.querySelector(".wp-admin.wp-core-ui.upload-php #wp-media-grid");if(t){console.log("Adding Generate AI Image button to Media Library toolbar");var n=document.createElement("button");n.className="websamurai-generate-image-btn",n.innerText="Generate AI Image",n.onclick=function(e){e.preventDefault(),e.stopPropagation(),console.log("stop");var t=document.querySelector("#websamurai-ai-image-modal-trigger");t||((t=document.createElement("div")).id="websamurai-ai-image-modal-trigger",t.onclick=function(e){"websamurai-ai-image-modal-trigger"===e.target.id&&t.remove()},document.body.appendChild(t)),(0,r.H)(t).render((0,a.jsx)(E,{}))},t&&t.childNodes[1].after(n)}})})();2 (()=>{"use strict";var e={20:(e,t,n)=>{var r=n(609),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,a={},u=null,l=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)i.call(t,r)&&!s.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:o,type:e,key:u,ref:l,props:a,_owner:c.current}}t.Fragment=a,t.jsx=u,t.jsxs=u},338:(e,t,n)=>{var r=n(795);t.H=r.createRoot,r.hydrateRoot},609:e=>{e.exports=window.React},795:e=>{e.exports=window.ReactDOM},848:(e,t,n)=>{e.exports=n(20)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=n(338),o=n(609),a=n(848);function i(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var i=r&&r.prototype instanceof u?r:u,l=Object.create(i.prototype);return c(l,"_invoke",function(n,r,o){var a,i,c,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,i=0,c=e,f.n=n,s}};function p(n,r){for(i=n,c=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(c=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(i=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,i=0))}if(o||n>1)return s;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),i=l,c=m;(t=i<2?e:c)||!d;){a||(i?i<3?(i>1&&(f.n=-1),p(i,c)):f.n=c:f.v=c);try{if(u=2,a){if(i||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,i<2&&(i=0)}else 1===i&&(t=a.return)&&t.call(a),i<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==s)break}catch(t){a=e,i=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),l}var s={};function u(){}function l(){}function d(){}t=Object.getPrototypeOf;var f=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return l.prototype=d,c(p,"constructor",d),c(d,"constructor",l),l.displayName="GeneratorFunction",c(d,o,"GeneratorFunction"),c(p),c(p,o,"Generator"),c(p,r,function(){return this}),c(p,"toString",function(){return"[object Generator]"}),(i=function(){return{w:a,m}})()}function c(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,n,r){function a(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},c(e,t,n,r)}function s(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,c,"next",e)}function c(e){s(a,r,o,i,c,"throw",e)}i(void 0)})}}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const f=function(){var e=l((0,o.useState)([]),2),t=e[0],n=e[1],r=l((0,o.useState)(!0),2),c=r[0],s=r[1],d=l((0,o.useState)(null),2),f=d[0],p=d[1],m=l((0,o.useState)(""),2),h=m[0],v=m[1],y=l((0,o.useState)(null),2),b=y[0],j=y[1],g=l((0,o.useState)(!1),2),x=g[0],w=g[1],A=window.samurAiAdmin||{},N=(A.ajaxUrl,A.nonce),S=A.apiUrl;(0,o.useEffect)(function(){k()},[]);var k=function(){var e=u(i().m(function e(){var t,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,s(!0),e.n=1,fetch("".concat(S,"/api-keys"),{headers:{"X-WP-Nonce":N}});case 1:if((t=e.v).ok){e.n=2;break}throw new Error("Failed to fetch API keys");case 2:return e.n=3,t.json();case 3:r=e.v,n(r),p(null),e.n=5;break;case 4:e.p=4,o=e.v,p(o.message);case 5:return e.p=5,s(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),P=function(){var e=u(i().m(function e(t){var n,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),h.trim()){e.n=1;break}return p("Please enter a name for the API key"),e.a(2);case 1:return e.p=1,w(!0),p(null),e.n=2,fetch("".concat(S,"/api-keys"),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":N},body:JSON.stringify({name:h})});case 2:if((n=e.v).ok){e.n=3;break}throw new Error("Failed to generate API key");case 3:return e.n=4,n.json();case 4:return r=e.v,j(r),v(""),e.n=5,k();case 5:e.n=7;break;case 6:e.p=6,o=e.v,p(o.message);case 7:return e.p=7,w(!1),e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}));return function(t){return e.apply(this,arguments)}}(),I=function(){var e=u(i().m(function e(t){var n;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to delete this API key?")){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,fetch("".concat(S,"/api-keys/").concat(t),{method:"DELETE",headers:{"X-WP-Nonce":N}});case 2:if(e.v.ok){e.n=3;break}throw new Error("Failed to delete API key");case 3:return e.n=4,k();case 4:e.n=6;break;case 5:e.p=5,n=e.v,p(n.message);case 6:return e.a(2)}},e,null,[[1,5]])}));return function(t){return e.apply(this,arguments)}}();return c&&0===t.length?(0,a.jsx)("div",{className:"loading",children:"Loading API keys..."}):(0,a.jsxs)("div",{className:"api-key-manager",children:[f&&(0,a.jsx)("div",{className:"notice notice-error",children:(0,a.jsx)("p",{children:f})}),b&&(0,a.jsx)("div",{className:"generated-key-modal",children:(0,a.jsxs)("div",{className:"generated-key-content",children:[(0,a.jsx)("h3",{children:"API Key Generated Successfully!"}),(0,a.jsx)("p",{className:"warning-text",children:"Make sure to copy your API key now. You won't be able to see it again!"}),(0,a.jsxs)("div",{className:"key-display",children:[(0,a.jsx)("code",{children:b.key}),(0,a.jsx)("button",{className:"button button-primary",onClick:function(){return e=b.key,navigator.clipboard.writeText(e),void alert("API key copied to clipboard!");var e},children:"Copy Key"})]}),(0,a.jsxs)("div",{className:"key-info",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Name:"})," ",b.name]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Created:"})," ",b.created]})]}),(0,a.jsx)("button",{className:"button",onClick:function(){j(null)},children:"Close"})]})}),(0,a.jsxs)("div",{className:"generate-key-form",children:[(0,a.jsx)("h3",{children:"Generate New API Key"}),(0,a.jsxs)("form",{onSubmit:P,children:[(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"key-name",children:"Key Name"}),(0,a.jsx)("input",{type:"text",id:"key-name",className:"regular-text",value:h,onChange:function(e){return v(e.target.value)},placeholder:"e.g., Production Server, Development",disabled:x})]}),(0,a.jsx)("button",{type:"submit",className:"button button-primary",disabled:x,children:x?"Generating...":"Generate API Key"})]})]}),(0,a.jsxs)("div",{className:"api-keys-list",children:[(0,a.jsx)("h3",{children:"Existing API Keys"}),0===t.length?(0,a.jsx)("p",{children:"No API keys found. Generate one to get started."}):(0,a.jsxs)("table",{className:"wp-list-table widefat fixed striped",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Key"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Last Used"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:t.map(function(e){return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:e.name}),(0,a.jsx)("td",{children:(0,a.jsx)("code",{children:e.key_prefix})}),(0,a.jsx)("td",{children:e.created}),(0,a.jsx)("td",{children:e.last_used||"Never"}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"button button-small button-link-delete",onClick:function(){return I(e.id)},children:"Delete"})})]},e.id)})})]})]}),(0,a.jsxs)("div",{className:"mcp-server-info",children:[(0,a.jsx)("h3",{children:"MCP Server Information"}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Endpoint:"})," ",(0,a.jsxs)("code",{children:[S,"/mcp"]})]}),(0,a.jsx)("p",{children:"To use this MCP server, include your API key in requests using either:"}),(0,a.jsxs)("ul",{children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"X-API-Key"})," header"]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"Authorization: Bearer YOUR_KEY"})," header"]})]})]}),(0,a.jsxs)("div",{className:"mcp-setup-help",children:[(0,a.jsx)("h3",{children:"Help Setting Up"}),(0,a.jsxs)("p",{children:["To connect this MCP server to your AI chatbot (Claude Desktop, Cline, or other MCP-compatible clients), you'll need to configure the server endpoint and authentication. Generate an API key above, then follow the step-by-step instructions in our comprehensive setup guide."," ",(0,a.jsx)("a",{href:"https://websamurai.io/chatbot_setup/",target:"_blank",rel:"noopener noreferrer",className:"setup-guide-link",children:"View Complete Setup Guide →"})]})]})]})};function p(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return m(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(m(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,m(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,m(d,"constructor",u),m(u,"constructor",s),s.displayName="GeneratorFunction",m(u,o,"GeneratorFunction"),m(d),m(d,o,"Generator"),m(d,r,function(){return this}),m(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:a,m:f}})()}function m(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,n,r){function a(t,n){m(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},m(e,t,n,r)}function h(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){h(a,r,o,i,c,"next",e)}function c(e){h(a,r,o,i,c,"throw",e)}i(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const j=function(e){var t=e.onConnectionChange,n=y((0,o.useState)(!1),2),r=n[0],i=n[1],c=y((0,o.useState)(!0),2),s=c[0],u=c[1],l=y((0,o.useState)(null),2),d=l[0],f=l[1],m=y((0,o.useState)(null),2),h=m[0],b=m[1];(0,o.useEffect)(function(){j()},[]);var j=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return n=e.v,e.n=3,n.json();case 3:(r=e.v).connected&&(i(!0),f(r)),t&&t(),e.n=5;break;case 4:e.p=4,o=e.v,console.error("Error checking OAuth status:",o);case 5:return e.p=5,u(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),g=function(){var e=v(p().m(function e(){var t,n,r;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/refresh"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 2:return t=e.v,e.n=3,t.json();case 3:if(!(n=e.v).success){e.n=5;break}return e.n=4,j();case 4:e.n=6;break;case 5:b(n.message||"Failed to refresh user data");case 6:e.n=8;break;case 7:e.p=7,r=e.v,b("An error occurred while refreshing user data"),console.error("Error refreshing:",r);case 8:return e.p=8,u(!1),e.f(8);case 9:return e.a(2)}},e,null,[[1,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),x=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to disconnect from cp.websamurai.io?")){e.n=1;break}return e.a(2);case 1:return u(!0),b(null),e.p=2,e.n=3,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/disconnect"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 3:return n=e.v,e.n=4,n.json();case 4:(r=e.v).success?(i(!1),f(null),t&&t()):b(r.message||"Failed to disconnect"),e.n=6;break;case 5:e.p=5,o=e.v,b("An error occurred while disconnecting"),console.error("Error disconnecting:",o);case 6:return e.p=6,u(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}();return s?(0,a.jsx)("div",{className:"oauth-connect",children:(0,a.jsx)("div",{className:"loading",children:"Loading connection status..."})}):(0,a.jsxs)("div",{className:"oauth-connect",children:[(0,a.jsxs)("div",{className:"oauth-header",children:[(0,a.jsx)("h3",{children:"Connect to Service"}),(0,a.jsx)("p",{children:"Authenticate with your SamuraiWP Control Panel account to enable advanced AI features and synchronization."})]}),h&&(0,a.jsxs)("div",{className:"oauth-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",h]}),r?(0,a.jsxs)("div",{className:"oauth-connected",children:[(0,a.jsxs)("div",{className:"status-badge connected",children:[(0,a.jsx)("span",{className:"status-icon",children:"✓"}),"Connected"]}),(0,a.jsxs)("div",{className:"connection-info",children:[(0,a.jsxs)("div",{className:"connection-info-header",children:[(0,a.jsx)("h4",{children:"Connection Details"}),(0,a.jsx)("button",{className:"button button-small oauth-refresh",onClick:g,disabled:s,title:"Refresh user data from server",children:"↻ Refresh"})]}),d&&(0,a.jsxs)("dl",{children:[(0,a.jsx)("dt",{children:"Connected:"}),(0,a.jsx)("dd",{children:d.connected_at?new Date(d.connected_at).toLocaleString():"N/A"}),d.user_data&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:"User ID:"}),(0,a.jsx)("dd",{children:d.user_data.id||"N/A"}),(0,a.jsx)("dt",{children:"Name:"}),(0,a.jsxs)("dd",{children:[d.user_data.FirstName," ",d.user_data.LastName]}),(0,a.jsx)("dt",{children:"Login ID:"}),(0,a.jsx)("dd",{children:d.user_data.LoginID||"N/A"}),(0,a.jsx)("dt",{children:"User Email:"}),(0,a.jsx)("dd",{children:d.user_data.Email||"N/A"}),(0,a.jsx)("dt",{children:"Role:"}),(0,a.jsx)("dd",{children:d.user_data.RoleList||"N/A"}),(0,a.jsx)("dt",{children:"Last Refreshed:"}),(0,a.jsx)("dd",{children:d.refreshed_at?new Date(d.refreshed_at).toLocaleString():"Never"})]})]})]}),(0,a.jsx)("button",{className:"button button-secondary oauth-disconnect",onClick:x,disabled:s,children:"Disconnect"})]}):(0,a.jsxs)("div",{className:"oauth-disconnected",children:[(0,a.jsxs)("div",{className:"status-badge disconnected",children:[(0,a.jsx)("span",{className:"status-icon",children:"○"}),"Not Connected"]}),(0,a.jsxs)("div",{className:"oauth-benefits",children:[(0,a.jsx)("h4",{children:"Benefits of Connecting:"}),(0,a.jsxs)("ul",{children:[(0,a.jsx)("li",{children:"Access advanced AI models and features"}),(0,a.jsx)("li",{children:"Sync your settings across multiple sites"}),(0,a.jsx)("li",{children:"Automatic updates and improvements"}),(0,a.jsx)("li",{children:"Priority support and assistance"})]})]}),(0,a.jsx)("button",{className:"button button-primary oauth-connect-btn",onClick:function(){b(null);var e="".concat(window.samurAiAdmin.siteURL,"/samuraiauth/?nonce=").concat(window.samurAiAdmin.nonce),t=window.samurAiAdmin.oauthBaseUrl||"https://cp.websamurai.io",n="".concat(t,"/oauth/auth/?callback=").concat(encodeURIComponent(e));window.location.href=n},disabled:s,children:"Connect to Service"}),(0,a.jsx)("p",{className:"oauth-privacy",children:"Your authentication is secure and encrypted. We only access the information necessary to provide our services."})]})]})};function g(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return x(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(x(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,x(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,x(d,"constructor",u),x(u,"constructor",s),s.displayName="GeneratorFunction",x(u,o,"GeneratorFunction"),x(d),x(d,o,"Generator"),x(d,r,function(){return this}),x(d,"toString",function(){return"[object Generator]"}),(g=function(){return{w:a,m:f}})()}function x(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}x=function(e,t,n,r){function a(t,n){x(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},x(e,t,n,r)}function w(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function A(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,c,"next",e)}function c(e){w(a,r,o,i,c,"throw",e)}i(void 0)})}}function N(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const k=function(){var e=N((0,o.useState)(!0),2),t=e[0],n=e[1],r=N((0,o.useState)(!1),2),i=r[0],c=r[1],s=N((0,o.useState)(null),2),u=s[0],l=s[1],d=N((0,o.useState)(null),2),f=d[0],p=d[1],m=N((0,o.useState)(""),2),h=m[0],v=m[1],y=N((0,o.useState)(""),2),b=y[0],j=y[1];(0,o.useEffect)(function(){x()},[]);var x=function(){var e=A(g().m(function e(){var t,r,o;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return n(!0),l(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return t=e.v,e.n=3,t.json();case 3:(r=e.v).success?(v(r.data.PromptInstructions||""),j(r.data.PromptInstructionsImage||"")):l(r.message||"Failed to load prompt instructions"),e.n=5;break;case 4:e.p=4,o=e.v,l("An error occurred while loading prompt instructions"),console.error("Error loading prompt instructions:",o);case 5:return e.p=5,n(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),w=function(){var e=A(g().m(function e(){var t,n,r;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return c(!0),l(null),p(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"},body:JSON.stringify({promptInstructions:h,promptInstructionsImage:b})});case 2:return t=e.v,e.n=3,t.json();case 3:(n=e.v).success?(p("Prompt instructions saved successfully!"),setTimeout(function(){return p(null)},3e3)):l(n.message||"Failed to save prompt instructions"),e.n=5;break;case 4:e.p=4,r=e.v,l("An error occurred while saving prompt instructions"),console.error("Error saving prompt instructions:",r);case 5:return e.p=5,c(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}();return t?(0,a.jsx)("div",{className:"prompt-instructions",children:(0,a.jsx)("div",{className:"loading",children:"Loading prompt instructions..."})}):u&&!f?(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),(0,a.jsxs)("div",{className:"prompt-instructions-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",u]})]}):(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),f&&(0,a.jsxs)("div",{className:"prompt-instructions-success",children:[(0,a.jsx)("strong",{children:"Success:"})," ",f]}),(0,a.jsxs)("div",{className:"prompt-instructions-fields",children:[(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions",children:(0,a.jsx)("strong",{children:"Prompt Instructions"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for general AI text generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions",className:"large-text",rows:"8",value:h,onChange:function(e){return v(e.target.value)},placeholder:"Enter additional prompt instructions for text generation..."})]}),(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions-image",children:(0,a.jsx)("strong",{children:"Prompt Instructions (Image)"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for AI image generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions-image",className:"large-text",rows:"8",value:b,onChange:function(e){return j(e.target.value)},placeholder:"Enter additional prompt instructions for image generation..."})]})]}),(0,a.jsx)("div",{className:"prompt-instructions-actions",children:(0,a.jsx)("button",{className:"button button-primary",onClick:w,disabled:i,children:i?"Saving...":"Save Prompt Instructions"})})]})},P=window.jQuery;function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=n.n(P)();const E=function(){var e=O((0,o.useState)(""),2),t=e[0],n=e[1],r=O((0,o.useState)(""),2),i=r[0],c=r[1],s=O((0,o.useState)(""),2),u=s[0],l=s[1],d=O((0,o.useState)(!1),2),f=d[0],p=d[1],m=O((0,o.useState)(!1),2),h=m[0],v=m[1],y=O((0,o.useState)(!1),2),b=y[0],j=y[1],g=(0,o.useRef)(null),x=(0,o.useRef)(null);(0,o.useEffect)(function(){return function(){g.current&&clearInterval(g.current)}},[]);var w=function(e){c(e)},A=function(){n(""),c(""),l(""),p(!1),v(!1),j(!1),g.current&&(clearInterval(g.current),g.current=null),x.current=null};return(0,a.jsxs)("div",{className:"websamurai-generate-container",children:[(0,a.jsxs)("div",{className:"websamurai-generate-header",children:[(0,a.jsx)("h2",{children:"Generate Image with AI"}),(0,a.jsx)("p",{children:"Describe the image you want to create and our AI will generate it for you."})]}),(0,a.jsxs)("div",{className:"websamurai-generate-body",children:[(0,a.jsxs)("div",{className:"websamurai-input-group",children:[(0,a.jsx)("label",{htmlFor:"websamurai-description",children:"Image Description:"}),(0,a.jsx)("textarea",{id:"websamurai-description",className:"websamurai-textarea",placeholder:"e.g., A serene landscape with mountains and a lake at sunset",rows:"4",value:t,onChange:function(e){return n(e.target.value)},disabled:f})]}),i&&(0,a.jsx)("div",{className:"websamurai-status",children:(0,a.jsx)("p",{children:i})}),u&&(0,a.jsx)("div",{className:"websamurai-preview",children:(0,a.jsx)("img",{src:u,alt:"Generated"})}),(0,a.jsxs)("div",{className:"websamurai-actions",children:[!f&&!h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",onClick:function(){""!==t.trim()?(p(!0),v(!1),j(!1),l(""),w("Starting image generation..."),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_generate_image",nonce:window.samurAiAdmin.nonce,description:t},success:function(e){var t,n;e.success&&e.data.conversation?(x.current=e.data.conversation.id,w("Image generation started. Please wait..."),t=e.data.conversation.id,n=0,g.current=setInterval(function(){if(++n>60)return clearInterval(g.current),g.current=null,w("Image generation timed out. Please try again."),p(!1),void j(!0);C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_poll_image",nonce:window.samurAiAdmin.nonce,conversation_id:t},success:function(e){if(e.success&&e.data.conversation){var t=e.data.conversation;if(!0===t.DoneResponse||"true"===t.DoneResponse){clearInterval(g.current),g.current=null;var r=null;if(t.Prompt&&t.Prompt.prompts&&Array.isArray(t.Prompt.prompts))for(var o=0;o<t.Prompt.prompts.length;o++){var a=t.Prompt.prompts[o];if("assistant"===a.role&&a.content&&"object"===I(a.content)&&a.content.url){var i=a.content.url;r=window.samurAiAdmin.oauthBaseUrl+i;break}}r?(w("Image generated successfully!"),l(r),p(!1),v(!0),j(!0)):(w("Image generation completed but no image URL was returned."),p(!1),j(!0))}else w("Generating image... ("+n+")")}},error:function(){}})},5e3)):(w(e.data.message||"Failed to start image generation."),p(!1),j(!0))},error:function(e,t,n){w("Error: "+n),p(!1),j(!0)}})):alert("Please enter a description for the image.")},children:"Generate Image"}),f&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",disabled:!0,children:"Generating..."}),h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-add-btn",onClick:function(){u?(w("Adding image to media library..."),v(!1),j(!1),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_add_image_to_media",nonce:window.samurAiAdmin.nonce,image_url:u,description:t},success:function(e){e.success?(w("Image added to media library successfully!"),setTimeout(function(){A()},2e3)):(w(e.data.message||"Failed to add image to library."),v(!0),j(!0))},error:function(e,t,n){w("Error: "+n),v(!0),j(!0)}})):alert("No image to add.")},children:"Add to Library"}),b&&(0,a.jsx)("button",{type:"button",className:"button button-large websamurai-retry-btn",onClick:A,children:"Try Again"})]})]})]})};function T(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return G(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(G(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,G(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,G(d,"constructor",u),G(u,"constructor",s),s.displayName="GeneratorFunction",G(u,o,"GeneratorFunction"),G(d),G(d,o,"Generator"),G(d,r,function(){return this}),G(d,"toString",function(){return"[object Generator]"}),(T=function(){return{w:a,m:f}})()}function G(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}G=function(e,t,n,r){function a(t,n){G(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},G(e,t,n,r)}function F(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function U(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return R(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const D=function(){var e=U((0,o.useState)("oauth"),2),t=e[0],n=e[1],r=U((0,o.useState)(!1),2),i=r[0],c=r[1];(0,o.useEffect)(function(){s()},[]);var s=function(){var e,t=(e=T().m(function e(){var t,n,r;return T().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 1:return t=e.v,e.n=2,t.json();case 2:n=e.v,c(n.connected||!1),e.n=4;break;case 3:e.p=3,r=e.v,console.error("Error checking OAuth status:",r);case 4:return e.a(2)}},e,null,[[0,3]])}),function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){F(a,r,o,i,c,"next",e)}function c(e){F(a,r,o,i,c,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}();return(0,a.jsxs)("div",{className:"websamurai-admin",children:[(0,a.jsx)("div",{className:"websamurai-admin-header",children:(0,a.jsx)("p",{children:"Configure authentication and manage API keys"})}),(0,a.jsxs)("div",{className:"websamurai-tabs",children:[(0,a.jsxs)("div",{className:"tab-navigation",children:[(0,a.jsx)("button",{className:"tab-button ".concat("oauth"===t?"active":""),onClick:function(){return n("oauth")},children:"OAuth Connection"}),(0,a.jsx)("button",{className:"tab-button ".concat("api-keys"===t?"active":""),onClick:function(){return n("api-keys")},children:"API Keys"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("prompt-instructions"===t?"active":""),onClick:function(){return n("prompt-instructions")},children:"Extra Prompt Instructions"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("media-generate"===t?"active":""),onClick:function(){return n("media-generate")},children:"Generate AI Image"})]}),(0,a.jsxs)("div",{className:"tab-content",children:["oauth"===t&&(0,a.jsx)(j,{onConnectionChange:s}),"api-keys"===t&&(0,a.jsx)(f,{}),"prompt-instructions"===t&&i&&(0,a.jsx)(k,{}),"media-generate"===t&&i&&(0,a.jsx)(E,{})]})]})]})};document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("websamurai-admin-root");e&&(0,r.H)(e).render((0,a.jsx)(D,{}));var t=document.querySelector(".wp-admin.wp-core-ui.upload-php #wp-media-grid");if(t){console.log("Adding Generate AI Image button to Media Library toolbar");var n=document.createElement("button");n.className="websamurai-generate-image-btn",n.innerText="Generate AI Image",n.onclick=function(e){e.preventDefault(),e.stopPropagation(),console.log("stop");var t=document.querySelector("#websamurai-ai-image-modal-trigger");t||((t=document.createElement("div")).id="websamurai-ai-image-modal-trigger",t.onclick=function(e){"websamurai-ai-image-modal-trigger"===e.target.id&&t.remove()},document.body.appendChild(t)),(0,r.H)(t).render((0,a.jsx)(E,{}))},t&&t.childNodes[1].after(n)}})})(); -
websamurai/trunk/inc/class-websamurai-api-keys.php
r3439610 r3496835 250 250 * Get or create the Samurai Remote Key 251 251 * 252 * This key is used for MCP server communication with the SamuraiWPControl Panel.252 * This key is used for MCP server communication with the WebSamurai Control Panel. 253 253 * 254 254 * @return string The API key. -
websamurai/trunk/inc/enqueue.php
r3439610 r3496835 50 50 'apiUrl' => rest_url( 'websamurai/v1' ), 51 51 'oauthBaseUrl' => $oauth_base_url, 52 'siteUrl' => get_site_url(), 52 53 ) 53 54 ); -
websamurai/trunk/inc/oauth-api.php
r3439610 r3496835 125 125 array( 126 126 'success' => true, 127 'message' => 'Successfully disconnected from SamuraiWPControl Panel',127 'message' => 'Successfully disconnected from WebSamurai Control Panel', 128 128 ), 129 129 200 … … 140 140 141 141 if ( empty( $auth_key ) ) { 142 return new WP_Error( 'not_connected', 'Not connected to SamuraiWPControl Panel' );142 return new WP_Error( 'not_connected', 'Not connected to WebSamurai Control Panel' ); 143 143 } 144 144 … … 256 256 array( 257 257 'success' => false, 258 'message' => 'Not connected to SamuraiWPControl Panel',258 'message' => 'Not connected to WebSamurai Control Panel', 259 259 ), 260 260 400 … … 312 312 array( 313 313 'success' => false, 314 'message' => 'Not connected to SamuraiWPControl Panel',314 'message' => 'Not connected to WebSamurai Control Panel', 315 315 ), 316 316 400 -
websamurai/trunk/inc/oauth-handler.php
r3448047 r3496835 72 72 // If sync failed and we disconnected, redirect to show error. 73 73 if ( empty( get_option( 'websamurai_cp_auth_key' ) ) ) { 74 wp_die( 'OAuth Error: Failed to register site with SamuraiWPControl Panel. Please try again.<br>' . $site_result->get_error_message() );74 wp_die( 'OAuth Error: Failed to register site with WebSamurai Control Panel. Please try again.<br>' . $site_result->get_error_message() ); 75 75 } 76 76 } … … 101 101 ?> 102 102 <div class="notice notice-success is-dismissible"> 103 <p><strong>Success!</strong> You have successfully connected to SamuraiWPControl Panel.</p>103 <p><strong>Success!</strong> You have successfully connected to WebSamurai Control Panel.</p> 104 104 </div> 105 105 <?php -
websamurai/trunk/readme.txt
r3448047 r3496835 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 16 Stable tag: 1.0.2 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 135 135 Please visit our website at https://websamurai.io or contact our support team for assistance. 136 136 137 = The AI is having difficulty accessing my site = 138 139 Your site's REST API for the MCP will need to be accessable to the AI. take a look at the "Connection Failures" at https://www.websamurai.io/chatbot_setup/#connection_failures 140 137 141 == Screenshots == 138 142 … … 142 146 == Changelog == 143 147 144 = 1.0.1 148 = 1.0.2 = 149 * Update lingering old names of plugin 150 * Fix oauth callback for WP sites in a subdirectory on the domain 151 * Minor documentation updates 152 153 = 1.0.1 = 145 154 * Fix error messaging on front end 146 155 * Fix recreate site if site config has been deleted -
websamurai/trunk/src/admin/App.jsx
r3439610 r3496835 37 37 <div className="websamurai-admin"> 38 38 <div className="websamurai-admin-header"> 39 <h2>Samur AI Settings</h2>40 39 <p>Configure authentication and manage API keys</p> 41 40 </div> -
websamurai/trunk/src/admin/components/OAuthConnect.jsx
r3439610 r3496835 50 50 51 51 // Build OAuth URL using localized base URL 52 const callbackUrl = `${window. location.origin}/samuraiauth/?nonce=${window.samurAiAdmin.nonce}`;52 const callbackUrl = `${window.samurAiAdmin.siteURL}/samuraiauth/?nonce=${window.samurAiAdmin.nonce}`; 53 53 const oauthBaseUrl = window.samurAiAdmin.oauthBaseUrl || 'https://cp.websamurai.io'; 54 54 const oauthUrl = `${oauthBaseUrl}/oauth/auth/?callback=${encodeURIComponent(callbackUrl)}`; -
websamurai/trunk/websamurai.php
r3448047 r3496835 4 4 * Plugin URI: https://websamurai.io 5 5 * Description: AI-powered features for WordPress 6 * Version: 1.0. 16 * Version: 1.0.3 7 7 * Author: Kiera Howe, Wiley Solutions 8 8 * Author URI: https://wileysol.com
Note: See TracChangeset
for help on using the changeset viewer.