/*!*
 **                 _     _                         
 ** __      ___ __ | |   (_)_ __   __ _ _   _  __ _ 
 ** \ \ /\ / / '_ \| |   | | '_ \ / _` | | | |/ _` |
 **  \ 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 l=1,t=0,e=setInterval(function(){99<=l?(l=99,clearInterval(e)):l>=t?l=t:(l++,u("#wplng-notice-first-loading-loading-percent").text(l+" %"))},800),g=u("#wplng-notice-first-loading-loading").attr("data-wplng-url-first-load");if(g)(async()=>{for(let a=0;a<3;a++)await new Promise(e=>{l=t,t+=33,u.ajax({url:g,method:"GET",success:function(a){e(a)},error:function(){e()}})}),a<2&&await new Promise(a=>setTimeout(a,1e3));clearInterval(e),l=100,u("#wplng-notice-first-loading-loading-percent").text("100 %"),u("#wplng-notice-first-loading-loading").hide(),u("#wplng-notice-first-loading-loaded").slideDown();{let n=document.createElement("canvas"),t=(n.style.cssText="position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:99999;",document.body.appendChild(n),n.getContext("2d")),i=(n.width=window.innerWidth,n.height=window.innerHeight,["#e8a0a0","#e8b4c8","#c4a8d4","#a8b8e0","#a8ccec","#a8d8e0","#a8d4b8","#e8e0a0","#e8cca0","#d8d8d8"]),r=[];function a(e,l){for(let a=0;a<80;a++){var t=(40*Math.random()-20)*Math.PI/180,g=16*Math.random()+10;r.push({x:e,y:n.height,vx:Math.cos(t)*g*l,vy:-Math.abs(Math.sin(t)*g)-12*Math.random()-8,w:10*Math.random()+5,h:5*Math.random()+3,color:i[Math.floor(Math.random()*i.length)],rot:Math.random()*Math.PI*2,rotSpeed:.15*(Math.random()-.5),gravity:.3,alpha:1})}}a(.1*n.width,1),a(.9*n.width,-1);let g,s=performance.now();g=requestAnimationFrame(function a(){let e=performance.now()-s,l=(t.clearRect(0,0,n.width,n.height),!1);r.forEach(function(a){a.vy+=a.gravity,a.x+=a.vx,a.y+=a.vy,a.rot+=a.rotSpeed,4e3<e&&(a.alpha=Math.max(0,a.alpha-.02)),a.y<n.height+20&&0<a.alpha&&(l=!0),t.save(),t.globalAlpha=a.alpha,t.translate(a.x,a.y),t.rotate(a.rot),t.fillStyle=a.color,t.fillRect(-a.w/2,-a.h/2,a.w,a.h),t.restore()}),l&&e<5e3?g=requestAnimationFrame(a):(cancelAnimationFrame(g),n.remove())})}u("#wplng-option-settings-form").slideDown(),u("#toplevel_page_wplingua-settings .wp-submenu-wrap").slideDown()})()}let g=u("#wplng_website_language").val(),f=JSON.parse(u("#wplng_target_languages").val());function n(e){let l=!1;return f.forEach(a=>{a.id==e&&(l=!0)}),l}function a(){let l="",t=!0;return wplngAllLanguages.forEach(a=>{let e="";void 0!==g&&g===a.id||n(a.id)?e=" disabled":t=!1,l+='<option value="'+a.id+'"'+e+">"+a.name+"</option>"}),t?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(),l}function e(){let n="";return wplngAllLanguages.forEach(a=>{if(a.id==g){var e=u("#wplng-flags-radio-original-website-custom").text();let l=u("#wplng_website_flag").val(),t=!1,g=" checked";""==l&&(t=!0),a.flags.forEach(a=>{let e="";l==a.flag&&(e=" checked",g=""),t&&(e=" checked",g="",t=!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+'"'+e+'><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"'+g+'><label for="wplng-website-flag-custom">'+e+"</label></span>",""!=g?u("#wplng-website-flag-container").show():u("#wplng-website-flag-container").hide()}}),n}function l(){let c="",d=u("#wplng-target-language-template").html();return f.forEach((r,s)=>{let p=wplngAllLanguages.find(a=>a.id===r.id);if(p){let a="";var o=u("#wplng-flags-radio-original-website-custom").text();let l="",t=!1,g=" checked",n=r.flag||"";""==n&&(t=!0),p.flags.forEach(a=>{let e="";n==a.flag&&(e=" checked",g=""),t&&(e=" checked",g="",t=!1,value=a.flag),l+='<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+'"'+e+'><label for="wplng-subflag-'+p.id+"-"+a.id+'">'+a.name+' (<img src="'+a.flag+'">)</label></span>'}),l+='<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+'" '+g+'><label for="wplng-target-flag-custom-'+p.id+'">'+o+"</label></span>";o=(e=>{let l=!1;return f.forEach(a=>{a.id==e&&1==a.private&&(l=!0)}),l})(p.id);let e="";e=(e=(e=(e=e+"<input "+' type="checkbox"')+(' id="wplng-language-private-'+p.id+'"'))+' name="wplng-language-private"'+' value="private"')+(' wplng-target-lang="'+p.id+'"'),o&&(e+=" checked"),e+="/>",a=(a=(a=(a=d).replaceAll("[PRIVATE_INPUT]",e)).replaceAll("[NAME]",p.name)).replaceAll("[LANG]",p.id);var w='<img src="'+n+'" class="wplng-target-flag">';a=(a=a.replaceAll("[FLAG]",w)).replaceAll("[FLAGS_OPTIONS]",l),o&&(a=a.replaceAll('class="wplng-target-language"','class="wplng-target-language wplng-is-private"'));let i="";1<f.length?0===s?i="wplng-hide-up-arrow":s===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+'"');w='<input type="url" class="wplng-target-subflag" wplng-target-lang="'+p.id+'" value="'+r.flag+'" />';a=a.replaceAll("[INPUT]",w),a=""==g?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 t(){u("#wplng_website_language").html((()=>{let t="";return wplngAllLanguages.forEach(a=>{let e="",l="";void 0!==g&&g===a.id&&(e=" selected"),n(a.id)&&(l=" disabled"),t+='<option value="'+a.id+'"'+e+l+">"+a.name+"</option>"}),t})()),u("#wplng_add_new_target_language").html(a()),u("#wplng-flags-radio-original-website").html(e()),u("#wplng-target-languages-list").html(l()),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 e=u("#wplng_add_new_target_language").val(),l="";wplngAllLanguages.forEach(a=>{a.id==e&&(l=a.flag)});var a={id:e,flag:l};n(e)||f.push(a),t()}}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-remove",a=>{let e=[],l=u(a.target).attr("wplng-target-lang");f.forEach(a=>{a.id!=l&&e.push(a)}),f=e,t()}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-move-up",a=>{a.preventDefault();let e=u(a.target).closest("a").attr("wplng-target-lang");var l,a=f.findIndex(a=>a.id===e);0<a&&(l=f[a],f[a]=f[a-1],f[a-1]=l,t())}),u("#wplng-target-languages-list").on("click",".wplng-target-lang-move-down",a=>{a.preventDefault();let e=u(a.target).closest("a").attr("wplng-target-lang");var l,a=f.findIndex(a=>a.id===e);a<f.length-1&&(l=f[a],f[a]=f[a+1],f[a+1]=l,t())}),u("#wplng_website_language").on("change",function(){g=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(e()),u("#wplng-website-language").html((()=>{let e="";return wplngAllLanguages.forEach(a=>{a.id==g&&(e=(e+='<img src="'+a.flag+'" id="wplng-website-flag"></img> ')+a.name)}),e})())}),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 l=u(this).attr("wplng-target-lang"),t=u(this).val();var a=".wplng-subflag-target-custom[wplng-target-lang="+l+"]";if("custom"==t)u(a).slideDown("fast");else{u(a).slideUp("fast"),u(".wplng-target-subflag[wplng-target-lang="+l+"]").val(t);let e=[];f.forEach(a=>{a.id==l?e.push({id:a.id,flag:t}):e.push(a)}),f=e,u("#wplng_target_languages").val(JSON.stringify(e))}}),u("#wplng-target-languages-list").on("click","input[type=checkbox]",function(){let e=u(this).attr("wplng-target-lang"),l=u(this).is(":checked"),t=(l?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==e?t.push({id:a.id,flag:a.flag,private:l}):t.push(a)}),f=t,u("#wplng_target_languages").val(JSON.stringify(t))}),u("#wplng-target-languages-list").on("input",".wplng-target-subflag",function(){let e=u(this).attr("wplng-target-lang"),l=u(this).val(),t=[];f.forEach(a=>{a.id==e?t.push({id:a.id,flag:l}):t.push(a)}),f=t,u("#wplng_target_languages").val(JSON.stringify(t))}),t(),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
