laipower/wp-content/plugins/activitypub/build/follow-me/view.js

1 line
7.1 KiB
JavaScript
Raw Normal View History

(()=>{"use strict";var e,t={792:(e,t,o)=>{const r=window.wp.element,n=window.wp.domReady;var a=o.n(n);const c=window.wp.apiFetch;var i=o.n(c);const l=window.wp.components,u=window.wp.i18n;function s(e){return`var(--wp--preset--color--${e})`}function p(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return s(t)}function m(e,t,o=null,r=""){return o?`${e}${r} { ${t}: ${o}; }\n`:""}function d(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 v({selector:e,style:t,backgroundColor:o}){const n=function(e,t,o){const r=`${e} .components-button`,n=("string"==typeof(a=o)?s(a):a?.color?.background||null)||t?.color?.background;var a;return d(r,p(t?.elements?.link?.color?.text),n,p(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,o);return(0,r.createElement)("style",null,n)}const f=window.wp.primitives,y=(0,r.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(f.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),b=(0,r.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),w=function({icon:e,size:t=24,...o}){return(0,r.cloneElement)(e,{width:t,height:t,...o})},_=window.wp.compose;function h(e){try{return new URL(e),!0}catch(e){return!1}}function g({actionText:e,copyDescription:t,handle:o,resourceUrl:n}){const a=(0,u.__)("Loading...","activitypub"),c=(0,u.__)("Opening...","activitypub"),s=(0,u.__)("Error","activitypub"),p=(0,u.__)("Invalid","activitypub"),[m,d]=(0,r.useState)(e),[v,f]=(0,r.useState)(y),g=(0,_.useCopyToClipboard)(o,(()=>{f(b),setTimeout((()=>f(y)),1e3)})),[E,k]=(0,r.useState)(""),x=(0,r.useCallback)((()=>{let t;if(!h(E)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&h(`https://${t[1]}`)}(E))return d(p),t=setTimeout((()=>d(e)),2e3),()=>clearTimeout(t);const o=n+E;d(a),i()({path:o}).then((({url:t})=>{d(c),setTimeout((()=>{window.open(t,"_blank"),d(e)}),200)})).catch((()=>{d(s),setTimeout((()=>d(e)),2e3)}))}),[E]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,u.__)("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)(l.Button,{ref:g},(0,r.createElement)(w,{icon:v}),(0,u.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,u.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,r.createInterpolateElement)((0,u.__)("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:E,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>k(e.target.value)}),(0,r.createElement)(l.Button,{onClick:x},m))))}const{namespace:E}=window._activityPubOptions,k={avatar:"",webfinger:"@well@hello.dolly",name:(0,u.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function x(e){if(!e)return k;const t={...k,...e};return t.avatar=t?.icon?.url,t}function O({profile:e,popupStyles:t,userId:o}){const{avatar:n,name:a,webfinger:c}=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:"