fictioneer/js/complete.min.js

6 lines
136 KiB
JavaScript
Raw Normal View History

const _$=document.querySelector.bind(document),_$$=document.querySelectorAll.bind(document),_$$$=document.getElementById.bind(document),FcnUtils={userDataDefaults:{lastLoaded:0,timestamp:0,loggedIn:"pending",follows:!1,reminders:!1,checkmarks:!1,bookmarks:null,likes:null,fingerprint:!1,nonceHtml:"",nonce:"",isAdmin:!1,isModerator:!1,isAuthor:!1,isEditor:!1},userData(){const t=FcnUtils.parseJSON(localStorage.getItem("fcnUserData"))||{};return{...FcnUtils.userDataDefaults,...t}},resetUserData(){const t=FcnUtils.parseJSON(localStorage.getItem("fcnUserData"))||{},e={lastLoaded:t.lastLoaded??0,loggedIn:(!FcnGlobals.ajaxAuth||!1!==t.loggedIn)&&"pending"};localStorage.setItem("fcnUserData",JSON.stringify({...t,...FcnUtils.userDataDefaults,...e}))},removeUserData(){localStorage.removeItem("fcnUserData")},setUserData(t){localStorage.setItem("fcnUserData",JSON.stringify(t))},loggedInCache:null,loggedInCacheTime:0,loggedIn(){const t=Date.now();return null!==FcnUtils.loggedInCache&&t-FcnUtils.loggedInCacheTime<20||(FcnUtils.loggedInCache=FcnUtils.hasLoginCookie(),FcnUtils.loggedInCacheTime=t),FcnUtils.loggedInCache},hasLoginCookie(){const t=document.cookie.split(";");for(let e=0;e<t.length;e++){if(-1!==t[e].trim().indexOf("fcnLoggedIn="))return!0}return!1},async aGet(t={},e=null,n={}){try{return fcn_ajaxGet(t,e,n)}catch(t){throw console.error("aGet Error:",t),t}},async aPost(t={},e=null,n={}){try{return await fcn_ajaxPost(t,e,n)}catch(t){throw console.error("aPost Error:",t),t}},remoteAction(t,{element:e=null,callback:n=null,errorCallback:a=null,finalCallback:s=null,nonce:i=null,fast:o=!0,payload:r={}}={}){e?.classList.add("ajax-in-progress"),FcnUtils.aPost({action:t,fcn_fast_ajax:!!o,nonce:i??FcnUtils.nonce(),...r}).then((t=>{n&&n(t,e),t.success||(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,10,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{429===t.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),a&&a(t,e),console.error(t)})).then((()=>{e?.classList.remove("ajax-in-progress"),s&&s(e)}))},parseJSON(t){if(null==t||"string"!=typeof t)return null;try{return JSON.parse(t)}catch(t){return null}},copyToClipboard(t,e=!1){e=e||fictioneer_tl.notification.copiedToClipboard,navigator.clipboard&&(navigator.clipboard.writeText(t),e&&fcn_showNotification(e,2))},clamp:(t,e,n)=>Math.min(Math.max(n,t),e),offset(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}},throttle(t,e,n){var a,s,i,o=null,r=0;n||(n={});var c=function(){r=!1===n.leading?0:Date.now(),o=null,i=t.apply(a,s),o||(a=s=null)};return function(){var l=Date.now();r||!1!==n.leading||(r=l);var d=e-(l-r);return a=this,s=arguments,d<=0||d>e?(o&&(clearTimeout(o),o=null),r=l,i=t.apply(a,s),o||(a=s=null)):o||!1===n.trailing||(o=setTimeout(c,d)),i}},deleteCookie(t){document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"},deleteAllCookies(){localStorage.clear(),document.cookie.split(";").forEach((t=>{document.cookie=t.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")}))},setCookie(t,e,n=30){const a=new Date;a.setTime(a.getTime()+24*n*60*60*1e3);const s="expires="+a.toUTCString();document.cookie=t+"="+encodeURIComponent(e)+";"+s+";SameSite=Strict;path=/"},getCookie(t){const e=t+"=",n=document.cookie.split(";");for(var a=0;a<n.length;a++){const t=n[a].trim();if(0==t.indexOf(e))return decodeURIComponent(t.substring(e.length,t.length))}return null},nonce:()=>_$$$("fictioneer-ajax-nonce")?.value??_$$$("general-fictioneer-nonce")?.value??_$('[name="fictioneer_nonce"]')?.value??0,buildUrl:(t={},e=null)=>(e=e?new URL(e):new URL(window.location.protocol+"//"+window.location.host+window.location.pathname),t&&Object.keys(t).forEach((n=>{e.searchParams.append(n,t[n])})),e),buildErrorNotice(t,e=!1,n=!0){console.error("Error:",t);const a=document.createElement("div");let s=t;return e&&(a.id=e),a.classList
2025-01-16 18:44:28 +01:00
e.querySelector('[data-finder="tooltip-dialog-content"]').innerHTML=a,e.showModal()}}))})),document.body.addEventListener("keydown",(t=>{let e=document.activeElement.closest('[tabindex="0"]:not(a, input, button, select)');if(["BUTTON","A","INPUT","SELECT"].includes(document.activeElement.tagName)&&(e=null),e&&(" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),e.click())),"Escape"===t.key){_$$(".modal-toggle:checked").forEach((t=>{t.checked=!1,t.dispatchEvent(new Event("change"))}));const t=_$(".lightbox.show");if(t)return void t.querySelector(".lightbox__close").click();const e=_$(".selected-paragraph #button-close-paragraph-tools");if(e)return void e.click();const n=_$("#tts-interface:not(.hidden)");if(n){if(n.classList.contains("playing")){const t=_$$$("button-tts-pause");t?.click(),t?.focus(),t?.blur()}else _$$$("button-tts-stop").click();return}}}));class FCN_KeywordInput{constructor(t){this.input=t,this.type=t.dataset.type,this.operator=t.closest(".keyword-input").querySelector(".keyword-input__operator input"),this.inputWrapper=t.closest(".keyword-input__input-wrapper"),this.block=t.closest(".keyword-input"),this.form=this.block.closest(".search-form"),this.collection=this.block.querySelector(".keyword-input__collection"),this.suggestionList=this.block.querySelector(".keyword-input__suggestion-list"),this.tabSuggestion=this.block.querySelector(".keyword-input__tab-suggestion"),this.allowText=this.form.querySelector(".allow-list")?.innerText??"{}",this.allowList=FcnUtils.parseJSON(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 s=a.innerText.toLowerCase();s.includes(t)&&this.keywords.indexOf(s)<0?(a.hidden=!1,e++,""==n&&s.startsWith(t)&&(n=s)):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 s=document.createElement("div");s.innerHTML=`<span class="node-name">${n}</span><span class="node-delete"><i class="fa-solid fa-xmark"></i></span>`,s.classList.add("node"),s.dataset.value=a,this.inputWrapper.parentNode.insertBefore(s,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(
})(),_$$("#reader-settings-indent-toggle").forEach((t=>{const e={invertClass:!0,toggleClass:"no-indent"},n="indent";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)};fcn_updateToggle(FcnFormatting.get()[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-justify-toggle").forEach((t=>{const e={toggleClass:"justify"},n="justify";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)};fcn_updateToggle(FcnFormatting.get()[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-paragraph-tools-toggle").forEach((t=>{const e="show-paragraph-tools";t.onclick=n=>{fcn_updateToggle(n.currentTarget.checked,`#${t.id}`,e)};fcn_updateToggle(FcnFormatting.get()[e],`#${t.id}`,e,{save:!1})})),_$$("#reader-settings-chapter-notes-toggle").forEach((t=>{const e={notes:!0},n="show-chapter-notes";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)};fcn_updateToggle(FcnFormatting.get()[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-comments-toggle").forEach((t=>{const e={comments:!0},n="show-comments";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)};fcn_updateToggle(FcnFormatting.get()[n],`#${t.id}`,n,{save:!1,...e})})),_$$("#reader-settings-sensitive-content-toggle").forEach((t=>{const e={toggleClass:"hide-sensitive",invertClass:!0,sensitiveContent:!0},n="show-sensitive-content";t.onclick=a=>{fcn_updateToggle(a.currentTarget.checked,`#${t.id}`,n,e)};fcn_updateToggle(FcnFormatting.get()[n],`#${t.id}`,n,{save:!1,...e})}));var diff_match_patch=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff=function(t,e){this[0]=t,this[1]=e},diff_match_patch.Diff.prototype.length=2,diff_match_patch.Diff.prototype.toString=function(){return this[0]+","+this[1]},diff_match_patch.prototype.diff_main=function(t,e,n,a){if(void 0===a&&(a=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout),null==t||null==e)throw Error("Null input. (diff_main)");if(t==e)return t?[new diff_match_patch.Diff(DIFF_EQUAL,t)]:[];void 0===n&&(n=!0);var s=n,i=this.diff_commonPrefix(t,e);n=t.substring(0,i),t=t.substring(i),e=e.substring(i),i=this.diff_commonSuffix(t,e);var o=t.substring(t.length-i);return t=t.substring(0,t.length-i),e=e.substring(0,e.length-i),t=this.diff_compute_(t,e,s,a),n&&t.unshift(new diff_match_patch.Diff(DIFF_EQUAL,n)),o&&t.push(new diff_match_patch.Diff(DIFF_EQUAL,o)),this.diff_cleanupMerge(t),t},diff_match_patch.prototype.diff_compute_=function(t,e,n,a){if(!t)return[new diff_match_patch.Diff(DIFF_INSERT,e)];if(!e)return[new diff_match_patch.Diff(DIFF_DELETE,t)];var s=t.length>e.length?t:e,i=t.length>e.length?e:t,o=s.indexOf(i);return-1!=o?(n=[new diff_match_patch.Diff(DIFF_INSERT,s.substring(0,o)),new diff_match_patch.Diff(DIFF_EQUAL,i),new diff_match_patch.Diff(DIFF_INSERT,s.substring(o+i.length))],t.length>e.length&&(n[0][0]=n[2][0]=DIFF_DELETE),n):1==i.length?[new diff_match_patch.Diff(DIFF_DELETE,t),new diff_match_patch.Diff(DIFF_INSERT,e)]:(s=this.diff_halfMatch_(t,e))?(e=s[1],i=s[3],t=s[4],s=this.diff_main(s[0],s[2],n,a),n=this.diff_main(e,i,n,a),s.concat([new diff_match_patch.Diff(DIFF_EQUAL,t)],n)):n&&100<t.length&&100<e.length?this.diff_lineMode_(t,e,a):this.diff_bisect_(t,e,a)},diff_match_patch.prototype.diff_lineMode_=function(t,e,n){var a=this.diff_linesToChars_(t,e);t=a.chars1,e=a.chars2,a=a.lineArray,t=this.diff_main(t,e,!1,n),this.diff_charsToLines_(t,a),this.diff_cleanupSemantic(t),t.push(new diff_match_patch.Diff(DIFF_EQUAL,""));for(var s=a=e=0,i="",o="";e<t.length;){switch(t[e][0]){case DIFF_INSERT:s++,o+=t[e][1];break;case DIFF_DELETE:a++,i+=t[e][1];break;case DIFF_EQUAL:if(1<=a&&1<=s){for(t.splice(e-a-s,a+s),e=e-a-s,s=(a=this.diff_main(i,o,!1,n)).length-1;0<=s;s--)t.splice(e,0,a[s]);e+=a.length}a=s=0,o=i=""}e++}return t.pop(),t},diff_match_patch.prototype.diff_bisect_=function(t,e,n){for(var a=t.length,s=e.length,i=Math.ceil((a+s)/2),o=2*i,r=
2025-01-16 19:01:24 +01:00
const a=window.FictioneerApp.Controllers.fictioneerCheckmarks;if(!a)return void fcn_showNotification("Error: Checkmarks Controller not connected.",3,"warning");const s=FcnUtils.userData();let i="story";if((t=parseInt(t??0))<1)return void fcn_showNotification("Error: Invalid story ID.",3,"warning");if(null!==e){if((e=parseInt(e))<1)return void fcn_showNotification("Error: Invalid chapter ID.",3,"warning");i="chapter"}("object"!=typeof s.checkmarks.data||null===s.checkmarks.data||Array.isArray(s.checkmarks.data))&&(s.checkmarks.data={}),s.checkmarks.data[t]||(s.checkmarks.data[t]=[]),null===n&&(n="chapter"===i?!s.checkmarks.data[t]?.includes(e):!s.checkmarks.data[t]?.includes(t));const o="chapter"===i?e:t;n?s.checkmarks.data[t].push(o):(FcnUtils.removeArrayItemOnce(s.checkmarks.data[t],o),"chapter"===i&&FcnUtils.removeArrayItemOnce(s.checkmarks.data[t],t)),s.checkmarks.data[t]=s.checkmarks.data[t].filter(((t,e,n)=>n.indexOf(t)==e)),s.lastLoaded=0,FcnUtils.setUserData(s),a.refreshView(),clearTimeout(a.timeout),a.timeout=setTimeout((()=>{FcnUtils.remoteAction("fictioneer_ajax_set_checkmark",{payload:{update:s.checkmarks.data[t].join(" "),story_id:t}})}),FcnGlobals.debounceRate)}function fcn_toggleReminder(t,e=null){const n=window.FictioneerApp.Controllers.fictioneerReminders;if(!n)return void fcn_showNotification("Error: Reminders Controller not connected.",3,"warning");const a=FcnUtils.userData();("object"!=typeof a.reminders.data||null===a.reminders.data||Array.isArray(a.reminders.data))&&(a.reminders.data={}),(e=e??!a.reminders.data[t])?a.reminders.data[t]={story_id:parseInt(t),timestamp:Date.now()}:delete a.reminders.data[t],a.lastLoaded=0,FcnUtils.setUserData(a),n.refreshView(),clearTimeout(n.timeout),n.timeout=setTimeout((()=>{FcnUtils.remoteAction("fictioneer_ajax_toggle_reminder",{payload:{set:e,story_id:t}})}),FcnGlobals.debounceRate)}function fcn_wrapInTag(t,e,n={}){const a=n.href?' href="'+n.href+'" target="_blank" rel="nofollow noreferrer noopener"':"",s=n.shortcode?["[","]"]:["<",">"],i=t.selectionStart,o=t.selectionEnd,r=s[0]+e+a+s[1],c=s[0]+"/"+e+s[1],l=r+t.value.substring(i,o)+c;t.value=t.value.substring(0,i)+l+t.value.substring(o,t.value.length),t.setSelectionRange(i+r.length,o+r.length),t.focus()}"undefined"!=typeof speechSynthesis&&fcn_ttsInterface&&(_$$$("button-tts-set").addEventListener("click",(t=>{fcn_ttsStack=[],fcn_currentReadingId=-1;const e=_$(".chapter-formatting")?.classList.contains("hide-sensitive")??!1?"sensitive-content":"sensitive-alternative",n=_$$$("button-tts-play"),a=new RegExp(fcn_ttsInterface.dataset.regex,"gm");fcn_synth.speaking&&fcn_utter.removeEventListener("end",fcn_readTextStack),fcn_synth.cancel();const s=new Set(["P","H1","H2","H3","H4","H5","H6"]),i=["skip-tts","inside-epub",e];let o=t.target.closest("p[data-paragraph-id]");for(fcn_ttsStack.push(o);o=o.nextElementSibling;)s.has(o.tagName)&&!i.some((t=>o.classList.contains(t)))&&fcn_ttsStack.push(o);fcn_ttsStack=fcn_ttsStack.flatMap((t=>{const e=[];return FcnUtils.extractTextNodes(t).replace(a,"$1|").split("|").forEach((n=>{const a=n.trim();a.length>0&&e.push([t.id,a])})),e})),fcn_readTextStack(),document.body.classList.add("tts-open"),fcn_ttsInterface.classList.remove("hidden","ended","paused"),fcn_ttsInterface.classList.add("playing"),n.focus(),n.blur()})),_$$$("button-tts-stop")?.addEventListener("click",(()=>{const t=_$(".current-reading");fcn_ttsInterface.classList.add("hidden","ended"),fcn_ttsInterface.classList.remove("playing","paused"),document.body.classList.remove("tts-open"),t&&t.classList.remove("current-reading"),fcn_ttsStack=[],fcn_currentReadingId=-1,fcn_utter.removeEventListener("end",fcn_readTextStack),fcn_synth.cancel()})),_$$$("button-tts-play")?.addEventListener("click",(()=>{fcn_synth.resume(),-1!==fcn_ttsPauseTimestamp&&Date.now()-fcn_ttsPauseTimestamp>1e4&&(fcn_ttsStack.unshift([fcn_currentReadingId,fcn_ttsCurrentText]),fcn_synth.cancel(),fcn_readTextStack(),fcn_ttsPauseTimestamp=-1),fcn_ttsInterface.classList.add("playing"),fcn_ttsInterface.classList.remove("paused")})),_$$$("button-tts-pause")?.addEv
<input type="hidden" name="fictioneer_comment_validator" value="299792458">
`)}revealFormInputs(){this.respond.querySelectorAll(".fictioneer-respond__form-actions, .fictioneer-respond__form-bottom").forEach((t=>{t.classList.remove("hidden")}))}ajaxSubmit(t){if(Date.now()<FcnGlobals.pageLoadTimestamp+3e3)return;if(this.element.classList.remove("_invalid"),!document.documentElement.dataset.ajaxSubmit)return this.element.reportValidity()?(this.submitTarget.value=this.submitTarget.dataset.disabled,this.submitTarget.classList.add("_disabled"),void setTimeout((()=>{this.submitTarget.value=this.submitTarget.dataset.enabled,this.submitTarget.classList.remove("_disabled")}),2e3)):void this.element.classList.add("_invalid");if(t.preventDefault(),!this.element.reportValidity())return void this.element.classList.add("_invalid");const e=new FormData(this.element),n=Object.fromEntries(e.entries()),a=n.comment_parent??0,s=_$$$(`comment-${a}`),i=this.textareaTarget.value.length>1;let o=!0,r=!0;if(this.textareaTarget.classList.toggle("_error",!i),this.hasPrivacyPolicyTarget&&(r=this.privacyPolicyTarget.checked,this.privacyPolicyTarget.classList.toggle("_error",!r)),this.hasEmailTarget&&this.emailTarget?.value.length>0&&(o=/\S+@\S+\.\S+/.test(this.emailTarget.value),this.emailTarget.classList.toggle("_error",!o)),!i||!r||!o)return;this.element.classList.add("ajax-in-progress"),this.submitTarget.value=this.submitTarget.dataset.disabled,this.submitTarget.disabled=!0;const c={action:"fictioneer_ajax_submit_comment",content:this.textareaTarget.value,depth:s?parseInt(s.dataset.depth)+1:1,fcn_fast_comment_ajax:1,...n};this.hasEmailTarget&&this.emailTarget?.value&&(c.email=this.emailTarget.value),this.hasAuthorTarget&&this.authorTarget?.value&&(c.author=this.authorTarget.value),_$$$("comment-submit-error-notice")?.remove(),FcnUtils.aPost(c).then((t=>{if(t.success&&t.data?.comment){let e=_$(".commentlist"),n="insertBefore";if(e&&!s&&e.firstElementChild){let t=null;if(e.firstElementChild.classList.contains("_sticky"))for(t=e.firstElementChild,e=t,n="insertAfter";t.nextElementSibling&&t.nextElementSibling.classList.contains("_sticky");)t=e.nextElementSibling,e=t}if(e||(e=document.createElement("ol"),e.classList="fictioneer-comments__list commentlist",_$$$("comments").appendChild(e),n="append"),s&&(e=s.querySelector(".children"),n="append",!e)){const t=document.createElement("ol");s.appendChild(t),e=t}let a=document.createElement("div");switch(a.innerHTML=t.data.comment,a=a.firstChild,n){case"append":e.appendChild(a);break;case"insertBefore":e.insertBefore(a,e.firstChild);break;case"insertAfter":e.nextSibling?e.parentNode.insertBefore(a,e.nextSibling):e.parentNode.appendChild(a)}this.textareaTarget.value="",this.textareaTarget.style.height="","0"!=this.parent.value&&this.cancelTarget.click();const i=window.location.protocol+"//"+window.location.host+window.location.pathname;("desc"!=this.order||FcnGlobals.urlParams.corder)&&(FcnGlobals.urlParams.corder=this.order),t.data.commentcode&&(FcnGlobals.urlParams.commentcode=t.data.commentcode);let o=Object.entries(FcnGlobals.urlParams).map((([t,e])=>`${t}=${e}`)).join("&");""!==o&&(o=`?${o}`),history.replaceState({path:i},"",i+o+`#comment-${t.data.comment_id}`),a.scrollIntoView({behavior:"smooth"})}else this.element.insertBefore(FcnUtils.buildErrorNotice(t.data.failure??t.data.error??fictioneer_tl.notification.error,"comment-submit-error-notice",!1),this.element.firstChild),console.error("Error:",t.data.error??t.data.failure??"Unknown")})).catch((t=>{this.element.insertBefore(FcnUtils.buildErrorNotice(`${t.statusText} (${t.status})`,"comment-submit-error-notice"),this.element.firstChild)})).then((()=>{this.element.classList.remove("ajax-in-progress"),this.submitTarget.disabled=!1,this.submitTarget.value=this.submitTarget.dataset.enabled}))}togglePrivate(){this.respond.classList.toggle("_private",this.privateToggleTarget.checked)}}),application.register("fictioneer-comment",class extends Stimulus.Controller{static get targets(){return["modMenuToggle","modMenu","modIcon","editLink","flagButton","deleteButton","editButton","content","inlineEditWrapper","inlineEditTextarea","inli