@remyxjs/react 1.0.0-beta → 1.0.4-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/{AttachmentModal-D-uxbXvb.cjs → AttachmentModal-BDFFiZJt.cjs} +2 -2
  2. package/dist/{AttachmentModal-D-uxbXvb.cjs.map → AttachmentModal-BDFFiZJt.cjs.map} +1 -1
  3. package/dist/{AttachmentModal--6T-vYJt.js → AttachmentModal-Di5V6QX-.js} +2 -2
  4. package/dist/{AttachmentModal--6T-vYJt.js.map → AttachmentModal-Di5V6QX-.js.map} +1 -1
  5. package/dist/{ContextMenu-B4K3Zbfp.cjs → ContextMenu-BafbP2Uh.cjs} +2 -2
  6. package/dist/{ContextMenu-B4K3Zbfp.cjs.map → ContextMenu-BafbP2Uh.cjs.map} +1 -1
  7. package/dist/{ContextMenu-D8wNSMc3.js → ContextMenu-DsA0YsY7.js} +2 -2
  8. package/dist/{ContextMenu-D8wNSMc3.js.map → ContextMenu-DsA0YsY7.js.map} +1 -1
  9. package/dist/{EmbedModal-Bh2Tcow9.cjs → EmbedModal-C73lODIT.cjs} +2 -2
  10. package/dist/{EmbedModal-Bh2Tcow9.cjs.map → EmbedModal-C73lODIT.cjs.map} +1 -1
  11. package/dist/{EmbedModal-cxE4maD2.js → EmbedModal-alpHQiAP.js} +2 -2
  12. package/dist/{EmbedModal-cxE4maD2.js.map → EmbedModal-alpHQiAP.js.map} +1 -1
  13. package/dist/{ExportModal-Cf1uE4r_.js → ExportModal-BN8LUaSR.js} +2 -2
  14. package/dist/{ExportModal-Cf1uE4r_.js.map → ExportModal-BN8LUaSR.js.map} +1 -1
  15. package/dist/{ExportModal-DwQVsrZE.cjs → ExportModal-Cu-cCwa6.cjs} +2 -2
  16. package/dist/{ExportModal-DwQVsrZE.cjs.map → ExportModal-Cu-cCwa6.cjs.map} +1 -1
  17. package/dist/{FindReplaceModal-Dgt_MrWb.js → FindReplaceModal-BqNcotUr.js} +2 -2
  18. package/dist/{FindReplaceModal-Dgt_MrWb.js.map → FindReplaceModal-BqNcotUr.js.map} +1 -1
  19. package/dist/{FindReplaceModal-DYL_2z8U.cjs → FindReplaceModal-DgysYT04.cjs} +2 -2
  20. package/dist/{FindReplaceModal-DYL_2z8U.cjs.map → FindReplaceModal-DgysYT04.cjs.map} +1 -1
  21. package/dist/{ImageModal-D39ywxqI.cjs → ImageModal-BzgYXY9y.cjs} +2 -2
  22. package/dist/{ImageModal-D39ywxqI.cjs.map → ImageModal-BzgYXY9y.cjs.map} +1 -1
  23. package/dist/{ImageModal-DqScpPrc.js → ImageModal-bCzSSTmd.js} +2 -2
  24. package/dist/{ImageModal-DqScpPrc.js.map → ImageModal-bCzSSTmd.js.map} +1 -1
  25. package/dist/{ImportDocumentModal-BKqMxO3z.js → ImportDocumentModal-BypTEn2i.js} +4 -4
  26. package/dist/{ImportDocumentModal-BKqMxO3z.js.map → ImportDocumentModal-BypTEn2i.js.map} +1 -1
  27. package/dist/{ImportDocumentModal-Bev9hp_J.cjs → ImportDocumentModal-gCFept9p.cjs} +2 -2
  28. package/dist/{ImportDocumentModal-Bev9hp_J.cjs.map → ImportDocumentModal-gCFept9p.cjs.map} +1 -1
  29. package/dist/{LinkModal-k9IeDtAb.js → LinkModal-CmkK4m-k.js} +3 -3
  30. package/dist/{LinkModal-k9IeDtAb.js.map → LinkModal-CmkK4m-k.js.map} +1 -1
  31. package/dist/{LinkModal-B-igSa-g.cjs → LinkModal-DPxg7YCE.cjs} +2 -2
  32. package/dist/{LinkModal-B-igSa-g.cjs.map → LinkModal-DPxg7YCE.cjs.map} +1 -1
  33. package/dist/{MenuBar-DWxJNHmb.js → MenuBar-DOv7JPwR.js} +2 -2
  34. package/dist/{MenuBar-DWxJNHmb.js.map → MenuBar-DOv7JPwR.js.map} +1 -1
  35. package/dist/{MenuBar-B-ZAX9rH.cjs → MenuBar-Lw_5Jp8u.cjs} +2 -2
  36. package/dist/{MenuBar-B-ZAX9rH.cjs.map → MenuBar-Lw_5Jp8u.cjs.map} +1 -1
  37. package/dist/{ModalOverlay-BDsGgv3_.cjs → ModalOverlay-Dh5quv7X.cjs} +2 -2
  38. package/dist/{ModalOverlay-BDsGgv3_.cjs.map → ModalOverlay-Dh5quv7X.cjs.map} +1 -1
  39. package/dist/{ModalOverlay-CLvRNHmp.js → ModalOverlay-Dt0JiW3M.js} +2 -2
  40. package/dist/{ModalOverlay-CLvRNHmp.js.map → ModalOverlay-Dt0JiW3M.js.map} +1 -1
  41. package/dist/{SourceModal-BNI_i4iW.cjs → SourceModal-CHKC5xcv.cjs} +2 -2
  42. package/dist/{SourceModal-BNI_i4iW.cjs.map → SourceModal-CHKC5xcv.cjs.map} +1 -1
  43. package/dist/{SourceModal-MdTGK3Uf.js → SourceModal-ChhNVz7y.js} +2 -2
  44. package/dist/{SourceModal-MdTGK3Uf.js.map → SourceModal-ChhNVz7y.js.map} +1 -1
  45. package/dist/{TablePickerModal-DYODWEA1.js → TablePickerModal-BnZHyMsk.js} +2 -2
  46. package/dist/{TablePickerModal-DYODWEA1.js.map → TablePickerModal-BnZHyMsk.js.map} +1 -1
  47. package/dist/{TablePickerModal-Do1QyoyM.cjs → TablePickerModal-Dr0wUx_h.cjs} +2 -2
  48. package/dist/{TablePickerModal-Do1QyoyM.cjs.map → TablePickerModal-Dr0wUx_h.cjs.map} +1 -1
  49. package/dist/index-Bg_uAWlM.js +3 -0
  50. package/dist/index-Bg_uAWlM.js.map +1 -0
  51. package/dist/index-DL-qBZZU.js +357 -0
  52. package/dist/index-DL-qBZZU.js.map +1 -0
  53. package/dist/index-OfJxpaev.cjs +2 -0
  54. package/dist/index-OfJxpaev.cjs.map +1 -0
  55. package/dist/index-qh1Yzh-l.cjs +2 -0
  56. package/dist/index-qh1Yzh-l.cjs.map +1 -0
  57. package/dist/remyx-react.cjs +1 -1
  58. package/dist/remyx-react.css +1 -1
  59. package/dist/remyx-react.js +1 -1
  60. package/package.json +3 -3
  61. package/dist/index-C720tbJA.js +0 -359
  62. package/dist/index-C720tbJA.js.map +0 -1
  63. package/dist/index-Dc63uIP0.cjs +0 -2
  64. package/dist/index-Dc63uIP0.cjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@remyxjs/core");function t(e){if(!(e=e.toLowerCase().replace(/[^a-z]/g,"")))return 0;if(e.length<=3)return 1;const t=(e=(e=e.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"")).replace(/^y/,"")).match(/[aeiouy]{1,2}/g);return t?t.length:1}function n(e){return e?e.split(new RegExp("(?<=[.!?])\\s+")).map((e=>e.trim())).filter((e=>e.length>0)):[]}function r(e){return e.trim().split(/\s+/).filter((e=>e.length>0))}function o(e){return 0===e.sentences||0===e.words?0:e.words/e.sentences*.39+e.syllables/e.words*11.8-15.59}function s(e){return 0===e.sentences||0===e.words?0:206.835-e.words/e.sentences*1.015-e.syllables/e.words*84.6}function a(e){return 0===e.sentences||0===e.words?0:.4*(e.words/e.sentences+e.complexWords/e.words*100)}function l(e){if(0===e.words)return 0;return.0588*(e.chars/e.words*100)-.296*(e.sentences/e.words*100)-15.8}function i(e){return e<=6?"basic":e<=12?"intermediate":"advanced"}function c(e,c={}){const{wordsPerMinute:u=200,targetWordCount:m=0,maxSentenceLength:d=30,maxParagraphLength:p=150}=c,g=r(e),h=n(e),f=function(e){return e.split(/\n\s*\n/).map((e=>e.trim())).filter((e=>e.length>0))}(e),y=e.replace(/\s/g,"").length;let b=0,x=0;for(const n of g){const e=t(n);b+=e,e>=3&&x++}const v={words:g.length,sentences:h.length,syllables:b,complexWords:x,chars:y},w=o(v),C=s(v),k=a(v),S=l(v),T=i(w),A=g.length/u,_=Math.round(60*A),E=h.map(((e,t)=>({index:t,text:e,wordCount:r(e).length}))).filter((e=>e.wordCount>d)),L=f.map(((e,t)=>({index:t,text:e.substring(0,100)+(e.length>100?"...":""),wordCount:r(e).length}))).filter((e=>e.wordCount>p)),N=m>0?{target:m,current:g.length,percentage:Math.round(g.length/m*100)}:null;return{wordCount:g.length,charCount:y,sentenceCount:h.length,paragraphCount:f.length,syllableCount:b,complexWordCount:x,readability:{fleschKincaid:Math.round(10*w)/10,fleschReadingEase:Math.round(10*C)/10,gunningFog:Math.round(10*k)/10,colemanLiau:Math.round(10*S)/10,vocabularyLevel:T},readingTime:{minutes:Math.ceil(A),seconds:_,wordsPerMinute:u},warnings:{longSentences:E,longParagraphs:L},goalProgress:N}}function u(e,t){if(!e||!t)return{count:0,density:0,positions:[]};const n=r(e),o=t.toLowerCase(),s=[];let a=0;return n.forEach(((e,t)=>{e.toLowerCase()===o&&(a++,s.push(t))})),{count:a,density:n.length>0?Math.round(a/n.length*1e4)/100:0,positions:s}}function m(e,t,n){const o=r(e),s=t.querySelectorAll("h1, h2, h3, h4, h5, h6"),a=t.querySelectorAll("h1").length,l=[];0===a&&l.push("Missing H1 heading"),a>1&&l.push("Multiple H1 headings — consider using only one"),o.length<300&&l.push("Content is short — aim for 300+ words for SEO"),0===s.length&&l.push("No headings — add headings to improve content structure");let i=null;return n&&(i=u(e,n),i.density<.5&&l.push(`Keyword "${n}" density is low (${i.density}%) — aim for 1-3%`),i.density>3&&l.push(`Keyword "${n}" density is high (${i.density}%) — may be over-optimized`)),{wordCount:o.length,headingCount:s.length,h1Count:a,keywordInfo:i,hints:l}}const d=Object.freeze(Object.defineProperty({__proto__:null,AnalyticsPlugin:function(n={}){const{wordsPerMinute:r=200,targetWordCount:s=0,onAnalytics:i,maxSentenceLength:d=30,maxParagraphLength:p=150}=n;let g=null,h=null,f=null,y=null,b=null;function x(){if(!g)return;const e=g.getText();e===b&&y||(b=e,y=c(e,{wordsPerMinute:r,targetWordCount:s,maxSentenceLength:d,maxParagraphLength:p}),g.eventBus.emit("analytics:update",y),i?.(y))}return e.createPlugin({name:"analytics",requiresFullAccess:!0,version:"1.0.0",description:"Readability scores, reading time, vocabulary level, SEO hints",commands:[{name:"toggleAnalytics",execute:e=>(e._analyticsVisible=!e._analyticsVisible,e.eventBus.emit("analytics:toggle",{visible:e._analyticsVisible}),e._analyticsVisible),meta:{icon:"analytics",tooltip:"Toggle Analytics Panel"}},{name:"getAnalytics",execute:e=>c(e.getText(),{wordsPerMinute:r,targetWordCount:s,maxSentenceLength:d,maxParagraphLength:p}),meta:{tooltip:"Get Content Analytics"}},{name:"getSeoAnalysis",execute:(e,t)=>m(e.getText(),e.element,t),meta:{tooltip:"Get SEO Analysis"}},{name:"getKeywordDensity",execute:(e,t)=>u(e.getText(),t),meta:{tooltip:"Get Keyword Density"}}],init(e){g=e,g._analytics={analyzeContent:()=>c(g.getText(),{wordsPerMinute:r,targetWordCount:s,maxSentenceLength:d,maxParagraphLength:p}),seoAnalysis:e=>m(g.getText(),g.element,e),keywordDensity:e=>u(g.getText(),e),getStats:()=>y,countSyllables:t,fleschKincaid:o,gunningFog:a,colemanLiau:l},h=g.eventBus.on("content:change",(()=>{clearTimeout(f),f=setTimeout(x,300)})),x()},destroy(){clearTimeout(f),h?.(),g=null}})},analyzeContent:c,colemanLiau:l,countSyllables:t,fleschKincaid:o,fleschReadingEase:s,gunningFog:a,keywordDensity:u,seoAnalysis:m,splitSentences:n,vocabularyLevel:i},Symbol.toStringTag,{value:"Module"})),p={"Feature Card":'<div class="rmx-template-feature-card" style="border:1px solid #e2e8f0;border-radius:8px;padding:16px;margin:8px 0;">\n <img src="" alt="Feature image" style="width:100%;height:auto;border-radius:4px;margin-bottom:12px;" />\n <h3>Feature Title</h3>\n <p>Describe the feature here. Highlight key benefits and value propositions.</p>\n</div>',"Two-Column":'<div class="rmx-template-two-column" style="display:flex;gap:16px;margin:8px 0;">\n <div style="flex:1;padding:12px;border:1px solid #e2e8f0;border-radius:4px;">\n <p>Left column content</p>\n </div>\n <div style="flex:1;padding:12px;border:1px solid #e2e8f0;border-radius:4px;">\n <p>Right column content</p>\n </div>\n</div>',"Call to Action":'<div class="rmx-template-cta" style="text-align:center;padding:24px;margin:8px 0;background:#f8fafc;border-radius:8px;">\n <h2>Ready to Get Started?</h2>\n <p>Take the next step and join thousands of satisfied users today.</p>\n <p><span style="display:inline-block;padding:10px 24px;background:#6366f1;color:#fff;border-radius:6px;font-weight:600;">Get Started</span></p>\n</div>'};const g=Object.freeze(Object.defineProperty({__proto__:null,BlockTemplatePlugin:function(){const t=new Map;return e.createPlugin({name:"blockTemplates",requiresFullAccess:!0,init(e){for(const[n,r]of Object.entries(p))t.set(n,r);e._blockTemplates={registerTemplate:function(e,n){e&&"string"==typeof n&&t.set(e,n)},insertTemplate:function(n){const r=t.get(n);if(!r)return;e.history.snapshot();const o=e.selection.getRange();if(!o)return;const s=document.createElement("div");s.innerHTML=e.sanitizer.sanitize(r);const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);o.collapsed||o.deleteContents(),o.insertNode(a);const l=e.element;if(!l.lastElementChild||"P"!==l.lastElementChild.tagName){const e=document.createElement("p");e.innerHTML="<br>",l.appendChild(e)}e.eventBus.emit("content:change")},getTemplates:function(){return Array.from(t.entries()).map((([e,t])=>({name:e,html:t})))},removeTemplate:function(e){return t.delete(e)}}},destroy(){t.clear()}})}},Symbol.toStringTag,{value:"Module"})),h=new Map,f=[{type:"info",label:"Info",icon:"ℹ️",color:"#3b82f6"},{type:"warning",label:"Warning",icon:"⚠️",color:"#f59e0b"},{type:"error",label:"Error",icon:"❌",color:"#ef4444"},{type:"success",label:"Success",icon:"✅",color:"#22c55e"},{type:"tip",label:"Tip",icon:"💡",color:"#8b5cf6"},{type:"note",label:"Note",icon:"📝",color:"#6366f1"},{type:"question",label:"Question",icon:"❓",color:"#ec4899"}];for(const qt of f)h.set(qt.type,qt);function y(e){e&&e.type&&h.set(e.type,e)}function b(e){return h.delete(e)}function x(){return Array.from(h.values())}function v(e){return h.get(e)}const w={NOTE:"note",TIP:"tip",IMPORTANT:"info",WARNING:"warning",CAUTION:"error"};function C(e){if(!e)return null;const t=e.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*\n?([\s\S]*)/);if(!t)return null;const n=t[1];return{type:w[n]||n.toLowerCase(),body:t[2].trim()}}function k(e,t="",n={}){const{collapsible:r=!1,collapsed:o=!1,title:s}=n,a=h.get(e)||{label:e,icon:"📌"},l=document.createElement("div");l.className=`rmx-callout rmx-callout-${e}`,l.setAttribute("data-callout",e),r&&(l.setAttribute("data-callout-collapsible",""),o&&l.setAttribute("data-callout-collapsed",""));const i=document.createElement("div");i.className="rmx-callout-header",i.contentEditable="false";const c=document.createElement("span");c.className="rmx-callout-icon",c.textContent=a.icon,i.appendChild(c);const u=document.createElement("span");if(u.className="rmx-callout-title",u.textContent=s||a.label,i.appendChild(u),r){const e=document.createElement("button");e.className="rmx-callout-toggle",e.type="button",e.setAttribute("aria-label",o?"Expand":"Collapse"),e.textContent=o?"▶":"▼",i.appendChild(e)}l.appendChild(i);const m=document.createElement("div");if(m.className="rmx-callout-body",t)m.innerHTML=t;else{const e=document.createElement("p");e.innerHTML="<br>",m.appendChild(e)}return r&&o&&(m.style.display="none"),l.appendChild(m),l}function S(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return null;let r=n.anchorNode;for(3===r.nodeType&&(r=r.parentNode);r&&r!==e.element;){if(r.classList?.contains(t))return r;r=r.parentNode}return null}const T=Object.freeze(Object.defineProperty({__proto__:null,CalloutPlugin:function(){let t=null,n=null,r=null;function o(e){const t=e.target.closest?.(".rmx-callout-toggle");if(!t)return;const n=t.closest(".rmx-callout");if(!n)return;e.preventDefault(),e.stopPropagation();const r=n.querySelector(".rmx-callout-body");if(!r)return;n.hasAttribute("data-callout-collapsed")?(n.removeAttribute("data-callout-collapsed"),r.style.display="",t.textContent="▼",t.setAttribute("aria-label","Collapse")):(n.setAttribute("data-callout-collapsed",""),r.style.display="none",t.textContent="▶",t.setAttribute("aria-label","Expand"))}function s(){if(!t)return;const e=t.element.querySelectorAll("blockquote");for(const n of e){const e=C(n.textContent);if(e){t.history.snapshot();const r=k(e.type,`<p>${e.body||"<br>"}</p>`);n.parentNode.replaceChild(r,n),t.eventBus.emit("content:change")}}}return e.createPlugin({name:"callouts",requiresFullAccess:!0,version:"1.0.0",description:"Styled callout blocks with 7 built-in types, custom types, collapsible toggle, and GFM alert syntax",commands:[{name:"insertCallout",execute(e,t={}){const{type:n="info",content:r="",collapsible:o=!1,collapsed:s=!1,title:a}=t;e.history.snapshot();const l=k(n,r,{collapsible:o,collapsed:s,title:a}),i=window.getSelection();if(i&&i.rangeCount>0&&e.element.contains(i.anchorNode)){let t=i.getRangeAt(0).startContainer;for(;t&&t.parentNode!==e.element;)t=t.parentNode;t?t.parentNode.insertBefore(l,t.nextSibling):e.element.appendChild(l)}else e.element.appendChild(l);const c=l.querySelector(".rmx-callout-body p");if(c){const e=document.createRange();e.selectNodeContents(c),e.collapse(!0),i?.removeAllRanges(),i?.addRange(e)}return e.eventBus.emit("content:change"),l},meta:{icon:"callout",tooltip:"Insert Callout"}},{name:"removeCallout",execute(e){const t=e.selection.getClosestElement?.(".rmx-callout")||S(e,"rmx-callout");if(!t)return;e.history.snapshot();const n=t.querySelector(".rmx-callout-body"),r=t.parentNode;if(n)for(;n.firstChild;)r.insertBefore(n.firstChild,t);r.removeChild(t),r.normalize(),e.eventBus.emit("content:change")},meta:{icon:"remove",tooltip:"Remove Callout"}},{name:"changeCalloutType",execute(e,t){const n=S(e,"rmx-callout");if(!n||!t)return;const r=h.get(t);if(!r)return;e.history.snapshot();const o=n.getAttribute("data-callout");n.classList.remove(`rmx-callout-${o}`),n.classList.add(`rmx-callout-${t}`),n.setAttribute("data-callout",t);const s=n.querySelector(".rmx-callout-icon"),a=n.querySelector(".rmx-callout-title");s&&(s.textContent=r.icon),a&&(a.textContent=r.label),e.eventBus.emit("content:change")},meta:{icon:"swap",tooltip:"Change Callout Type"}},{name:"toggleCalloutCollapse",execute(e){const t=S(e,"rmx-callout");if(!t)return;const n=t.querySelector(".rmx-callout-body"),r=t.querySelector(".rmx-callout-toggle");if(n){if(t.hasAttribute("data-callout-collapsible")){t.hasAttribute("data-callout-collapsed")?(t.removeAttribute("data-callout-collapsed"),n.style.display="",r&&(r.textContent="▼",r.setAttribute("aria-label","Collapse"))):(t.setAttribute("data-callout-collapsed",""),n.style.display="none",r&&(r.textContent="▶",r.setAttribute("aria-label","Expand")))}else if(t.setAttribute("data-callout-collapsible",""),!r){const e=document.createElement("button");e.className="rmx-callout-toggle",e.type="button",e.textContent="▼",e.setAttribute("aria-label","Collapse"),t.querySelector(".rmx-callout-header")?.appendChild(e)}e.eventBus.emit("content:change")}},meta:{icon:"collapse",tooltip:"Toggle Callout Collapse"}}],contextMenuItems:[{label:"Insert Callout",command:"insertCallout"},{label:"Remove Callout",command:"removeCallout",when:e=>!!S(e,"rmx-callout")}],init(e){t=e,t._callouts={getCalloutTypes:x,getCalloutType:v,registerCalloutType:y,unregisterCalloutType:b,parseGFMAlert:C},t.element.addEventListener("click",o);let a=null;r=t.eventBus.on("content:change",(()=>{clearTimeout(a),a=setTimeout(s,300)})),s(),n=new MutationObserver((()=>{const e=t.element.querySelectorAll(".rmx-callout-body");for(const t of e)t.hasAttribute("contenteditable")})),n.observe(t.element,{childList:!0,subtree:!0})},destroy(){n?.disconnect(),n=null,r?.(),t?.element?.removeEventListener("click",o),t=null}})},getCalloutType:v,getCalloutTypes:x,parseGFMAlert:C,registerCalloutType:y,unregisterCalloutType:b},Symbol.toStringTag,{value:"Module"}));function A(e,t,n=0){const r=document.createRange(),o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=0,a=!1;for(;o.nextNode();){const e=o.currentNode,l=e.textContent.length;if(!a&&s+l>=t&&(r.setStart(e,t-s),a=!0,0===n))return r.setEnd(e,t-s),r;if(a&&s+l>=t+n)return r.setEnd(e,t+n-s),r;s+=l}return a||(r.selectNodeContents(e),r.collapse(!1)),r}function _(e,t){const n=document.createRange();n.selectNodeContents(e),n.setEnd(t.startContainer,t.startOffset);return{offset:n.toString().length,length:t.toString().length}}class E{constructor(e){this.userId=e,this._clock={[e]:0},this._pendingOps=[],this._seenOps=new Set,this._maxSeenOps=1e4,this._suppressRemote=!1,this._lastTextContent=null}_trackOp(e){if(this._seenOps.add(e),this._seenOps.size>this._maxSeenOps){const e=this._seenOps.size-this._maxSeenOps,t=this._seenOps.values();for(let n=0;n<e;n++)this._seenOps.delete(t.next().value)}}_tickLocal(){return this._clock[this.userId]=(this._clock[this.userId]||0)+1,{...this._clock}}_merge(e){for(const[t,n]of Object.entries(e))this._clock[t]=Math.max(this._clock[t]||0,n)}captureOperations(e,t){if(this._suppressRemote)return[];const n=t.textContent,r=this._lastTextContent;if(null===r||n===r)return this._lastTextContent=n,[];const o=[],s=this._tickLocal(),a=`${this.userId}-${this._clock[this.userId]}`;if(n.length>r.length){const{position:e,content:t}=this._findInsert(r,n),l={id:a,type:"insert",userId:this.userId,clock:s,timestamp:Date.now(),position:e,content:t};o.push(l),this._trackOp(a)}else if(n.length<r.length){const{position:e,length:t}=this._findDelete(r,n),l={id:a,type:"delete",userId:this.userId,clock:s,timestamp:Date.now(),position:e,length:t};o.push(l),this._trackOp(a)}else{const{position:e,length:t,content:l}=this._findReplace(r,n);if(void 0!==l){const n={id:a,type:"replace",userId:this.userId,clock:s,timestamp:Date.now(),position:e,length:t,content:l};o.push(n),this._trackOp(a)}}return this._lastTextContent=n,o}_findInsert(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;const r=t.length-e.length;return{position:n,content:t.substring(n,n+r)}}_findDelete(e,t){let n=0;for(;n<t.length&&e[n]===t[n];)n++;return{position:n,length:e.length-t.length}}_findReplace(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;if(n>=e.length)return{};let r=e.length-1,o=t.length-1;for(;r>n&&e[r]===t[o];)r--,o--;return{position:n,length:r-n+1,content:t.substring(n,o+1)}}_transformPosition(e,t){if("insert"===t.type){if(t.position<=e)return e+t.content.length}else if("delete"===t.type){if(t.position+t.length<=e)return e-t.length;if(t.position<e)return t.position}else if("replace"===t.type){if(t.position+t.length<=e)return e+(t.content.length-t.length);if(t.position<e)return t.position+t.content.length}return e}applyRemoteOperations(e,t){const n=e.filter((e=>!this._seenOps.has(e.id)));if(0!==n.length){n.sort(((e,t)=>{const n=Object.values(e.clock).reduce(((e,t)=>e+t),0),r=Object.values(t.clock).reduce(((e,t)=>e+t),0);return n!==r?n-r:e.timestamp!==t.timestamp?e.timestamp-t.timestamp:e.userId.localeCompare(t.userId)})),this._suppressRemote=!0;for(const e of n)this._trackOp(e.id),this._applyOp(e,t);this._lastTextContent=t.textContent,this._suppressRemote=!1}}_applyOp(e,t){try{if("insert"===e.type){const n=A(t,e.position);n&&(n.collapse(!0),n.insertNode(document.createTextNode(e.content)),t.normalize())}else if("delete"===e.type){const n=A(t,e.position,e.length);n&&(n.deleteContents(),t.normalize())}else if("replace"===e.type){const n=A(t,e.position,e.length);n&&(n.deleteContents(),n.insertNode(document.createTextNode(e.content)),t.normalize())}}catch(n){}}queueOperation(e){this._pendingOps.push(e)}flushQueue(){const e=[...this._pendingOps];return this._pendingOps=[],e}hasPendingOps(){return this._pendingOps.length>0}initTextContent(e){this._lastTextContent=e.textContent}getState(){return{clock:{...this._clock},pendingOps:this._pendingOps.length,seenOps:this._seenOps.size}}destroy(){this._pendingOps=[],this._seenOps.clear(),this._lastTextContent=null}}class L{constructor(e,t,n){this.userId=e,this._localState={cursor:null,userName:t,userColor:n,status:"active",lastActive:Date.now()},this._remoteStates=new Map,this._broadcastInterval=null,this._idleTimer=null,this._cursorsContainer=null,this._renderRafId=null}updateLocalCursor(e,t){try{const t=window.getSelection();if(!t||0===t.rangeCount||!e.contains(t.anchorNode))return void(this._localState.cursor=null);const n=t.getRangeAt(0);this._localState.cursor=_(e,n),this._localState.lastActive=Date.now()}catch{this._localState.cursor=null}}setStatus(e){this._localState.status=e}resetIdleTimer(){this._localState.status="active",this._localState.lastActive=Date.now(),clearTimeout(this._idleTimer),this._idleTimer=setTimeout((()=>{this._localState.status="idle"}),3e4)}applyRemoteAwareness(e,t){e!==this.userId&&this._remoteStates.set(e,{...t})}removeUser(e){this._remoteStates.delete(e)}getCollaborators(){return Array.from(this._remoteStates.entries()).map((([e,t])=>({userId:e,userName:t.userName,userColor:t.userColor,cursor:t.cursor,status:t.status})))}renderRemoteCursors(e){this._renderRafId&&cancelAnimationFrame(this._renderRafId),this._renderRafId=requestAnimationFrame((()=>{this._doRender(e)}))}_doRender(e){this._cursorsContainer||(this._cursorsContainer=document.createElement("div"),this._cursorsContainer.className="rmx-collab-cursors-container",this._cursorsContainer.setAttribute("aria-hidden","true"),e.parentNode?.insertBefore(this._cursorsContainer,e.nextSibling)),this._cursorsContainer.innerHTML="";const t=e.getBoundingClientRect();let n=0;for(const[r,o]of this._remoteStates)if(o.cursor&&"offline"!==o.status){if(n>=20)break;n++;try{const n=A(e,o.cursor.offset,o.cursor.length);if(!n)continue;const r=n.getClientRects();if(0===r.length)continue;const s=r[0],a=document.createElement("div");a.className="rmx-collab-cursor",a.style.cssText=`\n left: ${s.left-t.left}px;\n top: ${s.top-t.top}px;\n height: ${s.height}px;\n background-color: ${o.userColor};\n `;const l=document.createElement("span");if(l.className="rmx-collab-cursor-label",l.textContent=o.userName,l.style.backgroundColor=o.userColor,a.appendChild(l),this._cursorsContainer.appendChild(a),o.cursor.length>0)for(const e of r){const n=document.createElement("div");n.className="rmx-collab-selection",n.style.cssText=`\n left: ${e.left-t.left}px;\n top: ${e.top-t.top}px;\n width: ${e.width}px;\n height: ${e.height}px;\n background-color: ${o.userColor};\n `,this._cursorsContainer.appendChild(n)}}catch{}}}clearRemoteCursors(e){this._cursorsContainer&&(this._cursorsContainer.innerHTML="")}getLocalState(){return{...this._localState}}startBroadcasting(e,t=1e3){this.stopBroadcasting(),this._broadcastInterval=setInterval((()=>{e(this.getLocalState())}),t)}stopBroadcasting(){this._broadcastInterval&&(clearInterval(this._broadcastInterval),this._broadcastInterval=null)}destroy(){this.stopBroadcasting(),clearTimeout(this._idleTimer),this._renderRafId&&cancelAnimationFrame(this._renderRafId),this._cursorsContainer&&(this._cursorsContainer.remove(),this._cursorsContainer=null),this._remoteStates.clear()}}class N{constructor(e,t={}){this._url=e,this._reconnect=!1!==t.reconnect,this._reconnectInterval=t.reconnectInterval||2e3,this._maxAttempts=t.maxReconnectAttempts||10,this._maxDelay=t.maxReconnectDelay||3e4,this._ws=null,this._messageHandler=null,this._connectHandler=null,this._disconnectHandler=null,this._reconnectTimer=null,this._reconnectAttempts=0,this._intentionalClose=!1}connect(){if(!this._ws||this._ws.readyState!==WebSocket.OPEN){this._intentionalClose=!1,this._reconnectAttempts=0;try{this._ws=new WebSocket(this._url)}catch(e){return void this._scheduleReconnect()}this._ws.onopen=()=>{this._reconnectAttempts=0,this._connectHandler?.()},this._ws.onmessage=t=>{try{const e=JSON.parse(t.data);this._messageHandler?.(e)}catch(e){}},this._ws.onclose=()=>{this._disconnectHandler?.(),!this._intentionalClose&&this._reconnect&&this._scheduleReconnect()},this._ws.onerror=()=>{}}}disconnect(){this._intentionalClose=!0,clearTimeout(this._reconnectTimer),this._reconnectTimer=null,this._ws&&(this._ws.onclose=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onopen=null,this._ws.readyState!==WebSocket.OPEN&&this._ws.readyState!==WebSocket.CONNECTING||this._ws.close(),this._ws=null)}send(e){this._ws&&this._ws.readyState===WebSocket.OPEN&&this._ws.send(JSON.stringify(e))}onMessage(e){this._messageHandler=e}onConnect(e){this._connectHandler=e}onDisconnect(e){this._disconnectHandler=e}isConnected(){return this._ws?.readyState===WebSocket.OPEN}_scheduleReconnect(){if(this._reconnectAttempts>=this._maxAttempts)return;const e=Math.min(this._reconnectInterval*Math.pow(2,this._reconnectAttempts),this._maxDelay);this._reconnectAttempts++,this._reconnectTimer=setTimeout((()=>{this.connect()}),e)}destroy(){this.disconnect(),this._messageHandler=null,this._connectHandler=null,this._disconnectHandler=null}}const R=Object.freeze(Object.defineProperty({__proto__:null,AwarenessProtocol:L,CollaborationPlugin:function(t={}){const{signalingServer:n,transport:r,userId:o=`user-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,userName:s="Anonymous",userColor:a="#6366f1",roomId:l="default",autoConnect:i=!0,broadcastInterval:c=1e3,onUserJoin:u,onUserLeave:m,onSync:d,onConflict:p}=t;let g=null,h=null,f=null,y=null,b=null,x=[],v=!1;function w(e){if(g)switch(e.type){case"op":{if(e.userId===o)return;const t=window.getSelection();let n=null;if(t&&t.rangeCount>0&&g.element.contains(t.anchorNode))try{const e=t.getRangeAt(0);n={startOffset:e.startOffset,startContainer:e.startContainer}}catch{}if(g._isRemoteOperation=!0,f.applyRemoteOperations(e.operations,g.element),f._merge(e.clock),g._isRemoteOperation=!1,n)try{const e=document.createRange();e.setStart(n.startContainer,Math.min(n.startOffset,n.startContainer.length||0)),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}catch{}g.eventBus.emit("collab:sync",{userId:e.userId,opCount:e.operations.length}),g.eventBus.emit("content:change"),d?.({userId:e.userId,operations:e.operations});break}case"awareness":if(e.userId===o)return;y.applyRemoteAwareness(e.userId,e.state),y.renderRemoteCursors(g.element);break;case"join":if(e.userId===o)return;y.applyRemoteAwareness(e.userId,{userName:e.userName,userColor:e.userColor,status:"active",cursor:null,lastActive:Date.now()}),g.eventBus.emit("collab:userJoin",{userId:e.userId,userName:e.userName}),u?.({userId:e.userId,userName:e.userName});break;case"leave":if(e.userId===o)return;y.removeUser(e.userId),y.renderRemoteCursors(g.element),g.eventBus.emit("collab:userLeave",{userId:e.userId}),m?.({userId:e.userId});break;case"sync-request":if(e.userId===o)return;h?.send({type:"sync-response",roomId:l,userId:o,html:g.getHTML(),clock:f._clock});break;case"sync-response":if(e.userId===o)return;Object.entries(e.clock).some((([e,t])=>(f._clock[e]||0)<t))&&(g._isRemoteOperation=!0,g.setHTML(e.html),f._merge(e.clock),f.initTextContent(g.element),g._isRemoteOperation=!1,g.eventBus.emit("content:change"));break}}function C(){h&&!v&&(h.onMessage(w),h.onConnect((()=>{v=!0,h.send({type:"join",roomId:l,userId:o,userName:s,userColor:a}),h.send({type:"sync-request",roomId:l,userId:o,clock:f._clock});const e=f.flushQueue();e.length>0&&h.send({type:"op",roomId:l,userId:o,clock:f._clock,operations:e,timestamp:Date.now()}),y.setStatus("active"),y.startBroadcasting((e=>{h.send({type:"awareness",roomId:l,userId:o,state:e})}),c),g?.eventBus.emit("collab:connected")})),h.onDisconnect((()=>{v=!1,y.setStatus("offline"),y.stopBroadcasting(),g&&(y.clearRemoteCursors(g.element),g.eventBus.emit("collab:disconnected"))})),h.connect())}function k(){h&&(v&&h.send({type:"leave",roomId:l,userId:o}),y.stopBroadcasting(),g&&y.clearRemoteCursors(g.element),h.disconnect(),v=!1)}function S(){return h?h.isConnected()?"connected":"disconnected":"unconfigured"}function T(e){e.userName&&(y._localState.userName=e.userName),e.userColor&&(y._localState.userColor=e.userColor)}return e.createPlugin({name:"collaboration",version:"1.0.0",description:"Real-time collaborative editing with CRDT-inspired conflict resolution, live cursors, and configurable transport",requiresFullAccess:!0,commands:[{name:"startCollaboration",execute(){C()},meta:{icon:"collaboration",tooltip:"Start Collaboration"}},{name:"stopCollaboration",execute(){k()},meta:{icon:"collaboration",tooltip:"Stop Collaboration"}},{name:"getCollaborators",execute:()=>y?.getCollaborators()??[],meta:{tooltip:"Get Collaborators"}},{name:"setUserInfo",execute(e,t){T(t)},meta:{tooltip:"Set User Info"}}],init(e){g=e,f=new E(o),y=new L(o,s,a),r?h=r:n&&(h=new N(n)),f.initTextContent(g.element),g._collaboration={startCollaboration:C,stopCollaboration:k,getCollaborators:()=>y.getCollaborators(),isConnected:()=>h?.isConnected()??!1,getConnectionStatus:S,setUserInfo:T,getCrdtState:()=>f.getState(),userId:o,userName:s,userColor:a},b=new MutationObserver((e=>{if(f._suppressRemote||g._isRemoteOperation)return;const t=f.captureOperations(e,g.element);t.length>0&&(h?.isConnected()?h.send({type:"op",roomId:l,userId:o,clock:{...f._clock},operations:t,timestamp:Date.now()}):t.forEach((e=>f.queueOperation(e))))})),b.observe(g.element,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0});const t=g.eventBus.on("selection:change",(()=>{y.updateLocalCursor(g.element,g.selection),y.resetIdleTimer()}));x.push(t);const c=g.eventBus.on("content:change",(()=>{y.renderRemoteCursors(g.element)}));x.push(c),i&&h&&C()},destroy(){k(),b?.disconnect(),b=null;for(const e of x)e?.();x=[],f?.destroy(),y?.destroy(),h&&!r&&h.destroy?.(),g=null,h=null,f=null,y=null}})},CrdtEngine:E,WebSocketTransport:N,offsetToRange:A,rangeToOffset:_},Symbol.toStringTag,{value:"Module"}));let I=1;function O(){return`rmx-comment-${Date.now()}-${I++}`}function B(e){if(!e)return[];const t=e.match(/@([\w.-]+)/g);return t?t.map((e=>e.slice(1))):[]}const M=Object.freeze(Object.defineProperty({__proto__:null,CommentsPlugin:function(t={}){const{onComment:n,onResolve:r,onDelete:o,onReply:s,mentionUsers:a=[],commentOnly:l=!1}=t,i=new Map;let c=null,u=null,m=null,d=null;function p(){return Array.from(i.values()).sort(((e,t)=>t.createdAt-e.createdAt))}function g(e){return i.get(e)}function h(){return p().filter((e=>!e.resolved))}function f(){return p().filter((e=>e.resolved))}function y({author:e="Anonymous",body:t=""}={}){if(!c)return null;const r=window.getSelection();if(!r||r.isCollapsed||0===r.rangeCount)return null;const o=r.getRangeAt(0);if(!c.element.contains(o.commonAncestorContainer))return null;const s=O(),a=Date.now(),l={id:s,author:e,body:t,mentions:B(t),resolved:!1,createdAt:a,updatedAt:a,replies:[]};c.history.snapshot();const u=document.createElement("mark");u.className="rmx-comment",u.setAttribute("data-comment-id",s),u.setAttribute("data-comment-resolved","false"),u.setAttribute("title",`${e}: ${t}`);try{o.surroundContents(u)}catch{const e=o.extractContents();u.appendChild(e),o.insertNode(u)}return r.removeAllRanges(),i.set(s,l),c.eventBus.emit("comment:created",{thread:l}),c.eventBus.emit("content:change"),n?.(l),l}function b(e,{author:t="Anonymous",body:n=""}={}){const r=i.get(e);if(!r)return null;const o={id:O(),author:t,body:n,mentions:B(n),createdAt:Date.now()};return r.replies.push(o),r.updatedAt=Date.now(),c?.eventBus.emit("comment:replied",{thread:r,reply:o}),s?.({thread:r,reply:o}),o}function x(e,t=!0){const n=i.get(e);if(!n)return;n.resolved=t,n.updatedAt=Date.now();const o=c?.element.querySelector(`[data-comment-id="${e}"]`);o&&(o.setAttribute("data-comment-resolved",String(t)),t?o.classList.add("rmx-comment-resolved"):o.classList.remove("rmx-comment-resolved")),c?.eventBus.emit("comment:resolved",{thread:n,resolved:t}),r?.({thread:n,resolved:t})}function v(e){const t=i.get(e);if(!t)return;const n=c?.element.querySelector(`[data-comment-id="${e}"]`);if(n){c.history.snapshot();const e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n),e.normalize(),c.eventBus.emit("content:change")}i.delete(e),c?.eventBus.emit("comment:deleted",{thread:t}),o?.(t)}function w(e,t){const n=i.get(e);if(!n)return;n.body=t,n.mentions=B(t),n.updatedAt=Date.now();const r=c?.element.querySelector(`[data-comment-id="${e}"]`);r&&r.setAttribute("title",`${n.author}: ${t}`),c?.eventBus.emit("comment:updated",{thread:n})}function C(e){const t=c?.element.querySelector(`[data-comment-id="${e}"]`);if(!t)return;t.scrollIntoView?.({behavior:"smooth",block:"center"});const n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),n.removeAllRanges(),n.addRange(r),c?.eventBus.emit("comment:navigated",{threadId:e})}function k(e){for(const t of e)i.set(t.id,{...t});c?.eventBus.emit("comment:imported",{count:e.length})}function S(){return p().map((e=>({...e,replies:[...e.replies]})))}function T(){if(c)for(const[e]of i){c.element.querySelector(`[data-comment-id="${e}"]`)||i.delete(e)}}function A(){return[...a]}return e.createPlugin({name:"comments",requiresFullAccess:!0,commands:[{name:"addComment",execute:(e,t)=>y(t),isEnabled(e){const t=window.getSelection();return t&&!t.isCollapsed&&e.element.contains(t.anchorNode)},meta:{icon:"comment",tooltip:"Add Comment"}},{name:"deleteComment",execute(e,t){v(t)},meta:{icon:"trash",tooltip:"Delete Comment"}},{name:"resolveComment",execute(e,t,n){x(t,n)},meta:{icon:"check",tooltip:"Resolve Comment"}},{name:"replyToComment",execute:(e,t,n)=>b(t,n),meta:{icon:"reply",tooltip:"Reply to Comment"}},{name:"editComment",execute(e,t,n){w(t,n)},meta:{icon:"edit",tooltip:"Edit Comment"}},{name:"navigateToComment",execute(e,t){C(t)},meta:{icon:"navigate",tooltip:"Go to Comment"}}],contextMenuItems:[{label:"Add Comment",command:"addComment",when:e=>{const t=window.getSelection();return t&&!t.isCollapsed}}],init(e){c=e,c._comments={addComment:y,deleteComment:v,resolveComment:x,replyToComment:b,editComment:w,navigateToComment:C,getAllThreads:p,getThread:g,getUnresolvedThreads:h,getResolvedThreads:f,importThreads:k,exportThreads:S,syncWithDOM:T,getMentionUsers:A},l&&(c.element.setAttribute("contenteditable","false"),c.element.classList.add("rmx-comment-only"));const t=c.element.querySelectorAll("[data-comment-id]");for(const n of t){const e=n.getAttribute("data-comment-id");i.has(e)||i.set(e,{id:e,author:"Imported",body:n.getAttribute("title")||"",mentions:[],resolved:"true"===n.getAttribute("data-comment-resolved"),createdAt:Date.now(),updatedAt:Date.now(),replies:[]})}u=c.eventBus.on("content:change",(()=>{clearTimeout(d),d=setTimeout(T,100)})),c.element.addEventListener("click",_),m=c.eventBus.on("destroy",E)},destroy(){E()}});function _(e){const t=e.target.closest?.("[data-comment-id]");if(t){const e=t.getAttribute("data-comment-id"),n=i.get(e);n&&c.eventBus.emit("comment:clicked",{thread:n,element:t})}}function E(){clearTimeout(d),d=null,u?.(),m?.(),c?.element?.removeEventListener("click",_),l&&c?.element&&(c.element.removeAttribute("contenteditable"),c.element.classList.remove("rmx-comment-only")),c=null}},parseMentions:B},Symbol.toStringTag,{value:"Module"})),D="rmx-drop-zone",q="rmx-drop-zone-active",P="rmx-drop-indicator",$="rmx-dragging";function H(e,t){const n=Array.from(e.children).filter((e=>!e.classList.contains(P)&&!e.classList.contains(D)));let r=null,o=1/0,s="after";for(const a of n){const e=a.getBoundingClientRect(),n=e.top+e.height/2,l=Math.abs(t-n);l<o&&(o=l,r=a,s=t<n?"before":"after")}return{element:r,position:s}}function j(e,t){let n=e;for(;n&&n!==t&&n.parentNode!==t;)n=n.parentNode;return n!==t?n:null}const z=Object.freeze(Object.defineProperty({__proto__:null,DragDropPlugin:function(t={}){const{onDrop:n,onFileDrop:r,allowExternalDrop:o=!0,showDropZone:s=!0,enableReorder:a=!0}=t;let l=null,i=null,c=null,u=null;function m(e){if(!l||!a)return;const t=j(e.target,l.element);t&&(c=t,t.classList.add($),u=t.cloneNode(!0),u.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0.6;pointer-events:none;max-width:400px;",document.body.appendChild(u),e.dataTransfer.setDragImage(u,20,20),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/x-remyx-block","true"),e.dataTransfer.setData("text/html",t.outerHTML))}function d(e){if(l&&(e.preventDefault(),e.dataTransfer.dropEffect="move",s&&l.element.classList.add(q),a&&i)){const{element:t,position:n}=H(l.element,e.clientY);if(t){const e=t.getBoundingClientRect(),r=l.element.getBoundingClientRect(),o="before"===n?e.top-r.top-2:e.bottom-r.top+1;i.style.top=`${o}px`,i.style.display="block"}}}function p(e){l&&(l.element.contains(e.relatedTarget)||(l.element.classList.remove(q),i&&(i.style.display="none")))}function g(e){if(!l)return;if(e.preventDefault(),l.element.classList.remove(q),i&&(i.style.display="none"),l.history.snapshot(),c&&l.element.contains(c)){const{element:t,position:r}=H(l.element,e.clientY);return t&&t!==c&&("before"===r?t.before(c):t.after(c),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:reorder",{block:c})),f(),void n?.(e,{type:"reorder"})}if(e.dataTransfer.getData("text/x-remyx-block")){const t=e.dataTransfer.getData("text/html");if(t){const{element:r,position:o}=H(l.element,e.clientY),s=document.createElement("div");s.innerHTML=t;const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);r?"before"===o?r.before(a):r.after(a):l.element.appendChild(a),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:crossEditor",{}),n?.(e,{type:"crossEditor",html:t})}f()}else{if(o&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r?.(t),l.eventBus.emit("dragdrop:fileDrop",{files:t});for(const n of t)if(n.type.startsWith("image/")){const t=new FileReader;t.onload=()=>{const n=document.createElement("img");n.src=t.result,n.style.maxWidth="100%";const{element:r,position:o}=H(l.element,e.clientY);r?"before"===o?r.before(n):r.after(n):l.element.appendChild(n),l.eventBus.emit("content:change")},t.readAsDataURL(n)}return f(),void n?.(e,{type:"file",files:t})}if(o){const t=e.dataTransfer.getData("text/html"),r=e.dataTransfer.getData("text/plain"),o=t||(r?`<p>${r.replace(/\n/g,"</p><p>")}</p>`:"");if(o){const{element:t,position:r}=H(l.element,e.clientY),s=document.createElement("div");s.innerHTML=o;const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);t?"before"===r?t.before(a):t.after(a):l.element.appendChild(a),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:externalDrop",{html:o}),n?.(e,{type:"external",html:o})}}f()}}function h(){f()}function f(){c&&(c.classList.remove($),c=null),u&&(u.remove(),u=null),l?.element?.classList.remove(q),i&&(i.style.display="none")}function y(e){if(!l||!a)return;const t=j(e.target,l.element);if(!t)return;const n=t.getBoundingClientRect();e.clientX-n.left<30&&(t.draggable=!0,t.addEventListener("dragend",(()=>{t.draggable=!1}),{once:!0}))}return e.createPlugin({name:"dragDrop",requiresFullAccess:!0,version:"1.0.0",description:"Drop zones, cross-editor drag, file drops, block reorder, ghost previews",commands:[{name:"moveBlockUp",execute(e){const t=e.selection?.getParentBlock?.();if(!t)return;let n=t;for(;n.parentNode!==e.element;)n=n.parentNode;const r=n.previousElementSibling;r&&(e.history.snapshot(),r.before(n),e.eventBus.emit("content:change"))},shortcut:"mod+shift+ArrowUp",meta:{icon:"arrow-up",tooltip:"Move Block Up"}},{name:"moveBlockDown",execute(e){const t=e.selection?.getParentBlock?.();if(!t)return;let n=t;for(;n.parentNode!==e.element;)n=n.parentNode;const r=n.nextElementSibling;r&&(e.history.snapshot(),r.after(n),e.eventBus.emit("content:change"))},shortcut:"mod+shift+ArrowDown",meta:{icon:"arrow-down",tooltip:"Move Block Down"}}],init(e){l=e,a&&(i=function(){const e=document.createElement("div");return e.className=P,e.style.cssText="position:absolute;left:0;right:0;height:3px;background:var(--rmx-primary,#6366f1);border-radius:2px;pointer-events:none;z-index:100;transition:top 0.1s ease;",e}(),i.style.display="none",l.element.style.position="relative",l.element.appendChild(i)),l.element.addEventListener("dragstart",m),l.element.addEventListener("dragover",d),l.element.addEventListener("dragleave",p),l.element.addEventListener("drop",g),l.element.addEventListener("dragend",h),l.element.addEventListener("mousedown",y),s&&l.element.classList.add(D),l._dragDrop={getDropTarget:e=>H(l.element,e)}},destroy(){l?.element?.removeEventListener("dragstart",m),l?.element?.removeEventListener("dragover",d),l?.element?.removeEventListener("dragleave",p),l?.element?.removeEventListener("drop",g),l?.element?.removeEventListener("dragend",h),l?.element?.removeEventListener("mousedown",y),i?.remove(),f(),l?.element?.classList.remove(D,q),l=null}})}},Symbol.toStringTag,{value:"Module"})),F={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},W=new Set(Object.values(F)),U="normal",G="insert",V="visual";function K(){return{mode:U,pending:""}}const J={"ctrl+a":"moveToLineStart","ctrl+e":"moveToLineEnd","ctrl+k":"killToLineEnd","ctrl+y":"yank","ctrl+w":"killWord","ctrl+f":"moveForward","ctrl+b":"moveBackward","ctrl+n":"moveDown","ctrl+p":"moveUp","ctrl+d":"deleteForward","ctrl+h":"deleteBackward","ctrl+space":"setMark"};function Z(e){const t=e.querySelectorAll("h1, h2, h3, h4, h5, h6");return Array.from(t).map((e=>({level:parseInt(e.tagName.charAt(1),10),text:e.textContent,element:e})))}function X(e){const t=window.getSelection();if(!t||0===t.rangeCount)return 0;const n=t.toString();if(!n)return 0;const r=t.getRangeAt(t.rangeCount-1).endOffset,o=e.textContent,s=o.indexOf(n,-1===o.indexOf(n,r)?0:r+1);if(-1===s)return t.rangeCount;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=0;for(;a.nextNode();){const e=a.currentNode,r=e.textContent.length;if(l+r>s){const o=s-l,a=document.createRange();a.setStart(e,o),a.setEnd(e,Math.min(o+n.length,r)),t.addRange(a);break}l+=r}return t.rangeCount}const Y=Object.freeze(Object.defineProperty({__proto__:null,KeyboardPlugin:function(t={}){const{mode:n="default",keyBindings:r={},autoPair:o=!0,jumpToHeading:s=!0}=t;let a=null,l=null,i="";function c(e){if(!a)return;if("vim"===n&&l)return void function(e){if(l.mode===G)return"Escape"===e.key?(e.preventDefault(),l.mode=U,a.element.classList.remove("rmx-vim-insert"),a.element.classList.add("rmx-vim-normal"),void a.eventBus.emit("vim:modeChange",{mode:U})):void(o&&u(e));e.preventDefault();const t=window.getSelection();switch(e.key){case"i":l.mode=G,a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:G});break;case"a":if(l.mode=G,t&&t.rangeCount>0){t.getRangeAt(0).collapse(!1)}a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:G});break;case"v":l.mode=V,a.element.classList.add("rmx-vim-visual"),a.eventBus.emit("vim:modeChange",{mode:V});break;case"Escape":l.mode===V&&(l.mode=U,a.element.classList.remove("rmx-vim-visual"),t?.collapseToStart(),a.eventBus.emit("vim:modeChange",{mode:U}));break;case"h":t?.modify("move","backward","character");break;case"l":t?.modify("move","forward","character");break;case"j":t?.modify("move","forward","line");break;case"k":t?.modify("move","backward","line");break;case"w":t?.modify("move","forward","word");break;case"b":t?.modify("move","backward","word");break;case"0":t?.modify("move","backward","lineboundary");break;case"$":t?.modify("move","forward","lineboundary");break;case"G":if(t&&a.element.lastChild){const e=document.createRange();e.selectNodeContents(a.element.lastChild),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}break;case"u":a.executeCommand("undo");break;case"x":a.history.snapshot(),document.execCommand("delete");break;case"d":if("d"===l.pending){l.pending="",a.history.snapshot();const e=a.selection?.getParentBlock?.();e&&e.remove(),a.eventBus.emit("content:change")}else l.pending="d";break;case"o":a.history.snapshot();{const e=a.selection?.getParentBlock?.()||a.element.lastChild,n=document.createElement("p");n.innerHTML="<br>",e?.after(n);const r=document.createRange();r.selectNodeContents(n),r.collapse(!0),t?.removeAllRanges(),t?.addRange(r)}l.mode=G,a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:G}),a.eventBus.emit("content:change");break;default:l.pending=""}}(e);"emacs"===n&&function(e){if(!e.ctrlKey)return;const t=`ctrl+${e.key}`,n=J[t];if(!n)return;e.preventDefault();const r=window.getSelection(),o=r?.rangeCount>0?r.getRangeAt(0):null;switch(n){case"moveToLineStart":r?.modify("move","backward","lineboundary");break;case"moveToLineEnd":r?.modify("move","forward","lineboundary");break;case"moveForward":r?.modify("move","forward","character");break;case"moveBackward":r?.modify("move","backward","character");break;case"moveDown":r?.modify("move","forward","line");break;case"moveUp":r?.modify("move","backward","line");break;case"deleteForward":document.execCommand("forwardDelete");break;case"deleteBackward":document.execCommand("delete");break;case"killToLineEnd":o&&(a.history.snapshot(),r.modify("extend","forward","lineboundary"),i=r.toString(),o.deleteContents(),a.eventBus.emit("content:change"));break;case"yank":i&&o&&(a.history.snapshot(),o.insertNode(document.createTextNode(i)),o.collapse(!1),a.eventBus.emit("content:change"));break;case"killWord":o&&(a.history.snapshot(),r.modify("extend","backward","word"),i=r.toString(),o.deleteContents(),a.eventBus.emit("content:change"))}}(e);const t=function(e){const t=[];e.ctrlKey&&t.push("ctrl");e.metaKey&&t.push("cmd");e.altKey&&t.push("alt");e.shiftKey&&t.push("shift");1===e.key.length?t.push(e.key.toLowerCase()):t.push(e.key);return t.join("+")}(e);if(!r[t]){if(o&&"vim"!==n&&u(e),s){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"g"===e.key)return e.preventDefault(),void a.eventBus.emit("keyboard:jumpToHeading")}return!e.metaKey&&!e.ctrlKey||"d"!==e.key||e.shiftKey?void 0:(e.preventDefault(),void X(a.element))}{e.preventDefault();const n=r[t];"function"==typeof n?n(a):"string"==typeof n&&a.executeCommand(n)}}function u(e){if(1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey)return;const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);if(F[e.key]){const r=F[e.key];if(!n.collapsed){e.preventDefault();const t=n.toString();return n.deleteContents(),void n.insertNode(document.createTextNode(e.key+t+r))}e.preventDefault();const o=document.createTextNode(e.key+r);return n.insertNode(o),n.setStart(o,1),n.setEnd(o,1),t.removeAllRanges(),t.addRange(n),void a.eventBus.emit("content:change")}if(W.has(e.key)&&n.collapsed){const r=n.startContainer;if(3===r.nodeType&&r.textContent.charAt(n.startOffset)===e.key)return e.preventDefault(),n.setStart(r,n.startOffset+1),n.collapse(!0),t.removeAllRanges(),void t.addRange(n)}}return e.createPlugin({name:"keyboard",requiresFullAccess:!0,version:"1.0.0",description:"Vim/Emacs modes, auto-pairing, multi-cursor, jump-to-heading",commands:[{name:"setKeyboardMode",execute(e,t){"vim"===t?(l=K(),e.element.classList.add("rmx-vim-normal"),e.eventBus.emit("vim:modeChange",{mode:U})):(l=null,e.element.classList.remove("rmx-vim-normal","rmx-vim-insert","rmx-vim-visual")),e.eventBus.emit("keyboard:modeChange",{mode:t})},meta:{tooltip:"Set Keyboard Mode"}},{name:"getVimMode",execute:()=>l?.mode||null,meta:{tooltip:"Get Vim Mode"}},{name:"jumpToHeading",execute(e,t){!function(e,t){const n=Z(e);if(t<0||t>=n.length)return;const r=n[t];r.element.scrollIntoView?.({behavior:"smooth",block:"center"});const o=window.getSelection(),s=document.createRange();s.selectNodeContents(r.element),s.collapse(!0),o.removeAllRanges(),o.addRange(s)}(e.element,t)},meta:{icon:"heading",tooltip:"Jump to Heading"}},{name:"getHeadings",execute:e=>Z(e.element),meta:{tooltip:"Get Headings"}},{name:"selectNextOccurrence",execute:e=>X(e.element),shortcut:"mod+d",meta:{tooltip:"Select Next Occurrence"}}],init(e){a=e,"vim"===n&&(l=K(),a.element.classList.add("rmx-vim-normal")),a.element.addEventListener("keydown",c,!0),a._keyboard={getHeadings:()=>Z(a.element),getVimMode:()=>l?.mode||null,selectNextOccurrence:()=>X(a.element)}},destroy(){a?.element?.removeEventListener("keydown",c,!0),a?.element?.classList.remove("rmx-vim-normal","rmx-vim-insert","rmx-vim-visual"),l=null,a=null}})},getHeadings:Z,selectNextOccurrence:X},Symbol.toStringTag,{value:"Module"})),Q=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,ee=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,te=/(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g;function ne(e){const t=[];let n;for(Q.lastIndex=0;null!==(n=Q.exec(e));)t.push({type:"url",value:n[0],index:n.index});for(ee.lastIndex=0;null!==(n=ee.exec(e));){const e=n.index;t.some((t=>e>=t.index&&e<t.index+t.value.length))||t.push({type:"email",value:n[0],index:n.index})}for(te.lastIndex=0;null!==(n=te.exec(e));)t.push({type:"phone",value:n[0],index:n.index});return t.sort(((e,t)=>e.index-t.index))}function re(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"anchor"}let oe=null;function se(){oe&&(oe.remove(),oe=null)}function ae(t){return t?e.escapeHTMLAttr(t):""}const le=Object.freeze(Object.defineProperty({__proto__:null,LinkPlugin:function(t={}){const{onLinkClick:n,onUnfurl:r,onSuggest:o,onBrokenLink:s,validateLink:a,scanInterval:l=6e4,autoLink:i=!0,showPreviews:c=!0}=t;let u=null,m=null,d=null,p=null;const g=new Map,h=new Set;function f(e){if(!i||!u)return;if(" "!==e.key&&"Enter"!==e.key)return;const t=window.getSelection();if(!t||0===t.rangeCount||!t.isCollapsed)return;const n=t.getRangeAt(0),r=n.startContainer;if(3!==r.nodeType)return;if(r.parentElement?.closest("a"))return;if(!u.element.contains(r))return;const o=ne(r.textContent.substring(0,n.startOffset));if(0===o.length)return;const s=o[o.length-1],a=s.index+s.value.length;if(a!==n.startOffset)return;e.preventDefault(),u.history.snapshot();const l="email"===(c=s).type?`mailto:${c.value}`:"phone"===c.type?`tel:${c.value.replace(/[^\d+]/g,"")}`:c.value.startsWith("www.")?`https://${c.value}`:c.value;var c;const m=document.createRange();m.setStart(r,s.index),m.setEnd(r,a);const d=document.createElement("a");d.href=l,d.target="_blank",d.rel="noopener noreferrer",d.textContent=s.value,m.deleteContents(),m.insertNode(d);const p=document.createTextNode(" "===e.key?" ":"");if(d.after(p),"Enter"===e.key){const e=document.createElement("br");d.after(e);const n=document.createTextNode("");e.after(n);const r=document.createRange();r.setStart(n,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r)}else{const e=document.createRange();e.setStartAfter(p),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}r.parentNode?.normalize(),u.eventBus.emit("content:change")}function y(e){const t=e.target.closest?.("a[href]");t&&u?.element.contains(t)&&n&&n({href:t.href,text:t.textContent,target:t.target,timestamp:Date.now(),element:t})}function b(e){if(!c||!r)return;const t=e.target.closest?.("a[href]");t&&u?.element.contains(t)&&(clearTimeout(d),d=setTimeout((async()=>{const e=t.href;try{let n=g.get(e);n||(n=await r(e),n&&g.set(e,n)),n&&function(e,t,n){se();const r=e.getBoundingClientRect(),o=n.getBoundingClientRect();oe=document.createElement("div"),oe.className="rmx-link-preview",oe.innerHTML=`\n ${t.image?`<img class="rmx-link-preview-img" src="${t.image}" alt="" />`:""}\n <div class="rmx-link-preview-text">\n <div class="rmx-link-preview-title">${ae(t.title||e.href)}</div>\n ${t.description?`<div class="rmx-link-preview-desc">${ae(t.description)}</div>`:""}\n <div class="rmx-link-preview-url">${ae(e.href)}</div>\n </div>\n `,oe.style.position="absolute",oe.style.left=r.left-o.left+"px",oe.style.top=r.bottom-o.top+4+"px",n.style.position="relative",n.appendChild(oe)}(t,n,u.element)}catch{}}),400))}function x(e){const t=e.target.closest?.("a[href]");t&&(clearTimeout(d),se())}async function v(){if(!u||!a)return;const e=u.element.querySelectorAll("a[href]"),t=new Set,n=[];for(const r of e){const e=r.href;t.has(e)||e.startsWith("mailto:")||e.startsWith("tel:")||e.startsWith("#")||(t.add(e),n.push({url:e,anchor:r}))}for(let r=0;r<n.length;r+=5){const e=n.slice(r,r+5);await Promise.all(e.map((async({url:e,anchor:t})=>{try{await a(e)?(h.delete(e),t.classList.remove("rmx-link-broken"),t.removeAttribute("data-link-broken")):(h.add(e),t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"),s?.(e,t))}catch{h.add(e),t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"),s?.(e,t)}})))}u.eventBus.emit("link:scanComplete",{total:t.size,broken:h.size})}function w(){if(!u||0===h.size)return;const e=u.element.querySelectorAll("a[href]");for(const t of e)h.has(t.href)&&(t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"))}return e.createPlugin({name:"advancedLinks",requiresFullAccess:!0,version:"1.0.0",description:"Link previews, broken link detection, auto-linking, analytics, bookmarks",commands:[{name:"insertBookmark",execute(e,t={}){const{name:n,id:r}=t,o=r||re(n||"bookmark");e.history.snapshot();const s=window.getSelection();if(!s||0===s.rangeCount)return;const a=s.getRangeAt(0),l=document.createElement("a");l.id=o,l.className="rmx-bookmark",l.setAttribute("data-bookmark",o),l.textContent=n?`📌 ${n}`:`📌 ${o}`,l.contentEditable="false",a.collapse(!0),a.insertNode(l);const i=document.createTextNode(" ");return l.after(i),e.eventBus.emit("content:change"),e.eventBus.emit("bookmark:created",{id:o,name:n}),l},meta:{icon:"bookmark",tooltip:"Insert Bookmark Anchor"}},{name:"linkToBookmark",execute(e,t){if(!t)return;const n=e.selection;if(!n.getSelectedText())return;e.history.snapshot();const r=n.wrapWith("a",{href:`#${t}`});r&&r.classList.add("rmx-internal-link"),e.eventBus.emit("content:change")},meta:{icon:"link",tooltip:"Link to Bookmark"}},{name:"getBookmarks",execute(e){const t=e.element.querySelectorAll("[data-bookmark]");return Array.from(t).map((e=>({id:e.getAttribute("data-bookmark"),name:e.textContent.replace(/^\u{1F4CC}\s*/u,""),element:e})))},meta:{tooltip:"List Bookmarks"}},{name:"removeBookmark",execute(e,t){const n=e.element.querySelector(`[data-bookmark="${t}"]`);n&&(e.history.snapshot(),n.remove(),e.eventBus.emit("content:change"),e.eventBus.emit("bookmark:deleted",{id:t}))},meta:{icon:"trash",tooltip:"Remove Bookmark"}},{name:"scanBrokenLinks",execute(){v()},meta:{icon:"scan",tooltip:"Scan for Broken Links"}},{name:"getBrokenLinks",execute:()=>Array.from(h),meta:{tooltip:"Get Broken Links"}}],contextMenuItems:[{label:"Insert Bookmark Here",command:"insertBookmark"}],init(e){u=e,u._links={detectLinks:ne,slugify:re,getBrokenLinks:()=>Array.from(h),getBookmarks:()=>{const e=u.element.querySelectorAll("[data-bookmark]");return Array.from(e).map((e=>({id:e.getAttribute("data-bookmark"),name:e.textContent.replace(/^\u{1F4CC}\s*/u,"")})))},scanForBrokenLinks:v,clearUnfurlCache:()=>g.clear()},i&&u.element.addEventListener("keydown",f),u.element.addEventListener("click",y),c&&r&&(u.element.addEventListener("mouseover",b),u.element.addEventListener("mouseout",x)),a&&l>0&&(m=setInterval(v,l),setTimeout(v,2e3)),p=u.eventBus.on("content:change",w)},destroy(){i&&u?.element?.removeEventListener("keydown",f),u?.element?.removeEventListener("click",y),u?.element?.removeEventListener("mouseover",b),u?.element?.removeEventListener("mouseout",x),se(),clearTimeout(d),clearInterval(m),p?.(),g.clear(),h.clear(),u=null}})},detectLinks:ne,slugify:re},Symbol.toStringTag,{value:"Module"})),ie=[{category:"Greek",symbols:[{label:"α",latex:"\\alpha"},{label:"β",latex:"\\beta"},{label:"γ",latex:"\\gamma"},{label:"δ",latex:"\\delta"},{label:"ε",latex:"\\epsilon"},{label:"θ",latex:"\\theta"},{label:"λ",latex:"\\lambda"},{label:"μ",latex:"\\mu"},{label:"π",latex:"\\pi"},{label:"σ",latex:"\\sigma"},{label:"φ",latex:"\\phi"},{label:"ω",latex:"\\omega"},{label:"Δ",latex:"\\Delta"},{label:"Σ",latex:"\\Sigma"},{label:"Ω",latex:"\\Omega"}]},{category:"Operators",symbols:[{label:"±",latex:"\\pm"},{label:"×",latex:"\\times"},{label:"÷",latex:"\\div"},{label:"≠",latex:"\\neq"},{label:"≤",latex:"\\leq"},{label:"≥",latex:"\\geq"},{label:"∞",latex:"\\infty"},{label:"≈",latex:"\\approx"},{label:"√",latex:"\\sqrt{}"},{label:"∑",latex:"\\sum"},{label:"∏",latex:"\\prod"},{label:"∫",latex:"\\int"}]},{category:"Arrows",symbols:[{label:"←",latex:"\\leftarrow"},{label:"→",latex:"\\rightarrow"},{label:"↔",latex:"\\leftrightarrow"},{label:"⇒",latex:"\\Rightarrow"},{label:"⇔",latex:"\\Leftrightarrow"},{label:"↑",latex:"\\uparrow"},{label:"↓",latex:"\\downarrow"}]},{category:"Common",symbols:[{label:"²",latex:"^{2}"},{label:"³",latex:"^{3}"},{label:"xⁿ",latex:"^{n}"},{label:"x₁",latex:"_{1}"},{label:"∀",latex:"\\forall"},{label:"∃",latex:"\\exists"},{label:"∈",latex:"\\in"},{label:"⊂",latex:"\\subset"},{label:"∪",latex:"\\cup"},{label:"∩",latex:"\\cap"},{label:"frac",latex:"\\frac{}{}"},{label:"∂",latex:"\\partial"}]}];function ce(){return ie}const ue=new RegExp("(?<!\\$)\\$(?!\\$)(.+?)(?<!\\$)\\$(?!\\$)","g"),me=/\$\$([\s\S]+?)\$\$/g;function de(e){if(!e)return[];const t=[];let n;for(me.lastIndex=0;null!==(n=me.exec(e));)t.push({type:"block",src:n[1].trim(),index:n.index,length:n[0].length});for(ue.lastIndex=0;null!==(n=ue.exec(e));)t.some((e=>n.index>=e.index&&n.index<e.index+e.length))||t.push({type:"inline",src:n[1].trim(),index:n.index,length:n[0].length});return t.sort(((e,t)=>e.index-t.index))}function pe(e){return`<math xmlns="http://www.w3.org/1998/Math/MathML">${e.replace(/\\frac\{([^}]*)\}\{([^}]*)\}/g,"<mfrac><mrow>$1</mrow><mrow>$2</mrow></mfrac>").replace(/\\sqrt\{([^}]*)\}/g,"<msqrt><mrow>$1</mrow></msqrt>").replace(/\^{([^}]*)}/g,"<msup><mo></mo><mn>$1</mn></msup>").replace(/_{([^}]*)}/g,"<msub><mo></mo><mn>$1</mn></msub>").replace(/\\sum/g,"<mo>&sum;</mo>").replace(/\\prod/g,"<mo>&prod;</mo>").replace(/\\int/g,"<mo>&int;</mo>").replace(/\\infty/g,"<mo>&infin;</mo>").replace(/\\alpha/g,"<mi>&alpha;</mi>").replace(/\\beta/g,"<mi>&beta;</mi>").replace(/\\pi/g,"<mi>&pi;</mi>")}</math>`}function ge(t,n){return`<code class="rmx-math-latex">${e.escapeHTML(t)}</code>`}const he=Object.freeze(Object.defineProperty({__proto__:null,MathPlugin:function(t={}){const{renderMath:n=ge,autoRender:r=!0,numbering:o=!0}=t;let s=null,a=null,l=0;function i(e){const t=e.getAttribute("data-math-src");if(!t)return;const r=e.classList.contains("rmx-math-block"),s=n(t,r);if(e.innerHTML=s,r&&o){const t=e.getAttribute("data-equation-number");if(t){const n=document.createElement("span");n.className="rmx-equation-number",n.textContent=`(${t})`,e.appendChild(n)}}}function c(){if(!s)return;s.element.querySelectorAll("[data-math-src]").forEach(i)}return e.createPlugin({name:"math",requiresFullAccess:!0,version:"1.0.0",description:"LaTeX/KaTeX math rendering, symbol palette, equation numbering",commands:[{name:"insertMath",execute(e,t={}){const{latex:r="",displayMode:s=!1}=t;e.history.snapshot(),l++;const a=function(e,t,r){const s=t?"div":"span",a=document.createElement(s);if(a.className="rmx-math "+(t?"rmx-math-block":"rmx-math-inline"),a.setAttribute("data-math","latex"),a.setAttribute("data-math-src",e),a.contentEditable="false",t&&o&&r&&a.setAttribute("data-equation-number",String(r)),a.innerHTML=n(e,t),t&&o&&r){const e=document.createElement("span");e.className="rmx-equation-number",e.textContent=`(${r})`,a.appendChild(e)}return a}(r,s,s?l:null),i=window.getSelection();if(i&&i.rangeCount>0){const e=i.getRangeAt(0);e.deleteContents(),e.insertNode(a);const t=document.createTextNode(" ");a.after(t),e.setStartAfter(t),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}return e.eventBus.emit("content:change"),a},meta:{icon:"math",tooltip:"Insert Math Equation"}},{name:"editMath",execute(e,{element:t,latex:n}){t&&n&&(e.history.snapshot(),t.setAttribute("data-math-src",n),i(t),e.eventBus.emit("content:change"))},meta:{tooltip:"Edit Math Equation"}},{name:"insertSymbol",execute(e,t){if(!t)return;const n=window.getSelection();if(!n||0===n.rangeCount)return;const r=n.getRangeAt(0);r.deleteContents(),r.insertNode(document.createTextNode(t)),r.collapse(!1),e.eventBus.emit("content:change")},meta:{icon:"symbol",tooltip:"Insert Symbol"}},{name:"getSymbolPalette",execute:()=>ce(),meta:{tooltip:"Get Symbol Palette"}},{name:"getMathElements",execute(e){const t=e.element.querySelectorAll("[data-math-src]");return Array.from(t).map(((e,t)=>({index:t,src:e.getAttribute("data-math-src"),displayMode:e.classList.contains("rmx-math-block"),equationNumber:e.getAttribute("data-equation-number"),element:e})))},meta:{tooltip:"Get Math Elements"}},{name:"copyMathAs",execute(e,{element:t,format:n="latex"}){if(!t)return null;const r=t.getAttribute("data-math-src");return r?"latex"===n?r:"mathml"===n?pe(r):r:null},meta:{tooltip:"Copy Math As Format"}}],contextMenuItems:[{label:"Insert Inline Math",command:"insertMath"}],init(e){s=e,s._math={getSymbolPalette:ce,parseMathExpressions:de,latexToMathML:pe,renderAllMath:c,getEquationCount:()=>l},s.element.addEventListener("dblclick",(e=>{const t=e.target.closest("[data-math-src]");t&&s.eventBus.emit("math:edit",{element:t,src:t.getAttribute("data-math-src"),displayMode:t.classList.contains("rmx-math-block")})})),a=new MutationObserver((()=>c())),a.observe(s.element,{childList:!0,subtree:!0}),c()},destroy(){a?.disconnect(),s=null}})},getSymbolPalette:ce,latexToMathML:pe,parseMathExpressions:de},Symbol.toStringTag,{value:"Module"})),fe=/\b(was|were|been|being|is|are|am|get|gets|got|gotten)\b/i,ye=/\b\w+(ed|en|wn|nt|ht|lt)\b/i;function be(e){const t=[],n=e.split(/(\s+)/);let r=0;for(let o=0;o<n.length;o++){const s=n[o];if(/^\s+$/.test(s))r+=s.length;else{if(fe.test(s)){let a=o+1;for(;a<n.length&&/^\s+$/.test(n[a]);)a++;if(a<n.length&&ye.test(n[a])){const l=r;let i=r+s.length;for(let e=o+1;e<=a;e++)i+=n[e].length;const c=e.slice(l,i);t.push({offset:l,length:i-l,message:`Passive voice detected: "${c}". Consider using active voice.`,suggestions:[],type:"grammar",rule:"passive-voice"})}}r+=s.length}}return t}const xe=[{pattern:/\bin order to\b/gi,replacement:"to",message:'"in order to" can be simplified to "to"'},{pattern:/\bat this point in time\b/gi,replacement:"now",message:'"at this point in time" can be simplified to "now"'},{pattern:/\bdue to the fact that\b/gi,replacement:"because",message:'"due to the fact that" can be simplified to "because"'},{pattern:/\bin the event that\b/gi,replacement:"if",message:'"in the event that" can be simplified to "if"'},{pattern:/\bfor the purpose of\b/gi,replacement:"to",message:'"for the purpose of" can be simplified to "to"'},{pattern:/\bin the near future\b/gi,replacement:"soon",message:'"in the near future" can be simplified to "soon"'},{pattern:/\bat the present time\b/gi,replacement:"now",message:'"at the present time" can be simplified to "now"'},{pattern:/\bin spite of the fact that\b/gi,replacement:"although",message:'"in spite of the fact that" can be simplified to "although"'},{pattern:/\bwith regard to\b/gi,replacement:"about",message:'"with regard to" can be simplified to "about"'},{pattern:/\bin close proximity\b/gi,replacement:"near",message:'"in close proximity" can be simplified to "near"'},{pattern:/\ba large number of\b/gi,replacement:"many",message:'"a large number of" can be simplified to "many"'},{pattern:/\bhas the ability to\b/gi,replacement:"can",message:'"has the ability to" can be simplified to "can"'},{pattern:/\bis able to\b/gi,replacement:"can",message:'"is able to" can be simplified to "can"'},{pattern:/\bit is important to note that\b/gi,replacement:"(remove)",message:'"it is important to note that" is unnecessary filler'},{pattern:/\bneedless to say\b/gi,replacement:"(remove)",message:'"needless to say" is unnecessary — just say it'},{pattern:/\beach and every\b/gi,replacement:"each",message:'"each and every" can be simplified to "each" or "every"'},{pattern:/\bfirst and foremost\b/gi,replacement:"first",message:'"first and foremost" can be simplified to "first"'},{pattern:/\bbasically\b/gi,replacement:"(remove)",message:'"basically" is often unnecessary filler'},{pattern:/\bvery unique\b/gi,replacement:"unique",message:'"unique" is absolute — "very" is redundant'},{pattern:/\bcompletely eliminate\b/gi,replacement:"eliminate",message:'"eliminate" is absolute — "completely" is redundant'}];function ve(e){const t=[];for(const n of xe){let r;const o=new RegExp(n.pattern.source,n.pattern.flags);for(;null!==(r=o.exec(e));)t.push({offset:r.index,length:r[0].length,message:n.message,suggestions:"(remove)"===n.replacement?[]:[n.replacement],type:"style",rule:"wordiness"})}return t}const we=["at the end of the day","think outside the box","low-hanging fruit","move the needle","take it to the next level","game changer","paradigm shift","synergy","it goes without saying","avoid it like the plague","better late than never","the bottom line","by the same token","crystal clear","few and far between","hit the ground running","in a nutshell","level playing field","read between the lines","reinvent the wheel","tip of the iceberg","win-win situation","back to the drawing board","bite the bullet","cutting edge","pushing the envelope","raise the bar","on the same page","circle back","deep dive","best practice","leverage","ecosystem","robust","scalable solution"];function Ce(e){const t=[],n=e.toLowerCase();for(const r of we){let o=n.indexOf(r);for(;-1!==o;)t.push({offset:o,length:r.length,message:`Cliche detected: "${e.slice(o,o+r.length)}". Consider using more original phrasing.`,suggestions:[],type:"style",rule:"cliche"}),o=n.indexOf(r,o+r.length)}return t}function ke(e){const t=[];let n;const r=/ +/g;for(;null!==(n=r.exec(e));)0!==n.index&&"\n"!==e[n.index-1]&&t.push({offset:n.index,length:n[0].length,message:"Multiple consecutive spaces detected.",suggestions:[" "],type:"grammar",rule:"double-space"});const o=/([.,!?;:])\1+/g;for(;null!==(n=o.exec(e));)"..."!==n[0]&&".."!==n[0]&&t.push({offset:n.index,length:n[0].length,message:`Repeated punctuation: "${n[0]}"`,suggestions:[n[1]],type:"grammar",rule:"repeated-punctuation"});const s=/[.!?,;:](?=[A-Za-z])/g;for(;null!==(n=s.exec(e));){const r=e.slice(Math.max(0,n.index-4),n.index+1);/\b[A-Z]\.$/.test(r)||/[a-z]\.[a-z]/.test(r)||/https?:/.test(r)||t.push({offset:n.index,length:2,message:"Missing space after punctuation.",suggestions:[e[n.index]+" "+e[n.index+1]],type:"grammar",rule:"missing-space"})}return t}const Se={formal:{passiveVoice:!0,wordiness:!0,cliches:!0,punctuation:!0},casual:{passiveVoice:!1,wordiness:!1,cliches:!0,punctuation:!0},technical:{passiveVoice:!0,wordiness:!1,cliches:!1,punctuation:!0},academic:{passiveVoice:!0,wordiness:!0,cliches:!1,punctuation:!0}};function Te(e,t={}){if(!e)return[];const n=Se[t.stylePreset]||Se.formal,r=t.passiveVoice??n.passiveVoice,o=t.wordiness??n.wordiness,s=t.cliches??n.cliches,a=t.punctuation??n.punctuation,l=[];return r&&l.push(...be(e)),o&&l.push(...ve(e)),s&&l.push(...Ce(e)),a&&l.push(...ke(e)),l.sort(((e,t)=>e.offset-t.offset)),l}function Ae(e){const t={total:e.length,grammar:0,style:0,byRule:{}};for(const n of e)"grammar"===n.type?t.grammar++:t.style++,t.byRule[n.rule]=(t.byRule[n.rule]||0)+1;return t}const _e="rmx-spellcheck-dictionary",Ee="rmx-spellcheck-ignored";function Le(){try{const e=localStorage.getItem(_e);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Ne(e){try{localStorage.setItem(_e,JSON.stringify(e))}catch{}}const Re=Object.freeze(Object.defineProperty({__proto__:null,STYLE_PRESETS:Se,SpellcheckPlugin:function(t={}){const{language:n="en-US",enabled:r=!0,grammarRules:o=!0,stylePreset:s="formal",customService:a=null,dictionary:l=[],persistent:i=!0,onError:c,onCorrection:u}=t;let m=null,d=r,p=s,g=n,h=null,f=[],y=null,b=null;const x=new Set([...l,...i?Le():[]]),v=i?function(){try{const e=localStorage.getItem(Ee);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t:[])}catch{return new Set}}():new Set;function w(){if(!m)return;const e=m.element.querySelectorAll(".rmx-spelling-error, .rmx-grammar-error, .rmx-style-suggestion");for(const t of e){const e=t.parentNode;for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()}}async function C(){if(!m||!d)return[];const e=m.getText();if(!e.trim())return f=[],m.eventBus.emit("spellcheck:update",{errors:[],stats:Ae([])}),[];let t=[];if(o){const n=Te(e,{stylePreset:p});t.push(...n)}if(a?.check)try{const n=await a.check(e);Array.isArray(n)&&t.push(...n)}catch(r){m.eventBus.emit("spellcheck:error",{error:r})}t=t.filter((t=>{const n=e.slice(t.offset,t.offset+t.length).toLowerCase();return!x.has(n)&&!v.has(n)})),t.sort(((e,t)=>e.offset-t.offset)),f=t,w(),function(e){if(!m||0===e.length)return;m.getText();const t=document.createTreeWalker(m.element,NodeFilter.SHOW_TEXT,null),n=[];let r,o=0;for(;r=t.nextNode();)n.push({node:r,start:o,end:o+r.textContent.length}),o+=r.textContent.length;const s=[...e].sort(((e,t)=>t.offset-e.offset));for(const a of s){const e=a.offset+a.length;let t=null,r=null,o=0,s=0;for(const l of n)if(!t&&l.end>a.offset&&(t=l,o=a.offset-l.start),l.end>=e){r=l,s=e-l.start;break}if(t&&r&&t.node===r.node)try{const e=document.createRange();e.setStart(t.node,o),e.setEnd(r.node,s);const n="spelling"===a.type?"rmx-spelling-error":"grammar"===a.type?"rmx-grammar-error":"rmx-style-suggestion",l=document.createElement("span");l.className=n,l.setAttribute("data-spellcheck-message",a.message),l.setAttribute("data-spellcheck-suggestions",JSON.stringify(a.suggestions||[])),l.setAttribute("data-spellcheck-type",a.type),l.setAttribute("title",a.message),e.surroundContents(l)}catch{}}}(t);const n=Ae(t);return m.eventBus.emit("spellcheck:update",{errors:t,stats:n}),m.eventBus.emit("grammar:check",{errors:t,stats:n}),c?.(t),t}function k(){clearTimeout(h),h=setTimeout(C,500)}function S(e){if(!e)return;const t=e.toLowerCase();x.add(t),i&&Ne([...x]),m?.eventBus.emit("spellcheck:dictionary:add",{word:t}),k()}function T(e){x.delete(e.toLowerCase()),i&&Ne([...x]),k()}function A(){return[...x]}function _(e){if(!e)return;const t=e.toLowerCase();v.add(t),i&&function(e){try{localStorage.setItem(Ee,JSON.stringify([...e]))}catch{}}(v),m?.eventBus.emit("spellcheck:ignored:add",{word:t}),k()}function E(){return[...v]}function L(e,t){if(!m||!e)return;const n=e.textContent;m.history.snapshot();const r=document.createTextNode(t);e.parentNode.replaceChild(r,e),r.parentNode.normalize(),m.eventBus.emit("content:change"),m.eventBus.emit("spellcheck:correction",{original:n,replacement:t}),u?.({original:n,replacement:t}),k()}function N(e){Se[e]&&(p=e,m?.eventBus.emit("spellcheck:style:change",{preset:e}),k())}function R(){return p}function I(e){g=e,m?.element&&m.element.setAttribute("lang",e),m?.eventBus.emit("spellcheck:language:change",{language:e}),k()}function O(){return g}function B(){return{...Ae(f),enabled:d,stylePreset:p,language:g,dictionarySize:x.size,ignoredCount:v.size}}function M(e){const t=e.target.closest?.(".rmx-spelling-error, .rmx-grammar-error, .rmx-style-suggestion");if(!t)return;e.preventDefault();const n=t.getAttribute("data-spellcheck-message")||"",r=t.getAttribute("data-spellcheck-suggestions")||"[]",o=t.getAttribute("data-spellcheck-type")||"grammar";let s=[];try{s=JSON.parse(r)}catch{}const a=t.textContent,l=t.getBoundingClientRect();m.eventBus.emit("spellcheck:contextmenu",{word:a,message:n,suggestions:s,type:o,rect:l,mark:t,applyCorrection:e=>L(t,e),ignoreWord:()=>_(a),addToDictionary:()=>S(a)})}return e.createPlugin({name:"spellcheck",requiresFullAccess:!0,version:"1.0.0",description:"Spelling & grammar checking with inline underlines, writing-style presets, and custom service integration",commands:[{name:"toggleSpellcheck",execute:e=>(d=!d,d?(e.element.setAttribute("spellcheck","true"),k()):(e.element.setAttribute("spellcheck","false"),w(),f=[],e.eventBus.emit("spellcheck:update",{errors:[],stats:Ae([])})),e.eventBus.emit("spellcheck:toggle",{enabled:d}),d),meta:{icon:"spellcheck",tooltip:"Toggle Spellcheck"}},{name:"checkGrammar",execute:async e=>C(),meta:{icon:"spellcheck",tooltip:"Check Grammar"}},{name:"addToDictionary",execute(e,t){S(t)},meta:{tooltip:"Add to Dictionary"}},{name:"ignoreWord",execute(e,t){_(t)},meta:{tooltip:"Ignore Word"}},{name:"setWritingStyle",execute:(e,t)=>(N(t),t),meta:{tooltip:"Set Writing Style"}},{name:"getSpellcheckStats",execute:e=>B(),meta:{tooltip:"Get Spellcheck Stats"}}],contextMenuItems:[{label:"Check Grammar",command:"checkGrammar",when:()=>d}],init(e){m=e,m._spellcheck={runCheck:C,clearMarks:w,addToDictionary:S,removeFromDictionary:T,getDictionary:A,ignoreWord:_,getIgnoredWords:E,applyCorrection:L,setWritingStyle:N,getWritingStyle:R,setLanguage:I,getLanguage:O,getErrors:()=>[...f],getStats:B,isEnabled:()=>d},m.element.setAttribute("spellcheck",d?"true":"false"),m.element.setAttribute("lang",g),y=m.eventBus.on("content:change",k),m.element.addEventListener("contextmenu",M),b=m.eventBus.on("destroy",D),d&&k()},destroy(){D()}});function D(){clearTimeout(h),w(),y?.(),b?.(),m?.element?.removeEventListener("contextmenu",M),m=null}},analyzeGrammar:Te,detectCliches:Ce,detectPassiveVoice:be,detectPunctuationIssues:ke,detectWordiness:ve,summarizeIssues:Ae},Symbol.toStringTag,{value:"Module"}));function Ie(e,t){const n=[];let r=0,o="";const s=()=>{o&&(n.push({text:o,className:null}),o="")};for(;r<e.length;){let a=!1;for(const[o,l]of t){o.lastIndex=r;const t=o.exec(e);if(t&&t.index===r){s(),n.push({text:t[0],className:l}),r+=t[0].length,a=!0;break}}a||(o+=e[r],r++)}return s(),n}function Oe(e){return new RegExp(`\\b(?:${e.join("|")})\\b`,"g")}function Be(e){const t=new Set(e);return e=>t.has(e)}function Me(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>t.has(e.toLowerCase())}function De(e,t){const n=[],r=/\b[a-zA-Z_$]\w*\b/g;for(const o of e){if(null!==o.className){n.push(o);continue}let e,s=0;for(r.lastIndex=0;null!==(e=r.exec(o.text));){e.index>s&&n.push({text:o.text.slice(s,e.index),className:null});let a=null;for(const{match:n,className:r}of t)if(n(e[0])){a=r;break}n.push({text:e[0],className:a}),s=r.lastIndex}s<o.text.length&&n.push({text:o.text.slice(s),className:null})}return n}const qe=[{match:Be(["any","boolean","never","number","string","unknown","void","type","keyof","readonly","infer"]),className:"rmx-syn-type"},{match:Be(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","if","implements","import","in","instanceof","interface","let","new","of","package","return","static","super","switch","this","throw","try","typeof","var","void","while","with","yield","async"]),className:"rmx-syn-keyword"},{match:Be(["Array","Boolean","console","Date","Error","JSON","Map","Math","Number","Object","Promise","Proxy","RegExp","Set","String","Symbol","WeakMap","WeakSet","parseInt","parseFloat","undefined","null","true","false","NaN","Infinity"]),className:"rmx-syn-builtin"}],Pe=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/\/(?:[^/\\*\n]|\\.){1,200}\/[gimsuy]{0,6}/g,"rmx-syn-regex"],[/`(?:[^`\\]|\\.|\$\{[^}]{0,200}\}){0,2000}`/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bB][01_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_$]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_$]\\w{0,50}","g"),"rmx-syn-property"],[/=>|[+\-*/%=!<>&|^~?:]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function $e(e){return De(Ie(e,Pe),qe)}const He=[{match:Be(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]),className:"rmx-syn-keyword"},{match:Be(["abs","all","any","bin","bool","bytes","callable","chr","dict","dir","enumerate","eval","filter","float","format","frozenset","getattr","hasattr","hash","hex","id","input","int","isinstance","issubclass","iter","len","list","map","max","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"]),className:"rmx-syn-builtin"}],je=[[/#[^\n]{0,500}/g,"rmx-syn-comment"],[/"""[^]*?(?:"""|$)/g,"rmx-syn-string"],[/'''[^]*?(?:'''|$)/g,"rmx-syn-string"],[/f"(?:[^"\\]|\\.|\{[^}]{0,200}\}){0,1000}"/g,"rmx-syn-string"],[/f'(?:[^'\\]|\\.|\{[^}]{0,200}\}){0,1000}'/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bBoO][\d_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^~@:]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function ze(e){return De(Ie(e,je),He)}const Fe=[[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[new RegExp(`@(?:${["charset","import","namespace","media","supports","keyframes","font-face","layer","container","property","scope"].join("|")})\\b`,"g"),"rmx-syn-keyword"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/#[\da-fA-F]{3,8}\b/g,"rmx-syn-number"],[/\b\d[\d.]{0,20}(?:%|px|rem|em|vh|vw|ch|ex|s|ms|deg|fr|vmin|vmax)?\b/g,"rmx-syn-number"],[/(?:^|\s|[{;])\s{0,10}[a-zA-Z-]{1,40}(?=\s{0,5}:)/gm,"rmx-syn-attr-name"],[/[.#][\w-]{1,60}/g,"rmx-syn-tag"],[/::?[\w-]{1,40}/g,"rmx-syn-entity"],[/\b(?:rgb|rgba|hsl|hsla|var|calc|min|max|clamp)(?=\()/g,"rmx-syn-builtin"],[/!important\b/g,"rmx-syn-keyword"],[/[{}();:,]/g,"rmx-syn-punctuation"]];const We=[{match:Me(["INT","INTEGER","BIGINT","SMALLINT","TINYINT","FLOAT","DOUBLE","DECIMAL","NUMERIC","CHAR","VARCHAR","TEXT","BLOB","BOOLEAN","DATE","TIMESTAMP","SERIAL"]),className:"rmx-syn-type"},{match:Me(["SELECT","FROM","WHERE","INSERT","INTO","UPDATE","DELETE","CREATE","DROP","ALTER","TABLE","INDEX","VIEW","JOIN","INNER","LEFT","RIGHT","OUTER","FULL","CROSS","ON","AS","AND","OR","NOT","IN","BETWEEN","LIKE","IS","NULL","ORDER","BY","GROUP","HAVING","LIMIT","OFFSET","UNION","ALL","DISTINCT","SET","VALUES","EXISTS","CASE","WHEN","THEN","ELSE","END","ASC","DESC","PRIMARY","KEY","FOREIGN","REFERENCES","CONSTRAINT","DEFAULT","WITH","RECURSIVE","RETURNING","BEGIN","COMMIT","ROLLBACK","TRANSACTION","GRANT","REVOKE","TRUNCATE"]),className:"rmx-syn-keyword"},{match:Me(["COUNT","SUM","AVG","MIN","MAX","COALESCE","IFNULL","NULLIF","CAST","CONVERT","SUBSTRING","TRIM","UPPER","LOWER","LENGTH","CONCAT","NOW","CURRENT_TIMESTAMP","TRUE","FALSE"]),className:"rmx-syn-builtin"}],Ue=[[/--[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/\b\d[\d.]{0,20}\b/g,"rmx-syn-number"],[/[+\-*/%=!<>]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];const Ge=[[/"(?:[^"\\]|\\.){0,1000}"(?=\s{0,10}:)/g,"rmx-syn-attr-name"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/\b(?:true|false)\b/g,"rmx-syn-builtin"],[/\bnull\b/g,"rmx-syn-builtin"],[/-?\b\d[\d.]{0,20}(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/[{}[\]:,]/g,"rmx-syn-punctuation"]];const Ve=[[/#[^\n]{0,500}/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.|\$\{[^}]{0,200}\}|\$\w{1,50}){0,1000}"/g,"rmx-syn-string"],[/'[^']{0,2000}'/g,"rmx-syn-string"],[/\$\{[^}]{0,200}\}/g,"rmx-syn-entity"],[/\$[\w?!#@*]{1,50}/g,"rmx-syn-entity"],[Oe(["if","then","else","elif","fi","for","while","until","do","done","case","esac","in","function","select","return","exit","break","continue","local","export","declare","readonly","unset","shift","source","trap"]),"rmx-syn-keyword"],[Oe(["echo","printf","cd","pwd","ls","cp","mv","rm","mkdir","cat","grep","sed","awk","find","sort","uniq","wc","head","tail","chmod","chown","curl","wget","tar","git","docker","npm","yarn","pip","sudo","apt","brew","test","read","eval","exec","set"]),"rmx-syn-builtin"],[/\b\d[\d.]{0,20}\b/g,"rmx-syn-number"],[/[|&;<>]{1,3}/g,"rmx-syn-operator"],[/[{}()[\]]/g,"rmx-syn-punctuation"]];function Ke(e){return Ie(e,Ve)}const Je=[{match:Be(["bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","Self","Box","Vec","String","Option","Result","Rc","Arc","HashMap","HashSet","BTreeMap","BTreeSet","Cow"]),className:"rmx-syn-type"},{match:Be(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","static","struct","super","trait","type","unsafe","use","where","while","yield"]),className:"rmx-syn-keyword"},{match:Be(["Some","None","Ok","Err","true","false","println","eprintln","format","panic","assert","assert_eq","assert_ne","todo","unimplemented","unreachable","dbg","cfg","derive"]),className:"rmx-syn-builtin"}],Ze=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/r#*"[^]*?"#*/g,"rmx-syn-string"],[/'[a-zA-Z_]\w{0,30}/g,"rmx-syn-entity"],[/b?'(?:[^'\\]|\\.){1,4}'/g,"rmx-syn-string"],[/#!\[[\w:]{1,50}/g,"rmx-syn-decorator"],[/#\[[\w:]{1,50}/g,"rmx-syn-decorator"],[/\b\w{1,30}!/g,"rmx-syn-builtin"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?(?:_?(?:f32|f64|i8|i16|i32|i64|i128|u8|u16|u32|u64|u128|isize|usize))?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bB][01_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^]{1,3}|::|=>/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function Xe(e){return De(Ie(e,Ze),Je)}const Ye=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/`[^`]{0,5000}`/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[Oe(["bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),"rmx-syn-type"],[Oe(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"]),"rmx-syn-keyword"],[Oe(["append","cap","close","complex","copy","delete","imag","len","make","new","panic","print","println","real","recover","true","false","nil","iota"]),"rmx-syn-builtin"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/:=|[+\-*/%=!<>&|^]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function Qe(e){return Ie(e,Ye)}const et=[{match:Be(["String","Integer","Long","Double","Float","Boolean","Byte","Character","Short","Object","List","Map","Set","Collection","ArrayList","HashMap","HashSet","Optional","Stream"]),className:"rmx-syn-type"},{match:Be(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","var","record","sealed","permits","yield"]),className:"rmx-syn-keyword"},{match:Be(["true","false","null","System","Math","Arrays","Collections"]),className:"rmx-syn-builtin"}],tt=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){1,4}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?[lLfFdD]?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}[lL]?/g,"rmx-syn-number"],[/0[bB][01_]{1,64}[lL]?/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^~?:]{1,3}|->/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];const nt=[[/<!--[^]*?(?:-->|$)/g,"rmx-syn-comment"],[/<!DOCTYPE[^>]{0,200}>/gi,"rmx-syn-entity"],[/<\/?[a-zA-Z][\w.-]{0,50}/g,"rmx-syn-tag"],[/\/?>/g,"rmx-syn-tag"],[/\b[a-zA-Z_:][\w:.-]{0,50}(?=\s{0,5}=)/g,"rmx-syn-attr-name"],[/=\s{0,5}"[^"]{0,1000}"/g,"rmx-syn-attr-value"],[/=\s{0,5}'[^']{0,1000}'/g,"rmx-syn-attr-value"],[/&\w{1,20};/g,"rmx-syn-entity"]];function rt(e){return Ie(e,nt)}function ot(e){return[{text:e,className:null}]}const st={javascript:$e,js:$e,jsx:$e,typescript:$e,ts:$e,tsx:$e,python:ze,py:ze,css:function(e){return Ie(e,Fe)},sql:function(e){return De(Ie(e,Ue),We)},json:function(e){return Ie(e,Ge)},bash:Ke,sh:Ke,shell:Ke,zsh:Ke,rust:Xe,rs:Xe,go:Qe,golang:Qe,java:function(e){return De(Ie(e,tt),et)},html:rt,htm:rt,xml:rt,svg:rt,plaintext:ot,text:ot,txt:ot},at=[{id:"javascript",label:"JavaScript"},{id:"typescript",label:"TypeScript"},{id:"python",label:"Python"},{id:"css",label:"CSS"},{id:"sql",label:"SQL"},{id:"json",label:"JSON"},{id:"bash",label:"Bash"},{id:"rust",label:"Rust"},{id:"go",label:"Go"},{id:"java",label:"Java"},{id:"html",label:"HTML"},{id:"plaintext",label:"Plain Text"}];function lt(e,t){const n=st[t?.toLowerCase()];if(!n||n===ot)return null;return n(e).map((({text:e,className:t})=>({type:t?t.replace("rmx-syn-",""):"plain",value:e})))}function it(e){if(!e||"string"!=typeof e)return"plaintext";const t=e.trimStart(),n=t.slice(0,200);if(n.toLowerCase(),/^\s*[{\[]/.test(t))try{return JSON.parse(t),"json"}catch{}return/^\s*<!doctype\s+html/i.test(t)||/^\s*<(?:html|head|body|div|span|p|a|img|ul|ol|li|table|form|section|header|footer|nav|main|article)\b/i.test(t)?"html":/^\s*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP|WITH|GRANT|EXPLAIN)\b/i.test(t)?"sql":/^#!.*python/i.test(t)||/^\s*(?:def |class \w+[:(]|from \w+ import|import (?:os|sys|re|json|math|typing|collections|pathlib|django|flask|numpy|pandas))\b/.test(t)?"python":/^\s*(?:fn |use std|pub fn|impl |#\[derive|mod \w+;|extern crate)/.test(t)?"rust":/^\s*(?:package \w+|func (?:main|\w+)\(|import \()/.test(t)?"go":/^\s*(?:(?:public|private|protected)\s+(?:class|interface|enum|abstract)|import java|@Override|package [a-z]+\.)/.test(t)?"java":/^#!\/(?:bin\/(?:ba)?sh|usr\/bin\/env (?:ba)?sh)/.test(t)||/^\s*(?:export |alias |source |if \[)/.test(t)?"bash":/^\s*(?:@(?:media|import|charset|keyframes|font-face)|[.#][\w-]+\s*\{|:root\s*\{|\*\s*\{|body\s*\{)/.test(t)?"css":/^\s*(?:import |export |const |let |var |function |class |async |'use strict')/.test(t)||/=>/.test(n)||/(?:React|require\(|module\.exports)/.test(n)?"javascript":"plaintext"}function ct(e){const t=e.selection.getSelection();if(!t||!t.anchorNode)return null;const n=t.anchorNode.nodeType===Node.TEXT_NODE?t.anchorNode.parentElement:t.anchorNode;return n?.closest?.("pre")??null}const ut=Object.freeze(Object.defineProperty({__proto__:null,LANGUAGE_MAP:st,SUPPORTED_LANGUAGES:at,SyntaxHighlightPlugin:function(){let t=null,n=null,r=null,o=null,s=null;function a(t,n){const r=t.closest("pre");if(!r)return;let o=t.getAttribute("data-language");o||(o=it(t.textContent),o&&t.setAttribute("data-language",o));const s=lt(t.textContent,o);if(!s)return void r.classList.add("rmx-highlighted");let a="";for(const i of s)"plain"===i.type?a+=e.escapeHTML(i.value):a+=`<span class="rmx-syn-${i.type}">${e.escapeHTML(i.value)}</span>`;const l=n.selection.save();t.innerHTML=a,r.classList.add("rmx-highlighted"),l&&n.selection.restore(l)}function l(e){const t=e.hasAttribute("data-line-numbers");let n=e.querySelector(".rmx-line-numbers");if(!t)return n&&n.remove(),void e.classList.remove("rmx-has-line-numbers");const r=e.querySelector("code");if(!r)return;const o=(r.textContent.match(/\n/g)||[]).length+1;n||(n=document.createElement("span"),n.className="rmx-line-numbers",n.setAttribute("aria-hidden","true"),n.contentEditable="false",e.insertBefore(n,e.firstChild));let s="";for(let a=1;a<=o;a++)s+=`<span class="rmx-line-number">${a}</span>`;n.innerHTML=s,e.classList.add("rmx-has-line-numbers")}function i(e){if(e.querySelector(".rmx-code-copy-btn"))return;const t=document.createElement("button");t.className="rmx-code-copy-btn",t.type="button",t.setAttribute("aria-label","Copy code"),t.contentEditable="false",t.textContent="⧉",e.appendChild(t)}function c(t){const n=function(){if(!document.activeElement)return null;const e=window.getSelection();if(!e||!e.focusNode)return null;const t=e.focusNode.nodeType===Node.TEXT_NODE?e.focusNode.parentElement:e.focusNode;return t?.closest?.("pre")??null}(),r=t.element.querySelectorAll("pre");for(const e of r){if(i(e),l(e),e===n)continue;if(e.classList.contains("rmx-highlighted"))continue;const r=e.querySelector("code");r&&a(r,t)}!function(t){const n=t.element.querySelectorAll("code[data-language]:not(pre code)");for(const r of n){if(r.classList.contains("rmx-inline-highlighted"))continue;const t=r.getAttribute("data-language"),n=lt(r.textContent,t);if(!n)continue;let o="";for(const r of n)"plain"===r.type?o+=e.escapeHTML(r.value):o+=`<span class="rmx-syn-${r.type}">${e.escapeHTML(r.value)}</span>`;r.innerHTML=o,r.classList.add("rmx-inline-highlighted")}}(t)}return e.createPlugin({name:"syntaxHighlight",requiresFullAccess:!0,commands:[{name:"setCodeLanguage",execute(e,{language:t}={}){if(!t)return!1;const n=ct(e);if(!n)return!1;const r=n.querySelector("code");return!!r&&(r.setAttribute("data-language",t),n.classList.remove("rmx-highlighted"),a(r,e),e.eventBus.emit("codeblock:language-change",{language:t,element:r}),!0)}},{name:"getCodeLanguage",execute(e){const t=ct(e);if(!t)return null;const n=t.querySelector("code");return n&&n.getAttribute("data-language")||null}},{name:"toggleLineNumbers",execute(e,{element:t}={}){const n=t||ct(e);return!!n&&(n.hasAttribute("data-line-numbers")?n.removeAttribute("data-line-numbers"):n.setAttribute("data-line-numbers",""),l(n),!0)},meta:{icon:"lineNumbers",tooltip:"Toggle Line Numbers"}}],init(e){c(e),t=new MutationObserver((t=>{let r=!1;for(const e of t){if("childList"===e.type)for(const t of e.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&(t.matches?.("pre")||t.querySelector?.("pre"))){r=!0;break}if("characterData"===e.type){const t=e.target.parentElement?.closest?.("pre");t&&(t.classList.remove("rmx-highlighted"),r=!0)}if("attributes"===e.type){const t=e.target;if(t.matches?.("code")&&"data-language"===e.attributeName){const e=t.closest("pre");e&&(e.classList.remove("rmx-highlighted"),r=!0)}}if(r)break}r&&function(e){clearTimeout(n),n=setTimeout((()=>c(e)),150)}(e)})),t.observe(e.element,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-language"]}),s=async e=>{const t=e.target.closest(".rmx-code-copy-btn");if(!t)return;const n=t.closest("pre");if(!n)return;const r=n.querySelector("code");if(r){e.preventDefault(),e.stopPropagation();try{await navigator.clipboard.writeText(r.textContent),t.textContent="✓",t.classList.add("rmx-code-copy-success"),setTimeout((()=>{t.textContent="⧉",t.classList.remove("rmx-code-copy-success")}),1500)}catch{const e=document.createElement("textarea");e.value=r.textContent,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),t.textContent="✓",t.classList.add("rmx-code-copy-success"),setTimeout((()=>{t.textContent="⧉",t.classList.remove("rmx-code-copy-success")}),1500)}}},e.element.addEventListener("click",s,!0),r=t=>{const n=t.target?.closest?.("pre");if(n&&e.element.contains(n)){n.classList.remove("rmx-highlighted");const t=n.querySelector("code");t&&a(t,e),l(n)}},e.element.addEventListener("focusout",r,!0),o=e.eventBus.on("codeblock:language-change",(({language:t,element:n})=>{if(!n)return;const r=n.closest("pre");r&&e.element.contains(r)&&(r.classList.remove("rmx-highlighted"),a(n,e))}))},destroy(e){clearTimeout(n),n=null,t&&(t.disconnect(),t=null),r&&(e.element.removeEventListener("focusout",r,!0),r=null),s&&(e.element.removeEventListener("click",s,!0),s=null),o&&(o(),o=null)}})},detectLanguage:it,registerLanguage:function(e,t,n,r=[]){if(!e||"string"!=typeof e)throw new Error("registerLanguage: id is required");if(!t||"string"!=typeof t)throw new Error("registerLanguage: label is required");if("function"!=typeof n)throw new Error("registerLanguage: tokenizer must be a function");st[e.toLowerCase()]=n;for(const o of r)st[o.toLowerCase()]=n;at.find((t=>t.id===e))||at.push({id:e,label:t})},runRules:Ie,tokenize:lt,unregisterLanguage:function(e,t=[]){delete st[e.toLowerCase()];for(const r of t)delete st[r.toLowerCase()];const n=at.findIndex((t=>t.id===e));-1!==n&&at.splice(n,1)}},Symbol.toStringTag,{value:"Module"}));function mt(e,t){const n=[];let r=null,o=null;function s(){i();const t=e.querySelector("thead");if(!t)return;t.querySelectorAll("th").forEach(((e,t)=>{const s=document.createElement("span");s.className="rmx-filter-btn",s.textContent="▽",s.title="Filter column",s.setAttribute("data-col-index",String(t)),s.addEventListener("mousedown",(n=>{n.preventDefault(),n.stopPropagation(),function(e,t){if(r&&r.parentElement===e)return void l();l();const n=document.createElement("div");n.className="rmx-filter-dropdown",n.addEventListener("mousedown",(e=>e.stopPropagation()));const s=document.createElement("input");s.type="text",s.className="rmx-filter-input",s.placeholder="Filter...",s.value=e.getAttribute("data-filter-value")||"",s.addEventListener("input",(()=>{clearTimeout(o),o=setTimeout((()=>{a(t,s.value)}),200)}));const i=document.createElement("button");i.className="rmx-filter-clear-btn",i.textContent="Clear",i.type="button",i.addEventListener("click",(e=>{e.stopPropagation(),s.value="",a(t,""),l()})),n.appendChild(s),n.appendChild(i),e.appendChild(n),r=n,setTimeout((()=>s.focus()),0);const c=t=>{n.contains(t.target)||t.target===e.querySelector(".rmx-filter-btn")||(l(),document.removeEventListener("mousedown",c))};setTimeout((()=>document.addEventListener("mousedown",c)),0)}(e,t)})),e.style.position="relative",e.appendChild(s),n.push(s),e.getAttribute("data-filter-value")&&s.classList.add("rmx-filter-active")}))}function a(n,r){const o=e.querySelector("thead"),s=e.querySelector("tbody");if(!s)return;if(o){const e=o.querySelectorAll("th");if(e[n])if(r){e[n].setAttribute("data-filter-value",r);const t=e[n].querySelector(".rmx-filter-btn");t&&t.classList.add("rmx-filter-active")}else{e[n].removeAttribute("data-filter-value");const t=e[n].querySelector(".rmx-filter-btn");t&&t.classList.remove("rmx-filter-active")}}const a=[];o&&o.querySelectorAll("th").forEach(((e,t)=>{const n=e.getAttribute("data-filter-value");n&&a.push({columnIndex:t,value:n.toLowerCase()})}));s.querySelectorAll("tr").forEach((e=>{const t=e.querySelectorAll("td, th");a.some((e=>!(t[e.columnIndex]?.textContent||"").toLowerCase().includes(e.value)))?e.classList.add("rmx-row-hidden"):e.classList.remove("rmx-row-hidden")})),t?.eventBus&&t.eventBus.emit("table:filter-change",{table:e,filters:a})}function l(){r&&(r.remove(),r=null)}function i(){n.forEach((e=>e.remove())),n.length=0,l()}return s(),{update:s,destroy:()=>{clearTimeout(o),i()}}}const dt=Object.freeze(Object.defineProperty({__proto__:null,TablePlugin:function(){let t=null,n=new Map,r=null,o=null,s=null,a=null,l=null;function i(t,r){if(n.has(t))return;const o={};o.resize=function(e,t){const n=[];let r=0,o=0,s=0,a=0,l=-1,i=null;function c(){const t=e.getBoundingClientRect(),r=e.querySelector("thead"),o=r?.querySelector("tr")||e.querySelector("tr");if(!o)return;const s=o.querySelectorAll("th, td");n.forEach((n=>{if(n.classList.contains("rmx-col-resize-handle")){const r=parseInt(n.getAttribute("data-col-index")),o=s[r];if(!o)return;const a=o.getBoundingClientRect();n.style.position="absolute",n.style.top="0",n.style.left=a.right-t.left-3+"px",n.style.width="6px",n.style.height=e.offsetHeight+"px"}else if(n.classList.contains("rmx-row-resize-handle")){const r=parseInt(n.getAttribute("data-row-index")),o=e.querySelectorAll("tbody tr")[r];if(!o)return;const s=o.getBoundingClientRect();n.style.position="absolute",n.style.left="0",n.style.top=s.bottom-t.top-3+"px",n.style.width=e.offsetWidth+"px",n.style.height="6px"}}))}function u(t){t.preventDefault(),t.stopPropagation(),l=parseInt(t.target.getAttribute("data-col-index"));const n=e.querySelector("thead"),o=n?.querySelector("tr")||e.querySelector("tr"),a=o?.querySelectorAll("th, td")[l];a&&(r=t.clientX,s=a.offsetWidth,t.target,e.classList.add("rmx-table-resizing"),document.addEventListener("mousemove",m),document.addEventListener("mouseup",d))}function m(t){if(l<0)return;const n=t.clientX-r,o=Math.max(40,s+n);e.querySelectorAll("tr").forEach((e=>{const t=e.cells[l];t&&t.colSpan<=1&&(t.style.width=o+"px")}))}function d(){document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),e.classList.remove("rmx-table-resizing"),l=-1,t?.history&&t.history.snapshot(),c()}function p(t){t.preventDefault(),t.stopPropagation();const n=parseInt(t.target.getAttribute("data-row-index")),r=e.querySelectorAll("tbody tr");i=r[n],i&&(o=t.clientY,a=i.offsetHeight,e.classList.add("rmx-table-resizing"),document.addEventListener("mousemove",g),document.addEventListener("mouseup",h))}function g(e){if(!i)return;const t=e.clientY-o,n=Math.max(24,a+t);i.style.height=n+"px"}function h(){document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h),e.classList.remove("rmx-table-resizing"),i=null,t?.history&&t.history.snapshot(),c()}function f(){n.forEach((e=>e.remove())),n.length=0}return"static"===getComputedStyle(e).position&&(e.style.position="relative"),function(){f();const t=e.querySelector("thead"),r=t?.querySelector("tr")||e.querySelector("tr");if(!r)return;const o=r.querySelectorAll("th, td");o.forEach(((t,r)=>{if(r===o.length-1)return;const s=document.createElement("div");s.className="rmx-col-resize-handle",s.setAttribute("data-col-index",String(r)),s.addEventListener("mousedown",u),e.appendChild(s),n.push(s)}));const s=e.querySelectorAll("tbody tr");s.forEach(((t,r)=>{if(r===s.length-1)return;const o=document.createElement("div");o.className="rmx-row-resize-handle",o.setAttribute("data-row-index",String(r)),o.addEventListener("mousedown",p),e.appendChild(o),n.push(o)})),c()}(),{update:c,destroy:()=>{f(),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h)}}}(t,r),t.querySelector("thead")&&(o.filter=mt(t,r));const s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach((e=>{e.classList.add("rmx-sortable")})),t.querySelectorAll("td, th").forEach((e=>{const t=e.textContent.trim();t.startsWith("=")&&!e.hasAttribute("data-formula")&&e.setAttribute("data-formula",t)})),e.evaluateTableFormulas(t),n.set(t,o)}function c(e){const t=n.get(e);t&&(t.resize?.destroy(),t.filter?.destroy(),n.delete(e))}function u(e){e.element.querySelectorAll("table.rmx-table").forEach((t=>i(t,e)))}return e.createPlugin({name:"tableFeatures",requiresFullAccess:!0,init(n){u(n),t=new MutationObserver((e=>{let t=!1;for(const n of e){if("childList"===n.type){for(const e of n.addedNodes)if(e.nodeType===Node.ELEMENT_NODE&&(e.matches?.("table.rmx-table")||e.querySelector?.("table.rmx-table"))){t=!0;break}for(const e of n.removedNodes)e.nodeType===Node.ELEMENT_NODE&&e.matches?.("table.rmx-table")&&c(e)}if(t)break}t&&u(n)})),t.observe(n.element,{childList:!0,subtree:!0}),o=e=>{const t=e.target.closest("th");if(!t)return;const r=t.closest("thead");if(!r)return;const o=r.closest("table.rmx-table");if(!o||!n.element.contains(o))return;if(e.target.closest(".rmx-filter-btn")||e.target.closest(".rmx-filter-dropdown"))return;const s=Array.from(r.querySelectorAll("th")),a=s.indexOf(t);if(a<0)return;const l=t.getAttribute("data-sort-dir");let i;if(i=l?"asc"===l?"desc":null:"asc",e.shiftKey){const e=[];s.forEach(((t,n)=>{const r=t.getAttribute("data-sort-dir");r&&n!==a&&e.push({columnIndex:n,direction:r})})),i&&e.push({columnIndex:a,direction:i}),e.length>0?n.executeCommand("sortTable",{keys:e}):s.forEach((e=>{e.removeAttribute("data-sort-dir"),e.removeAttribute("data-sort-priority")}))}else i?n.executeCommand("sortTable",{columnIndex:a,direction:i}):s.forEach((e=>{e.removeAttribute("data-sort-dir"),e.removeAttribute("data-sort-priority")}))},n.element.addEventListener("click",o),s=e=>{const t=e.target.closest("td, th");if(!t||!n.element.contains(t))return;const r=t.getAttribute("data-formula");r&&(t.textContent="="+r)},a=t=>{const r=t.target.closest("td, th");if(!r||!n.element.contains(r))return;const o=r.textContent.trim();if(o.startsWith("=")&&o.length>1){const t=o.slice(1);r.setAttribute("data-formula",t);const n=r.closest("table.rmx-table");n&&e.evaluateTableFormulas(n)}else r.hasAttribute("data-formula")&&!o.startsWith("=")&&r.removeAttribute("data-formula")},n.element.addEventListener("focusin",s,!0),n.element.addEventListener("focusout",a,!0),l=n.eventBus.on("content:change",(()=>{clearTimeout(r),r=setTimeout((()=>{n.element.querySelectorAll("table.rmx-table").forEach((t=>e.evaluateTableFormulas(t)))}),200)}))},destroy(e){clearTimeout(r),r=null,l?.(),l=null,t&&(t.disconnect(),t=null),o&&(e.element.removeEventListener("click",o),o=null),s&&(e.element.removeEventListener("focusin",s,!0),s=null),a&&(e.element.removeEventListener("focusout",a,!0),a=null);for(const t of n.keys())c(t);n.clear()}})}},Symbol.toStringTag,{value:"Module"})),pt=/\{\{([^{}]+)\}\}/g,gt=/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g,ht=/\{\{#each\s+(\w+)\}\}([\s\S]*?)\{\{\/each\}\}/g;function ft(e,t){if(!e||!t)return e||"";let n=e;return n=n.replace(ht,((e,n,r)=>{const o=t[n];return Array.isArray(o)?o.map((e=>{let n=r;return n="object"==typeof e&&null!==e?ft(r,{...t,...e}):n.replace(/\{\{this\}\}/g,String(e)),n})).join(""):""})),n=n.replace(gt,((e,n,r)=>t[n]?ft(r,t):"")),n=n.replace(pt,((e,n)=>{const r=n.trim();return r in t?String(t[r]):`{{${r}}}`})),n}function yt(e){if(!e)return[];const t=new Set,n=e.matchAll(/\{\{(?:#(?:if|each)\s+)?(\w+)\}\}/g);for(const r of n)t.add(r[1]);return Array.from(t)}const bt=new Map,xt=[{id:"email",name:"Email",category:"Communication",html:"<p>Dear {{recipient_name}},</p><p>{{body}}</p><p>Best regards,<br>{{sender_name}}<br>{{sender_title}}</p>",sampleData:{recipient_name:"John Doe",body:"Thank you for your interest in our product.",sender_name:"Jane Smith",sender_title:"Sales Manager"}},{id:"invoice",name:"Invoice",category:"Business",html:'<h2>Invoice #{{invoice_number}}</h2><p>Date: {{date}}</p><p>Bill to: <strong>{{client_name}}</strong></p><p>{{client_address}}</p><table class="rmx-table"><thead><tr><th>Item</th><th>Qty</th><th>Price</th></tr></thead><tbody><tr><td>{{item_1}}</td><td>{{qty_1}}</td><td>{{price_1}}</td></tr></tbody></table><p><strong>Total: {{total}}</strong></p>',sampleData:{invoice_number:"INV-001",date:"2026-03-19",client_name:"Acme Corp",client_address:"123 Main St",item_1:"Widget",qty_1:"10",price_1:"$29.99",total:"$299.90"}},{id:"letter",name:"Letter",category:"Communication",html:"<p>{{date}}</p><p>{{recipient_name}}<br>{{recipient_address}}</p><p>Dear {{recipient_name}},</p><p>{{body}}</p><p>Sincerely,<br>{{sender_name}}</p>",sampleData:{date:"March 19, 2026",recipient_name:"John Doe",recipient_address:"456 Oak Ave",body:"I am writing to inform you...",sender_name:"Jane Smith"}},{id:"report",name:"Report",category:"Business",html:"<h1>{{title}}</h1><p><em>Prepared by {{author}} | {{date}}</em></p><h2>Executive Summary</h2><p>{{summary}}</p><h2>Findings</h2><p>{{findings}}</p><h2>Recommendations</h2><p>{{recommendations}}</p>",sampleData:{title:"Q1 2026 Report",author:"Analytics Team",date:"March 2026",summary:"Key findings from Q1...",findings:"Revenue increased by 15%...",recommendations:"Continue investing in..."}},{id:"newsletter",name:"Newsletter",category:"Marketing",html:'<h1>{{newsletter_name}}</h1><p><em>{{edition}} | {{date}}</em></p><hr><h2>{{headline}}</h2><p>{{lead_story}}</p>{{#if has_coupon}}<div class="rmx-callout rmx-callout-success" data-callout="success"><div class="rmx-callout-header" contenteditable="false"><span class="rmx-callout-icon">✅</span><span class="rmx-callout-title">Special Offer</span></div><div class="rmx-callout-body"><p>Use code <strong>{{coupon_code}}</strong> for {{discount}} off!</p></div></div>{{/if}}<p>{{closing}}</p>',sampleData:{newsletter_name:"The Weekly Digest",edition:"Vol. 12",date:"March 19, 2026",headline:"Big News This Week",lead_story:"We are excited to announce...",has_coupon:!0,coupon_code:"SAVE20",discount:"20%",closing:"Thanks for reading!"}}];for(const qt of xt)bt.set(qt.id,qt);function vt(e){e?.id&&bt.set(e.id,e)}function wt(e){return bt.delete(e)}function Ct(){return Array.from(bt.values())}function kt(e){return bt.get(e)}function St(e){return e.replace(pt,((e,t)=>{const n=t.trim();return n.startsWith("#")||n.startsWith("/")?e:`<span class="rmx-merge-tag" data-tag="${n}" contenteditable="false">{{${n}}}</span>`}))}function Tt(e){return e.replace(/<span[^>]*class="rmx-merge-tag"[^>]*data-tag="([^"]*)"[^>]*>.*?<\/span>/g,((e,t)=>`{{${t}}}`))}const At=Object.freeze(Object.defineProperty({__proto__:null,TemplatePlugin:function(t={}){let n=null,r=!1,o={};return e.createPlugin({name:"templates",requiresFullAccess:!0,version:"1.0.0",description:"Merge tags, conditional blocks, repeatable sections, live preview, template library",commands:[{name:"insertMergeTag",execute(e,t){if(!t)return;e.history.snapshot();const n=window.getSelection();if(!n||0===n.rangeCount)return;const r=n.getRangeAt(0),o=document.createElement("span");o.className="rmx-merge-tag",o.setAttribute("data-tag",t),o.contentEditable="false",o.textContent=`{{${t}}}`,r.deleteContents(),r.insertNode(o);const s=document.createTextNode(" ");o.after(s),r.setStartAfter(s),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.eventBus.emit("content:change")},meta:{icon:"tag",tooltip:"Insert Merge Tag"}},{name:"loadTemplate",execute(e,t){const n=bt.get(t);return n?(e.history.snapshot(),e.element.innerHTML=St(n.html),o={...n.sampleData||{}},e.eventBus.emit("content:change"),e.eventBus.emit("template:loaded",{id:t,template:n}),n):null},meta:{icon:"template",tooltip:"Load Template"}},{name:"previewTemplate",execute(e,t){if(!t&&0===Object.keys(o).length)return;const n=t||o;o=n;const s=ft(Tt(e.getHTML()),n);r=!0,e._templateBackup=e.element.innerHTML,e.element.innerHTML=s,e.element.contentEditable="false",e.element.classList.add("rmx-template-preview"),e.eventBus.emit("template:preview",{data:n})},meta:{icon:"preview",tooltip:"Preview Template"}},{name:"exitPreview",execute(e){r&&(r=!1,e._templateBackup&&(e.element.innerHTML=e._templateBackup,delete e._templateBackup),e.element.contentEditable="true",e.element.classList.remove("rmx-template-preview"),e.eventBus.emit("template:exitPreview"))},meta:{icon:"edit",tooltip:"Exit Preview"}},{name:"exportTemplate",execute(e){const t=Tt(e.getHTML());return{html:t,tags:yt(t),sampleData:{...o}}},meta:{icon:"export",tooltip:"Export Template"}},{name:"getTemplateTags",execute:e=>yt(Tt(e.getHTML())),meta:{tooltip:"Get Template Tags"}}],contextMenuItems:[{label:"Insert Merge Tag",command:"insertMergeTag"}],init(e){n=e,n._templates={renderTemplate:ft,extractTags:yt,getTemplateLibrary:Ct,getTemplate:kt,registerTemplate:vt,unregisterTemplate:wt,textToChips:St,chipsToText:Tt,setPreviewData:e=>{o={...e}},getPreviewData:()=>({...o}),isPreviewMode:()=>r}},destroy(){r&&n&&(n.element.contentEditable="true",n.element.classList.remove("rmx-template-preview")),n=null}})},extractTags:yt,getTemplate:kt,getTemplateLibrary:Ct,registerTemplate:vt,renderTemplate:ft,unregisterTemplate:wt},Symbol.toStringTag,{value:"Module"}));let _t=0;function Et(e,t={}){const{numbering:n=!0}=t,r=e.querySelectorAll("h1, h2, h3, h4, h5, h6"),o=[];for(const l of r){if(!l.id){const e=l.textContent.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"heading-"+ ++_t;l.id=e}o.push({id:l.id,text:l.textContent,level:parseInt(l.tagName.charAt(1),10),element:l,children:[],number:""})}const s=[],a=[];for(const l of o){for(;a.length>0&&a[a.length-1].level>=l.level;)a.pop();0===a.length?s.push(l):a[a.length-1].item.children.push(l),a.push({item:l,level:l.level})}return n&&Lt(s,""),s}function Lt(e,t){e.forEach(((e,n)=>{e.number=t?`${t}.${n+1}`:String(n+1),Lt(e.children,e.number)}))}function Nt(e){const t=[];return function e(n){for(const r of n)t.push(r),e(r.children)}(e),t}function Rt(t,n={}){const{numbering:r=!0,linkPrefix:o="#"}=n;return`<nav class="rmx-toc" role="navigation" aria-label="Table of Contents"><ul>${function t(n){return 0===n.length?"":n.map((n=>{const s=r&&n.number?`<span class="rmx-toc-number">${n.number}</span> `:"",a=n.children.length>0?`<ul>${t(n.children)}</ul>`:"";return`<li><a href="${o}${n.id}" class="rmx-toc-link">${s}${e.escapeHTML(n.text)}</a>${a}</li>`})).join("")}(t)}</ul></nav>`}function It(e){const t=[];for(let n=1;n<e.length;n++){const r=e[n-1].level,o=e[n].level;o>r+1&&t.push({message:`Heading level skipped: H${r} → H${o} (expected H${r+1})`,element:e[n].element})}return t}const Ot=Object.freeze(Object.defineProperty({__proto__:null,TocPlugin:function(t={}){const{onOutlineChange:n,numbering:r=!0,collapsible:o=!0}=t;let s=null,a=null,l=[],i=null;function c(){s&&(l=Et(s.element,{numbering:r}),s.eventBus.emit("toc:change",{outline:l}),n?.(l))}return e.createPlugin({name:"toc",requiresFullAccess:!0,version:"1.0.0",description:"Auto-generated table of contents, document outline, heading validation",commands:[{name:"getOutline",execute:e=>Et(e.element,{numbering:r}),meta:{tooltip:"Get Document Outline"}},{name:"insertToc",execute(e){e.history.snapshot();const t=Rt(Et(e.element,{numbering:r}),{numbering:r}),n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0),r=document.createElement("div");r.innerHTML=t;const o=document.createDocumentFragment();for(;r.firstChild;)o.appendChild(r.firstChild);e.deleteContents(),e.insertNode(o)}e.eventBus.emit("content:change")},meta:{icon:"toc",tooltip:"Insert Table of Contents"}},{name:"scrollToHeading",execute(e,t){const n=e.element.querySelector(`#${CSS.escape(t)}`);if(n){n.scrollIntoView?.({behavior:"smooth",block:"start"});const e=window.getSelection(),t=document.createRange();t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}},meta:{icon:"scroll",tooltip:"Scroll to Heading"}},{name:"validateHeadings",execute:e=>It(Nt(Et(e.element,{numbering:!1}))),meta:{tooltip:"Validate Heading Hierarchy"}}],init(e){s=e,s._toc={buildOutline:()=>Et(s.element,{numbering:r}),flattenOutline:Nt,renderTocHTML:Rt,validateHeadingHierarchy:It,getOutline:()=>l},a=s.eventBus.on("content:change",(()=>{clearTimeout(i),i=setTimeout(c,200)})),s.element.addEventListener("click",(e=>{const t=e.target.closest(".rmx-toc-link");if(t){e.preventDefault();const n=t.getAttribute("href")?.replace("#","");if(n){const e=s.element.querySelector(`#${CSS.escape(n)}`);e?.scrollIntoView?.({behavior:"smooth",block:"start"})}}})),c()},destroy(){clearTimeout(i),a?.(),s=null}})},buildOutline:Et,flattenOutline:Nt,renderTocHTML:Rt,validateHeadingHierarchy:It},Symbol.toStringTag,{value:"Module"})),Bt=Object.assign({"./analytics/index.js":d,"./block-templates/index.js":g,"./callout/index.js":T,"./collaboration/index.js":R,"./comments/index.js":M,"./drag-drop/index.js":z,"./keyboard/index.js":Y,"./link/index.js":le,"./math/index.js":he,"./spellcheck/index.js":Re,"./syntax-highlight/index.js":ut,"./table/index.js":dt,"./template/index.js":At,"./toc/index.js":Ot}),Mt=new Map;for(const[qt,Pt]of Object.entries(Bt)){const e=qt.split("/");if(3===e.length&&"index.js"===e[2]){const t=e[1];Mt.set(t,Pt)}}function Dt(e,t={}){const n=Mt.get(e);if(!n)return null;const r=Object.keys(n).find((e=>e.endsWith("Plugin")&&"function"==typeof n[e]));return r?n[r](t):null}exports.loadPlugin=Dt,exports.resolvePluginsFromConfig=function(e){return e&&"object"==typeof e?Object.entries(e).filter((([,e])=>!1!==e&&("object"!=typeof e||null===e||!1!==e.enabled))).map((([e,t])=>{const n="object"==typeof t&&null!==t?{...t}:{};return delete n.enabled,Dt(e,n)})).filter(Boolean):[]};
2
+ //# sourceMappingURL=index-OfJxpaev.cjs.map