laipower/wp-content/plugins/activitypub/build/remote-reply/index.js

1 line
5.1 KiB
JavaScript

(()=>{"use strict";var e,t={202:(e,t,a)=>{const n=window.React,o=window.wp.element,r=window.wp.domReady;var i=a.n(r);const c=window.wp.components,l=window.wp.i18n,u=window.wp.apiFetch;var s=a.n(u);const p=window.wp.primitives,m=(0,n.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(p.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"})),d=(0,n.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),v=(0,o.forwardRef)((function({icon:e,size:t=24,...a},n){return(0,o.cloneElement)(e,{width:t,height:t,...a,ref:n})})),y=window.wp.compose;function w(e){try{return new URL(e),!0}catch(e){return!1}}function _({actionText:e,copyDescription:t,handle:a,resourceUrl:r}){const i=(0,l.__)("Loading...","activitypub"),u=(0,l.__)("Opening...","activitypub"),p=(0,l.__)("Error","activitypub"),_=(0,l.__)("Invalid","activitypub"),[b,h]=(0,o.useState)(e),[f,E]=(0,o.useState)(m),g=(0,y.useCopyToClipboard)(a,(()=>{E(d),setTimeout((()=>E(m)),1e3)})),[O,C]=(0,o.useState)(""),x=(0,o.useCallback)((()=>{let t;if(!w(O)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&w(`https://${t[1]}`)}(O))return h(_),t=setTimeout((()=>h(e)),2e3),()=>clearTimeout(t);const a=r+O;h(i),s()({path:a}).then((({url:t})=>{h(u),setTimeout((()=>{window.open(t,"_blank"),h(e)}),200)})).catch((()=>{h(p),setTimeout((()=>h(e)),2e3)}))}),[O]);return(0,n.createElement)("div",{className:"activitypub__dialog"},(0,n.createElement)("div",{className:"activitypub-dialog__section"},(0,n.createElement)("h4",null,(0,l.__)("My Profile","activitypub")),(0,n.createElement)("div",{className:"activitypub-dialog-description"},t),(0,n.createElement)("div",{className:"activitypub-dialog__button-group"},(0,n.createElement)("input",{type:"text",value:a,readOnly:!0}),(0,n.createElement)(c.Button,{ref:g},(0,n.createElement)(v,{icon:f}),(0,l.__)("Copy","activitypub")))),(0,n.createElement)("div",{className:"activitypub-dialog__section"},(0,n.createElement)("h4",null,(0,l.__)("Your Profile","activitypub")),(0,n.createElement)("div",{className:"activitypub-dialog__description"},(0,o.createInterpolateElement)((0,l.__)("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,n.createElement)("code",null)})),(0,n.createElement)("div",{className:"activitypub-dialog__button-group"},(0,n.createElement)("input",{type:"text",value:O,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>C(e.target.value)}),(0,n.createElement)(c.Button,{onClick:x},b))))}const{namespace:b}=window._activityPubOptions;function h({selectedComment:e,commentId:t}){const a=(0,l.__)("Reply","activitypub"),o=`/${b}/comments/${t}/remote-reply?resource=`,r=(0,l.__)("Copy and paste the Comment URL into the search field of your favorite fediverse app or server.","activitypub");return(0,n.createElement)(_,{actionText:a,copyDescription:r,handle:e,resourceUrl:o})}function f({selectedComment:e,commentId:t}){const[a,r]=(0,o.useState)(!1),i=(0,l.__)("Remote Reply","activitypub");return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(c.Button,{isLink:!0,className:"comment-reply-link activitypub-remote-reply__button",onClick:()=>r(!0)},(0,l.__)("Reply on the Fediverse","activitypub")),a&&(0,n.createElement)(c.Modal,{className:"activitypub-remote-reply__modal activitypub__modal",onRequestClose:()=>r(!1),title:i},(0,n.createElement)(h,{selectedComment:e,commentId:t})))}let E=1;i()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-remote-reply"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,o.createRoot)(e).render((0,n.createElement)(f,{...t,id:"activitypub-remote-reply-link-"+E++,useId:!0}))}))}))}},a={};function n(e){var o=a[e];if(void 0!==o)return o.exports;var r=a[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.m=t,e=[],n.O=(t,a,o,r)=>{if(!a){var i=1/0;for(s=0;s<e.length;s++){for(var[a,o,r]=e[s],c=!0,l=0;l<a.length;l++)(!1&r||i>=r)&&Object.keys(n.O).every((e=>n.O[e](a[l])))?a.splice(l--,1):(c=!1,r<i&&(i=r));if(c){e.splice(s--,1);var u=o();void 0!==u&&(t=u)}}return t}r=r||0;for(var s=e.length;s>0&&e[s-1][2]>r;s--)e[s]=e[s-1];e[s]=[a,o,r]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={227:0,739:0};n.O.j=t=>0===e[t];var t=(t,a)=>{var o,r,[i,c,l]=a,u=0;if(i.some((t=>0!==e[t]))){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)var s=l(n)}for(t&&t(a);u<i.length;u++)r=i[u],n.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return n.O(s)},a=globalThis.webpackChunkwordpress_activitypub=globalThis.webpackChunkwordpress_activitypub||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var o=n.O(void 0,[739],(()=>n(202)));o=n.O(o)})();