jQuery(document).ready((function($){$.post(ajaxurl,{action:"sb_gsc_get_keywords",post_id:sb_gsc_metabox_data.post_id,post_url:sb_gsc_metabox_data.post_url,security:sb_gsc_metabox_data.security},(function(t){$("#sb-gsc-keywords-container").html('<div class="sb-loader"></div>'),setTimeout((function(){if($("#sb-gsc-keywords-container .sb-loader").remove(),t.data.error)$("#sb-gsc-keywords-container").html("<p>"+t.data.message+"</p>");else{var e="";e+='<table class="widefat fixed" cellspacing="0">',e+="<thead>",e+="<tr>",e+="<th>Query</th>",e+="<th>Seen in content?</th>",e+="<th>Clicks</th>",e+="<th>Impressions</th>",e+="<th>CTR</th>",e+="<th>Position</th>",e+="<th>First Seen</th>",e+="<th>Latest Seen</th>",e+="<th>Autolink</th>",e+="</tr>",e+="</thead>",e+="<tbody>",$.each(t.data.keywords,(function(t,a){e+='<tr style="display:none;">',e+=`<td><div class="query-container"><div class="copyicon" data-clipboard-text="${a.query}"></div>${a.query}</div></td>`,e+="<td>"+a.position_intext+"</td>",e+="<td>"+a.clicks+"</td>",e+="<td>"+a.impressions+"</td>",e+="<td>"+a.ctr+"</td>",e+="<td>"+a.position+"</td>",e+="<td>"+new Date(a.first_seen_date).toLocaleDateString()+"</td>",e+="<td>"+new Date(a.latest_date).toLocaleDateString()+"</td>",e+="<td>"+a.autolink+"</td>",e+="</tr>"})),e+="</tbody>",e+="</table>",$("#sb-gsc-keywords-container").html(e);new ClipboardJS(".copyicon");$("#sb-gsc-keywords-container table tbody tr").each((function(t){$(this).delay(200*t).fadeIn(150)})),$("#sb-gsc-keywords-container").append("<p>Time: "+t.data.time+" s.</p>"),jQuery(".sparkline").each((function(){let t=jQuery(this).data("original").split(",").map(Number),e=Math.max(...t),a=Math.min(...t),s=t.map((t=>e+a-t));jQuery(this).sparkline(s,{type:"line",width:"100px",height:"20px",lineColor:"#6f42c1",fillColor:"#e9ecef",tooltipFormatter:function(e,a,s){return t[s.x]}})}))}}),100)})),$(document).on("click",".seobooster-add-autolink",(function(t){t.preventDefault();var e=$(this).data("postid"),a=$(this).data("queryid"),s=$(this);s.replaceWith('<span class="spinner is-active spin-'+e+'"></span>'),$.post(ajaxurl,{action:"seobooster_gsc_make_auto_link",post_id:e,query_id:a,security:sb_gsc_metabox_data.security},(function(t){t.success?$(".spinner.is-active.spin-"+e).replaceWith("<p>&#10003; "+t.data.message+"</p>"):$(s).replaceWith("Error: "+t.data.message)})).always((function(){}))}))}));