var spinners={primary:'
',"primary-spinner":'
Loading...
'};const app={visitor_pages:[],conversion_button:document.querySelector(".conversion-button"),conversion_type:null,allowed_types:[],seo_tags:["description","title"],is_dev:!1,is_logged:!1,allowed_file_size:null,file_size:0,init(){void 0!==(cookies=this.getCookies()).logged&&"false"!==cookies.logged&&(this.is_logged=!0),this.check_if_dev()&&(this.is_dev=!0),null!==this.conversion_button&&void 0!==this.conversion_button&&(this.conversion_type=this.conversion_button.id,"ocr"===this.conversion_type&&(this.allowed_types=["jpg","png","jpeg","pdf","tiff"],this.max_files=15,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"pdf-to-image"===this.conversion_type&&(this.allowed_types=["pdf"],this.max_files=10,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"image-to-pdf"===this.conversion_type&&(this.allowed_types=["jpg","jpeg","png","tiff"],this.is_logged?this.max_files=15:this.max_files=5,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"split-pdf"===this.conversion_type&&(this.allowed_types=["pdf"],this.is_logged,this.max_files=1),"kw-check"===this.conversion_type&&(this.allowed_types=["txt","docx"],this.max_files=1,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"pdf-add-watermark"==this.conversion_type&&(this.allowed_types=["pdf"],this.max_files=1,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"merge-pdf"==this.conversion_type&&(this.allowed_types=["pdf"],this.max_files=10,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"compress-pdf"==this.conversion_type&&(this.allowed_types=["pdf"],this.max_files=1,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30),"swap-pdf-pages"==this.conversion_type&&(this.allowed_types=["pdf"],this.max_files=1,this.is_logged?this.allowed_file_size=200:this.allowed_file_size=30)),prefix=this.is_dev?"dev.":"",this.visitor_pages=["https://"+prefix+"dailyocr.com/","https://"+prefix+"dailyocr.com/tools/","https://"+prefix+"dailyocr.com/tools/ocr","https://"+prefix+"dailyocr.com/tools/pdf-to-image","https://"+prefix+"dailyocr.com/tools/image-to-pdf","https://"+prefix+"dailyocr.com/tools/keyword-density","https://"+prefix+"dailyocr.com/tools/seo-heading-checker","https://"+prefix+"dailyocr.com/tools/seo-description-checker","https://"+prefix+"dailyocr.com/tools/seo-title-checker","https://"+prefix+"dailyocr.com/tools/seo-sitemap-checker","https://"+prefix+"dailyocr.com/tools/sitemap-broken-links","https://"+prefix+"dailyocr.com/tools/sitemap-generator","https://"+prefix+"dailyocr.com/tools/seo-robots-checker","https://"+prefix+"dailyocr.com/tools/write-seo-title","https://"+prefix+"dailyocr.com/tools/write-seo-description","https://"+prefix+"dailyocr.com/tools/split-pdf","https://"+prefix+"dailyocr.com/tools/pdf-add-watermark","https://"+prefix+"dailyocr.com/tools/merge-pdf","https://"+prefix+"dailyocr.com/tools/swap-pdf-pages","https://"+prefix+"dailyocr.com/tools/minified-js-checker","https://"+prefix+"dailyocr.com/tools/minified-css-checker","https://"+prefix+"dailyocr.com/tools/seo-image-checker","https://"+prefix+"dailyocr.com/tools/seo-social-checker","https://"+prefix+"dailyocr.com/tools/seo-canonical-checker","https://"+prefix+"dailyocr.com/tools/seo-page-size-checker","https://"+prefix+"dailyocr.com/tools/seo-gzip-checker","https://"+prefix+"dailyocr.com/tools/whois-lookup","https://"+prefix+"dailyocr.com/tools/check-http-header","https://"+prefix+"dailyocr.com/tools/domain-age-checker","https://"+prefix+"dailyocr.com/tools/website-tree-structure","https://"+prefix+"dailyocr.com/tools/broken-links-checker",],!this.is_dev&&this.visitor_pages.find(e=>e===window.location.href)&&load_analitics()},check_if_dev:()=>-1!==location.hostname.indexOf("dev"),getCookies(){for(var e=document.cookie.split(";"),t={},a=0;ae.hasAttribute("checked"));var t=document.querySelector(".total-pdfs").innerHTML,a=[];a.total_pdfs=t,a.split_type=e.id;var n=[],l=[];switch(e.id){case"manual":var r=document.querySelectorAll(".manual-split"),s=document.querySelectorAll(".manual-remove");r.forEach(function(e){var t=parseInt(e.querySelector(".manual-from-span").innerHTML.split(":")[1]),a=parseInt(e.querySelector(".manual-to-span").innerHTML.split(":")[1]);n.push(t+"-"+a)}),a.splits=n,s.forEach(function(e){l.push(e.innerHTML)}),0==l.length?a.removes="none":a.removes=l;break;case"range":document.querySelectorAll(".range-split-holder").forEach(function(e,t){var a=parseInt(e.querySelector("#start-page-"+(t+1)).querySelector(".page-number").innerHTML),l=parseInt(e.querySelector("#end-page-"+(t+1)).querySelector(".page-number").innerHTML);n.push(a+"-"+l)}),a.splits=n,a.removes="none";break;case"all":document.querySelectorAll(".all-split").forEach(function(e,t){var a=parseInt(e.children[0].innerHTML.split(":")[1]);n.push(a)}),document.querySelectorAll(".manual-remove").forEach(function(e){l.push(e.innerHTML.split(":")[1])}),a.splits=n,a.removes=l}return document.querySelector("#zip-files").hasAttribute("checked")?a.has_zip="true":a.has_zip="false",a}function add_swap_pdf_pages_data(){var e=[];return e["page-order"]=[],(pages=document.querySelectorAll(".page-holder")).forEach(function(t){e["page-order"].push(t.id)}),(removed=document.querySelectorAll(".manual-remove")).length>0&&(e.removed=[],removed.forEach(function(t){e.removed.push(t.innerHTML)})),e}function add_watermark_data(){var e=document.querySelectorAll(".method");e=Array.from(e).find(e=>e.hasAttribute("checked"));var t=[];if(t.pages=[],"manual"==e.id){if(0==(pages=document.querySelectorAll(".watermarked")).length)return set_alert("Select pages to add watermark!","danger"),!1;to_add=[],pages.forEach(function(e){holder=e.parentElement.previousSibling,to_add.push(parseInt(holder.querySelector(".page-number").innerHTML)-1)}),t.pages=to_add}if("all"==e.id&&(t.pages=[1,pdf_renderer.total_pages],(removed_pages=document.querySelector(".removed-pages-list").querySelectorAll(".manual-remove")).length>0&&(t["removed-pages"]=[],removed_pages.forEach(function(e){t["removed-pages"].push(e.innerHTML)}))),"range"==e.id&&(menus=document.querySelectorAll(".range-menu")).forEach(function(e){inpts=e.querySelectorAll(".range-input"),t.pages.push([parseInt(inpts[0].value)-1,parseInt(inpts[1].value)-1])}),t.method=e.id,t["wm-type"]=document.querySelector(".selected-watermark").id,"text-wm"==t["wm-type"]){if(t["input-text"]=document.querySelector("input[name=input-text]").value,!t["input-text"])return set_alert("Insert text before submitting!","danger"),!1;t["text-font"]=document.querySelector("select[name=font-text]").value,t["text-size"]=document.querySelector("input[name=size-text]").value,t["text-color"]=hex2rgb(document.querySelector("input[name=color-text]").value),t["text-dimensions"]=get_text_dimensions(t["input-text"],t["text-size"]),(text_buttons=document.querySelectorAll(".text-decoration-input")).forEach(function(e){e.hasAttribute("checked")&&(t[e.name]="yes")})}else{if(!(file=document.querySelector("#wm-file")).files)return set_alert("Please select an image as watermakr!","danger"),!1;t["file-name"]=file.files[0].name}return(positions=[],(p_boxes=document.querySelectorAll(".position-box")).forEach(function(e){e.hasAttribute("checked")&&positions.push(e.value)}),0==positions.length)?(set_alert("Select a position for the watermark!","danger"),!1):(t.positions=positions,t.opacity=document.querySelector("select[name=opacity]").value,t.orientation=document.querySelector("select[name=orientation]").value,t)}function get_text_dimensions(e="",t=!1){return(div=document.createElement("div")).style.position="absolute",div.style.visibility="hidden",div.style.height="auto",div.style.width="auto",div.style.whiteSpace="nowrap",div.innerHTML=e,document.body.appendChild(div),res=[div.clientWidth,div.clientHeight],div.remove(),res}async function upload_files(e=!0){loading(!0),change_convert_btn(!1),remove_download_btn();let t=new FormData;var a=document.querySelector("#file"),n=document.querySelectorAll("select"),l=document.querySelectorAll("input[type=checkbox]");if(idx=0,0==a.files.length)return set_alert(message="Please upload files before converting!","danger"),change_convert_btn(!0),loading(!1,!0),!1;if(a.files.length>app.max_files)return set_alert(message="You can upload up to "+app.max_files+" files at the same time!","danger"),change_convert_btn(!0),loading(!1,!0),!1;if(app.file_size>app.allowed_file_size)return set_alert(message="Your files have exceeded the allowed size of "+app.allowed_file_size+"MB!","danger"),loading(!1,!0),change_convert_btn(!0),!1;if("image-to-pdf"===app.conversion_type||"merge-pdf"==app.conversion_type||"swap-pdf-pages"==app.conversion)t=order_file_list();else for(let r of a.files)t.append("files_"+idx,r),++idx;if("split-pdf"===app.conversion_type){var s=split_pdf_data();if(0==s.splits.length)return set_alert("Please make sure your resulted PDF contains at least 1 page!","danger"),change_convert_btn(!0),loading(!1,!0),!1;t.append("split_type",s.split_type),t.append("total_pdfs",s.total_pdfs),t.append("ranges",s.splits),t.append("removes",s.removes),t.append("has_zip",s.has_zip)}if("pdf-add-watermark"==app.conversion_type){if(!(data=add_watermark_data()))return change_convert_btn(!0),!1;"img-wm"==data["wm-type"]&&t.append("watermark-image",document.querySelector("#wm-file").files[0]),t.append("pdf-options",JSON.stringify(Object.assign({},data)))}function o(e){loading(!1),console.log("ERROR: "+e)}function d(e){if(loading(!1),null!==e.Error&&void 0!==e.Error)return set_alert(e.Error,"danger"),!1;null!==e.success&&void 0!==e.success&&conversion(e.success)}if("swap-pdf-pages"==app.conversion_type&&(data=add_swap_pdf_pages_data(),t.append("pdf-options",JSON.stringify(Object.assign({},data)))),n.length>0&&n.forEach(function(e){t.append(e.id,e.value)}),l.length>0&&l.forEach(function(e){t.append(e.id,e.value)}),t.append("conversion",app.conversion_type),e)await fetch("/upload",{method:"POST",body:t,success:function(e){}}).then(e=>e.json()).then(e=>d(e)).catch(e=>o(e));else{let c=await fetch("/upload",{method:"POST",body:t,success:function(e){}});return await c.json()}}async function conversion(e){function t(e){change_convert_btn(!0),processing(!1),console.log("ERROR: "+e)}function a(e){change_convert_btn(!0),processing(!1),null!==e.success&&void 0!==e.success?create_download_btn(e.success):null!==e.Error&&void 0!==e.Error&&set_alert(e.Error,"danger")}processing(!0),localStorage.setItem("order_id",e),await fetch("../conversion-api?id="+e+"&type="+app.conversion_type,{}).then(e=>e.json()).then(e=>a(e)).catch(e=>t(e))}function exploded_name(e){var t=[];return last_pos=e.lastIndexOf("."),t.push(e.slice(0,last_pos)),t.push(e.slice(last_pos+1,e.length)),t}function check_types(e=!1,t=[]){if(!e)var e=document.querySelector("#file");for(let a of(0==t.length&&(t=app.allowed_types),e.files))if(type=exploded_name(a.name)[1],null===(found=t.find(e=>e===type.toLowerCase()))||void 0===found)return e.value="",!1;return!0}function remove_file_handler(){(null==(parent=this.parentElement.closest("li"))||void 0==parent)&&(parent=this.parentElement.parentElement);var e=document.querySelector("#file-list-holder");l=document.querySelector(".file-counter"),r=document.querySelector(".size-counter"),id=parent.id,parent.remove();var t=document.querySelector("#file");let a=new DataTransfer;for(let n of(app.file_size=0,idx=0,app.file_size=0,t.files))idx!=id&&(a.items.add(n),app.file_size+=parseFloat((n.size/1048576).toFixed(2))),idx++;if(t.files=a.files,0===a.files.length&&e&&e.classList.add("d-none"),null!=l&&null!=r){var l=document.querySelector(".file-counter"),r=document.querySelector(".size-counter");app.file_size<=app.allowed_file_size&&r.classList.remove("bg-danger"),a.files.length<=app.max_files&&l.classList.remove("bg-danger"),l.innerHTML=a.files.length,r.innerHTML=app.file_size.toFixed(2)+" MB"}reset_list_ids()}function replace_file_handler(){target=this,parent=this.parentElement.closest("li"),holder=target.parentElement.parentElement,replace_input=document.querySelector("#replace_file"),file_input=document.querySelector("#file"),replace_input.click(),replace_input.addEventListener("change",function(){if(replace_input.files.length>0){n=document.querySelector(".file-counter"),l=document.querySelector(".size-counter");let e=new DataTransfer;for(let t of(idx=0,id=holder.id,file_input.files))idx!=id?e.items.add(t):e.items.add(replace_input.files[0]),idx++;if(file_input.files=e.files,null!=parent&&(parent.querySelector(".size-span").innerHTML=(replace_input.files[0].size/1048576).toFixed(2)+" MB"),void 0!==(img=holder.querySelector("img"))&&null!==img&&(holder.querySelector("img").src=URL.createObjectURL(replace_input.files[0])),(name_span=holder.querySelector(".image-name")||holder.querySelector(".file-name")).innerHTML=replace_input.files[0].name,void 0!==(obj=holder.querySelector("object"))&&null!==obj&&("jpeg"==(type=exploded_name(replace_input.files[0].name)[1].toLowerCase())&&(type="jpg"),obj.className="",obj.data="../images/"+type+"-type.svg",obj.classList.add(type+"-icon")),null!=n&&null!=l){for(let a of(idx=0,app.file_size=0,file_input.files))app.file_size+=parseFloat((a.size/1048576).toFixed(2));var n=document.querySelector(".file-counter"),l=document.querySelector(".size-counter");app.file_size<=app.allowed_file_size&&l.classList.remove("bg-danger"),e.files.length<=app.max_files&&n.classList.remove("bg-danger"),n.innerHTML=e.files.length,l.innerHTML=app.file_size.toFixed(2)+" MB"}}})}function remove_file(){document.querySelectorAll(".delete").forEach(function(e){e.addEventListener("click",remove_file_handler)})}function replace_file(){(replace_btns=document.querySelectorAll(".replace")).forEach(function(e){e.addEventListener("click",replace_file_handler)})}function reset_list_ids(){var e=document.querySelectorAll(".name-li");0==e.length&&(e=document.querySelectorAll(".list-image-holder")),e.forEach(function(e,t){e.id=t})}function clear_name_list(){null!==(list_div=null!==document.querySelector("#file-list-holder")?document.querySelector("#file-list-holder"):document.querySelector("#image-list"))&&null!==list_div.querySelector("#name-list")&&(list_div.querySelector("#name-list").remove(),document.querySelector(".file-counter").classList.remove("bg-danger"),document.querySelector(".size-counter").classList.remove("bg-danger"))}function names_list(){clear_name_list(),document.querySelector("#tool-work-area").classList.remove("d-none");var e=document.querySelector("#file-list-holder");e.classList.contains("d-none")&&e.classList.remove("d-none"),(label=document.querySelector(".input-label")||document.querySelector(".small-input-label")).classList.contains("input-label");var t=document.querySelector(".file-counter"),a=document.querySelector(".size-counter"),n=document.querySelector("#file"),l=document.createElement("ul");for(let r of(l.setAttribute("id","name-list"),e.appendChild(l),i=0,app.file_size=0,n.files)){var s=document.createElement("li"),o=document.createElement("span"),d=document.createElement("object"),c=document.createElement("div"),p=document.createElement("div"),u=document.createElement("span"),f=document.createElement("span");u.innerHTML=(r.size/1048576).toFixed(2)+" MB",app.file_size+=parseFloat((r.size/1048576).toFixed(2)),u.classList.add("size-span"),c.classList.add("justify-content-end","align-items-center","d-flex"),p.classList.add("align-items-center","d-flex","overflow-hidden"),"jpeg"==(type=exploded_name(r.name)[1].toLowerCase())&&(type="jpg"),d.data="../images/"+type+"-type.svg",d.classList.add(type+"-icon"),s.classList.add("text-start","name-li","list-group-item","align-items-center","d-flex","justify-content-between"),app.allowed_file_size>(r.size/1048576).toFixed(2)||s.classList.add("list-group-item-danger"),s.setAttribute("id",i),p.appendChild(d),p.appendChild(o),s.appendChild(p),o.classList.add("file-name"),o.innerHTML=r.name;var m=document.createElement("i"),h=document.createElement("i"),g=document.createElement("button"),v=document.createElement("button");g.setAttribute("title","Remove File"),v.setAttribute("title","Replace File"),g.classList.add("btn","btn-sm","btn-danger","p-2","py-1","delete"),v.classList.add("btn","btn-sm","btn-primary","p-2","py-1","me-2","replace"),m.classList.add("fa-solid","fa-trash-can"),h.classList.add("fa-solid","fa-file-arrow-up"),f.innerHTML="Pages: 1",f.classList.add("me-2"),g.appendChild(m),v.appendChild(h),c.appendChild(v),c.appendChild(u),c.appendChild(g),s.appendChild(c),l.appendChild(s),i++}i>0&&(t.innerHTML=i,i>app.max_files?t.classList.add("text-danger"):t.classList.add("text-success")),app.file_size>0&&(a.innerHTML=app.file_size.toFixed(2)+" MB",app.file_size>app.allowed_file_size?a.classList.add("text-danger"):a.classList.add("text-success")),l.style.display="block",loading(!1),change_convert_btn(!0),remove_file(),replace_file()}function swap_images(){function e(e,t){t.parentNode.insertBefore(e,t.nextSibling)}list_div_rect=(list_div=document.querySelector("#image-list")).getBoundingClientRect(),right=document.querySelector(".right-arrow").parentElement,left=document.querySelector(".left-arrow").parentElement,right.addEventListener("click",function(){if(selected_rect=(selected=document.querySelector(".selected")).getBoundingClientRect(),null==selected)return!1;null!==(parent_next_sibling=(parent=selected.parentElement).nextSibling)&&(e(parent,parent_next_sibling),list_div.scrollLeft+=selected_rect.width)}),left.addEventListener("click",function(){if(selected_rect=(selected=document.querySelector(".selected")).getBoundingClientRect(),null==selected)return!1;list=(parent=selected.parentElement).parentElement,null!==(parent_prev_sibling=parent.previousSibling)&&(list.insertBefore(parent,parent_prev_sibling),list_div.scrollLeft=list_div.scrollLeft-selected_rect.width)})}function select_image(){(images=document.querySelectorAll(".list-image-holder")).forEach(function(e){e.addEventListener("click",function(){e.classList.contains("selected")?e.classList.remove("selected"):((found=Array.from(images).find(e=>e.classList.contains("selected")))&&found.classList.remove("selected"),e.classList.add("selected"))})})}function images_list(){clear_name_list();var e=document.querySelector("#image-list");e.classList.remove("d-none"),e.innerHTML="",e.parentElement.parentElement.classList.remove("d-none"),document.querySelector(".file-counter");var t=document.querySelector("#file");for(let a of(document.createElement("ul"),(label=document.querySelector(".input-label")||document.querySelector(".small-input-label")).classList.contains("input-label")&&(label.classList.add("small-input-label","flex-row"),label.classList.remove("input-label","flex-column"),document.querySelector(".input-label-wrapper").classList.add("d-inline-block","float-end"),document.querySelector("#conversion-btn-holder").classList.add("d-inline-block")),i=0,t.files)){var n=document.createElement("span"),l=document.createElement("div"),r=document.createElement("div"),s=document.createElement("img"),o=document.createElement("div");s.classList.add("list-image"),s.src=URL.createObjectURL(a),l.classList.add("list-image-holder","m-2","p-2"),r.classList.add("image-holder");var d=document.createElement("i"),c=document.createElement("i"),p=document.createElement("button"),u=document.createElement("button");p.setAttribute("title","Remove File"),u.setAttribute("title","Replace File"),p.classList.add("btn","btn-sm","btn-danger","position-absolute","delete"),u.classList.add("btn","btn-sm","btn-primary","position-absolute","replace"),d.classList.add("fa-solid","fa-trash-can"),c.classList.add("fa-solid","fa-file-arrow-up"),p.style.top="10px",p.style.right="10px",u.style.top="10px",u.style.left="10px",p.appendChild(d),u.appendChild(c),r.appendChild(p),r.appendChild(u),r.appendChild(s),n.classList.add("image-name"),n.innerHTML=a.name,o.classList.add("d-flex","justify-content-center"),o.appendChild(n),l.appendChild(o),l.appendChild(r),l.setAttribute("id",i),l.setAttribute("draggable","false"),e.appendChild(l),i++}(holders=document.querySelectorAll(".list-image-holder")).forEach(function(e){e.addEventListener("dragover",function(t){base_handlers._handleDragover(t,e)}),e.addEventListener("dragleave",function(t){base_handlers._handleDragleave(t,e)}),e.addEventListener("drop",function(t){base_handlers._handleDrop(t,e,!0)}),e.addEventListener("dragend",function(){e.setAttribute("draggable","false"),e.classList.remove("text-dark"),e.classList.remove("bg-white")}),e.addEventListener("dragstart",function(t){base_handlers._handleDragStart(t,e)}),e.addEventListener("mousedown",function(){e.setAttribute("draggable","true")})}),remove_file(),replace_file(),loading(!1)}function order_file_list(){var e=document.querySelectorAll(".list-image-holder");0===e.length&&(e=document.querySelectorAll(".page-holder"));let t=new FormData;var a=document.querySelector("#file");for(j=0;j1&&alert_box.children[0].remove(),null!=input_alert_box&&input_alert_box.classList.add("d-none")}function check_file_upload(){var e=document.querySelector("#file");async function t(t){if(t.type,"error"===t.type&&set_alert("Some problems encountered while loading the files! Please try again","danger"),"loadend"===t.type){if(e.files.length>app.max_files){set_alert("You can upload up to "+app.max_files+" files!","danger");let a=new DataTransfer;return e.files=a.files,!1}if(check_types()){switch(clear_name_list(),label=document.querySelector(".input-label")||document.querySelector(".small-input-label"),app.conversion_type){case"image-to-pdf":images_list();break;case"kw-check":break;case"split-pdf":await pdf_renderer.load_pdf(),await pdf_display.show(),await pdf_handlers.toggle_zip(),label.classList.contains("input-label")&&(label.classList.add("small-input-label","flex-row"),label.parentElement.classList.add("d-inline-block","float-end"),label.classList.remove("input-label","flex-column"));break;case"pdf-add-watermark":await pdf_renderer.load_pdf(),await pdf_display.show(),add_manual_events(),label.classList.contains("input-label")&&(label.classList.add("small-input-label","flex-row"),label.parentElement.classList.add("d-inline-block","float-end"),label.classList.remove("input-label","flex-column"));break;case"merge-pdf":await pdf_display.display_all_first_page(),await pdf_display.make_replaceable(),label.classList.contains("input-label")&&(label.classList.add("small-input-label","flex-row"),label.parentElement.classList.add("d-inline-block","float-end"),label.classList.remove("input-label","flex-column"));break;case"swap-pdf-pages":await pdf_display.show_all(),await pdf_display.add_pdf_icons(),pdf_display.update_removed(),await pdf_display.make_replaceable(!0),label.classList.contains("input-label")&&(label.classList.add("small-input-label","flex-row"),label.parentElement.classList.add("d-inline-block","float-end"),label.classList.remove("input-label","flex-column"));break;default:names_list()}change_convert_btn(!0)}else set_alert(message="Some files are not compatible! Make sure your files are "+app.allowed_types.join(", ").toUpperCase()+".","danger")}}function a(e){e.addEventListener("loadstart",t),e.addEventListener("load",t),e.addEventListener("loadend",t),e.addEventListener("progress",t),e.addEventListener("error",t),e.addEventListener("abort",t)}function n(t){let n=new FileReader,l=e.files[0];l&&(n.readAsDataURL(l),a(n))}e.addEventListener("change",n)}function toggle_sm_menu(){(rotita=document.querySelector("#menu-toggle")).addEventListener("click",function(){rotita.previousElementSibling.classList.contains("closed-menu")?(rotita.previousElementSibling.classList.remove("closed-menu"),rotita.previousElementSibling.children[0].classList.remove("d-none"),rotita.querySelector("i").style.bottom="130px",rotita.querySelector("span").style.bottom="105px"):(rotita.previousElementSibling.classList.add("closed-menu"),rotita.previousElementSibling.children[0].classList.add("d-none"),rotita.querySelector("i").style.bottom="35px",rotita.querySelector("span").style.bottom="15px",containers=document.querySelectorAll(".sm-menu-content-item"),document.querySelector("#small-menu-contents").classList.contains("d-none")||document.querySelector("#small-menu-contents").classList.add("d-none"),containers.forEach(function(e){e.classList.contains("d-none")||e.classList.add("d-none")}))})}function split_pdf_menu(){}function pdf_watermark_menu(){function e(){opt=this.id.split("-")[1],container=document.getElementById("wm-"+opt+"-options"),containers=document.querySelectorAll(".sm-menu-content-item"),container.classList.contains("d-none")?(container.classList.remove("d-none"),container.parentElement.classList.remove("d-none")):(container.classList.add("d-none"),container.parentElement.classList.add("d-none")),containers.forEach(function(e){e!==container&&(e.classList.contains("d-none")||e.classList.add("d-none"))})}rotita=document.querySelector("#menu-toggle"),small_menu=document.querySelector("#small-menu"),(wm_option_btns=document.querySelectorAll(".wm-option-btn")).forEach(function(t){t.addEventListener("click",e)})}function toggle_help(){var e=document.querySelector(".help-menu-holder"),t=document.querySelector(".help-section"),a=document.querySelector(".close-help-holder");e.addEventListener("click",function(){t.classList.contains("d-none")?t.classList.remove("d-none"):t.classList.add("d-none")}),a.addEventListener("click",function(){t.classList.contains("d-none")?t.classList.remove("d-none"):t.classList.add("d-none")})}app.init();var pdf_renderer={total_pages:0,pdfDoc:null,icons:[],tool:document.querySelector(".conversion-button")?document.querySelector(".conversion-button").id:null,pages_div_range:document.querySelector("#pdf-pages-range"),pages_div_manual:document.querySelector("#pdf-pages-manual"),pages_div_all:document.querySelector("#pdf-pages-all"),manual_list:document.querySelector(".manual-list"),range_list:document.querySelector(".range-list"),all_list:document.querySelector(".all-list"),async load_pdf(e=!1){if(!e){if(null==(file_selector=document.querySelector("#file"))||void 0==file_selector)return!1;e=file_selector.files[0]}let t=window["pdfjs-dist/build/pdf"];return t.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.6.172/pdf.worker.min.js",new Promise(async(a,n)=>{let l=this,r=new FileReader;r.onload=async function(){var e=new Uint8Array(this.result);l.pdfDoc=t.getDocument(e),await l.pdfDoc.promise.then(e=>{l.total_pages=e._pdfInfo.numPages}),a()},await r.readAsArrayBuffer(e)})},async render_all_first_page(){for(let e of(file_selector=document.querySelector("#file"),(container=document.querySelector("#pdfs-preview")).innerHTML="",counter=1,infos=[],window.localStorage.setItem("uploaded_pdfs",JSON.stringify(infos)),file_selector.files))await this.load_pdf(e),(number=(page=await this.render_page(1)).querySelector(".page-number")).parentElement.classList.add("justify-content-center"),number.innerHTML=e.name,number.nextSibling.remove(),number.style.fontSize="12px;",page.setAttribute("id",counter),container.appendChild(page),counter++},async render_page(e,t=null){var a=document.createElement("canvas");a.classList.add("pdf-page-canvas");var n=this.page_container(a,e);return null!==t&&n.setAttribute("id",t),this.pdfDoc.promise.then(t=>{t.getPage(parseInt(e)).then(function(e){var t=e.getViewport({scale:.3}),n=window.devicePixelRatio||1,l=a.getContext("2d");a.width=Math.floor(t.width*n),a.height=Math.floor(t.height*n),a.style.width="140px",a.style.height="200px";var r=1!==n?[n,0,0,n,0,0]:null,s={canvasContext:l,transform:r,viewport:t};e.render(s)}).catch(e=>{throw Error("no page found")})}).catch(()=>{throw Error("problems querying doc")}),n},page_container(e,t,a){var n=document.createElement("div"),l=document.createElement("div");l.classList.add("d-flex","justify-content-end","w-100","align-items-center");var r=document.createElement("span");r.classList.add("page-number"),r.innerHTML=t;var s=document.createElement("div");s.classList.add("pdf-page-menu","d-flex","align-items-center","border-bottom","mb-2"),s.appendChild(r),s.appendChild(l);var o=document.createElement("div");o.classList.add("d-flex","justify-content-center","align-items-center","h-100");var d=document.createElement("div");return d.classList.add("canvas-holder","position-relative"),d.appendChild(e),o.appendChild(d),n.appendChild(s),n.appendChild(o),n.classList.add("mx-3","my-3","d-flex","flex-column","page-holder"),a&&n.classList.add("col","col-xl-2"),n.setAttribute("id",t),n},async render_range(){object=this,range_div=document.querySelector("#pdf-pages-range");var e=await this.create_range_inputs(1,1,this.total_pages),t=document.createElement("div");t.classList.add("range-pages","d-flex","justify-content-center"),range_div.appendChild(e),(pages=await this.create_range_page_list(1)).forEach(function(e){e.classList.remove("mx-3"),e.classList.remove("my-3"),e.classList.add("m-2"),t.appendChild(e)}),e.appendChild(t)},async create_range_page_list(e){var t=[],a=document.querySelector("#start-"+e),n=document.querySelector("#end-"+e);return page_1=await this.render_page(a.value,"start-page-"+e),page_2=await this.render_page(n.value,"end-page-"+e),t.push(page_1),t.push(page_2),t},async create_range_inputs(e=0,t=1,a=2){var n=document.createElement("div");n.classList.add("range-split-holder","col","col-lg-6","col-xl-6","border","p-2","m-2"),n.setAttribute("id",e);var l=document.createElement("div");l.classList.add("range-menu","d-flex","position-relative","justify-content-center");var r=document.createElement("div");r.classList.add("range-inputs"),n.appendChild(l);var s=document.createElement("i");s.classList.add("fa-regular","fa-circle-xmark","range-remove-icon","position-absolute"),s.style.left="95%",s.addEventListener("click",function(){pdf_handlers.removeRangeHandler(n)});let o=document.createElement("input");o.setAttribute("id","start-"+e),o.addEventListener("change",function(e){pdf_handlers.rangeChangeHandler(e,o)}),o.classList.add("range-input");var d=document.createElement("span");d.classList.add("mx-3"),d.innerHTML="to";let c=document.createElement("input");return c.setAttribute("id","end-"+e),c.classList.add("range-input"),c.addEventListener("change",function(e){pdf_handlers.rangeChangeHandler(e,c)}),l.appendChild(r),r.appendChild(o),r.appendChild(d),r.appendChild(c),l.appendChild(s),o.setAttribute("type","text"),o.value=t,c.setAttribute("type","text"),c.value=a,n},async render_manually(){for(i=1,pages_div_manual=document.querySelector("#pdf-pages-manual");i<=this.total_pages;i++)await pages_div_manual.appendChild(container=await this.render_page(i))},async render_all(){var e=document.querySelector("#pdf-pages-all");for(j=1;j<=this.total_pages;j++){var t=await this.render_page(j);e.appendChild(t)}},async render_all_methods(){await this.render_all(),await this.render_manually(),await this.render_range()}},pdf_display={method:document.querySelector("#method-selectors")?document.querySelector("#method-selectors").querySelector("input[checked]").id:null,zip_input:document.querySelector("#zip-files"),add_range:document.querySelector("#add-range"),async show(){await pdf_renderer.load_pdf();let e=pdf_handlers.methodSelectHandler.bind(null,null),t=document.querySelectorAll("input[name=split-select]");t.forEach(function(t){var a=t.cloneNode(!0);t.parentElement.replaceChild(a,t),document.querySelector("#pdf-pages-"+t.id).innerHTML="",t.removeEventListener("click",e,!0)}),await pdf_renderer.render_all_methods(),this.display_containers(),t=document.querySelectorAll("input[name=split-select]"),this.method_select(),this.add_range&&this.add_range.addEventListener("click",pdf_handlers.addRangeHandler);var a=document.querySelector("#zip-files"),n=a?a.cloneNode(!0):null;a&&a.parentElement.replaceChild(n,a),this.add_pdf_icons(),this.update_results(pdf_renderer.tool)},display_containers(e=!0){e?(document.querySelector(".tool-holder").classList.remove("d-none"),document.querySelector("#tool-work-area").classList.remove("d-none")):(tool_holder=document.querySelector(".tool-holder"),tool_wrapper=document.querySelector("#tool-work-area"),pdf_menu=document.querySelector(".pdf-menu"),tool_holder.contains("d-none")||tool_holder.classList.add("d-none"),tool_wrapper.contains("d-none")||tool_wrapper.classList.add("d-none"),pdf_menu.contains("d-none")||pdf_menu.classList.add("d-none"))},async show_all(){document.querySelector("#pdf-pages-all").innerHTML="",await pdf_renderer.load_pdf(),await pdf_renderer.render_all(),this.display_containers(),this.update_results(pdf_renderer.tool)},async display_all_first_page(){await pdf_renderer.render_all_first_page(),this.display_containers()},method_select(){radios=document.querySelectorAll("input[name=split-select]"),document.querySelector("#pdf-pages"),radios.forEach(function(e){e.addEventListener("click",function(){pdf_handlers.methodSelectHandler(e)})})},update_results(tool){this.update_removed(),eval((f_name="this."+tool.replaceAll("-","_")+"_update")+"()")},pdf_add_watermark_update(){},swap_pdf_pages_update(){},split_pdf_update(){switch(this.method){case"manual":this.update_manual();break;case"range":this.update_range();break;case"all":this.update_all()}},update_manual(){let e=document.querySelector(".total-pdfs");var t=document.querySelector(".manual-list");t.classList.remove("d-none"),document.querySelector(".pdf-list");let a=document.querySelector(".manual-splits");document.querySelector(".removed-pages-list");let n=pdf_renderer.pages_div_manual.querySelectorAll(".page-holder");a.innerHTML="";var l=document.querySelectorAll(".action-point");u=l.length==pdf_renderer.total_pages?pdf_renderer.total_pages:parseInt(l.length)+1,l[0];var r=l[l.length-1];void 0!==r&&(1==parseInt(r.parentElement.id)&&1==l.length&&(u=1),u=Array.from(n).find(e=>parseInt(e.id)>parseInt(r.parentElement.id)&&!e.children[1].classList.contains("remove-point"))?l.length+1:l.length),e.innerHTML=u;var s=Array.from(pdf_renderer.pages_div_manual.querySelectorAll(".remove-point")),o=document.createElement("div");o.classList.add("d-flex","p-3","result-pdf","manual-split","custom-shadow","border","border-1","border-secondary"),o.setAttribute("id","pdf-1");var d=document.createElement("span");d.classList.add("d-block","split-pdf-label");var c=document.createElement("span"),p=document.createElement("span");if(c.classList.add("manual-from-span","range-span"),p.classList.add("manual-to-span","range-span"),s.length===pdf_renderer.total_pages)return t.innerHTML="",!1;if(0==l.length)c.innerHTML="Page: 1",p.innerHTML="Page: "+pdf_renderer.total_pages,d.innerHTML="PDF - 1:",(icon=document.createElement("i")).classList.add("fa-solid","fa-ellipsis","mx-2"),o.appendChild(c),o.appendChild(icon),o.appendChild(p),a.appendChild(o);else for(i=0;i<=l.length;i++){var u,f,m=d.cloneNode();m.classList.add("d-block");var h=o.cloneNode();h.classList.add("manual-split"),h.setAttribute("id","pdf-"+(i+1));var g=c.cloneNode(),v=p.cloneNode();(g.classList.add("manual-from-span","range-span"),v.classList.add("manual-to-span","range-span"),i==l.length)?parseInt(f=l[i-1].parentElement.id)!==pdf_renderer.total_pages&&(v.innerHTML="Page: "+pdf_renderer.total_pages,g.innerHTML="Page: "+(parseInt(l[i-1].parentElement.id)+1),m.innerHTML="PDF - "+(i+1)+":",h.appendChild(g),(icon=document.createElement("i")).classList.add("fa-solid","fa-ellipsis","mx-2"),h.appendChild(icon),h.appendChild(v),a.appendChild(h)):(f=l[i].parentElement.id,v.innerHTML="Page: "+f,i>0?g.innerHTML="Page: "+(parseInt(l[i-1].parentElement.id)+1):g.innerHTML="Page: 1",parseInt(g.innerHTML.split(":")[1]),m.innerHTML="PDF - "+(i+1)+":",h.appendChild(g),(icon=document.createElement("i")).classList.add("fa-solid","fa-ellipsis","mx-2"),h.appendChild(icon),h.appendChild(v),a.appendChild(h))}var y=document.querySelectorAll(".result-pdf");document.querySelectorAll(".remove-point"),s.length>0&&y.forEach(function(e){let t=!1;var a=parseInt(e.children[0].innerHTML.split(":")[1]),n=parseInt(e.children[2].innerHTML.split(":")[1]);for(j=a;j<=n;j++){var l=document.getElementById(j);l.children[1].classList.contains("remove-point")||t||(t=!0,e.children[0].innerHTML="Page: "+parseInt(l.id))}if(e==y[y.length-1]){for(var r=0,o=parseInt(s[s.length-1].parentElement.id);o+r==pdf_renderer.total_pages;)s.pop(),o=s.length>0?parseInt(s[s.length-1].parentElement.id):pdf_renderer.total_pages+1,r++;parseInt(pdf_renderer.total_pages-r){})})}},pdf_handlers={tool:document.querySelector(".conversion-button")?document.querySelector(".conversion-button").id:null,_handlePDFDrop(e,t,a){parent=t.parentElement,t.classList.remove("bg-white"),t.classList.remove("text-dark"),t.classList.remove("border-danger"),dragged=document.getElementById(window.localStorage.getItem("dragged")),zone_box=t.getBoundingClientRect(),dragged_box=dragged.getBoundingClientRect(),a?(cloned=t.cloneNode(!0),dragged_ind=Array.from(all_holders=document.querySelectorAll(".page-holder")).indexOf(dragged),t.replaceWith(dragged),parent.insertBefore(t,parent.children[dragged_ind])):zone_box.right>dragged_box.right?t.after(dragged):parent.insertBefore(dragged,t),dragged.classList.remove("text-dark"),dragged.classList.remove("bg-white"),dragged.style.borderColor="white"},_handleDragMouseDown({movementX:e,movementY:t}){if(pdf=this,original_rect=JSON.parse(window.localStorage.getItem("pdf-"+pdf.id)),parent=pdf.parentElement,pdf_rect=pdf.getBoundingClientRect(),parent_rect=parent.getBoundingClientRect(),pdf_rect.bottom>parent_rect.bottom||pdf_rect.topparent_rect.right||pdf_rect.leftparseInt(t.value)&&(t.value=1),t.id.includes("start")&&parseInt(t.value)>pdf_renderer.total_pages&&(t.value=1),t.id.includes("end")&&parseInt(t.value)>pdf_renderer.total_pages&&(t.value=pdf_renderer.total_pages),t.id.includes("end")&&1>parseInt(t.value)&&(t.value=pdf_renderer.total_pages)):t.id.includes("start")?t.value=1:t.value=pdf_renderer.total_pages,e.srcElement.id.includes("start")){a=document.querySelector("#start-page-"+l);try{n=await pdf_renderer.render_page(e.srcElement.value,"start-page-"+l)}catch(r){console.log("yeee")}}else a=document.querySelector("#end-page-"+l),n=await pdf_renderer.render_page(e.srcElement.value,"end-page-"+l);n.classList.remove("mx-3"),n.classList.remove("my-3"),n.classList.add("m-2"),a.parentElement.replaceChild(n,a),pdf_display.update_results(pdf_renderer.tool)},toggle_menu(){var e=document.querySelector(".toggle-menu"),t=document.querySelector(".main-menu");document.querySelector("#method-selectors"),document.querySelector(".split-results"),document.querySelector(".removed-pages"),e.addEventListener("click",function(){e.classList.contains("fa-chevron-right")?(e.parentElement.parentElement.classList.add("hide-menu"),t.classList.add("d-none"),e.classList.remove("fa-chevron-right"),e.classList.add("fa-chevron-left"),document.querySelector(".help-section").classList.add("d-none")):(t.classList.remove("d-none"),e.parentElement.parentElement.classList.remove("hide-menu","p-3"),e.classList.add("fa-chevron-right"),e.classList.remove("fa-chevron-left"))}),pdf_handlers.toggle_zip()},toggle_zip(){var e=document.querySelector("#zip-files");if(!e)return!1;e.addEventListener("click",function(){e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","checked")})},removeRangeHandler(e){e.remove(),document.querySelectorAll(".range-split-holder").forEach(function(e,t){e.setAttribute("id",t+1),e.children[1].children[0].setAttribute("id","start-page-"+(t+1)),e.children[1].children[1].setAttribute("id","end-page-"+(t+1)),e.children[0].children[0].children[0].setAttribute("id","start-"+(t+1)),e.children[0].children[0].children[2].setAttribute("id","end-"+(t+1))}),pdf_display.update_results(pdf_renderer.tool)},pageIconHandler(e,t){var a,n=e.parentElement.parentElement.parentElement.nextSibling;switch(e.parentElement.parentElement.parentElement.parentElement,document.querySelector(".removed-pages-list"),t){case"action":a="action",n.classList.remove("remove-point");break;case"remove":a="remove",n.classList.remove("action-point")}n.classList.contains(a+"-point")?(n.classList.remove(a+"-point"),t):n.classList.add(a+"-point"),pdf_display.update_results(pdf_renderer.tool)}},base_handlers={_handleDragStart(e,t){window.localStorage.setItem("dragged",t.id),t.style.borderColor="red",t.classList.add("text-dark","bg-white")},_handleDragleave(e,t){"false"==t.getAttribute("draggable")&&(t.classList.remove("border-danger"),t.classList.remove("bg-dark"),t.classList.remove("text-dark"))},_handleDragover(e,t){e.preventDefault(),target=e.target,"false"==t.getAttribute("draggable")&&t.classList.add("border-danger","bg-dark","text-dark")},_handleDrop(e,t,a){parent=t.parentElement,t.classList.remove("bg-dark"),t.classList.remove("text-dark"),t.classList.remove("border-danger"),dragged=document.getElementById(window.localStorage.getItem("dragged")),zone_box=t.getBoundingClientRect(),dragged_box=dragged.getBoundingClientRect(),a?(cloned=t.cloneNode(!0),dragged_ind=Array.from(all_holders=document.querySelectorAll(".list-image-holder")).indexOf(dragged),t.replaceWith(dragged),parent.insertBefore(t,parent.children[dragged_ind])):zone_box.right>dragged_box.right?t.after(dragged):parent.insertBefore(dragged,t),dragged.classList.remove("text-dark"),dragged.classList.remove("bg-white"),dragged.style.borderColor="white"}};function add_position_events(){(boxes=document.querySelectorAll(".position-box")).forEach(function(e){e.addEventListener("click",_handleSelectPosition)})}function add_manual_events(){(icons=document.querySelectorAll(".action-icon")).forEach(function(e){new_i=e.cloneNode(!0),e.parentElement.appendChild(new_i),e.remove(),new_i.addEventListener("click",_handleManualWatermark)}),(text_buttons=document.querySelectorAll(".text-decoration-input")).forEach(function(e){e.addEventListener("click",_handleTextDecorationButton)}),(watermark_type_selects=document.querySelectorAll(".watermark-type-select")).forEach(function(e){e.addEventListener("click",_handleChangeWmType)}),range=document.querySelector("input[name=range-size]"),(inpt=document.querySelector("input[name=size-text]")).addEventListener("input",_handleTextSizeInput),range.addEventListener("input",_handleTextSizeRange),(file=document.querySelector("#wm-file")).addEventListener("change",_handleAddWmImage)}function _handleAddWmImage(){check_types(this,["jpg","jpeg","png"])||(this.value="",set_alert("Please select a JPG, JPEG or PNG image!","danger"))}function _handleChangeWmType(){this.classList.contains("selected-watermark")||((sibling=this.nextElementSibling||this.previousElementSibling).classList.remove("selected-watermark"),document.querySelector("#watermark-"+this.id.split("-")[0]+"-options").classList.remove("d-none"),document.querySelector("#watermark-"+sibling.id.split("-")[0]+"-options").classList.add("d-none"),this.classList.add("selected-watermark"))}function _handleTextSizeRange(){document.querySelector("input[name=size-text]").value=this.value}function _handleTextSizeInput(){if(this.value<0)return this.value=0,!1;document.querySelector("input[name=range-size]").value=this.value}function _handleTextDecorationButton(){btn=this,btn.hasAttribute("checked")?(btn.removeAttribute("checked"),btn.classList.remove("btn-secondary"),btn.classList.add("btn-outline-secondary")):(btn.classList.remove("btn-outline-secondary"),btn.classList.add("btn-secondary"),btn.setAttribute("checked","checked"))}function _handleManualWatermark(){icon=this,element_holder=this.parentElement.parentElement.parentElement.nextSibling.children[0],boxes=document.querySelectorAll(".position-box"),element_holder.classList.contains("watermarked")?(element_holder.classList.remove("watermarked"),boxes.forEach(function(e){(mark=element_holder.querySelector("."+e.value))&&mark.remove()})):(element_holder.classList.add("watermarked"),boxes.forEach(function(e){e.hasAttribute("checked")&&display_mark(element_holder,e.value)}))}function _handleSelectPosition(){inpt=this,pages_container_all=document.querySelector("#pdf-pages-all"),pages_container_manual=document.querySelector("#pdf-pages-manual"),all_holders=pages_container_all.querySelectorAll(".canvas-holder"),manual_holders=pages_container_manual.querySelectorAll(".watermarked"),holders=Array.from(all_holders).concat(Array.from(manual_holders)),inpt.hasAttribute("checked")?(inpt.removeAttribute("checked"),holders.forEach(function(e){(mark=e.querySelector("."+inpt.value))&&mark.remove()})):(inpt.setAttribute("checked","checked"),holders.forEach(function(e){display_mark(e,inpt.value)}))}function display_mark(e,t){switch((mark=document.createElement("i")).classList.add("fa-regular","fa-circle-dot","position-absolute",t),mark.style.height="20px",mark.style.width="20px",mark.style.color="red",(copy=e.cloneNode(!0)).classList.remove("position-relative"),copy.classList.add("position-absolute"),copy.style.display="block",copy.style.top="-100000",copy.style.left="-100000",copy.style.visibility="hidden",document.body.appendChild(copy),c_height=parseInt(copy.offsetHeight),c_width=parseInt(copy.offsetWidth),copy.remove(),t){case"north-west":mark.style.top="6px",mark.style.left="6px";break;case"north":mark.style.top="6px",mark.style.left=c_width/2-10+"px";break;case"north-east":mark.style.top="6px",mark.style.right="6px";break;case"west":mark.style.top=c_height/2-15+"px",mark.style.left="6px";break;case"center":mark.style.top=c_height/2-15+"px",mark.style.left=c_width/2-10+"px";break;case"east":mark.style.top=c_height/2-15+"px",mark.style.right="6px";break;case"south-west":mark.style.left="6px",mark.style.bottom="16px";break;case"south":mark.style.bottom="16px",mark.style.left=c_width/2-10+"px";break;case"south-east":mark.style.right="6px",mark.style.bottom="16px"}e.appendChild(mark)}function clear_file_info(e=null,t=null){null===e&&(e=document.querySelector(".file-counter")),null===t&&(t=document.querySelector(".size-counter")),e&&(e.innerHTML="",e.classList.add("d-none")),t&&(t.innerHTML="",t.classList.add("d-none"))}function loading(e,t=!1){var a=document.getElementById("loading");null!=a&&(e?(a.parentElement.classList.contains("hidden")&&a.parentElement.classList.remove("hidden"),a.parentElement.parentElement.classList.contains("hidden")&&a.parentElement.parentElement.classList.remove("hidden"),a.classList.remove("hidden")):(a.parentElement.classList.contains("hidden")||a.parentElement.classList.add("hidden"),t&&(a.parentElement.parentElement.classList.contains("hidden")||a.parentElement.parentElement.classList.add("hidden")),a.classList.add("hidden")))}function processing(e,t=!1){var a=document.getElementById("processing");null!=a&&(e?(a.parentElement.classList.contains("hidden")&&a.parentElement.classList.remove("hidden"),a.parentElement.parentElement.classList.contains("hidden")&&a.parentElement.parentElement.classList.remove("hidden"),a.classList.remove("hidden")):(a.parentElement.classList.contains("hidden")||a.parentElement.classList.add("hidden"),t&&(a.parentElement.parentElement.classList.contains("hidden")||a.parentElement.parentElement.classList.add("hidden")),a.classList.add("hidden")))}function window_close(){window.onbeforeunload=function(){return"Are you sure"}}function load_analitics(){var e=document.createElement("script");e.src="https://googletagmanager.com/gtag/js?id=G-JMJ9E5GWL9",document.getElementsByTagName("head")[0].appendChild(e);var t=document.createElement("script");t.setAttribute("async","async"),t.innerHTML="window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', 'G-JMJ9E5GWL9');",document.getElementsByTagName("head")[0].appendChild(t)}function load_pdfjs(){var e=document.createElement("script"),t=document.createElement("link");e.src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.6.172/build/pdf.min.js",t.href="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.6.172/web/pdf_viewer.min.css",document.getElementsByTagName("head")[0].appendChild(e),document.getElementsByTagName("head")[0].appendChild(t)}function create_download_btn(e=""){var t=document.createElement("div"),a=document.querySelector(".conversion-tab")||document.querySelector("#results")||document.querySelector("#download-section");("split-pdf"==app.conversion_type||"ocr"==app.conversion_type||"pdf-add-watermark"==app.conversion_type||"merge-pdf"==app.conversion_type||"swap-pdf-pages"==app.conversion_type)&&(a=document.querySelector("#download-section")).classList.remove("d-none"),null!==document.querySelector("div[id=button-holder]")&&document.querySelector("div[id=button-holder]").remove();var n=document.createElement("a");n.setAttribute("id","download"),document.createElement("lable"),t.setAttribute("id","button-holder"),isValidUrl(e)?fetch(e,{method:"get",mode:"no-cors",referrerPolicy:"no-referrer"}).then(e=>e.blob()).then(e=>{n.setAttribute("download","dailyocr-file");let t=URL.createObjectURL(e);n.href=t,n.setAttribute("target","_blank")}):(n.target="_blank",n.setAttribute("href",e)),n.style.textDecoration="none","pdf-to-image"==app.conversion_type||"split-pdf"==app.conversion_type?(t.classList.add("form-group","text-center","m-auto","w-100"),n.classList.add("btn-sample","form-control","text-center","m-auto"),n.innerHTML="Download"):(n.classList.add("text-center","m-auto"),n.innerHTML=e,t.classList.add("text-center","m-auto","text-break"),t.style.maxWidth="100%"),t.appendChild(n),a.appendChild(t),processing(!1)}async function multiple_download_links(e){var t=document.createElement("div"),a=document.querySelector("#tool-wrapper");for(url of(t.classList.add("text-center","m-auto","text-break","w-100","mb-2"),counter=0,e)){var n=document.createElement("a");n.style.fontSize="18px",n.classList.add("text-center","m-auto","d-block"),n.innerHTML=url,await fetch(url,{method:"get",mode:"no-cors",referrerPolicy:"no-referrer"}).then(e=>e.blob()).then(e=>{n.setAttribute("download","dailyocr-file-"+counter);let t=URL.createObjectURL(e);n.href=t,n.setAttribute("target","_blank")}),t.appendChild(n),counter++}a.appendChild(t)}function remove_download_btn(){var e=document.querySelector("#button-holder");null!=e&&e.remove()}function enable_convert_button(){(btn=document.querySelector(".conversion-button")).hasAttribute("hidden")&&btn.removeAttribute("hidden"),btn.removeAttribute("disabled")}function disable_convert_button(){(btn=document.querySelector(".conversion-button")).setAttribute("disabled","disabled")}function active_link(){Array.from(document.querySelectorAll(".nav-link")).find(function(e){e.href===window.location.href&&e.classList.add("active","fw-bold")})}function isEmpty(e){return 0===Object.keys(e).length}function landing_upload(){var e=document.querySelector("#file");e.addEventListener("change",function(){if(check_types()){var t=document.querySelector(".upload-file-name"),a=document.querySelector(".conversion-button");t.innerHTML=e.files[0].name;var n=parseFloat((e.files[0].size/1048576).toFixed(2));if(a.removeAttribute("disabled"),n>app.allowed_file_size)return set_alert("File size must not exceed "+app.allowed_file_size+" MB!","danger"),!1;redirect_to_ocr(a,e.files[0].name,n)}else set_alert("Bad file type! Make sure your file is "+app.allowed_types.join(", ").toUpperCase(),"danger")})}function _handleSitemapBoxClick(){clicked=this,clicked.setAttribute("value","true"),document.querySelectorAll("input[type=checkbox]").forEach(function(e){e!==clicked&&(e.removeAttribute("value"),e.checked=!1)})}function sitemap_check_select(){document.querySelectorAll("input[type=checkbox]").forEach(function(e){e.addEventListener("click",_handleSitemapBoxClick)})}function sitemap_home_click(){(btn=document.querySelector(".conversion-button")).addEventListener("click",_handleSitemapHomeRedirect)}function _handleSitemapHomeRedirect(){var e;if(check_type=document.querySelector("input[value=true]"),!(e=document.querySelector("input[name=url]")).value)return set_alert("Please insert a valid ULR.","danger"),!1;switch(type=check_type?check_type.name:"validate",localStorage.setItem("sitemap_home_url",e.value),localStorage.setItem("sitemap_home_type",type),type){case"validate":e="/tools/seo-sitemap-checker";break;case"broken-links":e="/tools/sitemap-broken-links";break;case"generate":e="/tools/sitemap-generator"}window.location.href=e}function handle_sitemap_home_redirect(){type=localStorage.getItem("sitemap_home_type"),url=localStorage.getItem("sitemap_home_url"),type&&url&&((input=document.querySelector("input[name=url]")).innerHTML=url,input.value=url,seo_check()),localStorage.removeItem("sitemap_home_type"),localStorage.removeItem("sitemap_home_url")}function redirect_to_ocr(e,t,a){e.addEventListener("click",async function(e){var n;return e.preventDefault(),await upload_files(!1).then(e=>n=e).catch(e=>console.log("Message:"+e.message)),null!==n.success&&void 0!==n.success&&(localStorage.setItem("order_id",n.success),localStorage.setItem("file_name",t),localStorage.setItem("size",a),window.location.replace("/tools/ocr")),!1})}function create_file_list_landing(e,t){document.querySelector("#tool-files").classList.remove("d-none");var a=document.createElement("li"),n=document.querySelector("#file-list-holder"),l=document.querySelector(".file-counter"),r=document.querySelector(".size-counter"),s=document.createElement("span"),o=document.createElement("object"),d=document.createElement("span"),c=document.createElement("div"),p=document.createElement("div"),u=document.createElement("span"),f=document.createElement("ul");f.setAttribute("id","name-list"),f.style.display="block",u.innerHTML=t+" MB",app.file_size=t,u.classList.add("size-span"),c.classList.add("justify-content-end","align-items-center","w-50","d-flex"),p.classList.add("align-items-center","d-flex","overflow-hidden","w-100"),"jpeg"==(type=exploded_name(e)[1].toLowerCase())&&(type="jpg"),a.classList.add("text-start","name-li","list-group-item","align-items-center"),o.data="../images/"+type+"-type.svg",o.classList.add(type+"-icon"),o.classList.add("file-icon","blue"),p.appendChild(o),p.appendChild(s),a.appendChild(p),s.classList.add("file-name"),s.innerHTML=e,d.classList.add("remove-file","delete"),d.innerHTML="✕",c.appendChild(u),c.appendChild(d),a.appendChild(c),f.appendChild(a),l.innerHTML="Total files: 1",app.file_size>0&&(r.innerHTML="Total size: "+t+" MB",app.file_size>app.allowed_file_size&&r.classList.add("bg-danger")),n.appendChild(f),loading(!1),change_convert_btn(!0),remove_file()}async function get_landing_file(){let e=localStorage.getItem("order_id");var t="https://"+location.hostname+"/";if(e&&document.referrer==t){let a;create_file_list_landing(localStorage.getItem("file_name"),localStorage.getItem("size")),await conversion(e),localStorage.removeItem("size")}}async function preview_image(){document.querySelectorAll(".image-content").forEach(async e=>{await fetch(url=e.nextElementSibling.children[0].getAttribute("href-a-data"),{method:"get"}).then(e=>e.blob()).then(t=>{let a=URL.createObjectURL(t);e.querySelector("img").src=a}),e.addEventListener("click",function(){var t=e.children[0],a=document.querySelector(".modal");a.style.display="block",(modal_img=a.children[1]).src=t.src,close_image(a)})})}function close_image(e){e.querySelector(".close").addEventListener("click",function(){e.style.display="none"})}function include_on_click(){(boxes=document.querySelectorAll(".page-include")).forEach(function(e){e.addEventListener("click",function(){""===e.value?e.value=!0:e.value=""})})}function source_select(){let e=document.querySelector("#source-nav").querySelectorAll("span"),t=document.querySelectorAll(".source-input-holder");t[0].style.maxHeight="500px",e.forEach(function(a){a.addEventListener("click",function(n){e.forEach(function(e){e.classList.contains("active")&&e.classList.remove("active")}),t.forEach(function(e){"0px"!==e.style.maxHeight&&(e.style.maxHeight=0,e.style.overflow="hidden")}),a.classList.add("active"),document.querySelector("#kw-source-"+a.dataset.source).style.maxHeight="500px",document.querySelector("#kw-source-"+a.dataset.source).style.overflow="auto"})})}function uncheck_method(){(boxes=document.querySelectorAll(".kw-method")).forEach(function(e){e.addEventListener("click",function(){""===e.value?e.value=!0:e.value="",boxes.forEach(function(t){t!==e&&(t.checked=!1,t.value="")})})})}function density_on_key(){window.addEventListener("keypress",function(e){"Enter"===e.key&&(e.preventDefault(),density())})}async function density(){processing(!0);let e=document.querySelector("#main-results"),t=new FormData,a="";if(url_selector=document.querySelector("#main-url"),competitor_url_selector=document.querySelector("#competitor-url"),include_boxes=document.querySelectorAll(".page-include"),a=(a=Array.from(method_boxes=document.querySelector("#source-nav").querySelectorAll(".nav-link")).find(e=>e.classList.contains("active"))).dataset.source,t.append("method",a),"link"==a){if(""==url_selector.value)return set_alert("Please insert the url to your webpage before proceeding!","danger"),!1;t.append("url",url_selector.value),competitor_url_selector.value.trim()&&t.append("competitor-url",competitor_url_selector.value),include_boxes.forEach(function(e,a){"true"===e.value&&t.append(e.name,e.value)})}if("text"==a){if(text_area=document.querySelector("#kw-text"),""!==(custom_kw=document.querySelector("#kw-input-text").value).trim()&&t.append("custom-keywords",custom_kw),""==text_area.value)return set_alert("Please insert text in the input area before proceeding!","danger"),!1;t.append("text",text_area.value)}if("file"==a){var n;if(0==document.querySelector("#file").files.length)return set_alert("Please select a file before proceeding!","danger"),!1;await upload_files(!1).then(e=>n=e).catch(e=>console.log("Message:"+e.message)),!1!==n?(t.append("id",n.success),""!==(custom_kw=document.querySelector("#kw-input-file").value).trim()&&t.append("custom-keywords",custom_kw)):set_alert("We encountered some problems. Please try again or try again later!","danger"),loading(!1),change_convert_btn(!0)}function l(t){if(clear_results(),null!==t.status&&void 0!==t.status)set_alert(t.status,"danger");else for(let n in t){if("link"==a&&(url=document.querySelector("#"+n+"-url"),e=document.querySelector("#"+n+"-results"),(indicator=document.createElement("span")).innerHTML="Results for: "+url.value,hr=document.createElement("hr"),e.appendChild(indicator)),"link"==a&&0===t[n].density.keywords.length){var l=document.createElement("div");l.classList.add("alert","alert-danger","p-2","mb-2"),l.innerHTML="The Page does not have Meta Keywords!",l.style.fontSize="15px",e.appendChild(l),hr=document.createElement("hr")}create_tables(t[n].density,a,n),statistics(t[n].statistics,n)}processing(!1),e.removeAttribute("hidden")}function r(e){console.log(e)}await fetch("/find-density",{method:"POST",body:t,success:function(e){}}).then(e=>e.json()).then(e=>l(e)).catch(e=>r(e))}function clear_results(){(arr=["main","competitor"]).forEach(function(e){(result_div=document.querySelector("#"+e+"-results")).classList.remove("d-none"),stats_div=document.querySelector(".statistics"),density_div=document.querySelector(".density"),null!==stats_div&&null!==density_div?(stats_div.innerHTML="",density_div.innerHTML=""):result_div.innerHTML=""})}function statistics(e,t){var a=(main_res=document.querySelector("#"+t+"-results")).querySelector("#phrases"),n=document.createElement("div");for(let[l,r]of(n.classList.add("p-2","alert","alert-primary","mb-2"),n.style.fontSize="15px",Object.entries(e))){var s=document.createElement("span");s.classList.add("me-2"),s.innerHTML=l+": "+r+"",n.appendChild(s)}a.insertBefore(n,a.children[0])}function create_tables(e,t,a){let n=["keywords","one-word","two-words","three-words","four-words"];if(results_div=document.querySelector("#"+a+"-results"),"link"==t)var l=["Keyword","Frequency","Title","Description","H-tags","Density"];else var l=["Keyword","Frequency","Density"];(buttons_holder=document.createElement("div")).classList.add("nav","nav-tabs"),(words_table_container=document.createElement("div")).classList.add("w-100"),(tables_and_menu_holder=document.createElement("div")).setAttribute("id","phrases"),tables_and_menu_holder.classList.add("d-flex","flex-column"),tables_and_menu_holder.appendChild(buttons_holder),tables_and_menu_holder.appendChild(buttons_holder),tables_and_menu_holder.appendChild(words_table_container),results_div.appendChild(tables_and_menu_holder),n.forEach((a,n)=>{if(0===e[a].length)return;(result_table=document.createElement("table")).classList.add("word-density-table");var r=document.createElement("h5");r.innerHTML="Results for "+a.replace("-"," "),r.classList.add("mt-3","kw-table-name"),"keywords"==a?result_table.classList.add("table","table-success","table-striped","m-auto"):result_table.classList.add("table","table-primary","table-striped","m-auto");let s=document.createElement("div");s.setAttribute("id",a),result_table.setAttribute("id",a),table_head=document.createElement("thead"),th_r=document.createElement("tr"),table_head.appendChild(th_r),l.forEach(e=>{(head=document.createElement("th")).innerHTML=e,head.classList.add("kw-table-heading"),th_r.appendChild(head)}),result_table.appendChild(table_head),table_body=document.createElement("tbody"),result_table.appendChild(table_body),hr=document.createElement("hr"),"keywords"===a?((collapse_btn=document.createElement("button")).classList.add("btn","btn-sm","btn-primary","shadow-none","border-0","rounded-0","d-flex","justify-content-between","w-100"),collapse_btn.style.backgroundColor="#777",collapse_btn.addEventListener("click",_handleKWTableDropDown),(show_span=document.createElement("span")).innerHTML="Hide Keywords",(icon=document.createElement("i")).classList.add("fa-solid","fa-caret-down"),collapse_btn.appendChild(show_span),collapse_btn.appendChild(icon),result_table.classList.add("w-100","mb-2"),s.appendChild(collapse_btn),s.appendChild(result_table),"link"==t?results_div.insertBefore(s,results_div.children[1]):results_div.insertBefore(s,results_div.children[0])):(btn=document.createElement("span"),btn_name=(btn_name=a.replace("-"," ")).charAt(0).toUpperCase()+btn_name.slice(1),btn.innerHTML=btn_name+" phrases",btn.style.fontSize="15px",btn.setAttribute("onclick","_handleShowTable(this)"),btn.setAttribute("id",a+"-toggle"),buttons_holder.appendChild(btn),result_table.classList.add("w-100"),"one-word"!==a?(s.classList.add("d-none"),btn.classList.add("nav-link","flex-fill")):(btn.classList.add("active"),btn.classList.add("nav-link","flex-fill")),s.appendChild(result_table),words_table_container.appendChild(s)),populate_table(e[a],result_table)})}function _handleKWTableDropDown(){(target=this.nextElementSibling).classList.contains("d-none")?(target.classList.remove("d-none"),this.querySelector("i").classList.remove("fa-caret-up"),this.querySelector("i").classList.add("fa-caret-down"),this.querySelector("span").innerHTML="Hide Keywords",this.classList.remove("mb-2")):(target.classList.add("d-none"),this.querySelector("i").classList.remove("fa-caret-down"),this.querySelector("i").classList.add("fa-caret-up"),this.querySelector("span").innerHTML="Show Keywords",this.classList.add("mb-2"))}function _handleShowTable(e){if((current_btn=e.parentElement.parentElement.querySelector(".active"))==e)return!1;e.classList.remove("btn-outline-primary"),table_name=(table_name=e.id.split("-"))[0]+"-"+table_name[1],(next_table=e.parentElement.parentElement.querySelector("#"+table_name)).classList.remove("d-none"),e.classList.add("active"),current_btn.classList.remove("active"),prev_table_name=(prev_table_name=current_btn.id.split("-"))[0]+"-"+prev_table_name[1],e.parentElement.parentElement.querySelector("#"+prev_table_name).classList.add("d-none")}function populate_table(e,t){for(let[a,n]of(console.log(Object.entries(e)),Object.entries(e))){if(0===e.length)return;var l=t.querySelector("tbody").insertRow(),r=l.insertCell(0);r.classList.add("kw-table-cell","kw-table-cell-words"),r.innerHTML=a,Object.values(n).forEach(function(e,a){"keywords"==t.id&&0==a&&0==e&&l.classList.add("table-danger");var n=l.insertCell(a+1);n.classList.add("kw-table-cell","align-middle"),n.innerHTML=e})}}function make_token(e){let t="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=a.length,l=0;for(;l=f&&(processed_links_string=Object.values(e["total-urls"])[0].toString(),u+=5,power=u>=10?parseInt(processed_links_string.length)-parseInt(parseInt(u.toString().length)-1):parseInt(processed_links_string.length),power=3,f=c=parseInt(u)*10**power,clearInterval(p),p=setInterval(await L,c),e["time-update"]={"Updating every:":parseInt(c)/1e3+" seconds"}),e["time-update"]={"Updating every: ":parseInt(c)/1e3+" seconds"}),update_data(e,n.value)}async function L(){fetch("/progress-data?data="+n.value+"&token="+l,{async:!0,method:"GET",keepalive:!0,success:function(e){}}).then(e=>e.json()).then(e=>y(e)).catch(e=>v(e))}null!=m&&m.remove(),e.append("url",t.value),e.append("to-check",n.value),t="/seo-check",a&&e.append("prot",a.value),l&&e.append("token",l),r&&e.append("user-agent",r.value),s&&e.append("country",s.value),fetch(t,{async:!0,keepalive:!0,body:e,method:"POST",success:function(e){}}).then(e=>e.json()).then(e=>h(e)).catch(e=>g(e)),p=setInterval(await L,c)}function update_data(e,t){if(first_update=!0,data_types=[],first_update=null==(main_content_holder=document.querySelector("#tool-wrapper")).querySelector("#update-holder-"+t)||void 0==main_content_holder.querySelector("#update-holder-"+t)){for(type in(update_holder=document.createElement("div")).setAttribute("id","update-holder-"+t),update_holder.classList.add("m-auto","p-2","custom-shadow","mb-2"),update_holder.style.backgroundColor="#FCFCFB",e)if(null!==e[type]&&void 0!==e[type]){var a=Object.keys(e[type]);if((data_holder=document.createElement("div")).classList.add("data-holder-"+t),"processed-pages"==type){for(lnk in links=Object.values(e[type])[0],(h_span=document.createElement("span")).innerHTML="Broken links found: ",data_holder.appendChild(h_span),h_span.classList.add("d-block"),data_holder.appendChild(document.createElement("hr")),links)spn=document.createElement("span"),(code_spn=document.createElement("span")).innerHTML=" - "+links[lnk].response_code,spn.innerHTML=lnk,spn.appendChild(code_spn),spn.classList.add("d-block"),data_holder.appendChild(spn);update_holder.appendChild(data_holder);continue}(data_message_span=document.createElement("span")).innerHTML=a[0],data_span=document.createElement("span"),data_message_span.setAttribute("id",type),data_span.innerHTML=Object.values(e[type])[0],data_holder.appendChild(data_message_span),data_holder.appendChild(data_span),update_holder.appendChild(data_holder)}"sitemap-urls"==t&&(spinner=node_from_string(spinners.primary),update_holder.appendChild(spinner),percent=Math.floor(parseInt(Object.values(e["total-processed"])[0])/parseInt(Object.values(e["total-urls"])[0])*100),spinner.querySelector(".progress-bar").innerHTML=percent+"%",spinner.querySelector(".progress-bar").style.width=percent+"%")}else{for(type in update_holder=document.querySelector("#update-holder-"+t),count=0,e)if(null!==e[type]&&void 0!==e[type]){var a=Object.keys(e[type]);if(data_holder=update_holder.querySelectorAll(".data-holder-"+t)[count],"processed-pages"==type){for(lnk in links=Object.values(e[type])[0])spn=document.createElement("span"),(code_spn=document.createElement("span")).innerHTML=" - "+links[lnk].response_code,spn.innerHTML=lnk,spn.appendChild(code_spn),spn.classList.add("d-block"),data_holder.appendChild(spn);continue}(data_span=data_holder.querySelector("#"+type))&&(data_span.nextSibling.innerHTML=Object.values(e[type])[0],data_holder.children[0].innerHTML=a[0],count++)}"sitemap-urls"==t&&(spinner=document.querySelector(".progress"),update_holder.appendChild(spinner),void 0!==e["total-processed"]&&null!==e["total-processed"]&&(percent=Math.floor(parseInt(Object.values(e["total-processed"])[0])/parseInt(Object.values(e["total-urls"])[0])*100),spinner.querySelector(".progress-bar").innerHTML=percent+"%",spinner.querySelector(".progress-bar").style.width=percent+"%"))}first_update&&main_content_holder.appendChild(update_holder),void 0!==e.added&&((span=document.createElement("span")).innerHTML=e.added,span.classList.add("d-block"),main_content_holder.appendChild(span))}function tool_link_btn(e){if(app.seo_tags.includes(e)){var t=document.createElement("a");t.classList.add("btn","btn-sample","btn-sm"),t.innerHTML="Create SEO "+e.charAt(0).toUpperCase()+e.slice(1),t.href="/tools/write-seo-"+e}else if("sitemap"===e){var t=document.createElement("button");t.classList.add("btn","btn-sample","btn-sm"),t.innerHTML="Test Sitemap URLs",t.addEventListener("click",sitemapToolLinkHandler(link))}return t}function sitemapToolLinkHandler(e){var t=event.target||event.srcElement;event.preventDefault(),localStorage.setItem("sitemap",t.parentElement.parentElement.children[0].textContent),window.open("/tools/sitemap-broken-links","_blank")}function sitemap_redirect_check(){let e=localStorage.getItem("sitemap");var t="https://"+location.hostname+"/tools/seo-sitemap-checker";e&&document.referrer==t&&(document.querySelector("#url").value=e,set_progress_token(),seo_check(),localStorage.removeItem("sitemap"))}function isValidUrl(e){try{return new URL(e),!0}catch(t){return!1}}function escape_html(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function parse_html_tags(e){return e=(e=(e=(e=e.replaceAll("&","&")).replaceAll("&","&")).replaceAll("<","<")).replaceAll(">",">")}function node_from_string(e){if(!e)return!1;var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}function messages_rows(e,t){for(message_type in container=document.querySelector(".results-container"),msg_count=Object.keys(e.Messages).length,null==e.Messages["failed-audits"]||void 0==e.Messages["failed-audits"]?container.querySelector("#failed-audits").remove():container.querySelector("#failed-audits").style.width=100/msg_count+"%",null==e.Messages["passed-audits"]||void 0==e.Messages["passed-audits"]?container.querySelector("#passed-audits").remove():container.querySelector("#passed-audits").style.width=100/msg_count+"%",null==e.Messages.warnings||void 0==e.Messages.warnings?container.querySelector("#warnings").remove():container.querySelector("#warnings").style.width=100/msg_count+"%",e.Messages)message_div=container.querySelector("#"+message_type),e.Messages[message_type].forEach(function(e){msg_container=document.createElement("div");var t=document.createElement("span"),a=node_from_string(spans["mark-"+message_type]);t.innerHTML=e,msg_container.appendChild(a),msg_container.appendChild(t),message_div.appendChild(msg_container)})}function general_row(e,t){if(table=document.querySelector("."+t+"-table-results"),null==e.general||void 0==e.general)return table.querySelector("#general-row").remove(),!1;if(app.seo_tags.includes(t)){for(stat_type in e.general)for(stat in e.general[stat_type])table.querySelector("."+stat).innerHTML=e.general[stat_type][stat];table.querySelector("#tool-link").href="/tools/write-seo-"+t,table.querySelector("#tool-link").innerHTML="Create SEO "+t.charAt(0).toUpperCase()+t.slice(1),stats_text()}else if(null!==table.querySelector("#general-row")){for(gen_mess in(cell=table.querySelector("#general-row").insertCell()).setAttribute("id","general-message"),e.general.messages){var a=document.createElement("span");a.innerHTML=e.general.messages[gen_mess],a.classList.add("text-info","d-block"),cell.appendChild(a)}var n=document.createElement("span");n.classList.add("d-block"),n.innerHTML="Analysed "+t+": "+e[t],cell.appendChild(n)}}function results_table(e,t,a){var n=document.querySelector("#results");if((json_entries=["Messages","Result Content"]).forEach(n=>{for(type in"Result Content"==n&&(e=document.createElement("table")).classList.add("table","seo-table","table-dark"),t[n]){var l=e.insertRow(),r=l.insertCell(),s=l.insertCell();r.setAttribute("colspan",1),r.innerHTML=type;var o=type.replace(" ","-");o=o.toLowerCase(),r.classList.add("seo-table-head","p-2");var d=document.createElement("span");if("Passed Audits"==type?(l.classList.add("table-success"),d.classList.add("seo-check-mark"),d.innerHTML=" ✔"):"Failed Audits"==type?(l.classList.add("table-danger"),d.classList.add("seo-uncheck-mark"),d.innerHTML=" ✘"):"Warnings"==type?(l.classList.add("table-warning"),d.classList.add("seo-warning-mark","text-warning"),d.innerHTML=" ⚠"):l.classList.add("table-warning"),s.setAttribute("colspan",4),s.classList.add("seo-message-cell"),"object"==typeof t[n][type])Array.from(t[n][type]).forEach(function(e){var t=document.createElement("span");t.innerHTML=e,t.classList.add("d-block","my-2"),"Messages"==n&&t.appendChild(d.cloneNode(!0)),s.appendChild(t)});else{var c=document.createElement("span");c.innerHTML=t[n][type],c.classList.add("d-block","my-2"),"Messages"==n&&c.appendChild(d.cloneNode(!0)),s.appendChild(c)}}if(void 0!==t[n]&&parseInt(Object.keys(t[n]).length)>0){var p=e.createTHead().insertRow(),u=p.insertCell();if(u.classList.add("text-center","align-middle"),"Messages"==n)u.innerHTML=a.charAt(0).toUpperCase()+a.slice(1)+" Status",u.setAttribute("colspan","5");else{var f=p.insertCell(0);f.classList.add("text-center","align-middle"),"sitemap-urls"===a&&(u.innerHTML="Found URLS",f.innerHTML="HTTP Code"),"h-tag"===a&&(f.innerHTML="Tag Type",u.innerHTML="Tag Text")}}}),void 0!==t.Contents&&parseInt(Object.keys(t.Contents).length)>0){var l=document.createElement("div");l.classList.add("mb-3");var r=document.createElement("span"),s=document.createElement("span");s.classList.add("border","p-2","border-2","seo-content","text-center"),s.innerHTML=t.Contents,r.innerHTML="Your "+a+" contents: ",r.classList.add("text-center","d-block"),l.appendChild(r),l.appendChild(s),n.appendChild(l)}}function stats_text(){var e=document.querySelector(".pixel-length"),t=document.querySelector(".character-count"),a=document.querySelector(".recomended-pixels-limit"),n=document.querySelector(".recomended-characters-limit");a.classList.add("text-info"),n.classList.add("text-info"),parseInt(e.innerHTML)>parseInt(a.innerHTML.split(",")[0])&&parseInt(e.innerHTML)parseInt(n.innerHTML.split(",")[0])&&parseInt(t.innerHTML)d[1]?(a.style.color="#dc3545",u.innerHTML="Pixel length out of limits!",u.classList.add("alert-danger")):(a.style.color="#198754",u.innerHTML="Pixel length is ok!",u.classList.add("alert-success")),l.lengtho[1]?(c.innerHTML="Character count out of limits!",t.style.color="#dc3545",c.classList.add("alert-danger")):(t.style.color="#198754",c.innerHTML="Character count is ok!",c.classList.add("alert-success")),n.appendChild(c),n.appendChild(u),a.innerHTML=Math.ceil(m),t.innerHTML=l.length})}function duplicate_words(e){var t=e.toLowerCase().replace(/[^\w\s]/gi,"").split(" ").filter(function(e){return""!=e});return 0!=t.filter((e,a)=>t.indexOf(e)!==a).length}async function verify_pass(){var e=document.querySelector("[name=input-pass]");function t(e){console.log("ERROR: "+e)}function a(e){if("failed"===e&&(remove_alert(),set_alert("Incorect Password!","danger")),"success"===e){var t=document.querySelector("#details-form");document.querySelector("[name=change-details");var a=document.createElement("input");a.setAttribute("hidden","hidden"),a.name="change-details",t.appendChild(a),t.submit()}}await fetch("/verify-pass?pass="+e.value,{}).then(e=>e.json()).then(e=>a(e)).catch(e=>t(e))}function download_file(e,t){fetch(e,{method:"get",mode:"no-cors",referrerPolicy:"no-referrer"}).then(e=>e.blob()).then(e=>{let a=document.createElement("a");a.setAttribute("download",t);let n=URL.createObjectURL(e);a.href=n,a.setAttribute("target","_blank"),a.click(),URL.revokeObjectURL(n)})}function set_transitions(){(elements=document.querySelectorAll(".no-transition")).forEach(function(e){e.classList.remove("no-transition")})}function toggle_nav(){btn=document.querySelector(".navbar-toggler"),nav=document.querySelector("#navbar_collapse"),btn.addEventListener("click",function(){nav.classList.contains("show")?nav.classList.remove("show"):nav.classList.add("show")})}function toggleLinkList(e){e.parentElement.children[e.parentElement.children.length-1].classList.contains("d-none")?(e.parentElement.children[e.parentElement.children.length-1].classList.remove("d-none"),e.classList.remove("tree-list-arrow-right"),e.classList.add("tree-list-arrow-down")):(e.classList.remove("tree-list-arrow-down"),e.classList.add("tree-list-arrow-right"),e.parentElement.children[e.parentElement.children.length-1].classList.add("d-none"))}function lazy_load(){let e=document.querySelectorAll(".lazy"),t={root:null,rootMargin:"0px 0px 50px 0px",threshold:.5},a=(e,t)=>{e.forEach(e=>{if(e.isIntersecting){let a=e.target;if(a.getAttribute("data-srcset")){let n=a.getAttribute("data-srcset");a.setAttribute("srcset",n),a.classList.remove("lazy"),a.classList.add("lazy-loaded"),t.unobserve(a)}else if(a.getAttribute("data-src")){let l=a.getAttribute("data-src");a.setAttribute("src",l),a.classList.remove("lazy"),a.classList.add("lazy-loaded"),t.unobserve(a)}}})},n=new IntersectionObserver(a,t);e.forEach(e=>{n.observe(e)})}function call_index(){}function write_seo_title(){seo_tag_create()}function write_seo_description(){seo_tag_create()}function ocr(){clear_storage(),check_file_upload()}function image_to_pdf(){clear_storage(),check_file_upload()}function split_pdf(){check_file_upload(),clear_storage(),toggle_sm_menu(),load_pdfjs(),(btn=document.querySelector("#toggle-pdf-list")).addEventListener("click",function(){(list=document.querySelector(".pdf-list")).parentElement.classList.contains("d-none")?list.parentElement.classList.remove("d-none"):list.parentElement.classList.add("d-none"),list.parentElement.parentElement.classList.contains("d-none")?list.parentElement.parentElement.classList.remove("d-none"):list.parentElement.parentElement.classList.add("d-none")})}function pdf_add_watermark(){check_file_upload(),clear_storage(),load_pdfjs(),add_position_events(),toggle_sm_menu(),pdf_watermark_menu()}function merge_pdf(){load_pdfjs(),check_file_upload(),toggle_help(),clear_storage()}function swap_pdf_pages(){load_pdfjs(),check_file_upload(),clear_storage(),toggle_help()}function pdf_to_image(){clear_storage(),check_file_upload();var e=document.querySelector("#zip-files");function t(){(inpt=this.querySelector("input")).checked?(inpt.checked=!1,inpt.value="link"):(inpt.checked=!0,inpt.value="zip")}(zip_inpt=document.querySelector("#download_type")).addEventListener("click",function(){this.checked?(this.checked=!1,this.value="link"):(this.checked=!0,this.value="zip")}),e&&e.addEventListener("click",t)}function keyword_density(){source_select(),include_on_click(),density_on_key(),uncheck_method(),check_file_upload()}function seo_title_checker(){}function seo_description_desc(){}function sitemap_broken_links(){sitemap_redirect_check(),set_progress_token(),handle_sitemap_home_redirect()}function seo_sitemap_checker(){set_progress_token(),handle_sitemap_home_redirect()}function sitemap_generator(){set_progress_token(),update_connection_status(),clear_storage(),handle_sitemap_home_redirect()}function seo_robots_checker(){}function seo_heading_checker(){}function broken_links_checker(){set_progress_token(),update_connection_status()}function check_http_header(){set_progress_token()}function domain_age_checker(){set_progress_token()}function website_tree_structure(){set_progress_token(),update_connection_status()}window.onload=function(){subscribe()},null!==app.conversion_type&&app.input_accept();var loc=location.href.split("/").slice(3);let fname=!1;"tools"==loc[0]&&loc.shift(),loc.length>=1&&(fname=loc[0].replaceAll("-","_")),fname&&"function"==typeof window[fname]&&window[fname](),active_link(),set_transitions(),toggle_nav(),lazy_load();