const adminUrl=window.location.href.replace("auth-frame/","")+"api/admin",siteOrigin="http://localhost:2374";window.addEventListener("message",(async function(t){if(t.origin!==siteOrigin)return void console.warn("Ignored message to admin auth iframe because of mismatch in origin","expected",siteOrigin,"got",t.origin,"with data",t.data);let i=null;try{i=JSON.parse(t.data)}catch(t){console.error(t)}function n(n,e){t.source.postMessage(JSON.stringify({uid:i.uid,error:n,result:e}),siteOrigin)}if("getUser"===i.action)try{const t=await fetch(adminUrl+"/users/me/");n(null,await t.json())}catch(t){n(t,null)}if("hideComment"===i.action)try{const t=await fetch(adminUrl+"/comments/"+i.id+"/",{method:"PUT",body:JSON.stringify({comments:[{id:i.id,status:"hidden"}]}),headers:{"Content-Type":"application/json"}});n(null,await t.json())}catch(t){n(t,null)}if("showComment"===i.action)try{const t=await fetch(adminUrl+"/comments/"+i.id+"/",{method:"PUT",body:JSON.stringify({comments:[{id:i.id,status:"published"}]}),headers:{"Content-Type":"application/json"}});n(null,await t.json())}catch(t){n(t,null)}}));