fictioneer/js/complete.min.js

6 lines
131 KiB
JavaScript
Raw Normal View History

const _$=document.querySelector.bind(document),_$$=document.querySelectorAll.bind(document),_$$$=document.getElementById.bind(document);async function fcn_ajaxPost(t={},e=null,n={}){e&&!e.startsWith("http")&&(e=fictioneer_ajax.rest_url+e),e=e||fictioneer_ajax.ajax_url;let a={"Content-Type":"application/x-www-form-urlencoded","Cache-Control":"no-cache"};a={...a,...n},t={nonce:fcn_getNonce(),...t};const o=await fetch(e,{method:"POST",credentials:"same-origin",headers:a,mode:"same-origin",body:new URLSearchParams(t)});return o.ok?o.json():Promise.reject(o)}async function fcn_ajaxGet(t={},e=null,n={}){e&&!e.startsWith("http")&&(e=fictioneer_ajax.rest_url+e),e=e||fictioneer_ajax.ajax_url,e=fcn_buildUrl(t={nonce:fcn_getNonce(),...t},e);let a={"Content-Type":"application/x-www-form-urlencoded","Cache-Control":"no-cache"};a={...a,...n};const o=await fetch(e,{method:"GET",credentials:"same-origin",headers:a,mode:"same-origin"});return o.ok?o.json():Promise.reject(o)}function fcn_evaluateAsBoolean(t,e=!1){if(void 0===t)return e;if("boolean"==typeof t)return t;if(t instanceof HTMLInputElement&&"checkbox"===t.getAttribute("type"))return t.checked;t instanceof HTMLElement&&(t.hasAttribute("value")?t=t.value:t.hasAttribute("data-value")&&(t=t.dataset.value));const n=String(t),a=parseInt(t);return"true"===n||"1"===n||1===a||"false"!==n&&"0"!==n&&0!==a&&e}function fcn_copyToClipboard(t,e=!1){e=e||fictioneer_tl.notification.copiedToClipboard,navigator.clipboard&&(navigator.clipboard.writeText(t),e&&fcn_showNotification(e,2))}function fcn_parseJSON(t){if(null==t||"string"!=typeof t)return null;try{return JSON.parse(t)}catch(t){return null}}function fcn_removeItemOnce(t,e){var n=t.indexOf(e);return n>-1&&t.splice(n,1),t}function fcn_clamp(t,e,n){return Math.min(Math.max(n,t),e)}function fcn_updateThemeColor(t=!1){const e=fcn_siteSettings.darken?fcn_siteSettings.darken:0,n=fcn_siteSettings.saturation?fcn_siteSettings.saturation:0,a=fcn_siteSettings["hue-rotate"]?fcn_siteSettings["hue-rotate"]:0,o=e>=0?1+e**2:1-e**2,c=n>=0?1+n**2:1-n**2;let s=getComputedStyle(document.documentElement).getPropertyValue("--theme-color-base").trim().split(" ");s=`hsl(${(parseInt(s[0])+a)%360}deg ${(parseInt(s[1])*c).toFixed(2)}% ${(parseInt(s[2])*o).toFixed(2)}%)`,_$("meta[name=theme-color]").setAttribute("content",t||s)}function fcn_offset(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}}function fcn_throttle(t,e,n){var a,o,c,s=null,i=0;n||(n={});var r=function(){i=!1===n.leading?0:Date.now(),s=null,c=t.apply(a,o),s||(a=o=null)};return function(){var l=Date.now();i||!1!==n.leading||(i=l);var f=e-(l-i);return a=this,o=arguments,f<=0||f>e?(s&&(clearTimeout(s),s=null),i=l,c=t.apply(a,o),s||(a=o=null)):s||!1===n.trailing||(s=setTimeout(r,f)),c}}var fcn_lastClicked,fcn_animFrameEvents=new Map;function fcn_bindEventToAnimationFrame(t,e,n=window){n.addEventListener(t,(function(){fcn_animFrameEvents.get(e)||(fcn_animFrameEvents.set(e,!0),requestAnimationFrame((()=>{n.dispatchEvent(new CustomEvent(e)),fcn_animFrameEvents.set(e,!1)})))}))}function fcn_toggleLastClicked(t){const e=!t.classList.contains("last-clicked");t.classList.toggle("last-clicked",e),t.closest(".watch-last-clicked")?.classList.toggle("has-last-clicked",e),fcn_lastClicked&&fcn_lastClicked!=t&&fcn_removeLastClick(fcn_lastClicked),fcn_lastClicked=t}function fcn_removeLastClick(t){t.closest(".watch-last-clicked")?.classList.remove("has-last-clicked"),t.classList.remove("last-clicked"),fcn_lastClicked=null}function fcn_cleanTextSelectionFromButtons(t){return t=(t=(t=(t=(t=(t=t.replace(/[\r\n]{2,}/g,"__$__")).replace(new RegExp("(__Bookmark|__Quote|__Link)","g"),"")).replace(new RegExp("(__Bookmark|__Quote|__TTS|__Link)","g"),"")).replace(new RegExp("(__Bookmark|__Quote|__Suggestion|__TTS|__Link)","g"),"")).replace(new RegExp("(__Bookmark|__Quote|__Suggestion|__Link)","g"),"")).replace(/[__$]{1,}/g,"\n\n").replace(/^[\r\n]+|[\r\n]+$/g,"")}function fcn_deleteCookie(t){document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"}function fcn_deleteAllC
9!=t.keyCode&&13!=t.keyCode||""!=this.tabSuggestion.innerText&&(t.preventDefault(),this.input.value=this.tabSuggestion.innerText,this.addNode()),27==t.keyCode&&(this.input.value="",this.tabSuggestion.innerHTML="",document.activeElement.blur()),8==t.keyCode&&""==this.input.value&&this.keywords.length>0&&this.removeNodeByValue(this.keywords.slice(-1))})),this.input.addEventListener("blur",(()=>{const t=this.allowList[this.encode(this.input.value)];this.blurTimeout=t?setTimeout((()=>{this.addNode()}),150):setTimeout((()=>{this.input.value="",this.tabSuggestion.innerHTML="",this.filterSuggestions(),this.resize()}),150)})),this.block.addEventListener("click",(t=>{t.target.closest(".node-delete")&&(t.preventDefault(),this.removeNodeByValue(t.target.closest(".node").dataset.value))})),this.block.querySelectorAll(".keyword-button").forEach((t=>{t.addEventListener("click",(t=>{clearTimeout(this.blurTimeout),this.addNode(t.currentTarget.innerText)}))}))}}function fcn_resetSearchForm(t,e,n){n.forEach((t=>t.reset())),e.querySelectorAll("input, select").forEach((t=>{t.value=t.dataset.default??t.value})),e.querySelector(".search-form__current").innerHTML="",fcn_showNotification(t.dataset.reset,2)}function fcn_handleTabInput(t){9==t.keyCode&&(fcn_theBody.classList.add("user-is-tabbing"),window.removeEventListener("keydown",fcn_handleTabInput),window.addEventListener("mousedown",fcn_handleMouseInput))}function fcn_handleMouseInput(){fcn_theBody.classList.remove("user-is-tabbing"),window.removeEventListener("mousedown",fcn_handleMouseInput),window.addEventListener("keydown",fcn_handleTabInput)}function fcn_popupPosition(){_$$(".popup-menu-toggle.last-clicked .popup-menu:not(._fixed-position)").forEach((t=>{if("none"===window.getComputedStyle(t).display)return;const e=fcn_detectScreenCollision(t);e&&0===e.length||(e.includes("top")?(t.classList.remove("_top"),t.classList.add("_bottom")):e.includes("bottom")&&(t.classList.remove("_bottom"),t.classList.add("_top")))}))}function fcn_markCurrentMenuItem(){_$$(`.menu-item > [data-nav-object-id="${fcn_theBody.dataset.postId}"]`).forEach((t=>{t.setAttribute("aria-current","page"),t.closest(".menu-item").classList.add("current-menu-item")}))}function fcn_showAgeConfirmationModal(){const t=_$(".story__article, .chapter__article")?.dataset.ageRating;if(!fcn_theRoot.dataset.ageConfirmation&&t&&"adult"!==t)return void _$$$("age-confirmation-modal")?.remove();const e=_$$$("age-confirmation-leave");fcn_theRoot.classList.add("age-modal-open"),_$$$("age-confirmation-modal").classList.add("_open"),_$$$("age-confirmation-confirm")?.addEventListener("click",(t=>{fcn_theRoot.classList.remove("age-modal-open"),t.currentTarget.closest(".modal").remove(),localStorage.setItem("fcnAgeConfirmation","1")})),e?.addEventListener("click",(()=>{window.location.href=e.dataset.redirect??"https://search.brave.com/",localStorage.removeItem("fcnAgeConfirmation")}))}function fcn_showLightbox(t){const e=_$$$("fictioneer-lightbox"),n=_$(".lightbox__content");let a=!1,o=null;if(n.innerHTML="",t.classList.add("lightbox-last-trigger"),"IMG"==t.tagName?(o=t.cloneNode(),a=!0):t.href&&(o=document.createElement("img"),o.src=t.href,a=!0),a&&o){["class","style","height","width"].forEach((t=>o.removeAttribute(t))),n.appendChild(o),e.classList.add("show");const t=e.querySelector(".lightbox__close");t?.focus(),t?.blur()}}function fcn_toggleMobileMenu(t){fcn_copyNavIntoMobileMenu(),_$(".mobile-menu._advanced-mobile-menu")?fcn_toggleAdvancedMobileMenu(t):fcn_toggleSimpleMobileMenu(t)}function fcn_toggleSimpleMobileMenu(t){t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down"),fcn_theBody.classList.remove("scrolling-up")):(fcn_theBody.classList.remove("mobile-menu-open"),fcn_closeMobileFrames(),fcn_openMobileFrame("main"),_$$$("mobile-menu-toggle").checked=!1)}function fcn_toggleAdvancedMobileMenu(t){const e=_$$$("wpadminbar")?.offsetHeight??0,n=window.scrollY,a=fcn_theSite.scrollTop;t?(fcn_theBody.classList.add("mobile-menu-open","scrolling-down"),fcn_theBody.classList.remove("scrolling-up"),fcn_theSite.classList.add("transforme
;return r||l?5:n||a?4:o&&!s&&i?3:s||i?2:o||c?1:0}for(var n=1;n<t.length-1;){if(t[n-1][0]==DIFF_EQUAL&&t[n+1][0]==DIFF_EQUAL){var a=t[n-1][1],o=t[n][1],c=t[n+1][1],s=this.diff_commonSuffix(a,o);if(s){var i=o.substring(o.length-s);a=a.substring(0,a.length-s),o=i+o.substring(0,o.length-s),c=i+c}s=a,i=o;for(var r=c,l=e(a,o)+e(o,c);o.charAt(0)===c.charAt(0);){a+=o.charAt(0),o=o.substring(1)+c.charAt(0),c=c.substring(1);var f=e(a,o)+e(o,c);f>=l&&(l=f,s=a,i=o,r=c)}t[n-1][1]!=s&&(s?t[n-1][1]=s:(t.splice(n-1,1),n--),t[n][1]=i,r?t[n+1][1]=r:(t.splice(n+1,1),n--))}n++}},diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,diff_match_patch.whitespaceRegex_=/\s/,diff_match_patch.linebreakRegex_=/[\r\n]/,diff_match_patch.blanklineEndRegex_=/\n\r?\n$/,diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/,diff_match_patch.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,n=[],a=0,o=null,c=0,s=!1,i=!1,r=!1,l=!1;c<t.length;)t[c][0]==DIFF_EQUAL?(t[c][1].length<this.Diff_EditCost&&(r||l)?(n[a++]=c,s=r,i=l,o=t[c][1]):(a=0,o=null),r=l=!1):(t[c][0]==DIFF_DELETE?l=!0:r=!0,o&&(s&&i&&r&&l||o.length<this.Diff_EditCost/2&&3==s+i+r+l)&&(t.splice(n[a-1],0,new diff_match_patch.Diff(DIFF_DELETE,o)),t[n[a-1]+1][0]=DIFF_INSERT,a--,o=null,s&&i?(r=l=!0,a=0):(c=0<--a?n[a-1]:-1,r=l=!1),e=!0)),c++;e&&this.diff_cleanupMerge(t)},diff_match_patch.prototype.diff_cleanupMerge=function(t){t.push(new diff_match_patch.Diff(DIFF_EQUAL,""));for(var e,n=0,a=0,o=0,c="",s="";n<t.length;)switch(t[n][0]){case DIFF_INSERT:o++,s+=t[n][1],n++;break;case DIFF_DELETE:a++,c+=t[n][1],n++;break;case DIFF_EQUAL:1<a+o?(0!==a&&0!==o&&(0!==(e=this.diff_commonPrefix(s,c))&&(0<n-a-o&&t[n-a-o-1][0]==DIFF_EQUAL?t[n-a-o-1][1]+=s.substring(0,e):(t.splice(0,0,new diff_match_patch.Diff(DIFF_EQUAL,s.substring(0,e))),n++),s=s.substring(e),c=c.substring(e)),0!==(e=this.diff_commonSuffix(s,c))&&(t[n][1]=s.substring(s.length-e)+t[n][1],s=s.substring(0,s.length-e),c=c.substring(0,c.length-e))),n-=a+o,t.splice(n,a+o),c.length&&(t.splice(n,0,new diff_match_patch.Diff(DIFF_DELETE,c)),n++),s.length&&(t.splice(n,0,new diff_match_patch.Diff(DIFF_INSERT,s)),n++),n++):0!==n&&t[n-1][0]==DIFF_EQUAL?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,a=o=0,s=c=""}for(""===t[t.length-1][1]&&t.pop(),a=!1,n=1;n<t.length-1;)t[n-1][0]==DIFF_EQUAL&&t[n+1][0]==DIFF_EQUAL&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)==t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),a=!0):t[n][1].substring(0,t[n+1][1].length)==t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),a=!0)),n++;a&&this.diff_cleanupMerge(t)},diff_match_patch.prototype.diff_xIndex=function(t,e){var n,a=0,o=0,c=0,s=0;for(n=0;n<t.length&&(t[n][0]!==DIFF_INSERT&&(a+=t[n][1].length),t[n][0]!==DIFF_DELETE&&(o+=t[n][1].length),!(a>e));n++)c=a,s=o;return t.length!=n&&t[n][0]===DIFF_DELETE?s:s+(e-c)},diff_match_patch.prototype.diff_prettyHtml=function(t){for(var e=[],n=/&/g,a=/</g,o=/>/g,c=/\n/g,s=0;s<t.length;s++){var i=t[s][0],r=t[s][1].replace(n,"&amp;").replace(a,"&lt;").replace(o,"&gt;").replace(c,"&para;<br>");switch(i){case DIFF_INSERT:e[s]='<ins style="background:#e6ffe6;">'+r+"</ins>";break;case DIFF_DELETE:e[s]='<del style="background:#ffe6e6;">'+r+"</del>";break;case DIFF_EQUAL:e[s]="<span>"+r+"</span>"}}return e.join("")},diff_match_patch.prototype.diff_text1=function(t){for(var e=[],n=0;n<t.length;n++)t[n][0]!==DIFF_INSERT&&(e[n]=t[n][1]);return e.join("")},diff_match_patch.prototype.diff_text2=function(t){for(var e=[],n=0;n<t.length;n++)t[n][0]!==DIFF_DELETE&&(e[n]=t[n][1]);return e.join("")},diff_match_patch.prototype.diff_levenshtein=function(t){for(var e=0,n=0,a=0,o=0;o<t.length;o++){var c=t[o][1];switch(t[o][0]){case DIFF_INSERT:n+=c.length;break;case DIFF_DELETE:a+=c.length;break;case DIFF_EQUAL:e+=Math.max(n,a),a=n=0}}return e+Math.max(n,a)},diff_match_patch.prototype.diff_toDelta=function(t){for(var e=[],n=0;n<t.length;n++)switch(t[n][0]){case DIFF_INSERT:e[n]="+"+encodeURI(t[n][1]);break;case DIFF_DELETE:e[n]="-"+t[
})),_$$$("button-delete-my-account")?.addEventListener("click",(t=>{fcn_deleteMyAccount(t.currentTarget)}));const fcn_profileDataTranslations=_$$$("profile-data-translations")?.dataset;function fcn_dataDeletionPrompt(t){const e=prompt(t.dataset.warning);return!(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())}function fcn_clearData(t,e){const n=t.closest(".card");localStorage.removeItem("fcnBookshelfContent"),n.classList.add("ajax-in-progress"),t.remove(),fcn_ajaxPost({action:e,fcn_fast_ajax:1,nonce:t.dataset.nonce}).then((t=>{t.success?n.querySelector(".card__content").innerHTML=t.data.success:fcn_showNotification(t.data.error,10,"warning")})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,10,"warning")})).then((()=>{n.classList.remove("ajax-in-progress")}))}_$(".button-clear-comments")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comments")})),_$(".button-clear-comment-subscriptions")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comment_subscriptions")})),_$(".button-clear-checkmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.checkmarks={data:{},updated:Date.now()},fcn_setUserData(e),fcn_updateCheckmarksView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_checkmarks",!0)})),_$(".button-clear-reminders")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.reminders={data:{}},fcn_setUserData(e),fcn_updateRemindersView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_reminders",!0)})),_$(".button-clear-follows")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.follows={data:{}},fcn_setUserData(e),fcn_updateFollowsView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_follows",!0)})),_$(".button-clear-bookmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.bookmarks="{}",fcn_setUserData(e),fcn_bookmarks.data={},t.currentTarget.closest(".card").querySelector(".card__content").innerHTML=fcn_profileDataTranslations.clearedSuccess,fcn_setBookmarks(fcn_bookmarks)}));const fcn_jumpToBookmarkButtons=_$$(".button--bookmark"),fcn_mobileBookmarkJump=_$$$("mobile-menu-bookmark-jump"),fcn_mobileBookmarkList=_$(".mobile-menu__bookmark-list"),fcn_bookmarksSmallCardBlock=_$(".bookmarks-block"),fcn_bookmarksSmallCardTemplate=_$(".bookmark-small-card-template");var fcn_bookmarks,fcn_userBookmarksTimeout;function fcn_initializeLocalBookmarks(){fcn_setBookmarks(fcn_bookmarks=fcn_getBookmarks(),!0),fcn_updateBookmarksView()}function fcn_initializeUserBookmarks(t){fcn_setBookmarks(JSON.parse(t.detail.data.bookmarks),!0),fcn_updateBookmarksView()}function fcn_getBookmarks(){let t=fcn_parseJSON(localStorage.getItem("fcnChapterBookmarks"))??{data:{}};return Array.isArray(t.data)&&0===t.data.length&&(t.data={}),t=fcn_fixBookmarks(t),!t||Object.keys(t).length<1?{data:{}}:t}function fcn_fixBookmarks(t){const e={};for(const n in t.data)if(n.startsWith("ch-")){const a=fcn_fixBookmarksNode(t.data[n]);a&&(e[n]=a)}return{data:e}}function fcn_fixBookmarksNode(t){const e={},n={"paragraph-id":"",progress:0,date:"",color:"",chapter:"",link:"",thumb:"",image:"",story:"",content:""};for(const a in n){if(typeof t[a]!=typeof n[a])return null;e[a]=t[a]}const a=new Date(e.date);return a&&"[object Date]"===Object.prototype.toString.call(a)&&!isNaN(a)||(e.date=(new Date).toISOString()),("number"!=typeof e.progress||e.progress<0)&&(e.progress=0),e}function fcn_setBookmarks(t,e=!1){if("object"==typeof t){if(fcn_bookmarks=t,localStorage.setItem("fcnChapterBookmarks",JSON.stringify(t)),fcn_isLoggedIn){const e=fcn_getUserData();e&&(e.bookmarks=JSON.stringify(t),fcn_setUserData(e))}e||fcn_saveUserBookmarks(t)}}function fcn_updateBookmarksView(){if(!fcn_bookmarks||!fcn_bookmarks.data)retur
2024-03-09 19:51:06 +01:00
<input type="hidden" id="fictioneer-comment-validator" name="fictioneer_comment_validator" value="299792458">
`)}function fcn_moderateComment(t,e){const n=_$$$(`comment-${t}`),a=n.querySelector(".mod-menu-toggle-icon");n.classList.contains("ajax-in-progress")||(n.classList.add("ajax-in-progress"),"trash"!=e&&"spam"!=e||(n.style.height=n.clientHeight+"px"),fcn_ajaxPost({action:"fictioneer_ajax_moderate_comment",operation:e,id:t}).then((t=>{if(t.success)switch(t.data.operation){case"sticky":n.classList.add("_sticky");break;case"unsticky":n.classList.remove("_sticky");break;case"approve":n.classList.remove("_unapproved");break;case"unapprove":n.classList.add("_unapproved");break;case"open":n.classList.remove("_closed");break;case"close":n.classList.add("_closed");break;case"trash":case"spam":n.style.cssText="overflow: hidden; height: 0; margin: 0; opacity: 0;"}else a.classList="fa-solid fa-triangle-exclamation mod-menu-toggle-icon",a.style.color="var(--notice-warning-background)",n.querySelector(".popup-menu-toggle").style.opacity="1",t.data.error&&fcn_showNotification(t.data.error,5,"warning")})).catch((t=>{a.classList="fa-solid fa-triangle-exclamation mod-menu-toggle-icon",a.style.color="var(--notice-warning-background)",n.querySelector(".popup-menu-toggle").style.opacity="1",t.status&&t.statusText?fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"):t&&fcn_showNotification(t,5,"warning")})).then((()=>{n.classList.remove("ajax-in-progress"),fcn_lastClicked?.classList.remove("last-clicked"),fcn_lastClicked=null})))}function fcn_addCommentMouseleaveEvents(){_$$(".fictioneer-comment__container").forEach((t=>{t.addEventListener("mouseleave",(t=>{fcn_lastClicked?.classList.remove("last-clicked"),fcn_lastClicked=null,t.stopPropagation()}))}))}function fcn_flagComment(t){if(!fcn_isLoggedIn)return;const e=t.closest(".fictioneer-comment"),n=e.querySelector(".fictioneer-report-comment-button");e.classList.contains("ajax-in-progress")||(e.classList.add("ajax-in-progress"),fcn_ajaxPost({action:"fictioneer_ajax_report_comment",id:e.dataset.id,dubious:n.classList.contains("_dubious")}).then((t=>{t.success?(n.classList.toggle("on",t.data.flagged),n.classList.remove("_dubious"),t.data.resync&&fcn_showNotification(t.data.resync)):t.data?.error&&fcn_showNotification(t.data.error,5,"warning")})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning")})).then((()=>{e.classList.remove("ajax-in-progress")})))}function fcn_revealCommentFormInputs(t){t.closest("form").querySelectorAll(".fictioneer-respond__form-actions, .fictioneer-respond__form-bottom").forEach((t=>{t.classList.remove("hidden")}))}function fcn_addCommentFormEvents(){_$(fictioneer_comments.form_selector??"#comment")?.addEventListener("focus",(t=>{fcn_revealCommentFormInputs(t.currentTarget)}),{once:!0})}function fcn_textareaAdjust(t){t.style.height="auto",t.style.height=`${t.scrollHeight}px`}function fcn_wrapInTag(t,e,n={}){const a=n.href?' href="'+n.href+'" target="_blank" rel="nofollow noreferrer noopener"':"",o=n.shortcode?["[","]"]:["<",">"],c=t.selectionStart,s=t.selectionEnd,i=o[0]+e+a+o[1],r=o[0]+"/"+e+o[1],l=i+t.value.substring(c,s)+r;t.value=t.value.substring(0,c)+l+t.value.substring(s,t.value.length),t.setSelectionRange(c+i.length,s+i.length),t.focus()}function fcn_bindAJAXCommentSubmit(){fcn_theRoot.dataset.ajaxSubmit&&_$$$("commentform")?.addEventListener("submit",(t=>{if(t.preventDefault(),Date.now()<fcn_pageLoadTimestamp+3e3)return;const e=t.currentTarget,n=_$$$("submit"),a=_$(fictioneer_comments.form_selector??"#comment"),o=_$$$("author"),c=_$$$("email"),s=_$$$("wp-comment-cookies-consent"),i=_$$$("fictioneer-privacy-policy-consent"),r=_$$$("fictioneer-comment-validator"),l=_$$$("comment_parent").value,f=_$$$(`comment-${l}`),d=_$$$("fictioneer-private-comment-toggle"),_=_$$$("fictioneer-comment-notification-toggle"),h=e.closest(".fictioneer-comments")?.dataset.order??"desc";let u=!0,g=!0,m=!0;if(g=a.value.length>1,a.classList.toggle("_error",!g),i&&(m=i.checked,i.classList.toggle("_error",!m)),c&&c.value.length>0&&(u=/\S+@\S+\.\S+/.test(c.value),c.classList.toggle("_error",!u)),!g||!m||!u)return!1;e.classList.ad