wordpress-activitypub/build/follow-me/index.js
2023-08-10 21:40:07 -05:00

1 line
No EOL
5.4 KiB
JavaScript

(()=>{"use strict";var e,t={535:(e,t,o)=>{const n=window.wp.blocks,r=window.wp.element,l=window.wp.primitives,a=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",fillRule:"evenodd"})),i=window.wp.blockEditor,c=window.wp.i18n,s=window.wp.components,u=window.wp.data,p=window._activityPubOptions?.enabled;function v(e){return`var(--wp--preset--color--${e})`}function d(e){if("string"==typeof e&&e.match(/^#/))return e;const[,,t]=e.split("|");return v(t)}function m(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return o?`${e}${arguments.length>3&&void 0!==arguments[3]?arguments[3]:""} { ${t}: ${o}; }\n`:""}const f="activitypub-follow-modal-active";function w(e){let{id:t,style:o,backgroundColor:n}=e;const l=function(e,t,o){const n=`#${e} .components-button`,r=("string"==typeof(l=o)?v(l):l?.color?.background||null)||t?.color?.background;var l;const a=d(t?.elements?.link?.color?.text),i=d(t?.elements?.link?.[":hover"]?.color?.text);return m(n,"color",r)+m(n,"background-color",a)+m(n,"background-color",i,":hover")}(t,o,n);return(0,r.createElement)("style",null,l)}const b=window.wp.apiFetch;var h=o.n(b);const{namespace:y}=window._activityPubOptions,_={avatar:"",handle:"@well@hello.dolly",name:(0,c.__)("Hello Dolly Fan Account","fediverse"),url:"#"};function g(e){if(!e)return _;e.handle=function(e){try{var t;const{host:o,pathname:n}=new URL(e.url);return`${null!==(t=e.preferredUsername)&&void 0!==t?t:n.replace(/^\//,"")}@${o}`}catch(e){return"@error@error"}}(e);const t={..._,...e};return t.avatar=t?.icon?.url,t}function k(e){let{profile:t,popupStyles:o}=e;const{handle:n,avatar:l,name:a}=t;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:l}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},a),(0,r.createElement)("div",{className:"activitypub-profile__handle"},n)),(0,r.createElement)(E,{profile:t,popupStyles:o}))}function E(e){let{profile:t,popupStyles:o}=e;const[n,l]=(0,r.useState)(!1);function a(e){const t=e?"add":"remove";document.body.classList[t](f),l(e)}return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(s.Button,{className:"activitypub-profile__follow",onClick:()=>a(!0)},(0,c.__)("Follow","fediverse")),(0,r.createElement)(s.__experimentalConfirmDialog,{className:"activitypub-profile__confirm",isOpen:n,onConfirm:()=>a(!1),onCancel:()=>a(!1)},(0,r.createElement)("p",null,"Howdy let's put some dialogs here"),(0,r.createElement)("style",null,o)))}(0,n.registerBlockType)("activitypub/follow-me",{edit:function(e){let{attributes:t,setAttributes:o}=e;const[n,l]=(0,r.useState)(g()),{selectedUser:a}=t,v="site"===a?0:a;function b(e){l(g(e))}(0,r.useEffect)((()=>{(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${y}/users/${e}`};return h()(t)})(v).then(b)}),[v]);const _=(0,i.useBlockProps)(),E=function(){const e=p?.users?(0,u.useSelect)((e=>e("core").getUsers({who:"authors"}))):[];return(0,r.useMemo)((()=>{if(!e)return[];const t=p?.site?[{label:(0,c.__)("Whole Site","activitypub"),value:"site"}]:[];return e.reduce(((e,t)=>(e.push({label:t.name,value:t.id}),e)),t)}),[e])}(),O=function(e){const t=`.${f} .components-modal__content .components-button`,o=`${t}.is-primary`,n=`${t}.is-tertiary`,r=d(e?.elements?.link?.color?.text),l=d(e?.elements?.link?.[":hover"]?.color?.text);return m(o,"background-color",r)+m(o,"background-color",l,":hover")+m(n,"color",r)}(t.style);return(0,r.createElement)("div",_,(0,r.createElement)(i.InspectorControls,{key:"setting"},(0,r.createElement)(s.PanelBody,{title:(0,c.__)("Followers Options","activitypub")},(0,r.createElement)(s.SelectControl,{label:(0,c.__)("Select User","activitypub"),value:a,options:E,onChange:e=>o({selectedUser:e})}))),(0,r.createElement)(w,{id:_.id,style:t.style,backgroundColor:t.backgroundColor}),(0,r.createElement)(k,{profile:n,popupStyles:O}))},save:()=>null,icon:a})}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var l=o[e]={exports:{}};return t[e](l,l.exports,n),l.exports}n.m=t,e=[],n.O=(t,o,r,l)=>{if(!o){var a=1/0;for(u=0;u<e.length;u++){for(var[o,r,l]=e[u],i=!0,c=0;c<o.length;c++)(!1&l||a>=l)&&Object.keys(n.O).every((e=>n.O[e](o[c])))?o.splice(c--,1):(i=!1,l<a&&(a=l));if(i){e.splice(u--,1);var s=r();void 0!==s&&(t=s)}}return t}l=l||0;for(var u=e.length;u>0&&e[u-1][2]>l;u--)e[u]=e[u-1];e[u]=[o,r,l]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={127:0,740:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var r,l,[a,i,c]=o,s=0;if(a.some((t=>0!==e[t]))){for(r in i)n.o(i,r)&&(n.m[r]=i[r]);if(c)var u=c(n)}for(t&&t(o);s<a.length;s++)l=a[s],n.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return n.O(u)},o=globalThis.webpackChunkwordpress_activitypub=globalThis.webpackChunkwordpress_activitypub||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var r=n.O(void 0,[740],(()=>n(535)));r=n.O(r)})();