/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
function vB_Facebook(a){this.config=a;this.loginperms={scope:"public_profile,email"};FB.Event.subscribe("auth.statusChange",function d(b){"connected"==b.status&&($(document).trigger("facebookinitialized"),FB.Event.unsubscribe("auth.statusChange",d))});FB.init({appId:this.get_config("appid"),version:"v15.0",status:!0,cookie:!0,xfbml:!0});this.register_loginbtns();this.make_visible();$("#lnkFacebookDisconnectSettings").off("click").on("click",this.do_disconnect);$("#lnkFacebookLoginSettings").off("click").on("click",
this.makeAuthEvent(this.do_connect))}vB_Facebook.prototype.get_config=function(a){return"undefined"==typeof this.config||"undefined"==typeof this.config[a]?!1:this.config[a]};
vB_Facebook.prototype.register_loginbtns=function(){var a=this.makeAuthEvent(this.do_login);$("#lnkFacebookLogin").on("click",a);$("#fb_getconnected").on("click",a);$("#fb_regloginbtn").on("click",function(e){e.preventDefault();FB.login(vBfb.reload,vBfb.loginperms)});a=$("#facebookusername");var c=$("#facebookpassword"),b=$("#facebookassociate"),d=this.makeAuthEvent(this.login_and_associate),f=function(e){13==e.which&&d(e)};a.length&&c.length&&b.length&&(b.on("click",$.proxy(function(){d()},this)),
a.keypress(f),c.keypress(f))};vB_Facebook.prototype.make_visible=function(){$("#fb_headerbox").removeClass("hidden");$("#fbregbox").removeClass("hidden")};vB_Facebook.prototype.do_login=function(a){vBulletin.AJAX({call:"/auth/loginExternal",data:{provider:"facebook",auth:a.accessToken},success:vBfb.reload,api_error:function(c){return vBulletin.ajaxtools.hasError(c,"error_external_no_vb_user")?(window.top.location="register?source=facebook",!1):!0}})};
vB_Facebook.prototype.do_connect=function(a){vBulletin.AJAX({call:"/ajax/api/facebook/connectCurrentUser",data:{accessToken:a.accessToken},success:vBfb.reload});return!1};vB_Facebook.prototype.do_disconnect=function(){vBulletin.AJAX({call:"/ajax/api/facebook/disconnectUser",data:{userid:pageData.userid},success:vBfb.reload});return!1};
vB_Facebook.prototype.login_and_associate=function(a){var c=$("#facebookusername").get(0).value,b=$("#facebookpassword").get(0).value;vBulletin.AJAX({call:"/auth/loginAndAssociate",data:{username:c,vb_login_md5password:hex_md5(str_to_ent(trim(b))),vb_login_md5password_utf:hex_md5(trim(b)),auth:a.accessToken},success:function(d,f,e){window.top.location=d.redirect}})};vB_Facebook.prototype.reload=function(){window.top.location.reload(!0)};
vB_Facebook.prototype.makeAuthEvent=function(a){return function(c){c&&c.preventDefault();(c=FB.getAuthResponse())&&c.accessToken?a(c):FB.login(function(b){b.authResponse&&b.authResponse.accessToken&&a(b.authResponse)},vBfb.loginperms);return!1}};vB_Facebook.prototype.register_logout=function(){vBulletin.AJAX({call:"/ajax/api/facebook/clearSession",success:function(){FB.logout(vBfb.reload)},api_error:vBulletin.ajaxtools.logApiError})};
vB_Facebook.prototype.handle_submit_override=function(){if("undefined"==typeof this.onSubmitEvent||!this.onSubmitEvent||this.onSubmitEvent.call(this.editFormEl)){var a=document.createElement("input");a.setAttribute("type","hidden");a.setAttribute("name",this.btnClicked.name);a.setAttribute("value",this.btnClicked.value);this.editFormEl.appendChild(a);this.editFormEl.submit()}};
vB_Facebook.prototype.has_permission=function(a,c){FB.api("/me/permissions/"+a,function(b){c(b&&!b.error&&b.data.length&&"granted"==b.data[0].status)})};vB_Facebook.prototype.request_permission=function(a,c){FB.login(function(b){var d=!1;"undefined"!=typeof b.authResponse.grantedScopes&&(d=-1<jQuery.inArray(a,b.authResponse.grantedScopes.split(",")));c(d)},{scope:a,auth_type:"rerequest",return_scopes:!0})};
vB_Facebook.prototype.isFbLogin=function(){return!!vBulletin.storagetools.getCookie("fbsr_"+this.get_config("appid"),!1)};vBulletin.precache([],["enablefacebookconnect","facebookappid","facebookactive","facebookautoregister"]);
window.fbAsyncInit=function(){$(document).ready(function(){let a=vBulletin.options.get("facebookactive"),c=0<$(".js-external-login-provider:not(.js-external-login-provider--facebook)").length;a&&(vBfb=new vB_Facebook({appid:vBulletin.options.get("facebookappid"),connected:0,active:0,autoreg:vBulletin.options.get("facebookautoregister")}));$(".js-external-login-provider--facebook").toggleClass("h-hide-imp",!a);$(".js-external-login-providers").toggleClass("h-hide-imp",!(a||c));$(document).on("click",
".js-fb-share-dialog",function(b){if(vBulletin.options.get("facebookactive"))b=$(this).data("url-not-encoded"),FB.ui({method:"share",mobile_iframe:!0,href:b},function(d){});else if(b=$(this).prop("href"),b=window.open(b,"_blank","width=573,height=239,resizable=yes,scrollbars=yes,status=yes"),!b||b.closed||"undefined"==typeof b.closed)return!0;return!1});$(document).on("click",".js-twitter-share",function(b){b=$(this).prop("href");b=window.open(b,"_blank","width=548,height=419,resizable=yes,scrollbars=yes,status=yes");
return!b||b.closed||"undefined"==typeof b.closed?!0:!1})})};(function(a){var c=a.getElementsByTagName("script")[0],b=$("#fb-root").data("facebook-language");a.getElementById("facebook-jssdk")||(a=a.createElement("script"),a.id="facebook-jssdk",a.async=!0,a.src="//connect.facebook.net/"+b+"/sdk.js#xfbml=1&version=v3.3",c.parentNode.insertBefore(a,c))})(document);
