/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache(["cancel","no","ok","yes"],[]);
vBulletin.createDialogTools=(f,y,k)=>{function u(a,b,c,d){a.data("created")||a.dialog({autoOpen:!1,modal:!0,resizable:!1,closeOnEscape:!1,showCloseButton:!1,create:()=>{a.data("created",!0)}});b={dialogClass:"dialog-container dialog-box "+(c||""),width:b||500};d&&(b.title=d);a.dialog("option",b);d&&a.closest(".ui-dialog").find(".ui-dialog-title").html(d);a.find(".js-button").toggleClass("b-button--sitebuilder",f("body").is(".edit-mode, .js-edit-mode-style"))}function z(a,b){a=a.find(".icon");a.removeClass((c,
d)=>(d.match(/b-icon\S+\b/g)||[]).join(" ")+" no-icon b-icon");switch(b){case "warning":case "error":a.addClass("b-icon b-icon__warning-l--red h-margin-right-xl");a.show();break;default:a.addClass("no-icon").hide()}}function v(a,b,c=d=>d){b&&a.find(".message").html(c(b))}function D(a){a=a||{};let b=f("#prompt-dialog");var c=b.find(".dialog-content");let d=b.find(".js-prompt-error");u(b,500,(a.dialogClass||"")+" prompt-dialog-container",a.title);v(c,a.message);let e=a.initialValue||"",g=!a.multiline,
h,n;g?(h="input",(n=Number(a.maxlength))||(n=""),d.insertBefore(c)):(h="textarea",n="",d.insertAfter(c));c.find(".input-box").addClass("h-hide");let m=c.find(h+".input-box").val(e).removeClass("h-hide");c.toggleClass("table",g).find("> div").toggleClass("td",g);m.attr("maxlength",n);c=a.buttonLabel||{};let E=f("#btnPromptDialogOK").html(c.okLabel||k.get("ok"));$cancelButton=f("#btnPromptDialogCancel").html(c.cancelLabel||k.get("cancel"));b.find(".js-button").toggleClass("b-button--sitebuilder",f("body").is(".edit-mode, .js-edit-mode-style"));
let r;b.offon("dialogopen",function(){E.offon("click",function(){var t=f.trim(m.val());if(a.validation){var p=a.validation;Array.isArray(p)||(p=[p]);for(let A of p)if("function"==typeof A&&(p=A.apply(b,[m,a]),!0!==p))return p&&d.html(k.get(p)).removeClass("h-hide"),m.trigger("select").trigger("focus"),!1;r=this}t=[t];if(!1===l(a.onClickOK).apply(r,t)||!1===l(a.onBeforeClose).apply(r,void 0))return!1;b.dialog("close")}).trigger("focus");$cancelButton.offon("click",function(){r=this;l(a.onClickCancel).apply(r,
void 0);l(a.onBeforeClose).apply(r,void 0);b.dialog("close")})});b.offon("dialogclose",function(){d.addClass("h-hide");var t=[b];l(a.onAfterClose).apply(r,t);m.val("")});b.dialog("open");m.trigger("focus");return b}function B(a){a=a||{};var b=f(".js-dialog-template");let c=b.clone().removeClass("js-dialog-template").addClass("js-dialog").insertAfter(b);u(c,a.width,(a.dialogClass||"")+" confirm-dialog-container",a.title);b=c.find(".dialog-content");z(b,a.iconType);v(b,a.message,g=>g.replace("\n","<br />"));
b=a.buttonLabel||{};let d=f(".js-button-primary",c).html(b.yesLabel||k.get("yes"));$noButton=f(".js-button-secondary",c).html(b.noLabel||k.get("no"));let e;c.offon("dialogopen",function(){a.handleEnter&&c.offon("keydown",'[type="text"], [type="password"]',h=>{13==h.which&&(h.preventDefault(),d.trigger("click"))});let g=function(h,n){e=n.currentTarget;if(!1===l(h).apply(e,[c])||!1===l(a.onBeforeClose).apply(e,[c]))return!1;c.dialog("close")};d.offon("click",g.bind(null,a.onClickYes)).trigger("focus");
$noButton.offon("click",g.bind(null,a.onClickNo))});c.offon("dialogclose",()=>{l(a.onAfterClose).apply(e,[c]);c.dialog("destroy");c.remove()});c.dialog("open");return c}function C(a){let b={title:q(a.title),message:q(a.message),buttonLabel:{yesLabel:q(a.yesPhrase),noLabel:q(a.noPhrase)}};var c="width dialogClass onAfterClose onClickYes onClickNo iconType handleEnter".split(" ");for(let d of c)b[d]=a[d];return B(b)}function w(a){a=a||{};let b=f("#alert-dialog");u(b,a.width,"alert-dialog-container",
a.title);var c=b.find(".dialog-content"),d=f("#btnAlertDialogOK"),e="",g="";z(c,a.iconType);v(c,a.message);a.maxHeight&&(e=a.maxHeight,g="auto");c.css({"max-height":e,overflow:g});d.html(a.buttonLabel||k.get("ok"));b.offon("dialogopen",function(){d.offon("click",function(){l(a.onBeforeClose).apply(this);b.dialog("close")}).trigger("focus");b.parent(".alert-dialog-container").css("z-index","10100")});b.offon("dialogclose",()=>{l(a.onAfterClose).apply(d)});b.dialog("open");return b}function x(a,b,c,
d){let e=d;e instanceof jQuery&&(e=()=>{d.trigger("focus")});w({title:k.get(a),message:k.get(b),iconType:c,onAfterClose:e})}let l=y.ensureFun;f.widget("ui.dialog",f.ui.dialog,{_allowInteraction:function(a){if(this._super(a)||a.target.ownerDocument!=this.document[0]||f(a.target).closest(".cke_dialog").length||f(a.target).closest(".cke").length)return!0}});(function(){var a=jQuery.fn.dialog;jQuery.fn.dialog=function(){if("object"==typeof arguments[0]){var b=function(){};"function"==typeof arguments[0].open&&
(b=arguments[0].open);arguments[0].open=function(){var d=f(this);setTimeout(function(){vBulletin.Responsive.Debounce.runCallbacks();d.closest(".ui-dialog").find(".ui-dialog-titlebar-close .ui-icon").removeClass("ui-icon ui-icon-closethick").addClass("b-icon b-icon__x-square--gray")},0);d.closest(".ui-dialog").find(".ui-dialog-content").removeClass("h-hide");return b.apply(this,arguments)};var c=function(){};"function"==typeof arguments[0].close&&(c=arguments[0].close);arguments[0].close=function(){f(this).closest(".ui-dialog").find(".ui-dialog-content").addClass("h-hide");
return c.apply(this,arguments)}}return a.apply(this,arguments)}})();let q=a=>a?k.get(a):"";return{openAlertDialog:w,openModalDialog:function(a,b){let c=f(a);b=b||{};u(c,b.width,b.dialogClass,k.get(b.title));c.offon("dialogopen",function(){l(b.onOpen).call(this,c)});c.offon("dialogclose",function(){l(b.onAfterClose).call(this,c)});c.dialog("open");return c},openConfirmDialog:B,openConfirmDialogSimple:C,openPromptDialogSimple:function(a){let b={title:q(a.title),message:q(a.message),buttonLabel:{okLabel:q(a.okPhrase),
cancelLabel:q(a.cancelPhrase)},onClickOK:a.onClickOk};var c="width dialogClass onAfterClose onClickCancel validation initialValue maxlength multiline".split(" ");for(let d of c)b[d]=a[d];return D(b)},openTemplateConfirmDialog:function(a,b,c){b.message="loading_ellipsis";b.dialogClass=(b.dialogClass||"")+" loading";let d=C(b),e=c.data||{};e.isAjaxTemplateRender=!0;e.isAjaxTemplateRenderWithData=!0;let g=c.call||"/ajax/render/"+(c.template||c.name);return new Promise((h,n)=>{a.ajax({call:g,data:e,success:m=>
{m=m.template||m;d.parent(".confirm-dialog-container").removeClass("loading");f(".dialog-content .message",d).html(m).trigger("vb-instrument");d.dialog("option","position",{of:window});f("select",d).selectBox();h(d)},api_error:c.api_error,title_phrase:b.title,error_phrase:"error_loading_dialog_form",after_error:()=>{n();d.dialog("close")}})})},openTemplateAlertDialog:function(a,b,c){return new Promise((d,e)=>{let g=f.extend(c,{success:h=>{b.title=k.get(b.title);b.message=h.template||h;b.buttonLabel=
k.get(b.okPhrase||"ok");h=w(b);f(".dialog-content .message",h).trigger("vb-instrument");d(h)},title_phrase:b.title,error_phrase:"error_loading_dialog_form",after_error:()=>{e()}});a.render(g)})},validationString:function(a,b){return(a=f.trim(a.val()))?b.multiline&&a.length>b.maxlength?["message_too_long",b.maxlength]:!0:"please_enter_a_value"},popupWindow:function(a,b,c,d){let e=window,g=document;a=e.open(a,b,"status=yes,resizable=yes,scrollbars=yes,width="+c+", height="+d+", top="+((e.innerHeight||
g.documentElement.clientHeight||screen.height)/2-d/2+(e.screenTop||screen.top))+", left="+((e.innerWidth||g.documentElement.clientWidth||screen.width)/2-c/2+(e.screenLeft||screen.left)));e.focus&&a.focus();return a},alert:x,warning:(a,b,c)=>x(a,b,"warning",c),error:(a,b,c)=>x(a,b,"error",c),showStatusMessage:function(a,b){let c=f(".conversation-status-message.notice");var d;if(0<c.length){a=k.get(a);let e=c.filter("."+b);c=1==e.length?e:1==(d=c.filter(".h-hide")).length?d:c.first().clone().removeClass().addClass("conversation-status-message notice").appendTo(".conversation-status-messages");
c=(1==e.length?e:c).show();y.isScrolledIntoView(c)?c.hasClass("h-hide")?c.hide().removeClass("h-hide").addClass(b+" show-x").find("span").html(a).end().fadeIn(800,"linear"):c.fadeOut("slow","linear",function(){c.find("span").html(a).end().addClass(b+" show-x").fadeIn("slow","linear")}):(d=c.offset().top-10,c.hide(),f("html,body").animate({scrollTop:d},"slow",function(){c.find("span").html(a).end().addClass(b+" show-x").fadeIn("slow","linear")}))}}}};
