fictioneer/js/complete.min.js

6 lines
137 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
this.tabSuggestion=this.block.querySelector(".keyword-input__tab-suggestion"),this.allowText=this.form.querySelector(".allow-list")?.innerText??"{}",this.allowList=JSON.parse(this.allowText),this.hints=this.block.querySelector(".keyword-input__hints"),this.noHint=this.block.querySelector(".keyword-input__no-suggestions"),this.keywords=this.collection.value.length>0?this.collection.value.split(","):[],this.bindEvents(),this.resize(),this.filterSuggestions()}resize(){const t=this.tabSuggestion.innerText.length>0?this.tabSuggestion.innerText.length:this.input.value.length;this.input.style.width=.88*t+2+"ch"}reset(){this.keywords=[],this.block.querySelectorAll(".node").forEach((t=>{t.remove()})),this.block.querySelectorAll(".keyword-input__operator > input").forEach((t=>{t.checked=!1})),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}encode(t){const e=(new TextEncoder).encode(t.toLowerCase());return btoa(String.fromCharCode.apply(null,e))}filterSuggestions(){const t=this.input.value.toLowerCase();let e=0,n="";""==t?this.suggestionList.querySelectorAll(".keyword-button").forEach((t=>{t.hidden=!0})):this.suggestionList.querySelectorAll(".keyword-button").forEach((a=>{const o=a.innerText.toLowerCase();o.includes(t)&&this.keywords.indexOf(o)<0?(a.hidden=!1,e++,""==n&&o.startsWith(t)&&(n=o)):a.hidden=!0})),this.hints.querySelectorAll(".keyword-button").forEach((t=>{this.keywords.indexOf(t.value.toLowerCase())>-1?t.hidden=!0:t.hidden=!1})),this.tabSuggestion.innerHTML=n,this.hints.hidden=!(""==t),this.noHint.hidden=!(""!=t&&e<1)}addNode(t=null,e=null){const n=t??this.input.value.replace(",","");let a=this.allowList[`${this.type}_${this.encode(n)}`];if("authors"!=this.collection.name&&"ex_authors"!=this.collection.name||!e||(a=this.allowList[`${this.type}_${this.encode(n)}_${e.value}`]),!a||this.keywords.indexOf(a)>-1)return;this.keywords.push(a);const o=document.createElement("div");o.innerHTML=`<span class="node-name">${n}</span><span class="node-delete"><i class="fa-solid fa-xmark"></i></span>`,o.classList.add("node"),o.dataset.value=a,this.inputWrapper.parentNode.insertBefore(o,this.inputWrapper),this.input.value="",this.updateCollection(),this.filterSuggestions(),this.resize()}removeNodeByValue(t){this.block.querySelector(`[data-value="${t}"]`)?.remove(),this.keywords=this.keywords.filter((e=>e!=t)),this.updateCollection(),this.filterSuggestions(),this.resize()}updateCollection(){this.collection.value=this.keywords.join(","),this.block.classList.toggle("_empty",""===this.collection.value),this.form.querySelector(".search-form__current").innerHTML=""}bindEvents(){this.input.addEventListener("input",(t=>{t.currentTarget.value.includes(",")&&this.addNode(),this.block.classList.toggle("_empty",""===t.currentTarget.value&&""===this.collection.value),this.filterSuggestions(),this.resize()})),this.input.addEventListener("keydown",(t=>{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,t.currentTarget)}))}))}}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_show
;for(var n=0,a=Math.min(t.length,e.length),o=a,c=0;n<o;)t.substring(c,o)==e.substring(c,o)?c=n=o:a=o,o=Math.floor((a-n)/2+n);return o},diff_match_patch.prototype.diff_commonSuffix=function(t,e){if(!t||!e||t.charAt(t.length-1)!=e.charAt(e.length-1))return 0;for(var n=0,a=Math.min(t.length,e.length),o=a,c=0;n<o;)t.substring(t.length-o,t.length-c)==e.substring(e.length-o,e.length-c)?c=n=o:a=o,o=Math.floor((a-n)/2+n);return o},diff_match_patch.prototype.diff_commonOverlap_=function(t,e){var n=t.length,a=e.length;if(0==n||0==a)return 0;if(n>a?t=t.substring(n-a):n<a&&(e=e.substring(0,n)),n=Math.min(n,a),t==e)return n;a=0;for(var o=1;;){var c=t.substring(n-o);if(-1==(c=e.indexOf(c)))return a;o+=c,0!=c&&t.substring(n-o)!=e.substring(0,o)||(a=o,o++)}},diff_match_patch.prototype.diff_halfMatch_=function(t,e){function n(t,e,n){for(var a,o,s,i,r=t.substring(n,n+Math.floor(t.length/4)),l=-1,f="";-1!=(l=e.indexOf(r,l+1));){var d=c.diff_commonPrefix(t.substring(n),e.substring(l)),_=c.diff_commonSuffix(t.substring(0,n),e.substring(0,l));f.length<_+d&&(f=e.substring(l-_,l)+e.substring(l,l+d),a=t.substring(0,n-_),o=t.substring(n+d),s=e.substring(0,l-_),i=e.substring(l+d))}return 2*f.length>=t.length?[a,o,s,i,f]:null}if(0>=this.Diff_Timeout)return null;var a=t.length>e.length?t:e,o=t.length>e.length?e:t;if(4>a.length||2*o.length<a.length)return null;var c=this,s=n(a,o,Math.ceil(a.length/4));if(a=n(a,o,Math.ceil(a.length/2)),!s&&!a)return null;if(s=a?s&&s[4].length>a[4].length?s:a:s,t.length>e.length){a=s[0],o=s[1];var i=s[2],r=s[3]}else i=s[0],r=s[1],a=s[2],o=s[3];return[a,o,i,r,s[4]]},diff_match_patch.prototype.diff_cleanupSemantic=function(t){for(var e=!1,n=[],a=0,o=null,c=0,s=0,i=0,r=0,l=0;c<t.length;)t[c][0]==DIFF_EQUAL?(n[a++]=c,s=r,i=l,l=r=0,o=t[c][1]):(t[c][0]==DIFF_INSERT?r+=t[c][1].length:l+=t[c][1].length,o&&o.length<=Math.max(s,i)&&o.length<=Math.max(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--,c=0<--a?n[a-1]:-1,l=r=i=s=0,o=null,e=!0)),c++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),c=1;c<t.length;)t[c-1][0]==DIFF_DELETE&&t[c][0]==DIFF_INSERT&&(e=t[c-1][1],n=t[c][1],(a=this.diff_commonOverlap_(e,n))>=(o=this.diff_commonOverlap_(n,e))?(a>=e.length/2||a>=n.length/2)&&(t.splice(c,0,new diff_match_patch.Diff(DIFF_EQUAL,n.substring(0,a))),t[c-1][1]=e.substring(0,e.length-a),t[c+1][1]=n.substring(a),c++):(o>=e.length/2||o>=n.length/2)&&(t.splice(c,0,new diff_match_patch.Diff(DIFF_EQUAL,e.substring(0,o))),t[c-1][0]=DIFF_INSERT,t[c-1][1]=n.substring(0,n.length-o),t[c+1][0]=DIFF_DELETE,t[c+1][1]=e.substring(o),c++),c++),c++},diff_match_patch.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var n=t.charAt(t.length-1),a=e.charAt(0),o=n.match(diff_match_patch.nonAlphaNumericRegex_),c=a.match(diff_match_patch.nonAlphaNumericRegex_),s=o&&n.match(diff_match_patch.whitespaceRegex_),i=c&&a.match(diff_match_patch.whitespaceRegex_);n=s&&n.match(diff_match_patch.linebreakRegex_),a=i&&a.match(diff_match_patch.linebreakRegex_);var r=n&&t.match(diff_match_patch.blanklineEndRegex_),l=a&&e.match(diff_match_patch.blanklineStartRegex_);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.leng
action:"fictioneer_ajax_get_user_data",fcn_fast_ajax:1}).then((t=>{if(t.success){let e=fcn_getUserData();e=t.data,e.lastLoaded=Date.now(),fcn_setUserData(e);const n=new CustomEvent("fcnUserDataReady",{detail:{data:t.data,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(n)}else{const e=fcn_getUserData();e.lastLoaded=Date.now(),e.loggedIn=!1,fcn_setUserData(e);const n=new CustomEvent("fcnUserDataFailed",{detail:{response:t,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(n)}})).catch((t=>{localStorage.removeItem("fcnUserData");const e=new CustomEvent("fcnUserDataError",{detail:{error:t,time:new Date},bubbles:!0,cancelable:!1});document.dispatchEvent(e)}))}function fcn_unsetOauth(t){const e=prompt(t.dataset.warning);if(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())return;const n=_$$$(`oauth-${t.dataset.channel}`);n.classList.add("ajax-in-progress"),fcn_ajaxPost(payload={action:"fictioneer_ajax_unset_my_oauth",nonce:t.dataset.nonce,channel:t.dataset.channel,id:t.dataset.id}).then((t=>{t.success?(n.classList.remove("_connected"),n.classList.add("_disconnected"),n.querySelector("button").remove(),fcn_showNotification(n.dataset.unset)):(n.style.background="var(--notice-warning-background)",fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&(n.style.background="var(--notice-warning-background)",fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning")),console.error(t)})).then((()=>{n.classList.remove("ajax-in-progress")}))}function fcn_deleteMyAccount(t){if(_$$$("button-delete-my-account").hasAttribute("disabled"))return;const e=prompt(t.dataset.warning);e&&e.toLowerCase()==t.dataset.confirm.toLowerCase()&&(_$$$("button-delete-my-account").setAttribute("disabled",!0),fcn_ajaxPost({action:"fictioneer_ajax_delete_my_account",nonce:t.dataset.nonce,id:t.dataset.id}).then((t=>{t.success?(localStorage.removeItem("fcnAuth"),localStorage.removeItem("fcnProfileAvatar"),location.reload()):(_$$$("button-delete-my-account").innerHTML=t.data.button,fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&(fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),_$$$("button-delete-my-account").innerHTML=response.data.button),console.error(t)})))}_$$('[data-click-action*="toggle-chapter-order"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.order="asc"===t.currentTarget.dataset.order?"desc":"asc",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$('[data-click-action*="toggle-chapter-view"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.view="list"===t.currentTarget.dataset.view?"grid":"list",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$(".chapter-group__folding-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-group[data-folded]");e&&(e.dataset.folded="true"==e.dataset.folded?"false":"true")}))})),_$$(".tabs__item").forEach((t=>{t.addEventListener("click",(t=>{fcn_toggleStoryTab(t.currentTarget)}))})),_$(".comment-section")?.addEventListener("click",(t=>{t.target?.classList.contains("load-more-comments-button")&&fcn_loadStoryComments(t.target)})),_$$('[data-action="download-epub"]').forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.currentTarget.classList.contains("ajax-in-progress")||(t.currentTarget.classList.add("ajax-in-progress"),fcn_startEpubDownload(t.currentTarget))}))})),document.addEventListener("DOMContentLoaded",(()=>{fcn_isLoggedIn&&!fcn_theRoot.dataset.ajaxAuth&&fcn_getProfileImage()})),fcn_theRoot.dataset.ajaxAuth&&document.addEventListener("fcnAuthR
<input type="hidden" name="fictioneer_comment_validator" value="299792458">
2024-11-16 14:00:38 +01:00
`)}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,fcn_fast_comment_ajax:1}).then((t=>{if(t.success)switch(t.data.operation){case"sticky":n.classList.add("_sticky");break;case"unsticky":n.classList.remove("_sticky");break;case"offensive":n.classList.add("_offensive");break;case"unoffensive":n.classList.remove("_offensive");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"),fcn_fast_comment_ajax:1}).then((t=>{t.success?(n.classList.toggle("on",t.data.flagged),n.classList.remove("_dubious"),t.data.resync&&fcn_showNotification(t.data.resync)):(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,5,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),console.error(t)})).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&&(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=new FormData(e),a=Object.fromEntries(n.entries()),o=e.querySelector('[name="submit"]'),c=_$(fictioneer_comments.form_selector??"#comment"),s=e.querySelector('[name="author"]'),i=e.querySelector('[name="email"]'),r=e.querySelector('[name="fictioneer-privacy-policy-consent"]'),l=a.comment_parent??0,f=_$$$(`comment-${l}`),d=e.closest(".fictioneer-comments")?.dataset.o