1 line
7.1 KiB
JavaScript
1 line
7.1 KiB
JavaScript
(()=>{"use strict";var e,t={421:(e,t,o)=>{const r=window.React,n=window.wp.element,a=window.wp.domReady;var i=o.n(a);const l=window.wp.apiFetch;var c=o.n(l);const u=window.wp.components,s=window.wp.i18n;function p(e){return`var(--wp--preset--color--${e})`}function d(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return p(t)}function m(e,t,o=null,r=""){return o?`${e}${r} { ${t}: ${o}; }\n`:""}function v(e,t,o,r){return m(e,"background-color",t)+m(e,"color",o)+m(e,"background-color",r,":hover")+m(e,"background-color",r,":focus")}function f({selector:e,style:t,backgroundColor:o}){const n=function(e,t,o){const r=`${e} .components-button`,n=("string"==typeof(a=o)?p(a):a?.color?.background||null)||t?.color?.background;var a;return v(r,d(t?.elements?.link?.color?.text),n,d(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,o);return(0,r.createElement)("style",null,n)}const y=window.wp.primitives,b=(0,r.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(y.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"})),w=(0,r.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(y.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_=(0,n.forwardRef)((function({icon:e,size:t=24,...o},r){return(0,n.cloneElement)(e,{width:t,height:t,...o,ref:r})})),h=window.wp.compose;function g(e){try{return new URL(e),!0}catch(e){return!1}}function E({actionText:e,copyDescription:t,handle:o,resourceUrl:a}){const i=(0,s.__)("Loading...","activitypub"),l=(0,s.__)("Opening...","activitypub"),p=(0,s.__)("Error","activitypub"),d=(0,s.__)("Invalid","activitypub"),[m,v]=(0,n.useState)(e),[f,y]=(0,n.useState)(b),E=(0,h.useCopyToClipboard)(o,(()=>{y(w),setTimeout((()=>y(b)),1e3)})),[k,x]=(0,n.useState)(""),O=(0,n.useCallback)((()=>{let t;if(!g(k)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&g(`https://${t[1]}`)}(k))return v(d),t=setTimeout((()=>v(e)),2e3),()=>clearTimeout(t);const o=a+k;v(i),c()({path:o}).then((({url:t})=>{v(l),setTimeout((()=>{window.open(t,"_blank"),v(e)}),200)})).catch((()=>{v(p),setTimeout((()=>v(e)),2e3)}))}),[k]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,s.__)("My Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog-description"},t),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:o,readOnly:!0}),(0,r.createElement)(u.Button,{ref:E},(0,r.createElement)(_,{icon:f}),(0,s.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,s.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,n.createInterpolateElement)((0,s.__)("Or, if you know your own profile, we can start things that way! (eg <code>https://example.com/yourusername</code> or <code>yourusername@example.com</code>)","activitypub"),{code:(0,r.createElement)("code",null)})),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:k,onKeyDown:e=>{"Enter"===e?.code&&O()},onChange:e=>x(e.target.value)}),(0,r.createElement)(u.Button,{onClick:O},m))))}const{namespace:k}=window._activityPubOptions,x={avatar:"",webfinger:"@well@hello.dolly",name:(0,s.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function O(e){if(!e)return x;const t={...x,...e};return t.avatar=t?.icon?.url,t}function N({profile:e,popupStyles:t,userId:o}){const{avatar:n,name:a,webfinger:i}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:n,alt:a}),(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",title:i},i)),(0,r.createElement)(C,{profile:e,popupStyles:t,userId:o}))}function C({profile:e,popupStyles:t,userId:o}){const[a,i]=(0,n.useState)(!1),l=(0,s.sprintf)((0,s.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(u.Button,{className:"activitypub-profile__follow",onClick:()=>i(!0)},(0,s.__)("Follow","activitypub")),a&&(0,r.createElement)(u.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>i(!1),title:l},(0,r.createElement)(S,{profile:e,userId:o}),(0,r.createElement)("style",null,t)))}function S({profile:e,userId:t}){const{webfinger:o}=e,n=(0,s.__)("Follow","activitypub"),a=`/${k}/users/${t}/remote-follow?resource=`,i=(0,s.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub");return(0,r.createElement)(E,{actionText:n,copyDescription:i,handle:o,resourceUrl:a})}function $({selectedUser:e,style:t,backgroundColor:o,id:a,useId:i=!1,profileData:l=!1}){const[u,s]=(0,n.useState)(O()),p="site"===e?0:e,m=function(e){return v(".apfmd__button-group .components-button",d(e?.elements?.link?.color?.text)||"#111","#fff",d(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),y=i?{id:a}:{};function b(e){s(O(e))}return(0,n.useEffect)((()=>{if(l)return b(l);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${k}/users/${e}`};return c()(t)})(p).then(b)}),[p,l]),(0,r.createElement)("div",{...y},(0,r.createElement)(f,{selector:`#${a}`,style:t,backgroundColor:o}),(0,r.createElement)(N,{profile:u,userId:p,popupStyles:m}))}let I=1;i()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follow-me-block-wrapper"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,n.render)((0,r.createElement)($,{...t,id:"activitypub-follow-me-block-"+I++,useId:!0}),e)}))}))}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,o,n,a)=>{if(!o){var i=1/0;for(s=0;s<e.length;s++){for(var[o,n,a]=e[s],l=!0,c=0;c<o.length;c++)(!1&a||i>=a)&&Object.keys(r.O).every((e=>r.O[e](o[c])))?o.splice(c--,1):(l=!1,a<i&&(i=a));if(l){e.splice(s--,1);var u=n();void 0!==u&&(t=u)}}return t}a=a||0;for(var s=e.length;s>0&&e[s-1][2]>a;s--)e[s]=e[s-1];e[s]=[o,n,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={41:0,301:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var n,a,[i,l,c]=o,u=0;if(i.some((t=>0!==e[t]))){for(n in l)r.o(l,n)&&(r.m[n]=l[n]);if(c)var s=c(r)}for(t&&t(o);u<i.length;u++)a=i[u],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(s)},o=globalThis.webpackChunkwordpress_activitypub=globalThis.webpackChunkwordpress_activitypub||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var n=r.O(void 0,[301],(()=>r(421)));n=r.O(n)})(); |