/*!*
 **                 _     _                         
 ** __      ___ __ | |   (_)_ __   __ _ _   _  __ _ 
 ** \ \ /\ / / '_ \| |   | | '_ \ / _` | | | |/ _` |
 **  \ V  V /| |_) | |___| | | | | (_| | |_| | (_| |
 **   \_/\_/ | .__/|_____|_|_| |_|\__, |\__,_|\__,_|
 **          |_|                  |___/             
 **
 **        -- wpLingua | WordPress plugin --
 **   Translate and make your website multilingual
 **
 **     https://github.com/julien-jacob/wplingua
 **      https://wordpress.org/plugins/wplingua/
 **              https://wplingua.com/
 **
 **/
jQuery(document).ready(function(u){if(u("#wplng-notice-first-loading-loading").length&&u("#toplevel_page_wplingua-settings .wp-submenu-wrap").hide(),u("#wplng-notice-first-loading-loading").length){let e=1,g=0,a=setInterval(function(){99<=e?(e=99,clearInterval(a)):e>=g?e=g:(e++,u("#wplng-notice-first-loading-loading-percent").text(e+" %"))},800),t=u("#wplng-notice-first-loading-loading").attr("data-wplng-url-first-load");if(t)(async()=>{for(let a=0;a<3;a++)await new Promise(l=>{e=g,g+=33,u.ajax({url:t,method:"GET",success:function(a){l(a)},error:function(){l()}})}),a<2&&await new Promise(a=>setTimeout(a,1e3));clearInterval(a),e=100,u("#wplng-notice-first-loading-loading-percent").text("100 %"),u("#wplng-notice-first-loading-loading").hide(),u("#wplng-notice-first-loading-loaded").slideDown(),u("#wplng-option-settings-form").slideDown(),u("#toplevel_page_wplingua-settings .wp-submenu-wrap").slideDown()})()}let t=u("#wplng_website_language").val(),f=JSON.parse(u("#wplng_target_languages").val());function n(l){let e=!1;return f.forEach(a=>{a.id==l&&(e=!0)}),e}function a(){let e="",g=!0;return wplngAllLanguages.forEach(a=>{let l="";void 0!==t&&t===a.id||n(a.id)?l=" disabled":g=!1,e+='<option value="'+a.id+'"'+l+">"+a.name+"</option>"}),g?u("#fieldset-add-target-language").hide():u("#fieldset-add-target-language").show(),u("#fieldset-add-target-language").is(":visible")&&u("#wplng-target-languages-container").is(":visible")?u("#wplng-languages-target-separator").show():u("#wplng-languages-target-separator").hide(),e}function l(){let n="";return wplngAllLanguages.forEach(a=>{if(a.id==t){var l=u("#wplng-flags-radio-original-website-custom").text();let e=u("#wplng_website_flag").val(),g=!1,t=" checked";""==e&&(g=!0),a.flags.forEach(a=>{let l="";e==a.flag&&(l=" checked",t=""),g&&(l=" checked",t="",g=!1,u("#wplng_website_flag").val(a.flag)),n+='<span class="wplng-flags-radio"><input type="radio" name="wplng-website-flag" value="'+a.flag+'" id="wplng-flag-'+a.id+'"'+l+'><label for="wplng-flag-'+a.id+'">'+a.name+' (<img src="'+a.flag+'">)</label></span>'}),n+='<span class="wplng-flags-radio"><input type="radio" name="wplng-website-flag" id="wplng-website-flag-custom" value="custom"'+t+'><label for="wplng-website-flag-custom">'+l+"</label></span>",""!=t?u("#wplng-website-flag-container").show():u("#wplng-website-flag-container").hide()}}),n}function e(){let c="",d=u("#wplng-target-language-template").html();return f.forEach((s,r)=>{let p=wplngAllLanguages.find(a=>a.id===s.id);if(p){let a="";var w=u("#wplng-flags-radio-original-website-custom").text();let e="",g=!1,t=" checked",n=s.flag||"";""==n&&(g=!0),p.flags.forEach(a=>{let l="";n==a.flag&&(l=" checked",t=""),g&&(l=" checked",t="",g=!1,value=a.flag),e+='<span class="wplng-subflags-radio"><input type="radio" name="wplng-target-subflag-'+p.id+'" value="'+a.flag+'" wplng-target-lang="'+p.id+'" id="wplng-subflag-'+p.id+"-"+a.id+'"'+l+'><label for="wplng-subflag-'+p.id+"-"+a.id+'">'+a.name+' (<img src="'+a.flag+'">)</label></span>'}),e+='<span class="wplng-flags-radio"><input type="radio" name="wplng-target-subflag-'+p.id+'" id="wplng-target-flag-custom-'+p.id+'" value="custom" wplng-target-lang="'+p.id+'" '+t+'><label for="wplng-target-flag-custom-'+p.id+'">'+w+"</label></span>";w=(l=>{let e=!1;return f.forEach(a=>{a.id==l&&1==a.private&&(e=!0)}),e})(p.id);let l="";l=(l=(l=(l=l+"<input "+' type="checkbox"')+(' id="wplng-language-private-'+p.id+'"'))+' name="wplng-language-private"'+' value="private"')+(' wplng-target-lang="'+p.id+'"'),w&&(l+=" checked"),l+="/>",a=(a=(a=(a=d).replaceAll("[PRIVATE_INPUT]",l)).replaceAll("[NAME]",p.name)).replaceAll("[LANG]",p.id);var o='<img src="'+n+'" class="wplng-target-flag">';a=(a=a.replaceAll("[FLAG]",o)).replaceAll("[FLAGS_OPTIONS]",e),w&&(a=a.replaceAll('class="wplng-target-language"','class="wplng-target-language wplng-is-private"'));let i="";1<f.length?0===r?i="wplng-hide-up-arrow":r===f.length-1&&(i="wplng-hide-down-arrow"):i="wplng-hide-arrows",a=(a=a.replaceAll('class="wplng-target-language"','class="wplng-target-language '+i+'"')).replaceAll('class="wplng-target-language wplng-is-private"','class="wplng-target-language wplng-is-private '+i+'"');o='<input type="url" class="wplng-target-subflag" wplng-target-lang="'+p.id+'" value="'+s.flag+'" />';a=a.replaceAll("[INPUT]",o),a=""==t?a.replaceAll('class="wplng-subflag-target-custom"','class="wplng-subflag-target-custom hide"'):a.replaceAll('class="wplng-subflag-target-custom"','class="wplng-subflag-target-custom show"'),c+=a}}),""==c?u("#wplng-target-languages-container").hide():u("#wplng-target-languages-container").show(),u("#fieldset-add-target-language").is(":visible")&&u("#wplng-target-languages-container").is(":visible")?u("#wplng-languages-target-separator").show():u("#wplng-languages-target-separator").hide(),c}function g(){u("#wplng_website_language").html((()=>{let g="";return wplngAllLanguages.forEach(a=>{let l="",e="";void 0!==t&&t===a.id&&(l=" selected"),n(a.id)&&(e=" disabled"),g+='<option value="'+a.id+'"'+l+e+">"+a.name+"</option>"}),g})()),u("#wplng_add_new_target_language").html(a()),u("#wplng-flags-radio-original-website").html(l()),u("#wplng-target-languages-list").html(e()),u("#wplng_target_languages").val(JSON.stringify(f))}function i(){var a=u("input[name=wplng_browser_language_redirect]:checked").val();"php_js"===a||"js_only"===a?u("#wplng_browser_language_redirect_checkbox").prop("checked",!0):u("#wplng_browser_language_redirect_checkbox").prop("checked",!1)}u("#wplng-target-lang-add").on("click",function(){if(0==f.length||confirm(u("#wplng_add_new_target_language_message").text())){let l=u("#wplng_add_new_target_language").val(),e="";wplngAllLanguages.forEach(a=>{a.id==l&&(e=a.flag)});var a={id:l,flag:e};n(l)||f.push(a),g()}}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-remove",a=>{let l=[],e=u(a.target).attr("wplng-target-lang");f.forEach(a=>{a.id!=e&&l.push(a)}),f=l,g()}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-move-up",a=>{a.preventDefault();let l=u(a.target).closest("a").attr("wplng-target-lang");var e,a=f.findIndex(a=>a.id===l);0<a&&(e=f[a],f[a]=f[a-1],f[a-1]=e,g())}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-move-down",a=>{a.preventDefault();let l=u(a.target).closest("a").attr("wplng-target-lang");var e,a=f.findIndex(a=>a.id===l);a<f.length-1&&(e=f[a],f[a]=f[a+1],f[a+1]=e,g())}),u("#wplng_website_language").on("change",function(){t=u("#wplng_website_language").val(),u("#wplng_website_flag").val(""),u("#wplng_add_new_target_language").html(a()),u("#wplng-flags-radio-original-website").html(l()),u("#wplng-website-language").html((()=>{let l="";return wplngAllLanguages.forEach(a=>{a.id==t&&(l=(l+='<img src="'+a.flag+'" id="wplng-website-flag"></img> ')+a.name)}),l})())}),u("#wplng-flags-radio-original-website").on("click","input[type=radio][name=wplng-website-flag]",function(){u("#wplng-website-flag-custom").is(":checked")?u("#wplng-website-flag-container").slideDown("fast"):(u("#wplng-website-flag-container").slideUp("fast"),u("#wplng_website_flag").val(u(this).val()))}),u("#wplng-website-lang-update-flag").on("click",function(){u("#wplng-flag-website-container").slideToggle()}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-update-flag",function(){var a=u(this).attr("wplng-target-lang");u("#wplng-target-languages-list .wplng-flag-target-container[wplng-target-lang="+a+"]").slideToggle()}),u("#wplng-target-languages-list").on("click","input[type=radio]",function(){let e=u(this).attr("wplng-target-lang"),g=u(this).val();var a=".wplng-subflag-target-custom[wplng-target-lang="+e+"]";if("custom"==g)u(a).slideDown("fast");else{u(a).slideUp("fast"),u(".wplng-target-subflag[wplng-target-lang="+e+"]").val(g);let l=[];f.forEach(a=>{a.id==e?l.push({id:a.id,flag:g}):l.push(a)}),f=l,u("#wplng_target_languages").val(JSON.stringify(l))}}),u("#wplng-target-languages-list").on("click","input[type=checkbox]",function(){let l=u(this).attr("wplng-target-lang"),e=u(this).is(":checked"),g=(e?u(this).parents(".wplng-target-language").addClass("wplng-is-private"):u(this).parents(".wplng-target-language").removeClass("wplng-is-private"),console.log(u(this).parents(".wplng-target-language")),[]);f.forEach(a=>{a.id==l?g.push({id:a.id,flag:a.flag,private:e}):g.push(a)}),f=g,u("#wplng_target_languages").val(JSON.stringify(g))}),u("#wplng-target-languages-list").on("input",".wplng-target-subflag",function(){let l=u(this).attr("wplng-target-lang"),e=u(this).val(),g=[];f.forEach(a=>{a.id==l?g.push({id:a.id,flag:e}):g.push(a)}),f=g,u("#wplng_target_languages").val(JSON.stringify(g))}),g(),u("#wplng_browser_language_redirect_checkbox").on("change",function(){(u(this).is(":checked")?u("input[name=wplng_browser_language_redirect][value=js_only]"):u("input[name=wplng_browser_language_redirect][value=disable]")).prop("checked",!0)}),u("input[name=wplng_browser_language_redirect]").on("change",function(){i()}),i(),u("#wplng-api-key-show").click(function(){u("#wplng-api-key-show").hide(),u("#wplng-api-key-hide").show(),u("#wplng-api-key-fake").hide(),u("#wplng_api_key").show()}),u("#wplng-api-key-hide").click(function(){u("#wplng-api-key-hide").hide(),u("#wplng-api-key-show").show(),u("#wplng-api-key-fake").show(),u("#wplng_api_key").hide()})});//# sourceMappingURL=option-page-settings.js.map
