import{p as _}from"./DkUbt2PL.js";import{a1 as z,y as X,a4 as j}from"./yYc-42Uc.js";function He(e,t,r,n){_(()=>{let i=document.createElement("script");i.setAttribute("src","https://apis.google.com/js/api:client.js"),document.head.appendChild(i),i.onload=()=>q(e,t,r,n)})}function q(e,t,r,n){gapi.load("auth2",()=>{const a=gapi.auth2.init({client_id:t,cookiepolicy:"single_host_origin"});let s=document.getElementsByClassName(e);for(let c=0;c<s.length;c++)a.attachClickHandler(s[c],{},i,o)});function i(a){r(a.getBasicProfile()),a.disconnect()}function o({error:a}){n(a)}}function $e(){_(()=>{let e=document.createElement("script");e.setAttribute("src","https://connect.facebook.net/en_US/sdk.js"),e.setAttribute("id","facebook-jssdk"),document.head.appendChild(e),e.onload=Y})}function Y(){window.fbAsyncInit=function(){FB.init({appId:"1177952395736313",autoLogAppEvents:!0,xfbml:!0,version:"v20.0"}),FB.AppEvents.logPageView(),window.dispatchEvent(new Event("fb-sdk-ready"))}}function Ke(e,t){window.FB.login(function(i){let o=i.authResponse;o?(o.userID,window.FB.api("/me",r)):n()});function r(i){e(i)}function n(){t()}}const O=crypto,L=e=>e instanceof CryptoKey,g=new TextEncoder,v=new TextDecoder;function Q(...e){const t=e.reduce((i,{length:o})=>i+o,0),r=new Uint8Array(t);let n=0;return e.forEach(i=>{r.set(i,n),n+=i.length}),r}const Z=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r},R=e=>{let t=e;t instanceof Uint8Array&&(t=v.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Z(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class b extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){var r;super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(r=Error.captureStackTrace)==null||r.call(Error,this,this.constructor)}}class p extends b{static get code(){return"ERR_JWT_CLAIM_VALIDATION_FAILED"}constructor(t,r="unspecified",n="unspecified"){super(t),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=n}}class H extends b{static get code(){return"ERR_JWT_EXPIRED"}constructor(t,r="unspecified",n="unspecified"){super(t),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=n}}class ee extends b{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}}class C extends b{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class d extends b{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}}class N extends b{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}}class te extends b{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}function m(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function E(e,t){return e.name===t}function P(e){return parseInt(e.name.slice(4),10)}function re(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function ne(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function ie(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!E(e.algorithm,"HMAC"))throw m("HMAC");const n=parseInt(t.slice(2),10);if(P(e.algorithm.hash)!==n)throw m(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!E(e.algorithm,"RSASSA-PKCS1-v1_5"))throw m("RSASSA-PKCS1-v1_5");const n=parseInt(t.slice(2),10);if(P(e.algorithm.hash)!==n)throw m(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!E(e.algorithm,"RSA-PSS"))throw m("RSA-PSS");const n=parseInt(t.slice(2),10);if(P(e.algorithm.hash)!==n)throw m(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw m("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!E(e.algorithm,"ECDSA"))throw m("ECDSA");const n=re(t);if(e.algorithm.namedCurve!==n)throw m(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}ne(e,r)}function M(e,t,...r){if(r.length>2){const n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const $=(e,...t)=>M("Key must be ",e,...t);function F(e,t,...r){return M(`Key for the ${e} algorithm must be `,t,...r)}const B=e=>L(e),h=["CryptoKey"],ae=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(const n of t){const i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(const o of i){if(r.has(o))return!1;r.add(o)}}return!0};function oe(e){return typeof e=="object"&&e!==null}function x(e){if(!oe(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}const ce=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},w=(e,t,r=0)=>{r===0&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(n===-1)return!1;const i=e.subarray(n,n+t.length);return i.length!==t.length?!1:i.every((o,a)=>o===t[a])||w(e,t,n+1)},K=e=>{switch(!0){case w(e,[42,134,72,206,61,3,1,7]):return"P-256";case w(e,[43,129,4,0,34]):return"P-384";case w(e,[43,129,4,0,35]):return"P-521";case w(e,[43,101,110]):return"X25519";case w(e,[43,101,111]):return"X448";case w(e,[43,101,112]):return"Ed25519";case w(e,[43,101,113]):return"Ed448";default:throw new C("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},se=async(e,t,r,n,i)=>{let o,a;const s=new Uint8Array(atob(r.replace(e,"")).split("").map(u=>u.charCodeAt(0))),c=t==="spki";switch(n){case"PS256":case"PS384":case"PS512":o={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":o={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},a=c?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":o={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=c?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"},a=c?["verify"]:["sign"];break;case"ES384":o={name:"ECDSA",namedCurve:"P-384"},a=c?["verify"]:["sign"];break;case"ES512":o={name:"ECDSA",namedCurve:"P-521"},a=c?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const u=K(s);o=u.startsWith("P-")?{name:"ECDH",namedCurve:u}:{name:u},a=c?[]:["deriveBits"];break}case"EdDSA":o={name:K(s)},a=c?["verify"]:["sign"];break;default:throw new C('Invalid or unsupported "alg" (Algorithm) value')}return O.subtle.importKey(t,s,o,(i==null?void 0:i.extractable)??!1,a)},de=(e,t,r)=>se(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);async function ue(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw new TypeError('"spki" must be SPKI formatted string');return de(e,t,r)}const fe=(e,t)=>{if(!(t instanceof Uint8Array)){if(!B(t))throw new TypeError(F(e,t,...h,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${h.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},le=(e,t,r)=>{if(!B(t))throw new TypeError(F(e,t,...h));if(t.type==="secret")throw new TypeError(`${h.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${h.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${h.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${h.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${h.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},pe=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?fe(e,t):le(e,t,r)};function he(e,t,r,n,i){if(i.crit!==void 0&&n.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o;r!==void 0?o=new Map([...Object.entries(r),...t.entries()]):o=t;for(const a of n.crit){if(!o.has(a))throw new C(`Extension Header Parameter "${a}" is not recognized`);if(i[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(o.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}const me=(e,t)=>{if(t!==void 0&&(!Array.isArray(t)||t.some(r=>typeof r!="string")))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};function ye(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new C(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function we(e,t,r){if(L(t))return ie(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...h));return O.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...h,"Uint8Array"))}const Se=async(e,t,r,n)=>{const i=await we(e,t,"verify");ce(e,i);const o=ye(e,i.algorithm);try{return await O.subtle.verify(o,i,r,n)}catch{return!1}};async function be(e,t,r){if(!x(e))throw new d("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new d('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!="string")throw new d("JWS Protected Header incorrect type");if(e.payload===void 0)throw new d("JWS Payload missing");if(typeof e.signature!="string")throw new d("JWS Signature missing or incorrect type");if(e.header!==void 0&&!x(e.header))throw new d("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{const I=R(e.protected);n=JSON.parse(v.decode(I))}catch{throw new d("JWS Protected Header is invalid")}if(!ae(n,e.header))throw new d("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const i={...n,...e.header},o=he(d,new Map([["b64",!0]]),r==null?void 0:r.crit,n,i);let a=!0;if(o.has("b64")&&(a=n.b64,typeof a!="boolean"))throw new d('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:s}=i;if(typeof s!="string"||!s)throw new d('JWS "alg" (Algorithm) Header Parameter missing or invalid');const c=r&&me("algorithms",r.algorithms);if(c&&!c.has(s))throw new ee('"alg" (Algorithm) Header Parameter value not allowed');if(a){if(typeof e.payload!="string")throw new d("JWS Payload must be a string")}else if(typeof e.payload!="string"&&!(e.payload instanceof Uint8Array))throw new d("JWS Payload must be a string or an Uint8Array instance");let u=!1;typeof t=="function"&&(t=await t(n,e),u=!0),pe(s,t,"verify");const S=Q(g.encode(e.protected??""),g.encode("."),typeof e.payload=="string"?g.encode(e.payload):e.payload);let l;try{l=R(e.signature)}catch{throw new d("Failed to base64url decode the signature")}if(!await Se(s,t,l,S))throw new te;let y;if(a)try{y=R(e.payload)}catch{throw new d("Failed to base64url decode the payload")}else typeof e.payload=="string"?y=g.encode(e.payload):y=e.payload;const f={payload:y};return e.protected!==void 0&&(f.protectedHeader=n),e.header!==void 0&&(f.unprotectedHeader=e.header),u?{...f,key:t}:f}async function ge(e,t,r){if(e instanceof Uint8Array&&(e=v.decode(e)),typeof e!="string")throw new d("Compact JWS must be a string or Uint8Array");const{0:n,1:i,2:o,length:a}=e.split(".");if(a!==3)throw new d("Invalid Compact JWS");const s=await be({payload:i,protected:n,signature:o},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t=="function"?{...c,key:s.key}:c}const Ee=e=>Math.floor(e.getTime()/1e3),V=60,G=V*60,J=G*24,Ae=J*7,ve=J*365.25,Ce=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,k=e=>{const t=Ce.exec(e);if(!t)throw new TypeError("Invalid time period format");const r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(r*V);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(r*G);case"day":case"days":case"d":return Math.round(r*J);case"week":case"weeks":case"w":return Math.round(r*Ae);default:return Math.round(r*ve)}},D=e=>e.toLowerCase().replace(/^application\//,""),Ie=(e,t)=>typeof e=="string"?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1,Re=(e,t,r={})=>{const{typ:n}=r;if(n&&(typeof e.typ!="string"||D(e.typ)!==D(n)))throw new p('unexpected "typ" JWT header value',"typ","check_failed");let i;try{i=JSON.parse(v.decode(t))}catch{}if(!x(i))throw new N("JWT Claims Set must be a top-level JSON object");const{requiredClaims:o=[],issuer:a,subject:s,audience:c,maxTokenAge:u}=r,S=[...o];u!==void 0&&S.push("iat"),c!==void 0&&S.push("aud"),s!==void 0&&S.push("sub"),a!==void 0&&S.push("iss");for(const f of new Set(S.reverse()))if(!(f in i))throw new p(`missing required "${f}" claim`,f,"missing");if(a&&!(Array.isArray(a)?a:[a]).includes(i.iss))throw new p('unexpected "iss" claim value',"iss","check_failed");if(s&&i.sub!==s)throw new p('unexpected "sub" claim value',"sub","check_failed");if(c&&!Ie(i.aud,typeof c=="string"?[c]:c))throw new p('unexpected "aud" claim value',"aud","check_failed");let l;switch(typeof r.clockTolerance){case"string":l=k(r.clockTolerance);break;case"number":l=r.clockTolerance;break;case"undefined":l=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:W}=r,y=Ee(W||new Date);if((i.iat!==void 0||u)&&typeof i.iat!="number")throw new p('"iat" claim must be a number',"iat","invalid");if(i.nbf!==void 0){if(typeof i.nbf!="number")throw new p('"nbf" claim must be a number',"nbf","invalid");if(i.nbf>y+l)throw new p('"nbf" claim timestamp check failed',"nbf","check_failed")}if(i.exp!==void 0){if(typeof i.exp!="number")throw new p('"exp" claim must be a number',"exp","invalid");if(i.exp<=y-l)throw new H('"exp" claim timestamp check failed',"exp","check_failed")}if(u){const f=y-i.iat,I=typeof u=="number"?u:k(u);if(f-l>I)throw new H('"iat" claim timestamp check failed (too far in the past)',"iat","check_failed");if(f<0-l)throw new p('"iat" claim timestamp check failed (it should be in the past)',"iat","check_failed")}return i};async function Pe(e,t,r){var a;const n=await ge(e,t,r);if((a=n.protectedHeader.crit)!=null&&a.includes("b64")&&n.protectedHeader.b64===!1)throw new N("JWTs MUST NOT use unencoded payload");const o={payload:Re(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return typeof t=="function"?{...o,key:n.key}:o}function T(e){this.message=e}T.prototype=new Error,T.prototype.name="InvalidCharacterError";var U=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new T("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,o=0,a="";n=t.charAt(o++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};function xe(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(r){return decodeURIComponent(U(r).replace(/(.)/g,function(n,i){var o=i.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(t)}catch{return U(t)}}function A(e){this.message=e}function Te(e,t){if(typeof e!="string")throw new A("Invalid token specified");var r=(t=t||{}).header===!0?0:1;try{return JSON.parse(xe(e.split(".")[r]))}catch(n){throw new A("Invalid token specified: "+n.message)}}A.prototype=new Error,A.prototype.name="InvalidTokenError";async function _e(e){const{data:t}=await j("/getApplePublicKey/"+e,"$4ztoJOa0Tm");return t.value.pubKey}async function Oe(e){let t=Te(e,{header:!0});const r=await _e(t.kid),n=await ue(r,"RS256"),{payload:i}=await Pe(e,n);return i}function ke(){z({script:[{src:"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"}]}),_(()=>{})}async function De(e,t){const r=X();let n="/api/auth/callback/apple";switch(window.location.origin){case"https://pcdev.24h-sports.com":case"http://pcdev.24h-sports.com":n="/auth/apple/callback";break}AppleID.auth.init({clientId:r.public.apple.clientId||"com.strops-h42.www",scope:"name email",redirectURI:window.location.origin+n,state:"132",nonce:"hehe",usePopup:!0});try{const i=await AppleID.auth.signIn();let o=await Oe(i.authorization.id_token,"com.strops-h42.www").then(a=>a);e(i,o)}catch(i){t(i)}}export{$e as a,ke as b,De as c,Ke as f,He as i};
