/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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(b){function z(){var a=b(this);setTimeout(()=>{A(a)},0)}function A(a){var d=a.val();a.attr("id");var c=a.nextAll(".stylevar-display-value").first(),g=a.nextAll(".stylevar-display-value-color").first(),e=a.nextAll(".inherit-param-display-value").first(),f=a.nextAll(".inherit-param-display-value-color").first(),k=B(a,d),l=k.inherited;k=k.transformed;c.val(l);e.val(k);"color"==d.substr(-5)?(g.removeClass("hide").css("background",l),f.removeClass("hide").css("background",k),k&&a.closest(".js-inheritance-container").prevAll(".color_input_container").first().find("input").val(k).change()):
(g.addClass("hide"),f.addClass("hide"))}function C(a){a=a.toString(16);2>a.length&&(a="0"+a);return a.toUpperCase()}function F(a,d){var c="",g="",e="",f="",k="1";if("string"!=typeof a&&"undefined"!=typeof a.red)c="array",g=a.red,e=a.green,f=a.blue,k=a.alpha;else if("#"==a.substr(0,1)&&(4==a.length||7==a.length))c="hex",f=a.substr(1),3==f.length?(g=f.substr(0,1),e=f.substr(1,1),f=f.substr(2,1),g=""+g+g,e=""+e+e,f=""+f+f):(g=f.substr(0,2),e=f.substr(2,2),f=f.substr(4,2)),g=parseInt(g,16),e=parseInt(e,
16),f=parseInt(f,16);else if(a=a.match(/(rgba?)\(([^)]+)\)/)){c=a[1];var l=a[2].split(",");g=l[0];e=l[1];f=l[2];"rgba"==a[1]&&(k=l[3])}a={};a.format=c;switch(d){case "array":a.value={red:g,green:e,blue:f,alpha:k};break;case "hex":a.value="#"+C(g)+C(e)+C(f);break;case "rgb":a.value="rgb("+g+", "+e+", "+f+")";break;case "rgba":a.value="rgba("+g+", "+e+", "+f+", "+k+")";break;default:throw"Unexpected color format in convertColorFormat(): "+d;}return a}function v(a){var d={originalValue:a,originalFormat:"",
red:"",green:"",blue:"",alpha:""};a=F(a,"array");d.originalFormat=a.format;d.red=a.value.red;d.green=a.value.green;d.blue=a.value.blue;d.alpha=a.value.alpha;return d}function U(a,d,c,g,e,f,k,l,w,x,q,n){a=[{original:a,transform:w,"new":""},{original:d,transform:x,"new":""},{original:c,transform:q,"new":""}];e=[{color:"red",inherited:e},{color:"green",inherited:f},{color:"blue",inherited:k}];for(var h in a)f=a[h],a[h].deviation=Math.abs(f.original-128);for(h in e)f=e[h],e[h].inherited_deviation=Math.abs(f.inherited-
128),e[h].direction=0<f.inherited-128?"+":"-";a.sort(function(r,t){return r.deviation==t.deviation?0:r.deviation>t.deviation?-1:1});e.sort(function(r,t){return r.inherited_deviation==t.inherited_deviation?0:r.inherited_deviation>t.inherited_deviation?-1:1});f=[0,1,2];for(var m in f)a[m].color=e[m].color,a[m].inherited=e[m].inherited,a[m].inherited_deviation=e[m].inherited_deviation,a[m].direction=e[m].direction;m={};for(h in a)f=a[h],a[h].transformedValue="+"==f.direction?parseInt(f.inherited,10)+
parseInt(f.transform,10):parseInt(f.inherited,10)-parseInt(f.transform,10),m[f.color]=a[h].transformedValue;for(h in m)m[h]=Math.max(0,Math.min(255,m[h]));""!=l&&n?(m.alpha=parseFloat(l)+parseFloat(n),m.alpha=Math.max(0,Math.min(1,m.alpha))):m.alpha=l;return m}function B(a,d){a=b(a);var c=d.split(".");if(2==c.length&&(d=c[0],c=c[1],vBulletin.globalStylevarInfo&&vBulletin.globalStylevarInfo[d]&&(d=vBulletin.globalStylevarInfo[d],"undefined"!=typeof d[c]))){d={inherited:d[c],transformed:""};if("color"==
c.substr(-5)&&(a=a.attr("name").replace("stylevar_","inherit_param_"),c=b('input[name="'+a+'"]').val())){a=d.inherited;c=c.split("|");var g=c[0];c=c[1].split(",");var e=v(g);g=v(a);g.originalFormat&&(a=U(e.red,e.green,e.blue,e.alpha,g.red,g.green,g.blue,g.alpha,c[0],c[1],c[2],"undefined"!=typeof c[3]?c[3]:"1"),c=g.originalFormat,1>a.alpha&&(c="rgba"),a=F(a,c).value);d.transformed=a}return d}return{inherited:"",transformed:""}}function G(a){var d=function(n,h){n=b(document.getElementById("ctrl_stylevar["+
n+"]["+h+"]"));if("color"==h||"image"==h||"x"==h||"y"==h||"gradient_start_color"==h||"gradient_mid_color"==h||"gradient_end_color"==h){if(h=n.find("input"),h.length)return!h.eq(0).val()&&1<h.length&&h.eq(1).val()?B(h.eq(1),h.eq(1).val()).transformed:h.eq(0).val()}else if(h=n.find("select"),n=n.find("input"),h.length)return!h.eq(0).val()&&n.length&&n.eq(0).val()?B(n.eq(0),n.eq(0).val()).transformed:h.eq(0).val()},c=[],g=d(a,"image"),e=d(a,"units"),f=d(a,"x")||0,k=d(a,"x")||0,l=d(a,"color"),w=d(a,"gradient_type"),
x=d(a,"gradient_direction"),q=[];c.push((g?g:"none")+" "+d(a,"repeat")+" "+f+e+" "+k+e);b.each(["gradient_start_color","gradient_mid_color","gradient_end_color"],function(n,h){(n=d(a,h))&&q.push(n)});w&&x&&2<=q.length&&c.push(w+"("+x+", "+q.join(", ")+")");l&&c.push(l);c=c.join(", ");b("#preview_bg_"+a).css("background",c)}function H(){function a(k,l){return k==l?0:parseInt((128<=k?k>l?"-":"+":k<l?"-":"+")+Math.abs(k-l),10)}var d=b(this),c=d.val(),g=d.prevAll(".js-inherit-params").first(),e=d.prevAll(".stylevar-display-value").first().val();
var f=e+"|";c=v(c);e=v(e);f+=a(e.red,c.red)+", ";f+=a(e.green,c.green)+", ";f+=a(e.blue,c.blue);g.val(f);A(d.prevAll(".stylevar-autocomplete").first())}function I(){var a=b(this),d=a.data("stylevarid"),c=a.val();a=a.closest("#cpform_table").find('input[type="text"]:visible');"undefined"!=typeof vBulletin.globalStylevarInfo[c]&&a.each(function(){var g=b(this),e=g.attr("name");if("undefined"==typeof e)return!0;e=e.split("[");if("stylevar"!=e[0]||e[1]!=d+"]"||"stylevar_"!=e[2].substr(0,9))return!0;e=
e[2].substr(9,e[2].length-10);g.val(c+"."+e)})}function J(){var a=b(this);a.data("stylevarid");a.closest("#cpform_table").find('input[type="text"]:visible, select:visible').each(function(){var d=b(this);if("undefined"==typeof d.attr("name"))return!0;d.val("")});return!1}function K(a){D(b(".js-varlist-optgroup"),a)}function D(a,d){a.each(function(){var c=b(this);c.prop("label");c.find("option").toggleClass("h-hide-imp",!d);var g=d?c.data("label-expanded"):c.data("label-collapsed");c.prop("label",g)});
L()}function L(){var a=V();b(".js-stylevar-editor__toggle-all-groups").removeClass("toggle-link-selected");a.allGroupsExpanded?b(".js-stylevar-editor__toggle-all-groups.js-toggle-expand-all").addClass("toggle-link-selected"):a.allGroupsCollapsed&&b(".js-stylevar-editor__toggle-all-groups.js-toggle-collapse-all").addClass("toggle-link-selected")}function V(){var a=!0,d=!0;b(".js-varlist-optgroup:visible").each(function(){0<b(this).find(".js-varlist-option:visible").length?a=!1:d=!1});return{allGroupsCollapsed:a,
allGroupsExpanded:d}}function M(){b(".js-stylevar-editor__text-filter").val("");p()}function p(){var a=b(".js-stylevar-editor__text-filter").val().toLowerCase(),d=b(".js-stylevar-editor__customized-filter").prop("checked");b(".js-hidden-by-text-search:not(.js-hidden-by-iscustomized-filter)").removeClass("h-hide-imp js-hidden-by-text-search");b(".js-hidden-by-text-search.js-hidden-by-iscustomized-filter").removeClass("js-hidden-by-text-search");b(".js-stylevar-editor__clear-text-filter").addClass("h-hide-imp");
b(".js-hidden-by-iscustomized-filter:not(.js-hidden-by-text-search)").removeClass("h-hide-imp js-hidden-by-iscustomized-filter");b(".js-hidden-by-iscustomized-filter.js-hidden-by-text-search").removeClass("js-hidden-by-iscustomized-filter");b(".js-varlist-optgroup").removeClass("h-hide-imp");if(""==a&&!d)return!1;K(!0);""!=a&&(b(".js-stylevar-editor__clear-text-filter").removeClass("h-hide-imp"),b(".js-varlist-option").each(function(){var c=b(this);-1==c.data("search-text").indexOf(a)&&c.addClass("h-hide-imp js-hidden-by-text-search").prop("selected",
!1)}));d&&b(".js-varlist-option:not(.col-c):not(.col-i)").addClass("h-hide-imp js-hidden-by-iscustomized-filter").prop("selected",!1);b(".js-varlist-optgroup").each(function(){var c=b(this);0==c.find(".js-varlist-option:visible").length&&c.addClass("h-hide-imp")});y();L()}function y(){var a=[],d="";b(".js-varlist-option").each(function(){var c=b(this);c.prop("selected")&&a.push("stylevarid[]="+c.prop("value"))});0<a.length&&(a.push("securitytoken="+SECURITYTOKEN),a.push("adminhash="+ADMINHASH),a.push("do=fetchstylevareditor"),
a.push("dostyleid="+b(".js-stylevar-editor-data").data("dostyleid")),d="admincp/stylevar.php?"+a.join("&"));b(".js-edit-scroller").prop("src",d)}function N(a){a="expand-all"==b(this).data("action");a||(M(),b(".js-stylevar-editor__customized-filter").prop("checked",!1),p(),b(".js-varlist-option").prop("selected",!1),y());K(a);a&&(E.call(b(".js-stylevar-editor__text-filter")),b(".js-stylevar-editor__customized-filter"),p());return!1}function E(a){u&&(clearTimeout(u),u=0);!a||a.keyCode&&13==a.keyCode?
p():u=setTimeout(()=>{u=0;p()},50);return!1}function O(a){M();return!1}function P(a){p()}function Q(a){var d=b(this),c=d.find(".js-varlist-option:visible");1>c.length&&(D(d,!0),c=d.find(".js-varlist-option:visible"));var g=!0;c=d.find(".js-varlist-option:visible");c.each(function(){if(!b(this).prop("selected"))return g=!1});a.ctrlKey||a.metaKey||b(".js-varlist-option").prop("selected",!1);g?(c.prop("selected",!1),D(d,!1)):c.prop("selected",!0);p();y();return!1}function R(a){y();return!1}function W(){b(".js-varlist-option").each(function(){var a=
b(this),d=a.text().toLowerCase();a.data("search-text",d)})}function X(){b(".js-stylevar-preview-bg").each(function(){G(b(this).data("stylevarid"))})}function S(a){G(b(this).data("stylevarid"));return!1}function T(a){a=b("#varlist").find(":selected").map((d,c)=>"stylevarid="+b(c).val()).get();0!=a.length&&(a="admincp/stylevar.php?adminhash="+ADMINHASH+"&do=confirmrevert&"+a.join("&")+"&dostyleid="+b(".js-stylevar-editor-data").data("dostyleid"),vBRedirect(a))}var u=0;b(()=>{b(".js-stylevar-editor__toggle-all-groups").off("click",
N).on("click",N);b(".js-stylevar-editor__text-filter").off("keyup",E).on("keyup",E);b(".js-stylevar-editor__clear-text-filter").off("click",O).on("click",O);b(".js-stylevar-editor__customized-filter").off("click",P).on("click",P);b(".js-varlist-optgroup").off("click",Q).on("click",Q);b(".js-varlist-option").off("click",R).on("click",R);b(".js-stylevar-button-delete").off("click",T).on("click",T);b(".js-stylevar-button-link").off("click").on("click",a=>{window.open(b(a.currentTarget).data("url"),"edit_scroller")});
b(".js-stylevar-preview-bg-update").off("click",S).on("click",S);b(".js-stylevar-editor__toggle-all-groups.toggle-link-selected").click();W();X()});vBulletin.initStylevarInheritanceControls=function(a,d){vBulletin.globalStylevarInfo=d;b(".stylevar-autocomplete").not(".readonly").autocomplete({source:a,appendTo:".stylevar-autocomplete-menu",minLength:0,select:z}).focus(function(){var c=b(this);c.autocomplete("search",c.val())}).on("keyup",z).trigger("keyup");b(".stylevar-autocomplete.readonly").each(function(){z.call(this)});
b(".js-inherit-params").off("change keyup").on("change keyup",function(){A(b(this).prevAll(".stylevar-autocomplete").first())});b(".js-generate-transform-params").off("change keyup",H).on("change keyup",H);b(".js-inherit-all-properties").off("change",I).on("change",I);b(".js-clear-all-stylevar-fields").off("click",J).on("click",J)}})(jQuery);
