");return[n,t.join("")]},resurrectText=(e,t)=>{for(var n=0;n",t[n]);return e},getStc=o=>{var a=500;if(o.split("").length<=a)return[o];{for(var[o,s]=encodePunc(o),m=s.split("<#*/>"),i=0;ia){let e=m[i].split(" "),t="",n=[];for(var g=0;g"),t=[],n=0,l="",r=(e=(e=resurrectText(e=(e=e.replaceAll(";<#*/>","<#*/>")).replaceAll("<#*/>;","<#*/>"),o)).replaceAll(" "," ")).split("");for(i=0;i{if(l.split("").length<=500)return[l];{let e=(l=l.replaceAll("...","etc")).split(".").filter(e=>""!==e.trim()),t=[],n="";for(var r=0;r{var n=e.indexOf(t.trim());return"\n"===e[n-1]&&"\n"!==e[n-2]?"
"+t:"\n"===e[n-1]&&"\n"===e[n-2]?"
"+t:" "+t};async function getRequest(r){if(""!==document.getElementById("question").inneText){let e=(r.match(/[^.?!]+[.!?]+[\])'"`’”]*/g)||[]).filter(e=>""!==e.trim()),t=(0===e.length&&(e=[r]),13*Math.ceil(r.split("").length/500)),n=startTimer(t,null),l=(showPb(t),document.getElementById("proc2").style.display="inline-block",!0);for(var o="",a=0;ae.text()).then(e=>(e=strip(e),restorn(r,e))).catch(e=>(console.log(e),alert("Unexpected error! Please retry the current operation by clicking again on the button."),l=!1,clearInterval(n),""));return hidePb(),document.getElementById("proc2").style.display="none",document.getElementById("stopAtThisOp").checked=!1,clearInterval(n),o}alert("Please choose a rephrasing mode!")}const btnStop=()=>{document.getElementById("getHeadlineAnswer").disabled=!0,document.getElementById("getTitleAnswer").disabled=!0,document.getElementById("getListAnswer").disabled=!0,document.getElementById("getParagraphAnswer").disabled=!0},btnAct=()=>{document.getElementById("getHeadlineAnswer").disabled=!1,document.getElementById("getTitleAnswer").disabled=!1,document.getElementById("getListAnswer").disabled=!1,document.getElementById("getParagraphAnswer").disabled=!1},lenFilter=(e,t)=>{for(var n=document.getElementById("htmlResult").getElementsByTagName(e),l=n.length-1;0<=l;l--)n[l].textContent.replace(/\s\s+/g," ").split(" ").length{for(var t=document.getElementsByTagName(e),n=t.length-1;0<=n;n--)(0{for(var e=document.getElementById("htmlResult").querySelectorAll("*"),t=0;t/g,"ol>"));for(t=e.length-1;0<=t;t--)"OL"===e[t].tagName&&(e[t].textContent.replace(/\s\s+/g," ").includes("am")&&e[t].textContent.replace(/\s\s+/g," ").includes("Reply")||e[t].textContent.replace(/\s\s+/g," ").includes("pm")&&e[t].textContent.replace(/\s\s+/g," ").includes("Reply")||e[t].textContent.replace(/\s\s+/g," ").includes("wikiHow")||e[t].textContent.replace(/\s\s+/g," ").includes("WikiHow")||e[t].textContent.replace(/\s\s+/g," ").includes('"smallUrl":')||e[t].textContent.replace(/\s\s+/g," ").includes("AM")&&e[t].textContent.replace(/\s\s+/g," ").includes("Reply")||e[t].textContent.replace(/\s\s+/g," ").includes("Reply")&&e[t].textContent.replace(/\s\s+/g," ").includes("@")||null!==e[t].textContent.replace(/\s\s+/g," ").match(/[1-9], (19|20)\d{2} at/g)||null!==e[t].textContent.replace(/\s\s+/g," ").match(/[1-9], (19|20)\d{2} At/g)||4{for(var e=document.getElementById("htmlResult").getElementsByTagName("ol"),t=0;te.split(/[;:,\.\?!]/g).join(""),compareSentences=(e,t,n)=>{for(var e=removePunc(e).toLowerCase().split(" ").filter(e=>""!==e.trim()).join(" "),t=removePunc(t).toLowerCase().split(" ").filter(e=>""!==e.trim()).join(" "),l=e.split(" "),r=t.split(" "),o=(l.length,r.length,0),a=0;a=l.length*n)return!0;return!1},getMiniSc=e=>{var t=new MiniSearch({fields:["txt"],storeFields:["id","txt"]});return t.addAll(e),t.search(document.getElementById("question").value).map(e=>(e.len=e.txt.split(" ").filter(e=>""!==e.trim()).length,e))},getAnswer=async()=>{let l=startTimer(13,null);return document.getElementById("warning").style.display="inline-block",setTimeout(()=>{document.getElementById("warning").style.display="none"},5e3),showPb(13),document.getElementById("proc1").style.display="inline-block",fetch("/ai-writer",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({input:document.getElementById("question").value})}).then(e=>e.text()).then(e=>{if("error!"===e)throw"Server error!";if("Code G0"===e)throw"Code G0";if("Code Q0"===e)throw"Code Q0";document.getElementById("proc1").style.display="none",e.replaceAll("::marker",""),document.getElementById("htmlResult").innerHTML=e;for(var t=document.getElementById("htmlResult").getElementsByTagName("*").length-1;0<=t;t--)""===document.getElementById("htmlResult").getElementsByTagName("*")[t].textContent&&document.getElementById("htmlResult").getElementsByTagName("*")[t].id!==htmlResult&&document.getElementById("htmlResult").getElementsByTagName("*")[t].remove();filter1(),filter2(),hidePb();var e={},n=document.getElementById("htmlResult");return e.title=[...n.querySelectorAll("h1")].map((e,t)=>({id:t,txt:e.textContent,sc:0})),e.headline=[...n.querySelectorAll("h2,h3,h4")].map((e,t)=>({id:t,txt:e.textContent,sc:0})),e.p=[...n.querySelectorAll("p")].map((e,t)=>({id:t,txt:e.textContent,sc:0})),e.lst=[...n.querySelectorAll("ul,ol")].map((e,t)=>({id:t,txt:e.outerHTML,sc:0})),e.headline=getMiniSc(e.headline),e.title=getMiniSc(e.title),e.p=getMiniSc(e.p),e.lst=getMiniSc(e.lst),document.getElementById("htmlResult").innerHTML=JSON.stringify(e),clearInterval(l),!0}).catch(e=>(console.log(e),document.getElementById("question1").value="",alert("We are experiencing a very high traffic, please try again or reload the page!"),b1=!1,clearInterval(l),document.getElementById("proc1").style.display="none",hidePb(),clearInterval(l),!1))},finder1=(t,e)=>{for(var n=[],l=0;l"LI"!==t[l].tagName&&t[l].textContent.replace(/\s\s+/g," ").split(" ").includes(e)).filter(e=>!0===e).length,(r/=o.split(" ").length)>=e))&&n.push(t[l])}return n},finder2=(e,t)=>{if(!isNaN(parseInt(t))&&""!==t.trim()&&null!==e){for(var n=[],l=0;l{for(var n=[],l=0;let{for(var t,n,l=[],r=document.getElementById("approWordcount").value,o=document.getElementsByName("lengthChoice"),a=0;a{var t;if("headline"===e){var n=document.getElementById("htmlResult").getElementsByTagName("h1");if(!(0{e{if("OL"===e.tagName)for(var t=e.getElementsByTagName("li"),n=0;n{let n=document.createElement("div");n.className="inline-block";var l=document.createElement("button"),r=(l.className="btn2 marginLeft10px",l.innerHTML='',l.onclick=()=>{document.getElementById("article").prepend(e),n.remove(),document.getElementById("wordCount").textContent=document.getElementById("article").textContent.split(" ").length},document.createElement("button")),o=(r.className="btn2 marginLeft10px",r.innerHTML='',r.onclick=()=>{n.remove()},document.createElement("div"));return o.className="marginTop20px greenText1 marginLeft20px",o.textContent="Approx. "+t+" Words",n.append(l),n.append(r),n.append(o),n.append(e),document.getElementById("output").prepend(n),n},getLenChoice=()=>[...document.getElementsByName("lengthChoice")].filter(e=>!0===e.checked)[0].value,extractTextResult=(e,t,n)=>{},getElementsFromServer_1=async n=>{let l=JSON.parse(document.getElementById("htmlResult").innerHTML),e=getLenChoice(),r="";var t;if("random"===e&&0!==(t=l[n]).length&&(r=t[0].txt),"longest"===e&&0!==(t=l[n].sort((e,t)=>t.txt.length-e.txt.length)).length&&(r=t[0].txt),"shortest"===e&&0!==(t=l[n].sort((e,t)=>e.txt.length-t.txt.length)).length&&(r=t[0].txt),"count"===e){let t=parseInt(document.getElementById("approWordcount").value)||20,e=l[n].filter(e=>e.txt.split(" ").length<=t).sort((e,t)=>t.txt.length*t.score-e.txt.length*e.score);0!==e.length&&(r=e[0].txt)}if(""!==r&&(l[n]=l[n].filter(e=>e.txt!==r)),document.getElementById("htmlResult").innerHTML=JSON.stringify(l),""===r)return""===document.getElementById("approWordcount").value.trim()&&"count"===document.querySelector("input[name=lengthChoice]:checked").value?void alert("Please set a text's word count value!"):void alert("No proposition for this element for now! Please try to change the word count or try tweak your requirement!");if("lst"===n){let t=document.createElement("ul");r.includes("")&&(t=document.createElement("ol"));var o=(r.match(/- ([\s\S]*?)<\/li>/g)||[]).map(e=>strip(e));o.length,addElt(t,o.map(e=>e.split(" ").filter(e=>""!==e.trim()).length).reduce((e,t)=>e+t,0));for(let e=0;e""!==e.trim()).length),typeWriter(0,await getRequest(r,t),50,t))},getElementsFromServer=async e=>{var t=getText(e);if(null===t)return""===document.getElementById("approWordcount").value.trim()&&"count"===document.querySelector("input[name=lengthChoice]:checked").value?void alert("Please set a text's word count value!"):void alert("No proposition for this element for now! Please try to change the word count or try tweak your requirement!");e=t;if(void 0!==t)for(var n=0;n{if(""===document.getElementById("question").value.trim())alert("Please insert your requirement!");else{if(document.getElementById("question1").value!==document.getElementById("question").value){if(!0!==await getAnswer())return;document.getElementById("question1").value=document.getElementById("question").value}await getElementsFromServer_1("headline")}},document.getElementById("getTitleAnswer").onclick=async()=>{if(""===document.getElementById("question").value.trim())alert("Please insert your requirement!");else{if(document.getElementById("question1").value!==document.getElementById("question").value){if(!0!==await getAnswer())return;document.getElementById("question1").value=document.getElementById("question").value}await getElementsFromServer_1("title")}},document.getElementById("getListAnswer").onclick=async()=>{if(""===document.getElementById("question").value.trim())alert("Please insert your requirement!");else{if(document.getElementById("question1").value!==document.getElementById("question").value){if(!0!==await getAnswer())return;document.getElementById("question1").value=document.getElementById("question").value}await getElementsFromServer_1("lst")}},document.getElementById("getParagraphAnswer").onclick=async()=>{if(""===document.getElementById("question").value.trim())alert("Please insert your requirement!");else{if(document.getElementById("question1").value!==document.getElementById("question").value){if(!0!==await getAnswer())return;document.getElementById("question1").value=document.getElementById("question").value}await getElementsFromServer_1("p")}},e=>{for(var t=document.getElementById("htmlResult").querySelectorAll("p"),n=0;n{document.getElementById("stopIn").value="stop"};document.getElementById("article").onkeyup=()=>{document.getElementById("wordCount").textContent=document.getElementById("article").textContent.split(" ").length}