@ryzeup/richtexteditor 1.0.27 â 1.0.29
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/dist/index.es.js +464 -445
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var ht=Object.defineProperty,pt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Te=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var Ae=(a,c,u)=>c in a?ht(a,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[c]=u,oe=(a,c)=>{for(var u in c||(c={}))yt.call(c,u)&&Ae(a,u,c[u]);if(Te)for(var u of Te(c))Et.call(c,u)&&Ae(a,u,c[u]);return a},le=(a,c)=>pt(a,vt(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),wt=require("react-dom");function Ct(a){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(c,u,m.get?m:{enumerable:!0,get:()=>a[u]})}}return c.default=a,Object.freeze(c)}const bt=Ct(r);window.React=bt;var Oe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ne=r.createContext&&r.createContext(Oe),Lt=["attr","size","title"];function Rt(a,c){if(a==null)return{};var u=St(a,c),m,p;if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(a);for(p=0;p<b.length;p++)m=b[p],!(c.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(u[m]=a[m])}return u}function St(a,c){if(a==null)return{};var u={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(c.indexOf(m)>=0)continue;u[m]=a[m]}return u}function Q(){return Q=Object.assign?Object.assign.bind():function(a){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(a[m]=u[m])}return a},Q.apply(this,arguments)}function ke(a,c){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);c&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(a,p).enumerable})),u.push.apply(u,m)}return u}function J(a){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?ke(Object(u),!0).forEach(function(m){xt(a,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):ke(Object(u)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(u,m))})}return a}function xt(a,c,u){return c=Mt(c),c in a?Object.defineProperty(a,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[c]=u,a}function Mt(a){var c=Tt(a,"string");return typeof c=="symbol"?c:c+""}function Tt(a,c){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var m=u.call(a,c);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}function He(a){return a&&a.map((c,u)=>r.createElement(c.tag,J({key:u},c.attr),He(c.child)))}function N(a){return c=>r.createElement(At,Q({attr:J({},a.attr)},c),He(a.child))}function At(a){var c=u=>{var{attr:m,size:p,title:b}=a,x=Rt(a,Lt),T=p||u.size||"1em",E;return u.className&&(E=u.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",Q({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,x,{className:E,style:J(J({color:a.color||u.color},u.style),a.style),height:T,width:T,xmlns:"http://www.w3.org/2000/svg"}),b&&r.createElement("title",null,b),a.children)};return Ne!==void 0?r.createElement(Ne.Consumer,null,u=>c(u)):c(Oe)}function Nt(a){return N({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(a)}function kt(a){return N({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function zt(a){return N({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function Dt(a){return N({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function Ot(a){return N({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Ht(a){return N({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function jt(a){return N({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function _t(a){return N({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Ft(a){return N({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function Pt(a){return N({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function It(a){return N({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(a)}function qt(a){return N({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Bt(a){return N({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(a)}function Vt(a){return N({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(a)}function Ut(a){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(a)}function $t(a){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(a)}function Wt(a){return N({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(a)}function Zt(a){return N({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(a)}const Xt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],je=({exec:a,saveSelection:c,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:b,handleLink:x,removeFormatting:T,visibleActions:E,className:w,style:R})=>{var $,q;const S=r.useRef(null),D=r.useRef(null),k=r.useRef(null),[O,j]=r.useState(!1),[P,z]=r.useState({x:0,y:0});r.useEffect(()=>{const g=L=>{!L.target.closest(".rte-emoji-popup")&&!L.target.closest("button[title='Emoji']")&&j(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const H=g=>{var B;g.preventDefault();const L=g.currentTarget.dataset.command;if(L)switch(L){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(L);break;case"insertImage":{(B=S.current)==null||B.click();break}default:console.warn("Unknown command:",L)}},V=g=>{a("foreColor",g.target.value)},U=g=>{a("backColor",g.target.value)},[M,_]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const g=()=>{_({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),r.createElement("div",{className:`rte-toolbar ${w||""}`,style:R},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:H,className:M.bold?"rte-active":""},r.createElement(Ht,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:H,className:M.italic?"rte-active":""},r.createElement(_t,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:H,className:M.underline?"rte-active":""},r.createElement(qt,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:H,title:"UnorderedList",className:M.unorderedList?"rte-active":""},r.createElement(Vt,null)),E.staticUnorderedList&&r.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:H,title:"StaticUnorderedList",className:M.unorderedList?"rte-active":""},r.createElement(Pt,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:H,className:M.orderedList?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Bt,null)),E.staticOrderedList&&r.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:H,className:M.orderedList?"rte-active":""},r.createElement(Dt,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:x,className:M.link?"rte-active":""},r.createElement(Ft,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),c(),T()},className:M.removeFormat?"rte-active":""},r.createElement(Zt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:H,className:M.image?"rte-active":""},r.createElement(zt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:S,style:{display:"none"},onChange:u}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),c();const L=g.currentTarget.getBoundingClientRect();z({x:L.left,y:L.bottom+8}),j(B=>!B)},className:M.emoji?"rte-active":""},r.createElement(It,null)),O&&wt.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:P.y,left:P.x}},Xt.map((g,L)=>r.createElement("span",{key:L,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:B=>{B.preventDefault(),b(g),j(!1)}},g))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:g=>{var L;g.preventDefault(),c(),(L=D.current)==null||L.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:(($=D.current)==null?void 0:$.value)||"#000",fontSize:"18px"},className:M.color?"rte-active":""},r.createElement(Wt,null)),r.createElement("input",{ref:D,type:"color",defaultValue:"#000000",onChange:g=>{var L;V(g),((L=g.target.parentElement)==null?void 0:L.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:g=>{var L;g.preventDefault(),c(),(L=k.current)==null||L.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=k.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:M.highlight?"rte-active":""},r.createElement(jt,null)),r.createElement("input",{ref:k,type:"color",onChange:g=>{var L;U(g),((L=g.target.parentElement)==null?void 0:L.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:M.alignLeft?"rte-active":""},r.createElement(Ot,null)),r.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:M.alignCenter?"rte-active":""},r.createElement(Nt,null)),r.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:M.alignRight?"rte-active":""},r.createElement(kt,null))),E.table&&r.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:M.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Ut,null)),E.table&&r.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:M.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement($t,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:p},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,L)=>10+L).map(g=>r.createElement("option",{key:g,value:g},g,"px"))))},Kt=({show:a,position:c,filtered:u,insertMention:m,onClose:p,query:b})=>{const x=r.useRef(null),[T,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const w=R=>{x.current&&!x.current.contains(R.target)&&p()};return a&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[a,p]),r.useEffect(()=>{if(!a)return;const w=R=>{if(!(!a||u.length===0)&&(R.key==="ArrowDown"&&(R.preventDefault(),E(S=>Math.min(S+1,u.length-1))),R.key==="ArrowUp"&&(R.preventDefault(),E(S=>Math.max(S-1,0))),R.key==="Enter")){R.preventDefault();const S=u[T];S&&m(S)}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a,u,T]),r.useEffect(()=>{if(!x.current)return;const R=x.current.querySelectorAll("li")[T];R&&R.scrollIntoView({block:"nearest",behavior:"smooth"})},[T]),a?r.createElement("ul",{ref:x,className:"rte-popup",style:{top:c.y,left:c.x}},u.length>0?u.map(({name:w,value:R},S)=>{const D=w.toLowerCase(),k=b.toLowerCase(),O=D.indexOf(k);let j=w;if(O!==-1&&b.length>0){const P=O+b.length;j=w.substring(0,O)+`<span class="rte-highlight">${w.substring(O,P)}</span>`+w.substring(P)}return r.createElement("li",{key:R,onMouseDown:P=>{P.preventDefault(),m({name:w,value:R})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:S===T?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:j},onMouseEnter:()=>E(S)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ze(a){return N({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function Y(a){return N({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(a)}const Yt=({visible:a,x:c,y:u,onAction:m,onClose:p})=>{if(!a)return null;const b={top:u,left:c};return r.createElement("div",{style:b,className:"rte-table-menu",onMouseLeave:p},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(Y,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(Y,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(Y,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(Y,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(ze,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(ze,null)," Delete column"))},_e=({html:a,className:c,style:u})=>{const m=b=>{const x=b.target;if(x.tagName==="A"){b.preventDefault();const T=x.href;T&&window.open(T,"_blank","noopener,noreferrer")}},p=b=>{const x=document.createElement("div");x.innerHTML=b;const T=document.createTreeWalker(x,NodeFilter.SHOW_TEXT,null),E=[];for(;T.nextNode();){const w=T.currentNode;w.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(w.nodeValue)&&E.push(w)}return E.forEach(w=>{var P;const R=w.nodeValue||"",S=w.parentElement;if(!S)return;let D=S,k=!1;for(;D;){if(D.tagName==="FONT"&&D.getAttribute("color")){k=!0;break}const z=(P=D.style)==null?void 0:P.color;if(z&&z!==""){k=!0;break}const H=window.getComputedStyle(D);if(H.color&&H.color!=="rgb(0, 0, 0)"&&H.color!=="rgba(0, 0, 0, 0)"){k=!0;break}D=D.parentElement}const O=document.createDocumentFragment();let j=0;R.replace(/{{\s*([\s\S]*?)\s*}}/g,(z,H,V)=>{if(V>j&&O.appendChild(document.createTextNode(R.slice(j,V))),k)O.appendChild(document.createTextNode(z));else{const U=document.createElement("span");U.style.color="blue",U.textContent=z,O.appendChild(U)}return j=V+z.length,z}),j<R.length&&O.appendChild(document.createTextNode(R.slice(j))),S.replaceChild(O,w)}),x.innerHTML=x.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),x.innerHTML};return r.createElement("div",{className:`rte-preview ${c||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:p(a)}})},Qt=({visible:a,linkData:c,onClose:u,onInsert:m})=>{const[p,b]=r.useState(""),[x,T]=r.useState(""),[E,w]=r.useState(""),[R,S]=r.useState("_self");if(r.useEffect(()=>{a?(b(c.url||""),T(c.text||""),w(c.title||""),S(c.target||"_self")):(b(""),T(""),w(""),S("_self"))},[a,c]),!a)return null;const D=()=>{m({url:p,text:x,title:E,target:R})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:k=>b(k.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:x,onChange:k=>T(k.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:k=>w(k.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:R,onChange:k=>S(k.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:D},"OK"))))};function De(a){const c=new Map;return a.forEach(u=>{c.set(u.name,u.value)}),Array.from(c.entries()).map(([u,m])=>({name:u,value:m}))}const Jt=({atSuggestions:a=[],showOutput:c=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:b={},handleGetHtml:x=()=>{},onChange:T=()=>{},value:E,onMentionSelect:w=()=>{},handleAddAttributes:R=()=>{}})=>{var pe,ve,ye,Ee,we,Ce,be,Le,Re,Se,xe,Me;const S=r.useRef(null),[D,k]=r.useState(E!=null&&E.length?E:" "),[O,j]=r.useState(""),[P,z]=r.useState(!1),[H,V]=r.useState({x:0,y:0}),[U,M]=r.useState([]),_=r.useRef(null),$=r.useRef(null),[q,g]=r.useState({visible:!1,x:0,y:0}),[L,B]=r.useState(!1),K=r.useRef(null),[Fe,ie]=r.useState({url:"",text:"",title:"",target:"_self"}),Pe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(pe=m.unorderedList)!=null?pe:!0,orderedList:(ve=m.orderedList)!=null?ve:!0,staticUnorderedList:(ye=m.staticUnorderedList)!=null?ye:!0,staticOrderedList:(Ee=m.staticOrderedList)!=null?Ee:!0,align:!0,link:(we=m.link)!=null?we:!1,image:(Ce=m.image)!=null?Ce:!1,emoji:(be=m.emoji)!=null?be:!1,table:(Le=m.table)!=null?Le:!1,color:(Re=m.color)!=null?Re:!1,fontFamily:(Se=m.fontFamily)!=null?Se:!1,fontSize:(xe=m.fontSize)!=null?xe:!1,highlight:(Me=m.fontSize)!=null?Me:!1},[Ie,G]=r.useState(""),[ce,ee]=r.useState([]),I=()=>S.current,A=()=>{const e=qe(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),n=n.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(l,h,y)=>{if(/list-type=["']static["']/.test(y)||l.includes("data-hidden-array-start")||l.includes("data-hidden-array-end"))return l;const f=`<${h}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',v='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',C=`</${h}>`,F=l.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${C}$`),"");return`${f}${s}${F}${v}${C}`}),j(n),x==null||x(n);const o=it(e);T(o);const d=Ke(),i=De(d);JSON.stringify(i)!==JSON.stringify(ce)&&(ee(i),w(i))},qe=()=>{const e=I();if(!e)return D;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=Be(n),n},Be=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(n=>{n.getAttribute("table-type")==="static"||(n.innerHTML=`{{#arrayData}}${n.innerHTML}{{/arrayData}}`)}),t.innerHTML},W=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(_.current=n.cloneRange())},Z=()=>{const e=window.getSelection();!e||!_.current||(e.removeAllRanges(),e.addRange(_.current))},se=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(_.current=n.getRangeAt(0)),Z(),document.execCommand(e,!1,t),A()};r.useEffect(()=>{const e=I();if(!e||!E)return;const t=Ve(E);e.innerHTML=t,A()},[]);const Ve=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{R&&R(e=>{Xe(e)})},[]),r.useEffect(()=>{const e=I();if(!e)return;e.querySelectorAll("table").forEach(n=>{n.hasAttribute("data-has-resize-handle")||(re(n),n.querySelectorAll("th, td").forEach(d=>X(d)))})},[]);const de=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ue=(e,t)=>{var f;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.getRangeAt(0),d=de(o.startContainer);let i,l;const h=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(d){let s=d.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",d.appendChild(s)),l=s,i=document.createElement("li"),i.textContent="â",l.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=I();if(l=s==null?void 0:s.querySelector(`${e}:last-child`),!l)return;h&&l.setAttribute("list-type","static"),i=l.querySelector("li:last-child")}const y=document.createRange();y.setStart(i,0),y.collapse(!0),n.removeAllRanges(),n.addRange(y),(f=I())==null||f.focus(),A()},te=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?ue("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?ue("ul",e):e.startsWith("justify")?st(e):se(e,t),e==="insertTable"&&fe(),e==="insertStaticTable"&&fe("insertStaticTable")},Ue=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),V({x:n.left,y:n.bottom+window.scrollY}),M(a||[]),z(!0),$.current=e.cloneRange()},$e=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const d=o.textContent||"",i=o===t?n:d.length,l=d.lastIndexOf("@",i-1);if(l!==-1){const h=document.createRange();return h.setStart(o,l),h.setEnd(o,i),h}}o=o.previousSibling}return null},We=e=>{var i;const t=window.getSelection();if(!t)return;const n=$e();n?(t.removeAllRanges(),t.addRange(n)):$.current&&(t.removeAllRanges(),t.addRange($.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const l=t.rangeCount?t.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(o);else{const f=document.createRange(),s=I();f.selectNodeContents(s),f.collapse(!1),f.insertNode(o)}const h=document.createTextNode("â");o.after(h);const y=document.createRange();y.setStartAfter(h),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(l){console.error("insertMention error:",l)}let d=De([...ce,e]);ee(d),w(d),z(!1),(i=I())==null||i.focus(),A()},Ze=e=>{const t=I();if(!t)return;let n=null;_.current&&t.contains(_.current.startContainer)?n=_.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const d=document.createElement("span");d.textContent=`{{${e.name}}}`,d.style.display="inline",d.setAttribute("data-mention",e.value||e.name),n.insertNode(d);const i=document.createTextNode(" ");d.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),o.removeAllRanges(),o.addRange(l),_.current=l.cloneRange(),t.focus()},Xe=e=>{e.forEach(t=>Ze(t)),ee(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(d=>[d.name,d])).values());return w(o),o}),A()},Ke=()=>{const e=I();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const d=o.getAttribute("data-mention")||"",l=(o.textContent||"").match(/{{(.+?)}}/);l&&n.push({name:l[1],value:d})}),n},Ye=e=>{var n,o,d;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),te(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),l=i!=null&&i.anchorNode?de(i.anchorNode):null;if(!l)return;if(((n=l.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=l.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(l);const s=document.createElement("p");s.innerHTML="<br />",(o=f.parentElement)==null||o.insertBefore(s,f.nextSibling);const v=document.createRange();v.setStart(s,0),v.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(v)}else{const s=l.closest("ul, ol");if(s){const v=document.createElement("p");v.innerHTML="<br />",(d=s.parentElement)==null||d.insertBefore(v,s.nextSibling),s.removeChild(l);const C=document.createRange();C.setStart(v,0),C.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(C)}}A()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const l=i.getRangeAt(0);if(l.cloneContents().querySelector("table"))return;if(l.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},Qe=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(ne(o))return;setTimeout(()=>{Ue(n.getRangeAt(0)),G(""),M(a),z(!0)},0);return}if(P){setTimeout(()=>me(),0);return}},ne=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},me=()=>{A();const e=window.getSelection();if(!e||!e.anchorNode)return;if(ne(e.anchorNode)){z(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){z(!1);return}const o=n[1].trim().toLowerCase();G(o);const d=a.filter(i=>i.name.toLowerCase().includes(o));d.length>0?(M(d),z(!0)):z(!1)},Je=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=d=>{var C;const i=(C=d.target)==null?void 0:C.result;Z();const l=window.getSelection();let h=l&&l.rangeCount?l.getRangeAt(0):null;const y=document.createElement("img");y.src=i,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=I();if(!h||!f){f==null||f.appendChild(y);const F=document.createTextNode(" ");f==null||f.appendChild(F);const ae=document.createRange();ae.setStartAfter(F),ae.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(ae),f==null||f.focus(),A(),e.target.value="";return}h.deleteContents(),h.insertNode(y);const s=document.createTextNode(" ");y.after(s);const v=document.createRange();v.setStartAfter(s),v.collapse(!0),l.removeAllRanges(),l.addRange(v),f.focus(),A(),e.target.value=""},n.readAsDataURL(t)},Ge=e=>{var d;Z();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(d=I())==null||d.focus(),A()},fe=e=>{var s;ft(),Z();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const n=document.createElement("thead");p.thead&&n.classList.add(p.thead);const o=document.createElement("tbody");p.tbody&&o.classList.add(p.tbody),e==="insertStaticTable"&&o.setAttribute("table-type","static");const d=document.createElement("tr");p.tr&&d.classList.add(p.tr);const i=document.createElement("tr");p.tr&&i.classList.add(p.tr);for(let v=0;v<2;v++){const C=document.createElement("th");C.textContent="",C.style.border="1px solid #999",C.style.padding="4px",C.style.position="relative",C.style.backgroundColor="lightgray",C.style.height="20px",p.th&&C.classList.add(p.th);const F=document.createElement("td");F.textContent="",F.style.border="1px solid #999",F.style.padding="4px",F.style.position="relative",F.style.backgroundColor="#fff",F.style.height="20px",p.td&&F.classList.add(p.td),X(C),X(F),d.appendChild(C),i.appendChild(F)}n.appendChild(d),o.appendChild(i),t.appendChild(n),t.appendChild(o),re(t);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const h=l.getRangeAt(0);h.collapse(!1),h.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),l.removeAllRanges(),l.addRange(f),(s=I())==null||s.focus(),A()},re=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let n=0,o=0,d=0,i=0;t.addEventListener("mousedown",l=>{l.preventDefault(),n=l.clientX,o=l.clientY;const h=e.getBoundingClientRect();d=h.width,i=h.height;const y=s=>{const v=Math.max(100,d+(s.clientX-n)),C=Math.max(20,i+(s.clientY-o));e.style.width=`${v}px`,e.style.height=`${C}px`,A()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},X=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",n.classList.add("rte-resize-handle"),et(e,t,n),e.appendChild(t),e.appendChild(n)},et=(e,t,n)=>{let o=0,d=0,i=0,l=0;t.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)}),n.addEventListener("mousedown",s=>{s.preventDefault(),d=s.clientY,l=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const h=s=>{const v=i+(s.clientX-o);e.style.width=`${Math.max(30,v)}px`,A()},y=s=>{const v=l+(s.clientY-d);e.style.height=`${Math.max(20,v)}px`,A()},f=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()}},tt=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},ge=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},nt=e=>{if(!q.cell)return;const t=q.cell.closest("table"),n=q.cell.cellIndex,o=q.cell.parentElement.rowIndex,d=i=>{const l=i.tagName.toLowerCase(),h=document.createElement(l);return h.textContent="",h.style.cssText=i.style.cssText,X(h),h};switch(e){case"insertRowAbove":{const i=t.rows[o],l=t.insertRow(o);Array.from(i.cells).forEach(h=>{l.appendChild(d(h))});break}case"insertRowBelow":{const i=t.rows[o],l=t.insertRow(o+1);Array.from(i.cells).forEach(h=>{l.appendChild(d(h))});break}case"insertColLeft":{Array.from(t.rows).forEach(i=>{const l=i.cells[n];i.insertBefore(d(l),l)});break}case"insertColRight":{Array.from(t.rows).forEach(i=>{const l=i.cells[n];i.insertBefore(d(l),l.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(i=>{i.cells[n]&&i.deleteCell(n)});break}A(),g(le(oe({},q),{visible:!1})),ge()},rt=()=>{W(),K.current=_.current,ie({url:"",text:"",title:"",target:"_self"}),B(!0)},at=e=>{const t=window.getSelection();if(!t||!K.current)return;t.removeAllRanges(),t.addRange(K.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const d=t.getRangeAt(0);d.deleteContents(),d.insertNode(o);const i=document.createTextNode(" ");o.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),t.removeAllRanges(),t.addRange(l),B(!1),A()},ot=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),K.current=o,ie({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),B(!0)}},lt=()=>{const e=I();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&_.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(_.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);Z(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),i=document.createElement("div");i.appendChild(d);const l=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),h=[];for(;l.nextNode();){const s=l.currentNode,v=s.tagName.toUpperCase(),C=s.getAttribute&&s.getAttribute("data-mention")!==null;v!=="A"&&!C&&h.push(s)}for(let s=h.length-1;s>=0;s--){const v=h[s],C=v.parentNode;if(C){for(;v.firstChild;)C.insertBefore(v.firstChild,v);C.removeChild(v)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;i.firstChild;)y.appendChild(i.firstChild);o.insertNode(y);const f=document.createRange();f.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),f.collapse(!0),n.removeAllRanges(),n.addRange(f),e.normalize(),A()},it=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
1
|
+
"use strict";var pt=Object.defineProperty,vt=Object.defineProperties;var Et=Object.getOwnPropertyDescriptors;var Te=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var Ae=(a,i,u)=>i in a?pt(a,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[i]=u,oe=(a,i)=>{for(var u in i||(i={}))yt.call(i,u)&&Ae(a,u,i[u]);if(Te)for(var u of Te(i))wt.call(i,u)&&Ae(a,u,i[u]);return a},le=(a,i)=>vt(a,Et(i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),Ct=require("react-dom");function bt(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(i,u,m.get?m:{enumerable:!0,get:()=>a[u]})}}return i.default=a,Object.freeze(i)}const Lt=bt(r);window.React=Lt;var Oe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ne=r.createContext&&r.createContext(Oe),Rt=["attr","size","title"];function St(a,i){if(a==null)return{};var u=xt(a,i),m,p;if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(a);for(p=0;p<M.length;p++)m=M[p],!(i.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(u[m]=a[m])}return u}function xt(a,i){if(a==null)return{};var u={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(i.indexOf(m)>=0)continue;u[m]=a[m]}return u}function J(){return J=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(a[m]=u[m])}return a},J.apply(this,arguments)}function ke(a,i){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);i&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(a,p).enumerable})),u.push.apply(u,m)}return u}function G(a){for(var i=1;i<arguments.length;i++){var u=arguments[i]!=null?arguments[i]:{};i%2?ke(Object(u),!0).forEach(function(m){Mt(a,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):ke(Object(u)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(u,m))})}return a}function Mt(a,i,u){return i=Tt(i),i in a?Object.defineProperty(a,i,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[i]=u,a}function Tt(a){var i=At(a,"string");return typeof i=="symbol"?i:i+""}function At(a,i){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var m=u.call(a,i);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(a)}function He(a){return a&&a.map((i,u)=>r.createElement(i.tag,G({key:u},i.attr),He(i.child)))}function k(a){return i=>r.createElement(Nt,J({attr:G({},a.attr)},i),He(a.child))}function Nt(a){var i=u=>{var{attr:m,size:p,title:M}=a,L=St(a,Rt),T=p||u.size||"1em",E;return u.className&&(E=u.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",J({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,L,{className:E,style:G(G({color:a.color||u.color},u.style),a.style),height:T,width:T,xmlns:"http://www.w3.org/2000/svg"}),M&&r.createElement("title",null,M),a.children)};return Ne!==void 0?r.createElement(Ne.Consumer,null,u=>i(u)):i(Oe)}function kt(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(a)}function zt(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function Dt(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function Ot(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(a)}function Ht(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function jt(a){return k({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function _t(a){return k({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function Ft(a){return k({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function Pt(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function It(a){return k({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function qt(a){return k({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(a)}function Bt(a){return k({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Vt(a){return k({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(a)}function Ut(a){return k({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(a)}function $t(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(a)}function Wt(a){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(a)}function Zt(a){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(a)}function Xt(a){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(a)}const Kt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],je=({exec:a,saveSelection:i,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:M,handleLink:L,removeFormatting:T,visibleActions:E,className:x,style:C})=>{var $,q;const R=r.useRef(null),P=r.useRef(null),N=r.useRef(null),[H,j]=r.useState(!1),[D,_]=r.useState({x:0,y:0});r.useEffect(()=>{const g=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&j(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const z=g=>{var B;g.preventDefault();const b=g.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(b);break;case"insertImage":{(B=R.current)==null||B.click();break}default:console.warn("Unknown command:",b)}},V=g=>{a("foreColor",g.target.value)},U=g=>{a("backColor",g.target.value)},[S,F]=r.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return r.useEffect(()=>{const g=()=>{F({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),r.createElement("div",{className:`rte-toolbar ${x||""}`,style:C},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:z,className:S.bold?"rte-active":""},r.createElement(jt,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:z,className:S.italic?"rte-active":""},r.createElement(Ft,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:z,className:S.underline?"rte-active":""},r.createElement(Bt,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:z,title:"UnorderedList",className:S.unorderedList?"rte-active":""},r.createElement(Ut,null)),E.staticUnorderedList&&r.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:z,title:"StaticUnorderedList",className:S.unorderedList?"rte-active":""},r.createElement(It,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:z,className:S.orderedList?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Vt,null)),E.staticOrderedList&&r.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:z,className:S.orderedList?"rte-active":""},r.createElement(Ot,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:S.link?"rte-active":""},r.createElement(Pt,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),i(),T()},className:S.removeFormat?"rte-active":""},r.createElement(Xt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:z,className:S.image?"rte-active":""},r.createElement(Dt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:R,style:{display:"none"},onChange:u}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),i();const b=g.currentTarget.getBoundingClientRect();_({x:b.left,y:b.bottom+8}),j(B=>!B)},className:S.emoji?"rte-active":""},r.createElement(qt,null)),H&&Ct.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:D.y,left:D.x}},Kt.map((g,b)=>r.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:B=>{B.preventDefault(),M(g),j(!1)}},g))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:g=>{var b;g.preventDefault(),i(),(b=P.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:(($=P.current)==null?void 0:$.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},r.createElement(Zt,null)),r.createElement("input",{ref:P,type:"color",defaultValue:"#000000",onChange:g=>{var b;V(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:g=>{var b;g.preventDefault(),i(),(b=N.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=N.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},r.createElement(_t,null)),r.createElement("input",{ref:N,type:"color",onChange:g=>{var b;U(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:S.alignLeft?"rte-active":""},r.createElement(Ht,null)),r.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:S.alignCenter?"rte-active":""},r.createElement(kt,null)),r.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:S.alignRight?"rte-active":""},r.createElement(zt,null))),E.table&&r.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement($t,null)),E.table&&r.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Wt,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:p},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,b)=>10+b).map(g=>r.createElement("option",{key:g,value:g},g,"px"))))},Yt=({show:a,position:i,filtered:u,insertMention:m,onClose:p,query:M})=>{const L=r.useRef(null),[T,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const x=C=>{L.current&&!L.current.contains(C.target)&&p()};return a&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[a,p]),r.useEffect(()=>{if(!a)return;const x=C=>{if(!(!a||u.length===0)&&(C.key==="ArrowDown"&&(C.preventDefault(),E(R=>Math.min(R+1,u.length-1))),C.key==="ArrowUp"&&(C.preventDefault(),E(R=>Math.max(R-1,0))),C.key==="Enter")){C.preventDefault();const R=u[T];R&&m(R)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a,u,T]),r.useEffect(()=>{if(!L.current)return;const C=L.current.querySelectorAll("li")[T];C&&C.scrollIntoView({block:"nearest",behavior:"smooth"})},[T]),a?r.createElement("ul",{ref:L,className:"rte-popup",style:{top:i.y,left:i.x}},u.length>0?u.map(({name:x,value:C},R)=>{const P=x.toLowerCase(),N=M.toLowerCase(),H=P.indexOf(N);let j=x;if(H!==-1&&M.length>0){const D=H+M.length;j=x.substring(0,H)+`<span class="rte-highlight">${x.substring(H,D)}</span>`+x.substring(D)}return r.createElement("li",{key:C,onMouseDown:D=>{D.preventDefault(),m({name:x,value:C})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:R===T?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:j},onMouseEnter:()=>E(R)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ze(a){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function Q(a){return k({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(a)}const Qt=({visible:a,x:i,y:u,onAction:m,onClose:p})=>{if(!a)return null;const M={top:u,left:i};return r.createElement("div",{style:M,className:"rte-table-menu",onMouseLeave:p},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(Q,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(Q,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(Q,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(Q,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(ze,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(ze,null)," Delete column"))},_e=({html:a,className:i,style:u})=>{const m=L=>{const T=L.target;if(T.tagName==="A"){L.preventDefault();const E=T.href;E&&window.open(E,"_blank","noopener,noreferrer")}},p=L=>L==="rgb(0, 0, 0)"||L==="rgba(0, 0, 0, 1)"||L==="#000"||L==="#000000"||L==="black",M=L=>{const T=document.createElement("div");T.innerHTML=L;const E=document.createTreeWalker(T,NodeFilter.SHOW_TEXT,null),x=[];for(;E.nextNode();){const C=E.currentNode;C.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(C.nodeValue)&&x.push(C)}return x.forEach(C=>{var _;const R=C.nodeValue||"",P=C.parentElement;if(!P)return;let N=P,H=!1;for(;N;){if(N.tagName==="FONT"&&N.getAttribute("color")){H=!0;break}const z=(_=N.style)==null?void 0:_.color;if(z&&!p(z)){H=!0;break}const V=window.getComputedStyle(N);if(V.color&&!p(V.color)){H=!0;break}N=N.parentElement}const j=document.createDocumentFragment();let D=0;R.replace(/{{\s*([\s\S]*?)\s*}}/g,(z,V,U)=>{if(U>D&&j.appendChild(document.createTextNode(R.slice(D,U))),H)j.appendChild(document.createTextNode(z));else{const S=document.createElement("span");S.style.color="blue",S.textContent=z,j.appendChild(S)}return D=U+z.length,z}),D<R.length&&j.appendChild(document.createTextNode(R.slice(D))),P.replaceChild(j,C)}),T.innerHTML=T.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),T.innerHTML};return r.createElement("div",{className:`rte-preview ${i||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:M(a)}})},Jt=({visible:a,linkData:i,onClose:u,onInsert:m})=>{const[p,M]=r.useState(""),[L,T]=r.useState(""),[E,x]=r.useState(""),[C,R]=r.useState("_self");if(r.useEffect(()=>{a?(M(i.url||""),T(i.text||""),x(i.title||""),R(i.target||"_self")):(M(""),T(""),x(""),R("_self"))},[a,i]),!a)return null;const P=()=>{m({url:p,text:L,title:E,target:C})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:N=>M(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:N=>T(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:N=>x(N.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:C,onChange:N=>R(N.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:P},"OK"))))};function De(a){const i=new Map;return a.forEach(u=>{i.set(u.name,u.value)}),Array.from(i.entries()).map(([u,m])=>({name:u,value:m}))}const Gt=({atSuggestions:a=[],showOutput:i=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:M={},handleGetHtml:L=()=>{},onChange:T=()=>{},value:E,onMentionSelect:x=()=>{},handleAddAttributes:C=()=>{}})=>{var pe,ve,Ee,ye,we,Ce,be,Le,Re,Se,xe,Me;const R=r.useRef(null),[P,N]=r.useState(E!=null&&E.length?E:" "),[H,j]=r.useState(""),[D,_]=r.useState(!1),[z,V]=r.useState({x:0,y:0}),[U,S]=r.useState([]),F=r.useRef(null),$=r.useRef(null),[q,g]=r.useState({visible:!1,x:0,y:0}),[b,B]=r.useState(!1),Y=r.useRef(null),[Fe,ce]=r.useState({url:"",text:"",title:"",target:"_self"}),Pe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(pe=m.unorderedList)!=null?pe:!0,orderedList:(ve=m.orderedList)!=null?ve:!0,staticUnorderedList:(Ee=m.staticUnorderedList)!=null?Ee:!0,staticOrderedList:(ye=m.staticOrderedList)!=null?ye:!0,align:!0,link:(we=m.link)!=null?we:!1,image:(Ce=m.image)!=null?Ce:!1,emoji:(be=m.emoji)!=null?be:!1,table:(Le=m.table)!=null?Le:!1,color:(Re=m.color)!=null?Re:!1,fontFamily:(Se=m.fontFamily)!=null?Se:!1,fontSize:(xe=m.fontSize)!=null?xe:!1,highlight:(Me=m.fontSize)!=null?Me:!1},[Ie,ee]=r.useState(""),[ie,te]=r.useState([]),I=()=>R.current,A=()=>{const e=qe(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),n=n.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(l,v,y)=>{if(/list-type=["']static["']/.test(y)||l.includes("data-hidden-array-start")||l.includes("data-hidden-array-end"))return l;const f=`<${v}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',h='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',w=`</${v}>`,O=l.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${w}$`),"");return`${f}${s}${O}${h}${w}`}),j(n),L==null||L(n);const o=ct(e);T(o);const d=Ke(),c=De(d);JSON.stringify(c)!==JSON.stringify(ie)&&(te(c),x(c))},qe=()=>{const e=I();if(!e)return P;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=Be(n),n},Be=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(n=>{n.getAttribute("table-type")==="static"||(n.innerHTML=`{{#arrayData}}${n.innerHTML}{{/arrayData}}`)}),t.innerHTML},W=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(F.current=n.cloneRange())},Z=()=>{const e=window.getSelection();!e||!F.current||(e.removeAllRanges(),e.addRange(F.current))},se=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(F.current=n.getRangeAt(0)),Z(),document.execCommand(e,!1,t),A()};r.useEffect(()=>{const e=I();if(!e||!E)return;const t=Ve(E);e.innerHTML=t,A()},[]);const Ve=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{C&&C(e=>{Xe(e)})},[]),r.useEffect(()=>{const e=I();if(!e)return;e.querySelectorAll("table").forEach(n=>{n.hasAttribute("data-has-resize-handle")||(ae(n),n.querySelectorAll("th, td").forEach(d=>X(d)))})},[]);const de=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ue=(e,t)=>{var f;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.getRangeAt(0),d=de(o.startContainer);let c,l;const v=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(d){let s=d.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",d.appendChild(s)),l=s,c=document.createElement("li"),c.textContent="â",l.appendChild(c)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=I();if(l=s==null?void 0:s.querySelector(`${e}:last-child`),!l)return;v&&l.setAttribute("list-type","static"),c=l.querySelector("li:last-child")}const y=document.createRange();y.setStart(c,0),y.collapse(!0),n.removeAllRanges(),n.addRange(y),(f=I())==null||f.focus(),A()},ne=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?ue("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?ue("ul",e):e.startsWith("justify")?st(e):se(e,t),e==="insertTable"&&fe(),e==="insertStaticTable"&&fe("insertStaticTable")},Ue=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),V({x:n.left,y:n.bottom+window.scrollY}),S(a||[]),_(!0),$.current=e.cloneRange()},$e=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const d=o.textContent||"",c=o===t?n:d.length,l=d.lastIndexOf("@",c-1);if(l!==-1){const v=document.createRange();return v.setStart(o,l),v.setEnd(o,c),v}}o=o.previousSibling}return null},We=e=>{var c;const t=window.getSelection();if(!t)return;const n=$e();n?(t.removeAllRanges(),t.addRange(n)):$.current&&(t.removeAllRanges(),t.addRange($.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const l=t.rangeCount?t.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(o);else{const f=document.createRange(),s=I();f.selectNodeContents(s),f.collapse(!1),f.insertNode(o)}const v=document.createTextNode("â");o.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(l){console.error("insertMention error:",l)}let d=De([...ie,e]);te(d),x(d),_(!1),(c=I())==null||c.focus(),A()},Ze=e=>{const t=I();if(!t)return;let n=null;F.current&&t.contains(F.current.startContainer)?n=F.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const d=document.createElement("span");d.textContent=`{{${e.name}}}`,d.style.display="inline",d.setAttribute("data-mention",e.value||e.name),n.insertNode(d);const c=document.createTextNode(" ");d.after(c);const l=document.createRange();l.setStartAfter(c),l.collapse(!0),o.removeAllRanges(),o.addRange(l),F.current=l.cloneRange(),t.focus()},Xe=e=>{e.forEach(t=>Ze(t)),te(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(d=>[d.name,d])).values());return x(o),o}),A()},Ke=()=>{const e=I();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const d=o.getAttribute("data-mention")||"",l=(o.textContent||"").match(/{{(.+?)}}/);l&&n.push({name:l[1],value:d})}),n},Ye=e=>{var n,o,d;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ne(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const c=window.getSelection(),l=c!=null&&c.anchorNode?de(c.anchorNode):null;if(!l)return;if(((n=l.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=l.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(l);const s=document.createElement("p");s.innerHTML="<br />",(o=f.parentElement)==null||o.insertBefore(s,f.nextSibling);const h=document.createRange();h.setStart(s,0),h.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(h)}else{const s=l.closest("ul, ol");if(s){const h=document.createElement("p");h.innerHTML="<br />",(d=s.parentElement)==null||d.insertBefore(h,s.nextSibling),s.removeChild(l);const w=document.createRange();w.setStart(h,0),w.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(w)}}A()}}if(t==="backspace"||t==="delete"){const c=window.getSelection();if(!c||c.rangeCount===0)return;const l=c.getRangeAt(0);if(l.cloneContents().querySelector("table"))return;if(l.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},Qe=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(re(o))return;setTimeout(()=>{Ue(n.getRangeAt(0)),ee(""),S(a),_(!0)},0);return}if(D){setTimeout(()=>me(),0);return}},re=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},me=()=>{A();const e=window.getSelection();if(!e||!e.anchorNode)return;if(re(e.anchorNode)){_(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){_(!1);return}const o=n[1].trim().toLowerCase();ee(o);const d=a.filter(c=>c.name.toLowerCase().includes(o));d.length>0?(S(d),_(!0)):_(!1)},Je=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=d=>{var w;const c=(w=d.target)==null?void 0:w.result;Z();const l=window.getSelection();let v=l&&l.rangeCount?l.getRangeAt(0):null;const y=document.createElement("img");y.src=c,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=I();if(!v||!f){f==null||f.appendChild(y);const O=document.createTextNode(" ");f==null||f.appendChild(O);const K=document.createRange();K.setStartAfter(O),K.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(K),f==null||f.focus(),A(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const s=document.createTextNode(" ");y.after(s);const h=document.createRange();h.setStartAfter(s),h.collapse(!0),l.removeAllRanges(),l.addRange(h),f.focus(),A(),e.target.value=""},n.readAsDataURL(t)},Ge=e=>{var d;Z();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(d=I())==null||d.focus(),A()},fe=e=>{var s;gt(),Z();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const n=document.createElement("thead");p.thead&&n.classList.add(p.thead);const o=document.createElement("tbody");p.tbody&&o.classList.add(p.tbody),e==="insertStaticTable"&&o.setAttribute("table-type","static");const d=document.createElement("tr");p.tr&&d.classList.add(p.tr);const c=document.createElement("tr");p.tr&&c.classList.add(p.tr);for(let h=0;h<2;h++){const w=document.createElement("th");w.textContent="",w.style.border="1px solid #999",w.style.padding="4px",w.style.position="relative",w.style.backgroundColor="lightgray",w.style.height="20px",p.th&&w.classList.add(p.th);const O=document.createElement("td");O.textContent="",O.style.border="1px solid #999",O.style.padding="4px",O.style.position="relative",O.style.backgroundColor="#fff",O.style.height="20px",p.td&&O.classList.add(p.td),X(w),X(O),d.appendChild(w),c.appendChild(O)}n.appendChild(d),o.appendChild(c),t.appendChild(n),t.appendChild(o),ae(t);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const v=l.getRangeAt(0);v.collapse(!1),v.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),l.removeAllRanges(),l.addRange(f),(s=I())==null||s.focus(),A()},ae=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let n=0,o=0,d=0,c=0;t.addEventListener("mousedown",l=>{l.preventDefault(),n=l.clientX,o=l.clientY;const v=e.getBoundingClientRect();d=v.width,c=v.height;const y=s=>{const h=Math.max(100,d+(s.clientX-n)),w=Math.max(20,c+(s.clientY-o));e.style.width=`${h}px`,e.style.height=`${w}px`,A()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},X=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",n.classList.add("rte-resize-handle"),et(e,t,n),e.appendChild(t),e.appendChild(n)},et=(e,t,n)=>{let o=0,d=0,c=0,l=0;t.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,c=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)}),n.addEventListener("mousedown",s=>{s.preventDefault(),d=s.clientY,l=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const v=s=>{const h=c+(s.clientX-o);e.style.width=`${Math.max(30,h)}px`,A()},y=s=>{const h=l+(s.clientY-d);e.style.height=`${Math.max(20,h)}px`,A()},f=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()}},tt=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},ge=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},nt=e=>{if(!q.cell)return;const t=q.cell.closest("table"),n=q.cell.cellIndex,o=q.cell.parentElement.rowIndex,d=c=>{const l=c.tagName.toLowerCase(),v=document.createElement(l);return v.textContent="",v.style.cssText=c.style.cssText,X(v),v};switch(e){case"insertRowAbove":{const c=t.rows[o],l=t.insertRow(o);Array.from(c.cells).forEach(v=>{l.appendChild(d(v))});break}case"insertRowBelow":{const c=t.rows[o],l=t.insertRow(o+1);Array.from(c.cells).forEach(v=>{l.appendChild(d(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(c=>{const l=c.cells[n];c.insertBefore(d(l),l)});break}case"insertColRight":{Array.from(t.rows).forEach(c=>{const l=c.cells[n];c.insertBefore(d(l),l.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(c=>{c.cells[n]&&c.deleteCell(n)});break}A(),g(le(oe({},q),{visible:!1})),ge()},rt=()=>{W(),Y.current=F.current,ce({url:"",text:"",title:"",target:"_self"}),B(!0)},at=e=>{const t=window.getSelection();if(!t||!Y.current)return;t.removeAllRanges(),t.addRange(Y.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const d=t.getRangeAt(0);d.deleteContents(),d.insertNode(o);const c=document.createTextNode(" ");o.after(c);const l=document.createRange();l.setStartAfter(c),l.collapse(!0),t.removeAllRanges(),t.addRange(l),B(!1),A()},ot=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),Y.current=o,ce({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),B(!0)}},lt=()=>{const e=I();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&F.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(F.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);Z(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),c=document.createElement("div");c.appendChild(d);const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,null),v=[];for(;l.nextNode();){const s=l.currentNode,h=s.tagName.toUpperCase(),w=s.getAttribute&&s.getAttribute("data-mention")!==null;h!=="A"&&!w&&v.push(s)}for(let s=v.length-1;s>=0;s--){const h=v[s],w=h.parentNode;if(w){for(;h.firstChild;)w.insertBefore(h.firstChild,h);w.removeChild(h)}}c.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;c.firstChild;)y.appendChild(c.firstChild);o.insertNode(y);const f=document.createRange();f.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),f.collapse(!0),n.removeAllRanges(),n.addRange(f),e.normalize(),A()},ct=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
2
2
|
`)}),n.querySelectorAll("p, div, tr").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
3
3
|
`)}),n.querySelectorAll("table").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
4
4
|
`)}),((o=n.textContent)==null?void 0:o.replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim())||""};function
|
|
6
|
+
`).trim())||""};function it(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let c=t.startContainer,l=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;const v=l==null?void 0:l.closest("td, th");return v?[v]:[]}const n=t.commonAncestorContainer,o=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(c=>{const l=document.createRange();return l.selectNodeContents(c),t.compareBoundaryPoints(Range.END_TO_START,l)<0&&t.compareBoundaryPoints(Range.START_TO_END,l)>0})}function st(e){const t=it();if(t.length===0){se(e);return}let n="left";e==="justifyCenter"&&(n="center"),e==="justifyRight"&&(n="right"),t.forEach(o=>{o.style.textAlign=n}),A()}const dt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return!1;let t=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;for(;t;){if(t.tagName==="TABLE")return!0;t=t.parentElement}return!1},ut=e=>{if(dt()){e.preventDefault();const f=e.clipboardData.getData("text/plain");if(!f)return;const s=window.getSelection();if(!s||!s.rangeCount)return;const h=s.getRangeAt(0);h.deleteContents();const w=f.split(/\r?\n/);w.forEach((O,K)=>{h.insertNode(document.createTextNode(O)),K<w.length-1&&h.insertNode(document.createElement("br"))}),h.collapse(!1),s.removeAllRanges(),s.addRange(h),A();return}const t=e.clipboardData.getData("text/html")||"";if(!t)return;const n=document.createElement("div");if(n.innerHTML=t,n.querySelector("img")){e.preventDefault();return}e.preventDefault();const o=document.createElement("div");o.innerHTML=t;const d=f=>{f.hasAttribute("data-has-resize-handle")||(f.style.borderCollapse="collapse",f.style.width="100%",f.style.border="1px solid #ccc",f.style.margin="8px 0",f.style.position="relative",f.style.textAlign="center",f.querySelectorAll("th").forEach(s=>{const h=s;h.style.border="1px solid #999",h.style.padding="4px",h.style.position="relative",h.style.backgroundColor="lightgray",h.style.height="20px"}),f.querySelectorAll("td").forEach(s=>{const h=s;h.style.border="1px solid #999",h.style.padding="4px",h.style.position="relative",h.style.backgroundColor="#fff",h.style.height="20px"}))};o.querySelectorAll("table").forEach(f=>d(f));const c=window.getSelection();if(!c||!c.rangeCount)return;const l=c.getRangeAt(0);l.deleteContents();const v=document.createDocumentFragment();for(;o.firstChild;)v.appendChild(o.firstChild);l.insertNode(v),l.collapse(!1),c.removeAllRanges(),c.addRange(l);const y=R.current;y&&(y.querySelectorAll("table").forEach(f=>{const s=f;s.hasAttribute("data-has-resize-handle")||(ae(s),s.querySelectorAll("th, td").forEach(h=>{const w=h;w.dataset.hasResizeHandles||X(w)}))}),A())},mt=e=>{Z();const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0),o=document.createElement("span");o.style.fontSize=`${e}px`,o.appendChild(n.extractContents()),n.insertNode(o);const d=document.createRange();d.setStartAfter(o),d.collapse(!0),t.removeAllRanges(),t.addRange(d),A()},ft=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(re(t)||t.nodeType!==Node.TEXT_NODE)return null;const n=t.textContent||"",o=e.anchorOffset,d=n.lastIndexOf("@",o-1);if(d===-1)return null;const c=n.substring(d+1,o);if(c.includes(" ")||c.includes("Â "))return null;const l=document.createRange();return l.setStart(t,d),l.setEnd(t,o),{range:l,query:c}},he=()=>{const e=ft();if(!e)return;const{range:t,query:n}=e,o=document.createElement("span");o.textContent="â",t.insertNode(o);const d=o.getBoundingClientRect();o.remove(),V({x:d.left,y:d.bottom+window.scrollY}),ee(n.toLowerCase());const c=a.filter(l=>l.name.toLowerCase().includes(n.toLowerCase()));S(c),_(!0),$.current=t.cloneRange()};function gt(){const e=R.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),F.current=n.cloneRange()}const ht=e=>{const t=e.target;if(!t||!(t.textContent||"").match(/{{([\s\S]+?)}}/)||!R.current)return;let c=t.firstChild;if((!c||c.nodeType!==Node.TEXT_NODE)&&(c=t.childNodes[0]),!c||c.nodeType!==Node.TEXT_NODE)return;const l=c.textContent||"",v=l.indexOf("{{"),y=l.indexOf("}}");if(v===-1||y===-1)return;const f=window.getSelection();if(!f)return;const s=document.createRange();s.setStart(c,v),s.setEnd(c,y+2),f.removeAllRanges(),f.addRange(s)};return r.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:M.wrapper},r.createElement("div",{style:{flex:1}},r.createElement(je,{exec:ne,saveSelection:W,handleFileChange:Je,handleFontSizeChange:e=>mt(e.target.value),handleFontFamilyChange:e=>ne("fontName",e.target.value),insertEmoji:Ge,handleLink:rt,removeFormatting:lt,visibleActions:Pe,className:p.toolbar,style:M.toolbar}),r.createElement("div",{ref:R,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:M.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:ut,onKeyUp:()=>{W(),he()},onMouseUp:W,onInput:()=>{me(),W()},onKeyDown:Ye,onBeforeInput:Qe,onContextMenu:tt,onClick:e=>{ot(e),W(),he()},onDoubleClick:ht}),r.createElement(Yt,{show:D,position:z,filtered:U,insertMention:We,onClose:()=>_(!1),query:Ie}),i&&r.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:M.output},r.createElement("h4",null,"Output HTML:"),r.createElement("p",null,H)),r.createElement(Qt,{visible:q.visible,x:q.x,y:q.y,onAction:nt,onClose:()=>{g(le(oe({},q),{visible:!1})),ge()}}),r.createElement(Jt,{visible:b,linkData:Fe,onClose:()=>B(!1),onInsert:at})),u?r.createElement(_e,{className:p.preview,style:M.preview,html:H}):null)};exports.RichTextEditor=Gt;exports.RtePreview=_e;exports.RteToolbar=je;
|
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(k,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(k=typeof globalThis!="undefined"?globalThis:k||self,n(k.RichTextEditor={},k.React,k.ReactDOM))})(this,(function(k,n,R){"use strict";var Kt=Object.defineProperty,Yt=Object.defineProperties;var Qt=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var Jt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Ie=(k,n,R)=>n in k?Kt(k,n,{enumerable:!0,configurable:!0,writable:!0,value:R}):k[n]=R,ie=(k,n)=>{for(var R in n||(n={}))Jt.call(n,R)&&Ie(k,R,n[R]);if(Pe)for(var R of Pe(n))Gt.call(n,R)&&Ie(k,R,n[R]);return k},se=(k,n)=>Yt(k,Qt(n));function qe(o){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const u in o)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(o,u);Object.defineProperty(d,u,m.get?m:{enumerable:!0,get:()=>o[u]})}}return d.default=o,Object.freeze(d)}const Be=qe(n);window.React=Be;var ce={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},de=n.createContext&&n.createContext(ce),Re=["attr","size","title"];function Ve(o,d){if(o==null)return{};var u=Ue(o,d),m,p;if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(o);for(p=0;p<b.length;p++)m=b[p],!(d.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(o,m)&&(u[m]=o[m])}return u}function Ue(o,d){if(o==null)return{};var u={};for(var m in o)if(Object.prototype.hasOwnProperty.call(o,m)){if(d.indexOf(m)>=0)continue;u[m]=o[m]}return u}function Q(){return Q=Object.assign?Object.assign.bind():function(o){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(o[m]=u[m])}return o},Q.apply(this,arguments)}function ue(o,d){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(o);d&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(o,p).enumerable})),u.push.apply(u,m)}return u}function J(o){for(var d=1;d<arguments.length;d++){var u=arguments[d]!=null?arguments[d]:{};d%2?ue(Object(u),!0).forEach(function(m){$e(o,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):ue(Object(u)).forEach(function(m){Object.defineProperty(o,m,Object.getOwnPropertyDescriptor(u,m))})}return o}function $e(o,d,u){return d=We(d),d in o?Object.defineProperty(o,d,{value:u,enumerable:!0,configurable:!0,writable:!0}):o[d]=u,o}function We(o){var d=Ze(o,"string");return typeof d=="symbol"?d:d+""}function Ze(o,d){if(typeof o!="object"||!o)return o;var u=o[Symbol.toPrimitive];if(u!==void 0){var m=u.call(o,d);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(o)}function me(o){return o&&o.map((d,u)=>n.createElement(d.tag,J({key:u},d.attr),me(d.child)))}function z(o){return d=>n.createElement(Xe,Q({attr:J({},o.attr)},d),me(o.child))}function Xe(o){var d=u=>{var{attr:m,size:p,title:b}=o,M=Ve(o,Re),A=p||u.size||"1em",E;return u.className&&(E=u.className),o.className&&(E=(E?E+" ":"")+o.className),n.createElement("svg",Q({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,M,{className:E,style:J(J({color:o.color||u.color},u.style),o.style),height:A,width:A,xmlns:"http://www.w3.org/2000/svg"}),b&&n.createElement("title",null,b),o.children)};return de!==void 0?n.createElement(de.Consumer,null,u=>d(u)):d(ce)}function Ke(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function Ye(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function Qe(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function Je(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(o)}function Ge(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function et(o){return z({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function tt(o){return z({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function nt(o){return z({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function rt(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function ot(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function lt(o){return z({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function at(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function it(o){return z({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(o)}function st(o){return z({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(o)}function ct(o){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(o)}function dt(o){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(o)}function ut(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function mt(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const ft=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],fe=({exec:o,saveSelection:d,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:b,handleLink:M,removeFormatting:A,visibleActions:E,className:w,style:S})=>{var Z,V;const x=n.useRef(null),H=n.useRef(null),D=n.useRef(null),[j,F]=n.useState(!1),[q,O]=n.useState({x:0,y:0});n.useEffect(()=>{const g=L=>{!L.target.closest(".rte-emoji-popup")&&!L.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const _=g=>{var U;g.preventDefault();const L=g.currentTarget.dataset.command;if(L)switch(L){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":o(L);break;case"insertImage":{(U=x.current)==null||U.click();break}default:console.warn("Unknown command:",L)}},$=g=>{o("foreColor",g.target.value)},W=g=>{o("backColor",g.target.value)},[T,P]=n.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return n.useEffect(()=>{const g=()=>{P({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),n.createElement("div",{className:`rte-toolbar ${w||""}`,style:S},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:T.bold?"rte-active":""},n.createElement(et,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:T.italic?"rte-active":""},n.createElement(nt,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:T.underline?"rte-active":""},n.createElement(at,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:T.unorderedList?"rte-active":""},n.createElement(st,null)),E.staticUnorderedList&&n.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:_,title:"StaticUnorderedList",className:T.unorderedList?"rte-active":""},n.createElement(ot,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:T.orderedList?"rte-active":"",style:{fontSize:"medium"}},n.createElement(it,null)),E.staticOrderedList&&n.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:_,className:T.orderedList?"rte-active":""},n.createElement(Je,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:M,className:T.link?"rte-active":""},n.createElement(rt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),d(),A()},className:T.removeFormat?"rte-active":""},n.createElement(mt,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:T.image?"rte-active":""},n.createElement(Qe,null)),n.createElement("input",{type:"file",accept:"image/*",ref:x,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),d();const L=g.currentTarget.getBoundingClientRect();O({x:L.left,y:L.bottom+8}),F(U=>!U)},className:T.emoji?"rte-active":""},n.createElement(lt,null)),j&&R.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:q.y,left:q.x}},ft.map((g,L)=>n.createElement("span",{key:L,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:U=>{U.preventDefault(),b(g),F(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var L;g.preventDefault(),d(),(L=H.current)==null||L.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Z=H.current)==null?void 0:Z.value)||"#000",fontSize:"18px"},className:T.color?"rte-active":""},n.createElement(ut,null)),n.createElement("input",{ref:H,type:"color",defaultValue:"#000000",onChange:g=>{var L;$(g),((L=g.target.parentElement)==null?void 0:L.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:g=>{var L;g.preventDefault(),d(),(L=D.current)==null||L.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=D.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:T.highlight?"rte-active":""},n.createElement(tt,null)),n.createElement("input",{ref:D,type:"color",onChange:g=>{var L;W(g),((L=g.target.parentElement)==null?void 0:L.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyLeft"),className:T.alignLeft?"rte-active":""},n.createElement(Ge,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyCenter"),className:T.alignCenter?"rte-active":""},n.createElement(Ke,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyRight"),className:T.alignRight?"rte-active":""},n.createElement(Ye,null))),E.table&&n.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertTable"),className:T.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(ct,null)),E.table&&n.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertStaticTable"),className:T.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(dt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:p},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,L)=>10+L).map(g=>n.createElement("option",{key:g,value:g},g,"px"))))},gt=({show:o,position:d,filtered:u,insertMention:m,onClose:p,query:b})=>{const M=n.useRef(null),[A,E]=n.useState(0);return n.useEffect(()=>{o&&E(0)},[o]),n.useEffect(()=>{const w=S=>{M.current&&!M.current.contains(S.target)&&p()};return o&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[o,p]),n.useEffect(()=>{if(!o)return;const w=S=>{if(!(!o||u.length===0)&&(S.key==="ArrowDown"&&(S.preventDefault(),E(x=>Math.min(x+1,u.length-1))),S.key==="ArrowUp"&&(S.preventDefault(),E(x=>Math.max(x-1,0))),S.key==="Enter")){S.preventDefault();const x=u[A];x&&m(x)}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[o,u,A]),n.useEffect(()=>{if(!M.current)return;const S=M.current.querySelectorAll("li")[A];S&&S.scrollIntoView({block:"nearest",behavior:"smooth"})},[A]),o?n.createElement("ul",{ref:M,className:"rte-popup",style:{top:d.y,left:d.x}},u.length>0?u.map(({name:w,value:S},x)=>{const H=w.toLowerCase(),D=b.toLowerCase(),j=H.indexOf(D);let F=w;if(j!==-1&&b.length>0){const q=j+b.length;F=w.substring(0,j)+`<span class="rte-highlight">${w.substring(j,q)}</span>`+w.substring(q)}return n.createElement("li",{key:S,onMouseDown:q=>{q.preventDefault(),m({name:w,value:S})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:x===A?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(x)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ge(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function G(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const ht=({visible:o,x:d,y:u,onAction:m,onClose:p})=>{if(!o)return null;const b={top:u,left:d};return n.createElement("div",{style:b,className:"rte-table-menu",onMouseLeave:p},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(G,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(G,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(G,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(G,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(ge,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(ge,null)," Delete column"))},he=({html:o,className:d,style:u})=>{const m=b=>{const M=b.target;if(M.tagName==="A"){b.preventDefault();const A=M.href;A&&window.open(A,"_blank","noopener,noreferrer")}},p=b=>{const M=document.createElement("div");M.innerHTML=b;const A=document.createTreeWalker(M,NodeFilter.SHOW_TEXT,null),E=[];for(;A.nextNode();){const w=A.currentNode;w.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(w.nodeValue)&&E.push(w)}return E.forEach(w=>{var q;const S=w.nodeValue||"",x=w.parentElement;if(!x)return;let H=x,D=!1;for(;H;){if(H.tagName==="FONT"&&H.getAttribute("color")){D=!0;break}const O=(q=H.style)==null?void 0:q.color;if(O&&O!==""){D=!0;break}const _=window.getComputedStyle(H);if(_.color&&_.color!=="rgb(0, 0, 0)"&&_.color!=="rgba(0, 0, 0, 0)"){D=!0;break}H=H.parentElement}const j=document.createDocumentFragment();let F=0;S.replace(/{{\s*([\s\S]*?)\s*}}/g,(O,_,$)=>{if($>F&&j.appendChild(document.createTextNode(S.slice(F,$))),D)j.appendChild(document.createTextNode(O));else{const W=document.createElement("span");W.style.color="blue",W.textContent=O,j.appendChild(W)}return F=$+O.length,O}),F<S.length&&j.appendChild(document.createTextNode(S.slice(F))),x.replaceChild(j,w)}),M.innerHTML=M.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),M.innerHTML};return n.createElement("div",{className:`rte-preview ${d||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:p(o)}})},pt=({visible:o,linkData:d,onClose:u,onInsert:m})=>{const[p,b]=n.useState(""),[M,A]=n.useState(""),[E,w]=n.useState(""),[S,x]=n.useState("_self");if(n.useEffect(()=>{o?(b(d.url||""),A(d.text||""),w(d.title||""),x(d.target||"_self")):(b(""),A(""),w(""),x("_self"))},[o,d]),!o)return null;const H=()=>{m({url:p,text:M,title:E,target:S})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:D=>b(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:M,onChange:D=>A(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:D=>w(D.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:S,onChange:D=>x(D.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:H},"OK"))))};function pe(o){const d=new Map;return o.forEach(u=>{d.set(u.name,u.value)}),Array.from(d.entries()).map(([u,m])=>({name:u,value:m}))}const vt=({atSuggestions:o=[],showOutput:d=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:b={},handleGetHtml:M=()=>{},onChange:A=()=>{},value:E,onMentionSelect:w=()=>{},handleAddAttributes:S=()=>{}})=>{var Me,Te,Ae,Ne,ke,ze,De,Oe,He,je,_e,Fe;const x=n.useRef(null),[H,D]=n.useState(E!=null&&E.length?E:" "),[j,F]=n.useState(""),[q,O]=n.useState(!1),[_,$]=n.useState({x:0,y:0}),[W,T]=n.useState([]),P=n.useRef(null),Z=n.useRef(null),[V,g]=n.useState({visible:!1,x:0,y:0}),[L,U]=n.useState(!1),ee=n.useRef(null),[yt,ve]=n.useState({url:"",text:"",title:"",target:"_self"}),Et={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Me=m.unorderedList)!=null?Me:!0,orderedList:(Te=m.orderedList)!=null?Te:!0,staticUnorderedList:(Ae=m.staticUnorderedList)!=null?Ae:!0,staticOrderedList:(Ne=m.staticOrderedList)!=null?Ne:!0,align:!0,link:(ke=m.link)!=null?ke:!1,image:(ze=m.image)!=null?ze:!1,emoji:(De=m.emoji)!=null?De:!1,table:(Oe=m.table)!=null?Oe:!1,color:(He=m.color)!=null?He:!1,fontFamily:(je=m.fontFamily)!=null?je:!1,fontSize:(_e=m.fontSize)!=null?_e:!1,highlight:(Fe=m.fontSize)!=null?Fe:!1},[wt,te]=n.useState(""),[ye,ne]=n.useState([]),B=()=>x.current,N=()=>{const e=Ct(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(a,h,y)=>{if(/list-type=["']static["']/.test(y)||a.includes("data-hidden-array-start")||a.includes("data-hidden-array-end"))return a;const f=`<${h}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',v='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',C=`</${h}>`,I=a.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${C}$`),"");return`${f}${s}${I}${v}${C}`}),F(r),M==null||M(r);const l=Bt(e);A(l);const c=Nt(),i=pe(c);JSON.stringify(i)!==JSON.stringify(ye)&&(ne(i),w(i))},Ct=()=>{const e=B();if(!e)return H;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(l=>l.remove()),t.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=bt(r),r},bt=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),t.innerHTML},X=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(P.current=r.cloneRange())},K=()=>{const e=window.getSelection();!e||!P.current||(e.removeAllRanges(),e.addRange(P.current))},Ee=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(P.current=r.getRangeAt(0)),K(),document.execCommand(e,!1,t),N()};n.useEffect(()=>{const e=B();if(!e||!E)return;const t=Lt(E);e.innerHTML=t,N()},[]);const Lt=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{S&&S(e=>{At(e)})},[]),n.useEffect(()=>{const e=B();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(le(r),r.querySelectorAll("th, td").forEach(c=>Y(c)))})},[]);const we=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Ce=(e,t)=>{var f;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),c=we(l.startContainer);let i,a;const h=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(c){let s=c.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",c.appendChild(s)),a=s,i=document.createElement("li"),i.textContent="â",a.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=B();if(a=s==null?void 0:s.querySelector(`${e}:last-child`),!a)return;h&&a.setAttribute("list-type","static"),i=a.querySelector("li:last-child")}const y=document.createRange();y.setStart(i,0),y.collapse(!0),r.removeAllRanges(),r.addRange(y),(f=B())==null||f.focus(),N()},re=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?Ce("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?Ce("ul",e):e.startsWith("justify")?Vt(e):Ee(e,t),e==="insertTable"&&Le(),e==="insertStaticTable"&&Le("insertStaticTable")},St=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),$({x:r.left,y:r.bottom+window.scrollY}),T(o||[]),O(!0),Z.current=e.cloneRange()},xt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let l=t;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=t.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",i=l===t?r:c.length,a=c.lastIndexOf("@",i-1);if(a!==-1){const h=document.createRange();return h.setStart(l,a),h.setEnd(l,i),h}}l=l.previousSibling}return null},Mt=e=>{var i;const t=window.getSelection();if(!t)return;const r=xt();r?(t.removeAllRanges(),t.addRange(r)):Z.current&&(t.removeAllRanges(),t.addRange(Z.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||"");try{const a=t.rangeCount?t.getRangeAt(0):null;if(a)a.deleteContents(),a.insertNode(l);else{const f=document.createRange(),s=B();f.selectNodeContents(s),f.collapse(!1),f.insertNode(l)}const h=document.createTextNode("â");l.after(h);const y=document.createRange();y.setStartAfter(h),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(a){console.error("insertMention error:",a)}let c=pe([...ye,e]);ne(c),w(c),O(!1),(i=B())==null||i.focus(),N()},Tt=e=>{const t=B();if(!t)return;let r=null;P.current&&t.contains(P.current.startContainer)?r=P.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const c=document.createElement("span");c.textContent=`{{${e.name}}}`,c.style.display="inline",c.setAttribute("data-mention",e.value||e.name),r.insertNode(c);const i=document.createTextNode(" ");c.after(i);const a=document.createRange();a.setStartAfter(i),a.collapse(!0),l.removeAllRanges(),l.addRange(a),P.current=a.cloneRange(),t.focus()},At=e=>{e.forEach(t=>Tt(t)),ne(t=>{const r=[...t,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return w(l),l}),N()},Nt=()=>{const e=B();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(l=>{const c=l.getAttribute("data-mention")||"",a=(l.textContent||"").match(/{{(.+?)}}/);a&&r.push({name:a[1],value:c})}),r},kt=e=>{var r,l,c;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),re(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),a=i!=null&&i.anchorNode?we(i.anchorNode):null;if(!a)return;if(((r=a.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=a.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(a);const s=document.createElement("p");s.innerHTML="<br />",(l=f.parentElement)==null||l.insertBefore(s,f.nextSibling);const v=document.createRange();v.setStart(s,0),v.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(v)}else{const s=a.closest("ul, ol");if(s){const v=document.createElement("p");v.innerHTML="<br />",(c=s.parentElement)==null||c.insertBefore(v,s.nextSibling),s.removeChild(a);const C=document.createRange();C.setStart(v,0),C.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(C)}}N()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const a=i.getRangeAt(0);if(a.cloneContents().querySelector("table"))return;if(a.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},zt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(oe(l))return;setTimeout(()=>{St(r.getRangeAt(0)),te(""),T(o),O(!0)},0);return}if(q){setTimeout(()=>be(),0);return}},oe=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},be=()=>{N();const e=window.getSelection();if(!e||!e.anchorNode)return;if(oe(e.anchorNode)){O(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){O(!1);return}const l=r[1].trim().toLowerCase();te(l);const c=o.filter(i=>i.name.toLowerCase().includes(l));c.length>0?(T(c),O(!0)):O(!1)},Dt=e=>{var l;const t=(l=e.target.files)==null?void 0:l[0];if(!t)return;const r=new FileReader;r.onload=c=>{var C;const i=(C=c.target)==null?void 0:C.result;K();const a=window.getSelection();let h=a&&a.rangeCount?a.getRangeAt(0):null;const y=document.createElement("img");y.src=i,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=B();if(!h||!f){f==null||f.appendChild(y);const I=document.createTextNode(" ");f==null||f.appendChild(I);const ae=document.createRange();ae.setStartAfter(I),ae.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(ae),f==null||f.focus(),N(),e.target.value="";return}h.deleteContents(),h.insertNode(y);const s=document.createTextNode(" ");y.after(s);const v=document.createRange();v.setStartAfter(s),v.collapse(!0),a.removeAllRanges(),a.addRange(v),f.focus(),N(),e.target.value=""},r.readAsDataURL(t)},Ot=e=>{var c;K();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(c=B())==null||c.focus(),N()},Le=e=>{var s;Zt(),K();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const r=document.createElement("thead");p.thead&&r.classList.add(p.thead);const l=document.createElement("tbody");p.tbody&&l.classList.add(p.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const c=document.createElement("tr");p.tr&&c.classList.add(p.tr);const i=document.createElement("tr");p.tr&&i.classList.add(p.tr);for(let v=0;v<2;v++){const C=document.createElement("th");C.textContent="",C.style.border="1px solid #999",C.style.padding="4px",C.style.position="relative",C.style.backgroundColor="lightgray",C.style.height="20px",p.th&&C.classList.add(p.th);const I=document.createElement("td");I.textContent="",I.style.border="1px solid #999",I.style.padding="4px",I.style.position="relative",I.style.backgroundColor="#fff",I.style.height="20px",p.td&&I.classList.add(p.td),Y(C),Y(I),c.appendChild(C),i.appendChild(I)}r.appendChild(c),l.appendChild(i),t.appendChild(r),t.appendChild(l),le(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const h=a.getRangeAt(0);h.collapse(!1),h.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),a.removeAllRanges(),a.addRange(f),(s=B())==null||s.focus(),N()},le=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let r=0,l=0,c=0,i=0;t.addEventListener("mousedown",a=>{a.preventDefault(),r=a.clientX,l=a.clientY;const h=e.getBoundingClientRect();c=h.width,i=h.height;const y=s=>{const v=Math.max(100,c+(s.clientX-r)),C=Math.max(20,i+(s.clientY-l));e.style.width=`${v}px`,e.style.height=`${C}px`,N()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),N()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},Y=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),Ht(e,t,r),e.appendChild(t),e.appendChild(r)},Ht=(e,t,r)=>{let l=0,c=0,i=0,a=0;t.addEventListener("mousedown",s=>{s.preventDefault(),l=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)}),r.addEventListener("mousedown",s=>{s.preventDefault(),c=s.clientY,a=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const h=s=>{const v=i+(s.clientX-l);e.style.width=`${Math.max(30,v)}px`,N()},y=s=>{const v=a+(s.clientY-c);e.style.height=`${Math.max(20,v)}px`,N()},f=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),N()}},jt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},Se=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},_t=e=>{if(!V.cell)return;const t=V.cell.closest("table"),r=V.cell.cellIndex,l=V.cell.parentElement.rowIndex,c=i=>{const a=i.tagName.toLowerCase(),h=document.createElement(a);return h.textContent="",h.style.cssText=i.style.cssText,Y(h),h};switch(e){case"insertRowAbove":{const i=t.rows[l],a=t.insertRow(l);Array.from(i.cells).forEach(h=>{a.appendChild(c(h))});break}case"insertRowBelow":{const i=t.rows[l],a=t.insertRow(l+1);Array.from(i.cells).forEach(h=>{a.appendChild(c(h))});break}case"insertColLeft":{Array.from(t.rows).forEach(i=>{const a=i.cells[r];i.insertBefore(c(a),a)});break}case"insertColRight":{Array.from(t.rows).forEach(i=>{const a=i.cells[r];i.insertBefore(c(a),a.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(l);break;case"deleteCol":Array.from(t.rows).forEach(i=>{i.cells[r]&&i.deleteCell(r)});break}N(),g(se(ie({},V),{visible:!1})),Se()},Ft=()=>{X(),ee.current=P.current,ve({url:"",text:"",title:"",target:"_self"}),U(!0)},Pt=e=>{const t=window.getSelection();if(!t||!ee.current)return;t.removeAllRanges(),t.addRange(ee.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const c=t.getRangeAt(0);c.deleteContents(),c.insertNode(l);const i=document.createTextNode(" ");l.after(i);const a=document.createRange();a.setStartAfter(i),a.collapse(!0),t.removeAllRanges(),t.addRange(a),U(!1),N()},It=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),ee.current=l,ve({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),U(!0)}},qt=()=>{const e=B();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&P.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(P.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);K(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),i=document.createElement("div");i.appendChild(c);const a=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),h=[];for(;a.nextNode();){const s=a.currentNode,v=s.tagName.toUpperCase(),C=s.getAttribute&&s.getAttribute("data-mention")!==null;v!=="A"&&!C&&h.push(s)}for(let s=h.length-1;s>=0;s--){const v=h[s],C=v.parentNode;if(C){for(;v.firstChild;)C.insertBefore(v.firstChild,v);C.removeChild(v)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),l.deleteContents();const y=document.createDocumentFragment();for(;i.firstChild;)y.appendChild(i.firstChild);l.insertNode(y);const f=document.createRange();f.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),f.collapse(!0),r.removeAllRanges(),r.addRange(f),e.normalize(),N()},Bt=e=>{var l;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(c=>{c.replaceWith(`
|
|
1
|
+
(function(z,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(z=typeof globalThis!="undefined"?globalThis:z||self,n(z.RichTextEditor={},z.React,z.ReactDOM))})(this,(function(z,n,R){"use strict";var Yt=Object.defineProperty,Qt=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var Ie=(z,n,R)=>n in z?Yt(z,n,{enumerable:!0,configurable:!0,writable:!0,value:R}):z[n]=R,ie=(z,n)=>{for(var R in n||(n={}))Gt.call(n,R)&&Ie(z,R,n[R]);if(Pe)for(var R of Pe(n))en.call(n,R)&&Ie(z,R,n[R]);return z},se=(z,n)=>Qt(z,Jt(n));function qe(o){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const u in o)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(o,u);Object.defineProperty(d,u,m.get?m:{enumerable:!0,get:()=>o[u]})}}return d.default=o,Object.freeze(d)}const Be=qe(n);window.React=Be;var ce={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},de=n.createContext&&n.createContext(ce),Re=["attr","size","title"];function Ve(o,d){if(o==null)return{};var u=Ue(o,d),m,p;if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(o);for(p=0;p<T.length;p++)m=T[p],!(d.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(o,m)&&(u[m]=o[m])}return u}function Ue(o,d){if(o==null)return{};var u={};for(var m in o)if(Object.prototype.hasOwnProperty.call(o,m)){if(d.indexOf(m)>=0)continue;u[m]=o[m]}return u}function J(){return J=Object.assign?Object.assign.bind():function(o){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(o[m]=u[m])}return o},J.apply(this,arguments)}function ue(o,d){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(o);d&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(o,p).enumerable})),u.push.apply(u,m)}return u}function G(o){for(var d=1;d<arguments.length;d++){var u=arguments[d]!=null?arguments[d]:{};d%2?ue(Object(u),!0).forEach(function(m){$e(o,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):ue(Object(u)).forEach(function(m){Object.defineProperty(o,m,Object.getOwnPropertyDescriptor(u,m))})}return o}function $e(o,d,u){return d=We(d),d in o?Object.defineProperty(o,d,{value:u,enumerable:!0,configurable:!0,writable:!0}):o[d]=u,o}function We(o){var d=Ze(o,"string");return typeof d=="symbol"?d:d+""}function Ze(o,d){if(typeof o!="object"||!o)return o;var u=o[Symbol.toPrimitive];if(u!==void 0){var m=u.call(o,d);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(o)}function me(o){return o&&o.map((d,u)=>n.createElement(d.tag,G({key:u},d.attr),me(d.child)))}function D(o){return d=>n.createElement(Xe,J({attr:G({},o.attr)},d),me(o.child))}function Xe(o){var d=u=>{var{attr:m,size:p,title:T}=o,L=Ve(o,Re),A=p||u.size||"1em",E;return u.className&&(E=u.className),o.className&&(E=(E?E+" ":"")+o.className),n.createElement("svg",J({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,L,{className:E,style:G(G({color:o.color||u.color},u.style),o.style),height:A,width:A,xmlns:"http://www.w3.org/2000/svg"}),T&&n.createElement("title",null,T),o.children)};return de!==void 0?n.createElement(de.Consumer,null,u=>d(u)):d(ce)}function Ke(o){return D({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function Ye(o){return D({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function Qe(o){return D({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function Je(o){return D({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(o)}function Ge(o){return D({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function et(o){return D({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function tt(o){return D({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function nt(o){return D({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function rt(o){return D({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function ot(o){return D({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function lt(o){return D({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function at(o){return D({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function it(o){return D({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(o)}function st(o){return D({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(o)}function ct(o){return D({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(o)}function dt(o){return D({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(o)}function ut(o){return D({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function mt(o){return D({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const ft=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],fe=({exec:o,saveSelection:d,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:T,handleLink:L,removeFormatting:A,visibleActions:E,className:M,style:C})=>{var Z,V;const S=n.useRef(null),q=n.useRef(null),k=n.useRef(null),[_,F]=n.useState(!1),[H,P]=n.useState({x:0,y:0});n.useEffect(()=>{const g=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const O=g=>{var U;g.preventDefault();const b=g.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":o(b);break;case"insertImage":{(U=S.current)==null||U.click();break}default:console.warn("Unknown command:",b)}},$=g=>{o("foreColor",g.target.value)},W=g=>{o("backColor",g.target.value)},[x,I]=n.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return n.useEffect(()=>{const g=()=>{I({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),n.createElement("div",{className:`rte-toolbar ${M||""}`,style:C},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:O,className:x.bold?"rte-active":""},n.createElement(et,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:O,className:x.italic?"rte-active":""},n.createElement(nt,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:O,className:x.underline?"rte-active":""},n.createElement(at,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:O,title:"UnorderedList",className:x.unorderedList?"rte-active":""},n.createElement(st,null)),E.staticUnorderedList&&n.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:O,title:"StaticUnorderedList",className:x.unorderedList?"rte-active":""},n.createElement(ot,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:O,className:x.orderedList?"rte-active":"",style:{fontSize:"medium"}},n.createElement(it,null)),E.staticOrderedList&&n.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:O,className:x.orderedList?"rte-active":""},n.createElement(Je,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:x.link?"rte-active":""},n.createElement(rt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),d(),A()},className:x.removeFormat?"rte-active":""},n.createElement(mt,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:O,className:x.image?"rte-active":""},n.createElement(Qe,null)),n.createElement("input",{type:"file",accept:"image/*",ref:S,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),d();const b=g.currentTarget.getBoundingClientRect();P({x:b.left,y:b.bottom+8}),F(U=>!U)},className:x.emoji?"rte-active":""},n.createElement(lt,null)),_&&R.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:H.y,left:H.x}},ft.map((g,b)=>n.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:U=>{U.preventDefault(),T(g),F(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var b;g.preventDefault(),d(),(b=q.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Z=q.current)==null?void 0:Z.value)||"#000",fontSize:"18px"},className:x.color?"rte-active":""},n.createElement(ut,null)),n.createElement("input",{ref:q,type:"color",defaultValue:"#000000",onChange:g=>{var b;$(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:g=>{var b;g.preventDefault(),d(),(b=k.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=k.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:x.highlight?"rte-active":""},n.createElement(tt,null)),n.createElement("input",{ref:k,type:"color",onChange:g=>{var b;W(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyLeft"),className:x.alignLeft?"rte-active":""},n.createElement(Ge,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyCenter"),className:x.alignCenter?"rte-active":""},n.createElement(Ke,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyRight"),className:x.alignRight?"rte-active":""},n.createElement(Ye,null))),E.table&&n.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertTable"),className:x.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(ct,null)),E.table&&n.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertStaticTable"),className:x.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(dt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:p},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,b)=>10+b).map(g=>n.createElement("option",{key:g,value:g},g,"px"))))},gt=({show:o,position:d,filtered:u,insertMention:m,onClose:p,query:T})=>{const L=n.useRef(null),[A,E]=n.useState(0);return n.useEffect(()=>{o&&E(0)},[o]),n.useEffect(()=>{const M=C=>{L.current&&!L.current.contains(C.target)&&p()};return o&&document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},[o,p]),n.useEffect(()=>{if(!o)return;const M=C=>{if(!(!o||u.length===0)&&(C.key==="ArrowDown"&&(C.preventDefault(),E(S=>Math.min(S+1,u.length-1))),C.key==="ArrowUp"&&(C.preventDefault(),E(S=>Math.max(S-1,0))),C.key==="Enter")){C.preventDefault();const S=u[A];S&&m(S)}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[o,u,A]),n.useEffect(()=>{if(!L.current)return;const C=L.current.querySelectorAll("li")[A];C&&C.scrollIntoView({block:"nearest",behavior:"smooth"})},[A]),o?n.createElement("ul",{ref:L,className:"rte-popup",style:{top:d.y,left:d.x}},u.length>0?u.map(({name:M,value:C},S)=>{const q=M.toLowerCase(),k=T.toLowerCase(),_=q.indexOf(k);let F=M;if(_!==-1&&T.length>0){const H=_+T.length;F=M.substring(0,_)+`<span class="rte-highlight">${M.substring(_,H)}</span>`+M.substring(H)}return n.createElement("li",{key:C,onMouseDown:H=>{H.preventDefault(),m({name:M,value:C})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:S===A?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(S)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ge(o){return D({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function ee(o){return D({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const ht=({visible:o,x:d,y:u,onAction:m,onClose:p})=>{if(!o)return null;const T={top:u,left:d};return n.createElement("div",{style:T,className:"rte-table-menu",onMouseLeave:p},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(ee,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(ee,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(ee,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(ee,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(ge,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(ge,null)," Delete column"))},he=({html:o,className:d,style:u})=>{const m=L=>{const A=L.target;if(A.tagName==="A"){L.preventDefault();const E=A.href;E&&window.open(E,"_blank","noopener,noreferrer")}},p=L=>L==="rgb(0, 0, 0)"||L==="rgba(0, 0, 0, 1)"||L==="#000"||L==="#000000"||L==="black",T=L=>{const A=document.createElement("div");A.innerHTML=L;const E=document.createTreeWalker(A,NodeFilter.SHOW_TEXT,null),M=[];for(;E.nextNode();){const C=E.currentNode;C.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(C.nodeValue)&&M.push(C)}return M.forEach(C=>{var P;const S=C.nodeValue||"",q=C.parentElement;if(!q)return;let k=q,_=!1;for(;k;){if(k.tagName==="FONT"&&k.getAttribute("color")){_=!0;break}const O=(P=k.style)==null?void 0:P.color;if(O&&!p(O)){_=!0;break}const $=window.getComputedStyle(k);if($.color&&!p($.color)){_=!0;break}k=k.parentElement}const F=document.createDocumentFragment();let H=0;S.replace(/{{\s*([\s\S]*?)\s*}}/g,(O,$,W)=>{if(W>H&&F.appendChild(document.createTextNode(S.slice(H,W))),_)F.appendChild(document.createTextNode(O));else{const x=document.createElement("span");x.style.color="blue",x.textContent=O,F.appendChild(x)}return H=W+O.length,O}),H<S.length&&F.appendChild(document.createTextNode(S.slice(H))),q.replaceChild(F,C)}),A.innerHTML=A.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),A.innerHTML};return n.createElement("div",{className:`rte-preview ${d||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:T(o)}})},pt=({visible:o,linkData:d,onClose:u,onInsert:m})=>{const[p,T]=n.useState(""),[L,A]=n.useState(""),[E,M]=n.useState(""),[C,S]=n.useState("_self");if(n.useEffect(()=>{o?(T(d.url||""),A(d.text||""),M(d.title||""),S(d.target||"_self")):(T(""),A(""),M(""),S("_self"))},[o,d]),!o)return null;const q=()=>{m({url:p,text:L,title:E,target:C})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:k=>T(k.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:k=>A(k.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:k=>M(k.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:C,onChange:k=>S(k.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:q},"OK"))))};function pe(o){const d=new Map;return o.forEach(u=>{d.set(u.name,u.value)}),Array.from(d.entries()).map(([u,m])=>({name:u,value:m}))}const vt=({atSuggestions:o=[],showOutput:d=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:T={},handleGetHtml:L=()=>{},onChange:A=()=>{},value:E,onMentionSelect:M=()=>{},handleAddAttributes:C=()=>{}})=>{var Me,Te,Ae,Ne,ke,ze,De,Oe,He,je,_e,Fe;const S=n.useRef(null),[q,k]=n.useState(E!=null&&E.length?E:" "),[_,F]=n.useState(""),[H,P]=n.useState(!1),[O,$]=n.useState({x:0,y:0}),[W,x]=n.useState([]),I=n.useRef(null),Z=n.useRef(null),[V,g]=n.useState({visible:!1,x:0,y:0}),[b,U]=n.useState(!1),te=n.useRef(null),[Et,ve]=n.useState({url:"",text:"",title:"",target:"_self"}),yt={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Me=m.unorderedList)!=null?Me:!0,orderedList:(Te=m.orderedList)!=null?Te:!0,staticUnorderedList:(Ae=m.staticUnorderedList)!=null?Ae:!0,staticOrderedList:(Ne=m.staticOrderedList)!=null?Ne:!0,align:!0,link:(ke=m.link)!=null?ke:!1,image:(ze=m.image)!=null?ze:!1,emoji:(De=m.emoji)!=null?De:!1,table:(Oe=m.table)!=null?Oe:!1,color:(He=m.color)!=null?He:!1,fontFamily:(je=m.fontFamily)!=null?je:!1,fontSize:(_e=m.fontSize)!=null?_e:!1,highlight:(Fe=m.fontSize)!=null?Fe:!1},[wt,ne]=n.useState(""),[Ee,re]=n.useState([]),B=()=>S.current,N=()=>{const e=Ct(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(a,v,y)=>{if(/list-type=["']static["']/.test(y)||a.includes("data-hidden-array-start")||a.includes("data-hidden-array-end"))return a;const f=`<${v}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',h='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',w=`</${v}>`,j=a.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${w}$`),"");return`${f}${s}${j}${h}${w}`}),F(r),L==null||L(r);const l=Bt(e);A(l);const c=Nt(),i=pe(c);JSON.stringify(i)!==JSON.stringify(Ee)&&(re(i),M(i))},Ct=()=>{const e=B();if(!e)return q;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(l=>l.remove()),t.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=bt(r),r},bt=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),t.innerHTML},X=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(I.current=r.cloneRange())},K=()=>{const e=window.getSelection();!e||!I.current||(e.removeAllRanges(),e.addRange(I.current))},ye=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(I.current=r.getRangeAt(0)),K(),document.execCommand(e,!1,t),N()};n.useEffect(()=>{const e=B();if(!e||!E)return;const t=Lt(E);e.innerHTML=t,N()},[]);const Lt=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,t=>t.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{C&&C(e=>{At(e)})},[]),n.useEffect(()=>{const e=B();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(ae(r),r.querySelectorAll("th, td").forEach(c=>Y(c)))})},[]);const we=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Ce=(e,t)=>{var f;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),c=we(l.startContainer);let i,a;const v=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(c){let s=c.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",c.appendChild(s)),a=s,i=document.createElement("li"),i.textContent="â",a.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=B();if(a=s==null?void 0:s.querySelector(`${e}:last-child`),!a)return;v&&a.setAttribute("list-type","static"),i=a.querySelector("li:last-child")}const y=document.createRange();y.setStart(i,0),y.collapse(!0),r.removeAllRanges(),r.addRange(y),(f=B())==null||f.focus(),N()},oe=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?Ce("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?Ce("ul",e):e.startsWith("justify")?Vt(e):ye(e,t),e==="insertTable"&&Le(),e==="insertStaticTable"&&Le("insertStaticTable")},St=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),$({x:r.left,y:r.bottom+window.scrollY}),x(o||[]),P(!0),Z.current=e.cloneRange()},xt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let l=t;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=t.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",i=l===t?r:c.length,a=c.lastIndexOf("@",i-1);if(a!==-1){const v=document.createRange();return v.setStart(l,a),v.setEnd(l,i),v}}l=l.previousSibling}return null},Mt=e=>{var i;const t=window.getSelection();if(!t)return;const r=xt();r?(t.removeAllRanges(),t.addRange(r)):Z.current&&(t.removeAllRanges(),t.addRange(Z.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||"");try{const a=t.rangeCount?t.getRangeAt(0):null;if(a)a.deleteContents(),a.insertNode(l);else{const f=document.createRange(),s=B();f.selectNodeContents(s),f.collapse(!1),f.insertNode(l)}const v=document.createTextNode("â");l.after(v);const y=document.createRange();y.setStartAfter(v),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(a){console.error("insertMention error:",a)}let c=pe([...Ee,e]);re(c),M(c),P(!1),(i=B())==null||i.focus(),N()},Tt=e=>{const t=B();if(!t)return;let r=null;I.current&&t.contains(I.current.startContainer)?r=I.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const c=document.createElement("span");c.textContent=`{{${e.name}}}`,c.style.display="inline",c.setAttribute("data-mention",e.value||e.name),r.insertNode(c);const i=document.createTextNode(" ");c.after(i);const a=document.createRange();a.setStartAfter(i),a.collapse(!0),l.removeAllRanges(),l.addRange(a),I.current=a.cloneRange(),t.focus()},At=e=>{e.forEach(t=>Tt(t)),re(t=>{const r=[...t,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return M(l),l}),N()},Nt=()=>{const e=B();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(l=>{const c=l.getAttribute("data-mention")||"",a=(l.textContent||"").match(/{{(.+?)}}/);a&&r.push({name:a[1],value:c})}),r},kt=e=>{var r,l,c;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),oe(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),a=i!=null&&i.anchorNode?we(i.anchorNode):null;if(!a)return;if(((r=a.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=a.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(a);const s=document.createElement("p");s.innerHTML="<br />",(l=f.parentElement)==null||l.insertBefore(s,f.nextSibling);const h=document.createRange();h.setStart(s,0),h.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(h)}else{const s=a.closest("ul, ol");if(s){const h=document.createElement("p");h.innerHTML="<br />",(c=s.parentElement)==null||c.insertBefore(h,s.nextSibling),s.removeChild(a);const w=document.createRange();w.setStart(h,0),w.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(w)}}N()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const a=i.getRangeAt(0);if(a.cloneContents().querySelector("table"))return;if(a.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},zt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(le(l))return;setTimeout(()=>{St(r.getRangeAt(0)),ne(""),x(o),P(!0)},0);return}if(H){setTimeout(()=>be(),0);return}},le=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},be=()=>{N();const e=window.getSelection();if(!e||!e.anchorNode)return;if(le(e.anchorNode)){P(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){P(!1);return}const l=r[1].trim().toLowerCase();ne(l);const c=o.filter(i=>i.name.toLowerCase().includes(l));c.length>0?(x(c),P(!0)):P(!1)},Dt=e=>{var l;const t=(l=e.target.files)==null?void 0:l[0];if(!t)return;const r=new FileReader;r.onload=c=>{var w;const i=(w=c.target)==null?void 0:w.result;K();const a=window.getSelection();let v=a&&a.rangeCount?a.getRangeAt(0):null;const y=document.createElement("img");y.src=i,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=B();if(!v||!f){f==null||f.appendChild(y);const j=document.createTextNode(" ");f==null||f.appendChild(j);const Q=document.createRange();Q.setStartAfter(j),Q.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(Q),f==null||f.focus(),N(),e.target.value="";return}v.deleteContents(),v.insertNode(y);const s=document.createTextNode(" ");y.after(s);const h=document.createRange();h.setStartAfter(s),h.collapse(!0),a.removeAllRanges(),a.addRange(h),f.focus(),N(),e.target.value=""},r.readAsDataURL(t)},Ot=e=>{var c;K();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(c=B())==null||c.focus(),N()},Le=e=>{var s;Xt(),K();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const r=document.createElement("thead");p.thead&&r.classList.add(p.thead);const l=document.createElement("tbody");p.tbody&&l.classList.add(p.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const c=document.createElement("tr");p.tr&&c.classList.add(p.tr);const i=document.createElement("tr");p.tr&&i.classList.add(p.tr);for(let h=0;h<2;h++){const w=document.createElement("th");w.textContent="",w.style.border="1px solid #999",w.style.padding="4px",w.style.position="relative",w.style.backgroundColor="lightgray",w.style.height="20px",p.th&&w.classList.add(p.th);const j=document.createElement("td");j.textContent="",j.style.border="1px solid #999",j.style.padding="4px",j.style.position="relative",j.style.backgroundColor="#fff",j.style.height="20px",p.td&&j.classList.add(p.td),Y(w),Y(j),c.appendChild(w),i.appendChild(j)}r.appendChild(c),l.appendChild(i),t.appendChild(r),t.appendChild(l),ae(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const v=a.getRangeAt(0);v.collapse(!1),v.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),a.removeAllRanges(),a.addRange(f),(s=B())==null||s.focus(),N()},ae=e=>{if(e.dataset.hasResizeHandle==="true")return;const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let r=0,l=0,c=0,i=0;t.addEventListener("mousedown",a=>{a.preventDefault(),r=a.clientX,l=a.clientY;const v=e.getBoundingClientRect();c=v.width,i=v.height;const y=s=>{const h=Math.max(100,c+(s.clientX-r)),w=Math.max(20,i+(s.clientY-l));e.style.width=`${h}px`,e.style.height=`${w}px`,N()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),N()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},Y=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),Ht(e,t,r),e.appendChild(t),e.appendChild(r)},Ht=(e,t,r)=>{let l=0,c=0,i=0,a=0;t.addEventListener("mousedown",s=>{s.preventDefault(),l=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)}),r.addEventListener("mousedown",s=>{s.preventDefault(),c=s.clientY,a=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const v=s=>{const h=i+(s.clientX-l);e.style.width=`${Math.max(30,h)}px`,N()},y=s=>{const h=a+(s.clientY-c);e.style.height=`${Math.max(20,h)}px`,N()},f=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),N()}},jt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},Se=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},_t=e=>{if(!V.cell)return;const t=V.cell.closest("table"),r=V.cell.cellIndex,l=V.cell.parentElement.rowIndex,c=i=>{const a=i.tagName.toLowerCase(),v=document.createElement(a);return v.textContent="",v.style.cssText=i.style.cssText,Y(v),v};switch(e){case"insertRowAbove":{const i=t.rows[l],a=t.insertRow(l);Array.from(i.cells).forEach(v=>{a.appendChild(c(v))});break}case"insertRowBelow":{const i=t.rows[l],a=t.insertRow(l+1);Array.from(i.cells).forEach(v=>{a.appendChild(c(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(i=>{const a=i.cells[r];i.insertBefore(c(a),a)});break}case"insertColRight":{Array.from(t.rows).forEach(i=>{const a=i.cells[r];i.insertBefore(c(a),a.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(l);break;case"deleteCol":Array.from(t.rows).forEach(i=>{i.cells[r]&&i.deleteCell(r)});break}N(),g(se(ie({},V),{visible:!1})),Se()},Ft=()=>{X(),te.current=I.current,ve({url:"",text:"",title:"",target:"_self"}),U(!0)},Pt=e=>{const t=window.getSelection();if(!t||!te.current)return;t.removeAllRanges(),t.addRange(te.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const c=t.getRangeAt(0);c.deleteContents(),c.insertNode(l);const i=document.createTextNode(" ");l.after(i);const a=document.createRange();a.setStartAfter(i),a.collapse(!0),t.removeAllRanges(),t.addRange(a),U(!1),N()},It=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),te.current=l,ve({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),U(!0)}},qt=()=>{const e=B();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&I.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(I.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);K(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),i=document.createElement("div");i.appendChild(c);const a=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),v=[];for(;a.nextNode();){const s=a.currentNode,h=s.tagName.toUpperCase(),w=s.getAttribute&&s.getAttribute("data-mention")!==null;h!=="A"&&!w&&v.push(s)}for(let s=v.length-1;s>=0;s--){const h=v[s],w=h.parentNode;if(w){for(;h.firstChild;)w.insertBefore(h.firstChild,h);w.removeChild(h)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),l.deleteContents();const y=document.createDocumentFragment();for(;i.firstChild;)y.appendChild(i.firstChild);l.insertNode(y);const f=document.createRange();f.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),f.collapse(!0),r.removeAllRanges(),r.addRange(f),e.normalize(),N()},Bt=e=>{var l;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(c=>{c.replaceWith(`
|
|
2
2
|
`)}),r.querySelectorAll("p, div, tr").forEach(c=>{c.insertAdjacentText("afterend",`
|
|
3
3
|
`)}),r.querySelectorAll("table").forEach(c=>{c.insertAdjacentText("afterend",`
|
|
4
4
|
`)}),((l=r.textContent)==null?void 0:l.replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim())||""};function Rt(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let i=t.startContainer,a=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const
|
|
6
|
+
`).trim())||""};function Rt(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let i=t.startContainer,a=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const v=a==null?void 0:a.closest("td, th");return v?[v]:[]}const r=t.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(i=>{const a=document.createRange();return a.selectNodeContents(i),t.compareBoundaryPoints(Range.END_TO_START,a)<0&&t.compareBoundaryPoints(Range.START_TO_END,a)>0})}function Vt(e){const t=Rt();if(t.length===0){ye(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(l=>{l.style.textAlign=r}),N()}const Ut=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return!1;let t=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;for(;t;){if(t.tagName==="TABLE")return!0;t=t.parentElement}return!1},$t=e=>{if(Ut()){e.preventDefault();const f=e.clipboardData.getData("text/plain");if(!f)return;const s=window.getSelection();if(!s||!s.rangeCount)return;const h=s.getRangeAt(0);h.deleteContents();const w=f.split(/\r?\n/);w.forEach((j,Q)=>{h.insertNode(document.createTextNode(j)),Q<w.length-1&&h.insertNode(document.createElement("br"))}),h.collapse(!1),s.removeAllRanges(),s.addRange(h),N();return}const t=e.clipboardData.getData("text/html")||"";if(!t)return;const r=document.createElement("div");if(r.innerHTML=t,r.querySelector("img")){e.preventDefault();return}e.preventDefault();const l=document.createElement("div");l.innerHTML=t;const c=f=>{f.hasAttribute("data-has-resize-handle")||(f.style.borderCollapse="collapse",f.style.width="100%",f.style.border="1px solid #ccc",f.style.margin="8px 0",f.style.position="relative",f.style.textAlign="center",f.querySelectorAll("th").forEach(s=>{const h=s;h.style.border="1px solid #999",h.style.padding="4px",h.style.position="relative",h.style.backgroundColor="lightgray",h.style.height="20px"}),f.querySelectorAll("td").forEach(s=>{const h=s;h.style.border="1px solid #999",h.style.padding="4px",h.style.position="relative",h.style.backgroundColor="#fff",h.style.height="20px"}))};l.querySelectorAll("table").forEach(f=>c(f));const i=window.getSelection();if(!i||!i.rangeCount)return;const a=i.getRangeAt(0);a.deleteContents();const v=document.createDocumentFragment();for(;l.firstChild;)v.appendChild(l.firstChild);a.insertNode(v),a.collapse(!1),i.removeAllRanges(),i.addRange(a);const y=S.current;y&&(y.querySelectorAll("table").forEach(f=>{const s=f;s.hasAttribute("data-has-resize-handle")||(ae(s),s.querySelectorAll("th, td").forEach(h=>{const w=h;w.dataset.hasResizeHandles||Y(w)}))}),N())},Wt=e=>{K();const t=window.getSelection();if(!t||!t.rangeCount)return;const r=t.getRangeAt(0),l=document.createElement("span");l.style.fontSize=`${e}px`,l.appendChild(r.extractContents()),r.insertNode(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),t.removeAllRanges(),t.addRange(c),N()},Zt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(le(t)||t.nodeType!==Node.TEXT_NODE)return null;const r=t.textContent||"",l=e.anchorOffset,c=r.lastIndexOf("@",l-1);if(c===-1)return null;const i=r.substring(c+1,l);if(i.includes(" ")||i.includes("Â "))return null;const a=document.createRange();return a.setStart(t,c),a.setEnd(t,l),{range:a,query:i}},xe=()=>{const e=Zt();if(!e)return;const{range:t,query:r}=e,l=document.createElement("span");l.textContent="â",t.insertNode(l);const c=l.getBoundingClientRect();l.remove(),$({x:c.left,y:c.bottom+window.scrollY}),ne(r.toLowerCase());const i=o.filter(a=>a.name.toLowerCase().includes(r.toLowerCase()));x(i),P(!0),Z.current=t.cloneRange()};function Xt(){const e=S.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r),I.current=r.cloneRange()}const Kt=e=>{const t=e.target;if(!t||!(t.textContent||"").match(/{{([\s\S]+?)}}/)||!S.current)return;let i=t.firstChild;if((!i||i.nodeType!==Node.TEXT_NODE)&&(i=t.childNodes[0]),!i||i.nodeType!==Node.TEXT_NODE)return;const a=i.textContent||"",v=a.indexOf("{{"),y=a.indexOf("}}");if(v===-1||y===-1)return;const f=window.getSelection();if(!f)return;const s=document.createRange();s.setStart(i,v),s.setEnd(i,y+2),f.removeAllRanges(),f.addRange(s)};return n.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:T.wrapper},n.createElement("div",{style:{flex:1}},n.createElement(fe,{exec:oe,saveSelection:X,handleFileChange:Dt,handleFontSizeChange:e=>Wt(e.target.value),handleFontFamilyChange:e=>oe("fontName",e.target.value),insertEmoji:Ot,handleLink:Ft,removeFormatting:qt,visibleActions:yt,className:p.toolbar,style:T.toolbar}),n.createElement("div",{ref:S,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:T.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:$t,onKeyUp:()=>{X(),xe()},onMouseUp:X,onInput:()=>{be(),X()},onKeyDown:kt,onBeforeInput:zt,onContextMenu:jt,onClick:e=>{It(e),X(),xe()},onDoubleClick:Kt}),n.createElement(gt,{show:H,position:O,filtered:W,insertMention:Mt,onClose:()=>P(!1),query:wt}),d&&n.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:T.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,_)),n.createElement(ht,{visible:V.visible,x:V.x,y:V.y,onAction:_t,onClose:()=>{g(se(ie({},V),{visible:!1})),Se()}}),n.createElement(pt,{visible:b,linkData:Et,onClose:()=>U(!1),onInsert:Pt})),u?n.createElement(he,{className:p.preview,style:T.preview,html:_}):null)};z.RichTextEditor=vt,z.RtePreview=he,z.RteToolbar=fe,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})}));
|