@editora/core 1.0.21 → 1.0.23
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.
- package/README.md +247 -243
- package/dist/{CodePlugin.native-AoJ_idGz.mjs → CodePlugin.native-CAHk9ecG.mjs} +211 -93
- package/dist/{CodePlugin.native-CEgR1DWC.mjs → CodePlugin.native-DZgIez08.mjs} +371 -253
- package/dist/editora.min.js +1 -1
- package/dist/editora.umd.js +1 -1
- package/dist/{index-Ct3Aik7_.js → index-C1sO7DAC.js} +2 -2
- package/dist/{index-6i4_TH66.mjs → index-DGMYWPLx.mjs} +3 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/webcomponent-core.js +3 -1
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +16 -15
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +3 -1
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +64 -63
- package/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/webcomponent.min.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
`}),r+=`
|
|
9
9
|
`}),r}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}function $R(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Qne(t){if(Array.isArray(t))return t}function $ne(t,e){var n=t==null?null:typeof Symbol!="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],c=!0,l=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);c=!0);}catch(u){l=!0,i=u}finally{try{if(!c&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}function zne(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
10
10
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jne(t,e){return Qne(t)||$ne(t,e)||qne(t,e)||zne()}function qne(t,e){if(t){if(typeof t=="string")return $R(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$R(t,e):void 0}}const zR=Object.entries,jR=Object.setPrototypeOf,Wne=Object.isFrozen,Kne=Object.getPrototypeOf,Vne=Object.getOwnPropertyDescriptor;let Di=Object.freeze,Ki=Object.seal,Ap=Object.create,qR=typeof Reflect!="undefined"&&Reflect,Xk=qR.apply,Yk=qR.construct;Di||(Di=function(e){return e}),Ki||(Ki=function(e){return e}),Xk||(Xk=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)}),Yk||(Yk=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});const hA=hi(Array.prototype.forEach),Gne=hi(Array.prototype.lastIndexOf),WR=hi(Array.prototype.pop),Lb=hi(Array.prototype.push),Xne=hi(Array.prototype.splice),hp=Array.isArray,Fb=hi(String.prototype.toLowerCase),Zk=hi(String.prototype.toString),KR=hi(String.prototype.match),Ib=hi(String.prototype.replace),VR=hi(String.prototype.indexOf),Yne=hi(String.prototype.trim),Zne=hi(Number.prototype.toString),Jne=hi(Boolean.prototype.toString),GR=typeof BigInt=="undefined"?null:hi(BigInt.prototype.toString),XR=typeof Symbol=="undefined"?null:hi(Symbol.prototype.toString),Ca=hi(Object.prototype.hasOwnProperty),Ub=hi(Object.prototype.toString),Fo=hi(RegExp.prototype.test),Id=ere(TypeError);function hi(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Xk(t,e,r)}}function ere(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Yk(t,n)}}function Bn(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fb;if(jR&&jR(t,null),!hp(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const o=n(i);o!==i&&(Wne(e)||(e[r]=o),i=o)}t[i]=!0}return t}function tre(t){for(let e=0;e<t.length;e++)Ca(t,e)||(t[e]=null);return t}function Za(t){const e=Ap(null);for(const r of zR(t)){var n=jne(r,2);const i=n[0],o=n[1];Ca(t,i)&&(hp(o)?e[i]=tre(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Za(o):e[i]=o)}return e}function nre(t){switch(typeof t){case"string":return t;case"number":return Zne(t);case"boolean":return Jne(t);case"bigint":return GR?GR(t):"0";case"symbol":return XR?XR(t):"Symbol()";case"undefined":return Ub(t);case"function":case"object":{if(t===null)return Ub(t);const e=t,n=Cs(e,"toString");if(typeof n=="function"){const r=n(e);return typeof r=="string"?r:Ub(r)}return Ub(t)}default:return Ub(t)}}function Cs(t,e){for(;t!==null;){const r=Vne(t,e);if(r){if(r.get)return hi(r.get);if(typeof r.value=="function")return hi(r.value)}t=Kne(t)}function n(){return null}return n}function rre(t){try{return Fo(t,""),!0}catch(e){return!1}}const YR=Di(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Jk=Di(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),eB=Di(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ire=Di(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),tB=Di(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ore=Di(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ZR=Di(["#text"]),JR=Di(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),nB=Di(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),e4=Di(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Nv=Di(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),are=Ki(/{{[\w\W]*|^[\w\W]*}}/g),sre=Ki(/<%[\w\W]*|^[\w\W]*%>/g),cre=Ki(/\${[\w\W]*/g),lre=Ki(/^data-[\-\w.\u00B7-\uFFFF]+$/),ure=Ki(/^aria-[\-\w]+$/),t4=Ki(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dre=Ki(/^(?:\w+script|data):/i),fre=Ki(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Are=Ki(/^html$/i),hre=Ki(/^[a-z][.\w]*(-[.\w]+)+$/i),n4=Ki(/<[/\w!]/g),r4=Ki(/<[/\w]/g),pre=Ki(/<\/no(script|embed|frames)/i),gre=Ki(/\/>/i),Ja={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},i4=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],mre=Di(Bn({},i4)),bre=(function(){const t={};return hA(i4,e=>{t[e]=Ki(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Di(t)})(),yre=function(){return typeof window=="undefined"?null:window},vre=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch(a){return console.warn("TrustedTypes policy "+o+" could not be created."),null}},o4=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ud=function(e,n,r,i){return Ca(e,n)&&hp(e[n])?Bn(i.base?Za(i.base):{},e[n],i.transform):r},rB=function(e,n,r){const i=Ca(e,n)?e[n]:void 0;return i&&typeof i=="object"?Za(i):r()};function a4(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yre();const e=Qe=>a4(Qe);if(e.version="3.4.16",e.removed=[],!t||!t.document||t.document.nodeType!==Ja.document||!t.Element)return e.isSupported=!1,e;let n=t.document;const r=n,i=r.currentScript;t.DocumentFragment;const o=t.HTMLTemplateElement,a=t.Node,s=t.Element,c=t.NodeFilter;t.NamedNodeMap===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const l=t.DOMParser,u=t.trustedTypes,d=s.prototype,f=Cs(d,"cloneNode"),A=Cs(d,"remove"),h=Cs(d,"removeAttributeNode"),p=Cs(d,"nextSibling"),m=Cs(d,"childNodes"),g=Cs(d,"parentNode"),b=Cs(d,"shadowRoot"),y=Cs(d,"attributes"),w=a&&a.prototype?Cs(a.prototype,"nodeType"):null,x=a&&a.prototype?Cs(a.prototype,"nodeName"):null,k=a&&a.prototype?Cs(a.prototype,"ownerDocument"):null,T=function(Y){return w?w(Y):Y.nodeType},_=function(Y){return x?x(Y):Y.nodeName};if(typeof o=="function"){const Qe=n.createElement("template");Qe.content&&Qe.content.ownerDocument&&(n=Qe.content.ownerDocument)}let B,I="",R,C=!1,F=0;const v=function(){if(F>0)throw Id('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},P=function(Y){v(),F++;try{return B.createHTML(Y)}finally{F--}},W=function(Y){v(),F++;try{return B.createScriptURL(Y)}finally{F--}},q=function(){return C||(R=vre(u,i),C=!0),R},ie=n,ne=ie.implementation,le=ie.createNodeIterator,O=ie.createDocumentFragment,D=ie.getElementsByTagName,H=r.importNode;let Q=o4();e.isSupported=typeof zR=="function"&&typeof g=="function"&&ne&&ne.createHTMLDocument!==void 0;const te=are,V=sre,oe=cre,de=lre,Ae=ure,ye=dre,J=fre,j=hre;let Z=t4,L=null;const ae=Bn({},[...YR,...Jk,...eB,...tB,...ZR]);let X=null;const ce=Bn({},[...JR,...nB,...e4,...Nv]);let re=Object.seal(Ap(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ue=null,Se=null;const De=Object.seal(Ap(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Te=!0,Ee=!0,U=!1,z=!0,G=!1,me=!0,ke=!1,Le=!1,Ne=null,ze=null,ut=!1,Ie=!1,qe=!1,Ze=!1,ct=!0,mt=!1;const gt="user-content-";let Ht=!0,It=!1,Mt={},Ut=null;const Jt=Bn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let yt=null;const jt=Bn({},["audio","video","img","source","image","track"]);let Hr=null;const vn=Bn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pe="http://www.w3.org/1998/Math/MathML",we="http://www.w3.org/2000/svg",Be="http://www.w3.org/1999/xhtml";let Ve=Be,rt=!1,ht=null;const nt=Bn({},[pe,we,Be],Zk),Ct=Di(["mi","mo","mn","ms","mtext"]);let qt=Bn({},Ct);const _n=Di(["annotation-xml"]);let kn=Bn({},_n);const Jn=Bn({},["title","style","font","a","script"]);let sn=null;const fn=["application/xhtml+xml","text/html"],dr="text/html";let St=null,hn=null;const fr=n.createElement("form"),rn=function(Y){return Y instanceof RegExp||Y instanceof Function},vt=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(hn&&hn===Y)return;(!Y||typeof Y!="object")&&(Y={}),Y=Za(Y),sn=fn.indexOf(Y.PARSER_MEDIA_TYPE)===-1?dr:Y.PARSER_MEDIA_TYPE,St=sn==="application/xhtml+xml"?Zk:Fb,L=Ud(Y,"ALLOWED_TAGS",ae,{transform:St}),X=Ud(Y,"ALLOWED_ATTR",ce,{transform:St}),ht=Ud(Y,"ALLOWED_NAMESPACES",nt,{transform:Zk}),Hr=Ud(Y,"ADD_URI_SAFE_ATTR",vn,{transform:St,base:vn}),yt=Ud(Y,"ADD_DATA_URI_TAGS",jt,{transform:St,base:jt}),Ut=Ud(Y,"FORBID_CONTENTS",Jt,{transform:St}),ue=Ud(Y,"FORBID_TAGS",Za({}),{transform:St}),Se=Ud(Y,"FORBID_ATTR",Za({}),{transform:St}),Mt=Ca(Y,"USE_PROFILES")?Y.USE_PROFILES&&typeof Y.USE_PROFILES=="object"?Za(Y.USE_PROFILES):Y.USE_PROFILES:!1,Te=Y.ALLOW_ARIA_ATTR!==!1,Ee=Y.ALLOW_DATA_ATTR!==!1,U=Y.ALLOW_UNKNOWN_PROTOCOLS||!1,z=Y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,G=Y.SAFE_FOR_TEMPLATES||!1,me=Y.SAFE_FOR_XML!==!1,ke=Y.WHOLE_DOCUMENT||!1,Ie=Y.RETURN_DOM||!1,qe=Y.RETURN_DOM_FRAGMENT||!1,Ze=Y.RETURN_TRUSTED_TYPE||!1,ut=Y.FORCE_BODY||!1,ct=Y.SANITIZE_DOM!==!1,mt=Y.SANITIZE_NAMED_PROPS||!1,Ht=Y.KEEP_CONTENT!==!1,It=Y.IN_PLACE||!1,Z=rre(Y.ALLOWED_URI_REGEXP)?Y.ALLOWED_URI_REGEXP:t4,Ve=typeof Y.NAMESPACE=="string"?Y.NAMESPACE:Be,qt=rB(Y,"MATHML_TEXT_INTEGRATION_POINTS",()=>Bn({},Ct)),kn=rB(Y,"HTML_INTEGRATION_POINTS",()=>Bn({},_n));const ve=rB(Y,"CUSTOM_ELEMENT_HANDLING",()=>Ap(null));if(re=Ap(null),Ca(ve,"tagNameCheck")&&rn(ve.tagNameCheck)&&(re.tagNameCheck=ve.tagNameCheck),Ca(ve,"attributeNameCheck")&&rn(ve.attributeNameCheck)&&(re.attributeNameCheck=ve.attributeNameCheck),Ca(ve,"allowCustomizedBuiltInElements")&&typeof ve.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=ve.allowCustomizedBuiltInElements),Ki(re),G&&(Ee=!1),qe&&(Ie=!0),Mt&&(L=Bn({},ZR),X=Ap(null),Mt.html===!0&&(Bn(L,YR),Bn(X,JR)),Mt.svg===!0&&(Bn(L,Jk),Bn(X,nB),Bn(X,Nv)),Mt.svgFilters===!0&&(Bn(L,eB),Bn(X,nB),Bn(X,Nv)),Mt.mathMl===!0&&(Bn(L,tB),Bn(X,e4),Bn(X,Nv))),De.tagCheck=null,De.attributeCheck=null,Ca(Y,"ADD_TAGS")&&(typeof Y.ADD_TAGS=="function"?De.tagCheck=Y.ADD_TAGS:hp(Y.ADD_TAGS)&&(L===ae&&(L=Za(L)),Bn(L,Y.ADD_TAGS,St))),Ca(Y,"ADD_ATTR")&&(typeof Y.ADD_ATTR=="function"?De.attributeCheck=Y.ADD_ATTR:hp(Y.ADD_ATTR)&&(X===ce&&(X=Za(X)),Bn(X,Y.ADD_ATTR,St))),Ca(Y,"ADD_FORBID_CONTENTS")&&hp(Y.ADD_FORBID_CONTENTS)&&(Ut===Jt&&(Ut=Za(Ut)),Bn(Ut,Y.ADD_FORBID_CONTENTS,St)),Ht&&(L["#text"]=!0),ke&&Bn(L,["html","head","body"]),L.table&&(Bn(L,["tbody"]),delete ue.tbody),Y.TRUSTED_TYPES_POLICY){if(typeof Y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Id('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Id('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Pe=B;B=Y.TRUSTED_TYPES_POLICY;try{I=P("")}catch(We){throw B=Pe,We}}else Y.TRUSTED_TYPES_POLICY===null?(B=void 0,I=""):(B===void 0&&(B=q()),B&&typeof I=="string"&&(I=P("")));Di&&Di(Y),hn=Y},Re=Bn({},[...Jk,...eB,...ire]),lt=Bn({},[...tB,...ore]),pt=function(Y,ve,Pe){return ve.namespaceURI===Be?Y==="svg":ve.namespaceURI===pe?Y==="svg"&&(Pe==="annotation-xml"||qt[Pe]):!!Re[Y]},Gt=function(Y,ve,Pe){return ve.namespaceURI===Be?Y==="math":ve.namespaceURI===we?Y==="math"&&kn[Pe]:!!lt[Y]},Wn=function(Y,ve,Pe){return ve.namespaceURI===we&&!kn[Pe]||ve.namespaceURI===pe&&!qt[Pe]?!1:!lt[Y]&&(Jn[Y]||!Re[Y])},mn=function(Y){let ve=g(Y);(!ve||!ve.tagName)&&(ve={namespaceURI:Ve,tagName:"template"});const Pe=Fb(Y.tagName),We=Fb(ve.tagName);return ht[Y.namespaceURI]?Y.namespaceURI===we?pt(Pe,ve,We):Y.namespaceURI===pe?Gt(Pe,ve,We):Y.namespaceURI===Be?Wn(Pe,ve,We):!!(sn==="application/xhtml+xml"&&ht[Y.namespaceURI]):!1},Yt=function(Y){Lb(e.removed,{element:Y});try{g(Y).removeChild(Y)}catch(ve){if(A(Y),!g(Y))throw Id("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ar=function(Y,ve,Pe){try{h(Y,ve)}catch(We){try{Y.removeAttribute(Pe)}catch(Ye){}}},An=function(Y){ea(Y);const ve=m(Y);if(ve){const We=[];hA(ve,Ye=>{Lb(We,Ye)}),hA(We,Ye=>{try{A(Ye)}catch(bt){}})}const Pe=y(Y);if(Pe)for(let We=Pe.length-1;We>=0;--We){const Ye=Pe[We],bt=Ye&&Ye.name;typeof bt=="string"&&Ar(Y,Ye,bt)}},wr=function(Y,ve,Pe){if(!Pe)try{Pe=ve.getAttributeNode(Y)}catch(We){Pe=null}Lb(e.removed,{attribute:Pe||null,from:ve});try{Pe?h(ve,Pe):ve.removeAttribute(Y)}catch(We){try{ve.removeAttribute(Y)}catch(Ye){}}if(Y==="is")if(Ie||qe)try{Yt(ve)}catch(We){}else try{ve.setAttribute(Y,"")}catch(We){}},gs=function(Y){const ve=y(Y);if(ve)for(let Pe=ve.length-1;Pe>=0;--Pe){const We=ve[Pe],Ye=We&&We.name;typeof Ye!="string"||X[St(Ye)]||Ar(Y,We,Ye)}},ea=function(Y){const ve=[Y];for(;ve.length>0;){const Pe=ve.pop();T(Pe)===Ja.element&&gs(Pe);const We=m(Pe);if(We)for(let Ye=We.length-1;Ye>=0;--Ye)ve.push(We[Ye])}},ja=function(Y,ve){return me?Y==="patchsrc"?!0:Y==="for"&&ve!=="label"&&ve!=="output":!1},ld=function(Y){if(!me)return;const ve=[Y];for(;ve.length>0;){const Pe=ve.pop(),We=T(Pe);if(We===Ja.processingInstruction||We===Ja.comment&&Fo(r4,Pe.data)){try{A(Pe)}catch(bt){}continue}if(We===Ja.element){const bt=Pe,Et=St(_(Pe));try{bt.hasAttribute&&bt.hasAttribute("patchsrc")&&bt.removeAttribute("patchsrc"),bt.hasAttribute&&bt.hasAttribute("for")&&ja("for",Et)&&bt.removeAttribute("for")}catch(Nt){}}const Ye=m(Pe);if(Ye)for(let bt=Ye.length-1;bt>=0;--bt)ve.push(Ye[bt])}},Kn=function(Y){let ve=null,Pe=null;if(ut)Y="<remove></remove>"+Y;else{const bt=KR(Y,/^[\r\n\t ]+/);Pe=bt&&bt[0]}sn==="application/xhtml+xml"&&Ve===Be&&(Y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Y+"</body></html>");const We=B?P(Y):Y;if(Ve===Be)try{ve=new l().parseFromString(We,sn)}catch(bt){}if(!ve||!ve.documentElement){ve=ne.createDocument(Ve,"template",null);try{ve.documentElement.innerHTML=rt?I:We}catch(bt){}}const Ye=ve.body||ve.documentElement;return Y&&Pe&&Ye.insertBefore(n.createTextNode(Pe),Ye.childNodes[0]||null),Ve===Be?D.call(ve,ke?"html":"body")[0]:ke?ve.documentElement:Ye},ac=function(Y){const ve=k?k(Y):Y.ownerDocument;return le.call(ve||Y,Y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ta=function(Y){return Y=Ib(Y,te," "),Y=Ib(Y,V," "),Y=Ib(Y,oe," "),Y},qa=function(Y){var ve;Y.normalize();const Pe=k?k(Y):Y.ownerDocument,We=le.call(Pe||Y,Y,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let Ye=We.nextNode();for(;Ye;)Ye.data=ta(Ye.data),Ye=We.nextNode();const bt=(ve=Y.querySelectorAll)===null||ve===void 0?void 0:ve.call(Y,"template");bt&&hA(bt,Et=>{$i(Et.content)&&qa(Et.content)})},Eo=function(Y){const ve=x?x(Y):null;return typeof ve!="string"||St(ve)!=="form"?!1:typeof Y.nodeName!="string"||typeof Y.textContent!="string"||typeof Y.removeChild!="function"||Y.attributes!==y(Y)||typeof Y.removeAttribute!="function"||typeof Y.removeAttributeNode!="function"||typeof Y.getAttributeNode!="function"||typeof Y.setAttribute!="function"||typeof Y.namespaceURI!="string"||typeof Y.insertBefore!="function"||typeof Y.hasChildNodes!="function"||Y.nodeType!==w(Y)||Y.childNodes!==m(Y)},$i=function(Y){if(!w||typeof Y!="object"||Y===null)return!1;try{return w(Y)===Ja.documentFragment}catch(ve){return!1}},xr=function(Y){if(!w||typeof Y!="object"||Y===null)return!1;try{return typeof w(Y)=="number"}catch(ve){return!1}};function Qn(Qe,Y,ve){Qe.length!==0&&hA(Qe,Pe=>{Pe.call(e,Y,ve,hn)})}const ki=function(Y,ve){return!!(me&&Y.hasChildNodes()&&!xr(Y.firstElementChild)&&Fo(n4,Y.textContent)&&Fo(n4,Y.innerHTML)||me&&Y.namespaceURI===Be&&mre[ve]&&(xr(Y.firstElementChild)||typeof Y.textContent=="string"&&Fo(bre[ve],Y.textContent))||Y.nodeType===Ja.processingInstruction||me&&Y.nodeType===Ja.comment&&Fo(r4,Y.data))},Co=function(Y,ve){if(Y instanceof RegExp)return Fo(Y,ve);if(Y instanceof Function){for(var Pe=arguments.length,We=new Array(Pe>2?Pe-2:0),Ye=2;Ye<Pe;Ye++)We[Ye-2]=arguments[Ye];return!!Y(ve,...We)}return!1},tu=function(Y,ve,Pe){if(!ue[ve]&&ms(ve)&&Co(re.tagNameCheck,ve))return!1;if(Ht&&!Ut[ve]){const We=g(Y),Ye=m(Y);if(Ye&&We){const bt=Ye.length;for(let Et=bt-1;Et>=0;--Et){const Nt=Y===Pe?f(Ye[Et],!0):Ye[Et];We.insertBefore(Nt,p(Y))}}}return Yt(Y),!0},Vc=function(Y,ve,Pe,We){return Y.length===0?ve:ve===Pe||ve===We?Za(ve):ve},Bi=function(Y,ve){return Y===ve||g(Y)!==null?!1:(It&&ea(Y),!0)},Gc=function(Y,ve){if(Qn(Q.beforeSanitizeElements,Y,null),Bi(Y,ve))return!0;if(Eo(Y))return Yt(Y),!0;const Pe=St(_(Y));if(L=Vc(Q.uponSanitizeElement,L,ae,Ne),Qn(Q.uponSanitizeElement,Y,{tagName:Pe,allowedTags:L}),Bi(Y,ve))return!0;if(ki(Y,Pe))return Yt(Y),!0;if(ue[Pe]||!(De.tagCheck instanceof Function&&De.tagCheck(Pe))&&!L[Pe]){const We=tu(Y,Pe,ve);return We===!1&&(Qn(Q.afterSanitizeElements,Y,null),Bi(Y,ve))?!0:We}if(T(Y)===Ja.element&&!mn(Y)||(Pe==="noscript"||Pe==="noembed"||Pe==="noframes")&&Fo(pre,Y.innerHTML))return Yt(Y),!0;if(G&&Y.nodeType===Ja.text){const We=ta(Y.textContent);Y.textContent!==We&&(Lb(e.removed,{element:Y.cloneNode()}),Y.textContent=We)}return Qn(Q.afterSanitizeElements,Y,null),Bi(Y,ve)},sc=function(Y,ve,Pe){if(Se[ve]||ja(ve,Y)||ct&&(ve==="id"||ve==="name")&&(Pe in n||Pe in fr))return!1;const We=X[ve]||De.attributeCheck instanceof Function&&De.attributeCheck(ve,Y);return Ee&&Fo(de,ve)||Te&&Fo(Ae,ve)?!0:We?Hr[ve]||Fo(Z,Ib(Pe,J,""))||(ve==="src"||ve==="xlink:href"||ve==="href")&&Y!=="script"&&VR(Pe,"data:")===0&&yt[Y]||U&&!Fo(ye,Ib(Pe,J,""))?!0:!Pe:ms(Y)&&Co(re.tagNameCheck,Y)&&Co(re.attributeNameCheck,ve,Y)||ve==="is"&&re.allowCustomizedBuiltInElements&&Co(re.tagNameCheck,Pe)},ud=Bn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ms=function(Y){return!ud[Fb(Y)]&&Fo(j,Y)},dd=function(Y,ve,Pe,We){if(B&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!Pe)switch(u.getAttributeType(Y,ve)){case"TrustedHTML":return P(We);case"TrustedScriptURL":return W(We)}return We},fd=function(Y,ve,Pe,We){try{return Pe?Y.setAttributeNS(Pe,ve,We):Y.setAttribute(ve,We),Eo(Y)?(Yt(Y),!1):!0}catch(Ye){return wr(ve,Y),!1}},Xc=function(Y,ve){if(Qn(Q.beforeSanitizeAttributes,Y,null),Bi(Y,ve))return;const Pe=Y.attributes;if(!Pe||Eo(Y))return;X=Vc(Q.uponSanitizeAttribute,X,ce,ze);const We={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0};let Ye=Pe.length;const bt=St(Y.nodeName);for(;Ye--;){const Et=Pe[Ye],Nt=Et.name,In=Et.namespaceURI,xn=Et.value,Jr=St(Nt),na=xn;let bn=Nt==="value"?na:Yne(na),Yc=!1;if(We.attrName=Jr,We.attrValue=bn,We.keepAttr=!0,We.forceKeepAttr=void 0,Qn(Q.uponSanitizeAttribute,Y,We),bn=We.attrValue,mt&&(Jr==="id"||Jr==="name")&&VR(bn,gt)!==0&&(wr(Nt,Y,Et),bn=gt+bn,Yc=!0),me&&Fo(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,bn)){wr(Nt,Y,Et);continue}if(Jr==="attributename"&&KR(bn,"href")){wr(Nt,Y,Et);continue}if(!We.forceKeepAttr){if(!We.keepAttr){wr(Nt,Y,Et);continue}if(!z&&Fo(gre,bn)){wr(Nt,Y,Et);continue}if(G&&(bn=ta(bn)),!sc(bt,Jr,bn)){wr(Nt,Y,Et);continue}bn=dd(bt,Jr,In,bn),bn!==na&&fd(Y,Nt,In,bn)&&Yc&&WR(e.removed)}}Qn(Q.afterSanitizeAttributes,Y,null),Bi(Y,ve)},di=function(Y){let ve=null;const Pe=ac(Y);for(Qn(Q.beforeSanitizeShadowDOM,Y,null);ve=Pe.nextNode();)if(Qn(Q.uponSanitizeShadowNode,ve,null),Gc(ve,Y),Xc(ve,Y),$i(ve.content)&&di(ve.content),T(ve)===Ja.element){const We=b(ve);$i(We)&&(To(We),di(We))}Qn(Q.afterSanitizeShadowDOM,Y,null)},To=function(Y){const ve=[{node:Y,shadow:null}];for(;ve.length>0;){const Pe=ve.pop();if(Pe.shadow){di(Pe.shadow);continue}const We=Pe.node,Ye=T(We)===Ja.element,bt=m(We);if(bt)for(let Et=bt.length-1;Et>=0;--Et)ve.push({node:bt[Et],shadow:null});if(Ye){const Et=x?x(We):null;if(typeof Et=="string"&&St(Et)==="template"){const Nt=We.content;$i(Nt)&&ve.push({node:Nt,shadow:null})}}if(Ye){const Et=b(We);$i(Et)&&ve.push({node:null,shadow:Et},{node:Et,shadow:null})}}};return e.sanitize=function(Qe){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=null,Pe=null,We=null,Ye=null;if(rt=!Qe,rt&&(Qe="<!-->"),typeof Qe!="string"&&!xr(Qe)&&(Qe=nre(Qe),typeof Qe!="string"))throw Id("dirty is not a string, aborting");if(!e.isSupported)return Qe;Le?(L=Ne,X=ze):vt(Y),(Q.uponSanitizeElement.length>0||Q.uponSanitizeAttribute.length>0)&&(L=Za(L)),Q.uponSanitizeAttribute.length>0&&(X=Za(X)),e.removed=[];const bt=It&&typeof Qe!="string"&&xr(Qe);if(bt){ld(Qe);const In=_(Qe);if(typeof In=="string"){const xn=St(In);if(!L[xn]||ue[xn])throw An(Qe),Id("root node is forbidden and cannot be sanitized in-place")}if(Eo(Qe))throw An(Qe),Id("root node is clobbered and cannot be sanitized in-place");try{To(Qe)}catch(xn){throw An(Qe),xn}}else if(xr(Qe))ve=Kn("<!---->"),Pe=ve.ownerDocument.importNode(Qe,!0),Pe.nodeType===Ja.element&&Pe.nodeName==="BODY"||Pe.nodeName==="HTML"?ve=Pe:ve.appendChild(Pe),To(ve);else{if(!Ie&&!G&&!ke&&Qe.indexOf("<")===-1)return B&&Ze?P(Qe):Qe;if(ve=Kn(Qe),!ve)return Ie?null:Ze?I:""}ve&&ut&&Yt(ve.firstChild);const Et=bt?Qe:ve;try{const In=ac(Et);for(;We=In.nextNode();)Gc(We,Et),Xc(We,Et),$i(We.content)&&di(We.content)}catch(In){throw bt&&(An(Qe),hA(e.removed,xn=>{xn.element&&ea(xn.element)})),In}if(bt){let In=!1;if(hA(e.removed,xn=>{xn.element&&(xn.element===Qe&&(In=!0),ea(xn.element))}),In)throw Id("a node selected for removal could not be safely returned; refusing to sanitize in place");return G&&qa(Qe),Qe}if(Ie){if(G&&qa(ve),qe)for(Ye=O.call(ve.ownerDocument);ve.firstChild;)Ye.appendChild(ve.firstChild);else Ye=ve;return(X.shadowroot||X.shadowrootmode)&&(Ye=H.call(r,Ye,!0)),Ye}let Nt=ke?ve.outerHTML:ve.innerHTML;return ke&&L["!doctype"]&&ve.ownerDocument&&ve.ownerDocument.doctype&&ve.ownerDocument.doctype.name&&Fo(Are,ve.ownerDocument.doctype.name)&&(Nt="<!DOCTYPE "+ve.ownerDocument.doctype.name+`>
|
|
11
|
-
`+Nt),G&&(Nt=ta(Nt)),B&&Ze?P(Nt):Nt},e.setConfig=function(){let Qe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(Qe),Le=!0,Ne=L,ze=X},e.clearConfig=function(){hn=null,Le=!1,Ne=null,ze=null,B=R,I=""},e.isValidAttribute=function(Qe,Y,ve){hn||vt({});const Pe=St(Qe),We=St(Y);return sc(Pe,We,ve)},e.addHook=function(Qe,Y){typeof Y=="function"&&Ca(Q,Qe)&&Lb(Q[Qe],Y)},e.removeHook=function(Qe,Y){if(Ca(Q,Qe)){if(Y!==void 0){const ve=Gne(Q[Qe],Y);return ve===-1?void 0:Xne(Q[Qe],ve,1)[0]}return WR(Q[Qe])}},e.removeHooks=function(Qe){Ca(Q,Qe)&&(Q[Qe]=[])},e.removeAllHooks=function(){Q=o4()},e}var Rv=a4();const wre=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],xre={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},Ere="data-editora-embed";function Cre(t){if(!t||/\s/.test(t.trim()))return!1;try{const e=new URL(t.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function s4(t,e,n,r){if((e==null?void 0:e.sanitize)===!1)return t;const i=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:wre,o=n!=null&&n.length?Array.from(new Set([...i,...n])):i,s=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:xre,c=new Set;for(const d of Object.values(s))for(const f of d)c.add(f);const l={ALLOWED_TAGS:o,ALLOWED_ATTR:Array.from(c)};if(!r)return Rv.sanitize(t,l);const u=o.includes("iframe");Rv.addHook("uponSanitizeElement",(d,f)=>{var h;if(f.tagName!=="iframe")return;const A=d;f.allowedTags.iframe=u||((h=A.getAttribute)==null?void 0:h.call(A,Ere))==="true"&&Cre(A.getAttribute("src"))});try{return Rv.sanitize(t,l)}finally{Rv.removeHook("uponSanitizeElement")}}function Tre(t,e,n,r){return s4(t,e,r,!1)}function kre(t,e,n){return(n==null?void 0:n.sanitizeOnPaste)===!1?t:Tre(t,e)}function c4(t,e,n,r){return(n==null?void 0:n.sanitizeOnInput)===!1?t:s4(t,e,r,!0)}const Bre=".resize-handle, .table-resize-handle",Sre=/resize-handle/;function l4(t){if(!t||!Sre.test(t))return t;const e=document.createElement("template");e.innerHTML=t;const n=new Set;return e.content.querySelectorAll(Bre).forEach(r=>{const i=r.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&n.add(i),r.remove()}),n.forEach(r=>{var i;r.style.position==="relative"&&(r.style.removeProperty("position"),(i=r.getAttribute("style"))!=null&&i.trim()||r.removeAttribute("style"))}),e.innerHTML}function Nb(t){return t?l4(t.innerHTML):""}const xk=class xk{static resolve(e){const n={};if(Object.assign(n,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(n,e.pluginDefaults),e.attributes){const r=this.parseAttributes(e.attributes);Object.assign(n,r)}return e.jsConfig&&Object.assign(n,e.jsConfig),this.normalizeConfig(n)}static normalizeConfig(e){const n={...e};if(n.toolbarFloating!==void 0||n.toolbarSticky!==void 0){const a=typeof n.toolbar=="object"&&n.toolbar?{...n.toolbar}:typeof n.toolbar=="string"?{items:n.toolbar}:{};n.toolbarFloating!==void 0&&(a.floating=!!n.toolbarFloating),n.toolbarSticky!==void 0&&(a.sticky=!!n.toolbarSticky),n.toolbar=a}if(n.toolbarItems!==void 0&&typeof n.toolbar=="object"&&n.toolbar&&(n.toolbar.items=n.toolbarItems),n.autosaveEnabled!==void 0||n.autosaveIntervalMs!==void 0||n.autosaveStorageKey!==void 0||n.autosaveProvider!==void 0||n.autosaveApiUrl!==void 0){const a=typeof n.autosave=="object"&&n.autosave?{...n.autosave}:{};n.autosaveEnabled!==void 0&&(a.enabled=!!n.autosaveEnabled),n.autosaveIntervalMs!==void 0&&(a.intervalMs=Number(n.autosaveIntervalMs)),n.autosaveStorageKey!==void 0&&(a.storageKey=n.autosaveStorageKey),n.autosaveProvider!==void 0&&(a.provider=n.autosaveProvider),n.autosaveApiUrl!==void 0&&(a.apiUrl=n.autosaveApiUrl),n.autosave=a}const r={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof n.autosave=="boolean")n.autosave={...r,enabled:n.autosave};else if(typeof n.autosave=="object"&&n.autosave){const a={...r,...n.autosave};a.intervalMs===void 0&&a.interval!==void 0&&(a.intervalMs=Number(a.interval)),a.enabled===void 0&&(a.enabled=!0),(!Number.isFinite(a.intervalMs)||a.intervalMs<=0)&&(a.intervalMs=r.intervalMs),n.autosave=a}else n.autosave=r;if(n.languageLocale!==void 0||n.languageDirection!==void 0){const a=typeof n.language=="object"&&n.language?{...n.language}:{};n.languageLocale!==void 0&&(a.locale=n.languageLocale),n.languageDirection!==void 0&&(a.direction=n.languageDirection),n.language=a}const i={locale:"en",direction:"ltr"};if(typeof n.language=="string"?n.language={locale:n.language,direction:i.direction}:typeof n.language=="object"&&n.language?n.language={...i,...n.language}:n.language=i,n.spellcheckEnabled!==void 0||n.spellcheckProvider!==void 0||n.spellcheckApiUrl!==void 0){const a=typeof n.spellcheck=="object"&&n.spellcheck?{...n.spellcheck}:{};n.spellcheckEnabled!==void 0&&(a.enabled=!!n.spellcheckEnabled),n.spellcheckProvider!==void 0&&(a.provider=n.spellcheckProvider),n.spellcheckApiUrl!==void 0&&(a.apiUrl=n.spellcheckApiUrl),n.spellcheck=a}const o={enabled:!1,provider:"browser",apiUrl:""};if(typeof n.spellcheck=="boolean")n.spellcheck={...o,enabled:n.spellcheck};else if(typeof n.spellcheck=="object"&&n.spellcheck){const a={...o,...n.spellcheck};!a.provider&&a.mode&&(a.provider=a.mode==="local"?"browser":"api"),a.enabled===void 0&&(a.enabled=!!(a.mode||a.provider||a.apiUrl)),n.spellcheck=a}else n.spellcheck=o;return n.contextMenuEnabled!==void 0&&(n.contextMenu={enabled:!!n.contextMenuEnabled}),typeof n.contextMenu=="boolean"?n.contextMenu={enabled:n.contextMenu}:typeof n.contextMenu=="object"&&n.contextMenu?n.contextMenu={enabled:n.contextMenu.enabled!==!1}:n.contextMenu={enabled:!0},(n.pasteClean!==void 0||n.pasteKeepFormatting!==void 0||n.pasteConvertWord!==void 0)&&(n.paste={...n.paste||{},...n.pasteClean!==void 0?{clean:!!n.pasteClean}:{},...n.pasteKeepFormatting!==void 0?{keepFormatting:!!n.pasteKeepFormatting}:{},...n.pasteConvertWord!==void 0?{convertWord:!!n.pasteConvertWord}:{}}),n.paste={clean:!0,keepFormatting:!1,convertWord:!0,...n.paste||{}},n.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...n.contentConfig||{}},(n.securitySanitizeOnPaste!==void 0||n.securitySanitizeOnInput!==void 0)&&(n.security={...n.security||{},...n.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!n.securitySanitizeOnPaste}:{},...n.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!n.securitySanitizeOnInput}:{}}),n.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...n.security||{}},(n.accessibilityEnableAria!==void 0||n.accessibilityKeyboardNavigation!==void 0||n.accessibilityChecker!==void 0)&&(n.accessibility={...n.accessibility||{},...n.accessibilityEnableAria!==void 0?{enableARIA:!!n.accessibilityEnableAria}:{},...n.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!n.accessibilityKeyboardNavigation}:{},...n.accessibilityChecker!==void 0?{checker:!!n.accessibilityChecker}:{}}),typeof n.accessibility=="boolean"&&(n.accessibility={enableARIA:n.accessibility,keyboardNavigation:n.accessibility,checker:!1}),n.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...n.accessibility||{}},(n.performanceDebounceInputMs!==void 0||n.performanceViewportOnlyScan!==void 0)&&(n.performance={...n.performance||{},...n.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(n.performanceDebounceInputMs)}:{},...n.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!n.performanceViewportOnlyScan}:{}}),typeof n.performance=="boolean"&&(n.performance={debounceInputMs:100,viewportOnlyScan:n.performance}),n.performance={debounceInputMs:100,viewportOnlyScan:!0,...n.performance||{}},(typeof n.performance.debounceInputMs!="number"||!Number.isFinite(n.performance.debounceInputMs)||n.performance.debounceInputMs<0)&&(n.performance.debounceInputMs=100),n}static parseAttributes(e){const n={};for(const[r,i]of Object.entries(e)){const o=this.kebabToCamel(r);n[o]=this.BOOLEAN_ATTRIBUTES.has(r)&&(i===""||i===r)?!0:this.parseAttributeValue(i)}return n}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(n){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(n,r)=>r.toUpperCase())}static validate(e){const n=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&n.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&n.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&n.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&n.push("theme must be a string"),{valid:n.length===0,errors:n}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const n={};for(const r of e)for(const[i,o]of Object.entries(r))o!=null&&(typeof o=="object"&&!Array.isArray(o)&&n[i]?n[i]=this.merge(n[i],o):n[i]=o);return n}};xk.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},xk.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let iB=xk;const _re='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Ov;const Dre="__editoraCommandEditorRoot",Lre="__editoraLastCommandButton",u4="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",d4=".rte-content, .editora-content",Fre="Rich text editor",oB=new Set;let Nd=null,f4=!1,aB=null,sB=null;function A4(t){if(!(t instanceof HTMLElement))return!1;const e=t;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function Ire(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Rb(t){if(!t)return null;if(A4(t))return t;const e=t.matches(u4)?t:t.closest(u4);return!e||!A4(e)?null:e}function Ure(){var i;if(typeof window=="undefined")return null;const t=window[Dre];if(t instanceof HTMLElement){const o=Rb(t);if(o)return o;const a=t.matches(d4)?t:t.querySelector(d4);if(a){const s=Rb(a);if(s)return s}}const e=window[Lre];if(e instanceof HTMLElement){const o=Rb(e);if(o)return o}const n=document.activeElement;if(n){const o=Rb(n);if(o)return o}const r=(i=window.getSelection)==null?void 0:i.call(window);if(r&&r.rangeCount>0){const o=Rb(Ire(r.getRangeAt(0).startContainer));if(o)return o}if(Nd&&Nd.isConnected)return Nd;for(const o of oB)if(o.isConnected)return o;return null}function Nre(){if(typeof window=="undefined"||f4)return;aB=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,sB=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const t=(e,...n)=>{const r=Ure();return r?r.execCommand(e,...n):aB?aB(e,...n):sB?sB(e,...n):!1};window.executeEditorCommand=t,window.execEditorCommand=t,f4=!0}function Rre(){const t="editora-webcomponent-styles";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=_re,document.head.appendChild(e)}}function Ore(){if(!Ov){const t=Ts.__globalPluginLoader;t?Ov=t:Ov=new AA}return Ov}class Ts extends HTMLElement{constructor(){if(super(),this.pluginLoader=Ore(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Hne,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,Rre(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(Ts.__globalPluginLoader){this.pluginLoader=Ts.__globalPluginLoader;return}return new Promise(e=>{const n=()=>{Ts.__globalPluginLoader?(this.pluginLoader=Ts.__globalPluginLoader,e()):setTimeout(n,0)};n()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,n,r){n!==r&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,r))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var i;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),oB.add(this),Nd||(Nd=this),Nre(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();if(this.loadedPlugins=e,e.forEach(o=>{if(o.init&&typeof o.init=="function")try{o.init({editorElement:this})}catch(a){console.error(`[RichTextEditor] Error initializing plugin ${o.name}:`,a)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const o=this.innerHTML.trim();o&&this.setAttribute("data-initial-content",o)}const n=this.preservedContent;this.preservedContent=null;const r=this.sanitizeLoadedContent((i=n!=null?n:this.restoreAutosavedContent())!=null?i:this.getAttribute("data-initial-content")||"");this.engine=new Lne({content:r,plugins:e,readonly:this.config.readonly}),this.createUI(e,r),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(r=>r.nodeType===Node.TEXT_NODE?r.textContent:r.nodeType===Node.ELEMENT_NODE?r.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],n=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(n){if(typeof this.config.plugins=="string"){const o=this.config.plugins.split(/\s+/).filter(Boolean);i&&!o.includes("a11yChecker")&&o.push("a11yChecker");for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}else if(Array.isArray(this.config.plugins)){for(const o of this.config.plugins)if(typeof o=="string"){const a=await this.pluginLoader.load(o,this.getPluginLoadConfig(o));a&&e.push(a)}else e.push(o);if(i&&!e.some(o=>(o==null?void 0:o.name)==="a11yChecker")){const o=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));o&&e.push(o)}}}else{const o=this.pluginLoader.getRegisteredPluginNames();for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const n=this.config.toolbar;if(typeof n=="string")return n;if(!n||typeof n!="object")return;const r=n.items;if(typeof r=="string")return r;if(Array.isArray(r))return r.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var n;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const r=Number((n=e.debounceInputMs)!=null?n:100);return{debounceInputMs:Number.isFinite(r)&&r>=0?r:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){var n;if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const r=(n=this.getAttribute("aria-label"))==null?void 0:n.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",r||i||Fre)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const n=e.provider||"browser";return{enabled:!!e.enabled,provider:n,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),n=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=n,this.contentElement.setAttribute("spellcheck",n?"true":"false")}executeCommand(e,...n){var o;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const r={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(a=>a.commands&&a.commands[e]);if(i&&i.commands){const a=i.commands[e];if(typeof a=="function")try{return e==="toggleFullscreen"?a(this,r):a(...n,r),!0}catch(s){return console.error(`[RichTextEditor] Error executing native command ${e}:`,s),!1}}return((o=this.engine)==null?void 0:o.execCommand(e,...n))||!1}getPluginLoadConfig(e){const n=this.config.pluginConfig;if(n&&typeof n=="object"){const o=n[e];if(o&&typeof o=="object")return o}const r={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[e,e.toLowerCase(),...r[e]||[]];for(const o of i){const a=this.config[o];if(a&&typeof a=="object"&&!Array.isArray(a))return a}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(e){return c4(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var n,r;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((r=(n=e.intervalMs)!=null?n:e.interval)!=null?r:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const n=this.getAutosaveConfig();if(n.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,n.provider==="localStorage"){try{localStorage.setItem(n.storageKey,e),localStorage.setItem(`${n.storageKey}-timestamp`,Date.now().toString())}catch(r){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",r)}return}n.provider==="api"&&n.apiUrl&&fetch(n.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(r=>{console.error("[RichTextEditor] Failed to save autosave content to API:",r)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const n=localStorage.getItem(e.storageKey);if(n)return this.lastAutosavedContent=n,n}catch(n){console.error("[RichTextEditor] Failed to restore autosaved content:",n)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(Nb(this.contentElement))},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);r.deleteContents();const i=document.createElement("div");i.innerHTML=e;const o=document.createDocumentFragment();for(;i.firstChild;)o.appendChild(i.firstChild);r.insertNode(o),r.collapse(!1),n.removeAllRanges(),n.addRange(r)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,n){const r=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!r?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Fne({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((o,a)=>{var s;if(this.contentElement){this.contentElement.focus();const c=window.getSelection();if(!c||c.rangeCount===0||!this.contentElement.contains(c.anchorNode)){const l=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?l.setStart(u,((s=u.textContent)==null?void 0:s.length)||0):u.nodeType===Node.ELEMENT_NODE?(l.selectNodeContents(u),l.collapse(!1)):l.setStart(this.contentElement,0),l.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(l)}}return this.executeCommand(o,a)}),this.toolbar.render(this.toolbarElement)):r&&this.appendChild(r),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(o){console.warn("defaultParagraphSeparator not supported:",o)}if(n){const o=document.createElement("div");o.innerHTML=n.trim(),!Array.from(o.childNodes).some(s=>{if(s.nodeType===Node.ELEMENT_NODE){const c=s.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(c)}return!1})&&n.trim()?this.contentElement.innerHTML=`<p>${n.trim()}</p>`:this.contentElement.innerHTML=n}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Ine({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Une({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var o;return(o=this.contentElement)==null?void 0:o.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",r=>{this.lastBeforeInputType=r.inputType||null}),this.contentElement.addEventListener("input",r=>{var f;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const o=(f=r==null?void 0:r.detail)==null?void 0:f.allowedTags,a=this.getPerformanceConfig(),s=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),l=this.lastBeforeInputType;if(this.lastBeforeInputType=null,c.sanitizeOnInput!==!1&&s.sanitize!==!1&&!l){const A=c4(i,s,c,o);if(A!==i){const h=window.getSelection(),p=h&&h.rangeCount>0?h.getRangeAt(0):null;if(this.contentElement.innerHTML=A,p&&h)try{h.removeAllRanges(),h.addRange(p)}catch(m){}i=A}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const d=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:l4(i)},bubbles:!0}))};a.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(d,a.debounceInputMs):d(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",r=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&r.preventDefault()}),this.contentElement.addEventListener("paste",r=>{var u,d;if(r.__editoraSmartPasteHandled===!0||r.defaultPrevented)return;r.preventDefault();const i=this.config.paste||{};let o=((u=r.clipboardData)==null?void 0:u.getData("text/html"))||"";const a=((d=r.clipboardData)==null?void 0:d.getData("text/plain"))||"",s=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),l=!!o&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(o);if((i.clean||!i.keepFormatting)&&a){document.execCommand("insertText",!1,a);return}if(i.convertWord===!1&&l&&a){document.execCommand("insertText",!1,a);return}if(o){c.sanitizeOnPaste!==!1&&s.sanitize!==!1&&(o=kre(o,s,c)),this.insertHTMLAtSelection(o);return}a&&document.execCommand("insertText",!1,a)}),this.contentElement.addEventListener("focus",()=>{Nd=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Nb(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",r=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(r,(o,a)=>{this.executeCommand(o,a)})});const n=()=>{const r=this.getSelectionRangeInEditor(),i=document.activeElement,o=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!o||!r&&!o||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=n,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0),r=n.commonAncestorContainer;return this.contentElement.contains(r)?n:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const n=document.createRange();return n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.collapsed}catch(n){return!1}}getSelectionAnchorRect(e,n){const r=Array.from(n.getClientRects()).filter(o=>o.width>0||o.height>0);return r.length===0?n.getBoundingClientRect():this.isSelectionBackward(e)?r[0]:r[r.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const n=this.getPerformanceConfig(),r=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(n.viewportOnlyScan&&!this.isEditorInViewport()&&!r){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const o=window.getSelection();if(!o){this.floatingToolbar.hide();return}const a=this.getSelectionAnchorRect(o,i);if(!a){this.floatingToolbar.hide();return}this.floatingToolbar.show(a.left,a.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),n=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!n)return;const r=this.contentElement.textContent||"",{words:i,chars:o}=Mne(r),a=One(this.contentElement);let s,c;const l=this.getSelectionRangeInEditor();l&&(s=Nne(this.contentElement,l),l.collapsed||(c=Pne(l,s),s=void 0)),this.statusBar.update({wordCount:i,charCount:o,lineCount:a,cursorPosition:s,selectionInfo:c})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,n){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(n)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(n));break;case"theme":this.classList.forEach(r=>{r.startsWith("editora-theme-")&&this.classList.remove(r)}),n&&this.classList.add(`editora-theme-${n}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",n),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(r=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",r)})}));break}}resolveConfig(){const e={};for(let n=0;n<this.attributes.length;n++){const r=this.attributes[n];e[r.name]=r.value}return iB.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>Nb(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))},execCommand:(e,n)=>this.executeCommand(e,n),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,n)=>(this.addEventListener(e,n),()=>this.removeEventListener(e,n)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,n,r,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=Nb(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(n=this.toolbar)==null||n.destroy(),(r=this.floatingToolbar)==null||r.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,oB.delete(this),Nd===this&&(Nd=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return Nb(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))}execCommand(e,...n){return this.executeCommand(e,...n)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}const Mv=new AA;Ts.__globalPluginLoader=Mv;const Mre={bold:()=>Promise.resolve().then(()=>jre).then(t=>t.BoldPlugin()),italic:()=>Promise.resolve().then(()=>Wre).then(t=>t.ItalicPlugin()),underline:()=>Promise.resolve().then(()=>Kre).then(t=>t.UnderlinePlugin()),strikethrough:()=>Promise.resolve().then(()=>Xre).then(t=>t.StrikethroughPlugin()),clearFormatting:()=>Promise.resolve().then(()=>lie).then(t=>t.ClearFormattingPlugin()),heading:()=>Promise.resolve().then(()=>Cie).then(t=>t.HeadingPlugin()),blockquote:()=>Promise.resolve().then(()=>Rie).then(t=>t.BlockquotePlugin()),code:()=>Promise.resolve().then(()=>Foe).then(t=>t.CodePlugin()),codeSample:()=>Promise.resolve().then(()=>joe).then(t=>t.CodeSamplePlugin()),list:()=>Promise.resolve().then(()=>Goe).then(t=>t.ListPlugin()),checklist:()=>Promise.resolve().then(()=>uae).then(t=>t.ChecklistPlugin()),textAlignment:()=>Promise.resolve().then(()=>Aae).then(t=>t.TextAlignmentPlugin()),indent:()=>Promise.resolve().then(()=>hae).then(t=>t.IndentPlugin()),direction:()=>Promise.resolve().then(()=>Eae).then(t=>t.DirectionPlugin()),textColor:()=>Promise.resolve().then(()=>Mae).then(t=>t.TextColorPlugin()),backgroundColor:()=>Promise.resolve().then(()=>Vae).then(t=>t.BackgroundColorPlugin()),fontSize:()=>Promise.resolve().then(()=>ose).then(t=>t.FontSizePlugin()),fontFamily:()=>Promise.resolve().then(()=>gse).then(t=>t.FontFamilyPlugin()),formatPainter:()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),"format-painter":()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),formatpainter:()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),lineHeight:()=>Promise.resolve().then(()=>wce).then(t=>t.LineHeightPlugin()),capitalization:()=>Promise.resolve().then(()=>Ice).then(t=>t.CapitalizationPlugin()),history:()=>Promise.resolve().then(()=>Oce).then(t=>t.HistoryPlugin()),link:()=>Promise.resolve().then(()=>jce).then(t=>t.LinkPlugin()),table:()=>Promise.resolve().then(()=>fle).then(t=>t.TablePlugin()),trackChanges:()=>Promise.resolve().then(()=>Kle).then(t=>t.TrackChangesPlugin()),versionDiff:()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),"version-diff":()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),versiondiff:()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),conditionalContent:()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),"conditional-content":()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),conditionalcontent:()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),dataBinding:()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),"data-binding":()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),databinding:()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),docSchema:()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),"doc-schema":()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),docschema:()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),translationWorkflow:()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),"translation-workflow":()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),translationworkflow:()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),contentRules:()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),"content-rules":()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),contentrules:()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),citations:()=>Promise.resolve().then(()=>d9).then(t=>t.CitationsPlugin()),citation:()=>Promise.resolve().then(()=>d9).then(t=>t.CitationsPlugin()),approvalWorkflow:()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),"approval-workflow":()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),approvalworkflow:()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),piiRedaction:()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),"pii-redaction":()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),piiredaction:()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),smartPaste:()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),"smart-paste":()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),smartpaste:()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),blocksLibrary:()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),"blocks-library":()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),blockslibrary:()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),mentions:()=>Promise.resolve().then(()=>RH).then(t=>t.MentionPlugin()),mention:()=>Promise.resolve().then(()=>RH).then(t=>t.MentionPlugin()),anchor:()=>Promise.resolve().then(()=>Xpe).then(t=>t.AnchorPlugin()),embedIframe:()=>Promise.resolve().then(()=>yge).then(t=>t.EmbedIframePlugin()),math:()=>Promise.resolve().then(()=>Uge).then(t=>t.MathPlugin()),image:()=>Promise.resolve().then(()=>$ge).then(t=>t.MediaManagerPlugin()),mergeTag:()=>Promise.resolve().then(()=>cme).then(t=>t.MergeTagPlugin()),pageBreak:()=>Promise.resolve().then(()=>yme).then(t=>t.PageBreakPlugin()),print:()=>Promise.resolve().then(()=>wme).then(t=>t.PrintPlugin()),preview:()=>Promise.resolve().then(()=>Bme).then(t=>t.PreviewPlugin()),specialCharacters:()=>Promise.resolve().then(()=>Ome).then(t=>t.SpecialCharactersPlugin()),slashCommands:()=>Promise.resolve().then(()=>FQ).then(t=>t.SlashCommandsPlugin()),"slash-commands":()=>Promise.resolve().then(()=>FQ).then(t=>t.SlashCommandsPlugin()),spellCheck:()=>Promise.resolve().then(()=>Ube).then(t=>t.SpellCheckPlugin()),emojis:()=>Promise.resolve().then(()=>zbe).then(t=>t.EmojisPlugin()),a11yChecker:()=>Promise.resolve().then(()=>Kbe).then(t=>t.A11yCheckerPlugin()),comments:()=>Promise.resolve().then(()=>sye).then(t=>t.CommentsPlugin()),collaboration:()=>Promise.resolve().then(()=>gwe).then(t=>t.CollaborationPlugin()),"document-manager":()=>Promise.resolve().then(()=>ywe).then(t=>t.DocumentManagerPlugin()),fullscreen:()=>Promise.resolve().then(()=>wwe).then(t=>t.FullscreenPlugin()),template:()=>Promise.resolve().then(()=>Owe).then(t=>t.TemplatePlugin()),footnote:()=>Promise.resolve().then(()=>Ywe).then(t=>t.FootnotePlugin())};async function h4(){return Object.entries(Mre).forEach(([t,e])=>{Mv.register(t,e)}),Mv}typeof window!="undefined"&&h4().then(t=>{Ts.__globalPluginLoader=t,customElements.get("editora-editor")||customElements.define("editora-editor",Ts);const e=document.querySelectorAll("editora-editor:not([data-initial-content])"),n=[];e.forEach(o=>{const a=o.innerHTML.trim();n.push(a),a&&o.setAttribute("data-initial-content",a)});const r=document.querySelectorAll("editora-editor");Array.from(r).filter(o=>!o.hasAttribute("data-initial-content")).forEach(o=>{const a=Array.from(r).indexOf(o);n[a]&&o.setAttribute("data-initial-content",n[a])}),window.Editora={version:"1.0.0",plugins:Mv.getRegisteredPluginNames(),WebComponent:Ts,init:async(o,a)=>{const s=document.querySelector(o);return s instanceof Ts?(a&&await s.setConfig(a),s.getAPI()):null}}});const Pv="data-editora-selection-marker";function Pre(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function p4(t){return t?t.getAttribute("contenteditable")==="true"?t:t.querySelector('[contenteditable="true"]'):null}function Hre(t){var a;if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;const e=p4((a=t==null?void 0:t.editorElement)!=null?a:null);if(e)return e;const n=typeof window!="undefined"?window.__editoraCommandEditorRoot:null,r=n instanceof HTMLElement?p4(n):null;if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const s=Pre(i.getRangeAt(0).startContainer),c=s==null?void 0:s.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}const o=document.activeElement;if(o instanceof HTMLElement){const s=o.closest('.rte-content, .editora-content, [contenteditable="true"]');if(s instanceof HTMLElement)return s}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function Qre(t){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);return t.contains(n.startContainer)&&t.contains(n.endContainer)}function g4(t){const e=document.createElement("span");return e.setAttribute(Pv,t),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function $re(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer)||!t.contains(n.endContainer))return null;const r=n.collapsed,i=g4("start"),o=r?null:g4("end"),a=n.cloneRange();if(o){const c=a.cloneRange();c.collapse(!1),c.insertNode(o)}const s=a.cloneRange();return s.collapse(!0),s.insertNode(i),()=>{const c=window.getSelection(),l=document.createRange(),u=t.querySelector(`[${Pv}="start"]`),d=t.querySelector(`[${Pv}="end"]`);if(!c||!u){t.querySelectorAll(`[${Pv}]`).forEach(f=>f.remove());return}r||!d?(l.setStartBefore(u),l.collapse(!0)):(l.setStartAfter(u),l.setEndBefore(d)),c.removeAllRanges(),c.addRange(l),u.remove(),d==null||d.remove()}}function zre(t,e,n){if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch(r){}}}function Hv(t){const e=Hre(t.context);if(!e)return!1;const n=e.innerHTML;Qre(e)&&e.focus({preventScroll:!0});let r=!1;try{r=document.execCommand(t.command,!1)}catch(a){r=!1}const i=e.innerHTML;if(t.normalize&&i!==n){const a=$re(e);t.normalize(e),a==null||a()}const o=e.innerHTML;return n!==o&&(zre(e,n,o),e.dispatchEvent(new Event("input",{bubbles:!0}))),r!==!1||n!==o}const jre=Object.freeze(Object.defineProperty({__proto__:null,BoldPlugin:()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:t=>{const e=typeof t=="string"?t:t.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(t,e)=>Hv({command:"bold",context:e})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}})},Symbol.toStringTag,{value:"Module"})),cB=(t,e)=>Hv({command:"italic",context:e}),qre=(t,e)=>{var n;typeof window!="undefined"&&((n=window.registerEditorCommand)==null||n.call(window,t,e))},m4=()=>{qre("toggleItalic",cB)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m4):m4());const Wre=Object.freeze(Object.defineProperty({__proto__:null,ItalicPlugin:()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:cB},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),toggleItalic:cB},Symbol.toStringTag,{value:"Module"})),Kre=Object.freeze(Object.defineProperty({__proto__:null,UnderlinePlugin:()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(t,e)=>Hv({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}})},Symbol.toStringTag,{value:"Module"})),Vre=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(t,e)=>Hv({command:"strikeThrough",context:e,normalize:Gre})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function Gre(t){t.querySelectorAll("strike, del").forEach(n=>{var i;const r=document.createElement("s");for(const o of Array.from(n.attributes))o.name!=="style"&&r.setAttribute(o.name,o.value);for(;n.firstChild;)r.appendChild(n.firstChild);(i=n.parentNode)==null||i.replaceChild(r,n)})}const Xre=Object.freeze(Object.defineProperty({__proto__:null,StrikethroughPlugin:Vre},Symbol.toStringTag,{value:"Module"}));function Ta(t,e,n=t==null?void 0:t.innerHTML){if(!t||typeof n!="string"||e===n)return!1;try{if(typeof window.execEditorCommand=="function")return window.execEditorCommand("recordDomTransaction",t,e,n)!==!1;if(typeof window.executeEditorCommand=="function")return window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})!==!1}catch(r){}return!1}const Yre=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=tie();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);if(!t.contains(n.commonAncestorContainer))return!1;const r=n.cloneRange(),i=t.innerHTML;return t.focus({preventScroll:!0}),cie(t,r),sie(t,r),Ta(t,i),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),Zre=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),Jre=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),eie=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function tie(){const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement,i=r==null?void 0:r.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function b4(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch(r){}const n=document.createRange();return e.nodeType===Node.ELEMENT_NODE?n.selectNodeContents(e):n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)>0&&t.compareBoundaryPoints(Range.START_TO_END,n)<0}function Qv(t){let e=0,n=t;for(;n&&n.parentNode;)e+=1,n=n.parentNode;return e}function nie(t){eie.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.contains("rte-format-painted")&&t.classList.remove("rte-format-painted"),t.classList.length===0&&t.removeAttribute("class")}function lB(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function rie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function y4(t){Array.from(t.children).forEach(e=>{rie(e)&&e.remove()})}function v4(t){y4(t),lB(t)}function w4(t){var n;const e=document.createElement("p");for(Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),(n=t.parentNode)==null||n.replaceChild(e,t)}function iie(t){return!/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName)||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, svg, math")}function oie(t){Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((n,r)=>Qv(r)-Qv(n)).forEach(n=>{n.isConnected&&iie(n)&&n.remove()})}function aie(t){if(y4(t),t.parentElement instanceof HTMLLIElement){v4(t);return}if(Array.from(t.childNodes).filter(i=>i.nodeType!==Node.TEXT_NODE||(i.textContent||"").trim()!=="").some(i=>i instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(i.tagName))){v4(t);return}w4(t)}function sie(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(r=>{if(b4(e,r)&&Jre.has(r.tagName)){if(r.tagName==="BLOCKQUOTE"){aie(r);return}w4(r)}})}function cie(t,e){const n=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));n.sort((r,i)=>Qv(i)-Qv(r)),n.forEach(r=>{if(r.isConnected&&b4(e,r)&&!(r.getAttribute("contenteditable")==="false"||r.closest('[contenteditable="false"]'))){if(nie(r),Zre.has(r.tagName)){lB(r);return}r.tagName==="SPAN"&&r.attributes.length===0&&lB(r)}}),oie(t)}const lie=Object.freeze(Object.defineProperty({__proto__:null,ClearFormattingPlugin:Yre},Symbol.toStringTag,{value:"Module"})),Ob='.rte-content, .editora-content, [contenteditable="true"]',uie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",x4=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E4="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",die=new Set(["p","h1","h2","h3","h4","h5","h6"]);function C4(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function fie(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const n=t==null?void 0:t.editorElement;if(n instanceof HTMLElement){const a=n.querySelector(Ob);if(a instanceof HTMLElement)return a;if(n.getAttribute("contenteditable")==="true")return n}const r=window.getSelection();if(r&&r.rangeCount>0){const a=C4(r.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(Ob);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(uie),l=c==null?void 0:c.querySelector(Ob);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(Ob);return o instanceof HTMLElement?o:document.querySelector(Ob)}function Aie(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n}function T4(t,e){let n=C4(e);if(!n||n===t||!t.contains(n))return null;for(;n.parentElement&&n.parentElement!==t;)n=n.parentElement;if(n.parentElement!==t)return null;if(n.matches(E4))return n;const r=n.closest(E4);return r instanceof HTMLElement&&r.parentElement===t?r:n}function k4(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(r){return!1}const n=document.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0}function hie(t,e){const n=T4(t,e.startContainer),r=T4(t,e.endContainer);if(!n)return[];if(!r||n===r)return[n];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>k4(e,a));return o.length>0?o:[n]}function pie(t,e){Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)})}function uB(t,e){for(;t.firstChild;)e.appendChild(t.firstChild)}function gie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function $v(t,e){const n=document.createElement(t);return e&&pie(e,n),n}function B4(t,e){const n=$v(e,t);return uB(t,n),n.innerHTML.trim()||(n.innerHTML="<br>"),n}function mie(t){const e=t.cloneNode(!1);return e instanceof HTMLElement?e:document.createElement(t.tagName.toLowerCase())}function S4(t,e,n){const r=t.parentNode;if(!r)return[];const i=document.createDocumentFragment(),o=[];let a=null;const s=()=>{a&&a.children.length>0&&i.appendChild(a),a=null};return Array.from(t.children).forEach(c=>{if(c instanceof HTMLLIElement){if(e.has(c)){s();const l=B4(c,n);i.appendChild(l),o.push(l);return}a||(a=mie(t)),a.appendChild(c)}}),s(),r.insertBefore(i,t),r.removeChild(t),o}function bie(t,e){var r;if(t.tagName.toLowerCase()===e)return[t];const n=$v(e,t);return uB(t,n),n.innerHTML.trim()||(n.innerHTML="<br>"),(r=t.parentNode)==null||r.replaceChild(n,t),[n]}function yie(t,e){const n=t.parentNode;if(!n)return[];const r=document.createDocumentFragment(),i=[];return Array.from(t.childNodes).forEach(o=>{if(o instanceof HTMLElement&&gie(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(s=>{if(!(s instanceof HTMLLIElement))return;const c=B4(s,e);r.appendChild(c),i.push(c)}),o.remove();return}if(o instanceof HTMLElement&&x4.has(o.tagName)){const s=$v(e,o);uB(o,s),r.appendChild(s),i.push(s);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=$v(e,t);a.appendChild(o),r.appendChild(a),i.push(a)}),n.insertBefore(r,t),n.removeChild(t),i}function vie(t){const e=window.getSelection();if(!e)return;const n=document.createRange(),r=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;n.selectNodeContents(r),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function wie(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function xie(t,e,n){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",t,e,n);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}function Eie(t,e){const n=new Map;return Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&k4(e,i)).forEach(i=>{var a;const o=i.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===t&&(n.has(o)||n.set(o,new Set),(a=n.get(o))==null||a.add(i))}),n}function Mb(t,e){const n=t.toLowerCase();if(!die.has(n))return!1;const r=fie(e);if(!r)return!1;const i=Aie(r);if(!i)return!1;const o=r.innerHTML,a=[],s=Eie(r,i);s.size>0?s.forEach((l,u)=>{a.push(...S4(u,l,n))}):hie(r,i).forEach(u=>{if(u instanceof HTMLUListElement||u instanceof HTMLOListElement){const d=new Set(Array.from(u.children).filter(f=>f instanceof HTMLLIElement));a.push(...S4(u,d,n));return}if(x4.has(u.tagName)){const d=u.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...d?yie(u,n):bie(u,n))}});const c=r.innerHTML;return o===c||a.length===0?!1:(xie(r,o,c),wie(r),vie(a[0]),!0)}const Cie=Object.freeze(Object.defineProperty({__proto__:null,HeadingPlugin:()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(t,e)=>t?Mb(t,e):!1,setHeading1:(t,e)=>Mb("h1",e),setHeading2:(t,e)=>Mb("h2",e),setHeading3:(t,e)=>Mb("h3",e),setParagraph:(t,e)=>Mb("p",e)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}})},Symbol.toStringTag,{value:"Module"})),Pb='.rte-content, .editora-content, [contenteditable="true"]',Tie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",_4=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function dB(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function kie(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const n=t==null?void 0:t.editorElement;if(n instanceof HTMLElement){const a=n.querySelector(Pb);if(a instanceof HTMLElement)return a;if(n.getAttribute("contenteditable")==="true")return n}const r=window.getSelection();if(r&&r.rangeCount>0){const a=dB(r.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(Pb);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(Tie),l=c==null?void 0:c.querySelector(Pb);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(Pb);return o instanceof HTMLElement?o:document.querySelector(Pb)}function Bie(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n}function D4(t,e){let n=dB(e);if(!n||n===t||!t.contains(n))return null;for(;n.parentElement&&n.parentElement!==t;)n=n.parentElement;if(n.parentElement!==t)return null;if(n.matches(_4))return n;const r=n.closest(_4);return r instanceof HTMLElement&&r.parentElement===t?r:n}function L4(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(r){return!1}const n=document.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0}function Sie(t,e){const n=D4(t,e.startContainer),r=D4(t,e.endContainer);if(!n)return[];if(!r||n===r)return[n];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>L4(e,a));return o.length>0?o:[n]}function F4(t,e){const n=dB(e),r=n==null?void 0:n.closest("blockquote");return r instanceof HTMLQuoteElement&&t.contains(r)?r:null}function _ie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Die(t){Array.from(t.children).forEach(e=>{_ie(e)&&e.remove()})}function fB(t){Die(t);const e=t.parentNode;if(!e)return;Array.from(t.childNodes).forEach(r=>{e.insertBefore(r,t)}),e.removeChild(t)}function I4(t){return t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim()===""}function U4(t){const e=Array.from(t.childNodes).filter(r=>!I4(r));if(e.length!==1)return null;const n=e[0];return n instanceof HTMLQuoteElement?n:null}function Lie(t){const e=document.createElement("blockquote");return Array.from(t.childNodes).filter(r=>!I4(r)).forEach(r=>{e.appendChild(r)}),e.childNodes.length||(e.innerHTML="<br>"),t.appendChild(e),e}function Fie(t,e){const n=Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&L4(e,i)),r=new Set(n);return n.filter(i=>{var a,s;let o=(a=i.parentElement)==null?void 0:a.closest("li");for(;o;){if(r.has(o))return!1;o=(s=o.parentElement)==null?void 0:s.closest("li")}return!0})}function Hb(t){const e=window.getSelection();if(!e)return;const n=document.createRange(),r=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;n.selectNodeContents(r),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function Iie(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Uie(t,e,n){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",t,e,n);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}function Nie(t){var u,d;const e=kie(t);if(!e)return!1;const n=Bie(e);if(!n)return!1;const r=e.innerHTML,i=F4(e,n.startContainer),o=F4(e,n.endContainer),a=Fie(e,n),s=Sie(e,n),c=s.length>0&&s.every(f=>f.tagName==="BLOCKQUOTE");if(i&&i===o){const f=i.firstChild||i;fB(i),Hb(f)}else if(a.length>0){const f=a.map(U4);if(f.every(Boolean)){const h=((u=f[0])==null?void 0:u.firstChild)||a[0];f.forEach(p=>{p&&fB(p)}),Hb(h)}else{const h=a[0];a.forEach(p=>{U4(p)||Lie(p)}),Hb(h)}}else if(c){const f=s[0].firstChild||s[0];s.forEach(fB),Hb(f)}else{const f=s.filter(p=>p.tagName!=="BLOCKQUOTE");if(f.length===0)return!1;const A=document.createElement("blockquote"),h=f[0];(d=h.parentNode)==null||d.insertBefore(A,h),f.forEach(p=>{A.appendChild(p)}),Hb(A)}const l=e.innerHTML;return r===l?!1:(Uie(e,r,l),Iie(e),!0)}const Rie=Object.freeze(Object.defineProperty({__proto__:null,BlockquotePlugin:()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(t,e)=>Nie(e)},keymap:{"Mod-Shift-9":"toggleBlockquote"}})},Symbol.toStringTag,{value:"Module"}));function Oie(t){let e=!1;t.addEventListener("pointerdown",n=>{e=n.target!==t},!0),t.addEventListener("click",n=>{n.target===t&&e&&n.stopImmediatePropagation(),e=!1},!0)}const N4="rte-dialog-base-styles";function Mie(){if(typeof document=="undefined"||document.getElementById(N4))return;const t=document.createElement("style");t.id=N4,t.textContent=`
|
|
11
|
+
`+Nt),G&&(Nt=ta(Nt)),B&&Ze?P(Nt):Nt},e.setConfig=function(){let Qe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(Qe),Le=!0,Ne=L,ze=X},e.clearConfig=function(){hn=null,Le=!1,Ne=null,ze=null,B=R,I=""},e.isValidAttribute=function(Qe,Y,ve){hn||vt({});const Pe=St(Qe),We=St(Y);return sc(Pe,We,ve)},e.addHook=function(Qe,Y){typeof Y=="function"&&Ca(Q,Qe)&&Lb(Q[Qe],Y)},e.removeHook=function(Qe,Y){if(Ca(Q,Qe)){if(Y!==void 0){const ve=Gne(Q[Qe],Y);return ve===-1?void 0:Xne(Q[Qe],ve,1)[0]}return WR(Q[Qe])}},e.removeHooks=function(Qe){Ca(Q,Qe)&&(Q[Qe]=[])},e.removeAllHooks=function(){Q=o4()},e}var Rv=a4();const wre=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],xre={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],ol:["start","reversed"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},Ere="data-editora-embed";function Cre(t){if(!t||/\s/.test(t.trim()))return!1;try{const e=new URL(t.trim());return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}function s4(t,e,n,r){if((e==null?void 0:e.sanitize)===!1)return t;const i=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:wre,o=n!=null&&n.length?Array.from(new Set([...i,...n])):i,s=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:xre,c=new Set;for(const d of Object.values(s))for(const f of d)c.add(f);const l={ALLOWED_TAGS:o,ALLOWED_ATTR:Array.from(c)};if(!r)return Rv.sanitize(t,l);const u=o.includes("iframe");Rv.addHook("uponSanitizeElement",(d,f)=>{var h;if(f.tagName!=="iframe")return;const A=d;f.allowedTags.iframe=u||((h=A.getAttribute)==null?void 0:h.call(A,Ere))==="true"&&Cre(A.getAttribute("src"))});try{return Rv.sanitize(t,l)}finally{Rv.removeHook("uponSanitizeElement")}}function Tre(t,e,n,r){return s4(t,e,r,!1)}function kre(t,e,n){return(n==null?void 0:n.sanitizeOnPaste)===!1?t:Tre(t,e)}function c4(t,e,n,r){return(n==null?void 0:n.sanitizeOnInput)===!1?t:s4(t,e,r,!0)}const Bre=".resize-handle, .table-resize-handle",Sre=/resize-handle/;function l4(t){if(!t||!Sre.test(t))return t;const e=document.createElement("template");e.innerHTML=t;const n=new Set;return e.content.querySelectorAll(Bre).forEach(r=>{const i=r.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&n.add(i),r.remove()}),n.forEach(r=>{var i;r.style.position==="relative"&&(r.style.removeProperty("position"),(i=r.getAttribute("style"))!=null&&i.trim()||r.removeAttribute("style"))}),e.innerHTML}function Nb(t){return t?l4(t.innerHTML):""}const xk=class xk{static resolve(e){const n={};if(Object.assign(n,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(n,e.pluginDefaults),e.attributes){const r=this.parseAttributes(e.attributes);Object.assign(n,r)}return e.jsConfig&&Object.assign(n,e.jsConfig),this.normalizeConfig(n)}static normalizeConfig(e){const n={...e};if(n.toolbarFloating!==void 0||n.toolbarSticky!==void 0){const a=typeof n.toolbar=="object"&&n.toolbar?{...n.toolbar}:typeof n.toolbar=="string"?{items:n.toolbar}:{};n.toolbarFloating!==void 0&&(a.floating=!!n.toolbarFloating),n.toolbarSticky!==void 0&&(a.sticky=!!n.toolbarSticky),n.toolbar=a}if(n.toolbarItems!==void 0&&typeof n.toolbar=="object"&&n.toolbar&&(n.toolbar.items=n.toolbarItems),n.autosaveEnabled!==void 0||n.autosaveIntervalMs!==void 0||n.autosaveStorageKey!==void 0||n.autosaveProvider!==void 0||n.autosaveApiUrl!==void 0){const a=typeof n.autosave=="object"&&n.autosave?{...n.autosave}:{};n.autosaveEnabled!==void 0&&(a.enabled=!!n.autosaveEnabled),n.autosaveIntervalMs!==void 0&&(a.intervalMs=Number(n.autosaveIntervalMs)),n.autosaveStorageKey!==void 0&&(a.storageKey=n.autosaveStorageKey),n.autosaveProvider!==void 0&&(a.provider=n.autosaveProvider),n.autosaveApiUrl!==void 0&&(a.apiUrl=n.autosaveApiUrl),n.autosave=a}const r={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof n.autosave=="boolean")n.autosave={...r,enabled:n.autosave};else if(typeof n.autosave=="object"&&n.autosave){const a={...r,...n.autosave};a.intervalMs===void 0&&a.interval!==void 0&&(a.intervalMs=Number(a.interval)),a.enabled===void 0&&(a.enabled=!0),(!Number.isFinite(a.intervalMs)||a.intervalMs<=0)&&(a.intervalMs=r.intervalMs),n.autosave=a}else n.autosave=r;if(n.languageLocale!==void 0||n.languageDirection!==void 0){const a=typeof n.language=="object"&&n.language?{...n.language}:{};n.languageLocale!==void 0&&(a.locale=n.languageLocale),n.languageDirection!==void 0&&(a.direction=n.languageDirection),n.language=a}const i={locale:"en",direction:"ltr"};if(typeof n.language=="string"?n.language={locale:n.language,direction:i.direction}:typeof n.language=="object"&&n.language?n.language={...i,...n.language}:n.language=i,n.spellcheckEnabled!==void 0||n.spellcheckProvider!==void 0||n.spellcheckApiUrl!==void 0){const a=typeof n.spellcheck=="object"&&n.spellcheck?{...n.spellcheck}:{};n.spellcheckEnabled!==void 0&&(a.enabled=!!n.spellcheckEnabled),n.spellcheckProvider!==void 0&&(a.provider=n.spellcheckProvider),n.spellcheckApiUrl!==void 0&&(a.apiUrl=n.spellcheckApiUrl),n.spellcheck=a}const o={enabled:!1,provider:"browser",apiUrl:""};if(typeof n.spellcheck=="boolean")n.spellcheck={...o,enabled:n.spellcheck};else if(typeof n.spellcheck=="object"&&n.spellcheck){const a={...o,...n.spellcheck};!a.provider&&a.mode&&(a.provider=a.mode==="local"?"browser":"api"),a.enabled===void 0&&(a.enabled=!!(a.mode||a.provider||a.apiUrl)),n.spellcheck=a}else n.spellcheck=o;return n.contextMenuEnabled!==void 0&&(n.contextMenu={enabled:!!n.contextMenuEnabled}),typeof n.contextMenu=="boolean"?n.contextMenu={enabled:n.contextMenu}:typeof n.contextMenu=="object"&&n.contextMenu?n.contextMenu={enabled:n.contextMenu.enabled!==!1}:n.contextMenu={enabled:!0},(n.pasteClean!==void 0||n.pasteKeepFormatting!==void 0||n.pasteConvertWord!==void 0)&&(n.paste={...n.paste||{},...n.pasteClean!==void 0?{clean:!!n.pasteClean}:{},...n.pasteKeepFormatting!==void 0?{keepFormatting:!!n.pasteKeepFormatting}:{},...n.pasteConvertWord!==void 0?{convertWord:!!n.pasteConvertWord}:{}}),n.paste={clean:!0,keepFormatting:!1,convertWord:!0,...n.paste||{}},n.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...n.contentConfig||{}},(n.securitySanitizeOnPaste!==void 0||n.securitySanitizeOnInput!==void 0)&&(n.security={...n.security||{},...n.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!n.securitySanitizeOnPaste}:{},...n.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!n.securitySanitizeOnInput}:{}}),n.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...n.security||{}},(n.accessibilityEnableAria!==void 0||n.accessibilityKeyboardNavigation!==void 0||n.accessibilityChecker!==void 0)&&(n.accessibility={...n.accessibility||{},...n.accessibilityEnableAria!==void 0?{enableARIA:!!n.accessibilityEnableAria}:{},...n.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!n.accessibilityKeyboardNavigation}:{},...n.accessibilityChecker!==void 0?{checker:!!n.accessibilityChecker}:{}}),typeof n.accessibility=="boolean"&&(n.accessibility={enableARIA:n.accessibility,keyboardNavigation:n.accessibility,checker:!1}),n.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...n.accessibility||{}},(n.performanceDebounceInputMs!==void 0||n.performanceViewportOnlyScan!==void 0)&&(n.performance={...n.performance||{},...n.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(n.performanceDebounceInputMs)}:{},...n.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!n.performanceViewportOnlyScan}:{}}),typeof n.performance=="boolean"&&(n.performance={debounceInputMs:100,viewportOnlyScan:n.performance}),n.performance={debounceInputMs:100,viewportOnlyScan:!0,...n.performance||{}},(typeof n.performance.debounceInputMs!="number"||!Number.isFinite(n.performance.debounceInputMs)||n.performance.debounceInputMs<0)&&(n.performance.debounceInputMs=100),n}static parseAttributes(e){const n={};for(const[r,i]of Object.entries(e)){const o=this.kebabToCamel(r);n[o]=this.BOOLEAN_ATTRIBUTES.has(r)&&(i===""||i===r)?!0:this.parseAttributeValue(i)}return n}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(n){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(n,r)=>r.toUpperCase())}static validate(e){const n=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&n.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&n.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&n.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&n.push("theme must be a string"),{valid:n.length===0,errors:n}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const n={};for(const r of e)for(const[i,o]of Object.entries(r))o!=null&&(typeof o=="object"&&!Array.isArray(o)&&n[i]?n[i]=this.merge(n[i],o):n[i]=o);return n}};xk.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},xk.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let iB=xk;const _re='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Ov;const Dre="__editoraCommandEditorRoot",Lre="__editoraLastCommandButton",u4="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",d4=".rte-content, .editora-content",Fre="Rich text editor",oB=new Set;let Nd=null,f4=!1,aB=null,sB=null;function A4(t){if(!(t instanceof HTMLElement))return!1;const e=t;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function Ire(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Rb(t){if(!t)return null;if(A4(t))return t;const e=t.matches(u4)?t:t.closest(u4);return!e||!A4(e)?null:e}function Ure(){var i;if(typeof window=="undefined")return null;const t=window[Dre];if(t instanceof HTMLElement){const o=Rb(t);if(o)return o;const a=t.matches(d4)?t:t.querySelector(d4);if(a){const s=Rb(a);if(s)return s}}const e=window[Lre];if(e instanceof HTMLElement){const o=Rb(e);if(o)return o}const n=document.activeElement;if(n){const o=Rb(n);if(o)return o}const r=(i=window.getSelection)==null?void 0:i.call(window);if(r&&r.rangeCount>0){const o=Rb(Ire(r.getRangeAt(0).startContainer));if(o)return o}if(Nd&&Nd.isConnected)return Nd;for(const o of oB)if(o.isConnected)return o;return null}function Nre(){if(typeof window=="undefined"||f4)return;aB=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,sB=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const t=(e,...n)=>{const r=Ure();return r?r.execCommand(e,...n):aB?aB(e,...n):sB?sB(e,...n):!1};window.executeEditorCommand=t,window.execEditorCommand=t,f4=!0}function Rre(){const t="editora-webcomponent-styles";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=_re,document.head.appendChild(e)}}function Ore(){if(!Ov){const t=Ts.__globalPluginLoader;t?Ov=t:Ov=new AA}return Ov}class Ts extends HTMLElement{constructor(){if(super(),this.pluginLoader=Ore(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Hne,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,Rre(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","aria-label","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(Ts.__globalPluginLoader){this.pluginLoader=Ts.__globalPluginLoader;return}return new Promise(e=>{const n=()=>{Ts.__globalPluginLoader?(this.pluginLoader=Ts.__globalPluginLoader,e()):setTimeout(n,0)};n()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,n,r){n!==r&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,r))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var i;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),oB.add(this),Nd||(Nd=this),Nre(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();if(this.loadedPlugins=e,e.forEach(o=>{if(o.init&&typeof o.init=="function")try{o.init({editorElement:this})}catch(a){console.error(`[RichTextEditor] Error initializing plugin ${o.name}:`,a)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const o=this.innerHTML.trim();o&&this.setAttribute("data-initial-content",o)}const n=this.preservedContent;this.preservedContent=null;const r=this.sanitizeLoadedContent((i=n!=null?n:this.restoreAutosavedContent())!=null?i:this.getAttribute("data-initial-content")||"");this.engine=new Lne({content:r,plugins:e,readonly:this.config.readonly}),this.createUI(e,r),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(r=>r.nodeType===Node.TEXT_NODE?r.textContent:r.nodeType===Node.ELEMENT_NODE?r.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],n=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(n){if(typeof this.config.plugins=="string"){const o=this.config.plugins.split(/\s+/).filter(Boolean);i&&!o.includes("a11yChecker")&&o.push("a11yChecker");for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}else if(Array.isArray(this.config.plugins)){for(const o of this.config.plugins)if(typeof o=="string"){const a=await this.pluginLoader.load(o,this.getPluginLoadConfig(o));a&&e.push(a)}else e.push(o);if(i&&!e.some(o=>(o==null?void 0:o.name)==="a11yChecker")){const o=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));o&&e.push(o)}}}else{const o=this.pluginLoader.getRegisteredPluginNames();for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const n=this.config.toolbar;if(typeof n=="string")return n;if(!n||typeof n!="object")return;const r=n.items;if(typeof r=="string")return r;if(Array.isArray(r))return r.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var n;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const r=Number((n=e.debounceInputMs)!=null?n:100);return{debounceInputMs:Number.isFinite(r)&&r>=0?r:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){var n;if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const r=(n=this.getAttribute("aria-label"))==null?void 0:n.trim(),i=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",r||i||Fre)}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const n=e.provider||"browser";return{enabled:!!e.enabled,provider:n,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),n=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=n,this.contentElement.setAttribute("spellcheck",n?"true":"false")}executeCommand(e,...n){var o;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const r={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(a=>a.commands&&a.commands[e]);if(i&&i.commands){const a=i.commands[e];if(typeof a=="function")try{return e==="toggleFullscreen"?a(this,r):a(...n,r),!0}catch(s){return console.error(`[RichTextEditor] Error executing native command ${e}:`,s),!1}}return((o=this.engine)==null?void 0:o.execCommand(e,...n))||!1}getPluginLoadConfig(e){const n=this.config.pluginConfig;if(n&&typeof n=="object"){const o=n[e];if(o&&typeof o=="object")return o}const r={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[e,e.toLowerCase(),...r[e]||[]];for(const o of i){const a=this.config[o];if(a&&typeof a=="object"&&!Array.isArray(a))return a}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(e){return c4(e,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var n,r;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((r=(n=e.intervalMs)!=null?n:e.interval)!=null?r:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const n=this.getAutosaveConfig();if(n.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,n.provider==="localStorage"){try{localStorage.setItem(n.storageKey,e),localStorage.setItem(`${n.storageKey}-timestamp`,Date.now().toString())}catch(r){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",r)}return}n.provider==="api"&&n.apiUrl&&fetch(n.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(r=>{console.error("[RichTextEditor] Failed to save autosave content to API:",r)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const n=localStorage.getItem(e.storageKey);if(n)return this.lastAutosavedContent=n,n}catch(n){console.error("[RichTextEditor] Failed to restore autosaved content:",n)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(Nb(this.contentElement))},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);r.deleteContents();const i=document.createElement("div");i.innerHTML=e;const o=document.createDocumentFragment();for(;i.firstChild;)o.appendChild(i.firstChild);r.insertNode(o),r.collapse(!1),n.removeAllRanges(),n.addRange(r)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,n){const r=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!r?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Fne({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((o,a)=>{var s;if(this.contentElement){this.contentElement.focus();const c=window.getSelection();if(!c||c.rangeCount===0||!this.contentElement.contains(c.anchorNode)){const l=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?l.setStart(u,((s=u.textContent)==null?void 0:s.length)||0):u.nodeType===Node.ELEMENT_NODE?(l.selectNodeContents(u),l.collapse(!1)):l.setStart(this.contentElement,0),l.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(l)}}return this.executeCommand(o,a)}),this.toolbar.render(this.toolbarElement)):r&&this.appendChild(r),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(o){console.warn("defaultParagraphSeparator not supported:",o)}if(n){const o=document.createElement("div");o.innerHTML=n.trim(),!Array.from(o.childNodes).some(s=>{if(s.nodeType===Node.ELEMENT_NODE){const c=s.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(c)}return!1})&&n.trim()?this.contentElement.innerHTML=`<p>${n.trim()}</p>`:this.contentElement.innerHTML=n}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Ine({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Une({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var o;return(o=this.contentElement)==null?void 0:o.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",r=>{this.lastBeforeInputType=r.inputType||null}),this.contentElement.addEventListener("input",r=>{var f;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const o=(f=r==null?void 0:r.detail)==null?void 0:f.allowedTags,a=this.getPerformanceConfig(),s=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),l=this.lastBeforeInputType;if(this.lastBeforeInputType=null,c.sanitizeOnInput!==!1&&s.sanitize!==!1&&!l){const A=c4(i,s,c,o);if(A!==i){const h=window.getSelection(),p=h&&h.rangeCount>0?h.getRangeAt(0):null;if(this.contentElement.innerHTML=A,p&&h)try{h.removeAllRanges(),h.addRange(p)}catch(m){}i=A}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const d=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:l4(i)},bubbles:!0}))};a.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(d,a.debounceInputMs):d(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",r=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&r.preventDefault()}),this.contentElement.addEventListener("paste",r=>{var u,d;if(r.__editoraSmartPasteHandled===!0||r.defaultPrevented)return;r.preventDefault();const i=this.config.paste||{};let o=((u=r.clipboardData)==null?void 0:u.getData("text/html"))||"";const a=((d=r.clipboardData)==null?void 0:d.getData("text/plain"))||"",s=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),l=!!o&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(o);if((i.clean||!i.keepFormatting)&&a){document.execCommand("insertText",!1,a);return}if(i.convertWord===!1&&l&&a){document.execCommand("insertText",!1,a);return}if(o){c.sanitizeOnPaste!==!1&&s.sanitize!==!1&&(o=kre(o,s,c)),this.insertHTMLAtSelection(o);return}a&&document.execCommand("insertText",!1,a)}),this.contentElement.addEventListener("focus",()=>{Nd=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Nb(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",r=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(r,(o,a)=>{this.executeCommand(o,a)})});const n=()=>{const r=this.getSelectionRangeInEditor(),i=document.activeElement,o=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!o||!r&&!o||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=n,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0),r=n.commonAncestorContainer;return this.contentElement.contains(r)?n:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const n=document.createRange();return n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.collapsed}catch(n){return!1}}getSelectionAnchorRect(e,n){const r=Array.from(n.getClientRects()).filter(o=>o.width>0||o.height>0);return r.length===0?n.getBoundingClientRect():this.isSelectionBackward(e)?r[0]:r[r.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const n=this.getPerformanceConfig(),r=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(n.viewportOnlyScan&&!this.isEditorInViewport()&&!r){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const o=window.getSelection();if(!o){this.floatingToolbar.hide();return}const a=this.getSelectionAnchorRect(o,i);if(!a){this.floatingToolbar.hide();return}this.floatingToolbar.show(a.left,a.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),n=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!n)return;const r=this.contentElement.textContent||"",{words:i,chars:o}=Mne(r),a=One(this.contentElement);let s,c;const l=this.getSelectionRangeInEditor();l&&(s=Nne(this.contentElement,l),l.collapsed||(c=Pne(l,s),s=void 0)),this.statusBar.update({wordCount:i,charCount:o,lineCount:a,cursorPosition:s,selectionInfo:c})}isReadonlyAttribute(e){return e!==null&&e!=="false"}handleAttributeChange(e,n){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(n)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(n));break;case"theme":this.classList.forEach(r=>{r.startsWith("editora-theme-")&&this.classList.remove(r)}),n&&this.classList.add(`editora-theme-${n}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",n),this.applyAccessibilitySettings());break;case"aria-label":case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(r=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",r)})}));break}}resolveConfig(){const e={};for(let n=0;n<this.attributes.length;n++){const r=this.attributes[n];e[r.name]=r.value}return iB.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>Nb(this.contentElement),setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))},execCommand:(e,n)=>this.executeCommand(e,n),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,n)=>(this.addEventListener(e,n),()=>this.removeEventListener(e,n)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,n,r,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=Nb(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(n=this.toolbar)==null||n.destroy(),(r=this.floatingToolbar)==null||r.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,oB.delete(this),Nd===this&&(Nd=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return Nb(this.contentElement)}setContent(e){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(e))}execCommand(e,...n){return this.executeCommand(e,...n)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}const Mv=new AA;Ts.__globalPluginLoader=Mv;const Mre={bold:()=>Promise.resolve().then(()=>jre).then(t=>t.BoldPlugin()),italic:()=>Promise.resolve().then(()=>Wre).then(t=>t.ItalicPlugin()),underline:()=>Promise.resolve().then(()=>Kre).then(t=>t.UnderlinePlugin()),strikethrough:()=>Promise.resolve().then(()=>Xre).then(t=>t.StrikethroughPlugin()),clearFormatting:()=>Promise.resolve().then(()=>lie).then(t=>t.ClearFormattingPlugin()),heading:()=>Promise.resolve().then(()=>Cie).then(t=>t.HeadingPlugin()),blockquote:()=>Promise.resolve().then(()=>Rie).then(t=>t.BlockquotePlugin()),code:()=>Promise.resolve().then(()=>Foe).then(t=>t.CodePlugin()),codeSample:()=>Promise.resolve().then(()=>joe).then(t=>t.CodeSamplePlugin()),list:()=>Promise.resolve().then(()=>Goe).then(t=>t.ListPlugin()),checklist:()=>Promise.resolve().then(()=>uae).then(t=>t.ChecklistPlugin()),textAlignment:()=>Promise.resolve().then(()=>Aae).then(t=>t.TextAlignmentPlugin()),indent:()=>Promise.resolve().then(()=>hae).then(t=>t.IndentPlugin()),direction:()=>Promise.resolve().then(()=>Eae).then(t=>t.DirectionPlugin()),textColor:()=>Promise.resolve().then(()=>Mae).then(t=>t.TextColorPlugin()),backgroundColor:()=>Promise.resolve().then(()=>Vae).then(t=>t.BackgroundColorPlugin()),fontSize:()=>Promise.resolve().then(()=>ose).then(t=>t.FontSizePlugin()),fontFamily:()=>Promise.resolve().then(()=>gse).then(t=>t.FontFamilyPlugin()),formatPainter:()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),"format-painter":()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),formatpainter:()=>Promise.resolve().then(()=>tS).then(t=>t.FormatPainterPlugin()),lineHeight:()=>Promise.resolve().then(()=>wce).then(t=>t.LineHeightPlugin()),capitalization:()=>Promise.resolve().then(()=>Ice).then(t=>t.CapitalizationPlugin()),history:()=>Promise.resolve().then(()=>Oce).then(t=>t.HistoryPlugin()),link:()=>Promise.resolve().then(()=>jce).then(t=>t.LinkPlugin()),table:()=>Promise.resolve().then(()=>fle).then(t=>t.TablePlugin()),trackChanges:()=>Promise.resolve().then(()=>Kle).then(t=>t.TrackChangesPlugin()),versionDiff:()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),"version-diff":()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),versiondiff:()=>Promise.resolve().then(()=>MS).then(t=>t.VersionDiffPlugin()),conditionalContent:()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),"conditional-content":()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),conditionalcontent:()=>Promise.resolve().then(()=>jS).then(t=>t.ConditionalContentPlugin()),dataBinding:()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),"data-binding":()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),databinding:()=>Promise.resolve().then(()=>ZS).then(t=>t.DataBindingPlugin()),docSchema:()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),"doc-schema":()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),docschema:()=>Promise.resolve().then(()=>l5).then(t=>t.DocSchemaPlugin()),translationWorkflow:()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),"translation-workflow":()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),translationworkflow:()=>Promise.resolve().then(()=>x5).then(t=>t.TranslationWorkflowPlugin()),contentRules:()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),"content-rules":()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),contentrules:()=>Promise.resolve().then(()=>L5).then(t=>t.ContentRulesPlugin()),citations:()=>Promise.resolve().then(()=>dH).then(t=>t.CitationsPlugin()),citation:()=>Promise.resolve().then(()=>dH).then(t=>t.CitationsPlugin()),approvalWorkflow:()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),"approval-workflow":()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),approvalworkflow:()=>Promise.resolve().then(()=>V5).then(t=>t.ApprovalWorkflowPlugin()),piiRedaction:()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),"pii-redaction":()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),piiredaction:()=>Promise.resolve().then(()=>a_).then(t=>t.PIIRedactionPlugin()),smartPaste:()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),"smart-paste":()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),smartpaste:()=>Promise.resolve().then(()=>m_).then(t=>t.SmartPastePlugin()),blocksLibrary:()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),"blocks-library":()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),blockslibrary:()=>Promise.resolve().then(()=>T_).then(t=>t.BlocksLibraryPlugin()),mentions:()=>Promise.resolve().then(()=>R9).then(t=>t.MentionPlugin()),mention:()=>Promise.resolve().then(()=>R9).then(t=>t.MentionPlugin()),anchor:()=>Promise.resolve().then(()=>Xpe).then(t=>t.AnchorPlugin()),embedIframe:()=>Promise.resolve().then(()=>yge).then(t=>t.EmbedIframePlugin()),math:()=>Promise.resolve().then(()=>Uge).then(t=>t.MathPlugin()),image:()=>Promise.resolve().then(()=>$ge).then(t=>t.MediaManagerPlugin()),mergeTag:()=>Promise.resolve().then(()=>cme).then(t=>t.MergeTagPlugin()),pageBreak:()=>Promise.resolve().then(()=>yme).then(t=>t.PageBreakPlugin()),print:()=>Promise.resolve().then(()=>wme).then(t=>t.PrintPlugin()),preview:()=>Promise.resolve().then(()=>Bme).then(t=>t.PreviewPlugin()),specialCharacters:()=>Promise.resolve().then(()=>Ome).then(t=>t.SpecialCharactersPlugin()),slashCommands:()=>Promise.resolve().then(()=>FQ).then(t=>t.SlashCommandsPlugin()),"slash-commands":()=>Promise.resolve().then(()=>FQ).then(t=>t.SlashCommandsPlugin()),spellCheck:()=>Promise.resolve().then(()=>Ube).then(t=>t.SpellCheckPlugin()),emojis:()=>Promise.resolve().then(()=>zbe).then(t=>t.EmojisPlugin()),a11yChecker:()=>Promise.resolve().then(()=>Kbe).then(t=>t.A11yCheckerPlugin()),comments:()=>Promise.resolve().then(()=>sye).then(t=>t.CommentsPlugin()),collaboration:()=>Promise.resolve().then(()=>gwe).then(t=>t.CollaborationPlugin()),"document-manager":()=>Promise.resolve().then(()=>ywe).then(t=>t.DocumentManagerPlugin()),fullscreen:()=>Promise.resolve().then(()=>wwe).then(t=>t.FullscreenPlugin()),template:()=>Promise.resolve().then(()=>Owe).then(t=>t.TemplatePlugin()),footnote:()=>Promise.resolve().then(()=>Ywe).then(t=>t.FootnotePlugin())};async function h4(){return Object.entries(Mre).forEach(([t,e])=>{Mv.register(t,e)}),Mv}typeof window!="undefined"&&h4().then(t=>{Ts.__globalPluginLoader=t,customElements.get("editora-editor")||customElements.define("editora-editor",Ts);const e=document.querySelectorAll("editora-editor:not([data-initial-content])"),n=[];e.forEach(o=>{const a=o.innerHTML.trim();n.push(a),a&&o.setAttribute("data-initial-content",a)});const r=document.querySelectorAll("editora-editor");Array.from(r).filter(o=>!o.hasAttribute("data-initial-content")).forEach(o=>{const a=Array.from(r).indexOf(o);n[a]&&o.setAttribute("data-initial-content",n[a])}),window.Editora={version:"1.0.0",plugins:Mv.getRegisteredPluginNames(),WebComponent:Ts,init:async(o,a)=>{const s=document.querySelector(o);return s instanceof Ts?(a&&await s.setConfig(a),s.getAPI()):null}}});const Pv="data-editora-selection-marker";function Pre(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function p4(t){return t?t.getAttribute("contenteditable")==="true"?t:t.querySelector('[contenteditable="true"]'):null}function Hre(t){var a;if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;const e=p4((a=t==null?void 0:t.editorElement)!=null?a:null);if(e)return e;const n=typeof window!="undefined"?window.__editoraCommandEditorRoot:null,r=n instanceof HTMLElement?p4(n):null;if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const s=Pre(i.getRangeAt(0).startContainer),c=s==null?void 0:s.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}const o=document.activeElement;if(o instanceof HTMLElement){const s=o.closest('.rte-content, .editora-content, [contenteditable="true"]');if(s instanceof HTMLElement)return s}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function Qre(t){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);return t.contains(n.startContainer)&&t.contains(n.endContainer)}function g4(t){const e=document.createElement("span");return e.setAttribute(Pv,t),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function $re(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer)||!t.contains(n.endContainer))return null;const r=n.collapsed,i=g4("start"),o=r?null:g4("end"),a=n.cloneRange();if(o){const c=a.cloneRange();c.collapse(!1),c.insertNode(o)}const s=a.cloneRange();return s.collapse(!0),s.insertNode(i),()=>{const c=window.getSelection(),l=document.createRange(),u=t.querySelector(`[${Pv}="start"]`),d=t.querySelector(`[${Pv}="end"]`);if(!c||!u){t.querySelectorAll(`[${Pv}]`).forEach(f=>f.remove());return}r||!d?(l.setStartBefore(u),l.collapse(!0)):(l.setStartAfter(u),l.setEndBefore(d)),c.removeAllRanges(),c.addRange(l),u.remove(),d==null||d.remove()}}function zre(t,e,n){if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch(r){}}}function Hv(t){const e=Hre(t.context);if(!e)return!1;const n=e.innerHTML;Qre(e)&&e.focus({preventScroll:!0});let r=!1;try{r=document.execCommand(t.command,!1)}catch(a){r=!1}const i=e.innerHTML;if(t.normalize&&i!==n){const a=$re(e);t.normalize(e),a==null||a()}const o=e.innerHTML;return n!==o&&(zre(e,n,o),e.dispatchEvent(new Event("input",{bubbles:!0}))),r!==!1||n!==o}const jre=Object.freeze(Object.defineProperty({__proto__:null,BoldPlugin:()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:t=>{const e=typeof t=="string"?t:t.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(t,e)=>Hv({command:"bold",context:e})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}})},Symbol.toStringTag,{value:"Module"})),cB=(t,e)=>Hv({command:"italic",context:e}),qre=(t,e)=>{var n;typeof window!="undefined"&&((n=window.registerEditorCommand)==null||n.call(window,t,e))},m4=()=>{qre("toggleItalic",cB)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m4):m4());const Wre=Object.freeze(Object.defineProperty({__proto__:null,ItalicPlugin:()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:cB},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),toggleItalic:cB},Symbol.toStringTag,{value:"Module"})),Kre=Object.freeze(Object.defineProperty({__proto__:null,UnderlinePlugin:()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(t,e)=>Hv({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}})},Symbol.toStringTag,{value:"Module"})),Vre=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(t,e)=>Hv({command:"strikeThrough",context:e,normalize:Gre})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function Gre(t){t.querySelectorAll("strike, del").forEach(n=>{var i;const r=document.createElement("s");for(const o of Array.from(n.attributes))o.name!=="style"&&r.setAttribute(o.name,o.value);for(;n.firstChild;)r.appendChild(n.firstChild);(i=n.parentNode)==null||i.replaceChild(r,n)})}const Xre=Object.freeze(Object.defineProperty({__proto__:null,StrikethroughPlugin:Vre},Symbol.toStringTag,{value:"Module"}));function Ta(t,e,n=t==null?void 0:t.innerHTML){if(!t||typeof n!="string"||e===n)return!1;try{if(typeof window.execEditorCommand=="function")return window.execEditorCommand("recordDomTransaction",t,e,n)!==!1;if(typeof window.executeEditorCommand=="function")return window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})!==!1}catch(r){}return!1}const Yre=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=tie();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);if(!t.contains(n.commonAncestorContainer))return!1;const r=n.cloneRange(),i=t.innerHTML;return t.focus({preventScroll:!0}),cie(t,r),sie(t,r),Ta(t,i),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),Zre=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),Jre=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),eie=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function tie(){const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement,i=r==null?void 0:r.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function b4(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch(r){}const n=document.createRange();return e.nodeType===Node.ELEMENT_NODE?n.selectNodeContents(e):n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)>0&&t.compareBoundaryPoints(Range.START_TO_END,n)<0}function Qv(t){let e=0,n=t;for(;n&&n.parentNode;)e+=1,n=n.parentNode;return e}function nie(t){eie.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.contains("rte-format-painted")&&t.classList.remove("rte-format-painted"),t.classList.length===0&&t.removeAttribute("class")}function lB(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function rie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function y4(t){Array.from(t.children).forEach(e=>{rie(e)&&e.remove()})}function v4(t){y4(t),lB(t)}function w4(t){var n;const e=document.createElement("p");for(Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),(n=t.parentNode)==null||n.replaceChild(e,t)}function iie(t){return!/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName)||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, svg, math")}function oie(t){Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((n,r)=>Qv(r)-Qv(n)).forEach(n=>{n.isConnected&&iie(n)&&n.remove()})}function aie(t){if(y4(t),t.parentElement instanceof HTMLLIElement){v4(t);return}if(Array.from(t.childNodes).filter(i=>i.nodeType!==Node.TEXT_NODE||(i.textContent||"").trim()!=="").some(i=>i instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(i.tagName))){v4(t);return}w4(t)}function sie(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(r=>{if(b4(e,r)&&Jre.has(r.tagName)){if(r.tagName==="BLOCKQUOTE"){aie(r);return}w4(r)}})}function cie(t,e){const n=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));n.sort((r,i)=>Qv(i)-Qv(r)),n.forEach(r=>{if(r.isConnected&&b4(e,r)&&!(r.getAttribute("contenteditable")==="false"||r.closest('[contenteditable="false"]'))){if(nie(r),Zre.has(r.tagName)){lB(r);return}r.tagName==="SPAN"&&r.attributes.length===0&&lB(r)}}),oie(t)}const lie=Object.freeze(Object.defineProperty({__proto__:null,ClearFormattingPlugin:Yre},Symbol.toStringTag,{value:"Module"})),Ob='.rte-content, .editora-content, [contenteditable="true"]',uie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",x4=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E4="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",die=new Set(["p","h1","h2","h3","h4","h5","h6"]);function C4(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function fie(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const n=t==null?void 0:t.editorElement;if(n instanceof HTMLElement){const a=n.querySelector(Ob);if(a instanceof HTMLElement)return a;if(n.getAttribute("contenteditable")==="true")return n}const r=window.getSelection();if(r&&r.rangeCount>0){const a=C4(r.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(Ob);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(uie),l=c==null?void 0:c.querySelector(Ob);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(Ob);return o instanceof HTMLElement?o:document.querySelector(Ob)}function Aie(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n}function T4(t,e){let n=C4(e);if(!n||n===t||!t.contains(n))return null;for(;n.parentElement&&n.parentElement!==t;)n=n.parentElement;if(n.parentElement!==t)return null;if(n.matches(E4))return n;const r=n.closest(E4);return r instanceof HTMLElement&&r.parentElement===t?r:n}function k4(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(r){return!1}const n=document.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0}function hie(t,e){const n=T4(t,e.startContainer),r=T4(t,e.endContainer);if(!n)return[];if(!r||n===r)return[n];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>k4(e,a));return o.length>0?o:[n]}function pie(t,e){Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)})}function uB(t,e){for(;t.firstChild;)e.appendChild(t.firstChild)}function gie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function $v(t,e){const n=document.createElement(t);return e&&pie(e,n),n}function B4(t,e){const n=$v(e,t);return uB(t,n),n.innerHTML.trim()||(n.innerHTML="<br>"),n}function mie(t){const e=t.cloneNode(!1);return e instanceof HTMLElement?e:document.createElement(t.tagName.toLowerCase())}function S4(t,e,n){const r=t.parentNode;if(!r)return[];const i=document.createDocumentFragment(),o=[];let a=null;const s=()=>{a&&a.children.length>0&&i.appendChild(a),a=null};return Array.from(t.children).forEach(c=>{if(c instanceof HTMLLIElement){if(e.has(c)){s();const l=B4(c,n);i.appendChild(l),o.push(l);return}a||(a=mie(t)),a.appendChild(c)}}),s(),r.insertBefore(i,t),r.removeChild(t),o}function bie(t,e){var r;if(t.tagName.toLowerCase()===e)return[t];const n=$v(e,t);return uB(t,n),n.innerHTML.trim()||(n.innerHTML="<br>"),(r=t.parentNode)==null||r.replaceChild(n,t),[n]}function yie(t,e){const n=t.parentNode;if(!n)return[];const r=document.createDocumentFragment(),i=[];return Array.from(t.childNodes).forEach(o=>{if(o instanceof HTMLElement&&gie(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(s=>{if(!(s instanceof HTMLLIElement))return;const c=B4(s,e);r.appendChild(c),i.push(c)}),o.remove();return}if(o instanceof HTMLElement&&x4.has(o.tagName)){const s=$v(e,o);uB(o,s),r.appendChild(s),i.push(s);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=$v(e,t);a.appendChild(o),r.appendChild(a),i.push(a)}),n.insertBefore(r,t),n.removeChild(t),i}function vie(t){const e=window.getSelection();if(!e)return;const n=document.createRange(),r=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;n.selectNodeContents(r),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function wie(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function xie(t,e,n){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",t,e,n);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}function Eie(t,e){const n=new Map;return Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&k4(e,i)).forEach(i=>{var a;const o=i.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===t&&(n.has(o)||n.set(o,new Set),(a=n.get(o))==null||a.add(i))}),n}function Mb(t,e){const n=t.toLowerCase();if(!die.has(n))return!1;const r=fie(e);if(!r)return!1;const i=Aie(r);if(!i)return!1;const o=r.innerHTML,a=[],s=Eie(r,i);s.size>0?s.forEach((l,u)=>{a.push(...S4(u,l,n))}):hie(r,i).forEach(u=>{if(u instanceof HTMLUListElement||u instanceof HTMLOListElement){const d=new Set(Array.from(u.children).filter(f=>f instanceof HTMLLIElement));a.push(...S4(u,d,n));return}if(x4.has(u.tagName)){const d=u.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...d?yie(u,n):bie(u,n))}});const c=r.innerHTML;return o===c||a.length===0?!1:(xie(r,o,c),wie(r),vie(a[0]),!0)}const Cie=Object.freeze(Object.defineProperty({__proto__:null,HeadingPlugin:()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(t,e)=>t?Mb(t,e):!1,setHeading1:(t,e)=>Mb("h1",e),setHeading2:(t,e)=>Mb("h2",e),setHeading3:(t,e)=>Mb("h3",e),setParagraph:(t,e)=>Mb("p",e)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}})},Symbol.toStringTag,{value:"Module"})),Pb='.rte-content, .editora-content, [contenteditable="true"]',Tie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",_4=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function dB(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function kie(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const n=t==null?void 0:t.editorElement;if(n instanceof HTMLElement){const a=n.querySelector(Pb);if(a instanceof HTMLElement)return a;if(n.getAttribute("contenteditable")==="true")return n}const r=window.getSelection();if(r&&r.rangeCount>0){const a=dB(r.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(Pb);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(Tie),l=c==null?void 0:c.querySelector(Pb);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(Pb);return o instanceof HTMLElement?o:document.querySelector(Pb)}function Bie(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n}function D4(t,e){let n=dB(e);if(!n||n===t||!t.contains(n))return null;for(;n.parentElement&&n.parentElement!==t;)n=n.parentElement;if(n.parentElement!==t)return null;if(n.matches(_4))return n;const r=n.closest(_4);return r instanceof HTMLElement&&r.parentElement===t?r:n}function L4(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(r){return!1}const n=document.createRange();return n.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0}function Sie(t,e){const n=D4(t,e.startContainer),r=D4(t,e.endContainer);if(!n)return[];if(!r||n===r)return[n];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>L4(e,a));return o.length>0?o:[n]}function F4(t,e){const n=dB(e),r=n==null?void 0:n.closest("blockquote");return r instanceof HTMLQuoteElement&&t.contains(r)?r:null}function _ie(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function Die(t){Array.from(t.children).forEach(e=>{_ie(e)&&e.remove()})}function fB(t){Die(t);const e=t.parentNode;if(!e)return;Array.from(t.childNodes).forEach(r=>{e.insertBefore(r,t)}),e.removeChild(t)}function I4(t){return t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim()===""}function U4(t){const e=Array.from(t.childNodes).filter(r=>!I4(r));if(e.length!==1)return null;const n=e[0];return n instanceof HTMLQuoteElement?n:null}function Lie(t){const e=document.createElement("blockquote");return Array.from(t.childNodes).filter(r=>!I4(r)).forEach(r=>{e.appendChild(r)}),e.childNodes.length||(e.innerHTML="<br>"),t.appendChild(e),e}function Fie(t,e){const n=Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&L4(e,i)),r=new Set(n);return n.filter(i=>{var a,s;let o=(a=i.parentElement)==null?void 0:a.closest("li");for(;o;){if(r.has(o))return!1;o=(s=o.parentElement)==null?void 0:s.closest("li")}return!0})}function Hb(t){const e=window.getSelection();if(!e)return;const n=document.createRange(),r=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;n.selectNodeContents(r),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function Iie(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Uie(t,e,n){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",t,e,n);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}function Nie(t){var u,d;const e=kie(t);if(!e)return!1;const n=Bie(e);if(!n)return!1;const r=e.innerHTML,i=F4(e,n.startContainer),o=F4(e,n.endContainer),a=Fie(e,n),s=Sie(e,n),c=s.length>0&&s.every(f=>f.tagName==="BLOCKQUOTE");if(i&&i===o){const f=i.firstChild||i;fB(i),Hb(f)}else if(a.length>0){const f=a.map(U4);if(f.every(Boolean)){const h=((u=f[0])==null?void 0:u.firstChild)||a[0];f.forEach(p=>{p&&fB(p)}),Hb(h)}else{const h=a[0];a.forEach(p=>{U4(p)||Lie(p)}),Hb(h)}}else if(c){const f=s[0].firstChild||s[0];s.forEach(fB),Hb(f)}else{const f=s.filter(p=>p.tagName!=="BLOCKQUOTE");if(f.length===0)return!1;const A=document.createElement("blockquote"),h=f[0];(d=h.parentNode)==null||d.insertBefore(A,h),f.forEach(p=>{A.appendChild(p)}),Hb(A)}const l=e.innerHTML;return r===l?!1:(Uie(e,r,l),Iie(e),!0)}const Rie=Object.freeze(Object.defineProperty({__proto__:null,BlockquotePlugin:()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(t,e)=>Nie(e)},keymap:{"Mod-Shift-9":"toggleBlockquote"}})},Symbol.toStringTag,{value:"Module"}));function Oie(t){let e=!1;t.addEventListener("pointerdown",n=>{e=n.target!==t},!0),t.addEventListener("click",n=>{n.target===t&&e&&n.stopImmediatePropagation(),e=!1},!0)}const N4="rte-dialog-base-styles";function Mie(){if(typeof document=="undefined"||document.getElementById(N4))return;const t=document.createElement("style");t.id=N4,t.textContent=`
|
|
12
12
|
[data-rte-dialog] {
|
|
13
13
|
font-family: var(--rte-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
|
|
14
14
|
}
|
|
@@ -22,7 +22,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
22
22
|
`,document.head.appendChild(t)}function Io(t){t.setAttribute("data-rte-dialog",""),Mie(),Oie(t)}class AB{constructor(e=""){this._lines=[],this._version=0,this.setText(e)}getLine(e){return this._lines[e]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
|
|
23
23
|
`)}setText(e){this._lines=e.split(`
|
|
24
24
|
`),this._version++}getTextInRange(e){if(e.start.line===e.end.line)return this.getLine(e.start.line).substring(e.start.column,e.end.column);const n=[];n.push(this.getLine(e.start.line).substring(e.start.column));for(let r=e.start.line+1;r<e.end.line;r++)n.push(this.getLine(r));return e.end.line<this.getLineCount()&&n.push(this.getLine(e.end.line).substring(0,e.end.column)),n.join(`
|
|
25
|
-
`)}replaceRange(e,n){const r=this.normalizeRange(e),i=this.getTextInRange(r),o=this.getText(),a=this.positionToOffset(r.start),s=this.positionToOffset(r.end),c=o.slice(0,a)+n+o.slice(s);return this.setText(c),{range:r,text:n,oldText:i}}insertText(e,n){const r={start:e,end:e};return this.replaceRange(r,n)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let n=0;for(let r=0;r<e.line;r++)n+=this.getLine(r).length+1;return n+=e.column,n}offsetToPosition(e){let n=e;for(let r=0;r<this.getLineCount();r++){const i=this.getLine(r).length;if(n<=i)return{line:r,column:n};n-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new AB;return e._lines=[...this._lines],e._version=this._version,e}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,n){return e.line!==n.line?e.line-n.line:e.column-n.column}}class Pie{constructor(e){this.gutterWidth=50,this.gutterFoldColumnWidth=24,this.gutterFoldColumnGap=4,this.gutterLineNumberPaddingLeft=8,this.gutterLineNumberPaddingRight=4,this.gutterDigitWidth=9,this.lineHeight=24,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.foldPlaceholderAttr="data-lce-fold-placeholder",this.virtualMarkerRegex=/[\u200B\uE000]/,this.virtualMarkerGlobalRegex=/[\u200B\uE000]/g,this.lastLineCount=0,this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.setAttribute("data-lce-editor-container","true"),e.style.cssText=`
|
|
25
|
+
`)}replaceRange(e,n){const r=this.normalizeRange(e),i=this.getTextInRange(r),o=this.getText(),a=this.positionToOffset(r.start),s=this.positionToOffset(r.end),c=o.slice(0,a)+n+o.slice(s);return this.setText(c),{range:r,text:n,oldText:i}}insertText(e,n){const r={start:e,end:e};return this.replaceRange(r,n)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let n=0;for(let r=0;r<e.line;r++)n+=this.getLine(r).length+1;return n+=e.column,n}offsetToPosition(e){let n=e;for(let r=0;r<this.getLineCount();r++){const i=this.getLine(r).length;if(n<=i)return{line:r,column:n};n-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new AB;return e._lines=[...this._lines],e._version=this._version,e}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,n){return e.line!==n.line?e.line-n.line:e.column-n.column}}class Pie{constructor(e){this.gutterWidth=50,this.gutterFoldColumnWidth=24,this.gutterFoldColumnGap=4,this.gutterLineNumberPaddingLeft=8,this.gutterLineNumberPaddingRight=4,this.gutterDigitWidth=9,this.lineHeight=24,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.foldPlaceholderAttr="data-lce-fold-placeholder",this.virtualMarkerRegex=/[\u200B\uE000]/,this.virtualMarkerGlobalRegex=/[\u200B\uE000]/g,this.lastLineCount=0,this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.lineDecorations=[],this.gutterDecorations=[],this.lineWrapping=!1,this.measuredHeights=null,this.measuredTops=[],this.measuredLines=null,this.measuredSignature="",this.measureQueued=!1,this.measurer=null,this.resizeObserver=null,this.destroyed=!1,this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.setAttribute("data-lce-editor-container","true"),e.style.cssText=`
|
|
26
26
|
position: relative;
|
|
27
27
|
display: flex;
|
|
28
28
|
width: 100%;
|
|
@@ -114,20 +114,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
114
114
|
width: 100%;
|
|
115
115
|
min-width: 100%;
|
|
116
116
|
height: 100%;
|
|
117
|
-
`,this.lineNumbersElement.appendChild(this.lineNumbersContentElement),this.lineNumbersElement.appendChild(this.gutterDecorationsElement),r.appendChild(this.lineNumbersElement),n.appendChild(this.lineDecorationsElement),n.appendChild(this.highlightElement),n.appendChild(this.contentElement),r.appendChild(n),e.appendChild(r),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){
|
|
117
|
+
`,this.lineNumbersElement.appendChild(this.lineNumbersContentElement),this.lineNumbersElement.appendChild(this.gutterDecorationsElement),r.appendChild(this.lineNumbersElement),n.appendChild(this.lineDecorationsElement),n.appendChild(this.highlightElement),n.appendChild(this.contentElement),r.appendChild(n),e.appendChild(r),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){this.updateGutterWidth(e),this.queueWrapMeasure(),e!==this.lastLineCount&&(this.lastLineCount=e,this.syncGutterRows(Math.max(e,1)))}syncGutterRows(e){const n=this.lineNumbersContentElement;for(;n.children.length>e;)n.lastElementChild.remove();let r="";for(let i=n.children.length+1;i<=e;i+=1)r+=`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${i}</div>`;r&&n.insertAdjacentHTML("beforeend",r)}lineTop(e){var n;return(n=this.measuredTops[e])!=null?n:e*this.lineHeight}lineHeightAt(e){var n,r;return(r=(n=this.measuredHeights)==null?void 0:n[e])!=null?r:this.lineHeight}queueWrapMeasure(){!this.lineWrapping||this.measureQueued||this.destroyed||(this.measureQueued=!0,Promise.resolve().then(()=>{this.measureQueued=!1,this.measureWrappedLines()}))}measureWrappedLines(){if(!this.lineWrapping||this.destroyed||!this.contentElement.isConnected)return;const e=this.contentElement.__lceFoldPlaceholderSources,n=this.lineNumbersContentElement.children,r=(this.contentElement.textContent||"").split(`
|
|
118
|
+
`),i=this.contentElement.clientWidth;if(e&&e.size>0||n.length!==r.length||i===0){this.applyMeasuredHeights(null);return}const o=this.wrapSignature(i),a=this.measuredLines,s=this.measuredHeights;let c;if(a&&s&&s.length===a.length&&o===this.measuredSignature){const l=Math.min(a.length,r.length);let u=0;for(;u<l&&a[u]===r[u];)u+=1;let d=0;for(;d<l-u&&a[a.length-1-d]===r[r.length-1-d];)d+=1;c=s.slice(0,u).concat(this.measureLines(r.slice(u,r.length-d),i),s.slice(s.length-d))}else c=this.measureLines(r,i);this.measuredLines=r,this.measuredSignature=o,this.applyMeasuredHeights(c)}measureLines(e,n){if(e.length===0)return[];const r=this.ensureMeasurer(n);r.innerHTML=e.map(o=>`<div>${o===""?"​":o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</div>`).join("");const i=Array.from(r.children,o=>o.offsetHeight);return r.textContent="",i}wrapSignature(e){const n=getComputedStyle(this.contentElement);return[e,n.fontFamily,n.fontSize,n.fontWeight,n.letterSpacing,n.tabSize,n.paddingLeft,n.paddingRight,n.whiteSpace,n.overflowWrap,n.wordBreak].join("|")}ensureMeasurer(e){if(!this.measurer){const n=document.createElement("div");n.setAttribute("aria-hidden","true"),n.setAttribute("data-editor-measurer","true"),this.contentSurface.appendChild(n),this.measurer=n}return this.measurer.style.cssText=this.contentElement.style.cssText,Object.assign(this.measurer.style,{position:"absolute",top:"0",left:"0",zIndex:"-1",visibility:"hidden",pointerEvents:"none",width:`${e}px`,minWidth:"0",minHeight:"0",height:"auto"}),this.measurer}applyMeasuredHeights(e){var o,a;const n=this.measuredHeights;if(n===e||n!==null&&e!==null&&n.length===e.length&&n.every((s,c)=>s===e[c]))return;if(this.measuredHeights=e,this.measuredTops=[],e){let s=0;for(const c of e)this.measuredTops.push(s),s+=c}else this.measuredLines=null;const i=this.lineNumbersContentElement.children;for(let s=0;s<i.length;s+=1){const c=(o=n==null?void 0:n[s])!=null?o:this.lineHeight,l=(a=e==null?void 0:e[s])!=null?a:this.lineHeight;c!==l&&(i[s].style.height=`${l}px`)}this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.renderLineDecorations(this.lineDecorations),this.renderGutterDecorations(this.gutterDecorations)}updateGutterWidth(e){const r=String(Math.max(e,1)).length*this.gutterDigitWidth+this.gutterLineNumberPaddingLeft+this.gutterLineNumberPaddingRight,i=Math.ceil(r+this.gutterFoldColumnGap+this.gutterFoldColumnWidth);i!==this.gutterWidth&&(this.gutterWidth=i,this.lineNumbersElement.style.display!=="none"&&(this.lineNumbersElement.style.width=`${this.gutterWidth}px`,this.lineNumbersElement.style.minWidth=`${this.gutterWidth}px`))}setDecorations(e,n){this.lineDecorations=e,this.gutterDecorations=n,this.renderLineDecorations(e),this.renderGutterDecorations(n)}clearDecorations(){this.lastLineDecorationSnapshot&&(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=""),this.lastGutterDecorationSnapshot&&(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot="")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.serializeContentToSource()}setText(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map),this.contentElement.textContent!==e&&(this.contentElement.textContent=e),this.syncTrailingNewlineMarker(e.endsWith(`
|
|
118
119
|
`));const n=e.split(`
|
|
119
120
|
`).length;this.updateLineNumbers(n)}setHTML(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map);const n=/\n$/.test(e),r=/<|>/.test(e),i=/<span\b/i.test(e),o=/<[^>]+>/.test(e);r&&i?this.contentElement.innerHTML=e:o&&!r?this.contentElement.textContent=e:this.contentElement.innerHTML=e,this.syncTrailingNewlineMarker(n);const s=(this.contentElement.textContent||"").split(`
|
|
120
121
|
`).length;this.updateLineNumbers(s)}setHighlightHTML(e){e!==this.lastHighlightHTML&&(this.highlightElement.innerHTML=e,this.lastHighlightHTML=e),this.highlightElement.style.visibility="visible",this.highlightOverlayActive=!0,this.contentElement.style.color="transparent",this.contentElement.style.WebkitTextFillColor="transparent";const r=(this.contentElement.textContent||"").split(`
|
|
121
|
-
`).length;this.updateLineNumbers(r)}setLineWrapping(e){this.contentElement.style.whiteSpace=e?"pre-wrap":"pre",this.contentElement.style.overflow="visible",this.contentElement.style.minWidth=e?"100%":"max-content",this.contentSurface.style.minWidth=e?"100%":"max-content",this.contentElement.style.wordBreak="normal",this.contentElement.style.overflowWrap=e?"anywhere":"normal",this.highlightElement.style.whiteSpace=e?"pre-wrap":"pre",this.highlightElement.style.wordBreak="normal",this.highlightElement.style.overflowWrap=e?"anywhere":"normal"}setLineNumbersVisible(e){this.lineNumbersElement.style.display=e?"table-cell":"none",this.lineNumbersElement.style.width=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.minWidth=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.borderRightWidth=e?"1px":"0",this.scrollWrapper.style.width="100%",this.scrollWrapper.style.minWidth="100%"}setTabSize(e){const n=Math.max(1,Math.floor(e)||2);this.contentElement.style.tabSize=String(n),this.contentElement.style.MozTabSize=String(n),this.highlightElement.style.tabSize=String(n),this.highlightElement.style.MozTabSize=String(n)}syncTrailingNewlineMarkerForText(e){this.syncTrailingNewlineMarker(e.endsWith(`
|
|
122
|
-
`))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const n=this.getText(),r=this.positionToTextOffset(e,n),i=window.getSelection(),o=this.createDomRangeFromOffsets(r);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(a){console.warn("Could not set cursor position:",a)}else{const a=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),s=document.createRange();try{a&&a.parentNode===this.contentElement?s.setStartBefore(a):(s.selectNodeContents(this.contentElement),s.collapse(!1)),s.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(s),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const n=e.getRangeAt(0);if(!this.isNodeInsideContent(n.startContainer)||!this.isNodeInsideContent(n.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const r=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(n.startContainer,n.startOffset),endOffset:this.sourceOffsetFromBoundary(n.endContainer,n.endOffset),anchorOffset:r,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const n=e.getRangeAt(0);if(!this.isNodeInsideContent(n.startContainer)||!this.isNodeInsideContent(n.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const r=this.getText(),i=this.sourceOffsetFromBoundary(n.startContainer,n.startOffset),o=this.sourceOffsetFromBoundary(n.endContainer,n.endOffset),a=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,s=this.offsetToPositionInText(i,r),c=this.offsetToPositionInText(o,r),l=this.offsetToPositionInText(a,r);return{isInEditor:!0,isCollapsed:e.isCollapsed,cursor:l,range:e.isCollapsed?void 0:{start:s,end:c}}}setSelectionRange(e){const n=this.createDomRangeFromRange(e);if(n)try{const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(n),this.ensureCaretVisible()}catch(r){console.warn("Could not set selection range:",r)}}createDomRangeFromOffsets(e,n=e){const[r,i]=e<=n?[e,n]:[n,e],o=this.resolveOffsetToDomPoint(r),a=this.resolveOffsetToDomPoint(i);if(!o||!a)return null;const s=document.createRange();try{return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}catch(c){return null}}createDomRangeFromRange(e){const n=this.getText();return this.createDomRangeFromOffsets(this.positionToTextOffset(e.start,n),this.positionToTextOffset(e.end,n))}getPositionFromClientPoint(e,n){const r=this.getDomRangeFromClientPoint(e,n);if(!r||!this.isNodeInsideContent(r.startContainer))return null;const i=this.sourceOffsetFromBoundary(r.startContainer,r.startOffset);return this.offsetToPositionInText(i,this.getText())}setSelectionOffsets(e,n=e){const r=this.createDomRangeFromOffsets(e,n);if(r)try{const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r),this.ensureCaretVisible()}catch(i){console.warn("Could not set selection offsets:",i)}}setSelectionBoundaryOffsets(e,n){const r=this.resolveOffsetToDomPoint(e),i=this.resolveOffsetToDomPoint(n),o=window.getSelection();if(!r||!i||!o){this.setSelectionOffsets(e,n);return}try{if(o.removeAllRanges(),e===n){const s=document.createRange();s.setStart(r.node,r.offset),s.collapse(!0),o.addRange(s),this.ensureCaretVisible();return}if(typeof o.extend=="function"){const s=document.createRange();s.setStart(r.node,r.offset),s.collapse(!0),o.addRange(s),o.extend(i.node,i.offset),this.ensureCaretVisible();return}const a=this.createDomRangeFromOffsets(e,n);if(!a)return;o.addRange(a),this.ensureCaretVisible()}catch(a){console.warn("Could not set selection boundary offsets:",a),this.setSelectionOffsets(e,n)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([n,r])=>{this.container.style.setProperty(`--${n}`,r)})}scrollToPosition(e){const
|
|
122
|
+
`).length;this.updateLineNumbers(r)}setLineWrapping(e){var n;this.lineWrapping=e,e?(!this.resizeObserver&&typeof ResizeObserver!="undefined"&&(this.resizeObserver=new ResizeObserver(()=>this.queueWrapMeasure()),this.resizeObserver.observe(this.contentElement)),this.queueWrapMeasure()):((n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.applyMeasuredHeights(null)),this.contentElement.style.whiteSpace=e?"pre-wrap":"pre",this.contentElement.style.overflow="visible",this.contentElement.style.minWidth=e?"100%":"max-content",this.contentSurface.style.minWidth=e?"100%":"max-content",this.contentElement.style.wordBreak="normal",this.contentElement.style.overflowWrap=e?"anywhere":"normal",this.highlightElement.style.whiteSpace=e?"pre-wrap":"pre",this.highlightElement.style.wordBreak="normal",this.highlightElement.style.overflowWrap=e?"anywhere":"normal"}setLineNumbersVisible(e){this.lineNumbersElement.style.display=e?"table-cell":"none",this.lineNumbersElement.style.width=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.minWidth=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.borderRightWidth=e?"1px":"0",this.scrollWrapper.style.width="100%",this.scrollWrapper.style.minWidth="100%"}setTabSize(e){const n=Math.max(1,Math.floor(e)||2);this.contentElement.style.tabSize=String(n),this.contentElement.style.MozTabSize=String(n),this.highlightElement.style.tabSize=String(n),this.highlightElement.style.MozTabSize=String(n)}syncTrailingNewlineMarkerForText(e){this.syncTrailingNewlineMarker(e.endsWith(`
|
|
123
|
+
`))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const n=this.getText(),r=this.positionToTextOffset(e,n),i=window.getSelection(),o=this.createDomRangeFromOffsets(r);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(a){console.warn("Could not set cursor position:",a)}else{const a=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),s=document.createRange();try{a&&a.parentNode===this.contentElement?s.setStartBefore(a):(s.selectNodeContents(this.contentElement),s.collapse(!1)),s.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(s),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const n=e.getRangeAt(0);if(!this.isNodeInsideContent(n.startContainer)||!this.isNodeInsideContent(n.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const r=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(n.startContainer,n.startOffset),endOffset:this.sourceOffsetFromBoundary(n.endContainer,n.endOffset),anchorOffset:r,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const n=e.getRangeAt(0);if(!this.isNodeInsideContent(n.startContainer)||!this.isNodeInsideContent(n.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const r=this.getText(),i=this.sourceOffsetFromBoundary(n.startContainer,n.startOffset),o=this.sourceOffsetFromBoundary(n.endContainer,n.endOffset),a=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,s=this.offsetToPositionInText(i,r),c=this.offsetToPositionInText(o,r),l=this.offsetToPositionInText(a,r);return{isInEditor:!0,isCollapsed:e.isCollapsed,cursor:l,range:e.isCollapsed?void 0:{start:s,end:c}}}setSelectionRange(e){const n=this.createDomRangeFromRange(e);if(n)try{const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(n),this.ensureCaretVisible()}catch(r){console.warn("Could not set selection range:",r)}}createDomRangeFromOffsets(e,n=e){const[r,i]=e<=n?[e,n]:[n,e],o=this.resolveOffsetToDomPoint(r),a=this.resolveOffsetToDomPoint(i);if(!o||!a)return null;const s=document.createRange();try{return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}catch(c){return null}}createDomRangeFromRange(e){const n=this.getText();return this.createDomRangeFromOffsets(this.positionToTextOffset(e.start,n),this.positionToTextOffset(e.end,n))}getPositionFromClientPoint(e,n){const r=this.getDomRangeFromClientPoint(e,n);if(!r||!this.isNodeInsideContent(r.startContainer))return null;const i=this.sourceOffsetFromBoundary(r.startContainer,r.startOffset);return this.offsetToPositionInText(i,this.getText())}setSelectionOffsets(e,n=e){const r=this.createDomRangeFromOffsets(e,n);if(r)try{const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(r),this.ensureCaretVisible()}catch(i){console.warn("Could not set selection offsets:",i)}}setSelectionBoundaryOffsets(e,n){const r=this.resolveOffsetToDomPoint(e),i=this.resolveOffsetToDomPoint(n),o=window.getSelection();if(!r||!i||!o){this.setSelectionOffsets(e,n);return}try{if(o.removeAllRanges(),e===n){const s=document.createRange();s.setStart(r.node,r.offset),s.collapse(!0),o.addRange(s),this.ensureCaretVisible();return}if(typeof o.extend=="function"){const s=document.createRange();s.setStart(r.node,r.offset),s.collapse(!0),o.addRange(s),o.extend(i.node,i.offset),this.ensureCaretVisible();return}const a=this.createDomRangeFromOffsets(e,n);if(!a)return;o.addRange(a),this.ensureCaretVisible()}catch(a){console.warn("Could not set selection boundary offsets:",a),this.setSelectionOffsets(e,n)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([n,r])=>{this.container.style.setProperty(`--${n}`,r)})}scrollToPosition(e){const n=Math.max(0,Math.floor(e.line)||0),i=this.lineTop(n)-this.editorContainer.clientHeight/2+this.lineHeight/2;this.editorContainer.scrollTop=Math.max(0,i)}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(e){this.editorContainer.scrollTop=e}syncTrailingNewlineMarker(e){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(r=>r.remove()),!e)return;const n=document.createElement("span");n.setAttribute(this.trailingNewlineMarkerAttr,"true"),n.setAttribute("aria-hidden","true"),n.contentEditable="false",n.style.cssText=`
|
|
123
124
|
display: inline-block;
|
|
124
125
|
width: 0;
|
|
125
126
|
overflow: hidden;
|
|
126
127
|
pointer-events: none;
|
|
127
128
|
user-select: none;
|
|
128
|
-
`,n.appendChild(document.createTextNode("")),this.contentElement.appendChild(n)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=this.getCaretClientRect(e);if(!n)return;const r=this.editorContainer.getBoundingClientRect(),i=12;n.bottom>r.bottom-i?this.editorContainer.scrollTop+=n.bottom-(r.bottom-i):n.top<r.top+i&&(this.editorContainer.scrollTop-=r.top+i-n.top),n.right>r.right-i?this.editorContainer.scrollLeft+=n.right-(r.right-i):n.left<r.left+i&&(this.editorContainer.scrollLeft-=r.left+i-n.left)}destroy(){this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const n=Math.max(0,e);let r=0;const i=Array.from(this.contentElement.childNodes);for(let a=0;a<i.length;a++){const s=i[a];if(s instanceof Text){const c=s.textContent||"",l=this.buildVisibleToDomMap(c),u=Math.max(0,l.length-1);if(r+u>=n){const d=Math.max(0,n-r),f=(o=l[d])!=null?o:c.length;return{node:s,offset:f}}r+=u;continue}if(s instanceof HTMLElement&&!s.hasAttribute(this.trailingNewlineMarkerAttr)&&s.hasAttribute(this.foldPlaceholderAttr)){const l=this.getFoldPlaceholderSource(s).length;if(r+l>=n){const u=n-r;return{node:this.contentElement,offset:u<=l/2?a:a+1}}r+=l}}return{node:this.contentElement,offset:this.contentElement.childNodes.length}}getDomRangeFromClientPoint(e,n){const r=document;if(typeof r.caretPositionFromPoint=="function"){const i=r.caretPositionFromPoint(e,n);if(i!=null&&i.offsetNode){const o=document.createRange();try{return o.setStart(i.offsetNode,i.offset),o.collapse(!0),o}catch(a){return null}}}return typeof r.caretRangeFromPoint=="function"?r.caretRangeFromPoint(e,n):null}buildVisibleToDomMap(e){const n=[0];let r=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(r+=1,n[r]=i+1)}return n}isNodeInsideContent(e){return e===this.contentElement||this.contentElement.contains(e)}getCaretClientRect(e){var s,c,l;const n=e.getRangeAt(0).cloneRange();n.collapse(!1);const r=this.getUsableRangeRect(n);if(r)return r;const i=e.focusNode,o=e.focusOffset;if(i instanceof Text){const u=(c=(s=i.textContent)==null?void 0:s.length)!=null?c:0,d=document.createRange();if(o<u){d.setStart(i,o),d.setEnd(i,Math.min(u,o+1));const f=this.getUsableRangeRect(d);if(f)return f}if(o>0){d.setStart(i,o-1),d.setEnd(i,o);const f=this.getUsableRangeRect(d);if(f)return f}}const a=i instanceof Element?i:(l=i==null?void 0:i.parentElement)!=null?l:null;if(a&&a!==this.contentElement&&a!==this.editorContainer&&this.contentElement.contains(a)){const u=a.getBoundingClientRect();if(this.isUsableRect(u))return u}return null}getUsableRangeRect(e){const n=Array.from(e.getClientRects());for(let i=0;i<n.length;i++)if(this.isUsableRect(n[i]))return n[i];const r=e.getBoundingClientRect();return this.isUsableRect(r)?r:null}isUsableRect(e){return!!e&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&(e.width>0||e.height>0)}stripVirtualMarkers(e){return e.replace(this.virtualMarkerGlobalRegex,"")}clearHighlightOverlay(){!this.highlightOverlayActive&&!this.lastHighlightHTML||(this.highlightElement.innerHTML="",this.highlightElement.style.visibility="hidden",this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.contentElement.style.color="inherit",this.contentElement.style.WebkitTextFillColor="currentcolor")}serializeContentToSource(){let e="";const n=Array.from(this.contentElement.childNodes);for(const r of n){if(r instanceof Text){e+=this.stripVirtualMarkers(r.textContent||"");continue}if(r instanceof HTMLElement&&!r.hasAttribute(this.trailingNewlineMarkerAttr)){if(r.hasAttribute(this.foldPlaceholderAttr)){e+=this.getFoldPlaceholderSource(r);continue}e+=this.stripVirtualMarkers(r.textContent||"")}}return e}sourceOffsetFromBoundary(e,n){let r=0;const i=Array.from(this.contentElement.childNodes);if(e===this.contentElement){for(let o=0;o<Math.min(n,i.length);o++)r+=this.getSourceLength(i[o]);return r}for(let o=0;o<i.length;o++){const a=i[o];if(a===e){if(a instanceof Text)return r+this.stripVirtualMarkers((a.textContent||"").slice(0,n)).length;if(a instanceof HTMLElement){if(a.hasAttribute(this.foldPlaceholderAttr))return r+this.getFoldPlaceholderBoundaryOffset(a,a,n);const s=Array.from(a.childNodes);for(let c=0;c<Math.min(n,s.length);c++)r+=this.getSourceLength(s[c]);return r}}if(a instanceof HTMLElement&&a.contains(e))return a.hasAttribute(this.foldPlaceholderAttr)?r+this.getFoldPlaceholderBoundaryOffset(a,e,n):r+this.sourceOffsetWithinNode(a,e,n);r+=this.getSourceLength(a)}return r}sourceOffsetWithinNode(e,n,r){let i=0;const o=Array.from(e.childNodes);if(n===e){for(let a=0;a<Math.min(r,o.length);a++)i+=this.getSourceLength(o[a]);return i}for(let a=0;a<o.length;a++){const s=o[a];if(s===n){if(s instanceof Text)return i+this.stripVirtualMarkers((s.textContent||"").slice(0,r)).length;if(s instanceof HTMLElement){if(s.hasAttribute(this.foldPlaceholderAttr))return i+this.getFoldPlaceholderBoundaryOffset(s,s,r);const c=Array.from(s.childNodes);for(let l=0;l<Math.min(r,c.length);l++)i+=this.getSourceLength(c[l]);return i}}if(s instanceof HTMLElement&&s.contains(n))return s.hasAttribute(this.foldPlaceholderAttr)?i+this.getFoldPlaceholderBoundaryOffset(s,n,r):i+this.sourceOffsetWithinNode(s,n,r);i+=this.getSourceLength(s)}return i}getSourceLength(e){if(e instanceof Text)return this.stripVirtualMarkers(e.textContent||"").length;if(!(e instanceof HTMLElement)||e.hasAttribute(this.trailingNewlineMarkerAttr))return 0;if(e.hasAttribute(this.foldPlaceholderAttr))return this.getFoldPlaceholderSource(e).length;let n=0;return e.childNodes.forEach(r=>{n+=this.getSourceLength(r)}),n}renderLineDecorations(e){const n=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),r=n.map(o=>`${o.id}:${o.line}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(r===this.lastLineDecorationSnapshot||(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=r,n.length===0))return;const i=document.createDocumentFragment();for(const o of n){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-line",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${o.line
|
|
129
|
+
`,n.appendChild(document.createTextNode("")),this.contentElement.appendChild(n)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=this.getCaretClientRect(e);if(!n)return;const r=this.editorContainer.getBoundingClientRect(),i=12;n.bottom>r.bottom-i?this.editorContainer.scrollTop+=n.bottom-(r.bottom-i):n.top<r.top+i&&(this.editorContainer.scrollTop-=r.top+i-n.top),n.right>r.right-i?this.editorContainer.scrollLeft+=n.right-(r.right-i):n.left<r.left+i&&(this.editorContainer.scrollLeft-=r.left+i-n.left)}destroy(){var e;this.destroyed=!0,(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const n=Math.max(0,e);let r=0;const i=Array.from(this.contentElement.childNodes);for(let a=0;a<i.length;a++){const s=i[a];if(s instanceof Text){const c=s.textContent||"",l=this.buildVisibleToDomMap(c),u=Math.max(0,l.length-1);if(r+u>=n){const d=Math.max(0,n-r),f=(o=l[d])!=null?o:c.length;return{node:s,offset:f}}r+=u;continue}if(s instanceof HTMLElement&&!s.hasAttribute(this.trailingNewlineMarkerAttr)&&s.hasAttribute(this.foldPlaceholderAttr)){const l=this.getFoldPlaceholderSource(s).length;if(r+l>=n){const u=n-r;return{node:this.contentElement,offset:u<=l/2?a:a+1}}r+=l}}return{node:this.contentElement,offset:this.contentElement.childNodes.length}}getDomRangeFromClientPoint(e,n){const r=document;if(typeof r.caretPositionFromPoint=="function"){const i=r.caretPositionFromPoint(e,n);if(i!=null&&i.offsetNode){const o=document.createRange();try{return o.setStart(i.offsetNode,i.offset),o.collapse(!0),o}catch(a){return null}}}return typeof r.caretRangeFromPoint=="function"?r.caretRangeFromPoint(e,n):null}buildVisibleToDomMap(e){const n=[0];let r=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(r+=1,n[r]=i+1)}return n}isNodeInsideContent(e){return e===this.contentElement||this.contentElement.contains(e)}getCaretClientRect(e){var s,c,l;const n=e.getRangeAt(0).cloneRange();n.collapse(!1);const r=this.getUsableRangeRect(n);if(r)return r;const i=e.focusNode,o=e.focusOffset;if(i instanceof Text){const u=(c=(s=i.textContent)==null?void 0:s.length)!=null?c:0,d=document.createRange();if(o<u){d.setStart(i,o),d.setEnd(i,Math.min(u,o+1));const f=this.getUsableRangeRect(d);if(f)return f}if(o>0){d.setStart(i,o-1),d.setEnd(i,o);const f=this.getUsableRangeRect(d);if(f)return f}}const a=i instanceof Element?i:(l=i==null?void 0:i.parentElement)!=null?l:null;if(a&&a!==this.contentElement&&a!==this.editorContainer&&this.contentElement.contains(a)){const u=a.getBoundingClientRect();if(this.isUsableRect(u))return u}return null}getUsableRangeRect(e){const n=Array.from(e.getClientRects());for(let i=0;i<n.length;i++)if(this.isUsableRect(n[i]))return n[i];const r=e.getBoundingClientRect();return this.isUsableRect(r)?r:null}isUsableRect(e){return!!e&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&(e.width>0||e.height>0)}stripVirtualMarkers(e){return e.replace(this.virtualMarkerGlobalRegex,"")}clearHighlightOverlay(){!this.highlightOverlayActive&&!this.lastHighlightHTML||(this.highlightElement.innerHTML="",this.highlightElement.style.visibility="hidden",this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.contentElement.style.color="inherit",this.contentElement.style.WebkitTextFillColor="currentcolor")}serializeContentToSource(){let e="";const n=Array.from(this.contentElement.childNodes);for(const r of n){if(r instanceof Text){e+=this.stripVirtualMarkers(r.textContent||"");continue}if(r instanceof HTMLElement&&!r.hasAttribute(this.trailingNewlineMarkerAttr)){if(r.hasAttribute(this.foldPlaceholderAttr)){e+=this.getFoldPlaceholderSource(r);continue}e+=this.stripVirtualMarkers(r.textContent||"")}}return e}sourceOffsetFromBoundary(e,n){let r=0;const i=Array.from(this.contentElement.childNodes);if(e===this.contentElement){for(let o=0;o<Math.min(n,i.length);o++)r+=this.getSourceLength(i[o]);return r}for(let o=0;o<i.length;o++){const a=i[o];if(a===e){if(a instanceof Text)return r+this.stripVirtualMarkers((a.textContent||"").slice(0,n)).length;if(a instanceof HTMLElement){if(a.hasAttribute(this.foldPlaceholderAttr))return r+this.getFoldPlaceholderBoundaryOffset(a,a,n);const s=Array.from(a.childNodes);for(let c=0;c<Math.min(n,s.length);c++)r+=this.getSourceLength(s[c]);return r}}if(a instanceof HTMLElement&&a.contains(e))return a.hasAttribute(this.foldPlaceholderAttr)?r+this.getFoldPlaceholderBoundaryOffset(a,e,n):r+this.sourceOffsetWithinNode(a,e,n);r+=this.getSourceLength(a)}return r}sourceOffsetWithinNode(e,n,r){let i=0;const o=Array.from(e.childNodes);if(n===e){for(let a=0;a<Math.min(r,o.length);a++)i+=this.getSourceLength(o[a]);return i}for(let a=0;a<o.length;a++){const s=o[a];if(s===n){if(s instanceof Text)return i+this.stripVirtualMarkers((s.textContent||"").slice(0,r)).length;if(s instanceof HTMLElement){if(s.hasAttribute(this.foldPlaceholderAttr))return i+this.getFoldPlaceholderBoundaryOffset(s,s,r);const c=Array.from(s.childNodes);for(let l=0;l<Math.min(r,c.length);l++)i+=this.getSourceLength(c[l]);return i}}if(s instanceof HTMLElement&&s.contains(n))return s.hasAttribute(this.foldPlaceholderAttr)?i+this.getFoldPlaceholderBoundaryOffset(s,n,r):i+this.sourceOffsetWithinNode(s,n,r);i+=this.getSourceLength(s)}return i}getSourceLength(e){if(e instanceof Text)return this.stripVirtualMarkers(e.textContent||"").length;if(!(e instanceof HTMLElement)||e.hasAttribute(this.trailingNewlineMarkerAttr))return 0;if(e.hasAttribute(this.foldPlaceholderAttr))return this.getFoldPlaceholderSource(e).length;let n=0;return e.childNodes.forEach(r=>{n+=this.getSourceLength(r)}),n}renderLineDecorations(e){const n=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),r=n.map(o=>`${o.id}:${o.line}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(r===this.lastLineDecorationSnapshot||(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=r,n.length===0))return;const i=document.createDocumentFragment();for(const o of n){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-line",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${this.lineTop(o.line)}px`,`height: ${this.lineHeightAt(o.line)}px`,"left: 12px","right: 12px","border-radius: 3px",this.serializeStyleObject(o.style)]),i.appendChild(a)}this.lineDecorationsElement.appendChild(i)}renderGutterDecorations(e){const n=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),r=n.map(o=>`${o.id}:${o.line}:${o.label||""}:${o.title||""}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(r===this.lastGutterDecorationSnapshot||(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot=r,n.length===0))return;const i=document.createDocumentFragment();for(const o of n){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-gutter",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${this.lineTop(o.line)}px`,`height: ${this.lineHeightAt(o.line)}px`,"left: 0","right: 0","display: flex","align-items: center","justify-content: flex-end","padding-right: 4px","box-sizing: border-box",this.serializeStyleObject(o.style)]),o.title&&(a.title=o.title),a.textContent=o.label||"",i.appendChild(a)}this.gutterDecorationsElement.appendChild(i)}joinClassNames(...e){return e.filter(Boolean).join(" ").trim()}joinStyleFragments(e){return e.filter(n=>!!n&&n.trim().length>0).map(n=>{const r=n.trim();return r.endsWith(";")?r:`${r};`}).join(" ")}serializeStyleObject(e){return e?Object.entries(e).filter(([,n])=>typeof n=="string"&&n.length>0).map(([n,r])=>`${this.toKebabCase(n)}: ${r}`).join("; "):""}toKebabCase(e){return e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}offsetToPositionInText(e,n){const r=Math.max(0,Math.min(e,n.length)),o=n.slice(0,r).split(`
|
|
129
130
|
`);return{line:o.length-1,column:o[o.length-1].length}}positionToTextOffset(e,n){var s;const r=n.split(`
|
|
130
|
-
`),i=Math.max(0,Math.min(e.line,r.length-1)),o=Math.max(0,Math.min(e.column,((s=r[i])==null?void 0:s.length)||0));let a=0;for(let c=0;c<i;c++)a+=r[c].length+1;return a+o}getFoldPlaceholderSource(e){const n=e.getAttribute(this.foldPlaceholderAttr),r=this.getFoldPlaceholderSources();return n&&r.has(n)?r.get(n)||"":e.__lceFoldHiddenText||""}getFoldPlaceholderSources(){return this.contentElement.__lceFoldPlaceholderSources||new Map}getFoldPlaceholderBoundaryOffset(e,n,r){const i=this.getFoldPlaceholderSource(e).length,o=this.stripVirtualMarkers(e.textContent||"").length;if(i===0||o===0)return 0;const a=document.createRange();a.selectNodeContents(e);try{a.setEnd(n,r)}catch(c){return 0}return this.stripVirtualMarkers(a.toString()).length<=o/2?0:i}setFoldPlaceholderSources(e){this.contentElement.__lceFoldPlaceholderSources=e}}let Hie=0;const xo=class xo{constructor(e,n={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.undoStack=[],this.redoStack=[],this.suppressHistory=!1,this.highlightTimeout=null,this.expectingProgrammaticCursor=!1,this.lastKnownCursor={line:0,column:0},this.editorInstanceId=++Hie,this.decorationHighlightStyleId=`editora-decoration-style-${this.editorInstanceId}`,this.decorationHighlightLimit=1e3,this.decorationLayers=new Map,this.inlineDecorationHighlightNames=new Set,this.decorationRenderRaf=null,this.decorationMutationObserver=null,this.hasCustomDecorationHighlightSupport=!1,this.lastProgrammaticClipboardInsertAt=0,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...n},this.textModel=new AB(this.config.value),this.view=new Pie(e),this.view.setTabSize(this.config.tabSize||2),this.view.setLineWrapping(!!this.config.lineWrapping),this.view.setLineNumbersVisible(this.config.lineNumbers!==!1),this.hasCustomDecorationHighlightSupport=this.detectCustomHighlightSupport(),this.observeDecorationRelevantMutations(),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(r=>this.addExtension(r)),this.setTheme(this.config.theme),this.view.setReadOnly(this.config.readOnly||!1),this.renderTextWithHighlight(this.textModel.getText()),this.registerBuiltInCommands()}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}registerBuiltInCommands(){this.registerCommand("undo",()=>this.undo()),this.registerCommand("redo",()=>this.redo()),this.registerCommand("insertTab",()=>this.insertTab()),this.registerCommand("outdent",()=>{this.shiftSelectedLines(!0)}),this.registerCommand("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("beforeinput",n=>{if(this.suppressHistory||this.config.readOnly){this.pendingInputSnapshot=void 0;return}if(n.inputType==="insertFromPaste"||n.inputType==="insertFromPasteAsQuotation"||n.inputType==="insertFromDrop"){const r=n.dataTransfer,i=this.getPlainTextFromDataTransfer(r);if(i.length===0||(n.preventDefault(),this.pendingInputSnapshot=void 0,Date.now()-this.lastProgrammaticClipboardInsertAt<80))return;this.insertClipboardText(i);return}if(n.inputType==="insertParagraph"||n.inputType==="insertLineBreak"){n.preventDefault(),this.pendingInputSnapshot=void 0,this.insertNewLine();return}if(!n.isComposing){const r=xo.deletionUnit(n.inputType,"Backward");if(r){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteBackward(r);return}const i=xo.deletionUnit(n.inputType,"Forward");if(i){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteForward(i);return}}if(n.inputType==="deleteByCut"){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteSelection();return}if(n.inputType==="insertText"&&typeof n.data=="string"&&!n.isComposing){n.preventDefault(),this.pendingInputSnapshot=void 0,this.replaceSelectionWithText(n.data);return}this.pendingInputSnapshot=this.captureHistorySnapshot()}),e.addEventListener("paste",n=>{if(this.config.readOnly){n.preventDefault();return}if(Date.now()-this.lastProgrammaticClipboardInsertAt<80){n.preventDefault();return}const r=this.getPlainTextFromDataTransfer(n.clipboardData);r.length!==0&&(n.preventDefault(),this.insertClipboardText(r))}),e.addEventListener("input",()=>{var i;const n=this.view.getText(),r=this.textModel.getText();n!==r?(this.suppressHistory||this.pushUndoSnapshot((i=this.pendingInputSnapshot)!=null?i:this.captureHistorySnapshot(r)),this.pendingInputSnapshot=void 0,this.textModel.setText(n),this.view.syncTrailingNewlineMarkerForText(n),this.hasRenderedFoldPlaceholders()?this.clearPendingHighlightRender():(this.clearPendingHighlightRender(),this.highlightTimeout=setTimeout(()=>{const o=this.view.getText();o!==this.textModel.getText()&&this.textModel.setText(o),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300)),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:n,oldText:r}])):this.pendingInputSnapshot=void 0}),this.documentSelectionChangeHandler=()=>{var i,o,a;const n=this.syncSelectionCacheFromView();if(!n.isInEditor)return;const r=(i=n.cursor)!=null?i:this.lastKnownCursor;this.emit("cursor",{position:r,anchor:(a=(o=n.range)==null?void 0:o.start)!=null?a:r}),this.emit("selection",n.isCollapsed?void 0:n.range)},document.addEventListener("selectionchange",this.documentSelectionChangeHandler),e.addEventListener("keydown",n=>{this.emit("keydown",n);const r=Array.from(this.extensions.values()).reverse();for(const a of r)if(a.onKeyDown&&a.onKeyDown(n)===!1){n.preventDefault(),n.stopPropagation();return}if(n.key==="Tab"&&!this.config.readOnly){n.shiftKey?this.shiftSelectedLines(!0):this.insertTab(),n.preventDefault(),n.stopPropagation();return}const i=n.altKey||n.ctrlKey||n.metaKey,o=n.isComposing||n.keyCode===229;if(n.key==="Backspace"&&!this.config.readOnly&&!i&&!o){this.deleteBackward(),n.preventDefault(),n.stopPropagation();return}if(n.key==="Delete"&&!this.config.readOnly&&!i&&!o){this.deleteForward(),n.preventDefault(),n.stopPropagation();return}if(n.key==="Enter"&&!this.config.readOnly){this.insertNewLine(),n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("mousedown",n=>{this.emit("mousedown",n);const r=Array.from(this.extensions.values()).reverse();for(const i of r)if(i.onMouseDown&&i.onMouseDown(n)===!1){n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("contextmenu",n=>{this.emit("contextmenu",n);const r=Array.from(this.extensions.values()).reverse();for(const i of r)if(i.onContextMenu&&i.onContextMenu(n)===!1){n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...n){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(...n))}getValue(){return this.textModel.getText()}setValue(e){const n=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:n}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){var r,i,o;const e=this.syncSelectionCacheFromView(),n=(r=e.cursor)!=null?r:this.lastKnownCursor;return{position:n,anchor:(o=(i=e.range)==null?void 0:i.start)!=null?o:n}}setCursor(e){const n=this.textModel.getText(),r=this.clampPositionToText(e,n),i=this.positionToOffsetInText(r,n);this.lastKnownCursor=r,this.lastKnownSelection=void 0,this.view.setSelectionOffsets(i),this.emit("cursor",this.getCursor())}getSelection(){const e=this.syncSelectionCacheFromView();if(!(!e.isInEditor||e.isCollapsed))return e.range}setSelection(e){const n=this.textModel.getText(),r=this.normalizeRange({start:this.clampPositionToText(e.start,n),end:this.clampPositionToText(e.end,n)}),i=this.positionToOffsetInText(r.start,n),o=this.positionToOffsetInText(r.end,n);this.lastKnownSelection=r,this.lastKnownCursor=r.end,this.view.setSelectionOffsets(i,o),this.emit("selection",r)}setTheme(e){this.currentTheme=e;const n={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(n);const r=this.extensions.get("syntax-highlighting");if(r&&typeof r.setTheme=="function")try{r.setTheme(e==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this),e.name==="syntax-highlighting"&&typeof e.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(e){const n=this.extensions.get(e);n&&n.destroy&&n.destroy(),this.extensions.delete(e)}executeCommand(e,...n){const r=this.commands.get(e);r?r(...n):console.warn(`Command '${e}' not found`)}registerCommand(e,n){this.commands.set(e,n)}setDecorations(e,n){const r=e.trim();if(!r)throw new Error("Decoration layer name must not be empty");if(!Array.isArray(n)||n.length===0){this.decorationLayers.delete(r),this.scheduleDecorationRender();return}this.decorationLayers.set(r,n.map(i=>this.cloneDecoration(i))),this.scheduleDecorationRender()}clearDecorations(e){typeof e=="string"?this.decorationLayers.delete(e.trim()):this.decorationLayers.clear(),this.scheduleDecorationRender()}getDecorations(e){if(typeof e=="string")return(this.decorationLayers.get(e.trim())||[]).map(r=>this.cloneDecoration(r));const n=[];for(const r of this.decorationLayers.values())n.push(...r.map(i=>this.cloneDecoration(i)));return n}search(e,n={}){var u;if(!e)return[];const r={query:e,caseSensitive:!1,wholeWord:!1,regex:!1,...n},i=[],o=this.textModel.getText(),{normalizedText:a,normalizedToRawOffsets:s}=this.buildSearchTextAndOffsetMap(o),c=r.caseSensitive?a:a.toLowerCase(),l=r.caseSensitive?e:e.toLowerCase();if(r.regex){let d;try{d=new RegExp(e,r.caseSensitive?"g":"gi")}catch(A){return[]}let f;for(;(f=d.exec(a))!==null;){const A=(u=f[0])!=null?u:"";if(A.length===0){d.lastIndex=f.index+1;continue}const h=f.index,p=f.index+A.length;r.wholeWord&&!this.isWholeWordBoundary(a,h,p)||this.pushSearchResultFromOffsets(i,h,p,a,s)}}else{let d=0,f=c.indexOf(l,d);for(;f!==-1;){const A=f+l.length;!r.wholeWord||this.isWholeWordBoundary(a,f,A)?(this.pushSearchResultFromOffsets(i,f,A,a,s),d=A):d=f+1,f=c.indexOf(l,d)}}return i}pushSearchResultFromOffsets(e,n,r,i,o){var u,d;const a=(u=o[n])!=null?u:n,s=(d=o[r])!=null?d:a,c=this.textModel.offsetToPosition(a),l=this.textModel.offsetToPosition(s);e.push({range:{start:c,end:l},match:i.substring(n,r)})}isWholeWordBoundary(e,n,r){const i=n>0?e[n-1]:"",o=r<e.length?e[r]:"";return!this.isWordChar(i)&&!this.isWordChar(o)}isWordChar(e){return/^[A-Za-z0-9_]$/.test(e)}buildSearchTextAndOffsetMap(e){const n=[],r=[0];let i=0;for(let o=0;o<e.length;o++){const a=e[o];a===""||a===xo.CURSOR_SENTINEL||(n.push(a),i+=1,r[i]=o+1)}return r[i]=e.length,{normalizedText:n.join(""),normalizedToRawOffsets:r}}replace(e,n){const r=this.getValue();this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(r));const i=this.textModel.replaceRange(e,n);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(e,n,r={}){const i=this.search(e,r);if(i.length===0)return 0;this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));const o=[];for(let a=i.length-1;a>=0;a--)o.push(this.textModel.replaceRange(i[a].range,n));return this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",o),i.length}fold(e){this.clearPendingHighlightRender();const n=this.normalizeRange(e);if(n.start.line===n.end.line&&n.start.column===n.end.column)return;const r=this.folds.findIndex(o=>this.isSameFoldRange(o,n)),i={start:n.start,end:n.end,collapsed:!0,level:0};r!==-1?this.folds[r]=i:(this.folds.push(i),this.folds.sort((o,a)=>this.comparePositions(o.start,a.start)))}unfold(e){this.clearPendingHighlightRender();const n=this.normalizeRange(e);this.folds=this.folds.filter(r=>!this.isSameFoldRange(r,n))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(e,n=!0){const r=this.extensions.get("syntax-highlighting");if(r&&typeof r.highlightHTML=="function")try{if(typeof this.view.setHighlightHTML=="function"){const p=this.view.getContentElement();(p.querySelector("[data-lce-fold-placeholder]")||p.textContent!==e)&&this.view.setText(e);const g=typeof r.highlight=="function"?r.highlight(e):r.highlightHTML(e);this.view.setHighlightHTML(g),this.view.syncTrailingNewlineMarkerForText(e),this.scheduleDecorationRender();return}const o=!n&&!this.expectingProgrammaticCursor;let a,s,c,l;const u=this.view.getSelectionState(),d=u.isInEditor&&!!u.cursor;(n||o)&&d&&(a=u.isCollapsed?void 0:u.range,s=this.textModel.positionToOffset(u.cursor),a&&(c=this.textModel.positionToOffset(a.start),l=this.textModel.positionToOffset(a.end)));const f=d&&(n||o)&&!a&&s!==void 0&&this.hasCollapsedSelectionInEditor(),A=f?this.insertSentinelAtOffset(e,s):e,h=typeof r.highlight=="function"?r.highlight(A):r.highlightHTML(A);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(h):this.view.setHTML(h),this.view.syncTrailingNewlineMarkerForText(e),(n||o)&&d&&requestAnimationFrame(()=>{try{if(f&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(a&&(c!==void 0||l!==void 0)){const p=c!==void 0?c:s,m=l!==void 0?l:s,g=Math.min(p,m),b=Math.max(p,m),y=this.textModel.offsetToPosition(g),w=this.textModel.offsetToPosition(b);this.view.setSelectionRange({start:y,end:w})}else if(s!==void 0){const p=this.textModel.offsetToPosition(s);this.view.setCursorPosition(p)}}catch(p){}}),this.scheduleDecorationRender();return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e),this.scheduleDecorationRender()}hasCollapsedSelectionInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return!1;const n=e.getRangeAt(0);return this.view.getContentElement().contains(n.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return;const n=e.getRangeAt(0),r=this.view.getContentElement();if(!r.contains(n.commonAncestorContainer))return;const i=n.cloneRange();return i.selectNodeContents(r),i.setEnd(n.endContainer,n.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(e){return e.replace(/\u200B/g,"").split(xo.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(e,n){const r=Math.max(0,Math.min(n,e.length));return e.slice(0,r)+xo.CURSOR_SENTINEL+e.slice(r)}restoreCursorFromSentinel(){var s;const e=this.view.getContentElement(),n=window.getSelection(),r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=r.nextNode(),o=null,a=0;for(;i;){const c=(s=i.textContent)!=null?s:"",l=c.indexOf(xo.CURSOR_SENTINEL);l!==-1&&(o||(o=i,a=l),i.textContent=c.split(xo.CURSOR_SENTINEL).join("")),i=r.nextNode()}if(!o||!n)return!1;try{const c=document.createRange();return c.setStart(o,a),c.collapse(!0),n.removeAllRanges(),n.addRange(c),!0}catch(c){return!1}}destroy(){var e;if(!this.isDestroyed){this.isDestroyed=!0,this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null),this.pendingInputSnapshot=void 0,this.documentSelectionChangeHandler&&(document.removeEventListener("selectionchange",this.documentSelectionChangeHandler),this.documentSelectionChangeHandler=void 0),this.decorationRenderRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.decorationRenderRaf),this.decorationRenderRaf=null),(e=this.decorationMutationObserver)==null||e.disconnect(),this.decorationMutationObserver=null,this.clearInlineDecorationHighlights(!0),this.decorationLayers.clear(),this.view.clearDecorations();for(const n of this.extensions.values())n.destroy&&n.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}undo(){if(this.undoStack.length===0)return;const e=this.undoStack.pop(),n=this.captureHistorySnapshot();this.pushSnapshot(this.redoStack,n);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop(),n=this.captureHistorySnapshot();this.pushSnapshot(this.undoStack,n);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly||this.shiftSelectedLines(!1))return;const e=" ".repeat(this.config.tabSize||2);this.replaceSelectionWithText(e)}shiftSelectedLines(e){if(this.config.readOnly)return!1;const n=this.textModel.getText(),{startOffset:r,endOffset:i}=this.getActiveSelectionOffsets(n),o=Math.min(r,i),a=Math.max(r,i);if(!e&&!n.slice(o,a).includes(`
|
|
131
|
+
`),i=Math.max(0,Math.min(e.line,r.length-1)),o=Math.max(0,Math.min(e.column,((s=r[i])==null?void 0:s.length)||0));let a=0;for(let c=0;c<i;c++)a+=r[c].length+1;return a+o}getFoldPlaceholderSource(e){const n=e.getAttribute(this.foldPlaceholderAttr),r=this.getFoldPlaceholderSources();return n&&r.has(n)?r.get(n)||"":e.__lceFoldHiddenText||""}getFoldPlaceholderSources(){return this.contentElement.__lceFoldPlaceholderSources||new Map}getFoldPlaceholderBoundaryOffset(e,n,r){const i=this.getFoldPlaceholderSource(e).length,o=this.stripVirtualMarkers(e.textContent||"").length;if(i===0||o===0)return 0;const a=document.createRange();a.selectNodeContents(e);try{a.setEnd(n,r)}catch(c){return 0}return this.stripVirtualMarkers(a.toString()).length<=o/2?0:i}setFoldPlaceholderSources(e){this.contentElement.__lceFoldPlaceholderSources=e}}let Hie=0;const xo=class xo{constructor(e,n={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.undoStack=[],this.redoStack=[],this.suppressHistory=!1,this.highlightTimeout=null,this.expectingProgrammaticCursor=!1,this.lastKnownCursor={line:0,column:0},this.editorInstanceId=++Hie,this.decorationHighlightStyleId=`editora-decoration-style-${this.editorInstanceId}`,this.decorationHighlightLimit=1e3,this.decorationLayers=new Map,this.inlineDecorationHighlightNames=new Set,this.decorationRenderRaf=null,this.decorationMutationObserver=null,this.hasCustomDecorationHighlightSupport=!1,this.lastProgrammaticClipboardInsertAt=0,this.tabReleased=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...n},this.textModel=new AB(this.config.value),this.view=new Pie(e),this.view.setTabSize(this.config.tabSize||2),this.view.setLineWrapping(!!this.config.lineWrapping),this.view.setLineNumbersVisible(this.config.lineNumbers!==!1),this.hasCustomDecorationHighlightSupport=this.detectCustomHighlightSupport(),this.observeDecorationRelevantMutations(),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(r=>this.addExtension(r)),this.setTheme(this.config.theme),this.view.setReadOnly(this.config.readOnly||!1),this.renderTextWithHighlight(this.textModel.getText()),this.registerBuiltInCommands()}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}registerBuiltInCommands(){this.registerCommand("undo",()=>this.undo()),this.registerCommand("redo",()=>this.redo()),this.registerCommand("insertTab",()=>this.insertTab()),this.registerCommand("outdent",()=>{this.shiftSelectedLines(!0)}),this.registerCommand("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("beforeinput",n=>{if(this.suppressHistory||this.config.readOnly){this.pendingInputSnapshot=void 0;return}if(n.inputType==="insertFromPaste"||n.inputType==="insertFromPasteAsQuotation"||n.inputType==="insertFromDrop"){const r=n.dataTransfer,i=this.getPlainTextFromDataTransfer(r);if(i.length===0||(n.preventDefault(),this.pendingInputSnapshot=void 0,Date.now()-this.lastProgrammaticClipboardInsertAt<80))return;this.insertClipboardText(i);return}if(n.inputType==="insertParagraph"||n.inputType==="insertLineBreak"){n.preventDefault(),this.pendingInputSnapshot=void 0,this.insertNewLine();return}if(!n.isComposing){const r=xo.deletionUnit(n.inputType,"Backward");if(r){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteBackward(r);return}const i=xo.deletionUnit(n.inputType,"Forward");if(i){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteForward(i);return}}if(n.inputType==="deleteByCut"){n.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteSelection();return}if(n.inputType==="insertText"&&typeof n.data=="string"&&!n.isComposing){n.preventDefault(),this.pendingInputSnapshot=void 0,this.replaceSelectionWithText(n.data);return}this.pendingInputSnapshot=this.captureHistorySnapshot()}),e.addEventListener("paste",n=>{if(this.config.readOnly){n.preventDefault();return}if(Date.now()-this.lastProgrammaticClipboardInsertAt<80){n.preventDefault();return}const r=this.getPlainTextFromDataTransfer(n.clipboardData);r.length!==0&&(n.preventDefault(),this.insertClipboardText(r))}),e.addEventListener("input",()=>{var i;const n=this.view.getText(),r=this.textModel.getText();n!==r?(this.suppressHistory||this.pushUndoSnapshot((i=this.pendingInputSnapshot)!=null?i:this.captureHistorySnapshot(r)),this.pendingInputSnapshot=void 0,this.textModel.setText(n),this.view.syncTrailingNewlineMarkerForText(n),this.hasRenderedFoldPlaceholders()?this.clearPendingHighlightRender():(this.clearPendingHighlightRender(),this.highlightTimeout=setTimeout(()=>{const o=this.view.getText();o!==this.textModel.getText()&&this.textModel.setText(o),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300)),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:n,oldText:r}])):this.pendingInputSnapshot=void 0}),this.documentSelectionChangeHandler=()=>{var i,o,a;const n=this.syncSelectionCacheFromView();if(!n.isInEditor)return;const r=(i=n.cursor)!=null?i:this.lastKnownCursor;this.emit("cursor",{position:r,anchor:(a=(o=n.range)==null?void 0:o.start)!=null?a:r}),this.emit("selection",n.isCollapsed?void 0:n.range)},document.addEventListener("selectionchange",this.documentSelectionChangeHandler),e.addEventListener("blur",()=>{this.tabReleased=!1}),e.addEventListener("keydown",n=>{if(this.emit("keydown",n),n.key==="Tab"&&this.tabReleased&&!n.ctrlKey&&!n.metaKey&&!n.altKey){this.tabReleased=!1;return}n.key!=="Escape"&&n.key!=="Shift"&&n.key!=="Control"&&n.key!=="Alt"&&n.key!=="Meta"&&(this.tabReleased=!1);const r=Array.from(this.extensions.values()).reverse();for(const a of r)if(a.onKeyDown&&a.onKeyDown(n)===!1){n.preventDefault(),n.stopPropagation();return}if(n.key==="Escape"&&!n.defaultPrevented&&(this.tabReleased=!0),n.key==="Tab"&&!this.config.readOnly){n.shiftKey?this.shiftSelectedLines(!0):this.insertTab(),n.preventDefault(),n.stopPropagation();return}const i=n.altKey||n.ctrlKey||n.metaKey,o=n.isComposing||n.keyCode===229;if(n.key==="Backspace"&&!this.config.readOnly&&!i&&!o){this.deleteBackward(),n.preventDefault(),n.stopPropagation();return}if(n.key==="Delete"&&!this.config.readOnly&&!i&&!o){this.deleteForward(),n.preventDefault(),n.stopPropagation();return}if(n.key==="Enter"&&!this.config.readOnly){this.insertNewLine(),n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("mousedown",n=>{this.emit("mousedown",n);const r=Array.from(this.extensions.values()).reverse();for(const i of r)if(i.onMouseDown&&i.onMouseDown(n)===!1){n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("contextmenu",n=>{this.emit("contextmenu",n);const r=Array.from(this.extensions.values()).reverse();for(const i of r)if(i.onContextMenu&&i.onContextMenu(n)===!1){n.preventDefault(),n.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...n){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(...n))}getValue(){return this.textModel.getText()}setValue(e){const n=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:n}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){var r,i,o;const e=this.syncSelectionCacheFromView(),n=(r=e.cursor)!=null?r:this.lastKnownCursor;return{position:n,anchor:(o=(i=e.range)==null?void 0:i.start)!=null?o:n}}setCursor(e){const n=this.textModel.getText(),r=this.clampPositionToText(e,n),i=this.positionToOffsetInText(r,n);this.lastKnownCursor=r,this.lastKnownSelection=void 0,this.view.setSelectionOffsets(i),this.emit("cursor",this.getCursor())}getSelection(){const e=this.syncSelectionCacheFromView();if(!(!e.isInEditor||e.isCollapsed))return e.range}setSelection(e){const n=this.textModel.getText(),r=this.normalizeRange({start:this.clampPositionToText(e.start,n),end:this.clampPositionToText(e.end,n)}),i=this.positionToOffsetInText(r.start,n),o=this.positionToOffsetInText(r.end,n);this.lastKnownSelection=r,this.lastKnownCursor=r.end,this.view.setSelectionOffsets(i,o),this.emit("selection",r)}setTheme(e){this.currentTheme=e;const n={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(n);const r=this.extensions.get("syntax-highlighting");if(r&&typeof r.setTheme=="function")try{r.setTheme(e==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this),e.name==="syntax-highlighting"&&typeof e.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(e){const n=this.extensions.get(e);n&&n.destroy&&n.destroy(),this.extensions.delete(e)}executeCommand(e,...n){const r=this.commands.get(e);r?r(...n):console.warn(`Command '${e}' not found`)}registerCommand(e,n){this.commands.set(e,n)}setDecorations(e,n){const r=e.trim();if(!r)throw new Error("Decoration layer name must not be empty");if(!Array.isArray(n)||n.length===0){this.decorationLayers.delete(r),this.scheduleDecorationRender();return}this.decorationLayers.set(r,n.map(i=>this.cloneDecoration(i))),this.scheduleDecorationRender()}clearDecorations(e){typeof e=="string"?this.decorationLayers.delete(e.trim()):this.decorationLayers.clear(),this.scheduleDecorationRender()}getDecorations(e){if(typeof e=="string")return(this.decorationLayers.get(e.trim())||[]).map(r=>this.cloneDecoration(r));const n=[];for(const r of this.decorationLayers.values())n.push(...r.map(i=>this.cloneDecoration(i)));return n}search(e,n={}){var u;if(!e)return[];const r={query:e,caseSensitive:!1,wholeWord:!1,regex:!1,...n},i=[],o=this.textModel.getText(),{normalizedText:a,normalizedToRawOffsets:s}=this.buildSearchTextAndOffsetMap(o),c=r.caseSensitive?a:a.toLowerCase(),l=r.caseSensitive?e:e.toLowerCase();if(r.regex){let d;try{d=new RegExp(e,r.caseSensitive?"g":"gi")}catch(A){return[]}let f;for(;(f=d.exec(a))!==null;){const A=(u=f[0])!=null?u:"";if(A.length===0){d.lastIndex=f.index+1;continue}const h=f.index,p=f.index+A.length;r.wholeWord&&!this.isWholeWordBoundary(a,h,p)||this.pushSearchResultFromOffsets(i,h,p,a,s)}}else{let d=0,f=c.indexOf(l,d);for(;f!==-1;){const A=f+l.length;!r.wholeWord||this.isWholeWordBoundary(a,f,A)?(this.pushSearchResultFromOffsets(i,f,A,a,s),d=A):d=f+1,f=c.indexOf(l,d)}}return i}pushSearchResultFromOffsets(e,n,r,i,o){var u,d;const a=(u=o[n])!=null?u:n,s=(d=o[r])!=null?d:a,c=this.textModel.offsetToPosition(a),l=this.textModel.offsetToPosition(s);e.push({range:{start:c,end:l},match:i.substring(n,r)})}isWholeWordBoundary(e,n,r){const i=n>0?e[n-1]:"",o=r<e.length?e[r]:"";return!this.isWordChar(i)&&!this.isWordChar(o)}isWordChar(e){return/^[A-Za-z0-9_]$/.test(e)}buildSearchTextAndOffsetMap(e){const n=[],r=[0];let i=0;for(let o=0;o<e.length;o++){const a=e[o];a===""||a===xo.CURSOR_SENTINEL||(n.push(a),i+=1,r[i]=o+1)}return r[i]=e.length,{normalizedText:n.join(""),normalizedToRawOffsets:r}}replace(e,n){const r=this.getValue();this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(r));const i=this.textModel.replaceRange(e,n);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(e,n,r={}){const i=this.search(e,r);if(i.length===0)return 0;this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));const o=[];for(let a=i.length-1;a>=0;a--)o.push(this.textModel.replaceRange(i[a].range,n));return this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",o),i.length}fold(e){this.clearPendingHighlightRender();const n=this.normalizeRange(e);if(n.start.line===n.end.line&&n.start.column===n.end.column)return;const r=this.folds.findIndex(o=>this.isSameFoldRange(o,n)),i={start:n.start,end:n.end,collapsed:!0,level:0};r!==-1?this.folds[r]=i:(this.folds.push(i),this.folds.sort((o,a)=>this.comparePositions(o.start,a.start)))}unfold(e){this.clearPendingHighlightRender();const n=this.normalizeRange(e);this.folds=this.folds.filter(r=>!this.isSameFoldRange(r,n))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(e,n=!0){const r=this.extensions.get("syntax-highlighting");if(r&&typeof r.highlightHTML=="function")try{if(typeof this.view.setHighlightHTML=="function"){const p=this.view.getContentElement();(p.querySelector("[data-lce-fold-placeholder]")||p.textContent!==e)&&this.view.setText(e);const g=typeof r.highlight=="function"?r.highlight(e):r.highlightHTML(e);this.view.setHighlightHTML(g),this.view.syncTrailingNewlineMarkerForText(e),this.scheduleDecorationRender();return}const o=!n&&!this.expectingProgrammaticCursor;let a,s,c,l;const u=this.view.getSelectionState(),d=u.isInEditor&&!!u.cursor;(n||o)&&d&&(a=u.isCollapsed?void 0:u.range,s=this.textModel.positionToOffset(u.cursor),a&&(c=this.textModel.positionToOffset(a.start),l=this.textModel.positionToOffset(a.end)));const f=d&&(n||o)&&!a&&s!==void 0&&this.hasCollapsedSelectionInEditor(),A=f?this.insertSentinelAtOffset(e,s):e,h=typeof r.highlight=="function"?r.highlight(A):r.highlightHTML(A);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(h):this.view.setHTML(h),this.view.syncTrailingNewlineMarkerForText(e),(n||o)&&d&&requestAnimationFrame(()=>{try{if(f&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(a&&(c!==void 0||l!==void 0)){const p=c!==void 0?c:s,m=l!==void 0?l:s,g=Math.min(p,m),b=Math.max(p,m),y=this.textModel.offsetToPosition(g),w=this.textModel.offsetToPosition(b);this.view.setSelectionRange({start:y,end:w})}else if(s!==void 0){const p=this.textModel.offsetToPosition(s);this.view.setCursorPosition(p)}}catch(p){}}),this.scheduleDecorationRender();return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e),this.scheduleDecorationRender()}hasCollapsedSelectionInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return!1;const n=e.getRangeAt(0);return this.view.getContentElement().contains(n.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return;const n=e.getRangeAt(0),r=this.view.getContentElement();if(!r.contains(n.commonAncestorContainer))return;const i=n.cloneRange();return i.selectNodeContents(r),i.setEnd(n.endContainer,n.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(e){return e.replace(/\u200B/g,"").split(xo.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(e,n){const r=Math.max(0,Math.min(n,e.length));return e.slice(0,r)+xo.CURSOR_SENTINEL+e.slice(r)}restoreCursorFromSentinel(){var s;const e=this.view.getContentElement(),n=window.getSelection(),r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=r.nextNode(),o=null,a=0;for(;i;){const c=(s=i.textContent)!=null?s:"",l=c.indexOf(xo.CURSOR_SENTINEL);l!==-1&&(o||(o=i,a=l),i.textContent=c.split(xo.CURSOR_SENTINEL).join("")),i=r.nextNode()}if(!o||!n)return!1;try{const c=document.createRange();return c.setStart(o,a),c.collapse(!0),n.removeAllRanges(),n.addRange(c),!0}catch(c){return!1}}destroy(){var e;if(!this.isDestroyed){this.isDestroyed=!0,this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null),this.pendingInputSnapshot=void 0,this.documentSelectionChangeHandler&&(document.removeEventListener("selectionchange",this.documentSelectionChangeHandler),this.documentSelectionChangeHandler=void 0),this.decorationRenderRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.decorationRenderRaf),this.decorationRenderRaf=null),(e=this.decorationMutationObserver)==null||e.disconnect(),this.decorationMutationObserver=null,this.clearInlineDecorationHighlights(!0),this.decorationLayers.clear(),this.view.clearDecorations();for(const n of this.extensions.values())n.destroy&&n.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}undo(){if(this.undoStack.length===0)return;const e=this.undoStack.pop(),n=this.captureHistorySnapshot();this.pushSnapshot(this.redoStack,n);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop(),n=this.captureHistorySnapshot();this.pushSnapshot(this.undoStack,n);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly||this.shiftSelectedLines(!1))return;const e=" ".repeat(this.config.tabSize||2);this.replaceSelectionWithText(e)}shiftSelectedLines(e){if(this.config.readOnly)return!1;const n=this.textModel.getText(),{startOffset:r,endOffset:i}=this.getActiveSelectionOffsets(n),o=Math.min(r,i),a=Math.max(r,i);if(!e&&!n.slice(o,a).includes(`
|
|
131
132
|
`))return!1;const s=" ".repeat(this.config.tabSize||2),c=n.lastIndexOf(`
|
|
132
133
|
`,o-1)+1,l=a>o&&n[a-1]===`
|
|
133
134
|
`?a-1:a,u=n.indexOf(`
|
|
@@ -1542,7 +1543,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1542
1543
|
</button>
|
|
1543
1544
|
</div>
|
|
1544
1545
|
</form>
|
|
1545
|
-
`,n.appendChild(r),document.body.appendChild(n);const i=r.querySelector("#link-form"),o=r.querySelector("#link-text"),a=r.querySelector("#link-url"),s=r.querySelector("#link-title"),c=r.querySelector("#link-target"),l=r.querySelector(".link-dialog-close"),u=r.querySelector(".btn-cancel"),d=r.querySelector(".btn-remove"),f=r.querySelector("#link-url-error");o.value=t.text||"",a.value=t.url||"",s.value=t.title||"",a.addEventListener("input",()=>{f.hidden=!0,a.removeAttribute("aria-invalid")});const A=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),h())},h=()=>{document.removeEventListener("keydown",A,!0),n.remove()};l.addEventListener("click",h),u.addEventListener("click",h),d==null||d.addEventListener("click",()=>{if(jr){const p=Aw(jr),m=p?p.innerHTML:"",g=jr.parentNode;if(g){for(;jr.firstChild;)g.insertBefore(jr.firstChild,jr);g.removeChild(jr)}p&&(Ta(p,m),ty(p))}No=null,Ep="",Cp=!1,jr=null,h()}),n.addEventListener("click",p=>{p.target===n&&h()}),document.addEventListener("keydown",A,!0),i.addEventListener("submit",p=>{p.preventDefault();const m=SM(a.value);if("error"in m){f.textContent=m.error,f.hidden=!1,a.setAttribute("aria-invalid","true"),a.focus();return}const g=m.url;a.value=g,zce({text:o.value.trim()||g,url:g,target:c.checked?"_blank":"_self",title:s.value.trim()||void 0}),h()}),setTimeout(()=>o.focus(),100)},hS=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const e=t.getRangeAt(0).cloneRange();No=e;const n=Qce(e),r=t.toString()||"";Ep=r;const i=e.startContainer,o=i.nodeType===Node.TEXT_NODE?i.parentElement:i,a=o==null?void 0:o.closest("a");return a?(Cp=!0,jr=a,_M({text:a.textContent||"",url:a.getAttribute("href")||"",target:a.target||"_self",title:a.title||"",isEditing:!0},n)):(Cp=!1,jr=null,_M({text:r,url:"",target:"_self",isEditing:!1},n)),!0},pS=()=>{const t=window.getSelection(),e=t&&t.rangeCount>0?t.getRangeAt(0).startContainer:null,n=e&&e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=Aw(n),i=r?r.innerHTML:"";return document.execCommand("unlink",!1),r&&(Ta(r,i),ty(r)),!0},gS=(t,e)=>{var n;typeof window!="undefined"&&((n=window.registerEditorCommand)==null||n.call(window,t,e))},DM=()=>{gS("openLinkDialog",hS),gS("removeLink",pS),gS("createLink",t=>{if(!t)return;const e=SM(t);if("error"in e)return;const n=window.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0).startContainer:null,i=r&&r.nodeType===Node.TEXT_NODE?r.parentElement:r,o=Aw(i),a=o?o.innerHTML:"";document.execCommand("createLink",!1,e.url),o&&(Ta(o,a),ty(o))})};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",DM):DM());const jce=Object.freeze(Object.defineProperty({__proto__:null,LinkPlugin:()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")})}],toDOM:t=>["a",{href:t.attrs.href,title:t.attrs.title,target:t.attrs.target,rel:t.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:hS,removeLink:pS},keymap:{"Mod-k":"openLinkDialog"}}),openLinkDialog:hS,removeLink:pS},Symbol.toStringTag,{value:"Module"}));function mS(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const n=t.getRangeAt(0).startContainer,r=n.nodeType===Node.TEXT_NODE?n.parentElement:n;return qce(r)}function qce(t){if(!t)return null;if(t.hasAttribute("data-editora-editor"))return t;let e=t.parentElement;for(;e;){if(e.hasAttribute("data-editora-editor"))return e;e=e.parentElement}return null}function bS(t){return t?t.querySelector(".rte-content"):(console.warn("[Editora] Editor container not found"),null)}let Br=null,Ur=null,LM=null,FM=null,IM=null,UM=null,NM=null;const yS='[data-theme="dark"], .dark, .editora-theme-dark';let ny=!1,ry=null,RM=0,OM=0,vS=!1,MM=0,PM=0,HM=0,QM=0;const Wce=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function $M(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&Wce.has(n.tagName))return n;n=n.parentNode}return null}function zM(t){const e=t.parentElement;if(e&&e.classList.contains("rte-table-wrapper"))return e;const n=document.createElement("div");return n.className="rte-table-wrapper",e==null||e.insertBefore(n,t),n.appendChild(t),n}const jM=()=>{const t=mS(),e=bS(t);if(!e)return alert("Please place your cursor in the editor before inserting a table"),!1;const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0),i=document.createElement("table");i.className="rte-table";const o=document.createElement("thead"),a=document.createElement("tr");for(let h=0;h<3;h++){const p=document.createElement("th"),m=document.createElement("p");m.appendChild(document.createElement("br")),p.appendChild(m),a.appendChild(p)}o.appendChild(a);const s=document.createElement("tbody");for(let h=0;h<2;h++){const p=document.createElement("tr");for(let m=0;m<3;m++){const g=document.createElement("td"),b=document.createElement("p");b.appendChild(document.createElement("br")),g.appendChild(b),p.appendChild(g)}s.appendChild(p)}i.appendChild(o),i.appendChild(s);const c=zM(i),l=(h,p,m)=>{if(h!==e)return h;const g=m?p-1:p;return e.childNodes[Math.min(Math.max(g,0),e.childNodes.length-1)]||null},u=l(r.endContainer,r.endOffset,!0),d=l(r.startContainer,r.startOffset,!1),f=u&&$M(u,e)||d&&$M(d,e);f&&f.parentNode?f.parentNode.insertBefore(c,f.nextSibling):(r.collapse(!1),r.insertNode(c));const A=i.querySelector("th p");if(A){const h=document.createRange();h.setStart(A,0),h.collapse(!0),n.removeAllRanges(),n.addRange(h)}e.focus()},qM=()=>{var a;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=document.createElement("tr"),i=((a=e.rows[0])==null?void 0:a.cells.length)||0;for(let s=0;s<i;s++){const c=document.createElement("td"),l=document.createElement("p");l.innerHTML="<br>",c.appendChild(l),r.appendChild(c)}const o=e.rows[n];o&&o.parentElement?o.parentElement.insertBefore(r,o):e.appendChild(r),vu()},WM=()=>{var o,a;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=document.createElement("tr"),i=((o=e.rows[0])==null?void 0:o.cells.length)||0;for(let s=0;s<i;s++){const c=document.createElement("td"),l=document.createElement("p");l.innerHTML="<br>",c.appendChild(l),r.appendChild(c)}if(n>=e.rows.length-1){const s=e.rows[e.rows.length-1];s&&s.parentElement?s.parentElement.appendChild(r):e.appendChild(r)}else{const s=e.rows[n+1];(a=s.parentElement)==null||a.insertBefore(r,s)}vu()},KM=()=>{const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let r=0;r<e.rows.length;r++){const i=e.rows[r],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n===0?i.insertBefore(o,i.cells[0]):i.insertBefore(o,i.cells[n])}vu()},VM=()=>{const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let r=0;r<e.rows.length;r++){const i=e.rows[r],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n>=i.cells.length-1?i.appendChild(o):i.insertBefore(o,i.cells[n+1])}vu()},GM=()=>{const t=Ss();if(!t||t.rowCount<=1)return;const{table:e,rowIndex:n,colIndex:r}=t;e.deleteRow(n),r7(e,n,r),vu()},XM=()=>{const t=Ss();if(!t||t.cellCount<=1)return;const{table:e,rowIndex:n,colIndex:r}=t;for(let i=0;i<e.rows.length;i++){const o=e.rows[i];o.cells[r]&&o.deleteCell(r)}r7(e,n,r),vu()},YM=()=>{var a,s;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=e.rows[n];if(!r)return;const i=((a=r.parentElement)==null?void 0:a.tagName.toLowerCase())==="thead",o=e.querySelector("thead");if(i){const c=r.parentElement;if(r===c.rows[c.rows.length-1]){const l=e.querySelector("tbody")||e.appendChild(document.createElement("tbody"));l.insertBefore(r,l.firstChild),c.rows.length===0&&c.remove()}else ZM(r,"td")}else if(!o||r===((s=e.tBodies[0])==null?void 0:s.rows[0])){let c=o;c||(c=document.createElement("thead"),e.insertBefore(c,e.firstChild)),c.appendChild(r)}else ZM(r,"th");vu()};function ZM(t,e){Array.from(t.cells).forEach(n=>{var i;if(n.tagName.toLowerCase()===e)return;const r=document.createElement(e);r.innerHTML=n.innerHTML;for(let o=0;o<n.attributes.length;o++){const a=n.attributes[o];r.setAttribute(a.name,a.value)}(i=n.parentNode)==null||i.replaceChild(r,n)})}const JM=()=>{var r;const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let i=0;i<e.rows.length;i++){const o=e.rows[i].cells[n];if(o){const a=o.tagName.toLowerCase()==="th"?"td":"th",s=document.createElement(a);s.innerHTML=o.innerHTML;for(let c=0;c<o.attributes.length;c++){const l=o.attributes[c];s.setAttribute(l.name,l.value)}(r=o.parentNode)==null||r.replaceChild(s,o)}}vu()},e7=()=>{const t=Ss();if(!t)return;const e=t.table,n=e.parentElement;n&&n.classList.contains("rte-table-wrapper")?n.remove():e.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))};function yA(t,e){if(!t||!(t instanceof Node))return null;const n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return n?n.closest(e):null}function t7(t){if(!t)return!1;const e=t.closest("[contenteditable]");return!e||e.getAttribute("contenteditable")==="false"?!1:!e.closest('[data-readonly="true"]')}function Kce(){const t=window.getSelection(),e=t&&t.rangeCount>0?t.getRangeAt(0).startContainer:null;return yA(e,".rte-content")||(Ur?Ur.closest(".rte-content"):null)}function Vce(t,e,n){const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,n)}catch(i){}}function n7(t){const e=Kce();if(e&&!t7(e))return;const n=e?e.innerHTML:"";if(t(),!e)return;const r=e.innerHTML;r!==n&&(Vce(e,n,r),e.dispatchEvent(new Event("input",{bubbles:!0})))}function r7(t,e,n){if(!t.isConnected||t.rows.length===0)return;const r=t.rows[Math.min(e,t.rows.length-1)],i=r.cells[Math.min(n,r.cells.length-1)];if(!i)return;const o=document.createRange(),a=i.querySelector("p, div, li")||i;o.selectNodeContents(a),o.collapse(!0);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}const i7=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).startContainer;if(!yA(n,"table"))return;const r=yA(n,"td, th");if(!r)return;const i=r.parentElement;if(!i)return;let o=-1;for(let l=0;l<i.cells.length;l++)if(i.cells[l]===r){o=l;break}if(o===-1||o===i.cells.length-1)return;const a=i.cells[o+1];if(!a)return;const s=(l,u)=>{const d=parseInt(l.getAttribute(u)||"1",10);return Number.isFinite(d)&&d>0?d:1};if(s(r,"rowspan")!==s(a,"rowspan"))return;r.setAttribute("colspan",String(s(r,"colspan")+s(a,"colspan"))),Array.from(a.childNodes).forEach(l=>{r.appendChild(l)}),a.remove(),vu()};function Ss(){var s;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0).startContainer,r=yA(n,"table");if(!r)return null;let i=0,o=0;const a=yA(n,"td, th");if(a){const c=a.parentElement;for(;c&&c!==r.rows[i]&&(i++,!(i>=r.rows.length)););const l=c;if(l){for(let u=0;u<l.cells.length;u++)if(l.cells[u]===a){o=u;break}}}return{table:r,rowIndex:i,colIndex:o,rowCount:r.rows.length,cellCount:((s=r.rows[0])==null?void 0:s.cells.length)||0}}function vu(){if(!Br||!Ur)return;const t=Ss();if(!t)return;const e=t.rowCount>1,n=t.cellCount>1;a7(e,n)}function Gce(){LM=()=>{const t=Ss();t&&t7(t.table)?Xce(t.table):ES()},FM=t=>{const e=yA(t.target,"table"),n=yA(t.target,".table-toolbar");!e&&!n&&ES()},IM=()=>{ES()},UM=()=>{Ur&&Br&&Br.style.display!=="none"&&wS(Ur)},NM=()=>{Ur&&Br&&Br.style.display!=="none"&&wS(Ur)},document.addEventListener("selectionchange",LM),document.addEventListener("mousedown",FM),document.addEventListener("tableDeleted",IM),window.addEventListener("scroll",UM,!0),window.addEventListener("resize",NM)}function wS(t){if(!Br)return;const e=t.getBoundingClientRect(),n=Br.getBoundingClientRect(),r=n.height||40,i=n.width||280,o=10;let a=e.top-r-o,s=e.left+e.width/2-i/2;a<o&&(a=e.bottom+o),s<o&&(s=o);const c=window.innerWidth;s+i>c-o&&(s=c-i-o);const l=window.innerHeight;a+r>l-o&&(a=l-r-o),Br.style.top=a+"px",Br.style.left=s+"px"}function Xce(t){Ur=t,Br||(Br=Zce(),document.body.appendChild(Br));const e=!!t.closest(yS)||document.body.matches(yS)||document.documentElement.matches(yS);Br.classList.toggle("rte-theme-dark",e),Br.style.display="flex",Br.style.visibility="hidden",requestAnimationFrame(()=>{wS(t),Br&&(Br.style.visibility="visible")});const n=Ss();n&&a7(n.rowCount>1,n.cellCount>1),Jce(t)}const xS=new Set;function o7(){xS.forEach(t=>{var e;t.style.position==="relative"&&(t.style.removeProperty("position"),(e=t.getAttribute("style"))!=null&&e.trim()||t.removeAttribute("style"))}),xS.clear()}function ES(){if(Br&&(Br.style.display="none"),Ur){Ur.querySelectorAll(".resize-handle").forEach(r=>r.remove());const e=Ur.parentElement,n=e!=null&&e.classList.contains("rte-table-wrapper")?e.querySelector(".table-resize-handle"):Ur.querySelector(".table-resize-handle");n&&n.remove()}o7(),Ur=null}function a7(t,e){if(!Br)return;const n=Br.querySelector('[data-action="deleteRow"]'),r=Br.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!t),r&&(r.disabled=!e)}let CS=!1;function Yce(){if(CS||typeof document=="undefined")return;if(document.getElementById("rte-table-toolbar-styles")){CS=!0;return}CS=!0;const t=document.createElement("style");t.id="rte-table-toolbar-styles",t.textContent=`
|
|
1546
|
+
`,n.appendChild(r),document.body.appendChild(n);const i=r.querySelector("#link-form"),o=r.querySelector("#link-text"),a=r.querySelector("#link-url"),s=r.querySelector("#link-title"),c=r.querySelector("#link-target"),l=r.querySelector(".link-dialog-close"),u=r.querySelector(".btn-cancel"),d=r.querySelector(".btn-remove"),f=r.querySelector("#link-url-error");o.value=t.text||"",a.value=t.url||"",s.value=t.title||"",a.addEventListener("input",()=>{f.hidden=!0,a.removeAttribute("aria-invalid")});const A=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),h())},h=()=>{document.removeEventListener("keydown",A,!0),n.remove()};l.addEventListener("click",h),u.addEventListener("click",h),d==null||d.addEventListener("click",()=>{if(jr){const p=Aw(jr),m=p?p.innerHTML:"",g=jr.parentNode;if(g){for(;jr.firstChild;)g.insertBefore(jr.firstChild,jr);g.removeChild(jr)}p&&(Ta(p,m),ty(p))}No=null,Ep="",Cp=!1,jr=null,h()}),n.addEventListener("click",p=>{p.target===n&&h()}),document.addEventListener("keydown",A,!0),i.addEventListener("submit",p=>{p.preventDefault();const m=SM(a.value);if("error"in m){f.textContent=m.error,f.hidden=!1,a.setAttribute("aria-invalid","true"),a.focus();return}const g=m.url;a.value=g,zce({text:o.value.trim()||g,url:g,target:c.checked?"_blank":"_self",title:s.value.trim()||void 0}),h()}),setTimeout(()=>o.focus(),100)},hS=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const e=t.getRangeAt(0).cloneRange();No=e;const n=Qce(e),r=t.toString()||"";Ep=r;const i=e.startContainer,o=i.nodeType===Node.TEXT_NODE?i.parentElement:i,a=o==null?void 0:o.closest("a");return a?(Cp=!0,jr=a,_M({text:a.textContent||"",url:a.getAttribute("href")||"",target:a.target||"_self",title:a.title||"",isEditing:!0},n)):(Cp=!1,jr=null,_M({text:r,url:"",target:"_self",isEditing:!1},n)),!0},pS=()=>{const t=window.getSelection(),e=t&&t.rangeCount>0?t.getRangeAt(0).startContainer:null,n=e&&e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=Aw(n),i=r?r.innerHTML:"";return document.execCommand("unlink",!1),r&&(Ta(r,i),ty(r)),!0},gS=(t,e)=>{var n;typeof window!="undefined"&&((n=window.registerEditorCommand)==null||n.call(window,t,e))},DM=()=>{gS("openLinkDialog",hS),gS("removeLink",pS),gS("createLink",t=>{if(!t)return;const e=SM(t);if("error"in e)return;const n=window.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0).startContainer:null,i=r&&r.nodeType===Node.TEXT_NODE?r.parentElement:r,o=Aw(i),a=o?o.innerHTML:"";document.execCommand("createLink",!1,e.url),o&&(Ta(o,a),ty(o))})};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",DM):DM());const jce=Object.freeze(Object.defineProperty({__proto__:null,LinkPlugin:()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")})}],toDOM:t=>["a",{href:t.attrs.href,title:t.attrs.title,target:t.attrs.target,rel:t.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:hS,removeLink:pS},keymap:{"Mod-k":"openLinkDialog"}}),openLinkDialog:hS,removeLink:pS},Symbol.toStringTag,{value:"Module"}));function mS(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const n=t.getRangeAt(0).startContainer,r=n.nodeType===Node.TEXT_NODE?n.parentElement:n;return qce(r)}function qce(t){if(!t)return null;if(t.hasAttribute("data-editora-editor"))return t;let e=t.parentElement;for(;e;){if(e.hasAttribute("data-editora-editor"))return e;e=e.parentElement}return null}function bS(t){return t?t.querySelector(".rte-content"):(console.warn("[Editora] Editor container not found"),null)}let Br=null,Ur=null,LM=null,FM=null,IM=null,UM=null,NM=null;const yS='[data-theme="dark"], .dark, .editora-theme-dark';let ny=!1,ry=null,RM=0,OM=0,vS=!1,MM=0,PM=0,HM=0,QM=0;const Wce=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function $M(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&Wce.has(n.tagName))return n;n=n.parentNode}return null}function zM(t){const e=t.parentElement;if(e&&e.classList.contains("rte-table-wrapper"))return e;const n=document.createElement("div");return n.className="rte-table-wrapper",e==null||e.insertBefore(n,t),n.appendChild(t),n}const jM=()=>{const t=mS(),e=bS(t);if(!e)return alert("Please place your cursor in the editor before inserting a table"),!1;const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0),i=document.createElement("table");i.className="rte-table";const o=document.createElement("thead"),a=document.createElement("tr");for(let h=0;h<3;h++){const p=document.createElement("th"),m=document.createElement("p");m.appendChild(document.createElement("br")),p.appendChild(m),a.appendChild(p)}o.appendChild(a);const s=document.createElement("tbody");for(let h=0;h<2;h++){const p=document.createElement("tr");for(let m=0;m<3;m++){const g=document.createElement("td"),b=document.createElement("p");b.appendChild(document.createElement("br")),g.appendChild(b),p.appendChild(g)}s.appendChild(p)}i.appendChild(o),i.appendChild(s);const c=zM(i),l=(h,p,m)=>{if(h!==e)return h;const g=m?p-1:p;return e.childNodes[Math.min(Math.max(g,0),e.childNodes.length-1)]||null},u=l(r.endContainer,r.endOffset,!0),d=l(r.startContainer,r.startOffset,!1),f=u&&$M(u,e)||d&&$M(d,e);f&&f.parentNode?f.parentNode.insertBefore(c,f.nextSibling):(r.collapse(!1),r.insertNode(c));const A=i.querySelector("th p");if(A){const h=document.createRange();h.setStart(A,0),h.collapse(!0),n.removeAllRanges(),n.addRange(h)}e.focus()},qM=()=>{var a;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=document.createElement("tr"),i=((a=e.rows[0])==null?void 0:a.cells.length)||0;for(let s=0;s<i;s++){const c=document.createElement("td"),l=document.createElement("p");l.innerHTML="<br>",c.appendChild(l),r.appendChild(c)}const o=e.rows[n];o&&o.parentElement?o.parentElement.insertBefore(r,o):e.appendChild(r),vu()},WM=()=>{var o,a;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=document.createElement("tr"),i=((o=e.rows[0])==null?void 0:o.cells.length)||0;for(let s=0;s<i;s++){const c=document.createElement("td"),l=document.createElement("p");l.innerHTML="<br>",c.appendChild(l),r.appendChild(c)}if(n>=e.rows.length-1){const s=e.rows[e.rows.length-1];s&&s.parentElement?s.parentElement.appendChild(r):e.appendChild(r)}else{const s=e.rows[n+1];(a=s.parentElement)==null||a.insertBefore(r,s)}vu()},KM=()=>{const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let r=0;r<e.rows.length;r++){const i=e.rows[r],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n===0?i.insertBefore(o,i.cells[0]):i.insertBefore(o,i.cells[n])}vu()},VM=()=>{const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let r=0;r<e.rows.length;r++){const i=e.rows[r],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n>=i.cells.length-1?i.appendChild(o):i.insertBefore(o,i.cells[n+1])}vu()},GM=()=>{const t=Ss();if(!t||t.rowCount<=1)return;const{table:e,rowIndex:n,colIndex:r}=t;e.deleteRow(n),rP(e,n,r),vu()},XM=()=>{const t=Ss();if(!t||t.cellCount<=1)return;const{table:e,rowIndex:n,colIndex:r}=t;for(let i=0;i<e.rows.length;i++){const o=e.rows[i];o.cells[r]&&o.deleteCell(r)}rP(e,n,r),vu()},YM=()=>{var a,s;const t=Ss();if(!t)return;const{table:e,rowIndex:n}=t,r=e.rows[n];if(!r)return;const i=((a=r.parentElement)==null?void 0:a.tagName.toLowerCase())==="thead",o=e.querySelector("thead");if(i){const c=r.parentElement;if(r===c.rows[c.rows.length-1]){const l=e.querySelector("tbody")||e.appendChild(document.createElement("tbody"));l.insertBefore(r,l.firstChild),c.rows.length===0&&c.remove()}else ZM(r,"td")}else if(!o||r===((s=e.tBodies[0])==null?void 0:s.rows[0])){let c=o;c||(c=document.createElement("thead"),e.insertBefore(c,e.firstChild)),c.appendChild(r)}else ZM(r,"th");vu()};function ZM(t,e){Array.from(t.cells).forEach(n=>{var i;if(n.tagName.toLowerCase()===e)return;const r=document.createElement(e);r.innerHTML=n.innerHTML;for(let o=0;o<n.attributes.length;o++){const a=n.attributes[o];r.setAttribute(a.name,a.value)}(i=n.parentNode)==null||i.replaceChild(r,n)})}const JM=()=>{var r;const t=Ss();if(!t)return;const{table:e,colIndex:n}=t;for(let i=0;i<e.rows.length;i++){const o=e.rows[i].cells[n];if(o){const a=o.tagName.toLowerCase()==="th"?"td":"th",s=document.createElement(a);s.innerHTML=o.innerHTML;for(let c=0;c<o.attributes.length;c++){const l=o.attributes[c];s.setAttribute(l.name,l.value)}(r=o.parentNode)==null||r.replaceChild(s,o)}}vu()},eP=()=>{const t=Ss();if(!t)return;const e=t.table,n=e.parentElement;n&&n.classList.contains("rte-table-wrapper")?n.remove():e.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))};function yA(t,e){if(!t||!(t instanceof Node))return null;const n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return n?n.closest(e):null}function tP(t){if(!t)return!1;const e=t.closest("[contenteditable]");return!e||e.getAttribute("contenteditable")==="false"?!1:!e.closest('[data-readonly="true"]')}function Kce(){const t=window.getSelection(),e=t&&t.rangeCount>0?t.getRangeAt(0).startContainer:null;return yA(e,".rte-content")||(Ur?Ur.closest(".rte-content"):null)}function Vce(t,e,n){const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,n)}catch(i){}}function nP(t){const e=Kce();if(e&&!tP(e))return;const n=e?e.innerHTML:"";if(t(),!e)return;const r=e.innerHTML;r!==n&&(Vce(e,n,r),e.dispatchEvent(new Event("input",{bubbles:!0})))}function rP(t,e,n){if(!t.isConnected||t.rows.length===0)return;const r=t.rows[Math.min(e,t.rows.length-1)],i=r.cells[Math.min(n,r.cells.length-1)];if(!i)return;const o=document.createRange(),a=i.querySelector("p, div, li")||i;o.selectNodeContents(a),o.collapse(!0);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}const iP=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).startContainer;if(!yA(n,"table"))return;const r=yA(n,"td, th");if(!r)return;const i=r.parentElement;if(!i)return;let o=-1;for(let l=0;l<i.cells.length;l++)if(i.cells[l]===r){o=l;break}if(o===-1||o===i.cells.length-1)return;const a=i.cells[o+1];if(!a)return;const s=(l,u)=>{const d=parseInt(l.getAttribute(u)||"1",10);return Number.isFinite(d)&&d>0?d:1};if(s(r,"rowspan")!==s(a,"rowspan"))return;r.setAttribute("colspan",String(s(r,"colspan")+s(a,"colspan"))),Array.from(a.childNodes).forEach(l=>{r.appendChild(l)}),a.remove(),vu()};function Ss(){var s;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0).startContainer,r=yA(n,"table");if(!r)return null;let i=0,o=0;const a=yA(n,"td, th");if(a){const c=a.parentElement;for(;c&&c!==r.rows[i]&&(i++,!(i>=r.rows.length)););const l=c;if(l){for(let u=0;u<l.cells.length;u++)if(l.cells[u]===a){o=u;break}}}return{table:r,rowIndex:i,colIndex:o,rowCount:r.rows.length,cellCount:((s=r.rows[0])==null?void 0:s.cells.length)||0}}function vu(){if(!Br||!Ur)return;const t=Ss();if(!t)return;const e=t.rowCount>1,n=t.cellCount>1;aP(e,n)}function Gce(){LM=()=>{const t=Ss();t&&tP(t.table)?Xce(t.table):ES()},FM=t=>{const e=yA(t.target,"table"),n=yA(t.target,".table-toolbar");!e&&!n&&ES()},IM=()=>{ES()},UM=()=>{Ur&&Br&&Br.style.display!=="none"&&wS(Ur)},NM=()=>{Ur&&Br&&Br.style.display!=="none"&&wS(Ur)},document.addEventListener("selectionchange",LM),document.addEventListener("mousedown",FM),document.addEventListener("tableDeleted",IM),window.addEventListener("scroll",UM,!0),window.addEventListener("resize",NM)}function wS(t){if(!Br)return;const e=t.getBoundingClientRect(),n=Br.getBoundingClientRect(),r=n.height||40,i=n.width||280,o=10;let a=e.top-r-o,s=e.left+e.width/2-i/2;a<o&&(a=e.bottom+o),s<o&&(s=o);const c=window.innerWidth;s+i>c-o&&(s=c-i-o);const l=window.innerHeight;a+r>l-o&&(a=l-r-o),Br.style.top=a+"px",Br.style.left=s+"px"}function Xce(t){Ur=t,Br||(Br=Zce(),document.body.appendChild(Br));const e=!!t.closest(yS)||document.body.matches(yS)||document.documentElement.matches(yS);Br.classList.toggle("rte-theme-dark",e),Br.style.display="flex",Br.style.visibility="hidden",requestAnimationFrame(()=>{wS(t),Br&&(Br.style.visibility="visible")});const n=Ss();n&&aP(n.rowCount>1,n.cellCount>1),Jce(t)}const xS=new Set;function oP(){xS.forEach(t=>{var e;t.style.position==="relative"&&(t.style.removeProperty("position"),(e=t.getAttribute("style"))!=null&&e.trim()||t.removeAttribute("style"))}),xS.clear()}function ES(){if(Br&&(Br.style.display="none"),Ur){Ur.querySelectorAll(".resize-handle").forEach(r=>r.remove());const e=Ur.parentElement,n=e!=null&&e.classList.contains("rte-table-wrapper")?e.querySelector(".table-resize-handle"):Ur.querySelector(".table-resize-handle");n&&n.remove()}oP(),Ur=null}function aP(t,e){if(!Br)return;const n=Br.querySelector('[data-action="deleteRow"]'),r=Br.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!t),r&&(r.disabled=!e)}let CS=!1;function Yce(){if(CS||typeof document=="undefined")return;if(document.getElementById("rte-table-toolbar-styles")){CS=!0;return}CS=!0;const t=document.createElement("style");t.id="rte-table-toolbar-styles",t.textContent=`
|
|
1546
1547
|
.table-toolbar {
|
|
1547
1548
|
background: white;
|
|
1548
1549
|
border: 1px solid #d0d0d0;
|
|
@@ -1699,7 +1700,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1699
1700
|
position: fixed;
|
|
1700
1701
|
z-index: 1000;
|
|
1701
1702
|
display: none;
|
|
1702
|
-
`,t.setAttribute("role","toolbar"),t.setAttribute("aria-label","Table editing toolbar");const e=u=>{const d=document.createElement("button");return d.className="toolbar-icon-btn",u.danger&&d.classList.add("toolbar-icon-btn-danger"),u.delete&&d.classList.add("toolbar-icon-btn-delete"),d.innerHTML=u.icon,d.title=u.title,d.setAttribute("aria-label",u.title),d.setAttribute("type","button"),d.setAttribute("data-action",u.action),d.onclick=()=>iy(u.action),d},n=()=>{const u=document.createElement("div");return u.className="toolbar-divider",u},r=(...u)=>{const d=document.createElement("div");return d.className="toolbar-section",u.forEach(f=>d.appendChild(f)),d},i=r(e({icon:nle(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),e({icon:rle(),title:"Add row below",action:"addRowBelow"}),e({icon:ile(),title:"Delete row",action:"deleteRow",danger:!0})),o=r(e({icon:ole(),title:"Add column left",action:"addColumnLeft"}),e({icon:ale(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),e({icon:sle(),title:"Delete column",action:"deleteColumn",danger:!0})),a=r(e({icon:cle(),title:"Toggle header row",action:"toggleHeaderRow"}),e({icon:lle(),title:"Toggle header column",action:"toggleHeaderColumn"})),s=r(e({icon:dle(),title:"Merge cells (horizontally)",action:"mergeCells"})),c=r(e({icon:ule(),title:"Delete table",action:"deleteTable",delete:!0}));t.appendChild(i),t.appendChild(n()),t.appendChild(o),t.appendChild(n()),t.appendChild(a),t.appendChild(n()),t.appendChild(s),t.appendChild(n()),t.appendChild(c);const l=u=>{!Br||Br.style.display==="none"||(u.ctrlKey||u.metaKey)&&u.shiftKey&&(u.key==="r"||u.key==="R"?(u.preventDefault(),iy("addRowBelow")):(u.key==="c"||u.key==="C")&&(u.preventDefault(),iy("addColumnRight")))};return window.addEventListener("keydown",l),t}function iy(t){
|
|
1703
|
+
`,t.setAttribute("role","toolbar"),t.setAttribute("aria-label","Table editing toolbar");const e=u=>{const d=document.createElement("button");return d.className="toolbar-icon-btn",u.danger&&d.classList.add("toolbar-icon-btn-danger"),u.delete&&d.classList.add("toolbar-icon-btn-delete"),d.innerHTML=u.icon,d.title=u.title,d.setAttribute("aria-label",u.title),d.setAttribute("type","button"),d.setAttribute("data-action",u.action),d.onclick=()=>iy(u.action),d},n=()=>{const u=document.createElement("div");return u.className="toolbar-divider",u},r=(...u)=>{const d=document.createElement("div");return d.className="toolbar-section",u.forEach(f=>d.appendChild(f)),d},i=r(e({icon:nle(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),e({icon:rle(),title:"Add row below",action:"addRowBelow"}),e({icon:ile(),title:"Delete row",action:"deleteRow",danger:!0})),o=r(e({icon:ole(),title:"Add column left",action:"addColumnLeft"}),e({icon:ale(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),e({icon:sle(),title:"Delete column",action:"deleteColumn",danger:!0})),a=r(e({icon:cle(),title:"Toggle header row",action:"toggleHeaderRow"}),e({icon:lle(),title:"Toggle header column",action:"toggleHeaderColumn"})),s=r(e({icon:dle(),title:"Merge cells (horizontally)",action:"mergeCells"})),c=r(e({icon:ule(),title:"Delete table",action:"deleteTable",delete:!0}));t.appendChild(i),t.appendChild(n()),t.appendChild(o),t.appendChild(n()),t.appendChild(a),t.appendChild(n()),t.appendChild(s),t.appendChild(n()),t.appendChild(c);const l=u=>{!Br||Br.style.display==="none"||(u.ctrlKey||u.metaKey)&&u.shiftKey&&(u.key==="r"||u.key==="R"?(u.preventDefault(),iy("addRowBelow")):(u.key==="c"||u.key==="C")&&(u.preventDefault(),iy("addColumnRight")))};return window.addEventListener("keydown",l),t}function iy(t){nP(()=>{switch(t){case"addRowAbove":qM();break;case"addRowBelow":WM();break;case"addColumnLeft":KM();break;case"addColumnRight":VM();break;case"deleteRow":GM();break;case"deleteColumn":XM();break;case"toggleHeaderRow":YM();break;case"toggleHeaderColumn":JM();break;case"deleteTable":eP();break;case"mergeCells":iP();break}})}function Jce(t){const e=zM(t);t.querySelectorAll(".resize-handle").forEach(s=>s.remove());const r=e.querySelector(".table-resize-handle");r&&r.remove(),oP();const i=t.querySelector("thead tr, tbody tr:first-child");if(!i)return;const o=i.querySelectorAll("td, th");o.forEach((s,c)=>{if(c===o.length-1)return;const l=document.createElement("div");l.className="resize-handle",l.style.cssText=`
|
|
1703
1704
|
position: absolute;
|
|
1704
1705
|
right: -4px;
|
|
1705
1706
|
top: 0;
|
|
@@ -1729,7 +1730,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1729
1730
|
<path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
|
|
1730
1731
|
</svg>`}function dle(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1731
1732
|
<path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
|
|
1732
|
-
</svg>`}if(typeof window!="undefined"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const t=()=>{Gce()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t,100)}const fle=Object.freeze(Object.defineProperty({__proto__:null,TablePlugin:()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(n7(()=>{jM()}),!0)},keymap:{"Mod-Shift-r":()=>(iy("addRowBelow"),!0),"Mod-Shift-c":()=>(iy("addColumnRight"),!0)}}),addColumnLeftCommand:KM,addColumnRightCommand:VM,addRowAboveCommand:qM,addRowBelowCommand:WM,deleteColumnCommand:XM,deleteRowCommand:GM,deleteTableCommand:e7,insertTableCommand:jM,mergeCellsCommand:i7,toggleHeaderColumnCommand:JM,toggleHeaderRowCommand:YM},Symbol.toStringTag,{value:"Module"})),vA=".rte-content, .editora-content",_s='.rte-track-insert[data-track-change="insert"]',rs='.rte-track-delete[data-track-change="delete"]',TS=`${_s}, ${rs}`,s7="__editoraCommandEditorRoot",c7=new WeakMap,hw=new WeakMap,kS=new WeakMap,BS=new Set;let l7=!1,fc=null,u7=!1,Tp={},d7=!1;const Ale=typeof InputEvent!="undefined"&&typeof InputEvent.prototype=="object"&&"inputType"in InputEvent.prototype,hle=new Set(["IMG","TABLE","VIDEO","AUDIO","SVG","MATH","HR","IFRAME","INPUT","TEXTAREA","SELECT","BUTTON","CANVAS"]);function ple(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function gle(){if(typeof window=="undefined")return null;const t=window[s7];if(!(t instanceof HTMLElement))return null;window[s7]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const r=ple(e);if(r)return r;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function mle(t){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.getAttribute("contenteditable")==="true")return i;const o=i.querySelector('[contenteditable="true"]');if(o instanceof HTMLElement)return o}const e=gle();if(e&&document.contains(e))return e;const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(vA);if(a)return a}const r=document.activeElement;if(r){if(r.matches(vA))return r;const i=r.closest(vA);if(i)return i}return fc!=null&&fc.isConnected?fc:document.querySelector(vA)}function SS(t,e){var r;wA(t),IS(t);let n=c7.get(t);return n||(n={enabled:!!e.enabledByDefault,author:((r=e.author)==null?void 0:r.trim())||"system",includeTimestamp:e.includeTimestamp!==!1},c7.set(t,n),n.enabled&&(bw(t,n),pw(t,n.enabled))),gw(t,"toggleTrackChanges",n.enabled),n}function pw(t,e){t.classList.toggle("rte-track-changes-enabled",e),e?t.setAttribute("data-track-changes","true"):t.removeAttribute("data-track-changes")}function ble(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function gw(t,e,n){const r=ble(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false"),o.setAttribute("title",n?"Track Changes (On)":"Track Changes (Off)")})}function yle(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function vle(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function wu(t,e){yle(t),vle(t,e)}function wle(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}function f7(t){return{author:t.author,timestamp:t.includeTimestamp?new Date().toISOString():""}}function xle(t,e){const n=document.createElement("span");n.className="rte-track-insert",n.setAttribute("data-track-change","insert"),n.setAttribute("contenteditable","false");const r=f7(e);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(document.createTextNode(t)),n}function wA(t){Array.from(t.querySelectorAll(_s)).forEach(n=>{n.setAttribute("contenteditable","false")})}function xA(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Ele(t,e){const n=t.startContainer,r=t.startOffset;if(n.nodeType===Node.TEXT_NODE){const i=n,o=i.previousSibling||i.nextSibling;if(o instanceof HTMLElement&&o.matches(_s)&&e.contains(o))return o}if(n.nodeType===Node.ELEMENT_NODE){const i=n,o=i.childNodes[r-1];if(o instanceof HTMLElement&&o.matches(_s)&&e.contains(o))return o;const a=i.childNodes[r];if(a instanceof HTMLElement&&a.matches(_s)&&e.contains(a))return a}return null}function A7(t,e,n){const r=e.lastChild;r&&r.nodeType===Node.TEXT_NODE?r.data+=n:e.appendChild(document.createTextNode(n)),Bp(t,e)}function Cle(t,e){const n=document.createElement("span");n.className="rte-track-delete",n.setAttribute("data-track-change","delete"),n.setAttribute("contenteditable","false");const r=f7(e);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(t),n}function kp(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null}function Tle(){d7||typeof document=="undefined"||(d7=!0,document.addEventListener("selectionchange",()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0),n=xA(e.startContainer),r=(n==null?void 0:n.closest(vA))||null;r&&(kS.set(r,e.cloneRange()),fc=r)},!0))}function Bp(t,e){if(!e.parentNode){t.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartAfter(e),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.focus({preventScroll:!0})}function _S(t,e){if(!e.parentNode){t.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartBefore(e),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.focus({preventScroll:!0})}function kle(t,e,n){const r=window.getSelection();if(!r)return;const i=document.createRange();i.setStart(e,Math.max(0,n)),i.collapse(!0),r.removeAllRanges(),r.addRange(i),t.focus({preventScroll:!0})}function h7(t){let e=kp(t);if(!e){const a=kS.get(t);a&&t.contains(a.commonAncestorContainer)&&(e=a.cloneRange())}if(!e||!e.collapsed)return;const n=xA(e.startContainer);if(!n)return;const r=n.closest(_s);if(!r||!t.contains(r)||!r.parentNode)return;const i=window.getSelection();if(!i)return;const o=document.createRange();o.setStartAfter(r),o.collapse(!0),i.removeAllRanges(),i.addRange(o),t.focus({preventScroll:!0})}function p7(t,e){const n=t.innerHTML;wA(t),h7(t),t.focus({preventScroll:!0});const r=e==="insertLineBreak"?"insertLineBreak":"insertParagraph",i=document.execCommand(r,!1);return wA(t),wu(t,n),i!==!1}function Ble(t){const e=kp(t);if(e&&e.collapsed)return e;const n=kS.get(t);return n&&n.collapsed&&t.contains(n.commonAncestorContainer)?n.cloneRange():null}function Sle(t){return t.matches(_s)||t.matches(rs)?(t.textContent||"").replace(/\u200B/g,"").trim().length>0:hle.has(t.tagName)}function g7(t,e){if(e!=="insertParagraph")return!1;const n=Ble(t);if(!n)return!1;const r=xA(n.startContainer);if(!r)return!1;const i=r.closest("li");return!(i instanceof HTMLElement)||!t.contains(i)||(i.textContent||"").replace(/\u200B/g,"").trim().length>0?!1:!Array.from(i.querySelectorAll("*")).some(s=>Sle(s))}function _le(t){const e=document.createRange(),n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);if(t.contains(r.commonAncestorContainer))return e.setStart(r.endContainer,r.endOffset),e.collapse(!0),e}return e.selectNodeContents(t),e.collapse(!1),e}function Dle(t){return(t.textContent||"").length>0?!0:Array.from(t.childNodes).some(n=>{if(n.nodeType!==Node.ELEMENT_NODE)return!1;const r=n;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(r.tagName)})}function Lle(t){return Array.from(t.childNodes).some(e=>{if(e.nodeType===Node.TEXT_NODE)return(e.textContent||"").length>0;if(e.nodeType!==Node.ELEMENT_NODE)return!1;const n=e;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(n.tagName)})}function Fle(t,e,n){if(!t.collapsed)return null;const r=t.startContainer,i=t.startOffset;let o=null;if(r.nodeType===Node.TEXT_NODE){const a=r;e==="backward"&&i===0?o=a.previousSibling:e==="forward"&&i===a.length&&(o=a.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const a=r;e==="backward"&&i>0?o=a.childNodes[i-1]||null:e==="forward"&&i<a.childNodes.length&&(o=a.childNodes[i]||null)}return!(o instanceof HTMLElement)||!o.matches(_s)||!n.contains(o)?null:o}function Ile(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];let i=n.nextNode();for(;i;){const o=i;o.data.length>0&&r.push(o),i=n.nextNode()}return r.length===0?null:e?r[r.length-1]:r[0]}function Ule(t,e,n){const r=Fle(e,n,t);return r?DS(t,r,n):!1}function DS(t,e,n){const r=e.parentNode;if(!r)return!1;const i=Array.prototype.indexOf.call(r.childNodes,e),o=Ile(e,n==="backward");return o?(n==="backward"?o.data=o.data.slice(0,-1):o.data=o.data.slice(1),o.data.length===0&&o.remove(),Lle(e)?(n==="backward"?Bp(t,e):_S(t,e),!0):(e.remove(),kle(t,r,i),!0)):!1}function m7(t){if(t.startContainer!==t.endContainer||t.startContainer.nodeType!==Node.ELEMENT_NODE)return null;const e=t.startContainer;return t.endOffset-t.startOffset!==1?null:e.childNodes[t.startOffset]||null}function LS(t,e){const n=m7(t);return!(n instanceof HTMLElement)||!n.matches(rs)||!e.contains(n)?null:n}function Nle(t,e){const n=m7(t);return!(n instanceof HTMLElement)||!n.matches(_s)||!e.contains(n)?null:n}function Rle(t,e){var o,a;if(e.collapsed){const s=xA(e.startContainer),c=s==null?void 0:s.closest(rs);if(c&&t.contains(c)){const l=document.createRange();return l.setStartAfter(c),l.collapse(!0),l}return e}const n=LS(e,t);if(n){const s=document.createRange();return s.setStartAfter(n),s.collapse(!0),s}const r=(o=xA(e.startContainer))==null?void 0:o.closest(rs),i=(a=xA(e.endContainer))==null?void 0:a.closest(rs);if(r&&i&&r===i&&t.contains(r)){const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),s}return e}function Ole(t,e){const r=Array.from(e.querySelectorAll(_s)).filter(s=>{try{return t.intersectsNode(s)}catch(c){return!1}});if(r.length!==1)return null;const i=r[0],o=(t.toString()||"").replace(/\s+/g,""),a=(i.textContent||"").replace(/\s+/g,"");return!a||o!==a?null:i}function b7(t,e,n){if(e.collapsed)return null;const r=e.cloneContents();if(!Dle(r))return null;const i=Cle(r,n);return e.deleteContents(),e.insertNode(i),Bp(t,i),i}function Mle(t,e,n){if(!e.collapsed)return e;const r=e.startContainer,i=e.startOffset;if(r.nodeType===Node.TEXT_NODE){const s=r;if(n==="backward"&&i>0){const c=e.cloneRange();return c.setStart(s,i-1),c}if(n==="forward"&&i<s.length){const c=e.cloneRange();return c.setEnd(s,i+1),c}}if(r.nodeType===Node.ELEMENT_NODE){const s=r;if(n==="backward"&&i>0)for(let c=i-1;c>=0;c-=1){const l=s.childNodes[c];if(!l||l instanceof HTMLElement&&l.matches(rs))continue;const u=e.cloneRange();if(l.nodeType===Node.TEXT_NODE){const d=l;if(d.length===0)continue;u.setStart(d,d.length-1),u.setEnd(d,d.length)}else u.setStartBefore(l),u.setEndAfter(l);return u}if(n==="forward"&&i<s.childNodes.length)for(let c=i;c<s.childNodes.length;c+=1){const l=s.childNodes[c];if(!l||l instanceof HTMLElement&&l.matches(rs))continue;const u=e.cloneRange();if(l.nodeType===Node.TEXT_NODE){const d=l;if(d.length===0)continue;u.setStart(d,0),u.setEnd(d,1)}else u.setStartBefore(l),u.setEndAfter(l);return u}}const o=window.getSelection();if(!o||typeof o.modify!="function")return null;const a=e.cloneRange();o.removeAllRanges(),o.addRange(a);try{if(o.modify("extend",n,"character"),o.rangeCount===0)return null;const s=o.getRangeAt(0).cloneRange();if(s.collapsed||!t.contains(s.commonAncestorContainer))return null;const c=LS(s,t);return c?(n==="backward"?_S(t,c):Bp(t,c),null):s}catch(s){return null}finally{o.removeAllRanges(),o.addRange(a)}}function y7(t,e,n){let r=kp(t);if(!r)return!1;const i=Rle(t,r.cloneRange());if(!wle(i,r)){const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(i)),r=i}const o=t.innerHTML;r.collapsed||b7(t,r.cloneRange(),e);const a=xA(r.startContainer),s=a==null?void 0:a.closest(_s);if(r.collapsed&&s&&t.contains(s))return A7(t,s,n),wu(t,o),!0;const c=r.collapsed?Ele(r,t):null;if(c)return A7(t,c,n),wu(t,o),!0;const l=_le(t),u=xle(n,e);return l.insertNode(u),Bp(t,u),wu(t,o),!0}function v7(t,e,n){const r=kp(t);if(!r)return!1;const i=n.includes("Backward")?"backward":"forward",o=t.innerHTML;if(r.collapsed&&Ule(t,r.cloneRange(),i))return wu(t,o),!0;const a=Nle(r,t);if(a&&DS(t,a,i))return wu(t,o),!0;if(!r.collapsed){const u=Ole(r,t);if(u&&DS(t,u,i))return wu(t,o),!0}const s=r.collapsed?Mle(t,r.cloneRange(),i):r.cloneRange();if(!s)return!1;const c=LS(s,t);return c?(i==="backward"?_S(t,c):Bp(t,c),!0):b7(t,s,e)?(IS(t),wu(t,o),!0):!1}function FS(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function IS(t){Array.from(t.querySelectorAll(rs)).forEach(r=>{r.setAttribute("contenteditable","false"),Array.from(r.querySelectorAll(rs)).forEach(o=>{o!==r&&FS(o)})});let n=!0;for(;n;)n=!1,Array.from(t.querySelectorAll(rs)).forEach(i=>{if(!i.isConnected)return;let o=i.nextSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim();)o=o.nextSibling;if(o instanceof HTMLElement&&o.matches(rs)){for(;o.firstChild;)i.appendChild(o.firstChild);o.remove(),n=!0}i.firstChild||(i.remove(),n=!0)})}function w7(t){return Array.from(t.querySelectorAll(TS))}function Ple(t){const e=kp(t);if(!e)return[];const n=new Set,r=e.startContainer.nodeType===Node.ELEMENT_NODE?e.startContainer:e.startContainer.parentElement,i=e.endContainer.nodeType===Node.ELEMENT_NODE?e.endContainer:e.endContainer.parentElement,o=r==null?void 0:r.closest(TS);o&&t.contains(o)&&n.add(o);const a=i==null?void 0:i.closest(TS);return a&&t.contains(a)&&n.add(a),w7(t).filter(c=>{try{return e.intersectsNode(c)}catch(l){return!1}}).forEach(c=>n.add(c)),Array.from(n)}function mw(t,e,n){const r=n==="all"?w7(t):Ple(t);if(r.length===0)return!1;const i=t.innerHTML;return r.forEach(o=>{if(!o.isConnected)return;const a=o.matches(_s),s=o.matches(rs);if(!(!a&&!s)){if(e==="accept"){a?FS(o):o.remove();return}a?o.remove():(o.removeAttribute("contenteditable"),FS(o))}}),IS(t),wu(t,i),!0}function Hle(t){if(!(t instanceof Node))return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return(e==null?void 0:e.closest(vA))||null}function Qle(){u7||typeof document=="undefined"||(u7=!0,document.addEventListener("focusin",t=>{if(!Tp.enabledByDefault)return;const e=Hle(t.target);if(!e)return;fc=e;const n=SS(e,Tp);n.enabled?(bw(e,n),pw(e,!0),gw(e,"toggleTrackChanges",!0)):wA(e)},!0))}function $le(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true")return;fc=t;const r=n.inputType||"";if(r==="insertParagraph"||r==="insertLineBreak"){if(g7(t,r))return;n.preventDefault(),p7(t,r);return}if(r.startsWith("delete")){n.preventDefault(),v7(t,e,r);return}if(r==="insertText"||r==="insertCompositionText"){const i=n.data||"";if(!i)return;n.preventDefault(),y7(t,e,i)}}}function zle(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true"||n.key!=="Enter"||Ale)return;const r=n.shiftKey?"insertLineBreak":"insertParagraph";g7(t,r)||(fc=t,n.preventDefault(),n.stopPropagation(),p7(t,r))}}function jle(t,e){return n=>{var i;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented||!e.enabled||t.getAttribute("data-track-changes")!=="true")return;const r=((i=n.clipboardData)==null?void 0:i.getData("text/plain"))||"";r&&(n.preventDefault(),fc=t,y7(t,e,r))}}function qle(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true")return;const r=kp(t);if(!r||r.collapsed)return;const i=r.toString();n.clipboardData&&(n.clipboardData.setData("text/plain",i),n.preventDefault()),fc=t,v7(t,e,"deleteByCut")}}function bw(t,e){if(hw.has(t))return;wA(t);const n={beforeInput:$le(t,e),keydown:zle(t,e),paste:jle(t,e),cut:qle(t,e)};t.addEventListener("beforeinput",n.beforeInput),t.addEventListener("keydown",n.keydown),t.addEventListener("paste",n.paste),t.addEventListener("cut",n.cut),hw.set(t,n),BS.add(t)}function x7(t){const e=hw.get(t);e&&(t.removeEventListener("beforeinput",e.beforeInput),t.removeEventListener("keydown",e.keydown),t.removeEventListener("paste",e.paste),t.removeEventListener("cut",e.cut),hw.delete(t),BS.delete(t))}function Wle(){if(l7||typeof document=="undefined")return;l7=!0;const t=document.createElement("style");t.id="rte-track-changes-styles",t.textContent=`
|
|
1733
|
+
</svg>`}if(typeof window!="undefined"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const t=()=>{Gce()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t,100)}const fle=Object.freeze(Object.defineProperty({__proto__:null,TablePlugin:()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(nP(()=>{jM()}),!0)},keymap:{"Mod-Shift-r":()=>(iy("addRowBelow"),!0),"Mod-Shift-c":()=>(iy("addColumnRight"),!0)}}),addColumnLeftCommand:KM,addColumnRightCommand:VM,addRowAboveCommand:qM,addRowBelowCommand:WM,deleteColumnCommand:XM,deleteRowCommand:GM,deleteTableCommand:eP,insertTableCommand:jM,mergeCellsCommand:iP,toggleHeaderColumnCommand:JM,toggleHeaderRowCommand:YM},Symbol.toStringTag,{value:"Module"})),vA=".rte-content, .editora-content",_s='.rte-track-insert[data-track-change="insert"]',rs='.rte-track-delete[data-track-change="delete"]',TS=`${_s}, ${rs}`,sP="__editoraCommandEditorRoot",cP=new WeakMap,hw=new WeakMap,kS=new WeakMap,BS=new Set;let lP=!1,fc=null,uP=!1,Tp={},dP=!1;const Ale=typeof InputEvent!="undefined"&&typeof InputEvent.prototype=="object"&&"inputType"in InputEvent.prototype,hle=new Set(["IMG","TABLE","VIDEO","AUDIO","SVG","MATH","HR","IFRAME","INPUT","TEXTAREA","SELECT","BUTTON","CANVAS"]);function ple(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function gle(){if(typeof window=="undefined")return null;const t=window[sP];if(!(t instanceof HTMLElement))return null;window[sP]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const r=ple(e);if(r)return r;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function mle(t){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.getAttribute("contenteditable")==="true")return i;const o=i.querySelector('[contenteditable="true"]');if(o instanceof HTMLElement)return o}const e=gle();if(e&&document.contains(e))return e;const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(vA);if(a)return a}const r=document.activeElement;if(r){if(r.matches(vA))return r;const i=r.closest(vA);if(i)return i}return fc!=null&&fc.isConnected?fc:document.querySelector(vA)}function SS(t,e){var r;wA(t),IS(t);let n=cP.get(t);return n||(n={enabled:!!e.enabledByDefault,author:((r=e.author)==null?void 0:r.trim())||"system",includeTimestamp:e.includeTimestamp!==!1},cP.set(t,n),n.enabled&&(bw(t,n),pw(t,n.enabled))),gw(t,"toggleTrackChanges",n.enabled),n}function pw(t,e){t.classList.toggle("rte-track-changes-enabled",e),e?t.setAttribute("data-track-changes","true"):t.removeAttribute("data-track-changes")}function ble(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function gw(t,e,n){const r=ble(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false"),o.setAttribute("title",n?"Track Changes (On)":"Track Changes (Off)")})}function yle(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function vle(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function wu(t,e){yle(t),vle(t,e)}function wle(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}function fP(t){return{author:t.author,timestamp:t.includeTimestamp?new Date().toISOString():""}}function xle(t,e){const n=document.createElement("span");n.className="rte-track-insert",n.setAttribute("data-track-change","insert"),n.setAttribute("contenteditable","false");const r=fP(e);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(document.createTextNode(t)),n}function wA(t){Array.from(t.querySelectorAll(_s)).forEach(n=>{n.setAttribute("contenteditable","false")})}function xA(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Ele(t,e){const n=t.startContainer,r=t.startOffset;if(n.nodeType===Node.TEXT_NODE){const i=n,o=i.previousSibling||i.nextSibling;if(o instanceof HTMLElement&&o.matches(_s)&&e.contains(o))return o}if(n.nodeType===Node.ELEMENT_NODE){const i=n,o=i.childNodes[r-1];if(o instanceof HTMLElement&&o.matches(_s)&&e.contains(o))return o;const a=i.childNodes[r];if(a instanceof HTMLElement&&a.matches(_s)&&e.contains(a))return a}return null}function AP(t,e,n){const r=e.lastChild;r&&r.nodeType===Node.TEXT_NODE?r.data+=n:e.appendChild(document.createTextNode(n)),Bp(t,e)}function Cle(t,e){const n=document.createElement("span");n.className="rte-track-delete",n.setAttribute("data-track-change","delete"),n.setAttribute("contenteditable","false");const r=fP(e);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(t),n}function kp(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null}function Tle(){dP||typeof document=="undefined"||(dP=!0,document.addEventListener("selectionchange",()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0),n=xA(e.startContainer),r=(n==null?void 0:n.closest(vA))||null;r&&(kS.set(r,e.cloneRange()),fc=r)},!0))}function Bp(t,e){if(!e.parentNode){t.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartAfter(e),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.focus({preventScroll:!0})}function _S(t,e){if(!e.parentNode){t.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartBefore(e),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.focus({preventScroll:!0})}function kle(t,e,n){const r=window.getSelection();if(!r)return;const i=document.createRange();i.setStart(e,Math.max(0,n)),i.collapse(!0),r.removeAllRanges(),r.addRange(i),t.focus({preventScroll:!0})}function hP(t){let e=kp(t);if(!e){const a=kS.get(t);a&&t.contains(a.commonAncestorContainer)&&(e=a.cloneRange())}if(!e||!e.collapsed)return;const n=xA(e.startContainer);if(!n)return;const r=n.closest(_s);if(!r||!t.contains(r)||!r.parentNode)return;const i=window.getSelection();if(!i)return;const o=document.createRange();o.setStartAfter(r),o.collapse(!0),i.removeAllRanges(),i.addRange(o),t.focus({preventScroll:!0})}function pP(t,e){const n=t.innerHTML;wA(t),hP(t),t.focus({preventScroll:!0});const r=e==="insertLineBreak"?"insertLineBreak":"insertParagraph",i=document.execCommand(r,!1);return wA(t),wu(t,n),i!==!1}function Ble(t){const e=kp(t);if(e&&e.collapsed)return e;const n=kS.get(t);return n&&n.collapsed&&t.contains(n.commonAncestorContainer)?n.cloneRange():null}function Sle(t){return t.matches(_s)||t.matches(rs)?(t.textContent||"").replace(/\u200B/g,"").trim().length>0:hle.has(t.tagName)}function gP(t,e){if(e!=="insertParagraph")return!1;const n=Ble(t);if(!n)return!1;const r=xA(n.startContainer);if(!r)return!1;const i=r.closest("li");return!(i instanceof HTMLElement)||!t.contains(i)||(i.textContent||"").replace(/\u200B/g,"").trim().length>0?!1:!Array.from(i.querySelectorAll("*")).some(s=>Sle(s))}function _le(t){const e=document.createRange(),n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);if(t.contains(r.commonAncestorContainer))return e.setStart(r.endContainer,r.endOffset),e.collapse(!0),e}return e.selectNodeContents(t),e.collapse(!1),e}function Dle(t){return(t.textContent||"").length>0?!0:Array.from(t.childNodes).some(n=>{if(n.nodeType!==Node.ELEMENT_NODE)return!1;const r=n;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(r.tagName)})}function Lle(t){return Array.from(t.childNodes).some(e=>{if(e.nodeType===Node.TEXT_NODE)return(e.textContent||"").length>0;if(e.nodeType!==Node.ELEMENT_NODE)return!1;const n=e;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(n.tagName)})}function Fle(t,e,n){if(!t.collapsed)return null;const r=t.startContainer,i=t.startOffset;let o=null;if(r.nodeType===Node.TEXT_NODE){const a=r;e==="backward"&&i===0?o=a.previousSibling:e==="forward"&&i===a.length&&(o=a.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const a=r;e==="backward"&&i>0?o=a.childNodes[i-1]||null:e==="forward"&&i<a.childNodes.length&&(o=a.childNodes[i]||null)}return!(o instanceof HTMLElement)||!o.matches(_s)||!n.contains(o)?null:o}function Ile(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];let i=n.nextNode();for(;i;){const o=i;o.data.length>0&&r.push(o),i=n.nextNode()}return r.length===0?null:e?r[r.length-1]:r[0]}function Ule(t,e,n){const r=Fle(e,n,t);return r?DS(t,r,n):!1}function DS(t,e,n){const r=e.parentNode;if(!r)return!1;const i=Array.prototype.indexOf.call(r.childNodes,e),o=Ile(e,n==="backward");return o?(n==="backward"?o.data=o.data.slice(0,-1):o.data=o.data.slice(1),o.data.length===0&&o.remove(),Lle(e)?(n==="backward"?Bp(t,e):_S(t,e),!0):(e.remove(),kle(t,r,i),!0)):!1}function mP(t){if(t.startContainer!==t.endContainer||t.startContainer.nodeType!==Node.ELEMENT_NODE)return null;const e=t.startContainer;return t.endOffset-t.startOffset!==1?null:e.childNodes[t.startOffset]||null}function LS(t,e){const n=mP(t);return!(n instanceof HTMLElement)||!n.matches(rs)||!e.contains(n)?null:n}function Nle(t,e){const n=mP(t);return!(n instanceof HTMLElement)||!n.matches(_s)||!e.contains(n)?null:n}function Rle(t,e){var o,a;if(e.collapsed){const s=xA(e.startContainer),c=s==null?void 0:s.closest(rs);if(c&&t.contains(c)){const l=document.createRange();return l.setStartAfter(c),l.collapse(!0),l}return e}const n=LS(e,t);if(n){const s=document.createRange();return s.setStartAfter(n),s.collapse(!0),s}const r=(o=xA(e.startContainer))==null?void 0:o.closest(rs),i=(a=xA(e.endContainer))==null?void 0:a.closest(rs);if(r&&i&&r===i&&t.contains(r)){const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),s}return e}function Ole(t,e){const r=Array.from(e.querySelectorAll(_s)).filter(s=>{try{return t.intersectsNode(s)}catch(c){return!1}});if(r.length!==1)return null;const i=r[0],o=(t.toString()||"").replace(/\s+/g,""),a=(i.textContent||"").replace(/\s+/g,"");return!a||o!==a?null:i}function bP(t,e,n){if(e.collapsed)return null;const r=e.cloneContents();if(!Dle(r))return null;const i=Cle(r,n);return e.deleteContents(),e.insertNode(i),Bp(t,i),i}function Mle(t,e,n){if(!e.collapsed)return e;const r=e.startContainer,i=e.startOffset;if(r.nodeType===Node.TEXT_NODE){const s=r;if(n==="backward"&&i>0){const c=e.cloneRange();return c.setStart(s,i-1),c}if(n==="forward"&&i<s.length){const c=e.cloneRange();return c.setEnd(s,i+1),c}}if(r.nodeType===Node.ELEMENT_NODE){const s=r;if(n==="backward"&&i>0)for(let c=i-1;c>=0;c-=1){const l=s.childNodes[c];if(!l||l instanceof HTMLElement&&l.matches(rs))continue;const u=e.cloneRange();if(l.nodeType===Node.TEXT_NODE){const d=l;if(d.length===0)continue;u.setStart(d,d.length-1),u.setEnd(d,d.length)}else u.setStartBefore(l),u.setEndAfter(l);return u}if(n==="forward"&&i<s.childNodes.length)for(let c=i;c<s.childNodes.length;c+=1){const l=s.childNodes[c];if(!l||l instanceof HTMLElement&&l.matches(rs))continue;const u=e.cloneRange();if(l.nodeType===Node.TEXT_NODE){const d=l;if(d.length===0)continue;u.setStart(d,0),u.setEnd(d,1)}else u.setStartBefore(l),u.setEndAfter(l);return u}}const o=window.getSelection();if(!o||typeof o.modify!="function")return null;const a=e.cloneRange();o.removeAllRanges(),o.addRange(a);try{if(o.modify("extend",n,"character"),o.rangeCount===0)return null;const s=o.getRangeAt(0).cloneRange();if(s.collapsed||!t.contains(s.commonAncestorContainer))return null;const c=LS(s,t);return c?(n==="backward"?_S(t,c):Bp(t,c),null):s}catch(s){return null}finally{o.removeAllRanges(),o.addRange(a)}}function yP(t,e,n){let r=kp(t);if(!r)return!1;const i=Rle(t,r.cloneRange());if(!wle(i,r)){const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(i)),r=i}const o=t.innerHTML;r.collapsed||bP(t,r.cloneRange(),e);const a=xA(r.startContainer),s=a==null?void 0:a.closest(_s);if(r.collapsed&&s&&t.contains(s))return AP(t,s,n),wu(t,o),!0;const c=r.collapsed?Ele(r,t):null;if(c)return AP(t,c,n),wu(t,o),!0;const l=_le(t),u=xle(n,e);return l.insertNode(u),Bp(t,u),wu(t,o),!0}function vP(t,e,n){const r=kp(t);if(!r)return!1;const i=n.includes("Backward")?"backward":"forward",o=t.innerHTML;if(r.collapsed&&Ule(t,r.cloneRange(),i))return wu(t,o),!0;const a=Nle(r,t);if(a&&DS(t,a,i))return wu(t,o),!0;if(!r.collapsed){const u=Ole(r,t);if(u&&DS(t,u,i))return wu(t,o),!0}const s=r.collapsed?Mle(t,r.cloneRange(),i):r.cloneRange();if(!s)return!1;const c=LS(s,t);return c?(i==="backward"?_S(t,c):Bp(t,c),!0):bP(t,s,e)?(IS(t),wu(t,o),!0):!1}function FS(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function IS(t){Array.from(t.querySelectorAll(rs)).forEach(r=>{r.setAttribute("contenteditable","false"),Array.from(r.querySelectorAll(rs)).forEach(o=>{o!==r&&FS(o)})});let n=!0;for(;n;)n=!1,Array.from(t.querySelectorAll(rs)).forEach(i=>{if(!i.isConnected)return;let o=i.nextSibling;for(;o&&o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim();)o=o.nextSibling;if(o instanceof HTMLElement&&o.matches(rs)){for(;o.firstChild;)i.appendChild(o.firstChild);o.remove(),n=!0}i.firstChild||(i.remove(),n=!0)})}function wP(t){return Array.from(t.querySelectorAll(TS))}function Ple(t){const e=kp(t);if(!e)return[];const n=new Set,r=e.startContainer.nodeType===Node.ELEMENT_NODE?e.startContainer:e.startContainer.parentElement,i=e.endContainer.nodeType===Node.ELEMENT_NODE?e.endContainer:e.endContainer.parentElement,o=r==null?void 0:r.closest(TS);o&&t.contains(o)&&n.add(o);const a=i==null?void 0:i.closest(TS);return a&&t.contains(a)&&n.add(a),wP(t).filter(c=>{try{return e.intersectsNode(c)}catch(l){return!1}}).forEach(c=>n.add(c)),Array.from(n)}function mw(t,e,n){const r=n==="all"?wP(t):Ple(t);if(r.length===0)return!1;const i=t.innerHTML;return r.forEach(o=>{if(!o.isConnected)return;const a=o.matches(_s),s=o.matches(rs);if(!(!a&&!s)){if(e==="accept"){a?FS(o):o.remove();return}a?o.remove():(o.removeAttribute("contenteditable"),FS(o))}}),IS(t),wu(t,i),!0}function Hle(t){if(!(t instanceof Node))return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return(e==null?void 0:e.closest(vA))||null}function Qle(){uP||typeof document=="undefined"||(uP=!0,document.addEventListener("focusin",t=>{if(!Tp.enabledByDefault)return;const e=Hle(t.target);if(!e)return;fc=e;const n=SS(e,Tp);n.enabled?(bw(e,n),pw(e,!0),gw(e,"toggleTrackChanges",!0)):wA(e)},!0))}function $le(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true")return;fc=t;const r=n.inputType||"";if(r==="insertParagraph"||r==="insertLineBreak"){if(gP(t,r))return;n.preventDefault(),pP(t,r);return}if(r.startsWith("delete")){n.preventDefault(),vP(t,e,r);return}if(r==="insertText"||r==="insertCompositionText"){const i=n.data||"";if(!i)return;n.preventDefault(),yP(t,e,i)}}}function zle(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true"||n.key!=="Enter"||Ale)return;const r=n.shiftKey?"insertLineBreak":"insertParagraph";gP(t,r)||(fc=t,n.preventDefault(),n.stopPropagation(),pP(t,r))}}function jle(t,e){return n=>{var i;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented||!e.enabled||t.getAttribute("data-track-changes")!=="true")return;const r=((i=n.clipboardData)==null?void 0:i.getData("text/plain"))||"";r&&(n.preventDefault(),fc=t,yP(t,e,r))}}function qle(t,e){return n=>{if(!e.enabled||t.getAttribute("data-track-changes")!=="true")return;const r=kp(t);if(!r||r.collapsed)return;const i=r.toString();n.clipboardData&&(n.clipboardData.setData("text/plain",i),n.preventDefault()),fc=t,vP(t,e,"deleteByCut")}}function bw(t,e){if(hw.has(t))return;wA(t);const n={beforeInput:$le(t,e),keydown:zle(t,e),paste:jle(t,e),cut:qle(t,e)};t.addEventListener("beforeinput",n.beforeInput),t.addEventListener("keydown",n.keydown),t.addEventListener("paste",n.paste),t.addEventListener("cut",n.cut),hw.set(t,n),BS.add(t)}function xP(t){const e=hw.get(t);e&&(t.removeEventListener("beforeinput",e.beforeInput),t.removeEventListener("keydown",e.keydown),t.removeEventListener("paste",e.paste),t.removeEventListener("cut",e.cut),hw.delete(t),BS.delete(t))}function Wle(){if(lP||typeof document=="undefined")return;lP=!0;const t=document.createElement("style");t.id="rte-track-changes-styles",t.textContent=`
|
|
1733
1734
|
.rte-track-insert[data-track-change="insert"] {
|
|
1734
1735
|
background: rgba(22, 163, 74, 0.2);
|
|
1735
1736
|
color: inherit;
|
|
@@ -1805,12 +1806,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1805
1806
|
.editora-toolbar-button[data-command="toggleTrackChanges"].active {
|
|
1806
1807
|
background-color: #ccc;
|
|
1807
1808
|
}
|
|
1808
|
-
`,document.head.appendChild(t)}const Kle=Object.freeze(Object.defineProperty({__proto__:null,TrackChangesPlugin:(t={})=>{Wle(),Tle(),Tp={...Tp,...t},Qle(),Tp.enabledByDefault&&typeof document!="undefined"&&(typeof requestAnimationFrame=="function"?requestAnimationFrame:i=>window.setTimeout(i,0))(()=>{Array.from(document.querySelectorAll(vA)).forEach(o=>{const a=SS(o,Tp);a.enabled?(bw(o,a),pw(o,!0),gw(o,"toggleTrackChanges",!0)):wA(o)})});const e=r=>{const i=mle(r);return i?(fc=i,i):null},n=r=>{const i=e(r);if(!i)return null;const o=SS(i,t);return{editor:i,state:o}};return{name:"trackChanges",toolbar:[{label:"Track Changes",command:"toggleTrackChanges",type:"group",items:[{label:"Track Changes",command:"toggleTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',shortcut:"Mod-Shift-t"},{label:"Accept All Changes",command:"acceptAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'},{label:"Reject All Changes",command:"rejectAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'}]}],commands:{toggleTrackChanges:(r,i)=>{const o=n(i);if(!o)return!1;const{editor:a,state:s}=o;return s.enabled=!s.enabled,s.enabled?bw(a,s):(
|
|
1809
|
-
`)}function
|
|
1809
|
+
`,document.head.appendChild(t)}const Kle=Object.freeze(Object.defineProperty({__proto__:null,TrackChangesPlugin:(t={})=>{Wle(),Tle(),Tp={...Tp,...t},Qle(),Tp.enabledByDefault&&typeof document!="undefined"&&(typeof requestAnimationFrame=="function"?requestAnimationFrame:i=>window.setTimeout(i,0))(()=>{Array.from(document.querySelectorAll(vA)).forEach(o=>{const a=SS(o,Tp);a.enabled?(bw(o,a),pw(o,!0),gw(o,"toggleTrackChanges",!0)):wA(o)})});const e=r=>{const i=mle(r);return i?(fc=i,i):null},n=r=>{const i=e(r);if(!i)return null;const o=SS(i,t);return{editor:i,state:o}};return{name:"trackChanges",toolbar:[{label:"Track Changes",command:"toggleTrackChanges",type:"group",items:[{label:"Track Changes",command:"toggleTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',shortcut:"Mod-Shift-t"},{label:"Accept All Changes",command:"acceptAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'},{label:"Reject All Changes",command:"rejectAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'}]}],commands:{toggleTrackChanges:(r,i)=>{const o=n(i);if(!o)return!1;const{editor:a,state:s}=o;return s.enabled=!s.enabled,s.enabled?bw(a,s):(xP(a),wA(a),hP(a)),pw(a,s.enabled),gw(a,"toggleTrackChanges",s.enabled),a.dispatchEvent(new CustomEvent("editora:track-changes-toggle",{bubbles:!0,detail:{enabled:s.enabled,author:s.author}})),s.enabled},acceptAllTrackChanges:(r,i)=>{const o=n(i);return o?mw(o.editor,"accept","all"):!1},rejectAllTrackChanges:(r,i)=>{const o=n(i);return o?mw(o.editor,"reject","all"):!1},acceptSelectedTrackChanges:(r,i)=>{const o=n(i);return o?mw(o.editor,"accept","selection"):!1},rejectSelectedTrackChanges:(r,i)=>{const o=n(i);return o?mw(o.editor,"reject","selection"):!1}},keymap:{"Mod-Shift-t":"toggleTrackChanges","Mod-Shift-T":"toggleTrackChanges"},destroy:()=>{Array.from(BS).forEach(r=>xP(r))}}}},Symbol.toStringTag,{value:"Module"})),Pd=".rte-content, .editora-content",gi='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark',qr="rte-version-diff-overlay",EP="rte-version-diff-styles",Vle={title:"Version Diff",baseline:"Baseline",current:"Current",noChanges:"No changes detected between baseline and current content.",loading:"Preparing diff...",tabInline:"Inline Diff",tabSideBySide:"Side by Side",refresh:"Refresh",setBaseline:"Set Current as Baseline",close:"Close",mode:"Mode",ignoreWhitespace:"Ignore whitespace",largeDocFallback:"Large document fallback mode applied for performance."},EA=new WeakMap,yw=new WeakMap;let vw=0,Sp=null,oy=null,US=null,_p=null,Dp=null,Lp=null;function Ii(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Gle(t){return{...Vle,...t||{}}}function NS(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(Pd))return i;const o=i.querySelector(Pd);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(Pd);if(a)return a}const r=document.activeElement;if(r){if(r.matches(Pd))return r;const i=r.closest(Pd);if(i)return i}return Lp&&Lp.isConnected?Lp:e?document.querySelector(Pd):null}function RS(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function ww(t){if(!t)return!1;const e=t.getAttribute("data-theme")||t.getAttribute("theme");if(e&&e.toLowerCase()==="dark")return!0;const n=t.classList;return n.contains("dark")||n.contains("editora-theme-dark")||n.contains("rte-theme-dark")}function CP(t){const e=RS(t);if(ww(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return!!(ww(n)||ww(document.documentElement)||ww(document.body))}function Xle(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}function OS(t){const n=RS(t).getAttribute("data-initial-content");return n?Xle(n):t.innerHTML}function TP(t){return t.replace(/\r\n?/g,`
|
|
1810
|
+
`)}function kP(t){const e=document.createElement("div"),n=t.replace(/<br\s*\/?>/gi,`
|
|
1810
1811
|
`).replace(/<\/(p|div|h1|h2|h3|h4|h5|h6|li|tr|blockquote|pre|section|article)>/gi,`$&
|
|
1811
|
-
`);e.innerHTML=n;const r=e.textContent||"";return
|
|
1812
|
+
`);e.innerHTML=n;const r=e.textContent||"";return TP(r).replace(/\u00a0/g," ").replace(/\n{3,}/g,`
|
|
1812
1813
|
|
|
1813
|
-
`).trim()}function
|
|
1814
|
+
`).trim()}function BP(t,e,n){let r=TP(t);if(n&&(r=r.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
|
|
1814
1815
|
|
|
1815
1816
|
`).trim()),!r)return[];if(e==="line")return r.split(`
|
|
1816
1817
|
`);if(n)return r.split(/\s+/).filter(Boolean);const i=[],o=r.split(`
|
|
@@ -1819,8 +1820,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1819
1820
|
`);if(n)return t.join(" ");let r="";for(let i=0;i<t.length;i+=1){const o=t[i];if(o===`
|
|
1820
1821
|
`){r=r.replace(/[ \t]+$/g,""),r+=`
|
|
1821
1822
|
`;continue}r.length>0&&!r.endsWith(`
|
|
1822
|
-
`)&&(r+=" "),r+=o}return r}function Zle(t,e,n){const r=[];return t.forEach(i=>{const o=r[r.length-1];if(o&&o.type===i.type){o.tokens.push(i.token);return}r.push({type:i.type,tokens:[i.token]})}),r.map(i=>({type:i.type,value:Yle(i.tokens,e,n),count:i.tokens.length}))}function Jle(t,e){let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n+=1;let r=t.length-1,i=e.length-1;for(;r>=n&&i>=n&&t[r]===e[i];)r-=1,i-=1;const o=t.slice(0,n),a=r<t.length-1?t.slice(r+1):[],s=n<=r?t.slice(n,r+1):[],c=n<=i?e.slice(n,i+1):[];return{prefix:o,suffix:a,aMiddle:s,bMiddle:c}}function eue(t,e,n,r,i,o){if(t.length===0&&e.length===0)return{segments:[],insertedCount:0,deletedCount:0,equalCount:0,usedFallback:!1};const{prefix:a,suffix:s,aMiddle:c,bMiddle:l}=Jle(t,e),u=[];a.forEach(g=>u.push({type:"equal",token:g}));const d=c.length*l.length,f=c.length>o||l.length>o||d>i;if(f)c.forEach(g=>u.push({type:"delete",token:g})),l.forEach(g=>u.push({type:"insert",token:g}));else{const g=Array.from({length:c.length+1},()=>new Uint32Array(l.length+1));for(let w=c.length-1;w>=0;w-=1){const x=g[w],k=g[w+1];for(let T=l.length-1;T>=0;T-=1)x[T]=c[w]===l[T]?k[T+1]+1:Math.max(k[T],x[T+1])}let b=0,y=0;for(;b<c.length&&y<l.length;)c[b]===l[y]?(u.push({type:"equal",token:c[b]}),b+=1,y+=1):g[b+1][y]>=g[b][y+1]?(u.push({type:"delete",token:c[b]}),b+=1):(u.push({type:"insert",token:l[y]}),y+=1);for(;b<c.length;)u.push({type:"delete",token:c[b]}),b+=1;for(;y<l.length;)u.push({type:"insert",token:l[y]}),y+=1}s.forEach(g=>u.push({type:"equal",token:g}));const A=Zle(u,n,r);let h=0,p=0,m=0;return A.forEach(g=>{g.type==="insert"&&(h+=g.count),g.type==="delete"&&(p+=g.count),g.type==="equal"&&(m+=g.count)}),{segments:A,insertedCount:h,deletedCount:p,equalCount:m,usedFallback:f}}function
|
|
1823
|
-
`)}function tue(t,e){return t.length===0?`<p class="rte-version-diff-empty">${Ii(e.noChanges)}</p>`:t.map(n=>`<span class="${n.type==="equal"?"rte-version-diff-equal":n.type==="insert"?"rte-version-diff-insert":"rte-version-diff-delete"}">${
|
|
1823
|
+
`)&&(r+=" "),r+=o}return r}function Zle(t,e,n){const r=[];return t.forEach(i=>{const o=r[r.length-1];if(o&&o.type===i.type){o.tokens.push(i.token);return}r.push({type:i.type,tokens:[i.token]})}),r.map(i=>({type:i.type,value:Yle(i.tokens,e,n),count:i.tokens.length}))}function Jle(t,e){let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n+=1;let r=t.length-1,i=e.length-1;for(;r>=n&&i>=n&&t[r]===e[i];)r-=1,i-=1;const o=t.slice(0,n),a=r<t.length-1?t.slice(r+1):[],s=n<=r?t.slice(n,r+1):[],c=n<=i?e.slice(n,i+1):[];return{prefix:o,suffix:a,aMiddle:s,bMiddle:c}}function eue(t,e,n,r,i,o){if(t.length===0&&e.length===0)return{segments:[],insertedCount:0,deletedCount:0,equalCount:0,usedFallback:!1};const{prefix:a,suffix:s,aMiddle:c,bMiddle:l}=Jle(t,e),u=[];a.forEach(g=>u.push({type:"equal",token:g}));const d=c.length*l.length,f=c.length>o||l.length>o||d>i;if(f)c.forEach(g=>u.push({type:"delete",token:g})),l.forEach(g=>u.push({type:"insert",token:g}));else{const g=Array.from({length:c.length+1},()=>new Uint32Array(l.length+1));for(let w=c.length-1;w>=0;w-=1){const x=g[w],k=g[w+1];for(let T=l.length-1;T>=0;T-=1)x[T]=c[w]===l[T]?k[T+1]+1:Math.max(k[T],x[T+1])}let b=0,y=0;for(;b<c.length&&y<l.length;)c[b]===l[y]?(u.push({type:"equal",token:c[b]}),b+=1,y+=1):g[b+1][y]>=g[b][y+1]?(u.push({type:"delete",token:c[b]}),b+=1):(u.push({type:"insert",token:l[y]}),y+=1);for(;b<c.length;)u.push({type:"delete",token:c[b]}),b+=1;for(;y<l.length;)u.push({type:"insert",token:l[y]}),y+=1}s.forEach(g=>u.push({type:"equal",token:g}));const A=Zle(u,n,r);let h=0,p=0,m=0;return A.forEach(g=>{g.type==="insert"&&(h+=g.count),g.type==="delete"&&(p+=g.count),g.type==="equal"&&(m+=g.count)}),{segments:A,insertedCount:h,deletedCount:p,equalCount:m,usedFallback:f}}function SP(t){return Ii(t.value).replace(/\n/g,`
|
|
1824
|
+
`)}function tue(t,e){return t.length===0?`<p class="rte-version-diff-empty">${Ii(e.noChanges)}</p>`:t.map(n=>`<span class="${n.type==="equal"?"rte-version-diff-equal":n.type==="insert"?"rte-version-diff-insert":"rte-version-diff-delete"}">${SP(n)}</span>`).join("")}function nue(t,e){if(t.length===0){const i=`<p class="rte-version-diff-empty">${Ii(e.noChanges)}</p>`;return{baselineHtml:i,currentHtml:i}}const n=[],r=[];return t.forEach(i=>{const o=SP(i);if(i.type==="equal"){n.push(`<span class="rte-version-diff-equal">${o}</span>`),r.push(`<span class="rte-version-diff-equal">${o}</span>`);return}if(i.type==="delete"){n.push(`<span class="rte-version-diff-delete">${o}</span>`);return}r.push(`<span class="rte-version-diff-insert">${o}</span>`)}),{baselineHtml:n.join(""),currentHtml:r.join("")}}function rue(t){const e=t.metaKey||t.ctrlKey,r=(typeof t.key=="string"?t.key:"").toLowerCase(),i=typeof t.code=="string"?t.code.toLowerCase():"",o=e&&t.altKey&&!t.shiftKey&&(r==="d"||i==="keyd"),a=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&(r==="f8"||i==="f8");return o||a}function iue(){if(typeof document=="undefined"||document.getElementById(EP))return;const t=document.createElement("style");t.id=EP,t.textContent=`
|
|
1824
1825
|
.${qr} {
|
|
1825
1826
|
position: fixed;
|
|
1826
1827
|
inset: 0;
|
|
@@ -2117,7 +2118,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2117
2118
|
:is(${gi}) .rte-toolbar-item .rte-toolbar-button[data-command="openVersionDiff"] svg{
|
|
2118
2119
|
fill: none;
|
|
2119
2120
|
}
|
|
2120
|
-
`,document.head.appendChild(t)}async function oue(t,e,n){if(n!=null)return n;if(typeof e.getBaselineHtml=="function"){const o=RS(t),a=await Promise.resolve(e.getBaselineHtml({editor:t,editorRoot:o}));if(typeof a=="string")return a}const r=EA.get(t);if(typeof r=="string")return r;if(typeof e.baselineHtml=="string")return e.baselineHtml;const i=OS(t);return EA.set(t,i),i}function aue(t){const e=t.querySelector('button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');e==null||e.focus()}function sue(t,e){if(t.key!=="Tab")return;const n=Array.from(e.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(a=>!a.hasAttribute("disabled"));if(n.length===0)return;const r=n[0],i=n[n.length-1],o=document.activeElement;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}function
|
|
2121
|
+
`,document.head.appendChild(t)}async function oue(t,e,n){if(n!=null)return n;if(typeof e.getBaselineHtml=="function"){const o=RS(t),a=await Promise.resolve(e.getBaselineHtml({editor:t,editorRoot:o}));if(typeof a=="string")return a}const r=EA.get(t);if(typeof r=="string")return r;if(typeof e.baselineHtml=="string")return e.baselineHtml;const i=OS(t);return EA.set(t,i),i}function aue(t){const e=t.querySelector('button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');e==null||e.focus()}function sue(t,e){if(t.key!=="Tab")return;const n=Array.from(e.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(a=>!a.hasAttribute("disabled"));if(n.length===0)return;const r=n[0],i=n[n.length-1],o=document.activeElement;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}function _P(){oy&&(oy(),oy=null)}function DP(t){!t||EA.has(t)||EA.set(t,OS(t))}function cue(t){var e,n;return{baselineHtml:t.baselineHtml,getBaselineHtml:t.getBaselineHtml,mode:t.mode||"word",ignoreWhitespace:t.ignoreWhitespace!==!1,maxTokens:Math.max(200,(e=t.maxTokens)!=null?e:1200),maxMatrixSize:Math.max(5e4,(n=t.maxMatrixSize)!=null?n:1e6),labels:Gle(t.labels)}}function LP(t,e,n){var _;_P(),Lp=t,yw.set(t,e);const r=document.createElement("div");Io(r),r.className=qr,CP(t)&&r.classList.add("rte-version-diff-theme-dark");const i=document.createElement("section");i.className="rte-version-diff-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby","rte-version-diff-title");const o=e.labels;let a=(n==null?void 0:n.mode)||e.mode,s=(_=n==null?void 0:n.ignoreWhitespace)!=null?_:e.ignoreWhitespace,c="inline";i.innerHTML=`
|
|
2121
2122
|
<header class="rte-version-diff-header">
|
|
2122
2123
|
<h2 id="rte-version-diff-title" class="rte-version-diff-title">${Ii(o.title)}</h2>
|
|
2123
2124
|
<div class="rte-version-diff-controls">
|
|
@@ -2166,7 +2167,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2166
2167
|
<small>Shortcut: Ctrl/Cmd + Alt + D (fallback: F8)</small>
|
|
2167
2168
|
<small>Esc: close</small>
|
|
2168
2169
|
</footer>
|
|
2169
|
-
`,r.appendChild(i),document.body.appendChild(r);const l=i.querySelector(".rte-version-diff-select");l.value=a;const u=i.querySelector(".rte-version-diff-ignore-ws"),d=i.querySelector(".rte-version-diff-summary"),f=i.querySelector(".rte-version-diff-inline"),A=i.querySelector('[data-side="baseline"]'),h=i.querySelector('[data-side="current"]');let p=0;const m=()=>{const B=`<p class="rte-version-diff-empty">${Ii(o.loading)}</p>`;f.innerHTML=B,A.innerHTML=B,h.innerHTML=B,d.textContent=""},g=async B=>{var le;p+=1;const I=p;r.classList.toggle("rte-version-diff-theme-dark",C7(t)),m();const R=t.innerHTML;let C="";try{C=await oue(t,e,B!=null?B:n==null?void 0:n.baselineHtml)}catch(O){C=(le=EA.get(t))!=null?le:OS(t)}if(I!==p||!r.isConnected)return;const F=k7(C),v=k7(R),P=B7(F,a,s),W=B7(v,a,s),q=eue(P,W,a,s,e.maxMatrixSize,e.maxTokens),ie=nue(q.segments,o);f.innerHTML=tue(q.segments,o),A.innerHTML=ie.baselineHtml,h.innerHTML=ie.currentHtml;const ne=[`+${q.insertedCount} inserted`,`-${q.deletedCount} deleted`,`${q.equalCount} unchanged`];q.usedFallback&&ne.push(o.largeDocFallback),d.textContent=ne.join(" | ")},b=B=>{c=B,i.querySelectorAll(".rte-version-diff-tab").forEach(I=>{const R=I.getAttribute("data-tab")===B;I.setAttribute("aria-selected",R?"true":"false"),I.tabIndex=R?0:-1}),i.querySelectorAll(".rte-version-diff-panel").forEach(I=>{I.classList.toggle("active",I.getAttribute("data-panel")===B)})},y=()=>{r.removeEventListener("keydown",k,!0),r.removeEventListener("click",x),document.removeEventListener("keydown",w,!0),r.parentNode&&r.parentNode.removeChild(r),oy=null,t.focus({preventScroll:!0})},w=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),y())},x=B=>{B.target===r&&y()},k=B=>{if(B.key==="Escape"){B.preventDefault(),y();return}if(sue(B,i),B.target&&B.target.classList.contains("rte-version-diff-tab")&&(B.key==="ArrowRight"||B.key==="ArrowLeft")){B.preventDefault();const I=c==="inline"?"side":"inline";b(I);const R=i.querySelector(`.rte-version-diff-tab[data-tab="${I}"]`);R==null||R.focus()}};i.addEventListener("click",B=>{const I=B.target,R=I.getAttribute("data-action");if(R==="close"){y();return}if(R==="refresh"){g();return}const C=I.getAttribute("data-tab");(C==="inline"||C==="side")&&b(C)}),l.addEventListener("change",()=>{a=l.value==="line"?"line":"word",g()}),u.addEventListener("change",()=>{s=u.checked,g()}),i.querySelector(".rte-version-diff-set-baseline").addEventListener("click",()=>{EA.set(t,t.innerHTML),g(t.innerHTML)}),r.addEventListener("keydown",k,!0),r.addEventListener("click",x),document.addEventListener("keydown",w,!0),oy=y,aue(i),g()}function lue(t){US=t,!Sp&&(Sp=e=>{if(!rue(e))return;if(document.querySelector(`.${qr}`)){e.preventDefault();return}const n=e.target;if(!!(n!=null&&n.closest("input, textarea, select")))return;const i=NS(void 0,!1);if(!i||i.getAttribute("contenteditable")==="false")return;e.preventDefault(),e.stopPropagation();const o=yw.get(i)||US||t;L7(i,o)},document.addEventListener("keydown",Sp,!0))}function uue(){Sp&&(document.removeEventListener("keydown",Sp,!0),Sp=null,US=null)}function due(){_p||(_p=t=>{const e=t.target,n=e==null?void 0:e.closest(Pd);n&&(Lp=n,D7(n))},document.addEventListener("focusin",_p,!0)),Dp||(Dp=t=>{const n=t.target,r=n==null?void 0:n.closest(Pd);r&&r.getAttribute("contenteditable")!=="false"&&(Lp=r,D7(r))},document.addEventListener("beforeinput",Dp,!0))}function fue(){_p&&(document.removeEventListener("focusin",_p,!0),_p=null),Dp&&(document.removeEventListener("beforeinput",Dp,!0),Dp=null)}const MS=Object.freeze(Object.defineProperty({__proto__:null,VersionDiffPlugin:(t={})=>{const e=cue(t);return iue(),{name:"versionDiff",toolbar:[{id:"versionDiff",label:"Version Diff",command:"openVersionDiff",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><rect x="13.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><path d="M5.5 12h3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path><path d="M15.5 12h3m-1.5-1.5v3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg>'}],commands:{openVersionDiff:(n,r)=>{const i=NS(r);return i?(yw.set(i,e),L7(i,e,n),!0):!1},setVersionDiffBaseline:(n,r)=>{const i=NS(r);if(!i)return!1;yw.set(i,e);const o=typeof n=="string"?n:typeof(n==null?void 0:n.html)=="string"?n.html:i.innerHTML;return EA.set(i,o),!0}},keymap:{"Mod-Alt-d":"openVersionDiff","Mod-Alt-D":"openVersionDiff",F8:"openVersionDiff"},init:()=>{vw+=1,lue(e),due()},destroy:()=>{vw=Math.max(0,vw-1),vw===0&&(_7(),uue(),fue())}}}},Symbol.toStringTag,{value:"Module"})),Ac=".rte-content, .editora-content",hc='.rte-conditional-block[data-conditional-content="true"]',or=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ar=':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)',ri=":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)",mi=":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)",F7="rte-conditional-content-styles",Wt="rte-conditional-dialog-overlay",zn="rte-conditional-floating-toolbar",hl=new WeakMap,PS=new WeakMap,Gi=new WeakMap,CA=new Map,TA=new Map;let ay=null,xw=0,Fp=null,Ip=null,Up=null,Np=null,Rp=null,Op=null,Hd=null,bi=null,Mp=null;const Aue={dialogTitleInsert:"Insert Conditional Content",dialogTitleEdit:"Edit Conditional Content",conditionLabel:"Condition",conditionPlaceholder:'user.role == "admin"',audienceLabel:"Audience (comma separated)",audiencePlaceholder:"all",localeLabel:"Locale (comma separated)",localePlaceholder:"all",elseLabel:"Enable Else Block",saveText:"Save",cancelText:"Cancel",blockIfLabel:"IF",blockElseLabel:"ELSE",allAudiencesText:"all audiences",allLocalesText:"all locales"};function Ui(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qd(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function I7(t){return!t||t.length===0?"":t.join(", ")}function Pp(t){return t?t.map(e=>e.trim()).filter(Boolean):[]}function hue(t){return{...Aue,...t||{}}}function xu(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function sy(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function Ew(t){if(!t)return!1;const e=t.getAttribute("data-theme")||t.getAttribute("theme");return e&&e.toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark")}function pue(t){const e=sy(t);if(Ew(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Ew(n)?!0:Ew(document.documentElement)||Ew(document.body)}function Cw(t){if(!t)return!1;const e=t.getAttribute("data-theme")||t.getAttribute("theme");return e&&e.toLowerCase()==="acme"?!0:t.classList.contains("editora-theme-acme")||t.classList.contains("rte-theme-acme")}function gue(t){const e=sy(t);if(Cw(e))return!0;const n=e.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");return Cw(n)?!0:Cw(document.documentElement)||Cw(document.body)}function mue(t){return pue(t)?"dark":gue(t)?"acme":"light"}function Tw(t,e){const n=mue(e);t.classList.remove("rte-conditional-theme-dark","rte-conditional-theme-acme"),n==="dark"?t.classList.add("rte-conditional-theme-dark"):n==="acme"&&t.classList.add("rte-conditional-theme-acme")}function pl(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(Ac))return i;const o=i.querySelector(Ac);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(Ac);if(a)return a}const r=document.activeElement;if(r){if(r.matches(Ac))return r;const i=r.closest(Ac);if(i)return i}return bi&&bi.isConnected?bi:e?document.querySelector(Ac):null}function U7(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function HS(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function N7(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function R7(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function kw(t,e){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),HS(t,n)}function QS(t,e){if(e)return e.split(".").filter(Boolean).reduce((n,r)=>{if(n!=null&&typeof n=="object")return n[r]},t)}function bue(t){const e=t.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;const n=Number(e);if(!Number.isNaN(n)&&e!=="")return n;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch(r){return e}return e}function yue(t,e){const n=t.trim();if(!n)return!0;if(n.startsWith("!")){const l=n.slice(1).trim();return!QS(e,l)}const r=n.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);if(!r)return!!QS(e,n);const[,i,o,a]=r,s=QS(e,i),c=bue(a);switch(o){case"==":return s==c;case"!=":return s!=c;case">":return Number(s)>Number(c);case"<":return Number(s)<Number(c);case">=":return Number(s)>=Number(c);case"<=":return Number(s)<=Number(c);case"in":return Array.isArray(c)?c.some(l=>l==s):typeof c=="string"?c.split(",").map(l=>l.trim()).includes(String(s)):!1;case"contains":case"~=":return Array.isArray(s)?s.some(l=>String(l).toLowerCase()===String(c).toLowerCase()):typeof s=="string"?s.toLowerCase().includes(String(c).toLowerCase()):!1;default:return!1}}function vue(){if(typeof document=="undefined"||document.getElementById(F7))return;const t=document.createElement("style");t.id=F7,t.textContent=`
|
|
2170
|
+
`,r.appendChild(i),document.body.appendChild(r);const l=i.querySelector(".rte-version-diff-select");l.value=a;const u=i.querySelector(".rte-version-diff-ignore-ws"),d=i.querySelector(".rte-version-diff-summary"),f=i.querySelector(".rte-version-diff-inline"),A=i.querySelector('[data-side="baseline"]'),h=i.querySelector('[data-side="current"]');let p=0;const m=()=>{const B=`<p class="rte-version-diff-empty">${Ii(o.loading)}</p>`;f.innerHTML=B,A.innerHTML=B,h.innerHTML=B,d.textContent=""},g=async B=>{var le;p+=1;const I=p;r.classList.toggle("rte-version-diff-theme-dark",CP(t)),m();const R=t.innerHTML;let C="";try{C=await oue(t,e,B!=null?B:n==null?void 0:n.baselineHtml)}catch(O){C=(le=EA.get(t))!=null?le:OS(t)}if(I!==p||!r.isConnected)return;const F=kP(C),v=kP(R),P=BP(F,a,s),W=BP(v,a,s),q=eue(P,W,a,s,e.maxMatrixSize,e.maxTokens),ie=nue(q.segments,o);f.innerHTML=tue(q.segments,o),A.innerHTML=ie.baselineHtml,h.innerHTML=ie.currentHtml;const ne=[`+${q.insertedCount} inserted`,`-${q.deletedCount} deleted`,`${q.equalCount} unchanged`];q.usedFallback&&ne.push(o.largeDocFallback),d.textContent=ne.join(" | ")},b=B=>{c=B,i.querySelectorAll(".rte-version-diff-tab").forEach(I=>{const R=I.getAttribute("data-tab")===B;I.setAttribute("aria-selected",R?"true":"false"),I.tabIndex=R?0:-1}),i.querySelectorAll(".rte-version-diff-panel").forEach(I=>{I.classList.toggle("active",I.getAttribute("data-panel")===B)})},y=()=>{r.removeEventListener("keydown",k,!0),r.removeEventListener("click",x),document.removeEventListener("keydown",w,!0),r.parentNode&&r.parentNode.removeChild(r),oy=null,t.focus({preventScroll:!0})},w=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),y())},x=B=>{B.target===r&&y()},k=B=>{if(B.key==="Escape"){B.preventDefault(),y();return}if(sue(B,i),B.target&&B.target.classList.contains("rte-version-diff-tab")&&(B.key==="ArrowRight"||B.key==="ArrowLeft")){B.preventDefault();const I=c==="inline"?"side":"inline";b(I);const R=i.querySelector(`.rte-version-diff-tab[data-tab="${I}"]`);R==null||R.focus()}};i.addEventListener("click",B=>{const I=B.target,R=I.getAttribute("data-action");if(R==="close"){y();return}if(R==="refresh"){g();return}const C=I.getAttribute("data-tab");(C==="inline"||C==="side")&&b(C)}),l.addEventListener("change",()=>{a=l.value==="line"?"line":"word",g()}),u.addEventListener("change",()=>{s=u.checked,g()}),i.querySelector(".rte-version-diff-set-baseline").addEventListener("click",()=>{EA.set(t,t.innerHTML),g(t.innerHTML)}),r.addEventListener("keydown",k,!0),r.addEventListener("click",x),document.addEventListener("keydown",w,!0),oy=y,aue(i),g()}function lue(t){US=t,!Sp&&(Sp=e=>{if(!rue(e))return;if(document.querySelector(`.${qr}`)){e.preventDefault();return}const n=e.target;if(!!(n!=null&&n.closest("input, textarea, select")))return;const i=NS(void 0,!1);if(!i||i.getAttribute("contenteditable")==="false")return;e.preventDefault(),e.stopPropagation();const o=yw.get(i)||US||t;LP(i,o)},document.addEventListener("keydown",Sp,!0))}function uue(){Sp&&(document.removeEventListener("keydown",Sp,!0),Sp=null,US=null)}function due(){_p||(_p=t=>{const e=t.target,n=e==null?void 0:e.closest(Pd);n&&(Lp=n,DP(n))},document.addEventListener("focusin",_p,!0)),Dp||(Dp=t=>{const n=t.target,r=n==null?void 0:n.closest(Pd);r&&r.getAttribute("contenteditable")!=="false"&&(Lp=r,DP(r))},document.addEventListener("beforeinput",Dp,!0))}function fue(){_p&&(document.removeEventListener("focusin",_p,!0),_p=null),Dp&&(document.removeEventListener("beforeinput",Dp,!0),Dp=null)}const MS=Object.freeze(Object.defineProperty({__proto__:null,VersionDiffPlugin:(t={})=>{const e=cue(t);return iue(),{name:"versionDiff",toolbar:[{id:"versionDiff",label:"Version Diff",command:"openVersionDiff",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><rect x="13.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><path d="M5.5 12h3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path><path d="M15.5 12h3m-1.5-1.5v3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg>'}],commands:{openVersionDiff:(n,r)=>{const i=NS(r);return i?(yw.set(i,e),LP(i,e,n),!0):!1},setVersionDiffBaseline:(n,r)=>{const i=NS(r);if(!i)return!1;yw.set(i,e);const o=typeof n=="string"?n:typeof(n==null?void 0:n.html)=="string"?n.html:i.innerHTML;return EA.set(i,o),!0}},keymap:{"Mod-Alt-d":"openVersionDiff","Mod-Alt-D":"openVersionDiff",F8:"openVersionDiff"},init:()=>{vw+=1,lue(e),due()},destroy:()=>{vw=Math.max(0,vw-1),vw===0&&(_P(),uue(),fue())}}}},Symbol.toStringTag,{value:"Module"})),Ac=".rte-content, .editora-content",hc='.rte-conditional-block[data-conditional-content="true"]',or=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ar=':is([data-theme="acme"], .editora-theme-acme, .rte-theme-acme)',ri=":is(.rte-content.rte-conditional-theme-dark, .editora-content.rte-conditional-theme-dark)",mi=":is(.rte-content.rte-conditional-theme-acme, .editora-content.rte-conditional-theme-acme)",FP="rte-conditional-content-styles",Wt="rte-conditional-dialog-overlay",zn="rte-conditional-floating-toolbar",hl=new WeakMap,PS=new WeakMap,Gi=new WeakMap,CA=new Map,TA=new Map;let ay=null,xw=0,Fp=null,Ip=null,Up=null,Np=null,Rp=null,Op=null,Hd=null,bi=null,Mp=null;const Aue={dialogTitleInsert:"Insert Conditional Content",dialogTitleEdit:"Edit Conditional Content",conditionLabel:"Condition",conditionPlaceholder:'user.role == "admin"',audienceLabel:"Audience (comma separated)",audiencePlaceholder:"all",localeLabel:"Locale (comma separated)",localePlaceholder:"all",elseLabel:"Enable Else Block",saveText:"Save",cancelText:"Cancel",blockIfLabel:"IF",blockElseLabel:"ELSE",allAudiencesText:"all audiences",allLocalesText:"all locales"};function Ui(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qd(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function IP(t){return!t||t.length===0?"":t.join(", ")}function Pp(t){return t?t.map(e=>e.trim()).filter(Boolean):[]}function hue(t){return{...Aue,...t||{}}}function xu(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function sy(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function Ew(t){if(!t)return!1;const e=t.getAttribute("data-theme")||t.getAttribute("theme");return e&&e.toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark")}function pue(t){const e=sy(t);if(Ew(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Ew(n)?!0:Ew(document.documentElement)||Ew(document.body)}function Cw(t){if(!t)return!1;const e=t.getAttribute("data-theme")||t.getAttribute("theme");return e&&e.toLowerCase()==="acme"?!0:t.classList.contains("editora-theme-acme")||t.classList.contains("rte-theme-acme")}function gue(t){const e=sy(t);if(Cw(e))return!0;const n=e.closest("[data-theme], [theme], .editora-theme-acme, .rte-theme-acme");return Cw(n)?!0:Cw(document.documentElement)||Cw(document.body)}function mue(t){return pue(t)?"dark":gue(t)?"acme":"light"}function Tw(t,e){const n=mue(e);t.classList.remove("rte-conditional-theme-dark","rte-conditional-theme-acme"),n==="dark"?t.classList.add("rte-conditional-theme-dark"):n==="acme"&&t.classList.add("rte-conditional-theme-acme")}function pl(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(Ac))return i;const o=i.querySelector(Ac);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(Ac);if(a)return a}const r=document.activeElement;if(r){if(r.matches(Ac))return r;const i=r.closest(Ac);if(i)return i}return bi&&bi.isConnected?bi:e?document.querySelector(Ac):null}function UP(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function HS(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function NP(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function RP(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function kw(t,e){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),HS(t,n)}function QS(t,e){if(e)return e.split(".").filter(Boolean).reduce((n,r)=>{if(n!=null&&typeof n=="object")return n[r]},t)}function bue(t){const e=t.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;const n=Number(e);if(!Number.isNaN(n)&&e!=="")return n;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch(r){return e}return e}function yue(t,e){const n=t.trim();if(!n)return!0;if(n.startsWith("!")){const l=n.slice(1).trim();return!QS(e,l)}const r=n.match(/^([a-zA-Z_$][\w.$]*)\s*(==|!=|>=|<=|>|<|in|contains|~=)\s*(.+)$/);if(!r)return!!QS(e,n);const[,i,o,a]=r,s=QS(e,i),c=bue(a);switch(o){case"==":return s==c;case"!=":return s!=c;case">":return Number(s)>Number(c);case"<":return Number(s)<Number(c);case">=":return Number(s)>=Number(c);case"<=":return Number(s)<=Number(c);case"in":return Array.isArray(c)?c.some(l=>l==s):typeof c=="string"?c.split(",").map(l=>l.trim()).includes(String(s)):!1;case"contains":case"~=":return Array.isArray(s)?s.some(l=>String(l).toLowerCase()===String(c).toLowerCase()):typeof s=="string"?s.toLowerCase().includes(String(c).toLowerCase()):!1;default:return!1}}function vue(){if(typeof document=="undefined"||document.getElementById(FP))return;const t=document.createElement("style");t.id=FP,t.textContent=`
|
|
2170
2171
|
.rte-conditional-block {
|
|
2171
2172
|
border: 1px solid #dbe3ec;
|
|
2172
2173
|
border-radius: 8px;
|
|
@@ -2756,21 +2757,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2756
2757
|
color: #8b1f2f;
|
|
2757
2758
|
background: #fff4f6;
|
|
2758
2759
|
}
|
|
2759
|
-
`,document.head.appendChild(t)}function wue(t){return{defaultCondition:t.defaultCondition||"",defaultAudience:Pp(t.defaultAudience||[]),defaultLocale:Pp(t.defaultLocale||[]),enableElseByDefault:t.enableElseByDefault===!0,labels:hue(t.labels),context:t.context,getContext:t.getContext,currentAudience:t.currentAudience,currentLocale:t.currentLocale,evaluateCondition:t.evaluateCondition||yue}}function
|
|
2760
|
+
`,document.head.appendChild(t)}function wue(t){return{defaultCondition:t.defaultCondition||"",defaultAudience:Pp(t.defaultAudience||[]),defaultLocale:Pp(t.defaultLocale||[]),enableElseByDefault:t.enableElseByDefault===!0,labels:hue(t.labels),context:t.context,getContext:t.getContext,currentAudience:t.currentAudience,currentLocale:t.currentLocale,evaluateCondition:t.evaluateCondition||yue}}function OP(){ay&&(ay.cleanup(),ay=null)}function xue(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Hp(t,e){t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false");const n=t.querySelector(".rte-conditional-header");n&&(n.setAttribute("contenteditable","false"),n.setAttribute("tabindex","0"),n.setAttribute("role","button"),n.setAttribute("aria-label","Edit conditional rule"));const r=t.querySelector(".rte-conditional-else-label");r&&r.setAttribute("contenteditable","false"),Tue(t,!e)}function Eue(t){const e=t.querySelector('.rte-conditional-body[data-slot="if"]');if(!e)return;const n=new Set,r=t.querySelector(".rte-conditional-header"),i=t.querySelector(".rte-conditional-else-label"),o=t.querySelector('.rte-conditional-body[data-slot="else"]');r&&n.add(r),n.add(e),i&&n.add(i),o&&n.add(o),Array.from(t.childNodes).forEach(s=>{if(!(s instanceof HTMLElement&&n.has(s))){if(s.nodeType===Node.TEXT_NODE&&!(s.textContent||"").trim()){s.remove();return}e.appendChild(s)}})}function Qp(t){const e=window.getSelection();if(e&&e.rangeCount>0){const i=e.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,a=o==null?void 0:o.closest(hc);if(a&&t.contains(a))return a}const n=document.activeElement,r=n==null?void 0:n.closest(hc);return r&&t.contains(r)?r:null}function $S(t,e){let n=t.querySelector(".rte-conditional-else-label"),r=t.querySelector('.rte-conditional-body[data-slot="else"]');n||(n=document.createElement("div"),n.className="rte-conditional-else-label",n.setAttribute("contenteditable","false"),n.innerHTML=`
|
|
2760
2761
|
<span class="rte-conditional-chip rte-conditional-chip-else">${Ui(e.blockElseLabel)}</span>
|
|
2761
2762
|
<span class="rte-conditional-summary">Else branch</span>
|
|
2762
2763
|
`,t.appendChild(n)),r||(r=document.createElement("div"),r.className="rte-conditional-body rte-conditional-else-body",r.setAttribute("data-slot","else"),r.innerHTML="<p><br></p>",t.appendChild(r))}function Cue(t,e){t.setAttribute("data-has-else",e?"true":"false");const n=t.querySelector(".rte-conditional-else-label"),r=t.querySelector('.rte-conditional-body[data-slot="else"]');n&&n.classList.toggle("rte-conditional-hidden",!e),r&&r.classList.toggle("rte-conditional-hidden",!e)}function Tue(t,e){Array.from(t.querySelectorAll(".rte-conditional-body")).forEach(r=>{r.setAttribute("contenteditable",e?"true":"false")}),t.setAttribute("contenteditable","false")}function zS(t,e){const n=t.getAttribute("data-condition")||"",r=Qd(t.getAttribute("data-audience")),i=Qd(t.getAttribute("data-locale"));let o=t.querySelector(".rte-conditional-header");o||(o=document.createElement("div"),o.className="rte-conditional-header",t.prepend(o)),o.setAttribute("contenteditable","false"),o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.setAttribute("aria-label","Edit conditional rule");const a=n||"(always true)",s=r.length>0?r.join(", "):e.allAudiencesText,c=i.length>0?i.join(", "):e.allLocalesText;if(o.innerHTML=`
|
|
2763
2764
|
<span class="rte-conditional-chip">${Ui(e.blockIfLabel)}</span>
|
|
2764
2765
|
<span class="rte-conditional-summary">${Ui(a)}</span>
|
|
2765
2766
|
<span class="rte-conditional-meta">${Ui(s)} · ${Ui(c)}</span>
|
|
2766
|
-
`,!t.querySelector('.rte-conditional-body[data-slot="if"]')){const d=document.createElement("div");d.className="rte-conditional-body",d.setAttribute("data-slot","if"),d.innerHTML="<p><br></p>",t.insertBefore(d,t.children[1]||null)}const u=t.getAttribute("data-has-else")==="true";u&&$S(t,e),Eue(t),Cue(t,u)}function
|
|
2767
|
+
`,!t.querySelector('.rte-conditional-body[data-slot="if"]')){const d=document.createElement("div");d.className="rte-conditional-body",d.setAttribute("data-slot","if"),d.innerHTML="<p><br></p>",t.insertBefore(d,t.children[1]||null)}const u=t.getAttribute("data-has-else")==="true";u&&$S(t,e),Eue(t),Cue(t,u)}function MP(t,e){const n=document.createElement("section");n.className="rte-conditional-block",n.setAttribute("data-conditional-content","true"),n.setAttribute("data-condition",(t.condition||"").trim()),n.setAttribute("data-audience",Pp(t.audience).join(",")),n.setAttribute("data-locale",Pp(t.locale).join(",")),n.setAttribute("data-has-else",t.hasElse?"true":"false"),n.setAttribute("role","group"),n.setAttribute("aria-label","Conditional content block"),n.setAttribute("contenteditable","false"),n.setAttribute("spellcheck","false");const r=document.createElement("div");r.className="rte-conditional-header",r.setAttribute("contenteditable","false");const i=document.createElement("div");return i.className="rte-conditional-body",i.setAttribute("data-slot","if"),i.innerHTML="<p><br></p>",n.appendChild(r),n.appendChild(i),t.hasElse&&$S(n,e),zS(n,e),Hp(n,!1),n}function kue(t,e){if(e)try{if(!t.isConnected)return;const n=t.contains(e.startContainer),r=t.contains(e.endContainer);if(!n||!r)return;HS(t,e)}catch(n){}}function Bue(t){return(t.textContent||"").replace(/\u200B/g,"").trim().length>0?!0:t.querySelector("img, video, table, iframe, hr, pre, blockquote, ul, ol")!==null}const PP=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER"]);function HP(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&PP.has(n.tagName))return n;n=n.parentNode}return null}function Sue(t){let e=null;Array.from(t.childNodes).forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE&&PP.has(n.tagName)){e=null;return}n.nodeType===Node.TEXT_NODE&&!(n.textContent||"").trim()||(e||(e=document.createElement("p"),t.insertBefore(e,n)),e.appendChild(n))})}function QP(t,e,n){let r=null;r||(r=UP(t)),r||(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));let i=null;r.collapsed||(i=r.extractContents());const o=HP(r.endContainer,t)||HP(r.startContainer,t);o&&o.parentNode?o.parentNode.insertBefore(e,o.nextSibling):r.insertNode(e);const a=e.querySelector('.rte-conditional-body[data-slot="if"]');a&&i&&Bue(i)&&(a.innerHTML="",a.appendChild(i)),Sue(t),a?kw(t,a):kw(t,e),t.normalize()}function _ue(t){return{condition:t.getAttribute("data-condition")||"",audience:Qd(t.getAttribute("data-audience")),locale:Qd(t.getAttribute("data-locale")),hasElse:t.getAttribute("data-has-else")==="true"}}function Due(t,e,n){t.setAttribute("data-condition",(e.condition||"").trim()),t.setAttribute("data-audience",Pp(e.audience).join(",")),t.setAttribute("data-locale",Pp(e.locale).join(",")),t.setAttribute("data-has-else",e.hasElse?"true":"false"),e.hasElse&&$S(t,n),zS(t,n),Hp(t,t.classList.contains("rte-conditional-preview"))}function $p(t,e){Tw(t,t);const n=Array.from(t.querySelectorAll(hc)),r=hl.get(t)===!0;return n.forEach(i=>{i.classList.add("rte-conditional-block"),i.setAttribute("data-conditional-content","true"),i.hasAttribute("data-condition")||i.setAttribute("data-condition",""),i.hasAttribute("data-audience")||i.setAttribute("data-audience",""),i.hasAttribute("data-locale")||i.setAttribute("data-locale",""),i.hasAttribute("data-has-else")||i.setAttribute("data-has-else","false"),i.setAttribute("role","group"),i.setAttribute("aria-label","Conditional content block"),i.setAttribute("contenteditable","false"),i.setAttribute("spellcheck","false"),zS(i,e),Hp(i,r)}),n}async function Lue(t,e){const n=PS.get(t);if(n)return n;if(typeof e.getContext=="function")try{const r=sy(t),i=await Promise.resolve(e.getContext({editor:t,editorRoot:r}));if(i&&typeof i=="object")return i}catch(r){return{}}if(typeof e.context=="function")try{const r=e.context();if(r&&typeof r=="object")return r}catch(r){return{}}return e.context&&typeof e.context=="object"?e.context:{}}function Bw(t){return Array.isArray(t)?t.map(e=>e.trim().toLowerCase()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function $P(t,e){return t.length===0||t.includes("all")?!0:e.length===0?!1:t.some(n=>e.includes(n))}async function zp(t,e,n){var A,h,p,m;const r=e.labels,i=$p(t,r);if(hl.set(t,n),zP(t,n),sy(t).classList.toggle("rte-conditional-preview-on",n),!n){i.forEach(g=>{g.classList.remove("rte-conditional-preview"),Hp(g,!1);const b=g.querySelector('.rte-conditional-body[data-slot="if"]'),y=g.querySelector('.rte-conditional-body[data-slot="else"]'),w=g.querySelector(".rte-conditional-else-label"),x=g.getAttribute("data-has-else")==="true";b&&(b.classList.remove("rte-conditional-hidden"),b.removeAttribute("aria-hidden")),y&&(y.classList.toggle("rte-conditional-hidden",!x),y.setAttribute("aria-hidden",x?"false":"true")),w&&w.classList.toggle("rte-conditional-hidden",!x)});return}const a=await Lue(t,e),s=Bw(e.currentAudience),c=Bw(e.currentLocale),l=Bw((h=a.audience)!=null?h:(A=a.user)==null?void 0:A.audience),u=Bw((m=a.locale)!=null?m:(p=a.user)==null?void 0:p.locale),d=s.length>0?s:l,f=c.length>0?c:u;i.forEach(g=>{const b=g.getAttribute("data-condition")||"",y=Qd(g.getAttribute("data-audience")).map(F=>F.toLowerCase()),w=Qd(g.getAttribute("data-locale")).map(F=>F.toLowerCase()),x=g.getAttribute("data-has-else")==="true",k=e.evaluateCondition(b,a),T=$P(y,d),_=$P(w,f),B=k&&T&&_,I=g.querySelector('.rte-conditional-body[data-slot="if"]'),R=g.querySelector('.rte-conditional-body[data-slot="else"]'),C=g.querySelector(".rte-conditional-else-label");if(g.classList.add("rte-conditional-preview"),Hp(g,!0),I&&(I.classList.toggle("rte-conditional-hidden",!B),I.setAttribute("aria-hidden",B?"false":"true")),R){const F=x&&!B;R.classList.toggle("rte-conditional-hidden",!F),R.setAttribute("aria-hidden",F?"false":"true")}if(C){const F=x&&!B;C.classList.toggle("rte-conditional-hidden",!F)}})}function zP(t,e){const n=sy(t);Array.from(n.querySelectorAll('[data-command="toggleConditionalPreview"], [data-command="conditionalPreview"]')).forEach(i=>{i.setAttribute("data-active",e?"true":"false"),i.classList.toggle("active",e),i.setAttribute("aria-pressed",e?"true":"false")})}function Fue(t){const e=CA.get(t);if(e&&e.isConnected)return e;const n=document.createElement("div");return n.className=zn,n.setAttribute("role","toolbar"),n.setAttribute("aria-label","Conditional block actions"),n.innerHTML=`
|
|
2767
2768
|
<button type="button" class="rte-conditional-float-btn" data-action="edit" title="Edit Condition" aria-label="Edit Condition">
|
|
2768
2769
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 17.3V20h2.7l9.7-9.7-2.7-2.7L4 17.3Zm14.7-9.4a1 1 0 0 0 0-1.4l-1.2-1.2a1 1 0 0 0-1.4 0l-1.1 1.1 2.7 2.7 1-1.2Z" fill="currentColor"></path></svg>
|
|
2769
2770
|
</button>
|
|
2770
2771
|
<button type="button" class="rte-conditional-float-btn" data-action="delete" title="Delete Block" aria-label="Delete Block">
|
|
2771
2772
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 4h8l1 2h4v2H3V6h4l1-2Zm1 6h2v8H9v-8Zm4 0h2v8h-2v-8Z" fill="currentColor"></path></svg>
|
|
2772
2773
|
</button>
|
|
2773
|
-
`,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("click",r=>{var c;const i=r.target,o=(c=i==null?void 0:i.closest("[data-action]"))==null?void 0:c.getAttribute("data-action");if(!o)return;const a=Gi.get(t)||Mp;if(!a)return;const s=TA.get(t);if(!(!s||!t.contains(s))){if(o==="edit"){Ds(t,a,"edit",void 0,s);return}o==="delete"&&(
|
|
2774
|
+
`,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("click",r=>{var c;const i=r.target,o=(c=i==null?void 0:i.closest("[data-action]"))==null?void 0:c.getAttribute("data-action");if(!o)return;const a=Gi.get(t)||Mp;if(!a)return;const s=TA.get(t);if(!(!s||!t.contains(s))){if(o==="edit"){Ds(t,a,"edit",void 0,s);return}o==="delete"&&(qP(t,s),TA.set(t,null),kA(t))}}),document.body.appendChild(n),CA.set(t,n),n}function kA(t){const e=CA.get(t);e&&e.classList.remove("show")}function jP(t,e){const n=e.getBoundingClientRect();t.style.left="0px",t.style.top="0px",t.classList.add("show");const r=t.getBoundingClientRect(),i=8,o=window.innerWidth,a=window.innerHeight;let s=n.top-r.height-i;s<i&&(s=n.bottom+i),s=Math.min(s,a-r.height-i);let c=n.right-r.width;c=Math.max(i,Math.min(c,o-r.width-i)),t.style.left=`${c}px`,t.style.top=`${s}px`}function Sw(t,e){const n=Fue(t);Tw(n,t),TA.set(t,e),jP(n,e)}function $d(t){const e=Gi.get(t)||Mp;if(!e)return;const n=Qp(t);if(!n||!t.contains(n)||xu(t)){TA.set(t,null),kA(t);return}$p(t,e.labels),Sw(t,n)}function Iue(){CA.forEach((t,e)=>{if(!e.isConnected||!t.isConnected){t.remove(),CA.delete(e),TA.delete(e);return}if(!t.classList.contains("show"))return;Tw(t,e);const n=TA.get(e);if(!n||!e.contains(n)){kA(e);return}jP(t,n)})}function qP(t,e){if(!t.contains(e))return!1;const n=t.innerHTML,r=e.parentNode,i=e.nextSibling;e.remove(),r===t&&t.innerHTML.trim()===""&&(t.innerHTML="<p><br></p>");const o=document.createRange();return i&&t.contains(i)?o.setStartBefore(i):(o.selectNodeContents(t),o.collapse(!1)),o.collapse(!0),HS(t,o),NP(t),RP(t,n),!0}function WP(t,e,n){const r=t.cloneRange(),i=document.createRange();return i.selectNodeContents(e),i.collapse(n==="start"),r.startContainer===i.startContainer&&r.startOffset===i.startOffset&&r.endContainer===i.endContainer&&r.endOffset===i.endOffset}function Ds(t,e,n,r,i){var B,I,R,C;OP();const o=e.labels,a=n==="insert"?UP(t):null,s=document.createElement("div");Io(s),s.className=Wt,Tw(s,t);const c=document.createElement("section");c.className="rte-conditional-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","rte-conditional-dialog-title");const l=i?_ue(i):void 0,u=r||l||{},d=(B=u.condition)!=null?B:e.defaultCondition,f=(I=u.audience)!=null?I:e.defaultAudience,A=(R=u.locale)!=null?R:e.defaultLocale,h=(C=u.hasElse)!=null?C:e.enableElseByDefault;c.innerHTML=`
|
|
2774
2775
|
<header class="rte-conditional-dialog-header">
|
|
2775
2776
|
<h2 id="rte-conditional-dialog-title" class="rte-conditional-dialog-title">${Ui(n==="edit"?o.dialogTitleEdit:o.dialogTitleInsert)}</h2>
|
|
2776
2777
|
<button type="button" class="rte-conditional-btn" data-action="cancel" aria-label="${Ui(o.cancelText)}">✕</button>
|
|
@@ -2782,11 +2783,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2782
2783
|
</div>
|
|
2783
2784
|
<div class="rte-conditional-field">
|
|
2784
2785
|
<label for="rte-conditional-audience">${Ui(o.audienceLabel)}</label>
|
|
2785
|
-
<input id="rte-conditional-audience" class="rte-conditional-input-audience" type="text" value="${Ui(
|
|
2786
|
+
<input id="rte-conditional-audience" class="rte-conditional-input-audience" type="text" value="${Ui(IP(f))}" placeholder="${Ui(o.audiencePlaceholder)}" />
|
|
2786
2787
|
</div>
|
|
2787
2788
|
<div class="rte-conditional-field">
|
|
2788
2789
|
<label for="rte-conditional-locale">${Ui(o.localeLabel)}</label>
|
|
2789
|
-
<input id="rte-conditional-locale" class="rte-conditional-input-locale" type="text" value="${Ui(
|
|
2790
|
+
<input id="rte-conditional-locale" class="rte-conditional-input-locale" type="text" value="${Ui(IP(A))}" placeholder="${Ui(o.localePlaceholder)}" />
|
|
2790
2791
|
</div>
|
|
2791
2792
|
<label class="rte-conditional-checkbox">
|
|
2792
2793
|
<input class="rte-conditional-input-else" type="checkbox" ${h?"checked":""} />
|
|
@@ -2798,7 +2799,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2798
2799
|
<button type="button" class="rte-conditional-btn" data-action="cancel">${Ui(o.cancelText)}</button>
|
|
2799
2800
|
<button type="button" class="rte-conditional-btn rte-conditional-btn-primary" data-action="save">${Ui(o.saveText)}</button>
|
|
2800
2801
|
</footer>
|
|
2801
|
-
`,s.appendChild(c),document.body.appendChild(s);const p=c.querySelector(".rte-conditional-input-condition"),m=c.querySelector(".rte-conditional-input-audience"),g=c.querySelector(".rte-conditional-input-locale"),b=c.querySelector(".rte-conditional-input-else"),y=()=>{s.removeEventListener("click",x),s.removeEventListener("keydown",_,!0),document.removeEventListener("keydown",w,!0),s.parentNode&&s.parentNode.removeChild(s),ay=null,t.focus({preventScroll:!0}),$d(t)},w=F=>{F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),y())},x=F=>{F.target===s&&y()},k=F=>{if(F.key!=="Tab")return;const v=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(v.length===0)return;const P=v[0],W=v[v.length-1],q=document.activeElement;if(F.shiftKey&&q===P){F.preventDefault(),W.focus();return}!F.shiftKey&&q===W&&(F.preventDefault(),P.focus())},T=async()=>{var W;const F={condition:((W=p==null?void 0:p.value)==null?void 0:W.trim())||"",audience:Qd(m==null?void 0:m.value),locale:Qd(g==null?void 0:g.value),hasElse:(b==null?void 0:b.checked)||!1},v=t.innerHTML;if(i)Due(i,F,o),Hp(i,hl.get(t)===!0);else{kue(t,a);const q=M7(F,o);try{Q7(t,q)}catch(ie){t.appendChild(q);const ne=q.querySelector('.rte-conditional-body[data-slot="if"]');ne?kw(t,ne):kw(t,q)}}hl.get(t)===!0&&await zp(t,e,!0),N7(t),R7(t,v),$d(t),y()},_=F=>{if(F.key==="Escape"){F.preventDefault(),y();return}k(F),F.key==="Enter"&&!F.shiftKey&&F.target instanceof HTMLInputElement&&(F.preventDefault(),T())};c.addEventListener("click",F=>{const P=F.target.getAttribute("data-action");if(P==="cancel"){y();return}P==="save"&&T()}),s.addEventListener("click",x),s.addEventListener("keydown",_,!0),document.addEventListener("keydown",w,!0),ay={cleanup:y},p==null||p.focus()}function Uue(t){const e=t.metaKey||t.ctrlKey,r=(typeof t.key=="string"?t.key:"").toLowerCase(),i=typeof t.code=="string"?t.code.toLowerCase():"",o=e&&t.altKey&&t.shiftKey&&(r==="c"||i==="keyc"),a=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&(r==="f9"||i==="f9");return o||a}function Nue(t){const e=t.metaKey||t.ctrlKey,r=(typeof t.key=="string"?t.key:"").toLowerCase(),i=typeof t.code=="string"?t.code.toLowerCase():"",o=e&&t.altKey&&t.shiftKey&&(r==="p"||i==="keyp"),a=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&(r==="f10"||i==="f10");return o||a}function Rue(t){Mp=t,Ip||(Ip=e=>{const n=e.target,r=n==null?void 0:n.closest(Ac);if(!r)return;bi=r,Gi.has(r)||Gi.set(r,t);const i=Gi.get(r)||t;$p(r,i.labels),z7(r,hl.get(r)===!0),$d(r)},document.addEventListener("focusin",Ip,!0)),Fp||(Fp=e=>{var u;if(document.querySelector(`.${Wt}`))return;const r=e.target;if(!!(r!=null&&r.closest("input, textarea, select")))return;const a=(r==null?void 0:r.closest(Ac))||pl(void 0,!1)||bi;if(!a||xu(a))return;const s=Gi.get(a)||Mp||t,c=document.activeElement,l=(r==null?void 0:r.closest(".rte-conditional-header"))||(c==null?void 0:c.closest(".rte-conditional-header"));if(l&&(e.key==="Enter"||e.key===" ")){const d=l.closest(hc);if(d&&a.contains(d)){e.preventDefault(),e.stopPropagation(),Ds(a,s,"edit",void 0,d);return}}if(Uue(e)){e.preventDefault(),e.stopPropagation();const d=Qp(a);d?Ds(a,s,"edit",void 0,d):Ds(a,s,"insert");return}if(Nue(e)){e.preventDefault(),e.stopPropagation();const d=hl.get(a)!==!0;zp(a,s,d),$d(a);return}if((e.key==="Backspace"||e.key==="Delete")&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const d=window.getSelection();if(!d||d.rangeCount===0)return;const f=d.getRangeAt(0);if(!f.collapsed||!a.contains(f.commonAncestorContainer))return;const A=(u=xue(f.startContainer))==null?void 0:u.closest(".rte-conditional-body");if(!A||!a.contains(A))return;if(e.key==="Backspace"&&W7(f,A,"start")){e.preventDefault();return}if(e.key==="Delete"&&W7(f,A,"end")){e.preventDefault();return}}},document.addEventListener("keydown",Fp,!0)),Np||(Np=e=>{const n=e.target;if(!n||n.closest(`.${zn}`))return;const r=n.closest(Ac);if(!r){bi&&kA(bi);return}if(xu(r))return;bi=r,Gi.has(r)||Gi.set(r,t);const i=n.closest(hc);if(!i){kA(r);return}requestAnimationFrame(()=>{!r.isConnected||!r.contains(i)||Sw(r,i)})},document.addEventListener("mousedown",Np,!0)),Up||(Up=e=>{const n=e.target;if(!n||n.closest(`.${zn}`))return;const r=n.closest(Ac);if(!r){bi&&kA(bi);return}if(xu(r))return;bi=r,Gi.has(r)||Gi.set(r,t);const i=Gi.get(r)||t,o=n.closest(hc),a=!!n.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");if(o&&a){e.preventDefault(),e.stopPropagation(),Ds(r,i,"edit",void 0,o),Sw(r,o);return}o?Sw(r,o):kA(r)},document.addEventListener("click",Up,!0)),Rp||(Rp=()=>{const e=pl(void 0,!1)||bi;e&&e.isConnected&&$d(e)},document.addEventListener("selectionchange",Rp)),Op||(Op=e=>{const n=e.target,r=n==null?void 0:n.closest(Ac);if(!r)return;const i=Gi.get(r)||Mp||t;$p(r,i.labels),$d(r)},document.addEventListener("input",Op,!0)),Hd||(Hd=()=>{Iue()},window.addEventListener("scroll",Hd,!0),window.addEventListener("resize",Hd))}function Oue(){Ip&&(document.removeEventListener("focusin",Ip,!0),Ip=null),Fp&&(document.removeEventListener("keydown",Fp,!0),Fp=null),Up&&(document.removeEventListener("click",Up,!0),Up=null),Np&&(document.removeEventListener("mousedown",Np,!0),Np=null),Rp&&(document.removeEventListener("selectionchange",Rp),Rp=null),Op&&(document.removeEventListener("input",Op,!0),Op=null),Hd&&(window.removeEventListener("scroll",Hd,!0),window.removeEventListener("resize",Hd),Hd=null),CA.forEach(t=>{t.remove()}),CA.clear(),TA.clear(),Mp=null,bi=null}const jS=Object.freeze(Object.defineProperty({__proto__:null,ConditionalContentPlugin:(t={})=>{const e=wue(t);return vue(),{name:"conditionalContent",toolbar:[{id:"conditionalContentGroup",label:"Conditional Content",type:"group",command:"conditionalContent",items:[{id:"conditionalContent",label:"Conditional Rule",command:"openConditionalDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-c"},{id:"conditionalPreview",label:"Conditional Preview",command:"toggleConditionalPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-p"}]}],commands:{conditionalContent:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e),$p(i,e.labels);const o=n==null?void 0:n.target;if(o==="insert")return Ds(i,e,"insert",n),!0;const a=Qp(i);return o==="edit"||a?!a&&o==="edit"?!1:(Ds(i,e,"edit",n,a||void 0),!0):(Ds(i,e,"insert",n),!0)},openConditionalDialog:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e),$p(i,e.labels);const o=n==null?void 0:n.target;if(o==="insert")return Ds(i,e,"insert",n),!0;const a=Qp(i);return o==="edit"||a?!a&&o==="edit"?!1:(Ds(i,e,"edit",n,a||void 0),!0):(Ds(i,e,"insert",n),!0)},conditionalPreview:async(n,r)=>{const i=pl(r);if(!i)return!1;bi=i,Gi.set(i,e);const o=typeof n=="boolean"?n:hl.get(i)!==!0;return await zp(i,e,o),$d(i),!0},editConditionalBlock:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e);const o=Qp(i);return o?(Ds(i,e,"edit",n,o),!0):!1},deleteConditionalBlock:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;const o=Qp(i);if(!o)return!1;const a=q7(i,o);return a&&$d(i),a},insertConditionalBlock:(n,r)=>{var c,l,u,d;const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e);const o={condition:(c=n==null?void 0:n.condition)!=null?c:e.defaultCondition,audience:(l=n==null?void 0:n.audience)!=null?l:e.defaultAudience,locale:(u=n==null?void 0:n.locale)!=null?u:e.defaultLocale,hasElse:(d=n==null?void 0:n.hasElse)!=null?d:e.enableElseByDefault},a=M7(o,e.labels);return Q7(i,a),hl.get(i)===!0&&zp(i,e,!0),!0},toggleConditionalPreview:async(n,r)=>{const i=pl(r);if(!i)return!1;bi=i,Gi.set(i,e);const o=typeof n=="boolean"?n:hl.get(i)!==!0;return await zp(i,e,o),!0},setConditionalContext:(n,r)=>{const i=pl(r);return i?(bi=i,!n||typeof n!="object"?PS.delete(i):PS.set(i,n),hl.get(i)===!0&&zp(i,e,!0),!0):!1}},keymap:{"Mod-Alt-Shift-c":"openConditionalDialog","Mod-Alt-Shift-C":"openConditionalDialog","Mod-Alt-Shift-p":"toggleConditionalPreview","Mod-Alt-Shift-P":"toggleConditionalPreview",F9:"openConditionalDialog",F10:"toggleConditionalPreview"},init:()=>{xw+=1,Rue(e)},destroy:()=>{xw=Math.max(0,xw-1),xw===0&&(O7(),Oue())}}}},Symbol.toStringTag,{value:"Module"})),zd=".rte-content, .editora-content",jp='.rte-data-binding[data-binding="true"]',K7="rte-data-binding-styles",lo="rte-data-binding-dialog-overlay",Xi=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Mue={dialogTitleInsert:"Insert Data Binding",dialogTitleEdit:"Edit Data Binding",keyLabel:"Data Key",keyPlaceholder:"user.firstName",fallbackLabel:"Fallback Text",fallbackPlaceholder:"Guest",formatLabel:"Format",currencyLabel:"Currency",currencyPlaceholder:"USD",saveText:"Save",cancelText:"Cancel",previewOnText:"Preview On",previewOffText:"Preview Off",tokenAriaPrefix:"Data binding token"},pc=new WeakMap,qS=new WeakMap,Yi=new WeakMap,cy=new WeakMap,WS=new WeakMap;let ly=null,Sa=null,_w=0,qp=null,Wp=null,Kp=null,Dw=null;function Pue(t){return{...Mue,...t||{}}}function V7(t={}){var n;const e=(t.locale||(typeof navigator!="undefined"?navigator.language:"en-US")).trim()||"en-US";return{data:t.data,getData:t.getData,api:t.api,cacheTtlMs:Math.max(0,Number((n=t.cacheTtlMs)!=null?n:3e4)),labels:Pue(t.labels),defaultFormat:t.defaultFormat||"text",defaultFallback:t.defaultFallback||"",locale:e,numberFormatOptions:t.numberFormatOptions||{},dateFormatOptions:t.dateFormatOptions||{year:"numeric",month:"short",day:"2-digit"}}}function _a(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function G7(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function uy(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function Lw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Hue(t){const e=uy(t);if(Lw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Lw(n)?!0:Lw(document.documentElement)||Lw(document.body)}function jd(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(zd))return i;const o=i.querySelector(zd);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=G7(i),a=o==null?void 0:o.closest(zd);if(a)return a}const r=document.activeElement;if(r){if(r.matches(zd))return r;const i=r.closest(zd);if(i)return i}return Sa&&Sa.isConnected?Sa:e?document.querySelector(zd):null}function dy(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function X7(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function Y7(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function Que(t,e){const n=(e||"").trim();if(n)return n.split(".").filter(Boolean).reduce((r,i)=>{if(!(r==null||typeof r!="object"))return r[i]},t)}function $ue(){if(typeof document=="undefined"||document.getElementById(K7))return;const t=document.createElement("style");t.id=K7,t.textContent=`
|
|
2802
|
+
`,s.appendChild(c),document.body.appendChild(s);const p=c.querySelector(".rte-conditional-input-condition"),m=c.querySelector(".rte-conditional-input-audience"),g=c.querySelector(".rte-conditional-input-locale"),b=c.querySelector(".rte-conditional-input-else"),y=()=>{s.removeEventListener("click",x),s.removeEventListener("keydown",_,!0),document.removeEventListener("keydown",w,!0),s.parentNode&&s.parentNode.removeChild(s),ay=null,t.focus({preventScroll:!0}),$d(t)},w=F=>{F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),y())},x=F=>{F.target===s&&y()},k=F=>{if(F.key!=="Tab")return;const v=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(v.length===0)return;const P=v[0],W=v[v.length-1],q=document.activeElement;if(F.shiftKey&&q===P){F.preventDefault(),W.focus();return}!F.shiftKey&&q===W&&(F.preventDefault(),P.focus())},T=async()=>{var W;const F={condition:((W=p==null?void 0:p.value)==null?void 0:W.trim())||"",audience:Qd(m==null?void 0:m.value),locale:Qd(g==null?void 0:g.value),hasElse:(b==null?void 0:b.checked)||!1},v=t.innerHTML;if(i)Due(i,F,o),Hp(i,hl.get(t)===!0);else{kue(t,a);const q=MP(F,o);try{QP(t,q)}catch(ie){t.appendChild(q);const ne=q.querySelector('.rte-conditional-body[data-slot="if"]');ne?kw(t,ne):kw(t,q)}}hl.get(t)===!0&&await zp(t,e,!0),NP(t),RP(t,v),$d(t),y()},_=F=>{if(F.key==="Escape"){F.preventDefault(),y();return}k(F),F.key==="Enter"&&!F.shiftKey&&F.target instanceof HTMLInputElement&&(F.preventDefault(),T())};c.addEventListener("click",F=>{const P=F.target.getAttribute("data-action");if(P==="cancel"){y();return}P==="save"&&T()}),s.addEventListener("click",x),s.addEventListener("keydown",_,!0),document.addEventListener("keydown",w,!0),ay={cleanup:y},p==null||p.focus()}function Uue(t){const e=t.metaKey||t.ctrlKey,r=(typeof t.key=="string"?t.key:"").toLowerCase(),i=typeof t.code=="string"?t.code.toLowerCase():"",o=e&&t.altKey&&t.shiftKey&&(r==="c"||i==="keyc"),a=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&(r==="f9"||i==="f9");return o||a}function Nue(t){const e=t.metaKey||t.ctrlKey,r=(typeof t.key=="string"?t.key:"").toLowerCase(),i=typeof t.code=="string"?t.code.toLowerCase():"",o=e&&t.altKey&&t.shiftKey&&(r==="p"||i==="keyp"),a=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&(r==="f10"||i==="f10");return o||a}function Rue(t){Mp=t,Ip||(Ip=e=>{const n=e.target,r=n==null?void 0:n.closest(Ac);if(!r)return;bi=r,Gi.has(r)||Gi.set(r,t);const i=Gi.get(r)||t;$p(r,i.labels),zP(r,hl.get(r)===!0),$d(r)},document.addEventListener("focusin",Ip,!0)),Fp||(Fp=e=>{var u;if(document.querySelector(`.${Wt}`))return;const r=e.target;if(!!(r!=null&&r.closest("input, textarea, select")))return;const a=(r==null?void 0:r.closest(Ac))||pl(void 0,!1)||bi;if(!a||xu(a))return;const s=Gi.get(a)||Mp||t,c=document.activeElement,l=(r==null?void 0:r.closest(".rte-conditional-header"))||(c==null?void 0:c.closest(".rte-conditional-header"));if(l&&(e.key==="Enter"||e.key===" ")){const d=l.closest(hc);if(d&&a.contains(d)){e.preventDefault(),e.stopPropagation(),Ds(a,s,"edit",void 0,d);return}}if(Uue(e)){e.preventDefault(),e.stopPropagation();const d=Qp(a);d?Ds(a,s,"edit",void 0,d):Ds(a,s,"insert");return}if(Nue(e)){e.preventDefault(),e.stopPropagation();const d=hl.get(a)!==!0;zp(a,s,d),$d(a);return}if((e.key==="Backspace"||e.key==="Delete")&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const d=window.getSelection();if(!d||d.rangeCount===0)return;const f=d.getRangeAt(0);if(!f.collapsed||!a.contains(f.commonAncestorContainer))return;const A=(u=xue(f.startContainer))==null?void 0:u.closest(".rte-conditional-body");if(!A||!a.contains(A))return;if(e.key==="Backspace"&&WP(f,A,"start")){e.preventDefault();return}if(e.key==="Delete"&&WP(f,A,"end")){e.preventDefault();return}}},document.addEventListener("keydown",Fp,!0)),Np||(Np=e=>{const n=e.target;if(!n||n.closest(`.${zn}`))return;const r=n.closest(Ac);if(!r){bi&&kA(bi);return}if(xu(r))return;bi=r,Gi.has(r)||Gi.set(r,t);const i=n.closest(hc);if(!i){kA(r);return}requestAnimationFrame(()=>{!r.isConnected||!r.contains(i)||Sw(r,i)})},document.addEventListener("mousedown",Np,!0)),Up||(Up=e=>{const n=e.target;if(!n||n.closest(`.${zn}`))return;const r=n.closest(Ac);if(!r){bi&&kA(bi);return}if(xu(r))return;bi=r,Gi.has(r)||Gi.set(r,t);const i=Gi.get(r)||t,o=n.closest(hc),a=!!n.closest(".rte-conditional-header, .rte-conditional-summary, .rte-conditional-meta, .rte-conditional-else-label");if(o&&a){e.preventDefault(),e.stopPropagation(),Ds(r,i,"edit",void 0,o),Sw(r,o);return}o?Sw(r,o):kA(r)},document.addEventListener("click",Up,!0)),Rp||(Rp=()=>{const e=pl(void 0,!1)||bi;e&&e.isConnected&&$d(e)},document.addEventListener("selectionchange",Rp)),Op||(Op=e=>{const n=e.target,r=n==null?void 0:n.closest(Ac);if(!r)return;const i=Gi.get(r)||Mp||t;$p(r,i.labels),$d(r)},document.addEventListener("input",Op,!0)),Hd||(Hd=()=>{Iue()},window.addEventListener("scroll",Hd,!0),window.addEventListener("resize",Hd))}function Oue(){Ip&&(document.removeEventListener("focusin",Ip,!0),Ip=null),Fp&&(document.removeEventListener("keydown",Fp,!0),Fp=null),Up&&(document.removeEventListener("click",Up,!0),Up=null),Np&&(document.removeEventListener("mousedown",Np,!0),Np=null),Rp&&(document.removeEventListener("selectionchange",Rp),Rp=null),Op&&(document.removeEventListener("input",Op,!0),Op=null),Hd&&(window.removeEventListener("scroll",Hd,!0),window.removeEventListener("resize",Hd),Hd=null),CA.forEach(t=>{t.remove()}),CA.clear(),TA.clear(),Mp=null,bi=null}const jS=Object.freeze(Object.defineProperty({__proto__:null,ConditionalContentPlugin:(t={})=>{const e=wue(t);return vue(),{name:"conditionalContent",toolbar:[{id:"conditionalContentGroup",label:"Conditional Content",type:"group",command:"conditionalContent",items:[{id:"conditionalContent",label:"Conditional Rule",command:"openConditionalDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12a1 1 0 0 1 1 1v3h-2V7H7v3H5V6a1 1 0 0 1 1-1Zm-1 9h2v3h10v-3h2v4a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-4Zm3-2a1 1 0 0 1 1-1h2.6l1.8-2.4a1 1 0 1 1 1.6 1.2L13.8 11H15a1 1 0 1 1 0 2h-2.7l-1.9 2.5a1 1 0 1 1-1.6-1.2L10.1 13H9a1 1 0 0 1-1-1Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-c"},{id:"conditionalPreview",label:"Conditional Preview",command:"toggleConditionalPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6h16a1 1 0 0 1 1 1v3h-2V8H5v8h14v-2h2v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm5 3h2v2H9V9Zm0 4h2v2H9v-2Zm4-4h6v2h-6V9Zm0 4h6v2h-6v-2Z" fill="currentColor"></path></svg>',shortcut:"Mod-Alt-Shift-p"}]}],commands:{conditionalContent:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e),$p(i,e.labels);const o=n==null?void 0:n.target;if(o==="insert")return Ds(i,e,"insert",n),!0;const a=Qp(i);return o==="edit"||a?!a&&o==="edit"?!1:(Ds(i,e,"edit",n,a||void 0),!0):(Ds(i,e,"insert",n),!0)},openConditionalDialog:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e),$p(i,e.labels);const o=n==null?void 0:n.target;if(o==="insert")return Ds(i,e,"insert",n),!0;const a=Qp(i);return o==="edit"||a?!a&&o==="edit"?!1:(Ds(i,e,"edit",n,a||void 0),!0):(Ds(i,e,"insert",n),!0)},conditionalPreview:async(n,r)=>{const i=pl(r);if(!i)return!1;bi=i,Gi.set(i,e);const o=typeof n=="boolean"?n:hl.get(i)!==!0;return await zp(i,e,o),$d(i),!0},editConditionalBlock:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e);const o=Qp(i);return o?(Ds(i,e,"edit",n,o),!0):!1},deleteConditionalBlock:(n,r)=>{const i=pl(r);if(!i||xu(i))return!1;const o=Qp(i);if(!o)return!1;const a=qP(i,o);return a&&$d(i),a},insertConditionalBlock:(n,r)=>{var c,l,u,d;const i=pl(r);if(!i||xu(i))return!1;bi=i,Gi.set(i,e);const o={condition:(c=n==null?void 0:n.condition)!=null?c:e.defaultCondition,audience:(l=n==null?void 0:n.audience)!=null?l:e.defaultAudience,locale:(u=n==null?void 0:n.locale)!=null?u:e.defaultLocale,hasElse:(d=n==null?void 0:n.hasElse)!=null?d:e.enableElseByDefault},a=MP(o,e.labels);return QP(i,a),hl.get(i)===!0&&zp(i,e,!0),!0},toggleConditionalPreview:async(n,r)=>{const i=pl(r);if(!i)return!1;bi=i,Gi.set(i,e);const o=typeof n=="boolean"?n:hl.get(i)!==!0;return await zp(i,e,o),!0},setConditionalContext:(n,r)=>{const i=pl(r);return i?(bi=i,!n||typeof n!="object"?PS.delete(i):PS.set(i,n),hl.get(i)===!0&&zp(i,e,!0),!0):!1}},keymap:{"Mod-Alt-Shift-c":"openConditionalDialog","Mod-Alt-Shift-C":"openConditionalDialog","Mod-Alt-Shift-p":"toggleConditionalPreview","Mod-Alt-Shift-P":"toggleConditionalPreview",F9:"openConditionalDialog",F10:"toggleConditionalPreview"},init:()=>{xw+=1,Rue(e)},destroy:()=>{xw=Math.max(0,xw-1),xw===0&&(OP(),Oue())}}}},Symbol.toStringTag,{value:"Module"})),zd=".rte-content, .editora-content",jp='.rte-data-binding[data-binding="true"]',KP="rte-data-binding-styles",lo="rte-data-binding-dialog-overlay",Xi=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Mue={dialogTitleInsert:"Insert Data Binding",dialogTitleEdit:"Edit Data Binding",keyLabel:"Data Key",keyPlaceholder:"user.firstName",fallbackLabel:"Fallback Text",fallbackPlaceholder:"Guest",formatLabel:"Format",currencyLabel:"Currency",currencyPlaceholder:"USD",saveText:"Save",cancelText:"Cancel",previewOnText:"Preview On",previewOffText:"Preview Off",tokenAriaPrefix:"Data binding token"},pc=new WeakMap,qS=new WeakMap,Yi=new WeakMap,cy=new WeakMap,WS=new WeakMap;let ly=null,Sa=null,_w=0,qp=null,Wp=null,Kp=null,Dw=null;function Pue(t){return{...Mue,...t||{}}}function VP(t={}){var n;const e=(t.locale||(typeof navigator!="undefined"?navigator.language:"en-US")).trim()||"en-US";return{data:t.data,getData:t.getData,api:t.api,cacheTtlMs:Math.max(0,Number((n=t.cacheTtlMs)!=null?n:3e4)),labels:Pue(t.labels),defaultFormat:t.defaultFormat||"text",defaultFallback:t.defaultFallback||"",locale:e,numberFormatOptions:t.numberFormatOptions||{},dateFormatOptions:t.dateFormatOptions||{year:"numeric",month:"short",day:"2-digit"}}}function _a(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function GP(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function uy(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function Lw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Hue(t){const e=uy(t);if(Lw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Lw(n)?!0:Lw(document.documentElement)||Lw(document.body)}function jd(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(zd))return i;const o=i.querySelector(zd);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=GP(i),a=o==null?void 0:o.closest(zd);if(a)return a}const r=document.activeElement;if(r){if(r.matches(zd))return r;const i=r.closest(zd);if(i)return i}return Sa&&Sa.isConnected?Sa:e?document.querySelector(zd):null}function dy(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function XP(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function YP(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function Que(t,e){const n=(e||"").trim();if(n)return n.split(".").filter(Boolean).reduce((r,i)=>{if(!(r==null||typeof r!="object"))return r[i]},t)}function $ue(){if(typeof document=="undefined"||document.getElementById(KP))return;const t=document.createElement("style");t.id=KP,t.textContent=`
|
|
2802
2803
|
.rte-data-binding {
|
|
2803
2804
|
display: inline-flex;
|
|
2804
2805
|
align-items: center;
|
|
@@ -3084,7 +3085,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3084
3085
|
border-color: #2563eb;
|
|
3085
3086
|
color: #ffffff;
|
|
3086
3087
|
}
|
|
3087
|
-
`,document.head.appendChild(t)}function KS(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function VS(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function fy(t,e){var n,r;return{key:String(t.key||"").trim(),fallback:String((r=(n=t.fallback)!=null?n:e.defaultFallback)!=null?r:""),format:t.format||e.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function
|
|
3088
|
+
`,document.head.appendChild(t)}function KS(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function VS(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function fy(t,e){var n,r;return{key:String(t.key||"").trim(),fallback:String((r=(n=t.fallback)!=null?n:e.defaultFallback)!=null?r:""),format:t.format||e.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function ZP(t){return`{{${t.key}}}`}function JP(t,e){const n=document.createElement("span");return n.className="rte-data-binding",n.setAttribute("data-binding","true"),n.setAttribute("data-binding-key",t.key),n.setAttribute("data-binding-fallback",t.fallback||""),n.setAttribute("data-binding-format",t.format||"text"),n.setAttribute("data-binding-currency",t.currency||"USD"),n.setAttribute("contenteditable","false"),n.setAttribute("spellcheck","false"),n.setAttribute("draggable","false"),n.setAttribute("tabindex","0"),n.setAttribute("role","button"),n.setAttribute("aria-label",`${e.tokenAriaPrefix}: ${t.key}. Press Enter to edit.`),n.textContent=ZP(t),n}function Fw(t,e){return fy({key:t.getAttribute("data-binding-key")||"",fallback:t.getAttribute("data-binding-fallback")||e.defaultFallback,format:t.getAttribute("data-binding-format")||e.defaultFormat,currency:t.getAttribute("data-binding-currency")||"USD"},e)}function GS(t,e,n){t.classList.add("rte-data-binding"),t.setAttribute("data-binding","true"),t.setAttribute("data-binding-key",e.key),t.setAttribute("data-binding-fallback",e.fallback||""),t.setAttribute("data-binding-format",e.format||"text"),t.setAttribute("data-binding-currency",e.currency||"USD"),t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false"),t.setAttribute("draggable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label",`${n.tokenAriaPrefix}: ${e.key}. Press Enter to edit.`)}function Iw(t,e){const n=Array.from(t.querySelectorAll(jp));return n.forEach(r=>{const i=Fw(r,e);GS(r,i,e.labels)}),n}function XS(t){const e=window.getSelection();if(e&&e.rangeCount>0){const i=e.getRangeAt(0).startContainer,o=GP(i),a=o==null?void 0:o.closest(jp);if(a&&t.contains(a))return a}const n=document.activeElement,r=n==null?void 0:n.closest(jp);return r&&t.contains(r)?r:null}function e7(){ly&&(ly.cleanup(),ly=null)}function YS(t,e,n){const r=uy(t);Array.from(r.querySelectorAll('[data-command="toggleDataBindingPreview"]')).forEach(o=>{if(o.setAttribute("data-active",e?"true":"false"),o.classList.toggle("active",e),o.setAttribute("aria-pressed",e?"true":"false"),n){const a=e?n.labels.previewOnText:n.labels.previewOffText;o.setAttribute("title",a),o.setAttribute("aria-label",a)}})}function zue(t,e,n){const r=e.format||"text";if(t==null)return e.fallback||"";if(r==="json"){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch(i){return String(t)}}if(r==="date"){const i=t instanceof Date?t:new Date(String(t));if(Number.isNaN(i.getTime()))return String(t);try{return new Intl.DateTimeFormat(n.locale,n.dateFormatOptions).format(i)}catch(o){return i.toISOString()}}if(r==="number"||r==="currency"){const i=typeof t=="number"?t:Number(t);if(!Number.isFinite(i))return String(t);const o={...n.numberFormatOptions};if(r==="currency"){const a=(e.currency||"USD").toUpperCase();Object.assign(o,{style:"currency",currency:a})}try{return new Intl.NumberFormat(n.locale,o).format(i)}catch(a){return String(i)}}return String(t)}function BA(t,e,n,r){const i=Fw(t,e),o=i.key;if(t.classList.remove("rte-data-binding-preview","rte-data-binding-missing"),!n){t.textContent=ZP(i),t.setAttribute("aria-label",`${e.labels.tokenAriaPrefix}: ${o}. Press Enter to edit.`);return}const a=Que(r,o),s=a==null,c=s?i.fallback||"":zue(a,i,e);t.textContent=c||i.fallback||"",t.classList.add("rte-data-binding-preview"),s&&!(i.fallback||"").trim()&&t.classList.add("rte-data-binding-missing"),t.setAttribute("aria-label",`${e.labels.tokenAriaPrefix}: ${o} = ${t.textContent||""}. Press Enter to edit.`)}function Eu(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function jue(t,e){return e?e.split(".").filter(Boolean).reduce((n,r)=>{if(!(!Eu(n)&&!Array.isArray(n)))return n[r]},t):t}function que(t,e,n){const r=e.api,i=uy(t),o={editor:t,editorRoot:i,signal:n};if(r.buildRequest){const d=r.buildRequest(o);return{url:d.url,init:{...d.init||{},signal:n}}}const a=(r.method||"GET").toUpperCase(),s=typeof r.headers=="function"?r.headers(o):r.headers||{},c=typeof r.params=="function"?r.params(o):r.params,l=new URL(r.url,window.location.origin);c&&Object.entries(c).forEach(([d,f])=>{f!=null&&l.searchParams.set(d,String(f))});const u={method:a,headers:{...s},credentials:r.credentials,mode:r.mode,cache:r.cache,signal:n};if(a!=="GET"&&a!=="HEAD"){const d=typeof r.body=="function"?r.body(o):r.body;if(d!=null)if(Eu(d)){u.body=JSON.stringify(d);const f=u.headers;!f["Content-Type"]&&!f["content-type"]&&(f["Content-Type"]="application/json")}else u.body=d}return{url:l.toString(),init:u}}async function Wue(t,e){var c,l;const n=e.api;if(!n)return{};const r=new AbortController,i=uy(t),o={editor:t,editorRoot:i,signal:r.signal},a=Math.max(0,Number((c=n.timeoutMs)!=null?c:1e4));let s=null;a>0&&(s=window.setTimeout(()=>r.abort(),a));try{const{url:u,init:d}=que(t,e,r.signal),f=await fetch(u,{...d,signal:r.signal});if(!f.ok)throw new Error(`Data binding API request failed: ${f.status}`);const h=(n.responseType||"json")==="text"?await f.text():await f.json();if(n.transformResponse){const m=n.transformResponse(h,o);return Eu(m)?m:{}}const p=jue(h,n.responsePath);return Eu(p)?p:Eu(h)?h:{value:p}}catch(u){return(u==null?void 0:u.name)!=="AbortError"&&((l=n.onError)==null||l.call(n,u,o)),{}}finally{s!==null&&window.clearTimeout(s)}}async function Ay(t,e){const n=qS.get(t);if(n)return n;const r=cy.get(t),i=Date.now();if(r&&i-r.timestamp<=e.cacheTtlMs)return r.data;const o=WS.get(t);if(o)return o;const a=(async()=>{try{if(typeof e.getData=="function"){const c=await Promise.resolve(e.getData({editor:t,editorRoot:uy(t)}));if(Eu(c))return c}if(e.api){const c=await Wue(t,e);if(Eu(c))return c}if(typeof e.data=="function"){const c=await Promise.resolve(e.data());if(Eu(c))return c}return Eu(e.data)?e.data:{}}finally{WS.delete(t)}})();WS.set(t,a);const s=await a;return cy.set(t,{timestamp:i,data:s}),s}async function Uw(t,e,n){const r=Iw(t,e);if(pc.set(t,n),YS(t,n,e),!n){r.forEach(o=>BA(o,e,!1));return}const i=await Ay(t,e);r.forEach(o=>BA(o,e,!0,i))}function t7(t,e){let n=XP(t);n||(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1)),n.collapsed||n.deleteContents(),n.insertNode(e);const r=document.createTextNode(" ");e.after(r);const i=document.createRange();i.setStart(r,1),i.collapse(!0),YP(t,i),t.normalize()}function n7(t){return typeof t.key=="string"?t.key.toLowerCase():""}function Kue(t){const e=t.metaKey||t.ctrlKey,n=n7(t),r=e&&t.altKey&&t.shiftKey&&n==="d",i=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&n==="f7";return r||i}function Vue(t){const e=t.metaKey||t.ctrlKey,n=n7(t),r=e&&t.altKey&&t.shiftKey&&n==="b",i=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&n==="f8";return r||i}function SA(t,e,n,r,i){e7();const o=n==="insert"?XP(t):null,a=e.labels,s=i?Fw(i,e):fy(r||{},e),c=document.createElement("div");Io(c),c.className=lo,Hue(t)&&c.classList.add("rte-data-binding-theme-dark");const l=document.createElement("section");l.className="rte-data-binding-dialog",l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","rte-data-binding-dialog-title"),l.innerHTML=`
|
|
3088
3089
|
<header class="rte-data-binding-header">
|
|
3089
3090
|
<h2 id="rte-data-binding-dialog-title" class="rte-data-binding-title">${_a(n==="edit"?a.dialogTitleEdit:a.dialogTitleInsert)}</h2>
|
|
3090
3091
|
<button type="button" class="rte-data-binding-btn" data-action="cancel" aria-label="${_a(a.cancelText)}">✕</button>
|
|
@@ -3118,12 +3119,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3118
3119
|
<button type="button" class="rte-data-binding-btn" data-action="cancel">${_a(a.cancelText)}</button>
|
|
3119
3120
|
<button type="button" class="rte-data-binding-btn rte-data-binding-btn-primary" data-action="save">${_a(a.saveText)}</button>
|
|
3120
3121
|
</footer>
|
|
3121
|
-
`,c.appendChild(l),document.body.appendChild(c);const u=l.querySelector(".rte-data-binding-key"),d=l.querySelector(".rte-data-binding-fallback"),f=l.querySelector(".rte-data-binding-format"),A=l.querySelector(".rte-data-binding-currency"),h=()=>{const x=(f==null?void 0:f.value)==="currency",k=A==null?void 0:A.closest(".rte-data-binding-field");k&&(k.style.display=x?"grid":"none")};h(),f==null||f.addEventListener("change",h);const p=()=>{c.removeEventListener("click",g),c.removeEventListener("keydown",w,!0),document.removeEventListener("keydown",m,!0),c.parentNode&&c.parentNode.removeChild(c),ly=null,t.focus({preventScroll:!0})},m=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),p())},g=x=>{x.target===c&&p()},b=x=>{if(x.key!=="Tab")return;const k=Array.from(l.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(k.length===0)return;const T=k[0],_=k[k.length-1],B=document.activeElement;if(x.shiftKey&&B===T){x.preventDefault(),_.focus();return}!x.shiftKey&&B===_&&(x.preventDefault(),T.focus())},y=async()=>{const x=((u==null?void 0:u.value)||"").trim();if(!x){u==null||u.focus();return}const k=fy({key:x,fallback:((d==null?void 0:d.value)||"").trim(),format:(f==null?void 0:f.value)||e.defaultFormat,currency:((A==null?void 0:A.value)||"USD").trim().toUpperCase()},e),T=t.innerHTML;if(i){GS(i,k,a);const _=pc.get(t)===!0,B=_?await Ay(t,e):void 0;BA(i,e,_,B)}else{if(o)try{Y7(t,o)}catch(I){}const _=J7(k,a);if(tP(t,_),pc.get(t)===!0){const I=await Ay(t,e);BA(_,e,!0,I)}}KS(t),VS(t,T),p()},w=x=>{if(x.key==="Escape"){x.preventDefault(),p();return}b(x),x.key==="Enter"&&!x.shiftKey&&x.target instanceof HTMLInputElement&&(x.preventDefault(),y())};l.addEventListener("click",x=>{const k=x.target,T=k==null?void 0:k.getAttribute("data-action");if(T){if(T==="cancel"){p();return}T==="save"&&y()}}),c.addEventListener("click",g),c.addEventListener("keydown",w,!0),document.addEventListener("keydown",m,!0),ly={cleanup:p},u==null||u.focus()}function Gue(t){Dw=t,Wp||(Wp=e=>{const n=e.target,r=n==null?void 0:n.closest(zd);if(!r)return;Sa=r,Yi.has(r)||Yi.set(r,t);const i=Yi.get(r)||t;Iw(r,i);const o=pc.get(r)===!0;YS(r,o,i),o||Array.from(r.querySelectorAll(jp)).forEach(s=>BA(s,i,!1))},document.addEventListener("focusin",Wp,!0)),qp||(qp=e=>{if(document.querySelector(`.${lo}`))return;const n=e.target;if(n!=null&&n.closest("input, textarea, select"))return;const r=jd(void 0,!1);if(!r||dy(r))return;const i=Yi.get(r)||Dw||t,o=n==null?void 0:n.closest(jp);if(o&&(e.key==="Enter"||e.key===" ")){e.preventDefault(),e.stopPropagation(),Sa=r,SA(r,i,"edit",void 0,o);return}if(Kue(e)){e.preventDefault(),e.stopPropagation();const a=XS(r);a?SA(r,i,"edit",void 0,a):SA(r,i,"insert");return}if(Vue(e)){e.preventDefault(),e.stopPropagation();const a=pc.get(r)!==!0;Uw(r,i,a)}},document.addEventListener("keydown",qp,!0)),Kp||(Kp=e=>{if(document.querySelector(`.${lo}`)||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;const n=e.target,r=n==null?void 0:n.closest(jp);if(!r)return;const i=r.closest(zd);if(!i||dy(i))return;const o=Yi.get(i)||Dw||t;Yi.set(i,o),Sa=i,e.preventDefault(),e.stopPropagation(),r.focus({preventScroll:!0}),SA(i,o,"edit",void 0,r)},document.addEventListener("click",Kp,!0))}function Xue(){Wp&&(document.removeEventListener("focusin",Wp,!0),Wp=null),qp&&(document.removeEventListener("keydown",qp,!0),qp=null),Kp&&(document.removeEventListener("click",Kp,!0),Kp=null),Dw=null,Sa=null}const ZS=Object.freeze(Object.defineProperty({__proto__:null,DataBindingPlugin:(t={})=>{const e=V7(t);return $ue(),{name:"dataBinding",toolbar:[{id:"dataBindingTools",label:"Data Binding",type:"group",command:"openDataBindingDialog",items:[{id:"dataBinding",label:"Data Binding",command:"openDataBindingDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 4a3 3 0 0 0-3 3v3h2V7a1 1 0 0 1 1-1h3V4H7Zm10 0h-3v2h3a1 1 0 0 1 1 1v3h2V7a3 3 0 0 0-3-3ZM4 14v3a3 3 0 0 0 3 3h3v-2H7a1 1 0 0 1-1-1v-3H4Zm14 0v3a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3v-3h-2ZM8.5 12a1.5 1.5 0 1 1 0-3h7a1.5 1.5 0 0 1 0 3h-7Zm0 4a1.5 1.5 0 1 1 0-3h4a1.5 1.5 0 0 1 0 3h-4Z" fill="currentColor"></path></svg>'},{id:"dataBindingPreview",label:"Data Preview",command:"toggleDataBindingPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3c-4.4 0-8 1.3-8 3v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6c0-1.7-3.6-3-8-3Zm0 2c3.9 0 6 .9 6 1s-2.1 1-6 1-6-.9-6-1 2.1-1 6-1Zm0 4c3 0 5.6-.5 7-1.3V11c0 .9-2.7 2-7 2s-7-1.1-7-2V7.7C6.4 8.5 9 9 12 9Zm0 6c-4.3 0-7-1.1-7-2v3c0 .9 2.7 2 7 2s7-1.1 7-2v-3c0 .9-2.7 2-7 2Z" fill="currentColor"></path><path d="M16.5 9.4a1 1 0 0 1 1.4 0l1.1 1.1 1.8-1.8a1 1 0 1 1 1.4 1.4l-2.5 2.5a1 1 0 0 1-1.4 0l-1.8-1.8a1 1 0 0 1 0-1.4Z" fill="currentColor"></path></svg>'}]}],commands:{openDataBindingDialog:(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o),Iw(i,o);const a=n==null?void 0:n.target;if(a==="insert")return SA(i,o,"insert",n),!0;const s=XS(i);return a==="edit"||s?!s&&a==="edit"?!1:(SA(i,o,"edit",n,s||void 0),!0):(SA(i,o,"insert",n),!0)},insertDataBindingToken:async(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=fy(n||{},o);if(!a.key)return!1;const s=i.innerHTML,c=J7(a,o.labels);if(tP(i,c),pc.get(i)===!0){const u=await Ay(i,o);BA(c,o,!0,u)}return KS(i),VS(i,s),!0},editDataBindingToken:async(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=XS(i);if(!a)return!1;const s=Fw(a,o),c=fy({...s,...n||{}},o);if(!c.key)return!1;const l=i.innerHTML;GS(a,c,o.labels);const u=pc.get(i)===!0,d=u?await Ay(i,o):void 0;return BA(a,o,u,d),KS(i),VS(i,l),!0},toggleDataBindingPreview:async(n,r)=>{const i=jd(r);if(!i)return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=typeof n=="boolean"?n:pc.get(i)!==!0;return await Uw(i,o,a),!0},setDataBindingData:async(n,r)=>{const i=jd(r);if(!i)return!1;if(Sa=i,n&&typeof n=="object"?(qS.set(i,n),cy.set(i,{timestamp:Date.now(),data:n})):(qS.delete(i),cy.delete(i)),pc.get(i)===!0){const o=Yi.get(i)||e;await Uw(i,o,!0)}return!0},refreshDataBindings:async(n,r)=>{const i=jd(r);if(!i)return!1;Sa=i,cy.delete(i);const o=Yi.get(i)||e;Yi.set(i,o);const a=pc.get(i)===!0;return await Uw(i,o,a),!0}},keymap:{"Mod-Alt-Shift-d":"openDataBindingDialog","Mod-Alt-Shift-D":"openDataBindingDialog","Mod-Alt-Shift-b":"toggleDataBindingPreview","Mod-Alt-Shift-B":"toggleDataBindingPreview",F7:"openDataBindingDialog",F8:"toggleDataBindingPreview"},init:function(r){_w+=1;const i=this&&typeof this.__pluginConfig=="object"?V7({...e,...this.__pluginConfig}):e;Gue(i);const o=jd(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);if(o){Sa=o,Yi.set(o,i),Iw(o,i);const a=pc.get(o)===!0;YS(o,a,i)}},destroy:()=>{_w=Math.max(0,_w-1),_w===0&&(eP(),Xue())}}}},Symbol.toStringTag,{value:"Module"})),Da=".rte-content, .editora-content",JS="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",rP="__editoraCommandEditorRoot",iP="rte-doc-schema-styles",jn="rte-doc-schema-panel",Ls="document-schema",gl="doc-schema",qd="docSchema",Fs=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Yue={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},Tn=new WeakMap,Nw=new WeakMap,hy=new WeakMap,ca=new Map,py=new WeakMap,Rw=new WeakMap,Ow=new Set;let Mw=0,Zue=0,oP=0,Is=null,la=null,Vp=null,Gp=null,Xp=null,Wd=null,Yp=null;function ml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jue(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function _A(t,e,n){return Number.isFinite(t)?Math.max(e,Math.min(n,t)):e}function aP(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function e5(t,e){return e(t).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function sP(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function ede(t,e,n){var d,f;const r=n(t.title||"");if(!r)return null;const i=aP(n(t.id||r))||`section-${e+1}`,o=_A(Number((d=t.minOccurrences)!=null?d:1),0,20),a=Math.max(1,o),s=_A(Number((f=t.maxOccurrences)!=null?f:a),o,40),c=n(t.placeholder||""),l=Array.isArray(t.aliases)?t.aliases.map(A=>n(A)).filter(Boolean):[],u=[r,...l].map(A=>e5(A,n)).filter(Boolean);return{id:i,title:r,minOccurrences:o,maxOccurrences:s,placeholder:c,matchKeys:Array.from(new Set(u))}}function cP(t,e){const n=Array.isArray(t)&&t.length>0?t:sP(),r=[],i=new Set;return n.forEach((o,a)=>{const s=e(o.label||"");if(!s)return;const c=aP(e(o.id||s))||`schema-${a+1}`;let l=c,u=1;for(;i.has(l);)l=`${c}-${u++}`;i.add(l);const d=Array.isArray(o.sections)?o.sections:[],f=[],A=new Set;if(d.forEach((m,g)=>{const b=ede(m,g,e);if(!b)return;let y=b.id,w=1;for(;A.has(y);)y=`${b.id}-${w++}`;A.add(y),f.push({...b,id:y})}),f.length===0)return;const h=new Map,p=new Map;f.forEach((m,g)=>{p.set(m.id,g),m.matchKeys.forEach(b=>{h.has(b)||h.set(b,m)})}),r.push({id:l,label:s,description:e(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:h,orderBySectionId:p})}),r.length>0?r:cP(sP(),e)}function Pw(t={}){var o,a,s;const e=t.normalizeText||Jue,n=cP(t.schemas,e),r=e(t.defaultSchemaId||""),i=n.some(c=>c.id===r)?r:((o=n[0])==null?void 0:o.id)||null;return{schemas:n,defaultSchemaId:i,enableRealtime:t.enableRealtime!==!1,debounceMs:_A(Number((a=t.debounceMs)!=null?a:260),60,2e3),maxIssues:_A(Number((s=t.maxIssues)!=null?s:80),5,500),labels:{...Yue,...t.labels||{}},normalizeText:e}}function tde(t){return{schemas:t.schemas.map(e=>({id:e.id,label:e.label,description:e.description||void 0,strictOrder:e.strictOrder,allowUnknownHeadings:e.allowUnknownHeadings,sections:e.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:t.defaultSchemaId||void 0,enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxIssues:t.maxIssues,labels:{...t.labels},normalizeText:t.normalizeText}}function t5(t){return t.closest(JS)||t}function gy(t){if(!t)return null;if(t.matches(Da))return t;const e=t.querySelector(Da);return e instanceof HTMLElement?e:null}function nde(){if(typeof window=="undefined")return null;const t=window[rP];if(!(t instanceof HTMLElement))return null;window[rP]=null;const e=gy(t);if(e)return e;const n=t.closest(JS);if(n){const i=gy(n);if(i)return i}const r=t.closest(Da);return r instanceof HTMLElement?r:null}function rde(t){const e=t.closest("[data-editora-editor]");if(e&&gy(e)===t)return e;let n=t;for(;n;){if(n.matches(JS)&&(n===t||gy(n)===t))return n;n=n.parentElement}return t5(t)}function lP(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Hw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function ide(t){const e=t5(t);if(Hw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Hw(n)?!0:Hw(document.documentElement)||Hw(document.body)}function n5(t,e){t.classList.remove("rte-doc-schema-theme-dark"),ide(e)&&t.classList.add("rte-doc-schema-theme-dark")}function ode(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,Da)||(n=l.matches)!=null&&n.call(l,`.${jn}`)||(r=l.querySelector)!=null&&r.call(l,Da)||(i=l.querySelector)!=null&&i.call(l,`.${jn}`))return!0}}return!1}function Qw(){Array.from(Ow).forEach(e=>{e.isConnected||o5(e)})}function bl(t,e=!0,n=!0){var s;if(Qw(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const c=gy(t.editorElement);if(c)return c}const r=nde();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const c=(s=lP(i.getRangeAt(0).startContainer))==null?void 0:s.closest(Da);if(c)return c}const o=document.activeElement;if(o){if(o.matches(Da))return o;const c=o.closest(Da);if(c)return c}if(n&&la&&la.isConnected)return la;if(!e)return null;const a=document.querySelector(Da);return a instanceof HTMLElement?a:null}function ade(t){const e=t.target;if(e){const r=e.closest(`.${jn}`);if(r){const o=Array.from(ca.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=e.closest(Da);if(i)return i}const n=document.activeElement;if(n){const r=n.closest(`.${jn}`);if(r){const o=Array.from(ca.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=n.closest(Da);if(i)return i}return null}function uP(t,e,n){const r=rde(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function r5(t){const e=Rw.get(t);typeof e=="number"&&(window.clearTimeout(e),Rw.delete(t))}function Cu(t,e){return e&&t.schemas.find(n=>n.id===e)||null}function i5(t){var e;return t.defaultSchemaId||((e=t.schemas[0])==null?void 0:e.id)||null}function Ni(t,e){Tn.has(t)||Tn.set(t,e);let n=hy.get(t);return n||(n={activeSchemaId:i5(e),realtimeEnabled:e.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},hy.set(t,n)),(!n.activeSchemaId||!Cu(e,n.activeSchemaId))&&(n.activeSchemaId=i5(e)),Ow.add(t),n}function o5(t){var e;r5(t),(e=ca.get(t))==null||e.remove(),ca.delete(t),py.delete(t),Tn.delete(t),Nw.delete(t),hy.delete(t),Ow.delete(t),la===t&&(la=null)}function a5(t){return py.get(t)===!0}function dP(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function s5(t,e){if(!e.classList.contains("show"))return;const n=t5(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,440),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function $w(t,e){const n=t.querySelector(".rte-doc-schema-live");n&&(n.textContent=e)}function sde(t,e){const n=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((i,o)=>{const a=e(i.textContent||"");if(!a)return;const s=Number(i.tagName.slice(1))||0,c=e5(a,e);r.push({text:a,key:c,index:o,level:s})}),r}function fP(t,e,n){const r=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),i=[];return r.forEach(o=>{var d;const a=n(o.textContent||"");if(!a)return;const s=e5(a,n),c=s&&e.matchKeyToSection.get(s)||null,l=c&&(d=e.orderBySectionId.get(c.id))!=null?d:null,u=_A(Number(o.tagName.slice(1))||0,1,6);i.push({element:o,level:u,section:c,order:l})}),i}function cde(t,e=2){const n=t.filter(c=>c.section).map(c=>c.level),r=n.length>0?n:t.map(c=>c.level);if(r.length===0)return e;const i=new Map;r.forEach((c,l)=>{i.has(c)||i.set(c,{count:0,firstIndex:l});const u=i.get(c);u.count+=1});let o=e,a=-1,s=Number.MAX_SAFE_INTEGER;return i.forEach((c,l)=>{(c.count>a||c.count===a&&c.firstIndex<s||c.count===a&&c.firstIndex===s&&l<o)&&(o=l,a=c.count,s=c.firstIndex)}),_A(o,1,6)}function lde(t){var o;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(((o=lP(n.startContainer))==null?void 0:o.closest(Da))!==t)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const a=n.startContainer,s=a.childNodes[n.startOffset]||null;return{parent:a,referenceNode:s}}const i=n.startContainer.parentNode;return i?{parent:i,referenceNode:n.startContainer.nextSibling||null}:null}function ude(t,e,n,r){var c;const i=fP(t,n,r),o=n.orderBySectionId.get(e.id);if(typeof o!="number"||i.length===0)return{parent:t,referenceNode:null};const a=i.find(l=>typeof l.order=="number"&&l.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let s=-1;for(let l=0;l<i.length;l+=1){const u=i[l];typeof u.order=="number"&&u.order<o&&(s=l)}if(s>=0){const l=((c=i[s+1])==null?void 0:c.element)||null;return{parent:(l==null?void 0:l.parentNode)||i[s].element.parentNode||t,referenceNode:l}}return{parent:t,referenceNode:null}}function dde(t,e,n,r){const i=t.ownerDocument||document,o=`h${_A(r,1,6)}`,a=i.createElement(o);a.setAttribute("data-doc-schema-section",e.id),a.textContent=e.title;const s=i.createElement("p");return s.textContent=e.placeholder||n.labels.defaultPlaceholderText,[a,s]}function my(t,e,n,r={}){return oP+=1,{id:`doc-schema-issue-${oP}`,type:t,severity:e,message:n,...r}}function zw(t,e,n){return t.replace(/\{section\}/g,e||"").replace(/\{heading\}/g,n||"").trim()}function fde(t,e,n){var c;const r=sde(t,n.normalizeText),i=[],o=new Map,a=[];for(let l=0;l<r.length&&!(i.length>=n.maxIssues);l+=1){const u=r[l];if(!u.key)continue;const d=e.matchKeyToSection.get(u.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:u});continue}e.allowUnknownHeadings||i.push(my("unknown-heading","warning",zw(n.labels.unknownHeadingMessage,null,u.text),{headingText:u.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let s=0;for(let l=0;l<e.sections.length&&!(i.length>=n.maxIssues);l+=1){const u=e.sections[l],d=o.get(u.id)||0;d<u.minOccurrences&&(s+=1,i.push(my("missing-section","error",zw(n.labels.missingSectionMessage,u.title,null),{sectionId:u.id,sectionTitle:u.title,suggestion:`Add heading "${u.title}" to satisfy schema requirements.`}))),d>u.maxOccurrences&&i.length<n.maxIssues&&i.push(my("duplicate-section","warning",zw(n.labels.duplicateSectionMessage,u.title,null),{sectionId:u.id,sectionTitle:u.title,suggestion:`Keep at most ${u.maxOccurrences} instance(s) of "${u.title}".`}))}if(e.strictOrder&&i.length<n.maxIssues){let l=-1;for(let u=0;u<a.length&&!(i.length>=n.maxIssues);u+=1){const d=a[u],f=(c=e.orderBySectionId.get(d.section.id))!=null?c:u;f<l?i.push(my("out-of-order","warning",zw(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):l=f}}return{issues:i,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:s}}function AP(t){const e=Tn.get(t)||Is,n=hy.get(t),r=e?Cu(e,(n==null?void 0:n.activeSchemaId)||null):null;return{activeSchemaId:(n==null?void 0:n.activeSchemaId)||null,activeSchemaLabel:(r==null?void 0:r.label)||null,realtimeEnabled:(n==null?void 0:n.realtimeEnabled)===!0,issues:n!=null&&n.issues?n.issues.map(i=>({...i})):[],headingCount:(n==null?void 0:n.headingCount)||0,recognizedHeadingCount:(n==null?void 0:n.recognizedHeadingCount)||0,missingCount:(n==null?void 0:n.missingCount)||0,lastRunAt:(n==null?void 0:n.lastRunAt)||null}}function Kd(t){const e=hy.get(t);uP(t,"toggleDocSchemaPanel",a5(t)),uP(t,"toggleDocSchemaRealtime",(e==null?void 0:e.realtimeEnabled)===!0)}function DA(t){const e=ca.get(t);if(!e)return;const n=Tn.get(t)||Is;if(!n)return;const r=Ni(t,n),i=Cu(n,r.activeSchemaId),o=e.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=e.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(g=>`<option value="${ml(g.id)}">${ml(g.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const s=e.querySelector(".rte-doc-schema-description");if(s){const g=(i==null?void 0:i.description)||"";s.textContent=g?`${n.labels.schemaDescriptionPrefix}: ${g}`:"",s.hidden=!g}const c=e.querySelector(".rte-doc-schema-summary");if(c){const g=(i==null?void 0:i.label)||"N/A",b=r.issues.length;c.textContent=`${n.labels.summaryPrefix}: ${g} • ${b} issue${b===1?"":"s"}`}const l=e.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const u=e.querySelector(".rte-doc-schema-shortcut");u&&(u.textContent=n.labels.shortcutText);const d=e.querySelector('[data-action="run-validation"]');d&&(d.textContent=n.labels.validateText);const f=e.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const g=r.issues.some(b=>b.type==="missing-section");f.disabled=!g||dP(t)}const A=e.querySelector('[data-action="toggle-realtime"]');A&&(A.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,A.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const h=e.querySelector('[data-action="close"]');h&&h.setAttribute("aria-label",n.labels.closeText);const p=e.querySelector(".rte-doc-schema-issues"),m=e.querySelector(".rte-doc-schema-empty");p&&(p.setAttribute("aria-label",n.labels.issueListLabel),r.issues.length===0?(p.innerHTML="",m&&(m.hidden=!1,m.textContent=n.labels.noIssuesText)):(m&&(m.hidden=!0),p.innerHTML=r.issues.map(g=>{const b=g.severity==="error"?"error":g.severity==="warning"?"warning":"info",y=g.sectionTitle||g.headingText||"";return`
|
|
3122
|
+
`,c.appendChild(l),document.body.appendChild(c);const u=l.querySelector(".rte-data-binding-key"),d=l.querySelector(".rte-data-binding-fallback"),f=l.querySelector(".rte-data-binding-format"),A=l.querySelector(".rte-data-binding-currency"),h=()=>{const x=(f==null?void 0:f.value)==="currency",k=A==null?void 0:A.closest(".rte-data-binding-field");k&&(k.style.display=x?"grid":"none")};h(),f==null||f.addEventListener("change",h);const p=()=>{c.removeEventListener("click",g),c.removeEventListener("keydown",w,!0),document.removeEventListener("keydown",m,!0),c.parentNode&&c.parentNode.removeChild(c),ly=null,t.focus({preventScroll:!0})},m=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),p())},g=x=>{x.target===c&&p()},b=x=>{if(x.key!=="Tab")return;const k=Array.from(l.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(k.length===0)return;const T=k[0],_=k[k.length-1],B=document.activeElement;if(x.shiftKey&&B===T){x.preventDefault(),_.focus();return}!x.shiftKey&&B===_&&(x.preventDefault(),T.focus())},y=async()=>{const x=((u==null?void 0:u.value)||"").trim();if(!x){u==null||u.focus();return}const k=fy({key:x,fallback:((d==null?void 0:d.value)||"").trim(),format:(f==null?void 0:f.value)||e.defaultFormat,currency:((A==null?void 0:A.value)||"USD").trim().toUpperCase()},e),T=t.innerHTML;if(i){GS(i,k,a);const _=pc.get(t)===!0,B=_?await Ay(t,e):void 0;BA(i,e,_,B)}else{if(o)try{YP(t,o)}catch(I){}const _=JP(k,a);if(t7(t,_),pc.get(t)===!0){const I=await Ay(t,e);BA(_,e,!0,I)}}KS(t),VS(t,T),p()},w=x=>{if(x.key==="Escape"){x.preventDefault(),p();return}b(x),x.key==="Enter"&&!x.shiftKey&&x.target instanceof HTMLInputElement&&(x.preventDefault(),y())};l.addEventListener("click",x=>{const k=x.target,T=k==null?void 0:k.getAttribute("data-action");if(T){if(T==="cancel"){p();return}T==="save"&&y()}}),c.addEventListener("click",g),c.addEventListener("keydown",w,!0),document.addEventListener("keydown",m,!0),ly={cleanup:p},u==null||u.focus()}function Gue(t){Dw=t,Wp||(Wp=e=>{const n=e.target,r=n==null?void 0:n.closest(zd);if(!r)return;Sa=r,Yi.has(r)||Yi.set(r,t);const i=Yi.get(r)||t;Iw(r,i);const o=pc.get(r)===!0;YS(r,o,i),o||Array.from(r.querySelectorAll(jp)).forEach(s=>BA(s,i,!1))},document.addEventListener("focusin",Wp,!0)),qp||(qp=e=>{if(document.querySelector(`.${lo}`))return;const n=e.target;if(n!=null&&n.closest("input, textarea, select"))return;const r=jd(void 0,!1);if(!r||dy(r))return;const i=Yi.get(r)||Dw||t,o=n==null?void 0:n.closest(jp);if(o&&(e.key==="Enter"||e.key===" ")){e.preventDefault(),e.stopPropagation(),Sa=r,SA(r,i,"edit",void 0,o);return}if(Kue(e)){e.preventDefault(),e.stopPropagation();const a=XS(r);a?SA(r,i,"edit",void 0,a):SA(r,i,"insert");return}if(Vue(e)){e.preventDefault(),e.stopPropagation();const a=pc.get(r)!==!0;Uw(r,i,a)}},document.addEventListener("keydown",qp,!0)),Kp||(Kp=e=>{if(document.querySelector(`.${lo}`)||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;const n=e.target,r=n==null?void 0:n.closest(jp);if(!r)return;const i=r.closest(zd);if(!i||dy(i))return;const o=Yi.get(i)||Dw||t;Yi.set(i,o),Sa=i,e.preventDefault(),e.stopPropagation(),r.focus({preventScroll:!0}),SA(i,o,"edit",void 0,r)},document.addEventListener("click",Kp,!0))}function Xue(){Wp&&(document.removeEventListener("focusin",Wp,!0),Wp=null),qp&&(document.removeEventListener("keydown",qp,!0),qp=null),Kp&&(document.removeEventListener("click",Kp,!0),Kp=null),Dw=null,Sa=null}const ZS=Object.freeze(Object.defineProperty({__proto__:null,DataBindingPlugin:(t={})=>{const e=VP(t);return $ue(),{name:"dataBinding",toolbar:[{id:"dataBindingTools",label:"Data Binding",type:"group",command:"openDataBindingDialog",items:[{id:"dataBinding",label:"Data Binding",command:"openDataBindingDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 4a3 3 0 0 0-3 3v3h2V7a1 1 0 0 1 1-1h3V4H7Zm10 0h-3v2h3a1 1 0 0 1 1 1v3h2V7a3 3 0 0 0-3-3ZM4 14v3a3 3 0 0 0 3 3h3v-2H7a1 1 0 0 1-1-1v-3H4Zm14 0v3a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3v-3h-2ZM8.5 12a1.5 1.5 0 1 1 0-3h7a1.5 1.5 0 0 1 0 3h-7Zm0 4a1.5 1.5 0 1 1 0-3h4a1.5 1.5 0 0 1 0 3h-4Z" fill="currentColor"></path></svg>'},{id:"dataBindingPreview",label:"Data Preview",command:"toggleDataBindingPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3c-4.4 0-8 1.3-8 3v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6c0-1.7-3.6-3-8-3Zm0 2c3.9 0 6 .9 6 1s-2.1 1-6 1-6-.9-6-1 2.1-1 6-1Zm0 4c3 0 5.6-.5 7-1.3V11c0 .9-2.7 2-7 2s-7-1.1-7-2V7.7C6.4 8.5 9 9 12 9Zm0 6c-4.3 0-7-1.1-7-2v3c0 .9 2.7 2 7 2s7-1.1 7-2v-3c0 .9-2.7 2-7 2Z" fill="currentColor"></path><path d="M16.5 9.4a1 1 0 0 1 1.4 0l1.1 1.1 1.8-1.8a1 1 0 1 1 1.4 1.4l-2.5 2.5a1 1 0 0 1-1.4 0l-1.8-1.8a1 1 0 0 1 0-1.4Z" fill="currentColor"></path></svg>'}]}],commands:{openDataBindingDialog:(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o),Iw(i,o);const a=n==null?void 0:n.target;if(a==="insert")return SA(i,o,"insert",n),!0;const s=XS(i);return a==="edit"||s?!s&&a==="edit"?!1:(SA(i,o,"edit",n,s||void 0),!0):(SA(i,o,"insert",n),!0)},insertDataBindingToken:async(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=fy(n||{},o);if(!a.key)return!1;const s=i.innerHTML,c=JP(a,o.labels);if(t7(i,c),pc.get(i)===!0){const u=await Ay(i,o);BA(c,o,!0,u)}return KS(i),VS(i,s),!0},editDataBindingToken:async(n,r)=>{const i=jd(r);if(!i||dy(i))return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=XS(i);if(!a)return!1;const s=Fw(a,o),c=fy({...s,...n||{}},o);if(!c.key)return!1;const l=i.innerHTML;GS(a,c,o.labels);const u=pc.get(i)===!0,d=u?await Ay(i,o):void 0;return BA(a,o,u,d),KS(i),VS(i,l),!0},toggleDataBindingPreview:async(n,r)=>{const i=jd(r);if(!i)return!1;Sa=i;const o=Yi.get(i)||e;Yi.set(i,o);const a=typeof n=="boolean"?n:pc.get(i)!==!0;return await Uw(i,o,a),!0},setDataBindingData:async(n,r)=>{const i=jd(r);if(!i)return!1;if(Sa=i,n&&typeof n=="object"?(qS.set(i,n),cy.set(i,{timestamp:Date.now(),data:n})):(qS.delete(i),cy.delete(i)),pc.get(i)===!0){const o=Yi.get(i)||e;await Uw(i,o,!0)}return!0},refreshDataBindings:async(n,r)=>{const i=jd(r);if(!i)return!1;Sa=i,cy.delete(i);const o=Yi.get(i)||e;Yi.set(i,o);const a=pc.get(i)===!0;return await Uw(i,o,a),!0}},keymap:{"Mod-Alt-Shift-d":"openDataBindingDialog","Mod-Alt-Shift-D":"openDataBindingDialog","Mod-Alt-Shift-b":"toggleDataBindingPreview","Mod-Alt-Shift-B":"toggleDataBindingPreview",F7:"openDataBindingDialog",F8:"toggleDataBindingPreview"},init:function(r){_w+=1;const i=this&&typeof this.__pluginConfig=="object"?VP({...e,...this.__pluginConfig}):e;Gue(i);const o=jd(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);if(o){Sa=o,Yi.set(o,i),Iw(o,i);const a=pc.get(o)===!0;YS(o,a,i)}},destroy:()=>{_w=Math.max(0,_w-1),_w===0&&(e7(),Xue())}}}},Symbol.toStringTag,{value:"Module"})),Da=".rte-content, .editora-content",JS="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",r7="__editoraCommandEditorRoot",i7="rte-doc-schema-styles",jn="rte-doc-schema-panel",Ls="document-schema",gl="doc-schema",qd="docSchema",Fs=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Yue={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},Tn=new WeakMap,Nw=new WeakMap,hy=new WeakMap,ca=new Map,py=new WeakMap,Rw=new WeakMap,Ow=new Set;let Mw=0,Zue=0,o7=0,Is=null,la=null,Vp=null,Gp=null,Xp=null,Wd=null,Yp=null;function ml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jue(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function _A(t,e,n){return Number.isFinite(t)?Math.max(e,Math.min(n,t)):e}function a7(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function e5(t,e){return e(t).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function s7(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function ede(t,e,n){var d,f;const r=n(t.title||"");if(!r)return null;const i=a7(n(t.id||r))||`section-${e+1}`,o=_A(Number((d=t.minOccurrences)!=null?d:1),0,20),a=Math.max(1,o),s=_A(Number((f=t.maxOccurrences)!=null?f:a),o,40),c=n(t.placeholder||""),l=Array.isArray(t.aliases)?t.aliases.map(A=>n(A)).filter(Boolean):[],u=[r,...l].map(A=>e5(A,n)).filter(Boolean);return{id:i,title:r,minOccurrences:o,maxOccurrences:s,placeholder:c,matchKeys:Array.from(new Set(u))}}function c7(t,e){const n=Array.isArray(t)&&t.length>0?t:s7(),r=[],i=new Set;return n.forEach((o,a)=>{const s=e(o.label||"");if(!s)return;const c=a7(e(o.id||s))||`schema-${a+1}`;let l=c,u=1;for(;i.has(l);)l=`${c}-${u++}`;i.add(l);const d=Array.isArray(o.sections)?o.sections:[],f=[],A=new Set;if(d.forEach((m,g)=>{const b=ede(m,g,e);if(!b)return;let y=b.id,w=1;for(;A.has(y);)y=`${b.id}-${w++}`;A.add(y),f.push({...b,id:y})}),f.length===0)return;const h=new Map,p=new Map;f.forEach((m,g)=>{p.set(m.id,g),m.matchKeys.forEach(b=>{h.has(b)||h.set(b,m)})}),r.push({id:l,label:s,description:e(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:h,orderBySectionId:p})}),r.length>0?r:c7(s7(),e)}function Pw(t={}){var o,a,s;const e=t.normalizeText||Jue,n=c7(t.schemas,e),r=e(t.defaultSchemaId||""),i=n.some(c=>c.id===r)?r:((o=n[0])==null?void 0:o.id)||null;return{schemas:n,defaultSchemaId:i,enableRealtime:t.enableRealtime!==!1,debounceMs:_A(Number((a=t.debounceMs)!=null?a:260),60,2e3),maxIssues:_A(Number((s=t.maxIssues)!=null?s:80),5,500),labels:{...Yue,...t.labels||{}},normalizeText:e}}function tde(t){return{schemas:t.schemas.map(e=>({id:e.id,label:e.label,description:e.description||void 0,strictOrder:e.strictOrder,allowUnknownHeadings:e.allowUnknownHeadings,sections:e.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:t.defaultSchemaId||void 0,enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxIssues:t.maxIssues,labels:{...t.labels},normalizeText:t.normalizeText}}function t5(t){return t.closest(JS)||t}function gy(t){if(!t)return null;if(t.matches(Da))return t;const e=t.querySelector(Da);return e instanceof HTMLElement?e:null}function nde(){if(typeof window=="undefined")return null;const t=window[r7];if(!(t instanceof HTMLElement))return null;window[r7]=null;const e=gy(t);if(e)return e;const n=t.closest(JS);if(n){const i=gy(n);if(i)return i}const r=t.closest(Da);return r instanceof HTMLElement?r:null}function rde(t){const e=t.closest("[data-editora-editor]");if(e&&gy(e)===t)return e;let n=t;for(;n;){if(n.matches(JS)&&(n===t||gy(n)===t))return n;n=n.parentElement}return t5(t)}function l7(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Hw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function ide(t){const e=t5(t);if(Hw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Hw(n)?!0:Hw(document.documentElement)||Hw(document.body)}function n5(t,e){t.classList.remove("rte-doc-schema-theme-dark"),ide(e)&&t.classList.add("rte-doc-schema-theme-dark")}function ode(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,Da)||(n=l.matches)!=null&&n.call(l,`.${jn}`)||(r=l.querySelector)!=null&&r.call(l,Da)||(i=l.querySelector)!=null&&i.call(l,`.${jn}`))return!0}}return!1}function Qw(){Array.from(Ow).forEach(e=>{e.isConnected||o5(e)})}function bl(t,e=!0,n=!0){var s;if(Qw(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const c=gy(t.editorElement);if(c)return c}const r=nde();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const c=(s=l7(i.getRangeAt(0).startContainer))==null?void 0:s.closest(Da);if(c)return c}const o=document.activeElement;if(o){if(o.matches(Da))return o;const c=o.closest(Da);if(c)return c}if(n&&la&&la.isConnected)return la;if(!e)return null;const a=document.querySelector(Da);return a instanceof HTMLElement?a:null}function ade(t){const e=t.target;if(e){const r=e.closest(`.${jn}`);if(r){const o=Array.from(ca.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=e.closest(Da);if(i)return i}const n=document.activeElement;if(n){const r=n.closest(`.${jn}`);if(r){const o=Array.from(ca.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=n.closest(Da);if(i)return i}return null}function u7(t,e,n){const r=rde(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function r5(t){const e=Rw.get(t);typeof e=="number"&&(window.clearTimeout(e),Rw.delete(t))}function Cu(t,e){return e&&t.schemas.find(n=>n.id===e)||null}function i5(t){var e;return t.defaultSchemaId||((e=t.schemas[0])==null?void 0:e.id)||null}function Ni(t,e){Tn.has(t)||Tn.set(t,e);let n=hy.get(t);return n||(n={activeSchemaId:i5(e),realtimeEnabled:e.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},hy.set(t,n)),(!n.activeSchemaId||!Cu(e,n.activeSchemaId))&&(n.activeSchemaId=i5(e)),Ow.add(t),n}function o5(t){var e;r5(t),(e=ca.get(t))==null||e.remove(),ca.delete(t),py.delete(t),Tn.delete(t),Nw.delete(t),hy.delete(t),Ow.delete(t),la===t&&(la=null)}function a5(t){return py.get(t)===!0}function d7(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function s5(t,e){if(!e.classList.contains("show"))return;const n=t5(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,440),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function $w(t,e){const n=t.querySelector(".rte-doc-schema-live");n&&(n.textContent=e)}function sde(t,e){const n=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((i,o)=>{const a=e(i.textContent||"");if(!a)return;const s=Number(i.tagName.slice(1))||0,c=e5(a,e);r.push({text:a,key:c,index:o,level:s})}),r}function f7(t,e,n){const r=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),i=[];return r.forEach(o=>{var d;const a=n(o.textContent||"");if(!a)return;const s=e5(a,n),c=s&&e.matchKeyToSection.get(s)||null,l=c&&(d=e.orderBySectionId.get(c.id))!=null?d:null,u=_A(Number(o.tagName.slice(1))||0,1,6);i.push({element:o,level:u,section:c,order:l})}),i}function cde(t,e=2){const n=t.filter(c=>c.section).map(c=>c.level),r=n.length>0?n:t.map(c=>c.level);if(r.length===0)return e;const i=new Map;r.forEach((c,l)=>{i.has(c)||i.set(c,{count:0,firstIndex:l});const u=i.get(c);u.count+=1});let o=e,a=-1,s=Number.MAX_SAFE_INTEGER;return i.forEach((c,l)=>{(c.count>a||c.count===a&&c.firstIndex<s||c.count===a&&c.firstIndex===s&&l<o)&&(o=l,a=c.count,s=c.firstIndex)}),_A(o,1,6)}function lde(t){var o;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(((o=l7(n.startContainer))==null?void 0:o.closest(Da))!==t)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const a=n.startContainer,s=a.childNodes[n.startOffset]||null;return{parent:a,referenceNode:s}}const i=n.startContainer.parentNode;return i?{parent:i,referenceNode:n.startContainer.nextSibling||null}:null}function ude(t,e,n,r){var c;const i=f7(t,n,r),o=n.orderBySectionId.get(e.id);if(typeof o!="number"||i.length===0)return{parent:t,referenceNode:null};const a=i.find(l=>typeof l.order=="number"&&l.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let s=-1;for(let l=0;l<i.length;l+=1){const u=i[l];typeof u.order=="number"&&u.order<o&&(s=l)}if(s>=0){const l=((c=i[s+1])==null?void 0:c.element)||null;return{parent:(l==null?void 0:l.parentNode)||i[s].element.parentNode||t,referenceNode:l}}return{parent:t,referenceNode:null}}function dde(t,e,n,r){const i=t.ownerDocument||document,o=`h${_A(r,1,6)}`,a=i.createElement(o);a.setAttribute("data-doc-schema-section",e.id),a.textContent=e.title;const s=i.createElement("p");return s.textContent=e.placeholder||n.labels.defaultPlaceholderText,[a,s]}function my(t,e,n,r={}){return o7+=1,{id:`doc-schema-issue-${o7}`,type:t,severity:e,message:n,...r}}function zw(t,e,n){return t.replace(/\{section\}/g,e||"").replace(/\{heading\}/g,n||"").trim()}function fde(t,e,n){var c;const r=sde(t,n.normalizeText),i=[],o=new Map,a=[];for(let l=0;l<r.length&&!(i.length>=n.maxIssues);l+=1){const u=r[l];if(!u.key)continue;const d=e.matchKeyToSection.get(u.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:u});continue}e.allowUnknownHeadings||i.push(my("unknown-heading","warning",zw(n.labels.unknownHeadingMessage,null,u.text),{headingText:u.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let s=0;for(let l=0;l<e.sections.length&&!(i.length>=n.maxIssues);l+=1){const u=e.sections[l],d=o.get(u.id)||0;d<u.minOccurrences&&(s+=1,i.push(my("missing-section","error",zw(n.labels.missingSectionMessage,u.title,null),{sectionId:u.id,sectionTitle:u.title,suggestion:`Add heading "${u.title}" to satisfy schema requirements.`}))),d>u.maxOccurrences&&i.length<n.maxIssues&&i.push(my("duplicate-section","warning",zw(n.labels.duplicateSectionMessage,u.title,null),{sectionId:u.id,sectionTitle:u.title,suggestion:`Keep at most ${u.maxOccurrences} instance(s) of "${u.title}".`}))}if(e.strictOrder&&i.length<n.maxIssues){let l=-1;for(let u=0;u<a.length&&!(i.length>=n.maxIssues);u+=1){const d=a[u],f=(c=e.orderBySectionId.get(d.section.id))!=null?c:u;f<l?i.push(my("out-of-order","warning",zw(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):l=f}}return{issues:i,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:s}}function A7(t){const e=Tn.get(t)||Is,n=hy.get(t),r=e?Cu(e,(n==null?void 0:n.activeSchemaId)||null):null;return{activeSchemaId:(n==null?void 0:n.activeSchemaId)||null,activeSchemaLabel:(r==null?void 0:r.label)||null,realtimeEnabled:(n==null?void 0:n.realtimeEnabled)===!0,issues:n!=null&&n.issues?n.issues.map(i=>({...i})):[],headingCount:(n==null?void 0:n.headingCount)||0,recognizedHeadingCount:(n==null?void 0:n.recognizedHeadingCount)||0,missingCount:(n==null?void 0:n.missingCount)||0,lastRunAt:(n==null?void 0:n.lastRunAt)||null}}function Kd(t){const e=hy.get(t);u7(t,"toggleDocSchemaPanel",a5(t)),u7(t,"toggleDocSchemaRealtime",(e==null?void 0:e.realtimeEnabled)===!0)}function DA(t){const e=ca.get(t);if(!e)return;const n=Tn.get(t)||Is;if(!n)return;const r=Ni(t,n),i=Cu(n,r.activeSchemaId),o=e.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=e.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(g=>`<option value="${ml(g.id)}">${ml(g.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const s=e.querySelector(".rte-doc-schema-description");if(s){const g=(i==null?void 0:i.description)||"";s.textContent=g?`${n.labels.schemaDescriptionPrefix}: ${g}`:"",s.hidden=!g}const c=e.querySelector(".rte-doc-schema-summary");if(c){const g=(i==null?void 0:i.label)||"N/A",b=r.issues.length;c.textContent=`${n.labels.summaryPrefix}: ${g} • ${b} issue${b===1?"":"s"}`}const l=e.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const u=e.querySelector(".rte-doc-schema-shortcut");u&&(u.textContent=n.labels.shortcutText);const d=e.querySelector('[data-action="run-validation"]');d&&(d.textContent=n.labels.validateText);const f=e.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const g=r.issues.some(b=>b.type==="missing-section");f.disabled=!g||d7(t)}const A=e.querySelector('[data-action="toggle-realtime"]');A&&(A.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,A.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const h=e.querySelector('[data-action="close"]');h&&h.setAttribute("aria-label",n.labels.closeText);const p=e.querySelector(".rte-doc-schema-issues"),m=e.querySelector(".rte-doc-schema-empty");p&&(p.setAttribute("aria-label",n.labels.issueListLabel),r.issues.length===0?(p.innerHTML="",m&&(m.hidden=!1,m.textContent=n.labels.noIssuesText)):(m&&(m.hidden=!0),p.innerHTML=r.issues.map(g=>{const b=g.severity==="error"?"error":g.severity==="warning"?"warning":"info",y=g.sectionTitle||g.headingText||"";return`
|
|
3122
3123
|
<li class="rte-doc-schema-issue ${b}" role="listitem">
|
|
3123
3124
|
<p class="rte-doc-schema-issue-message">${ml(g.message)}${y?`: <strong>${ml(y)}</strong>`:""}</p>
|
|
3124
3125
|
${g.suggestion?`<p class="rte-doc-schema-issue-suggestion">${ml(g.suggestion)}</p>`:""}
|
|
3125
3126
|
</li>
|
|
3126
|
-
`}).join(""))),e.setAttribute("aria-label",n.labels.panelAriaLabel)}function by(t,e=!1){const n=ca.get(t);n&&(n.classList.remove("show"),py.set(t,!1),Kd(t),e&&t.focus({preventScroll:!0}))}function c5(t){const e=pde(t);ca.forEach((r,i)=>{i!==t&&by(i,!1)}),e.classList.add("show"),py.set(t,!0),DA(t),s5(t,e),Kd(t);const n=e.querySelector('[data-field="schema"]');n==null||n.focus(),gc(t,"panel-open",!1)}function
|
|
3127
|
+
`}).join(""))),e.setAttribute("aria-label",n.labels.panelAriaLabel)}function by(t,e=!1){const n=ca.get(t);n&&(n.classList.remove("show"),py.set(t,!1),Kd(t),e&&t.focus({preventScroll:!0}))}function c5(t){const e=pde(t);ca.forEach((r,i)=>{i!==t&&by(i,!1)}),e.classList.add("show"),py.set(t,!0),DA(t),s5(t,e),Kd(t);const n=e.querySelector('[data-field="schema"]');n==null||n.focus(),gc(t,"panel-open",!1)}function h7(t,e){const n=a5(t);return(typeof e=="boolean"?e:!n)?c5(t):by(t,!1),!0}function Ade(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function hde(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function gc(t,e,n){const r=Tn.get(t)||Is;if(!r)return[];const i=Ni(t,r),o=ca.get(t),a=t.innerHTML;if(!n&&i.snapshot===a)return i.issues;const s=Cu(r,i.activeSchemaId);if(!s)return i.issues=[my("missing-section","error","No active schema is configured for this editor.",{suggestion:"Set `defaultSchemaId` or update schema options."})],i.headingCount=0,i.recognizedHeadingCount=0,i.missingCount=1,i.lastRunAt=new Date().toISOString(),i.snapshot=a,DA(t),Kd(t),i.issues;const c=fde(t,s,r);return i.issues=c.issues,i.headingCount=c.headingCount,i.recognizedHeadingCount=c.recognizedHeadingCount,i.missingCount=c.missingCount,i.lastRunAt=new Date().toISOString(),i.snapshot=a,DA(t),Kd(t),t.dispatchEvent(new CustomEvent("editora:doc-schema-validation",{bubbles:!0,detail:{reason:e,state:A7(t)}})),o&&$w(o,c.issues.length===0?r.labels.noIssuesText:`${c.issues.length} issue${c.issues.length===1?"":"s"} detected.`),i.issues}function p7(t){const e=Tn.get(t)||Is;if(!e)return;r5(t);const n=window.setTimeout(()=>{Rw.delete(t),gc(t,"realtime",!1)},e.debounceMs);Rw.set(t,n)}function g7(t,e){const n=Tn.get(t)||Is;if(!n)return!1;const r=Ni(t,n),i=typeof e=="boolean"?e:!r.realtimeEnabled;return r.realtimeEnabled=i,i?p7(t):r5(t),DA(t),Kd(t),!0}function m7(t){const e=Tn.get(t)||Is;if(!e)return!1;const n=Ni(t,e),r=ca.get(t);if(d7(t))return r&&$w(r,e.labels.readonlyMessage),!1;const i=Cu(e,n.activeSchemaId);if(!i)return!1;gc(t,"insert-missing-pre",!0);const o=Array.from(new Set(n.issues.filter(f=>f.type==="missing-section"&&f.sectionId).map(f=>f.sectionId))),a=i.sections.filter(f=>o.includes(f.id));if(a.length===0)return r&&$w(r,e.labels.noIssuesText),!1;const s=t.innerHTML,c=f7(t,i,e.normalizeText),l=cde(c,2),u=lde(t);a.forEach(f=>{const A=i.strictOrder?ude(t,f,i,e.normalizeText):u||{parent:t,referenceNode:null},[h,p]=dde(t,f,e,l);A.parent.insertBefore(h,A.referenceNode),A.parent.insertBefore(p,A.referenceNode)}),Ade(t,s),hde(t),gc(t,"insert-missing-post",!0);const d=a.map(f=>f.title).join(", ");return t.dispatchEvent(new CustomEvent("editora:doc-schema-insert-missing",{bubbles:!0,detail:{schemaId:i.id,sectionIds:a.map(f=>f.id)}})),r&&$w(r,`${e.labels.insertedSummaryPrefix}: ${d}`),!0}function pde(t){const e=ca.get(t);if(e)return e;const n=Tn.get(t)||Is||Pw();Ni(t,n);const r=`rte-doc-schema-panel-${Zue++}`,i=`${r}-schema`,o=document.createElement("section");return o.className=jn,o.id=r,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false"),o.setAttribute("aria-label",n.labels.panelAriaLabel),o.innerHTML=`
|
|
3127
3128
|
<header class="rte-doc-schema-header">
|
|
3128
3129
|
<h2 class="rte-doc-schema-title">${ml(n.labels.panelTitle)}</h2>
|
|
3129
3130
|
<button type="button" class="rte-doc-schema-icon-btn" data-action="close" aria-label="${ml(n.labels.closeText)}">✕</button>
|
|
@@ -3146,7 +3147,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3146
3147
|
</div>
|
|
3147
3148
|
</div>
|
|
3148
3149
|
<div class="rte-doc-schema-live" aria-live="polite" aria-atomic="true"></div>
|
|
3149
|
-
`,o.addEventListener("click",a=>{const s=a.target,c=s==null?void 0:s.closest("[data-action]");if(!c)return;const l=c.getAttribute("data-action");if(l==="close"){by(t,!0);return}if(l==="run-validation"){gc(t,"panel-button",!0);return}if(l==="insert-missing"){
|
|
3150
|
+
`,o.addEventListener("click",a=>{const s=a.target,c=s==null?void 0:s.closest("[data-action]");if(!c)return;const l=c.getAttribute("data-action");if(l==="close"){by(t,!0);return}if(l==="run-validation"){gc(t,"panel-button",!0);return}if(l==="insert-missing"){m7(t);return}l==="toggle-realtime"&&g7(t)}),o.addEventListener("change",a=>{const s=a.target;if(!(s instanceof HTMLSelectElement)||s.getAttribute("data-field")!=="schema")return;const c=Tn.get(t)||Is;if(!c)return;const l=Ni(t,c),u=s.value;Cu(c,u)&&(l.activeSchemaId=u,l.snapshot="",gc(t,"schema-change",!0))}),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),by(t,!0))}),n5(o,t),document.body.appendChild(o),ca.set(t,o),py.set(t,!1),DA(t),o}function b7(t){return typeof t.key=="string"?t.key.toLowerCase():""}function gde(t){const e=b7(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="g"}function mde(t){const e=b7(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function bde(t){Is=t,Vp||(Vp=e=>{Qw();const n=e.target,r=n==null?void 0:n.closest(Da);if(!r)return;const i=Tn.get(r)||t;Ni(r,i),Tn.set(r,i),la=r,Kd(r);const o=ca.get(r);o&&(n5(o,r),s5(r,o),DA(r))},document.addEventListener("focusin",Vp,!0)),Gp||(Gp=e=>{const n=e.target,r=n==null?void 0:n.closest(Da);if(!r)return;const i=Tn.get(r)||Is;!i||!Ni(r,i).realtimeEnabled||p7(r)},document.addEventListener("input",Gp,!0)),Xp||(Xp=e=>{if(e.defaultPrevented)return;const n=e.target;if(n!=null&&n.closest(`.${jn}`)&&e.key!=="Escape")return;const r=ade(e);if(!r)return;const i=Tn.get(r)||Is||t;if(Ni(r,i),Tn.set(r,i),la=r,e.key==="Escape"&&a5(r)){e.preventDefault(),by(r,!0);return}if(gde(e)){e.preventDefault(),e.stopPropagation(),h7(r);return}mde(e)&&(e.preventDefault(),e.stopPropagation(),gc(r,"shortcut",!0))},document.addEventListener("keydown",Xp,!0)),Wd||(Wd=()=>{Qw(),ca.forEach((e,n)=>{!n.isConnected||!e.isConnected||(n5(e,n),s5(n,e))})},window.addEventListener("scroll",Wd,!0),window.addEventListener("resize",Wd)),!Yp&&typeof MutationObserver!="undefined"&&document.body&&(Yp=new MutationObserver(e=>{ode(e)&&Qw()}),Yp.observe(document.body,{childList:!0,subtree:!0}))}function yde(){Vp&&(document.removeEventListener("focusin",Vp,!0),Vp=null),Gp&&(document.removeEventListener("input",Gp,!0),Gp=null),Xp&&(document.removeEventListener("keydown",Xp,!0),Xp=null),Wd&&(window.removeEventListener("scroll",Wd,!0),window.removeEventListener("resize",Wd),Wd=null),Yp&&(Yp.disconnect(),Yp=null),ca.forEach(e=>e.remove()),ca.clear(),Array.from(Ow).forEach(e=>o5(e)),Is=null,la=null}function vde(){if(typeof document=="undefined"||document.getElementById(i7))return;const t=document.createElement("style");t.id=i7,t.textContent=`
|
|
3150
3151
|
.rte-toolbar-group-items.${Ls},
|
|
3151
3152
|
.editora-toolbar-group-items.${Ls},
|
|
3152
3153
|
.rte-toolbar-group-items.${gl},
|
|
@@ -3515,7 +3516,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3515
3516
|
grid-template-columns: 1fr;
|
|
3516
3517
|
}
|
|
3517
3518
|
}
|
|
3518
|
-
`,document.head.appendChild(t)}const l5=Object.freeze(Object.defineProperty({__proto__:null,DocSchemaPlugin:(t={})=>{const e=Pw(t),n=new Set;return vde(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 4.5h12A1.5 1.5 0 0 1 19.5 6v12A1.5 1.5 0 0 1 18 19.5H6A1.5 1.5 0 0 1 4.5 18V6A1.5 1.5 0 0 1 6 4.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 4.5 6.5v5c0 4.8 3.1 8.9 7.5 10 4.4-1.1 7.5-5.2 7.5-10v-5L12 3.5Z" stroke="currentColor" stroke-width="1.6"/><path d="m9 12.5 2 2 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}]}],commands:{docSchema:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,c5(o),!0},openDocSchemaPanel:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,c5(o),!0},toggleDocSchemaPanel:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,hP(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,gc(o,"command",!0),!0},insertMissingDocSchemaSections:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,mP(o)},toggleDocSchemaRealtime:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,gP(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e,s=Ni(o,a);Tn.set(o,a);const c=typeof r=="string"?r:(r==null?void 0:r.schemaId)||(r==null?void 0:r.id);return!c||!Cu(a,c)?!1:(s.activeSchemaId=c,s.snapshot="",gc(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,i)=>{const o=bl(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=Tn.get(o)||e,s=Nw.get(o)||tde(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:s.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Pw(c);Tn.set(o,l),Nw.set(o,c);const u=Ni(o,l);return typeof r.enableRealtime=="boolean"&&(u.realtimeEnabled=r.enableRealtime),(!u.activeSchemaId||!Cu(l,u.activeSchemaId))&&(u.activeSchemaId=i5(l)),typeof r.defaultSchemaId=="string"&&Cu(l,r.defaultSchemaId)&&(u.activeSchemaId=r.defaultSchemaId),u.snapshot="",gc(o,"set-options",!0),DA(o),Kd(o),!0},getDocSchemaState:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;Ni(o,a);const s=AP(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__docSchemaState=s,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(i){Mw+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=Pw(o);bde(a);const s=bl(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);s&&(la=s,n.add(s),Ni(s,a),Tn.set(s,a),Nw.set(s,o),Kd(s),gc(s,"init",!0))},destroy:()=>{n.forEach(r=>o5(r)),n.clear(),Mw=Math.max(0,Mw-1),!(Mw>0)&&yde()}}}},Symbol.toStringTag,{value:"Module"})),La=".rte-content, .editora-content",u5="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",yP="__editoraCommandEditorRoot",vP="rte-translation-workflow-styles",un="rte-translation-workflow-panel",Us="translation-workflow",yl="translationWorkflow",uo=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',wP=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),xP=new Set(["ArrowUp","ArrowDown","Home","End"]),EP=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],wde={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},cn=new WeakMap,jw=new WeakMap,LA=new WeakMap,Ri=new Map,yy=new WeakMap,qw=new WeakMap,vy=new Set;let Ww=0,xde=0,CP=0,Ede=0,fo=null,Ro=null,Zp=null,Jp=null,eg=null,tg=null,Vd=null,ng=null;function sr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Cde(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function FA(t,e,n){return Number.isFinite(t)?Math.max(e,Math.min(n,t)):e}function Tu(t){return(t||"").trim()||"en-US"}function wy(t){return t.trim().toLowerCase()}function Tde(t){return t.replace(/"/g,""")}function kde(t,e=120){return t.length<=e?t:`${t.slice(0,Math.max(0,e-1)).trimEnd()}…`}function TP(t){const e=t.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!e||e.length===0?[]:e.map(n=>n.trim()).filter(Boolean)}function Bde(t,e){const n=TP(t).sort(),r=TP(e).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return!1;return!0}function Sde(t,e){const n=Array.isArray(e)&&e.length>0?e:EP,r=[],i=new Set;return n.forEach(o=>{var c,l;const a=wy(o.locale||"");if(!a)return;const s=a;i.has(s)||(i.add(s),r.push({locale:s,label:(o.label||a).trim()||a,minLengthRatio:FA(Number((c=o.minLengthRatio)!=null?c:.5),.1,3),maxLengthRatio:FA(Number((l=o.maxLengthRatio)!=null?l:1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),t.forEach(o=>{const a=wy(o);if(i.has(a))return;const s=EP.find(c=>a.startsWith(c.locale));r.push(s?{...s,locale:a,label:o}:{locale:a,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),r}function Kw(t={}){var s,c,l,u;const e=t.normalizeText||Cde,n=Tu(t.sourceLocale||"en-US"),r=Tu(t.targetLocale||"fr-FR"),i=new Set([n,r]);(Array.isArray(t.locales)?t.locales:[]).forEach(d=>{if(typeof d!="string")return;const f=Tu(d);i.add(f)});const o=Array.from(i),a=Sde(o,t.localeRules);return{sourceLocale:n,targetLocale:r,locales:o,localeRules:a,enableRealtime:t.enableRealtime!==!1,debounceMs:FA(Number((s=t.debounceMs)!=null?s:260),60,2e3),maxIssues:FA(Number((c=t.maxIssues)!=null?c:120),5,1e3),maxSegments:FA(Number((l=t.maxSegments)!=null?l:600),20,3e3),minSourceLengthForRatio:FA(Number((u=t.minSourceLengthForRatio)!=null?u:8),2,100),segmentSelector:(t.segmentSelector||wP).trim()||wP,labels:{...wde,...t.labels||{}},normalizeText:e}}function _de(t){return{sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,locales:[...t.locales],localeRules:t.localeRules.map(e=>({locale:e.locale,label:e.label,minLengthRatio:e.minLengthRatio,maxLengthRatio:e.maxLengthRatio,requireDifferentFromSource:e.requireDifferentFromSource,preserveTokens:e.preserveTokens})),enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxIssues:t.maxIssues,maxSegments:t.maxSegments,minSourceLengthForRatio:t.minSourceLengthForRatio,segmentSelector:t.segmentSelector,labels:{...t.labels},normalizeText:t.normalizeText}}function d5(t){return t.closest(u5)||t}function xy(t){if(!t)return null;if(t.matches(La))return t;const e=t.querySelector(La);return e instanceof HTMLElement?e:null}function Dde(){if(typeof window=="undefined")return null;const t=window[yP];if(!(t instanceof HTMLElement))return null;window[yP]=null;const e=xy(t);if(e)return e;const n=t.closest(u5);if(n){const i=xy(n);if(i)return i}const r=t.closest(La);return r instanceof HTMLElement?r:null}function Lde(t){const e=t.closest("[data-editora-editor]");if(e&&xy(e)===t)return e;let n=t;for(;n;){if(n.matches(u5)&&(n===t||xy(n)===t))return n;n=n.parentElement}return d5(t)}function kP(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Vw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Fde(t){const e=d5(t);if(Vw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Vw(n)?!0:Vw(document.documentElement)||Vw(document.body)}function f5(t,e){t.classList.remove("rte-translation-workflow-theme-dark"),Fde(e)&&t.classList.add("rte-translation-workflow-theme-dark")}function Ide(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,La)||(n=l.matches)!=null&&n.call(l,`.${un}`)||(r=l.querySelector)!=null&&r.call(l,La)||(i=l.querySelector)!=null&&i.call(l,`.${un}`))return!0}}return!1}function Gw(){Array.from(vy).forEach(e=>{e.isConnected||g5(e)})}function mc(t,e=!0,n=!0){var s;if(Gw(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const c=xy(t.editorElement);if(c)return c}const r=Dde();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const c=(s=kP(i.getRangeAt(0).startContainer))==null?void 0:s.closest(La);if(c)return c}const o=document.activeElement;if(o){if(o.matches(La))return o;const c=o.closest(La);if(c)return c}if(n&&Ro&&Ro.isConnected)return Ro;if(!e)return null;const a=document.querySelector(La);return a instanceof HTMLElement?a:null}function Ude(t){const e=t.target;if(e){const r=e.closest(`.${un}`);if(r){const o=Array.from(Ri.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=e.closest(La);if(i)return i}const n=document.activeElement;if(n){const r=n.closest(`.${un}`);if(r){const o=Array.from(Ri.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=n.closest(La);if(i)return i}return null}function A5(t,e,n){const r=Lde(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function h5(t){const e=qw.get(t);typeof e=="number"&&(window.clearTimeout(e),qw.delete(t))}function Nde(t,e){const n=wy(e),r=t.localeRules.find(a=>wy(a.locale)===n);if(r)return r;const i=n.split("-")[0],o=t.localeRules.find(a=>wy(a.locale).split("-")[0]===i);return o||{locale:n,label:e,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function Rde(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Xw(t,e,n,r={}){return CP+=1,{id:`translation-workflow-issue-${CP}`,type:t,severity:e,message:n,...r}}function Yw(t,e){if(e){t.hasAttribute("data-translation-prev-contenteditable")||t.setAttribute("data-translation-prev-contenteditable",t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")||"inherit"),t.setAttribute("data-translation-locked","true"),t.setAttribute("contenteditable","false"),t.setAttribute("aria-readonly","true"),t.classList.add("rte-translation-segment-locked");return}t.removeAttribute("data-translation-locked"),t.removeAttribute("aria-readonly"),t.classList.remove("rte-translation-segment-locked");const n=t.getAttribute("data-translation-prev-contenteditable");t.removeAttribute("data-translation-prev-contenteditable"),n===null||n==="inherit"||n===""?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",n)}function Zw(t,e){return t.querySelector(`[data-translation-segment-id="${Tde(e)}"]`)}function BP(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=kP(e.getRangeAt(0).startContainer);return!n||!t.contains(n)?null:n.closest("[data-translation-segment-id]")}function Ode(t,e){const n=Array.from(t.querySelectorAll(e));if(n.length<=1)return n;const r=new Set(n);return n.filter(i=>{let o=i.parentElement;for(;o&&o!==t;){if(r.has(o))return!1;o=o.parentElement}return!0})}function Mde(t,e,n){let r=(n||"").trim();if(!r||e.has(r)){do r=`translation-segment-${xde++}`;while(e.has(r));t.setAttribute("data-translation-segment-id",r)}return r}function p5(t,e){if(e.lockedSegmentIds.size===0)return!1;let n=!1;return e.lockedSegmentIds.forEach(r=>{const i=Zw(t,r);if(!i)return;Yw(i,!0);const o=e.lockedHtmlBySegmentId.get(r);if(typeof o=="string"){i.innerHTML!==o&&(i.innerHTML=o,n=!0);return}e.lockedHtmlBySegmentId.set(r,i.innerHTML)}),n}function Gd(t,e,n){var a;const r=Ode(t,e.segmentSelector),i=[],o=new Set;for(let s=0;s<r.length&&!(i.length>=e.maxSegments);s+=1){const c=r[s],l=Mde(c,o,c.getAttribute("data-translation-segment-id")),u=n.lockedSegmentIds.has(l),d=c.getAttribute("data-translation-locked")==="true",f=u||d;if(f)if(n.lockedSegmentIds.add(l),Yw(c,!0),!n.lockedHtmlBySegmentId.has(l))n.lockedHtmlBySegmentId.set(l,c.innerHTML);else{const p=n.lockedHtmlBySegmentId.get(l)||"";c.innerHTML!==p&&(c.innerHTML=p)}else n.lockedHtmlBySegmentId.delete(l);const A=e.normalizeText(c.textContent||"");if(!A)continue;n.sourceTextBySegmentId.has(l)||n.sourceTextBySegmentId.set(l,A);const h=n.sourceTextBySegmentId.get(l)||A;i.push({id:l,tagName:c.tagName.toLowerCase(),index:i.length,text:A,sourceText:h,locked:f}),o.add(l)}return Array.from(n.sourceTextBySegmentId.keys()).forEach(s=>{o.has(s)||n.sourceTextBySegmentId.delete(s)}),Array.from(n.lockedSegmentIds.keys()).forEach(s=>{o.has(s)||n.lockedSegmentIds.delete(s)}),Array.from(n.lockedHtmlBySegmentId.keys()).forEach(s=>{(!o.has(s)||!n.lockedSegmentIds.has(s))&&n.lockedHtmlBySegmentId.delete(s)}),(!n.selectedSegmentId||!i.some(s=>s.id===n.selectedSegmentId))&&(n.selectedSegmentId=((a=i[0])==null?void 0:a.id)||null),i}function Nr(t,e){cn.has(t)||cn.set(t,e);let n=LA.get(t);return n||(n={sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,selectedSegmentId:null,realtimeEnabled:e.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},LA.set(t,n)),vy.add(t),n}function g5(t){h5(t);const e=Ri.get(t);e&&e.remove(),Ri.delete(t),yy.delete(t);const n=LA.get(t);n&&(n.lockedSegmentIds.forEach(r=>{const i=Zw(t,r);i&&Yw(i,!1)}),n.lockedHtmlBySegmentId.clear()),cn.delete(t),jw.delete(t),LA.delete(t),vy.delete(t),Ro===t&&(Ro=null)}function m5(t){return yy.get(t)===!0}function b5(t,e){if(!e.classList.contains("show"))return;const n=d5(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,520),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function IA(t,e){const n=t.querySelector(".rte-translation-live");n&&(n.textContent=e)}function Pde(t,e){return`${t.innerHTML}::${e.sourceLocale}::${e.targetLocale}::${Array.from(e.lockedSegmentIds).sort().join("|")}`}function Hde(t,e,n){const r=[],i=Nde(n,e.targetLocale);for(let o=0;o<t.length&&!(r.length>=n.maxIssues);o+=1){const a=t[o],s=n.normalizeText(a.sourceText||""),c=n.normalizeText(a.text||"");if(!c){r.push(Xw("missing-target","error",n.labels.missingTargetMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Provide translated content for this segment before export."}));continue}if(i.preserveTokens&&s&&!Bde(s,c)&&(r.push(Xw("token-mismatch","error",n.labels.tokenMismatchMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),r.length>=n.maxIssues)||i.requireDifferentFromSource&&s&&n.normalizeText(s)===n.normalizeText(c)&&(r.push(Xw("untranslated","warning",n.labels.untranslatedMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Translate the segment or mark it intentionally unchanged."})),r.length>=n.maxIssues))break;if(s.length>=n.minSourceLengthForRatio){const l=c.length/Math.max(1,s.length);(l<i.minLengthRatio||l>i.maxLengthRatio)&&r.push(Xw("length-out-of-range","warning",n.labels.lengthOutOfRangeMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:`Expected ratio for ${i.label}: ${i.minLengthRatio.toFixed(2)} - ${i.maxLengthRatio.toFixed(2)}.`}))}}return r}function SP(t){const e=cn.get(t)||fo,n=LA.get(t);return{sourceLocale:(n==null?void 0:n.sourceLocale)||(e==null?void 0:e.sourceLocale)||"en-US",targetLocale:(n==null?void 0:n.targetLocale)||(e==null?void 0:e.targetLocale)||"fr-FR",realtimeEnabled:(n==null?void 0:n.realtimeEnabled)===!0,selectedSegmentId:(n==null?void 0:n.selectedSegmentId)||null,segmentCount:(n==null?void 0:n.segments.length)||0,lockedSegmentCount:n?n.segments.filter(r=>r.locked).length:0,issues:n!=null&&n.issues?n.issues.map(r=>({...r})):[],segments:(n==null?void 0:n.segments.map(r=>({id:r.id,tagName:r.tagName,index:r.index,sourceLength:r.sourceText.length,targetLength:r.text.length,locked:r.locked})))||[],lastRunAt:(n==null?void 0:n.lastRunAt)||null}}function vl(t){const e=LA.get(t),n=e&&e.selectedSegmentId?e.segments.find(r=>r.id===e.selectedSegmentId):null;A5(t,"toggleTranslationWorkflowPanel",m5(t)),A5(t,"toggleTranslationRealtime",(e==null?void 0:e.realtimeEnabled)===!0),A5(t,"toggleTranslationSegmentLock",(n==null?void 0:n.locked)===!0)}function Qde(t,e){const n=Zw(t,e);if(!n)return;try{n.scrollIntoView({block:"nearest",inline:"nearest"})}catch(i){}const r=window.getSelection();if(!(!r||typeof document.createRange!="function"))try{const i=document.createRange();i.selectNodeContents(n),i.collapse(!0),r.removeAllRanges(),r.addRange(i),t.focus({preventScroll:!0})}catch(i){}}function ku(t){const e=Ri.get(t);if(!e)return;const n=cn.get(t)||fo;if(!n)return;const r=Nr(t,n),i=e.querySelector(".rte-translation-source-label");i&&(i.textContent=n.labels.sourceLocaleLabel);const o=e.querySelector(".rte-translation-target-label");o&&(o.textContent=n.labels.targetLocaleLabel);const a=e.querySelector('[data-field="source-locale"]'),s=e.querySelector('[data-field="target-locale"]'),c=n.locales.map(T=>`<option value="${sr(T)}">${sr(T)}</option>`).join("");a&&(a.innerHTML=c,a.value=r.sourceLocale),s&&(s.innerHTML=c,s.value=r.targetLocale);const l=e.querySelector(".rte-translation-summary");if(l){const T=r.issues.length,_=r.selectedSegmentId?` • ${n.labels.selectedSegmentPrefix}: ${r.selectedSegmentId}`:"";l.textContent=`${n.labels.summaryPrefix}: ${r.sourceLocale} → ${r.targetLocale} • ${T} issue${T===1?"":"s"}${_}`}const u=e.querySelector(".rte-translation-helper");u&&(u.textContent=n.labels.helperText);const d=e.querySelector(".rte-translation-shortcut");d&&(d.textContent=n.labels.shortcutText);const f=e.querySelector('[data-action="run-validation"]');f&&(f.textContent=n.labels.validateText);const A=e.querySelector('[data-action="capture-source"]');A&&(A.textContent=n.labels.captureSourceText);const h=e.querySelector('[data-action="toggle-realtime"]');h&&(h.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,h.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const p=e.querySelector('[data-action="lock-selected"]'),m=r.selectedSegmentId&&r.segments.find(T=>T.id===r.selectedSegmentId)||null;p&&(p.textContent=m!=null&&m.locked?n.labels.unlockSelectedText:n.labels.lockSelectedText,p.disabled=!m,p.setAttribute("aria-pressed",m!=null&&m.locked?"true":"false"));const g=e.querySelector('[data-action="close"]');g&&g.setAttribute("aria-label",n.labels.closeText);const b=e.querySelector(".rte-translation-issues"),y=e.querySelector(".rte-translation-empty");b&&(b.setAttribute("aria-label",n.labels.issuesLabel),r.issues.length===0?(b.innerHTML="",y&&(y.hidden=!1,y.textContent=n.labels.noIssuesText)):(y&&(y.hidden=!0),b.innerHTML=r.issues.map(T=>`
|
|
3519
|
+
`,document.head.appendChild(t)}const l5=Object.freeze(Object.defineProperty({__proto__:null,DocSchemaPlugin:(t={})=>{const e=Pw(t),n=new Set;return vde(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 4.5h12A1.5 1.5 0 0 1 19.5 6v12A1.5 1.5 0 0 1 18 19.5H6A1.5 1.5 0 0 1 4.5 18V6A1.5 1.5 0 0 1 6 4.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 4.5 6.5v5c0 4.8 3.1 8.9 7.5 10 4.4-1.1 7.5-5.2 7.5-10v-5L12 3.5Z" stroke="currentColor" stroke-width="1.6"/><path d="m9 12.5 2 2 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'}]}],commands:{docSchema:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,c5(o),!0},openDocSchemaPanel:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,c5(o),!0},toggleDocSchemaPanel:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,h7(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,gc(o,"command",!0),!0},insertMissingDocSchemaSections:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,m7(o)},toggleDocSchemaRealtime:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;return Ni(o,a),Tn.set(o,a),la=o,g7(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e,s=Ni(o,a);Tn.set(o,a);const c=typeof r=="string"?r:(r==null?void 0:r.schemaId)||(r==null?void 0:r.id);return!c||!Cu(a,c)?!1:(s.activeSchemaId=c,s.snapshot="",gc(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,i)=>{const o=bl(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=Tn.get(o)||e,s=Nw.get(o)||tde(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:s.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Pw(c);Tn.set(o,l),Nw.set(o,c);const u=Ni(o,l);return typeof r.enableRealtime=="boolean"&&(u.realtimeEnabled=r.enableRealtime),(!u.activeSchemaId||!Cu(l,u.activeSchemaId))&&(u.activeSchemaId=i5(l)),typeof r.defaultSchemaId=="string"&&Cu(l,r.defaultSchemaId)&&(u.activeSchemaId=r.defaultSchemaId),u.snapshot="",gc(o,"set-options",!0),DA(o),Kd(o),!0},getDocSchemaState:(r,i)=>{const o=bl(i,!1,!1);if(!o)return!1;const a=Tn.get(o)||e;Ni(o,a);const s=A7(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__docSchemaState=s,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(i){Mw+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=Pw(o);bde(a);const s=bl(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);s&&(la=s,n.add(s),Ni(s,a),Tn.set(s,a),Nw.set(s,o),Kd(s),gc(s,"init",!0))},destroy:()=>{n.forEach(r=>o5(r)),n.clear(),Mw=Math.max(0,Mw-1),!(Mw>0)&&yde()}}}},Symbol.toStringTag,{value:"Module"})),La=".rte-content, .editora-content",u5="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",y7="__editoraCommandEditorRoot",v7="rte-translation-workflow-styles",un="rte-translation-workflow-panel",Us="translation-workflow",yl="translationWorkflow",uo=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',w7=["p","h1","h2","h3","h4","h5","h6","li","td","th","blockquote","figcaption"].join(", "),x7=new Set(["ArrowUp","ArrowDown","Home","End"]),E7=[{locale:"en",label:"English",minLengthRatio:.6,maxLengthRatio:1.4,requireDifferentFromSource:!1,preserveTokens:!0},{locale:"fr",label:"French",minLengthRatio:.75,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"de",label:"German",minLengthRatio:.8,maxLengthRatio:1.9,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"es",label:"Spanish",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"it",label:"Italian",minLengthRatio:.7,maxLengthRatio:1.7,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"ja",label:"Japanese",minLengthRatio:.45,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0},{locale:"zh",label:"Chinese",minLengthRatio:.4,maxLengthRatio:1.2,requireDifferentFromSource:!0,preserveTokens:!0}],wde={panelTitle:"Translation Workflow",panelAriaLabel:"Translation workflow panel",sourceLocaleLabel:"Source Locale",targetLocaleLabel:"Target Locale",validateText:"Validate Locale",captureSourceText:"Capture Source",lockSelectedText:"Lock Selected",unlockSelectedText:"Unlock Selected",lockSegmentAriaLabel:"Lock segment",unlockSegmentAriaLabel:"Unlock segment",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",summaryPrefix:"Locale QA",noIssuesText:"No locale validation issues.",issuesLabel:"Locale issues",segmentsLabel:"Segments",sourcePreviewLabel:"Source",targetPreviewLabel:"Target",helperText:"Select segments, lock finalized ones, and run locale validation before handoff.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+L (panel), Ctrl/Cmd+Alt+Shift+V (validate), Ctrl/Cmd+Alt+Shift+K (lock segment)",readonlySegmentMessage:"This segment is locked. Unlock before editing.",sourceCapturedMessage:"Source snapshot captured from current content.",selectedSegmentPrefix:"Selected Segment",missingTargetMessage:"Segment is empty in target locale.",tokenMismatchMessage:"Tokens/placeholders do not match source segment.",untranslatedMessage:"Segment appears untranslated (same as source).",lengthOutOfRangeMessage:"Translation length is outside expected locale range."},cn=new WeakMap,jw=new WeakMap,LA=new WeakMap,Ri=new Map,yy=new WeakMap,qw=new WeakMap,vy=new Set;let Ww=0,xde=0,C7=0,Ede=0,fo=null,Ro=null,Zp=null,Jp=null,eg=null,tg=null,Vd=null,ng=null;function sr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Cde(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function FA(t,e,n){return Number.isFinite(t)?Math.max(e,Math.min(n,t)):e}function Tu(t){return(t||"").trim()||"en-US"}function wy(t){return t.trim().toLowerCase()}function Tde(t){return t.replace(/"/g,""")}function kde(t,e=120){return t.length<=e?t:`${t.slice(0,Math.max(0,e-1)).trimEnd()}…`}function T7(t){const e=t.match(/\{\{[^{}]+\}\}|%[A-Z0-9_]+%|\$\{[^{}]+\}/gi);return!e||e.length===0?[]:e.map(n=>n.trim()).filter(Boolean)}function Bde(t,e){const n=T7(t).sort(),r=T7(e).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1)if(n[i]!==r[i])return!1;return!0}function Sde(t,e){const n=Array.isArray(e)&&e.length>0?e:E7,r=[],i=new Set;return n.forEach(o=>{var c,l;const a=wy(o.locale||"");if(!a)return;const s=a;i.has(s)||(i.add(s),r.push({locale:s,label:(o.label||a).trim()||a,minLengthRatio:FA(Number((c=o.minLengthRatio)!=null?c:.5),.1,3),maxLengthRatio:FA(Number((l=o.maxLengthRatio)!=null?l:1.8),.2,4),requireDifferentFromSource:o.requireDifferentFromSource!==!1,preserveTokens:o.preserveTokens!==!1}))}),t.forEach(o=>{const a=wy(o);if(i.has(a))return;const s=E7.find(c=>a.startsWith(c.locale));r.push(s?{...s,locale:a,label:o}:{locale:a,label:o,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0})}),r}function Kw(t={}){var s,c,l,u;const e=t.normalizeText||Cde,n=Tu(t.sourceLocale||"en-US"),r=Tu(t.targetLocale||"fr-FR"),i=new Set([n,r]);(Array.isArray(t.locales)?t.locales:[]).forEach(d=>{if(typeof d!="string")return;const f=Tu(d);i.add(f)});const o=Array.from(i),a=Sde(o,t.localeRules);return{sourceLocale:n,targetLocale:r,locales:o,localeRules:a,enableRealtime:t.enableRealtime!==!1,debounceMs:FA(Number((s=t.debounceMs)!=null?s:260),60,2e3),maxIssues:FA(Number((c=t.maxIssues)!=null?c:120),5,1e3),maxSegments:FA(Number((l=t.maxSegments)!=null?l:600),20,3e3),minSourceLengthForRatio:FA(Number((u=t.minSourceLengthForRatio)!=null?u:8),2,100),segmentSelector:(t.segmentSelector||w7).trim()||w7,labels:{...wde,...t.labels||{}},normalizeText:e}}function _de(t){return{sourceLocale:t.sourceLocale,targetLocale:t.targetLocale,locales:[...t.locales],localeRules:t.localeRules.map(e=>({locale:e.locale,label:e.label,minLengthRatio:e.minLengthRatio,maxLengthRatio:e.maxLengthRatio,requireDifferentFromSource:e.requireDifferentFromSource,preserveTokens:e.preserveTokens})),enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxIssues:t.maxIssues,maxSegments:t.maxSegments,minSourceLengthForRatio:t.minSourceLengthForRatio,segmentSelector:t.segmentSelector,labels:{...t.labels},normalizeText:t.normalizeText}}function d5(t){return t.closest(u5)||t}function xy(t){if(!t)return null;if(t.matches(La))return t;const e=t.querySelector(La);return e instanceof HTMLElement?e:null}function Dde(){if(typeof window=="undefined")return null;const t=window[y7];if(!(t instanceof HTMLElement))return null;window[y7]=null;const e=xy(t);if(e)return e;const n=t.closest(u5);if(n){const i=xy(n);if(i)return i}const r=t.closest(La);return r instanceof HTMLElement?r:null}function Lde(t){const e=t.closest("[data-editora-editor]");if(e&&xy(e)===t)return e;let n=t;for(;n;){if(n.matches(u5)&&(n===t||xy(n)===t))return n;n=n.parentElement}return d5(t)}function k7(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Vw(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Fde(t){const e=d5(t);if(Vw(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Vw(n)?!0:Vw(document.documentElement)||Vw(document.body)}function f5(t,e){t.classList.remove("rte-translation-workflow-theme-dark"),Fde(e)&&t.classList.add("rte-translation-workflow-theme-dark")}function Ide(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,La)||(n=l.matches)!=null&&n.call(l,`.${un}`)||(r=l.querySelector)!=null&&r.call(l,La)||(i=l.querySelector)!=null&&i.call(l,`.${un}`))return!0}}return!1}function Gw(){Array.from(vy).forEach(e=>{e.isConnected||g5(e)})}function mc(t,e=!0,n=!0){var s;if(Gw(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const c=xy(t.editorElement);if(c)return c}const r=Dde();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const c=(s=k7(i.getRangeAt(0).startContainer))==null?void 0:s.closest(La);if(c)return c}const o=document.activeElement;if(o){if(o.matches(La))return o;const c=o.closest(La);if(c)return c}if(n&&Ro&&Ro.isConnected)return Ro;if(!e)return null;const a=document.querySelector(La);return a instanceof HTMLElement?a:null}function Ude(t){const e=t.target;if(e){const r=e.closest(`.${un}`);if(r){const o=Array.from(Ri.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=e.closest(La);if(i)return i}const n=document.activeElement;if(n){const r=n.closest(`.${un}`);if(r){const o=Array.from(Ri.entries()).find(([,a])=>a===r);if(o)return o[0]}const i=n.closest(La);if(i)return i}return null}function A5(t,e,n){const r=Lde(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function h5(t){const e=qw.get(t);typeof e=="number"&&(window.clearTimeout(e),qw.delete(t))}function Nde(t,e){const n=wy(e),r=t.localeRules.find(a=>wy(a.locale)===n);if(r)return r;const i=n.split("-")[0],o=t.localeRules.find(a=>wy(a.locale).split("-")[0]===i);return o||{locale:n,label:e,minLengthRatio:.5,maxLengthRatio:1.8,requireDifferentFromSource:!0,preserveTokens:!0}}function Rde(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Xw(t,e,n,r={}){return C7+=1,{id:`translation-workflow-issue-${C7}`,type:t,severity:e,message:n,...r}}function Yw(t,e){if(e){t.hasAttribute("data-translation-prev-contenteditable")||t.setAttribute("data-translation-prev-contenteditable",t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")||"inherit"),t.setAttribute("data-translation-locked","true"),t.setAttribute("contenteditable","false"),t.setAttribute("aria-readonly","true"),t.classList.add("rte-translation-segment-locked");return}t.removeAttribute("data-translation-locked"),t.removeAttribute("aria-readonly"),t.classList.remove("rte-translation-segment-locked");const n=t.getAttribute("data-translation-prev-contenteditable");t.removeAttribute("data-translation-prev-contenteditable"),n===null||n==="inherit"||n===""?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",n)}function Zw(t,e){return t.querySelector(`[data-translation-segment-id="${Tde(e)}"]`)}function B7(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=k7(e.getRangeAt(0).startContainer);return!n||!t.contains(n)?null:n.closest("[data-translation-segment-id]")}function Ode(t,e){const n=Array.from(t.querySelectorAll(e));if(n.length<=1)return n;const r=new Set(n);return n.filter(i=>{let o=i.parentElement;for(;o&&o!==t;){if(r.has(o))return!1;o=o.parentElement}return!0})}function Mde(t,e,n){let r=(n||"").trim();if(!r||e.has(r)){do r=`translation-segment-${xde++}`;while(e.has(r));t.setAttribute("data-translation-segment-id",r)}return r}function p5(t,e){if(e.lockedSegmentIds.size===0)return!1;let n=!1;return e.lockedSegmentIds.forEach(r=>{const i=Zw(t,r);if(!i)return;Yw(i,!0);const o=e.lockedHtmlBySegmentId.get(r);if(typeof o=="string"){i.innerHTML!==o&&(i.innerHTML=o,n=!0);return}e.lockedHtmlBySegmentId.set(r,i.innerHTML)}),n}function Gd(t,e,n){var a;const r=Ode(t,e.segmentSelector),i=[],o=new Set;for(let s=0;s<r.length&&!(i.length>=e.maxSegments);s+=1){const c=r[s],l=Mde(c,o,c.getAttribute("data-translation-segment-id")),u=n.lockedSegmentIds.has(l),d=c.getAttribute("data-translation-locked")==="true",f=u||d;if(f)if(n.lockedSegmentIds.add(l),Yw(c,!0),!n.lockedHtmlBySegmentId.has(l))n.lockedHtmlBySegmentId.set(l,c.innerHTML);else{const p=n.lockedHtmlBySegmentId.get(l)||"";c.innerHTML!==p&&(c.innerHTML=p)}else n.lockedHtmlBySegmentId.delete(l);const A=e.normalizeText(c.textContent||"");if(!A)continue;n.sourceTextBySegmentId.has(l)||n.sourceTextBySegmentId.set(l,A);const h=n.sourceTextBySegmentId.get(l)||A;i.push({id:l,tagName:c.tagName.toLowerCase(),index:i.length,text:A,sourceText:h,locked:f}),o.add(l)}return Array.from(n.sourceTextBySegmentId.keys()).forEach(s=>{o.has(s)||n.sourceTextBySegmentId.delete(s)}),Array.from(n.lockedSegmentIds.keys()).forEach(s=>{o.has(s)||n.lockedSegmentIds.delete(s)}),Array.from(n.lockedHtmlBySegmentId.keys()).forEach(s=>{(!o.has(s)||!n.lockedSegmentIds.has(s))&&n.lockedHtmlBySegmentId.delete(s)}),(!n.selectedSegmentId||!i.some(s=>s.id===n.selectedSegmentId))&&(n.selectedSegmentId=((a=i[0])==null?void 0:a.id)||null),i}function Nr(t,e){cn.has(t)||cn.set(t,e);let n=LA.get(t);return n||(n={sourceLocale:e.sourceLocale,targetLocale:e.targetLocale,selectedSegmentId:null,realtimeEnabled:e.enableRealtime,segments:[],issues:[],sourceTextBySegmentId:new Map,lockedSegmentIds:new Set,lockedHtmlBySegmentId:new Map,snapshot:"",lastRunAt:null},LA.set(t,n)),vy.add(t),n}function g5(t){h5(t);const e=Ri.get(t);e&&e.remove(),Ri.delete(t),yy.delete(t);const n=LA.get(t);n&&(n.lockedSegmentIds.forEach(r=>{const i=Zw(t,r);i&&Yw(i,!1)}),n.lockedHtmlBySegmentId.clear()),cn.delete(t),jw.delete(t),LA.delete(t),vy.delete(t),Ro===t&&(Ro=null)}function m5(t){return yy.get(t)===!0}function b5(t,e){if(!e.classList.contains("show"))return;const n=d5(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,520),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function IA(t,e){const n=t.querySelector(".rte-translation-live");n&&(n.textContent=e)}function Pde(t,e){return`${t.innerHTML}::${e.sourceLocale}::${e.targetLocale}::${Array.from(e.lockedSegmentIds).sort().join("|")}`}function Hde(t,e,n){const r=[],i=Nde(n,e.targetLocale);for(let o=0;o<t.length&&!(r.length>=n.maxIssues);o+=1){const a=t[o],s=n.normalizeText(a.sourceText||""),c=n.normalizeText(a.text||"");if(!c){r.push(Xw("missing-target","error",n.labels.missingTargetMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Provide translated content for this segment before export."}));continue}if(i.preserveTokens&&s&&!Bde(s,c)&&(r.push(Xw("token-mismatch","error",n.labels.tokenMismatchMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Preserve placeholders/tokens exactly (for example {{name}}, %ID%, ${value})."})),r.length>=n.maxIssues)||i.requireDifferentFromSource&&s&&n.normalizeText(s)===n.normalizeText(c)&&(r.push(Xw("untranslated","warning",n.labels.untranslatedMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:"Translate the segment or mark it intentionally unchanged."})),r.length>=n.maxIssues))break;if(s.length>=n.minSourceLengthForRatio){const l=c.length/Math.max(1,s.length);(l<i.minLengthRatio||l>i.maxLengthRatio)&&r.push(Xw("length-out-of-range","warning",n.labels.lengthOutOfRangeMessage,{segmentId:a.id,sourceText:s,targetText:c,suggestion:`Expected ratio for ${i.label}: ${i.minLengthRatio.toFixed(2)} - ${i.maxLengthRatio.toFixed(2)}.`}))}}return r}function S7(t){const e=cn.get(t)||fo,n=LA.get(t);return{sourceLocale:(n==null?void 0:n.sourceLocale)||(e==null?void 0:e.sourceLocale)||"en-US",targetLocale:(n==null?void 0:n.targetLocale)||(e==null?void 0:e.targetLocale)||"fr-FR",realtimeEnabled:(n==null?void 0:n.realtimeEnabled)===!0,selectedSegmentId:(n==null?void 0:n.selectedSegmentId)||null,segmentCount:(n==null?void 0:n.segments.length)||0,lockedSegmentCount:n?n.segments.filter(r=>r.locked).length:0,issues:n!=null&&n.issues?n.issues.map(r=>({...r})):[],segments:(n==null?void 0:n.segments.map(r=>({id:r.id,tagName:r.tagName,index:r.index,sourceLength:r.sourceText.length,targetLength:r.text.length,locked:r.locked})))||[],lastRunAt:(n==null?void 0:n.lastRunAt)||null}}function vl(t){const e=LA.get(t),n=e&&e.selectedSegmentId?e.segments.find(r=>r.id===e.selectedSegmentId):null;A5(t,"toggleTranslationWorkflowPanel",m5(t)),A5(t,"toggleTranslationRealtime",(e==null?void 0:e.realtimeEnabled)===!0),A5(t,"toggleTranslationSegmentLock",(n==null?void 0:n.locked)===!0)}function Qde(t,e){const n=Zw(t,e);if(!n)return;try{n.scrollIntoView({block:"nearest",inline:"nearest"})}catch(i){}const r=window.getSelection();if(!(!r||typeof document.createRange!="function"))try{const i=document.createRange();i.selectNodeContents(n),i.collapse(!0),r.removeAllRanges(),r.addRange(i),t.focus({preventScroll:!0})}catch(i){}}function ku(t){const e=Ri.get(t);if(!e)return;const n=cn.get(t)||fo;if(!n)return;const r=Nr(t,n),i=e.querySelector(".rte-translation-source-label");i&&(i.textContent=n.labels.sourceLocaleLabel);const o=e.querySelector(".rte-translation-target-label");o&&(o.textContent=n.labels.targetLocaleLabel);const a=e.querySelector('[data-field="source-locale"]'),s=e.querySelector('[data-field="target-locale"]'),c=n.locales.map(T=>`<option value="${sr(T)}">${sr(T)}</option>`).join("");a&&(a.innerHTML=c,a.value=r.sourceLocale),s&&(s.innerHTML=c,s.value=r.targetLocale);const l=e.querySelector(".rte-translation-summary");if(l){const T=r.issues.length,_=r.selectedSegmentId?` • ${n.labels.selectedSegmentPrefix}: ${r.selectedSegmentId}`:"";l.textContent=`${n.labels.summaryPrefix}: ${r.sourceLocale} → ${r.targetLocale} • ${T} issue${T===1?"":"s"}${_}`}const u=e.querySelector(".rte-translation-helper");u&&(u.textContent=n.labels.helperText);const d=e.querySelector(".rte-translation-shortcut");d&&(d.textContent=n.labels.shortcutText);const f=e.querySelector('[data-action="run-validation"]');f&&(f.textContent=n.labels.validateText);const A=e.querySelector('[data-action="capture-source"]');A&&(A.textContent=n.labels.captureSourceText);const h=e.querySelector('[data-action="toggle-realtime"]');h&&(h.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,h.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const p=e.querySelector('[data-action="lock-selected"]'),m=r.selectedSegmentId&&r.segments.find(T=>T.id===r.selectedSegmentId)||null;p&&(p.textContent=m!=null&&m.locked?n.labels.unlockSelectedText:n.labels.lockSelectedText,p.disabled=!m,p.setAttribute("aria-pressed",m!=null&&m.locked?"true":"false"));const g=e.querySelector('[data-action="close"]');g&&g.setAttribute("aria-label",n.labels.closeText);const b=e.querySelector(".rte-translation-issues"),y=e.querySelector(".rte-translation-empty");b&&(b.setAttribute("aria-label",n.labels.issuesLabel),r.issues.length===0?(b.innerHTML="",y&&(y.hidden=!1,y.textContent=n.labels.noIssuesText)):(y&&(y.hidden=!0),b.innerHTML=r.issues.map(T=>`
|
|
3519
3520
|
<li class="rte-translation-issue ${T.severity==="error"?"error":T.severity==="warning"?"warning":"info"}" role="listitem" data-segment-id="${sr(T.segmentId||"")}">
|
|
3520
3521
|
<p class="rte-translation-issue-message">${sr(T.message)}</p>
|
|
3521
3522
|
${T.suggestion?`<p class="rte-translation-issue-suggestion">${sr(T.suggestion)}</p>`:""}
|
|
@@ -3528,7 +3529,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3528
3529
|
</button>
|
|
3529
3530
|
<button type="button" class="rte-translation-segment-lock" data-action="toggle-lock" data-segment-id="${sr(T.id)}" aria-label="${T.locked?n.labels.unlockSegmentAriaLabel:n.labels.lockSegmentAriaLabel}" aria-pressed="${T.locked?"true":"false"}"></button>
|
|
3530
3531
|
</li>
|
|
3531
|
-
`}).join(""));const x=e.querySelector(".rte-translation-source-preview"),k=e.querySelector(".rte-translation-target-preview");if(x||k){const T=r.selectedSegmentId&&r.segments.find(_=>_.id===r.selectedSegmentId)||null;x&&(x.textContent=(T==null?void 0:T.sourceText)||"—",x.setAttribute("aria-label",n.labels.sourcePreviewLabel)),k&&(k.textContent=(T==null?void 0:T.text)||"—",k.setAttribute("aria-label",n.labels.targetPreviewLabel))}e.setAttribute("aria-label",n.labels.panelAriaLabel)}function
|
|
3532
|
+
`}).join(""));const x=e.querySelector(".rte-translation-source-preview"),k=e.querySelector(".rte-translation-target-preview");if(x||k){const T=r.selectedSegmentId&&r.segments.find(_=>_.id===r.selectedSegmentId)||null;x&&(x.textContent=(T==null?void 0:T.sourceText)||"—",x.setAttribute("aria-label",n.labels.sourcePreviewLabel)),k&&(k.textContent=(T==null?void 0:T.text)||"—",k.setAttribute("aria-label",n.labels.targetPreviewLabel))}e.setAttribute("aria-label",n.labels.panelAriaLabel)}function _7(t){const e=cn.get(t)||fo;if(!e)return;h5(t);const n=window.setTimeout(()=>{qw.delete(t),Ns(t,"realtime",!1)},e.debounceMs);qw.set(t,n)}function Ns(t,e,n){const r=cn.get(t)||fo;if(!r)return[];const i=Nr(t,r),o=p5(t,i);i.segments=Gd(t,r,i);const a=Pde(t,i);if(!n&&i.snapshot===a)return i.issues;i.issues=Hde(i.segments,i,r),i.lastRunAt=new Date().toISOString(),i.snapshot=a,ku(t),vl(t),t.dispatchEvent(new CustomEvent("editora:translation-workflow-validation",{bubbles:!0,detail:{reason:e,state:S7(t)}}));const s=Ri.get(t);if(s){if(o)return IA(s,r.labels.readonlySegmentMessage),i.issues;IA(s,i.issues.length===0?r.labels.noIssuesText:`${i.issues.length} issue${i.issues.length===1?"":"s"} detected.`)}return i.issues}function D7(t){const e=cn.get(t)||fo;if(!e)return!1;const n=Nr(t,e),r=Gd(t,e,n);r.forEach(o=>{n.sourceTextBySegmentId.set(o.id,o.text)}),n.snapshot="",Ns(t,"capture-source",!0);const i=Ri.get(t);return i&&IA(i,e.labels.sourceCapturedMessage),t.dispatchEvent(new CustomEvent("editora:translation-source-captured",{bubbles:!0,detail:{sourceLocale:n.sourceLocale,segmentCount:r.length}})),!0}function Jw(t,e,n){var l,u;if(Rde(t))return!1;const r=cn.get(t)||fo;if(!r)return!1;const i=Nr(t,r);i.segments=Gd(t,r,i);const o=((l=B7(t))==null?void 0:l.getAttribute("data-translation-segment-id"))||null,a=e||o||i.selectedSegmentId||((u=i.segments[0])==null?void 0:u.id)||null;if(!a)return!1;const s=Zw(t,a);if(!s)return!1;const c=typeof n=="boolean"?n:!i.lockedSegmentIds.has(a);return c?(i.lockedSegmentIds.add(a),i.lockedHtmlBySegmentId.set(a,s.innerHTML)):(i.lockedSegmentIds.delete(a),i.lockedHtmlBySegmentId.delete(a)),Yw(s,c),i.selectedSegmentId=a,i.snapshot="",Ns(t,"lock-segment",!0),t.dispatchEvent(new CustomEvent("editora:translation-segment-lock",{bubbles:!0,detail:{segmentId:a,locked:c}})),!0}function L7(t,e){const n=cn.get(t)||fo;if(!n)return!1;const r=Nr(t,n),i=typeof e=="boolean"?e:!r.realtimeEnabled;return r.realtimeEnabled=i,i?_7(t):h5(t),ku(t),vl(t),!0}function y5(t,e,n=!0){const r=cn.get(t)||fo;if(!r)return!1;const i=Nr(t,r);return i.segments=Gd(t,r,i),i.segments.some(o=>o.id===e)?(i.selectedSegmentId=e,ku(t),vl(t),n&&Qde(t,e),!0):!1}function e2(t,e){const n=cn.get(t)||fo;if(!n)return!1;const r=Nr(t,n);if(r.segments=Gd(t,n,r),r.segments.length===0)return!1;const i=Math.max(0,r.segments.findIndex(s=>s.id===r.selectedSegmentId));let o=i;e==="start"?o=0:e==="end"?o=r.segments.length-1:o=FA(i+e,0,r.segments.length-1);const a=r.segments[o];return a?y5(t,a.id,!0):!1}function Ey(t,e=!1){const n=Ri.get(t);n&&(n.classList.remove("show"),yy.set(t,!1),vl(t),e&&t.focus({preventScroll:!0}))}function v5(t){const e=Wde(t);Ri.forEach((r,i)=>{i!==t&&Ey(i,!1)}),e.classList.add("show"),yy.set(t,!0),Ns(t,"panel-open",!1),ku(t),b5(t,e),vl(t);const n=e.querySelector('[data-field="target-locale"]');n==null||n.focus()}function F7(t,e){const n=m5(t);return(typeof e=="boolean"?e:!n)?v5(t):Ey(t,!1),!0}function w5(t){return typeof t.key=="string"?t.key.toLowerCase():""}function $de(t){const e=w5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="l"}function zde(t){const e=w5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="v"}function jde(t){const e=w5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="k"}function qde(t){return t.key.length===1&&!t.metaKey&&!t.ctrlKey&&!t.altKey?!0:t.key==="Backspace"||t.key==="Delete"||t.key==="Enter"}function I7(t){return t instanceof HTMLElement?t.closest('[data-translation-locked="true"]'):null}function Wde(t){const e=Ri.get(t);if(e)return e;const n=cn.get(t)||fo||Kw();Nr(t,n);const r=`rte-translation-workflow-panel-${Ede++}`,i=`${r}-source`,o=`${r}-target`,a=document.createElement("section");return a.className=un,a.id=r,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","false"),a.setAttribute("aria-label",n.labels.panelAriaLabel),a.innerHTML=`
|
|
3532
3533
|
<header class="rte-translation-header">
|
|
3533
3534
|
<h2 class="rte-translation-title">${sr(n.labels.panelTitle)}</h2>
|
|
3534
3535
|
<button type="button" class="rte-translation-icon-btn" data-action="close" aria-label="${sr(n.labels.closeText)}">✕</button>
|
|
@@ -3577,7 +3578,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3577
3578
|
</section>
|
|
3578
3579
|
</div>
|
|
3579
3580
|
<div class="rte-translation-live" aria-live="polite" aria-atomic="true"></div>
|
|
3580
|
-
`,a.addEventListener("click",s=>{const c=s.target;if(!c)return;const l=c.closest("[data-action]");if(!l){const d=c.closest(".rte-translation-issue[data-segment-id]"),f=(d==null?void 0:d.getAttribute("data-segment-id"))||"";f&&y5(t,f,!0);return}const u=l.getAttribute("data-action");if(u==="close"){Ey(t,!0);return}if(u==="run-validation"){Ns(t,"panel-button",!0);return}if(u==="capture-source"){
|
|
3581
|
+
`,a.addEventListener("click",s=>{const c=s.target;if(!c)return;const l=c.closest("[data-action]");if(!l){const d=c.closest(".rte-translation-issue[data-segment-id]"),f=(d==null?void 0:d.getAttribute("data-segment-id"))||"";f&&y5(t,f,!0);return}const u=l.getAttribute("data-action");if(u==="close"){Ey(t,!0);return}if(u==="run-validation"){Ns(t,"panel-button",!0);return}if(u==="capture-source"){D7(t);return}if(u==="lock-selected"){Jw(t);return}if(u==="toggle-realtime"){L7(t);return}if(u==="select-segment"){const d=l.getAttribute("data-segment-id")||"";d&&y5(t,d,!0);return}if(u==="toggle-lock"){const d=l.getAttribute("data-segment-id")||"";d&&Jw(t,d)}}),a.addEventListener("change",s=>{const c=s.target;if(!(c instanceof HTMLSelectElement))return;const l=cn.get(t)||fo;if(!l)return;const u=Nr(t,l);if(c.getAttribute("data-field")==="source-locale"){u.sourceLocale=Tu(c.value),u.snapshot="",Ns(t,"source-locale-change",!0);return}c.getAttribute("data-field")==="target-locale"&&(u.targetLocale=Tu(c.value),u.snapshot="",Ns(t,"target-locale-change",!0))}),a.addEventListener("keydown",s=>{const c=s.target;if(s.key==="Escape"){s.preventDefault(),Ey(t,!0);return}!(c!=null&&c.closest(".rte-translation-segments"))||!x7.has(s.key)||(s.preventDefault(),s.key==="ArrowUp"?e2(t,-1):s.key==="ArrowDown"?e2(t,1):s.key==="Home"?e2(t,"start"):s.key==="End"&&e2(t,"end"))}),f5(a,t),document.body.appendChild(a),Ri.set(t,a),yy.set(t,!1),ku(t),a}function Kde(t){fo=t,Zp||(Zp=e=>{var c;Gw();const n=e.target,r=n==null?void 0:n.closest(La);if(!r)return;const i=cn.get(r)||t,o=Nr(r,i);cn.set(r,i),Ro=r;const a=((c=B7(r))==null?void 0:c.getAttribute("data-translation-segment-id"))||null;a&&(o.selectedSegmentId=a),vl(r);const s=Ri.get(r);s&&(f5(s,r),b5(r,s),ku(r))},document.addEventListener("focusin",Zp,!0)),Jp||(Jp=e=>{const n=e.target,r=n==null?void 0:n.closest(La);if(!r)return;const i=cn.get(r)||fo;if(!i)return;const o=Nr(r,i),a=p5(r,o);if(o.segments=Gd(r,i,o),!o.realtimeEnabled){if(a){const s=Ri.get(r);s&&IA(s,i.labels.readonlySegmentMessage)}ku(r),vl(r);return}_7(r)},document.addEventListener("input",Jp,!0)),eg||(eg=e=>{const n=e,r=n.target,i=r==null?void 0:r.closest(La);if(!i)return;const o=I7(r);if(!o||!i.contains(o))return;n.preventDefault();const a=Ri.get(i),s=cn.get(i)||fo;a&&s&&IA(a,s.labels.readonlySegmentMessage)},document.addEventListener("beforeinput",eg,!0)),tg||(tg=e=>{if(e.defaultPrevented)return;const n=e.target;if((n==null?void 0:n.closest(`.${un}`))&&e.key!=="Escape"&&!x7.has(e.key))return;const i=e.key==="Escape",o=$de(e),a=zde(e),s=jde(e),c=I7(n);if(!i&&!o&&!a&&!s&&!c)return;const l=Ude(e);if(!l)return;const u=cn.get(l)||fo||t;if(Nr(l,u),cn.set(l,u),Ro=l,i&&m5(l)){e.preventDefault(),Ey(l,!0);return}if(c&&l.contains(c)&&qde(e)){e.preventDefault();const d=Ri.get(l);d&&IA(d,u.labels.readonlySegmentMessage);return}if(o){e.preventDefault(),e.stopPropagation(),F7(l);return}if(a){e.preventDefault(),e.stopPropagation(),Ns(l,"shortcut",!0);return}s&&(e.preventDefault(),e.stopPropagation(),Jw(l))},document.addEventListener("keydown",tg,!0)),Vd||(Vd=()=>{Gw(),Ri.forEach((e,n)=>{!n.isConnected||!e.isConnected||(f5(e,n),b5(n,e))})},window.addEventListener("scroll",Vd,!0),window.addEventListener("resize",Vd)),!ng&&typeof MutationObserver!="undefined"&&document.body&&(ng=new MutationObserver(e=>{Ide(e)&&Gw(),e.some(r=>r.type==="characterData"?!0:r.type==="childList"&&(r.addedNodes.length>0||r.removedNodes.length>0))&&vy.forEach(r=>{const i=LA.get(r);if(!i||i.lockedSegmentIds.size===0||!p5(r,i))return;i.snapshot="";const a=cn.get(r)||fo,s=Ri.get(r);s&&a&&IA(s,a.labels.readonlySegmentMessage),a&&(i.segments=Gd(r,a,i),ku(r),vl(r))})}),ng.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function Vde(){Zp&&(document.removeEventListener("focusin",Zp,!0),Zp=null),Jp&&(document.removeEventListener("input",Jp,!0),Jp=null),eg&&(document.removeEventListener("beforeinput",eg,!0),eg=null),tg&&(document.removeEventListener("keydown",tg,!0),tg=null),Vd&&(window.removeEventListener("scroll",Vd,!0),window.removeEventListener("resize",Vd),Vd=null),ng&&(ng.disconnect(),ng=null),Ri.forEach(e=>e.remove()),Ri.clear(),Array.from(vy).forEach(e=>g5(e)),fo=null,Ro=null}function Gde(){if(typeof document=="undefined"||document.getElementById(v7))return;const t=document.createElement("style");t.id=v7,t.textContent=`
|
|
3581
3582
|
.rte-toolbar-group-items.${Us},
|
|
3582
3583
|
.editora-toolbar-group-items.${Us},
|
|
3583
3584
|
.rte-toolbar-group-items.${yl},
|
|
@@ -4140,7 +4141,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4140
4141
|
grid-template-columns: 1fr;
|
|
4141
4142
|
}
|
|
4142
4143
|
}
|
|
4143
|
-
`,document.head.appendChild(t)}const x5=Object.freeze(Object.defineProperty({__proto__:null,TranslationWorkflowPlugin:(t={})=>{const e=Kw(t),n=new Set;return Gde(),{name:"translationWorkflow",toolbar:[{id:"translationWorkflowGroup",label:"Translation Workflow",type:"group",command:"translationWorkflow",items:[{id:"toggleTranslationWorkflowPanel",label:"Translation Workflow",command:"toggleTranslationWorkflowPanel",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"runTranslationLocaleValidation",label:"Run Locale Validation",command:"runTranslationLocaleValidation",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleTranslationSegmentLock",label:"Toggle Segment Lock",command:"toggleTranslationSegmentLock",shortcut:"Mod-Alt-Shift-k",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'},{id:"toggleTranslationRealtime",label:"Toggle Translation Realtime",command:"toggleTranslationRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'}]}],commands:{translationWorkflow:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,v5(o),!0},openTranslationWorkflowPanel:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,v5(o),!0},toggleTranslationWorkflowPanel:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,FP(o,typeof r=="boolean"?r:void 0)},runTranslationLocaleValidation:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,Ns(o,"command",!0),!0},toggleTranslationRealtime:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,LP(o,typeof r=="boolean"?r:void 0)},toggleTranslationSegmentLock:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;Nr(o,a),cn.set(o,a),Ro=o;const s=typeof r=="boolean"?r:r==null?void 0:r.locked,c=typeof r=="object"?r==null?void 0:r.segmentId:void 0;return Jw(o,c,s)},setTranslationLocales:(r,i)=>{const o=mc(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=cn.get(o)||e,s=Nr(o,a);return cn.set(o,a),typeof r.sourceLocale=="string"&&r.sourceLocale.trim()&&(s.sourceLocale=Tu(r.sourceLocale)),typeof r.targetLocale=="string"&&r.targetLocale.trim()&&(s.targetLocale=Tu(r.targetLocale)),s.snapshot="",Ns(o,"set-locales",!0),!0},captureTranslationSourceSnapshot:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,DP(o)},setTranslationWorkflowOptions:(r,i)=>{const o=mc(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=cn.get(o)||e,s=jw.get(o)||_de(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},localeRules:Array.isArray(r.localeRules)?r.localeRules:s.localeRules,locales:Array.isArray(r.locales)?r.locales:s.locales,normalizeText:r.normalizeText||a.normalizeText},l=Kw(c);cn.set(o,l),jw.set(o,c);const u=Nr(o,l);return typeof r.enableRealtime=="boolean"&&(u.realtimeEnabled=r.enableRealtime),typeof r.sourceLocale=="string"&&r.sourceLocale.trim()&&(u.sourceLocale=Tu(r.sourceLocale)),typeof r.targetLocale=="string"&&r.targetLocale.trim()&&(u.targetLocale=Tu(r.targetLocale)),u.snapshot="",Ns(o,"set-options",!0),ku(o),vl(o),!0},getTranslationWorkflowState:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;Nr(o,a);const s=SP(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__translationWorkflowState=s,o.dispatchEvent(new CustomEvent("editora:translation-workflow-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-l":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-L":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-v":"runTranslationLocaleValidation","Mod-Alt-Shift-V":"runTranslationLocaleValidation","Mod-Alt-Shift-k":"toggleTranslationSegmentLock","Mod-Alt-Shift-K":"toggleTranslationSegmentLock"},init:function(i){Ww+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=Kw(o);Kde(a);const s=mc(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);if(!s)return;Ro=s,n.add(s);const c=Nr(s,a);cn.set(s,a),jw.set(s,o),c.segments=Gd(s,a,c),Ns(s,"init",!0),vl(s)},destroy:()=>{n.forEach(r=>g5(r)),n.clear(),Ww=Math.max(0,Ww-1),!(Ww>0)&&Vde()}}}},Symbol.toStringTag,{value:"Module"})),wl=".rte-content, .editora-content",E5="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",UP="__editoraCommandEditorRoot",NP="rte-content-rules-styles",Wr="rte-content-rules-panel",Cy=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Xde={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},Rr=new WeakMap,Bu=new WeakMap,RP=new WeakMap,Xd=new WeakMap,t2=new WeakMap,OP=new WeakMap,C5=new WeakMap,is=new Map,Ty=new WeakMap,ky=new Set;let n2=0,Yde=0,xl=null,ua=null,rg=null,ig=null,og=null,Yd=null;function El(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zde(t){return{...Xde,...t||{}}}function Jde(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function MP(t){if(!t)return[];const e=new Set;return t.forEach(n=>{const r=n.trim();r&&e.add(r)}),Array.from(e)}function r2(t={}){var e,n,r,i;return{bannedWords:MP(t.bannedWords),requiredHeadings:MP(t.requiredHeadings),maxSentenceWords:Math.max(8,Number((e=t.maxSentenceWords)!=null?e:32)),minReadabilityScore:Math.max(0,Math.min(120,Number((n=t.minReadabilityScore)!=null?n:55))),maxIssues:Math.max(1,Number((r=t.maxIssues)!=null?r:100)),debounceMs:Math.max(50,Number((i=t.debounceMs)!=null?i:220)),enableRealtime:t.enableRealtime!==!1,labels:Zde(t.labels),normalizeText:t.normalizeText||Jde,customRules:Array.isArray(t.customRules)?t.customRules:[]}}function i2(t){return t.closest(E5)||t}function o2(t){if(!t)return null;if(t.matches(wl))return t;const e=t.querySelector(wl);return e instanceof HTMLElement?e:null}function efe(){if(typeof window=="undefined")return null;const t=window[UP];if(!(t instanceof HTMLElement))return null;window[UP]=null;const e=o2(t);if(e)return e;const n=t.closest(E5);if(n){const r=o2(n);if(r)return r}return null}function tfe(t){const e=t.closest("[data-editora-editor]");if(e&&o2(e)===t)return e;let n=t;for(;n;){if(n.matches(E5)&&(n===t||o2(n)===t))return n;n=n.parentElement}return i2(t)}function a2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function nfe(t){const e=i2(t);if(a2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return a2(n)?!0:a2(document.documentElement)||a2(document.body)}function s2(t,e){t.classList.remove("rte-content-rules-theme-dark"),nfe(e)&&t.classList.add("rte-content-rules-theme-dark")}function rfe(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Zd(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement;if(o.matches(wl))return o;const a=o.querySelector(wl);if(a instanceof HTMLElement)return a}const n=efe();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=r.getRangeAt(0).startContainer,a=rfe(o),s=a==null?void 0:a.closest(wl);if(s)return s}const i=document.activeElement;if(i){if(i.matches(wl))return i;const o=i.closest(wl);if(o)return o}return ua&&ua.isConnected?ua:(ua&&!ua.isConnected&&(ua=null),e?document.querySelector(wl):null)}function T5(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function ife(t,e){const n=t.innerText||t.textContent||"";return e(n)}function ofe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function PP(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function HP(t){const e=t.match(/\b[\w'-]+\b/g);return e?e.length:0}function QP(t){const e=t.match(/[^.!?]+[.!?]*/g);return e?e.map(n=>n.trim()).filter(Boolean).length:0}function afe(t){const e=t.toLowerCase().replace(/[^a-z]/g,"");if(!e)return 0;if(e.length<=3)return 1;const n=e.match(/[aeiouy]+/g);let r=n?n.length:1;return e.endsWith("e")&&(r-=1),Math.max(1,r)}function sfe(t){const e=t.match(/\b[\w'-]+\b/g)||[],n=e.length;if(n===0)return 100;const r=Math.max(1,QP(t)),i=e.reduce((a,s)=>a+afe(s),0),o=206.835-1.015*(n/r)-84.6*(i/Math.max(1,n));return Number.isFinite(o)?Math.max(0,Math.min(120,o)):0}function By(t,e){return`${t}-${e}`}function bc(t,e){return t.length>=e}function Sy(t,e,n){bc(t,n)||t.push(e)}function $P(t,e=140){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}...`}function cfe(t,e,n,r){return{id:t.id||By(e,r),ruleId:t.ruleId||e,severity:t.severity||n,message:t.message||e,excerpt:t.excerpt?$P(t.excerpt,220):void 0,suggestion:t.suggestion,locateText:t.locateText,selector:t.selector}}function lfe(t,e){const n=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=new Set;return n.forEach(i=>{const o=e(i.textContent||"").toLowerCase();o&&r.add(o)}),r}function ufe(t){const e=t.match(/[^.!?\n]+[.!?]?/g);return e?e.map(n=>n.trim()).filter(Boolean):[]}async function Cl(t,e,n=!1){const r=ife(t,e.normalizeText),i=t.innerHTML,o=`${r.length}:${PP(r)}:${i.length}:${PP(i)}`;if(!n&&OP.get(t)===o)return Bu.get(t)||[];const a=(C5.get(t)||0)+1;C5.set(t,a);const s=HP(r),c=QP(r),l=sfe(r),u=[],d=e.labels;if(e.bannedWords.length>0){let A=0;for(const h of e.bannedWords){const p=new RegExp(`\\b${ofe(h)}\\b`,"gi");let m=p.exec(r);for(;m&&!bc(u,e.maxIssues);){const g=m[0];Sy(u,{id:By("banned-word",A),ruleId:"banned-word",severity:"error",message:`${d.bannedWordMessage}: "${g}"`,locateText:g,suggestion:"Replace or remove banned terms."},e.maxIssues),A+=1,m=p.exec(r)}if(bc(u,e.maxIssues))break}}if(!bc(u,e.maxIssues)&&e.requiredHeadings.length>0){const A=lfe(t,e.normalizeText);let h=0;e.requiredHeadings.forEach(p=>{if(bc(u,e.maxIssues))return;const m=e.normalizeText(p).toLowerCase();!m||A.has(m)||(Sy(u,{id:By("required-heading",h),ruleId:"required-heading",severity:"warning",message:`${d.requiredHeadingMessage}: "${p}"`,suggestion:`Add a heading named "${p}".`},e.maxIssues),h+=1)})}if(!bc(u,e.maxIssues)){const A=ufe(r);let h=0;for(const p of A){if(bc(u,e.maxIssues))break;const m=HP(p);m<=e.maxSentenceWords||(Sy(u,{id:By("sentence-length",h),ruleId:"sentence-length",severity:"warning",message:`${d.sentenceLengthMessage} (${m}/${e.maxSentenceWords} words)`,excerpt:$P(p,200),locateText:p.slice(0,64),suggestion:"Split into shorter sentences for readability."},e.maxIssues),h+=1)}}if(!bc(u,e.maxIssues)&&s>0&&l<e.minReadabilityScore&&Sy(u,{id:By("readability",0),ruleId:"readability",severity:"info",message:`${d.readabilityMessage}: ${l.toFixed(1)} < ${e.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},e.maxIssues),!bc(u,e.maxIssues)&&e.customRules.length>0){const A={editor:t,editorRoot:i2(t),text:r,html:i,wordCount:s,sentenceCount:c,readabilityScore:l};for(const h of e.customRules){if(bc(u,e.maxIssues))break;try{const p=await h.evaluate(A);if(!Array.isArray(p))continue;for(let m=0;m<p.length&&!bc(u,e.maxIssues);m+=1)Sy(u,cfe(p[m],h.id,h.severity||"warning",m),e.maxIssues)}catch(p){}}}if(C5.get(t)!==a)return Bu.get(t)||[];const f={readabilityScore:l,wordCount:s,sentenceCount:c};return OP.set(t,o),Bu.set(t,u),RP.set(t,f),B5(t),t.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:u,metrics:f}})),u}function dfe(t){return t.reduce((e,n)=>(e[n.severity]+=1,e),{error:0,warning:0,info:0})}function ffe(t){return t==="error"?"Error":t==="warning"?"Warning":"Info"}function Su(t,e,n){const r=tfe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function c2(t){return Ty.get(t)===!0}function k5(t,e){if(!e.classList.contains("show"))return;const r=i2(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,360);e.style.width=`${i}px`,e.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const o=Math.max(10,r.right-i),a=Math.max(10,window.innerWidth-i-10),s=Math.min(o,a),c=Math.max(10,Math.min(window.innerHeight-10-240,r.top+10));e.style.left=`${s}px`,e.style.top=`${c}px`}function zP(t,e){const n=e.trim().toLowerCase();if(!n)return!1;const r=window.getSelection();if(!r)return!1;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let o=i.nextNode();for(;o;){const s=o.data.toLowerCase().indexOf(n);if(s!==-1){const c=document.createRange();c.setStart(o,s),c.setEnd(o,Math.min(o.length,s+n.length)),r.removeAllRanges(),r.addRange(c);const l=o.parentElement;return l&&l.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),t.focus({preventScroll:!0}),!0}o=i.nextNode()}return!1}function Afe(t,e){if(e.selector){const n=t.querySelector(e.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(e.locateText&&zP(t,e.locateText)||e.excerpt&&zP(t,e.excerpt.slice(0,64)))}function hfe(t,e){return(Bu.get(t)||[]).find(r=>r.id===e)}function UA(t,e){const n=Xd.get(t);return typeof n=="boolean"?n:e?e.enableRealtime:!0}function ag(t,e,n){const r=e.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=UA(t,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),Su(t,"toggleContentRulesRealtime",i)}function B5(t){const e=is.get(t);if(!e)return;const n=Rr.get(t)||xl;if(!n)return;const r=Bu.get(t)||[],i=RP.get(t)||{readabilityScore:100},o=e.querySelector(".rte-content-rules-count"),a=e.querySelector(".rte-content-rules-summary"),s=e.querySelector(".rte-content-rules-list"),c=e.querySelector(".rte-content-rules-live");if(!o||!a||!s||!c)return;const l=dfe(r);if(o.textContent=String(r.length),a.textContent=`${n.labels.summaryPrefix}: ${r.length} | Error ${l.error} | Warning ${l.warning} | Info ${l.info} | Readability ${i.readabilityScore.toFixed(1)}`,c.textContent=`${r.length} issues. ${l.error} errors, ${l.warning} warnings, ${l.info} info.`,r.length===0){s.innerHTML=`<li class="rte-content-rules-empty">${El(n.labels.noIssuesText)}</li>`;return}s.innerHTML=r.map(u=>{const d=u.excerpt?`<p class="rte-content-rules-excerpt">${El(u.excerpt)}</p>`:"",f=u.suggestion?`<p class="rte-content-rules-suggestion">${El(u.suggestion)}</p>`:"",A=`${n.labels.locateText}: ${u.message}`;return`
|
|
4144
|
+
`,document.head.appendChild(t)}const x5=Object.freeze(Object.defineProperty({__proto__:null,TranslationWorkflowPlugin:(t={})=>{const e=Kw(t),n=new Set;return Gde(),{name:"translationWorkflow",toolbar:[{id:"translationWorkflowGroup",label:"Translation Workflow",type:"group",command:"translationWorkflow",items:[{id:"toggleTranslationWorkflowPanel",label:"Translation Workflow",command:"toggleTranslationWorkflowPanel",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 6.5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8l-4 3V6.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M20 17.5a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-1.5" stroke="currentColor" stroke-width="1.6"/><path d="m13 8 2 2m0 0 2-2m-2 2V4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"runTranslationLocaleValidation",label:"Run Locale Validation",command:"runTranslationLocaleValidation",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="4" width="12" height="16" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h5.5M8 11h4M8 14h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="m15.5 15.5 1.7 1.7 3.3-3.3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"toggleTranslationSegmentLock",label:"Toggle Segment Lock",command:"toggleTranslationSegmentLock",shortcut:"Mod-Alt-Shift-k",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="5" y="10" width="14" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M8.5 10V7.5a3.5 3.5 0 1 1 7 0V10" stroke="currentColor" stroke-width="1.6"/><circle cx="12" cy="15" r="1.2" fill="currentColor"/></svg>'},{id:"toggleTranslationRealtime",label:"Toggle Translation Realtime",command:"toggleTranslationRealtime",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 8v4l2.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'}]}],commands:{translationWorkflow:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,v5(o),!0},openTranslationWorkflowPanel:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,v5(o),!0},toggleTranslationWorkflowPanel:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,F7(o,typeof r=="boolean"?r:void 0)},runTranslationLocaleValidation:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,Ns(o,"command",!0),!0},toggleTranslationRealtime:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,L7(o,typeof r=="boolean"?r:void 0)},toggleTranslationSegmentLock:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;Nr(o,a),cn.set(o,a),Ro=o;const s=typeof r=="boolean"?r:r==null?void 0:r.locked,c=typeof r=="object"?r==null?void 0:r.segmentId:void 0;return Jw(o,c,s)},setTranslationLocales:(r,i)=>{const o=mc(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=cn.get(o)||e,s=Nr(o,a);return cn.set(o,a),typeof r.sourceLocale=="string"&&r.sourceLocale.trim()&&(s.sourceLocale=Tu(r.sourceLocale)),typeof r.targetLocale=="string"&&r.targetLocale.trim()&&(s.targetLocale=Tu(r.targetLocale)),s.snapshot="",Ns(o,"set-locales",!0),!0},captureTranslationSourceSnapshot:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;return Nr(o,a),cn.set(o,a),Ro=o,D7(o)},setTranslationWorkflowOptions:(r,i)=>{const o=mc(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=cn.get(o)||e,s=jw.get(o)||_de(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},localeRules:Array.isArray(r.localeRules)?r.localeRules:s.localeRules,locales:Array.isArray(r.locales)?r.locales:s.locales,normalizeText:r.normalizeText||a.normalizeText},l=Kw(c);cn.set(o,l),jw.set(o,c);const u=Nr(o,l);return typeof r.enableRealtime=="boolean"&&(u.realtimeEnabled=r.enableRealtime),typeof r.sourceLocale=="string"&&r.sourceLocale.trim()&&(u.sourceLocale=Tu(r.sourceLocale)),typeof r.targetLocale=="string"&&r.targetLocale.trim()&&(u.targetLocale=Tu(r.targetLocale)),u.snapshot="",Ns(o,"set-options",!0),ku(o),vl(o),!0},getTranslationWorkflowState:(r,i)=>{const o=mc(i,!1,!1);if(!o)return!1;const a=cn.get(o)||e;Nr(o,a);const s=S7(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__translationWorkflowState=s,o.dispatchEvent(new CustomEvent("editora:translation-workflow-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-l":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-L":"toggleTranslationWorkflowPanel","Mod-Alt-Shift-v":"runTranslationLocaleValidation","Mod-Alt-Shift-V":"runTranslationLocaleValidation","Mod-Alt-Shift-k":"toggleTranslationSegmentLock","Mod-Alt-Shift-K":"toggleTranslationSegmentLock"},init:function(i){Ww+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=Kw(o);Kde(a);const s=mc(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);if(!s)return;Ro=s,n.add(s);const c=Nr(s,a);cn.set(s,a),jw.set(s,o),c.segments=Gd(s,a,c),Ns(s,"init",!0),vl(s)},destroy:()=>{n.forEach(r=>g5(r)),n.clear(),Ww=Math.max(0,Ww-1),!(Ww>0)&&Vde()}}}},Symbol.toStringTag,{value:"Module"})),wl=".rte-content, .editora-content",E5="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",U7="__editoraCommandEditorRoot",N7="rte-content-rules-styles",Wr="rte-content-rules-panel",Cy=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Xde={panelTitle:"Content Rules",panelAriaLabel:"Content rules panel",runAuditText:"Run Audit",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No rule violations detected.",summaryPrefix:"Issues",locateText:"Locate",bannedWordMessage:"Banned word found",requiredHeadingMessage:"Missing required heading",sentenceLengthMessage:"Sentence is too long",readabilityMessage:"Readability score is below threshold"},Rr=new WeakMap,Bu=new WeakMap,R7=new WeakMap,Xd=new WeakMap,t2=new WeakMap,O7=new WeakMap,C5=new WeakMap,is=new Map,Ty=new WeakMap,ky=new Set;let n2=0,Yde=0,xl=null,ua=null,rg=null,ig=null,og=null,Yd=null;function El(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zde(t){return{...Xde,...t||{}}}function Jde(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function M7(t){if(!t)return[];const e=new Set;return t.forEach(n=>{const r=n.trim();r&&e.add(r)}),Array.from(e)}function r2(t={}){var e,n,r,i;return{bannedWords:M7(t.bannedWords),requiredHeadings:M7(t.requiredHeadings),maxSentenceWords:Math.max(8,Number((e=t.maxSentenceWords)!=null?e:32)),minReadabilityScore:Math.max(0,Math.min(120,Number((n=t.minReadabilityScore)!=null?n:55))),maxIssues:Math.max(1,Number((r=t.maxIssues)!=null?r:100)),debounceMs:Math.max(50,Number((i=t.debounceMs)!=null?i:220)),enableRealtime:t.enableRealtime!==!1,labels:Zde(t.labels),normalizeText:t.normalizeText||Jde,customRules:Array.isArray(t.customRules)?t.customRules:[]}}function i2(t){return t.closest(E5)||t}function o2(t){if(!t)return null;if(t.matches(wl))return t;const e=t.querySelector(wl);return e instanceof HTMLElement?e:null}function efe(){if(typeof window=="undefined")return null;const t=window[U7];if(!(t instanceof HTMLElement))return null;window[U7]=null;const e=o2(t);if(e)return e;const n=t.closest(E5);if(n){const r=o2(n);if(r)return r}return null}function tfe(t){const e=t.closest("[data-editora-editor]");if(e&&o2(e)===t)return e;let n=t;for(;n;){if(n.matches(E5)&&(n===t||o2(n)===t))return n;n=n.parentElement}return i2(t)}function a2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function nfe(t){const e=i2(t);if(a2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return a2(n)?!0:a2(document.documentElement)||a2(document.body)}function s2(t,e){t.classList.remove("rte-content-rules-theme-dark"),nfe(e)&&t.classList.add("rte-content-rules-theme-dark")}function rfe(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Zd(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement;if(o.matches(wl))return o;const a=o.querySelector(wl);if(a instanceof HTMLElement)return a}const n=efe();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=r.getRangeAt(0).startContainer,a=rfe(o),s=a==null?void 0:a.closest(wl);if(s)return s}const i=document.activeElement;if(i){if(i.matches(wl))return i;const o=i.closest(wl);if(o)return o}return ua&&ua.isConnected?ua:(ua&&!ua.isConnected&&(ua=null),e?document.querySelector(wl):null)}function T5(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function ife(t,e){const n=t.innerText||t.textContent||"";return e(n)}function ofe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function P7(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function H7(t){const e=t.match(/\b[\w'-]+\b/g);return e?e.length:0}function Q7(t){const e=t.match(/[^.!?]+[.!?]*/g);return e?e.map(n=>n.trim()).filter(Boolean).length:0}function afe(t){const e=t.toLowerCase().replace(/[^a-z]/g,"");if(!e)return 0;if(e.length<=3)return 1;const n=e.match(/[aeiouy]+/g);let r=n?n.length:1;return e.endsWith("e")&&(r-=1),Math.max(1,r)}function sfe(t){const e=t.match(/\b[\w'-]+\b/g)||[],n=e.length;if(n===0)return 100;const r=Math.max(1,Q7(t)),i=e.reduce((a,s)=>a+afe(s),0),o=206.835-1.015*(n/r)-84.6*(i/Math.max(1,n));return Number.isFinite(o)?Math.max(0,Math.min(120,o)):0}function By(t,e){return`${t}-${e}`}function bc(t,e){return t.length>=e}function Sy(t,e,n){bc(t,n)||t.push(e)}function $7(t,e=140){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}...`}function cfe(t,e,n,r){return{id:t.id||By(e,r),ruleId:t.ruleId||e,severity:t.severity||n,message:t.message||e,excerpt:t.excerpt?$7(t.excerpt,220):void 0,suggestion:t.suggestion,locateText:t.locateText,selector:t.selector}}function lfe(t,e){const n=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=new Set;return n.forEach(i=>{const o=e(i.textContent||"").toLowerCase();o&&r.add(o)}),r}function ufe(t){const e=t.match(/[^.!?\n]+[.!?]?/g);return e?e.map(n=>n.trim()).filter(Boolean):[]}async function Cl(t,e,n=!1){const r=ife(t,e.normalizeText),i=t.innerHTML,o=`${r.length}:${P7(r)}:${i.length}:${P7(i)}`;if(!n&&O7.get(t)===o)return Bu.get(t)||[];const a=(C5.get(t)||0)+1;C5.set(t,a);const s=H7(r),c=Q7(r),l=sfe(r),u=[],d=e.labels;if(e.bannedWords.length>0){let A=0;for(const h of e.bannedWords){const p=new RegExp(`\\b${ofe(h)}\\b`,"gi");let m=p.exec(r);for(;m&&!bc(u,e.maxIssues);){const g=m[0];Sy(u,{id:By("banned-word",A),ruleId:"banned-word",severity:"error",message:`${d.bannedWordMessage}: "${g}"`,locateText:g,suggestion:"Replace or remove banned terms."},e.maxIssues),A+=1,m=p.exec(r)}if(bc(u,e.maxIssues))break}}if(!bc(u,e.maxIssues)&&e.requiredHeadings.length>0){const A=lfe(t,e.normalizeText);let h=0;e.requiredHeadings.forEach(p=>{if(bc(u,e.maxIssues))return;const m=e.normalizeText(p).toLowerCase();!m||A.has(m)||(Sy(u,{id:By("required-heading",h),ruleId:"required-heading",severity:"warning",message:`${d.requiredHeadingMessage}: "${p}"`,suggestion:`Add a heading named "${p}".`},e.maxIssues),h+=1)})}if(!bc(u,e.maxIssues)){const A=ufe(r);let h=0;for(const p of A){if(bc(u,e.maxIssues))break;const m=H7(p);m<=e.maxSentenceWords||(Sy(u,{id:By("sentence-length",h),ruleId:"sentence-length",severity:"warning",message:`${d.sentenceLengthMessage} (${m}/${e.maxSentenceWords} words)`,excerpt:$7(p,200),locateText:p.slice(0,64),suggestion:"Split into shorter sentences for readability."},e.maxIssues),h+=1)}}if(!bc(u,e.maxIssues)&&s>0&&l<e.minReadabilityScore&&Sy(u,{id:By("readability",0),ruleId:"readability",severity:"info",message:`${d.readabilityMessage}: ${l.toFixed(1)} < ${e.minReadabilityScore}`,suggestion:"Use shorter sentences and simpler wording."},e.maxIssues),!bc(u,e.maxIssues)&&e.customRules.length>0){const A={editor:t,editorRoot:i2(t),text:r,html:i,wordCount:s,sentenceCount:c,readabilityScore:l};for(const h of e.customRules){if(bc(u,e.maxIssues))break;try{const p=await h.evaluate(A);if(!Array.isArray(p))continue;for(let m=0;m<p.length&&!bc(u,e.maxIssues);m+=1)Sy(u,cfe(p[m],h.id,h.severity||"warning",m),e.maxIssues)}catch(p){}}}if(C5.get(t)!==a)return Bu.get(t)||[];const f={readabilityScore:l,wordCount:s,sentenceCount:c};return O7.set(t,o),Bu.set(t,u),R7.set(t,f),B5(t),t.dispatchEvent(new CustomEvent("editora:content-rules-audit",{bubbles:!0,detail:{issues:u,metrics:f}})),u}function dfe(t){return t.reduce((e,n)=>(e[n.severity]+=1,e),{error:0,warning:0,info:0})}function ffe(t){return t==="error"?"Error":t==="warning"?"Warning":"Info"}function Su(t,e,n){const r=tfe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function c2(t){return Ty.get(t)===!0}function k5(t,e){if(!e.classList.contains("show"))return;const r=i2(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,360);e.style.width=`${i}px`,e.style.maxHeight=`${Math.max(220,window.innerHeight-24)}px`;const o=Math.max(10,r.right-i),a=Math.max(10,window.innerWidth-i-10),s=Math.min(o,a),c=Math.max(10,Math.min(window.innerHeight-10-240,r.top+10));e.style.left=`${s}px`,e.style.top=`${c}px`}function z7(t,e){const n=e.trim().toLowerCase();if(!n)return!1;const r=window.getSelection();if(!r)return!1;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let o=i.nextNode();for(;o;){const s=o.data.toLowerCase().indexOf(n);if(s!==-1){const c=document.createRange();c.setStart(o,s),c.setEnd(o,Math.min(o.length,s+n.length)),r.removeAllRanges(),r.addRange(c);const l=o.parentElement;return l&&l.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),t.focus({preventScroll:!0}),!0}o=i.nextNode()}return!1}function Afe(t,e){if(e.selector){const n=t.querySelector(e.selector);if(n)return n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0}),!0}return!!(e.locateText&&z7(t,e.locateText)||e.excerpt&&z7(t,e.excerpt.slice(0,64)))}function hfe(t,e){return(Bu.get(t)||[]).find(r=>r.id===e)}function UA(t,e){const n=Xd.get(t);return typeof n=="boolean"?n:e?e.enableRealtime:!0}function ag(t,e,n){const r=e.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=UA(t,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),Su(t,"toggleContentRulesRealtime",i)}function B5(t){const e=is.get(t);if(!e)return;const n=Rr.get(t)||xl;if(!n)return;const r=Bu.get(t)||[],i=R7.get(t)||{readabilityScore:100},o=e.querySelector(".rte-content-rules-count"),a=e.querySelector(".rte-content-rules-summary"),s=e.querySelector(".rte-content-rules-list"),c=e.querySelector(".rte-content-rules-live");if(!o||!a||!s||!c)return;const l=dfe(r);if(o.textContent=String(r.length),a.textContent=`${n.labels.summaryPrefix}: ${r.length} | Error ${l.error} | Warning ${l.warning} | Info ${l.info} | Readability ${i.readabilityScore.toFixed(1)}`,c.textContent=`${r.length} issues. ${l.error} errors, ${l.warning} warnings, ${l.info} info.`,r.length===0){s.innerHTML=`<li class="rte-content-rules-empty">${El(n.labels.noIssuesText)}</li>`;return}s.innerHTML=r.map(u=>{const d=u.excerpt?`<p class="rte-content-rules-excerpt">${El(u.excerpt)}</p>`:"",f=u.suggestion?`<p class="rte-content-rules-suggestion">${El(u.suggestion)}</p>`:"",A=`${n.labels.locateText}: ${u.message}`;return`
|
|
4144
4145
|
<li class="rte-content-rules-item rte-content-rules-item-${u.severity}">
|
|
4145
4146
|
<button
|
|
4146
4147
|
type="button"
|
|
@@ -4174,7 +4175,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4174
4175
|
<p class="rte-content-rules-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + R</p>
|
|
4175
4176
|
<span class="rte-content-rules-live" aria-live="polite"></span>
|
|
4176
4177
|
</div>
|
|
4177
|
-
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action");if(c){if(c==="close"){sg(t,!0);return}if(c==="run-audit"){const l=Rr.get(t)||xl||n;Cl(t,l,!0);return}if(c==="toggle-realtime"){const u=!UA(t,Rr.get(t)||xl||n);if(Xd.set(t,u),ag(t,i,Rr.get(t)||xl||n),u){const d=Rr.get(t)||xl||n;Cl(t,d,!0)}return}if(c==="focus-issue"){const l=s.getAttribute("data-issue-id")||"",u=hfe(t,l);if(!u)return;Afe(t,u),sg(t,!1)}}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),sg(t,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="issue-button"]'));if(a.length===0)return;const s=document.activeElement,c=a.findIndex(d=>d===s);if(c===-1)return;o.preventDefault();const l=o.key==="ArrowDown"?1:-1,u=(c+l+a.length)%a.length;a[u].focus()}),s2(i,t),document.body.appendChild(i),is.set(t,i),Ty.set(t,!1),ag(t,i,n),i}function S5(t){const e=gfe(t);pfe(t),e.classList.add("show"),Ty.set(t,!0),s2(e,t),k5(t,e),B5(t),Su(t,"toggleContentRulesPanel",!0);const n=e.querySelector('[data-action="run-audit"]');n==null||n.focus()}function _5(t,e){const n=c2(t);return(typeof e=="boolean"?e:!n)?S5(t):sg(t,!1),!0}function
|
|
4178
|
+
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action");if(c){if(c==="close"){sg(t,!0);return}if(c==="run-audit"){const l=Rr.get(t)||xl||n;Cl(t,l,!0);return}if(c==="toggle-realtime"){const u=!UA(t,Rr.get(t)||xl||n);if(Xd.set(t,u),ag(t,i,Rr.get(t)||xl||n),u){const d=Rr.get(t)||xl||n;Cl(t,d,!0)}return}if(c==="focus-issue"){const l=s.getAttribute("data-issue-id")||"",u=hfe(t,l);if(!u)return;Afe(t,u),sg(t,!1)}}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),sg(t,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="issue-button"]'));if(a.length===0)return;const s=document.activeElement,c=a.findIndex(d=>d===s);if(c===-1)return;o.preventDefault();const l=o.key==="ArrowDown"?1:-1,u=(c+l+a.length)%a.length;a[u].focus()}),s2(i,t),document.body.appendChild(i),is.set(t,i),Ty.set(t,!1),ag(t,i,n),i}function S5(t){const e=gfe(t);pfe(t),e.classList.add("show"),Ty.set(t,!0),s2(e,t),k5(t,e),B5(t),Su(t,"toggleContentRulesPanel",!0);const n=e.querySelector('[data-action="run-audit"]');n==null||n.focus()}function _5(t,e){const n=c2(t);return(typeof e=="boolean"?e:!n)?S5(t):sg(t,!1),!0}function j7(t){const e=t2.get(t);typeof e=="number"&&(window.clearTimeout(e),ky.delete(e),t2.delete(t))}function q7(t){const e=Rr.get(t)||xl;if(!e||!UA(t,e))return;j7(t);const n=window.setTimeout(()=>{ky.delete(n),t2.delete(t),Cl(t,e,!1)},e.debounceMs);ky.add(n),t2.set(t,n)}function D5(t){return typeof t.key=="string"?t.key.toLowerCase():""}function mfe(t){const e=D5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="r"}function bfe(t){const e=D5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="l"}function yfe(t){const e=D5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="t"}function vfe(){if(typeof document=="undefined"||document.getElementById(N7))return;const t=document.createElement("style");t.id=N7,t.textContent=`
|
|
4178
4179
|
.rte-toolbar-group-items.content-rules,
|
|
4179
4180
|
.editora-toolbar-group-items.content-rules {
|
|
4180
4181
|
display: flex;
|
|
@@ -4547,7 +4548,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4547
4548
|
max-height: 45vh;
|
|
4548
4549
|
}
|
|
4549
4550
|
}
|
|
4550
|
-
`,document.head.appendChild(t)}function wfe(t){xl=t,rg||(rg=e=>{const n=e.target,r=n==null?void 0:n.closest(wl);if(!r)return;ua=r,Rr.has(r)||Rr.set(r,t),Bu.has(r)||Bu.set(r,[]),Xd.has(r)||Xd.set(r,t.enableRealtime);const i=is.get(r);i&&(s2(i,r),k5(r,i),ag(r,i,Rr.get(r)||t)),Su(r,"toggleContentRulesPanel",c2(r)),Su(r,"toggleContentRulesRealtime",UA(r,t))},document.addEventListener("focusin",rg,!0)),ig||(ig=e=>{const n=e.target,r=n==null?void 0:n.closest(wl);r&&(ua=r,qP(r))},document.addEventListener("input",ig,!0)),og||(og=e=>{if(e.defaultPrevented)return;const n=e.target;if(n!=null&&n.closest("input, textarea, select"))return;const r=e.key==="Escape",i=mfe(e),o=bfe(e),a=yfe(e);if(!r&&!i&&!o&&!a)return;const s=Zd(void 0,!1);if(!s||T5(s))return;const c=Rr.get(s)||xl||t;if(Rr.set(s,c),ua=s,r&&c2(s)){e.preventDefault(),sg(s,!0);return}if(i){e.preventDefault(),e.stopPropagation(),_5(s);return}if(o){e.preventDefault(),e.stopPropagation(),Cl(s,c,!0),S5(s);return}if(a){e.preventDefault(),e.stopPropagation();const l=!UA(s,c);Xd.set(s,l);const u=is.get(s);u&&ag(s,u,c),Su(s,"toggleContentRulesRealtime",l),l&&Cl(s,c,!0)}},document.addEventListener("keydown",og,!0)),Yd||(Yd=()=>{is.forEach((e,n)=>{if(!n.isConnected||!e.isConnected){jP(n),e.remove(),is.delete(n),Ty.delete(n);return}s2(e,n),k5(n,e)})},window.addEventListener("scroll",Yd,!0),window.addEventListener("resize",Yd))}function xfe(){rg&&(document.removeEventListener("focusin",rg,!0),rg=null),ig&&(document.removeEventListener("input",ig,!0),ig=null),og&&(document.removeEventListener("keydown",og,!0),og=null),Yd&&(window.removeEventListener("scroll",Yd,!0),window.removeEventListener("resize",Yd),Yd=null),is.forEach(t=>{t.remove()}),is.clear(),xl=null,ua=null}const L5=Object.freeze(Object.defineProperty({__proto__:null,ContentRulesPlugin:(t={})=>{const e=r2(t);return vfe(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,r)=>{const i=Zd(r);if(!i||T5(i))return!1;const o=Rr.get(i)||e;return Rr.set(i,o),ua=i,_5(i,!0),Cl(i,o,!1),!0},toggleContentRulesPanel:(n,r)=>{const i=Zd(r);if(!i||T5(i))return!1;ua=i;const o=Rr.get(i)||e;Rr.set(i,o);const a=_5(i,typeof n=="boolean"?n:void 0);return c2(i)&&Cl(i,o,!1),a},runContentRulesAudit:async(n,r)=>{const i=Zd(r);if(!i)return!1;ua=i;const o=Rr.get(i)||e;return Rr.set(i,o),await Cl(i,o,!0),S5(i),!0},toggleContentRulesRealtime:(n,r)=>{const i=Zd(r);if(!i)return!1;ua=i;const o=Rr.get(i)||e;Rr.set(i,o);const a=typeof n=="boolean"?n:!UA(i,o);Xd.set(i,a);const s=is.get(i);return s&&ag(i,s,o),Su(i,"toggleContentRulesRealtime",a),a&&Cl(i,o,!0),!0},getContentRulesIssues:(n,r)=>{const i=Zd(r);if(!i)return!1;const o=Bu.get(i)||[];if(typeof n=="function")try{n(o)}catch(a){}return i.__contentRulesIssues=o,i.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:o}})),!0},setContentRulesOptions:(n,r)=>{const i=Zd(r);if(!i||!n||typeof n!="object")return!1;const o=Rr.get(i)||e,a=r2({...o,...n,labels:{...o.labels,...n.labels||{}}});Rr.set(i,a),typeof n.enableRealtime=="boolean"&&Xd.set(i,n.enableRealtime),UA(i,a)&&Cl(i,a,!0);const s=is.get(i);if(s){s.setAttribute("aria-label",a.labels.panelAriaLabel);const c=s.querySelector(".rte-content-rules-title");c&&(c.textContent=a.labels.panelTitle),ag(i,s,a),B5(i)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(r){n2+=1;const i=this&&typeof this.__pluginConfig=="object"?r2({...e,...this.__pluginConfig}):e;wfe(i);const o=Zd(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(ua=o,Rr.set(o,i),Xd.set(o,i.enableRealtime),Bu.set(o,[]),Su(o,"toggleContentRulesPanel",!1),Su(o,"toggleContentRulesRealtime",i.enableRealtime),i.enableRealtime&&qP(o))},destroy:()=>{n2=Math.max(0,n2-1),!(n2>0)&&(ky.forEach(n=>{window.clearTimeout(n)}),ky.clear(),xfe())}}}},Symbol.toStringTag,{value:"Module"})),_u=".rte-content, .editora-content",WP="rte-citations-styles",mr="rte-citations-panel",l2=".rte-citation-ref[data-citation-id]",_y='.rte-citation-bibliography[data-type="citation-bibliography"]',Dy='.rte-citation-footnotes[data-type="citation-footnotes"]',Rs=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',NA=["apa","mla","chicago"],Efe={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},Rn=new WeakMap,Jd=new WeakMap,KP=new WeakMap,cg=new WeakMap,Tl=new Map,Ly=new WeakMap,u2=new WeakMap,Fy=new Set;let lg=null,ug=null,dg=null,ef=null,d2=0,Cfe=0,F5=0,tf=null,Ao=null;function Kr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Tfe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function VP(t,e){const n=e(t);if(!n)return"";const r=n.match(/\d{4}/);return r?r[0]:n}function GP(t,e){const n=e(t);return n?/^https?:\/\//i.test(n)?n:`https://${n}`:""}function fg(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function XP(t,e){return{id:fg(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:VP(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:GP(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function f2(t={}){var r,i;const e=t.defaultStyle&&NA.includes(t.defaultStyle)?t.defaultStyle:"apa",n={...Efe,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number((r=t.debounceMs)!=null?r:220)),maxRecentCitations:Math.max(3,Math.min(30,Number((i=t.maxRecentCitations)!=null?i:8))),labels:n,normalizeText:t.normalizeText||Tfe,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function YP(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function I5(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function A2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function kfe(t){const e=I5(t);if(A2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return A2(n)?!0:A2(document.documentElement)||A2(document.body)}function h2(t,e){t.classList.remove("rte-citations-theme-dark"),kfe(e)&&t.classList.add("rte-citations-theme-dark")}function os(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(_u))return i;const o=i.querySelector(_u);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=YP(i),a=o==null?void 0:o.closest(_u);if(a)return a}const r=document.activeElement;if(r){if(r.matches(_u))return r;const i=r.closest(_u);if(i)return i}return Ao&&Ao.isConnected?Ao:(Ao&&!Ao.isConnected&&(Ao=null),e?document.querySelector(_u):null)}function Du(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Iy(t){const e=YP(t);return e?!!(e.closest(_y)||e.closest(Dy)):!1}function Bfe(t,e){if(F5+=1,e.generateCitationId){const n=e.generateCitationId({editor:t,index:F5}),r=fg(e.normalizeText(n||""));if(r)return r}return`cite-${Date.now().toString(36)}-${F5.toString(36)}`}function U5(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function Sfe(t,e){const n=t.author||"Unknown",r=t.year||"n.d.";return e==="mla"?`(${n} ${r})`:e==="chicago"?`(${n} ${r})`:`(${n}, ${r})`}function Ag(t){const e=t.trim();return!e||/[.!?]$/.test(e)?e:`${e}.`}function N5(t,e){const n=Ag(t.author||"Unknown"),r=t.year||"n.d.",i=t.title||"Untitled",o=(t.source||"").trim(),a=t.url||"";return U5(e==="mla"?[n,`"${Ag(i)}"`,o?`${o.replace(/[.,]$/,"")},`:"",`${r}.`,a]:e==="chicago"?[n,Ag(i),Ag(o),`(${r}).`,a]:[n,`(${r}).`,Ag(i),Ag(o),a])}function RA(t){return Array.from(t.querySelectorAll(l2)).filter(e=>!e.closest(_y)&&!e.closest(Dy))}function ZP(t,e){const n=fg(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!n)return null;const r=e.normalizeText(t.getAttribute("data-citation-author")||""),i=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:n,author:r||"Unknown",year:VP(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:i||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:GP(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function JP(t,e,n){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",n),t.textContent=Sfe(e,n)}function p2(t,e,n){const r=I5(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function OA(t,e){const n=Jd.get(t);return n&&NA.includes(n)?n:(e==null?void 0:e.defaultStyle)||"apa"}function Uy(t,e){const n=RA(t),r=new Map;return n.forEach(i=>{const o=ZP(i,e);if(!o)return;if(!r.has(o.id)){r.set(o.id,o);return}const a=r.get(o.id);r.set(o.id,{...a,author:a.author||o.author,title:a.title||o.title,year:a.year||o.year,source:a.source||o.source,url:a.url||o.url,note:a.note||o.note})}),Array.from(r.values())}function _fe(t,e,n){const r=XP(e,n);if(!r.id||!r.author||!r.title)return;const o=(cg.get(t)||[]).filter(a=>a.id!==r.id);cg.set(t,[r,...o].slice(0,n.maxRecentCitations))}function g2(t,e,n){const r=cg.get(t)||[],i=new Map;e.slice(Math.max(0,e.length-n.maxRecentCitations)).reverse().forEach(a=>{a.id&&i.set(a.id,a)}),r.forEach(a=>{!a.id||i.has(a.id)||i.set(a.id,a)});const o=Array.from(i.values()).slice(0,n.maxRecentCitations);return cg.set(t,o),o}function e9(t,e,n,r){const i=fg(r.normalizeText(e||""));return i&&g2(t,n,r).find(a=>a.id===i)||null}function Dfe(t,e,n){const r=fg(n.normalizeText(e||""));if(!r)return!1;const i=cg.get(t)||[],o=i.filter(a=>a.id!==r);return o.length===i.length?!1:(cg.set(t,o),!0)}function t9(t,e,n){const r=document.createElement("section");r.className=t,r.setAttribute("data-type",e),r.setAttribute("contenteditable","false"),r.setAttribute("aria-label",n),e==="citation-bibliography"?r.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&r.setAttribute("role","doc-endnotes");const i=document.createElement("h3");i.className="rte-citation-section-title",i.textContent=n;const o=document.createElement("ol");return o.className="rte-citation-list",o.setAttribute("role","list"),r.appendChild(i),r.appendChild(o),r}function Lfe(t,e){let n=t.querySelector(_y);n||(n=t9("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(n));const r=n.querySelector(".rte-citation-section-title");return r&&(r.textContent=e.labels.bibliographyTitle),n.setAttribute("aria-label",e.labels.bibliographyTitle),n}function Ffe(t,e){let n=t.querySelector(Dy);n||(n=t9("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(n));const r=n.querySelector(".rte-citation-section-title");return r&&(r.textContent=e.labels.footnotesTitle),n.setAttribute("aria-label",e.labels.footnotesTitle),n}function n9(t,e){const n=t.querySelector(e);n==null||n.remove()}function Ife(t,e,n,r){if(e.length===0){n9(t,_y);return}const o=Lfe(t,n).querySelector(".rte-citation-list");if(!o)return;const a=document.createDocumentFragment();e.forEach((s,c)=>{const l=document.createElement("li");l.className="rte-citation-item",l.id=`rte-citation-entry-${s.id}`,l.setAttribute("data-citation-id",s.id),l.setAttribute("data-citation-number",String(c+1)),l.textContent=N5(s,r),a.appendChild(l)}),o.innerHTML="",o.appendChild(a)}function Ufe(t,e,n,r){if(!n.enableFootnoteSync||e.length===0){n9(t,Dy),RA(t).forEach(u=>{u.removeAttribute("data-footnote-number"),u.removeAttribute("data-footnote-target")});return}const o=Ffe(t,n).querySelector(".rte-citation-list");if(!o)return;const a=new Map,s=new Map;e.forEach((u,d)=>{s.set(u.id,d+1)});const c=new Map;RA(t).forEach(u=>{const d=u.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const f=(c.get(d)||0)+1;c.set(d,f);const A=`rte-citation-ref-${d}-${f}`;u.id=A;const h=s.get(d);u.setAttribute("data-footnote-number",String(h)),u.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,A)});const l=document.createDocumentFragment();e.forEach((u,d)=>{const f=document.createElement("li");f.className="rte-citation-item rte-citation-footnote-item",f.id=`rte-citation-note-${u.id}`,f.setAttribute("data-citation-id",u.id);const A=document.createElement("span");A.className="rte-citation-footnote-number",A.textContent=`${d+1}. `;const h=document.createElement("span");h.className="rte-citation-footnote-text";const p=u.note?`${u.note}. `:"";h.textContent=`${p}${N5(u,r)}`,f.appendChild(A),f.appendChild(h);const m=a.get(u.id);if(m){const g=document.createElement("a");g.className="rte-citation-backref",g.href=`#${m}`,g.setAttribute("aria-label",`Back to citation ${d+1}`),g.textContent="Back",f.appendChild(g)}l.appendChild(f)}),o.innerHTML="",o.appendChild(l)}function Nfe(t,e,n,r){const i=N5(e,n);t.setAttribute("data-citation-number",String(r)),t.setAttribute("aria-label",`Citation ${r}: ${i}`)}function Rfe(t,e,n){const r=RA(t);let i=`${e}:${n?"1":"0"}:${r.length}`;return r.forEach(o=>{i+=`|${o.getAttribute("data-citation-id")||""}`,i+=`|${o.getAttribute("data-citation-author")||""}`,i+=`|${o.getAttribute("data-citation-year")||""}`,i+=`|${o.getAttribute("data-citation-title")||""}`,i+=`|${o.getAttribute("data-citation-source")||""}`,i+=`|${o.getAttribute("data-citation-url")||""}`,i+=`|${o.getAttribute("data-citation-note")||""}`}),i}function hg(t){const e=Tl.get(t);if(!e)return;const n=Rn.get(t)||tf;if(!n)return;const r=OA(t,n),i=Uy(t,n),o=g2(t,i,n),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),c=e.querySelector(".rte-citations-recent-list");if(a){const l=i.length;a.textContent=`${n.labels.summaryPrefix}: ${l} | Style: ${r.toUpperCase()} | Footnotes: ${n.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${n.labels.styleButtonPrefix}: ${r.toUpperCase()}`,s.setAttribute("aria-label",`${n.labels.styleButtonPrefix}: ${r.toUpperCase()}`)),c){if(o.length===0){c.innerHTML=`<li class="rte-citations-empty">${Kr(n.labels.noCitationsText)}</li>`;return}c.innerHTML=o.map(l=>`
|
|
4551
|
+
`,document.head.appendChild(t)}function wfe(t){xl=t,rg||(rg=e=>{const n=e.target,r=n==null?void 0:n.closest(wl);if(!r)return;ua=r,Rr.has(r)||Rr.set(r,t),Bu.has(r)||Bu.set(r,[]),Xd.has(r)||Xd.set(r,t.enableRealtime);const i=is.get(r);i&&(s2(i,r),k5(r,i),ag(r,i,Rr.get(r)||t)),Su(r,"toggleContentRulesPanel",c2(r)),Su(r,"toggleContentRulesRealtime",UA(r,t))},document.addEventListener("focusin",rg,!0)),ig||(ig=e=>{const n=e.target,r=n==null?void 0:n.closest(wl);r&&(ua=r,q7(r))},document.addEventListener("input",ig,!0)),og||(og=e=>{if(e.defaultPrevented)return;const n=e.target;if(n!=null&&n.closest("input, textarea, select"))return;const r=e.key==="Escape",i=mfe(e),o=bfe(e),a=yfe(e);if(!r&&!i&&!o&&!a)return;const s=Zd(void 0,!1);if(!s||T5(s))return;const c=Rr.get(s)||xl||t;if(Rr.set(s,c),ua=s,r&&c2(s)){e.preventDefault(),sg(s,!0);return}if(i){e.preventDefault(),e.stopPropagation(),_5(s);return}if(o){e.preventDefault(),e.stopPropagation(),Cl(s,c,!0),S5(s);return}if(a){e.preventDefault(),e.stopPropagation();const l=!UA(s,c);Xd.set(s,l);const u=is.get(s);u&&ag(s,u,c),Su(s,"toggleContentRulesRealtime",l),l&&Cl(s,c,!0)}},document.addEventListener("keydown",og,!0)),Yd||(Yd=()=>{is.forEach((e,n)=>{if(!n.isConnected||!e.isConnected){j7(n),e.remove(),is.delete(n),Ty.delete(n);return}s2(e,n),k5(n,e)})},window.addEventListener("scroll",Yd,!0),window.addEventListener("resize",Yd))}function xfe(){rg&&(document.removeEventListener("focusin",rg,!0),rg=null),ig&&(document.removeEventListener("input",ig,!0),ig=null),og&&(document.removeEventListener("keydown",og,!0),og=null),Yd&&(window.removeEventListener("scroll",Yd,!0),window.removeEventListener("resize",Yd),Yd=null),is.forEach(t=>{t.remove()}),is.clear(),xl=null,ua=null}const L5=Object.freeze(Object.defineProperty({__proto__:null,ContentRulesPlugin:(t={})=>{const e=r2(t);return vfe(),{name:"contentRules",toolbar:[{id:"contentRulesGroup",label:"Content Rules",type:"group",command:"contentRules",items:[{id:"contentRules",label:"Content Rules",command:"toggleContentRulesPanel",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"contentRulesAudit",label:"Run Rules Audit",command:"runContentRulesAudit",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"contentRulesRealtime",label:"Toggle Realtime Rules",command:"toggleContentRulesRealtime",shortcut:"Mod-Alt-Shift-t",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{contentRules:(n,r)=>{const i=Zd(r);if(!i||T5(i))return!1;const o=Rr.get(i)||e;return Rr.set(i,o),ua=i,_5(i,!0),Cl(i,o,!1),!0},toggleContentRulesPanel:(n,r)=>{const i=Zd(r);if(!i||T5(i))return!1;ua=i;const o=Rr.get(i)||e;Rr.set(i,o);const a=_5(i,typeof n=="boolean"?n:void 0);return c2(i)&&Cl(i,o,!1),a},runContentRulesAudit:async(n,r)=>{const i=Zd(r);if(!i)return!1;ua=i;const o=Rr.get(i)||e;return Rr.set(i,o),await Cl(i,o,!0),S5(i),!0},toggleContentRulesRealtime:(n,r)=>{const i=Zd(r);if(!i)return!1;ua=i;const o=Rr.get(i)||e;Rr.set(i,o);const a=typeof n=="boolean"?n:!UA(i,o);Xd.set(i,a);const s=is.get(i);return s&&ag(i,s,o),Su(i,"toggleContentRulesRealtime",a),a&&Cl(i,o,!0),!0},getContentRulesIssues:(n,r)=>{const i=Zd(r);if(!i)return!1;const o=Bu.get(i)||[];if(typeof n=="function")try{n(o)}catch(a){}return i.__contentRulesIssues=o,i.dispatchEvent(new CustomEvent("editora:content-rules-issues",{bubbles:!0,detail:{issues:o}})),!0},setContentRulesOptions:(n,r)=>{const i=Zd(r);if(!i||!n||typeof n!="object")return!1;const o=Rr.get(i)||e,a=r2({...o,...n,labels:{...o.labels,...n.labels||{}}});Rr.set(i,a),typeof n.enableRealtime=="boolean"&&Xd.set(i,n.enableRealtime),UA(i,a)&&Cl(i,a,!0);const s=is.get(i);if(s){s.setAttribute("aria-label",a.labels.panelAriaLabel);const c=s.querySelector(".rte-content-rules-title");c&&(c.textContent=a.labels.panelTitle),ag(i,s,a),B5(i)}return!0}},keymap:{"Mod-Alt-Shift-r":"toggleContentRulesPanel","Mod-Alt-Shift-R":"toggleContentRulesPanel","Mod-Alt-Shift-l":"runContentRulesAudit","Mod-Alt-Shift-L":"runContentRulesAudit","Mod-Alt-Shift-t":"toggleContentRulesRealtime","Mod-Alt-Shift-T":"toggleContentRulesRealtime"},init:function(r){n2+=1;const i=this&&typeof this.__pluginConfig=="object"?r2({...e,...this.__pluginConfig}):e;wfe(i);const o=Zd(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(ua=o,Rr.set(o,i),Xd.set(o,i.enableRealtime),Bu.set(o,[]),Su(o,"toggleContentRulesPanel",!1),Su(o,"toggleContentRulesRealtime",i.enableRealtime),i.enableRealtime&&q7(o))},destroy:()=>{n2=Math.max(0,n2-1),!(n2>0)&&(ky.forEach(n=>{window.clearTimeout(n)}),ky.clear(),xfe())}}}},Symbol.toStringTag,{value:"Module"})),_u=".rte-content, .editora-content",W7="rte-citations-styles",mr="rte-citations-panel",l2=".rte-citation-ref[data-citation-id]",_y='.rte-citation-bibliography[data-type="citation-bibliography"]',Dy='.rte-citation-footnotes[data-type="citation-footnotes"]',Rs=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',NA=["apa","mla","chicago"],Efe={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},Rn=new WeakMap,Jd=new WeakMap,K7=new WeakMap,cg=new WeakMap,Tl=new Map,Ly=new WeakMap,u2=new WeakMap,Fy=new Set;let lg=null,ug=null,dg=null,ef=null,d2=0,Cfe=0,F5=0,tf=null,Ao=null;function Kr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Tfe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function V7(t,e){const n=e(t);if(!n)return"";const r=n.match(/\d{4}/);return r?r[0]:n}function G7(t,e){const n=e(t);return n?/^https?:\/\//i.test(n)?n:`https://${n}`:""}function fg(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function X7(t,e){return{id:fg(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:V7(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:G7(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function f2(t={}){var r,i;const e=t.defaultStyle&&NA.includes(t.defaultStyle)?t.defaultStyle:"apa",n={...Efe,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number((r=t.debounceMs)!=null?r:220)),maxRecentCitations:Math.max(3,Math.min(30,Number((i=t.maxRecentCitations)!=null?i:8))),labels:n,normalizeText:t.normalizeText||Tfe,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function Y7(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function I5(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function A2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function kfe(t){const e=I5(t);if(A2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return A2(n)?!0:A2(document.documentElement)||A2(document.body)}function h2(t,e){t.classList.remove("rte-citations-theme-dark"),kfe(e)&&t.classList.add("rte-citations-theme-dark")}function os(t,e=!0){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const i=t.editorElement;if(i.matches(_u))return i;const o=i.querySelector(_u);if(o instanceof HTMLElement)return o}const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=Y7(i),a=o==null?void 0:o.closest(_u);if(a)return a}const r=document.activeElement;if(r){if(r.matches(_u))return r;const i=r.closest(_u);if(i)return i}return Ao&&Ao.isConnected?Ao:(Ao&&!Ao.isConnected&&(Ao=null),e?document.querySelector(_u):null)}function Du(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Iy(t){const e=Y7(t);return e?!!(e.closest(_y)||e.closest(Dy)):!1}function Bfe(t,e){if(F5+=1,e.generateCitationId){const n=e.generateCitationId({editor:t,index:F5}),r=fg(e.normalizeText(n||""));if(r)return r}return`cite-${Date.now().toString(36)}-${F5.toString(36)}`}function U5(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function Sfe(t,e){const n=t.author||"Unknown",r=t.year||"n.d.";return e==="mla"?`(${n} ${r})`:e==="chicago"?`(${n} ${r})`:`(${n}, ${r})`}function Ag(t){const e=t.trim();return!e||/[.!?]$/.test(e)?e:`${e}.`}function N5(t,e){const n=Ag(t.author||"Unknown"),r=t.year||"n.d.",i=t.title||"Untitled",o=(t.source||"").trim(),a=t.url||"";return U5(e==="mla"?[n,`"${Ag(i)}"`,o?`${o.replace(/[.,]$/,"")},`:"",`${r}.`,a]:e==="chicago"?[n,Ag(i),Ag(o),`(${r}).`,a]:[n,`(${r}).`,Ag(i),Ag(o),a])}function RA(t){return Array.from(t.querySelectorAll(l2)).filter(e=>!e.closest(_y)&&!e.closest(Dy))}function Z7(t,e){const n=fg(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!n)return null;const r=e.normalizeText(t.getAttribute("data-citation-author")||""),i=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:n,author:r||"Unknown",year:V7(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:i||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:G7(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function J7(t,e,n){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",n),t.textContent=Sfe(e,n)}function p2(t,e,n){const r=I5(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function OA(t,e){const n=Jd.get(t);return n&&NA.includes(n)?n:(e==null?void 0:e.defaultStyle)||"apa"}function Uy(t,e){const n=RA(t),r=new Map;return n.forEach(i=>{const o=Z7(i,e);if(!o)return;if(!r.has(o.id)){r.set(o.id,o);return}const a=r.get(o.id);r.set(o.id,{...a,author:a.author||o.author,title:a.title||o.title,year:a.year||o.year,source:a.source||o.source,url:a.url||o.url,note:a.note||o.note})}),Array.from(r.values())}function _fe(t,e,n){const r=X7(e,n);if(!r.id||!r.author||!r.title)return;const o=(cg.get(t)||[]).filter(a=>a.id!==r.id);cg.set(t,[r,...o].slice(0,n.maxRecentCitations))}function g2(t,e,n){const r=cg.get(t)||[],i=new Map;e.slice(Math.max(0,e.length-n.maxRecentCitations)).reverse().forEach(a=>{a.id&&i.set(a.id,a)}),r.forEach(a=>{!a.id||i.has(a.id)||i.set(a.id,a)});const o=Array.from(i.values()).slice(0,n.maxRecentCitations);return cg.set(t,o),o}function eH(t,e,n,r){const i=fg(r.normalizeText(e||""));return i&&g2(t,n,r).find(a=>a.id===i)||null}function Dfe(t,e,n){const r=fg(n.normalizeText(e||""));if(!r)return!1;const i=cg.get(t)||[],o=i.filter(a=>a.id!==r);return o.length===i.length?!1:(cg.set(t,o),!0)}function tH(t,e,n){const r=document.createElement("section");r.className=t,r.setAttribute("data-type",e),r.setAttribute("contenteditable","false"),r.setAttribute("aria-label",n),e==="citation-bibliography"?r.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&r.setAttribute("role","doc-endnotes");const i=document.createElement("h3");i.className="rte-citation-section-title",i.textContent=n;const o=document.createElement("ol");return o.className="rte-citation-list",o.setAttribute("role","list"),r.appendChild(i),r.appendChild(o),r}function Lfe(t,e){let n=t.querySelector(_y);n||(n=tH("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(n));const r=n.querySelector(".rte-citation-section-title");return r&&(r.textContent=e.labels.bibliographyTitle),n.setAttribute("aria-label",e.labels.bibliographyTitle),n}function Ffe(t,e){let n=t.querySelector(Dy);n||(n=tH("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(n));const r=n.querySelector(".rte-citation-section-title");return r&&(r.textContent=e.labels.footnotesTitle),n.setAttribute("aria-label",e.labels.footnotesTitle),n}function nH(t,e){const n=t.querySelector(e);n==null||n.remove()}function Ife(t,e,n,r){if(e.length===0){nH(t,_y);return}const o=Lfe(t,n).querySelector(".rte-citation-list");if(!o)return;const a=document.createDocumentFragment();e.forEach((s,c)=>{const l=document.createElement("li");l.className="rte-citation-item",l.id=`rte-citation-entry-${s.id}`,l.setAttribute("data-citation-id",s.id),l.setAttribute("data-citation-number",String(c+1)),l.textContent=N5(s,r),a.appendChild(l)}),o.innerHTML="",o.appendChild(a)}function Ufe(t,e,n,r){if(!n.enableFootnoteSync||e.length===0){nH(t,Dy),RA(t).forEach(u=>{u.removeAttribute("data-footnote-number"),u.removeAttribute("data-footnote-target")});return}const o=Ffe(t,n).querySelector(".rte-citation-list");if(!o)return;const a=new Map,s=new Map;e.forEach((u,d)=>{s.set(u.id,d+1)});const c=new Map;RA(t).forEach(u=>{const d=u.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const f=(c.get(d)||0)+1;c.set(d,f);const A=`rte-citation-ref-${d}-${f}`;u.id=A;const h=s.get(d);u.setAttribute("data-footnote-number",String(h)),u.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,A)});const l=document.createDocumentFragment();e.forEach((u,d)=>{const f=document.createElement("li");f.className="rte-citation-item rte-citation-footnote-item",f.id=`rte-citation-note-${u.id}`,f.setAttribute("data-citation-id",u.id);const A=document.createElement("span");A.className="rte-citation-footnote-number",A.textContent=`${d+1}. `;const h=document.createElement("span");h.className="rte-citation-footnote-text";const p=u.note?`${u.note}. `:"";h.textContent=`${p}${N5(u,r)}`,f.appendChild(A),f.appendChild(h);const m=a.get(u.id);if(m){const g=document.createElement("a");g.className="rte-citation-backref",g.href=`#${m}`,g.setAttribute("aria-label",`Back to citation ${d+1}`),g.textContent="Back",f.appendChild(g)}l.appendChild(f)}),o.innerHTML="",o.appendChild(l)}function Nfe(t,e,n,r){const i=N5(e,n);t.setAttribute("data-citation-number",String(r)),t.setAttribute("aria-label",`Citation ${r}: ${i}`)}function Rfe(t,e,n){const r=RA(t);let i=`${e}:${n?"1":"0"}:${r.length}`;return r.forEach(o=>{i+=`|${o.getAttribute("data-citation-id")||""}`,i+=`|${o.getAttribute("data-citation-author")||""}`,i+=`|${o.getAttribute("data-citation-year")||""}`,i+=`|${o.getAttribute("data-citation-title")||""}`,i+=`|${o.getAttribute("data-citation-source")||""}`,i+=`|${o.getAttribute("data-citation-url")||""}`,i+=`|${o.getAttribute("data-citation-note")||""}`}),i}function hg(t){const e=Tl.get(t);if(!e)return;const n=Rn.get(t)||tf;if(!n)return;const r=OA(t,n),i=Uy(t,n),o=g2(t,i,n),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),c=e.querySelector(".rte-citations-recent-list");if(a){const l=i.length;a.textContent=`${n.labels.summaryPrefix}: ${l} | Style: ${r.toUpperCase()} | Footnotes: ${n.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${n.labels.styleButtonPrefix}: ${r.toUpperCase()}`,s.setAttribute("aria-label",`${n.labels.styleButtonPrefix}: ${r.toUpperCase()}`)),c){if(o.length===0){c.innerHTML=`<li class="rte-citations-empty">${Kr(n.labels.noCitationsText)}</li>`;return}c.innerHTML=o.map(l=>`
|
|
4551
4552
|
<li class="rte-citations-recent-item">
|
|
4552
4553
|
<div class="rte-citations-recent-row">
|
|
4553
4554
|
<button
|
|
@@ -4569,7 +4570,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4569
4570
|
>${Kr(n.labels.deleteRecentText)}</button>
|
|
4570
4571
|
</div>
|
|
4571
4572
|
</li>
|
|
4572
|
-
`).join("")}}function Os(t,e,n=!1){const r=OA(t,e),i=Rfe(t,r,e.enableFootnoteSync);if(!n&&
|
|
4573
|
+
`).join("")}}function Os(t,e,n=!1){const r=OA(t,e),i=Rfe(t,r,e.enableFootnoteSync);if(!n&&K7.get(t)===i)return Uy(t,e);const o=RA(t),a=new Map;o.forEach(l=>{const u=Z7(l,e);u&&(a.has(u.id)||a.set(u.id,u))});const s=Array.from(a.values());g2(t,s,e);const c=new Map;return s.forEach((l,u)=>{c.set(l.id,u+1)}),o.forEach(l=>{const u=l.getAttribute("data-citation-id")||"",d=a.get(u);if(!d)return;J7(l,d,r);const f=c.get(d.id)||1;Nfe(l,d,r,Math.max(1,f))}),Ife(t,s,e,r),Ufe(t,s,e,r),K7.set(t,i),hg(t),t.dispatchEvent(new CustomEvent("editora:citations-refreshed",{bubbles:!0,detail:{citations:s,style:r,footnoteSync:e.enableFootnoteSync}})),s}function rH(t){const e=u2.get(t);typeof e=="number"&&(window.clearTimeout(e),Fy.delete(e),u2.delete(t))}function iH(t){const e=Rn.get(t)||tf;if(!e)return;rH(t);const n=window.setTimeout(()=>{Fy.delete(n),u2.delete(t),Os(t,e,!1)},e.debounceMs);Fy.add(n),u2.set(t,n)}function Ofe(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");if(e.rangeCount>0){const a=e.getRangeAt(0);if(t.contains(a.commonAncestorContainer)&&!Iy(a.commonAncestorContainer))return a.cloneRange()}const n=document.createRange(),r=t.querySelector(_y),i=t.querySelector(Dy),o=r||i;return o?(n.setStartBefore(o),n.collapse(!0),n):(n.selectNodeContents(t),n.collapse(!1),n)}function R5(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function O5(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function oH(t,e){const n=window.getSelection();if(!n)return;const r=document.createRange();if(t.nodeType===Node.TEXT_NODE){const i=t,o=Math.max(0,Math.min(e,i.length));r.setStart(i,o)}else{const i=t.childNodes.length,o=Math.max(0,Math.min(e,i));r.setStart(t,o)}r.collapse(!0),n.removeAllRanges(),n.addRange(r)}function aH(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(l2)?null:e}function m2(t,e,n){const{startContainer:r,startOffset:i}=t;if(r.nodeType===Node.ELEMENT_NODE){const a=r;if(n==="previous"){if(i>0)return a.childNodes[i-1]||null}else if(i<a.childNodes.length)return a.childNodes[i]||null}if(r.nodeType===Node.TEXT_NODE&&(n==="previous"&&i<r.data.length||n==="next"&&i>0))return null;let o=r;for(;o&&o!==e;){const a=n==="previous"?o.previousSibling:o.nextSibling;if(a)return a;o=o.parentNode}return null}function sH(t,e,n){if(!t.collapsed)return null;const r=a=>a instanceof HTMLElement&&a.matches(l2)?a:null,{startContainer:i,startOffset:o}=t;if(i.nodeType===Node.ELEMENT_NODE){const a=i;return n==="Backspace"&&o>0?r(a.childNodes[o-1]||null):n==="Delete"?r(a.childNodes[o]||null):null}if(i.nodeType===Node.TEXT_NODE){const a=i;if(n==="Backspace"&&o===0){const s=r(a.previousSibling);return s||r(m2(t,e,"previous"))}if(n==="Delete"&&o===a.data.length){const s=r(a.nextSibling);return s||r(m2(t,e,"next"))}}return r(n==="Backspace"?m2(t,e,"previous"):m2(t,e,"next"))}function pg(t,e,n){const r=t.closest(_u);if(!r||Iy(t))return!1;const i=t.parentNode;if(!i)return!1;const o=r.innerHTML,a=Array.from(i.childNodes).indexOf(t);if(a<0)return!1;const s=t.nextSibling;return s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),t.remove(),oH(i,a),Os(r,n,!0),O5(r,o),R5(r),e==="Delete"&&r.focus({preventScroll:!0}),!0}function Mfe(t,e,n){if(t.key!=="Backspace"&&t.key!=="Delete")return!1;const r=t.key,i=t.target;if(i!=null&&i.matches(l2)&&e.contains(i)&&!Iy(i))return t.preventDefault(),t.stopPropagation(),pg(i,r,n);const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!e.contains(a.commonAncestorContainer)||Iy(a.commonAncestorContainer))return!1;const s=aH(a);if(s)return t.preventDefault(),t.stopPropagation(),pg(s,r,n);const c=sH(a,e,r);return c?(t.preventDefault(),t.stopPropagation(),pg(c,r,n)):!1}function cH(t,e,n){const r=fg(n.normalizeText(e||""));if(!r)return!1;const i=RA(t).filter(a=>a.getAttribute("data-citation-id")===r);if(i.length===0)return!1;if(i.length===1)return pg(i[0],"Delete",n);const o=t.innerHTML;return i.forEach(a=>{const s=a.nextSibling;s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),a.remove()}),oH(t,t.childNodes.length),Os(t,n,!0),O5(t,o),R5(t),t.focus({preventScroll:!0}),!0}function Pfe(t,e){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!t.contains(r.commonAncestorContainer)||Iy(r.commonAncestorContainer))return!1;const i=aH(r);if(i)return pg(i,"Delete",e);const o=sH(r,t,"Backspace");return o?pg(o,"Backspace",e):!1}function b2(t,e,n){var u,d;const r=X7(e,n);if(!r.author||!r.title)return!1;r.id||(r.id=Bfe(t,n));const i=t.innerHTML;let o;try{o=Ofe(t)}catch(f){return!1}const a=window.getSelection();if(!a)return!1;o.collapsed||o.deleteContents();const s=document.createElement("span");J7(s,r,OA(t,n));try{o.insertNode(s)}catch(f){return!1}const c=document.createTextNode(" ");s.nextSibling?(u=s.parentNode)==null||u.insertBefore(c,s.nextSibling):(d=s.parentNode)==null||d.appendChild(c);const l=document.createRange();if(c.parentNode){const f=Array.from(c.parentNode.childNodes).indexOf(c)+1;l.setStart(c.parentNode,Math.max(0,f))}else l.setStartAfter(s);return l.collapse(!0),a.removeAllRanges(),a.addRange(l),_fe(t,r,n),Os(t,n,!0),O5(t,i),R5(t),!0}function Hfe(t,e){if(!e)return!1;const n=RA(t).find(o=>o.getAttribute("data-citation-id")===e)||null;if(!n)return!1;n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),n.focus({preventScroll:!0});const r=window.getSelection();if(!r)return!0;const i=document.createRange();return i.selectNode(n),r.removeAllRanges(),r.addRange(i),!0}function y2(t){return Ly.get(t)===!0}function Ny(t,e=!1){const n=Tl.get(t);n&&(n.classList.remove("show"),Ly.set(t,!1),p2(t,"toggleCitationsPanel",!1),e&&t.focus({preventScroll:!0}))}function Qfe(t){Tl.forEach((e,n)=>{n!==t&&Ny(n,!1)})}function M5(t,e){if(!e.classList.contains("show"))return;const r=I5(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,380),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),s=Math.max(10,Math.min(window.innerHeight-10-260,r.top+10));e.style.width=`${i}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-24)}px`}function yc(t,e){return t.querySelector(`[data-field="${e}"]`)}function $fe(t){var s,c,l,u,d,f;const e=((s=yc(t,"author"))==null?void 0:s.value)||"",n=((c=yc(t,"year"))==null?void 0:c.value)||"",r=((l=yc(t,"title"))==null?void 0:l.value)||"",i=((u=yc(t,"source"))==null?void 0:u.value)||"",o=((d=yc(t,"url"))==null?void 0:d.value)||"",a=((f=yc(t,"note"))==null?void 0:f.value)||"";return{author:e,year:n,title:r,source:i,url:o,note:a}}function Lu(t,e,n=!1){const r=t.querySelector(".rte-citations-live");r&&(r.textContent=e);const i=t.querySelector(".rte-citations-status");i&&(i.textContent=e,i.classList.toggle("rte-citations-status-error",n))}function zfe(t,e,n){const r=yc(e,"style");r&&(r.value=OA(t,n))}function lH(t,e,n){const r=NA.includes(e)?e:n.defaultStyle;return Jd.set(t,r),Os(t,n,!0),r}function P5(t,e){const n=OA(t,e),r=NA.indexOf(n),i=NA[(r+1)%NA.length];return Jd.set(t,i),Os(t,e,!0),i}function jfe(t){const e=Tl.get(t);if(e)return e;const n=Rn.get(t)||tf||f2(),r=`rte-citations-panel-${Cfe++}`,i=document.createElement("section");i.className=mr,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.setAttribute("tabindex","-1"),i.innerHTML=`
|
|
4573
4574
|
<header class="rte-citations-header">
|
|
4574
4575
|
<h2 class="rte-citations-title">${Kr(n.labels.panelTitle)}</h2>
|
|
4575
4576
|
<button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${Kr(n.labels.closeText)}">✕</button>
|
|
@@ -4627,7 +4628,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4627
4628
|
<p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
|
|
4628
4629
|
<span class="rte-citations-live" aria-live="polite"></span>
|
|
4629
4630
|
</div>
|
|
4630
|
-
`,i.addEventListener("click",a=>{const s=a.target;if(!s)return;const c=s.closest("[data-action]");if(!c)return;const l=c.getAttribute("data-action")||"",u=Rn.get(t)||tf||n;if(Rn.set(t,u),l==="close"){Ny(t,!0);return}if(l==="insert"){if(Du(t))return;const d=$fe(i);if(!u.normalizeText(d.author)||!u.normalizeText(d.title)){Lu(i,u.labels.invalidMessage,!0);return}if(!b2(t,d,u)){Lu(i,u.labels.invalidMessage,!0);return}Lu(i,"Citation inserted.");const A=yc(i,"title"),h=yc(i,"note");A&&(A.value=""),h&&(h.value="");return}if(l==="refresh"){const d=Os(t,u,!0);Lu(i,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(l==="cycle-style"){const d=P5(t,u);zfe(t,i,u),Lu(i,`Style changed to ${d.toUpperCase()}.`);return}if(l==="insert-from-recent"){if(Du(t))return;const d=c.getAttribute("data-citation-id")||"",f=
|
|
4631
|
+
`,i.addEventListener("click",a=>{const s=a.target;if(!s)return;const c=s.closest("[data-action]");if(!c)return;const l=c.getAttribute("data-action")||"",u=Rn.get(t)||tf||n;if(Rn.set(t,u),l==="close"){Ny(t,!0);return}if(l==="insert"){if(Du(t))return;const d=$fe(i);if(!u.normalizeText(d.author)||!u.normalizeText(d.title)){Lu(i,u.labels.invalidMessage,!0);return}if(!b2(t,d,u)){Lu(i,u.labels.invalidMessage,!0);return}Lu(i,"Citation inserted.");const A=yc(i,"title"),h=yc(i,"note");A&&(A.value=""),h&&(h.value="");return}if(l==="refresh"){const d=Os(t,u,!0);Lu(i,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(l==="cycle-style"){const d=P5(t,u);zfe(t,i,u),Lu(i,`Style changed to ${d.toUpperCase()}.`);return}if(l==="insert-from-recent"){if(Du(t))return;const d=c.getAttribute("data-citation-id")||"",f=eH(t,d,Uy(t,u),u);if(!f)return;b2(t,f,u),Lu(i,`Inserted citation: ${f.title}.`);return}if(l==="delete-by-id"){if(Du(t))return;const d=c.getAttribute("data-citation-id")||"";if(cH(t,d,u)){Lu(i,"Citation deleted.");return}Dfe(t,d,u)&&(hg(t),Lu(i,"Removed from recent citations."))}}),i.addEventListener("keydown",a=>{if(a.key==="Escape"){a.preventDefault(),Ny(t,!0);return}const s=a.target;if(!s||!s.matches(".rte-citations-recent-btn")||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const c=Array.from(i.querySelectorAll(".rte-citations-recent-btn"));if(c.length===0)return;const l=c.indexOf(s);if(l<0)return;a.preventDefault();const u=a.key==="ArrowDown"?1:-1,d=(l+u+c.length)%c.length;c[d].focus()});const o=yc(i,"style");return o==null||o.addEventListener("change",()=>{const a=Rn.get(t)||tf||n,s=o.value;lH(t,s,a),Lu(i,`Style changed to ${s.toUpperCase()}.`)}),h2(i,t),document.body.appendChild(i),Tl.set(t,i),Ly.set(t,!1),hg(t),i}function gg(t){const e=jfe(t);Qfe(t),e.classList.add("show"),Ly.set(t,!0),p2(t,"toggleCitationsPanel",!0),h2(e,t),M5(t,e),hg(t);const n=yc(e,"author");n==null||n.focus()}function uH(t,e){const n=y2(t);return(typeof e=="boolean"?e:!n)?gg(t):Ny(t,!1),!0}function H5(t){return typeof t.key=="string"?t.key.toLowerCase():""}function qfe(t){const e=H5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="c"}function Wfe(t){const e=H5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function Kfe(t){const e=H5(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function Vfe(t){tf=t,lg||(lg=e=>{const n=e.target,r=n==null?void 0:n.closest(_u);if(!r)return;Ao=r,Rn.has(r)||Rn.set(r,t),Jd.has(r)||Jd.set(r,t.defaultStyle);const i=Tl.get(r);i&&(h2(i,r),M5(r,i)),p2(r,"toggleCitationsPanel",y2(r))},document.addEventListener("focusin",lg,!0)),ug||(ug=e=>{const n=e.target,r=n==null?void 0:n.closest(_u);r&&(Ao=r,iH(r))},document.addEventListener("input",ug,!0)),dg||(dg=e=>{if(e.defaultPrevented)return;const n=e.target,r=!!(n!=null&&n.closest(`.${mr} input, .${mr} textarea, .${mr} select`)),i=os(void 0,!1);if(!i||Du(i))return;const o=Rn.get(i)||tf||t;if(Rn.set(i,o),Ao=i,e.key==="Escape"&&y2(i)){e.preventDefault(),Ny(i,!0);return}if(!r&&!Mfe(e,i,o)){if(qfe(e)){e.preventDefault(),e.stopPropagation(),uH(i);return}if(Wfe(e)){e.preventDefault(),e.stopPropagation(),Os(i,o,!0),gg(i);return}Kfe(e)&&(e.preventDefault(),e.stopPropagation(),P5(i,o))}},document.addEventListener("keydown",dg,!0)),ef||(ef=()=>{Tl.forEach((e,n)=>{if(!n.isConnected||!e.isConnected){rH(n),e.remove(),Tl.delete(n),Ly.delete(n);return}h2(e,n),M5(n,e)})},window.addEventListener("scroll",ef,!0),window.addEventListener("resize",ef))}function Gfe(){lg&&(document.removeEventListener("focusin",lg,!0),lg=null),ug&&(document.removeEventListener("input",ug,!0),ug=null),dg&&(document.removeEventListener("keydown",dg,!0),dg=null),ef&&(window.removeEventListener("scroll",ef,!0),window.removeEventListener("resize",ef),ef=null),Tl.forEach(t=>t.remove()),Tl.clear(),tf=null,Ao=null}function Xfe(){if(typeof document=="undefined"||document.getElementById(W7))return;const t=document.createElement("style");t.id=W7,t.textContent=`
|
|
4631
4632
|
.rte-toolbar-group-items.citations,
|
|
4632
4633
|
.editora-toolbar-group-items.citations {
|
|
4633
4634
|
display: flex;
|
|
@@ -5119,7 +5120,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5119
5120
|
max-height: 34vh;
|
|
5120
5121
|
}
|
|
5121
5122
|
}
|
|
5122
|
-
`,document.head.appendChild(t)}const d9=Object.freeze(Object.defineProperty({__proto__:null,CitationsPlugin:(t={})=>{const e=f2(t);return Xfe(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Jd.set(i,OA(i,o)),Ao=i,gg(i),Os(i,o,!1),!0},toggleCitationsPanel:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;Rn.set(i,o),Ao=i;const a=u9(i,typeof n=="boolean"?n:void 0);return y2(i)&&Os(i,o,!1),a},insertCitation:(n,r)=>{const i=os(r);if(!i||Du(i)||!n||typeof n!="object")return!1;const o=Rn.get(i)||e;Rn.set(i,o),Ao=i;const a=b2(i,n,o);return a&&gg(i),a},refreshCitations:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,Os(i,o,!0),gg(i),!0},setCitationStyle:(n,r)=>{const i=os(r);if(!i||!n)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,l9(i,n,o),!0},cycleCitationStyle:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,P5(i,o),hg(i),!0},getCitationRecords:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e,a=Uy(i,o);if(typeof n=="function")try{n(a)}catch(s){}return i.__citationRecords=a,i.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:OA(i,o)}})),!0},setCitationsOptions:(n,r)=>{const i=os(r);if(!i||!n||typeof n!="object")return!1;const o=Rn.get(i)||e,a=f2({...o,...n,labels:{...o.labels,...n.labels||{}},normalizeText:n.normalizeText||o.normalizeText,generateCitationId:n.generateCitationId||o.generateCitationId});return Rn.set(i,a),n.defaultStyle&&NA.includes(n.defaultStyle)&&Jd.set(i,n.defaultStyle),Os(i,a,!0),hg(i),!0},locateCitation:(n,r)=>{const i=os(r);return!i||typeof n!="string"?!1:Hfe(i,n)},deleteCitation:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;return Rn.set(i,o),typeof n=="string"&&n.trim()?c9(i,n,o):Pfe(i,o)},insertRecentCitation:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;Rn.set(i,o);const a=Uy(i,o),s=g2(i,a,o);if(s.length===0)return!1;const c=typeof n=="string"&&n.trim()?e9(i,n,a,o):s[0];if(!c)return!1;const l=b2(i,c,o);return l&&gg(i),l}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(r){d2+=1;const i=this&&typeof this.__pluginConfig=="object"?f2({...e,...this.__pluginConfig}):e;Vfe(i);const o=os(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(Ao=o,Rn.set(o,i),Jd.set(o,i.defaultStyle),p2(o,"toggleCitationsPanel",!1),i9(o))},destroy:()=>{d2=Math.max(0,d2-1),!(d2>0)&&(Fy.forEach(n=>{window.clearTimeout(n)}),Fy.clear(),Gfe())}}}},Symbol.toStringTag,{value:"Module"})),vc=".rte-content, .editora-content",v2="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",f9="__editoraCommandEditorRoot",A9="rte-approval-workflow-styles",Sr="rte-approval-panel",Ms="approval",kl="approvalWorkflow",Fa=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Yfe={panelTitle:"Approval Workflow",panelAriaLabel:"Approval workflow panel",statusLabel:"Status",statusDraftText:"Draft",statusReviewText:"In Review",statusApprovedText:"Approved",requestReviewText:"Request Review",approveText:"Approve",reopenDraftText:"Reopen Draft",addCommentText:"Add Comment",actorLabel:"Actor",actorPlaceholder:"Reviewer name",commentLabel:"Comment",commentPlaceholder:"Add review note or sign-off context",closeText:"Close",commentsHeading:"Comments",signoffsHeading:"Sign-offs",noCommentsText:"No comments yet.",noSignoffsText:"No sign-offs yet.",summaryPrefix:"Workflow",lockedSuffix:"Locked",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+A/R/P/D",approveCommentRequiredText:"Approval comment is required."},Zfe={draft:"statusDraftText",review:"statusReviewText",approved:"statusApprovedText"},Xn=new WeakMap,w2=new WeakMap,wc=new Map,Ry=new WeakMap,Oy=new Set;let x2=0,Jfe=0,h9=0,p9=0,mg=null,Ia=null,bg=null,yg=null,nf=null;function br(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function eAe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function g9(t){return t==="review"||t==="approved"?t:"draft"}function E2(t={}){var e;return{defaultStatus:g9(t.defaultStatus),lockOnApproval:t.lockOnApproval!==!1,maxHistoryEntries:Math.max(10,Math.min(500,Number((e=t.maxHistoryEntries)!=null?e:120))),requireCommentOnApprove:!!t.requireCommentOnApprove,defaultActor:(t.defaultActor||"system").trim()||"system",labels:{...Yfe,...t.labels||{}},normalizeText:t.normalizeText||eAe}}function Q5(t){return t.closest(v2)||t}function C2(t){if(!t)return null;if(t.matches(vc))return t;const e=t.querySelector(vc);return e instanceof HTMLElement?e:null}function tAe(){if(typeof window=="undefined")return null;const t=window[f9];if(!(t instanceof HTMLElement))return null;window[f9]=null;const e=C2(t);if(e)return e;const n=t.closest(v2);if(n){const r=C2(n);if(r)return r}return null}function nAe(t){const e=t.closest("[data-editora-editor]");if(e&&C2(e)===t)return e;let n=t;for(;n;){if(n.matches(v2)&&(n===t||C2(n)===t))return n;n=n.parentElement}return Q5(t)}function T2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function rAe(t){const e=Q5(t);if(T2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return T2(n)?!0:T2(document.documentElement)||T2(document.body)}function k2(t,e){t.classList.remove("rte-approval-theme-dark"),rAe(e)&&t.classList.add("rte-approval-theme-dark")}function m9(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function xc(t,e=!0){if(My(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement;if(o.matches(vc))return o;const a=o.querySelector(vc);if(a instanceof HTMLElement)return a}const n=tAe();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=m9(r.getRangeAt(0).startContainer),a=o==null?void 0:o.closest(vc);if(a)return a}const i=document.activeElement;if(i){if(i.matches(vc))return i;const o=i.closest(vc);if(o)return o}return Ia&&Ia.isConnected?Ia:(Ia&&!Ia.isConnected&&(Ia=null),e?document.querySelector(vc):null)}function My(){Array.from(Oy).forEach(e=>{var n;e.isConnected||((n=wc.get(e))==null||n.remove(),wc.delete(e),Ry.delete(e),Xn.delete(e),w2.delete(e),Oy.delete(e),Ia===e&&(Ia=null))})}function iAe(t){return t?!!(t.closest(`.${Sr}`)||t.closest(vc)||t.closest(v2)):!1}function oAe(){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const e=t.getRangeAt(0).startContainer,n=m9(e);return!!(n!=null&&n.closest(vc))}function vg(t,e,n){const r=nAe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("aria-pressed",n?"true":"false"),o.setAttribute("data-active",n?"true":"false")})}function b9(t,e,n){e!==null?t.setAttribute("contenteditable",e):t.setAttribute("contenteditable","true"),n!==null?t.setAttribute("data-readonly",n):t.removeAttribute("data-readonly")}function $5(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function z5(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function j5(){return h9+=1,`approval-comment-${Date.now().toString(36)}-${h9.toString(36)}`}function aAe(){return p9+=1,`approval-signoff-${Date.now().toString(36)}-${p9.toString(36)}`}function y9(t){return{status:t.status,locked:t.locked,comments:t.comments.map(e=>({...e})),signoffs:t.signoffs.map(e=>({...e})),updatedAt:t.updatedAt}}function sAe(t,e){const n=Zfe[t];return e.labels[n]||t}function v9(t,e,n){var o,a;const r=e.locked,i=e.status==="approved"&&n.lockOnApproval;if(t.setAttribute("data-approval-status",e.status),t.setAttribute("data-approval-locked",i?"true":"false"),t.classList.toggle("rte-approval-locked-editor",i),vg(t,"toggleApprovalWorkflowPanel",K5(t)),vg(t,"requestApprovalReview",e.status==="review"),vg(t,"approveDocument",e.status==="approved"),vg(t,"reopenDraft",e.status==="draft"),i){r||(e.preApprovalContentEditable=t.getAttribute("contenteditable"),e.preApprovalReadonly=t.getAttribute("data-readonly")),t.setAttribute("contenteditable","false"),t.setAttribute("data-readonly","true"),e.locked=!0;return}e.locked=!1,b9(t,(o=e.preApprovalContentEditable)!=null?o:e.originalContentEditable,(a=e.preApprovalReadonly)!=null?a:e.originalReadonly),e.preApprovalContentEditable=null,e.preApprovalReadonly=null}function ho(t,e){let n=w2.get(t);return n||(n={status:e.defaultStatus,locked:!1,comments:[],signoffs:[],updatedAt:new Date().toISOString(),originalContentEditable:t.getAttribute("contenteditable"),originalReadonly:t.getAttribute("data-readonly"),preApprovalContentEditable:null,preApprovalReadonly:null},w2.set(t,n),Oy.add(t),v9(t,n,e),n)}function B2(t,e){return t.length<=e?t:t.slice(t.length-e)}function Py(t,e){const n=t.querySelector(".rte-approval-live");n&&(n.textContent=e)}function cAe(t,e){const n=y9(e);t.__approvalWorkflowState=n,t.dispatchEvent(new CustomEvent("editora:approval-state-changed",{bubbles:!0,detail:{state:n}}))}function Hy(t){const e=wc.get(t);if(!e)return;const n=Xn.get(t)||mg;if(!n)return;const r=ho(t,n),i=e.querySelector(".rte-approval-summary"),o=e.querySelector('[data-action="request-review"]'),a=e.querySelector('[data-action="approve"]'),s=e.querySelector('[data-action="reopen-draft"]'),c=e.querySelector(".rte-approval-comments-list"),l=e.querySelector(".rte-approval-signoffs-list");if(i){const u=sAe(r.status,n);i.textContent=`${n.labels.summaryPrefix}: ${u} | Comments: ${r.comments.length} | Sign-offs: ${r.signoffs.length}${r.locked?` | ${n.labels.lockedSuffix}`:""}`}o&&(o.disabled=r.status!=="draft"),a&&(a.disabled=r.status==="approved"),s&&(s.disabled=r.status==="draft"),c&&(r.comments.length===0?c.innerHTML=`<li class="rte-approval-empty">${br(n.labels.noCommentsText)}</li>`:c.innerHTML=r.comments.slice().reverse().map(u=>`
|
|
5123
|
+
`,document.head.appendChild(t)}const dH=Object.freeze(Object.defineProperty({__proto__:null,CitationsPlugin:(t={})=>{const e=f2(t);return Xfe(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Jd.set(i,OA(i,o)),Ao=i,gg(i),Os(i,o,!1),!0},toggleCitationsPanel:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;Rn.set(i,o),Ao=i;const a=uH(i,typeof n=="boolean"?n:void 0);return y2(i)&&Os(i,o,!1),a},insertCitation:(n,r)=>{const i=os(r);if(!i||Du(i)||!n||typeof n!="object")return!1;const o=Rn.get(i)||e;Rn.set(i,o),Ao=i;const a=b2(i,n,o);return a&&gg(i),a},refreshCitations:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,Os(i,o,!0),gg(i),!0},setCitationStyle:(n,r)=>{const i=os(r);if(!i||!n)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,lH(i,n,o),!0},cycleCitationStyle:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e;return Rn.set(i,o),Ao=i,P5(i,o),hg(i),!0},getCitationRecords:(n,r)=>{const i=os(r);if(!i)return!1;const o=Rn.get(i)||e,a=Uy(i,o);if(typeof n=="function")try{n(a)}catch(s){}return i.__citationRecords=a,i.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:OA(i,o)}})),!0},setCitationsOptions:(n,r)=>{const i=os(r);if(!i||!n||typeof n!="object")return!1;const o=Rn.get(i)||e,a=f2({...o,...n,labels:{...o.labels,...n.labels||{}},normalizeText:n.normalizeText||o.normalizeText,generateCitationId:n.generateCitationId||o.generateCitationId});return Rn.set(i,a),n.defaultStyle&&NA.includes(n.defaultStyle)&&Jd.set(i,n.defaultStyle),Os(i,a,!0),hg(i),!0},locateCitation:(n,r)=>{const i=os(r);return!i||typeof n!="string"?!1:Hfe(i,n)},deleteCitation:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;return Rn.set(i,o),typeof n=="string"&&n.trim()?cH(i,n,o):Pfe(i,o)},insertRecentCitation:(n,r)=>{const i=os(r);if(!i||Du(i))return!1;const o=Rn.get(i)||e;Rn.set(i,o);const a=Uy(i,o),s=g2(i,a,o);if(s.length===0)return!1;const c=typeof n=="string"&&n.trim()?eH(i,n,a,o):s[0];if(!c)return!1;const l=b2(i,c,o);return l&&gg(i),l}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(r){d2+=1;const i=this&&typeof this.__pluginConfig=="object"?f2({...e,...this.__pluginConfig}):e;Vfe(i);const o=os(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(Ao=o,Rn.set(o,i),Jd.set(o,i.defaultStyle),p2(o,"toggleCitationsPanel",!1),iH(o))},destroy:()=>{d2=Math.max(0,d2-1),!(d2>0)&&(Fy.forEach(n=>{window.clearTimeout(n)}),Fy.clear(),Gfe())}}}},Symbol.toStringTag,{value:"Module"})),vc=".rte-content, .editora-content",v2="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",fH="__editoraCommandEditorRoot",AH="rte-approval-workflow-styles",Sr="rte-approval-panel",Ms="approval",kl="approvalWorkflow",Fa=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Yfe={panelTitle:"Approval Workflow",panelAriaLabel:"Approval workflow panel",statusLabel:"Status",statusDraftText:"Draft",statusReviewText:"In Review",statusApprovedText:"Approved",requestReviewText:"Request Review",approveText:"Approve",reopenDraftText:"Reopen Draft",addCommentText:"Add Comment",actorLabel:"Actor",actorPlaceholder:"Reviewer name",commentLabel:"Comment",commentPlaceholder:"Add review note or sign-off context",closeText:"Close",commentsHeading:"Comments",signoffsHeading:"Sign-offs",noCommentsText:"No comments yet.",noSignoffsText:"No sign-offs yet.",summaryPrefix:"Workflow",lockedSuffix:"Locked",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+A/R/P/D",approveCommentRequiredText:"Approval comment is required."},Zfe={draft:"statusDraftText",review:"statusReviewText",approved:"statusApprovedText"},Xn=new WeakMap,w2=new WeakMap,wc=new Map,Ry=new WeakMap,Oy=new Set;let x2=0,Jfe=0,hH=0,pH=0,mg=null,Ia=null,bg=null,yg=null,nf=null;function br(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function eAe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function gH(t){return t==="review"||t==="approved"?t:"draft"}function E2(t={}){var e;return{defaultStatus:gH(t.defaultStatus),lockOnApproval:t.lockOnApproval!==!1,maxHistoryEntries:Math.max(10,Math.min(500,Number((e=t.maxHistoryEntries)!=null?e:120))),requireCommentOnApprove:!!t.requireCommentOnApprove,defaultActor:(t.defaultActor||"system").trim()||"system",labels:{...Yfe,...t.labels||{}},normalizeText:t.normalizeText||eAe}}function Q5(t){return t.closest(v2)||t}function C2(t){if(!t)return null;if(t.matches(vc))return t;const e=t.querySelector(vc);return e instanceof HTMLElement?e:null}function tAe(){if(typeof window=="undefined")return null;const t=window[fH];if(!(t instanceof HTMLElement))return null;window[fH]=null;const e=C2(t);if(e)return e;const n=t.closest(v2);if(n){const r=C2(n);if(r)return r}return null}function nAe(t){const e=t.closest("[data-editora-editor]");if(e&&C2(e)===t)return e;let n=t;for(;n;){if(n.matches(v2)&&(n===t||C2(n)===t))return n;n=n.parentElement}return Q5(t)}function T2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function rAe(t){const e=Q5(t);if(T2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return T2(n)?!0:T2(document.documentElement)||T2(document.body)}function k2(t,e){t.classList.remove("rte-approval-theme-dark"),rAe(e)&&t.classList.add("rte-approval-theme-dark")}function mH(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function xc(t,e=!0){if(My(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement;if(o.matches(vc))return o;const a=o.querySelector(vc);if(a instanceof HTMLElement)return a}const n=tAe();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=mH(r.getRangeAt(0).startContainer),a=o==null?void 0:o.closest(vc);if(a)return a}const i=document.activeElement;if(i){if(i.matches(vc))return i;const o=i.closest(vc);if(o)return o}return Ia&&Ia.isConnected?Ia:(Ia&&!Ia.isConnected&&(Ia=null),e?document.querySelector(vc):null)}function My(){Array.from(Oy).forEach(e=>{var n;e.isConnected||((n=wc.get(e))==null||n.remove(),wc.delete(e),Ry.delete(e),Xn.delete(e),w2.delete(e),Oy.delete(e),Ia===e&&(Ia=null))})}function iAe(t){return t?!!(t.closest(`.${Sr}`)||t.closest(vc)||t.closest(v2)):!1}function oAe(){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const e=t.getRangeAt(0).startContainer,n=mH(e);return!!(n!=null&&n.closest(vc))}function vg(t,e,n){const r=nAe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("aria-pressed",n?"true":"false"),o.setAttribute("data-active",n?"true":"false")})}function bH(t,e,n){e!==null?t.setAttribute("contenteditable",e):t.setAttribute("contenteditable","true"),n!==null?t.setAttribute("data-readonly",n):t.removeAttribute("data-readonly")}function $5(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function z5(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function j5(){return hH+=1,`approval-comment-${Date.now().toString(36)}-${hH.toString(36)}`}function aAe(){return pH+=1,`approval-signoff-${Date.now().toString(36)}-${pH.toString(36)}`}function yH(t){return{status:t.status,locked:t.locked,comments:t.comments.map(e=>({...e})),signoffs:t.signoffs.map(e=>({...e})),updatedAt:t.updatedAt}}function sAe(t,e){const n=Zfe[t];return e.labels[n]||t}function vH(t,e,n){var o,a;const r=e.locked,i=e.status==="approved"&&n.lockOnApproval;if(t.setAttribute("data-approval-status",e.status),t.setAttribute("data-approval-locked",i?"true":"false"),t.classList.toggle("rte-approval-locked-editor",i),vg(t,"toggleApprovalWorkflowPanel",K5(t)),vg(t,"requestApprovalReview",e.status==="review"),vg(t,"approveDocument",e.status==="approved"),vg(t,"reopenDraft",e.status==="draft"),i){r||(e.preApprovalContentEditable=t.getAttribute("contenteditable"),e.preApprovalReadonly=t.getAttribute("data-readonly")),t.setAttribute("contenteditable","false"),t.setAttribute("data-readonly","true"),e.locked=!0;return}e.locked=!1,bH(t,(o=e.preApprovalContentEditable)!=null?o:e.originalContentEditable,(a=e.preApprovalReadonly)!=null?a:e.originalReadonly),e.preApprovalContentEditable=null,e.preApprovalReadonly=null}function ho(t,e){let n=w2.get(t);return n||(n={status:e.defaultStatus,locked:!1,comments:[],signoffs:[],updatedAt:new Date().toISOString(),originalContentEditable:t.getAttribute("contenteditable"),originalReadonly:t.getAttribute("data-readonly"),preApprovalContentEditable:null,preApprovalReadonly:null},w2.set(t,n),Oy.add(t),vH(t,n,e),n)}function B2(t,e){return t.length<=e?t:t.slice(t.length-e)}function Py(t,e){const n=t.querySelector(".rte-approval-live");n&&(n.textContent=e)}function cAe(t,e){const n=yH(e);t.__approvalWorkflowState=n,t.dispatchEvent(new CustomEvent("editora:approval-state-changed",{bubbles:!0,detail:{state:n}}))}function Hy(t){const e=wc.get(t);if(!e)return;const n=Xn.get(t)||mg;if(!n)return;const r=ho(t,n),i=e.querySelector(".rte-approval-summary"),o=e.querySelector('[data-action="request-review"]'),a=e.querySelector('[data-action="approve"]'),s=e.querySelector('[data-action="reopen-draft"]'),c=e.querySelector(".rte-approval-comments-list"),l=e.querySelector(".rte-approval-signoffs-list");if(i){const u=sAe(r.status,n);i.textContent=`${n.labels.summaryPrefix}: ${u} | Comments: ${r.comments.length} | Sign-offs: ${r.signoffs.length}${r.locked?` | ${n.labels.lockedSuffix}`:""}`}o&&(o.disabled=r.status!=="draft"),a&&(a.disabled=r.status==="approved"),s&&(s.disabled=r.status==="draft"),c&&(r.comments.length===0?c.innerHTML=`<li class="rte-approval-empty">${br(n.labels.noCommentsText)}</li>`:c.innerHTML=r.comments.slice().reverse().map(u=>`
|
|
5123
5124
|
<li class="rte-approval-item rte-approval-item-${u.kind}" role="listitem">
|
|
5124
5125
|
<div class="rte-approval-item-head">
|
|
5125
5126
|
<span class="rte-approval-item-author">${br(u.author)}</span>
|
|
@@ -5135,7 +5136,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5135
5136
|
</div>
|
|
5136
5137
|
<p class="rte-approval-item-message">${br(u.comment||"Approved")}</p>
|
|
5137
5138
|
</li>
|
|
5138
|
-
`).join(""))}function S2(t,e,n){e.updatedAt=new Date().toISOString(),
|
|
5139
|
+
`).join(""))}function S2(t,e,n){e.updatedAt=new Date().toISOString(),vH(t,e,n),Hy(t),cAe(t,e)}function wH(t,e,n,r){t.comments.push({id:j5(),author:n||e.defaultActor,message:r,kind:"system",createdAt:new Date().toISOString()}),t.comments=B2(t.comments,e.maxHistoryEntries)}function MA(t,e,n,r){const i=ho(t,n);if(i.status===e)return!1;const o=t.innerHTML;return i.status=e,e==="review"?wH(i,n,r,"Review requested."):e==="draft"&&wH(i,n,r,"Returned to draft."),S2(t,i,n),$5(t),z5(t,o),!0}function xH(t,e,n,r){const i=r.normalizeText(e);if(!i)return!1;const o=r.normalizeText(n)||r.defaultActor,a=ho(t,r),s=t.innerHTML;return a.comments.push({id:j5(),author:o,message:i,kind:"comment",createdAt:new Date().toISOString()}),a.comments=B2(a.comments,r.maxHistoryEntries),S2(t,a,r),$5(t),z5(t,s),!0}function q5(t,e,n,r){const i=e.normalizeText(n)||e.defaultActor,o=e.normalizeText(r);if(e.requireCommentOnApprove&&!o)return!1;const a=ho(t,e),s=t.innerHTML;return a.status="approved",a.signoffs.push({id:aAe(),author:i,comment:o||void 0,createdAt:new Date().toISOString()}),a.signoffs=B2(a.signoffs,e.maxHistoryEntries),o&&(a.comments.push({id:j5(),author:i,message:o,kind:"system",createdAt:new Date().toISOString()}),a.comments=B2(a.comments,e.maxHistoryEntries)),S2(t,a,e),$5(t),z5(t,s),!0}function _2(t,e){return t.querySelector(`[data-field="${e}"]`)}function lAe(t){var r,i;const e=((r=_2(t,"actor"))==null?void 0:r.value)||"",n=((i=_2(t,"comment"))==null?void 0:i.value)||"";return{actor:e,comment:n}}function W5(t,e){if(!e.classList.contains("show"))return;const r=Q5(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,420),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),s=Math.max(10,Math.min(window.innerHeight-10-280,r.top+12));e.style.width=`${i}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(280,window.innerHeight-24)}px`}function uAe(t){const e=wc.get(t);if(e)return e;const n=Xn.get(t)||mg||E2(),r=`rte-approval-panel-${Jfe++}`,i=document.createElement("section");return i.className=Sr,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.setAttribute("tabindex","-1"),i.innerHTML=`
|
|
5139
5140
|
<header class="rte-approval-header">
|
|
5140
5141
|
<h2 class="rte-approval-title">${br(n.labels.panelTitle)}</h2>
|
|
5141
5142
|
<button type="button" class="rte-approval-icon-btn" data-action="close" aria-label="${br(n.labels.closeText)}">✕</button>
|
|
@@ -5174,7 +5175,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5174
5175
|
<p class="rte-approval-shortcut">${br(n.labels.shortcutText)}</p>
|
|
5175
5176
|
<span class="rte-approval-live" aria-live="polite"></span>
|
|
5176
5177
|
</div>
|
|
5177
|
-
`,i.addEventListener("click",o=>{const a=o.target;if(!a)return;const s=a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action")||"",l=Xn.get(t)||mg||n;if(Xn.set(t,l),ho(t,l),c==="close"){Qy(t,!0);return}const u=lAe(i);if(c==="request-review"){MA(t,"review",l,u.actor||l.defaultActor)&&Py(i,"Status changed to review.");return}if(c==="reopen-draft"){MA(t,"draft",l,u.actor||l.defaultActor)&&Py(i,"Status changed to draft.");return}if(c==="approve"){const d=q5(t,l,u.actor,u.comment);if(!d&&l.requireCommentOnApprove){Py(i,l.labels.approveCommentRequiredText);return}if(d){const f=_2(i,"comment");f&&(f.value=""),Py(i,"Document approved and signed off.")}return}if(c==="add-comment"){if(!
|
|
5178
|
+
`,i.addEventListener("click",o=>{const a=o.target;if(!a)return;const s=a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action")||"",l=Xn.get(t)||mg||n;if(Xn.set(t,l),ho(t,l),c==="close"){Qy(t,!0);return}const u=lAe(i);if(c==="request-review"){MA(t,"review",l,u.actor||l.defaultActor)&&Py(i,"Status changed to review.");return}if(c==="reopen-draft"){MA(t,"draft",l,u.actor||l.defaultActor)&&Py(i,"Status changed to draft.");return}if(c==="approve"){const d=q5(t,l,u.actor,u.comment);if(!d&&l.requireCommentOnApprove){Py(i,l.labels.approveCommentRequiredText);return}if(d){const f=_2(i,"comment");f&&(f.value=""),Py(i,"Document approved and signed off.")}return}if(c==="add-comment"){if(!xH(t,u.comment,u.actor,l))return;const f=_2(i,"comment");f&&(f.value=""),Py(i,"Comment added.");return}}),i.addEventListener("keydown",o=>{o.key==="Escape"&&(o.preventDefault(),Qy(t,!0))}),k2(i,t),document.body.appendChild(i),wc.set(t,i),Ry.set(t,!1),Hy(t),i}function K5(t){return Ry.get(t)===!0}function Bl(t){My();const e=uAe(t);wc.forEach((n,r)=>{r!==t&&Qy(r,!1)}),e.classList.add("show"),Ry.set(t,!0),vg(t,"toggleApprovalWorkflowPanel",!0),k2(e,t),W5(t,e),Hy(t)}function Qy(t,e=!1){const n=wc.get(t);n&&(n.classList.remove("show"),Ry.set(t,!1),vg(t,"toggleApprovalWorkflowPanel",!1),e&&t.focus({preventScroll:!0}))}function EH(t,e){const n=K5(t);return(typeof e=="boolean"?e:!n)?Bl(t):Qy(t),!0}function D2(t){return typeof t.key=="string"?t.key.toLowerCase():""}function dAe(t){const e=D2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="a"}function fAe(t){const e=D2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="r"}function AAe(t){const e=D2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="p"}function hAe(t){const e=D2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="d"}function pAe(t){mg=t,bg||(bg=e=>{My();const n=e.target,r=n==null?void 0:n.closest(vc);if(!r)return;Ia=r;const i=Xn.get(r)||t;Xn.set(r,i),ho(r,i);const o=wc.get(r);o&&(k2(o,r),W5(r,o))},document.addEventListener("focusin",bg,!0)),yg||(yg=e=>{if(e.defaultPrevented)return;const n=dAe(e),r=fAe(e),i=AAe(e),o=hAe(e),a=e.key==="Escape";if(!a&&!n&&!r&&!i&&!o)return;My();const s=e.target,c=!!(s!=null&&s.closest(`.${Sr} input, .${Sr} textarea, .${Sr} select`));if(!iAe(s)&&!oAe())return;const u=xc(void 0,!1);if(!u)return;const d=Xn.get(u)||mg||t;Xn.set(u,d);const f=ho(u,d);if(Ia=u,a&&K5(u)){e.preventDefault(),Qy(u,!0);return}if(!c){if(n){e.preventDefault(),e.stopPropagation(),EH(u);return}if(r){e.preventDefault(),e.stopPropagation(),MA(u,"review",d,d.defaultActor)&&Bl(u);return}if(i){e.preventDefault(),e.stopPropagation(),q5(u,d,d.defaultActor,"Approved via keyboard shortcut.")&&Bl(u);return}o&&(e.preventDefault(),e.stopPropagation(),f.status!=="draft"&&MA(u,"draft",d,d.defaultActor)&&Bl(u))}},document.addEventListener("keydown",yg,!0)),nf||(nf=()=>{My(),wc.forEach((e,n)=>{!n.isConnected||!e.isConnected||(k2(e,n),W5(n,e))})},window.addEventListener("scroll",nf,!0),window.addEventListener("resize",nf))}function gAe(t){var n,r;const e=w2.get(t);e&&(t.classList.remove("rte-approval-locked-editor"),t.removeAttribute("data-approval-status"),t.removeAttribute("data-approval-locked"),bH(t,(n=e.preApprovalContentEditable)!=null?n:e.originalContentEditable,(r=e.preApprovalReadonly)!=null?r:e.originalReadonly))}function mAe(){bg&&(document.removeEventListener("focusin",bg,!0),bg=null),yg&&(document.removeEventListener("keydown",yg,!0),yg=null),nf&&(window.removeEventListener("scroll",nf,!0),window.removeEventListener("resize",nf),nf=null),wc.forEach(t=>t.remove()),wc.clear(),Oy.forEach(t=>gAe(t)),Oy.clear(),mg=null,Ia=null}function bAe(){if(typeof document=="undefined"||document.getElementById(AH))return;const t=document.createElement("style");t.id=AH,t.textContent=`
|
|
5178
5179
|
.rte-toolbar-group-items.${Ms},
|
|
5179
5180
|
.editora-toolbar-group-items.${Ms},
|
|
5180
5181
|
.rte-toolbar-group-items.${kl},
|
|
@@ -5565,7 +5566,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5565
5566
|
max-height: calc(100vh - 20px);
|
|
5566
5567
|
}
|
|
5567
5568
|
}
|
|
5568
|
-
`,document.head.appendChild(t)}const V5=Object.freeze(Object.defineProperty({__proto__:null,ApprovalWorkflowPlugin:(t={})=>{const e=E2(t);return bAe(),{name:"approvalWorkflow",toolbar:[{id:"approvalWorkflowGroup",label:"Approval",type:"group",command:"approvalWorkflow",items:[{id:"approvalWorkflow",label:"Approval Workflow",command:"toggleApprovalWorkflowPanel",shortcut:"Mod-Alt-Shift-a",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="16" height="14" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="M8 10h8M8 14h5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="m16.5 16 1.8 1.8 3.2-3.2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"approvalRequestReview",label:"Request Review",command:"requestApprovalReview",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><circle cx="11" cy="11" r="6.5" stroke="currentColor" stroke-width="1.7"/><path d="M11 8v3l2 2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17.5 17.5 20 20" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"approvalApprove",label:"Approve",command:"approveDocument",shortcut:"Mod-Alt-Shift-p",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 12.5 9.5 17 19 7.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><rect x="3.8" y="3.8" width="16.4" height="16.4" rx="3" stroke="currentColor" stroke-width="1.4"/></svg>'},{id:"approvalReopen",label:"Reopen Draft",command:"reopenDraft",shortcut:"Mod-Alt-Shift-d",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 8H4v4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M5 12a7 7 0 1 0 2-4.95" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'}]}],commands:{approvalWorkflow:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;return Xn.set(i,o),ho(i,o),Ia=i,Bl(i),Hy(i),!0},toggleApprovalWorkflowPanel:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;return Xn.set(i,o),ho(i,o),Ia=i,E9(i,typeof n=="boolean"?n:void 0)},requestApprovalReview:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=MA(i,"review",o,o.defaultActor);return Bl(i),a},approveDocument:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=typeof n=="object"&&n?String(n.author||""):o.defaultActor,s=typeof n=="object"&&n?String(n.comment||""):typeof n=="string"?n:"",c=q5(i,o,a,s);return c&&Bl(i),c},reopenDraft:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=MA(i,"draft",o,o.defaultActor);return a&&Bl(i),a},addApprovalComment:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=typeof n=="object"&&n?String(n.author||""):o.defaultActor,s=typeof n=="object"&&n?String(n.message||""):typeof n=="string"?n:"",c=x9(i,s,a,o);return c&&Bl(i),c},setApprovalStatus:(n,r)=>{const i=xc(r);if(!i||!n)return!1;const o=g9(n),a=Xn.get(i)||e;Xn.set(i,a),ho(i,a);const s=MA(i,o,a,a.defaultActor);return s&&Bl(i),s},setApprovalWorkflowOptions:(n,r)=>{const i=xc(r);if(!i||!n||typeof n!="object")return!1;const o=Xn.get(i)||e,a=E2({...o,...n,labels:{...o.labels,...n.labels||{}},normalizeText:n.normalizeText||o.normalizeText});Xn.set(i,a);const s=ho(i,a);return S2(i,s,a),!0},getApprovalWorkflowState:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o);const a=ho(i,o),s=y9(a);if(typeof n=="function")try{n(s)}catch(c){}return i.__approvalWorkflowState=s,i.dispatchEvent(new CustomEvent("editora:approval-state",{bubbles:!0,detail:{state:s}})),!0}},keymap:{"Mod-Alt-Shift-a":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-A":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-r":"requestApprovalReview","Mod-Alt-Shift-R":"requestApprovalReview","Mod-Alt-Shift-p":"approveDocument","Mod-Alt-Shift-P":"approveDocument","Mod-Alt-Shift-d":"reopenDraft","Mod-Alt-Shift-D":"reopenDraft"},init:function(r){x2+=1;const i=this&&typeof this.__pluginConfig=="object"?E2({...e,...this.__pluginConfig}):e;pAe(i);const o=xc(r!=null&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(Xn.set(o,i),ho(o,i),Ia=o,Hy(o))},destroy:()=>{x2=Math.max(0,x2-1),!(x2>0)&&mAe()}}}},Symbol.toStringTag,{value:"Module"})),as=".rte-content, .editora-content",L2="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",C9="__editoraCommandEditorRoot",T9="rte-pii-redaction-styles",qn="rte-pii-redaction-panel",Ps="pii-redaction",Sl="piiRedaction",_l=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',G5=typeof NodeFilter!="undefined"?NodeFilter.SHOW_TEXT:4,yAe=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],vAe={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},wAe={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:t=>kAe(t)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},tr=new WeakMap,Dl=new WeakMap,Ec=new WeakMap,rf=new WeakMap,F2=new WeakMap,X5=new WeakMap,I2=new WeakMap,po=new Map,$y=new WeakMap,zy=new Set,jy=new Set;let U2=0,xAe=0,k9=0,PA=null,Zi=null,wg=null,xg=null,Eg=null,of=null,Cg=null;function yi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function EAe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function N2(t){const e=t.flags.includes("g")?t.flags:`${t.flags}g`;return new RegExp(t.source,e)}function Y5(t){return new RegExp(t.source,t.flags)}function R2(t,e,n){return Math.max(e,Math.min(n,t))}function CAe(t,e){return t==="high"||t==="medium"||t==="low"?t:e}function TAe(t){const e=(t||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(e)?"*":e}function B9(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function kAe(t){const e=t.replace(/\D/g,"");if(e.length<13||e.length>19)return!1;let n=0,r=!1;for(let i=e.length-1;i>=0;i-=1){let o=Number(e[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function BAe(t,e){const n=wAe[t];if(typeof e=="boolean")return{type:t,label:n.label,severity:n.severity,enabled:e,pattern:N2(n.pattern),validator:n.validator};if(!e)return{type:t,label:n.label,severity:n.severity,enabled:!0,pattern:N2(n.pattern),validator:n.validator};const r=e.pattern instanceof RegExp?N2(e.pattern):N2(n.pattern);return{type:t,label:n.label,severity:CAe(e.severity,n.severity),enabled:e.enabled!==!1,pattern:r,validator:n.validator}}function O2(t={}){var r,i,o,a;const e=yAe.map(s=>{var c;return BAe(s,(c=t.detectors)==null?void 0:c[s])}),n=e.map(s=>`${s.type}:${s.enabled?"1":"0"}:${s.severity}:${s.pattern.source}:${s.pattern.flags}`).join("|");return{enableRealtime:t.enableRealtime!==!1,debounceMs:R2(Number((r=t.debounceMs)!=null?r:220),60,3e3),maxFindings:R2(Number((i=t.maxFindings)!=null?i:140),1,500),maskChar:TAe(t.maskChar),revealStart:R2(Number((o=t.revealStart)!=null?o:2),0,12),revealEnd:R2(Number((a=t.revealEnd)!=null?a:2),0,12),redactionMode:t.redactionMode==="mask"?"mask":"token",redactionToken:(t.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:t.skipInCodeBlocks!==!1,labels:{...vAe,...t.labels||{}},normalizeText:t.normalizeText||EAe,detectors:e,detectorSignature:n}}function Z5(t){const e={};return t.detectors.forEach(n=>{e[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxFindings:t.maxFindings,maskChar:t.maskChar,revealStart:t.revealStart,revealEnd:t.revealEnd,redactionMode:t.redactionMode,redactionToken:t.redactionToken,skipInCodeBlocks:t.skipInCodeBlocks,labels:{...t.labels},normalizeText:t.normalizeText,detectors:e}}function J5(t){return t.closest(L2)||t}function SAe(t){const e=t.closest("[data-editora-editor]");if(e&&Tg(e)===t)return e;let n=t;for(;n;){if(n.matches(L2)&&(n===t||Tg(n)===t))return n;n=n.parentElement}return J5(t)}function Tg(t){if(!t)return null;if(t.matches(as))return t;const e=t.querySelector(as);return e instanceof HTMLElement?e:null}function _Ae(){if(typeof window=="undefined")return null;const t=window[C9];if(!(t instanceof HTMLElement))return null;window[C9]=null;const e=Tg(t);if(e)return e;const n=t.closest(L2);if(n){const i=Tg(n);if(i)return i}const r=t.closest(as);return r instanceof HTMLElement?r:null}function M2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function DAe(t){const e=J5(t);if(M2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return M2(n)?!0:M2(document.documentElement)||M2(document.body)}function P2(t,e){t.classList.remove("rte-pii-redaction-theme-dark"),DAe(e)&&t.classList.add("rte-pii-redaction-theme-dark")}function H2(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function e_(t){const e=F2.get(t);typeof e=="number"&&(window.clearTimeout(e),jy.delete(e),F2.delete(t))}function qy(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Q2(t=0){return{total:0,high:0,medium:0,low:0,redactedCount:t,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function Wy(){Array.from(zy).forEach(e=>{e.isConnected||S9(e)})}function LAe(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,as)||(n=l.matches)!=null&&n.call(l,`.${qn}`)||(r=l.querySelector)!=null&&r.call(l,as)||(i=l.querySelector)!=null&&i.call(l,`.${qn}`))return!0}}return!1}function Fu(t,e=!0){if(Wy(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement,a=Tg(o);if(a)return a}const n=_Ae();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=H2(r.getRangeAt(0).startContainer),a=o==null?void 0:o.closest(as);if(a)return a}const i=document.activeElement;if(i){if(i.matches(as))return i;const o=i.closest(as);if(o)return o}return Zi&&Zi.isConnected?Zi:(Zi&&!Zi.isConnected&&(Zi=null),e?document.querySelector(as):null)}function S9(t){var e;e_(t),(e=po.get(t))==null||e.remove(),po.delete(t),$y.delete(t),tr.delete(t),Dl.delete(t),Ec.delete(t),rf.delete(t),X5.delete(t),I2.delete(t),zy.delete(t),Zi===t&&(Zi=null)}function Iu(t,e,n){const r=SAe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function Cc(t,e){tr.has(t)||tr.set(t,e),Dl.has(t)||Dl.set(t,[]),Ec.has(t)||Ec.set(t,Q2(0)),rf.has(t)||rf.set(t,e.enableRealtime),zy.add(t)}function $2(t){return $y.get(t)===!0}function _9(t,e,n,r){if(!t)return t;if(t.length<=n+r)return e.repeat(t.length);const i=t.slice(0,n),o=r>0?t.slice(t.length-r):"";return`${i}${e.repeat(Math.max(1,t.length-n-r))}${o}`}function t_(t,e,n){const r=t.replace(/\D/g,"");if(r.length===0)return t;let i=0;const o=Math.max(0,r.length-n);return t.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?e:a):a).join("")}function FAe(t,e){const n=t.indexOf("@");if(n<=0)return t;const r=t.slice(0,n),i=t.slice(n+1);return r.length<=2?`${r[0]||""}${e}[at]${i}`:`${r[0]}${e.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function IAe(t,e){const n=t.split(".");return n.length!==4?t:`${n[0]}.${n[1]}.${n[2]}.${e.repeat(Math.max(1,n[3].length))}`}function D9(t,e,n){return t&&(e==="email"?FAe(t,n.maskChar):e==="phone"||e==="ssn"||e==="credit-card"?t_(t,n.maskChar,4):e==="ipv4"?IAe(t,n.maskChar):e==="api-key"||e==="jwt"?_9(t,n.maskChar,0,0):_9(t,n.maskChar,n.revealStart,n.revealEnd))}function L9(t,e,n){return n.redactionMode==="mask"?D9(t,e,n):`[${n.redactionToken}:${e.toUpperCase()}]`}function UAe(t){return k9+=1,`pii-${t}-${Date.now().toString(36)}-${k9.toString(36)}`}function n_(t,e){var n;return e.skipInCodeBlocks?!!((n=t.parentElement)!=null&&n.closest("code, pre, kbd, samp")):!1}function NAe(t,e){return e.some(n=>t.start<n.end&&n.start<t.end)}function RAe(t,e,n){const r=[];e.filter(a=>a.enabled).forEach(a=>{const s=Y5(a.pattern);let c=s.exec(t);for(;c&&r.length<n*5;){const l=c[0]||"",u=c.index,d=u+l.length;l&&d>u&&(!a.validator||a.validator(l))&&r.push({type:a.type,severity:a.severity,value:l,start:u,end:d}),s.lastIndex===c.index&&(s.lastIndex+=1),c=s.exec(t)}}),r.sort((a,s)=>a.start!==s.start?a.start-s.start:s.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const s=r[a];NAe({start:s.start,end:s.end},o)||o.push(s)}return o}function r_(t,e=120){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}...`}function OAe(t,e,n){const r=Math.max(0,e-28),i=Math.min(t.length,n+28);return r_(t.slice(r,i).trim(),180)}function MAe(t,e){const n=Q2(e);return n.total=t.length,t.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function z2(t,e){const n=t.querySelector(".rte-pii-redaction-live");n&&(n.textContent=e)}function kg(t,e,n){const r=e.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=Sg(t,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),Iu(t,"togglePIIRealtime",i)}function PAe(t,e){t.setAttribute("aria-label",e.labels.panelAriaLabel);const n=t.querySelector(".rte-pii-redaction-title");n&&(n.textContent=e.labels.panelTitle);const r=t.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",e.labels.closeText);const i=t.querySelector('[data-action="run-scan"]');i&&(i.textContent=e.labels.scanText);const o=t.querySelector('[data-action="redact-all"]');o&&(o.textContent=e.labels.redactAllText);const a=t.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=e.labels.shortcutText)}function Bg(t){const e=po.get(t);if(!e)return;const n=tr.get(t)||PA;if(!n)return;const r=Dl.get(t)||[],i=Ec.get(t)||Q2(0),o=qy(t),a=e.querySelector(".rte-pii-redaction-count"),s=e.querySelector(".rte-pii-redaction-summary"),c=e.querySelector(".rte-pii-redaction-list"),l=e.querySelector('[data-action="redact-all"]');if(!(!a||!s||!c||!l)){if(a.textContent=String(i.total),s.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,l.disabled=o||r.length===0,o?z2(e,n.labels.readonlyRedactionText):z2(e,`${i.total} PII findings detected.`),kg(t,e,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${yi(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(u=>{const d=u.type.toUpperCase(),f=u.suggestion||"Redact this finding before export/share.",A=`${n.labels.locateText}: ${u.match}`,h=`${n.labels.redactText}: ${u.match}`,p=o?'disabled aria-disabled="true"':"";return`
|
|
5569
|
+
`,document.head.appendChild(t)}const V5=Object.freeze(Object.defineProperty({__proto__:null,ApprovalWorkflowPlugin:(t={})=>{const e=E2(t);return bAe(),{name:"approvalWorkflow",toolbar:[{id:"approvalWorkflowGroup",label:"Approval",type:"group",command:"approvalWorkflow",items:[{id:"approvalWorkflow",label:"Approval Workflow",command:"toggleApprovalWorkflowPanel",shortcut:"Mod-Alt-Shift-a",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="16" height="14" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="M8 10h8M8 14h5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="m16.5 16 1.8 1.8 3.2-3.2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"approvalRequestReview",label:"Request Review",command:"requestApprovalReview",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><circle cx="11" cy="11" r="6.5" stroke="currentColor" stroke-width="1.7"/><path d="M11 8v3l2 2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17.5 17.5 20 20" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"approvalApprove",label:"Approve",command:"approveDocument",shortcut:"Mod-Alt-Shift-p",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 12.5 9.5 17 19 7.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><rect x="3.8" y="3.8" width="16.4" height="16.4" rx="3" stroke="currentColor" stroke-width="1.4"/></svg>'},{id:"approvalReopen",label:"Reopen Draft",command:"reopenDraft",shortcut:"Mod-Alt-Shift-d",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 8H4v4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M5 12a7 7 0 1 0 2-4.95" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'}]}],commands:{approvalWorkflow:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;return Xn.set(i,o),ho(i,o),Ia=i,Bl(i),Hy(i),!0},toggleApprovalWorkflowPanel:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;return Xn.set(i,o),ho(i,o),Ia=i,EH(i,typeof n=="boolean"?n:void 0)},requestApprovalReview:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=MA(i,"review",o,o.defaultActor);return Bl(i),a},approveDocument:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=typeof n=="object"&&n?String(n.author||""):o.defaultActor,s=typeof n=="object"&&n?String(n.comment||""):typeof n=="string"?n:"",c=q5(i,o,a,s);return c&&Bl(i),c},reopenDraft:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=MA(i,"draft",o,o.defaultActor);return a&&Bl(i),a},addApprovalComment:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o),ho(i,o);const a=typeof n=="object"&&n?String(n.author||""):o.defaultActor,s=typeof n=="object"&&n?String(n.message||""):typeof n=="string"?n:"",c=xH(i,s,a,o);return c&&Bl(i),c},setApprovalStatus:(n,r)=>{const i=xc(r);if(!i||!n)return!1;const o=gH(n),a=Xn.get(i)||e;Xn.set(i,a),ho(i,a);const s=MA(i,o,a,a.defaultActor);return s&&Bl(i),s},setApprovalWorkflowOptions:(n,r)=>{const i=xc(r);if(!i||!n||typeof n!="object")return!1;const o=Xn.get(i)||e,a=E2({...o,...n,labels:{...o.labels,...n.labels||{}},normalizeText:n.normalizeText||o.normalizeText});Xn.set(i,a);const s=ho(i,a);return S2(i,s,a),!0},getApprovalWorkflowState:(n,r)=>{const i=xc(r);if(!i)return!1;const o=Xn.get(i)||e;Xn.set(i,o);const a=ho(i,o),s=yH(a);if(typeof n=="function")try{n(s)}catch(c){}return i.__approvalWorkflowState=s,i.dispatchEvent(new CustomEvent("editora:approval-state",{bubbles:!0,detail:{state:s}})),!0}},keymap:{"Mod-Alt-Shift-a":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-A":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-r":"requestApprovalReview","Mod-Alt-Shift-R":"requestApprovalReview","Mod-Alt-Shift-p":"approveDocument","Mod-Alt-Shift-P":"approveDocument","Mod-Alt-Shift-d":"reopenDraft","Mod-Alt-Shift-D":"reopenDraft"},init:function(r){x2+=1;const i=this&&typeof this.__pluginConfig=="object"?E2({...e,...this.__pluginConfig}):e;pAe(i);const o=xc(r!=null&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);o&&(Xn.set(o,i),ho(o,i),Ia=o,Hy(o))},destroy:()=>{x2=Math.max(0,x2-1),!(x2>0)&&mAe()}}}},Symbol.toStringTag,{value:"Module"})),as=".rte-content, .editora-content",L2="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",CH="__editoraCommandEditorRoot",TH="rte-pii-redaction-styles",qn="rte-pii-redaction-panel",Ps="pii-redaction",Sl="piiRedaction",_l=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',G5=typeof NodeFilter!="undefined"?NodeFilter.SHOW_TEXT:4,yAe=["email","phone","ssn","credit-card","ipv4","api-key","jwt"],vAe={panelTitle:"PII Redaction",panelAriaLabel:"PII redaction panel",scanText:"Scan PII",redactAllText:"Redact All",redactText:"Redact",locateText:"Locate",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noFindingsText:"No PII detected in the document.",summaryPrefix:"Findings",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",readonlyRedactionText:"Editor is read-only. Reopen editable mode to redact.",matchLabel:"Detected",maskedLabel:"Masked",excerptLabel:"Context"},wAe={email:{label:"Email",severity:"medium",pattern:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi},phone:{label:"Phone",severity:"medium",pattern:/\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g},ssn:{label:"SSN",severity:"high",pattern:/\b\d{3}-\d{2}-\d{4}\b/g},"credit-card":{label:"Credit Card",severity:"high",pattern:/\b(?:\d[ -]*?){13,19}\b/g,validator:t=>kAe(t)},ipv4:{label:"IPv4",severity:"low",pattern:/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g},"api-key":{label:"API Key",severity:"high",pattern:/\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g},jwt:{label:"JWT",severity:"high",pattern:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g}},tr=new WeakMap,Dl=new WeakMap,Ec=new WeakMap,rf=new WeakMap,F2=new WeakMap,X5=new WeakMap,I2=new WeakMap,po=new Map,$y=new WeakMap,zy=new Set,jy=new Set;let U2=0,xAe=0,kH=0,PA=null,Zi=null,wg=null,xg=null,Eg=null,of=null,Cg=null;function yi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function EAe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function N2(t){const e=t.flags.includes("g")?t.flags:`${t.flags}g`;return new RegExp(t.source,e)}function Y5(t){return new RegExp(t.source,t.flags)}function R2(t,e,n){return Math.max(e,Math.min(n,t))}function CAe(t,e){return t==="high"||t==="medium"||t==="low"?t:e}function TAe(t){const e=(t||"*").slice(0,1)||"*";return/[A-Za-z0-9._%+\-\s]/.test(e)?"*":e}function BH(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function kAe(t){const e=t.replace(/\D/g,"");if(e.length<13||e.length>19)return!1;let n=0,r=!1;for(let i=e.length-1;i>=0;i-=1){let o=Number(e[i]);r&&(o*=2,o>9&&(o-=9)),n+=o,r=!r}return n%10===0}function BAe(t,e){const n=wAe[t];if(typeof e=="boolean")return{type:t,label:n.label,severity:n.severity,enabled:e,pattern:N2(n.pattern),validator:n.validator};if(!e)return{type:t,label:n.label,severity:n.severity,enabled:!0,pattern:N2(n.pattern),validator:n.validator};const r=e.pattern instanceof RegExp?N2(e.pattern):N2(n.pattern);return{type:t,label:n.label,severity:CAe(e.severity,n.severity),enabled:e.enabled!==!1,pattern:r,validator:n.validator}}function O2(t={}){var r,i,o,a;const e=yAe.map(s=>{var c;return BAe(s,(c=t.detectors)==null?void 0:c[s])}),n=e.map(s=>`${s.type}:${s.enabled?"1":"0"}:${s.severity}:${s.pattern.source}:${s.pattern.flags}`).join("|");return{enableRealtime:t.enableRealtime!==!1,debounceMs:R2(Number((r=t.debounceMs)!=null?r:220),60,3e3),maxFindings:R2(Number((i=t.maxFindings)!=null?i:140),1,500),maskChar:TAe(t.maskChar),revealStart:R2(Number((o=t.revealStart)!=null?o:2),0,12),revealEnd:R2(Number((a=t.revealEnd)!=null?a:2),0,12),redactionMode:t.redactionMode==="mask"?"mask":"token",redactionToken:(t.redactionToken||"REDACTED").trim()||"REDACTED",skipInCodeBlocks:t.skipInCodeBlocks!==!1,labels:{...vAe,...t.labels||{}},normalizeText:t.normalizeText||EAe,detectors:e,detectorSignature:n}}function Z5(t){const e={};return t.detectors.forEach(n=>{e[n.type]={enabled:n.enabled,severity:n.severity,pattern:n.pattern}}),{enableRealtime:t.enableRealtime,debounceMs:t.debounceMs,maxFindings:t.maxFindings,maskChar:t.maskChar,revealStart:t.revealStart,revealEnd:t.revealEnd,redactionMode:t.redactionMode,redactionToken:t.redactionToken,skipInCodeBlocks:t.skipInCodeBlocks,labels:{...t.labels},normalizeText:t.normalizeText,detectors:e}}function J5(t){return t.closest(L2)||t}function SAe(t){const e=t.closest("[data-editora-editor]");if(e&&Tg(e)===t)return e;let n=t;for(;n;){if(n.matches(L2)&&(n===t||Tg(n)===t))return n;n=n.parentElement}return J5(t)}function Tg(t){if(!t)return null;if(t.matches(as))return t;const e=t.querySelector(as);return e instanceof HTMLElement?e:null}function _Ae(){if(typeof window=="undefined")return null;const t=window[CH];if(!(t instanceof HTMLElement))return null;window[CH]=null;const e=Tg(t);if(e)return e;const n=t.closest(L2);if(n){const i=Tg(n);if(i)return i}const r=t.closest(as);return r instanceof HTMLElement?r:null}function M2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function DAe(t){const e=J5(t);if(M2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return M2(n)?!0:M2(document.documentElement)||M2(document.body)}function P2(t,e){t.classList.remove("rte-pii-redaction-theme-dark"),DAe(e)&&t.classList.add("rte-pii-redaction-theme-dark")}function H2(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function e_(t){const e=F2.get(t);typeof e=="number"&&(window.clearTimeout(e),jy.delete(e),F2.delete(t))}function qy(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Q2(t=0){return{total:0,high:0,medium:0,low:0,redactedCount:t,byType:{email:0,phone:0,ssn:0,"credit-card":0,ipv4:0,"api-key":0,jwt:0}}}function Wy(){Array.from(zy).forEach(e=>{e.isConnected||SH(e)})}function LAe(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,as)||(n=l.matches)!=null&&n.call(l,`.${qn}`)||(r=l.querySelector)!=null&&r.call(l,as)||(i=l.querySelector)!=null&&i.call(l,`.${qn}`))return!0}}return!1}function Fu(t,e=!0){if(Wy(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const o=t.editorElement,a=Tg(o);if(a)return a}const n=_Ae();if(n)return n;const r=window.getSelection();if(r&&r.rangeCount>0){const o=H2(r.getRangeAt(0).startContainer),a=o==null?void 0:o.closest(as);if(a)return a}const i=document.activeElement;if(i){if(i.matches(as))return i;const o=i.closest(as);if(o)return o}return Zi&&Zi.isConnected?Zi:(Zi&&!Zi.isConnected&&(Zi=null),e?document.querySelector(as):null)}function SH(t){var e;e_(t),(e=po.get(t))==null||e.remove(),po.delete(t),$y.delete(t),tr.delete(t),Dl.delete(t),Ec.delete(t),rf.delete(t),X5.delete(t),I2.delete(t),zy.delete(t),Zi===t&&(Zi=null)}function Iu(t,e,n){const r=SAe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function Cc(t,e){tr.has(t)||tr.set(t,e),Dl.has(t)||Dl.set(t,[]),Ec.has(t)||Ec.set(t,Q2(0)),rf.has(t)||rf.set(t,e.enableRealtime),zy.add(t)}function $2(t){return $y.get(t)===!0}function _H(t,e,n,r){if(!t)return t;if(t.length<=n+r)return e.repeat(t.length);const i=t.slice(0,n),o=r>0?t.slice(t.length-r):"";return`${i}${e.repeat(Math.max(1,t.length-n-r))}${o}`}function t_(t,e,n){const r=t.replace(/\D/g,"");if(r.length===0)return t;let i=0;const o=Math.max(0,r.length-n);return t.split("").map(a=>/\d/.test(a)?(i+=1,i<=o?e:a):a).join("")}function FAe(t,e){const n=t.indexOf("@");if(n<=0)return t;const r=t.slice(0,n),i=t.slice(n+1);return r.length<=2?`${r[0]||""}${e}[at]${i}`:`${r[0]}${e.repeat(Math.max(1,r.length-2))}${r[r.length-1]}[at]${i}`}function IAe(t,e){const n=t.split(".");return n.length!==4?t:`${n[0]}.${n[1]}.${n[2]}.${e.repeat(Math.max(1,n[3].length))}`}function DH(t,e,n){return t&&(e==="email"?FAe(t,n.maskChar):e==="phone"||e==="ssn"||e==="credit-card"?t_(t,n.maskChar,4):e==="ipv4"?IAe(t,n.maskChar):e==="api-key"||e==="jwt"?_H(t,n.maskChar,0,0):_H(t,n.maskChar,n.revealStart,n.revealEnd))}function LH(t,e,n){return n.redactionMode==="mask"?DH(t,e,n):`[${n.redactionToken}:${e.toUpperCase()}]`}function UAe(t){return kH+=1,`pii-${t}-${Date.now().toString(36)}-${kH.toString(36)}`}function n_(t,e){var n;return e.skipInCodeBlocks?!!((n=t.parentElement)!=null&&n.closest("code, pre, kbd, samp")):!1}function NAe(t,e){return e.some(n=>t.start<n.end&&n.start<t.end)}function RAe(t,e,n){const r=[];e.filter(a=>a.enabled).forEach(a=>{const s=Y5(a.pattern);let c=s.exec(t);for(;c&&r.length<n*5;){const l=c[0]||"",u=c.index,d=u+l.length;l&&d>u&&(!a.validator||a.validator(l))&&r.push({type:a.type,severity:a.severity,value:l,start:u,end:d}),s.lastIndex===c.index&&(s.lastIndex+=1),c=s.exec(t)}}),r.sort((a,s)=>a.start!==s.start?a.start-s.start:s.end-a.end);const o=[];for(let a=0;a<r.length&&!(o.length>=n);a+=1){const s=r[a];NAe({start:s.start,end:s.end},o)||o.push(s)}return o}function r_(t,e=120){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}...`}function OAe(t,e,n){const r=Math.max(0,e-28),i=Math.min(t.length,n+28);return r_(t.slice(r,i).trim(),180)}function MAe(t,e){const n=Q2(e);return n.total=t.length,t.forEach(r=>{n.byType[r.type]+=1,r.severity==="high"?n.high+=1:r.severity==="medium"?n.medium+=1:n.low+=1}),n}function z2(t,e){const n=t.querySelector(".rte-pii-redaction-live");n&&(n.textContent=e)}function kg(t,e,n){const r=e.querySelector('[data-action="toggle-realtime"]');if(!r)return;const i=Sg(t,n);r.textContent=i?n.labels.realtimeOnText:n.labels.realtimeOffText,r.setAttribute("aria-pressed",i?"true":"false"),Iu(t,"togglePIIRealtime",i)}function PAe(t,e){t.setAttribute("aria-label",e.labels.panelAriaLabel);const n=t.querySelector(".rte-pii-redaction-title");n&&(n.textContent=e.labels.panelTitle);const r=t.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",e.labels.closeText);const i=t.querySelector('[data-action="run-scan"]');i&&(i.textContent=e.labels.scanText);const o=t.querySelector('[data-action="redact-all"]');o&&(o.textContent=e.labels.redactAllText);const a=t.querySelector(".rte-pii-redaction-shortcut");a&&(a.textContent=e.labels.shortcutText)}function Bg(t){const e=po.get(t);if(!e)return;const n=tr.get(t)||PA;if(!n)return;const r=Dl.get(t)||[],i=Ec.get(t)||Q2(0),o=qy(t),a=e.querySelector(".rte-pii-redaction-count"),s=e.querySelector(".rte-pii-redaction-summary"),c=e.querySelector(".rte-pii-redaction-list"),l=e.querySelector('[data-action="redact-all"]');if(!(!a||!s||!c||!l)){if(a.textContent=String(i.total),s.textContent=`${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`,l.disabled=o||r.length===0,o?z2(e,n.labels.readonlyRedactionText):z2(e,`${i.total} PII findings detected.`),kg(t,e,n),r.length===0){c.innerHTML=`<li class="rte-pii-redaction-empty">${yi(n.labels.noFindingsText)}</li>`;return}c.innerHTML=r.map(u=>{const d=u.type.toUpperCase(),f=u.suggestion||"Redact this finding before export/share.",A=`${n.labels.locateText}: ${u.match}`,h=`${n.labels.redactText}: ${u.match}`,p=o?'disabled aria-disabled="true"':"";return`
|
|
5569
5570
|
<li class="rte-pii-redaction-item rte-pii-redaction-item-${u.severity}">
|
|
5570
5571
|
<button
|
|
5571
5572
|
type="button"
|
|
@@ -5586,7 +5587,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5586
5587
|
<button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${yi(u.id)}" aria-label="${yi(h)}" ${p}>${yi(n.labels.redactText)}</button>
|
|
5587
5588
|
</div>
|
|
5588
5589
|
</li>
|
|
5589
|
-
`}).join("")}}function i_(t,e){if(!e.classList.contains("show"))return;const r=J5(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),s=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));e.style.width=`${i}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function Sg(t,e){const n=rf.get(t);return typeof n=="boolean"?n:e?e.enableRealtime:!0}function
|
|
5590
|
+
`}).join("")}}function i_(t,e){if(!e.classList.contains("show"))return;const r=J5(t).getBoundingClientRect(),i=Math.min(window.innerWidth-20,390),o=Math.max(10,window.innerWidth-i-10),a=Math.min(Math.max(10,r.right-i),o),s=Math.max(10,Math.min(window.innerHeight-10-280,r.top+10));e.style.width=`${i}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function Sg(t,e){const n=rf.get(t);return typeof n=="boolean"?n:e?e.enableRealtime:!0}function FH(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function IH(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function UH(t,e){t.dispatchEvent(new CustomEvent("editora:pii-redacted",{bubbles:!0,detail:{redactedCount:e}}))}function NH(t,e){return(Dl.get(t)||[]).find(r=>r.id===e)}function HAe(t){const e=po.get(t);if(e)return e;const n=tr.get(t)||PA||O2(),r=`rte-pii-redaction-panel-${xAe++}`,i=document.createElement("section");return i.className=qn,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
|
|
5590
5591
|
<header class="rte-pii-redaction-header">
|
|
5591
5592
|
<h2 class="rte-pii-redaction-title">${yi(n.labels.panelTitle)}</h2>
|
|
5592
5593
|
<button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${yi(n.labels.closeText)}">✕</button>
|
|
@@ -5605,7 +5606,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5605
5606
|
<p class="rte-pii-redaction-shortcut">${yi(n.labels.shortcutText)}</p>
|
|
5606
5607
|
<span class="rte-pii-redaction-live" aria-live="polite"></span>
|
|
5607
5608
|
</div>
|
|
5608
|
-
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action")||"",l=tr.get(t)||PA||n;if(tr.set(t,l),Cc(t,l),c==="close"){Ky(t,!0);return}if(c==="run-scan"){ss(t,l,!0);return}if(c==="toggle-realtime"){const u=!Sg(t,l);rf.set(t,u),kg(t,i,l),u&&ss(t,l,!0);return}if(c==="redact-all"){o_(t,l);return}if(c==="locate-finding"){const u=s.getAttribute("data-finding-id")||"",d=
|
|
5609
|
+
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action")||"",l=tr.get(t)||PA||n;if(tr.set(t,l),Cc(t,l),c==="close"){Ky(t,!0);return}if(c==="run-scan"){ss(t,l,!0);return}if(c==="toggle-realtime"){const u=!Sg(t,l);rf.set(t,u),kg(t,i,l),u&&ss(t,l,!0);return}if(c==="redact-all"){o_(t,l);return}if(c==="locate-finding"){const u=s.getAttribute("data-finding-id")||"",d=NH(t,u);if(!d)return;zAe(t,d,l);return}if(c==="redact-finding"){const u=s.getAttribute("data-finding-id")||"";MH(t,u,l)}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),Ky(t,!0);return}if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;const a=Array.from(i.querySelectorAll('[data-role="finding-button"]'));if(a.length===0)return;const s=document.activeElement,c=a.findIndex(d=>d===s);if(c===-1)return;o.preventDefault();const l=o.key==="ArrowDown"?1:-1,u=(c+l+a.length)%a.length;a[u].focus()}),P2(i,t),document.body.appendChild(i),po.set(t,i),$y.set(t,!1),Bg(t),i}function Ky(t,e=!1){const n=po.get(t);n&&(n.classList.remove("show"),$y.set(t,!1),Iu(t,"togglePIIRedactionPanel",!1),e&&t.focus({preventScroll:!0}))}function _g(t){Wy();const e=HAe(t);po.forEach((r,i)=>{i!==t&&Ky(i,!1)}),e.classList.add("show"),$y.set(t,!0),Iu(t,"togglePIIRedactionPanel",!0),P2(e,t),i_(t,e),Bg(t);const n=e.querySelector('[data-action="run-scan"]');n==null||n.focus()}function RH(t,e){const n=$2(t);return(typeof e=="boolean"?e:!n)?_g(t):Ky(t),!0}function QAe(t,e){const n=e.normalizeText(t.innerText||t.textContent||""),r=t.innerHTML;return`${n.length}:${BH(n)}:${r.length}:${BH(r)}:${e.detectorSignature}`}function $Ae(t,e){const n=[],r=Y5(t.pattern);let i=r.exec(e);for(;i;){const o=i[0]||"",a=i.index,s=a+o.length;o&&s>a&&(!t.validator||t.validator(o))&&n.push({value:o,start:a,end:s}),r.lastIndex===i.index&&(r.lastIndex+=1),i=r.exec(e)}return n}function OH(t,e,n){const r=n.detectors.find(c=>c.type===e.type&&c.enabled);if(!r)return null;const i=e.match.toLowerCase();let o=0;const a=document.createTreeWalker(t,G5,null);let s=a.nextNode();for(;s;){if(!n_(s,n)){const c=$Ae(r,s.data);for(let l=0;l<c.length;l+=1){const u=c[l];if(u.value.toLowerCase()===i&&(o+=1,o===e.occurrence)){const d=document.createRange();return d.setStart(s,u.start),d.setEnd(s,u.end),d}}}s=a.nextNode()}return null}function zAe(t,e,n){const r=OH(t,e,n);if(!r)return!1;const i=window.getSelection();if(!i)return!1;i.removeAllRanges(),i.addRange(r);const o=H2(r.startContainer);return o==null||o.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),t.focus({preventScroll:!0}),!0}async function ss(t,e,n=!1){var d;Cc(t,e);const r=QAe(t,e);if(!n&&X5.get(t)===r)return Dl.get(t)||[];const i=(I2.get(t)||0)+1;I2.set(t,i);const o=[],a=new Map,s=document.createTreeWalker(t,G5,null);let c=s.nextNode();for(;c&&o.length<e.maxFindings;){const f=c.data||"";if(f.trim()&&!n_(c,e)){const A=RAe(f,e.detectors,e.maxFindings-o.length);for(let h=0;h<A.length&&!(o.length>=e.maxFindings);h+=1){const p=A[h],m=`${p.type}:${p.value.toLowerCase()}`,g=(a.get(m)||0)+1;a.set(m,g),o.push({id:UAe(p.type),type:p.type,severity:p.severity,match:p.value,masked:DH(p.value,p.type,e),occurrence:g,excerpt:OAe(f,p.start,p.end),suggestion:"Review and redact this value before external sharing."})}}c=s.nextNode()}if(I2.get(t)!==i)return Dl.get(t)||[];const l=((d=Ec.get(t))==null?void 0:d.redactedCount)||0,u=MAe(o,l);return X5.set(t,r),Dl.set(t,o),Ec.set(t,u),Bg(t),t.dispatchEvent(new CustomEvent("editora:pii-scan",{bubbles:!0,detail:{findings:o,stats:u}})),o}function jAe(t,e){let n=t,r=0;return e.detectors.filter(o=>o.enabled).forEach(o=>{const a=Y5(o.pattern);n=n.replace(a,s=>o.validator&&!o.validator(s)?s:(r+=1,LH(s,o.type,e)))}),{nextValue:n,count:r}}async function MH(t,e,n){var l;if(qy(t)){const u=po.get(t);return u&&z2(u,n.labels.readonlyRedactionText),!1}const r=NH(t,e);if(!r)return!1;const i=OH(t,r,n);if(!i)return!1;const o=t.innerHTML,a=LH(r.match,r.type,n);if(i.startContainer===i.endContainer&&i.startContainer.nodeType===Node.TEXT_NODE){const u=i.startContainer,d=u.data,f=i.startOffset,A=i.endOffset;u.data=`${d.slice(0,f)}${a}${d.slice(A)}`}else i.deleteContents(),i.insertNode(document.createTextNode(a));IH(t),FH(t,o);const s=((l=Ec.get(t))==null?void 0:l.redactedCount)||0;await ss(t,n,!0);const c=Ec.get(t);return c&&(c.redactedCount=s+1,Bg(t)),UH(t,1),!0}async function o_(t,e){var l;if(qy(t)){const u=po.get(t);return u&&z2(u,e.labels.readonlyRedactionText),0}(Dl.get(t)||[]).length===0&&await ss(t,e,!0);const r=t.innerHTML;let i=0;const o=document.createTreeWalker(t,G5,null);let a=o.nextNode();for(;a;){if(n_(a,e)){a=o.nextNode();continue}const u=a.data||"";if(!u){a=o.nextNode();continue}const d=jAe(u,e);d.count>0&&d.nextValue!==u&&(a.data=d.nextValue,i+=d.count),a=o.nextNode()}if(i===0)return 0;IH(t),FH(t,r);const s=((l=Ec.get(t))==null?void 0:l.redactedCount)||0;await ss(t,e,!0);const c=Ec.get(t);return c&&(c.redactedCount=s+i,Bg(t)),UH(t,i),i}function PH(t){const e=tr.get(t)||PA;if(!e||!Sg(t,e)||qy(t))return;e_(t);const n=window.setTimeout(()=>{jy.delete(n),F2.delete(t),ss(t,e,!1)},e.debounceMs);jy.add(n),F2.set(t,n)}function j2(t){return typeof t.key=="string"?t.key.toLowerCase():""}function qAe(t){const e=j2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="i"}function WAe(t){const e=j2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="u"}function KAe(t){const e=j2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="m"}function VAe(t){const e=j2(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="y"}function GAe(t){var r;const e=H2(t.target);if(e){const i=e.closest(as);if(i)return i;const o=e.closest(L2);if(o){const s=Tg(o);if(s)return s}const a=e.closest(`.${qn}`);if(a){const s=Array.from(po.entries()).find(([,c])=>c===a);if(s)return s[0]}}const n=window.getSelection();if(n&&n.rangeCount>0){const i=(r=H2(n.getRangeAt(0).startContainer))==null?void 0:r.closest(as);if(i)return i}return null}function XAe(){if(typeof document=="undefined"||document.getElementById(TH))return;const t=document.createElement("style");t.id=TH,t.textContent=`
|
|
5609
5610
|
.rte-toolbar-group-items.${Ps},
|
|
5610
5611
|
.editora-toolbar-group-items.${Ps},
|
|
5611
5612
|
.rte-toolbar-group-items.${Sl},
|
|
@@ -6000,12 +6001,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6000
6001
|
max-height: 45vh;
|
|
6001
6002
|
}
|
|
6002
6003
|
}
|
|
6003
|
-
`,document.head.appendChild(t)}function YAe(t){PA=t,wg||(wg=e=>{Wy();const n=e.target,r=n==null?void 0:n.closest(as);if(!r)return;Zi=r;const i=tr.get(r)||t;Cc(r,i),tr.set(r,i),Iu(r,"togglePIIRedactionPanel",$2(r)),Iu(r,"togglePIIRealtime",Sg(r,i));const o=po.get(r);o&&(P2(o,r),i_(r,o),kg(r,o,i))},document.addEventListener("focusin",wg,!0)),xg||(xg=e=>{const n=e.target,r=n==null?void 0:n.closest(as);r&&(Zi=r,
|
|
6004
|
-
`)}function Xy(t){return t==="balanced"||t==="plain"?t:"fidelity"}function u_(t,e){var n,r,i,o;return{keepStyles:(n=t==null?void 0:t.keepStyles)!=null?n:e.keepStyles,keepClasses:(r=t==null?void 0:t.keepClasses)!=null?r:e.keepClasses,keepDataAttributes:(i=t==null?void 0:t.keepDataAttributes)!=null?i:e.keepDataAttributes,preserveTables:(o=t==null?void 0:t.preserveTables)!=null?o:e.preserveTables}}function K2(t={}){var n;const e=t.profileOptions||{};return{enabled:t.enabled!==!1,defaultProfile:Xy(t.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number((n=t.maxHtmlLength)!=null?n:22e4))),removeComments:t.removeComments!==!1,normalizeWhitespace:t.normalizeWhitespace!==!1,labels:{...ahe,...t.labels||{}},normalizeText:t.normalizeText||che,profileOptions:{fidelity:u_(e.fidelity,c_.fidelity),balanced:u_(e.balanced,c_.balanced),plain:u_(e.plain,c_.plain)}}}function
|
|
6004
|
+
`,document.head.appendChild(t)}function YAe(t){PA=t,wg||(wg=e=>{Wy();const n=e.target,r=n==null?void 0:n.closest(as);if(!r)return;Zi=r;const i=tr.get(r)||t;Cc(r,i),tr.set(r,i),Iu(r,"togglePIIRedactionPanel",$2(r)),Iu(r,"togglePIIRealtime",Sg(r,i));const o=po.get(r);o&&(P2(o,r),i_(r,o),kg(r,o,i))},document.addEventListener("focusin",wg,!0)),xg||(xg=e=>{const n=e.target,r=n==null?void 0:n.closest(as);r&&(Zi=r,PH(r))},document.addEventListener("input",xg,!0)),Eg||(Eg=e=>{if(e.defaultPrevented)return;const n=e.target;if(n!=null&&n.closest(`.${qn} input, .${qn} textarea, .${qn} select`))return;const r=GAe(e);if(!r)return;const i=tr.get(r)||PA||t;if(Cc(r,i),tr.set(r,i),Zi=r,e.key==="Escape"&&$2(r)){e.preventDefault(),Ky(r,!0);return}if(qAe(e)){e.preventDefault(),e.stopPropagation(),RH(r);return}if(WAe(e)){e.preventDefault(),e.stopPropagation(),ss(r,i,!0),_g(r);return}if(KAe(e)){e.preventDefault(),e.stopPropagation(),qy(r)||(o_(r,i),_g(r));return}if(VAe(e)){e.preventDefault(),e.stopPropagation();const o=!Sg(r,i);rf.set(r,o);const a=po.get(r);a&&kg(r,a,i),Iu(r,"togglePIIRealtime",o),o&&ss(r,i,!0)}},document.addEventListener("keydown",Eg,!0)),of||(of=()=>{Wy(),po.forEach((e,n)=>{!n.isConnected||!e.isConnected||(P2(e,n),i_(n,e))})},window.addEventListener("scroll",of,!0),window.addEventListener("resize",of)),!Cg&&typeof MutationObserver!="undefined"&&document.body&&(Cg=new MutationObserver(e=>{LAe(e)&&Wy()}),Cg.observe(document.body,{childList:!0,subtree:!0}))}function ZAe(){wg&&(document.removeEventListener("focusin",wg,!0),wg=null),xg&&(document.removeEventListener("input",xg,!0),xg=null),Eg&&(document.removeEventListener("keydown",Eg,!0),Eg=null),of&&(window.removeEventListener("scroll",of,!0),window.removeEventListener("resize",of),of=null),Cg&&(Cg.disconnect(),Cg=null),po.forEach(t=>t.remove()),po.clear(),zy.forEach(t=>e_(t)),zy.clear(),PA=null,Zi=null}const a_=Object.freeze(Object.defineProperty({__proto__:null,PIIRedactionPlugin:(t={})=>{const e=O2(t),n=new Set;return XAe(),{name:"piiRedaction",toolbar:[{id:"piiRedactionGroup",label:"PII Redaction",type:"group",command:"piiRedaction",items:[{id:"piiRedaction",label:"PII Redaction",command:"togglePIIRedactionPanel",shortcut:"Mod-Alt-Shift-i",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'},{id:"piiScan",label:"Scan PII",command:"runPIIScan",shortcut:"Mod-Alt-Shift-u",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"piiRedactAll",label:"Redact All PII",command:"redactAllPII",shortcut:"Mod-Alt-Shift-m",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"piiRealtime",label:"Toggle Realtime PII Scan",command:"togglePIIRealtime",shortcut:"Mod-Alt-Shift-y",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'}]}],commands:{piiRedaction:(r,i)=>{const o=Fu(i);if(!o)return!1;const a=tr.get(o)||e;return Cc(o,a),tr.set(o,a),Zi=o,_g(o),ss(o,a,!1),!0},togglePIIRedactionPanel:(r,i)=>{const o=Fu(i);if(!o)return!1;const a=tr.get(o)||e;Cc(o,a),tr.set(o,a),Zi=o;const s=RH(o,typeof r=="boolean"?r:void 0);return $2(o)&&ss(o,a,!1),s},runPIIScan:async(r,i)=>{const o=Fu(i);if(!o)return!1;const a=tr.get(o)||e;return Cc(o,a),tr.set(o,a),Zi=o,await ss(o,a,!0),_g(o),!0},redactAllPII:async(r,i)=>{const o=Fu(i);if(!o)return!1;const a=tr.get(o)||e;Cc(o,a),tr.set(o,a),Zi=o;const s=await o_(o,a);return s>0&&_g(o),s>0},redactPIIFinding:async(r,i)=>{const o=Fu(i);if(!o||typeof r!="string"||!r)return!1;const a=tr.get(o)||e;return Cc(o,a),tr.set(o,a),Zi=o,MH(o,r,a)},togglePIIRealtime:(r,i)=>{const o=Fu(i);if(!o)return!1;const a=tr.get(o)||e;Cc(o,a),tr.set(o,a);const s=typeof r=="boolean"?r:!Sg(o,a);rf.set(o,s);const c=po.get(o);return c&&kg(o,c,a),Iu(o,"togglePIIRealtime",s),s&&ss(o,a,!0),!0},getPIIRedactionFindings:(r,i)=>{const o=Fu(i);if(!o)return!1;const a=Dl.get(o)||[],s=Ec.get(o)||Q2(0),c=a.map(u=>({...u})),l={...s,byType:{...s.byType}};if(typeof r=="function")try{r(c,l)}catch(u){}return o.__piiRedactionFindings=c,o.dispatchEvent(new CustomEvent("editora:pii-findings",{bubbles:!0,detail:{findings:c,stats:l}})),!0},setPIIRedactionOptions:(r,i)=>{const o=Fu(i);if(!o||!r||typeof r!="object")return!1;const a=tr.get(o)||e,s=O2({...Z5(a),...r,labels:{...a.labels,...r.labels||{}},detectors:{...Z5(a).detectors||{},...r.detectors||{}},normalizeText:r.normalizeText||a.normalizeText});tr.set(o,s),typeof r.enableRealtime=="boolean"&&rf.set(o,r.enableRealtime);const c=po.get(o);return c&&(PAe(c,s),Bg(o),kg(o,c,s)),ss(o,s,!0),!0}},keymap:{"Mod-Alt-Shift-i":"togglePIIRedactionPanel","Mod-Alt-Shift-I":"togglePIIRedactionPanel","Mod-Alt-Shift-u":"runPIIScan","Mod-Alt-Shift-U":"runPIIScan","Mod-Alt-Shift-m":"redactAllPII","Mod-Alt-Shift-M":"redactAllPII","Mod-Alt-Shift-y":"togglePIIRealtime","Mod-Alt-Shift-Y":"togglePIIRealtime"},init:function(i){U2+=1;const o=this&&typeof this.__pluginConfig=="object"?O2({...Z5(e),...this.__pluginConfig}):e;YAe(o);const a=Fu(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1);a&&(Zi=a,n.add(a),Cc(a,o),tr.set(a,o),Iu(a,"togglePIIRedactionPanel",!1),Iu(a,"togglePIIRealtime",o.enableRealtime),o.enableRealtime&&PH(a))},destroy:()=>{n.forEach(r=>SH(r)),n.clear(),U2=Math.max(0,U2-1),!(U2>0)&&(jy.forEach(r=>{window.clearTimeout(r)}),jy.clear(),ZAe())}}}},Symbol.toStringTag,{value:"Module"})),Hs=".rte-content, .editora-content",s_="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",HH="__editoraCommandEditorRoot",QH="rte-smart-paste-styles",cr="rte-smart-paste-panel",Qs="smart-paste",Ll="smartPaste",Fl=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',JAe=typeof NodeFilter!="undefined"?NodeFilter.SHOW_COMMENT:128,$H="__editoraSmartPasteHandled",ehe=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),the=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),nhe=new Set(["span","font"]),rhe=/^(https?:|mailto:|tel:|#|\/)/i,ihe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,ohe=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),ahe={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},c_={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},nr=new WeakMap,Dg=new WeakMap,cs=new Map,Vy=new WeakMap,q2=new WeakMap,Gy=new Set;let W2=0,she=0,Lg=null,da=null,Fg=null,Ig=null,af=null,Ug=null;function l_(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function che(t){return t.replace(/\u00A0/g," ").replace(/\r\n?/g,`
|
|
6005
|
+
`)}function Xy(t){return t==="balanced"||t==="plain"?t:"fidelity"}function u_(t,e){var n,r,i,o;return{keepStyles:(n=t==null?void 0:t.keepStyles)!=null?n:e.keepStyles,keepClasses:(r=t==null?void 0:t.keepClasses)!=null?r:e.keepClasses,keepDataAttributes:(i=t==null?void 0:t.keepDataAttributes)!=null?i:e.keepDataAttributes,preserveTables:(o=t==null?void 0:t.preserveTables)!=null?o:e.preserveTables}}function K2(t={}){var n;const e=t.profileOptions||{};return{enabled:t.enabled!==!1,defaultProfile:Xy(t.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number((n=t.maxHtmlLength)!=null?n:22e4))),removeComments:t.removeComments!==!1,normalizeWhitespace:t.normalizeWhitespace!==!1,labels:{...ahe,...t.labels||{}},normalizeText:t.normalizeText||che,profileOptions:{fidelity:u_(e.fidelity,c_.fidelity),balanced:u_(e.balanced,c_.balanced),plain:u_(e.plain,c_.plain)}}}function zH(t){return{enabled:t.enabled,defaultProfile:t.defaultProfile,maxHtmlLength:t.maxHtmlLength,removeComments:t.removeComments,normalizeWhitespace:t.normalizeWhitespace,labels:{...t.labels},normalizeText:t.normalizeText,profileOptions:{fidelity:{...t.profileOptions.fidelity},balanced:{...t.profileOptions.balanced},plain:{...t.profileOptions.plain}}}}function d_(t){return t.closest(s_)||t}function Yy(t){if(!t)return null;if(t.matches(Hs))return t;const e=t.querySelector(Hs);return e instanceof HTMLElement?e:null}function lhe(){if(typeof window=="undefined")return null;const t=window[HH];if(!(t instanceof HTMLElement))return null;window[HH]=null;const e=Yy(t);if(e)return e;const n=t.closest(s_);if(n){const i=Yy(n);if(i)return i}const r=t.closest(Hs);return r instanceof HTMLElement?r:null}function uhe(t){const e=t.closest("[data-editora-editor]");if(e&&Yy(e)===t)return e;let n=t;for(;n;){if(n.matches(s_)&&(n===t||Yy(n)===t))return n;n=n.parentElement}return d_(t)}function jH(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function sf(t,e=!0,n=!0){if(X2(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const a=Yy(t.editorElement);if(a)return a}const r=lhe();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const a=jH(i.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(Hs);if(s)return s}const o=document.activeElement;if(o){if(o.matches(Hs))return o;const a=o.closest(Hs);if(a)return a}if(n){if(da&&da.isConnected)return da;da&&!da.isConnected&&(da=null)}return e?document.querySelector(Hs):null}function dhe(t){const e=t.target;if(e){const r=e.closest(Hs);if(r)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const r=jH(n.getRangeAt(0).startContainer),i=r==null?void 0:r.closest(Hs);if(i)return i}return null}function V2(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function fhe(t){const e=d_(t);if(V2(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return V2(n)?!0:V2(document.documentElement)||V2(document.body)}function G2(t,e){t.classList.remove("rte-smart-paste-theme-dark"),fhe(e)&&t.classList.add("rte-smart-paste-theme-dark")}function qH(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function Zy(t,e,n){const r=uhe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function Oo(t,e){nr.has(t)||nr.set(t,e);let n=Dg.get(t);return n||(n={enabled:e.enabled,profile:e.defaultProfile,lastReport:null},Dg.set(t,n)),Fhe(t),Gy.add(t),n}function WH(t){const e=q2.get(t);e&&(t.removeEventListener("paste",e,!0),q2.delete(t))}function KH(t){var e;WH(t),(e=cs.get(t))==null||e.remove(),cs.delete(t),Vy.delete(t),nr.delete(t),Dg.delete(t),Gy.delete(t),da===t&&(da=null)}function X2(){Array.from(Gy).forEach(e=>{e.isConnected||KH(e)})}function Ahe(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,Hs)||(n=l.matches)!=null&&n.call(l,`.${cr}`)||(r=l.querySelector)!=null&&r.call(l,Hs)||(i=l.querySelector)!=null&&i.call(l,`.${cr}`))return!0}}return!1}function f_(t){return Vy.get(t)===!0}function Jy(t,e){const n=t.querySelector(".rte-smart-paste-live");n&&(n.textContent=e)}function A_(t,e){const n=e.normalizeText(t);return e.normalizeWhitespace?n.split(`
|
|
6005
6006
|
`).map(i=>i.replace(/[\t ]+/g," ").trimEnd()).join(`
|
|
6006
6007
|
`).replace(/\n{3,}/g,`
|
|
6007
6008
|
|
|
6008
|
-
`).trim():n}function hhe(t){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(t)}function phe(t){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(t)}function ghe(t,e){return t?hhe(t)?"word":phe(t)?"google-docs":"html":e?"plain":"html"}function mhe(t){return t.split(/\s+/).map(n=>n.trim()).filter(Boolean).filter(n=>!/^mso/i.test(n)).filter(n=>!/^docs-/i.test(n)).filter(n=>!/^c\d+$/i.test(n)).join(" ")}function bhe(t){if(!t)return{value:"",changed:!1};const e=t.split(";"),n=[];let r=!1;return e.forEach(i=>{const o=i.indexOf(":");if(o<=0){i.trim()&&(r=!0);return}const a=i.slice(0,o).trim().toLowerCase(),s=i.slice(o+1).trim();if(!a||!s){r=!0;return}if(!ohe.has(a)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(s)){r=!0;return}n.push(`${a}: ${s}`)}),{value:n.join("; "),changed:r}}function V9(t){const e=t.trim();return e&&(rhe.test(e)||ihe.test(e))?e:""}function G9(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function yhe(t,e,n,r){const i=t.tagName.toLowerCase();if(ehe.has(i)){r.removedElements+=1,t.remove();return}if(!e.preserveTables&&the.has(i)){const a=t.textContent||"",s=document.createTextNode(a);t.replaceWith(s),r.removedElements+=1;return}if(Array.from(t.attributes).forEach(a=>{const s=a.name.toLowerCase(),c=a.value;if(s.startsWith("on")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="style"){if(!e.keepStyles){t.removeAttribute(a.name),r.removedAttributes+=1;return}const l=bhe(c);if(!l.value){t.removeAttribute(a.name),r.removedAttributes+=1,l.changed&&(r.normalizedStyles+=1);return}(l.changed||l.value!==c)&&(t.setAttribute("style",l.value),r.normalizedStyles+=1);return}if(s==="class"){if(!e.keepClasses){t.removeAttribute(a.name),r.removedAttributes+=1;return}const l=mhe(c);if(!l){t.removeAttribute(a.name),r.removedAttributes+=1;return}l!==c&&(t.setAttribute("class",l),r.removedAttributes+=1);return}if(s.startsWith("data-")&&!e.keepDataAttributes){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="id"||s==="xmlns"||s.startsWith("xml")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if((n==="word"||n==="google-docs")&&(s==="lang"||s==="dir")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="href"||s==="src"||s==="xlink:href"){const l=V9(c);if(!l){t.removeAttribute(a.name),r.removedAttributes+=1;return}l!==c&&t.setAttribute(a.name,l)}}),i==="a"){if(!t.getAttribute("href")){G9(t),r.removedElements+=1;return}t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer")}if(i==="img"){const a=t.getAttribute("src");if(!a||!V9(a)){r.removedElements+=1,t.remove();return}}if(nhe.has(i)&&!t.attributes.length&&!t.className&&!t.style.cssText){const a=t.children.length>0,s=(t.textContent||"").trim().length>0;if(!a&&!s){t.remove(),r.removedElements+=1;return}!a&&s&&(G9(t),r.removedElements+=1)}}const vhe=/\son\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi;function whe(t){return t.replace(vhe,"")}function xhe(t,e,n,r,i){const o=document.createElement("template");o.innerHTML=whe(t);const a={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const u=document.createTreeWalker(o.content,JAe,null),d=[];let f=u.nextNode();for(;f;)d.push(f),f=u.nextNode();d.forEach(A=>{A.remove(),a.removedComments+=1})}catch(u){}Array.from(o.content.querySelectorAll("*")).forEach(u=>{o.content.contains(u)&&yhe(u,e,n,a)});let c=o.innerHTML;r.normalizeWhitespace&&i!=="fidelity"?c=c.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(c=c.trim());const l=(o.content.textContent||"").trim().length;return{html:c,textLength:l,counters:a}}function X9(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null}function Y9(t,e){if(!t.isConnected)return;const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}function Ehe(t,e){t.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,e))return!0}catch(a){}const n=X9(t);if(!n)return!1;n.deleteContents();const r=document.createElement("template");r.innerHTML=e;const i=r.content,o=i.lastChild;if(n.insertNode(i),o){const a=document.createRange();a.setStartAfter(o),a.collapse(!0),Y9(t,a)}return!0}function Che(t,e){t.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,e))return!0}catch(o){}const n=X9(t);if(!n)return!1;n.deleteContents();const r=document.createTextNode(e);n.insertNode(r);const i=document.createRange();return i.setStart(r,r.length),i.collapse(!0),Y9(t,i),!0}function The(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function khe(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y2(t,e,n,r,i,o){return{source:t,profile:e,inputHtmlLength:n,outputHtmlLength:r,outputTextLength:i,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Bhe(t,e,n,r){const i=ghe(t,e);if(n==="plain"){const s=e||t.replace(/<[^>]*>/g," "),c=A_(s,r);return{mode:"text",value:c,report:Y2(i,n,t.length,0,c.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!t||t.length>r.maxHtmlLength){const s=A_(e||t.replace(/<[^>]*>/g," "),r);return{mode:"text",value:s,report:Y2(i,n,t.length,0,s.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[n],a=xhe(t,o,i,r,n);if(!a.html){const s=A_(e||t.replace(/<[^>]*>/g," "),r);return{mode:"text",value:s,report:Y2(i,n,t.length,0,s.length,a.counters)}}return{mode:"html",value:a.html,report:Y2(i,n,t.length,a.html.length,a.textLength,a.counters)}}function Z2(t,e){return t==="balanced"?e.balancedText:t==="plain"?e.plainText:e.fidelityText}function h_(t){return t==="fidelity"?"balanced":t==="balanced"?"plain":"fidelity"}function She(t,e){t.setAttribute("aria-label",e.labels.panelAriaLabel);const n=t.querySelector(".rte-smart-paste-title");n&&(n.textContent=e.labels.panelTitle);const r=t.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",e.labels.closeText);const i=t.querySelector('[data-action="toggle-enabled"]');if(i){const b=i.getAttribute("data-enabled")==="true";i.textContent=b?e.labels.toggleOnText:e.labels.toggleOffText}const o=t.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=e.labels.cycleProfileText);const a=t.querySelector(".rte-smart-paste-profile-heading");a&&(a.textContent=e.labels.profileLabel);const s=t.querySelector('.rte-smart-paste-profile[role="group"]');s&&s.setAttribute("aria-label",e.labels.profileLabel);const c=t.querySelector('[data-action="set-profile"][data-profile="fidelity"]');c&&(c.textContent=e.labels.fidelityText);const l=t.querySelector('[data-action="set-profile"][data-profile="balanced"]');l&&(l.textContent=e.labels.balancedText);const u=t.querySelector('[data-action="set-profile"][data-profile="plain"]');u&&(u.textContent=e.labels.plainText);const d=t.querySelector(".rte-smart-paste-report-title");d&&(d.textContent=e.labels.lastPasteHeading);const f=t.querySelector(".rte-smart-paste-empty");f&&(f.textContent=e.labels.lastPasteEmptyText);const A=t.querySelector('[data-key="source-label"]');A&&(A.textContent=e.labels.lastPasteSourceLabel);const h=t.querySelector('[data-key="profile-label"]');h&&(h.textContent=e.labels.lastPasteProfileLabel);const p=t.querySelector('[data-key="removed-label"]');p&&(p.textContent=e.labels.lastPasteRemovedLabel);const m=t.querySelector('[data-key="chars-label"]');m&&(m.textContent=e.labels.lastPasteCharsLabel);const g=t.querySelector(".rte-smart-paste-shortcut");g&&(g.textContent=e.labels.shortcutText)}function $s(t){const e=cs.get(t),n=nr.get(t)||Lg,r=Dg.get(t);if(!e||!n||!r)return;She(e,n);const i=e.querySelector(".rte-smart-paste-status");i&&(i.textContent=r.enabled?n.labels.enabledText:n.labels.disabledText);const o=e.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?n.labels.toggleOnText:n.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(e.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(A=>{const p=Xy(A.getAttribute("data-profile"))===r.profile;A.classList.toggle("active",p),A.setAttribute("aria-pressed",p?"true":"false")});const s=e.querySelector(".rte-smart-paste-empty"),c=e.querySelector(".rte-smart-paste-report"),l=e.querySelector('[data-key="source-value"]'),u=e.querySelector('[data-key="profile-value"]'),d=e.querySelector('[data-key="removed-value"]'),f=e.querySelector('[data-key="chars-value"]');if(!r.lastReport){s&&(s.hidden=!1),c&&(c.hidden=!0);return}if(s&&(s.hidden=!0),c&&(c.hidden=!1),l&&(l.textContent=r.lastReport.source),u&&(u.textContent=Z2(r.lastReport.profile,n.labels)),d){const A=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;d.textContent=String(A)}f&&(f.textContent=String(r.lastReport.outputTextLength))}function p_(t,e){if(!e.classList.contains("show"))return;const n=d_(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function e1(t,e=!1){const n=cs.get(t);n&&(n.classList.remove("show"),Vy.set(t,!1),Zy(t,"toggleSmartPastePanel",!1),e&&t.focus({preventScroll:!0}))}function _he(t){const e=cs.get(t);if(e)return e;const n=nr.get(t)||Lg||K2(),r=`rte-smart-paste-panel-${she++}`,i=document.createElement("section");return i.className=cr,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
|
|
6009
|
+
`).trim():n}function hhe(t){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(t)}function phe(t){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(t)}function ghe(t,e){return t?hhe(t)?"word":phe(t)?"google-docs":"html":e?"plain":"html"}function mhe(t){return t.split(/\s+/).map(n=>n.trim()).filter(Boolean).filter(n=>!/^mso/i.test(n)).filter(n=>!/^docs-/i.test(n)).filter(n=>!/^c\d+$/i.test(n)).join(" ")}function bhe(t){if(!t)return{value:"",changed:!1};const e=t.split(";"),n=[];let r=!1;return e.forEach(i=>{const o=i.indexOf(":");if(o<=0){i.trim()&&(r=!0);return}const a=i.slice(0,o).trim().toLowerCase(),s=i.slice(o+1).trim();if(!a||!s){r=!0;return}if(!ohe.has(a)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(s)){r=!0;return}n.push(`${a}: ${s}`)}),{value:n.join("; "),changed:r}}function VH(t){const e=t.trim();return e&&(rhe.test(e)||ihe.test(e))?e:""}function GH(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function yhe(t,e,n,r){const i=t.tagName.toLowerCase();if(ehe.has(i)){r.removedElements+=1,t.remove();return}if(!e.preserveTables&&the.has(i)){const a=t.textContent||"",s=document.createTextNode(a);t.replaceWith(s),r.removedElements+=1;return}if(Array.from(t.attributes).forEach(a=>{const s=a.name.toLowerCase(),c=a.value;if(s.startsWith("on")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="style"){if(!e.keepStyles){t.removeAttribute(a.name),r.removedAttributes+=1;return}const l=bhe(c);if(!l.value){t.removeAttribute(a.name),r.removedAttributes+=1,l.changed&&(r.normalizedStyles+=1);return}(l.changed||l.value!==c)&&(t.setAttribute("style",l.value),r.normalizedStyles+=1);return}if(s==="class"){if(!e.keepClasses){t.removeAttribute(a.name),r.removedAttributes+=1;return}const l=mhe(c);if(!l){t.removeAttribute(a.name),r.removedAttributes+=1;return}l!==c&&(t.setAttribute("class",l),r.removedAttributes+=1);return}if(s.startsWith("data-")&&!e.keepDataAttributes){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="id"||s==="xmlns"||s.startsWith("xml")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if((n==="word"||n==="google-docs")&&(s==="lang"||s==="dir")){t.removeAttribute(a.name),r.removedAttributes+=1;return}if(s==="href"||s==="src"||s==="xlink:href"){const l=VH(c);if(!l){t.removeAttribute(a.name),r.removedAttributes+=1;return}l!==c&&t.setAttribute(a.name,l)}}),i==="a"){if(!t.getAttribute("href")){GH(t),r.removedElements+=1;return}t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer")}if(i==="img"){const a=t.getAttribute("src");if(!a||!VH(a)){r.removedElements+=1,t.remove();return}}if(nhe.has(i)&&!t.attributes.length&&!t.className&&!t.style.cssText){const a=t.children.length>0,s=(t.textContent||"").trim().length>0;if(!a&&!s){t.remove(),r.removedElements+=1;return}!a&&s&&(GH(t),r.removedElements+=1)}}const vhe=/\son\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi;function whe(t){return t.replace(vhe,"")}function xhe(t,e,n,r,i){const o=document.createElement("template");o.innerHTML=whe(t);const a={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const u=document.createTreeWalker(o.content,JAe,null),d=[];let f=u.nextNode();for(;f;)d.push(f),f=u.nextNode();d.forEach(A=>{A.remove(),a.removedComments+=1})}catch(u){}Array.from(o.content.querySelectorAll("*")).forEach(u=>{o.content.contains(u)&&yhe(u,e,n,a)});let c=o.innerHTML;r.normalizeWhitespace&&i!=="fidelity"?c=c.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(c=c.trim());const l=(o.content.textContent||"").trim().length;return{html:c,textLength:l,counters:a}}function XH(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null}function YH(t,e){if(!t.isConnected)return;const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}function Ehe(t,e){t.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,e))return!0}catch(a){}const n=XH(t);if(!n)return!1;n.deleteContents();const r=document.createElement("template");r.innerHTML=e;const i=r.content,o=i.lastChild;if(n.insertNode(i),o){const a=document.createRange();a.setStartAfter(o),a.collapse(!0),YH(t,a)}return!0}function Che(t,e){t.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,e))return!0}catch(o){}const n=XH(t);if(!n)return!1;n.deleteContents();const r=document.createTextNode(e);n.insertNode(r);const i=document.createRange();return i.setStart(r,r.length),i.collapse(!0),YH(t,i),!0}function The(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function khe(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y2(t,e,n,r,i,o){return{source:t,profile:e,inputHtmlLength:n,outputHtmlLength:r,outputTextLength:i,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Bhe(t,e,n,r){const i=ghe(t,e);if(n==="plain"){const s=e||t.replace(/<[^>]*>/g," "),c=A_(s,r);return{mode:"text",value:c,report:Y2(i,n,t.length,0,c.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!t||t.length>r.maxHtmlLength){const s=A_(e||t.replace(/<[^>]*>/g," "),r);return{mode:"text",value:s,report:Y2(i,n,t.length,0,s.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[n],a=xhe(t,o,i,r,n);if(!a.html){const s=A_(e||t.replace(/<[^>]*>/g," "),r);return{mode:"text",value:s,report:Y2(i,n,t.length,0,s.length,a.counters)}}return{mode:"html",value:a.html,report:Y2(i,n,t.length,a.html.length,a.textLength,a.counters)}}function Z2(t,e){return t==="balanced"?e.balancedText:t==="plain"?e.plainText:e.fidelityText}function h_(t){return t==="fidelity"?"balanced":t==="balanced"?"plain":"fidelity"}function She(t,e){t.setAttribute("aria-label",e.labels.panelAriaLabel);const n=t.querySelector(".rte-smart-paste-title");n&&(n.textContent=e.labels.panelTitle);const r=t.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",e.labels.closeText);const i=t.querySelector('[data-action="toggle-enabled"]');if(i){const b=i.getAttribute("data-enabled")==="true";i.textContent=b?e.labels.toggleOnText:e.labels.toggleOffText}const o=t.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=e.labels.cycleProfileText);const a=t.querySelector(".rte-smart-paste-profile-heading");a&&(a.textContent=e.labels.profileLabel);const s=t.querySelector('.rte-smart-paste-profile[role="group"]');s&&s.setAttribute("aria-label",e.labels.profileLabel);const c=t.querySelector('[data-action="set-profile"][data-profile="fidelity"]');c&&(c.textContent=e.labels.fidelityText);const l=t.querySelector('[data-action="set-profile"][data-profile="balanced"]');l&&(l.textContent=e.labels.balancedText);const u=t.querySelector('[data-action="set-profile"][data-profile="plain"]');u&&(u.textContent=e.labels.plainText);const d=t.querySelector(".rte-smart-paste-report-title");d&&(d.textContent=e.labels.lastPasteHeading);const f=t.querySelector(".rte-smart-paste-empty");f&&(f.textContent=e.labels.lastPasteEmptyText);const A=t.querySelector('[data-key="source-label"]');A&&(A.textContent=e.labels.lastPasteSourceLabel);const h=t.querySelector('[data-key="profile-label"]');h&&(h.textContent=e.labels.lastPasteProfileLabel);const p=t.querySelector('[data-key="removed-label"]');p&&(p.textContent=e.labels.lastPasteRemovedLabel);const m=t.querySelector('[data-key="chars-label"]');m&&(m.textContent=e.labels.lastPasteCharsLabel);const g=t.querySelector(".rte-smart-paste-shortcut");g&&(g.textContent=e.labels.shortcutText)}function $s(t){const e=cs.get(t),n=nr.get(t)||Lg,r=Dg.get(t);if(!e||!n||!r)return;She(e,n);const i=e.querySelector(".rte-smart-paste-status");i&&(i.textContent=r.enabled?n.labels.enabledText:n.labels.disabledText);const o=e.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?n.labels.toggleOnText:n.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(e.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(A=>{const p=Xy(A.getAttribute("data-profile"))===r.profile;A.classList.toggle("active",p),A.setAttribute("aria-pressed",p?"true":"false")});const s=e.querySelector(".rte-smart-paste-empty"),c=e.querySelector(".rte-smart-paste-report"),l=e.querySelector('[data-key="source-value"]'),u=e.querySelector('[data-key="profile-value"]'),d=e.querySelector('[data-key="removed-value"]'),f=e.querySelector('[data-key="chars-value"]');if(!r.lastReport){s&&(s.hidden=!1),c&&(c.hidden=!0);return}if(s&&(s.hidden=!0),c&&(c.hidden=!1),l&&(l.textContent=r.lastReport.source),u&&(u.textContent=Z2(r.lastReport.profile,n.labels)),d){const A=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;d.textContent=String(A)}f&&(f.textContent=String(r.lastReport.outputTextLength))}function p_(t,e){if(!e.classList.contains("show"))return;const n=d_(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function e1(t,e=!1){const n=cs.get(t);n&&(n.classList.remove("show"),Vy.set(t,!1),Zy(t,"toggleSmartPastePanel",!1),e&&t.focus({preventScroll:!0}))}function _he(t){const e=cs.get(t);if(e)return e;const n=nr.get(t)||Lg||K2(),r=`rte-smart-paste-panel-${she++}`,i=document.createElement("section");return i.className=cr,i.id=r,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",n.labels.panelAriaLabel),i.innerHTML=`
|
|
6009
6010
|
<header class="rte-smart-paste-header">
|
|
6010
6011
|
<h2 class="rte-smart-paste-title">${l_(n.labels.panelTitle)}</h2>
|
|
6011
6012
|
<button type="button" class="rte-smart-paste-icon-btn" data-action="close" aria-label="${l_(n.labels.closeText)}">✕</button>
|
|
@@ -6037,7 +6038,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6037
6038
|
<p class="rte-smart-paste-shortcut"></p>
|
|
6038
6039
|
</div>
|
|
6039
6040
|
<div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
|
|
6040
|
-
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action");if(c){if(c==="close"){e1(t,!0);return}if(c==="toggle-enabled"){const l=Oo(t,nr.get(t)||n);l.enabled=!l.enabled,Zy(t,"toggleSmartPasteEnabled",l.enabled),$s(t),Jy(i,l.enabled?n.labels.enabledText:n.labels.disabledText);return}if(c==="cycle-profile"){const l=Oo(t,nr.get(t)||n);l.profile=h_(l.profile),$s(t),Jy(i,`${n.labels.profileLabel}: ${Z2(l.profile,n.labels)}`);return}if(c==="set-profile"){const l=Oo(t,nr.get(t)||n);l.profile=Xy(s.getAttribute("data-profile")),$s(t),Jy(i,`${n.labels.profileLabel}: ${Z2(l.profile,n.labels)}`)}}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),e1(t,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const a=Array.from(i.querySelectorAll('[data-action="set-profile"][data-profile]'));if(a.length===0)return;const s=a.findIndex(u=>u===document.activeElement);if(s<0)return;const c=o.key==="ArrowRight"?1:-1,l=(s+c+a.length)%a.length;o.preventDefault(),a[l].focus()}),G2(i,t),document.body.appendChild(i),cs.set(t,i),Vy.set(t,!1),$s(t),i}function
|
|
6041
|
+
`,i.addEventListener("click",o=>{const a=o.target,s=a==null?void 0:a.closest("[data-action]");if(!s)return;const c=s.getAttribute("data-action");if(c){if(c==="close"){e1(t,!0);return}if(c==="toggle-enabled"){const l=Oo(t,nr.get(t)||n);l.enabled=!l.enabled,Zy(t,"toggleSmartPasteEnabled",l.enabled),$s(t),Jy(i,l.enabled?n.labels.enabledText:n.labels.disabledText);return}if(c==="cycle-profile"){const l=Oo(t,nr.get(t)||n);l.profile=h_(l.profile),$s(t),Jy(i,`${n.labels.profileLabel}: ${Z2(l.profile,n.labels)}`);return}if(c==="set-profile"){const l=Oo(t,nr.get(t)||n);l.profile=Xy(s.getAttribute("data-profile")),$s(t),Jy(i,`${n.labels.profileLabel}: ${Z2(l.profile,n.labels)}`)}}}),i.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),e1(t,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const a=Array.from(i.querySelectorAll('[data-action="set-profile"][data-profile]'));if(a.length===0)return;const s=a.findIndex(u=>u===document.activeElement);if(s<0)return;const c=o.key==="ArrowRight"?1:-1,l=(s+c+a.length)%a.length;o.preventDefault(),a[l].focus()}),G2(i,t),document.body.appendChild(i),cs.set(t,i),Vy.set(t,!1),$s(t),i}function ZH(t){const e=_he(t);cs.forEach((r,i)=>{i!==t&&e1(i,!1)}),e.classList.add("show"),Vy.set(t,!0),Zy(t,"toggleSmartPastePanel",!0),G2(e,t),p_(t,e);const n=e.querySelector('[data-action="toggle-enabled"]');n==null||n.focus()}function JH(t,e){const n=f_(t);return(typeof e=="boolean"?e:!n)?ZH(t):e1(t,!1),!0}function e9(t){return{enabled:t.enabled,profile:t.profile,lastReport:t.lastReport?{...t.lastReport}:null}}function Dhe(t,e){const n=nr.get(t)||Lg;if(!n)return!1;const r=Oo(t,n);if(!r.enabled||qH(t)){const d=cs.get(t);return d&&qH(t)&&Jy(d,n.labels.readonlyMessage),!1}const i=e.clipboardData;if(!i)return!1;const o=i.getData("text/html")||"",a=i.getData("text/plain")||"";if(!o&&!a)return!1;const s=Bhe(o,a,r.profile,n);if(!s.value)return!1;const c=t.innerHTML;if(!(s.mode==="html"?Ehe(t,s.value):Che(t,s.value)))return!1;r.lastReport={...s.report},Dg.set(t,r),The(t,c),khe(t),t.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:e9(r)})),$s(t);const u=cs.get(t);if(u){const d=s.report.removedElements+s.report.removedAttributes+s.report.removedComments+s.report.normalizedStyles;Jy(u,`${n.labels.panelTitle}: ${Z2(r.profile,n.labels)}. ${n.labels.lastPasteRemovedLabel}: ${d}.`)}return!0}function Lhe(t){return e=>{e.defaultPrevented||e[$H]===!0||(da=t,!Dhe(t,e))||(e[$H]=!0,e.preventDefault(),typeof e.stopImmediatePropagation=="function"?e.stopImmediatePropagation():e.stopPropagation())}}function Fhe(t){if(q2.has(t))return;const e=Lhe(t);t.addEventListener("paste",e,!0),q2.set(t,e)}function t1(t){const e=Dg.get(t);Zy(t,"toggleSmartPastePanel",f_(t)),Zy(t,"toggleSmartPasteEnabled",(e==null?void 0:e.enabled)===!0)}function g_(t){return typeof t.key=="string"?t.key.toLowerCase():""}function Ihe(t){const e=g_(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="s"}function Uhe(t){const e=g_(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="v"}function Nhe(t){const e=g_(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="g"}function Rhe(t){Lg=t,Fg||(Fg=e=>{X2();const n=e.target,r=n==null?void 0:n.closest(Hs);if(!r)return;const i=nr.get(r)||t;Oo(r,i),nr.set(r,i),da=r,t1(r);const o=cs.get(r);o&&(G2(o,r),p_(r,o),$s(r))},document.addEventListener("focusin",Fg,!0)),Ig||(Ig=e=>{if(e.defaultPrevented)return;const n=e.target;if(n!=null&&n.closest(`.${cr} input, .${cr} textarea, .${cr} select`))return;const r=dhe(e);if(!r)return;const i=nr.get(r)||Lg||t;if(Oo(r,i),nr.set(r,i),da=r,e.key==="Escape"&&f_(r)){e.preventDefault(),e1(r,!0);return}if(Ihe(e)){e.preventDefault(),e.stopPropagation(),JH(r);return}if(Uhe(e)){e.preventDefault(),e.stopPropagation();const o=Oo(r,i);o.profile=h_(o.profile),$s(r);return}if(Nhe(e)){e.preventDefault(),e.stopPropagation();const o=Oo(r,i);o.enabled=!o.enabled,t1(r),$s(r)}},document.addEventListener("keydown",Ig,!0)),af||(af=()=>{X2(),cs.forEach((e,n)=>{!n.isConnected||!e.isConnected||(G2(e,n),p_(n,e))})},window.addEventListener("scroll",af,!0),window.addEventListener("resize",af)),!Ug&&typeof MutationObserver!="undefined"&&document.body&&(Ug=new MutationObserver(e=>{Ahe(e)&&X2()}),Ug.observe(document.body,{childList:!0,subtree:!0}))}function Ohe(){Fg&&(document.removeEventListener("focusin",Fg,!0),Fg=null),Ig&&(document.removeEventListener("keydown",Ig,!0),Ig=null),af&&(window.removeEventListener("scroll",af,!0),window.removeEventListener("resize",af),af=null),Ug&&(Ug.disconnect(),Ug=null),cs.forEach(t=>t.remove()),cs.clear(),Gy.forEach(t=>WH(t)),Gy.clear(),Lg=null,da=null}function Mhe(){if(typeof document=="undefined"||document.getElementById(QH))return;const t=document.createElement("style");t.id=QH,t.textContent=`
|
|
6041
6042
|
.rte-toolbar-group-items.${Qs},
|
|
6042
6043
|
.editora-toolbar-group-items.${Qs},
|
|
6043
6044
|
.rte-toolbar-group-items.${Ll},
|
|
@@ -6397,7 +6398,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6397
6398
|
grid-template-columns: 1fr;
|
|
6398
6399
|
}
|
|
6399
6400
|
}
|
|
6400
|
-
`,document.head.appendChild(t)}const m_=Object.freeze(Object.defineProperty({__proto__:null,SmartPastePlugin:(t={})=>{const e=K2(t),n=new Set;return Mhe(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e;return Oo(o,a),nr.set(o,a),da=o,Z9(o),!0},toggleSmartPastePanel:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e;return Oo(o,a),nr.set(o,a),da=o,J9(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.profile=h_(s.profile),$s(o),!0},setSmartPasteProfile:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.profile=Xy(r),$s(o),!0},toggleSmartPasteEnabled:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.enabled=typeof r=="boolean"?r:!s.enabled,t1(o),$s(o),!0},setSmartPasteOptions:(r,i)=>{var u,d,f,A,h,p;const o=sf(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=nr.get(o)||e,s=z9(a),c=K2({...s,...r,labels:{...a.labels,...r.labels||{}},profileOptions:{...s.profileOptions,...r.profileOptions||{},fidelity:{...((u=s.profileOptions)==null?void 0:u.fidelity)||{},...((d=r.profileOptions)==null?void 0:d.fidelity)||{}},balanced:{...((f=s.profileOptions)==null?void 0:f.balanced)||{},...((A=r.profileOptions)==null?void 0:A.balanced)||{}},plain:{...((h=s.profileOptions)==null?void 0:h.plain)||{},...((p=r.profileOptions)==null?void 0:p.plain)||{}}},normalizeText:r.normalizeText||a.normalizeText});nr.set(o,c);const l=Oo(o,c);return typeof r.enabled=="boolean"&&(l.enabled=r.enabled),r.defaultProfile&&(l.profile=Xy(r.defaultProfile)),$s(o),t1(o),!0},getSmartPasteState:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a),c=eH(s);if(typeof r=="function")try{r(c)}catch(l){}return o.__smartPasteState=c,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(i){W2+=1;const o=this&&typeof this.__pluginConfig=="object"?K2({...z9(e),...this.__pluginConfig}):e;Rhe(o);const a=sf(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);if(!a)return;da=a,n.add(a);const s=Oo(a,o);s.enabled=o.enabled,s.profile=o.defaultProfile,nr.set(a,o),t1(a)},destroy:()=>{n.forEach(r=>K9(r)),n.clear(),W2=Math.max(0,W2-1),!(W2>0)&&Ohe()}}}},Symbol.toStringTag,{value:"Module"})),zs=".rte-content, .editora-content",b_="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",tH="__editoraCommandEditorRoot",nH="rte-blocks-library-styles",Ln="rte-blocks-library-panel",js="blocks-library",Il="blocksLibrary",Ul=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Phe=80,rH=new Set(["script","style","meta","link","object","embed","iframe"]),Hhe=/^(https?:|mailto:|tel:|#|\/)/i,Qhe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,$he={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},On=new WeakMap,J2=new WeakMap,ls=new WeakMap,cf=new WeakMap,Ng=new WeakMap,n1=new WeakMap,r1=new WeakMap,Rg=new WeakMap,Og=new WeakMap,ex=new WeakMap,Ua=new Map,i1=new WeakMap,tx=new Set;let nx=0,zhe=0,iH=0,Uu=null,go=null,Mg=null,Pg=null,lf=null,Hg=null;function mo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jhe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function qhe(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function y_(t){const e=t.trim();return e&&(Hhe.test(e)||Qhe.test(e))?e:""}function oH(t){let e=t;return rH.forEach(n=>{const r=new RegExp(`<${n}[\\s\\S]*?>[\\s\\S]*?<\\/${n}>`,"gi"),i=new RegExp(`<${n}\\b[^>]*\\/?>`,"gi");e=e.replace(r,"").replace(i,"")}),e=e.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(n,r,i,o,a)=>{const s=typeof o=="string"&&o.length>0?o:a||"",c=y_(s);if(!c)return"";const l=i.startsWith('"')?'"':"'";return` ${r}=${l}${c}${l}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(n,r,i)=>{const o=y_(i);return o?` ${r}="${o}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(n,r,i,o)=>{const a=typeof i=="string"&&i.length>0?i:o||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=r.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),e}function Whe(t){if(!t)return"";if(typeof document=="undefined")return oH(t);const e=document.createElement("template");e.innerHTML=t;const n=e.content;return!n||typeof n.querySelectorAll!="function"?oH(t):(Array.from(n.querySelectorAll("*")).forEach(i=>{const o=i.tagName.toLowerCase();if(rH.has(o)){i.remove();return}Array.from(i.attributes).forEach(s=>{const c=s.name.toLowerCase(),l=s.value;if(c.startsWith("on")){i.removeAttribute(s.name);return}if(c==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)&&i.removeAttribute(s.name);return}if(c==="href"||c==="src"||c==="xlink:href"){const u=y_(l);if(!u){i.removeAttribute(s.name);return}u!==l&&i.setAttribute(s.name,u)}})}),e.innerHTML.trim())}function rx(t){return t.trim().toLowerCase()}function Khe(t){if(!t)return"";if(typeof document=="undefined")return t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const e=document.createElement("template");e.innerHTML=t;const n=e.content;return!n||typeof n.textContent!="string"?t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():n.textContent.replace(/\s+/g," ").trim()}function aH(t,e){if(!Array.isArray(t)||t.length===0)return[];const n=new Set,r=[];return t.forEach(i=>{const o=e.normalizeText(i.label||""),a=e.sanitizeBlockHtml(i.html||"",i).trim();if(!o||!a)return;const s=e.normalizeText(i.category||"General")||"General",c=rx(s);let u=qhe(e.normalizeText(i.id||o))||`block-${iH++}`;for(;n.has(u);)u=`${u}-${iH++}`;n.add(u);const d=(i.tags||[]).map(m=>e.normalizeText(m)).filter(Boolean),f=(i.keywords||[]).map(m=>e.normalizeText(m)).filter(Boolean),A=e.normalizeText(i.description||""),h=Khe(a),p=[o,A,s,...d,...f,h].join(" ").toLowerCase();r.push({id:u,label:o,html:a,description:A,category:s,categoryKey:c,tags:d,keywords:f,previewText:h,searchBlob:p})}),r}function ix(t={}){var i,o,a,s;const e=t.normalizeText||jhe,n=t.sanitizeBlockHtml||Whe,r={blocks:[],defaultCategory:e(t.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number((i=t.maxResults)!=null?i:80))),maxRecentBlocks:Math.max(1,Math.min(20,Number((o=t.maxRecentBlocks)!=null?o:6))),debounceMs:Math.max(0,Math.min(700,Number((a=t.debounceMs)!=null?a:90))),cacheTtlMs:Math.max(0,Number((s=t.cacheTtlMs)!=null?s:6e4)),labels:{...$he,...t.labels||{}},normalizeText:e,sanitizeBlockHtml:n,getBlocks:typeof t.getBlocks=="function"?t.getBlocks:void 0};return r.blocks=aH(t.blocks,r),r}function Vhe(t){return{blocks:t.blocks.map(e=>({id:e.id,label:e.label,html:e.html,description:e.description||void 0,category:e.category||void 0,tags:e.tags.length?[...e.tags]:void 0,keywords:e.keywords.length?[...e.keywords]:void 0})),defaultCategory:t.defaultCategory,maxResults:t.maxResults,maxRecentBlocks:t.maxRecentBlocks,debounceMs:t.debounceMs,cacheTtlMs:t.cacheTtlMs,labels:{...t.labels},normalizeText:t.normalizeText,sanitizeBlockHtml:t.sanitizeBlockHtml,getBlocks:t.getBlocks}}function ox(t){return t.closest(b_)||t}function o1(t){if(!t)return null;if(t.matches(zs))return t;const e=t.querySelector(zs);return e instanceof HTMLElement?e:null}function Ghe(){if(typeof window=="undefined")return null;const t=window[tH];if(!(t instanceof HTMLElement))return null;window[tH]=null;const e=o1(t);if(e)return e;const n=t.closest(b_);if(n){const i=o1(n);if(i)return i}const r=t.closest(zs);return r instanceof HTMLElement?r:null}function Xhe(t){const e=t.closest("[data-editora-editor]");if(e&&o1(e)===t)return e;let n=t;for(;n;){if(n.matches(b_)&&(n===t||o1(n)===t))return n;n=n.parentElement}return ox(t)}function sH(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ax(){Array.from(tx).forEach(e=>{e.isConnected||v_(e)})}function Nu(t,e=!0,n=!0){if(ax(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const a=o1(t.editorElement);if(a)return a}const r=Ghe();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const a=sH(i.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(zs);if(s)return s}const o=document.activeElement;if(o){if(o.matches(zs))return o;const a=o.closest(zs);if(a)return a}if(n){if(go&&go.isConnected)return go;go&&!go.isConnected&&(go=null)}return e?document.querySelector(zs):null}function Yhe(t){const e=t.target;if(e){const r=e.closest(zs);if(r)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const r=sH(n.getRangeAt(0).startContainer),i=r==null?void 0:r.closest(zs);if(i)return i}return null}function sx(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Zhe(t){const e=ox(t);if(sx(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return sx(n)?!0:sx(document.documentElement)||sx(document.body)}function cx(t,e){t.classList.remove("rte-blocks-library-theme-dark"),Zhe(e)&&t.classList.add("rte-blocks-library-theme-dark")}function cH(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function lH(t,e,n){const r=Xhe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function uH(t,e){const n=t.querySelector(".rte-blocks-library-live");n&&(n.textContent=e)}function lx(t){const e=gH(t);if(e)try{Og.set(t,e.cloneRange())}catch(n){}}function dH(t){const e=Og.get(t);if(!e)return null;if(!t.isConnected)return Og.delete(t),null;try{const n=e.cloneRange();return t.contains(n.commonAncestorContainer)?n:(Og.delete(t),null)}catch(n){return Og.delete(t),null}}function Jhe(t){const e=dH(t);return e?(mH(t,e),!0):!1}function epe(t){if(ex.has(t))return;const e=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);t.contains(r.commonAncestorContainer)&&lx(t)};t.addEventListener("keyup",e),t.addEventListener("mouseup",e),t.addEventListener("touchend",e),ex.set(t,e)}function tpe(t){const e=ex.get(t);e&&(t.removeEventListener("keyup",e),t.removeEventListener("mouseup",e),t.removeEventListener("touchend",e),ex.delete(t))}function fa(t,e){On.has(t)||On.set(t,e),cf.has(t)||(cf.set(t,e.blocks),Ng.set(t,Date.now()));let n=ls.get(t);return n||(n={query:"",category:e.defaultCategory?rx(e.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},ls.set(t,n)),tx.add(t),epe(t),n}function fH(t){const e=ls.get(t);!e||e.debounceTimer===null||(window.clearTimeout(e.debounceTimer),e.debounceTimer=null)}function v_(t){var n;fH(t),tpe(t),Og.delete(t);const e=r1.get(t);e&&(e.abort(),r1.delete(t)),n1.delete(t),Rg.delete(t),(n=Ua.get(t))==null||n.remove(),Ua.delete(t),i1.delete(t),On.delete(t),J2.delete(t),ls.delete(t),cf.delete(t),Ng.delete(t),tx.delete(t),go===t&&(go=null)}function npe(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,zs)||(n=l.matches)!=null&&n.call(l,`.${Ln}`)||(r=l.querySelector)!=null&&r.call(l,zs)||(i=l.querySelector)!=null&&i.call(l,`.${Ln}`))return!0}}return!1}function w_(t){return i1.get(t)===!0}function x_(t,e){if(!e.classList.contains("show"))return;const n=ox(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,420),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ux(t){var e;return cf.get(t)||((e=On.get(t))==null?void 0:e.blocks)||[]}function rpe(t,e){const n=new Map;ux(t).forEach(i=>{n.has(i.categoryKey)||n.set(i.categoryKey,i.category)});const r=Array.from(n.entries()).sort((i,o)=>i[1].localeCompare(o[1])).map(([i,o])=>({value:i,label:o}));return[{value:"all",label:e.labels.allCategoriesText},...r]}function AH(t,e){const n=fa(t,e),r=ux(t),i=n.query.trim().toLowerCase(),o=n.category||"all",a=`${i}|${o}|${e.maxResults}`,s=n.filterCache.get(a);if(s){const u=new Map(r.map(f=>[f.id,f])),d=s.ids.map(f=>u.get(f)).filter(Boolean);return n.totalMatches=s.total,n.visibleMatches=d.length,d}const c=[];let l=0;for(let u=0;u<r.length;u+=1){const d=r[u];o!=="all"&&d.categoryKey!==o||i&&!d.searchBlob.includes(i)||(l+=1,c.length<e.maxResults&&c.push(d))}if(n.totalMatches=l,n.visibleMatches=c.length,n.filterCache.set(a,{ids:c.map(u=>u.id),total:l}),n.filterCache.size>Phe){const u=n.filterCache.keys().next().value;typeof u=="string"&&n.filterCache.delete(u)}return c}function ipe(t,e){const n=ls.get(t);if(!n)return;if(e.length===0){n.selectedBlockId=null;return}e.some(i=>i.id===n.selectedBlockId)||(n.selectedBlockId=e[0].id)}function Qg(t){const e=ls.get(t);lH(t,"toggleBlocksLibraryPanel",w_(t)),lH(t,"insertLastBlockSnippet",!!(e!=null&&e.lastInsertedBlockId))}function Tc(t){const e=Ua.get(t),n=On.get(t)||Uu,r=ls.get(t);if(!e||!n||!r)return;cx(e,t);const i=e.querySelector(".rte-blocks-library-title");i&&(i.textContent=n.labels.panelTitle);const o=e.querySelector('[data-action="close"]');o&&(o.setAttribute("aria-label",n.labels.closeText),o.textContent="✕");const a=e.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=n.labels.searchLabel);const s=e.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",n.labels.searchPlaceholder),s.value!==r.query&&(s.value=r.query));const c=e.querySelector(".rte-blocks-library-category-label");c&&(c.textContent=n.labels.categoryLabel);const l=e.querySelector('[data-field="category"]');if(l){const y=rpe(t,n);l.innerHTML=y.map(w=>`<option value="${mo(w.value)}">${mo(w.label)}</option>`).join(""),y.some(w=>w.value===r.category)||(r.category="all"),l.value=r.category}const u=e.querySelector(".rte-blocks-library-helper");u&&(u.textContent=n.labels.helperText);const d=e.querySelector('.rte-blocks-library-list[role="listbox"]');d&&d.setAttribute("aria-label",n.labels.resultsListLabel);const f=e.querySelector(".rte-blocks-library-shortcut");f&&(f.textContent=n.labels.shortcutText);const A=e.querySelector('[data-action="insert-selected"]');if(A){A.textContent=n.labels.insertText;const y=!cH(t)&&!!r.selectedBlockId;A.disabled=!y,A.setAttribute("aria-disabled",y?"false":"true")}const h=e.querySelector(".rte-blocks-library-empty"),p=e.querySelector(".rte-blocks-library-list"),m=AH(t,n);ipe(t,m);const g=e.querySelector(".rte-blocks-library-status");if(g&&(r.loading?g.textContent=n.labels.loadingText:r.loadError?g.textContent=r.loadError:g.textContent=`${n.labels.summaryPrefix}: ${r.visibleMatches}/${r.totalMatches}`),p){const y=new Set(r.recentBlockIds);p.innerHTML=m.map(w=>{const x=r.selectedBlockId===w.id,k=w.tags.length?` • ${w.tags.join(", ")}`:"",T=y.has(w.id),_=w.previewText.slice(0,180);return`
|
|
6401
|
+
`,document.head.appendChild(t)}const m_=Object.freeze(Object.defineProperty({__proto__:null,SmartPastePlugin:(t={})=>{const e=K2(t),n=new Set;return Mhe(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e;return Oo(o,a),nr.set(o,a),da=o,ZH(o),!0},toggleSmartPastePanel:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e;return Oo(o,a),nr.set(o,a),da=o,JH(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.profile=h_(s.profile),$s(o),!0},setSmartPasteProfile:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.profile=Xy(r),$s(o),!0},toggleSmartPasteEnabled:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a);return nr.set(o,a),s.enabled=typeof r=="boolean"?r:!s.enabled,t1(o),$s(o),!0},setSmartPasteOptions:(r,i)=>{var u,d,f,A,h,p;const o=sf(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=nr.get(o)||e,s=zH(a),c=K2({...s,...r,labels:{...a.labels,...r.labels||{}},profileOptions:{...s.profileOptions,...r.profileOptions||{},fidelity:{...((u=s.profileOptions)==null?void 0:u.fidelity)||{},...((d=r.profileOptions)==null?void 0:d.fidelity)||{}},balanced:{...((f=s.profileOptions)==null?void 0:f.balanced)||{},...((A=r.profileOptions)==null?void 0:A.balanced)||{}},plain:{...((h=s.profileOptions)==null?void 0:h.plain)||{},...((p=r.profileOptions)==null?void 0:p.plain)||{}}},normalizeText:r.normalizeText||a.normalizeText});nr.set(o,c);const l=Oo(o,c);return typeof r.enabled=="boolean"&&(l.enabled=r.enabled),r.defaultProfile&&(l.profile=Xy(r.defaultProfile)),$s(o),t1(o),!0},getSmartPasteState:(r,i)=>{const o=sf(i,!1,!1);if(!o)return!1;const a=nr.get(o)||e,s=Oo(o,a),c=e9(s);if(typeof r=="function")try{r(c)}catch(l){}return o.__smartPasteState=c,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(i){W2+=1;const o=this&&typeof this.__pluginConfig=="object"?K2({...zH(e),...this.__pluginConfig}):e;Rhe(o);const a=sf(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);if(!a)return;da=a,n.add(a);const s=Oo(a,o);s.enabled=o.enabled,s.profile=o.defaultProfile,nr.set(a,o),t1(a)},destroy:()=>{n.forEach(r=>KH(r)),n.clear(),W2=Math.max(0,W2-1),!(W2>0)&&Ohe()}}}},Symbol.toStringTag,{value:"Module"})),zs=".rte-content, .editora-content",b_="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",t9="__editoraCommandEditorRoot",n9="rte-blocks-library-styles",Ln="rte-blocks-library-panel",js="blocks-library",Il="blocksLibrary",Ul=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Phe=80,r9=new Set(["script","style","meta","link","object","embed","iframe"]),Hhe=/^(https?:|mailto:|tel:|#|\/)/i,Qhe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,$he={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},On=new WeakMap,J2=new WeakMap,ls=new WeakMap,cf=new WeakMap,Ng=new WeakMap,n1=new WeakMap,r1=new WeakMap,Rg=new WeakMap,Og=new WeakMap,ex=new WeakMap,Ua=new Map,i1=new WeakMap,tx=new Set;let nx=0,zhe=0,i9=0,Uu=null,go=null,Mg=null,Pg=null,lf=null,Hg=null;function mo(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jhe(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function qhe(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function y_(t){const e=t.trim();return e&&(Hhe.test(e)||Qhe.test(e))?e:""}function o9(t){let e=t;return r9.forEach(n=>{const r=new RegExp(`<${n}[\\s\\S]*?>[\\s\\S]*?<\\/${n}>`,"gi"),i=new RegExp(`<${n}\\b[^>]*\\/?>`,"gi");e=e.replace(r,"").replace(i,"")}),e=e.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(n,r,i,o,a)=>{const s=typeof o=="string"&&o.length>0?o:a||"",c=y_(s);if(!c)return"";const l=i.startsWith('"')?'"':"'";return` ${r}=${l}${c}${l}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(n,r,i)=>{const o=y_(i);return o?` ${r}="${o}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(n,r,i,o)=>{const a=typeof i=="string"&&i.length>0?i:o||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=r.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),e}function Whe(t){if(!t)return"";if(typeof document=="undefined")return o9(t);const e=document.createElement("template");e.innerHTML=t;const n=e.content;return!n||typeof n.querySelectorAll!="function"?o9(t):(Array.from(n.querySelectorAll("*")).forEach(i=>{const o=i.tagName.toLowerCase();if(r9.has(o)){i.remove();return}Array.from(i.attributes).forEach(s=>{const c=s.name.toLowerCase(),l=s.value;if(c.startsWith("on")){i.removeAttribute(s.name);return}if(c==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)&&i.removeAttribute(s.name);return}if(c==="href"||c==="src"||c==="xlink:href"){const u=y_(l);if(!u){i.removeAttribute(s.name);return}u!==l&&i.setAttribute(s.name,u)}})}),e.innerHTML.trim())}function rx(t){return t.trim().toLowerCase()}function Khe(t){if(!t)return"";if(typeof document=="undefined")return t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const e=document.createElement("template");e.innerHTML=t;const n=e.content;return!n||typeof n.textContent!="string"?t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():n.textContent.replace(/\s+/g," ").trim()}function a9(t,e){if(!Array.isArray(t)||t.length===0)return[];const n=new Set,r=[];return t.forEach(i=>{const o=e.normalizeText(i.label||""),a=e.sanitizeBlockHtml(i.html||"",i).trim();if(!o||!a)return;const s=e.normalizeText(i.category||"General")||"General",c=rx(s);let u=qhe(e.normalizeText(i.id||o))||`block-${i9++}`;for(;n.has(u);)u=`${u}-${i9++}`;n.add(u);const d=(i.tags||[]).map(m=>e.normalizeText(m)).filter(Boolean),f=(i.keywords||[]).map(m=>e.normalizeText(m)).filter(Boolean),A=e.normalizeText(i.description||""),h=Khe(a),p=[o,A,s,...d,...f,h].join(" ").toLowerCase();r.push({id:u,label:o,html:a,description:A,category:s,categoryKey:c,tags:d,keywords:f,previewText:h,searchBlob:p})}),r}function ix(t={}){var i,o,a,s;const e=t.normalizeText||jhe,n=t.sanitizeBlockHtml||Whe,r={blocks:[],defaultCategory:e(t.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number((i=t.maxResults)!=null?i:80))),maxRecentBlocks:Math.max(1,Math.min(20,Number((o=t.maxRecentBlocks)!=null?o:6))),debounceMs:Math.max(0,Math.min(700,Number((a=t.debounceMs)!=null?a:90))),cacheTtlMs:Math.max(0,Number((s=t.cacheTtlMs)!=null?s:6e4)),labels:{...$he,...t.labels||{}},normalizeText:e,sanitizeBlockHtml:n,getBlocks:typeof t.getBlocks=="function"?t.getBlocks:void 0};return r.blocks=a9(t.blocks,r),r}function Vhe(t){return{blocks:t.blocks.map(e=>({id:e.id,label:e.label,html:e.html,description:e.description||void 0,category:e.category||void 0,tags:e.tags.length?[...e.tags]:void 0,keywords:e.keywords.length?[...e.keywords]:void 0})),defaultCategory:t.defaultCategory,maxResults:t.maxResults,maxRecentBlocks:t.maxRecentBlocks,debounceMs:t.debounceMs,cacheTtlMs:t.cacheTtlMs,labels:{...t.labels},normalizeText:t.normalizeText,sanitizeBlockHtml:t.sanitizeBlockHtml,getBlocks:t.getBlocks}}function ox(t){return t.closest(b_)||t}function o1(t){if(!t)return null;if(t.matches(zs))return t;const e=t.querySelector(zs);return e instanceof HTMLElement?e:null}function Ghe(){if(typeof window=="undefined")return null;const t=window[t9];if(!(t instanceof HTMLElement))return null;window[t9]=null;const e=o1(t);if(e)return e;const n=t.closest(b_);if(n){const i=o1(n);if(i)return i}const r=t.closest(zs);return r instanceof HTMLElement?r:null}function Xhe(t){const e=t.closest("[data-editora-editor]");if(e&&o1(e)===t)return e;let n=t;for(;n;){if(n.matches(b_)&&(n===t||o1(n)===t))return n;n=n.parentElement}return ox(t)}function s9(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ax(){Array.from(tx).forEach(e=>{e.isConnected||v_(e)})}function Nu(t,e=!0,n=!0){if(ax(),(t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const a=o1(t.editorElement);if(a)return a}const r=Ghe();if(r)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const a=s9(i.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(zs);if(s)return s}const o=document.activeElement;if(o){if(o.matches(zs))return o;const a=o.closest(zs);if(a)return a}if(n){if(go&&go.isConnected)return go;go&&!go.isConnected&&(go=null)}return e?document.querySelector(zs):null}function Yhe(t){const e=t.target;if(e){const r=e.closest(zs);if(r)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const r=s9(n.getRangeAt(0).startContainer),i=r==null?void 0:r.closest(zs);if(i)return i}return null}function sx(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Zhe(t){const e=ox(t);if(sx(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return sx(n)?!0:sx(document.documentElement)||sx(document.body)}function cx(t,e){t.classList.remove("rte-blocks-library-theme-dark"),Zhe(e)&&t.classList.add("rte-blocks-library-theme-dark")}function c9(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function l9(t,e,n){const r=Xhe(t);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function u9(t,e){const n=t.querySelector(".rte-blocks-library-live");n&&(n.textContent=e)}function lx(t){const e=g9(t);if(e)try{Og.set(t,e.cloneRange())}catch(n){}}function d9(t){const e=Og.get(t);if(!e)return null;if(!t.isConnected)return Og.delete(t),null;try{const n=e.cloneRange();return t.contains(n.commonAncestorContainer)?n:(Og.delete(t),null)}catch(n){return Og.delete(t),null}}function Jhe(t){const e=d9(t);return e?(m9(t,e),!0):!1}function epe(t){if(ex.has(t))return;const e=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);t.contains(r.commonAncestorContainer)&&lx(t)};t.addEventListener("keyup",e),t.addEventListener("mouseup",e),t.addEventListener("touchend",e),ex.set(t,e)}function tpe(t){const e=ex.get(t);e&&(t.removeEventListener("keyup",e),t.removeEventListener("mouseup",e),t.removeEventListener("touchend",e),ex.delete(t))}function fa(t,e){On.has(t)||On.set(t,e),cf.has(t)||(cf.set(t,e.blocks),Ng.set(t,Date.now()));let n=ls.get(t);return n||(n={query:"",category:e.defaultCategory?rx(e.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},ls.set(t,n)),tx.add(t),epe(t),n}function f9(t){const e=ls.get(t);!e||e.debounceTimer===null||(window.clearTimeout(e.debounceTimer),e.debounceTimer=null)}function v_(t){var n;f9(t),tpe(t),Og.delete(t);const e=r1.get(t);e&&(e.abort(),r1.delete(t)),n1.delete(t),Rg.delete(t),(n=Ua.get(t))==null||n.remove(),Ua.delete(t),i1.delete(t),On.delete(t),J2.delete(t),ls.delete(t),cf.delete(t),Ng.delete(t),tx.delete(t),go===t&&(go=null)}function npe(t){var e,n,r,i;for(let o=0;o<t.length;o+=1){const a=t[o];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const c=a.removedNodes[s];if(c.nodeType!==Node.ELEMENT_NODE)continue;const l=c;if((e=l.matches)!=null&&e.call(l,zs)||(n=l.matches)!=null&&n.call(l,`.${Ln}`)||(r=l.querySelector)!=null&&r.call(l,zs)||(i=l.querySelector)!=null&&i.call(l,`.${Ln}`))return!0}}return!1}function w_(t){return i1.get(t)===!0}function x_(t,e){if(!e.classList.contains("show"))return;const n=ox(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,420),i=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,n.right-r),i),a=Math.max(10,Math.min(window.innerHeight-10,n.top+12));e.style.width=`${r}px`,e.style.left=`${o}px`,e.style.top=`${a}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ux(t){var e;return cf.get(t)||((e=On.get(t))==null?void 0:e.blocks)||[]}function rpe(t,e){const n=new Map;ux(t).forEach(i=>{n.has(i.categoryKey)||n.set(i.categoryKey,i.category)});const r=Array.from(n.entries()).sort((i,o)=>i[1].localeCompare(o[1])).map(([i,o])=>({value:i,label:o}));return[{value:"all",label:e.labels.allCategoriesText},...r]}function A9(t,e){const n=fa(t,e),r=ux(t),i=n.query.trim().toLowerCase(),o=n.category||"all",a=`${i}|${o}|${e.maxResults}`,s=n.filterCache.get(a);if(s){const u=new Map(r.map(f=>[f.id,f])),d=s.ids.map(f=>u.get(f)).filter(Boolean);return n.totalMatches=s.total,n.visibleMatches=d.length,d}const c=[];let l=0;for(let u=0;u<r.length;u+=1){const d=r[u];o!=="all"&&d.categoryKey!==o||i&&!d.searchBlob.includes(i)||(l+=1,c.length<e.maxResults&&c.push(d))}if(n.totalMatches=l,n.visibleMatches=c.length,n.filterCache.set(a,{ids:c.map(u=>u.id),total:l}),n.filterCache.size>Phe){const u=n.filterCache.keys().next().value;typeof u=="string"&&n.filterCache.delete(u)}return c}function ipe(t,e){const n=ls.get(t);if(!n)return;if(e.length===0){n.selectedBlockId=null;return}e.some(i=>i.id===n.selectedBlockId)||(n.selectedBlockId=e[0].id)}function Qg(t){const e=ls.get(t);l9(t,"toggleBlocksLibraryPanel",w_(t)),l9(t,"insertLastBlockSnippet",!!(e!=null&&e.lastInsertedBlockId))}function Tc(t){const e=Ua.get(t),n=On.get(t)||Uu,r=ls.get(t);if(!e||!n||!r)return;cx(e,t);const i=e.querySelector(".rte-blocks-library-title");i&&(i.textContent=n.labels.panelTitle);const o=e.querySelector('[data-action="close"]');o&&(o.setAttribute("aria-label",n.labels.closeText),o.textContent="✕");const a=e.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=n.labels.searchLabel);const s=e.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",n.labels.searchPlaceholder),s.value!==r.query&&(s.value=r.query));const c=e.querySelector(".rte-blocks-library-category-label");c&&(c.textContent=n.labels.categoryLabel);const l=e.querySelector('[data-field="category"]');if(l){const y=rpe(t,n);l.innerHTML=y.map(w=>`<option value="${mo(w.value)}">${mo(w.label)}</option>`).join(""),y.some(w=>w.value===r.category)||(r.category="all"),l.value=r.category}const u=e.querySelector(".rte-blocks-library-helper");u&&(u.textContent=n.labels.helperText);const d=e.querySelector('.rte-blocks-library-list[role="listbox"]');d&&d.setAttribute("aria-label",n.labels.resultsListLabel);const f=e.querySelector(".rte-blocks-library-shortcut");f&&(f.textContent=n.labels.shortcutText);const A=e.querySelector('[data-action="insert-selected"]');if(A){A.textContent=n.labels.insertText;const y=!c9(t)&&!!r.selectedBlockId;A.disabled=!y,A.setAttribute("aria-disabled",y?"false":"true")}const h=e.querySelector(".rte-blocks-library-empty"),p=e.querySelector(".rte-blocks-library-list"),m=A9(t,n);ipe(t,m);const g=e.querySelector(".rte-blocks-library-status");if(g&&(r.loading?g.textContent=n.labels.loadingText:r.loadError?g.textContent=r.loadError:g.textContent=`${n.labels.summaryPrefix}: ${r.visibleMatches}/${r.totalMatches}`),p){const y=new Set(r.recentBlockIds);p.innerHTML=m.map(w=>{const x=r.selectedBlockId===w.id,k=w.tags.length?` • ${w.tags.join(", ")}`:"",T=y.has(w.id),_=w.previewText.slice(0,180);return`
|
|
6401
6402
|
<li class="rte-blocks-library-item-wrapper" role="presentation">
|
|
6402
6403
|
<button
|
|
6403
6404
|
type="button"
|
|
@@ -6417,7 +6418,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6417
6418
|
${_?`<span class="rte-blocks-library-item-preview">${mo(_)}</span>`:""}
|
|
6418
6419
|
</button>
|
|
6419
6420
|
</li>
|
|
6420
|
-
`}).join("")}h&&(h.hidden=m.length>0,h.textContent=n.labels.noResultsText);const b=e.querySelector(".rte-blocks-library-last-inserted");if(b)if(r.lastInsertedBlockId){const y=ux(t).find(w=>w.id===r.lastInsertedBlockId);y?(b.hidden=!1,b.textContent=`${n.labels.lastInsertedPrefix}: ${y.label}`):b.hidden=!0}else b.hidden=!0;e.setAttribute("aria-label",n.labels.panelAriaLabel)}function Ru(t,e=!1){const n=Ua.get(t);n&&(n.classList.remove("show"),i1.set(t,!1),Qg(t),e&&(t.focus({preventScroll:!0}),Jhe(t)))}function ope(t){const e=t.querySelector(".rte-blocks-library-item.active");e==null||e.focus()}function
|
|
6421
|
+
`}).join("")}h&&(h.hidden=m.length>0,h.textContent=n.labels.noResultsText);const b=e.querySelector(".rte-blocks-library-last-inserted");if(b)if(r.lastInsertedBlockId){const y=ux(t).find(w=>w.id===r.lastInsertedBlockId);y?(b.hidden=!1,b.textContent=`${n.labels.lastInsertedPrefix}: ${y.label}`):b.hidden=!0}else b.hidden=!0;e.setAttribute("aria-label",n.labels.panelAriaLabel)}function Ru(t,e=!1){const n=Ua.get(t);n&&(n.classList.remove("show"),i1.set(t,!1),Qg(t),e&&(t.focus({preventScroll:!0}),Jhe(t)))}function ope(t){const e=t.querySelector(".rte-blocks-library-item.active");e==null||e.focus()}function h9(t,e){const n=On.get(t)||Uu;if(!n)return;const r=ls.get(t);if(!r)return;const i=A9(t,n);if(i.length===0)return;const a=(Math.max(0,i.findIndex(c=>c.id===r.selectedBlockId))+e+i.length)%i.length;r.selectedBlockId=i[a].id,Tc(t);const s=Ua.get(t);s&&ope(s)}function E_(t){const e=dpe(t);lx(t),Ua.forEach((r,i)=>{i!==t&&Ru(i,!1)}),e.classList.add("show"),i1.set(t,!0),Tc(t),x_(t,e),Qg(t);const n=e.querySelector('[data-field="query"]');n==null||n.focus(),C_(t,!1)}function p9(t,e){const n=w_(t);return(typeof e=="boolean"?e:!n)?E_(t):Ru(t,!1),!0}function g9(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n:null}function m9(t,e){if(!t.isConnected)return;const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}const ape=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function b9(t,e){let n=t;for(;n&&n!==e;){if(n.nodeType===Node.ELEMENT_NODE&&ape.has(n.tagName))return n;n=n.parentNode}return null}function y9(t,e,n){const r=e.cloneRange();if(!t.contains(r.commonAncestorContainer))return!1;r.deleteContents();const i=document.createElement("template");i.innerHTML=n;const o=i.content;if(!o)return!1;const a=o.lastChild,s=b9(r.endContainer,t)||b9(r.startContainer,t);if(s&&s.parentNode?s.parentNode.insertBefore(o,s.nextSibling):r.insertNode(o),a){const c=document.createRange();c.setStartAfter(a),c.collapse(!0),m9(t,c)}return lx(t),!0}function spe(t,e){t.focus({preventScroll:!0});const n=d9(t);if(n&&y9(t,n,e))return!0;try{if(document.execCommand("insertHTML",!1,e))return lx(t),!0}catch(i){}const r=g9(t);return r?y9(t,r,e):!1}function cpe(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function lpe(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function a1(t,e){const n=On.get(t)||Uu;if(!n)return!1;const r=fa(t,n),i=Ua.get(t);if(c9(t))return i&&u9(i,n.labels.readonlyMessage),!1;const o=ux(t).find(c=>c.id===e);if(!o)return!1;const a=t.innerHTML;return spe(t,o.html)?(r.lastInsertedBlockId=o.id,r.selectedBlockId=o.id,r.recentBlockIds=[o.id,...r.recentBlockIds.filter(c=>c!==o.id)].slice(0,n.maxRecentBlocks),cpe(t,a),lpe(t),Qg(t),t.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:o.id,label:o.label,category:o.category}})),Tc(t),i&&u9(i,`${n.labels.lastInsertedPrefix}: ${o.label}`),!0):!1}function v9(t){const e=ls.get(t);return e!=null&&e.lastInsertedBlockId?a1(t,e.lastInsertedBlockId):!1}function upe(t){const e=On.get(t)||Uu;if(!e)return;const n=ls.get(t);if(!n)return;f9(t);const r=()=>{n.debounceTimer=null,n.filterCache.clear(),Tc(t)};if(e.debounceMs<=0){r();return}n.debounceTimer=window.setTimeout(r,e.debounceMs)}function dpe(t){const e=Ua.get(t);if(e)return e;const n=On.get(t)||Uu||ix(),r=fa(t,n),i=`rte-blocks-library-panel-${zhe++}`,o=`${i}-query`,a=`${i}-category`,s=document.createElement("section");return s.className=Ln,s.id=i,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",n.labels.panelAriaLabel),s.innerHTML=`
|
|
6421
6422
|
<header class="rte-blocks-library-header">
|
|
6422
6423
|
<h2 class="rte-blocks-library-title">${mo(n.labels.panelTitle)}</h2>
|
|
6423
6424
|
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${mo(n.labels.closeText)}">✕</button>
|
|
@@ -6440,7 +6441,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6440
6441
|
<p class="rte-blocks-library-shortcut"></p>
|
|
6441
6442
|
</div>
|
|
6442
6443
|
<div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
|
|
6443
|
-
`,s.addEventListener("click",c=>{const l=c.target,u=l==null?void 0:l.closest("[data-action]");if(u){const A=u.getAttribute("data-action");if(A==="close"){Ru(t,!0);return}if(A==="insert-selected"){if(!r.selectedBlockId)return;a1(t,r.selectedBlockId)&&Ru(t,!0)}return}const d=l==null?void 0:l.closest("[data-block-id]");if(!d)return;const f=d.getAttribute("data-block-id");f&&(r.selectedBlockId=f,Tc(t),c.detail>=2&&a1(t,f)&&Ru(t,!0))}),s.addEventListener("input",c=>{const l=c.target;!(l instanceof HTMLInputElement)||l.getAttribute("data-field")!=="query"||(r.query=n.normalizeText(l.value).toLowerCase(),r.filterCache.clear(),upe(t))}),s.addEventListener("change",c=>{const l=c.target;!(l instanceof HTMLSelectElement)||l.getAttribute("data-field")!=="category"||(r.category=rx(l.value||"all")||"all",r.filterCache.clear(),Tc(t))}),s.addEventListener("keydown",c=>{if(c.key==="Escape"){c.preventDefault(),Ru(t,!0);return}if(c.key==="ArrowDown"){c.preventDefault(),
|
|
6444
|
+
`,s.addEventListener("click",c=>{const l=c.target,u=l==null?void 0:l.closest("[data-action]");if(u){const A=u.getAttribute("data-action");if(A==="close"){Ru(t,!0);return}if(A==="insert-selected"){if(!r.selectedBlockId)return;a1(t,r.selectedBlockId)&&Ru(t,!0)}return}const d=l==null?void 0:l.closest("[data-block-id]");if(!d)return;const f=d.getAttribute("data-block-id");f&&(r.selectedBlockId=f,Tc(t),c.detail>=2&&a1(t,f)&&Ru(t,!0))}),s.addEventListener("input",c=>{const l=c.target;!(l instanceof HTMLInputElement)||l.getAttribute("data-field")!=="query"||(r.query=n.normalizeText(l.value).toLowerCase(),r.filterCache.clear(),upe(t))}),s.addEventListener("change",c=>{const l=c.target;!(l instanceof HTMLSelectElement)||l.getAttribute("data-field")!=="category"||(r.category=rx(l.value||"all")||"all",r.filterCache.clear(),Tc(t))}),s.addEventListener("keydown",c=>{if(c.key==="Escape"){c.preventDefault(),Ru(t,!0);return}if(c.key==="ArrowDown"){c.preventDefault(),h9(t,1);return}if(c.key==="ArrowUp"){c.preventDefault(),h9(t,-1);return}if(c.key==="Enter"){const l=c.target;if(!(l==null?void 0:l.matches('[data-field="query"], [data-field="category"], [data-block-id]'))||!r.selectedBlockId)return;c.preventDefault(),a1(t,r.selectedBlockId)&&Ru(t,!0)}}),cx(s,t),document.body.appendChild(s),Ua.set(t,s),i1.set(t,!1),Tc(t),s}function fpe(t){const e=ls.get(t);return{query:(e==null?void 0:e.query)||"",category:(e==null?void 0:e.category)||"all",selectedBlockId:(e==null?void 0:e.selectedBlockId)||null,totalMatches:(e==null?void 0:e.totalMatches)||0,visibleMatches:(e==null?void 0:e.visibleMatches)||0,recentBlockIds:e!=null&&e.recentBlockIds?[...e.recentBlockIds]:[],lastInsertedBlockId:(e==null?void 0:e.lastInsertedBlockId)||null,loading:(e==null?void 0:e.loading)===!0,loadError:(e==null?void 0:e.loadError)||null}}async function C_(t,e){const n=On.get(t)||Uu;if(!n||typeof n.getBlocks!="function")return;const r=fa(t,n),i=Ng.get(t)||0;if(!e&&n.cacheTtlMs>0&&Date.now()-i<n.cacheTtlMs)return;const o=n1.get(t);if(o&&!e)return o;const a=r1.get(t);a&&a.abort(),e&&o&&n1.delete(t);const s=new AbortController;r1.set(t,s);const c=(Rg.get(t)||0)+1;Rg.set(t,c),r.loading=!0,r.loadError=null,Tc(t);const l=Promise.resolve().then(async()=>{var h;const u={editor:t,editorRoot:ox(t),signal:s.signal},d=await((h=n.getBlocks)==null?void 0:h.call(n,u));if(s.signal.aborted||Rg.get(t)!==c)return;const f=a9(d||[],n);cf.set(t,f),Ng.set(t,Date.now());const A=ls.get(t);A&&(A.loading=!1,A.loadError=null,A.filterCache.clear())}).catch(()=>{if(s.signal.aborted||Rg.get(t)!==c)return;const u=ls.get(t);u&&(u.loading=!1,u.loadError=n.labels.loadErrorText)}).finally(()=>{Rg.get(t)===c&&(n1.delete(t),r1.delete(t)),Tc(t)});return n1.set(t,l),l}function w9(t){return typeof t.key=="string"?t.key.toLowerCase():""}function Ape(t){const e=w9(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function hpe(t){const e=w9(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="l"}function ppe(t){Uu=t,Mg||(Mg=e=>{ax();const n=e.target,r=n==null?void 0:n.closest(zs);if(!r)return;const i=On.get(r)||t;fa(r,i),On.set(r,i),go=r,Qg(r);const o=Ua.get(r);o&&(cx(o,r),x_(r,o),Tc(r))},document.addEventListener("focusin",Mg,!0)),Pg||(Pg=e=>{if(e.defaultPrevented)return;const n=`.${Ln} input, .${Ln} textarea, .${Ln} select`,r=e.target;if(r!=null&&r.closest(n)){if(e.key==="Escape"){const a=r.closest(`.${Ln}`),s=Array.from(Ua.entries()).find(([,c])=>c===a);s&&(e.preventDefault(),Ru(s[0],!0))}return}const i=Yhe(e);if(!i)return;const o=On.get(i)||Uu||t;if(fa(i,o),On.set(i,o),go=i,e.key==="Escape"&&w_(i)){e.preventDefault(),Ru(i,!0);return}if(Ape(e)){e.preventDefault(),e.stopPropagation(),p9(i);return}hpe(e)&&(e.preventDefault(),e.stopPropagation(),v9(i))},document.addEventListener("keydown",Pg,!0)),lf||(lf=()=>{ax(),Ua.forEach((e,n)=>{!n.isConnected||!e.isConnected||(cx(e,n),x_(n,e))})},window.addEventListener("scroll",lf,!0),window.addEventListener("resize",lf)),!Hg&&typeof MutationObserver!="undefined"&&document.body&&(Hg=new MutationObserver(e=>{npe(e)&&ax()}),Hg.observe(document.body,{childList:!0,subtree:!0}))}function gpe(){Mg&&(document.removeEventListener("focusin",Mg,!0),Mg=null),Pg&&(document.removeEventListener("keydown",Pg,!0),Pg=null),lf&&(window.removeEventListener("scroll",lf,!0),window.removeEventListener("resize",lf),lf=null),Hg&&(Hg.disconnect(),Hg=null),Ua.forEach(e=>e.remove()),Ua.clear(),Array.from(tx).forEach(e=>v_(e)),Uu=null,go=null}function mpe(){if(typeof document=="undefined"||document.getElementById(n9))return;const t=document.createElement("style");t.id=n9,t.textContent=`
|
|
6444
6445
|
.rte-toolbar-group-items.${js},
|
|
6445
6446
|
.editora-toolbar-group-items.${js},
|
|
6446
6447
|
.rte-toolbar-group-items.${Il},
|
|
@@ -6838,7 +6839,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6838
6839
|
max-height: calc(100vh - 20px);
|
|
6839
6840
|
}
|
|
6840
6841
|
}
|
|
6841
|
-
`,document.head.appendChild(t)}const T_=Object.freeze(Object.defineProperty({__proto__:null,BlocksLibraryPlugin:(t={})=>{const e=ix(t),n=new Set;return mpe(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,E_(o),!0},openBlocksLibraryPanel:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,E_(o),!0},toggleBlocksLibraryPanel:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,pH(o,typeof r=="boolean"?r:void 0)},insertBlockSnippet:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;fa(o,a),On.set(o,a);const s=typeof r=="string"?r:r==null?void 0:r.id;return s?(go=o,a1(o,s)):!1},insertLastBlockSnippet:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,vH(o)},refreshBlocksLibraryData:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),C_(o,!0),!0},setBlocksLibraryOptions:(r,i)=>{const o=Nu(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=On.get(o)||e,s=J2.get(o)||Vhe(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},blocks:Array.isArray(r.blocks)?r.blocks:s.blocks,normalizeText:r.normalizeText||a.normalizeText,sanitizeBlockHtml:r.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:r.getBlocks||a.getBlocks},l=ix(c),u=Array.isArray(r.blocks),d=r.getBlocks!==void 0;On.set(o,l),J2.set(o,c),(u||d||!cf.has(o))&&(cf.set(o,l.blocks),Ng.set(o,d?0:Date.now()));const f=fa(o,l);return f.filterCache.clear(),typeof r.defaultCategory=="string"&&(f.category=rx(l.defaultCategory)||"all"),Tc(o),Qg(o),d&&C_(o,!0),!0},getBlocksLibraryState:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;fa(o,a);const s=fpe(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__blocksLibraryState=s,o.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(i){nx+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=ix(o);ppe(a);const s=Nu(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);s&&(go=s,n.add(s),fa(s,a),On.set(s,a),J2.set(s,o),cf.set(s,a.blocks),Ng.set(s,Date.now()),Qg(s))},destroy:()=>{n.forEach(r=>v_(r)),n.clear(),nx=Math.max(0,nx-1),!(nx>0)&&gpe()}}}},Symbol.toStringTag,{value:"Module"})),Ou=".rte-content, .editora-content",bpe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",$g='.rte-mention[data-mention="true"]',HA=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',dx=new WeakMap,fx=new WeakMap;let xH=!1,Ax=!1,s1=null,hx=0;function EH(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function CH(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Mu(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function px(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}function QA(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function c1(t){Array.from(t.querySelectorAll($g)).forEach(n=>{n.setAttribute("data-mention","true"),n.setAttribute("contenteditable","false"),n.setAttribute("spellcheck","false"),n.setAttribute("draggable","false"),n.classList.add("rte-mention")})}function TH(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ype(t){return t.closest(bpe)||t}function gx(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function vpe(t){const e=ype(t);if(gx(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return gx(n)?!0:gx(document.documentElement)||gx(document.body)}function kH(t,e){t.classList.remove("rte-mention-theme-dark"),vpe(e)&&t.classList.add("rte-mention-theme-dark")}function wpe(t){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const r=t.editorElement;if(r.matches(Ou))return r;const i=r.querySelector(Ou);if(i instanceof HTMLElement)return i}const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0).startContainer,i=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement,o=i==null?void 0:i.closest(Ou);if(o)return o}const n=document.activeElement;if(n){if(n.matches(Ou))return n;const r=n.closest(Ou);if(r)return r}return document.querySelector(Ou)}function zg(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k_(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function xpe(t,e){return e?e.split(".").filter(Boolean).reduce((n,r)=>{if(!(!k_(n)&&!Array.isArray(n)))return n[r]},t):t}function Epe(t){return t?/\s|[([{"'`]/.test(t):!0}function Cpe(t){if(!t.collapsed)return null;const e=t.startContainer,n=t.startOffset;if(e.nodeType===Node.TEXT_NODE){const r=e;return{node:r,textBefore:r.data.slice(0,n),caretOffset:n}}if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(n>0){const i=r.childNodes[n-1];if(i&&i.nodeType===Node.TEXT_NODE){const o=i;return{node:o,textBefore:o.data,caretOffset:o.length}}}}return null}function Tpe(t,e,n){let r=-1,i="";if(e.forEach(a=>{const s=t.lastIndexOf(a);s>r&&(r=s,i=a)}),r<0||!Epe(t[r-1]))return null;const o=t.slice(r+1);return/\s/.test(o)||o.length>n?null:{trigger:i,query:o,startOffset:r}}function kpe(t,e){const n=e.cloneRange();n.collapse(!1);const r=n.getClientRects();if(r.length>0)return r[r.length-1];const i=document.createElement("span");i.textContent="",i.style.position="relative",n.insertNode(i);const o=i.getBoundingClientRect();return i.remove(),t.normalize(),o}function Bpe(t,e){if(t.panel&&t.list)return;const n=document.createElement("div");n.className="rte-mention-panel",n.style.display="none";const r=document.createElement("div");r.className="rte-mention-list",n.appendChild(r),document.body.appendChild(n),kH(n,t.editor),t.panel=n,t.list=r,n.addEventListener("mousedown",i=>{i.preventDefault()}),n.addEventListener("click",i=>{const o=i.target;if(!o)return;const a=o.closest(".rte-mention-item");if(!a)return;const s=Number(a.getAttribute("data-index"));Number.isFinite(s)&&DH(t,e,s)})}function kc(t){t.panel&&(t.debounceHandle!==null&&(window.clearTimeout(t.debounceHandle),t.debounceHandle=null),t.abortController&&(t.abortController.abort(),t.abortController=null),t.panel.style.display="none",t.panel.classList.remove("show"),t.isOpen=!1,t.loading=!1,t.items=[],t.activeIndex=0,t.query="",t.replaceRange=null)}function BH(t,e){if(!t.panel)return;kH(t.panel,t.editor);const n=kpe(t.editor,e),r=t.panel;r.style.display="block",r.classList.add("show"),r.style.left="0px",r.style.top="0px";const i=r.getBoundingClientRect(),o=window.innerWidth,a=window.innerHeight,s=Math.max(8,Math.min(n.left,o-i.width-8));let c=n.bottom+8;c+i.height>a-8&&(c=Math.max(8,n.top-i.height-8)),r.style.position="fixed",r.style.left=`${s}px`,r.style.top=`${c}px`}function Spe(t,e){if(!e)return zg(t);const n=t.toLowerCase(),r=e.toLowerCase(),i=n.indexOf(r);if(i<0)return zg(t);const o=zg(t.slice(0,i)),a=zg(t.slice(i,i+e.length)),s=zg(t.slice(i+e.length));return`${o}<mark>${a}</mark>${s}`}function SH(t,e){if(!t.list)return;const n=t.list;if(n.innerHTML="",t.loading){const r=document.createElement("div");r.className="rte-mention-empty",r.textContent=e.loadingText,n.appendChild(r);return}if(t.items.length===0){const r=document.createElement("div");r.className="rte-mention-empty",r.textContent=t.query.length>0?e.noResultsText:e.emptyStateText,n.appendChild(r);return}t.items.forEach((r,i)=>{const o=document.createElement("button");o.type="button",o.className="rte-mention-item",i===t.activeIndex&&o.classList.add("active"),o.setAttribute("data-index",String(i));const a=e.itemRenderer?e.itemRenderer(r,t.query):`<span class="rte-mention-item-label">${Spe(r.label,t.query)}</span>${r.meta?`<span class="rte-mention-item-meta">${zg(r.meta)}</span>`:""}`;o.innerHTML=a,n.appendChild(o)})}function _H(t,e){const n=new Set,r=[];return t.forEach(i=>{const o=(i.id||"").trim();!o||n.has(o)||(n.add(o),r.push({id:o,label:i.label||o,value:i.value,meta:i.meta}))}),r.slice(0,e)}function _pe(t,e){if(t.buildRequest){const u=t.buildRequest(e);return{url:u.url,init:u.init||{}}}const n=(t.method||"GET").toUpperCase(),r=typeof t.headers=="function"?t.headers(e):t.headers||{},i=t.queryParam||"q",o=t.triggerParam||"trigger",a=t.limitParam||"limit",s=t.staticParams||{},c={method:n,headers:{...r},credentials:t.credentials,mode:t.mode,cache:t.cache,signal:e.signal},l=new URL(t.url,window.location.origin);if(n==="GET"||n==="HEAD"){const u=new URLSearchParams(l.search);Object.entries(s).forEach(([d,f])=>u.set(d,String(f))),u.set(i,e.query),u.set(o,e.trigger),u.set(a,String(e.limit)),l.search=u.toString()}else{const u=typeof t.body=="function"?t.body(e):t.body,d={[i]:e.query,[o]:e.trigger,[a]:e.limit,...s},f=u!=null?u:d;if(k_(f)){c.body=JSON.stringify(f);const A=c.headers;!A["Content-Type"]&&!A["content-type"]&&(A["Content-Type"]="application/json")}else c.body=f}return{url:l.toString(),init:c}}async function Dpe(t,e,n,r){var l,u;const i=e.api;if(!i)return[];t.abortController&&t.abortController.abort();const o=new AbortController;t.abortController=o;const a={query:n,trigger:r,limit:e.maxSuggestions,signal:o.signal},s=Math.max(0,(l=i.timeoutMs)!=null?l:1e4);let c=null;s>0&&(c=window.setTimeout(()=>o.abort(),s));try{const{url:d,init:f}=_pe(i,a),A=await fetch(d,{...f,signal:o.signal});if(!A.ok)throw new Error(`Mention API request failed: ${A.status}`);const p=(i.responseType||"json")==="text"?await A.text():await A.json();let m=[];if(i.transformResponse)m=i.transformResponse(p,a)||[];else{const g=xpe(p,i.responsePath);m=(Array.isArray(g)?g:Array.isArray(p)?p:[]).map((y,w)=>{var T,_,B,I,R;if(i.mapItem)return i.mapItem(y,w);if(!k_(y))return null;const x=String((B=(_=(T=y.id)!=null?T:y.value)!=null?_:y.key)!=null?B:"").trim();if(!x)return null;const k=String((R=(I=y.label)!=null?I:y.name)!=null?R:x).trim();return{id:x,label:k,value:y.value?String(y.value):void 0,meta:y.meta?String(y.meta):void 0}}).filter(y=>!!y)}return _H(m,e.maxSuggestions)}catch(d){return(d==null?void 0:d.name)!=="AbortError"&&((u=i.onError)==null||u.call(i,d,a)),[]}finally{c!==null&&window.clearTimeout(c),t.abortController===o&&(t.abortController=null)}}async function Lpe(t,e,n,r){const i=++t.requestId;let o=[];if(e.search){const a=await e.search(n,r);o=Array.isArray(a)?a:[]}else if(e.api)o=await Dpe(t,e,n,r);else{const a=n.toLowerCase();o=e.items.filter(s=>a?s.label.toLowerCase().includes(a)||s.id.toLowerCase().includes(a):!0)}return i!==t.requestId?[]:_H(o,e.maxSuggestions)}function Fpe(t,e,n){const r=t.editor;if(c1(r),!window.getSelection())return!1;const o=r.innerHTML;let a=t.replaceRange?t.replaceRange.cloneRange():QA(r);if(!a||!r.contains(a.commonAncestorContainer)&&(a=QA(r),!a))return!1;const s=mx(r,a.cloneRange(),"after");px(s,a)||(Mu(r,s),a=s),a.deleteContents();const c=document.createElement("span");c.className="rte-mention",c.setAttribute("data-mention","true"),c.setAttribute("data-mention-id",n.id),c.setAttribute("contenteditable","false"),c.textContent=n.value||`${t.trigger}${n.label}`,a.insertNode(c);let l=c,u=1;if(e.insertSpaceAfterMention){const f=document.createTextNode(" ");c.after(f),l=f,u=1}const d=document.createRange();return d.setStart(l,u),d.collapse(!0),Mu(r,d),kc(t),c1(r),CH(r),EH(r,o),!0}function DH(t,e,n){if(n<0||n>=t.items.length)return;const r=t.items[n];Fpe(t,e,r)}function Ipe(t){return t.startContainer!==t.endContainer||t.startContainer.nodeType!==Node.ELEMENT_NODE||t.endOffset-t.startOffset!==1?null:t.startContainer.childNodes[t.startOffset]||null}function Upe(t,e){const n=Ipe(t);return!(n instanceof HTMLElement)||!n.matches($g)||!e.contains(n)?null:n}function LH(t,e){const n=Upe(t,e);if(n)return n;const r=TH(t.startContainer),i=r==null?void 0:r.closest($g);if(i&&e.contains(i))return i;const o=TH(t.endContainer),a=o==null?void 0:o.closest($g);return a&&e.contains(a)?a:null}function mx(t,e,n="after"){const r=LH(e,t);if(!r)return e;const i=document.createRange();return n==="before"?i.setStartBefore(r):i.setStartAfter(r),i.collapse(!0),i}function FH(t,e,n="after"){const r=document.createRange();n==="before"?r.setStartBefore(e):r.setStartAfter(e),r.collapse(!0),Mu(t,r)}function Npe(t,e,n){if(!t.collapsed)return null;const r=t.startContainer,i=t.startOffset;let o=null;if(r.nodeType===Node.TEXT_NODE){const a=r;e==="backward"&&i===0?o=a.previousSibling:e==="forward"&&i===a.length&&(o=a.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const a=r;e==="backward"&&i>0?o=a.childNodes[i-1]||null:e==="forward"&&i<a.childNodes.length&&(o=a.childNodes[i]||null)}return!(o instanceof HTMLElement)||!o.matches($g)||!n.contains(o)?null:o}function IH(t,e){const n=QA(t);if(!n)return!1;const r=Npe(n,e,t);if(!r)return!1;const i=r.parentNode;if(!i)return!1;const o=t.innerHTML,a=Array.prototype.indexOf.call(i.childNodes,r);r.remove();const s=document.createRange();return s.setStart(i,Math.max(0,a)),s.collapse(!0),Mu(t,s),CH(t),EH(t,o),!0}function UH(t,e,n,r,i,o){var c;if(Bpe(t,e),t.query=r,t.trigger=i,t.replaceRange=o.cloneRange(),t.loading=!!(e.api&&!e.search),t.debounceHandle!==null&&(window.clearTimeout(t.debounceHandle),t.debounceHandle=null),!t.panel)return;t.isOpen||(t.panel.style.display="block",t.panel.classList.add("show"),t.isOpen=!0),SH(t,e),BH(t,n);const a=()=>{t.debounceHandle=null,Lpe(t,e,r,i).then(l=>{t.loading=!1,t.items=l,t.activeIndex=0,t.panel&&(SH(t,e),BH(t,n))})},s=e.api&&!e.search?Math.max(0,(c=e.api.debounceMs)!=null?c:180):0;s>0?t.debounceHandle=window.setTimeout(a,s):a()}function Rpe(t,e){const n=t.editor;c1(n);let r=QA(n);if(!r||!r.collapsed){kc(t);return}const i=mx(n,r.cloneRange(),"after");if(!px(i,r)){Mu(n,i),r=i,kc(t);return}const o=Cpe(r);if(!o){kc(t);return}const a=Tpe(o.textBefore,e.triggerChars,e.maxQueryLength);if(!a){kc(t);return}if(a.query.length<e.minChars){kc(t);return}if(t.dismissedNode===o.node&&t.dismissedOffset===a.startOffset)return;t.dismissedNode=null,t.dismissedOffset=-1;const s=r.cloneRange();s.setStart(o.node,a.startOffset),s.setEnd(o.node,o.caretOffset),UH(t,e,r,a.query,a.trigger,s)}function NH(t,e){if(t.items.length===0)return;const n=t.items.length;if(t.activeIndex=((t.activeIndex+e)%n+n)%n,!t.list)return;const r=Array.from(t.list.querySelectorAll(".rte-mention-item"));r.forEach((o,a)=>o.classList.toggle("active",a===t.activeIndex));const i=r[t.activeIndex];i==null||i.scrollIntoView({block:"nearest"})}function Ope(t){return{editor:t,panel:null,list:null,replaceRange:null,items:[],activeIndex:0,query:"",trigger:"@",loading:!1,isOpen:!1,requestId:0,debounceHandle:null,abortController:null,dismissedNode:null,dismissedOffset:-1}}function Mpe(t){var n;const e=dx.get(t);e&&((n=e.panel)!=null&&n.parentNode&&e.panel.parentNode.removeChild(e.panel),dx.delete(t))}function B_(t,e,n){if(fx.has(t))return;c1(t);const r={beforeInput:i=>{c1(t);const o=QA(t);if(!o)return;const a=LH(o,t);if(!a)return;const s=i.inputType||"";if(s.startsWith("insert")){if(i.preventDefault(),FH(t,a,"after"),s==="insertParagraph"||s==="insertLineBreak"){const c=s==="insertLineBreak"?"insertLineBreak":"insertParagraph";document.execCommand(c,!1);return}if(s==="insertText"||s==="insertCompositionText"){const c=i.data||"";if(!c)return;document.execCommand("insertText",!1,c)}}},input:()=>{Rpe(e,n)},keydown:i=>{if(e.isOpen){if(i.key==="ArrowDown"){i.preventDefault(),NH(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),NH(e,-1);return}if(i.key==="Enter"||i.key==="Tab"){i.preventDefault(),DH(e,n,e.activeIndex);return}if(i.key==="Escape"){i.preventDefault(),e.replaceRange&&(e.dismissedNode=e.replaceRange.startContainer,e.dismissedOffset=e.replaceRange.startOffset),kc(e);return}}const o=QA(t);if(o){const a=mx(t,o.cloneRange(),"after");if(!px(a,o)){if(i.key==="Enter"){i.preventDefault(),Mu(t,a),document.execCommand("insertParagraph",!1);return}i.key.length===1&&!i.metaKey&&!i.ctrlKey&&!i.altKey&&Mu(t,a)}}if(i.key==="Backspace"&&IH(t,"backward")){i.preventDefault();return}if(i.key==="Delete"&&IH(t,"forward")){i.preventDefault();return}},click:i=>{const o=i.target;if(!o)return;const a=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,s=a==null?void 0:a.closest($g);!s||!t.contains(s)||(i.preventDefault(),i.stopPropagation(),FH(t,s,"after"),kc(e))},blur:()=>{window.setTimeout(()=>{const i=document.activeElement;e.panel&&i&&e.panel.contains(i)||kc(e)},0)},mousedown:i=>{if(!e.isOpen||!e.panel)return;const o=i.target;o&&!e.panel.contains(o)&&!t.contains(o)&&kc(e)}};t.addEventListener("beforeinput",r.beforeInput),t.addEventListener("input",r.input),t.addEventListener("keydown",r.keydown),t.addEventListener("click",r.click),t.addEventListener("blur",r.blur),document.addEventListener("mousedown",r.mousedown,!0),fx.set(t,r)}function Ppe(t){const e=fx.get(t);e&&(t.removeEventListener("beforeinput",e.beforeInput),t.removeEventListener("input",e.input),t.removeEventListener("keydown",e.keydown),t.removeEventListener("click",e.click),t.removeEventListener("blur",e.blur),document.removeEventListener("mousedown",e.mousedown,!0),fx.delete(t))}function Hpe(){if(xH||typeof document=="undefined")return;xH=!0;const t=document.createElement("style");t.id="rte-mention-plugin-styles",t.textContent=`
|
|
6842
|
+
`,document.head.appendChild(t)}const T_=Object.freeze(Object.defineProperty({__proto__:null,BlocksLibraryPlugin:(t={})=>{const e=ix(t),n=new Set;return mpe(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,E_(o),!0},openBlocksLibraryPanel:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,E_(o),!0},toggleBlocksLibraryPanel:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,p9(o,typeof r=="boolean"?r:void 0)},insertBlockSnippet:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;fa(o,a),On.set(o,a);const s=typeof r=="string"?r:r==null?void 0:r.id;return s?(go=o,a1(o,s)):!1},insertLastBlockSnippet:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),go=o,v9(o)},refreshBlocksLibraryData:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;return fa(o,a),On.set(o,a),C_(o,!0),!0},setBlocksLibraryOptions:(r,i)=>{const o=Nu(i,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=On.get(o)||e,s=J2.get(o)||Vhe(a),c={...s,...r,labels:{...s.labels||{},...r.labels||{}},blocks:Array.isArray(r.blocks)?r.blocks:s.blocks,normalizeText:r.normalizeText||a.normalizeText,sanitizeBlockHtml:r.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:r.getBlocks||a.getBlocks},l=ix(c),u=Array.isArray(r.blocks),d=r.getBlocks!==void 0;On.set(o,l),J2.set(o,c),(u||d||!cf.has(o))&&(cf.set(o,l.blocks),Ng.set(o,d?0:Date.now()));const f=fa(o,l);return f.filterCache.clear(),typeof r.defaultCategory=="string"&&(f.category=rx(l.defaultCategory)||"all"),Tc(o),Qg(o),d&&C_(o,!0),!0},getBlocksLibraryState:(r,i)=>{const o=Nu(i,!1,!1);if(!o)return!1;const a=On.get(o)||e;fa(o,a);const s=fpe(o);if(typeof r=="function")try{r(s)}catch(c){}return o.__blocksLibraryState=s,o.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(i){nx+=1;const o=this&&typeof this.__pluginConfig=="object"?{...t,...this.__pluginConfig}:t,a=ix(o);ppe(a);const s=Nu(i!=null&&i.editorElement?{editorElement:i.editorElement}:void 0,!1,!1);s&&(go=s,n.add(s),fa(s,a),On.set(s,a),J2.set(s,o),cf.set(s,a.blocks),Ng.set(s,Date.now()),Qg(s))},destroy:()=>{n.forEach(r=>v_(r)),n.clear(),nx=Math.max(0,nx-1),!(nx>0)&&gpe()}}}},Symbol.toStringTag,{value:"Module"})),Ou=".rte-content, .editora-content",bpe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",$g='.rte-mention[data-mention="true"]',HA=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',dx=new WeakMap,fx=new WeakMap;let x9=!1,Ax=!1,s1=null,hx=0;function E9(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function C9(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Mu(t,e){const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(e),t.focus({preventScroll:!0}))}function px(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}function QA(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return t.contains(n.commonAncestorContainer)?n.cloneRange():null}function c1(t){Array.from(t.querySelectorAll($g)).forEach(n=>{n.setAttribute("data-mention","true"),n.setAttribute("contenteditable","false"),n.setAttribute("spellcheck","false"),n.setAttribute("draggable","false"),n.classList.add("rte-mention")})}function T9(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ype(t){return t.closest(bpe)||t}function gx(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function vpe(t){const e=ype(t);if(gx(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return gx(n)?!0:gx(document.documentElement)||gx(document.body)}function k9(t,e){t.classList.remove("rte-mention-theme-dark"),vpe(e)&&t.classList.add("rte-mention-theme-dark")}function wpe(t){if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;if((t==null?void 0:t.editorElement)instanceof HTMLElement){const r=t.editorElement;if(r.matches(Ou))return r;const i=r.querySelector(Ou);if(i instanceof HTMLElement)return i}const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0).startContainer,i=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement,o=i==null?void 0:i.closest(Ou);if(o)return o}const n=document.activeElement;if(n){if(n.matches(Ou))return n;const r=n.closest(Ou);if(r)return r}return document.querySelector(Ou)}function zg(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k_(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function xpe(t,e){return e?e.split(".").filter(Boolean).reduce((n,r)=>{if(!(!k_(n)&&!Array.isArray(n)))return n[r]},t):t}function Epe(t){return t?/\s|[([{"'`]/.test(t):!0}function Cpe(t){if(!t.collapsed)return null;const e=t.startContainer,n=t.startOffset;if(e.nodeType===Node.TEXT_NODE){const r=e;return{node:r,textBefore:r.data.slice(0,n),caretOffset:n}}if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(n>0){const i=r.childNodes[n-1];if(i&&i.nodeType===Node.TEXT_NODE){const o=i;return{node:o,textBefore:o.data,caretOffset:o.length}}}}return null}function Tpe(t,e,n){let r=-1,i="";if(e.forEach(a=>{const s=t.lastIndexOf(a);s>r&&(r=s,i=a)}),r<0||!Epe(t[r-1]))return null;const o=t.slice(r+1);return/\s/.test(o)||o.length>n?null:{trigger:i,query:o,startOffset:r}}function kpe(t,e){const n=e.cloneRange();n.collapse(!1);const r=n.getClientRects();if(r.length>0)return r[r.length-1];const i=document.createElement("span");i.textContent="",i.style.position="relative",n.insertNode(i);const o=i.getBoundingClientRect();return i.remove(),t.normalize(),o}function Bpe(t,e){if(t.panel&&t.list)return;const n=document.createElement("div");n.className="rte-mention-panel",n.style.display="none";const r=document.createElement("div");r.className="rte-mention-list",n.appendChild(r),document.body.appendChild(n),k9(n,t.editor),t.panel=n,t.list=r,n.addEventListener("mousedown",i=>{i.preventDefault()}),n.addEventListener("click",i=>{const o=i.target;if(!o)return;const a=o.closest(".rte-mention-item");if(!a)return;const s=Number(a.getAttribute("data-index"));Number.isFinite(s)&&D9(t,e,s)})}function kc(t){t.panel&&(t.debounceHandle!==null&&(window.clearTimeout(t.debounceHandle),t.debounceHandle=null),t.abortController&&(t.abortController.abort(),t.abortController=null),t.panel.style.display="none",t.panel.classList.remove("show"),t.isOpen=!1,t.loading=!1,t.items=[],t.activeIndex=0,t.query="",t.replaceRange=null)}function B9(t,e){if(!t.panel)return;k9(t.panel,t.editor);const n=kpe(t.editor,e),r=t.panel;r.style.display="block",r.classList.add("show"),r.style.left="0px",r.style.top="0px";const i=r.getBoundingClientRect(),o=window.innerWidth,a=window.innerHeight,s=Math.max(8,Math.min(n.left,o-i.width-8));let c=n.bottom+8;c+i.height>a-8&&(c=Math.max(8,n.top-i.height-8)),r.style.position="fixed",r.style.left=`${s}px`,r.style.top=`${c}px`}function Spe(t,e){if(!e)return zg(t);const n=t.toLowerCase(),r=e.toLowerCase(),i=n.indexOf(r);if(i<0)return zg(t);const o=zg(t.slice(0,i)),a=zg(t.slice(i,i+e.length)),s=zg(t.slice(i+e.length));return`${o}<mark>${a}</mark>${s}`}function S9(t,e){if(!t.list)return;const n=t.list;if(n.innerHTML="",t.loading){const r=document.createElement("div");r.className="rte-mention-empty",r.textContent=e.loadingText,n.appendChild(r);return}if(t.items.length===0){const r=document.createElement("div");r.className="rte-mention-empty",r.textContent=t.query.length>0?e.noResultsText:e.emptyStateText,n.appendChild(r);return}t.items.forEach((r,i)=>{const o=document.createElement("button");o.type="button",o.className="rte-mention-item",i===t.activeIndex&&o.classList.add("active"),o.setAttribute("data-index",String(i));const a=e.itemRenderer?e.itemRenderer(r,t.query):`<span class="rte-mention-item-label">${Spe(r.label,t.query)}</span>${r.meta?`<span class="rte-mention-item-meta">${zg(r.meta)}</span>`:""}`;o.innerHTML=a,n.appendChild(o)})}function _9(t,e){const n=new Set,r=[];return t.forEach(i=>{const o=(i.id||"").trim();!o||n.has(o)||(n.add(o),r.push({id:o,label:i.label||o,value:i.value,meta:i.meta}))}),r.slice(0,e)}function _pe(t,e){if(t.buildRequest){const u=t.buildRequest(e);return{url:u.url,init:u.init||{}}}const n=(t.method||"GET").toUpperCase(),r=typeof t.headers=="function"?t.headers(e):t.headers||{},i=t.queryParam||"q",o=t.triggerParam||"trigger",a=t.limitParam||"limit",s=t.staticParams||{},c={method:n,headers:{...r},credentials:t.credentials,mode:t.mode,cache:t.cache,signal:e.signal},l=new URL(t.url,window.location.origin);if(n==="GET"||n==="HEAD"){const u=new URLSearchParams(l.search);Object.entries(s).forEach(([d,f])=>u.set(d,String(f))),u.set(i,e.query),u.set(o,e.trigger),u.set(a,String(e.limit)),l.search=u.toString()}else{const u=typeof t.body=="function"?t.body(e):t.body,d={[i]:e.query,[o]:e.trigger,[a]:e.limit,...s},f=u!=null?u:d;if(k_(f)){c.body=JSON.stringify(f);const A=c.headers;!A["Content-Type"]&&!A["content-type"]&&(A["Content-Type"]="application/json")}else c.body=f}return{url:l.toString(),init:c}}async function Dpe(t,e,n,r){var l,u;const i=e.api;if(!i)return[];t.abortController&&t.abortController.abort();const o=new AbortController;t.abortController=o;const a={query:n,trigger:r,limit:e.maxSuggestions,signal:o.signal},s=Math.max(0,(l=i.timeoutMs)!=null?l:1e4);let c=null;s>0&&(c=window.setTimeout(()=>o.abort(),s));try{const{url:d,init:f}=_pe(i,a),A=await fetch(d,{...f,signal:o.signal});if(!A.ok)throw new Error(`Mention API request failed: ${A.status}`);const p=(i.responseType||"json")==="text"?await A.text():await A.json();let m=[];if(i.transformResponse)m=i.transformResponse(p,a)||[];else{const g=xpe(p,i.responsePath);m=(Array.isArray(g)?g:Array.isArray(p)?p:[]).map((y,w)=>{var T,_,B,I,R;if(i.mapItem)return i.mapItem(y,w);if(!k_(y))return null;const x=String((B=(_=(T=y.id)!=null?T:y.value)!=null?_:y.key)!=null?B:"").trim();if(!x)return null;const k=String((R=(I=y.label)!=null?I:y.name)!=null?R:x).trim();return{id:x,label:k,value:y.value?String(y.value):void 0,meta:y.meta?String(y.meta):void 0}}).filter(y=>!!y)}return _9(m,e.maxSuggestions)}catch(d){return(d==null?void 0:d.name)!=="AbortError"&&((u=i.onError)==null||u.call(i,d,a)),[]}finally{c!==null&&window.clearTimeout(c),t.abortController===o&&(t.abortController=null)}}async function Lpe(t,e,n,r){const i=++t.requestId;let o=[];if(e.search){const a=await e.search(n,r);o=Array.isArray(a)?a:[]}else if(e.api)o=await Dpe(t,e,n,r);else{const a=n.toLowerCase();o=e.items.filter(s=>a?s.label.toLowerCase().includes(a)||s.id.toLowerCase().includes(a):!0)}return i!==t.requestId?[]:_9(o,e.maxSuggestions)}function Fpe(t,e,n){const r=t.editor;if(c1(r),!window.getSelection())return!1;const o=r.innerHTML;let a=t.replaceRange?t.replaceRange.cloneRange():QA(r);if(!a||!r.contains(a.commonAncestorContainer)&&(a=QA(r),!a))return!1;const s=mx(r,a.cloneRange(),"after");px(s,a)||(Mu(r,s),a=s),a.deleteContents();const c=document.createElement("span");c.className="rte-mention",c.setAttribute("data-mention","true"),c.setAttribute("data-mention-id",n.id),c.setAttribute("contenteditable","false"),c.textContent=n.value||`${t.trigger}${n.label}`,a.insertNode(c);let l=c,u=1;if(e.insertSpaceAfterMention){const f=document.createTextNode(" ");c.after(f),l=f,u=1}const d=document.createRange();return d.setStart(l,u),d.collapse(!0),Mu(r,d),kc(t),c1(r),C9(r),E9(r,o),!0}function D9(t,e,n){if(n<0||n>=t.items.length)return;const r=t.items[n];Fpe(t,e,r)}function Ipe(t){return t.startContainer!==t.endContainer||t.startContainer.nodeType!==Node.ELEMENT_NODE||t.endOffset-t.startOffset!==1?null:t.startContainer.childNodes[t.startOffset]||null}function Upe(t,e){const n=Ipe(t);return!(n instanceof HTMLElement)||!n.matches($g)||!e.contains(n)?null:n}function L9(t,e){const n=Upe(t,e);if(n)return n;const r=T9(t.startContainer),i=r==null?void 0:r.closest($g);if(i&&e.contains(i))return i;const o=T9(t.endContainer),a=o==null?void 0:o.closest($g);return a&&e.contains(a)?a:null}function mx(t,e,n="after"){const r=L9(e,t);if(!r)return e;const i=document.createRange();return n==="before"?i.setStartBefore(r):i.setStartAfter(r),i.collapse(!0),i}function F9(t,e,n="after"){const r=document.createRange();n==="before"?r.setStartBefore(e):r.setStartAfter(e),r.collapse(!0),Mu(t,r)}function Npe(t,e,n){if(!t.collapsed)return null;const r=t.startContainer,i=t.startOffset;let o=null;if(r.nodeType===Node.TEXT_NODE){const a=r;e==="backward"&&i===0?o=a.previousSibling:e==="forward"&&i===a.length&&(o=a.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const a=r;e==="backward"&&i>0?o=a.childNodes[i-1]||null:e==="forward"&&i<a.childNodes.length&&(o=a.childNodes[i]||null)}return!(o instanceof HTMLElement)||!o.matches($g)||!n.contains(o)?null:o}function I9(t,e){const n=QA(t);if(!n)return!1;const r=Npe(n,e,t);if(!r)return!1;const i=r.parentNode;if(!i)return!1;const o=t.innerHTML,a=Array.prototype.indexOf.call(i.childNodes,r);r.remove();const s=document.createRange();return s.setStart(i,Math.max(0,a)),s.collapse(!0),Mu(t,s),C9(t),E9(t,o),!0}function U9(t,e,n,r,i,o){var c;if(Bpe(t,e),t.query=r,t.trigger=i,t.replaceRange=o.cloneRange(),t.loading=!!(e.api&&!e.search),t.debounceHandle!==null&&(window.clearTimeout(t.debounceHandle),t.debounceHandle=null),!t.panel)return;t.isOpen||(t.panel.style.display="block",t.panel.classList.add("show"),t.isOpen=!0),S9(t,e),B9(t,n);const a=()=>{t.debounceHandle=null,Lpe(t,e,r,i).then(l=>{t.loading=!1,t.items=l,t.activeIndex=0,t.panel&&(S9(t,e),B9(t,n))})},s=e.api&&!e.search?Math.max(0,(c=e.api.debounceMs)!=null?c:180):0;s>0?t.debounceHandle=window.setTimeout(a,s):a()}function Rpe(t,e){const n=t.editor;c1(n);let r=QA(n);if(!r||!r.collapsed){kc(t);return}const i=mx(n,r.cloneRange(),"after");if(!px(i,r)){Mu(n,i),r=i,kc(t);return}const o=Cpe(r);if(!o){kc(t);return}const a=Tpe(o.textBefore,e.triggerChars,e.maxQueryLength);if(!a){kc(t);return}if(a.query.length<e.minChars){kc(t);return}if(t.dismissedNode===o.node&&t.dismissedOffset===a.startOffset)return;t.dismissedNode=null,t.dismissedOffset=-1;const s=r.cloneRange();s.setStart(o.node,a.startOffset),s.setEnd(o.node,o.caretOffset),U9(t,e,r,a.query,a.trigger,s)}function N9(t,e){if(t.items.length===0)return;const n=t.items.length;if(t.activeIndex=((t.activeIndex+e)%n+n)%n,!t.list)return;const r=Array.from(t.list.querySelectorAll(".rte-mention-item"));r.forEach((o,a)=>o.classList.toggle("active",a===t.activeIndex));const i=r[t.activeIndex];i==null||i.scrollIntoView({block:"nearest"})}function Ope(t){return{editor:t,panel:null,list:null,replaceRange:null,items:[],activeIndex:0,query:"",trigger:"@",loading:!1,isOpen:!1,requestId:0,debounceHandle:null,abortController:null,dismissedNode:null,dismissedOffset:-1}}function Mpe(t){var n;const e=dx.get(t);e&&((n=e.panel)!=null&&n.parentNode&&e.panel.parentNode.removeChild(e.panel),dx.delete(t))}function B_(t,e,n){if(fx.has(t))return;c1(t);const r={beforeInput:i=>{c1(t);const o=QA(t);if(!o)return;const a=L9(o,t);if(!a)return;const s=i.inputType||"";if(s.startsWith("insert")){if(i.preventDefault(),F9(t,a,"after"),s==="insertParagraph"||s==="insertLineBreak"){const c=s==="insertLineBreak"?"insertLineBreak":"insertParagraph";document.execCommand(c,!1);return}if(s==="insertText"||s==="insertCompositionText"){const c=i.data||"";if(!c)return;document.execCommand("insertText",!1,c)}}},input:()=>{Rpe(e,n)},keydown:i=>{if(e.isOpen){if(i.key==="ArrowDown"){i.preventDefault(),N9(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),N9(e,-1);return}if(i.key==="Enter"||i.key==="Tab"){i.preventDefault(),D9(e,n,e.activeIndex);return}if(i.key==="Escape"){i.preventDefault(),e.replaceRange&&(e.dismissedNode=e.replaceRange.startContainer,e.dismissedOffset=e.replaceRange.startOffset),kc(e);return}}const o=QA(t);if(o){const a=mx(t,o.cloneRange(),"after");if(!px(a,o)){if(i.key==="Enter"){i.preventDefault(),Mu(t,a),document.execCommand("insertParagraph",!1);return}i.key.length===1&&!i.metaKey&&!i.ctrlKey&&!i.altKey&&Mu(t,a)}}if(i.key==="Backspace"&&I9(t,"backward")){i.preventDefault();return}if(i.key==="Delete"&&I9(t,"forward")){i.preventDefault();return}},click:i=>{const o=i.target;if(!o)return;const a=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,s=a==null?void 0:a.closest($g);!s||!t.contains(s)||(i.preventDefault(),i.stopPropagation(),F9(t,s,"after"),kc(e))},blur:()=>{window.setTimeout(()=>{const i=document.activeElement;e.panel&&i&&e.panel.contains(i)||kc(e)},0)},mousedown:i=>{if(!e.isOpen||!e.panel)return;const o=i.target;o&&!e.panel.contains(o)&&!t.contains(o)&&kc(e)}};t.addEventListener("beforeinput",r.beforeInput),t.addEventListener("input",r.input),t.addEventListener("keydown",r.keydown),t.addEventListener("click",r.click),t.addEventListener("blur",r.blur),document.addEventListener("mousedown",r.mousedown,!0),fx.set(t,r)}function Ppe(t){const e=fx.get(t);e&&(t.removeEventListener("beforeinput",e.beforeInput),t.removeEventListener("input",e.input),t.removeEventListener("keydown",e.keydown),t.removeEventListener("click",e.click),t.removeEventListener("blur",e.blur),document.removeEventListener("mousedown",e.mousedown,!0),fx.delete(t))}function Hpe(){if(x9||typeof document=="undefined")return;x9=!0;const t=document.createElement("style");t.id="rte-mention-plugin-styles",t.textContent=`
|
|
6842
6843
|
.rte-mention {
|
|
6843
6844
|
display: inline-block;
|
|
6844
6845
|
padding: 0 6px;
|
|
@@ -6942,7 +6943,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
6942
6943
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
|
|
6943
6944
|
color: #9ca3af;
|
|
6944
6945
|
}
|
|
6945
|
-
`,document.head.appendChild(t)}function Qpe(t){var n,r,i;const e=(t.triggerChars||["@"]).filter(o=>typeof o=="string"&&o.length>0).map(o=>o[0]);return{triggerChars:e.length>0?e:["@"],minChars:Math.max(0,(n=t.minChars)!=null?n:1),maxQueryLength:Math.max(1,(r=t.maxQueryLength)!=null?r:32),maxSuggestions:Math.max(1,(i=t.maxSuggestions)!=null?i:8),items:t.items||[{id:"john.doe",label:"John Doe",meta:"john@acme.com"},{id:"sarah.lee",label:"Sarah Lee",meta:"sarah@acme.com"},{id:"alex.chen",label:"Alex Chen",meta:"alex@acme.com"}],api:t.api,search:t.search,itemRenderer:t.itemRenderer,emptyStateText:t.emptyStateText||"Type to search mentions",noResultsText:t.noResultsText||"No matching mentions",loadingText:t.loadingText||"Loading...",insertSpaceAfterMention:t.insertSpaceAfterMention!==!1}}function bx(t){const e=dx.get(t);if(e)return e;const n=Ope(t);return dx.set(t,n),n}function $pe(t){Ax||(Ax=!0,s1=e=>{const n=e.target;if(!(n instanceof Node))return;const r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement,i=(r==null?void 0:r.closest(Ou))||null;if(!i)return;const o=bx(i);B_(i,o,t)},document.addEventListener("focusin",s1,!0))}function zpe(){!Ax||!s1||(document.removeEventListener("focusin",s1,!0),Ax=!1,s1=null)}const
|
|
6946
|
+
`,document.head.appendChild(t)}function Qpe(t){var n,r,i;const e=(t.triggerChars||["@"]).filter(o=>typeof o=="string"&&o.length>0).map(o=>o[0]);return{triggerChars:e.length>0?e:["@"],minChars:Math.max(0,(n=t.minChars)!=null?n:1),maxQueryLength:Math.max(1,(r=t.maxQueryLength)!=null?r:32),maxSuggestions:Math.max(1,(i=t.maxSuggestions)!=null?i:8),items:t.items||[{id:"john.doe",label:"John Doe",meta:"john@acme.com"},{id:"sarah.lee",label:"Sarah Lee",meta:"sarah@acme.com"},{id:"alex.chen",label:"Alex Chen",meta:"alex@acme.com"}],api:t.api,search:t.search,itemRenderer:t.itemRenderer,emptyStateText:t.emptyStateText||"Type to search mentions",noResultsText:t.noResultsText||"No matching mentions",loadingText:t.loadingText||"Loading...",insertSpaceAfterMention:t.insertSpaceAfterMention!==!1}}function bx(t){const e=dx.get(t);if(e)return e;const n=Ope(t);return dx.set(t,n),n}function $pe(t){Ax||(Ax=!0,s1=e=>{const n=e.target;if(!(n instanceof Node))return;const r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement,i=(r==null?void 0:r.closest(Ou))||null;if(!i)return;const o=bx(i);B_(i,o,t)},document.addEventListener("focusin",s1,!0))}function zpe(){!Ax||!s1||(document.removeEventListener("focusin",s1,!0),Ax=!1,s1=null)}const R9=Object.freeze(Object.defineProperty({__proto__:null,MentionPlugin:(t={})=>{Hpe();const e=Qpe(t);return{name:"mentions",toolbar:[{label:"Mention",command:"insertMention",icon:'<svg width="24" height="24" focusable="false"><path d="M12.1 4a7.9 7.9 0 0 0-8 8c0 4.4 3.6 8 8 8 1.6 0 3-.4 4.4-1.3.4-.3.5-.9.2-1.3a1 1 0 0 0-1.3-.3 6 6 0 0 1-3.3.9 6 6 0 1 1 6-6v1.6c0 .8-.5 1.4-1.2 1.4-.8 0-1.2-.6-1.2-1.4V12c0-2-1.6-3.5-3.7-3.5s-3.8 1.6-3.8 3.6c0 2 1.7 3.6 3.8 3.6 1 0 1.9-.4 2.6-1 .5 1 1.4 1.6 2.5 1.6 1.8 0 3.2-1.5 3.2-3.4V12A7.9 7.9 0 0 0 12 4Zm0 9.7c-1 0-1.8-.8-1.8-1.7s.8-1.7 1.8-1.7c1 0 1.7.8 1.7 1.7s-.8 1.7-1.7 1.7Z"></path></svg>'}],commands:{insertMention:(n,r)=>{const i=wpe(r);if(!i)return!1;const o=bx(i);B_(i,o,e);let a=QA(i);a||(a=document.createRange(),a.selectNodeContents(i),a.collapse(!1),Mu(i,a));const s=mx(i,a.cloneRange(),"after");px(s,a)||(Mu(i,s),a=s),o.query="";const c=a.cloneRange();return o.trigger=e.triggerChars[0],U9(o,e,a,"",o.trigger,c),!0}},init:()=>{hx+=1,$pe(e),Array.from(document.querySelectorAll(Ou)).forEach(r=>{const i=bx(r);B_(r,i,e)})},destroy:()=>{hx=Math.max(0,hx-1),Array.from(document.querySelectorAll(Ou)).forEach(r=>{kc(bx(r)),Ppe(r),Mpe(r)}),hx===0&&zpe()}}}},Symbol.toStringTag,{value:"Module"})),$A=new Set,l1='[data-theme="dark"], .dark, .editora-theme-dark';function jpe(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function qpe(){if(typeof window=="undefined"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(e=>{e.forEach(n=>{n.removedNodes.forEach(r=>{var i,o;if(r.nodeType===Node.ELEMENT_NODE){const a=r;if((i=a.classList)!=null&&i.contains("rte-anchor")){const c=a.id;c&&$A.delete(c)}const s=(o=a.querySelectorAll)==null?void 0:o.call(a,".rte-anchor");s==null||s.forEach(c=>{const l=c.id;l&&$A.delete(l)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function O9(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[A-Za-z_]/.test(t)?/^[A-Za-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function Wpe(){const t=mS();if(!t)return;const e=bS(t);if(!e)return;const n=e.querySelectorAll(".rte-anchor"),r=new Set;n.forEach(i=>{const o=i.id;o&&r.add(o)}),$A.clear(),r.forEach(i=>$A.add(i))}function Kpe(t){if(t){const r=t.startContainer,i=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;if(i!=null&&i.closest(l1))return!0}const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0).startContainer,i=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;if(i!=null&&i.closest(l1))return!0}const n=document.activeElement;return n!=null&&n.closest(l1)?!0:document.body.matches(l1)||document.documentElement.matches(l1)}function Vpe(t,e,n,r){document.querySelectorAll(".rte-anchor-dialog-overlay").forEach(_=>_.remove()),Wpe();const i=Kpe(r),o=i?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},a=document.createElement("div");Io(a),a.className="rte-anchor-dialog-overlay",a.style.cssText=`
|
|
6946
6947
|
position: fixed;
|
|
6947
6948
|
top: 0;
|
|
6948
6949
|
left: 0;
|
|
@@ -7035,11 +7036,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7035
7036
|
transition: all 0.2s ease;
|
|
7036
7037
|
background: ${o.saveBg};
|
|
7037
7038
|
color: white;
|
|
7038
|
-
`,w.disabled=!p.value.trim();const x=()=>{p.value.trim()?(w.disabled=!1,w.style.background=o.saveBg,w.style.color="white",w.style.cursor="pointer"):(w.disabled=!0,w.style.background=o.saveDisabledBg,w.style.color=o.saveDisabledText,w.style.cursor="not-allowed")};w.onmouseover=()=>{w.disabled||(w.style.background=o.saveHover,w.style.boxShadow=i?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},w.onmouseout=()=>{w.disabled||(w.style.background=o.saveBg,w.style.boxShadow="none")},b.appendChild(y),b.appendChild(w),p.oninput=()=>{const _=p.value;if(x(),_.trim()){const B=
|
|
7039
|
+
`,w.disabled=!p.value.trim();const x=()=>{p.value.trim()?(w.disabled=!1,w.style.background=o.saveBg,w.style.color="white",w.style.cursor="pointer"):(w.disabled=!0,w.style.background=o.saveDisabledBg,w.style.color=o.saveDisabledText,w.style.cursor="not-allowed")};w.onmouseover=()=>{w.disabled||(w.style.background=o.saveHover,w.style.boxShadow=i?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},w.onmouseout=()=>{w.disabled||(w.style.background=o.saveBg,w.style.boxShadow="none")},b.appendChild(y),b.appendChild(w),p.oninput=()=>{const _=p.value;if(x(),_.trim()){const B=O9(_);B.valid?$A.has(_)?(c=`Anchor ID already exists: ${_}`,m.textContent="⚠ "+c,m.style.display="block",p.style.borderColor=o.fieldErrorBorder,p.style.background=o.fieldErrorBg):(c="",m.style.display="none",p.style.borderColor=o.fieldBorder,p.style.background=o.fieldBg):(c=B.error,m.textContent="⚠ "+c,m.style.display="block",p.style.borderColor=o.fieldErrorBorder,p.style.background=o.fieldErrorBg)}else m.style.display="none",p.style.borderColor=o.fieldBorder,p.style.background=o.fieldBg},p.onfocus=()=>{p.style.borderColor=c?o.fieldErrorBorder:o.saveBg,p.style.boxShadow=c?`0 0 0 3px ${o.errorRing}`:`0 0 0 3px ${o.focusRing}`,p.style.background=c?o.fieldErrorBg:o.fieldFocusBg},p.onblur=()=>{p.style.boxShadow="none",c||(p.style.background=o.fieldBg)};const k=()=>{const _=p.value.trim();!_||!O9(_).valid||$A.has(_)||(n&&n(_),a.remove())},T=()=>{a.remove()};w.onclick=k,y.onclick=T,d.onclick=T,p.onkeydown=_=>{_.key==="Enter"?(_.preventDefault(),k()):_.key==="Escape"&&(_.preventDefault(),T())},a.onclick=_=>{_.target===a&&T()},s.appendChild(l),s.appendChild(f),s.appendChild(b),a.appendChild(s),document.body.appendChild(a),setTimeout(()=>p.focus(),100)}function Gpe(t,e){var c;let n;if(e)n=e;else{const l=window.getSelection();if(!l||l.rangeCount===0)return;n=l.getRangeAt(0)}let r=null,i=n.startContainer;for(;i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE){const l=i;if(l.getAttribute("contenteditable")==="true"){r=l;break}}i=i.parentNode}const o=(c=r==null?void 0:r.innerHTML)!=null?c:"",a=document.createElement("span");a.id=t,a.className="rte-anchor",a.setAttribute("data-type","anchor"),a.setAttribute("data-anchor-id",t),a.setAttribute("title",`Anchor: ${t}`),a.style.cssText=`
|
|
7039
7040
|
display: inline;
|
|
7040
7041
|
position: relative;
|
|
7041
7042
|
cursor: pointer;
|
|
7042
|
-
`,n.insertNode(a),$A.add(t),n.setStart(a.nextSibling||a.parentNode,0),n.collapse(!0);const s=window.getSelection();if(s&&(s.removeAllRanges(),s.addRange(n)),r)jpe(r,o),r.dispatchEvent(new Event("input",{bubbles:!0}));else{const l=mS();if(l){const u=bS(l);u&&u.dispatchEvent(new Event("input",{bubbles:!0}))}}
|
|
7043
|
+
`,n.insertNode(a),$A.add(t),n.setStart(a.nextSibling||a.parentNode,0),n.collapse(!0);const s=window.getSelection();if(s&&(s.removeAllRanges(),s.addRange(n)),r)jpe(r,o),r.dispatchEvent(new Event("input",{bubbles:!0}));else{const l=mS();if(l){const u=bS(l);u&&u.dispatchEvent(new Event("input",{bubbles:!0}))}}M9()}function M9(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
|
|
7043
7044
|
.rte-anchor {
|
|
7044
7045
|
display: inline;
|
|
7045
7046
|
position: relative;
|
|
@@ -7117,7 +7118,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7117
7118
|
outline: 2px solid #0066cc;
|
|
7118
7119
|
outline-offset: 2px;
|
|
7119
7120
|
}
|
|
7120
|
-
`,document.head.appendChild(t)}const Xpe=Object.freeze(Object.defineProperty({__proto__:null,AnchorPlugin:()=>(typeof window!="undefined"&&(qpe(),
|
|
7121
|
+
`,document.head.appendChild(t)}const Xpe=Object.freeze(Object.defineProperty({__proto__:null,AnchorPlugin:()=>(typeof window!="undefined"&&(qpe(),M9()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const e=t.getRangeAt(0).cloneRange();return Vpe("add","",n=>{Gpe(n,e)},e),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}})},Symbol.toStringTag,{value:"Module"})),Ype=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],u1='[data-theme="dark"], .dark, .editora-theme-dark';let qs=null;const S_=new WeakMap,Pu=t=>(S_.has(t)||S_.set(t,{dialogElement:null,escapeHandler:null,savedRange:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),S_.get(t));function Zpe(t){if(t!=null&&t.matches(u1)||t!=null&&t.closest(u1))return!0;const e=document.activeElement;return e!=null&&e.closest(u1)?!0:document.body.matches(u1)||document.documentElement.matches(u1)}function P9(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function Jpe(t){const e=t==null?void 0:t.editorElement;if(e instanceof HTMLElement)return e;const n=t==null?void 0:t.contentElement;if(n instanceof HTMLElement){const a=n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");return a instanceof HTMLElement?a:n}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement)return r;const i=window.getSelection();if(i&&i.rangeCount>0){const a=P9(i.getRangeAt(0).startContainer),s=a==null?void 0:a.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(s instanceof HTMLElement)return s}const o=document.activeElement;if(o instanceof HTMLElement){const a=o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(a instanceof HTMLElement)return a}return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")}function H9(t){return t.getAttribute("contenteditable")==="true"?t:t.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function yx(t){const e=P9(t);return e==null?void 0:e.closest('.rte-content, .editora-content, [contenteditable="true"]')}function ege(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n.cloneRange()}function Q9(t,e,n){if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch(r){}}}function tge(t,e){let n=e;for(;n&&n.parentNode&&n.parentNode!==t;)n=n.parentNode;return n&&n.parentNode===t?n:null}function $9(t,e){return t.tagName!=="P"?!1:Array.from(t.childNodes).every(n=>{var r;return n===e?!0:n.nodeType===Node.ELEMENT_NODE?n.tagName==="BR":n.nodeType===Node.TEXT_NODE&&!((r=n.textContent)!=null&&r.trim())})}function nge(t){if(!(t instanceof Element))return null;const e=t.closest("iframe");if(e instanceof HTMLIFrameElement){const o=yx(e);if(!o)return null;const a=e.parentElement;return a&&a.parentElement===o&&$9(a,e)?a:e}const n=t.closest("p");if(!(n instanceof HTMLElement))return null;const r=yx(n);if(!r||n.parentElement!==r)return null;const i=Array.from(n.children).find(o=>o instanceof HTMLIFrameElement);return i&&$9(n,i)?n:null}function jg(){var t;qs&&(qs.classList.remove("rte-selected-embed-object"),(t=qs.querySelector("iframe"))==null||t.removeAttribute("data-rte-selected-object"),qs instanceof HTMLIFrameElement&&qs.removeAttribute("data-rte-selected-object"),qs=null)}function rge(t){if(qs===t)return;jg(),qs=t,t.classList.add("rte-selected-embed-object");const e=t instanceof HTMLIFrameElement?t:t.querySelector("iframe");e==null||e.setAttribute("data-rte-selected-object","true");const n=window.getSelection();if(!n)return;const r=document.createRange();r.selectNode(t),n.removeAllRanges(),n.addRange(r)}function ige(t,e){const n=window.getSelection();if(!n)return;const r=document.createRange();e&&e.parentNode===t?r.setStartBefore(e):(r.selectNodeContents(t),r.collapse(!1)),r.collapse(!0),n.removeAllRanges(),n.addRange(r)}function oge(t){if(t.childNodes.length>0)return;const e=document.createElement("p");e.appendChild(document.createElement("br")),t.appendChild(e)}function age(){if(!qs||!qs.isConnected)return jg(),!1;const t=qs,e=yx(t);if(!e)return jg(),!1;const n=e.innerHTML,r=t.nextSibling;t.remove(),oge(e),jg(),ige(e,r);const i=e.innerHTML;return Q9(e,n,i),e.dispatchEvent(new window.Event("input",{bubbles:!0})),n!==i}function z9(){if(document.getElementById("embed-iframe-object-selection-styles"))return;const t=document.createElement("style");t.id="embed-iframe-object-selection-styles",t.textContent=`
|
|
7121
7122
|
.rte-selected-embed-object {
|
|
7122
7123
|
outline: 2px solid #2563eb;
|
|
7123
7124
|
outline-offset: 3px;
|
|
@@ -7134,7 +7135,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7134
7135
|
iframe.rte-selected-embed-object {
|
|
7135
7136
|
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
|
|
7136
7137
|
}
|
|
7137
|
-
`,document.head.appendChild(t)}function sge(){typeof window=="undefined"||window.__embedIframeObjectSelectionInitialized||(window.__embedIframeObjectSelectionInitialized=!0,
|
|
7138
|
+
`,document.head.appendChild(t)}function sge(){typeof window=="undefined"||window.__embedIframeObjectSelectionInitialized||(window.__embedIframeObjectSelectionInitialized=!0,z9(),document.addEventListener("pointerdown",t=>{var n,r;const e=nge(t.target);if(!e){const i=t.target;(n=i==null?void 0:i.closest)!=null&&n.call(i,".rte-embed-iframe-overlay")||jg();return}t.preventDefault(),(r=yx(e))==null||r.focus(),rge(e)},!0),document.addEventListener("keydown",t=>{if(qs){if(t.key==="Escape"){jg();return}t.key!=="Backspace"&&t.key!=="Delete"||(t.preventDefault(),t.stopPropagation(),age())}},!0))}function cge(t){try{const e=new URL(t),n=e.hostname.replace(/^www\./,"");if(n==="youtu.be"){const r=e.pathname.split("/").filter(Boolean)[0];if(r)return`https://www.youtube.com/embed/${encodeURIComponent(r)}`}if(n==="youtube.com"||n==="m.youtube.com"){const r=e.searchParams.get("v");if(r)return`https://www.youtube.com/embed/${encodeURIComponent(r)}`;const i=e.pathname.match(/^\/embed\/([^/]+)/);if(i!=null&&i[1])return`https://www.youtube.com/embed/${encodeURIComponent(i[1])}`}if(n==="vimeo.com"){const r=e.pathname.split("/").filter(Boolean)[0];if(r&&/^\d+$/.test(r))return`https://player.vimeo.com/video/${r}`}return t}catch(e){return t}}function j9(t){if(/\s/.test(t))return!1;try{const e=new URL(t);return(e.protocol==="https:"||e.protocol==="http:")&&e.hostname.length>0}catch(e){return!1}}const lge=()=>({name:"embedIframe",init:sge,toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:(t,e)=>(uge(Jpe(e)||void 0),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function uge(t){if(document.querySelectorAll(".rte-embed-iframe-overlay").forEach(o=>o.remove()),!t){const o=document.activeElement;o&&o.closest("[data-editora-editor]")&&(t=o.closest("[data-editora-editor]"))}if(t||(t=document.querySelector("[data-editora-editor]")),!t){console.warn("Editor element not found");return}const e=Pu(t),n=H9(t);e.savedRange=n?ege(n):null,e.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},e.activeTab="general";const r=document.createElement("div");Io(r),r.className="rte-dialog-overlay rte-embed-iframe-overlay",Zpe(t)&&r.classList.add("rte-theme-dark"),r.onclick=()=>d1(t);const i=document.createElement("div");i.className="rte-dialog-content embed-iframe-dialog",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-labelledby","embed-iframe-dialog-title"),i.onclick=o=>o.stopPropagation(),i.innerHTML=`
|
|
7138
7139
|
<div class="rte-dialog-header">
|
|
7139
7140
|
<h3 id="embed-iframe-dialog-title">Embed Iframe</h3>
|
|
7140
7141
|
<button type="button" class="rte-dialog-close" aria-label="Close">×</button>
|
|
@@ -7210,7 +7211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7210
7211
|
<button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
|
|
7211
7212
|
<button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
|
|
7212
7213
|
</div>
|
|
7213
|
-
`,r.appendChild(i),document.body.appendChild(r),e.dialogElement=r,e.escapeHandler=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),d1(t))},document.addEventListener("keydown",e.escapeHandler,!0),dge(i,t),bge(),setTimeout(()=>{var o;(o=i.querySelector("#iframe-src"))==null||o.focus()},100)}function dge(t,e){var o,a,s,c;(o=t.querySelector(".rte-dialog-close"))==null||o.addEventListener("click",()=>d1(e)),t.querySelectorAll(".rte-tab-button").forEach(l=>{l.addEventListener("click",u=>{const d=u.target.getAttribute("data-tab");d&&
|
|
7214
|
+
`,r.appendChild(i),document.body.appendChild(r),e.dialogElement=r,e.escapeHandler=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),d1(t))},document.addEventListener("keydown",e.escapeHandler,!0),dge(i,t),bge(),setTimeout(()=>{var o;(o=i.querySelector("#iframe-src"))==null||o.focus()},100)}function dge(t,e){var o,a,s,c;(o=t.querySelector(".rte-dialog-close"))==null||o.addEventListener("click",()=>d1(e)),t.querySelectorAll(".rte-tab-button").forEach(l=>{l.addEventListener("click",u=>{const d=u.target.getAttribute("data-tab");d&&q9(t,d,e)})});const n=t.querySelector("#iframe-size");n==null||n.addEventListener("change",l=>fge(t,l.target.value,e));const r=t.querySelector("#iframe-width"),i=t.querySelector("#iframe-height");r==null||r.addEventListener("input",l=>Age(t,l.target.value,e)),i==null||i.addEventListener("input",l=>hge(t,l.target.value,e)),(a=t.querySelector("#constrain-btn"))==null||a.addEventListener("click",()=>pge(t,e)),(s=t.querySelector("#cancel-btn"))==null||s.addEventListener("click",()=>d1(e)),(c=t.querySelector("#save-btn"))==null||c.addEventListener("click",()=>gge(t,e))}function q9(t,e,n){const r=Pu(n);r.activeTab=e,t.querySelectorAll(".rte-tab-button").forEach(i=>{i.classList.toggle("active",i.getAttribute("data-tab")===e)}),t.querySelectorAll(".rte-tab-panel").forEach(i=>{i.style.display=i.getAttribute("data-panel")===e?"block":"none"})}function fge(t,e,n){const r=Pu(n);r.formData.selectedSize=e;const i=t.querySelector("#dimensions-row"),o=t.querySelector("#iframe-width"),a=t.querySelector("#iframe-height");e==="inline"?(i.style.display="flex",o.value="100%",a.value="400px",r.formData.width="100%",r.formData.height="400px"):(i.style.display="none",r.formData.width="100%",r.formData.height="auto")}function Age(t,e,n){const r=Pu(n);if(r.formData.width=e,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const i=parseFloat(e);if(!isNaN(i)){const o=i*9/16;r.formData.height=`${o}px`;const a=t.querySelector("#iframe-height");a&&(a.value=r.formData.height)}}}function hge(t,e,n){const r=Pu(n);if(r.formData.height=e,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const i=parseFloat(e);if(!isNaN(i)){const o=i*16/9;r.formData.width=`${o}px`;const a=t.querySelector("#iframe-width");a&&(a.value=r.formData.width)}}}function pge(t,e){const n=Pu(e);n.formData.constrainProportions=!n.formData.constrainProportions;const r=t.querySelector("#constrain-btn");r&&(r.textContent=n.formData.constrainProportions?"🔒":"🔓",r.className=`rte-constrain-btn ${n.formData.constrainProportions?"locked":"unlocked"}`,r.title=n.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function gge(t,e){var g,b,y,w,x,k,T;const n=Pu(e),r=t.querySelector("#iframe-src"),i=t.querySelector("#iframe-desc-url");let o=(r==null?void 0:r.value.trim())||"";o&&!/^[a-z][a-z0-9+.-]*:/i.test(o)&&/^[^\s/]+\.[^\s/]+/.test(o)&&(o=`https://${o}`,r&&(r.value=o));const a=(_,B,I,R)=>{q9(t,R,e);const C=t.querySelector(`#${B}`);C&&(C.textContent=I,C.hidden=!1),_&&(_.setAttribute("aria-invalid","true"),_.focus())},s=(_,B)=>{const I=t.querySelector(`#${B}`);I&&(I.textContent="",I.hidden=!0),_==null||_.removeAttribute("aria-invalid")};if(s(r,"iframe-src-error"),s(i,"iframe-desc-url-error"),!o){a(r,"iframe-src-error","Please enter a source URL.","general");return}if(!j9(o)){a(r,"iframe-src-error","Enter a valid URL starting with https:// or http://.","general");return}const c=(i==null?void 0:i.value.trim())||"";if(c&&!j9(c)){a(i,"iframe-desc-url-error","Enter a valid URL starting with https:// or http://.","advanced");return}const l=(g=t.querySelector("#iframe-name"))==null?void 0:g.value.trim(),u=(b=t.querySelector("#iframe-title"))==null?void 0:b.value.trim(),d=(y=t.querySelector("#iframe-longdesc"))==null?void 0:y.value.trim(),f=c,A=(x=(w=t.querySelector("#iframe-border"))==null?void 0:w.checked)!=null?x:!0,h=(T=(k=t.querySelector("#iframe-scrollbar"))==null?void 0:k.checked)!=null?T:!0;let p=n.formData.width,m=n.formData.height;n.formData.selectedSize!=="inline"&&(p="100%",m="auto"),mge(e,{src:o,width:p,height:m,aspectRatio:n.formData.selectedSize,name:l||void 0,title:u||void 0,longDescription:d||void 0,descriptionUrl:f||void 0,showBorder:A,enableScrollbar:h}),d1(e)}function mge(t,e){const n=Pu(t),r=H9(t);if(!r)return;const i=r.innerHTML,o=document.createElement("iframe");o.src=cge(e.src),o.width=e.width,o.height=e.height,o.allowFullscreen=!0,o.setAttribute("frameborder",e.showBorder?"1":"0"),o.setAttribute("scrolling",e.enableScrollbar?"auto":"no"),o.setAttribute("data-aspect-ratio",e.aspectRatio),o.setAttribute("data-editora-embed","true"),e.aspectRatio!=="inline"&&o.classList.add(`rte-iframe-${e.aspectRatio}`),e.name&&(o.name=e.name),e.title&&(o.title=e.title),e.longDescription&&o.setAttribute("data-long-description",e.longDescription),e.descriptionUrl&&o.setAttribute("longdesc",e.descriptionUrl);const a=document.createElement("p");a.appendChild(o),a.appendChild(document.createElement("br"));const s=n.savedRange&&r.contains(n.savedRange.commonAncestorContainer)?n.savedRange:document.createRange();(!n.savedRange||!r.contains(n.savedRange.commonAncestorContainer))&&(s.selectNodeContents(r),s.collapse(!1));const c=tge(r,s.startContainer),l=c?c.nextSibling:null;r.insertBefore(a,l);const u=document.createRange();u.setStartAfter(a),u.collapse(!0);const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(u)),n.savedRange=null;const f=r.innerHTML;Q9(r,i,f),r.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{allowedTags:["iframe"]}}))}function d1(t){const e=Pu(t);e.savedRange=null,e.escapeHandler&&(document.removeEventListener("keydown",e.escapeHandler,!0),e.escapeHandler=null),e.dialogElement&&(e.dialogElement.remove(),e.dialogElement=null)}function bge(){if(z9(),document.getElementById("embed-iframe-dialog-styles"))return;const t=document.createElement("style");t.id="embed-iframe-dialog-styles",t.textContent=`
|
|
7214
7215
|
/* Embed Iframe Dialog Styles */
|
|
7215
7216
|
.embed-iframe-dialog {
|
|
7216
7217
|
max-width: 600px;
|
|
@@ -7514,13 +7515,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7514
7515
|
width: 100%;
|
|
7515
7516
|
height: 100%;
|
|
7516
7517
|
}
|
|
7517
|
-
`,document.head.appendChild(t)}const yge=Object.freeze(Object.defineProperty({__proto__:null,EmbedIframePlugin:lge},Symbol.toStringTag,{value:"Module"})),vge={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let vx=null,qg=null,
|
|
7518
|
+
`,document.head.appendChild(t)}const yge=Object.freeze(Object.defineProperty({__proto__:null,EmbedIframePlugin:lge},Symbol.toStringTag,{value:"Module"})),vge={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let vx=null,qg=null,W9=!1,Wg=null,Nl=null;const f1='[data-theme="dark"], .dark, .editora-theme-dark',wge=new Set(["math","mrow","mi","mn","mo","ms","mtext","mspace","msup","msub","msubsup","mfrac","msqrt","mroot","mfenced","mstyle","mpadded","mphantom","menclose","mtable","mtr","mtd","mlabeledtr","munder","mover","munderover","mmultiscripts","mprescripts","none","semantics","annotation"]),xge=new Set(["display","displaystyle","mathvariant","mathsize","mathcolor","mathbackground","scriptlevel","fence","separator","stretchy","symmetric","lspace","rspace","largeop","movablelimits","accent","accentunder","open","close","separators","linethickness","columnalign","rowalign","columnspacing","rowspacing","columnlines","rowlines","frame","notation","width","height","depth","voffset","minsize","maxsize","form","encoding","xmlns","dir","class","id"]),wx=t=>{const e=new DOMParser().parseFromString(`<body>${t}</body>`,"text/html"),n=r=>{Array.from(r.childNodes).forEach(i=>{var o;if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(!wge.has(a.localName.toLowerCase())){a.remove();return}Array.from(a.attributes).forEach(s=>{xge.has(s.name.toLowerCase())||a.removeAttribute(s.name)}),n(a)}else i.nodeType!==Node.TEXT_NODE&&((o=i.parentNode)==null||o.removeChild(i))})};return n(e.body),e.body.innerHTML},Ege=()=>new Promise((t,e)=>{if(window.katex){t(window.katex);return}if(W9){const i=setInterval(()=>{window.katex&&(clearInterval(i),t(window.katex))},100);return}W9=!0;const n=document.createElement("link");n.rel="stylesheet",n.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(n);const r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",r.onload=()=>t(window.katex),r.onerror=e,document.head.appendChild(r)}),K9=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0).startContainer,n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(n==null?void 0:n.closest(".rte-content, .editora-content"))||null},Cge=t=>t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null,V9=t=>{const e=Cge(t);return(e==null?void 0:e.closest('.rte-content, .editora-content, [contenteditable="true"]'))||null},Tge=(t,e,n)=>{if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch(r){}}},kge=t=>{if(!(t instanceof Element))return null;const e=t.closest(".math-formula, .math-block");return e instanceof HTMLElement?e:null},zA=()=>{Nl&&(Nl.classList.remove("math-object-selected"),Nl.removeAttribute("data-rte-selected-object"),Nl=null)},Bge=t=>{if(Nl===t)return;zA(),Nl=t,t.classList.add("math-object-selected"),t.setAttribute("data-rte-selected-object","true");const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNode(t),e.removeAllRanges(),e.addRange(n)},Sge=(t,e)=>{const n=window.getSelection();if(!n)return;const r=document.createRange();e&&e.parentNode===t?r.setStartBefore(e):(r.selectNodeContents(t),r.collapse(!1)),r.collapse(!0),n.removeAllRanges(),n.addRange(r)},_ge=t=>{if(t.childNodes.length>0)return;const e=document.createElement("p");e.appendChild(document.createElement("br")),t.appendChild(e)},Dge=()=>{if(!Nl||!Nl.isConnected)return zA(),!1;const t=Nl,e=V9(t);if(!e)return zA(),!1;const n=e.innerHTML,r=t.nextSibling;t.remove(),_ge(e),zA(),Sge(e,r);const i=e.innerHTML;return Tge(e,n,i),e.dispatchEvent(new window.Event("input",{bubbles:!0})),n!==i},Lge=()=>{if(document.getElementById("math-object-selection-styles"))return;const t=document.createElement("style");t.id="math-object-selection-styles",t.textContent=`
|
|
7518
7519
|
.math-object-selected {
|
|
7519
7520
|
outline: 2px solid #2563eb !important;
|
|
7520
7521
|
outline-offset: 2px;
|
|
7521
7522
|
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
7522
7523
|
}
|
|
7523
|
-
`,document.head.appendChild(t)},Fge=()=>{typeof window=="undefined"||window.__mathPluginObjectSelectionInitialized||(window.__mathPluginObjectSelectionInitialized=!0,Lge(),document.addEventListener("pointerdown",t=>{var n,r;const e=kge(t.target);if(!e){const i=t.target;(n=i==null?void 0:i.closest)!=null&&n.call(i,".math-dialog-overlay")||zA();return}t.preventDefault(),(r=
|
|
7524
|
+
`,document.head.appendChild(t)},Fge=()=>{typeof window=="undefined"||window.__mathPluginObjectSelectionInitialized||(window.__mathPluginObjectSelectionInitialized=!0,Lge(),document.addEventListener("pointerdown",t=>{var n,r;const e=kge(t.target);if(!e){const i=t.target;(n=i==null?void 0:i.closest)!=null&&n.call(i,".math-dialog-overlay")||zA();return}t.preventDefault(),(r=V9(e))==null||r.focus(),Bge(e)},!0),document.addEventListener("keydown",t=>{if(Nl){if(t.key==="Escape"){zA();return}t.key!=="Backspace"&&t.key!=="Delete"||(t.preventDefault(),t.stopPropagation(),Dge())}},!0))},Ige=t=>{const e=t||K9();if(e!=null&&e.closest(f1))return!0;const n=window.getSelection();if(n&&n.rangeCount>0){const i=n.getRangeAt(0).startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;if(o!=null&&o.closest(f1))return!0}const r=document.activeElement;return r!=null&&r.closest(f1)?!0:document.body.matches(f1)||document.documentElement.matches(f1)},G9=async(t,e)=>{document.querySelectorAll(".math-dialog-overlay").forEach(F=>F.remove());const n=e||(qg==null?void 0:qg.closest(".rte-content, .editora-content"))||K9()||Wg;Wg=n||null;const r=window.getSelection();if(r&&r.rangeCount>0){const F=r.getRangeAt(0);vx=n&&n.contains(F.commonAncestorContainer)?F.cloneRange():null}await Ege();const i=Ige(n),o=i?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},a=document.createElement("div");Io(a),a.className="math-dialog-overlay",a.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${o.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const s=document.createElement("div");s.style.cssText=`background: ${o.dialogBg}; border: 1px solid ${o.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${o.text};`;let c=(t==null?void 0:t.format)||"latex",l=(t==null?void 0:t.formula)||"";const u=(t==null?void 0:t.inline)!==!1;let d=null,f="";s.innerHTML=`
|
|
7524
7525
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${o.border}; background: ${o.panelBg};">
|
|
7525
7526
|
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${o.text};">${t?"Edit":"Insert"} Math Formula</h2>
|
|
7526
7527
|
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${o.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
|
|
@@ -7564,7 +7565,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7564
7565
|
<div style="font-weight: 600; font-size: 12px; color: ${o.templateBtnText};">${v.name}</div>
|
|
7565
7566
|
<div style="font-size: 10px; color: ${o.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${v.formula.substring(0,20)}...</div>
|
|
7566
7567
|
</button>
|
|
7567
|
-
`).join("")},_=()=>{const F=A.value.trim(),v=`${c}:${F}`;if(v!==f){if(f=v,!F){h.innerHTML=`<span style="color: ${o.previewText};">Enter a formula to see preview</span>`,b.disabled=!0;return}b.disabled=!1;try{if(c==="latex"){const P=window.katex;h.innerHTML=P.renderToString(F,{displayMode:!1,throwOnError:!1})}else F.trim().startsWith("<math")?h.innerHTML=wx(F):h.innerHTML=wx(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${F}</math>`)}catch(P){h.innerHTML=`<span style="color: ${o.invalid};">Invalid formula</span>`}}},B=()=>{d!==null&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=null,_()})},I=F=>{F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),R())},R=()=>{document.removeEventListener("keydown",I,!0),d!==null&&(cancelAnimationFrame(d),d=null),a.parentNode&&a.parentNode.removeChild(a)};y.onmouseover=()=>{y.style.color="#f8fafc",y.style.background=i?"#334155":"#e5e7eb",y.style.borderRadius="4px"},y.onmouseout=()=>{y.style.color=o.muted,y.style.background="none"},w.onmouseover=()=>{w.style.background=i?"#475569":"#f3f4f6"},w.onmouseout=()=>{w.style.background=o.cancelBg},b.onmouseover=()=>{b.disabled||(b.style.background=o.insertHover)},b.onmouseout=()=>{b.style.background=o.insertBg},p.addEventListener("mouseover",F=>{const P=F.target.closest("button[data-formula]");P&&(P.style.background=o.templateBtnHover)}),p.addEventListener("mouseout",F=>{const P=F.target.closest("button[data-formula]");P&&(P.style.background=o.templateBtnBg)}),p.addEventListener("click",F=>{const P=F.target.closest("button[data-formula]");P&&(A.value=k(P.getAttribute("data-formula")||""),l=A.value,B())});const C=()=>{const F=A.value.trim();if(!F)return;const v={formula:F,format:c,inline:g.checked},P=v.inline?document.createElement("span"):document.createElement("div");if(P.className=v.inline?"math-formula":"math-block",P.setAttribute("data-math-formula",F),P.setAttribute("data-math-format",c),P.contentEditable="false",P.style.cssText=v.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",c==="latex"){const q=window.katex;try{P.innerHTML=q.renderToString(F,{displayMode:!v.inline,throwOnError:!1})}catch(ie){P.textContent=v.inline?`$${F}$`:`$$${F}$$`}}else if(F.trim().startsWith("<math"))P.innerHTML=wx(F);else{const q=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${v.inline?"inline":"block"}">${F}</math>`;P.innerHTML=wx(q)}if(qg)qg.replaceWith(P);else if(vx)vx.deleteContents(),vx.insertNode(P);else if(Wg&&Wg.isConnected){const q=document.createRange();q.selectNodeContents(Wg),q.collapse(!1),q.insertNode(P)}const W=P.closest(".rte-content, .editora-content")||Wg;W==null||W.dispatchEvent(new Event("input",{bubbles:!0})),R()};y.addEventListener("click",R),w.addEventListener("click",R),b.addEventListener("click",C),a.addEventListener("click",F=>{F.target===a&&R()}),document.addEventListener("keydown",I,!0),m.forEach(F=>{F.addEventListener("change",v=>{c=v.target.value,f="",T(),B()})}),A.addEventListener("input",()=>{l=A.value,B()}),A.addEventListener("keydown",F=>{(F.ctrlKey||F.metaKey)&&F.key==="Enter"&&(F.preventDefault(),C())}),T(),B(),A.focus()};if(typeof window!="undefined"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const t=n=>{const i=n.target.closest(".math-formula, .math-block");if(i){n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),zA(),qg=i;const o=i.getAttribute("data-math-formula")||"",a=i.getAttribute("data-math-format")||"latex",s=i.classList.contains("math-formula");
|
|
7568
|
+
`).join("")},_=()=>{const F=A.value.trim(),v=`${c}:${F}`;if(v!==f){if(f=v,!F){h.innerHTML=`<span style="color: ${o.previewText};">Enter a formula to see preview</span>`,b.disabled=!0;return}b.disabled=!1;try{if(c==="latex"){const P=window.katex;h.innerHTML=P.renderToString(F,{displayMode:!1,throwOnError:!1})}else F.trim().startsWith("<math")?h.innerHTML=wx(F):h.innerHTML=wx(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${F}</math>`)}catch(P){h.innerHTML=`<span style="color: ${o.invalid};">Invalid formula</span>`}}},B=()=>{d!==null&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=null,_()})},I=F=>{F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),R())},R=()=>{document.removeEventListener("keydown",I,!0),d!==null&&(cancelAnimationFrame(d),d=null),a.parentNode&&a.parentNode.removeChild(a)};y.onmouseover=()=>{y.style.color="#f8fafc",y.style.background=i?"#334155":"#e5e7eb",y.style.borderRadius="4px"},y.onmouseout=()=>{y.style.color=o.muted,y.style.background="none"},w.onmouseover=()=>{w.style.background=i?"#475569":"#f3f4f6"},w.onmouseout=()=>{w.style.background=o.cancelBg},b.onmouseover=()=>{b.disabled||(b.style.background=o.insertHover)},b.onmouseout=()=>{b.style.background=o.insertBg},p.addEventListener("mouseover",F=>{const P=F.target.closest("button[data-formula]");P&&(P.style.background=o.templateBtnHover)}),p.addEventListener("mouseout",F=>{const P=F.target.closest("button[data-formula]");P&&(P.style.background=o.templateBtnBg)}),p.addEventListener("click",F=>{const P=F.target.closest("button[data-formula]");P&&(A.value=k(P.getAttribute("data-formula")||""),l=A.value,B())});const C=()=>{const F=A.value.trim();if(!F)return;const v={formula:F,format:c,inline:g.checked},P=v.inline?document.createElement("span"):document.createElement("div");if(P.className=v.inline?"math-formula":"math-block",P.setAttribute("data-math-formula",F),P.setAttribute("data-math-format",c),P.contentEditable="false",P.style.cssText=v.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",c==="latex"){const q=window.katex;try{P.innerHTML=q.renderToString(F,{displayMode:!v.inline,throwOnError:!1})}catch(ie){P.textContent=v.inline?`$${F}$`:`$$${F}$$`}}else if(F.trim().startsWith("<math"))P.innerHTML=wx(F);else{const q=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${v.inline?"inline":"block"}">${F}</math>`;P.innerHTML=wx(q)}if(qg)qg.replaceWith(P);else if(vx)vx.deleteContents(),vx.insertNode(P);else if(Wg&&Wg.isConnected){const q=document.createRange();q.selectNodeContents(Wg),q.collapse(!1),q.insertNode(P)}const W=P.closest(".rte-content, .editora-content")||Wg;W==null||W.dispatchEvent(new Event("input",{bubbles:!0})),R()};y.addEventListener("click",R),w.addEventListener("click",R),b.addEventListener("click",C),a.addEventListener("click",F=>{F.target===a&&R()}),document.addEventListener("keydown",I,!0),m.forEach(F=>{F.addEventListener("change",v=>{c=v.target.value,f="",T(),B()})}),A.addEventListener("input",()=>{l=A.value,B()}),A.addEventListener("keydown",F=>{(F.ctrlKey||F.metaKey)&&F.key==="Enter"&&(F.preventDefault(),C())}),T(),B(),A.focus()};if(typeof window!="undefined"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const t=n=>{const i=n.target.closest(".math-formula, .math-block");if(i){n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),zA(),qg=i;const o=i.getAttribute("data-math-formula")||"",a=i.getAttribute("data-math-format")||"latex",s=i.classList.contains("math-formula");G9({formula:o,format:a,inline:s})}},e=()=>{document.addEventListener("dblclick",t,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const Uge=Object.freeze(Object.defineProperty({__proto__:null,MathPlugin:()=>({name:"math",init:Fge,toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:(t,e)=>{const n=(e==null?void 0:e.contentElement)instanceof HTMLElement?e.contentElement:null;return G9(void 0,n),!0}},keymap:{"Mod-Shift-m":"insertMath"}})},Symbol.toStringTag,{value:"Module"}));let xx=null,_r=null,Yn=null;const Ex=[];let Cx=!1,A1=null,X9=0,Y9=0,jA=0,qA=0,__=1,h1=null;const Z9='[data-theme="dark"], .dark, .editora-theme-dark',Tx=(t,e)=>{const n=r=>{r.key!=="Escape"||!t.isConnected||(r.preventDefault(),r.stopPropagation(),e())};return document.addEventListener("keydown",n,!0),()=>{document.removeEventListener("keydown",n,!0)}},Nge=()=>{if(typeof document=="undefined"||document.getElementById("rte-media-dialog-styles"))return;const t=document.createElement("style");t.id="rte-media-dialog-styles",t.textContent=`
|
|
7568
7569
|
.rte-media-overlay {
|
|
7569
7570
|
--rte-media-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
7570
7571
|
--rte-media-bg: #ffffff;
|
|
@@ -7942,7 +7943,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7942
7943
|
}
|
|
7943
7944
|
|
|
7944
7945
|
.media-floating-toolbar.rte-ui-theme-dark,
|
|
7945
|
-
${
|
|
7946
|
+
${Z9} .media-floating-toolbar {
|
|
7946
7947
|
--rte-media-toolbar-bg: #24303f;
|
|
7947
7948
|
--rte-media-toolbar-border: #4a5a71;
|
|
7948
7949
|
--rte-media-toolbar-text: #d9e6fb;
|
|
@@ -7990,7 +7991,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
7990
7991
|
margin: 0 2px;
|
|
7991
7992
|
background: var(--rte-media-toolbar-separator);
|
|
7992
7993
|
}
|
|
7993
|
-
`,document.head.appendChild(t)},Rge=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode,n=e instanceof HTMLElement?e:e==null?void 0:e.parentElement;return(n==null?void 0:n.closest(".rte-content, .editora-content"))||null},Oge=t=>{if(t)return t;const e=Rge();if(e)return e;if(h1)return h1;const n=document.activeElement;return n?n.closest(".rte-content, .editora-content")||n:null},
|
|
7994
|
+
`,document.head.appendChild(t)},Rge=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode,n=e instanceof HTMLElement?e:e==null?void 0:e.parentElement;return(n==null?void 0:n.closest(".rte-content, .editora-content"))||null},Oge=t=>{if(t)return t;const e=Rge();if(e)return e;if(h1)return h1;const n=document.activeElement;return n?n.closest(".rte-content, .editora-content")||n:null},J9=t=>{const e=Oge(t);return e?!!e.closest(Z9):!1},kx=t=>{Nge();const e=document.createElement("div");return Io(e),e.className="rte-media-overlay",J9(t)&&e.classList.add("rte-ui-theme-dark"),e},Bx=(t=!1)=>{const e=document.createElement("div");return e.className=t?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e},eQ=(t,e)=>{document.querySelectorAll(".rte-media-overlay").forEach(m=>m.remove());const n=window.getSelection();n&&n.rangeCount>0&&(xx=n.getRangeAt(0).cloneRange());const r=kx(e),i=Bx();let o="upload",a="",s="",c="",l="";const u=()=>{i.innerHTML=`
|
|
7994
7995
|
<div class="rte-media-header">
|
|
7995
7996
|
<h2 class="rte-media-title">Insert ${t==="image"?"Image":"Video"}</h2>
|
|
7996
7997
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -8156,7 +8157,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
8156
8157
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
8157
8158
|
<button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!i&&r==="url"?"disabled":""}>Replace</button>
|
|
8158
8159
|
</div>
|
|
8159
|
-
`};o(),e.appendChild(n),document.body.appendChild(e);let a=()=>{};const s=()=>{a(),e.parentNode&&e.parentNode.removeChild(e)};a=Tx(e,s);const c=()=>{i&&(t.src=i,s())},l=async d=>{const f=n.querySelector("#upload-progress"),A=n.querySelector("#progress-bar"),h=n.querySelector("#progress-text");if(f&&A&&h){f.style.display="block";let p=0;const m=setInterval(()=>{p+=Math.random()*30,p>90&&(p=90),A.style.width=`${p}%`},200);try{const g=new FileReader;g.onload=()=>{clearInterval(m),A.style.width="100%",h.textContent="Upload complete",setTimeout(()=>{i=g.result,r="url",o(),u()},500)},g.readAsDataURL(d)}catch(g){clearInterval(m),h.textContent="Upload failed"}}},u=()=>{const d=n.querySelector(".close-btn"),f=n.querySelector(".cancel-btn"),A=n.querySelector("#replace-btn"),h=n.querySelector(".tab-upload"),p=n.querySelector(".tab-url");if(d==null||d.addEventListener("click",s),f==null||f.addEventListener("click",s),A==null||A.addEventListener("click",c),h==null||h.addEventListener("click",()=>{r="upload",o(),u()}),p==null||p.addEventListener("click",()=>{r="url",o(),u()}),r==="upload"){const m=n.querySelector(".dropzone"),g=n.querySelector("#file-input");m==null||m.addEventListener("click",()=>g==null?void 0:g.click()),m==null||m.addEventListener("dragover",b=>{b.preventDefault(),m.classList.add("is-dragover")}),m==null||m.addEventListener("dragleave",()=>{m.classList.remove("is-dragover")}),m==null||m.addEventListener("drop",b=>{var w;b.preventDefault(),m.classList.remove("is-dragover");const y=(w=b.dataTransfer)==null?void 0:w.files[0];y&&l(y)}),g==null||g.addEventListener("change",b=>{var w;const y=(w=b.target.files)==null?void 0:w[0];y&&l(y)})}if(r==="url"){const m=n.querySelector("#url-input");m==null||m.addEventListener("input",()=>{i=m.value,o(),u()})}};u(),e.addEventListener("click",d=>{d.target===e&&s()})},Rl=()=>{if(!Yn||!_r)return;const t=Yn.offsetHeight||40,e=_r.offsetTop,n=_r.offsetLeft,r=_r.offsetWidth,i=e-t-8,o=n+r/2-(Yn.offsetWidth||120)/2;Yn.style.top=`${i}px`,Yn.style.left=`${o}px`,setTimeout(()=>{Yn&&(Yn.style.display="flex")},100)},D_=t=>{var s,c,l,u,d,f,A,h;Yn&&(Yn._cleanup&&Yn._cleanup(),Yn.remove());const e=t.parentElement;if(e){const p=e.style.position;(!p||p==="static")&&(e.style.position="relative",e._originalPosition=p),Yn=document.createElement("div"),Yn.className="media-floating-toolbar",
|
|
8160
|
+
`};o(),e.appendChild(n),document.body.appendChild(e);let a=()=>{};const s=()=>{a(),e.parentNode&&e.parentNode.removeChild(e)};a=Tx(e,s);const c=()=>{i&&(t.src=i,s())},l=async d=>{const f=n.querySelector("#upload-progress"),A=n.querySelector("#progress-bar"),h=n.querySelector("#progress-text");if(f&&A&&h){f.style.display="block";let p=0;const m=setInterval(()=>{p+=Math.random()*30,p>90&&(p=90),A.style.width=`${p}%`},200);try{const g=new FileReader;g.onload=()=>{clearInterval(m),A.style.width="100%",h.textContent="Upload complete",setTimeout(()=>{i=g.result,r="url",o(),u()},500)},g.readAsDataURL(d)}catch(g){clearInterval(m),h.textContent="Upload failed"}}},u=()=>{const d=n.querySelector(".close-btn"),f=n.querySelector(".cancel-btn"),A=n.querySelector("#replace-btn"),h=n.querySelector(".tab-upload"),p=n.querySelector(".tab-url");if(d==null||d.addEventListener("click",s),f==null||f.addEventListener("click",s),A==null||A.addEventListener("click",c),h==null||h.addEventListener("click",()=>{r="upload",o(),u()}),p==null||p.addEventListener("click",()=>{r="url",o(),u()}),r==="upload"){const m=n.querySelector(".dropzone"),g=n.querySelector("#file-input");m==null||m.addEventListener("click",()=>g==null?void 0:g.click()),m==null||m.addEventListener("dragover",b=>{b.preventDefault(),m.classList.add("is-dragover")}),m==null||m.addEventListener("dragleave",()=>{m.classList.remove("is-dragover")}),m==null||m.addEventListener("drop",b=>{var w;b.preventDefault(),m.classList.remove("is-dragover");const y=(w=b.dataTransfer)==null?void 0:w.files[0];y&&l(y)}),g==null||g.addEventListener("change",b=>{var w;const y=(w=b.target.files)==null?void 0:w[0];y&&l(y)})}if(r==="url"){const m=n.querySelector("#url-input");m==null||m.addEventListener("input",()=>{i=m.value,o(),u()})}};u(),e.addEventListener("click",d=>{d.target===e&&s()})},Rl=()=>{if(!Yn||!_r)return;const t=Yn.offsetHeight||40,e=_r.offsetTop,n=_r.offsetLeft,r=_r.offsetWidth,i=e-t-8,o=n+r/2-(Yn.offsetWidth||120)/2;Yn.style.top=`${i}px`,Yn.style.left=`${o}px`,setTimeout(()=>{Yn&&(Yn.style.display="flex")},100)},D_=t=>{var s,c,l,u,d,f,A,h;Yn&&(Yn._cleanup&&Yn._cleanup(),Yn.remove());const e=t.parentElement;if(e){const p=e.style.position;(!p||p==="static")&&(e.style.position="relative",e._originalPosition=p),Yn=document.createElement("div"),Yn.className="media-floating-toolbar",J9(t)&&Yn.classList.add("rte-ui-theme-dark"),e.insertBefore(Yn,e.firstChild),Rl()}const n=Yn;if(!n)return;const r=t.tagName==="IMG",i=t.closest("a");n.innerHTML=`
|
|
8160
8161
|
<button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
|
|
8161
8162
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
|
|
8162
8163
|
</button>
|
|
@@ -8182,7 +8183,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
8182
8183
|
<button class="media-floating-toolbar-btn btn-remove" title="Remove" type="button">
|
|
8183
8184
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
8184
8185
|
</button>
|
|
8185
|
-
`,setTimeout(()=>{Rl()},0);const o=()=>Rl();let a=t.parentElement;for(;a;)a.addEventListener("scroll",o),a=a.parentElement;window.addEventListener("scroll",o),window.addEventListener("resize",o),n._cleanup=()=>{let p=t.parentElement;for(;p;)p.removeEventListener("scroll",o),p=p.parentElement;window.removeEventListener("scroll",o),window.removeEventListener("resize",o)},(s=n.querySelector(".btn-align-left"))==null||s.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto",Rl()}),(c=n.querySelector(".btn-align-center"))==null||c.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto",Rl()}),(l=n.querySelector(".btn-align-right"))==null||l.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0",Rl()}),(u=n.querySelector(".btn-alt"))==null||u.addEventListener("click",()=>{t.tagName==="IMG"&&Pge(t)}),(d=n.querySelector(".btn-link"))==null||d.addEventListener("click",()=>{Hge(t)}),(f=n.querySelector(".btn-replace"))==null||f.addEventListener("click",()=>{t.tagName==="IMG"&&Qge(t)}),(A=n.querySelector(".btn-resize"))==null||A.addEventListener("click",()=>{const p=prompt("Enter width in pixels:",String(t.width||t.offsetWidth));if(p&&!isNaN(parseInt(p))){const m=parseInt(p);t.style.width=`${m}px`,t.setAttribute("width",String(m)),WA(),Rl()}}),(h=n.querySelector(".btn-remove"))==null||h.addEventListener("click",()=>{confirm("Remove this media?")&&(t.remove(),Yn&&(Yn._cleanup&&Yn._cleanup(),Yn.remove(),Yn=null),_r=null,WA())}),n._cleanup=()=>{window.removeEventListener("scroll",Rl),window.removeEventListener("resize",Rl)}},tQ=t=>{h1=t||null,Mge(),document.addEventListener("click",e=>{const n=e.target;if(n.tagName==="IMG"||n.tagName==="VIDEO"){const r=n;let i=!1;if(h1?i=h1.contains(r):i=!!r.closest('[contenteditable="true"]'),i){e.preventDefault(),e.stopPropagation(),_r=r,_r.style.display="block",D_(r),WA();return}}if(!n.closest(".btn-link, .btn-resize, .btn-remove")&&Yn&&!n.closest("button")){if(Yn._cleanup&&Yn._cleanup(),Yn.remove(),Yn=null,_r&&_r.parentElement){const r=_r.parentElement;r._originalPosition!==void 0&&(r.style.position=r._originalPosition,delete r._originalPosition)}_r=null,WA()}}),Ex.forEach(e=>{e.addEventListener("mousedown",n=>{if(!_r)return;n.preventDefault(),n.stopPropagation(),Cx=!0,A1=e.getAttribute("data-position"),
|
|
8186
|
+
`,setTimeout(()=>{Rl()},0);const o=()=>Rl();let a=t.parentElement;for(;a;)a.addEventListener("scroll",o),a=a.parentElement;window.addEventListener("scroll",o),window.addEventListener("resize",o),n._cleanup=()=>{let p=t.parentElement;for(;p;)p.removeEventListener("scroll",o),p=p.parentElement;window.removeEventListener("scroll",o),window.removeEventListener("resize",o)},(s=n.querySelector(".btn-align-left"))==null||s.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="0",t.style.marginRight="auto",Rl()}),(c=n.querySelector(".btn-align-center"))==null||c.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="auto",Rl()}),(l=n.querySelector(".btn-align-right"))==null||l.addEventListener("click",()=>{t.style.display="block",t.style.marginLeft="auto",t.style.marginRight="0",Rl()}),(u=n.querySelector(".btn-alt"))==null||u.addEventListener("click",()=>{t.tagName==="IMG"&&Pge(t)}),(d=n.querySelector(".btn-link"))==null||d.addEventListener("click",()=>{Hge(t)}),(f=n.querySelector(".btn-replace"))==null||f.addEventListener("click",()=>{t.tagName==="IMG"&&Qge(t)}),(A=n.querySelector(".btn-resize"))==null||A.addEventListener("click",()=>{const p=prompt("Enter width in pixels:",String(t.width||t.offsetWidth));if(p&&!isNaN(parseInt(p))){const m=parseInt(p);t.style.width=`${m}px`,t.setAttribute("width",String(m)),WA(),Rl()}}),(h=n.querySelector(".btn-remove"))==null||h.addEventListener("click",()=>{confirm("Remove this media?")&&(t.remove(),Yn&&(Yn._cleanup&&Yn._cleanup(),Yn.remove(),Yn=null),_r=null,WA())}),n._cleanup=()=>{window.removeEventListener("scroll",Rl),window.removeEventListener("resize",Rl)}},tQ=t=>{h1=t||null,Mge(),document.addEventListener("click",e=>{const n=e.target;if(n.tagName==="IMG"||n.tagName==="VIDEO"){const r=n;let i=!1;if(h1?i=h1.contains(r):i=!!r.closest('[contenteditable="true"]'),i){e.preventDefault(),e.stopPropagation(),_r=r,_r.style.display="block",D_(r),WA();return}}if(!n.closest(".btn-link, .btn-resize, .btn-remove")&&Yn&&!n.closest("button")){if(Yn._cleanup&&Yn._cleanup(),Yn.remove(),Yn=null,_r&&_r.parentElement){const r=_r.parentElement;r._originalPosition!==void 0&&(r.style.position=r._originalPosition,delete r._originalPosition)}_r=null,WA()}}),Ex.forEach(e=>{e.addEventListener("mousedown",n=>{if(!_r)return;n.preventDefault(),n.stopPropagation(),Cx=!0,A1=e.getAttribute("data-position"),X9=n.clientX,Y9=n.clientY;const r=_r.getBoundingClientRect();jA=r.width,qA=r.height,__=jA/qA,document.body.style.userSelect="none",document.body.style.cursor=`${A1}-resize`})}),document.addEventListener("mousemove",e=>{if(!Cx||!_r||!A1)return;const n=e.clientX-X9,r=e.clientY-Y9;let i=jA,o=qA;switch(A1){case"se":i=jA+n,o=qA+r;break;case"sw":i=jA-n,o=qA+r;break;case"ne":i=jA+n,o=qA-r;break;case"nw":i=jA-n,o=qA-r;break}Math.abs(n)>Math.abs(r)?o=i/__:i=o*__,i=Math.max(50,i),o=Math.max(50,o),_r.style.width=`${i}px`,_r.style.height=`${o}px`,_r.setAttribute("width",String(Math.round(i))),_r.setAttribute("height",String(Math.round(o))),WA(),Rl()}),document.addEventListener("mouseup",()=>{Cx&&(Cx=!1,A1=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",WA),window.addEventListener("resize",WA)};typeof window!="undefined"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,tQ());const $ge=Object.freeze(Object.defineProperty({__proto__:null,MediaManagerPlugin:()=>({name:"image",initialize:t=>{const e=t==null?void 0:t.editorElement;tQ(e)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(t,e)=>{const n=(e==null?void 0:e.contentElement)instanceof HTMLElement?e.contentElement:void 0;return eQ("image",n),!0},insertVideo:(t,e)=>{const n=(e==null?void 0:e.contentElement)instanceof HTMLElement?e.contentElement:void 0;return eQ("video",n),!0}},keymap:{"Mod-Shift-i":"insertImage"}})},Symbol.toStringTag,{value:"Module"})),Kg=".rte-content, .editora-content",zge='[data-theme="dark"], .dark, .editora-theme-dark',jge={title:"Insert Merge Tag",searchPlaceholder:"Search merge tags...",emptyStateText:"No merge tags found",cancelText:"Cancel",insertText:"Insert",showPreview:!0};function qge(){return[{id:"USER",name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},{id:"COMPANY",name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},{id:"DATE",name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},{id:"CUSTOM",name:"Custom",tags:[]}]}function L_(t,e){return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`CATEGORY_${e+1}`}function Wge(t,e){return(t.key||t.value||t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`tag_${e+1}`}function Kge(t){const e=(()=>{if(Array.isArray(t==null?void 0:t.categories)&&t.categories.length>0)return t.categories;if(Array.isArray(t==null?void 0:t.tags)&&t.tags.length>0){const a=new Map;return t.tags.forEach(s=>{const c=(s.category||"Custom").trim()||"Custom",l=a.get(c);l?l.push(s):a.set(c,[s])}),Array.from(a.entries()).map(([s,c],l)=>({id:L_(s,l),name:s,tags:c}))}return qge()})(),n={},r=[];if(e.forEach((a,s)=>{const c=L_(a.id||a.name,s);r.push(c),n[c]={name:a.name,tags:(Array.isArray(a.tags)?a.tags:[]).map((l,u)=>{var A,h;const d=Wge(l,u),f=(l.category||a.name).trim()||a.name;return{...l,key:d,category:f,categoryKey:c,searchIndex:`${l.label} ${d} ${f} ${(A=l.description)!=null?A:""} ${(h=l.value)!=null?h:""}`.toLowerCase()}})}}),r.length===0){const a="CUSTOM";r.push(a),n[a]={name:"Custom",tags:[]}}const i=t!=null&&t.defaultCategory?L_(t.defaultCategory,0):null,o=i&&r.includes(i)?i:r[0];return{categoriesByKey:n,categoryKeys:r,defaultCategory:o}}function Vge(t){const e=t==null?void 0:t.tokenTemplate;return typeof e=="function"?n=>{var i;const r=e(n);return typeof r=="string"&&r.trim()?r:((i=n.value)==null?void 0:i.trim())||`{{ ${n.label} }}`}:typeof e=="string"&&e.trim()?n=>{var r;return e.replace(/\{key\}/gi,n.key).replace(/\{label\}/gi,n.label).replace(/\{category\}/gi,n.category).replace(/\{value\}/gi,(r=n.value)!=null?r:"")}:n=>{var r;return((r=n.value)==null?void 0:r.trim())||`{{ ${n.label} }}`}}function Gge(t){return{catalog:Kge(t),dialog:{...jge,...(t==null?void 0:t.dialog)||{}},formatToken:Vge(t)}}let nQ=!1,rQ=!1,Vg=null,Sx=null,p1=null,iQ=!1,us=null;function oQ(t,e){if(e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch(r){}}function F_(){if(nQ||typeof document=="undefined")return;nQ=!0;const t=document.createElement("style");t.id="merge-tag-plugin-styles",t.textContent=`
|
|
8186
8187
|
.rte-merge-tag-overlay {
|
|
8187
8188
|
--rte-mt-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
8188
8189
|
--rte-mt-dialog-bg: #ffffff;
|