jQuery(document).ready(function(e){var h=esc_html=function(y){if(/[&\<\>"']/.test(y=String(y))){y=y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),y=y.replace(/"/g,"&quot;").replace(/'/g,"&#039;")}return y};if(location.href.match(/page\=ws-plugin--s2member-.+?-ops/)){e("#ws-plugin--s2member-pro-eot-reminder-email-enable").on("change",function(){var z=e(this),A=z.val(),y=e(".ws-menu-page-pro-eot-reminder-email-ops");y.css("opacity",A==="1"?"":"0.5")}).trigger("change");var b=e("#ws-plugin--s2member-pro-eot-reminder-email-day"),f=b.find(".-tabs");var o=e("#ws-plugin--s2member-pro-eot-reminder-email-days"),q=e("#ws-plugin--s2member-pro-eot-reminder-email-recipients"),l=q.length?e.JSON.parse(q.val()):{},i=e("#ws-plugin--s2member-pro-eot-reminder-email-recipients-for-day"),m=function(z,y){if(typeof l[z]==="string"){return l[z]}else{if(y&&typeof l._==="string"){return l._}}return""},n=e("#ws-plugin--s2member-pro-eot-reminder-email-subject"),p=n.length?e.JSON.parse(n.val()):{},c=e("#ws-plugin--s2member-pro-eot-reminder-email-subject-for-day"),k=function(z,y){if(typeof p[z]==="string"){return p[z]}else{if(y&&typeof p._==="string"){return p._}}return""},r=e("#ws-plugin--s2member-pro-eot-reminder-email-message"),u=r.length?e.JSON.parse(r.val()):{},g=e("#ws-plugin--s2member-pro-eot-reminder-email-message-for-day"),t=function(z,y){if(typeof u[z]==="string"){return u[z]}else{if(y&&typeof u._==="string"){return u._}}return""};var j=function(){var y,z=[];y=o.val();y=y.replace(/[^0-9,\-]/g,"").split(/,+/);y=e.unique(y);e.each(y,function(B,A){if(/^\-?[0-9]+$/.test(A)){z.push(A)}});return z};var a=function(){var y=String(b.data("current"));if(y!=="undefined"&&y!==""&&y!=="_"){l[y]=e.trim(i.val());p[y]=e.trim(c.val());u[y]=e.trim(g.val())}};var v=function(z,y){a();i.val(m(z,y));c.val(k(z,y));g.val(t(z,y));b.data("current",z);f.find("a[data-day]").removeClass("-current");f.find('a[data-day="'+z+'"]').addClass("-current")};var s=function(A){var z=j(),y="";f.html("");if(z.length){e.each(z,function(C,B){y+='<a href="#" data-day="'+h(B)+'">'+esc_html(B)+"</a>"});f.html(y);v(z[0],A);b.show()}else{b.hide();v("_")}};o.on("keyup cut copy paste",function(y){s(true)});f.on("click","a[data-day]",function(z){z.preventDefault();z.stopImmediatePropagation();var y=e(this).data("day");v(y)});o.closest("form").on("submit",function(A){a();var C=j(),z={},B={},y={};C.push("_");e.each(C,function(E,D){z[D]=m(D);B[D]=k(D);y[D]=t(D)});q.val(e.JSON.stringify(z));n.val(e.JSON.stringify(B));r.val(e.JSON.stringify(y))});if(o.length){s(true)}}if(location.href.match(/page\=ws-plugin--s2member-pro-coupon-codes/)){var x=e(".ws-menu-page-table"),w=x.find(".coupons-table"),d='<tr><td class="-code"><input type="text" spellcheck="false" value="" /></td><td class="-discount"><input type="text" spellcheck="false" value="" /></td><td class="-active_time"><input type="text" spellcheck="false" value="" /></td><td class="-expires_time"><input type="text" spellcheck="false" value="" /></td><td class="-directive"><input type="text" spellcheck="false" value="" /></td><td class="-singulars"><input type="text" spellcheck="false" value="" /></td><td class="-users"><input type="text" spellcheck="false" value="" /></td><td class="-max_uses"><input type="text" spellcheck="false" value="" /></td><td class="-uses"><input type="text" spellcheck="false" value="0" /></td><td class="-actions"><a href="#" class="-up" title="Move Up" tabindex="-1"><i class="fa fa-chevron-circle-up"></i></a><a href="#" class="-down" title="Move Down" tabindex="-1"><i class="fa fa-chevron-circle-down"></i></a><a href="#" class="-delete" title="Delete" tabindex="-1"><i class="fa fa-times-circle"></i></a></td></tr>';w.find("tbody").on("click","a.-up,a.-down",function(A){A.preventDefault(),A.stopImmediatePropagation();var z=e(this),y=z.closest("tr");if(z.is(".-up")){y.insertBefore(y.prev())}else{y.insertAfter(y.next())}});w.find("tbody").on("click","a.-delete",function(A){A.preventDefault(),A.stopImmediatePropagation();var z=e(this),y=z.closest("tr");if(confirm("Delete? Are you sure?")){y.remove()}});w.find("tbody").on("keypress","input",function(y){return y.which!==13});x.find(".coupon-add > a").on("click",function(z){z.preventDefault(),z.stopImmediatePropagation();var y=e(this);w.find("tbody").append(d)});x.find("form").on("submit",function(A){var z=e(this),y="";w.find("tbody > tr").each(function(B,C){e(this).find("input").each(function(D,E){if(D===2){y+=e(E).val()+"~"}else{y+=e(E).val()+"|"}});y+="\n"});e("#ws-plugin--s2member-pro-coupon-codes").val(y)});if(!w.find("tbody > tr").length){w.find("tbody").append(d)}}});