File: /var/www/html/wp-content/plugins/wp-graphql/build/extensions.js
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,n=window.wp.element,a=window.wp.i18n,l=window.wp.components,i=window.wp.apiFetch;var r=e.n(i);const s=({plugin:e})=>{const{installing:i,activating:s,status:o,error:p,installPlugin:c,activatePlugin:u}=((e,n)=>{const[l,i]=(0,t.useState)(!1),[s,o]=(0,t.useState)(!1),[p,c]=(0,t.useState)(""),[u,w]=(0,t.useState)(""),g=(e,t="")=>{c(e),w(t)},m=async(t=n)=>{if(o(!0),g((0,a.__)("Activating…","wp-graphql")),!t){const n=new URL(e).pathname.split("/").filter(Boolean).pop();t=`${n}/${n}.php`}try{const n=await r()({path:`/wp/v2/plugins/${t}`,method:"PUT",data:{status:"active"},headers:{"X-WP-Nonce":wpgraphqlExtensions.nonce}});if("active"===n.status)return g((0,a.__)("Active","wp-graphql")),window.wpgraphqlExtensions.extensions=window.wpgraphqlExtensions.extensions.map(t=>t.plugin_url===e?{...t,installed:!0,active:!0}:t),!0;throw n.message.includes("Plugin file does not exist")?new Error((0,a.__)("Plugin file does not exist","wp-graphql")):new Error((0,a.__)("Activation failed","wp-graphql"))}catch(e){throw g((0,a.__)("Activation failed","wp-graphql"),e.message||(0,a.__)("Activation failed","wp-graphql")),e}finally{i(!1),o(!1)}};return{installing:l,activating:s,status:p,error:u,installPlugin:async()=>{i(!0),g((0,a.__)("Installing…","wp-graphql"));const t=new URL(e).pathname.split("/").filter(Boolean).pop();try{if("inactive"!==(await r()({path:"/wp/v2/plugins",method:"POST",data:{slug:t,status:"inactive"},headers:{"X-WP-Nonce":wpgraphqlExtensions.nonce}})).status)throw new Error((0,a.__)("Installation failed","wp-graphql"));await m(n)}catch(e){if(!e.message.includes("destination folder already exists"))throw g((0,a.__)("Installation failed","wp-graphql"),e.message||(0,a.__)("Installation failed","wp-graphql")),i(!1),e;await m(n)}},activatePlugin:m}})(e.plugin_url,e.plugin_path),[w,g]=(0,n.useState)(e.installed),[m,d]=(0,n.useState)(e.active),[h,_]=(0,n.useState)(!0);(0,n.useEffect)(()=>{g(e.installed),d(e.active)},[e]);const E=new URL(e.plugin_url).host,{buttonText:b,buttonDisabled:f}=((e,t,n,l,i,r,s)=>{let o,p=!1,c=null;const u=e=>()=>window.open(e,"_blank");if(i)o=(0,a.__)("Installing…","wp-graphql"),p=!0;else if(r)o=(0,a.__)("Activating…","wp-graphql"),p=!0;else if(l)o=(0,a.__)("Active","wp-graphql"),p=!0;else if(n)o=(0,a.__)("Activate","wp-graphql"),c=s;else{const e=new URL(t).hostname.toLowerCase();switch(!0){case/github\.com$/.test(e):o=(0,a.__)("View on GitHub","wp-graphql"),c=u(t);break;case/bitbucket\.org$/.test(e):o=(0,a.__)("View on Bitbucket","wp-graphql"),c=u(t);break;case/gitlab\.com$/.test(e):o=(0,a.__)("View on GitLab","wp-graphql"),c=u(t);break;case/wordpress\.org$/.test(e):o=(0,a.__)("Install & Activate","wp-graphql"),c=s;break;default:o=(0,a.__)("View Plugin","wp-graphql"),c=u(t)}}return{buttonText:o,buttonDisabled:p,buttonOnClick:c}})(0,e.plugin_url,w,m,i,s);return(0,t.createElement)("div",{className:"plugin-card"},(0,t.createElement)("div",{className:"plugin-card-top"},(0,t.createElement)("div",{className:"name column-name"},(0,t.createElement)("h2",null,e.name),(0,t.createElement)(({author:e})=>e&&e.name&&e.homepage?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("em",null,"By "),(0,t.createElement)("cite",{key:e.homepage},(0,t.createElement)("a",{href:e.homepage,target:"_blank",rel:"noopener noreferrer"},e.name))):null,{author:e.author}),e.experiment&&(0,t.createElement)("em",{className:"plugin-experimental"},"(experimental)")),(0,t.createElement)("div",{className:"action-links"},(0,t.createElement)("ul",{className:"plugin-action-buttons"},/^(.*\.)?wordpress\.org$/i.test(E)&&(0,t.createElement)("li",null,(0,t.createElement)("button",{type:"button",className:"button "+(m?"button-disabled":"button-primary"),disabled:f,onClick:async()=>{const t=w,n=m;try{w?(await u(e.plugin_path),d(!0)):(await c(),g(!0),d(!0))}catch(e){g(t),d(n)}finally{window.wpgraphqlExtensions.extensions=window.wpgraphqlExtensions.extensions.map(t=>t.plugin_url===e.plugin_url?{...t,installed:w,active:m}:t)}}},b,(i||s)&&(0,t.createElement)(l.Spinner,null))),/^(.*\.)?github\.com$/i.test(E)&&(0,t.createElement)("li",null,(0,t.createElement)("a",{href:e.plugin_url,target:"_blank",rel:"noopener noreferrer",className:"button button-secondary"},(0,a.__)("View on GitHub","wp-graphql"))),e.support_url&&(0,t.createElement)("li",null,(0,t.createElement)("a",{href:e.support_url,target:"_blank",rel:"noopener noreferrer",className:"thickbox open-plugin-details-modal"},(0,a.__)("Get Support","wp-graphql"))),e.settings_url&&(0,t.createElement)("li",null,(0,t.createElement)("a",{href:e.settings_url},(0,a.__)("Settings","wp-graphql"))))),(0,t.createElement)("div",{className:"desc column-description"},(0,t.createElement)("p",null,e.description))),p&&h&&(0,t.createElement)(l.Notice,{status:"error",isDismissible:!0,onRemove:()=>_(!1)},p))},o=()=>{const[e,n]=(0,t.useState)([]);return(0,t.useEffect)(()=>{window.wpgraphqlExtensions&&window.wpgraphqlExtensions.extensions&&n(window.wpgraphqlExtensions.extensions)},[]),(0,t.createElement)("div",{className:"wp-clearfix"},(0,t.createElement)("div",{className:"plugin-cards"},e.map(e=>(0,t.createElement)(s,{key:e.plugin_url,plugin:e}))))};document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("wpgraphql-extensions");e&&(n.createRoot?(0,n.createRoot)(e).render((0,t.createElement)(o,null)):(0,n.render)((0,t.createElement)(o,null),e))})})();