Module 833291

5,006 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>K,br:()=>q,l7:()=>z,rL:()=>Y,st:()=>L,tl:()=>j,ts:()=>$}),n(321073);var i=n(492462),r=n(567243),s=n(179771),a=n(919535),o=n(121401);n(380610),n(100392);var l=n(842241);n(346542);var u=n(182490),c=n(123677),d=n(299091),_=n(257120),h=n(167189),f=n(652215),E=n(758836);let p=/^\/([a-zA-Z0-9-]+)$/,m=/^\/channels\/([0-9]+|@me)\/([0-9]+)$/,g=/^\/(invite|template)\/([a-zA-Z0-9-]+)\/?\.?$/,A=RegExp("^/events/(\\d+)(?:/)(\\d+)?((?:/)(\\d+))?"),I=/^\/(application-directory|discovery\/applications)\/([0-9-]+)\/?((about|images|privacy)\/?)?$/,T=/^\/(application-directory|discovery\/applications)\/([0-9-]+)\/store\/?([0-9-]+)?\/?$/,S=/^\/activities\/([0-9-]+)\/?$/,N=/^\/channels\/([0-9]+)\/shop\/([0-9]+)$/,C=/^(?:\/game-shop\/([0-9]+)|\/channels\/([0-9]+)\/game-shop\/(?:[0-9]+))\/([0-9]+)(?:\/([^\/]+))?$/,y=/^\/channels\/([0-9]+)\/shop$/,O=/^\/quests\/([0-9-]+)\/?$/,R=/^\/games\/([0-9]+)(?:\/[A-Za-z0-9-]*)?\/?$/,v=/^\/oauth2\/authorize/,b=/^#itemSkuId=([0-9]+)$/,L=/dev:\/\/[\w-.~:\/?#\[\]@!$&'()*+,;=%]+/i,D=F(window.GLOBAL_ENV.INVITE_HOST),w=F(window.GLOBAL_ENV.GUILD_TEMPLATE_HOST),P=F(window.GLOBAL_ENV.WEBAPP_ENDPOINT??`//canary.${f.U2_}`),M=F(`//canary.${f.U2_}`),x=F(`//ptb.${f.U2_}`),U=F("discordapp.com"),k=F("discord.com"),G=[_.A.escape(D.host??""),_.A.escape(w.host??""),_.A.escape(P.host??""),_.A.escape(U.host??""),_.A.escape(k.host??"")].filter(Boolean),V=RegExp(`((https?://[^ ]*)|^|\\s)(${G.join("|")})`,"g");function F(e){if(null==e)return{host:null,pathPrefix:null};if(e.indexOf("/")>=0){let t=(0,r.parse)(e,void 0,!0);return{host:t.host,pathPrefix:t.pathname}}return{host:e,pathPrefix:null}}function B(e,t){return t.host?.replace(/^www[.]/i,"")===e.host}function H(e,t){if(!B(e,t))return null;let n=t.pathname??"",i=e.pathPrefix??"";if(!n.startsWith(i))return null;let r=n.substring(i.length);return""===r?null:r}function j(e){return H(P,e)??H(M,e)??H(x,e)??H(U,e)??H(k,e)}function W(e){let t=z(e);if(null==t||null==t.pathname)return{url:null,inviteHostRemainingPath:null,templateHostRemainingPath:null,primaryHostRemainingPath:null};let n=H(D,t),i=H(w,t),r=H(P,t)??H(M,t)??H(x,t)??H(U,t)??H(k,t);return{url:t,inviteHostRemainingPath:n,templateHostRemainingPath:i,primaryHostRemainingPath:r}}function Y(e){if(e.includes("\\")){let t=z(e);if(null==t)return!1;if(B(D,t))return!0;if([P,M,x,U,k].some(e=>B(e,t)))return t.pathname?.toUpperCase().includes(h.I.INVITE)??!1}return!1}function K(e){if(null==e)return[];e=e.replace(V,(e,t,n,i)=>null==n?`${t}http://${i}`:e);let t=n(46054).A.parseToAST(e,!0,{allowLinks:!0}),r=[];(0,a.mm)(t,e=>{e.type===u.D.LINK&&"string"==typeof e.target&&e.target.length>0&&r.push(e.target)});let _=e.match(L);return(function(e){if(null==e||0===e.length)return[];let t=new Set,n=[];for(let a of e){let{url:e,inviteHostRemainingPath:u,templateHostRemainingPath:_,primaryHostRemainingPath:f}=W(a);if(null==e||null==e.pathname)continue;function r(e,i){t.has(i)||(t.add(i),n.push({type:e,code:i,url:a}))}if(u?.match(p)!=null&&("https:"===e.protocol||"http:"===e.protocol)){let t=(0,l.fB)(u.substring(1),e.search);if(d.A.getInvite(t),a.includes("\\"))continue;r(h.I.INVITE,t)}_?.match(p)!=null&&r(h.I.TEMPLATE,_.substring(1));let O=f?.match(g);if(null!=O){let t=O[1].toUpperCase();if(t===h.I.INVITE){if(a.includes("\\"))continue;let t=(0,l.fB)(O[2],e.search);r(h.I.INVITE,t)}else r(t,O[2])}f?.match(m)!=null&&r(h.I.CHANNEL_LINK,f.replace("/channels/",""));let L=function(e){if(null==e)return null;let t=e.match(A);return null!=t&&t.length>=4?{guildId:t[1],guildEventId:t[2],recurrenceId:t[4]}:null}(e.pathname);if(null!=L&&r(h.I.EVENT,`${L.guildId}-${L.guildEventId}`+(null!=L.recurrenceId?`-${L.recurrenceId}`:"")),null!=f?.match(v)&&null!=e.query){let t=(0,c._)(e.query),n=t.clientId;null==n||""===n||t.scopes?.some(e=>e!==s.F.APPLICATIONS_COMMANDS)||r(h.I.APP_OAUTH2_LINK,n)}let D=f?.match(I);if(null!=D){let e=D[2];r(h.I.APP_DIRECTORY_PROFILE,e)}let w=f?.match(T);if(null!=w){let e=w[2],t=w[3];if(null!=t){let n=(0,o.L)(e,t);r(h.I.APP_DIRECTORY_STOREFRONT_SKU,n)}else r(h.I.APP_DIRECTORY_STOREFRONT,e)}let P=f?.match(S);if(null!=P){let e=P[1];r(h.I.ACTIVITY_BOOKMARK,e)}let M=f?.match(N);null!=M&&r(h.I.GUILD_PRODUCT,`${M[1]}-${M[2]}`);let x=f?.match(y);null!=x&&r(h.I.SERVER_SHOP,x[1]);let U=f?.match(C);null!=U&&r(h.I.SOCIAL_LAYER_STOREFRONT,`${U[3]}-${U[1]??U[2]}`);let k=$(a);null!=k&&r(h.I.QUESTS_EMBED,k);let G=f?.match(R);if(null!=G&&r(h.I.GAME_PROFILE,G[1]),"/shop"===f){let t=null!=e.query?(0,i.parse)(e.query):null,n=t?.tab;if(n===E.G2.GAME_SHOPS&&t?.applicationId!=null&&t?.skuId!=null){let e=t.applicationId,n=t.skuId;"string"==typeof e&&"string"==typeof n&&r(h.I.SOCIAL_LAYER_STOREFRONT_APP,`${n}-${e}`)}else{let t=e.hash?.match(b);r(h.I.COLLECTIBLES_SHOP,`${n??""}-${t?.[1]??""}`)}}}return n})(r=(r??[]).concat(_??[])).slice(0,10)}function $(e){let t=W(e),n=t?.primaryHostRemainingPath?.match(O);return n?.[1]??null}function z(e){try{return(0,r.parse)(e)}catch(e){return null}}function q(e){return K(e)[0]}}