1import u from"./vendor_quill-Bw4YNUoM.js";const x=u.import("blots/embed");class b extends Event{constructor(t,e){super(t,e),this.value={},this.event=new Event(t)}}function E(r){return typeof r=="object"&&r!==null&&"value"in r&&typeof r.value=="string"&&"denotationChar"in r&&typeof r.denotationChar=="string"}class f extends x{constructor(t,e){super(t,e),this.mounted=!1}static create(t){const e=super.create();if(!E(t)||!(e instanceof HTMLElement))return e;const i=document.createElement("span");if(i.className="ql-mention-denotation-char",i.innerText=t.denotationChar,e.appendChild(i),typeof this.render=="function")e.appendChild(this.render(t));else{const n=document.createElement("span");n.className="ql-mention-value",n.innerText=t.value,e.appendChild(n)}return f.setDataValues(e,t)}static setDataValues(t,e){const i=t;return Object.keys(e).forEach(n=>{i.dataset[n]=e[n]}),i}static value(t){return t.dataset}attach(){super.attach(),this.mounted||(this.mounted=!0,this.clickHandler=this.getClickHandler(),this.hoverHandler=this.getHoverHandler(),this.domNode.addEventListener("click",this.clickHandler,!1),this.domNode.addEventListener("mouseenter",this.hoverHandler,!1))}detach(){super.detach(),this.mounted=!1,this.clickHandler&&(this.domNode.removeEventListener("click",this.clickHandler),this.clickHandler=void 0)}getClickHandler(){return t=>{const e=this.buildEvent("mention-clicked",t);window.dispatchEvent(e),t.preventDefault()}}getHoverHandler(){return t=>{const e=this.buildEvent("mention-hovered",t);window.dispatchEvent(e),t.preventDefault()}}buildEvent(t,e){const i=new b(t,{bubbles:!0,cancelable:!0});return i.value=Object.assign({},this.domNode.dataset),i.event=e,i}}f.blotName="mention";f.tagName="span";f.className="mention";const l={TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",UP:"ArrowUp",DOWN:"ArrowDown"};function I(r,t,e){const i=r;return Object.keys(t).forEach(n=>{e.indexOf(n)>-1?i.dataset[n]=t[n]:delete i.dataset[n]}),i}function g(r,t){t!==null&&(typeof t=="object"?r.appendChild(t):r.innerText=t)}function T(r,t,e,i){return t.reduce((n,o)=>{let s;if(e&&i){const h=new RegExp(`^${o}|\\s${o}`,"g"),a=(r.match(h)||[]).pop();if(!a)return{mentionChar:n.mentionChar,mentionCharIndex:n.mentionCharIndex};s=a!==o?r.lastIndexOf(a)+a.length-o.length:0}else s=r.lastIndexOf(o);return s>n.mentionCharIndex?{mentionChar:o,mentionCharIndex:s}:{mentionChar:n.mentionChar,mentionCharIndex:n.mentionCharIndex}},{mentionChar:null,mentionCharIndex:-1})}function v(r,t){return t.test(r)}function M(r,t,e,i){if(r===-1)return!1;if(!e)return!0;const n=r?t[r-1]:i;return!n||!!n.match(/\s/)}const L=u.import("core/module");class C extends L{constructor(t,e){super(t,e),this.isOpen=!1,this.itemIndex=0,this.values=[],this.suspendMouseEnter=!1,Array.isArray(e?.dataAttributes)&&(this.options.dataAttributes=this.options.dataAttributes?this.options.dataAttributes.concat(e.dataAttributes):e.dataAttributes);for(let i in this.options){const n=i,o=this.options[n];typeof o=="function"&&(this.options[n]=o.bind(this))}this.mentionContainer=document.createElement("div"),this.mentionContainer.className=this.options.mentionContainerClass?this.options.mentionContainerClass:"",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionContainer.onmousemove=this.onContainerMouseMove.bind(this),this.options.fixMentionsToQuill&&(this.mentionContainer.style.width="auto"),this.mentionList=document.createElement("ul"),this.mentionList.id="quill-mention-list",t.root.setAttribute("aria-owns","quill-mention-list"),this.mentionList.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.container.addEventListener("paste",()=>{setTimeout(()=>{const i=t.getSelection();this.onSelectionChange(i)})}),t.keyboard.addBinding({key:l.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[l.TAB].unshift(t.keyboard.bindings[l.TAB].pop());for(let i of this.options.selectKeys??[])t.keyboard.addBinding({key:i},this.selectHandler.bind(this));t.keyboard.bindings[l.ENTER].unshift(t.keyboard.bindings[l.ENTER].pop()),t.keyboard.addBinding({key:l.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:l.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:l.DOWN},this.downHandler.bind(this))}selectHandler(){return this.isOpen&&!this.existingSourceExecutionToken?(this.selectItem(),!1):!0}escapeHandler(){return this.isOpen?(this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList(),!1):!0}upHandler(){return this.isOpen&&!this.existingSourceExecutionToken?(this.prevItem(),!1):!0}downHandler(){return this.isOpen&&!this.existingSourceExecutionToken?(this.nextItem(),!1):!0}showMentionList(){this.options.positioningStrategy==="fixed"?document.body.appendChild(this.mentionContainer):this.quill.container.appendChild(this.mentionContainer),this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.mentionContainer.scrollTop=0,this.setMentionContainerPosition(),this.setIsOpen(!0)}hideMentionList(){this.options.onBeforeClose&&this.options.onBeforeClose(),this.mentionContainer.style.display="none",this.mentionContainer.remove(),this.setIsOpen(!1),this.quill.root.removeAttribute("aria-activedescendant")}highlightItem(t=!0){for(let i=0;i<this.mentionList.childNodes.length;i+=1){const n=this.mentionList.childNodes[i];n instanceof HTMLElement&&n.classList.remove("selected")}const e=this.mentionList.childNodes[this.itemIndex];if(!(this.itemIndex===-1||e.dataset.disabled==="true")&&(e.classList.add("selected"),this.quill.root.setAttribute("aria-activedescendant",e.id),t)){const i=e.offsetHeight,n=e.offsetTop,o=this.mentionContainer.scrollTop,s=o+this.mentionContainer.offsetHeight;n<o?this.mentionContainer.scrollTop=n:n>s-i&&(this.mentionContainer.scrollTop+=n-s+i)}}onContainerMouseMove(){this.suspendMouseEnter=!1}selectItem(){if(this.itemIndex===-1)return;const e=this.mentionList.childNodes[this.itemIndex].dataset;e.disabled||(this.options.onSelect?.(e,(i,n=!1,o={})=>this.insertItem(i,n,o)),this.hideMentionList())}insertItem(t,e,i={}){const n=t;if(n===null||this.mentionCharPos===void 0||this.cursorPos===void 0)return;const o={...this.options,...i};o.showDenotationChar||(n.denotationChar="");let s;e?s=this.cursorPos:(s=this.mentionCharPos,this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,u.sources.USER));const h=this.quill.insertEmbed(s,o.blotName??C.DEFAULTS.blotName,n,u.sources.USER);return o.spaceAfterInsert?(this.quill.insertText(s+1," ",u.sources.USER),this.quill.setSelection(s+2,u.sources.USER)):this.quill.setSelection(s+1,u.sources.USER),this.hideMentionList(),h}onItemMouseEnter(t){if(this.suspendMouseEnter||!(t.target instanceof HTMLElement))return;const e=Number(t.target?.dataset.index);!Number.isNaN(e)&&e!==this.itemIndex&&(this.itemIndex=e,this.highlightItem(!1))}onDisabledItemMouseEnter(){this.suspendMouseEnter||(this.itemIndex=-1,this.highlightItem(!1))}onItemClick(t){t.preventDefault(),t.stopImmediatePropagation(),t.currentTarget instanceof HTMLElement&&(this.itemIndex=t.currentTarget?.dataset.index?Number.parseInt(t.currentTarget.dataset.index):-1,this.highlightItem(),this.selectItem())}onItemMouseDown(t){t.preventDefault(),t.stopImmediatePropagation()}
1renderLoading(){const t=this.options.renderLoading?.()??void 0;if(t===void 0)return;if(this.mentionContainer.getElementsByClassName("ql-mention-loading").length>0){this.showMentionList();return}this.mentionList.innerHTML="";const e=document.createElement("div");e.className="ql-mention-loading",g(e,t),this.mentionContainer.append(e),this.showMentionList()}removeLoading(){const t=this.mentionContainer.getElementsByClassName("ql-mention-loading");t.length>0&&t[0].remove()}renderList(t,e,i){if(e&&e.length>0){this.removeLoading(),this.values=e,this.mentionList.innerText="";let n=-1;for(let o=0;o<e.length;o+=1){const s=document.createElement("li");s.id="quill-mention-item-"+o,s.className=this.options.listItemClass?this.options.listItemClass:"",e[o].disabled?(s.className+=" disabled",s.setAttribute("aria-hidden","true")):n===-1&&(n=o),s.dataset.index=o.toString();const h=this.options.renderItem(e[o],i);g(s,h),e[o].disabled?s.onmouseenter=this.onDisabledItemMouseEnter.bind(this):(s.onmouseenter=this.onItemMouseEnter.bind(this),s.onmouseup=this.onItemClick.bind(this),s.onmousedown=this.onItemMouseDown.bind(this)),s.dataset.denotationChar=t,this.mentionList.appendChild(I(s,e[o],this.options.dataAttributes))}this.itemIndex=n,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}nextItem(){let t=0,e,i;do if(t++,e=(this.itemIndex+t)%this.values.length,i=this.mentionList.childNodes[e].dataset.disabled==="true",t===this.values.length+1){e=-1;break}while(i);this.itemIndex=e,this.suspendMouseEnter=!0,this.highlightItem()}prevItem(){let t=0,e,i;do if(t++,e=(this.itemIndex+this.values.length-t)%this.values.length,i=this.mentionList.childNodes[e].dataset.disabled==="true",t===this.values.length+1){e=-1;break}while(i);this.itemIndex=e,this.suspendMouseEnter=!0,this.highlightItem()}containerBottomIsNotVisible(t,e){return t+this.mentionContainer.offsetHeight+e.top>window.scrollY+window.innerHeight}containerRightIsNotVisible(t,e){if(this.options.fixMentionsToQuill)return!1;const i=t+this.mentionContainer.offsetWidth+e.left,n=window.scrollX+document.documentElement.clientWidth;return i>n}setIsOpen(t){this.isOpen!==t&&(t?this.options.onOpen?.():this.options.onClose?.(),this.isOpen=t)}setMentionContainerPosition(){this.options.positioningStrategy==="fixed"?this.setMentionContainerPosition_Fixed():this.setMentionContainerPosition_Normal()}setMentionContainerPosition_Normal(){if(this.mentionCharPos===void 0)return;const t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.mentionCharPos);if(e===null)return;const i=this.mentionContainer.offsetHeight;let n=this.options.offsetTop,o=this.options.offsetLeft;if(this.options.fixMentionsToQuill?this.mentionContainer.style.right="0px":o+=e.left,this.containerRightIsNotVisible(o,t)){const s=this.mentionContainer.offsetWidth+this.options.offsetLeft;o=t.width-s}if(this.options.defaultMenuOrientation==="top"){if(this.options.fixMentionsToQuill?n=-1*(i+this.options.offsetTop):n=e.top-(i+this.options.offsetTop),n+t.top<=0){let s=this.options.offsetTop;this.options.fixMentionsToQuill?s+=t.height:s+=e.bottom,n=s}}else if(this.options.fixMentionsToQuill?n+=t.height:n+=e.bottom,this.containerBottomIsNotVisible(n,t)){let s=this.options.offsetTop*-1;this.options.fixMentionsToQuill||(s+=e.top),n=s-i}n>=0?this.options.mentionContainerClass?.split(" ").forEach(s=>{this.mentionContainer.classList.add(`${s}-bottom`),this.mentionContainer.classList.remove(`${s}-top`)}):this.options.mentionContainerClass?.split(" ").forEach(s=>{this.mentionContainer.classList.add(`${s}-top`),this.mentionContainer.classList.remove(`${s}-bottom`)}),this.mentionContainer.style.top=`${n}px`,this.mentionContainer.style.left=`${o}px`,this.mentionContainer.style.visibility="visible"}setMentionContainerPosition_Fixed(){if(this.mentionCharPos===void 0)return;this.mentionContainer.style.position="fixed",this.mentionContainer.style.height="";const t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.mentionCharPos);if(e===null)return;const i={right:t.right-e.right,left:t.left+e.left,top:t.top+e.top,height:e.height},n=this.options.fixMentionsToQuill?t:i;let o=this.options.offsetTop,s=this.options.offsetLeft;if(this.options.fixMentionsToQuill){const d=n.right;this.mentionContainer.style.right=`${d}px`}else s+=n.left,s+this.mentionContainer.offsetWidth>document.documentElement.clientWidth&&(s-=s+this.mentionContainer.offsetWidth-document.documentElement.clientWidth);const h=n.top,a=document.documentElement.clientHeight-(n.top+n.height),m=this.mentionContainer.offsetHeight<=a,p=this.mentionContainer.offsetHeight<=h;let c;this.options.defaultMenuOrientation==="top"&&p?c="top":this.options.defaultMenuOrientation==="bottom"&&m?c="bottom":c=a>h?"bottom":"top",c==="bottom"?(o=n.top+n.height,m||(this.mentionContainer.style.height=a-3+"px"),this.options.mentionContainerClass?.split(" ").forEach(d=>{this.mentionContainer.classList.add(`${d}-bottom`),this.mentionContainer.classList.remove(`${d}-top`)})):(o=n.top-this.mentionContainer.offsetHeight,p||(this.mentionContainer.style.height=h-3+"px",o=3),this.options.mentionContainerClass?.split(" ").forEach(d=>{this.mentionContainer.classList.add(`${d}-top`),this.mentionContainer.classList.remove(`${d}-bottom`)})),this.mentionContainer.style.top=`${o}px`,this.mentionContainer.style.left=`${s}px`,this.mentionContainer.style.visibility="visible"}
1getTextBeforeCursor(){const t=Math.max(0,(this.cursorPos??0)-this.options.maxChars);return this.quill.getText(t,(this.cursorPos??0)-t)}onSomethingChange(){const t=this.quill.getSelection();if(t==null)return;this.cursorPos=t.index;const e=this.getTextBeforeCursor(),i=Math.max(0,this.cursorPos-this.options.maxChars),n=i?this.quill.getText(i-1,i):"",{mentionChar:o,mentionCharIndex:s}=T(e,this.options.mentionDenotationChars,this.options.isolateCharacter,this.options.allowInlineMentionChar);if(o!==null&&M(s,e,this.options.isolateCharacter,n)){const h=this.cursorPos-(e.length-s);this.mentionCharPos=h;const a=e.substring(s+o.length);if(a.length>=this.options.minChars&&v(a,this.getAllowedCharsRegex(o))){this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.renderLoading();const m={abandoned:!1};this.existingSourceExecutionToken=m,this.options.source?.(a,(p,c)=>{m.abandoned||(this.existingSourceExecutionToken=void 0,this.renderList(o,p,c))},o)}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}getAllowedCharsRegex(t){return this.options.allowedChars instanceof RegExp?this.options.allowedChars:this.options.allowedChars?.(t)??/^[a-zA-Z0-9_]*$/}onTextChange(t,e,i){i==="user"&&setTimeout(this.onSomethingChange.bind(this),50)}onSelectionChange(t){t!==null&&t.length===0?this.onSomethingChange():this.hideMentionList()}openMenu(t){const e=this.quill.getSelection(!0);this.quill.insertText(e.index,t),this.quill.blur(),this.quill.focus()}}C.DEFAULTS={mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,allowInlineMentionChar:!1,fixMentionsToQuill:!1,positioningStrategy:"normal",defaultMenuOrientation:"bottom",blotName:"mention",dataAttributes:["id","value","denotationChar","link","target","disabled"],linkTarget:"_blank",listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0,selectKeys:[l.ENTER],source:(r,t,e)=>{t([],r)},renderItem:({value:r})=>`${r}`,onSelect:(r,t)=>t(r),onOpen:()=>!0,onBeforeClose:()=>!0,onClose:()=>!0,renderLoading:()=>null};export{C as M,f as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.