let page_generator_pro_research_timeout;function page_generator_pro_research_get_status(e,t,a){page_generator_pro_research_timeout=setInterval(function(){jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"page_generator_pro_research_get_status",id:e,nonce:page_generator_pro_tinymce.nonces.research},success(e){if(!e.success)return clearTimeout(page_generator_pro_research_timeout),wpzinc_modal_show_error_message(e.data);if(e.data.completed){switch(clearTimeout(page_generator_pro_research_timeout),a){case"tinymce":"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&tinyMCE.activeEditor.execCommand("mceReplaceContent",!1,e.data.content);break;case"quicktags":QTags.insertContent(e.data.content);break;case"gutenberg":const t=wp.blocks.createBlock("core/html",{content:e.data.content});wp.data.dispatch("core/block-editor").insertBlocks(t)}return wpzinc_modal_show_success_and_exit("Done!","")}wpzinc_modal_update_message(e.data.message)}})},1e4)}jQuery(document).ready(function(e){e("body").on("click","#wpzinc-tinymce-modal div.mce-run button, .wpzinc-backbone-modal .media-frame-toolbar .media-toolbar button.run",function(t){t.preventDefault();const a=e("form.wpzinc-tinymce-popup"),n=e('textarea[name="topic"]',e(a)).val(),c=e('textarea[name="instructions"]',e(a)).val(),o=e('select[name="content_type"]',e(a)).val(),r=e('input[name="limit"]',e(a)).val(),i=e('select[name="language"]',e(a)).val(),s=e('select[name="spintax"]',e(a)).val(),p=e('input[name="temperature"]',e(a)).val(),_=e('input[name="top_p"]',e(a)).val(),d=e('input[name="presence_penalty"]',e(a)).val(),m=e('input[name="frequency_penalty"]',e(a)).val(),l=e('input[name="editor_type"]',e(a)).val();if("tinymce"===l)tinyMCE.activeEditor.windowManager.close();else wpZincModal.close();wpzinc_modal_open("Researching..."),e.post(ajaxurl,{action:"page_generator_pro_research",nonce:page_generator_pro_tinymce.nonces.research,topic:n,instructions:c,content_type:o,limit:r,language:i,temperature:p,top_p:_,presence_penalty:d,frequency_penalty:m,spintax:s},function(e){if(!e.success)return wpzinc_modal_show_error_message(e.data);if(e.data.completed){switch(l){case"tinymce":"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&tinyMCE.activeEditor.execCommand("mceReplaceContent",!1,e.data.content);break;case"quicktags":QTags.insertContent(e.data.content);break;case"gutenberg":const t=wp.blocks.createBlock("core/html",{content:e.data.content});wp.data.dispatch("core/block-editor").insertBlocks(t)}return wpzinc_modal_show_success_and_exit("Done!","")}wpzinc_modal_update_message(e.data.message),page_generator_pro_research_get_status(e.data.id,e.data.estimated_time,l)})})});